aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.clang_complete5
-rw-r--r--.gitignore2
-rw-r--r--BUILD60
-rw-r--r--CMakeLists.txt695
-rw-r--r--CONTRIBUTING.md2
-rw-r--r--INSTALL.md43
-rw-r--r--Makefile490
-rw-r--r--README.md4
-rw-r--r--WORKSPACE71
-rw-r--r--bazel/cc_grpc_library.bzl4
-rw-r--r--bazel/grpc_build_system.bzl43
-rw-r--r--binding.gyp994
-rw-r--r--build.yaml155
-rw-r--r--config.m46
-rw-r--r--config.w326
-rw-r--r--doc/core/transport_explainer.md197
-rw-r--r--doc/g_stands_for.md1
-rw-r--r--doc/service_config.md2
-rw-r--r--examples/BUILD4
-rw-r--r--examples/cpp/helloworld/CMakeLists.txt24
-rw-r--r--examples/python/route_guide/route_guide_client.py3
-rw-r--r--gRPC-Core.podspec33
-rw-r--r--gRPC-ProtoRPC.podspec3
-rw-r--r--gRPC-RxLibrary.podspec6
-rw-r--r--gRPC.podspec3
-rw-r--r--grpc.def15
-rw-r--r--grpc.gemspec18
-rw-r--r--grpc.gyp24
-rw-r--r--include/grpc++/impl/codegen/call.h6
-rw-r--r--include/grpc++/impl/codegen/completion_queue.h32
-rw-r--r--include/grpc++/impl/codegen/core_codegen_interface.h4
-rw-r--r--include/grpc++/impl/codegen/proto_utils.h33
-rw-r--r--include/grpc++/server_builder.h151
-rw-r--r--include/grpc/fork.h24
-rw-r--r--include/grpc/grpc_security.h2
-rw-r--r--include/grpc/impl/codegen/fork.h48
-rw-r--r--include/grpc/impl/codegen/grpc_types.h7
-rw-r--r--include/grpc/impl/codegen/port_platform.h23
-rw-r--r--include/grpc/module.modulemap4
-rw-r--r--include/grpc/support/alloc.h2
-rw-r--r--include/grpc/support/histogram.h64
-rw-r--r--include/grpc/support/log.h2
-rw-r--r--include/grpc/support/thd.h5
-rw-r--r--include/grpc/support/tls_gcc.h40
-rw-r--r--package.json103
-rw-r--r--package.xml22
-rw-r--r--requirements.txt2
-rw-r--r--setup.py5
-rw-r--r--src/compiler/cpp_generator.cc2
-rw-r--r--src/compiler/csharp_generator.cc2
-rw-r--r--src/compiler/node_generator.cc2
-rw-r--r--src/compiler/objective_c_generator.cc3
-rw-r--r--src/compiler/objective_c_generator.h1
-rw-r--r--src/compiler/objective_c_plugin.cc20
-rw-r--r--src/compiler/php_generator.cc2
-rw-r--r--src/compiler/protobuf_plugin.h1
-rw-r--r--src/compiler/python_generator.cc2
-rw-r--r--src/compiler/ruby_generator.cc2
-rw-r--r--src/compiler/schema_interface.h1
-rw-r--r--src/core/ext/census/grpc_context.cc4
-rw-r--r--src/core/ext/filters/client_channel/backup_poller.cc10
-rw-r--r--src/core/ext/filters/client_channel/channel_connectivity.cc8
-rw-r--r--src/core/ext/filters/client_channel/client_channel.cc496
-rw-r--r--src/core/ext/filters/client_channel/client_channel.h10
-rw-r--r--src/core/ext/filters/client_channel/client_channel_factory.h8
-rw-r--r--src/core/ext/filters/client_channel/client_channel_plugin.cc14
-rw-r--r--src/core/ext/filters/client_channel/connector.h8
-rw-r--r--src/core/ext/filters/client_channel/http_connect_handshaker.cc20
-rw-r--r--src/core/ext/filters/client_channel/http_connect_handshaker.h8
-rw-r--r--src/core/ext/filters/client_channel/http_proxy.cc28
-rw-r--r--src/core/ext/filters/client_channel/http_proxy.h8
-rw-r--r--src/core/ext/filters/client_channel/lb_policy.cc35
-rw-r--r--src/core/ext/filters/client_channel/lb_policy.h29
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc4
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h8
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc324
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h8
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h8
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc6
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc6
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h8
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc14
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h8
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc209
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc228
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc69
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/subchannel_list.h12
-rw-r--r--src/core/ext/filters/client_channel/lb_policy_factory.cc20
-rw-r--r--src/core/ext/filters/client_channel/lb_policy_factory.h8
-rw-r--r--src/core/ext/filters/client_channel/lb_policy_registry.cc4
-rw-r--r--src/core/ext/filters/client_channel/lb_policy_registry.h8
-rw-r--r--src/core/ext/filters/client_channel/parse_address.cc6
-rw-r--r--src/core/ext/filters/client_channel/parse_address.h8
-rw-r--r--src/core/ext/filters/client_channel/proxy_mapper.h8
-rw-r--r--src/core/ext/filters/client_channel/proxy_mapper_registry.h8
-rw-r--r--src/core/ext/filters/client_channel/resolver.cc10
-rw-r--r--src/core/ext/filters/client_channel/resolver.h12
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc87
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h9
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc20
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc65
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h8
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc40
-rw-r--r--src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc28
-rw-r--r--src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h8
-rw-r--r--src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc22
-rw-r--r--src/core/ext/filters/client_channel/resolver_factory.cc4
-rw-r--r--src/core/ext/filters/client_channel/resolver_factory.h8
-rw-r--r--src/core/ext/filters/client_channel/resolver_registry.cc26
-rw-r--r--src/core/ext/filters/client_channel/resolver_registry.h8
-rw-r--r--src/core/ext/filters/client_channel/retry_throttle.cc20
-rw-r--r--src/core/ext/filters/client_channel/retry_throttle.h8
-rw-r--r--src/core/ext/filters/client_channel/subchannel.cc56
-rw-r--r--src/core/ext/filters/client_channel/subchannel.h8
-rw-r--r--src/core/ext/filters/client_channel/subchannel_index.cc12
-rw-r--r--src/core/ext/filters/client_channel/subchannel_index.h8
-rw-r--r--src/core/ext/filters/client_channel/uri_parser.cc16
-rw-r--r--src/core/ext/filters/client_channel/uri_parser.h8
-rw-r--r--src/core/ext/filters/deadline/deadline_filter.cc10
-rw-r--r--src/core/ext/filters/deadline/deadline_filter.h8
-rw-r--r--src/core/ext/filters/http/client/http_client_filter.cc16
-rw-r--r--src/core/ext/filters/http/client/http_client_filter.h8
-rw-r--r--src/core/ext/filters/http/http_filters_plugin.cc11
-rw-r--r--src/core/ext/filters/http/message_compress/message_compress_filter.cc22
-rw-r--r--src/core/ext/filters/http/message_compress/message_compress_filter.h8
-rw-r--r--src/core/ext/filters/http/server/http_server_filter.cc24
-rw-r--r--src/core/ext/filters/http/server/http_server_filter.h8
-rw-r--r--src/core/ext/filters/load_reporting/server_load_reporting_filter.cc4
-rw-r--r--src/core/ext/filters/load_reporting/server_load_reporting_filter.h8
-rw-r--r--src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc8
-rw-r--r--src/core/ext/filters/load_reporting/server_load_reporting_plugin.h8
-rw-r--r--src/core/ext/filters/max_age/max_age_filter.cc20
-rw-r--r--src/core/ext/filters/max_age/max_age_filter.h8
-rw-r--r--src/core/ext/filters/message_size/message_size_filter.cc42
-rw-r--r--src/core/ext/filters/message_size/message_size_filter.h8
-rw-r--r--src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc22
-rw-r--r--src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h8
-rw-r--r--src/core/ext/filters/workarounds/workaround_utils.cc2
-rw-r--r--src/core/ext/filters/workarounds/workaround_utils.h8
-rw-r--r--src/core/ext/transport/chttp2/alpn/alpn.h8
-rw-r--r--src/core/ext/transport/chttp2/client/chttp2_connector.cc57
-rw-r--r--src/core/ext/transport/chttp2/client/chttp2_connector.h8
-rw-r--r--src/core/ext/transport/chttp2/client/insecure/channel_create.cc16
-rw-r--r--src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc12
-rw-r--r--src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc60
-rw-r--r--src/core/ext/transport/chttp2/server/chttp2_server.cc106
-rw-r--r--src/core/ext/transport/chttp2/server/chttp2_server.h8
-rw-r--r--src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc9
-rw-r--r--src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc8
-rw-r--r--src/core/ext/transport/chttp2/transport/bin_decoder.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/bin_encoder.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/chttp2_plugin.cc11
-rw-r--r--src/core/ext/transport/chttp2/transport/chttp2_transport.cc238
-rw-r--r--src/core/ext/transport/chttp2/transport/chttp2_transport.h28
-rw-r--r--src/core/ext/transport/chttp2/transport/flow_control.cc6
-rw-r--r--src/core/ext/transport/chttp2/transport/flow_control.h5
-rw-r--r--src/core/ext/transport/chttp2/transport/frame.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_data.cc26
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_data.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_goaway.cc4
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_goaway.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_ping.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_rst_stream.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_settings.cc12
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_settings.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_window_update.cc4
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_window_update.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_encoder.cc12
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_encoder.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_parser.cc30
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_parser.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_table.cc8
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_table.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/http2_settings.h7
-rw-r--r--src/core/ext/transport/chttp2/transport/huffsyms.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/incoming_metadata.cc2
-rw-r--r--src/core/ext/transport/chttp2/transport/incoming_metadata.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/internal.h22
-rw-r--r--src/core/ext/transport/chttp2/transport/parsing.cc46
-rw-r--r--src/core/ext/transport/chttp2/transport/stream_lists.cc21
-rw-r--r--src/core/ext/transport/chttp2/transport/stream_map.cc21
-rw-r--r--src/core/ext/transport/chttp2/transport/stream_map.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/varint.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/writing.cc78
-rw-r--r--src/core/ext/transport/cronet/transport/cronet_api_dummy.cc2
-rw-r--r--src/core/ext/transport/cronet/transport/cronet_transport.cc56
-rw-r--r--src/core/ext/transport/cronet/transport/cronet_transport.h8
-rw-r--r--src/core/ext/transport/inproc/inproc_plugin.cc11
-rw-r--r--src/core/ext/transport/inproc/inproc_transport.cc178
-rw-r--r--src/core/ext/transport/inproc/inproc_transport.h10
-rw-r--r--src/core/lib/backoff/backoff.h8
-rw-r--r--src/core/lib/channel/channel_args.cc40
-rw-r--r--src/core/lib/channel/channel_args.h8
-rw-r--r--src/core/lib/channel/channel_stack.cc4
-rw-r--r--src/core/lib/channel/channel_stack.h13
-rw-r--r--src/core/lib/channel/channel_stack_builder.cc26
-rw-r--r--src/core/lib/channel/channel_stack_builder.h10
-rw-r--r--src/core/lib/channel/connected_channel.cc10
-rw-r--r--src/core/lib/channel/connected_channel.h8
-rw-r--r--src/core/lib/channel/handshaker.cc18
-rw-r--r--src/core/lib/channel/handshaker.h20
-rw-r--r--src/core/lib/channel/handshaker_factory.cc8
-rw-r--r--src/core/lib/channel/handshaker_factory.h8
-rw-r--r--src/core/lib/channel/handshaker_registry.h8
-rw-r--r--src/core/lib/compression/algorithm_metadata.h8
-rw-r--r--src/core/lib/compression/message_compress.h8
-rw-r--r--src/core/lib/compression/stream_compression.cc4
-rw-r--r--src/core/lib/compression/stream_compression.h8
-rw-r--r--src/core/lib/compression/stream_compression_gzip.cc14
-rw-r--r--src/core/lib/compression/stream_compression_gzip.h8
-rw-r--r--src/core/lib/compression/stream_compression_identity.cc4
-rw-r--r--src/core/lib/compression/stream_compression_identity.h8
-rw-r--r--src/core/lib/debug/stats.cc4
-rw-r--r--src/core/lib/debug/stats.h8
-rw-r--r--src/core/lib/debug/stats_data.h8
-rw-r--r--src/core/lib/debug/trace.cc125
-rw-r--r--src/core/lib/debug/trace.h78
-rw-r--r--src/core/lib/http/format_request.h8
-rw-r--r--src/core/lib/http/httpcli.cc12
-rw-r--r--src/core/lib/http/httpcli.h8
-rw-r--r--src/core/lib/http/httpcli_security_connector.cc33
-rw-r--r--src/core/lib/http/parser.cc16
-rw-r--r--src/core/lib/http/parser.h10
-rw-r--r--src/core/lib/iomgr/block_annotate.h8
-rw-r--r--src/core/lib/iomgr/call_combiner.cc33
-rw-r--r--src/core/lib/iomgr/call_combiner.h10
-rw-r--r--src/core/lib/iomgr/closure.cc219
-rw-r--r--src/core/lib/iomgr/closure.h250
-rw-r--r--src/core/lib/iomgr/combiner.cc35
-rw-r--r--src/core/lib/iomgr/combiner.h10
-rw-r--r--src/core/lib/iomgr/endpoint.h8
-rw-r--r--src/core/lib/iomgr/endpoint_pair.h8
-rw-r--r--src/core/lib/iomgr/error.cc35
-rw-r--r--src/core/lib/iomgr/error.h21
-rw-r--r--src/core/lib/iomgr/error_internal.h11
-rw-r--r--src/core/lib/iomgr/ev_epoll1_linux.cc126
-rw-r--r--src/core/lib/iomgr/ev_epoll1_linux.h8
-rw-r--r--src/core/lib/iomgr/ev_epollex_linux.cc180
-rw-r--r--src/core/lib/iomgr/ev_epollex_linux.h8
-rw-r--r--src/core/lib/iomgr/ev_epollsig_linux.cc144
-rw-r--r--src/core/lib/iomgr/ev_epollsig_linux.h8
-rw-r--r--src/core/lib/iomgr/ev_poll_posix.cc126
-rw-r--r--src/core/lib/iomgr/ev_poll_posix.h8
-rw-r--r--src/core/lib/iomgr/ev_posix.cc29
-rw-r--r--src/core/lib/iomgr/ev_posix.h10
-rw-r--r--src/core/lib/iomgr/ev_windows.cc4
-rw-r--r--src/core/lib/iomgr/exec_ctx.cc35
-rw-r--r--src/core/lib/iomgr/exec_ctx.h8
-rw-r--r--src/core/lib/iomgr/executor.cc30
-rw-r--r--src/core/lib/iomgr/executor.h8
-rw-r--r--src/core/lib/iomgr/fork_posix.cc90
-rw-r--r--src/core/lib/iomgr/fork_windows.cc39
-rw-r--r--src/core/lib/iomgr/gethostname.h8
-rw-r--r--src/core/lib/iomgr/gethostname_host_name_max.cc2
-rw-r--r--src/core/lib/iomgr/iocp_windows.h10
-rw-r--r--src/core/lib/iomgr/iomgr.cc2
-rw-r--r--src/core/lib/iomgr/iomgr.h8
-rw-r--r--src/core/lib/iomgr/iomgr_internal.h8
-rw-r--r--src/core/lib/iomgr/iomgr_posix.cc1
-rw-r--r--src/core/lib/iomgr/iomgr_uv.cc2
-rw-r--r--src/core/lib/iomgr/iomgr_uv.h8
-rw-r--r--src/core/lib/iomgr/is_epollexclusive_available.cc2
-rw-r--r--src/core/lib/iomgr/load_file.cc6
-rw-r--r--src/core/lib/iomgr/load_file.h8
-rw-r--r--src/core/lib/iomgr/lockfree_event.cc14
-rw-r--r--src/core/lib/iomgr/lockfree_event.h7
-rw-r--r--src/core/lib/iomgr/polling_entity.cc12
-rw-r--r--src/core/lib/iomgr/polling_entity.h7
-rw-r--r--src/core/lib/iomgr/pollset.h12
-rw-r--r--src/core/lib/iomgr/pollset_set.h8
-rw-r--r--src/core/lib/iomgr/pollset_uv.cc5
-rw-r--r--src/core/lib/iomgr/pollset_uv.h8
-rw-r--r--src/core/lib/iomgr/pollset_windows.cc5
-rw-r--r--src/core/lib/iomgr/pollset_windows.h9
-rw-r--r--src/core/lib/iomgr/port.h4
-rw-r--r--src/core/lib/iomgr/resolve_address.h8
-rw-r--r--src/core/lib/iomgr/resolve_address_posix.cc14
-rw-r--r--src/core/lib/iomgr/resource_quota.cc82
-rw-r--r--src/core/lib/iomgr/resource_quota.h10
-rw-r--r--src/core/lib/iomgr/sockaddr_utils.cc28
-rw-r--r--src/core/lib/iomgr/sockaddr_utils.h8
-rw-r--r--src/core/lib/iomgr/sockaddr_windows.h6
-rw-r--r--src/core/lib/iomgr/socket_factory_posix.h8
-rw-r--r--src/core/lib/iomgr/socket_mutator.h8
-rw-r--r--src/core/lib/iomgr/socket_utils.h8
-rw-r--r--src/core/lib/iomgr/socket_utils_common_posix.cc8
-rw-r--r--src/core/lib/iomgr/socket_utils_posix.h8
-rw-r--r--src/core/lib/iomgr/socket_windows.h9
-rw-r--r--src/core/lib/iomgr/tcp_client.h8
-rw-r--r--src/core/lib/iomgr/tcp_client_posix.cc30
-rw-r--r--src/core/lib/iomgr/tcp_client_posix.h8
-rw-r--r--src/core/lib/iomgr/tcp_client_uv.cc8
-rw-r--r--src/core/lib/iomgr/tcp_client_windows.cc2
-rw-r--r--src/core/lib/iomgr/tcp_posix.cc132
-rw-r--r--src/core/lib/iomgr/tcp_posix.h10
-rw-r--r--src/core/lib/iomgr/tcp_server.h8
-rw-r--r--src/core/lib/iomgr/tcp_server_posix.cc36
-rw-r--r--src/core/lib/iomgr/tcp_server_utils_posix.h8
-rw-r--r--src/core/lib/iomgr/tcp_server_utils_posix_common.cc12
-rw-r--r--src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc24
-rw-r--r--src/core/lib/iomgr/tcp_server_uv.cc108
-rw-r--r--src/core/lib/iomgr/tcp_uv.cc137
-rw-r--r--src/core/lib/iomgr/tcp_uv.h14
-rw-r--r--src/core/lib/iomgr/tcp_windows.cc6
-rw-r--r--src/core/lib/iomgr/tcp_windows.h9
-rw-r--r--src/core/lib/iomgr/time_averaged_stats.h8
-rw-r--r--src/core/lib/iomgr/timer.h8
-rw-r--r--src/core/lib/iomgr/timer_generic.cc97
-rw-r--r--src/core/lib/iomgr/timer_heap.h8
-rw-r--r--src/core/lib/iomgr/timer_manager.cc38
-rw-r--r--src/core/lib/iomgr/timer_manager.h8
-rw-r--r--src/core/lib/iomgr/timer_uv.cc7
-rw-r--r--src/core/lib/iomgr/udp_server.cc131
-rw-r--r--src/core/lib/iomgr/udp_server.h19
-rw-r--r--src/core/lib/iomgr/unix_sockets_posix.cc7
-rw-r--r--src/core/lib/iomgr/unix_sockets_posix.h8
-rw-r--r--src/core/lib/iomgr/wakeup_fd_cv.cc4
-rw-r--r--src/core/lib/iomgr/wakeup_fd_cv.h8
-rw-r--r--src/core/lib/iomgr/wakeup_fd_pipe.h8
-rw-r--r--src/core/lib/iomgr/wakeup_fd_posix.cc4
-rw-r--r--src/core/lib/iomgr/wakeup_fd_posix.h8
-rw-r--r--src/core/lib/json/json.h8
-rw-r--r--src/core/lib/json/json_reader.h8
-rw-r--r--src/core/lib/json/json_string.cc14
-rw-r--r--src/core/lib/json/json_writer.h8
-rw-r--r--src/core/lib/profiling/basic_timers.cc3
-rw-r--r--src/core/lib/profiling/timers.h8
-rw-r--r--src/core/lib/security/context/security_context.cc60
-rw-r--r--src/core/lib/security/context/security_context.h12
-rw-r--r--src/core/lib/security/credentials/composite/composite_credentials.cc26
-rw-r--r--src/core/lib/security/credentials/composite/composite_credentials.h8
-rw-r--r--src/core/lib/security/credentials/credentials.cc65
-rw-r--r--src/core/lib/security/credentials/credentials.h8
-rw-r--r--src/core/lib/security/credentials/fake/fake_credentials.cc8
-rw-r--r--src/core/lib/security/credentials/fake/fake_credentials.h8
-rw-r--r--src/core/lib/security/credentials/google_default/credentials_generic.cc6
-rw-r--r--src/core/lib/security/credentials/google_default/google_default_credentials.cc58
-rw-r--r--src/core/lib/security/credentials/google_default/google_default_credentials.h8
-rw-r--r--src/core/lib/security/credentials/iam/iam_credentials.cc6
-rw-r--r--src/core/lib/security/credentials/jwt/json_token.cc88
-rw-r--r--src/core/lib/security/credentials/jwt/json_token.h8
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_credentials.cc18
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_credentials.h8
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_verifier.cc259
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_verifier.h8
-rw-r--r--src/core/lib/security/credentials/oauth2/oauth2_credentials.cc78
-rw-r--r--src/core/lib/security/credentials/oauth2/oauth2_credentials.h8
-rw-r--r--src/core/lib/security/credentials/plugin/plugin_credentials.cc35
-rw-r--r--src/core/lib/security/credentials/plugin/plugin_credentials.h2
-rw-r--r--src/core/lib/security/credentials/ssl/ssl_credentials.cc64
-rw-r--r--src/core/lib/security/credentials/ssl/ssl_credentials.h8
-rw-r--r--src/core/lib/security/transport/auth_filters.h8
-rw-r--r--src/core/lib/security/transport/client_auth_filter.cc48
-rw-r--r--src/core/lib/security/transport/lb_targets_info.cc4
-rw-r--r--src/core/lib/security/transport/lb_targets_info.h8
-rw-r--r--src/core/lib/security/transport/secure_endpoint.cc19
-rw-r--r--src/core/lib/security/transport/secure_endpoint.h10
-rw-r--r--src/core/lib/security/transport/security_connector.cc189
-rw-r--r--src/core/lib/security/transport/security_connector.h12
-rw-r--r--src/core/lib/security/transport/security_handshaker.cc85
-rw-r--r--src/core/lib/security/transport/security_handshaker.h8
-rw-r--r--src/core/lib/security/transport/server_auth_filter.cc16
-rw-r--r--src/core/lib/security/transport/tsi_error.h8
-rw-r--r--src/core/lib/security/util/json_util.cc8
-rw-r--r--src/core/lib/security/util/json_util.h8
-rw-r--r--src/core/lib/slice/b64.h8
-rw-r--r--src/core/lib/slice/percent_encoding.h8
-rw-r--r--src/core/lib/slice/slice.cc24
-rw-r--r--src/core/lib/slice/slice_buffer.cc4
-rw-r--r--src/core/lib/slice/slice_hash_table.cc14
-rw-r--r--src/core/lib/slice/slice_hash_table.h8
-rw-r--r--src/core/lib/slice/slice_intern.cc4
-rw-r--r--src/core/lib/slice/slice_internal.h11
-rw-r--r--src/core/lib/slice/slice_string_helpers.h8
-rw-r--r--src/core/lib/slice/slice_traits.h8
-rw-r--r--src/core/lib/support/abstract.h29
-rw-r--r--src/core/lib/support/alloc.cc14
-rw-r--r--src/core/lib/support/arena.cc2
-rw-r--r--src/core/lib/support/arena.h8
-rw-r--r--src/core/lib/support/avl.cc40
-rw-r--r--src/core/lib/support/cmdline.cc20
-rw-r--r--src/core/lib/support/cpu_linux.cc10
-rw-r--r--src/core/lib/support/cpu_posix.cc30
-rw-r--r--src/core/lib/support/debug_location.h52
-rw-r--r--src/core/lib/support/env.h8
-rw-r--r--src/core/lib/support/env_linux.cc10
-rw-r--r--src/core/lib/support/fork.cc62
-rw-r--r--src/core/lib/support/fork.h35
-rw-r--r--src/core/lib/support/host_port.cc18
-rw-r--r--src/core/lib/support/log.cc8
-rw-r--r--src/core/lib/support/log_android.cc6
-rw-r--r--src/core/lib/support/log_linux.cc6
-rw-r--r--src/core/lib/support/log_posix.cc2
-rw-r--r--src/core/lib/support/log_windows.cc2
-rw-r--r--src/core/lib/support/manual_constructor.h135
-rw-r--r--src/core/lib/support/memory.h2
-rw-r--r--src/core/lib/support/mpscq.cc16
-rw-r--r--src/core/lib/support/mpscq.h7
-rw-r--r--src/core/lib/support/murmur_hash.cc19
-rw-r--r--src/core/lib/support/murmur_hash.h8
-rw-r--r--src/core/lib/support/ref_counted.h122
-rw-r--r--src/core/lib/support/ref_counted_ptr.h90
-rw-r--r--src/core/lib/support/stack_lockfree.cc137
-rw-r--r--src/core/lib/support/stack_lockfree.h46
-rw-r--r--src/core/lib/support/string.cc14
-rw-r--r--src/core/lib/support/string.h7
-rw-r--r--src/core/lib/support/string_posix.cc6
-rw-r--r--src/core/lib/support/string_windows.h8
-rw-r--r--src/core/lib/support/subprocess_posix.cc6
-rw-r--r--src/core/lib/support/sync.cc6
-rw-r--r--src/core/lib/support/sync_posix.cc8
-rw-r--r--src/core/lib/support/thd_internal.h30
-rw-r--r--src/core/lib/support/thd_posix.cc80
-rw-r--r--src/core/lib/support/thd_windows.cc5
-rw-r--r--src/core/lib/support/time_posix.cc4
-rw-r--r--src/core/lib/support/time_precise.h8
-rw-r--r--src/core/lib/support/time_windows.cc2
-rw-r--r--src/core/lib/support/tmpfile.h8
-rw-r--r--src/core/lib/support/tmpfile_posix.cc10
-rw-r--r--src/core/lib/surface/alarm.cc16
-rw-r--r--src/core/lib/surface/alarm_internal.h10
-rw-r--r--src/core/lib/surface/api_trace.cc2
-rw-r--r--src/core/lib/surface/api_trace.h12
-rw-r--r--src/core/lib/surface/byte_buffer.cc2
-rw-r--r--src/core/lib/surface/call.cc183
-rw-r--r--src/core/lib/surface/call.h15
-rw-r--r--src/core/lib/surface/call_log_batch.cc6
-rw-r--r--src/core/lib/surface/call_test_only.h8
-rw-r--r--src/core/lib/surface/channel.cc32
-rw-r--r--src/core/lib/surface/channel.h8
-rw-r--r--src/core/lib/surface/channel_init.cc2
-rw-r--r--src/core/lib/surface/channel_init.h8
-rw-r--r--src/core/lib/surface/channel_ping.cc4
-rw-r--r--src/core/lib/surface/channel_stack_type.h8
-rw-r--r--src/core/lib/surface/completion_queue.cc124
-rw-r--r--src/core/lib/surface/completion_queue.h21
-rw-r--r--src/core/lib/surface/completion_queue_factory.cc2
-rw-r--r--src/core/lib/surface/completion_queue_factory.h8
-rw-r--r--src/core/lib/surface/event_string.cc4
-rw-r--r--src/core/lib/surface/event_string.h8
-rw-r--r--src/core/lib/surface/init.cc46
-rw-r--r--src/core/lib/surface/init.h8
-rw-r--r--src/core/lib/surface/init_secure.cc29
-rw-r--r--src/core/lib/surface/lame_client.cc14
-rw-r--r--src/core/lib/surface/lame_client.h8
-rw-r--r--src/core/lib/surface/server.cc87
-rw-r--r--src/core/lib/surface/server.h10
-rw-r--r--src/core/lib/surface/validate_metadata.h8
-rw-r--r--src/core/lib/surface/version.cc2
-rw-r--r--src/core/lib/transport/bdp_estimator.cc9
-rw-r--r--src/core/lib/transport/bdp_estimator.h6
-rw-r--r--src/core/lib/transport/byte_stream.h8
-rw-r--r--src/core/lib/transport/connectivity_state.cc31
-rw-r--r--src/core/lib/transport/connectivity_state.h10
-rw-r--r--src/core/lib/transport/error_utils.cc29
-rw-r--r--src/core/lib/transport/error_utils.h16
-rw-r--r--src/core/lib/transport/metadata.cc38
-rw-r--r--src/core/lib/transport/metadata.h12
-rw-r--r--src/core/lib/transport/metadata_batch.cc39
-rw-r--r--src/core/lib/transport/metadata_batch.h8
-rw-r--r--src/core/lib/transport/service_config.cc92
-rw-r--r--src/core/lib/transport/service_config.h8
-rw-r--r--src/core/lib/transport/static_metadata.h8
-rw-r--r--src/core/lib/transport/status_conversion.h8
-rw-r--r--src/core/lib/transport/timeout_encoding.h8
-rw-r--r--src/core/lib/transport/transport.cc17
-rw-r--r--src/core/lib/transport/transport.h15
-rw-r--r--src/core/lib/transport/transport_impl.h8
-rw-r--r--src/core/lib/transport/transport_op_string.cc18
-rw-r--r--src/core/plugin_registry/grpc_cronet_plugin_registry.cc24
-rw-r--r--src/core/plugin_registry/grpc_plugin_registry.cc68
-rw-r--r--src/core/plugin_registry/grpc_unsecure_plugin_registry.cc64
-rw-r--r--src/core/tsi/fake_transport_security.cc52
-rw-r--r--src/core/tsi/fake_transport_security.h8
-rw-r--r--src/core/tsi/gts_transport_security.cc6
-rw-r--r--src/core/tsi/gts_transport_security.h8
-rw-r--r--src/core/tsi/ssl_transport_security.cc252
-rw-r--r--src/core/tsi/ssl_transport_security.h8
-rw-r--r--src/core/tsi/ssl_types.h8
-rw-r--r--src/core/tsi/transport_security.cc90
-rw-r--r--src/core/tsi/transport_security.h10
-rw-r--r--src/core/tsi/transport_security_adapter.cc23
-rw-r--r--src/core/tsi/transport_security_adapter.h8
-rw-r--r--src/core/tsi/transport_security_grpc.cc20
-rw-r--r--src/core/tsi/transport_security_grpc.h8
-rw-r--r--src/core/tsi/transport_security_interface.h10
-rw-r--r--src/cpp/client/channel_cc.cc16
-rw-r--r--src/cpp/client/client_context.cc2
-rw-r--r--src/cpp/client/create_channel.cc10
-rw-r--r--src/cpp/common/channel_arguments.cc3
-rw-r--r--src/cpp/common/channel_filter.cc2
-rw-r--r--src/cpp/common/channel_filter.h2
-rw-r--r--src/cpp/common/core_codegen.cc2
-rw-r--r--src/cpp/common/version_cc.cc2
-rw-r--r--src/cpp/server/server_cc.cc2
-rw-r--r--src/cpp/server/server_context.cc8
-rw-r--r--src/cpp/server/server_posix.cc2
-rw-r--r--src/cpp/util/core_stats.h2
-rw-r--r--src/csharp/Grpc.Core.Tests/CallCancellationTest.cs182
-rw-r--r--src/csharp/Grpc.Core.Tests/ClientServerTest.cs68
-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.cs79
-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/Channel.cs28
-rw-r--r--src/csharp/Grpc.Core/GrpcEnvironment.cs33
-rw-r--r--src/csharp/Grpc.Core/IAsyncStreamReader.cs7
-rw-r--r--src/csharp/Grpc.Core/Internal/AsyncCall.cs62
-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.cs74
-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.cs99
-rw-r--r--src/csharp/Grpc.Core/Internal/DefaultObjectPool.cs196
-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.cs35
-rw-r--r--src/csharp/Grpc.Core/Internal/NativeMethods.cs7
-rw-r--r--src/csharp/Grpc.Core/Internal/RequestCallContextSafeHandle.cs23
-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.cs7
-rw-r--r--src/csharp/Grpc.Core/Server.cs2
-rwxr-xr-xsrc/csharp/Grpc.Core/Version.csproj.include2
-rw-r--r--src/csharp/Grpc.Core/VersionInfo.cs4
-rw-r--r--src/csharp/Grpc.IntegrationTesting/ClientRunners.cs28
-rw-r--r--src/csharp/Grpc.IntegrationTesting/ControlExtensions.cs43
-rw-r--r--src/csharp/Grpc.IntegrationTesting/ServerRunners.cs16
-rw-r--r--src/csharp/Grpc.IntegrationTesting/StressTestClient.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/build_packages_dotnetcli.bat2
-rwxr-xr-xsrc/csharp/build_packages_dotnetcli.sh4
-rw-r--r--src/csharp/ext/grpc_csharp_ext.c13
-rwxr-xr-xsrc/csharp/generate_proto_csharp.sh5
-rw-r--r--src/csharp/tests.json2
-rw-r--r--src/node/health_check/package.json29
-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/GRPCClient/GRPCCall.m6
-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.m2
-rw-r--r--src/objective-c/GRPCClient/private/GRPCWrappedCall.h10
-rw-r--r--src/objective-c/GRPCClient/private/GRPCWrappedCall.m14
-rw-r--r--src/objective-c/GRPCClient/private/version.h2
-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/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm (renamed from src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m)96
-rw-r--r--src/objective-c/tests/CronetUnitTests/CronetUnitTests.m8
-rw-r--r--src/objective-c/tests/GRPCClientTests.m4
-rw-r--r--src/objective-c/tests/InteropTests.m1
-rw-r--r--src/objective-c/tests/RxLibraryUnitTests.m4
-rw-r--r--src/objective-c/tests/Tests.xcodeproj/project.pbxproj12
-rwxr-xr-xsrc/objective-c/tests/run_tests.sh2
-rw-r--r--src/objective-c/tests/version.h2
-rw-r--r--src/php/composer.json2
-rw-r--r--src/php/ext/grpc/version.h2
-rw-r--r--src/proto/grpc/testing/BUILD1
-rw-r--r--src/proto/grpc/testing/services.proto1
-rw-r--r--src/python/grpcio/grpc/__init__.py247
-rw-r--r--src/python/grpcio/grpc/_auth.py2
-rw-r--r--src/python/grpcio/grpc/_credential_composition.py33
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi13
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi8
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi89
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi405
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi40
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi38
-rw-r--r--src/python/grpcio/grpc/_grpcio_metadata.py2
-rw-r--r--src/python/grpcio/grpc/_plugin_wrapping.py127
-rw-r--r--src/python/grpcio/grpc/_server.py20
-rw-r--r--src/python/grpcio/grpc_core_dependencies.py6
-rw-r--r--src/python/grpcio/grpc_version.py2
-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/setup.py47
-rw-r--r--src/python/grpcio_reflection/MANIFEST.in3
-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.py47
-rw-r--r--src/python/grpcio_testing/grpc_version.py2
-rw-r--r--src/python/grpcio_testing/setup.py2
-rw-r--r--src/python/grpcio_tests/grpc_version.py2
-rw-r--r--src/python/grpcio_tests/setup.py4
-rw-r--r--src/python/grpcio_tests/tests/interop/client.py31
-rw-r--r--src/python/grpcio_tests/tests/interop/server.py7
-rw-r--r--src/python/grpcio_tests/tests/tests.json6
-rw-r--r--src/python/grpcio_tests/tests/unit/_api_test.py16
-rw-r--r--src/python/grpcio_tests/tests/unit/_auth_test.py6
-rw-r--r--src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py22
-rw-r--r--src/python/grpcio_tests/tests/unit/_invocation_defects_test.py22
-rw-r--r--src/python/grpcio_tests/tests/unit/_server_ssl_cert_config_test.py519
-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/resources.py80
-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.rb6
-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/multiple_killed_watching_threads_driver.rb2
-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/rb_grpc_imports.generated.c30
-rw-r--r--src/ruby/ext/grpc/rb_grpc_imports.generated.h54
-rw-r--r--src/ruby/lib/grpc/generic/interceptors.rb16
-rw-r--r--src/ruby/lib/grpc/generic/rpc_server.rb37
-rw-r--r--src/ruby/lib/grpc/version.rb2
-rw-r--r--src/ruby/pb/grpc/health/checker.rb14
-rwxr-xr-xsrc/ruby/qps/worker.rb12
-rw-r--r--src/ruby/spec/pb/health/checker_spec.rb29
-rw-r--r--src/ruby/tools/version.rb2
-rw-r--r--templates/CMakeLists.txt.template3
-rw-r--r--templates/Makefile.template12
-rw-r--r--templates/gRPC-Core.podspec.template5
-rw-r--r--templates/gRPC-ProtoRPC.podspec.template1
-rw-r--r--templates/gRPC-RxLibrary.podspec.template4
-rw-r--r--templates/gRPC.podspec.template1
-rw-r--r--templates/src/core/plugin_registry.template4
-rw-r--r--templates/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec.template2
-rw-r--r--templates/test/core/surface/public_headers_must_be_c89.c.template8
-rw-r--r--templates/tools/dockerfile/python_deps.include2
-rw-r--r--templates/tools/dockerfile/test/sanity/Dockerfile.template1
-rw-r--r--test/core/bad_client/bad_client.cc39
-rw-r--r--test/core/bad_client/tests/badreq.cc12
-rw-r--r--test/core/bad_client/tests/connection_prefix.cc51
-rw-r--r--test/core/bad_client/tests/head_of_line_blocking.cc6
-rw-r--r--test/core/bad_client/tests/headers.cc121
-rw-r--r--test/core/bad_client/tests/initial_settings_frame.cc55
-rw-r--r--test/core/bad_client/tests/large_metadata.cc4
-rw-r--r--test/core/bad_client/tests/server_registered_method.cc28
-rw-r--r--test/core/bad_client/tests/simple_request.cc26
-rw-r--r--test/core/bad_client/tests/unknown_frame.cc4
-rw-r--r--test/core/bad_client/tests/window_overflow.cc4
-rw-r--r--test/core/bad_ssl/bad_ssl_test.cc20
-rw-r--r--test/core/bad_ssl/server_common.cc24
-rw-r--r--test/core/bad_ssl/servers/alpn.cc6
-rw-r--r--test/core/bad_ssl/servers/cert.cc6
-rw-r--r--test/core/channel/channel_args_test.cc10
-rw-r--r--test/core/channel/channel_stack_builder_test.cc4
-rw-r--r--test/core/channel/channel_stack_test.cc6
-rw-r--r--test/core/channel/minimal_stack_is_minimal_test.cc35
-rw-r--r--test/core/client_channel/lb_policies_test.cc120
-rw-r--r--test/core/client_channel/parse_address_test.cc8
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc13
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_test.cc4
-rw-r--r--test/core/client_channel/resolvers/fake_resolver_test.cc20
-rw-r--r--test/core/client_channel/resolvers/sockaddr_resolver_test.cc4
-rw-r--r--test/core/client_channel/uri_parser_test.cc14
-rw-r--r--test/core/compression/algorithm_test.cc4
-rw-r--r--test/core/compression/stream_compression_test.cc14
-rw-r--r--test/core/debug/stats_test.cc19
-rw-r--r--test/core/end2end/bad_server_response_test.cc32
-rw-r--r--test/core/end2end/connection_refused_test.cc30
-rw-r--r--test/core/end2end/cq_verifier.cc27
-rw-r--r--test/core/end2end/cq_verifier.h8
-rw-r--r--test/core/end2end/cq_verifier_native.cc7
-rw-r--r--test/core/end2end/data/client_certs.cc8
-rw-r--r--test/core/end2end/data/server1_cert.cc2
-rw-r--r--test/core/end2end/data/server1_key.cc2
-rw-r--r--test/core/end2end/data/ssl_test_data.h8
-rw-r--r--test/core/end2end/data/test_root_cert.cc2
-rw-r--r--test/core/end2end/dualstack_socket_test.cc37
-rw-r--r--test/core/end2end/end2end_test_utils.cc6
-rw-r--r--test/core/end2end/end2end_tests.h8
-rw-r--r--test/core/end2end/fixtures/h2_census.cc11
-rw-r--r--test/core/end2end/fixtures/h2_compress.cc16
-rw-r--r--test/core/end2end/fixtures/h2_fakesec.cc21
-rw-r--r--test/core/end2end/fixtures/h2_fd.cc10
-rw-r--r--test/core/end2end/fixtures/h2_full+pipe.cc11
-rw-r--r--test/core/end2end/fixtures/h2_full+trace.cc11
-rw-r--r--test/core/end2end/fixtures/h2_full+workarounds.cc11
-rw-r--r--test/core/end2end/fixtures/h2_full.cc11
-rw-r--r--test/core/end2end/fixtures/h2_http_proxy.cc13
-rw-r--r--test/core/end2end/fixtures/h2_load_reporting.cc11
-rw-r--r--test/core/end2end/fixtures/h2_oauth2.cc37
-rw-r--r--test/core/end2end/fixtures/h2_proxy.cc14
-rw-r--r--test/core/end2end/fixtures/h2_sockpair+trace.cc20
-rw-r--r--test/core/end2end/fixtures/h2_sockpair.cc20
-rw-r--r--test/core/end2end/fixtures/h2_sockpair_1byte.cc18
-rw-r--r--test/core/end2end/fixtures/h2_ssl.cc31
-rw-r--r--test/core/end2end/fixtures/h2_ssl_proxy.cc41
-rw-r--r--test/core/end2end/fixtures/h2_uds.cc11
-rw-r--r--test/core/end2end/fixtures/http_proxy_fixture.cc146
-rw-r--r--test/core/end2end/fixtures/inproc.cc10
-rw-r--r--test/core/end2end/fixtures/proxy.cc72
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer.cc241
-rw-r--r--test/core/end2end/fuzzers/client_fuzzer.cc39
-rw-r--r--test/core/end2end/fuzzers/server_fuzzer.cc25
-rw-r--r--test/core/end2end/goaway_server_test.cc53
-rw-r--r--test/core/end2end/h2_ssl_cert_test.cc38
-rw-r--r--test/core/end2end/invalid_call_argument_test.cc170
-rw-r--r--test/core/end2end/multiple_server_queues_test.cc24
-rw-r--r--test/core/end2end/no_server_test.cc23
-rw-r--r--test/core/end2end/tests/authority_not_supported.cc34
-rw-r--r--test/core/end2end/tests/bad_hostname.cc24
-rw-r--r--test/core/end2end/tests/bad_ping.cc34
-rw-r--r--test/core/end2end/tests/binary_metadata.cc57
-rw-r--r--test/core/end2end/tests/call_creds.cc104
-rw-r--r--test/core/end2end/tests/cancel_after_accept.cc46
-rw-r--r--test/core/end2end/tests/cancel_after_client_done.cc47
-rw-r--r--test/core/end2end/tests/cancel_after_invoke.cc32
-rw-r--r--test/core/end2end/tests/cancel_after_round_trip.cc61
-rw-r--r--test/core/end2end/tests/cancel_before_invoke.cc32
-rw-r--r--test/core/end2end/tests/cancel_in_a_vacuum.cc16
-rw-r--r--test/core/end2end/tests/cancel_with_status.cc27
-rw-r--r--test/core/end2end/tests/compressed_payload.cc128
-rw-r--r--test/core/end2end/tests/connectivity.cc9
-rw-r--r--test/core/end2end/tests/default_host.cc40
-rw-r--r--test/core/end2end/tests/disappearing_server.cc36
-rw-r--r--test/core/end2end/tests/empty_batch.cc18
-rw-r--r--test/core/end2end/tests/filter_call_init_fails.cc94
-rw-r--r--test/core/end2end/tests/filter_causes_close.cc34
-rw-r--r--test/core/end2end/tests/filter_latency.cc42
-rw-r--r--test/core/end2end/tests/graceful_server_shutdown.cc35
-rw-r--r--test/core/end2end/tests/high_initial_seqno.cc32
-rw-r--r--test/core/end2end/tests/hpack_size.cc34
-rw-r--r--test/core/end2end/tests/idempotent_request.cc40
-rw-r--r--test/core/end2end/tests/invoke_large_request.cc44
-rw-r--r--test/core/end2end/tests/keepalive_timeout.cc22
-rw-r--r--test/core/end2end/tests/large_metadata.cc38
-rw-r--r--test/core/end2end/tests/load_reporting_hook.cc52
-rw-r--r--test/core/end2end/tests/max_concurrent_streams.cc166
-rw-r--r--test/core/end2end/tests/max_connection_age.cc62
-rw-r--r--test/core/end2end/tests/max_connection_idle.cc32
-rw-r--r--test/core/end2end/tests/max_message_length.cc102
-rw-r--r--test/core/end2end/tests/negative_deadline.cc24
-rw-r--r--test/core/end2end/tests/network_status_change.cc40
-rw-r--r--test/core/end2end/tests/no_logging.cc46
-rw-r--r--test/core/end2end/tests/no_op.cc10
-rw-r--r--test/core/end2end/tests/payload.cc48
-rw-r--r--test/core/end2end/tests/ping.cc6
-rw-r--r--test/core/end2end/tests/ping_pong_streaming.cc52
-rw-r--r--test/core/end2end/tests/proxy_auth.cc38
-rw-r--r--test/core/end2end/tests/registered_call.cc36
-rw-r--r--test/core/end2end/tests/request_with_flags.cc28
-rw-r--r--test/core/end2end/tests/request_with_payload.cc40
-rw-r--r--test/core/end2end/tests/resource_quota_server.cc48
-rw-r--r--test/core/end2end/tests/server_finishes_request.cc30
-rw-r--r--test/core/end2end/tests/shutdown_finishes_calls.cc29
-rw-r--r--test/core/end2end/tests/shutdown_finishes_tags.cc8
-rw-r--r--test/core/end2end/tests/simple_cacheable_request.cc56
-rw-r--r--test/core/end2end/tests/simple_delayed_request.cc38
-rw-r--r--test/core/end2end/tests/simple_metadata.cc57
-rw-r--r--test/core/end2end/tests/simple_request.cc52
-rw-r--r--test/core/end2end/tests/stream_compression_compressed_payload.cc119
-rw-r--r--test/core/end2end/tests/stream_compression_payload.cc50
-rw-r--r--test/core/end2end/tests/stream_compression_ping_pong_streaming.cc54
-rw-r--r--test/core/end2end/tests/streaming_error_response.cc37
-rw-r--r--test/core/end2end/tests/trailing_metadata.cc61
-rw-r--r--test/core/end2end/tests/workaround_cronet_compression.cc62
-rw-r--r--test/core/end2end/tests/write_buffering.cc46
-rw-r--r--test/core/end2end/tests/write_buffering_at_end.cc46
-rw-r--r--test/core/fling/client.cc50
-rw-r--r--test/core/fling/fling_stream_test.cc2
-rw-r--r--test/core/fling/fling_test.cc2
-rw-r--r--test/core/fling/server.cc60
-rw-r--r--test/core/handshake/BUILD31
-rw-r--r--test/core/handshake/client_ssl.cc13
-rw-r--r--test/core/handshake/readahead_handshaker_server_ssl.cc103
-rw-r--r--test/core/handshake/server_ssl.cc201
-rw-r--r--test/core/handshake/server_ssl_common.cc239
-rw-r--r--test/core/handshake/server_ssl_common.h36
-rw-r--r--test/core/http/format_request_test.cc2
-rw-r--r--test/core/http/httpcli_test.cc7
-rw-r--r--test/core/http/httpscli_test.cc7
-rw-r--r--test/core/http/parser_test.cc16
-rw-r--r--test/core/http/request_fuzzer.cc2
-rw-r--r--test/core/http/response_fuzzer.cc2
-rw-r--r--test/core/iomgr/combiner_test.cc9
-rw-r--r--test/core/iomgr/endpoint_tests.cc18
-rw-r--r--test/core/iomgr/ev_epollsig_linux_test.cc12
-rw-r--r--test/core/iomgr/fd_conservation_posix_test.cc2
-rw-r--r--test/core/iomgr/fd_posix_test.cc45
-rw-r--r--test/core/iomgr/load_file_test.cc24
-rw-r--r--test/core/iomgr/pollset_set_test.cc8
-rw-r--r--test/core/iomgr/resolve_address_posix_test.cc16
-rw-r--r--test/core/iomgr/resolve_address_test.cc20
-rw-r--r--test/core/iomgr/resource_quota_test.cc105
-rw-r--r--test/core/iomgr/sockaddr_utils_test.cc12
-rw-r--r--test/core/iomgr/tcp_client_posix_test.cc28
-rw-r--r--test/core/iomgr/tcp_posix_test.cc24
-rw-r--r--test/core/iomgr/tcp_server_posix_test.cc58
-rw-r--r--test/core/iomgr/timer_heap_test.cc12
-rw-r--r--test/core/iomgr/timer_list_test.cc23
-rw-r--r--test/core/iomgr/udp_server_test.cc56
-rw-r--r--test/core/iomgr/wakeup_fd_cv_test.cc10
-rw-r--r--test/core/json/json_rewrite.cc8
-rw-r--r--test/core/json/json_rewrite_test.cc4
-rw-r--r--test/core/json/json_stream_error_test.cc6
-rw-r--r--test/core/json/json_test.cc104
-rw-r--r--test/core/memory_usage/client.cc42
-rw-r--r--test/core/memory_usage/server.cc48
-rw-r--r--test/core/network_benchmarks/low_level_ping_pong.cc34
-rw-r--r--test/core/security/auth_context_test.cc32
-rw-r--r--test/core/security/create_jwt.cc18
-rw-r--r--test/core/security/credentials_test.cc202
-rw-r--r--test/core/security/fetch_oauth2.cc29
-rw-r--r--test/core/security/json_token_test.cc100
-rw-r--r--test/core/security/jwt_verifier_test.cc120
-rw-r--r--test/core/security/oauth2_utils.cc10
-rw-r--r--test/core/security/print_google_default_creds_token.cc8
-rw-r--r--test/core/security/secure_endpoint_test.cc22
-rw-r--r--test/core/security/security_connector_test.cc24
-rw-r--r--test/core/security/ssl_credentials_test.cc4
-rw-r--r--test/core/security/ssl_server_fuzzer.cc9
-rw-r--r--test/core/security/verify_jwt.cc16
-rw-r--r--test/core/slice/slice_hash_table_test.cc6
-rw-r--r--test/core/slice/slice_test.cc8
-rw-r--r--test/core/statistics/census_log_tests.cc576
-rw-r--r--test/core/statistics/hash_table_test.cc286
-rw-r--r--test/core/statistics/trace_test.cc239
-rw-r--r--test/core/statistics/window_stats_test.cc304
-rw-r--r--test/core/support/BUILD51
-rw-r--r--test/core/support/alloc_test.cc5
-rw-r--r--test/core/support/arena_test.cc5
-rw-r--r--test/core/support/avl_test.cc3474
-rw-r--r--test/core/support/cmdline_test.cc160
-rw-r--r--test/core/support/cpu_test.cc3
-rw-r--r--test/core/support/env_test.cc2
-rw-r--r--test/core/support/histogram_test.cc163
-rw-r--r--test/core/support/log_test.cc2
-rw-r--r--test/core/support/manual_constructor_test.cc99
-rw-r--r--test/core/support/mpscq_test.cc15
-rw-r--r--test/core/support/ref_counted_ptr_test.cc172
-rw-r--r--test/core/support/ref_counted_test.cc72
-rw-r--r--test/core/support/spinlock_test.cc3
-rw-r--r--test/core/support/stack_lockfree_test.cc140
-rw-r--r--test/core/support/string_test.cc10
-rw-r--r--test/core/support/sync_test.cc20
-rw-r--r--test/core/support/thd_test.cc5
-rw-r--r--test/core/support/tls_test.cc2
-rw-r--r--test/core/surface/alarm_test.cc38
-rw-r--r--test/core/surface/channel_create_test.cc4
-rw-r--r--test/core/surface/completion_queue_test.cc65
-rw-r--r--test/core/surface/completion_queue_threading_test.cc28
-rw-r--r--test/core/surface/concurrent_connectivity_test.cc61
-rw-r--r--test/core/surface/invalid_channel_args_test.cc12
-rw-r--r--test/core/surface/lame_client_test.cc23
-rw-r--r--test/core/surface/num_external_connectivity_watchers_test.cc32
-rw-r--r--test/core/surface/public_headers_must_be_c89.c552
-rw-r--r--test/core/surface/secure_channel_create_test.cc10
-rw-r--r--test/core/surface/sequential_connectivity_test.cc42
-rw-r--r--test/core/surface/server_chttp2_test.cc16
-rw-r--r--test/core/surface/server_test.cc64
-rw-r--r--test/core/transport/bdp_estimator_test.cc2
-rw-r--r--test/core/transport/byte_stream_test.cc10
-rw-r--r--test/core/transport/chttp2/BUILD15
-rw-r--r--test/core/transport/chttp2/hpack_encoder_test.cc14
-rw-r--r--test/core/transport/chttp2/hpack_parser_test.cc2
-rw-r--r--test/core/transport/chttp2/settings_timeout_test.cc258
-rw-r--r--test/core/transport/chttp2/stream_map_test.cc26
-rw-r--r--test/core/transport/connectivity_state_test.cc5
-rw-r--r--test/core/transport/stream_owned_slice_test.cc2
-rw-r--r--test/core/tsi/fake_transport_security_test.cc4
-rw-r--r--test/core/tsi/ssl_transport_security_test.cc69
-rw-r--r--test/core/tsi/transport_security_test.cc191
-rw-r--r--test/core/tsi/transport_security_test_lib.cc119
-rw-r--r--test/core/util/BUILD34
-rw-r--r--test/core/util/debugger_macros.cc6
-rw-r--r--test/core/util/fuzzer_corpus_test.cc15
-rw-r--r--test/core/util/grpc_fuzzer.bzl3
-rw-r--r--test/core/util/histogram.cc (renamed from src/core/lib/support/histogram.cc)62
-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.cc8
-rw-r--r--test/core/util/mock_endpoint.cc8
-rw-r--r--test/core/util/parse_hexstring.cc2
-rw-r--r--test/core/util/passthru_endpoint.cc12
-rw-r--r--test/core/util/port.cc10
-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.cc10
-rw-r--r--test/core/util/reconnect_server.cc18
-rwxr-xr-xtest/core/util/run_with_poller.sh19
-rw-r--r--test/core/util/slice_splitter.cc2
-rw-r--r--test/core/util/test_config.cc18
-rw-r--r--test/core/util/test_config.h10
-rw-r--r--test/core/util/test_tcp_server.cc8
-rw-r--r--test/core/util/tracer_util.cc31
-rw-r--r--test/core/util/tracer_util.h32
-rw-r--r--test/core/util/trickle_endpoint.cc11
-rw-r--r--test/cpp/client/BUILD51
-rw-r--r--test/cpp/client/client_channel_stress_test.cc327
-rw-r--r--test/cpp/codegen/proto_utils_test.cc112
-rw-r--r--test/cpp/common/auth_property_iterator_test.cc2
-rw-r--r--test/cpp/common/secure_auth_context_test.cc4
-rw-r--r--test/cpp/end2end/async_end2end_test.cc2
-rw-r--r--test/cpp/end2end/client_lb_end2end_test.cc9
-rw-r--r--test/cpp/end2end/end2end_test.cc4
-rw-r--r--test/cpp/end2end/grpclb_end2end_test.cc40
-rw-r--r--test/cpp/grpclb/grpclb_api_test.cc2
-rw-r--r--test/cpp/grpclb/grpclb_test.cc119
-rw-r--r--test/cpp/interop/http2_client.cc2
-rw-r--r--test/cpp/interop/interop_server.cc18
-rw-r--r--test/cpp/interop/server_helper.h20
-rw-r--r--test/cpp/interop/stress_test.cc4
-rw-r--r--test/cpp/microbenchmarks/bm_call_create.cc91
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_hpack.cc6
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_transport.cc8
-rw-r--r--test/cpp/microbenchmarks/bm_closure.cc60
-rw-r--r--test/cpp/microbenchmarks/bm_cq.cc31
-rw-r--r--test/cpp/microbenchmarks/bm_cq_multiple_threads.cc8
-rw-r--r--test/cpp/microbenchmarks/bm_error.cc8
-rw-r--r--test/cpp/microbenchmarks/bm_fullstack_trickle.cc6
-rw-r--r--test/cpp/microbenchmarks/bm_metadata.cc18
-rw-r--r--test/cpp/microbenchmarks/bm_pollset.cc11
-rw-r--r--test/cpp/microbenchmarks/fullstack_fixtures.h16
-rw-r--r--test/cpp/microbenchmarks/helpers.h8
-rw-r--r--test/cpp/naming/README.md2
-rwxr-xr-xtest/cpp/naming/create_private_dns_zone.sh4
-rwxr-xr-xtest/cpp/naming/private_dns_zone_init.sh152
-rw-r--r--test/cpp/naming/resolver_component_test.cc23
-rwxr-xr-xtest/cpp/naming/resolver_component_tests_runner.sh26
-rw-r--r--test/cpp/naming/resolver_component_tests_runner_invoker.cc4
-rwxr-xr-xtest/cpp/naming/resolver_gce_integration_tests_runner.sh156
-rw-r--r--test/cpp/naming/resolver_test_record_groups.yaml10
-rw-r--r--test/cpp/performance/writes_per_rpc_test.cc14
-rw-r--r--test/cpp/qps/BUILD2
-rw-r--r--test/cpp/qps/client_async.cc36
-rw-r--r--test/cpp/qps/client_sync.cc212
-rw-r--r--test/cpp/qps/histogram.h36
-rw-r--r--test/cpp/qps/json_run_localhost.cc6
-rw-r--r--test/cpp/qps/qps_interarrival_test.cc10
-rw-r--r--test/cpp/qps/qps_json_driver.cc2
-rw-r--r--test/cpp/qps/qps_worker.cc2
-rw-r--r--test/cpp/qps/server_async.cc2
-rw-r--r--test/cpp/qps/server_sync.cc2
-rw-r--r--test/cpp/thread_manager/thread_manager_test.cc2
-rw-r--r--test/cpp/util/BUILD100
-rw-r--r--test/cpp/util/grpc_tool.cc10
-rw-r--r--test/cpp/util/grpc_tool_test.cc32
-rw-r--r--test/distrib/cpp/run_distrib_test_cmake.bat75
-rwxr-xr-xtest/distrib/cpp/run_distrib_test_cmake.sh1
-rw-r--r--third_party/cares/cares.BUILD209
-rw-r--r--third_party/cares/cares_local_files.BUILD57
m---------third_party/protobuf0
-rw-r--r--third_party/zlib.BUILD2
-rw-r--r--tools/bazel.rc48
-rwxr-xr-xtools/codegen/core/gen_nano_proto.sh2
-rwxr-xr-xtools/distrib/python/check_grpcio_tools.py20
-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.py2
-rwxr-xr-xtools/distrib/python/make_grpcio_tools.py20
-rwxr-xr-xtools/distrib/run_clang_tidy.py70
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_csharp/Dockerfile2
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/Dockerfile2
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_cxx/Dockerfile2
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_go/Dockerfile2
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_go1.7/Dockerfile2
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_go1.8/Dockerfile2
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_http2/Dockerfile2
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_java/Dockerfile2
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_java_oracle8/Dockerfile2
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_node/Dockerfile2
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_python/Dockerfile2
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile2
-rw-r--r--tools/dockerfile/test/csharp_jessie_x64/Dockerfile2
-rw-r--r--tools/dockerfile/test/cxx_alpine_x64/Dockerfile2
-rw-r--r--tools/dockerfile/test/cxx_jessie_x64/Dockerfile2
-rw-r--r--tools/dockerfile/test/cxx_jessie_x86/Dockerfile2
-rw-r--r--tools/dockerfile/test/cxx_ubuntu1404_x64/Dockerfile2
-rw-r--r--tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile2
-rw-r--r--tools/dockerfile/test/fuzzer/Dockerfile2
-rw-r--r--tools/dockerfile/test/multilang_jessie_x64/Dockerfile2
-rw-r--r--tools/dockerfile/test/node_jessie_x64/Dockerfile2
-rw-r--r--tools/dockerfile/test/php7_jessie_x64/Dockerfile2
-rw-r--r--tools/dockerfile/test/php_jessie_x64/Dockerfile2
-rw-r--r--tools/dockerfile/test/python_alpine_x64/Dockerfile2
-rw-r--r--tools/dockerfile/test/python_jessie_x64/Dockerfile2
-rw-r--r--tools/dockerfile/test/python_pyenv_x64/Dockerfile2
-rw-r--r--tools/dockerfile/test/ruby_jessie_x64/Dockerfile2
-rw-r--r--tools/dockerfile/test/sanity/Dockerfile6
-rw-r--r--tools/doxygen/Doxyfile.c++5
-rw-r--r--tools/doxygen/Doxyfile.c++.internal13
-rw-r--r--tools/doxygen/Doxyfile.core5
-rw-r--r--tools/doxygen/Doxyfile.core.internal19
-rwxr-xr-xtools/gce/linux_kokoro_performance_worker_init.sh13
-rw-r--r--tools/internal_ci/helper_scripts/prepare_build_linux_perf_multilang_rc40
-rw-r--r--tools/internal_ci/linux/grpc_bazel_on_foundry.sh55
-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
-rw-r--r--tools/interop_matrix/README.md4
-rw-r--r--tools/interop_matrix/client_matrix.py34
-rwxr-xr-xtools/interop_matrix/create_matrix_images.py16
-rwxr-xr-xtools/interop_matrix/run_interop_matrix_tests.py2
-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/node__v1.0.136
-rwxr-xr-xtools/interop_matrix/testcases/python__master20
-rwxr-xr-xtools/run_tests/artifacts/build_artifact_ruby.sh1
-rw-r--r--tools/run_tests/artifacts/distribtest_targets.py17
-rw-r--r--tools/run_tests/generated/configs.json5
-rw-r--r--tools/run_tests/generated/sources_and_headers.json203
-rw-r--r--tools/run_tests/generated/tests.json196
-rwxr-xr-xtools/run_tests/run_interop_tests.py9
-rwxr-xr-xtools/run_tests/run_performance_tests.py12
-rwxr-xr-xtools/run_tests/run_tests.py2
-rwxr-xr-xtools/run_tests/sanity/check_bazel_workspace.py49
-rwxr-xr-xtools/run_tests/sanity/check_clang_tidy.sh21
-rwxr-xr-xtools/run_tests/sanity/check_submodules.sh2
-rwxr-xr-xtools/run_tests/sanity/check_unsecure.sh27
-rw-r--r--tools/run_tests/sanity/sanity_tests.yaml5
1040 files changed, 21302 insertions, 16760 deletions
diff --git a/.clang_complete b/.clang_complete
index 4c4a86f0be..aa77554f4e 100644
--- a/.clang_complete
+++ b/.clang_complete
@@ -10,3 +10,8 @@
-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/.gitignore b/.gitignore
index 5ccad2e4f2..2b35c5fb9a 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
@@ -120,6 +121,7 @@ gdb.txt
tags
# perf data
+memory_usage.csv
perf.data
perf.data.old
diff --git a/BUILD b/BUILD
index bcb75af032..13843195ea 100644
--- a/BUILD
+++ b/BUILD
@@ -33,6 +33,16 @@ load(
"grpc_generate_one_off_targets",
)
+config_setting(
+ name = "grpc_no_ares",
+ values = {"define": "grpc_no_ares=true"},
+)
+
+config_setting(
+ name = "remote_execution",
+ values = {"define": "GRPC_PORT_ISOLATED_RUNTIME=1"},
+)
+
# This should be updated along with build.yaml
g_stands_for = "generous"
@@ -49,7 +59,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 +83,11 @@ 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/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",
@@ -413,7 +423,6 @@ grpc_cc_library(
],
external_deps = [
"nanopb",
- "libssl",
],
language = "c++",
public_hdrs = [
@@ -441,7 +450,7 @@ grpc_cc_library(
"src/core/lib/support/env_linux.cc",
"src/core/lib/support/env_posix.cc",
"src/core/lib/support/env_windows.cc",
- "src/core/lib/support/histogram.cc",
+ "src/core/lib/support/fork.cc",
"src/core/lib/support/host_port.cc",
"src/core/lib/support/log.cc",
"src/core/lib/support/log_android.cc",
@@ -450,7 +459,6 @@ grpc_cc_library(
"src/core/lib/support/log_windows.cc",
"src/core/lib/support/mpscq.cc",
"src/core/lib/support/murmur_hash.cc",
- "src/core/lib/support/stack_lockfree.cc",
"src/core/lib/support/string.cc",
"src/core/lib/support/string_posix.cc",
"src/core/lib/support/string_util_windows.cc",
@@ -475,28 +483,30 @@ grpc_cc_library(
],
hdrs = [
"src/core/lib/profiling/timers.h",
+ "src/core/lib/support/abstract.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/env.h",
- "src/core/lib/support/memory.h",
- "src/core/lib/support/vector.h",
+ "src/core/lib/support/fork.h",
"src/core/lib/support/manual_constructor.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/thd_internal.h",
"src/core/lib/support/time_precise.h",
"src/core/lib/support/tmpfile.h",
+ "src/core/lib/support/vector.h",
],
language = "c++",
public_hdrs = GPR_PUBLIC_HDRS,
deps = [
"gpr_codegen",
- "@com_google_absl//absl/container:inlined_vector"
+ "@com_google_absl//absl/container:inlined_vector",
],
)
@@ -508,6 +518,7 @@ grpc_cc_library(
"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",
@@ -532,6 +543,28 @@ grpc_cc_library(
)
grpc_cc_library(
+ name = "debug_location",
+ public_hdrs = ["src/core/lib/support/debug_location.h"],
+ language = "c++",
+)
+
+grpc_cc_library(
+ name = "ref_counted",
+ public_hdrs = ["src/core/lib/support/ref_counted.h"],
+ language = "c++",
+ deps = [
+ "grpc_trace",
+ "debug_location",
+ ],
+)
+
+grpc_cc_library(
+ name = "ref_counted_ptr",
+ public_hdrs = ["src/core/lib/support/ref_counted_ptr.h"],
+ language = "c++",
+)
+
+grpc_cc_library(
name = "grpc_base_c",
srcs = [
"src/core/lib/backoff/backoff.cc",
@@ -553,7 +586,6 @@ grpc_cc_library(
"src/core/lib/http/httpcli.cc",
"src/core/lib/http/parser.cc",
"src/core/lib/iomgr/call_combiner.cc",
- "src/core/lib/iomgr/closure.cc",
"src/core/lib/iomgr/combiner.cc",
"src/core/lib/iomgr/endpoint.cc",
"src/core/lib/iomgr/endpoint_pair_posix.cc",
@@ -568,6 +600,8 @@ grpc_cc_library(
"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",
@@ -667,6 +701,7 @@ grpc_cc_library(
"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",
@@ -685,6 +720,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",
@@ -729,7 +765,6 @@ grpc_cc_library(
"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/block_annotate.h",
"src/core/lib/iomgr/tcp_client.h",
"src/core/lib/iomgr/tcp_client_posix.h",
"src/core/lib/iomgr/tcp_posix.h",
@@ -785,7 +820,6 @@ grpc_cc_library(
"src/core/lib/transport/timeout_encoding.h",
"src/core/lib/transport/transport.h",
"src/core/lib/transport/transport_impl.h",
- "src/core/lib/backoff/backoff.h",
],
external_deps = [
"zlib",
@@ -1245,8 +1279,8 @@ grpc_cc_library(
"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/frame.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",
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4daff95efd..22a1ab79af 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.8.0-dev")
+set(PACKAGE_VERSION "1.9.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/")
@@ -235,6 +235,7 @@ if("${gRPC_SSL_PROVIDER}" STREQUAL "module")
elseif("${gRPC_SSL_PROVIDER}" STREQUAL "package")
find_package(OpenSSL REQUIRED)
set(_gRPC_SSL_LIBRARIES ${OPENSSL_LIBRARIES})
+ include_directories(${OPENSSL_INCLUDE_DIR})
set(_gRPC_FIND_SSL "if(NOT OPENSSL_FOUND)\n find_package(OpenSSL)\nendif()")
endif()
@@ -427,12 +428,11 @@ add_dependencies(buildtests_c gpr_avl_test)
add_dependencies(buildtests_c gpr_cmdline_test)
add_dependencies(buildtests_c gpr_cpu_test)
add_dependencies(buildtests_c gpr_env_test)
-add_dependencies(buildtests_c gpr_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)
@@ -462,6 +462,10 @@ 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)
@@ -674,7 +678,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()
@@ -734,6 +740,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)
@@ -756,7 +764,6 @@ 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)
-add_dependencies(buildtests_cxx vector_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx writes_per_rpc_test)
endif()
@@ -793,7 +800,7 @@ add_library(gpr
src/core/lib/support/env_linux.cc
src/core/lib/support/env_posix.cc
src/core/lib/support/env_windows.cc
- src/core/lib/support/histogram.cc
+ src/core/lib/support/fork.cc
src/core/lib/support/host_port.cc
src/core/lib/support/log.cc
src/core/lib/support/log_android.cc
@@ -802,7 +809,6 @@ add_library(gpr
src/core/lib/support/log_windows.cc
src/core/lib/support/mpscq.cc
src/core/lib/support/murmur_hash.cc
- src/core/lib/support/stack_lockfree.cc
src/core/lib/support/string.cc
src/core/lib/support/string_posix.cc
src/core/lib/support/string_util_windows.cc
@@ -849,7 +855,6 @@ target_include_directories(gpr
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(gpr
@@ -865,7 +870,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
@@ -888,6 +892,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
@@ -942,7 +947,6 @@ target_include_directories(gpr_test_util
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(gpr_test_util
@@ -974,7 +978,6 @@ add_library(grpc
src/core/lib/http/httpcli.cc
src/core/lib/http/parser.cc
src/core/lib/iomgr/call_combiner.cc
- src/core/lib/iomgr/closure.cc
src/core/lib/iomgr/combiner.cc
src/core/lib/iomgr/endpoint.cc
src/core/lib/iomgr/endpoint_pair_posix.cc
@@ -989,6 +992,8 @@ add_library(grpc
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
@@ -1229,7 +1234,6 @@ target_include_directories(grpc
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc
@@ -1255,6 +1259,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
@@ -1267,6 +1272,7 @@ foreach(_hdr
include/grpc/byte_buffer.h
include/grpc/byte_buffer_reader.h
include/grpc/compression.h
+ include/grpc/fork.h
include/grpc/grpc.h
include/grpc/grpc_posix.h
include/grpc/grpc_security_constants.h
@@ -1315,7 +1321,6 @@ add_library(grpc_cronet
src/core/lib/http/httpcli.cc
src/core/lib/http/parser.cc
src/core/lib/iomgr/call_combiner.cc
- src/core/lib/iomgr/closure.cc
src/core/lib/iomgr/combiner.cc
src/core/lib/iomgr/endpoint.cc
src/core/lib/iomgr/endpoint_pair_posix.cc
@@ -1330,6 +1335,8 @@ add_library(grpc_cronet
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
@@ -1541,7 +1548,6 @@ target_include_directories(grpc_cronet
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_cronet
@@ -1567,6 +1573,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
@@ -1610,13 +1617,16 @@ add_library(grpc_test_util
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
@@ -1637,7 +1647,6 @@ add_library(grpc_test_util
src/core/lib/http/httpcli.cc
src/core/lib/http/parser.cc
src/core/lib/iomgr/call_combiner.cc
- src/core/lib/iomgr/closure.cc
src/core/lib/iomgr/combiner.cc
src/core/lib/iomgr/endpoint.cc
src/core/lib/iomgr/endpoint_pair_posix.cc
@@ -1652,6 +1661,8 @@ add_library(grpc_test_util
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
@@ -1825,7 +1836,6 @@ target_include_directories(grpc_test_util
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_test_util
@@ -1849,6 +1859,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
@@ -1876,13 +1887,16 @@ add_library(grpc_test_util_unsecure
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
@@ -1903,7 +1917,6 @@ add_library(grpc_test_util_unsecure
src/core/lib/http/httpcli.cc
src/core/lib/http/parser.cc
src/core/lib/iomgr/call_combiner.cc
- src/core/lib/iomgr/closure.cc
src/core/lib/iomgr/combiner.cc
src/core/lib/iomgr/endpoint.cc
src/core/lib/iomgr/endpoint_pair_posix.cc
@@ -1918,6 +1931,8 @@ add_library(grpc_test_util_unsecure
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
@@ -2091,7 +2106,6 @@ target_include_directories(grpc_test_util_unsecure
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_test_util_unsecure
@@ -2115,6 +2129,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
@@ -2155,7 +2170,6 @@ add_library(grpc_unsecure
src/core/lib/http/httpcli.cc
src/core/lib/http/parser.cc
src/core/lib/iomgr/call_combiner.cc
- src/core/lib/iomgr/closure.cc
src/core/lib/iomgr/combiner.cc
src/core/lib/iomgr/endpoint.cc
src/core/lib/iomgr/endpoint_pair_posix.cc
@@ -2170,6 +2184,8 @@ add_library(grpc_unsecure
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
@@ -2378,7 +2394,6 @@ target_include_directories(grpc_unsecure
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_unsecure
@@ -2403,6 +2418,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
@@ -2414,6 +2430,7 @@ foreach(_hdr
include/grpc/byte_buffer.h
include/grpc/byte_buffer_reader.h
include/grpc/compression.h
+ include/grpc/fork.h
include/grpc/grpc.h
include/grpc/grpc_posix.h
include/grpc/grpc_security_constants.h
@@ -2469,7 +2486,6 @@ target_include_directories(reconnect_server
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(reconnect_server
@@ -2512,7 +2528,6 @@ target_include_directories(test_tcp_server
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(test_tcp_server
@@ -2594,7 +2609,6 @@ target_include_directories(grpc++
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -2661,7 +2675,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
@@ -2684,6 +2697,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
@@ -2695,6 +2709,7 @@ foreach(_hdr
include/grpc/byte_buffer.h
include/grpc/byte_buffer_reader.h
include/grpc/compression.h
+ include/grpc/fork.h
include/grpc/grpc.h
include/grpc/grpc_posix.h
include/grpc/grpc_security_constants.h
@@ -2797,7 +2812,6 @@ target_include_directories(grpc++_core_stats
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -2906,7 +2920,6 @@ add_library(grpc++_cronet
src/core/lib/http/httpcli.cc
src/core/lib/http/parser.cc
src/core/lib/iomgr/call_combiner.cc
- src/core/lib/iomgr/closure.cc
src/core/lib/iomgr/combiner.cc
src/core/lib/iomgr/endpoint.cc
src/core/lib/iomgr/endpoint_pair_posix.cc
@@ -2921,6 +2934,8 @@ add_library(grpc++_cronet
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
@@ -3079,7 +3094,6 @@ target_include_directories(grpc++_cronet
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -3147,7 +3161,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
@@ -3170,6 +3183,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
@@ -3181,6 +3195,7 @@ foreach(_hdr
include/grpc/byte_buffer.h
include/grpc/byte_buffer_reader.h
include/grpc/compression.h
+ include/grpc/fork.h
include/grpc/grpc.h
include/grpc/grpc_posix.h
include/grpc/grpc_security_constants.h
@@ -3281,7 +3296,6 @@ target_include_directories(grpc++_error_details
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -3347,7 +3361,6 @@ target_include_directories(grpc++_proto_reflection_desc_db
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -3409,7 +3422,6 @@ target_include_directories(grpc++_reflection
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -3468,7 +3480,6 @@ target_include_directories(grpc++_test_config
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -3547,7 +3558,6 @@ target_include_directories(grpc++_test_util
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -3607,6 +3617,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
@@ -3688,7 +3699,6 @@ target_include_directories(grpc++_test_util_unsecure
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -3748,6 +3758,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
@@ -3831,7 +3842,6 @@ target_include_directories(grpc++_unsecure
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -3897,7 +3907,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
@@ -3920,6 +3929,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
@@ -3931,6 +3941,7 @@ foreach(_hdr
include/grpc/byte_buffer.h
include/grpc/byte_buffer_reader.h
include/grpc/compression.h
+ include/grpc/fork.h
include/grpc/grpc.h
include/grpc/grpc_posix.h
include/grpc/grpc_security_constants.h
@@ -4024,7 +4035,6 @@ target_include_directories(grpc_benchmark
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -4084,7 +4094,6 @@ target_include_directories(grpc_cli_libs
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -4145,7 +4154,6 @@ target_include_directories(grpc_plugin_support
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -4224,7 +4232,6 @@ target_include_directories(http2_client_main
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -4280,7 +4287,6 @@ target_include_directories(interop_client_helper
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -4351,7 +4357,6 @@ target_include_directories(interop_client_main
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -4403,7 +4408,6 @@ target_include_directories(interop_server_helper
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -4473,7 +4477,6 @@ target_include_directories(interop_server_lib
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -4525,7 +4528,6 @@ target_include_directories(interop_server_main
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -4614,7 +4616,6 @@ target_include_directories(qps
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -4662,7 +4663,6 @@ target_include_directories(grpc_csharp_ext
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_csharp_ext
@@ -4758,7 +4758,6 @@ target_include_directories(ares
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(ares
@@ -4797,7 +4796,6 @@ target_include_directories(bad_client_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(bad_client_test
@@ -4839,7 +4837,6 @@ target_include_directories(bad_ssl_test_server
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(bad_ssl_test_server
@@ -4941,7 +4938,6 @@ target_include_directories(end2end_tests
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(end2end_tests
@@ -5043,7 +5039,6 @@ target_include_directories(end2end_nosec_tests
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(end2end_nosec_tests
@@ -5075,7 +5070,6 @@ target_include_directories(alarm_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(alarm_test
@@ -5105,7 +5099,6 @@ target_include_directories(algorithm_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(algorithm_test
@@ -5135,7 +5128,6 @@ target_include_directories(alloc_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(alloc_test
@@ -5163,7 +5155,6 @@ target_include_directories(alpn_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(alpn_test
@@ -5193,7 +5184,6 @@ target_include_directories(arena_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(arena_test
@@ -5221,7 +5211,6 @@ target_include_directories(backoff_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(backoff_test
@@ -5251,7 +5240,6 @@ target_include_directories(bad_server_response_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(bad_server_response_test
@@ -5282,7 +5270,6 @@ target_include_directories(bin_decoder_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(bin_decoder_test
@@ -5310,7 +5297,6 @@ target_include_directories(bin_encoder_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(bin_encoder_test
@@ -5338,7 +5324,6 @@ target_include_directories(byte_stream_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(byte_stream_test
@@ -5368,7 +5353,6 @@ target_include_directories(channel_create_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(channel_create_test
@@ -5397,7 +5381,6 @@ target_include_directories(check_epollexclusive
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(check_epollexclusive
@@ -5433,7 +5416,6 @@ target_include_directories(chttp2_hpack_encoder_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(chttp2_hpack_encoder_test
@@ -5463,7 +5445,6 @@ target_include_directories(chttp2_stream_map_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(chttp2_stream_map_test
@@ -5493,7 +5474,6 @@ target_include_directories(chttp2_varint_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(chttp2_varint_test
@@ -5523,7 +5503,6 @@ target_include_directories(combiner_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(combiner_test
@@ -5553,7 +5532,6 @@ target_include_directories(compression_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(compression_test
@@ -5583,7 +5561,6 @@ target_include_directories(concurrent_connectivity_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(concurrent_connectivity_test
@@ -5613,7 +5590,6 @@ target_include_directories(connection_refused_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(connection_refused_test
@@ -5643,7 +5619,6 @@ target_include_directories(dns_resolver_connectivity_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(dns_resolver_connectivity_test
@@ -5673,7 +5648,6 @@ target_include_directories(dns_resolver_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(dns_resolver_test
@@ -5704,7 +5678,6 @@ target_include_directories(dualstack_socket_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(dualstack_socket_test
@@ -5735,7 +5708,6 @@ target_include_directories(endpoint_pair_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(endpoint_pair_test
@@ -5765,7 +5737,6 @@ target_include_directories(error_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(error_test
@@ -5796,7 +5767,6 @@ target_include_directories(ev_epollsig_linux_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(ev_epollsig_linux_test
@@ -5827,7 +5797,6 @@ target_include_directories(fake_resolver_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(fake_resolver_test
@@ -5859,7 +5828,6 @@ target_include_directories(fake_transport_security_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(fake_transport_security_test
@@ -5890,7 +5858,6 @@ target_include_directories(fd_conservation_posix_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(fd_conservation_posix_test
@@ -5922,7 +5889,6 @@ target_include_directories(fd_posix_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(fd_posix_test
@@ -5953,7 +5919,6 @@ target_include_directories(fling_client
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(fling_client
@@ -5983,7 +5948,6 @@ target_include_directories(fling_server
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(fling_server
@@ -6014,7 +5978,6 @@ target_include_directories(fling_stream_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(fling_stream_test
@@ -6046,7 +6009,6 @@ target_include_directories(fling_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(fling_test
@@ -6076,7 +6038,6 @@ target_include_directories(gen_hpack_tables
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(gen_hpack_tables
@@ -6111,7 +6072,6 @@ target_include_directories(gen_legal_metadata_characters
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(gen_legal_metadata_characters
@@ -6144,7 +6104,6 @@ target_include_directories(gen_percent_encoding_tables
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(gen_percent_encoding_tables
@@ -6179,7 +6138,6 @@ target_include_directories(goaway_server_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(goaway_server_test
@@ -6210,7 +6168,6 @@ target_include_directories(gpr_avl_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(gpr_avl_test
@@ -6238,7 +6195,6 @@ target_include_directories(gpr_cmdline_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(gpr_cmdline_test
@@ -6266,7 +6222,6 @@ target_include_directories(gpr_cpu_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(gpr_cpu_test
@@ -6294,7 +6249,6 @@ target_include_directories(gpr_env_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(gpr_env_test
@@ -6306,34 +6260,6 @@ target_link_libraries(gpr_env_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
-add_executable(gpr_histogram_test
- test/core/support/histogram_test.cc
-)
-
-
-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
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
-)
-
-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.cc
)
@@ -6350,7 +6276,6 @@ target_include_directories(gpr_host_port_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(gpr_host_port_test
@@ -6378,7 +6303,6 @@ target_include_directories(gpr_log_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(gpr_log_test
@@ -6390,12 +6314,12 @@ target_link_libraries(gpr_log_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
-add_executable(gpr_mpscq_test
- test/core/support/mpscq_test.cc
+add_executable(gpr_manual_constructor_test
+ test/core/support/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
@@ -6406,10 +6330,9 @@ target_include_directories(gpr_mpscq_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
-target_link_libraries(gpr_mpscq_test
+target_link_libraries(gpr_manual_constructor_test
${_gRPC_ALLTARGETS_LIBRARIES}
gpr_test_util
gpr
@@ -6418,12 +6341,12 @@ target_link_libraries(gpr_mpscq_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
-add_executable(gpr_spinlock_test
- test/core/support/spinlock_test.cc
+add_executable(gpr_mpscq_test
+ test/core/support/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
@@ -6434,10 +6357,9 @@ target_include_directories(gpr_spinlock_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
-target_link_libraries(gpr_spinlock_test
+target_link_libraries(gpr_mpscq_test
${_gRPC_ALLTARGETS_LIBRARIES}
gpr_test_util
gpr
@@ -6446,12 +6368,12 @@ 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.cc
+add_executable(gpr_spinlock_test
+ test/core/support/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
@@ -6462,10 +6384,9 @@ target_include_directories(gpr_stack_lockfree_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
-target_link_libraries(gpr_stack_lockfree_test
+target_link_libraries(gpr_spinlock_test
${_gRPC_ALLTARGETS_LIBRARIES}
gpr_test_util
gpr
@@ -6490,7 +6411,6 @@ target_include_directories(gpr_string_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(gpr_string_test
@@ -6518,7 +6438,6 @@ target_include_directories(gpr_sync_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(gpr_sync_test
@@ -6546,7 +6465,6 @@ target_include_directories(gpr_thd_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(gpr_thd_test
@@ -6574,7 +6492,6 @@ target_include_directories(gpr_time_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(gpr_time_test
@@ -6602,7 +6519,6 @@ target_include_directories(gpr_tls_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(gpr_tls_test
@@ -6630,7 +6546,6 @@ target_include_directories(gpr_useful_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(gpr_useful_test
@@ -6658,7 +6573,6 @@ target_include_directories(grpc_auth_context_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_auth_context_test
@@ -6688,7 +6602,6 @@ target_include_directories(grpc_b64_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_b64_test
@@ -6718,7 +6631,6 @@ target_include_directories(grpc_byte_buffer_reader_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_byte_buffer_reader_test
@@ -6748,7 +6660,6 @@ target_include_directories(grpc_channel_args_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_channel_args_test
@@ -6778,7 +6689,6 @@ target_include_directories(grpc_channel_stack_builder_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_channel_stack_builder_test
@@ -6808,7 +6718,6 @@ target_include_directories(grpc_channel_stack_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_channel_stack_test
@@ -6838,7 +6747,6 @@ target_include_directories(grpc_completion_queue_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_completion_queue_test
@@ -6868,7 +6776,6 @@ target_include_directories(grpc_completion_queue_threading_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_completion_queue_threading_test
@@ -6897,7 +6804,6 @@ target_include_directories(grpc_create_jwt
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_create_jwt
@@ -6934,7 +6840,6 @@ target_include_directories(grpc_credentials_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_credentials_test
@@ -6964,7 +6869,6 @@ target_include_directories(grpc_fetch_oauth2
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_fetch_oauth2
@@ -6994,7 +6898,6 @@ target_include_directories(grpc_invalid_channel_args_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_invalid_channel_args_test
@@ -7025,7 +6928,6 @@ target_include_directories(grpc_json_token_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_json_token_test
@@ -7056,7 +6958,6 @@ target_include_directories(grpc_jwt_verifier_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_jwt_verifier_test
@@ -7085,7 +6986,6 @@ target_include_directories(grpc_print_google_default_creds_token
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_print_google_default_creds_token
@@ -7121,7 +7021,6 @@ target_include_directories(grpc_security_connector_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_security_connector_test
@@ -7151,7 +7050,6 @@ target_include_directories(grpc_ssl_credentials_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_ssl_credentials_test
@@ -7180,7 +7078,6 @@ target_include_directories(grpc_verify_jwt
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(grpc_verify_jwt
@@ -7217,7 +7114,6 @@ target_include_directories(handshake_client
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(handshake_client
@@ -7236,6 +7132,7 @@ if(_gRPC_PLATFORM_LINUX)
add_executable(handshake_server
test/core/handshake/server_ssl.cc
+ test/core/handshake/server_ssl_common.cc
)
@@ -7250,7 +7147,6 @@ target_include_directories(handshake_server
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(handshake_server
@@ -7265,6 +7161,66 @@ 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 ${BORINGSSL_ROOT_DIR}/include
+ PRIVATE ${PROTOBUF_ROOT_DIR}/src
+ PRIVATE ${BENCHMARK_ROOT_DIR}/include
+ PRIVATE ${ZLIB_ROOT_DIR}
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_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(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 ${BORINGSSL_ROOT_DIR}/include
+ PRIVATE ${PROTOBUF_ROOT_DIR}/src
+ PRIVATE ${BENCHMARK_ROOT_DIR}/include
+ PRIVATE ${ZLIB_ROOT_DIR}
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_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(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.cc
@@ -7282,7 +7238,6 @@ target_include_directories(hpack_parser_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(hpack_parser_test
@@ -7312,7 +7267,6 @@ target_include_directories(hpack_table_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(hpack_table_test
@@ -7342,7 +7296,6 @@ target_include_directories(http_parser_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(http_parser_test
@@ -7372,7 +7325,6 @@ target_include_directories(httpcli_format_request_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(httpcli_format_request_test
@@ -7403,7 +7355,6 @@ target_include_directories(httpcli_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(httpcli_test
@@ -7435,7 +7386,6 @@ target_include_directories(httpscli_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(httpscli_test
@@ -7466,7 +7416,6 @@ target_include_directories(init_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(init_test
@@ -7496,7 +7445,6 @@ target_include_directories(invalid_call_argument_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(invalid_call_argument_test
@@ -7526,7 +7474,6 @@ target_include_directories(json_rewrite
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(json_rewrite
@@ -7554,7 +7501,6 @@ target_include_directories(json_rewrite_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(json_rewrite_test
@@ -7584,7 +7530,6 @@ target_include_directories(json_stream_error_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(json_stream_error_test
@@ -7614,7 +7559,6 @@ target_include_directories(json_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(json_test
@@ -7644,7 +7588,6 @@ target_include_directories(lame_client_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(lame_client_test
@@ -7674,7 +7617,6 @@ target_include_directories(lb_policies_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(lb_policies_test
@@ -7704,7 +7646,6 @@ target_include_directories(load_file_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(load_file_test
@@ -7734,7 +7675,6 @@ target_include_directories(memory_profile_client
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(memory_profile_client
@@ -7764,7 +7704,6 @@ target_include_directories(memory_profile_server
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(memory_profile_server
@@ -7795,7 +7734,6 @@ target_include_directories(memory_profile_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(memory_profile_test
@@ -7826,7 +7764,6 @@ target_include_directories(message_compress_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(message_compress_test
@@ -7856,7 +7793,6 @@ target_include_directories(minimal_stack_is_minimal_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(minimal_stack_is_minimal_test
@@ -7886,7 +7822,6 @@ target_include_directories(multiple_server_queues_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(multiple_server_queues_test
@@ -7916,7 +7851,6 @@ target_include_directories(murmur_hash_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(murmur_hash_test
@@ -7944,7 +7878,6 @@ target_include_directories(no_server_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(no_server_test
@@ -7974,7 +7907,6 @@ target_include_directories(num_external_connectivity_watchers_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(num_external_connectivity_watchers_test
@@ -8004,7 +7936,6 @@ target_include_directories(parse_address_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(parse_address_test
@@ -8034,7 +7965,6 @@ target_include_directories(percent_encoding_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(percent_encoding_test
@@ -8065,7 +7995,6 @@ target_include_directories(pollset_set_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(pollset_set_test
@@ -8097,7 +8026,6 @@ target_include_directories(resolve_address_posix_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(resolve_address_posix_test
@@ -8128,7 +8056,6 @@ target_include_directories(resolve_address_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(resolve_address_test
@@ -8158,7 +8085,6 @@ target_include_directories(resource_quota_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(resource_quota_test
@@ -8188,7 +8114,6 @@ target_include_directories(secure_channel_create_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(secure_channel_create_test
@@ -8218,7 +8143,6 @@ target_include_directories(secure_endpoint_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(secure_endpoint_test
@@ -8248,7 +8172,6 @@ target_include_directories(sequential_connectivity_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(sequential_connectivity_test
@@ -8278,7 +8201,6 @@ target_include_directories(server_chttp2_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(server_chttp2_test
@@ -8308,7 +8230,6 @@ target_include_directories(server_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(server_test
@@ -8338,7 +8259,6 @@ target_include_directories(slice_buffer_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(slice_buffer_test
@@ -8368,7 +8288,6 @@ target_include_directories(slice_hash_table_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(slice_hash_table_test
@@ -8398,7 +8317,6 @@ target_include_directories(slice_string_helpers_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(slice_string_helpers_test
@@ -8428,7 +8346,6 @@ target_include_directories(slice_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(slice_test
@@ -8458,7 +8375,6 @@ target_include_directories(sockaddr_resolver_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(sockaddr_resolver_test
@@ -8488,7 +8404,6 @@ target_include_directories(sockaddr_utils_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(sockaddr_utils_test
@@ -8519,7 +8434,6 @@ target_include_directories(socket_utils_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(socket_utils_test
@@ -8552,7 +8466,6 @@ target_include_directories(ssl_transport_security_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(ssl_transport_security_test
@@ -8582,7 +8495,6 @@ target_include_directories(status_conversion_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(status_conversion_test
@@ -8612,7 +8524,6 @@ target_include_directories(stream_compression_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(stream_compression_test
@@ -8642,7 +8553,6 @@ target_include_directories(stream_owned_slice_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(stream_owned_slice_test
@@ -8673,7 +8583,6 @@ target_include_directories(tcp_client_posix_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(tcp_client_posix_test
@@ -8704,7 +8613,6 @@ target_include_directories(tcp_client_uv_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(tcp_client_uv_test
@@ -8735,7 +8643,6 @@ target_include_directories(tcp_posix_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(tcp_posix_test
@@ -8767,7 +8674,6 @@ target_include_directories(tcp_server_posix_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(tcp_server_posix_test
@@ -8798,7 +8704,6 @@ target_include_directories(tcp_server_uv_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(tcp_server_uv_test
@@ -8828,7 +8733,6 @@ target_include_directories(time_averaged_stats_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(time_averaged_stats_test
@@ -8858,7 +8762,6 @@ target_include_directories(timeout_encoding_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(timeout_encoding_test
@@ -8888,7 +8791,6 @@ target_include_directories(timer_heap_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(timer_heap_test
@@ -8918,7 +8820,6 @@ target_include_directories(timer_list_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(timer_list_test
@@ -8948,7 +8849,6 @@ target_include_directories(transport_connectivity_state_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(transport_connectivity_state_test
@@ -8978,7 +8878,6 @@ target_include_directories(transport_metadata_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(transport_metadata_test
@@ -9009,7 +8908,6 @@ target_include_directories(transport_security_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(transport_security_test
@@ -9041,7 +8939,6 @@ target_include_directories(udp_server_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(udp_server_test
@@ -9072,7 +8969,6 @@ target_include_directories(uri_parser_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(uri_parser_test
@@ -9103,7 +8999,6 @@ target_include_directories(wakeup_fd_cv_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(wakeup_fd_cv_test
@@ -9136,7 +9031,6 @@ target_include_directories(alarm_cpp_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9177,7 +9071,6 @@ target_include_directories(async_end2end_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9218,7 +9111,6 @@ target_include_directories(auth_property_iterator_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9259,7 +9151,6 @@ target_include_directories(bdp_estimator_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9301,7 +9192,6 @@ target_include_directories(bm_arena
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9346,7 +9236,6 @@ target_include_directories(bm_call_create
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9391,7 +9280,6 @@ target_include_directories(bm_chttp2_hpack
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9436,7 +9324,6 @@ target_include_directories(bm_chttp2_transport
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9481,7 +9368,6 @@ target_include_directories(bm_closure
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9526,7 +9412,6 @@ target_include_directories(bm_cq
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9571,7 +9456,6 @@ target_include_directories(bm_cq_multiple_threads
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9616,7 +9500,6 @@ target_include_directories(bm_error
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9661,7 +9544,6 @@ target_include_directories(bm_fullstack_streaming_ping_pong
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9706,7 +9588,6 @@ target_include_directories(bm_fullstack_streaming_pump
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9751,7 +9632,6 @@ target_include_directories(bm_fullstack_trickle
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9797,7 +9677,6 @@ target_include_directories(bm_fullstack_unary_ping_pong
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9842,7 +9721,6 @@ target_include_directories(bm_metadata
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9887,7 +9765,6 @@ target_include_directories(bm_pollset
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9931,7 +9808,6 @@ target_include_directories(channel_arguments_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9969,7 +9845,6 @@ target_include_directories(channel_filter_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -9989,6 +9864,44 @@ 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 ${BORINGSSL_ROOT_DIR}/include
+ PRIVATE ${PROTOBUF_ROOT_DIR}/src
+ PRIVATE ${BENCHMARK_ROOT_DIR}/include
+ PRIVATE ${ZLIB_ROOT_DIR}
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
+ PRIVATE ${CARES_INCLUDE_DIR}
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ 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
@@ -10007,7 +9920,6 @@ target_include_directories(cli_call_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10030,6 +9942,53 @@ 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 ${BORINGSSL_ROOT_DIR}/include
+ PRIVATE ${PROTOBUF_ROOT_DIR}/src
+ PRIVATE ${BENCHMARK_ROOT_DIR}/include
+ PRIVATE ${ZLIB_ROOT_DIR}
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
+ PRIVATE ${CARES_INCLUDE_DIR}
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ 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
@@ -10050,7 +10009,6 @@ target_include_directories(client_crash_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10092,7 +10050,6 @@ target_include_directories(client_crash_test_server
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10133,7 +10090,6 @@ target_include_directories(client_lb_end2end_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10209,7 +10165,6 @@ target_include_directories(codegen_test_full
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10284,7 +10239,6 @@ target_include_directories(codegen_test_minimal
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10322,7 +10276,6 @@ target_include_directories(credentials_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10360,7 +10313,6 @@ target_include_directories(cxx_byte_buffer_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10400,7 +10352,6 @@ target_include_directories(cxx_slice_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10440,7 +10391,6 @@ target_include_directories(cxx_string_ref_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10477,7 +10427,6 @@ target_include_directories(cxx_time_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10517,7 +10466,6 @@ target_include_directories(end2end_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10565,7 +10513,6 @@ target_include_directories(error_details_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10602,7 +10549,6 @@ target_include_directories(filter_end2end_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10643,7 +10589,6 @@ target_include_directories(generic_end2end_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10691,7 +10636,6 @@ target_include_directories(golden_file_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10729,7 +10673,6 @@ target_include_directories(grpc_cli
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -10767,7 +10710,6 @@ target_include_directories(grpc_cpp_plugin
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -10804,7 +10746,6 @@ target_include_directories(grpc_csharp_plugin
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -10841,7 +10782,6 @@ target_include_directories(grpc_node_plugin
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -10878,7 +10818,6 @@ target_include_directories(grpc_objective_c_plugin
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -10915,7 +10854,6 @@ target_include_directories(grpc_php_plugin
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -10952,7 +10890,6 @@ target_include_directories(grpc_python_plugin
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -10989,7 +10926,6 @@ target_include_directories(grpc_ruby_plugin
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
@@ -11043,7 +10979,6 @@ target_include_directories(grpc_tool_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11094,7 +11029,6 @@ target_include_directories(grpclb_api_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11140,7 +11074,6 @@ target_include_directories(grpclb_end2end_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11188,7 +11121,6 @@ target_include_directories(grpclb_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11229,7 +11161,6 @@ target_include_directories(h2_ssl_cert_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11269,7 +11200,6 @@ target_include_directories(health_service_end2end_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11310,7 +11240,6 @@ target_include_directories(http2_client
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11352,7 +11281,6 @@ target_include_directories(hybrid_end2end_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11394,7 +11322,6 @@ target_include_directories(inproc_sync_unary_ping_pong_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11439,7 +11366,6 @@ target_include_directories(interop_client
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11484,7 +11410,6 @@ target_include_directories(interop_server
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11531,7 +11456,6 @@ target_include_directories(interop_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11573,7 +11497,6 @@ target_include_directories(json_run_localhost
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11616,7 +11539,6 @@ target_include_directories(memory_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11663,7 +11585,6 @@ target_include_directories(metrics_client
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11702,7 +11623,6 @@ target_include_directories(mock_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11743,7 +11663,6 @@ target_include_directories(noop-benchmark
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11779,7 +11698,6 @@ target_include_directories(proto_server_reflection_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11822,7 +11740,6 @@ target_include_directories(proto_utils_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11860,7 +11777,6 @@ target_include_directories(qps_interarrival_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11904,7 +11820,6 @@ target_include_directories(qps_json_driver
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11949,7 +11864,6 @@ target_include_directories(qps_openloop_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -11994,7 +11908,6 @@ target_include_directories(qps_worker
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12059,7 +11972,6 @@ target_include_directories(reconnect_interop_client
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12122,7 +12034,6 @@ target_include_directories(reconnect_interop_server
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12148,6 +12059,84 @@ target_link_libraries(reconnect_interop_server
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
+add_executable(ref_counted_ptr_test
+ test/core/support/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 ${BORINGSSL_ROOT_DIR}/include
+ PRIVATE ${PROTOBUF_ROOT_DIR}/src
+ PRIVATE ${BENCHMARK_ROOT_DIR}/include
+ PRIVATE ${ZLIB_ROOT_DIR}
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
+ PRIVATE ${CARES_INCLUDE_DIR}
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ 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/support/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 ${BORINGSSL_ROOT_DIR}/include
+ PRIVATE ${PROTOBUF_ROOT_DIR}/src
+ PRIVATE ${BENCHMARK_ROOT_DIR}/include
+ PRIVATE ${ZLIB_ROOT_DIR}
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
+ PRIVATE ${CARES_INCLUDE_DIR}
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+ 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
@@ -12166,7 +12155,6 @@ target_include_directories(secure_auth_context_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12208,7 +12196,6 @@ target_include_directories(secure_sync_unary_ping_pong_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12253,7 +12240,6 @@ target_include_directories(server_builder_plugin_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12308,7 +12294,6 @@ target_include_directories(server_builder_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12349,7 +12334,6 @@ target_include_directories(server_context_test_spouse_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12390,7 +12374,6 @@ target_include_directories(server_crash_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12432,7 +12415,6 @@ target_include_directories(server_crash_test_client
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12487,7 +12469,6 @@ target_include_directories(server_request_call_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12528,7 +12509,6 @@ target_include_directories(shutdown_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12569,7 +12549,6 @@ target_include_directories(stats_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12609,7 +12588,6 @@ target_include_directories(status_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12650,7 +12628,6 @@ target_include_directories(streaming_throughput_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12723,7 +12700,6 @@ target_include_directories(stress_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12765,7 +12741,6 @@ target_include_directories(thread_manager_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12804,7 +12779,6 @@ target_include_directories(thread_stress_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12845,7 +12819,6 @@ target_include_directories(transport_pid_controller_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12867,46 +12840,6 @@ target_link_libraries(transport_pid_controller_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
-
-add_executable(vector_test
- test/core/support/vector_test.cc
- third_party/googletest/googletest/src/gtest-all.cc
- third_party/googletest/googlemock/src/gmock-all.cc
-)
-
-
-target_include_directories(vector_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 ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
- 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(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(writes_per_rpc_test
@@ -12927,7 +12860,6 @@ target_include_directories(writes_per_rpc_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -12967,7 +12899,6 @@ target_include_directories(public_headers_must_be_c89
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(public_headers_must_be_c89
@@ -12995,7 +12926,6 @@ target_include_directories(badreq_bad_client_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(badreq_bad_client_test
@@ -13027,7 +12957,6 @@ target_include_directories(connection_prefix_bad_client_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(connection_prefix_bad_client_test
@@ -13059,7 +12988,6 @@ target_include_directories(head_of_line_blocking_bad_client_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(head_of_line_blocking_bad_client_test
@@ -13091,7 +13019,6 @@ target_include_directories(headers_bad_client_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(headers_bad_client_test
@@ -13123,7 +13050,6 @@ target_include_directories(initial_settings_frame_bad_client_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(initial_settings_frame_bad_client_test
@@ -13155,7 +13081,6 @@ target_include_directories(server_registered_method_bad_client_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(server_registered_method_bad_client_test
@@ -13187,7 +13112,6 @@ target_include_directories(simple_request_bad_client_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(simple_request_bad_client_test
@@ -13219,7 +13143,6 @@ target_include_directories(unknown_frame_bad_client_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(unknown_frame_bad_client_test
@@ -13251,7 +13174,6 @@ target_include_directories(window_overflow_bad_client_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(window_overflow_bad_client_test
@@ -13284,7 +13206,6 @@ target_include_directories(bad_ssl_cert_server
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(bad_ssl_cert_server
@@ -13317,7 +13238,6 @@ target_include_directories(bad_ssl_cert_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(bad_ssl_cert_test
@@ -13348,7 +13268,6 @@ target_include_directories(h2_census_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_census_test
@@ -13379,7 +13298,6 @@ target_include_directories(h2_compress_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_compress_test
@@ -13410,7 +13328,6 @@ target_include_directories(h2_fakesec_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_fakesec_test
@@ -13442,7 +13359,6 @@ target_include_directories(h2_fd_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_fd_test
@@ -13474,7 +13390,6 @@ target_include_directories(h2_full_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_full_test
@@ -13506,7 +13421,6 @@ target_include_directories(h2_full+pipe_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_full+pipe_test
@@ -13538,7 +13452,6 @@ target_include_directories(h2_full+trace_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_full+trace_test
@@ -13569,7 +13482,6 @@ target_include_directories(h2_full+workarounds_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_full+workarounds_test
@@ -13600,7 +13512,6 @@ target_include_directories(h2_http_proxy_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_http_proxy_test
@@ -13631,7 +13542,6 @@ target_include_directories(h2_load_reporting_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_load_reporting_test
@@ -13662,7 +13572,6 @@ target_include_directories(h2_oauth2_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_oauth2_test
@@ -13693,7 +13602,6 @@ target_include_directories(h2_proxy_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_proxy_test
@@ -13724,7 +13632,6 @@ target_include_directories(h2_sockpair_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_sockpair_test
@@ -13755,7 +13662,6 @@ target_include_directories(h2_sockpair+trace_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_sockpair+trace_test
@@ -13786,7 +13692,6 @@ target_include_directories(h2_sockpair_1byte_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_sockpair_1byte_test
@@ -13817,7 +13722,6 @@ target_include_directories(h2_ssl_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_ssl_test
@@ -13848,7 +13752,6 @@ target_include_directories(h2_ssl_proxy_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_ssl_proxy_test
@@ -13880,7 +13783,6 @@ target_include_directories(h2_uds_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_uds_test
@@ -13912,7 +13814,6 @@ target_include_directories(inproc_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(inproc_test
@@ -13943,7 +13844,6 @@ target_include_directories(h2_census_nosec_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_census_nosec_test
@@ -13974,7 +13874,6 @@ target_include_directories(h2_compress_nosec_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_compress_nosec_test
@@ -14006,7 +13905,6 @@ target_include_directories(h2_fd_nosec_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_fd_nosec_test
@@ -14038,7 +13936,6 @@ target_include_directories(h2_full_nosec_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_full_nosec_test
@@ -14070,7 +13967,6 @@ target_include_directories(h2_full+pipe_nosec_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_full+pipe_nosec_test
@@ -14102,7 +13998,6 @@ target_include_directories(h2_full+trace_nosec_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_full+trace_nosec_test
@@ -14133,7 +14028,6 @@ target_include_directories(h2_full+workarounds_nosec_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_full+workarounds_nosec_test
@@ -14164,7 +14058,6 @@ target_include_directories(h2_http_proxy_nosec_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_http_proxy_nosec_test
@@ -14195,7 +14088,6 @@ target_include_directories(h2_load_reporting_nosec_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_load_reporting_nosec_test
@@ -14226,7 +14118,6 @@ target_include_directories(h2_proxy_nosec_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_proxy_nosec_test
@@ -14257,7 +14148,6 @@ target_include_directories(h2_sockpair_nosec_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_sockpair_nosec_test
@@ -14288,7 +14178,6 @@ target_include_directories(h2_sockpair+trace_nosec_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_sockpair+trace_nosec_test
@@ -14319,7 +14208,6 @@ target_include_directories(h2_sockpair_1byte_nosec_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_sockpair_1byte_nosec_test
@@ -14351,7 +14239,6 @@ target_include_directories(h2_uds_nosec_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(h2_uds_nosec_test
@@ -14383,7 +14270,6 @@ target_include_directories(inproc_nosec_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(inproc_nosec_test
@@ -14417,7 +14303,6 @@ target_include_directories(resolver_component_test_unsecure
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -14461,7 +14346,6 @@ target_include_directories(resolver_component_test
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -14505,7 +14389,6 @@ target_include_directories(resolver_component_tests_runner_invoker_unsecure
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -14549,7 +14432,6 @@ target_include_directories(resolver_component_tests_runner_invoker
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
@@ -14591,7 +14473,6 @@ target_include_directories(api_fuzzer_one_entry
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(api_fuzzer_one_entry
@@ -14622,7 +14503,6 @@ target_include_directories(client_fuzzer_one_entry
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(client_fuzzer_one_entry
@@ -14653,7 +14533,6 @@ target_include_directories(hpack_parser_fuzzer_test_one_entry
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(hpack_parser_fuzzer_test_one_entry
@@ -14684,7 +14563,6 @@ target_include_directories(http_request_fuzzer_test_one_entry
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(http_request_fuzzer_test_one_entry
@@ -14715,7 +14593,6 @@ target_include_directories(http_response_fuzzer_test_one_entry
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(http_response_fuzzer_test_one_entry
@@ -14746,7 +14623,6 @@ target_include_directories(json_fuzzer_test_one_entry
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(json_fuzzer_test_one_entry
@@ -14777,7 +14653,6 @@ target_include_directories(nanopb_fuzzer_response_test_one_entry
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(nanopb_fuzzer_response_test_one_entry
@@ -14808,7 +14683,6 @@ target_include_directories(nanopb_fuzzer_serverlist_test_one_entry
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(nanopb_fuzzer_serverlist_test_one_entry
@@ -14839,7 +14713,6 @@ target_include_directories(percent_decode_fuzzer_one_entry
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(percent_decode_fuzzer_one_entry
@@ -14870,7 +14743,6 @@ target_include_directories(percent_encode_fuzzer_one_entry
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(percent_encode_fuzzer_one_entry
@@ -14901,7 +14773,6 @@ target_include_directories(server_fuzzer_one_entry
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(server_fuzzer_one_entry
@@ -14932,7 +14803,6 @@ target_include_directories(ssl_server_fuzzer_one_entry
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(ssl_server_fuzzer_one_entry
@@ -14963,7 +14833,6 @@ target_include_directories(uri_fuzzer_test_one_entry
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp
)
target_link_libraries(uri_fuzzer_test_one_entry
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e9c5fe2014..af46246822 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -7,7 +7,7 @@ If you are new to github, please start by reading [Pull Request howto](https://h
## 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
diff --git a/INSTALL.md b/INSTALL.md
index 15725bd188..430fd71989 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -95,37 +95,50 @@ on experience with the tools involved.
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
-
-#### 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.
+- 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).
```
-> md .build
-> cd .build
-> call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x64
-> cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release
-> cmake --build .
+> @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"
```
-#### cmake: Using Visual Studio 2015 (can only build with OPENSSL_NO_ASM).
+#### 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
> cmake .. -G "Visual Studio 14 2015" -DCMAKE_BUILD_TYPE=Release
> cmake --build .
```
+#### 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
+> call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x64
+> cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release
+> cmake --build .
+> ninja
+```
+
### msys2 (with mingw)
The Makefile (and source code) should support msys2's mingw32 and mingw64
diff --git a/Makefile b/Makefile
index 1e3418e410..9dfd2a8ae2 100644
--- a/Makefile
+++ b/Makefile
@@ -114,7 +114,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
@@ -327,7 +327,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 -Ithird_party/abseil-cpp
+CPPFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter -DOSATOMIC_USE_INLINED=1
+COREFLAGS += -fno-rtti -fno-exceptions
LDFLAGS += -g
CPPFLAGS += $(CPPFLAGS_$(CONFIG))
@@ -411,8 +412,8 @@ Q = @
endif
CORE_VERSION = 5.0.0-dev
-CPP_VERSION = 1.8.0-dev
-CSHARP_VERSION = 1.8.0-dev
+CPP_VERSION = 1.9.0-dev
+CSHARP_VERSION = 1.9.0-dev
CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
@@ -987,12 +988,11 @@ gpr_avl_test: $(BINDIR)/$(CONFIG)/gpr_avl_test
gpr_cmdline_test: $(BINDIR)/$(CONFIG)/gpr_cmdline_test
gpr_cpu_test: $(BINDIR)/$(CONFIG)/gpr_cpu_test
gpr_env_test: $(BINDIR)/$(CONFIG)/gpr_env_test
-gpr_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
@@ -1019,6 +1019,8 @@ 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
@@ -1112,7 +1114,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
@@ -1161,6 +1165,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
@@ -1177,7 +1183,6 @@ 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
-vector_test: $(BINDIR)/$(CONFIG)/vector_test
writes_per_rpc_test: $(BINDIR)/$(CONFIG)/writes_per_rpc_test
public_headers_must_be_c89: $(BINDIR)/$(CONFIG)/public_headers_must_be_c89
boringssl_aes_test: $(BINDIR)/$(CONFIG)/boringssl_aes_test
@@ -1379,12 +1384,11 @@ buildtests_c: privatelibs_c \
$(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 \
@@ -1408,6 +1412,8 @@ buildtests_c: privatelibs_c \
$(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 \
@@ -1552,7 +1558,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 \
@@ -1594,6 +1602,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 \
@@ -1610,7 +1620,6 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/thread_manager_test \
$(BINDIR)/$(CONFIG)/thread_stress_test \
$(BINDIR)/$(CONFIG)/transport_pid_controller_test \
- $(BINDIR)/$(CONFIG)/vector_test \
$(BINDIR)/$(CONFIG)/writes_per_rpc_test \
$(BINDIR)/$(CONFIG)/boringssl_aes_test \
$(BINDIR)/$(CONFIG)/boringssl_asn1_test \
@@ -1677,7 +1686,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 \
@@ -1719,6 +1730,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 \
@@ -1735,7 +1748,6 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/thread_manager_test \
$(BINDIR)/$(CONFIG)/thread_stress_test \
$(BINDIR)/$(CONFIG)/transport_pid_controller_test \
- $(BINDIR)/$(CONFIG)/vector_test \
$(BINDIR)/$(CONFIG)/writes_per_rpc_test \
$(BINDIR)/$(CONFIG)/resolver_component_test_unsecure \
$(BINDIR)/$(CONFIG)/resolver_component_test \
@@ -1820,18 +1832,16 @@ test_c: buildtests_c
$(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"
@@ -1876,6 +1886,10 @@ test_c: buildtests_c
$(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"
@@ -2058,8 +2072,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"
@@ -2116,6 +2134,10 @@ test_cxx: buildtests_cxx
$(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"
@@ -2144,8 +2166,6 @@ test_cxx: buildtests_cxx
$(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 vector_test"
- $(Q) $(BINDIR)/$(CONFIG)/vector_test || ( echo test vector_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"
@@ -2499,12 +2519,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) $<
@@ -2570,6 +2590,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 $@`
@@ -2803,7 +2833,7 @@ LIBGPR_SRC = \
src/core/lib/support/env_linux.cc \
src/core/lib/support/env_posix.cc \
src/core/lib/support/env_windows.cc \
- src/core/lib/support/histogram.cc \
+ src/core/lib/support/fork.cc \
src/core/lib/support/host_port.cc \
src/core/lib/support/log.cc \
src/core/lib/support/log_android.cc \
@@ -2812,7 +2842,6 @@ LIBGPR_SRC = \
src/core/lib/support/log_windows.cc \
src/core/lib/support/mpscq.cc \
src/core/lib/support/murmur_hash.cc \
- src/core/lib/support/stack_lockfree.cc \
src/core/lib/support/string.cc \
src/core/lib/support/string_posix.cc \
src/core/lib/support/string_util_windows.cc \
@@ -2844,7 +2873,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 \
@@ -2867,6 +2895,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 \
@@ -2959,7 +2988,6 @@ LIBGRPC_SRC = \
src/core/lib/http/httpcli.cc \
src/core/lib/http/parser.cc \
src/core/lib/iomgr/call_combiner.cc \
- src/core/lib/iomgr/closure.cc \
src/core/lib/iomgr/combiner.cc \
src/core/lib/iomgr/endpoint.cc \
src/core/lib/iomgr/endpoint_pair_posix.cc \
@@ -2974,6 +3002,8 @@ LIBGRPC_SRC = \
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 \
@@ -3204,6 +3234,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 \
@@ -3216,6 +3247,7 @@ PUBLIC_HEADERS_C += \
include/grpc/byte_buffer.h \
include/grpc/byte_buffer_reader.h \
include/grpc/compression.h \
+ include/grpc/fork.h \
include/grpc/grpc.h \
include/grpc/grpc_posix.h \
include/grpc/grpc_security_constants.h \
@@ -3299,7 +3331,6 @@ LIBGRPC_CRONET_SRC = \
src/core/lib/http/httpcli.cc \
src/core/lib/http/parser.cc \
src/core/lib/iomgr/call_combiner.cc \
- src/core/lib/iomgr/closure.cc \
src/core/lib/iomgr/combiner.cc \
src/core/lib/iomgr/endpoint.cc \
src/core/lib/iomgr/endpoint_pair_posix.cc \
@@ -3314,6 +3345,8 @@ LIBGRPC_CRONET_SRC = \
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 \
@@ -3515,6 +3548,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 \
@@ -3592,13 +3626,16 @@ LIBGRPC_TEST_UTIL_SRC = \
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 \
@@ -3619,7 +3656,6 @@ LIBGRPC_TEST_UTIL_SRC = \
src/core/lib/http/httpcli.cc \
src/core/lib/http/parser.cc \
src/core/lib/iomgr/call_combiner.cc \
- src/core/lib/iomgr/closure.cc \
src/core/lib/iomgr/combiner.cc \
src/core/lib/iomgr/endpoint.cc \
src/core/lib/iomgr/endpoint_pair_posix.cc \
@@ -3634,6 +3670,8 @@ LIBGRPC_TEST_UTIL_SRC = \
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 \
@@ -3797,6 +3835,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 \
@@ -3848,13 +3887,16 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \
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 \
@@ -3875,7 +3917,6 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \
src/core/lib/http/httpcli.cc \
src/core/lib/http/parser.cc \
src/core/lib/iomgr/call_combiner.cc \
- src/core/lib/iomgr/closure.cc \
src/core/lib/iomgr/combiner.cc \
src/core/lib/iomgr/endpoint.cc \
src/core/lib/iomgr/endpoint_pair_posix.cc \
@@ -3890,6 +3931,8 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \
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 \
@@ -4053,6 +4096,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 \
@@ -4104,7 +4148,6 @@ LIBGRPC_UNSECURE_SRC = \
src/core/lib/http/httpcli.cc \
src/core/lib/http/parser.cc \
src/core/lib/iomgr/call_combiner.cc \
- src/core/lib/iomgr/closure.cc \
src/core/lib/iomgr/combiner.cc \
src/core/lib/iomgr/endpoint.cc \
src/core/lib/iomgr/endpoint_pair_posix.cc \
@@ -4119,6 +4162,8 @@ LIBGRPC_UNSECURE_SRC = \
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 \
@@ -4317,6 +4362,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 \
@@ -4328,6 +4374,7 @@ PUBLIC_HEADERS_C += \
include/grpc/byte_buffer.h \
include/grpc/byte_buffer_reader.h \
include/grpc/compression.h \
+ include/grpc/fork.h \
include/grpc/grpc.h \
include/grpc/grpc_posix.h \
include/grpc/grpc_security_constants.h \
@@ -4551,7 +4598,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 \
@@ -4574,6 +4620,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 \
@@ -4585,6 +4632,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc/byte_buffer.h \
include/grpc/byte_buffer_reader.h \
include/grpc/compression.h \
+ include/grpc/fork.h \
include/grpc/grpc.h \
include/grpc/grpc_posix.h \
include/grpc/grpc_security_constants.h \
@@ -4833,7 +4881,6 @@ LIBGRPC++_CRONET_SRC = \
src/core/lib/http/httpcli.cc \
src/core/lib/http/parser.cc \
src/core/lib/iomgr/call_combiner.cc \
- src/core/lib/iomgr/closure.cc \
src/core/lib/iomgr/combiner.cc \
src/core/lib/iomgr/endpoint.cc \
src/core/lib/iomgr/endpoint_pair_posix.cc \
@@ -4848,6 +4895,8 @@ LIBGRPC++_CRONET_SRC = \
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 \
@@ -5036,7 +5085,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 \
@@ -5059,6 +5107,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 \
@@ -5070,6 +5119,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc/byte_buffer.h \
include/grpc/byte_buffer_reader.h \
include/grpc/compression.h \
+ include/grpc/fork.h \
include/grpc/grpc.h \
include/grpc/grpc_posix.h \
include/grpc/grpc_security_constants.h \
@@ -5484,6 +5534,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 \
@@ -5601,6 +5652,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 \
@@ -5754,7 +5806,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 \
@@ -5777,6 +5828,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,6 +5840,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc/byte_buffer.h \
include/grpc/byte_buffer_reader.h \
include/grpc/compression.h \
+ include/grpc/fork.h \
include/grpc/grpc.h \
include/grpc/grpc_posix.h \
include/grpc/grpc_security_constants.h \
@@ -10046,38 +10099,6 @@ endif
endif
-GPR_HISTOGRAM_TEST_SRC = \
- test/core/support/histogram_test.cc \
-
-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.cc \
@@ -10142,98 +10163,98 @@ endif
endif
-GPR_MPSCQ_TEST_SRC = \
- test/core/support/mpscq_test.cc \
+GPR_MANUAL_CONSTRUCTOR_TEST_SRC = \
+ test/core/support/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/support/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.cc \
+GPR_MPSCQ_TEST_SRC = \
+ test/core/support/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/support/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.cc \
+GPR_SPINLOCK_TEST_SRC = \
+ test/core/support/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/support/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
@@ -11040,6 +11061,7 @@ endif
HANDSHAKE_SERVER_SRC = \
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)
@@ -11061,6 +11083,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)
@@ -11070,6 +11094,73 @@ 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.cc \
@@ -14283,6 +14374,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 \
@@ -14326,6 +14460,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 \
@@ -16358,6 +16539,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/support/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/support/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/support/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/support/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 \
@@ -17085,49 +17352,6 @@ endif
endif
-VECTOR_TEST_SRC = \
- test/core/support/vector_test.cc \
-
-VECTOR_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(VECTOR_TEST_SRC))))
-ifeq ($(NO_SECURE),true)
-
-# You can't build secure targets if you don't have OpenSSL.
-
-$(BINDIR)/$(CONFIG)/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)/vector_test: protobuf_dep_error
-
-else
-
-$(BINDIR)/$(CONFIG)/vector_test: $(PROTOBUF_DEP) $(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) $(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)/vector_test
-
-endif
-
-endif
-
-$(OBJDIR)/$(CONFIG)/test/core/support/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_vector_test: $(VECTOR_TEST_OBJS:.o=.dep)
-
-ifneq ($(NO_SECURE),true)
-ifneq ($(NO_DEPS),true)
--include $(VECTOR_TEST_OBJS:.o=.dep)
-endif
-endif
-
-
WRITES_PER_RPC_TEST_SRC = \
test/cpp/performance/writes_per_rpc_test.cc \
diff --git a/README.md b/README.md
index 61479f34aa..048614a205 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,6 @@ Libraries in different languages may be in different states of development. We a
| 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 |
@@ -38,7 +37,8 @@ Libraries in different languages may be in different states of development. We a
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/WORKSPACE b/WORKSPACE
index 5f87d68a2f..bf09aa7cc9 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -10,7 +10,7 @@ bind(
bind(
name = "zlib",
- actual = "@submodule_zlib//:z",
+ actual = "@com_github_madler_zlib//:z",
)
bind(
@@ -35,22 +35,22 @@ bind(
bind(
name = "cares",
- actual = "@submodule_cares//:ares",
+ actual = "@com_github_cares_cares//:ares",
)
bind(
name = "gtest",
- actual = "@submodule_gtest//:gtest",
+ actual = "@com_github_google_googletest//:gtest",
)
bind(
name = "gmock",
- actual = "@submodule_gtest//:gmock",
+ actual = "@com_github_google_googletest//:gmock",
)
bind(
name = "benchmark",
- actual = "@submodule_benchmark//:benchmark",
+ actual = "@com_github_google_benchmark//:benchmark",
)
bind(
@@ -58,47 +58,70 @@ bind(
actual = "@com_github_gflags_gflags//:gflags",
)
-local_repository(
+http_archive(
name = "boringssl",
- path = "third_party/boringssl-with-bazel",
+ # on the master-with-bazel branch
+ url = "https://boringssl.googlesource.com/boringssl/+archive/886e7d75368e3f4fab3f4d0d3584e4abfc557755.tar.gz",
)
-new_local_repository(
- name = "submodule_zlib",
+new_http_archive(
+ name = "com_github_madler_zlib",
build_file = "third_party/zlib.BUILD",
- path = "third_party/zlib",
+ strip_prefix = "zlib-cacf7f1d4e3d44d871b605da3b647f07d718623f",
+ url = "https://github.com/madler/zlib/archive/cacf7f1d4e3d44d871b605da3b647f07d718623f.tar.gz",
)
-new_local_repository(
+http_archive(
name = "com_google_protobuf",
- build_file = "third_party/protobuf/BUILD",
- path = "third_party/protobuf",
+ strip_prefix = "protobuf-2761122b810fe8861004ae785cc3ab39f384d342",
+ url = "https://github.com/google/protobuf/archive/2761122b810fe8861004ae785cc3ab39f384d342.tar.gz",
)
-new_local_repository(
- name = "submodule_gtest",
+new_http_archive(
+ name = "com_github_google_googletest",
build_file = "third_party/gtest.BUILD",
- path = "third_party/googletest",
+ strip_prefix = "googletest-ec44c6c1675c25b9827aacd08c02433cccde7780",
+ url = "https://github.com/google/googletest/archive/ec44c6c1675c25b9827aacd08c02433cccde7780.tar.gz",
)
-local_repository(
+http_archive(
name = "com_github_gflags_gflags",
- path = "third_party/gflags",
+ strip_prefix = "gflags-30dbc81fb5ffdc98ea9b14b1918bfe4e8779b26e",
+ url = "https://github.com/gflags/gflags/archive/30dbc81fb5ffdc98ea9b14b1918bfe4e8779b26e.tar.gz",
)
-new_local_repository(
- name = "submodule_benchmark",
- path = "third_party/benchmark",
+new_http_archive(
+ name = "com_github_google_benchmark",
build_file = "third_party/benchmark.BUILD",
+ strip_prefix = "benchmark-5b7683f49e1e9223cf9927b24f6fd3d6bd82e3f8",
+ url = "https://github.com/google/benchmark/archive/5b7683f49e1e9223cf9927b24f6fd3d6bd82e3f8.tar.gz",
)
new_local_repository(
- name = "submodule_cares",
+ name = "cares_local_files",
+ build_file = "third_party/cares/cares_local_files.BUILD",
path = "third_party/cares",
+)
+
+new_http_archive(
+ name = "com_github_cares_cares",
build_file = "third_party/cares/cares.BUILD",
+ strip_prefix = "c-ares-3be1924221e1326df520f8498d704a5c4c8d0cce",
+ url = "https://github.com/c-ares/c-ares/archive/3be1924221e1326df520f8498d704a5c4c8d0cce.tar.gz",
)
-local_repository(
+http_archive(
name = "com_google_absl",
- path = "third_party/abseil-cpp",
+ strip_prefix = "abseil-cpp-cc4bed2d74f7c8717e31f9579214ab52a9c9c610",
+ url = "https://github.com/abseil/abseil-cpp/archive/cc4bed2d74f7c8717e31f9579214ab52a9c9c610.tar.gz",
+)
+
+http_archive(
+ name = "bazel_toolchains",
+ urls = [
+ "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/af4681c3d19f063f090222ec3d04108c4e0ca255.tar.gz",
+ "https://github.com/bazelbuild/bazel-toolchains/archive/af4681c3d19f063f090222ec3d04108c4e0ca255.tar.gz",
+ ],
+ strip_prefix = "bazel-toolchains-af4681c3d19f063f090222ec3d04108c4e0ca255",
+ sha256 = "d58bb2d6c8603f600d522b6104d6192a65339aa26cbba9f11ff5c4b36dedb928",
)
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..2ef8544502 100644
--- a/bazel/grpc_build_system.bzl
+++ b/bazel/grpc_build_system.bzl
@@ -23,6 +23,9 @@
# 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 grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [],
external_deps = [], deps = [], standalone = False,
language = "C++", testonly = False, visibility = None,
@@ -33,6 +36,10 @@ def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [],
native.cc_library(
name = name,
srcs = srcs,
+ defines = select({"//:grpc_no_ares": ["GRPC_ARES=0"],
+ "//conditions:default": [],}) +
+ select({"//:remote_execution": ["GRPC_PORT_ISOLATED_RUNTIME=1"],
+ "//conditions:default": [],}),
hdrs = hdrs + public_hdrs,
deps = deps + ["//external:" + dep for dep in external_deps],
copts = copts,
@@ -66,19 +73,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 + ["//external:" + dep for dep in external_deps],
+ 'copts': copts,
+ 'linkopts': ["-pthread"],
+ }
+ if uses_polling:
+ native.cc_binary(testonly=True, **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
+ ],
+ )
+ else:
+ native.cc_test(**args)
def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], data = [], language = "C++", testonly = False, linkshared = False, linkopts = []):
copts = []
diff --git a/binding.gyp b/binding.gyp
new file mode 100644
index 0000000000..cb0a2fbab1
--- /dev/null
+++ b/binding.gyp
@@ -0,0 +1,994 @@
+# 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/fork.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/fork_posix.c',
+ 'src/core/lib/iomgr/fork_windows.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 cd6486ea29..6158b466ea 100644
--- a/build.yaml
+++ b/build.yaml
@@ -13,8 +13,8 @@ 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: generous
- version: 1.8.0-dev
+ g_stands_for: glossy
+ version: 1.9.0-dev
filegroups:
- name: census
public_headers:
@@ -40,7 +40,7 @@ filegroups:
- src/core/lib/support/env_linux.cc
- src/core/lib/support/env_posix.cc
- src/core/lib/support/env_windows.cc
- - src/core/lib/support/histogram.cc
+ - src/core/lib/support/fork.cc
- src/core/lib/support/host_port.cc
- src/core/lib/support/log.cc
- src/core/lib/support/log_android.cc
@@ -49,7 +49,6 @@ filegroups:
- src/core/lib/support/log_windows.cc
- src/core/lib/support/mpscq.cc
- src/core/lib/support/murmur_hash.cc
- - src/core/lib/support/stack_lockfree.cc
- src/core/lib/support/string.cc
- src/core/lib/support/string_posix.cc
- src/core/lib/support/string_util_windows.cc
@@ -83,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
@@ -104,19 +102,21 @@ filegroups:
- include/grpc/support/useful.h
headers:
- src/core/lib/profiling/timers.h
+ - src/core/lib/support/abstract.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/env.h
+ - src/core/lib/support/fork.h
- src/core/lib/support/manual_constructor.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/thd_internal.h
- src/core/lib/support/time_precise.h
- src/core/lib/support/tmpfile.h
uses:
@@ -127,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
@@ -168,7 +169,6 @@ filegroups:
- src/core/lib/http/httpcli.cc
- src/core/lib/http/parser.cc
- src/core/lib/iomgr/call_combiner.cc
- - src/core/lib/iomgr/closure.cc
- src/core/lib/iomgr/combiner.cc
- src/core/lib/iomgr/endpoint.cc
- src/core/lib/iomgr/endpoint_pair_posix.cc
@@ -183,6 +183,8 @@ filegroups:
- 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
@@ -293,6 +295,7 @@ filegroups:
- include/grpc/byte_buffer.h
- include/grpc/byte_buffer_reader.h
- include/grpc/compression.h
+ - include/grpc/fork.h
- include/grpc/grpc.h
- include/grpc/grpc_posix.h
- include/grpc/grpc_security_constants.h
@@ -393,7 +396,9 @@ filegroups:
- 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/vector.h
+ - src/core/lib/support/debug_location.h
+ - src/core/lib/support/ref_counted.h
+ - src/core/lib/support/ref_counted_ptr.h
- src/core/lib/surface/alarm_internal.h
- src/core/lib/surface/api_trace.h
- src/core/lib/surface/call.h
@@ -707,6 +712,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
@@ -714,6 +720,7 @@ 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.cc
@@ -723,13 +730,16 @@ filegroups:
- 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
@@ -2187,29 +2197,30 @@ targets:
- gpr_test_util
- gpr
uses_polling: false
-- name: gpr_histogram_test
+- name: gpr_host_port_test
build: test
language: c
src:
- - test/core/support/histogram_test.cc
+ - test/core/support/host_port_test.cc
deps:
- gpr_test_util
- gpr
uses_polling: false
-- name: gpr_host_port_test
+- name: gpr_log_test
build: test
language: c
src:
- - test/core/support/host_port_test.cc
+ - test/core/support/log_test.cc
deps:
- gpr_test_util
- gpr
uses_polling: false
-- name: gpr_log_test
+- name: gpr_manual_constructor_test
+ cpu_cost: 3
build: test
language: c
src:
- - test/core/support/log_test.cc
+ - test/core/support/manual_constructor_test.cc
deps:
- gpr_test_util
- gpr
@@ -2234,16 +2245,6 @@ targets:
- gpr_test_util
- gpr
uses_polling: false
-- name: gpr_stack_lockfree_test
- cpu_cost: 7
- build: test
- language: c
- src:
- - test/core/support/stack_lockfree_test.cc
- deps:
- - gpr_test_util
- - gpr
- uses_polling: false
- name: gpr_string_test
build: test
language: c
@@ -2511,8 +2512,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/readahead_handshaker_server_ssl.cc
+ - test/core/handshake/server_ssl_common.cc
deps:
- grpc_test_util
- grpc
@@ -2523,6 +2545,15 @@ 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
@@ -3793,6 +3824,18 @@ targets:
- 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 +3850,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
@@ -4494,6 +4551,34 @@ targets:
- gpr_test_util
- gpr
- grpc++_test_config
+- name: ref_counted_ptr_test
+ gtest: true
+ build: test
+ language: c++
+ src:
+ - test/core/support/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/support/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
@@ -4735,20 +4820,6 @@ targets:
- grpc
- gpr_test_util
- gpr
-- name: vector_test
- gtest: true
- build: test
- language: c++
- src:
- - test/core/support/vector_test.cc
- deps:
- - grpc_test_util
- - grpc++
- - grpc
- - gpr_test_util
- - gpr
- uses:
- - grpc++_test
- name: writes_per_rpc_test
gtest: true
cpu_cost: 0.5
@@ -4868,8 +4939,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++
@@ -4877,6 +4948,8 @@ 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
@@ -4929,8 +5002,8 @@ defaults:
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
- -Ithird_party/abseil-cpp
LDFLAGS: -g
zlib:
CFLAGS: -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration
diff --git a/config.m4 b/config.m4
index 5cb46cf054..c026b83f35 100644
--- a/config.m4
+++ b/config.m4
@@ -53,7 +53,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/support/env_linux.cc \
src/core/lib/support/env_posix.cc \
src/core/lib/support/env_windows.cc \
- src/core/lib/support/histogram.cc \
+ src/core/lib/support/fork.cc \
src/core/lib/support/host_port.cc \
src/core/lib/support/log.cc \
src/core/lib/support/log_android.cc \
@@ -62,7 +62,6 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/support/log_windows.cc \
src/core/lib/support/mpscq.cc \
src/core/lib/support/murmur_hash.cc \
- src/core/lib/support/stack_lockfree.cc \
src/core/lib/support/string.cc \
src/core/lib/support/string_posix.cc \
src/core/lib/support/string_util_windows.cc \
@@ -104,7 +103,6 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/http/httpcli.cc \
src/core/lib/http/parser.cc \
src/core/lib/iomgr/call_combiner.cc \
- src/core/lib/iomgr/closure.cc \
src/core/lib/iomgr/combiner.cc \
src/core/lib/iomgr/endpoint.cc \
src/core/lib/iomgr/endpoint_pair_posix.cc \
@@ -119,6 +117,8 @@ if test "$PHP_GRPC" != "no"; then
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 \
diff --git a/config.w32 b/config.w32
index 0fc5066b29..cd3a16a465 100644
--- a/config.w32
+++ b/config.w32
@@ -30,7 +30,7 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\support\\env_linux.cc " +
"src\\core\\lib\\support\\env_posix.cc " +
"src\\core\\lib\\support\\env_windows.cc " +
- "src\\core\\lib\\support\\histogram.cc " +
+ "src\\core\\lib\\support\\fork.cc " +
"src\\core\\lib\\support\\host_port.cc " +
"src\\core\\lib\\support\\log.cc " +
"src\\core\\lib\\support\\log_android.cc " +
@@ -39,7 +39,6 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\support\\log_windows.cc " +
"src\\core\\lib\\support\\mpscq.cc " +
"src\\core\\lib\\support\\murmur_hash.cc " +
- "src\\core\\lib\\support\\stack_lockfree.cc " +
"src\\core\\lib\\support\\string.cc " +
"src\\core\\lib\\support\\string_posix.cc " +
"src\\core\\lib\\support\\string_util_windows.cc " +
@@ -81,7 +80,6 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\http\\httpcli.cc " +
"src\\core\\lib\\http\\parser.cc " +
"src\\core\\lib\\iomgr\\call_combiner.cc " +
- "src\\core\\lib\\iomgr\\closure.cc " +
"src\\core\\lib\\iomgr\\combiner.cc " +
"src\\core\\lib\\iomgr\\endpoint.cc " +
"src\\core\\lib\\iomgr\\endpoint_pair_posix.cc " +
@@ -96,6 +94,8 @@ if (PHP_GRPC != "no") {
"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 " +
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/g_stands_for.md b/doc/g_stands_for.md
index 4e2ca33276..edc6dc1e79 100644
--- a/doc/g_stands_for.md
+++ b/doc/g_stands_for.md
@@ -12,3 +12,4 @@ future), and the corresponding version numbers that used them:
- 1.6 'g' stands for 'garcia'
- 1.7 'g' stands for 'gambit'
- 1.8 'g' stands for 'generous'
+- 1.9 'g' stands for 'glossy'
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..49684a13b0 100644
--- a/examples/cpp/helloworld/CMakeLists.txt
+++ b/examples/cpp/helloworld/CMakeLists.txt
@@ -6,13 +6,29 @@ 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}")
+if(Protobuf_FOUND)
+ # Protobuf_FOUND is set for package type "CONFIG"
+ set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
+ set(_PROTOBUF_PROTOC protobuf::protoc)
+elseif(PROTOBUF_FOUND)
+ # PROTOBUF_FOUND is set for package type "MODULE"
+ set(_PROTOBUF_LIBPROTOBUF ${PROTOBUF_LIBRARIES})
+ set(_PROTOBUF_PROTOC ${PROTOBUF_PROTOC_EXECUTABLE})
+ include_directories(${PROTOBUF_INCLUDE_DIRS})
+else()
+ message(WARNING "Failed to locate libprotobuf and protoc!")
+endif()
+
# gRPC
find_package(gRPC CONFIG REQUIRED)
message(STATUS "Using gRPC ${gRPC_VERSION}")
@@ -31,7 +47,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 +64,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/python/route_guide/route_guide_client.py b/examples/python/route_guide/route_guide_client.py
index 653f0d02c6..a0e32fb6f5 100644
--- a/examples/python/route_guide/route_guide_client.py
+++ b/examples/python/route_guide/route_guide_client.py
@@ -17,7 +17,6 @@
from __future__ import print_function
import random
-import time
import grpc
@@ -66,7 +65,6 @@ def generate_route(feature_list):
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(stub):
@@ -91,7 +89,6 @@ def generate_messages():
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(stub):
diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec
index 01b8d65977..bc4b318cb2 100644
--- a/gRPC-Core.podspec
+++ b/gRPC-Core.podspec
@@ -22,7 +22,7 @@
Pod::Spec.new do |s|
s.name = 'gRPC-Core'
- version = '1.8.0-dev'
+ version = '1.9.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
@@ -85,6 +89,7 @@ Pod::Spec.new do |s|
'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'
@@ -112,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',
@@ -135,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',
@@ -156,6 +161,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',
@@ -168,6 +174,7 @@ Pod::Spec.new do |s|
'include/grpc/byte_buffer.h',
'include/grpc/byte_buffer_reader.h',
'include/grpc/compression.h',
+ 'include/grpc/fork.h',
'include/grpc/grpc.h',
'include/grpc/grpc_posix.h',
'include/grpc/grpc_security_constants.h',
@@ -187,19 +194,21 @@ Pod::Spec.new do |s|
# 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/abstract.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/env.h',
+ 'src/core/lib/support/fork.h',
'src/core/lib/support/manual_constructor.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/thd_internal.h',
'src/core/lib/support/time_precise.h',
'src/core/lib/support/tmpfile.h',
'src/core/lib/profiling/basic_timers.cc',
@@ -216,7 +225,7 @@ Pod::Spec.new do |s|
'src/core/lib/support/env_linux.cc',
'src/core/lib/support/env_posix.cc',
'src/core/lib/support/env_windows.cc',
- 'src/core/lib/support/histogram.cc',
+ 'src/core/lib/support/fork.cc',
'src/core/lib/support/host_port.cc',
'src/core/lib/support/log.cc',
'src/core/lib/support/log_android.cc',
@@ -225,7 +234,6 @@ Pod::Spec.new do |s|
'src/core/lib/support/log_windows.cc',
'src/core/lib/support/mpscq.cc',
'src/core/lib/support/murmur_hash.cc',
- 'src/core/lib/support/stack_lockfree.cc',
'src/core/lib/support/string.cc',
'src/core/lib/support/string_posix.cc',
'src/core/lib/support/string_util_windows.cc',
@@ -412,7 +420,9 @@ Pod::Spec.new do |s|
'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/vector.h',
+ 'src/core/lib/support/debug_location.h',
+ 'src/core/lib/support/ref_counted.h',
+ 'src/core/lib/support/ref_counted_ptr.h',
'src/core/lib/surface/alarm_internal.h',
'src/core/lib/surface/api_trace.h',
'src/core/lib/surface/call.h',
@@ -478,7 +488,6 @@ Pod::Spec.new do |s|
'src/core/lib/http/httpcli.cc',
'src/core/lib/http/parser.cc',
'src/core/lib/iomgr/call_combiner.cc',
- 'src/core/lib/iomgr/closure.cc',
'src/core/lib/iomgr/combiner.cc',
'src/core/lib/iomgr/endpoint.cc',
'src/core/lib/iomgr/endpoint_pair_posix.cc',
@@ -493,6 +502,8 @@ Pod::Spec.new do |s|
'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',
@@ -707,19 +718,21 @@ Pod::Spec.new do |s|
'src/core/plugin_registry/grpc_plugin_registry.cc'
ss.private_header_files = 'src/core/lib/profiling/timers.h',
+ 'src/core/lib/support/abstract.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/env.h',
+ 'src/core/lib/support/fork.h',
'src/core/lib/support/manual_constructor.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/thd_internal.h',
'src/core/lib/support/time_precise.h',
'src/core/lib/support/tmpfile.h',
'src/core/ext/transport/chttp2/transport/bin_decoder.h',
@@ -887,7 +900,9 @@ Pod::Spec.new do |s|
'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/vector.h',
+ 'src/core/lib/support/debug_location.h',
+ 'src/core/lib/support/ref_counted.h',
+ 'src/core/lib/support/ref_counted_ptr.h',
'src/core/lib/surface/alarm_internal.h',
'src/core/lib/surface/api_trace.h',
'src/core/lib/surface/call.h',
diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec
index db1e8db06c..cb1c5480da 100644
--- a/gRPC-ProtoRPC.podspec
+++ b/gRPC-ProtoRPC.podspec
@@ -21,7 +21,7 @@
Pod::Spec.new do |s|
s.name = 'gRPC-ProtoRPC'
- version = '1.8.0-dev'
+ version = '1.9.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 3689779039..0f9abb6f4b 100644
--- a/gRPC-RxLibrary.podspec
+++ b/gRPC-RxLibrary.podspec
@@ -21,7 +21,7 @@
Pod::Spec.new do |s|
s.name = 'gRPC-RxLibrary'
- version = '1.8.0-dev'
+ version = '1.9.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 4c6cd3535f..1f3a0a9950 100644
--- a/gRPC.podspec
+++ b/gRPC.podspec
@@ -20,7 +20,7 @@
Pod::Spec.new do |s|
s.name = 'gRPC'
- version = '1.8.0-dev'
+ version = '1.9.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|
diff --git a/grpc.def b/grpc.def
index 07c0b3e928..d4a18ccefc 100644
--- a/grpc.def
+++ b/grpc.def
@@ -200,21 +200,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 2fe2536cc7..d185995261 100644
--- a/grpc.gemspec
+++ b/grpc.gemspec
@@ -52,7 +52,6 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/support/avl.h )
s.files += %w( include/grpc/support/cmdline.h )
s.files += %w( include/grpc/support/cpu.h )
- s.files += %w( include/grpc/support/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 )
@@ -84,19 +84,21 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/impl/codegen/sync_posix.h )
s.files += %w( include/grpc/impl/codegen/sync_windows.h )
s.files += %w( src/core/lib/profiling/timers.h )
+ s.files += %w( src/core/lib/support/abstract.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/env.h )
+ s.files += %w( src/core/lib/support/fork.h )
s.files += %w( src/core/lib/support/manual_constructor.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/thd_internal.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.cc )
@@ -113,7 +115,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/support/env_linux.cc )
s.files += %w( src/core/lib/support/env_posix.cc )
s.files += %w( src/core/lib/support/env_windows.cc )
- s.files += %w( src/core/lib/support/histogram.cc )
+ s.files += %w( src/core/lib/support/fork.cc )
s.files += %w( src/core/lib/support/host_port.cc )
s.files += %w( src/core/lib/support/log.cc )
s.files += %w( src/core/lib/support/log_android.cc )
@@ -122,7 +124,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/support/log_windows.cc )
s.files += %w( src/core/lib/support/mpscq.cc )
s.files += %w( src/core/lib/support/murmur_hash.cc )
- s.files += %w( src/core/lib/support/stack_lockfree.cc )
s.files += %w( src/core/lib/support/string.cc )
s.files += %w( src/core/lib/support/string_posix.cc )
s.files += %w( src/core/lib/support/string_util_windows.cc )
@@ -157,6 +158,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 )
@@ -169,6 +171,7 @@ 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/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 )
@@ -343,7 +346,9 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/slice/slice_hash_table.h )
s.files += %w( src/core/lib/slice/slice_internal.h )
s.files += %w( src/core/lib/slice/slice_string_helpers.h )
- s.files += %w( src/core/lib/support/vector.h )
+ s.files += %w( src/core/lib/support/debug_location.h )
+ s.files += %w( src/core/lib/support/ref_counted.h )
+ s.files += %w( src/core/lib/support/ref_counted_ptr.h )
s.files += %w( src/core/lib/surface/alarm_internal.h )
s.files += %w( src/core/lib/surface/api_trace.h )
s.files += %w( src/core/lib/surface/call.h )
@@ -413,7 +418,6 @@ Gem::Specification.new do |s|
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/closure.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 )
@@ -428,6 +432,8 @@ Gem::Specification.new do |s|
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 )
diff --git a/grpc.gyp b/grpc.gyp
index 7075aa9afd..c34206b1a5 100644
--- a/grpc.gyp
+++ b/grpc.gyp
@@ -57,7 +57,6 @@
'-Wno-long-long',
'-Wno-unused-parameter',
'-DOSATOMIC_USE_INLINED=1',
- '-Ithird_party/abseil-cpp',
],
'ldflags': [
'-g',
@@ -135,7 +134,6 @@
'-Wno-long-long',
'-Wno-unused-parameter',
'-DOSATOMIC_USE_INLINED=1',
- '-Ithird_party/abseil-cpp',
],
'OTHER_CPLUSPLUSFLAGS': [
'-g',
@@ -145,7 +143,6 @@
'-Wno-long-long',
'-Wno-unused-parameter',
'-DOSATOMIC_USE_INLINED=1',
- '-Ithird_party/abseil-cpp',
'-stdlib=libc++',
'-std=c++11',
'-Wno-error=deprecated-declarations'
@@ -175,7 +172,7 @@
'src/core/lib/support/env_linux.cc',
'src/core/lib/support/env_posix.cc',
'src/core/lib/support/env_windows.cc',
- 'src/core/lib/support/histogram.cc',
+ 'src/core/lib/support/fork.cc',
'src/core/lib/support/host_port.cc',
'src/core/lib/support/log.cc',
'src/core/lib/support/log_android.cc',
@@ -184,7 +181,6 @@
'src/core/lib/support/log_windows.cc',
'src/core/lib/support/mpscq.cc',
'src/core/lib/support/murmur_hash.cc',
- 'src/core/lib/support/stack_lockfree.cc',
'src/core/lib/support/string.cc',
'src/core/lib/support/string_posix.cc',
'src/core/lib/support/string_util_windows.cc',
@@ -245,7 +241,6 @@
'src/core/lib/http/httpcli.cc',
'src/core/lib/http/parser.cc',
'src/core/lib/iomgr/call_combiner.cc',
- 'src/core/lib/iomgr/closure.cc',
'src/core/lib/iomgr/combiner.cc',
'src/core/lib/iomgr/endpoint.cc',
'src/core/lib/iomgr/endpoint_pair_posix.cc',
@@ -260,6 +255,8 @@
'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',
@@ -508,13 +505,16 @@
'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',
@@ -535,7 +535,6 @@
'src/core/lib/http/httpcli.cc',
'src/core/lib/http/parser.cc',
'src/core/lib/iomgr/call_combiner.cc',
- 'src/core/lib/iomgr/closure.cc',
'src/core/lib/iomgr/combiner.cc',
'src/core/lib/iomgr/endpoint.cc',
'src/core/lib/iomgr/endpoint_pair_posix.cc',
@@ -550,6 +549,8 @@
'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',
@@ -716,13 +717,16 @@
'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',
@@ -743,7 +747,6 @@
'src/core/lib/http/httpcli.cc',
'src/core/lib/http/parser.cc',
'src/core/lib/iomgr/call_combiner.cc',
- 'src/core/lib/iomgr/closure.cc',
'src/core/lib/iomgr/combiner.cc',
'src/core/lib/iomgr/endpoint.cc',
'src/core/lib/iomgr/endpoint_pair_posix.cc',
@@ -758,6 +761,8 @@
'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',
@@ -936,7 +941,6 @@
'src/core/lib/http/httpcli.cc',
'src/core/lib/http/parser.cc',
'src/core/lib/iomgr/call_combiner.cc',
- 'src/core/lib/iomgr/closure.cc',
'src/core/lib/iomgr/combiner.cc',
'src/core/lib/iomgr/endpoint.cc',
'src/core/lib/iomgr/endpoint_pair_posix.cc',
@@ -951,6 +955,8 @@
'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',
diff --git a/include/grpc++/impl/codegen/call.h b/include/grpc++/impl/codegen/call.h
index 1a988297dc..af2c2b510c 100644
--- a/include/grpc++/impl/codegen/call.h
+++ b/include/grpc++/impl/codegen/call.h
@@ -313,11 +313,6 @@ 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;
@@ -579,6 +574,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 = nullptr;
op->flags = 0;
op->reserved = NULL;
}
diff --git a/include/grpc++/impl/codegen/completion_queue.h b/include/grpc++/impl/codegen/completion_queue.h
index 11cc588879..b8a7862578 100644
--- a/include/grpc++/impl/codegen/completion_queue.h
+++ b/include/grpc++/impl/codegen/completion_queue.h
@@ -65,6 +65,7 @@ class CompletionQueue;
class Server;
class ServerBuilder;
class ServerContext;
+class ServerInterface;
namespace internal {
class CompletionQueueTag;
@@ -187,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) {
@@ -238,6 +224,7 @@ class CompletionQueue : private GrpcLibraryCodegen {
friend class ::grpc::internal::UnknownMethodHandler;
friend class ::grpc::Server;
friend class ::grpc::ServerContext;
+ friend class ::grpc::ServerInterface;
template <class InputMessage, class OutputMessage>
friend class ::grpc::internal::BlockingUnaryCallImpl;
@@ -309,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/core_codegen_interface.h b/include/grpc++/impl/codegen/core_codegen_interface.h
index 1949cdab76..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
diff --git a/include/grpc++/impl/codegen/proto_utils.h b/include/grpc++/impl/codegen/proto_utils.h
index 0f7e115c9a..b7636034d4 100644
--- a/include/grpc++/impl/codegen/proto_utils.h
+++ b/include/grpc++/impl/codegen/proto_utils.h
@@ -41,8 +41,11 @@ const int kGrpcBufferWriterMaxBufferLength = 1024 * 1024;
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;
}
@@ -54,11 +57,20 @@ class GrpcBufferWriter : public ::grpc::protobuf::io::ZeroCopyOutputStream {
}
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
@@ -70,7 +82,7 @@ class GrpcBufferWriter : public ::grpc::protobuf::io::ZeroCopyOutputStream {
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(
@@ -90,6 +102,7 @@ class GrpcBufferWriter : public ::grpc::protobuf::io::ZeroCopyOutputStream {
protected:
friend class GrpcBufferWriterPeer;
const int block_size_;
+ const int total_size_;
int64_t byte_count_;
grpc_slice_buffer* slice_buffer_;
bool have_backup_;
@@ -175,20 +188,20 @@ Status GenericSerialize(const grpc::protobuf::Message& msg,
"BufferWriter must be a subclass of io::ZeroCopyOutputStream");
*own_buffer = true;
int byte_size = msg.ByteSize();
- if (byte_size <= kGrpcBufferWriterMaxBufferLength) {
+ 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();
- } else {
- BufferWriter writer(bp, kGrpcBufferWriterMaxBufferLength);
- return msg.SerializeToZeroCopyStream(&writer)
- ? g_core_codegen_interface->ok()
- : Status(StatusCode::INTERNAL, "Failed to serialize message");
}
+ 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.
diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h
index bf842baf6f..e2bae4b41f 100644
--- a/include/grpc++/server_builder.h
+++ b/include/grpc++/server_builder.h
@@ -55,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
@@ -69,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
@@ -79,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;
@@ -119,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);
@@ -129,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.).
- /// \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.
- ///
- // 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)());
@@ -202,10 +222,7 @@ class ServerBuilder {
struct SyncServerSettings {
SyncServerSettings()
- : num_cqs(GPR_MAX(1, gpr_cpu_num_cores())),
- min_pollers(1),
- max_pollers(2),
- cq_timeout_msec(10000) {}
+ : num_cqs(1), min_pollers(1), max_pollers(2), cq_timeout_msec(10000) {}
/// Number of server completion queues to create to listen to incoming RPCs.
int num_cqs;
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_security.h b/include/grpc/grpc_security.h
index 7e87217de7..bae07ac309 100644
--- a/include/grpc/grpc_security.h
+++ b/include/grpc/grpc_security.h
@@ -185,7 +185,7 @@ GRPCAPI grpc_call_credentials* grpc_composite_call_credentials_create(
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.
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 03be610d25..77844aa2af 100644
--- a/include/grpc/impl/codegen/grpc_types.h
+++ b/include/grpc/impl/codegen/grpc_types.h
@@ -240,6 +240,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
@@ -558,6 +561,10 @@ typedef struct grpc_op {
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
diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h
index fb4bfc3162..5a0ed85111 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
@@ -195,6 +196,7 @@
#else /* __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_7 */
#define GPR_CPU_POSIX 1
#define GPR_GCC_TLS 1
+#define GPR_APPLE_PTHREAD_NAME 1
#endif
#else /* __MAC_OS_X_VERSION_MIN_REQUIRED */
#define GPR_CPU_POSIX 1
@@ -297,6 +299,27 @@
#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
+ * 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(__clang__) && 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(__ANDROID__) && defined(__clang__) && defined(__NDK_MAJOR__) && \
+ defined(__NDK_MINOR__) && \
+ ((__NDK_MAJOR__ < 12) || ((__NDK_MAJOR__ == 12) && (__NDK_MINOR__ < 1)))
+#undef GPR_GCC_TLS
+#define GPR_PTHREAD_TLS 1
+#endif
+#endif /*defined(__ANDROID__) && defined(__clang__) && defined(GPR_GCC_TLS) */
+
#if defined(__has_include)
#if __has_include(<atomic>)
#define GRPC_HAS_CXX11_ATOMIC
diff --git a/include/grpc/module.modulemap b/include/grpc/module.modulemap
index 342adc0dc9..67136cba8a 100644
--- a/include/grpc/module.modulemap
+++ b/include/grpc/module.modulemap
@@ -7,7 +7,6 @@ framework module grpc {
header "support/avl.h"
header "support/cmdline.h"
header "support/cpu.h"
- header "support/histogram.h"
header "support/host_port.h"
header "support/log.h"
header "support/log_windows.h"
@@ -21,6 +20,7 @@ framework module grpc {
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"
@@ -36,6 +36,7 @@ framework module grpc {
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"
@@ -45,6 +46,7 @@ framework module grpc {
header "byte_buffer.h"
header "byte_buffer_reader.h"
header "compression.h"
+ header "fork.h"
header "grpc.h"
header "grpc_posix.h"
header "grpc_security_constants.h"
diff --git a/include/grpc/support/alloc.h b/include/grpc/support/alloc.h
index 31cb225638..c559198237 100644
--- a/include/grpc/support/alloc.h
+++ b/include/grpc/support/alloc.h
@@ -58,7 +58,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/histogram.h b/include/grpc/support/histogram.h
deleted file mode 100644
index d2794d847e..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/log.h b/include/grpc/support/log.h
index 497cca9081..9cce4b1ae7 100644
--- a/include/grpc/support/log.h
+++ b/include/grpc/support/log.h
@@ -68,7 +68,7 @@ GPRAPI void gpr_log_message(const char* file, int line,
/** 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 */
diff --git a/include/grpc/support/thd.h b/include/grpc/support/thd.h
index 225d9d6c75..e9444e88c9 100644
--- a/include/grpc/support/thd.h
+++ b/include/grpc/support/thd.h
@@ -42,9 +42,12 @@ 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,
+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. */
diff --git a/include/grpc/support/tls_gcc.h b/include/grpc/support/tls_gcc.h
index 019acdf122..1b91d22be1 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;
};
@@ -80,6 +42,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/package.json b/package.json
new file mode 100644
index 0000000000..2b7930ce70
--- /dev/null
+++ b/package.json
@@ -0,0 +1,103 @@
+{
+ "name": "grpc",
+ "version": "1.7.2",
+ "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 9dee62f871..b4d8c88693 100644
--- a/package.xml
+++ b/package.xml
@@ -13,8 +13,8 @@
<date>2017-08-24</date>
<time>16:06:07</time>
<version>
- <release>1.8.0dev</release>
- <api>1.8.0dev</api>
+ <release>1.9.0dev</release>
+ <api>1.9.0dev</api>
</version>
<stability>
<release>beta</release>
@@ -64,7 +64,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 +86,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" />
@@ -96,19 +96,21 @@
<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/profiling/timers.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/support/abstract.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/env.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/support/fork.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/manual_constructor.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/thd_internal.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.cc" role="src" />
@@ -125,7 +127,7 @@
<file baseinstalldir="/" name="src/core/lib/support/env_linux.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/env_posix.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/env_windows.cc" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/histogram.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/support/fork.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/host_port.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/log.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/log_android.cc" role="src" />
@@ -134,7 +136,6 @@
<file baseinstalldir="/" name="src/core/lib/support/log_windows.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/mpscq.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/murmur_hash.cc" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/stack_lockfree.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/string.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/string_posix.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/string_util_windows.cc" role="src" />
@@ -169,6 +170,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" />
@@ -181,6 +183,7 @@
<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/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" />
@@ -355,7 +358,9 @@
<file baseinstalldir="/" name="src/core/lib/slice/slice_hash_table.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_internal.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice_string_helpers.h" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/vector.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/support/debug_location.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/support/ref_counted.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/support/ref_counted_ptr.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/alarm_internal.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/api_trace.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/call.h" role="src" />
@@ -425,7 +430,6 @@
<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/closure.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" />
@@ -440,6 +444,8 @@
<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" />
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 bf8aea6b6f..73af9ebc4a 100644
--- a/setup.py
+++ b/setup.py
@@ -173,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)
@@ -181,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.
@@ -237,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/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc
index 3adf0fa451..dec8cd0f25 100644
--- a/src/compiler/cpp_generator.cc
+++ b/src/compiler/cpp_generator.cc
@@ -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");
diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc
index e0957bf9bb..40fe0b054a 100644
--- a/src/compiler/csharp_generator.cc
+++ b/src/compiler/csharp_generator.cc
@@ -666,7 +666,7 @@ grpc::string GetServices(const FileDescriptor* file, bool generate_client,
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/node_generator.cc b/src/compiler/node_generator.cc
index ed835b4445..661587cbd6 100644
--- a/src/compiler/node_generator.cc
+++ b/src/compiler/node_generator.cc
@@ -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/objective_c_generator.cc b/src/compiler/objective_c_generator.cc
index 349f1dc281..ab7d869758 100644
--- a/src/compiler/objective_c_generator.cc
+++ b/src/compiler/objective_c_generator.cc
@@ -28,6 +28,7 @@
using ::google::protobuf::compiler::objectivec::ClassName;
using ::grpc::protobuf::FileDescriptor;
+using ::grpc::protobuf::FileDescriptor;
using ::grpc::protobuf::MethodDescriptor;
using ::grpc::protobuf::ServiceDescriptor;
using ::grpc::protobuf::io::Printer;
@@ -65,7 +66,7 @@ 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");
}
diff --git a/src/compiler/objective_c_generator.h b/src/compiler/objective_c_generator.h
index 2337abaf6a..d3aed76c4f 100644
--- a/src/compiler/objective_c_generator.h
+++ b/src/compiler/objective_c_generator.h
@@ -24,6 +24,7 @@
namespace grpc_objective_c_generator {
using ::grpc::protobuf::FileDescriptor;
+using ::grpc::protobuf::FileDescriptor;
using ::grpc::protobuf::ServiceDescriptor;
using ::grpc::string;
diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc
index 53ff81f94a..d5d488e84d 100644
--- a/src/compiler/objective_c_plugin.cc
+++ b/src/compiler/objective_c_plugin.cc
@@ -51,12 +51,15 @@ 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";
::grpc::string proto_imports;
proto_imports += "#if GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO\n" +
@@ -105,7 +108,10 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
// 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++) {
diff --git a/src/compiler/php_generator.cc b/src/compiler/php_generator.cc
index 1ff9520d7f..d9705e8077 100644
--- a/src/compiler/php_generator.cc
+++ b/src/compiler/php_generator.cc
@@ -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/protobuf_plugin.h b/src/compiler/protobuf_plugin.h
index 1551908156..b971af1310 100644
--- a/src/compiler/protobuf_plugin.h
+++ b/src/compiler/protobuf_plugin.h
@@ -141,6 +141,7 @@ class ProtoBufPrinter : public grpc_generator::Printer {
}
void Print(const char* string) { printer_.Print(string); }
+ void PrintRaw(const char* string) { printer_.PrintRaw(string); }
void Indent() { printer_.Indent(); }
void Outdent() { printer_.Outdent(); }
diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc
index c1ae7d31ad..8a0b889454 100644
--- a/src/compiler/python_generator.cc
+++ b/src/compiler/python_generator.cc
@@ -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/ruby_generator.cc b/src/compiler/ruby_generator.cc
index ed7e074b47..e81dea603b 100644
--- a/src/compiler/ruby_generator.cc
+++ b/src/compiler/ruby_generator.cc
@@ -174,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");
diff --git a/src/compiler/schema_interface.h b/src/compiler/schema_interface.h
index b2021f2926..c000478e68 100644
--- a/src/compiler/schema_interface.h
+++ b/src/compiler/schema_interface.h
@@ -86,6 +86,7 @@ struct 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 PrintRaw(const char* string) = 0;
virtual void Indent() = 0;
virtual void Outdent() = 0;
};
diff --git a/src/core/ext/census/grpc_context.cc b/src/core/ext/census/grpc_context.cc
index fb4fcb34a8..ffe7c51ff8 100644
--- a/src/core/ext/census/grpc_context.cc
+++ b/src/core/ext/census/grpc_context.cc
@@ -24,8 +24,8 @@
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 (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);
}
}
diff --git a/src/core/ext/filters/client_channel/backup_poller.cc b/src/core/ext/filters/client_channel/backup_poller.cc
index c3795c35c1..ed437d255c 100644
--- a/src/core/ext/filters/client_channel/backup_poller.cc
+++ b/src/core/ext/filters/client_channel/backup_poller.cc
@@ -46,7 +46,7 @@ typedef struct backup_poller {
static gpr_once g_once = GPR_ONCE_INIT;
static gpr_mu g_poller_mu;
-static backup_poller* g_poller = NULL; // guarded by 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.
@@ -55,7 +55,7 @@ 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 != NULL) {
+ if (env != nullptr) {
int poll_interval_ms = gpr_parse_nonnegative_int(env);
if (poll_interval_ms == -1) {
gpr_log(GPR_ERROR,
@@ -86,7 +86,7 @@ static void g_poller_unref(grpc_exec_ctx* exec_ctx) {
if (gpr_unref(&g_poller->refs)) {
gpr_mu_lock(&g_poller_mu);
backup_poller* p = g_poller;
- g_poller = NULL;
+ g_poller = nullptr;
gpr_mu_unlock(&g_poller_mu);
gpr_mu_lock(p->pollset_mu);
p->shutting_down = true;
@@ -113,7 +113,7 @@ static void run_poller(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
backup_poller_shutdown_unref(exec_ctx, p);
return;
}
- grpc_error* err = grpc_pollset_work(exec_ctx, p->pollset, NULL,
+ grpc_error* err = grpc_pollset_work(exec_ctx, p->pollset, nullptr,
grpc_exec_ctx_now(exec_ctx));
gpr_mu_unlock(p->pollset_mu);
GRPC_LOG_IF_ERROR("Run client channel backup poller", err);
@@ -129,7 +129,7 @@ void grpc_client_channel_start_backup_polling(
return;
}
gpr_mu_lock(&g_poller_mu);
- if (g_poller == NULL) {
+ 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;
diff --git a/src/core/ext/filters/client_channel/channel_connectivity.cc b/src/core/ext/filters/client_channel/channel_connectivity.cc
index 82a5edca93..7eaf5d98cd 100644
--- a/src/core/ext/filters/client_channel/channel_connectivity.cc
+++ b/src/core/ext/filters/client_channel/channel_connectivity.cc
@@ -115,14 +115,14 @@ static void partly_done(grpc_exec_ctx* exec_ctx, state_watcher* w,
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);
+ 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);
@@ -229,7 +229,7 @@ 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));
diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc
index 584872bfc1..aced9adf9f 100644
--- a/src/core/ext/filters/client_channel/client_channel.cc
+++ b/src/core/ext/filters/client_channel/client_channel.cc
@@ -56,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
@@ -115,7 +114,7 @@ static bool parse_timeout(grpc_json* field, grpc_millis* timeout) {
buf[len - 1] = '\0'; // Remove trailing 's'.
char* decimal_point = strchr(buf, '.');
int nanos = 0;
- if (decimal_point != NULL) {
+ if (decimal_point != nullptr) {
*decimal_point = '\0';
nanos = gpr_parse_nonnegative_int(decimal_point + 1);
if (nanos == -1) {
@@ -141,14 +140,14 @@ static bool parse_timeout(grpc_json* field, grpc_millis* timeout) {
static void* method_parameters_create_from_json(const grpc_json* json) {
wait_for_ready_value wait_for_ready = WAIT_FOR_READY_UNSET;
grpc_millis timeout = 0;
- 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, "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 > 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 =
@@ -211,6 +210,14 @@ typedef struct client_channel_channel_data {
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. */
@@ -234,7 +241,7 @@ static void set_channel_connectivity_state_locked(grpc_exec_ctx* exec_ctx,
* - 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(
@@ -248,7 +255,7 @@ static void set_channel_connectivity_state_locked(grpc_exec_ctx* exec_ctx,
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));
}
@@ -259,20 +266,13 @@ static void set_channel_connectivity_state_locked(grpc_exec_ctx* exec_ctx,
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;
/* 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(exec_ctx, 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);
@@ -299,7 +299,7 @@ static void watch_lb_policy_locked(grpc_exec_ctx* exec_ctx, channel_data* chand,
static void start_resolving_locked(grpc_exec_ctx* exec_ctx,
channel_data* chand) {
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p: starting name resolution", chand);
}
GPR_ASSERT(!chand->started_resolving);
@@ -318,13 +318,13 @@ 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;
@@ -339,7 +339,7 @@ static void parse_retry_throttle_params(const grpc_json* field, void* arg) {
uint32_t multiplier = 1;
uint32_t decimal_value = 0;
const char* decimal_point = strchr(sub_field->value, '.');
- if (decimal_point != NULL) {
+ if (decimal_point != nullptr) {
whole_len = (size_t)(decimal_point - sub_field->value);
multiplier = 1000;
size_t decimal_len = strlen(decimal_point + 1);
@@ -369,119 +369,155 @@ static void parse_retry_throttle_params(const grpc_json* field, void* arg) {
}
}
+static void request_reresolution_locked(grpc_exec_ctx* exec_ctx, 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(exec_ctx, 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(exec_ctx, chand->resolver);
+ // Give back the closure to the LB policy.
+ grpc_lb_policy_set_reresolve_closure_locked(exec_ctx, chand->lb_policy,
+ &args->closure);
+}
+
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)) {
+ 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(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 == 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(exec_ctx, 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_ref_wrapper, method_parameters_unref_wrapper);
- 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(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_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;
+ chand->resolver_result = nullptr;
}
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG,
"chand=%p: resolver result: lb_policy_name=\"%s\"%s, "
"service_config=\"%s\"",
@@ -494,35 +530,35 @@ 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) {
+ if (chand->method_params_table != nullptr) {
grpc_slice_hash_table_unref(exec_ctx, 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);
}
@@ -535,17 +571,17 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
}
// 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;
+ chand->resolver = nullptr;
}
set_channel_connectivity_state_locked(
exec_ctx, chand, GRPC_CHANNEL_SHUTDOWN,
@@ -562,8 +598,8 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
grpc_connectivity_state state = GRPC_CHANNEL_TRANSIENT_FAILURE;
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);
@@ -599,46 +635,46 @@ static void start_transport_op_locked(grpc_exec_ctx* exec_ctx, void* arg,
(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,
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 != nullptr) {
+ if (chand->lb_policy == nullptr) {
GRPC_CLOSURE_SCHED(
exec_ctx, op->send_ping,
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;
+ op->bind_pollset = nullptr;
}
- op->send_ping = NULL;
+ op->send_ping = 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,
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;
+ 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);
}
- if (chand->lb_policy != NULL) {
+ if (chand->lb_policy != nullptr) {
grpc_pollset_set_del_pollset_set(exec_ctx,
chand->lb_policy->interested_parties,
chand->interested_parties);
GRPC_LB_POLICY_UNREF(exec_ctx, chand->lb_policy, "channel");
- chand->lb_policy = NULL;
+ chand->lb_policy = nullptr;
}
}
GRPC_ERROR_UNREF(op->disconnect_with_error);
@@ -654,7 +690,7 @@ static void cc_start_transport_op(grpc_exec_ctx* exec_ctx,
channel_data* chand = (channel_data*)elem->channel_data;
GPR_ASSERT(op->set_accept_stream == false);
- if (op->bind_pollset != NULL) {
+ if (op->bind_pollset != nullptr) {
grpc_pollset_set_add_pollset(exec_ctx, chand->interested_parties,
op->bind_pollset);
}
@@ -673,15 +709,15 @@ static void cc_get_channel_info(grpc_exec_ctx* exec_ctx,
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);
@@ -700,7 +736,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;
@@ -714,7 +750,7 @@ static grpc_error* cc_init_channel_elem(grpc_exec_ctx* exec_ctx,
// Record client channel factory.
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");
}
@@ -728,7 +764,7 @@ static grpc_error* cc_init_channel_elem(grpc_exec_ctx* exec_ctx,
(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");
}
@@ -736,18 +772,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;
+ char* proxy_name = nullptr;
+ grpc_channel_args* new_args = nullptr;
grpc_proxy_mappers_map_name(exec_ctx, 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,
+ exec_ctx, 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(exec_ctx, new_args);
+ if (chand->resolver == nullptr) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("resolver creation failed");
}
chand->deadline_checking_enabled =
@@ -766,17 +802,17 @@ static void shutdown_resolver_locked(grpc_exec_ctx* exec_ctx, void* arg,
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) {
+ if (chand->resolver != nullptr) {
GRPC_CLOSURE_SCHED(
exec_ctx,
GRPC_CLOSURE_CREATE(shutdown_resolver_locked, chand->resolver,
grpc_combiner_scheduler(chand->combiner)),
GRPC_ERROR_NONE);
}
- if (chand->client_channel_factory != NULL) {
+ if (chand->client_channel_factory != nullptr) {
grpc_client_channel_factory_unref(exec_ctx, chand->client_channel_factory);
}
- if (chand->lb_policy != NULL) {
+ if (chand->lb_policy != nullptr) {
grpc_pollset_set_del_pollset_set(exec_ctx,
chand->lb_policy->interested_parties,
chand->interested_parties);
@@ -784,10 +820,10 @@ static void cc_destroy_channel_elem(grpc_exec_ctx* exec_ctx,
}
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) {
+ if (chand->method_params_table != nullptr) {
grpc_slice_hash_table_unref(exec_ctx, chand->method_params_table);
}
grpc_client_channel_stop_backup_polling(exec_ctx, chand->interested_parties);
@@ -870,7 +906,7 @@ grpc_subchannel_call* grpc_client_channel_get_subchannel_call(
static void waiting_for_pick_batches_add(
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);
@@ -897,7 +933,7 @@ 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)) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG,
"chand=%p calld=%p: failing %" PRIuPTR " pending batches: %s",
elem->channel_data, calld, calld->waiting_for_pick_batches_count,
@@ -912,7 +948,7 @@ static void waiting_for_pick_batches_fail(grpc_exec_ctx* exec_ctx,
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->call_combiner);
@@ -940,7 +976,7 @@ 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)) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG,
"chand=%p calld=%p: sending %" PRIuPTR
" pending batches to subchannel_call=%p",
@@ -956,7 +992,7 @@ static void waiting_for_pick_batches_resume(grpc_exec_ctx* exec_ctx,
GRPC_ERROR_NONE,
"waiting_for_pick_batches_resume");
}
- GPR_ASSERT(calld->initial_metadata_batch != NULL);
+ GPR_ASSERT(calld->initial_metadata_batch != nullptr);
grpc_subchannel_call_process_op(exec_ctx, calld->subchannel_call,
calld->initial_metadata_batch);
}
@@ -967,18 +1003,18 @@ 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)) {
+ 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) {
+ if (chand->method_params_table != nullptr) {
calld->method_params = (method_parameters*)grpc_method_config_table_get(
exec_ctx, chand->method_params_table, calld->path);
- if (calld->method_params != NULL) {
+ 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.
@@ -1013,7 +1049,7 @@ static void create_subchannel_call_locked(grpc_exec_ctx* exec_ctx,
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)) {
+ 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));
}
@@ -1031,7 +1067,7 @@ 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) {
+ if (calld->connected_subchannel == nullptr) {
// Failed to create subchannel.
GRPC_ERROR_UNREF(calld->error);
calld->error = error == GRPC_ERROR_NONE
@@ -1039,7 +1075,7 @@ 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));
@@ -1072,8 +1108,8 @@ static void pick_callback_cancel_locked(grpc_exec_ctx* exec_ctx, void* arg,
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)) {
+ if (calld->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);
}
@@ -1091,13 +1127,13 @@ static void pick_callback_done_locked(grpc_exec_ctx* exec_ctx, void* arg,
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)) {
+ 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);
+ GPR_ASSERT(calld->lb_policy != nullptr);
GRPC_LB_POLICY_UNREF(exec_ctx, calld->lb_policy, "pick_subchannel");
- calld->lb_policy = NULL;
+ calld->lb_policy = nullptr;
async_pick_done_locked(exec_ctx, elem, GRPC_ERROR_REF(error));
}
@@ -1108,7 +1144,7 @@ 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)) {
+ 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);
}
@@ -1123,7 +1159,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) {
@@ -1143,15 +1179,15 @@ static bool pick_callback_start_locked(grpc_exec_ctx* exec_ctx,
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->subchannel_call_context, nullptr, &calld->lb_pick_closure);
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;
+ calld->lb_policy = nullptr;
} else {
GRPC_CALL_STACK_REF(calld->owning_call, "pick_callback_cancel");
grpc_call_combiner_set_notify_on_cancel(
@@ -1191,7 +1227,7 @@ static void pick_after_resolver_result_cancel_locked(grpc_exec_ctx* exec_ctx,
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)) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG,
"chand=%p calld=%p: cancelling pick waiting for resolver result",
chand, calld);
@@ -1215,7 +1251,7 @@ static void pick_after_resolver_result_done_locked(grpc_exec_ctx* exec_ctx,
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);
@@ -1226,13 +1262,13 @@ static void pick_after_resolver_result_done_locked(grpc_exec_ctx* exec_ctx,
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 (chand->lb_policy != NULL) {
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ } 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);
}
@@ -1252,9 +1288,9 @@ static void pick_after_resolver_result_done_locked(grpc_exec_ctx* exec_ctx,
// 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 != NULL) {
+ else if (chand->resolver != nullptr) {
// No LB policy, so try again.
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG,
"chand=%p calld=%p: resolver returned but no LB policy, "
"trying again",
@@ -1262,7 +1298,7 @@ static void pick_after_resolver_result_done_locked(grpc_exec_ctx* exec_ctx,
}
pick_after_resolver_result_start_locked(exec_ctx, elem);
} else {
- if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p calld=%p: resolver disconnected", chand,
calld);
}
@@ -1275,7 +1311,7 @@ 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)) {
+ if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG,
"chand=%p calld=%p: deferring pick pending resolver result", chand,
calld);
@@ -1299,8 +1335,8 @@ static void start_pick_locked(grpc_exec_ctx* exec_ctx, void* arg,
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) {
+ GPR_ASSERT(calld->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)) {
// Pick completed synchronously.
@@ -1309,7 +1345,7 @@ static void start_pick_locked(grpc_exec_ctx* exec_ctx, void* arg,
}
} else {
// We do not yet have an LB policy, so wait for a resolver result.
- if (chand->resolver == NULL) {
+ if (chand->resolver == nullptr) {
pick_done_locked(exec_ctx, elem,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Disconnected"));
return;
@@ -1331,7 +1367,7 @@ static void start_pick_locked(grpc_exec_ctx* exec_ctx, void* arg,
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) {
+ if (calld->retry_throttle_data != nullptr) {
if (error == GRPC_ERROR_NONE) {
grpc_server_retry_throttle_data_record_success(
calld->retry_throttle_data);
@@ -1360,7 +1396,7 @@ static void cc_start_transport_stream_op_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));
}
@@ -1376,13 +1412,13 @@ 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) {
+ if (calld->subchannel_call != nullptr) {
grpc_subchannel_call_process_op(exec_ctx, calld->subchannel_call, batch);
} else {
waiting_for_pick_batches_add(calld, batch);
@@ -1394,7 +1430,7 @@ static void cc_start_transport_stream_op_batch(
// 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);
@@ -1404,8 +1440,8 @@ 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);
@@ -1419,7 +1455,7 @@ 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);
}
@@ -1430,7 +1466,7 @@ static void cc_start_transport_stream_op_batch(
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);
@@ -1473,25 +1509,25 @@ static void cc_destroy_call_elem(grpc_exec_ctx* exec_ctx,
grpc_deadline_state_destroy(exec_ctx, elem);
}
grpc_slice_unref_internal(exec_ctx, calld->path);
- if (calld->method_params != NULL) {
+ 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;
+ then_schedule_closure = nullptr;
GRPC_SUBCHANNEL_CALL_UNREF(exec_ctx, calld->subchannel_call,
"client_channel_destroy_call");
}
- GPR_ASSERT(calld->lb_policy == NULL);
+ GPR_ASSERT(calld->lb_policy == nullptr);
GPR_ASSERT(calld->waiting_for_pick_batches_count == 0);
- if (calld->connected_subchannel != NULL) {
+ if (calld->connected_subchannel != nullptr) {
GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, calld->connected_subchannel,
"picked");
}
for (size_t i = 0; i < GRPC_CONTEXT_COUNT; ++i) {
- if (calld->subchannel_call_context[i].value != NULL) {
+ if (calld->subchannel_call_context[i].value != nullptr) {
calld->subchannel_call_context[i].destroy(
calld->subchannel_call_context[i].value);
}
@@ -1527,11 +1563,11 @@ const grpc_channel_filter grpc_client_channel_filter = {
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) {
+ if (chand->lb_policy != nullptr) {
grpc_lb_policy_exit_idle_locked(exec_ctx, chand->lb_policy);
} else {
chand->exit_idle_when_lb_policy_arrives = true;
- if (!chand->started_resolving && chand->resolver != NULL) {
+ if (!chand->started_resolving && chand->resolver != nullptr) {
start_resolving_locked(exec_ctx, chand);
}
}
@@ -1569,7 +1605,7 @@ static external_connectivity_watcher* lookup_external_connectivity_watcher(
gpr_mu_lock(&chand->external_connectivity_watcher_list_mu);
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);
@@ -1599,7 +1635,7 @@ static void external_connectivity_watcher_list_remove(
}
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);
@@ -1618,7 +1654,7 @@ int grpc_client_channel_num_external_connectivity_watchers(
gpr_mu_lock(&chand->external_connectivity_watcher_list_mu);
external_connectivity_watcher* w =
chand->external_connectivity_watcher_list_head;
- while (w != NULL) {
+ while (w != nullptr) {
count++;
w = w->next;
}
@@ -1643,8 +1679,8 @@ static void on_external_watch_complete_locked(grpc_exec_ctx* exec_ctx,
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) {
+ 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_locked, w,
@@ -1652,12 +1688,12 @@ static void watch_connectivity_state_locked(grpc_exec_ctx* exec_ctx, void* arg,
grpc_connectivity_state_notify_on_state_change(
exec_ctx, &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);
+ exec_ctx, &found->chand->state_tracker, nullptr, &found->my_closure);
}
grpc_polling_entity_del_from_pollset_set(exec_ctx, &w->pollent,
w->chand->interested_parties);
diff --git a/src/core/ext/filters/client_channel/client_channel.h b/src/core/ext/filters/client_channel/client_channel.h
index 27862cf239..48e4637a82 100644
--- a/src/core/ext/filters/client_channel/client_channel.h
+++ b/src/core/ext/filters/client_channel/client_channel.h
@@ -23,15 +23,11 @@
#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"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* A client channel is a channel that begins disconnected, and can connect
to some endpoint on demand. If that endpoint disconnects, it will be
connected to again later.
@@ -56,8 +52,4 @@ void grpc_client_channel_watch_connectivity_state(
grpc_subchannel_call* grpc_client_channel_get_subchannel_call(
grpc_call_element* elem);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CLIENT_CHANNEL_H */
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 db8645cd00..db82b733ce 100644
--- a/src/core/ext/filters/client_channel/client_channel_factory.h
+++ b/src/core/ext/filters/client_channel/client_channel_factory.h
@@ -27,10 +27,6 @@
// Channel arg key for client channel factory.
#define GRPC_ARG_CLIENT_CHANNEL_FACTORY "grpc.client_channel_factory"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_client_channel_factory grpc_client_channel_factory;
typedef struct grpc_client_channel_factory_vtable
grpc_client_channel_factory_vtable;
@@ -78,8 +74,4 @@ grpc_channel* grpc_client_channel_factory_create_channel(
grpc_arg grpc_client_channel_factory_create_channel_arg(
grpc_client_channel_factory* factory);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CLIENT_CHANNEL_FACTORY_H */
diff --git a/src/core/ext/filters/client_channel/client_channel_plugin.cc b/src/core/ext/filters/client_channel/client_channel_plugin.cc
index 0db894913c..7a5bb18157 100644
--- a/src/core/ext/filters/client_channel/client_channel_plugin.cc
+++ b/src/core/ext/filters/client_channel/client_channel_plugin.cc
@@ -37,7 +37,7 @@
static bool append_filter(grpc_exec_ctx* exec_ctx,
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,
@@ -53,7 +53,7 @@ static bool set_default_host_if_unset(grpc_exec_ctx* exec_ctx,
}
char* default_authority = grpc_get_default_authority(
exec_ctx, grpc_channel_stack_builder_get_target(builder));
- if (default_authority != NULL) {
+ 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);
@@ -65,7 +65,7 @@ static bool set_default_host_if_unset(grpc_exec_ctx* exec_ctx,
return true;
}
-extern "C" void grpc_client_channel_init(void) {
+void grpc_client_channel_init(void) {
grpc_lb_policy_registry_init();
grpc_resolver_registry_init();
grpc_retry_throttle_map_init();
@@ -73,18 +73,14 @@ extern "C" 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);
grpc_http_connect_register_handshaker_factory();
- grpc_register_tracer(&grpc_client_channel_trace);
-#ifndef NDEBUG
- grpc_register_tracer(&grpc_trace_resolver_refcount);
-#endif
}
-extern "C" void grpc_client_channel_shutdown(void) {
+void grpc_client_channel_shutdown(void) {
grpc_subchannel_index_shutdown();
grpc_channel_init_shutdown();
grpc_proxy_mapper_registry_shutdown();
diff --git a/src/core/ext/filters/client_channel/connector.h b/src/core/ext/filters/client_channel/connector.h
index 12dc59bcdf..239ed8a8bd 100644
--- a/src/core/ext/filters/client_channel/connector.h
+++ b/src/core/ext/filters/client_channel/connector.h
@@ -23,10 +23,6 @@
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/transport/transport.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_connector grpc_connector;
typedef struct grpc_connector_vtable grpc_connector_vtable;
@@ -74,8 +70,4 @@ void grpc_connector_connect(grpc_exec_ctx* exec_ctx, grpc_connector* connector,
void grpc_connector_shutdown(grpc_exec_ctx* exec_ctx, grpc_connector* connector,
grpc_error* why);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CONNECTOR_H */
diff --git a/src/core/ext/filters/client_channel/http_connect_handshaker.cc b/src/core/ext/filters/client_channel/http_connect_handshaker.cc
index 418bb41ef6..b7cb2e3eba 100644
--- a/src/core/ext/filters/client_channel/http_connect_handshaker.cc
+++ b/src/core/ext/filters/client_channel/http_connect_handshaker.cc
@@ -65,10 +65,10 @@ static void http_connect_handshaker_unref(grpc_exec_ctx* exec_ctx,
http_connect_handshaker* handshaker) {
if (gpr_unref(&handshaker->refcount)) {
gpr_mu_destroy(&handshaker->mu);
- if (handshaker->endpoint_to_destroy != NULL) {
+ if (handshaker->endpoint_to_destroy != nullptr) {
grpc_endpoint_destroy(exec_ctx, handshaker->endpoint_to_destroy);
}
- if (handshaker->read_buffer_to_destroy != NULL) {
+ if (handshaker->read_buffer_to_destroy != nullptr) {
grpc_slice_buffer_destroy_internal(exec_ctx,
handshaker->read_buffer_to_destroy);
gpr_free(handshaker->read_buffer_to_destroy);
@@ -85,11 +85,11 @@ static void http_connect_handshaker_unref(grpc_exec_ctx* exec_ctx,
static void cleanup_args_for_failure_locked(
grpc_exec_ctx* exec_ctx, 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;
+ handshaker->args->read_buffer = nullptr;
grpc_channel_args_destroy(exec_ctx, handshaker->args->args);
- handshaker->args->args = NULL;
+ handshaker->args->args = nullptr;
}
// If the handshake failed or we're shutting down, clean up and invoke the
@@ -260,7 +260,7 @@ static void http_connect_handshaker_do_handshake(
// 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);
@@ -273,11 +273,11 @@ static void http_connect_handshaker_do_handshake(
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 +285,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;
diff --git a/src/core/ext/filters/client_channel/http_connect_handshaker.h b/src/core/ext/filters/client_channel/http_connect_handshaker.h
index 05a23cdba3..928a23dc93 100644
--- a/src/core/ext/filters/client_channel/http_connect_handshaker.h
+++ b/src/core/ext/filters/client_channel/http_connect_handshaker.h
@@ -28,15 +28,7 @@
/// seperated by colons.
#define GRPC_ARG_HTTP_CONNECT_HEADERS "grpc.http_connect_headers"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/// Registers handshaker factory.
void grpc_http_connect_register_handshaker_factory();
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_HTTP_CONNECT_HANDSHAKER_H */
diff --git a/src/core/ext/filters/client_channel/http_proxy.cc b/src/core/ext/filters/client_channel/http_proxy.cc
index a16b44d3dc..405d8c0e55 100644
--- a/src/core/ext/filters/client_channel/http_proxy.cc
+++ b/src/core/ext/filters/client_channel/http_proxy.cc
@@ -41,15 +41,15 @@
* 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;
+ 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;
+ if (uri_str == nullptr) return nullptr;
grpc_uri* uri =
grpc_uri_parse(exec_ctx, uri_str, false /* suppress_errors */);
- if (uri == NULL || uri->authority == NULL) {
+ if (uri == nullptr || uri->authority == nullptr) {
gpr_log(GPR_ERROR, "cannot parse value of 'http_proxy' env var");
goto done;
}
@@ -73,7 +73,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:
@@ -88,13 +88,13 @@ static bool proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
const grpc_channel_args* args,
char** name_to_resolve,
grpc_channel_args** new_args) {
- char* user_cred = NULL;
+ char* user_cred = nullptr;
*name_to_resolve = get_http_proxy_server(exec_ctx, &user_cred);
- if (*name_to_resolve == NULL) return false;
- char* no_proxy_str = NULL;
+ if (*name_to_resolve == nullptr) return false;
+ char* no_proxy_str = nullptr;
grpc_uri* uri =
grpc_uri_parse(exec_ctx, server_uri, false /* suppress_errors */);
- if (uri == NULL || uri->path[0] == '\0') {
+ 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",
@@ -107,7 +107,7 @@ static bool proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
goto no_use_proxy;
}
no_proxy_str = gpr_getenv("no_proxy");
- if (no_proxy_str != NULL) {
+ if (no_proxy_str != nullptr) {
static const char* NO_PROXY_SEPARATOR = ",";
bool use_proxy = true;
char* server_host;
@@ -149,7 +149,7 @@ static bool proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
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);
@@ -167,9 +167,9 @@ static bool proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
gpr_free(user_cred);
return true;
no_use_proxy:
- if (uri != NULL) grpc_uri_destroy(uri);
+ if (uri != nullptr) grpc_uri_destroy(uri);
gpr_free(*name_to_resolve);
- *name_to_resolve = NULL;
+ *name_to_resolve = nullptr;
gpr_free(user_cred);
return false;
}
diff --git a/src/core/ext/filters/client_channel/http_proxy.h b/src/core/ext/filters/client_channel/http_proxy.h
index bdad03def3..34694931d0 100644
--- a/src/core/ext/filters/client_channel/http_proxy.h
+++ b/src/core/ext/filters/client_channel/http_proxy.h
@@ -19,14 +19,6 @@
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_HTTP_PROXY_H
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_HTTP_PROXY_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
void grpc_register_http_proxy_mapper();
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_HTTP_PROXY_H */
diff --git a/src/core/ext/filters/client_channel/lb_policy.cc b/src/core/ext/filters/client_channel/lb_policy.cc
index 387c26ed5c..db566f1b56 100644
--- a/src/core/ext/filters/client_channel/lb_policy.cc
+++ b/src/core/ext/filters/client_channel/lb_policy.cc
@@ -21,10 +21,8 @@
#define WEAK_REF_BITS 16
-#ifndef NDEBUG
-grpc_tracer_flag grpc_trace_lb_policy_refcount =
- GRPC_TRACER_INITIALIZER(false, "lb_policy_refcount");
-#endif
+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,
@@ -52,7 +50,7 @@ static gpr_atm ref_mutate(grpc_lb_policy* c, gpr_atm delta,
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)) {
+ if (grpc_trace_lb_policy_refcount.enabled()) {
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);
@@ -163,3 +161,30 @@ void grpc_lb_policy_update_locked(grpc_exec_ctx* exec_ctx,
const grpc_lb_policy_args* lb_policy_args) {
policy->vtable->update_locked(exec_ctx, policy, lb_policy_args);
}
+
+void grpc_lb_policy_set_reresolve_closure_locked(
+ grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
+ grpc_closure* request_reresolution) {
+ policy->vtable->set_reresolve_closure_locked(exec_ctx, policy,
+ request_reresolution);
+}
+
+void grpc_lb_policy_try_reresolve(grpc_exec_ctx* exec_ctx,
+ grpc_lb_policy* policy,
+ grpc_core::TraceFlag* grpc_lb_trace,
+ grpc_error* error) {
+ if (policy->request_reresolution != nullptr) {
+ GRPC_CLOSURE_SCHED(exec_ctx, 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 590094e67e..d3159eebf3 100644
--- a/src/core/ext/filters/client_channel/lb_policy.h
+++ b/src/core/ext/filters/client_channel/lb_policy.h
@@ -23,19 +23,13 @@
#include "src/core/lib/iomgr/polling_entity.h"
#include "src/core/lib/transport/connectivity_state.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/** A load balancing policy: specified by a vtable and a struct (which
is expected to be extended to contain some parameters) */
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;
@@ -44,6 +38,8 @@ struct grpc_lb_policy {
grpc_pollset_set* interested_parties;
/* combiner under which lb_policy actions take place */
grpc_combiner* combiner;
+ /* callback to force a re-resolution */
+ grpc_closure* request_reresolution;
};
/** Extra arguments for an LB pick */
@@ -102,6 +98,11 @@ struct grpc_lb_policy_vtable {
void (*update_locked)(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
const grpc_lb_policy_args* args);
+
+ /** \see grpc_lb_policy_set_reresolve_closure */
+ void (*set_reresolve_closure_locked)(grpc_exec_ctx* exec_ctx,
+ grpc_lb_policy* policy,
+ grpc_closure* request_reresolution);
};
#ifndef NDEBUG
@@ -208,8 +209,16 @@ void grpc_lb_policy_update_locked(grpc_exec_ctx* exec_ctx,
grpc_lb_policy* policy,
const grpc_lb_policy_args* lb_policy_args);
-#ifdef __cplusplus
-}
-#endif
+/** Set the re-resolution closure to \a request_reresolution. */
+void grpc_lb_policy_set_reresolve_closure_locked(
+ grpc_exec_ctx* exec_ctx, 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_exec_ctx* exec_ctx,
+ 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.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc
index d93a9c3710..6d9fadaf30 100644
--- 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
@@ -72,8 +72,8 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
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);
+ GPR_ASSERT(args->context != nullptr);
+ GPR_ASSERT(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.
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 abf613a23b..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
@@ -21,15 +21,7 @@
#include "src/core/lib/channel/channel_stack.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
extern const grpc_channel_filter grpc_client_load_reporting_filter;
-#ifdef __cplusplus
-}
-#endif
-
#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.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
index 6675cacc41..db06fc20b6 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
@@ -126,14 +126,14 @@
#define GRPC_GRPCLB_RECONNECT_JITTER 0.2
#define GRPC_GRPCLB_DEFAULT_FALLBACK_TIMEOUT_MS 10000
-grpc_tracer_flag grpc_lb_glb_trace = GRPC_TRACER_INITIALIZER(false, "glb");
+grpc_core::TraceFlag grpc_lb_glb_trace(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(lb_token_mdelem_storage != nullptr);
GPR_ASSERT(!GRPC_MDISNULL(lb_token));
return grpc_metadata_batch_add_tail(exec_ctx, initial_metadata,
lb_token_mdelem_storage, lb_token);
@@ -190,14 +190,14 @@ 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);
+ GPR_ASSERT(wc_arg->wrapped_closure != nullptr);
GRPC_CLOSURE_SCHED(exec_ctx, wc_arg->wrapped_closure, GRPC_ERROR_REF(error));
- if (wc_arg->rr_policy != NULL) {
+ if (wc_arg->rr_policy != nullptr) {
/* 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 (*wc_arg->target != nullptr) {
if (!GRPC_MDISNULL(wc_arg->lb_token)) {
initial_metadata_add_lb_token(exec_ctx, wc_arg->initial_metadata,
wc_arg->lb_token_mdelem_storage,
@@ -211,19 +211,19 @@ static void wrapped_rr_closure(grpc_exec_ctx* exec_ctx, void* arg,
abort();
}
// Pass on client stats via context. Passes ownership of the reference.
- GPR_ASSERT(wc_arg->client_stats != NULL);
+ GPR_ASSERT(wc_arg->client_stats != nullptr);
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)) {
+ if (grpc_lb_glb_trace.enabled()) {
gpr_log(GPR_INFO, "[grpclb %p] Unreffing RR %p", wc_arg->glb_policy,
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_ASSERT(wc_arg->free_when_done != nullptr);
gpr_free(wc_arg->free_when_done);
}
@@ -455,12 +455,12 @@ static bool is_server_valid(const grpc_grpclb_server* server, size_t idx,
/* vtable for LB tokens in grpc_lb_addresses. */
static void* lb_token_copy(void* token) {
- return token == NULL
- ? NULL
+ return token == nullptr
+ ? nullptr
: (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) {
+ if (token != nullptr) {
GRPC_MDELEM_UNREF(exec_ctx, grpc_mdelem{(uintptr_t)token});
}
}
@@ -543,7 +543,7 @@ static grpc_lb_addresses* process_serverlist_locked(
grpc_lb_addresses_set_address(lb_addresses, addr_idx, &addr.addr, addr.len,
false /* is_balancer */,
- NULL /* balancer_name */, user_data);
+ nullptr /* balancer_name */, user_data);
++addr_idx;
}
GPR_ASSERT(addr_idx == num_valid);
@@ -569,7 +569,7 @@ static grpc_lb_addresses* extract_backend_addresses_locked(
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 */,
- NULL /* balancer_name */,
+ nullptr /* balancer_name */,
(void*)GRPC_MDELEM_LB_TOKEN_EMPTY.payload);
++num_copied;
}
@@ -623,7 +623,7 @@ static void update_lb_connectivity_status_locked(
GPR_ASSERT(rr_state_error == GRPC_ERROR_NONE);
}
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
+ if (grpc_lb_glb_trace.enabled()) {
gpr_log(
GPR_INFO,
"[grpclb %p] Setting grpclb's state to %s from new RR policy %p state.",
@@ -637,7 +637,7 @@ static void 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.
+ * 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(
@@ -645,7 +645,7 @@ static bool pick_from_internal_rr_locked(
const grpc_lb_policy_pick_args* pick_args, bool force_async,
grpc_connected_subchannel** target, wrapped_rr_closure_arg* wc_arg) {
// Check for drops if we are not using fallback backend addresses.
- if (glb_policy->serverlist != NULL) {
+ 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++];
@@ -654,7 +654,7 @@ static bool pick_from_internal_rr_locked(
}
if (server->drop) {
// Not using the RR policy, so unref it.
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
+ if (grpc_lb_glb_trace.enabled()) {
gpr_log(GPR_INFO, "[grpclb %p] Unreffing RR %p for drop", glb_policy,
wc_arg->rr_policy);
}
@@ -664,12 +664,12 @@ static bool pick_from_internal_rr_locked(
// the client_load_reporting filter, because we do not create a
// subchannel call (and therefore no client_load_reporting filter)
// for dropped calls.
- GPR_ASSERT(wc_arg->client_stats != NULL);
+ GPR_ASSERT(wc_arg->client_stats != nullptr);
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);
+ GPR_ASSERT(wc_arg->wrapped_closure != nullptr);
GRPC_CLOSURE_SCHED(exec_ctx, wc_arg->wrapped_closure, GRPC_ERROR_NONE);
gpr_free(wc_arg->free_when_done);
return false;
@@ -684,7 +684,7 @@ static bool pick_from_internal_rr_locked(
(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)) {
+ if (grpc_lb_glb_trace.enabled()) {
gpr_log(GPR_INFO, "[grpclb %p] Unreffing RR %p", glb_policy,
wc_arg->rr_policy);
}
@@ -694,11 +694,11 @@ static bool pick_from_internal_rr_locked(
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);
+ GPR_ASSERT(wc_arg->client_stats != nullptr);
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);
+ GPR_ASSERT(wc_arg->wrapped_closure != nullptr);
GRPC_CLOSURE_SCHED(exec_ctx, wc_arg->wrapped_closure, GRPC_ERROR_NONE);
gpr_free(wc_arg->free_when_done);
return false;
@@ -715,7 +715,7 @@ static bool pick_from_internal_rr_locked(
static grpc_lb_policy_args* lb_policy_args_create(grpc_exec_ctx* exec_ctx,
glb_lb_policy* glb_policy) {
grpc_lb_addresses* addresses;
- if (glb_policy->serverlist != NULL) {
+ if (glb_policy->serverlist != nullptr) {
GPR_ASSERT(glb_policy->serverlist->num_servers > 0);
addresses = process_serverlist_locked(exec_ctx, glb_policy->serverlist);
} else {
@@ -723,10 +723,10 @@ static grpc_lb_policy_args* lb_policy_args_create(grpc_exec_ctx* exec_ctx,
// 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 != NULL);
+ GPR_ASSERT(glb_policy->fallback_backend_addresses != nullptr);
addresses = grpc_lb_addresses_copy(glb_policy->fallback_backend_addresses);
}
- GPR_ASSERT(addresses != NULL);
+ 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;
@@ -751,11 +751,11 @@ 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);
+ GPR_ASSERT(glb_policy->rr_policy == nullptr);
grpc_lb_policy* new_rr_policy =
grpc_lb_policy_create(exec_ctx, "round_robin", args);
- if (new_rr_policy == NULL) {
+ if (new_rr_policy == nullptr) {
gpr_log(GPR_ERROR,
"[grpclb %p] Failure creating a RoundRobin policy for serverlist "
"update with %" PRIuPTR
@@ -766,8 +766,11 @@ static void create_rr_locked(grpc_exec_ctx* exec_ctx, glb_lb_policy* glb_policy,
glb_policy->rr_policy);
return;
}
+ grpc_lb_policy_set_reresolve_closure_locked(
+ exec_ctx, 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 = NULL;
+ grpc_error* rr_state_error = nullptr;
const grpc_connectivity_state rr_state =
grpc_lb_policy_check_connectivity_locked(exec_ctx, glb_policy->rr_policy,
&rr_state_error);
@@ -806,7 +809,7 @@ static void create_rr_locked(grpc_exec_ctx* exec_ctx, glb_lb_policy* glb_policy,
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)) {
+ 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);
@@ -821,7 +824,7 @@ static void create_rr_locked(grpc_exec_ctx* exec_ctx, glb_lb_policy* glb_policy,
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)) {
+ 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);
}
@@ -835,16 +838,16 @@ static void rr_handover_locked(grpc_exec_ctx* exec_ctx,
glb_lb_policy* glb_policy) {
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_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(exec_ctx, glb_policy->rr_policy, args);
} else {
create_rr_locked(exec_ctx, glb_policy, args);
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
+ if (grpc_lb_glb_trace.enabled()) {
gpr_log(GPR_DEBUG, "[grpclb %p] Created new RR policy %p", glb_policy,
glb_policy->rr_policy);
}
@@ -868,7 +871,7 @@ static void glb_rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx,
* 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;
+ glb_policy->rr_policy = nullptr;
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
"glb_rr_connectivity_cb");
gpr_free(rr_connectivity);
@@ -923,7 +926,7 @@ static grpc_channel_args* build_lb_channel_args(
* 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_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);
@@ -931,7 +934,7 @@ static grpc_channel_args* build_lb_channel_args(
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) {
+ if (addresses->addresses[i].user_data != nullptr) {
gpr_log(GPR_ERROR,
"This LB policy doesn't support user data. It will be ignored");
}
@@ -945,7 +948,7 @@ static grpc_channel_args* build_lb_channel_args(
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 */);
+ addresses->addresses[i].balancer_name, nullptr /* user data */);
}
GPR_ASSERT(num_grpclb_addrs == lb_addresses_idx);
grpc_slice_hash_table* targets_info =
@@ -970,18 +973,18 @@ static grpc_channel_args* build_lb_channel_args(
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_ASSERT(glb_policy->pending_picks == nullptr);
+ GPR_ASSERT(glb_policy->pending_pings == nullptr);
gpr_free((void*)glb_policy->server_name);
grpc_channel_args_destroy(exec_ctx, glb_policy->args);
- if (glb_policy->client_stats != NULL) {
+ if (glb_policy->client_stats != nullptr) {
grpc_grpclb_client_stats_unref(glb_policy->client_stats);
}
grpc_connectivity_state_destroy(exec_ctx, &glb_policy->state_tracker);
- if (glb_policy->serverlist != NULL) {
+ if (glb_policy->serverlist != nullptr) {
grpc_grpclb_destroy_serverlist(glb_policy->serverlist);
}
- if (glb_policy->fallback_backend_addresses != NULL) {
+ if (glb_policy->fallback_backend_addresses != nullptr) {
grpc_lb_addresses_destroy(exec_ctx, glb_policy->fallback_backend_addresses);
}
grpc_fake_resolver_response_generator_unref(glb_policy->response_generator);
@@ -991,6 +994,7 @@ static void glb_destroy(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
static void glb_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
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;
/* We need a copy of the lb_call pointer because we can't cancell the call
@@ -1002,8 +1006,8 @@ static void glb_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
* 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);
+ if (lb_call != nullptr) {
+ grpc_call_cancel(lb_call, nullptr);
/* lb_on_server_status_received will pick up the cancel and clean up */
}
if (glb_policy->retry_timer_active) {
@@ -1016,42 +1020,44 @@ static void glb_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
}
pending_pick* pp = glb_policy->pending_picks;
- glb_policy->pending_picks = NULL;
+ glb_policy->pending_picks = nullptr;
pending_ping* pping = glb_policy->pending_pings;
- glb_policy->pending_pings = NULL;
- if (glb_policy->rr_policy != NULL) {
+ glb_policy->pending_pings = nullptr;
+ if (glb_policy->rr_policy != nullptr) {
GRPC_LB_POLICY_UNREF(exec_ctx, glb_policy->rr_policy, "glb_shutdown");
+ } else {
+ grpc_lb_policy_try_reresolve(exec_ctx, 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 != NULL) {
+ if (glb_policy->lb_channel != nullptr) {
grpc_channel_destroy(glb_policy->lb_channel);
- glb_policy->lb_channel = NULL;
+ glb_policy->lb_channel = nullptr;
}
- grpc_connectivity_state_set(
- exec_ctx, &glb_policy->state_tracker, GRPC_CHANNEL_SHUTDOWN,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Shutdown"), "glb_shutdown");
+ grpc_connectivity_state_set(exec_ctx, &glb_policy->state_tracker,
+ GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_REF(error),
+ "glb_shutdown");
- while (pp != NULL) {
+ while (pp != nullptr) {
pending_pick* next = pp->next;
- *pp->target = NULL;
- GRPC_CLOSURE_SCHED(
- exec_ctx, &pp->wrapped_on_complete_arg.wrapper_closure,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Shutdown"));
+ *pp->target = nullptr;
+ GRPC_CLOSURE_SCHED(exec_ctx, &pp->wrapped_on_complete_arg.wrapper_closure,
+ GRPC_ERROR_REF(error));
gpr_free(pp);
pp = next;
}
- while (pping != NULL) {
+ while (pping != nullptr) {
pending_ping* next = pping->next;
- GRPC_CLOSURE_SCHED(
- exec_ctx, &pping->wrapped_notify_arg.wrapper_closure,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Shutdown"));
+ GRPC_CLOSURE_SCHED(exec_ctx, &pping->wrapped_notify_arg.wrapper_closure,
+ GRPC_ERROR_REF(error));
gpr_free(pping);
pping = next;
}
+ GRPC_ERROR_UNREF(error);
}
// Cancel a specific pending pick.
@@ -1069,11 +1075,11 @@ static void glb_cancel_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
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) {
+ glb_policy->pending_picks = nullptr;
+ while (pp != nullptr) {
pending_pick* next = pp->next;
if (pp->target == target) {
- *target = NULL;
+ *target = nullptr;
GRPC_CLOSURE_SCHED(exec_ctx, &pp->wrapped_on_complete_arg.wrapper_closure,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Pick Cancelled", &error, 1));
@@ -1083,7 +1089,7 @@ static void glb_cancel_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
}
pp = next;
}
- if (glb_policy->rr_policy != NULL) {
+ if (glb_policy->rr_policy != nullptr) {
grpc_lb_policy_cancel_pick_locked(exec_ctx, glb_policy->rr_policy, target,
GRPC_ERROR_REF(error));
}
@@ -1107,8 +1113,8 @@ static void glb_cancel_picks_locked(grpc_exec_ctx* exec_ctx,
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) {
+ glb_policy->pending_picks = nullptr;
+ while (pp != nullptr) {
pending_pick* next = pp->next;
if ((pp->pick_args.initial_metadata_flags & initial_metadata_flags_mask) ==
initial_metadata_flags_eq) {
@@ -1121,7 +1127,7 @@ static void glb_cancel_picks_locked(grpc_exec_ctx* exec_ctx,
}
pp = next;
}
- if (glb_policy->rr_policy != NULL) {
+ if (glb_policy->rr_policy != nullptr) {
grpc_lb_policy_cancel_picks_locked(
exec_ctx, glb_policy->rr_policy, initial_metadata_flags_mask,
initial_metadata_flags_eq, GRPC_ERROR_REF(error));
@@ -1137,7 +1143,7 @@ static void start_picking_locked(grpc_exec_ctx* exec_ctx,
glb_lb_policy* glb_policy) {
/* start a timer to fall back */
if (glb_policy->lb_fallback_timeout_ms > 0 &&
- glb_policy->serverlist == NULL && !glb_policy->fallback_timer_active) {
+ glb_policy->serverlist == nullptr && !glb_policy->fallback_timer_active) {
grpc_millis deadline =
grpc_exec_ctx_now(exec_ctx) + glb_policy->lb_fallback_timeout_ms;
GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "grpclb_fallback_timer");
@@ -1166,8 +1172,8 @@ static int glb_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
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;
+ if (pick_args->lb_token_mdelem_storage == nullptr) {
+ *target = nullptr;
GRPC_CLOSURE_SCHED(exec_ctx, on_complete,
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"No mdelem storage for the LB token. Load reporting "
@@ -1176,17 +1182,17 @@ static int glb_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
}
glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
bool pick_done = false;
- if (glb_policy->rr_policy != NULL) {
+ if (glb_policy->rr_policy != nullptr) {
const grpc_connectivity_state rr_connectivity_state =
- grpc_lb_policy_check_connectivity_locked(exec_ctx,
- glb_policy->rr_policy, NULL);
+ grpc_lb_policy_check_connectivity_locked(
+ exec_ctx, glb_policy->rr_policy, nullptr);
// The glb_policy->rr_policy may have transitioned to SHUTDOWN but the
// callback registered to capture this event
// (glb_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_TRACER_ON(grpc_lb_glb_trace)) {
+ 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,
@@ -1196,7 +1202,7 @@ static int glb_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
on_complete);
pick_done = false;
} else { // RR not in shutdown
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
+ if (grpc_lb_glb_trace.enabled()) {
gpr_log(GPR_INFO, "[grpclb %p] about to PICK from RR %p", glb_policy,
glb_policy->rr_policy);
}
@@ -1208,7 +1214,7 @@ static int glb_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
wc_arg->rr_policy = glb_policy->rr_policy;
wc_arg->target = target;
wc_arg->context = context;
- GPR_ASSERT(glb_policy->client_stats != NULL);
+ GPR_ASSERT(glb_policy->client_stats != nullptr);
wc_arg->client_stats =
grpc_grpclb_client_stats_ref(glb_policy->client_stats);
wc_arg->wrapped_closure = on_complete;
@@ -1221,7 +1227,7 @@ static int glb_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
false /* force_async */, target, wc_arg);
}
} else { // glb_policy->rr_policy == NULL
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
+ if (grpc_lb_glb_trace.enabled()) {
gpr_log(GPR_DEBUG,
"[grpclb %p] No RR policy. Adding to grpclb's pending picks",
glb_policy);
@@ -1270,9 +1276,9 @@ 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 && glb_policy->lb_call == NULL &&
+ if (!glb_policy->shutting_down && glb_policy->lb_call == nullptr &&
error == GRPC_ERROR_NONE) {
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
+ if (grpc_lb_glb_trace.enabled()) {
gpr_log(GPR_INFO, "[grpclb %p] Restarting call to LB server", glb_policy);
}
query_for_backends_locked(exec_ctx, glb_policy);
@@ -1293,7 +1299,7 @@ static void maybe_restart_lb_call(grpc_exec_ctx* exec_ctx,
grpc_millis next_try =
grpc_backoff_step(exec_ctx, &glb_policy->lb_call_backoff_state)
.next_attempt_start_time;
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
+ 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_exec_ctx_now(exec_ctx);
@@ -1337,11 +1343,14 @@ 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_payload = nullptr;
+ if (error != GRPC_ERROR_NONE || glb_policy->lb_call == nullptr) {
glb_policy->client_load_report_timer_pending = false;
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
"client_load_report");
+ if (glb_policy->lb_call == nullptr) {
+ maybe_restart_lb_call(exec_ctx, glb_policy);
+ }
return;
}
schedule_next_client_load_report(exec_ctx, glb_policy);
@@ -1356,23 +1365,23 @@ static bool load_report_counters_are_zero(grpc_grpclb_request* request) {
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);
+ (drop_entries == nullptr || 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) {
+ if (error == GRPC_ERROR_CANCELLED || glb_policy->lb_call == nullptr) {
glb_policy->client_load_report_timer_pending = false;
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
"client_load_report");
- if (glb_policy->lb_call == NULL) {
+ if (glb_policy->lb_call == nullptr) {
maybe_restart_lb_call(exec_ctx, glb_policy);
}
return;
}
// Construct message payload.
- GPR_ASSERT(glb_policy->client_load_report_payload == NULL);
+ GPR_ASSERT(glb_policy->client_load_report_payload == nullptr);
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
@@ -1415,9 +1424,9 @@ 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 != nullptr);
GPR_ASSERT(glb_policy->server_name[0] != '\0');
- GPR_ASSERT(glb_policy->lb_call == NULL);
+ GPR_ASSERT(glb_policy->lb_call == nullptr);
GPR_ASSERT(!glb_policy->shutting_down);
/* Note the following LB call progresses every time there's activity in \a
@@ -1429,13 +1438,13 @@ static void lb_call_init_locked(grpc_exec_ctx* exec_ctx,
? GRPC_MILLIS_INF_FUTURE
: grpc_exec_ctx_now(exec_ctx) + glb_policy->lb_call_timeout_ms;
glb_policy->lb_call = grpc_channel_create_pollset_set_call(
- exec_ctx, glb_policy->lb_channel, NULL, GRPC_PROPAGATE_DEFAULTS,
+ exec_ctx, 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, NULL);
+ &host, deadline, nullptr);
grpc_slice_unref_internal(exec_ctx, host);
- if (glb_policy->client_stats != NULL) {
+ if (glb_policy->client_stats != nullptr) {
grpc_grpclb_client_stats_unref(glb_policy->client_stats);
}
glb_policy->client_stats = grpc_grpclb_client_stats_create();
@@ -1471,9 +1480,9 @@ static void lb_call_init_locked(grpc_exec_ctx* exec_ctx,
static void lb_call_destroy_locked(grpc_exec_ctx* exec_ctx,
glb_lb_policy* glb_policy) {
- GPR_ASSERT(glb_policy->lb_call != NULL);
+ GPR_ASSERT(glb_policy->lb_call != nullptr);
grpc_call_unref(glb_policy->lb_call);
- glb_policy->lb_call = NULL;
+ glb_policy->lb_call = nullptr;
grpc_metadata_array_destroy(&glb_policy->lb_initial_metadata_recv);
grpc_metadata_array_destroy(&glb_policy->lb_trailing_metadata_recv);
@@ -1491,17 +1500,17 @@ static void lb_call_destroy_locked(grpc_exec_ctx* exec_ctx,
*/
static void query_for_backends_locked(grpc_exec_ctx* exec_ctx,
glb_lb_policy* glb_policy) {
- GPR_ASSERT(glb_policy->lb_channel != NULL);
+ GPR_ASSERT(glb_policy->lb_channel != nullptr);
if (glb_policy->shutting_down) return;
lb_call_init_locked(exec_ctx, glb_policy);
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
+ if (grpc_lb_glb_trace.enabled()) {
gpr_log(GPR_INFO,
"[grpclb %p] Query for backends (lb_channel: %p, lb_call: %p)",
glb_policy, glb_policy->lb_channel, glb_policy->lb_call);
}
- GPR_ASSERT(glb_policy->lb_call != NULL);
+ GPR_ASSERT(glb_policy->lb_call != nullptr);
grpc_call_error call_error;
grpc_op ops[3];
@@ -1511,22 +1520,22 @@ static void query_for_backends_locked(grpc_exec_ctx* exec_ctx,
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 =
&glb_policy->lb_initial_metadata_recv;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- GPR_ASSERT(glb_policy->lb_request_payload != NULL);
+ GPR_ASSERT(glb_policy->lb_request_payload != nullptr);
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = glb_policy->lb_request_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
- call_error = grpc_call_start_batch_and_execute(exec_ctx, glb_policy->lb_call,
- ops, (size_t)(op - ops), NULL);
+ call_error = grpc_call_start_batch_and_execute(
+ exec_ctx, glb_policy->lb_call, ops, (size_t)(op - ops), nullptr);
GPR_ASSERT(GRPC_CALL_OK == call_error);
op = ops;
@@ -1537,7 +1546,7 @@ static void query_for_backends_locked(grpc_exec_ctx* exec_ctx,
op->data.recv_status_on_client.status_details =
&glb_policy->lb_call_status_details;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
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 */
@@ -1552,7 +1561,7 @@ static void query_for_backends_locked(grpc_exec_ctx* exec_ctx,
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &glb_policy->lb_response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
/* take another weak ref to be unref'd/reused in
* lb_on_response_received_locked */
@@ -1569,7 +1578,7 @@ static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg,
grpc_op ops[2];
memset(ops, 0, sizeof(ops));
grpc_op* op = ops;
- if (glb_policy->lb_response_payload != NULL) {
+ if (glb_policy->lb_response_payload != nullptr) {
grpc_backoff_reset(&glb_policy->lb_call_backoff_state);
/* Received data from the LB server. Look inside
* glb_policy->lb_response_payload, for a serverlist. */
@@ -1579,15 +1588,15 @@ static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg,
grpc_byte_buffer_reader_destroy(&bbr);
grpc_byte_buffer_destroy(glb_policy->lb_response_payload);
- grpc_grpclb_initial_response* response = NULL;
+ grpc_grpclb_initial_response* response = nullptr;
if (!glb_policy->seen_initial_response &&
(response = grpc_grpclb_initial_response_parse(response_slice)) !=
- NULL) {
+ nullptr) {
if (response->has_client_stats_report_interval) {
glb_policy->client_stats_report_interval = GPR_MAX(
GPR_MS_PER_SEC, grpc_grpclb_duration_to_millis(
&response->client_stats_report_interval));
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
+ if (grpc_lb_glb_trace.enabled()) {
gpr_log(GPR_INFO,
"[grpclb %p] Received initial LB response message; "
"client load reporting interval = %" PRIdPTR " milliseconds",
@@ -1599,7 +1608,7 @@ static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg,
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)) {
+ } else if (grpc_lb_glb_trace.enabled()) {
gpr_log(GPR_INFO,
"[grpclb %p] Received initial LB response message; client load "
"reporting NOT enabled",
@@ -1610,9 +1619,9 @@ static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg,
} 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)) {
+ if (serverlist != nullptr) {
+ GPR_ASSERT(glb_policy->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);
@@ -1630,7 +1639,7 @@ static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg,
if (serverlist->num_servers > 0) {
if (grpc_grpclb_serverlist_equals(glb_policy->serverlist,
serverlist)) {
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
+ if (grpc_lb_glb_trace.enabled()) {
gpr_log(GPR_INFO,
"[grpclb %p] Incoming server list identical to current, "
"ignoring.",
@@ -1638,14 +1647,14 @@ static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg,
}
grpc_grpclb_destroy_serverlist(serverlist);
} else { /* new serverlist */
- if (glb_policy->serverlist != NULL) {
+ 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(exec_ctx,
glb_policy->fallback_backend_addresses);
- glb_policy->fallback_backend_addresses = NULL;
+ glb_policy->fallback_backend_addresses = nullptr;
if (glb_policy->fallback_timer_active) {
grpc_timer_cancel(exec_ctx, &glb_policy->lb_fallback_timer);
glb_policy->fallback_timer_active = false;
@@ -1659,7 +1668,7 @@ static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg,
rr_handover_locked(exec_ctx, glb_policy);
}
} else {
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
+ if (grpc_lb_glb_trace.enabled()) {
gpr_log(GPR_INFO,
"[grpclb %p] Received empty server list, ignoring.",
glb_policy);
@@ -1679,7 +1688,7 @@ static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg,
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &glb_policy->lb_response_payload;
op->flags = 0;
- op->reserved = NULL;
+ op->reserved = nullptr;
op++;
/* reuse the "lb_on_response_received_locked" weak ref taken in
* query_for_backends_locked() */
@@ -1705,14 +1714,14 @@ static void lb_on_fallback_timer_locked(grpc_exec_ctx* exec_ctx, void* arg,
glb_policy->fallback_timer_active = false;
/* If we receive a serverlist after the timer fires but before this callback
* actually runs, don't fall back. */
- if (glb_policy->serverlist == NULL) {
+ if (glb_policy->serverlist == nullptr) {
if (!glb_policy->shutting_down && error == GRPC_ERROR_NONE) {
- if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
+ 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 != NULL);
+ GPR_ASSERT(glb_policy->fallback_backend_addresses != nullptr);
rr_handover_locked(exec_ctx, glb_policy);
}
}
@@ -1723,8 +1732,8 @@ static void lb_on_fallback_timer_locked(grpc_exec_ctx* exec_ctx, void* arg,
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)) {
+ GPR_ASSERT(glb_policy->lb_call != nullptr);
+ if (grpc_lb_glb_trace.enabled()) {
char* status_details =
grpc_slice_to_c_string(glb_policy->lb_call_status_details);
gpr_log(GPR_INFO,
@@ -1747,12 +1756,12 @@ static void lb_on_server_status_received_locked(grpc_exec_ctx* exec_ctx,
static void fallback_update_locked(grpc_exec_ctx* exec_ctx,
glb_lb_policy* glb_policy,
const grpc_lb_addresses* addresses) {
- GPR_ASSERT(glb_policy->fallback_backend_addresses != NULL);
+ GPR_ASSERT(glb_policy->fallback_backend_addresses != nullptr);
grpc_lb_addresses_destroy(exec_ctx, glb_policy->fallback_backend_addresses);
glb_policy->fallback_backend_addresses =
extract_backend_addresses_locked(exec_ctx, addresses);
if (glb_policy->lb_fallback_timeout_ms > 0 &&
- !glb_policy->fallback_timer_active) {
+ glb_policy->rr_policy != nullptr) {
rr_handover_locked(exec_ctx, glb_policy);
}
}
@@ -1762,8 +1771,8 @@ static void glb_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
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 == NULL || arg->type != GRPC_ARG_POINTER) {
- if (glb_policy->lb_channel == NULL) {
+ 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(
@@ -1783,10 +1792,10 @@ static void glb_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
(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 == NULL) {
+ if (glb_policy->serverlist == nullptr) {
fallback_update_locked(exec_ctx, glb_policy, addresses);
}
- GPR_ASSERT(glb_policy->lb_channel != NULL);
+ 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(
@@ -1809,7 +1818,7 @@ static void glb_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
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);
+ &glb_policy->lb_channel_on_connectivity_changed, nullptr);
}
}
@@ -1837,7 +1846,7 @@ static void glb_lb_channel_on_connectivity_changed_cb(grpc_exec_ctx* exec_ctx,
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);
+ &glb_policy->lb_channel_on_connectivity_changed, nullptr);
break;
}
case GRPC_CHANNEL_IDLE:
@@ -1845,12 +1854,12 @@ static void glb_lb_channel_on_connectivity_changed_cb(grpc_exec_ctx* exec_ctx,
// call to kick the lb channel into gear.
/* fallthrough */
case GRPC_CHANNEL_READY:
- if (glb_policy->lb_call != NULL) {
+ if (glb_policy->lb_call != nullptr) {
glb_policy->updating_lb_call = true;
- grpc_call_cancel(glb_policy->lb_call, NULL);
+ grpc_call_cancel(glb_policy->lb_call, nullptr);
// lb_on_server_status_received() will pick up the cancel and reinit
// lb_call.
- } else if (glb_policy->started_picking && !glb_policy->shutting_down) {
+ } else if (glb_policy->started_picking) {
if (glb_policy->retry_timer_active) {
grpc_timer_cancel(exec_ctx, &glb_policy->lb_call_retry_timer);
glb_policy->retry_timer_active = false;
@@ -1867,6 +1876,20 @@ static void glb_lb_channel_on_connectivity_changed_cb(grpc_exec_ctx* exec_ctx,
}
}
+static void glb_set_reresolve_closure_locked(
+ grpc_exec_ctx* exec_ctx, 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(exec_ctx, 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,
@@ -1878,7 +1901,8 @@ static const grpc_lb_policy_vtable glb_lb_policy_vtable = {
glb_exit_idle_locked,
glb_check_connectivity_locked,
glb_notify_on_state_change_locked,
- glb_update_locked};
+ glb_update_locked,
+ glb_set_reresolve_closure_locked};
static grpc_lb_policy* glb_create(grpc_exec_ctx* exec_ctx,
grpc_lb_policy_factory* factory,
@@ -1886,27 +1910,27 @@ static grpc_lb_policy* glb_create(grpc_exec_ctx* exec_ctx,
/* 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 == NULL || arg->type != GRPC_ARG_POINTER) {
- return NULL;
+ 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 NULL;
+ 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 != NULL);
+ GPR_ASSERT(arg != nullptr);
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)) {
+ 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);
@@ -1914,7 +1938,7 @@ static grpc_lb_policy* glb_create(grpc_exec_ctx* exec_ctx,
grpc_uri_destroy(uri);
glb_policy->cc_factory = args->client_channel_factory;
- GPR_ASSERT(glb_policy->cc_factory != NULL);
+ 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 =
@@ -1952,11 +1976,11 @@ static grpc_lb_policy* glb_create(grpc_exec_ctx* exec_ctx,
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) {
+ if (glb_policy->lb_channel == nullptr) {
gpr_free((void*)glb_policy->server_name);
grpc_channel_args_destroy(exec_ctx, glb_policy->args);
gpr_free(glb_policy);
- return NULL;
+ return nullptr;
}
grpc_subchannel_index_ref();
GRPC_CLOSURE_INIT(&glb_policy->lb_channel_on_connectivity_changed,
@@ -1990,24 +2014,20 @@ static bool maybe_add_client_load_reporting_filter(
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 &&
+ 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, NULL, NULL);
+ builder, (const grpc_channel_filter*)arg, nullptr, nullptr);
}
return true;
}
-extern "C" void grpc_lb_policy_grpclb_init() {
+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);
}
-extern "C" void grpc_lb_policy_grpclb_shutdown() {}
+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 b6135a4768..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
@@ -21,17 +21,9 @@
#include "src/core/ext/filters/client_channel/lb_policy_factory.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/** 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();
-#ifdef __cplusplus
-}
-#endif
-
#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.h b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h
index 39cbf53428..70b1c28b0d 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
@@ -23,10 +23,6 @@
#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h"
#include "src/core/lib/slice/slice_hash_table.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/** Create the channel used for communicating with an LB service.
* Note that an LB *service* may be comprised of several LB *servers*.
*
@@ -44,9 +40,5 @@ grpc_channel_args* grpc_lb_policy_grpclb_build_lb_channel_args(
grpc_fake_resolver_response_generator* response_generator,
const grpc_channel_args* args);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_GRPCLB_CHANNEL_H \
*/
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc
index 2dcf29fe0e..8eaa90e97b 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc
@@ -35,7 +35,7 @@ grpc_channel* grpc_lb_policy_grpclb_create_lb_channel(
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 */
@@ -43,7 +43,7 @@ grpc_channel* grpc_lb_policy_grpclb_create_lb_channel(
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 */
@@ -55,7 +55,7 @@ grpc_channel* grpc_lb_policy_grpclb_create_lb_channel(
grpc_channel* lb_channel = grpc_client_channel_factory_create_channel(
exec_ctx, client_channel_factory, lb_service_target_addresses,
GRPC_CLIENT_CHANNEL_TYPE_LOAD_BALANCING, new_args);
- if (channel_credentials != NULL) {
+ if (channel_credentials != nullptr) {
grpc_channel_args_destroy(exec_ctx, new_args);
}
return lb_channel;
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc
index 903120ca7d..e19a6a71aa 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc
@@ -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 ce88cf9ee4..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
@@ -23,10 +23,6 @@
#include <grpc/impl/codegen/grpc_types.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_grpclb_client_stats grpc_grpclb_client_stats;
typedef struct {
@@ -65,9 +61,5 @@ void grpc_grpclb_client_stats_get_locked(
void grpc_grpclb_dropped_call_counts_destroy(
grpc_grpclb_dropped_call_counts* drop_entries);
-#ifdef __cplusplus
-}
-#endif
-
#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.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc
index 341b4e4f08..fc781da330 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc
@@ -89,7 +89,7 @@ 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;
+ 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;
@@ -165,10 +165,10 @@ 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(
@@ -196,7 +196,7 @@ 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) {
@@ -212,14 +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;
}
}
return sl;
}
void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist* serverlist) {
- if (serverlist == NULL) {
+ if (serverlist == nullptr) {
return;
}
for (size_t i = 0; i < serverlist->num_servers; i++) {
@@ -246,7 +246,7 @@ grpc_grpclb_serverlist* grpc_grpclb_serverlist_copy(
bool grpc_grpclb_serverlist_equals(const grpc_grpclb_serverlist* lhs,
const grpc_grpclb_serverlist* rhs) {
- if (lhs == NULL || rhs == NULL) {
+ if (lhs == nullptr || rhs == nullptr) {
return false;
}
if (lhs->num_servers != rhs->num_servers) {
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 be44695c57..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;
@@ -86,9 +82,5 @@ grpc_millis grpc_grpclb_duration_to_millis(grpc_grpclb_duration* duration_pb);
void grpc_grpclb_initial_response_destroy(
grpc_grpclb_initial_response* response);
-#ifdef __cplusplus
-}
-#endif
-
#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/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
index c79ee5687d..228a77d9db 100644
--- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
@@ -29,8 +29,7 @@
#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");
+grpc_core::TraceFlag grpc_lb_pick_first_trace(false, "pick_first");
typedef struct pending_pick {
struct pending_pick* next;
@@ -60,61 +59,59 @@ typedef struct {
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->subchannel_list == NULL);
- GPR_ASSERT(p->latest_pending_subchannel_list == NULL);
- GPR_ASSERT(p->pending_picks == NULL);
+ GPR_ASSERT(p->subchannel_list == nullptr);
+ GPR_ASSERT(p->latest_pending_subchannel_list == nullptr);
+ GPR_ASSERT(p->pending_picks == nullptr);
grpc_connectivity_state_destroy(exec_ctx, &p->state_tracker);
gpr_free(p);
grpc_subchannel_index_unref();
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
+ if (grpc_lb_pick_first_trace.enabled()) {
gpr_log(GPR_DEBUG, "Pick First %p destroyed.", (void*)p);
}
}
-static void shutdown_locked(grpc_exec_ctx* exec_ctx, pick_first_lb_policy* p,
- grpc_error* error) {
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
+static void pf_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
+ 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;
pending_pick* pp;
- while ((pp = p->pending_picks) != NULL) {
+ while ((pp = p->pending_picks) != nullptr) {
p->pending_picks = pp->next;
- *pp->target = NULL;
+ *pp->target = nullptr;
GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete, GRPC_ERROR_REF(error));
gpr_free(pp);
}
grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_REF(error),
"shutdown");
- if (p->subchannel_list != NULL) {
+ if (p->subchannel_list != nullptr) {
grpc_lb_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
"pf_shutdown");
- p->subchannel_list = NULL;
+ p->subchannel_list = nullptr;
}
- if (p->latest_pending_subchannel_list != NULL) {
+ if (p->latest_pending_subchannel_list != nullptr) {
grpc_lb_subchannel_list_shutdown_and_unref(
exec_ctx, p->latest_pending_subchannel_list, "pf_shutdown");
- p->latest_pending_subchannel_list = NULL;
+ p->latest_pending_subchannel_list = nullptr;
}
+ grpc_lb_policy_try_reresolve(exec_ctx, &p->base, &grpc_lb_pick_first_trace,
+ GRPC_ERROR_CANCELLED);
GRPC_ERROR_UNREF(error);
}
-static void pf_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
- shutdown_locked(exec_ctx, (pick_first_lb_policy*)pol,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel shutdown"));
-}
-
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 = p->pending_picks;
- p->pending_picks = NULL;
- while (pp != NULL) {
+ p->pending_picks = nullptr;
+ while (pp != nullptr) {
pending_pick* next = pp->next;
if (pp->target == target) {
- *target = NULL;
+ *target = nullptr;
GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Pick Cancelled", &error, 1));
@@ -134,8 +131,8 @@ static void pf_cancel_picks_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
grpc_error* error) {
pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
pending_pick* pp = p->pending_picks;
- p->pending_picks = NULL;
- while (pp != NULL) {
+ p->pending_picks = nullptr;
+ while (pp != nullptr) {
pending_pick* next = pp->next;
if ((pp->initial_metadata_flags & initial_metadata_flags_mask) ==
initial_metadata_flags_eq) {
@@ -155,12 +152,18 @@ static void pf_cancel_picks_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
static void start_picking_locked(grpc_exec_ctx* exec_ctx,
pick_first_lb_policy* p) {
p->started_picking = true;
- if (p->subchannel_list != NULL && p->subchannel_list->num_subchannels > 0) {
+ if (p->subchannel_list != nullptr &&
+ p->subchannel_list->num_subchannels > 0) {
p->subchannel_list->checking_subchannel = 0;
- grpc_lb_subchannel_list_ref_for_connectivity_watch(
- p->subchannel_list, "connectivity_watch+start_picking");
- grpc_lb_subchannel_data_start_connectivity_watch(
- exec_ctx, &p->subchannel_list->subchannels[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(
+ exec_ctx, &p->subchannel_list->subchannels[i]);
+ break;
+ }
+ }
}
}
@@ -178,7 +181,7 @@ static int pf_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
grpc_closure* on_complete) {
pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
// If we have a selected subchannel already, return synchronously.
- if (p->selected != NULL) {
+ if (p->selected != nullptr) {
*target = GRPC_CONNECTED_SUBCHANNEL_REF(p->selected->connected_subchannel,
"picked");
return 1;
@@ -242,8 +245,8 @@ static void pf_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
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->subchannel_list == NULL) {
+ 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(
exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
@@ -260,7 +263,7 @@ static void pf_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
}
const grpc_lb_addresses* addresses =
(const grpc_lb_addresses*)arg->value.pointer.p;
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
+ 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);
}
@@ -274,18 +277,18 @@ static void pf_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty update"),
"pf_update_empty");
- if (p->subchannel_list != NULL) {
+ if (p->subchannel_list != nullptr) {
grpc_lb_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
"sl_shutdown_empty_update");
}
p->subchannel_list = subchannel_list; // Empty list.
- p->selected = NULL;
+ p->selected = nullptr;
return;
}
- if (p->selected == NULL) {
+ if (p->selected == nullptr) {
// We don't yet have a selected subchannel, so replace the current
// subchannel list immediately.
- if (p->subchannel_list != NULL) {
+ if (p->subchannel_list != nullptr) {
grpc_lb_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
"pf_update_before_selected");
}
@@ -297,35 +300,35 @@ static void pf_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
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_TRACER_ON(grpc_lb_pick_first_trace)) {
+ 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);
}
- grpc_lb_subchannel_list_ref_for_connectivity_watch(
- subchannel_list, "connectivity_watch+replace_selected");
- grpc_lb_subchannel_data_start_connectivity_watch(exec_ctx, sd);
- if (p->subchannel_list != NULL) {
- grpc_lb_subchannel_list_shutdown_and_unref(
- exec_ctx, p->subchannel_list, "pf_update_includes_selected");
- }
- p->subchannel_list = subchannel_list;
- if (p->selected->connected_subchannel != NULL) {
+ if (p->selected->connected_subchannel != nullptr) {
sd->connected_subchannel = GRPC_CONNECTED_SUBCHANNEL_REF(
p->selected->connected_subchannel, "pf_update_includes_selected");
}
p->selected = sd;
+ if (p->subchannel_list != nullptr) {
+ grpc_lb_subchannel_list_shutdown_and_unref(
+ exec_ctx, p->subchannel_list, "pf_update_includes_selected");
+ }
+ p->subchannel_list = subchannel_list;
destroy_unselected_subchannels_locked(exec_ctx, p);
+ grpc_lb_subchannel_list_ref_for_connectivity_watch(
+ subchannel_list, "connectivity_watch+replace_selected");
+ grpc_lb_subchannel_data_start_connectivity_watch(exec_ctx, 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 != NULL) {
+ if (p->latest_pending_subchannel_list != nullptr) {
grpc_lb_subchannel_list_shutdown_and_unref(
exec_ctx, p->latest_pending_subchannel_list,
"pf_update_includes_selected+outdated");
- p->latest_pending_subchannel_list = NULL;
+ p->latest_pending_subchannel_list = nullptr;
}
return;
}
@@ -334,8 +337,8 @@ static void pf_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
// 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 != NULL) {
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
+ 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",
@@ -362,7 +365,7 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, 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_TRACER_ON(grpc_lb_pick_first_trace)) {
+ if (grpc_lb_pick_first_trace.enabled()) {
gpr_log(GPR_DEBUG,
"Pick First %p connectivity changed for subchannel %p (%" PRIuPTR
" of %" PRIuPTR
@@ -402,31 +405,48 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
// 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 != NULL) {
- p->selected = NULL;
+ p->latest_pending_subchannel_list != nullptr) {
+ p->selected = nullptr;
+ grpc_lb_subchannel_data_stop_connectivity_watch(exec_ctx, sd);
+ grpc_lb_subchannel_list_unref_for_connectivity_watch(
+ exec_ctx, sd->subchannel_list, "selected_not_ready+switch_to_update");
grpc_lb_subchannel_list_shutdown_and_unref(
exec_ctx, p->subchannel_list, "selected_not_ready+switch_to_update");
p->subchannel_list = p->latest_pending_subchannel_list;
- p->latest_pending_subchannel_list = NULL;
+ p->latest_pending_subchannel_list = nullptr;
grpc_connectivity_state_set(
exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
GRPC_ERROR_REF(error), "selected_not_ready+switch_to_update");
} else {
- if (sd->curr_connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
- /* if the selected channel goes bad, we're done */
- sd->curr_connectivity_state = GRPC_CHANNEL_SHUTDOWN;
+ // 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.
+ if (sd->curr_connectivity_state == GRPC_CHANNEL_SHUTDOWN ||
+ sd->curr_connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
+ // If the selected channel goes bad, request a re-resolution.
+ grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
+ GRPC_CHANNEL_IDLE, GRPC_ERROR_NONE,
+ "selected_changed+reresolve");
+ p->started_picking = false;
+ grpc_lb_policy_try_reresolve(
+ exec_ctx, &p->base, &grpc_lb_pick_first_trace, GRPC_ERROR_NONE);
+ } else {
+ grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
+ sd->curr_connectivity_state,
+ GRPC_ERROR_REF(error), "selected_changed");
}
- grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
- sd->curr_connectivity_state,
- GRPC_ERROR_REF(error), "selected_changed");
if (sd->curr_connectivity_state != GRPC_CHANNEL_SHUTDOWN) {
// Renew notification.
grpc_lb_subchannel_data_start_connectivity_watch(exec_ctx, sd);
} else {
+ p->selected = nullptr;
grpc_lb_subchannel_data_stop_connectivity_watch(exec_ctx, sd);
grpc_lb_subchannel_list_unref_for_connectivity_watch(
exec_ctx, sd->subchannel_list, "pf_selected_shutdown");
- shutdown_locked(exec_ctx, p, GRPC_ERROR_REF(error));
+ grpc_lb_subchannel_data_unref_subchannel(exec_ctx, sd,
+ "pf_selected_shutdown");
}
}
return;
@@ -445,11 +465,11 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
// Case 2. Promote p->latest_pending_subchannel_list to
// p->subchannel_list.
if (sd->subchannel_list == p->latest_pending_subchannel_list) {
- GPR_ASSERT(p->subchannel_list != NULL);
+ GPR_ASSERT(p->subchannel_list != nullptr);
grpc_lb_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
"finish_update");
p->subchannel_list = p->latest_pending_subchannel_list;
- p->latest_pending_subchannel_list = NULL;
+ p->latest_pending_subchannel_list = nullptr;
}
// Cases 1 and 2.
grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
@@ -459,7 +479,7 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
grpc_subchannel_get_connected_subchannel(sd->subchannel),
"connected");
p->selected = sd;
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
+ if (grpc_lb_pick_first_trace.enabled()) {
gpr_log(GPR_INFO, "Pick First %p selected subchannel %p", (void*)p,
(void*)sd->subchannel);
}
@@ -471,7 +491,7 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
p->pending_picks = pp->next;
*pp->target = GRPC_CONNECTED_SUBCHANNEL_REF(
p->selected->connected_subchannel, "picked");
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
+ if (grpc_lb_pick_first_trace.enabled()) {
gpr_log(GPR_INFO,
"Servicing pending pick with selected subchannel %p",
(void*)p->selected);
@@ -491,7 +511,7 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
sd->subchannel_list->num_subchannels;
sd = &sd->subchannel_list
->subchannels[sd->subchannel_list->checking_subchannel];
- } while (sd->subchannel == NULL);
+ } 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 &&
@@ -528,27 +548,40 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
sd->subchannel_list->num_subchannels;
sd = &sd->subchannel_list
->subchannels[sd->subchannel_list->checking_subchannel];
- } while (sd->subchannel == NULL && sd != original_sd);
+ } while (sd->subchannel == nullptr && sd != original_sd);
if (sd == original_sd) {
grpc_lb_subchannel_list_unref_for_connectivity_watch(
- exec_ctx, sd->subchannel_list, "pf_candidate_shutdown");
- shutdown_locked(exec_ctx, p,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Pick first exhausted channels", &error, 1));
- break;
- }
- if (sd->subchannel_list == p->subchannel_list) {
- grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
- GRPC_CHANNEL_TRANSIENT_FAILURE,
- GRPC_ERROR_REF(error), "subchannel_failed");
+ exec_ctx, sd->subchannel_list, "pf_exhausted_subchannels");
+ if (sd->subchannel_list == p->subchannel_list) {
+ grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
+ GRPC_CHANNEL_IDLE, GRPC_ERROR_NONE,
+ "exhausted_subchannels+reresolve");
+ p->started_picking = false;
+ grpc_lb_policy_try_reresolve(
+ exec_ctx, &p->base, &grpc_lb_pick_first_trace, GRPC_ERROR_NONE);
+ }
+ } else {
+ if (sd->subchannel_list == p->subchannel_list) {
+ grpc_connectivity_state_set(
+ exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ GRPC_ERROR_REF(error), "subchannel_failed");
+ }
+ // Reuses the connectivity refs from the previous watch.
+ grpc_lb_subchannel_data_start_connectivity_watch(exec_ctx, sd);
}
- // Reuses the connectivity refs from the previous watch.
- grpc_lb_subchannel_data_start_connectivity_watch(exec_ctx, sd);
- break;
}
}
}
+static void pf_set_reresolve_closure_locked(
+ grpc_exec_ctx* exec_ctx, 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,
@@ -559,7 +592,8 @@ static const grpc_lb_policy_vtable pick_first_lb_policy_vtable = {
pf_exit_idle_locked,
pf_check_connectivity_locked,
pf_notify_on_state_change_locked,
- pf_update_locked};
+ pf_update_locked,
+ pf_set_reresolve_closure_locked};
static void pick_first_factory_ref(grpc_lb_policy_factory* factory) {}
@@ -568,9 +602,9 @@ 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);
+ GPR_ASSERT(args->client_channel_factory != nullptr);
pick_first_lb_policy* p = (pick_first_lb_policy*)gpr_zalloc(sizeof(*p));
- if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
+ if (grpc_lb_pick_first_trace.enabled()) {
gpr_log(GPR_DEBUG, "Pick First %p created.", (void*)p);
}
pf_update_locked(exec_ctx, &p->base, args);
@@ -592,9 +626,8 @@ static grpc_lb_policy_factory* pick_first_lb_factory_create() {
/* Plugin registration */
-extern "C" void grpc_lb_policy_pick_first_init() {
+void grpc_lb_policy_pick_first_init() {
grpc_register_lb_policy(pick_first_lb_factory_create());
- grpc_register_tracer(&grpc_lb_pick_first_trace);
}
-extern "C" void grpc_lb_policy_pick_first_shutdown() {}
+void grpc_lb_policy_pick_first_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
index df235922c8..c05557ba6f 100644
--- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc
@@ -20,9 +20,9 @@
*
* 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. */
+ * 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>
@@ -39,8 +39,7 @@
#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");
+grpc_core::TraceFlag grpc_lb_round_robin_trace(false, "round_robin");
/** List of entities waiting for a pick.
*
@@ -100,8 +99,8 @@ typedef struct round_robin_lb_policy {
* 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_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",
@@ -111,7 +110,7 @@ static size_t get_next_ready_subchannel_index_locked(
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)) {
+ if (grpc_lb_round_robin_trace.enabled()) {
gpr_log(
GPR_DEBUG,
"[RR %p] checking subchannel %p, subchannel_list %p, index %lu: "
@@ -123,7 +122,7 @@ static size_t get_next_ready_subchannel_index_locked(
}
if (p->subchannel_list->subchannels[index].curr_connectivity_state ==
GRPC_CHANNEL_READY) {
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
+ 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",
@@ -134,7 +133,7 @@ static size_t get_next_ready_subchannel_index_locked(
return index;
}
}
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
+ 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;
@@ -145,7 +144,7 @@ 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)) {
+ 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,
@@ -157,63 +156,60 @@ static void update_last_ready_subchannel_index_locked(round_robin_lb_policy* p,
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)) {
+ 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 == NULL);
- GPR_ASSERT(p->latest_pending_subchannel_list == NULL);
+ GPR_ASSERT(p->subchannel_list == nullptr);
+ GPR_ASSERT(p->latest_pending_subchannel_list == nullptr);
grpc_connectivity_state_destroy(exec_ctx, &p->state_tracker);
grpc_subchannel_index_unref();
gpr_free(p);
}
-static void shutdown_locked(grpc_exec_ctx* exec_ctx, round_robin_lb_policy* p,
- grpc_error* error) {
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
+static void rr_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
+ 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;
pending_pick* pp;
- while ((pp = p->pending_picks) != NULL) {
+ while ((pp = p->pending_picks) != nullptr) {
p->pending_picks = pp->next;
- *pp->target = NULL;
+ *pp->target = nullptr;
GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete, GRPC_ERROR_REF(error));
gpr_free(pp);
}
grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_REF(error),
"rr_shutdown");
- if (p->subchannel_list != NULL) {
+ if (p->subchannel_list != nullptr) {
grpc_lb_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
"sl_shutdown_rr_shutdown");
- p->subchannel_list = NULL;
+ p->subchannel_list = nullptr;
}
- if (p->latest_pending_subchannel_list != NULL) {
+ if (p->latest_pending_subchannel_list != nullptr) {
grpc_lb_subchannel_list_shutdown_and_unref(
exec_ctx, p->latest_pending_subchannel_list,
"sl_shutdown_pending_rr_shutdown");
- p->latest_pending_subchannel_list = NULL;
+ p->latest_pending_subchannel_list = nullptr;
}
+ grpc_lb_policy_try_reresolve(exec_ctx, &p->base, &grpc_lb_round_robin_trace,
+ GRPC_ERROR_CANCELLED);
GRPC_ERROR_UNREF(error);
}
-static void rr_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
- round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
- shutdown_locked(exec_ctx, p,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Shutdown"));
-}
-
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) {
+ p->pending_picks = nullptr;
+ while (pp != nullptr) {
pending_pick* next = pp->next;
if (pp->target == target) {
- *target = NULL;
+ *target = nullptr;
GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Pick cancelled", &error, 1));
@@ -233,12 +229,12 @@ static void rr_cancel_picks_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
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) {
+ p->pending_picks = nullptr;
+ while (pp != nullptr) {
pending_pick* next = pp->next;
if ((pp->initial_metadata_flags & initial_metadata_flags_mask) ==
initial_metadata_flags_eq) {
- *pp->target = NULL;
+ *pp->target = nullptr;
GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Pick cancelled", &error, 1));
@@ -256,10 +252,12 @@ 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++) {
- grpc_lb_subchannel_list_ref_for_connectivity_watch(p->subchannel_list,
- "connectivity_watch");
- grpc_lb_subchannel_data_start_connectivity_watch(
- exec_ctx, &p->subchannel_list->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(
+ exec_ctx, &p->subchannel_list->subchannels[i]);
+ }
}
}
@@ -276,12 +274,12 @@ static int rr_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
grpc_call_context_element* context, void** user_data,
grpc_closure* on_complete) {
round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
+ if (grpc_lb_round_robin_trace.enabled()) {
gpr_log(GPR_INFO, "[RR %p] Trying to pick (shutdown: %d)", (void*)pol,
p->shutdown);
}
GPR_ASSERT(!p->shutdown);
- if (p->subchannel_list != NULL) {
+ 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 */
@@ -289,10 +287,10 @@ static int rr_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
&p->subchannel_list->subchannels[next_ready_index];
*target =
GRPC_CONNECTED_SUBCHANNEL_REF(sd->connected_subchannel, "rr_picked");
- if (user_data != NULL) {
+ if (user_data != nullptr) {
*user_data = sd->user_data;
}
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
+ if (grpc_lb_round_robin_trace.enabled()) {
gpr_log(
GPR_DEBUG,
"[RR %p] Picked target <-- Subchannel %p (connected %p) (sl %p, "
@@ -347,71 +345,63 @@ static void update_state_counters_locked(grpc_lb_subchannel_data* sd) {
}
/** Sets the policy's connectivity status based on that of the passed-in \a sd
- * (the grpc_lb_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, grpc_lb_subchannel_data* sd, grpc_error* error) {
+ * (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_exec_ctx* exec_ctx,
+ 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: At least one subchannel is ready iff p->ready_list is NOT empty.
+ * 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 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.
+ * 3) RULE: ALL subchannels are SHUTDOWN => policy is IDLE (and requests
+ * re-resolution).
+ * CHECK: subchannel_list->num_shutdown ==
+ * subchannel_list->num_subchannels.
*
- * 5) RULE: ALL subchannels are IDLE => policy is IDLE.
- * CHECK: p->num_idle == p->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.
*/
- grpc_connectivity_state new_state = sd->curr_connectivity_state;
+ // 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;
- if (subchannel_list->num_ready > 0) { /* 1) READY */
+ GPR_ASSERT(sd->curr_connectivity_state != GRPC_CHANNEL_IDLE);
+ 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 */
+ } 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;
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
- gpr_log(GPR_INFO,
- "[RR %p] Shutting down: all subchannels have gone into shutdown",
- (void*)p);
- }
- } else if (subchannel_list->num_transient_failures ==
- p->subchannel_list->num_subchannels) { /* 4) TRANSIENT_FAILURE */
+ } else if (subchannel_list->num_shutdown ==
+ subchannel_list->num_subchannels) {
+ /* 3) IDLE and re-resolve */
+ grpc_connectivity_state_set(exec_ctx, &p->state_tracker, GRPC_CHANNEL_IDLE,
+ GRPC_ERROR_NONE,
+ "rr_exhausted_subchannels+reresolve");
+ p->started_picking = false;
+ grpc_lb_policy_try_reresolve(exec_ctx, &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(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,
@@ -419,7 +409,7 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
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_TRACER_ON(grpc_lb_round_robin_trace)) {
+ if (grpc_lb_round_robin_trace.enabled()) {
gpr_log(
GPR_DEBUG,
"[RR %p] connectivity changed for subchannel %p, subchannel_list %p: "
@@ -455,24 +445,19 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
// 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 and new overall state.
update_state_counters_locked(sd);
- 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.
+ update_lb_connectivity_status_locked(exec_ctx, sd, GRPC_ERROR_REF(error));
+ // If the sd's new state is SHUTDOWN, unref the subchannel.
if (sd->curr_connectivity_state == GRPC_CHANNEL_SHUTDOWN) {
grpc_lb_subchannel_data_stop_connectivity_watch(exec_ctx, sd);
grpc_lb_subchannel_data_unref_subchannel(exec_ctx, sd,
"rr_connectivity_shutdown");
grpc_lb_subchannel_list_unref_for_connectivity_watch(
exec_ctx, sd->subchannel_list, "rr_connectivity_shutdown");
- if (new_policy_connectivity_state == GRPC_CHANNEL_SHUTDOWN) {
- shutdown_locked(exec_ctx, p, GRPC_ERROR_REF(error));
- }
} else { // sd not in SHUTDOWN
if (sd->curr_connectivity_state == GRPC_CHANNEL_READY) {
- if (sd->connected_subchannel == NULL) {
+ if (sd->connected_subchannel == nullptr) {
sd->connected_subchannel = GRPC_CONNECTED_SUBCHANNEL_REF(
grpc_subchannel_get_connected_subchannel(sd->subchannel),
"connected");
@@ -484,9 +469,9 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
// 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)) {
+ if (grpc_lb_round_robin_trace.enabled()) {
const unsigned long num_subchannels =
- p->subchannel_list != NULL
+ p->subchannel_list != nullptr
? (unsigned long)p->subchannel_list->num_subchannels
: 0;
gpr_log(GPR_DEBUG,
@@ -495,22 +480,22 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
(void*)p, (void*)p->subchannel_list, num_subchannels,
(void*)sd->subchannel_list, num_subchannels);
}
- if (p->subchannel_list != NULL) {
+ if (p->subchannel_list != nullptr) {
// dispose of the current subchannel_list
grpc_lb_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;
+ 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 preemtively replicates rr_pick()'s actions. */
+ * 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 != NULL) {
+ 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);
@@ -520,10 +505,10 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
p->pending_picks = pp->next;
*pp->target = GRPC_CONNECTED_SUBCHANNEL_REF(
selected->connected_subchannel, "rr_picked");
- if (pp->user_data != NULL) {
+ if (pp->user_data != nullptr) {
*pp->user_data = selected->user_data;
}
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
+ if (grpc_lb_round_robin_trace.enabled()) {
gpr_log(GPR_DEBUG,
"[RR %p] Fulfilling pending pick. Target <-- subchannel %p "
"(subchannel_list %p, index %lu)",
@@ -577,11 +562,11 @@ static void rr_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
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 (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 == NULL) {
+ if (p->subchannel_list == nullptr) {
grpc_connectivity_state_set(
exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing update in args"),
@@ -590,7 +575,7 @@ static void rr_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
return;
}
grpc_lb_addresses* addresses = (grpc_lb_addresses*)arg->value.pointer.p;
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
+ if (grpc_lb_round_robin_trace.enabled()) {
gpr_log(GPR_DEBUG, "[RR %p] received update with %" PRIuPTR " addresses", p,
addresses->num_addresses);
}
@@ -602,7 +587,7 @@ static void rr_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
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) {
+ if (p->subchannel_list != nullptr) {
grpc_lb_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
"sl_shutdown_empty_update");
}
@@ -610,8 +595,8 @@ static void rr_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
return;
}
if (p->started_picking) {
- if (p->latest_pending_subchannel_list != NULL) {
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
+ 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",
@@ -635,7 +620,7 @@ static void rr_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
} else {
// The policy isn't picking yet. Save the update for later, disposing of
// previous version if any.
- if (p->subchannel_list != NULL) {
+ if (p->subchannel_list != nullptr) {
grpc_lb_subchannel_list_shutdown_and_unref(
exec_ctx, p->subchannel_list, "rr_update_before_started_picking");
}
@@ -643,6 +628,15 @@ static void rr_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
}
}
+static void rr_set_reresolve_closure_locked(
+ grpc_exec_ctx* exec_ctx, 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,
@@ -653,7 +647,8 @@ static const grpc_lb_policy_vtable round_robin_lb_policy_vtable = {
rr_exit_idle_locked,
rr_check_connectivity_locked,
rr_notify_on_state_change_locked,
- rr_update_locked};
+ rr_update_locked,
+ rr_set_reresolve_closure_locked};
static void round_robin_factory_ref(grpc_lb_policy_factory* factory) {}
@@ -662,14 +657,14 @@ 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);
+ 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(exec_ctx, &p->base, args);
- if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
+ 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);
}
@@ -689,9 +684,8 @@ static grpc_lb_policy_factory* round_robin_lb_factory_create() {
/* Plugin registration */
-extern "C" void grpc_lb_policy_round_robin_init() {
+void grpc_lb_policy_round_robin_init() {
grpc_register_lb_policy(round_robin_lb_factory_create());
- grpc_register_tracer(&grpc_lb_round_robin_trace);
}
-extern "C" void grpc_lb_policy_round_robin_shutdown() {}
+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
index db38ef5305..b6fce4d207 100644
--- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc
@@ -31,38 +31,38 @@
void grpc_lb_subchannel_data_unref_subchannel(grpc_exec_ctx* exec_ctx,
grpc_lb_subchannel_data* sd,
const char* reason) {
- if (sd->subchannel != NULL) {
- if (GRPC_TRACER_ON(*sd->subchannel_list->tracer)) {
+ 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->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(exec_ctx, sd->subchannel, reason);
- sd->subchannel = NULL;
- if (sd->connected_subchannel != NULL) {
+ sd->subchannel = nullptr;
+ if (sd->connected_subchannel != nullptr) {
GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, sd->connected_subchannel,
reason);
- sd->connected_subchannel = NULL;
+ sd->connected_subchannel = nullptr;
}
- if (sd->user_data != NULL) {
- GPR_ASSERT(sd->user_data_vtable != NULL);
+ if (sd->user_data != nullptr) {
+ GPR_ASSERT(sd->user_data_vtable != nullptr);
sd->user_data_vtable->destroy(exec_ctx, sd->user_data);
- sd->user_data = NULL;
+ sd->user_data = nullptr;
}
}
}
void grpc_lb_subchannel_data_start_connectivity_watch(
grpc_exec_ctx* exec_ctx, grpc_lb_subchannel_data* sd) {
- if (GRPC_TRACER_ON(*sd->subchannel_list->tracer)) {
+ 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->tracer->name(), sd->subchannel_list->policy,
sd->subchannel_list,
(size_t)(sd - sd->subchannel_list->subchannels),
sd->subchannel_list->num_subchannels, sd->subchannel);
@@ -76,11 +76,11 @@ void grpc_lb_subchannel_data_start_connectivity_watch(
void grpc_lb_subchannel_data_stop_connectivity_watch(
grpc_exec_ctx* exec_ctx, grpc_lb_subchannel_data* sd) {
- if (GRPC_TRACER_ON(*sd->subchannel_list->tracer)) {
+ 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->tracer->name(), sd->subchannel_list->policy,
sd->subchannel_list,
(size_t)(sd - sd->subchannel_list->subchannels),
sd->subchannel_list->num_subchannels, sd->subchannel);
@@ -90,15 +90,15 @@ void grpc_lb_subchannel_data_stop_connectivity_watch(
}
grpc_lb_subchannel_list* grpc_lb_subchannel_list_create(
- grpc_exec_ctx* exec_ctx, grpc_lb_policy* p, grpc_tracer_flag* tracer,
+ grpc_exec_ctx* exec_ctx, 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 (GRPC_TRACER_ON(*tracer)) {
+ if (tracer->enabled()) {
gpr_log(GPR_DEBUG,
"[%s %p] Creating subchannel list %p for %" PRIuPTR " subchannels",
- tracer->name, p, subchannel_list, addresses->num_addresses);
+ tracer->name(), p, subchannel_list, addresses->num_addresses);
}
subchannel_list->policy = p;
subchannel_list->tracer = tracer;
@@ -126,26 +126,26 @@ grpc_lb_subchannel_list* grpc_lb_subchannel_list_create(
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);
- if (subchannel == NULL) {
+ if (subchannel == nullptr) {
// Subchannel could not be created.
- if (GRPC_TRACER_ON(*tracer)) {
+ 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);
+ tracer->name(), subchannel_list->policy, address_uri);
gpr_free(address_uri);
}
continue;
}
- if (GRPC_TRACER_ON(*tracer)) {
+ 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,
+ tracer->name(), p, subchannel_list, subchannel_index, subchannel,
address_uri);
gpr_free(address_uri);
}
@@ -162,7 +162,7 @@ grpc_lb_subchannel_list* grpc_lb_subchannel_list_create(
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 != NULL) {
+ if (sd->user_data_vtable != nullptr) {
sd->user_data =
sd->user_data_vtable->copy(addresses->addresses[i].user_data);
}
@@ -174,9 +174,9 @@ grpc_lb_subchannel_list* grpc_lb_subchannel_list_create(
static void subchannel_list_destroy(grpc_exec_ctx* exec_ctx,
grpc_lb_subchannel_list* subchannel_list) {
- if (GRPC_TRACER_ON(*subchannel_list->tracer)) {
+ if (subchannel_list->tracer->enabled()) {
gpr_log(GPR_DEBUG, "[%s %p] Destroying subchannel_list %p",
- subchannel_list->tracer->name, subchannel_list->policy,
+ subchannel_list->tracer->name(), subchannel_list->policy,
subchannel_list);
}
for (size_t i = 0; i < subchannel_list->num_subchannels; i++) {
@@ -191,10 +191,10 @@ static void subchannel_list_destroy(grpc_exec_ctx* exec_ctx,
void grpc_lb_subchannel_list_ref(grpc_lb_subchannel_list* subchannel_list,
const char* reason) {
gpr_ref_non_zero(&subchannel_list->refcount);
- if (GRPC_TRACER_ON(*subchannel_list->tracer)) {
+ 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->tracer->name(), subchannel_list->policy,
subchannel_list, (unsigned long)(count - 1), (unsigned long)count,
reason);
}
@@ -204,10 +204,10 @@ void grpc_lb_subchannel_list_unref(grpc_exec_ctx* exec_ctx,
grpc_lb_subchannel_list* subchannel_list,
const char* reason) {
const bool done = gpr_unref(&subchannel_list->refcount);
- if (GRPC_TRACER_ON(*subchannel_list->tracer)) {
+ 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->tracer->name(), subchannel_list->policy,
subchannel_list, (unsigned long)(count + 1), (unsigned long)count,
reason);
}
@@ -231,25 +231,26 @@ void grpc_lb_subchannel_list_unref_for_connectivity_watch(
static void subchannel_data_cancel_connectivity_watch(
grpc_exec_ctx* exec_ctx, grpc_lb_subchannel_data* sd, const char* reason) {
- if (GRPC_TRACER_ON(*sd->subchannel_list->tracer)) {
+ 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->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(exec_ctx, sd->subchannel, NULL, NULL,
+ grpc_subchannel_notify_on_state_change(exec_ctx, sd->subchannel, nullptr,
+ nullptr,
&sd->connectivity_changed_closure);
}
void grpc_lb_subchannel_list_shutdown_and_unref(
grpc_exec_ctx* exec_ctx, grpc_lb_subchannel_list* subchannel_list,
const char* reason) {
- if (GRPC_TRACER_ON(*subchannel_list->tracer)) {
+ 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->tracer->name(), subchannel_list->policy,
subchannel_list, reason);
}
GPR_ASSERT(!subchannel_list->shutting_down);
@@ -261,7 +262,7 @@ void grpc_lb_subchannel_list_shutdown_and_unref(
// Otherwise, unref the subchannel directly.
if (sd->connectivity_notification_pending) {
subchannel_data_cancel_connectivity_watch(exec_ctx, sd, reason);
- } else if (sd->subchannel != NULL) {
+ } else if (sd->subchannel != nullptr) {
grpc_lb_subchannel_data_unref_subchannel(exec_ctx, sd, 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
index e18ad490e8..e3e5eba56a 100644
--- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h
+++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h
@@ -36,10 +36,6 @@
// round_robin that could be refactored and moved here. In a future PR,
// need to clean this up.
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_lb_subchannel_list grpc_lb_subchannel_list;
typedef struct {
@@ -88,7 +84,7 @@ struct grpc_lb_subchannel_list {
/** backpointer to owning policy */
grpc_lb_policy* policy;
- grpc_tracer_flag* tracer;
+ grpc_core::TraceFlag* tracer;
/** all our subchannels */
size_t num_subchannels;
@@ -121,7 +117,7 @@ struct grpc_lb_subchannel_list {
};
grpc_lb_subchannel_list* grpc_lb_subchannel_list_create(
- grpc_exec_ctx* exec_ctx, grpc_lb_policy* p, grpc_tracer_flag* tracer,
+ grpc_exec_ctx* exec_ctx, 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);
@@ -146,8 +142,4 @@ void grpc_lb_subchannel_list_shutdown_and_unref(
grpc_exec_ctx* exec_ctx, grpc_lb_subchannel_list* subchannel_list,
const char* reason);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_SUBCHANNEL_LIST_H */
diff --git a/src/core/ext/filters/client_channel/lb_policy_factory.cc b/src/core/ext/filters/client_channel/lb_policy_factory.cc
index 05ab43d0b6..d43f9fd1b9 100644
--- a/src/core/ext/filters/client_channel/lb_policy_factory.cc
+++ 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);
}
@@ -60,7 +60,7 @@ void grpc_lb_addresses_set_address(grpc_lb_addresses* addresses, size_t index,
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;
@@ -116,7 +116,7 @@ void grpc_lb_addresses_destroy(grpc_exec_ctx* exec_ctx,
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) {
+ if (addresses->addresses[i].user_data != nullptr) {
addresses->user_data_vtable->destroy(exec_ctx,
addresses->addresses[i].user_data);
}
@@ -148,8 +148,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;
}
@@ -164,6 +164,6 @@ 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;
+ if (factory == nullptr) return nullptr;
return factory->vtable->create_lb_policy(exec_ctx, 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 360a42b177..8f6d8c1b08 100644
--- a/src/core/ext/filters/client_channel/lb_policy_factory.h
+++ b/src/core/ext/filters/client_channel/lb_policy_factory.h
@@ -29,10 +29,6 @@
// Channel arg key for grpc_lb_addresses.
#define GRPC_ARG_LB_ADDRESSES "grpc.lb_addresses"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_lb_policy_factory grpc_lb_policy_factory;
typedef struct grpc_lb_policy_factory_vtable grpc_lb_policy_factory_vtable;
@@ -134,8 +130,4 @@ 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);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_FACTORY_H */
diff --git a/src/core/ext/filters/client_channel/lb_policy_registry.cc b/src/core/ext/filters/client_channel/lb_policy_registry.cc
index 7b0a926a1b..6e710e86d9 100644
--- a/src/core/ext/filters/client_channel/lb_policy_registry.cc
+++ b/src/core/ext/filters/client_channel/lb_policy_registry.cc
@@ -50,7 +50,7 @@ void grpc_register_lb_policy(grpc_lb_policy_factory* factory) {
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,7 +58,7 @@ 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,
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 055f751b57..acddc90fdd 100644
--- a/src/core/ext/filters/client_channel/lb_policy_registry.h
+++ b/src/core/ext/filters/client_channel/lb_policy_registry.h
@@ -22,10 +22,6 @@
#include "src/core/ext/filters/client_channel/lb_policy_factory.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/** Initialize the registry and set \a default_factory as the factory to be
* returned when no name is provided in a lookup */
void grpc_lb_policy_registry_init(void);
@@ -41,8 +37,4 @@ void grpc_register_lb_policy(grpc_lb_policy_factory* factory);
grpc_lb_policy* grpc_lb_policy_create(grpc_exec_ctx* exec_ctx, const char* name,
grpc_lb_policy_args* args);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_REGISTRY_H */
diff --git a/src/core/ext/filters/client_channel/parse_address.cc b/src/core/ext/filters/client_channel/parse_address.cc
index 6cf77f13bc..39b1237c77 100644
--- a/src/core/ext/filters/client_channel/parse_address.cc
+++ b/src/core/ext/filters/client_channel/parse_address.cc
@@ -75,7 +75,7 @@ bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr,
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;
}
@@ -118,7 +118,7 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* 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) {
+ 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;
}
diff --git a/src/core/ext/filters/client_channel/parse_address.h b/src/core/ext/filters/client_channel/parse_address.h
index b45859f9a2..ca0a0d18f0 100644
--- a/src/core/ext/filters/client_channel/parse_address.h
+++ b/src/core/ext/filters/client_channel/parse_address.h
@@ -24,10 +24,6 @@
#include "src/core/ext/filters/client_channel/uri_parser.h"
#include "src/core/lib/iomgr/resolve_address.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/** 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);
@@ -49,8 +45,4 @@ bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr,
bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr,
bool log_errors);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PARSE_ADDRESS_H */
diff --git a/src/core/ext/filters/client_channel/proxy_mapper.h b/src/core/ext/filters/client_channel/proxy_mapper.h
index bb8259f854..a13861ccaf 100644
--- a/src/core/ext/filters/client_channel/proxy_mapper.h
+++ b/src/core/ext/filters/client_channel/proxy_mapper.h
@@ -25,10 +25,6 @@
#include "src/core/lib/iomgr/resolve_address.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_proxy_mapper grpc_proxy_mapper;
typedef struct {
@@ -75,8 +71,4 @@ bool grpc_proxy_mapper_map_address(grpc_exec_ctx* exec_ctx,
void grpc_proxy_mapper_destroy(grpc_proxy_mapper* mapper);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_H */
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 39c607cefc..99e54d1a78 100644
--- a/src/core/ext/filters/client_channel/proxy_mapper_registry.h
+++ b/src/core/ext/filters/client_channel/proxy_mapper_registry.h
@@ -21,10 +21,6 @@
#include "src/core/ext/filters/client_channel/proxy_mapper.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
void grpc_proxy_mapper_registry_init();
void grpc_proxy_mapper_registry_shutdown();
@@ -45,8 +41,4 @@ bool grpc_proxy_mappers_map_address(grpc_exec_ctx* exec_ctx,
grpc_resolved_address** new_address,
grpc_channel_args** new_args);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_REGISTRY_H */
diff --git a/src/core/ext/filters/client_channel/resolver.cc b/src/core/ext/filters/client_channel/resolver.cc
index 7e84b98cb9..c16b1515c7 100644
--- a/src/core/ext/filters/client_channel/resolver.cc
+++ b/src/core/ext/filters/client_channel/resolver.cc
@@ -19,10 +19,8 @@
#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
+grpc_core::DebugOnlyTraceFlag grpc_trace_resolver_refcount(false,
+ "resolver_refcount");
void grpc_resolver_init(grpc_resolver* resolver,
const grpc_resolver_vtable* vtable,
@@ -35,7 +33,7 @@ void grpc_resolver_init(grpc_resolver* resolver,
#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)) {
+ 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,
@@ -50,7 +48,7 @@ void grpc_resolver_ref(grpc_resolver* resolver) {
#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)) {
+ 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,
diff --git a/src/core/ext/filters/client_channel/resolver.h b/src/core/ext/filters/client_channel/resolver.h
index a0eb0bcfdf..4e8cfbe417 100644
--- a/src/core/ext/filters/client_channel/resolver.h
+++ b/src/core/ext/filters/client_channel/resolver.h
@@ -22,16 +22,10 @@
#include "src/core/ext/filters/client_channel/subchannel.h"
#include "src/core/lib/iomgr/iomgr.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
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 {
@@ -91,8 +85,4 @@ void grpc_resolver_next_locked(grpc_exec_ctx* exec_ctx, grpc_resolver* resolver,
grpc_channel_args** result,
grpc_closure* on_complete);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_H */
diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
index 76f08281f7..3a16b3492d 100644
--- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
+++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
@@ -121,15 +121,15 @@ static void dns_ares_shutdown_locked(grpc_exec_ctx* exec_ctx,
if (r->have_retry_timer) {
grpc_timer_cancel(exec_ctx, &r->retry_timer);
}
- if (r->pending_request != NULL) {
+ if (r->pending_request != nullptr) {
grpc_cancel_ares_request(exec_ctx, r->pending_request);
}
- if (r->next_completion != NULL) {
- *r->target_result = NULL;
+ if (r->next_completion != nullptr) {
+ *r->target_result = nullptr;
GRPC_CLOSURE_SCHED(
exec_ctx, r->next_completion,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resolver Shutdown"));
- r->next_completion = NULL;
+ r->next_completion = nullptr;
}
}
@@ -155,7 +155,7 @@ static void dns_ares_on_retry_timer_locked(grpc_exec_ctx* exec_ctx, void* arg,
}
static bool value_in_json_array(grpc_json* array, const char* value) {
- for (grpc_json* entry = array->child; entry != NULL; entry = entry->next) {
+ for (grpc_json* entry = array->child; entry != nullptr; entry = entry->next) {
if (entry->type == GRPC_JSON_STRING && strcmp(entry->value, value) == 0) {
return true;
}
@@ -165,47 +165,48 @@ static bool value_in_json_array(grpc_json* array, const char* value) {
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) {
+ 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 ||
+ 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 +217,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;
}
@@ -228,33 +229,33 @@ static char* choose_service_config(char* service_config_choice_json) {
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;
+ grpc_channel_args* result = nullptr;
GPR_ASSERT(r->resolving);
r->resolving = false;
- r->pending_request = NULL;
- if (r->lb_addresses != NULL) {
+ 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);
service_config = grpc_service_config_create(service_config_string);
- if (service_config != NULL) {
+ 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);
@@ -265,7 +266,7 @@ 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);
} else {
@@ -287,7 +288,7 @@ static void dns_ares_on_resolved_locked(grpc_exec_ctx* exec_ctx, void* arg,
grpc_timer_init(exec_ctx, &r->retry_timer, next_try,
&r->dns_ares_on_retry_timer_locked);
}
- if (r->resolved_result != NULL) {
+ if (r->resolved_result != nullptr) {
grpc_channel_args_destroy(exec_ctx, r->resolved_result);
}
r->resolved_result = result;
@@ -318,25 +319,25 @@ static void dns_ares_start_resolving_locked(grpc_exec_ctx* exec_ctx,
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,
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 &&
+ 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;
+ r->next_completion = nullptr;
r->published_version = r->resolved_version;
}
}
@@ -344,7 +345,7 @@ static void dns_ares_maybe_finish_next_locked(grpc_exec_ctx* exec_ctx,
static void dns_ares_destroy(grpc_exec_ctx* exec_ctx, grpc_resolver* gr) {
gpr_log(GPR_DEBUG, "dns_ares_destroy");
ares_dns_resolver* r = (ares_dns_resolver*)gr;
- if (r->resolved_result != NULL) {
+ if (r->resolved_result != nullptr) {
grpc_channel_args_destroy(exec_ctx, r->resolved_result);
}
grpc_pollset_set_destroy(exec_ctx, r->interested_parties);
@@ -376,7 +377,7 @@ static grpc_resolver* dns_ares_create(grpc_exec_ctx* exec_ctx,
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) {
+ if (args->pollset_set != nullptr) {
grpc_pollset_set_add_pollset_set(exec_ctx, r->interested_parties,
args->pollset_set);
}
@@ -424,11 +425,11 @@ static grpc_resolver_factory* dns_ares_resolver_factory_create() {
return &dns_resolver_factory;
}
-extern "C" void grpc_resolver_dns_ares_init(void) {
+void grpc_resolver_dns_ares_init(void) {
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) {
+ 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);
@@ -440,9 +441,9 @@ extern "C" void grpc_resolver_dns_ares_init(void) {
gpr_free(resolver);
}
-extern "C" void grpc_resolver_dns_ares_shutdown(void) {
+void grpc_resolver_dns_ares_shutdown(void) {
char* resolver = gpr_getenv("GRPC_DNS_RESOLVER");
- if (resolver != NULL && gpr_stricmp(resolver, "ares") == 0) {
+ if (resolver != nullptr && gpr_stricmp(resolver, "ares") == 0) {
grpc_ares_cleanup();
}
gpr_free(resolver);
@@ -450,8 +451,8 @@ extern "C" void grpc_resolver_dns_ares_shutdown(void) {
#else /* GRPC_ARES == 1 && !defined(GRPC_UV) */
-extern "C" void grpc_resolver_dns_ares_init(void) {}
+void grpc_resolver_dns_ares_init(void) {}
-extern "C" void grpc_resolver_dns_ares_shutdown(void) {}
+void grpc_resolver_dns_ares_shutdown(void) {}
#endif /* GRPC_ARES == 1 && !defined(GRPC_UV) */
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 a5fb1f10e1..03ea36bfcc 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,13 +19,10 @@
#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"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
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
@@ -53,9 +50,5 @@ void grpc_ares_ev_driver_destroy(grpc_ares_ev_driver* ev_driver);
void grpc_ares_ev_driver_shutdown(grpc_exec_ctx* exec_ctx,
grpc_ares_ev_driver* ev_driver);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H \
*/
diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc
index 2bb98c1a3f..4cb068a41d 100644
--- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc
+++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc
@@ -91,7 +91,7 @@ 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);
@@ -106,7 +106,7 @@ 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(exec_ctx, fdn->fd, nullptr, nullptr, true /* already_closed */,
"c-ares query finished");
gpr_free(fdn);
}
@@ -142,7 +142,7 @@ 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;
@@ -165,7 +165,7 @@ void grpc_ares_ev_driver_shutdown(grpc_exec_ctx* exec_ctx,
gpr_mu_lock(&ev_driver->mu);
ev_driver->shutting_down = true;
fd_node* fn = ev_driver->fds;
- while (fn != NULL) {
+ while (fn != nullptr) {
grpc_fd_shutdown(
exec_ctx, fn->fd,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("grpc_ares_ev_driver_shutdown"));
@@ -180,7 +180,7 @@ 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) {
+ while (node->next != nullptr) {
if (grpc_fd_wrapped_fd(node->next->fd) == fd) {
fd_node* ret = node->next;
node->next = node->next->next;
@@ -189,7 +189,7 @@ static fd_node* pop_fd_node(fd_node** head, int fd) {
}
node = node->next;
}
- return NULL;
+ return nullptr;
}
/* Check if \a fd is still readable */
@@ -275,7 +275,7 @@ ares_channel* grpc_ares_ev_driver_get_channel(grpc_ares_ev_driver* ev_driver) {
// 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;
+ fd_node* new_list = nullptr;
if (!ev_driver->shutting_down) {
ares_socket_t socks[ARES_GETSOCK_MAXNUM];
int socks_bitmask =
@@ -285,7 +285,7 @@ static void grpc_ares_notify_on_event_locked(grpc_exec_ctx* exec_ctx,
ARES_GETSOCK_WRITABLE(socks_bitmask, 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) {
+ if (fdn == nullptr) {
char* fd_name;
gpr_asprintf(&fd_name, "ares_ev_driver-%" PRIuPTR, i);
fdn = (fd_node*)gpr_malloc(sizeof(fd_node));
@@ -332,14 +332,14 @@ 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) {
+ while (ev_driver->fds != nullptr) {
fd_node* cur = ev_driver->fds;
ev_driver->fds = ev_driver->fds->next;
fd_node_shutdown(exec_ctx, 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");
}
diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
index 9408b9d81d..7846576c11 100644
--- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
+++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
@@ -102,7 +102,7 @@ static void grpc_ares_request_unref(grpc_exec_ctx* exec_ctx,
request */
if (gpr_unref(&r->pending_queries)) {
/* TODO(zyc): Sort results with RFC6724 before invoking on_done. */
- if (exec_ctx == NULL) {
+ if (exec_ctx == nullptr) {
/* 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
@@ -150,12 +150,12 @@ static void on_hostbyname_done_cb(void* arg, int status, int timeouts,
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);
+ 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(
@@ -174,8 +174,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 +195,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,
@@ -220,7 +220,7 @@ 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(nullptr, hr);
}
static void on_srv_query_done_cb(void* arg, int status, int timeouts,
@@ -234,7 +234,7 @@ static void on_srv_query_done_cb(void* arg, int status, int timeouts,
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;
+ 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(
@@ -249,7 +249,7 @@ static void on_srv_query_done_cb(void* arg, int status, int timeouts,
grpc_ares_ev_driver_start(&exec_ctx, r->ev_driver);
}
}
- if (reply != NULL) {
+ if (reply != nullptr) {
ares_free_data(reply);
}
} else if (!r->success) {
@@ -276,15 +276,15 @@ static void on_txt_done_cb(void* arg, int status, int timeouts,
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;
+ 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,12 +292,12 @@ 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);
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, service_config_len + result->length + 1);
@@ -323,7 +323,7 @@ fail:
}
done:
gpr_mu_unlock(&r->mu);
- grpc_ares_request_unref(NULL, r);
+ grpc_ares_request_unref(nullptr, r);
}
static grpc_ares_request* grpc_dns_lookup_ares_impl(
@@ -332,9 +332,9 @@ static grpc_ares_request* grpc_dns_lookup_ares_impl(
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;
+ 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",
@@ -345,13 +345,13 @@ static grpc_ares_request* grpc_dns_lookup_ares_impl(
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));
@@ -375,7 +375,7 @@ 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 */)) {
@@ -429,9 +429,12 @@ static grpc_ares_request* grpc_dns_lookup_ares_impl(
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);
@@ -444,7 +447,7 @@ error_cleanup:
GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
gpr_free(host);
gpr_free(port);
- return NULL;
+ return nullptr;
}
grpc_ares_request* (*grpc_dns_lookup_ares)(
@@ -503,8 +506,8 @@ static void on_dns_lookup_done_cb(grpc_exec_ctx* exec_ctx, void* arg,
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;
+ 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));
@@ -536,10 +539,10 @@ static void grpc_resolve_address_ares_impl(grpc_exec_ctx* exec_ctx,
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(exec_ctx, 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)(
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 6882b7b1d1..72db622954 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
@@ -25,10 +25,6 @@
#include "src/core/lib/iomgr/polling_entity.h"
#include "src/core/lib/iomgr/resolve_address.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_ares_request grpc_ares_request;
/* Asynchronously resolve \a name. Use \a default_port if a port isn't
@@ -69,9 +65,5 @@ grpc_error* grpc_ares_init(void);
it has been called the same number of times as grpc_ares_init(). */
void grpc_ares_cleanup(void);
-#ifdef __cplusplus
-}
-#endif
-
#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/native/dns_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
index a57ab66118..fc40ce6966 100644
--- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
+++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
@@ -100,12 +100,12 @@ static void dns_shutdown_locked(grpc_exec_ctx* exec_ctx,
if (r->have_retry_timer) {
grpc_timer_cancel(exec_ctx, &r->retry_timer);
}
- if (r->next_completion != NULL) {
- *r->target_result = NULL;
+ if (r->next_completion != nullptr) {
+ *r->target_result = nullptr;
GRPC_CLOSURE_SCHED(
exec_ctx, r->next_completion,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resolver Shutdown"));
- r->next_completion = NULL;
+ r->next_completion = nullptr;
}
}
@@ -150,20 +150,20 @@ static void dns_on_retry_timer_locked(grpc_exec_ctx* exec_ctx, void* arg,
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;
+ 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 != NULL) {
+ if (r->addresses != nullptr) {
grpc_lb_addresses* addresses = grpc_lb_addresses_create(
- r->addresses->naddrs, NULL /* user_data_vtable */);
+ 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 */,
- NULL /* balancer_name */, NULL /* user_data */);
+ 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);
@@ -187,7 +187,7 @@ static void dns_on_resolved_locked(grpc_exec_ctx* exec_ctx, void* arg,
grpc_combiner_scheduler(r->base.combiner));
grpc_timer_init(exec_ctx, &r->retry_timer, next_try, &r->on_retry);
}
- if (r->resolved_result != NULL) {
+ if (r->resolved_result != nullptr) {
grpc_channel_args_destroy(exec_ctx, r->resolved_result);
}
r->resolved_result = result;
@@ -203,7 +203,7 @@ static void dns_start_resolving_locked(grpc_exec_ctx* exec_ctx,
GRPC_RESOLVER_REF(&r->base, "dns-resolving");
GPR_ASSERT(!r->resolving);
r->resolving = true;
- r->addresses = NULL;
+ r->addresses = nullptr;
grpc_resolve_address(
exec_ctx, r->name_to_resolve, r->default_port, r->interested_parties,
GRPC_CLOSURE_CREATE(dns_on_resolved_locked, r,
@@ -213,20 +213,20 @@ static void dns_start_resolving_locked(grpc_exec_ctx* exec_ctx,
static void dns_maybe_finish_next_locked(grpc_exec_ctx* exec_ctx,
dns_resolver* r) {
- if (r->next_completion != NULL &&
+ 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);
GRPC_CLOSURE_SCHED(exec_ctx, r->next_completion, GRPC_ERROR_NONE);
- r->next_completion = NULL;
+ r->next_completion = nullptr;
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) {
+ if (r->resolved_result != nullptr) {
grpc_channel_args_destroy(exec_ctx, r->resolved_result);
}
grpc_pollset_set_destroy(exec_ctx, r->interested_parties);
@@ -241,7 +241,7 @@ static grpc_resolver* dns_create(grpc_exec_ctx* exec_ctx,
const char* default_port) {
if (0 != strcmp(args->uri->authority, "")) {
gpr_log(GPR_ERROR, "authority based dns uri's not supported");
- return NULL;
+ return nullptr;
}
// Get name from args.
char* path = args->uri->path;
@@ -253,7 +253,7 @@ static grpc_resolver* dns_create(grpc_exec_ctx* exec_ctx,
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) {
+ if (args->pollset_set != nullptr) {
grpc_pollset_set_add_pollset_set(exec_ctx, r->interested_parties,
args->pollset_set);
}
@@ -295,15 +295,15 @@ static grpc_resolver_factory* dns_resolver_factory_create() {
return &dns_resolver_factory;
}
-extern "C" void grpc_resolver_dns_native_init(void) {
+void grpc_resolver_dns_native_init(void) {
char* resolver = gpr_getenv("GRPC_DNS_RESOLVER");
- if (resolver != NULL && gpr_stricmp(resolver, "native") == 0) {
+ 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 == NULL) {
+ if (existing_factory == nullptr) {
gpr_log(GPR_DEBUG, "Using native dns resolver");
grpc_register_resolver_type(dns_resolver_factory_create());
} else {
@@ -313,4 +313,4 @@ extern "C" void grpc_resolver_dns_native_init(void) {
gpr_free(resolver);
}
-extern "C" void grpc_resolver_dns_native_shutdown(void) {}
+void grpc_resolver_dns_native_shutdown(void) {}
diff --git a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc
index ed5b1011fb..44798ca434 100644
--- a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc
+++ b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc
@@ -78,31 +78,31 @@ static void fake_resolver_destroy(grpc_exec_ctx* exec_ctx, grpc_resolver* gr) {
static void fake_resolver_shutdown_locked(grpc_exec_ctx* exec_ctx,
grpc_resolver* resolver) {
fake_resolver* r = (fake_resolver*)resolver;
- if (r->next_completion != NULL) {
- *r->target_result = NULL;
+ if (r->next_completion != nullptr) {
+ *r->target_result = nullptr;
GRPC_CLOSURE_SCHED(
exec_ctx, r->next_completion,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resolver Shutdown"));
- r->next_completion = NULL;
+ 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) {
+ 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;
+ r->next_results = nullptr;
GRPC_CLOSURE_SCHED(exec_ctx, r->next_completion, GRPC_ERROR_NONE);
- r->next_completion = NULL;
+ r->next_completion = nullptr;
}
}
static void fake_resolver_channel_saw_error_locked(grpc_exec_ctx* exec_ctx,
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);
}
@@ -162,11 +162,11 @@ static void set_response_closure_fn(grpc_exec_ctx* exec_ctx, void* arg,
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) {
+ if (r->next_results != nullptr) {
grpc_channel_args_destroy(exec_ctx, r->next_results);
}
r->next_results = closure_arg->next_response;
- if (r->results_upon_error != NULL) {
+ if (r->results_upon_error != nullptr) {
grpc_channel_args_destroy(exec_ctx, r->results_upon_error);
}
r->results_upon_error = grpc_channel_args_copy(closure_arg->next_response);
@@ -177,7 +177,7 @@ static void set_response_closure_fn(grpc_exec_ctx* exec_ctx, void* arg,
void grpc_fake_resolver_response_generator_set_response(
grpc_exec_ctx* exec_ctx, 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;
@@ -220,7 +220,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;
}
@@ -240,7 +240,7 @@ static grpc_resolver* fake_resolver_create(grpc_exec_ctx* exec_ctx,
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;
}
@@ -258,8 +258,8 @@ static const grpc_resolver_factory_vtable fake_resolver_factory_vtable = {
static grpc_resolver_factory fake_resolver_factory = {
&fake_resolver_factory_vtable};
-extern "C" void grpc_resolver_fake_init(void) {
+void grpc_resolver_fake_init(void) {
grpc_register_resolver_type(&fake_resolver_factory);
}
-extern "C" void grpc_resolver_fake_shutdown(void) {}
+void grpc_resolver_fake_shutdown(void) {}
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 3f341fa8ed..7035cdda01 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
@@ -21,10 +21,6 @@
#include "src/core/ext/filters/client_channel/uri_parser.h"
#include "src/core/lib/channel/channel_args.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#define GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR \
"grpc.fake_resolver.response_generator"
@@ -60,9 +56,5 @@ grpc_fake_resolver_response_generator_ref(
void grpc_fake_resolver_response_generator_unref(
grpc_fake_resolver_response_generator* generator);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FAKE_FAKE_RESOLVER_H \
*/
diff --git a/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc b/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc
index 9fc8dffea3..f0934b5943 100644
--- a/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc
+++ b/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc
@@ -71,12 +71,12 @@ static const grpc_resolver_vtable sockaddr_resolver_vtable = {
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;
+ if (r->next_completion != nullptr) {
+ *r->target_result = nullptr;
GRPC_CLOSURE_SCHED(
exec_ctx, r->next_completion,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resolver Shutdown"));
- r->next_completion = NULL;
+ r->next_completion = nullptr;
}
}
@@ -100,13 +100,13 @@ static void sockaddr_next_locked(grpc_exec_ctx* exec_ctx,
static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx* exec_ctx,
sockaddr_resolver* r) {
- if (r->next_completion != NULL && !r->published) {
+ 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;
+ r->next_completion = nullptr;
}
}
@@ -149,7 +149,7 @@ static grpc_resolver* sockaddr_create(grpc_exec_ctx* exec_ctx,
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,8 +157,8 @@ 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;
@@ -174,7 +174,7 @@ static grpc_resolver* sockaddr_create(grpc_exec_ctx* exec_ctx,
grpc_slice_unref_internal(exec_ctx, path_slice);
if (errors_found) {
grpc_lb_addresses_destroy(exec_ctx, addresses);
- return NULL;
+ return nullptr;
}
/* Instantiate resolver. */
sockaddr_resolver* r =
@@ -211,7 +211,7 @@ DECL_FACTORY(unix);
DECL_FACTORY(ipv4);
DECL_FACTORY(ipv6);
-extern "C" void grpc_resolver_sockaddr_init(void) {
+void grpc_resolver_sockaddr_init(void) {
grpc_register_resolver_type(&ipv4_resolver_factory);
grpc_register_resolver_type(&ipv6_resolver_factory);
#ifdef GRPC_HAVE_UNIX_SOCKET
@@ -219,4 +219,4 @@ extern "C" void grpc_resolver_sockaddr_init(void) {
#endif
}
-extern "C" void grpc_resolver_sockaddr_shutdown(void) {}
+void grpc_resolver_sockaddr_shutdown(void) {}
diff --git a/src/core/ext/filters/client_channel/resolver_factory.cc b/src/core/ext/filters/client_channel/resolver_factory.cc
index 6f0a7c1e36..1a289d9771 100644
--- a/src/core/ext/filters/client_channel/resolver_factory.cc
+++ b/src/core/ext/filters/client_channel/resolver_factory.cc
@@ -30,12 +30,12 @@ void grpc_resolver_factory_unref(grpc_resolver_factory* factory) {
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;
+ if (factory == nullptr) return nullptr;
return factory->vtable->create_resolver(exec_ctx, 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 62555a4f01..fcf8ec425e 100644
--- a/src/core/ext/filters/client_channel/resolver_factory.h
+++ b/src/core/ext/filters/client_channel/resolver_factory.h
@@ -24,10 +24,6 @@
#include "src/core/ext/filters/client_channel/uri_parser.h"
#include "src/core/lib/iomgr/pollset_set.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_resolver_factory grpc_resolver_factory;
typedef struct grpc_resolver_factory_vtable grpc_resolver_factory_vtable;
@@ -71,8 +67,4 @@ grpc_resolver* grpc_resolver_factory_create_resolver(
char* grpc_resolver_factory_get_default_authority(
grpc_resolver_factory* factory, grpc_uri* uri);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FACTORY_H */
diff --git a/src/core/ext/filters/client_channel/resolver_registry.cc b/src/core/ext/filters/client_channel/resolver_registry.cc
index 9e45887f35..5da6114a3d 100644
--- a/src/core/ext/filters/client_channel/resolver_registry.cc
+++ b/src/core/ext/filters/client_channel/resolver_registry.cc
@@ -78,7 +78,7 @@ 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) {
@@ -88,7 +88,7 @@ grpc_resolver_factory* grpc_resolver_factory_lookup(const char* name) {
}
static grpc_resolver_factory* lookup_factory_by_uri(grpc_uri* uri) {
- if (!uri) return NULL;
+ if (!uri) return nullptr;
return lookup_factory(uri->scheme);
}
@@ -96,17 +96,17 @@ 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;
+ grpc_resolver_factory* factory = nullptr;
- GPR_ASSERT(uri != NULL);
+ GPR_ASSERT(uri != nullptr);
*uri = grpc_uri_parse(exec_ctx, 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);
factory = lookup_factory_by_uri(*uri);
- if (factory == NULL) {
+ if (factory == nullptr) {
grpc_uri_destroy(grpc_uri_parse(exec_ctx, target, 0));
grpc_uri_destroy(grpc_uri_parse(exec_ctx, *canonical_target, 0));
gpr_log(GPR_ERROR, "don't know how to resolve '%s' or '%s'", target,
@@ -120,8 +120,8 @@ 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_uri* uri = nullptr;
+ char* canonical_target = nullptr;
grpc_resolver_factory* factory =
resolve_factory(exec_ctx, target, &uri, &canonical_target);
grpc_resolver* resolver;
@@ -139,8 +139,8 @@ grpc_resolver* grpc_resolver_create(grpc_exec_ctx* exec_ctx, const char* target,
}
char* grpc_get_default_authority(grpc_exec_ctx* exec_ctx, const char* target) {
- grpc_uri* uri = NULL;
- char* canonical_target = NULL;
+ grpc_uri* uri = nullptr;
+ char* canonical_target = nullptr;
grpc_resolver_factory* factory =
resolve_factory(exec_ctx, target, &uri, &canonical_target);
char* authority = grpc_resolver_factory_get_default_authority(factory, uri);
@@ -151,9 +151,9 @@ char* grpc_get_default_authority(grpc_exec_ctx* exec_ctx, const char* target) {
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;
+ grpc_uri* uri = nullptr;
+ char* canonical_target = nullptr;
resolve_factory(exec_ctx, 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 01a2d0b18b..ecc9f824e8 100644
--- a/src/core/ext/filters/client_channel/resolver_registry.h
+++ b/src/core/ext/filters/client_channel/resolver_registry.h
@@ -22,10 +22,6 @@
#include "src/core/ext/filters/client_channel/resolver_factory.h"
#include "src/core/lib/iomgr/pollset_set.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
void grpc_resolver_registry_init();
void grpc_resolver_registry_shutdown(void);
@@ -70,8 +66,4 @@ char* grpc_get_default_authority(grpc_exec_ctx* exec_ctx, const char* target);
char* grpc_resolver_factory_add_default_prefix_if_needed(
grpc_exec_ctx* exec_ctx, const char* target);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_REGISTRY_H */
diff --git a/src/core/ext/filters/client_channel/retry_throttle.cc b/src/core/ext/filters/client_channel/retry_throttle.cc
index 09dcade089..867d775151 100644
--- a/src/core/ext/filters/client_channel/retry_throttle.cc
+++ 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/retry_throttle.h b/src/core/ext/filters/client_channel/retry_throttle.h
index 399383df78..bf99297e98 100644
--- a/src/core/ext/filters/client_channel/retry_throttle.h
+++ b/src/core/ext/filters/client_channel/retry_throttle.h
@@ -21,10 +21,6 @@
#include <stdbool.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/// Tracks retry throttling data for an individual server name.
typedef struct grpc_server_retry_throttle_data grpc_server_retry_throttle_data;
@@ -51,8 +47,4 @@ void grpc_retry_throttle_map_shutdown();
grpc_server_retry_throttle_data* grpc_retry_throttle_map_get_data_for_server(
const char* server_name, int max_milli_tokens, int milli_token_ratio);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RETRY_THROTTLE_H */
diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc
index 427df743d6..58e294d597 100644
--- a/src/core/ext/filters/client_channel/subchannel.cc
+++ b/src/core/ext/filters/client_channel/subchannel.cc
@@ -199,7 +199,7 @@ static gpr_atm ref_mutate(grpc_subchannel* c, gpr_atm delta,
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)) {
+ 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);
@@ -227,7 +227,7 @@ grpc_subchannel* grpc_subchannel_weak_ref(
grpc_subchannel* grpc_subchannel_ref_from_weak_ref(
grpc_subchannel* c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
- if (!c) return NULL;
+ if (!c) return nullptr;
for (;;) {
gpr_atm old_refs = gpr_atm_acq_load(&c->ref_pair);
if (old_refs >= (1 << INTERNAL_REF_BITS)) {
@@ -236,7 +236,7 @@ grpc_subchannel* grpc_subchannel_ref_from_weak_ref(
return c;
}
} else {
- return NULL;
+ return nullptr;
}
}
}
@@ -251,7 +251,7 @@ static void disconnect(grpc_exec_ctx* exec_ctx, grpc_subchannel* c) {
exec_ctx, c->connector,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Subchannel disconnected"));
con = GET_CONNECTED_SUBCHANNEL(c, no_barrier);
- if (con != NULL) {
+ if (con != nullptr) {
GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, con, "connection");
gpr_atm_no_barrier_store(&c->connected_subchannel, (gpr_atm)0xdeadbeef);
}
@@ -306,17 +306,17 @@ grpc_subchannel* grpc_subchannel_create(grpc_exec_ctx* exec_ctx,
memcpy((void*)c->filters, args->filters,
sizeof(grpc_channel_filter*) * c->num_filters);
} else {
- c->filters = NULL;
+ 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(exec_ctx, args->args, addr);
- grpc_resolved_address* new_address = NULL;
- grpc_channel_args* new_args = NULL;
+ grpc_resolved_address* new_address = nullptr;
+ grpc_channel_args* new_args = nullptr;
if (grpc_proxy_mappers_map_address(exec_ctx, addr, args->args, &new_address,
&new_args)) {
- GPR_ASSERT(new_address != NULL);
+ GPR_ASSERT(new_address != nullptr);
gpr_free(addr);
addr = new_address;
}
@@ -324,10 +324,10 @@ grpc_subchannel* grpc_subchannel_create(grpc_exec_ctx* exec_ctx,
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,
+ 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 != NULL) grpc_channel_args_destroy(exec_ctx, new_args);
+ if (new_args != nullptr) 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,
@@ -404,7 +404,7 @@ 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) {
+ if (w->pollset_set != nullptr) {
grpc_pollset_set_del_pollset_set(exec_ctx, w->subchannel->pollset_set,
w->pollset_set);
}
@@ -451,7 +451,7 @@ static void maybe_start_connecting_locked(grpc_exec_ctx* exec_ctx,
return;
}
- if (GET_CONNECTED_SUBCHANNEL(c, no_barrier) != NULL) {
+ if (GET_CONNECTED_SUBCHANNEL(c, no_barrier) != nullptr) {
/* Already connected: don't restart */
return;
}
@@ -490,13 +490,13 @@ void grpc_subchannel_notify_on_state_change(
grpc_closure* notify) {
external_state_watcher* w;
- if (state == NULL) {
+ 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(
- exec_ctx, &c->state_tracker, NULL, &w->closure);
+ exec_ctx, &c->state_tracker, nullptr, &w->closure);
}
}
gpr_mu_unlock(&c->mu);
@@ -507,7 +507,7 @@ void grpc_subchannel_notify_on_state_change(
w->notify = notify;
GRPC_CLOSURE_INIT(&w->closure, on_external_state_watcher_done, w,
grpc_schedule_on_exec_ctx);
- if (interested_parties != NULL) {
+ if (interested_parties != nullptr) {
grpc_pollset_set_add_pollset_set(exec_ctx, c->pollset_set,
interested_parties);
}
@@ -549,10 +549,10 @@ static void subchannel_on_child_state_changed(grpc_exec_ctx* exec_ctx, void* p,
"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,
+ exec_ctx, GET_CONNECTED_SUBCHANNEL(c, no_barrier), nullptr,
&sw->connectivity_state, &sw->closure);
GRPC_SUBCHANNEL_WEAK_REF(c, "state_watcher");
- sw = NULL;
+ sw = nullptr;
}
gpr_mu_unlock(mu);
@@ -565,7 +565,7 @@ static void connected_subchannel_state_op(grpc_exec_ctx* exec_ctx,
grpc_pollset_set* interested_parties,
grpc_connectivity_state* state,
grpc_closure* closure) {
- grpc_transport_op* op = grpc_make_transport_op(NULL);
+ grpc_transport_op* op = grpc_make_transport_op(nullptr);
grpc_channel_element* elem;
op->connectivity_state = state;
op->on_connectivity_state_change = closure;
@@ -585,7 +585,7 @@ void grpc_connected_subchannel_notify_on_state_change(
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_transport_op* op = grpc_make_transport_op(nullptr);
grpc_channel_element* elem;
op->send_ping = closure;
elem = grpc_channel_stack_element(CHANNEL_STACK_FROM_CONNECTION(con), 0);
@@ -611,7 +611,7 @@ static bool publish_transport_locked(grpc_exec_ctx* exec_ctx,
return false;
}
grpc_error* error = grpc_channel_stack_builder_finish(
- exec_ctx, builder, 0, 1, connection_destroy, NULL, (void**)&con);
+ exec_ctx, builder, 0, 1, connection_destroy, nullptr, (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",
@@ -666,7 +666,7 @@ static void subchannel_connected(grpc_exec_ctx* exec_ctx, void* arg,
GRPC_SUBCHANNEL_WEAK_REF(c, "connected");
gpr_mu_lock(&c->mu);
c->connecting = false;
- if (c->connecting_result.transport != NULL &&
+ if (c->connecting_result.transport != nullptr &&
publish_transport_locked(exec_ctx, c)) {
/* do nothing, transport was published */
} else if (c->disconnected) {
@@ -697,10 +697,10 @@ static void subchannel_connected(grpc_exec_ctx* exec_ctx, void* arg,
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_ASSERT(c->schedule_closure_after_destroy != nullptr);
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,
+ grpc_call_stack_destroy(exec_ctx, SUBCHANNEL_CALL_TO_CALL_STACK(c), nullptr,
c->schedule_closure_after_destroy);
GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, connection, "subchannel_call");
GPR_TIMER_END("grpc_subchannel_call_unref.destroy", 0);
@@ -708,8 +708,8 @@ static void subchannel_call_destroy(grpc_exec_ctx* exec_ctx, void* call,
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);
+ GPR_ASSERT(call->schedule_closure_after_destroy == nullptr);
+ GPR_ASSERT(closure != nullptr);
call->schedule_closure_after_destroy = closure;
}
@@ -756,7 +756,7 @@ grpc_error* grpc_connected_subchannel_create_call(
(*call)->connection = GRPC_CONNECTED_SUBCHANNEL_REF(con, "subchannel_call");
const grpc_call_element_args call_args = {
callstk, /* call_stack */
- NULL, /* server_transport_data */
+ nullptr, /* server_transport_data */
args->context, /* context */
args->path, /* path */
args->start_time, /* start_time */
@@ -783,7 +783,7 @@ grpc_call_stack* grpc_subchannel_call_get_call_stack(
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);
+ GPR_ASSERT(uri != nullptr);
if (!grpc_parse_uri(uri, addr)) memset(addr, 0, sizeof(*addr));
grpc_uri_destroy(uri);
}
@@ -801,7 +801,7 @@ void grpc_get_subchannel_address_arg(grpc_exec_ctx* exec_ctx,
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 != nullptr); // Should have been set by LB policy.
GPR_ASSERT(addr_arg->type == GRPC_ARG_STRING);
return addr_arg->value.string;
}
diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h
index 970f182ff0..1f326fc1d2 100644
--- a/src/core/ext/filters/client_channel/subchannel.h
+++ b/src/core/ext/filters/client_channel/subchannel.h
@@ -26,10 +26,6 @@
#include "src/core/lib/transport/connectivity_state.h"
#include "src/core/lib/transport/metadata.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
// Channel arg containing a grpc_resolved_address to connect to.
#define GRPC_ARG_SUBCHANNEL_ADDRESS "grpc.subchannel_address"
@@ -192,8 +188,4 @@ const char* grpc_get_subchannel_address_uri_arg(const grpc_channel_args* args);
/// Caller is responsible for freeing the string.
grpc_arg grpc_create_subchannel_address_arg(const grpc_resolved_address* addr);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SUBCHANNEL_H */
diff --git a/src/core/ext/filters/client_channel/subchannel_index.cc b/src/core/ext/filters/client_channel/subchannel_index.cc
index 0c4213cf77..1624643d0b 100644
--- a/src/core/ext/filters/client_channel/subchannel_index.cc
+++ b/src/core/ext/filters/client_channel/subchannel_index.cc
@@ -53,7 +53,7 @@ static grpc_subchannel_key* create_key(
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;
@@ -162,10 +162,10 @@ grpc_subchannel* grpc_subchannel_index_find(grpc_exec_ctx* exec_ctx,
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* c = nullptr;
+ bool need_to_unref_constructed = false;
- while (c == NULL) {
+ while (c == nullptr) {
need_to_unref_constructed = false;
// Compare and swap loop:
@@ -176,10 +176,10 @@ grpc_subchannel* grpc_subchannel_index_register(grpc_exec_ctx* exec_ctx,
// - Check to see if a subchannel already exists
c = (grpc_subchannel*)gpr_avl_get(index, key, exec_ctx);
- if (c != NULL) {
+ 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 {
diff --git a/src/core/ext/filters/client_channel/subchannel_index.h b/src/core/ext/filters/client_channel/subchannel_index.h
index 47f9c7bb1e..6a4d06ef8f 100644
--- a/src/core/ext/filters/client_channel/subchannel_index.h
+++ b/src/core/ext/filters/client_channel/subchannel_index.h
@@ -21,10 +21,6 @@
#include "src/core/ext/filters/client_channel/subchannel.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/** \file Provides an index of active subchannels so that they can be
shared amongst channels */
@@ -82,8 +78,4 @@ void grpc_subchannel_index_unref(void);
* force_creation set. */
void grpc_subchannel_index_test_only_set_force_creation(bool force_creation);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SUBCHANNEL_INDEX_H */
diff --git a/src/core/ext/filters/client_channel/uri_parser.cc b/src/core/ext/filters/client_channel/uri_parser.cc
index 1cc52dec12..b76dcbe4e3 100644
--- a/src/core/ext/filters/client_channel/uri_parser.cc
+++ b/src/core/ext/filters/client_channel/uri_parser.cc
@@ -52,7 +52,7 @@ static grpc_uri* bad_uri(const char* uri_text, size_t pos, const char* section,
gpr_free(line_prefix);
}
- return NULL;
+ return nullptr;
}
/** Returns a copy of percent decoded \a src[begin, end) */
@@ -148,10 +148,10 @@ static int parse_fragment_or_query(const char* uri_text, size_t* i) {
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);
+ 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;
}
@@ -174,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]);
@@ -289,15 +289,15 @@ grpc_uri* grpc_uri_parse(grpc_exec_ctx* exec_ctx, const char* uri_text,
}
const char* grpc_uri_get_query_arg(const grpc_uri* uri, const char* key) {
- GPR_ASSERT(key != NULL);
- if (key[0] == '\0') return NULL;
+ 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) {
diff --git a/src/core/ext/filters/client_channel/uri_parser.h b/src/core/ext/filters/client_channel/uri_parser.h
index cd877ade8d..84752905e8 100644
--- a/src/core/ext/filters/client_channel/uri_parser.h
+++ b/src/core/ext/filters/client_channel/uri_parser.h
@@ -22,10 +22,6 @@
#include <stddef.h>
#include "src/core/lib/iomgr/exec_ctx.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct {
char* scheme;
char* authority;
@@ -51,8 +47,4 @@ const char* grpc_uri_get_query_arg(const grpc_uri* uri, const char* key);
/** destroy a uri */
void grpc_uri_destroy(grpc_uri* uri);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_URI_PARSER_H */
diff --git a/src/core/ext/filters/deadline/deadline_filter.cc b/src/core/ext/filters/deadline/deadline_filter.cc
index dc194ec068..5db7584a59 100644
--- a/src/core/ext/filters/deadline/deadline_filter.cc
+++ b/src/core/ext/filters/deadline/deadline_filter.cc
@@ -91,7 +91,7 @@ static void start_timer_if_needed(grpc_exec_ctx* exec_ctx,
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
@@ -111,7 +111,7 @@ 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);
}
@@ -378,11 +378,11 @@ static bool maybe_add_deadline_filter(grpc_exec_ctx* exec_ctx,
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;
}
-extern "C" void grpc_deadline_filter_init(void) {
+void grpc_deadline_filter_init(void) {
grpc_channel_init_register_stage(
GRPC_CLIENT_DIRECT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
maybe_add_deadline_filter, (void*)&grpc_client_deadline_filter);
@@ -391,4 +391,4 @@ extern "C" void grpc_deadline_filter_init(void) {
maybe_add_deadline_filter, (void*)&grpc_server_deadline_filter);
}
-extern "C" void grpc_deadline_filter_shutdown(void) {}
+void grpc_deadline_filter_shutdown(void) {}
diff --git a/src/core/ext/filters/deadline/deadline_filter.h b/src/core/ext/filters/deadline/deadline_filter.h
index e665dc53ee..8d835d0382 100644
--- a/src/core/ext/filters/deadline/deadline_filter.h
+++ b/src/core/ext/filters/deadline/deadline_filter.h
@@ -20,10 +20,6 @@
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/iomgr/timer.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef enum grpc_deadline_timer_state {
GRPC_DEADLINE_STATE_INITIAL,
GRPC_DEADLINE_STATE_PENDING,
@@ -94,8 +90,4 @@ bool grpc_deadline_checking_enabled(const grpc_channel_args* args);
extern const grpc_channel_filter grpc_client_deadline_filter;
extern const grpc_channel_filter grpc_server_deadline_filter;
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_DEADLINE_DEADLINE_FILTER_H */
diff --git a/src/core/ext/filters/http/client/http_client_filter.cc b/src/core/ext/filters/http/client/http_client_filter.cc
index 590bd22b1e..a625369b02 100644
--- a/src/core/ext/filters/http/client/http_client_filter.cc
+++ b/src/core/ext/filters/http/client/http_client_filter.cc
@@ -71,7 +71,7 @@ typedef struct channel_data {
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) {
+ 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);
} else {
@@ -93,7 +93,7 @@ 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,
@@ -105,7 +105,7 @@ static grpc_error* client_filter_incoming_metadata(grpc_exec_ctx* exec_ctx,
}
}
- 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),
@@ -292,7 +292,7 @@ static grpc_error* update_path_for_get(grpc_exec_ctx* exec_ctx,
static void remove_if_present(grpc_exec_ctx* exec_ctx,
grpc_metadata_batch* batch,
grpc_metadata_batch_callouts_index idx) {
- if (batch->idx.array[idx] != NULL) {
+ if (batch->idx.array[idx] != nullptr) {
grpc_metadata_batch_remove(exec_ctx, batch, batch->idx.array[idx]);
}
}
@@ -450,7 +450,7 @@ static grpc_mdelem scheme_from_args(const grpc_channel_args* args) {
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) {
@@ -467,7 +467,7 @@ static grpc_mdelem scheme_from_args(const grpc_channel_args* args) {
}
static size_t max_payload_size_from_args(const grpc_channel_args* args) {
- if (args != NULL) {
+ 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) {
@@ -524,7 +524,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);
@@ -538,7 +538,7 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
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);
diff --git a/src/core/ext/filters/http/client/http_client_filter.h b/src/core/ext/filters/http/client/http_client_filter.h
index 9ed8e76915..ec8177c436 100644
--- a/src/core/ext/filters/http/client/http_client_filter.h
+++ b/src/core/ext/filters/http/client/http_client_filter.h
@@ -20,18 +20,10 @@
#include "src/core/lib/channel/channel_stack.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Processes metadata on the client side for HTTP2 transports */
extern const grpc_channel_filter grpc_http_client_filter;
/* Channel arg to determine maximum size of payload eligable for GET request */
#define GRPC_ARG_MAX_PAYLOAD_SIZE_FOR_GET "grpc.max_payload_size_for_get"
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_HTTP_CLIENT_HTTP_CLIENT_FILTER_H */
diff --git a/src/core/ext/filters/http/http_filters_plugin.cc b/src/core/ext/filters/http/http_filters_plugin.cc
index 064e66e323..483eb021e8 100644
--- a/src/core/ext/filters/http/http_filters_plugin.cc
+++ b/src/core/ext/filters/http/http_filters_plugin.cc
@@ -37,7 +37,7 @@ static optional_filter compress_filter = {
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");
+ return t != nullptr && strstr(t->vtable->name, "http");
}
static bool maybe_add_optional_filter(grpc_exec_ctx* exec_ctx,
@@ -51,7 +51,7 @@ static bool maybe_add_optional_filter(grpc_exec_ctx* exec_ctx,
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;
}
@@ -60,12 +60,11 @@ static bool maybe_add_required_filter(grpc_exec_ctx* exec_ctx,
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;
}
-extern "C" void grpc_http_filters_init(void) {
- grpc_register_tracer(&grpc_compression_trace);
+void grpc_http_filters_init(void) {
grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL,
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
maybe_add_optional_filter, &compress_filter);
@@ -86,4 +85,4 @@ extern "C" void grpc_http_filters_init(void) {
maybe_add_required_filter, (void*)&grpc_http_server_filter);
}
-extern "C" void grpc_http_filters_shutdown(void) {}
+void grpc_http_filters_shutdown(void) {}
diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.cc b/src/core/ext/filters/http/message_compress/message_compress_filter.cc
index 949ff917d6..d070b56b6a 100644
--- a/src/core/ext/filters/http/message_compress/message_compress_filter.cc
+++ b/src/core/ext/filters/http/message_compress/message_compress_filter.cc
@@ -112,7 +112,7 @@ static grpc_error* process_send_initial_metadata(
grpc_stream_compression_algorithm stream_compression_algorithm =
GRPC_STREAM_COMPRESS_NONE;
if (initial_metadata->idx.named.grpc_internal_stream_encoding_request !=
- NULL) {
+ nullptr) {
grpc_mdelem md =
initial_metadata->idx.named.grpc_internal_stream_encoding_request->md;
if (!grpc_stream_compression_algorithm_parse(
@@ -141,13 +141,13 @@ static grpc_error* process_send_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) {
+ if (initial_metadata->idx.named.grpc_internal_encoding_request != nullptr) {
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) {
+ nullptr) {
grpc_mdelem md =
initial_metadata->idx.named.grpc_internal_encoding_request->md;
if (!grpc_compression_algorithm_parse(GRPC_MDVALUE(md),
@@ -228,7 +228,7 @@ static void send_message_batch_continue(grpc_exec_ctx* exec_ctx,
// before we do that.
grpc_transport_stream_op_batch* send_message_batch =
calld->send_message_batch;
- calld->send_message_batch = NULL;
+ calld->send_message_batch = nullptr;
grpc_call_next_op(exec_ctx, elem, send_message_batch);
}
@@ -243,7 +243,7 @@ static void finish_send_message(grpc_exec_ctx* exec_ctx,
bool did_compress = grpc_msg_compress(exec_ctx, calld->compression_algorithm,
&calld->slices, &tmp);
if (did_compress) {
- if (GRPC_TRACER_ON(grpc_compression_trace)) {
+ if (grpc_compression_trace.enabled()) {
const char* algo_name;
const size_t before_size = calld->slices.length;
const size_t after_size = tmp.length;
@@ -258,7 +258,7 @@ static void finish_send_message(grpc_exec_ctx* exec_ctx,
grpc_slice_buffer_swap(&calld->slices, &tmp);
send_flags |= GRPC_WRITE_INTERNAL_COMPRESS;
} else {
- if (GRPC_TRACER_ON(grpc_compression_trace)) {
+ if (grpc_compression_trace.enabled()) {
const char* algo_name;
GPR_ASSERT(grpc_compression_algorithm_name(calld->compression_algorithm,
&algo_name));
@@ -287,11 +287,11 @@ 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) {
+ 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 = nullptr;
}
}
@@ -382,7 +382,7 @@ static void compress_start_transport_stream_op_batch(
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,
@@ -423,7 +423,7 @@ 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->start_send_message_batch_in_call_combiner, GRPC_ERROR_NONE,
@@ -432,7 +432,7 @@ static void compress_start_transport_stream_op_batch(
}
// 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
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 79a2815655..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
@@ -23,10 +23,6 @@
#include "src/core/lib/channel/channel_stack.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/** Compression filter for outgoing data.
*
* See <grpc/compression.h> for the available compression settings.
@@ -51,9 +47,5 @@ extern "C" {
extern const grpc_channel_filter grpc_message_compress_filter;
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_HTTP_MESSAGE_COMPRESS_MESSAGE_COMPRESS_FILTER_H \
*/
diff --git a/src/core/ext/filters/http/server/http_server_filter.cc b/src/core/ext/filters/http/server/http_server_filter.cc
index 5cfe5acced..4f3897915c 100644
--- a/src/core/ext/filters/http/server/http_server_filter.cc
+++ b/src/core/ext/filters/http/server/http_server_filter.cc
@@ -69,7 +69,7 @@ typedef struct channel_data {
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) {
+ 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);
@@ -100,7 +100,7 @@ static grpc_error* server_filter_incoming_metadata(grpc_exec_ctx* exec_ctx,
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 |
@@ -132,7 +132,7 @@ 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(
@@ -147,7 +147,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)) {
@@ -165,7 +165,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),
@@ -194,7 +194,7 @@ static grpc_error* server_filter_incoming_metadata(grpc_exec_ctx* exec_ctx,
grpc_metadata_batch_remove(exec_ctx, 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"),
@@ -239,7 +239,7 @@ static grpc_error* server_filter_incoming_metadata(grpc_exec_ctx* exec_ctx,
}
}
- if (b->idx.named.host != NULL && b->idx.named.authority == NULL) {
+ 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);
@@ -252,7 +252,7 @@ static grpc_error* server_filter_incoming_metadata(grpc_exec_ctx* exec_ctx,
GRPC_MDELEM_UNREF(exec_ctx, md);
}
- if (b->idx.named.authority == NULL) {
+ if (b->idx.named.authority == nullptr) {
add_error(
error_name, &error,
grpc_error_set_str(
@@ -281,16 +281,16 @@ static void hs_on_complete(grpc_exec_ctx* exec_ctx, void* user_data,
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
+ ? 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),
"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));
@@ -341,7 +341,7 @@ static grpc_error* hs_mutate_op(grpc_exec_ctx* exec_ctx,
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 =
diff --git a/src/core/ext/filters/http/server/http_server_filter.h b/src/core/ext/filters/http/server/http_server_filter.h
index 4b38cc5bf7..c0f678a329 100644
--- a/src/core/ext/filters/http/server/http_server_filter.h
+++ b/src/core/ext/filters/http/server/http_server_filter.h
@@ -21,15 +21,7 @@
#include "src/core/lib/channel/channel_stack.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Processes metadata on the client side for HTTP2 transports */
extern const grpc_channel_filter grpc_http_server_filter;
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_HTTP_SERVER_HTTP_SERVER_FILTER_H */
diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc b/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc
index 77b086c324..762198f034 100644
--- a/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc
+++ b/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc
@@ -60,7 +60,7 @@ static void on_initial_md_ready(grpc_exec_ctx* exec_ctx, void* 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,7 +68,7 @@ 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;
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 356f8b8e66..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
@@ -22,15 +22,7 @@
#include "src/core/ext/filters/load_reporting/server_load_reporting_plugin.h"
#include "src/core/lib/channel/channel_stack.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
extern const grpc_channel_filter grpc_server_load_reporting_filter;
-#ifdef __cplusplus
-}
-#endif
-
#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.cc b/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc
index b26cbe3579..accb7797dd 100644
--- a/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc
+++ b/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc
@@ -48,8 +48,8 @@ static bool maybe_add_server_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;
}
@@ -61,10 +61,10 @@ grpc_arg grpc_load_reporting_enable_arg() {
/* Plugin registration */
-extern "C" void grpc_server_load_reporting_plugin_init(void) {
+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);
}
-extern "C" void grpc_server_load_reporting_plugin_shutdown() {}
+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 a6448ce97e..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
@@ -23,10 +23,6 @@
#include "src/core/lib/channel/channel_stack.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/** Identifiers for the invocation point of the users LR callback */
typedef enum grpc_load_reporting_source {
GRPC_LR_POINT_UNKNOWN = 0,
@@ -59,9 +55,5 @@ typedef struct grpc_load_reporting_call_data {
/** Return a \a grpc_arg enabling load reporting */
grpc_arg grpc_load_reporting_enable_arg();
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_SERVER_LOAD_REPORTING_PLUGIN_H \
*/
diff --git a/src/core/ext/filters/max_age/max_age_filter.cc b/src/core/ext/filters/max_age/max_age_filter.cc
index ade2e5bc82..917fbd9198 100644
--- a/src/core/ext/filters/max_age/max_age_filter.cc
+++ b/src/core/ext/filters/max_age/max_age_filter.cc
@@ -126,8 +126,8 @@ static void start_max_age_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg,
grpc_exec_ctx_now(exec_ctx) + 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);
@@ -159,7 +159,7 @@ static void close_max_idle_channel(grpc_exec_ctx* exec_ctx, void* 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);
@@ -204,7 +204,7 @@ static void force_close_max_age_channel(grpc_exec_ctx* exec_ctx, void* arg,
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 =
@@ -221,8 +221,8 @@ static void channel_connectivity_changed(grpc_exec_ctx* exec_ctx, 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);
@@ -398,16 +398,16 @@ 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;
}
}
-extern "C" void grpc_max_age_filter_init(void) {
+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);
}
-extern "C" void grpc_max_age_filter_shutdown(void) {}
+void grpc_max_age_filter_shutdown(void) {}
diff --git a/src/core/ext/filters/max_age/max_age_filter.h b/src/core/ext/filters/max_age/max_age_filter.h
index eeeefd695e..68fb4a4ca5 100644
--- a/src/core/ext/filters/max_age/max_age_filter.h
+++ b/src/core/ext/filters/max_age/max_age_filter.h
@@ -19,14 +19,6 @@
#include "src/core/lib/channel/channel_stack.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
extern const grpc_channel_filter grpc_max_age_filter;
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_MAX_AGE_MAX_AGE_FILTER_H */
diff --git a/src/core/ext/filters/message_size/message_size_filter.cc b/src/core/ext/filters/message_size/message_size_filter.cc
index 9376d978b4..3d2252af2e 100644
--- a/src/core/ext/filters/message_size/message_size_filter.cc
+++ b/src/core/ext/filters/message_size/message_size_filter.cc
@@ -60,22 +60,22 @@ 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;
}
}
refcounted_message_size_limits* value =
@@ -112,7 +112,7 @@ static void recv_message_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;
- 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,
@@ -175,7 +175,7 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
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.
@@ -183,11 +183,11 @@ 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) {
+ if (chand->method_limit_table != nullptr) {
refcounted_message_size_limits* limits =
(refcounted_message_size_limits*)grpc_method_config_table_get(
exec_ctx, chand->method_limit_table, args->path);
- if (limits != NULL) {
+ 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)) {
@@ -250,11 +250,11 @@ 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,
@@ -299,27 +299,27 @@ 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;
}
}
-extern "C" void grpc_message_size_filter_init(void) {
+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);
}
-extern "C" void grpc_message_size_filter_shutdown(void) {}
+void grpc_message_size_filter_shutdown(void) {}
diff --git a/src/core/ext/filters/message_size/message_size_filter.h b/src/core/ext/filters/message_size/message_size_filter.h
index da325d6f89..d3667f7003 100644
--- a/src/core/ext/filters/message_size/message_size_filter.h
+++ b/src/core/ext/filters/message_size/message_size_filter.h
@@ -19,14 +19,6 @@
#include "src/core/lib/channel/channel_stack.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
extern const grpc_channel_filter grpc_message_size_filter;
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_MESSAGE_SIZE_MESSAGE_SIZE_FILTER_H */
diff --git a/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc b/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc
index f77ed02421..4ab1ee4e79 100644
--- a/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc
+++ b/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc
@@ -42,7 +42,7 @@ typedef struct call_data {
// 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;
}
@@ -104,7 +104,7 @@ 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;
- 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,
@@ -139,10 +139,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 +153,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);
}
@@ -186,22 +186,22 @@ static bool register_workaround_cronet_compression(
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);
}
-extern "C" void grpc_workaround_cronet_compression_filter_init(void) {
+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);
}
-extern "C" void grpc_workaround_cronet_compression_filter_shutdown(void) {}
+void grpc_workaround_cronet_compression_filter_shutdown(void) {}
diff --git a/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h b/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h
index c8b07df63e..9dae4f0734 100644
--- a/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h
+++ b/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h
@@ -19,15 +19,7 @@
#include "src/core/lib/channel/channel_stack.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
extern const grpc_channel_filter grpc_workaround_cronet_compression_filter;
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_WORKAROUNDS_WORKAROUND_CRONET_COMPRESSION_FILTER_H \
*/
diff --git a/src/core/ext/filters/workarounds/workaround_utils.cc b/src/core/ext/filters/workarounds/workaround_utils.cc
index 9db42fbeee..9d76582ea2 100644
--- a/src/core/ext/filters/workarounds/workaround_utils.cc
+++ b/src/core/ext/filters/workarounds/workaround_utils.cc
@@ -30,7 +30,7 @@ grpc_workaround_user_agent_md* grpc_parse_user_agent(grpc_mdelem 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(
diff --git a/src/core/ext/filters/workarounds/workaround_utils.h b/src/core/ext/filters/workarounds/workaround_utils.h
index a954ad4001..d6ef5e84fa 100644
--- a/src/core/ext/filters/workarounds/workaround_utils.h
+++ b/src/core/ext/filters/workarounds/workaround_utils.h
@@ -24,10 +24,6 @@
#define GRPC_WORKAROUND_PRIORITY_HIGH 10001
#define GRPC_WORKAROUND_PROIRITY_LOW 9999
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_workaround_user_agent_md {
bool workaround_active[GRPC_MAX_WORKAROUND_ID];
} grpc_workaround_user_agent_md;
@@ -38,8 +34,4 @@ typedef bool (*user_agent_parser)(grpc_mdelem);
void grpc_register_workaround(uint32_t id, user_agent_parser parser);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_FILTERS_WORKAROUNDS_WORKAROUND_UTILS_H */
diff --git a/src/core/ext/transport/chttp2/alpn/alpn.h b/src/core/ext/transport/chttp2/alpn/alpn.h
index 4a420e83e0..fd7513c665 100644
--- a/src/core/ext/transport/chttp2/alpn/alpn.h
+++ b/src/core/ext/transport/chttp2/alpn/alpn.h
@@ -21,10 +21,6 @@
#include <string.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Retuns 1 if the version is supported, 0 otherwise. */
int grpc_chttp2_is_alpn_version_supported(const char* version, size_t size);
@@ -35,8 +31,4 @@ size_t grpc_chttp2_num_alpn_versions(void);
* grpc_chttp2_num_alpn_versions()) */
const char* grpc_chttp2_get_alpn_version_index(size_t i);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H */
diff --git a/src/core/ext/transport/chttp2/client/chttp2_connector.cc b/src/core/ext/transport/chttp2/client/chttp2_connector.cc
index 6cd476f4ca..819f66aec3 100644
--- a/src/core/ext/transport/chttp2/client/chttp2_connector.cc
+++ b/src/core/ext/transport/chttp2/client/chttp2_connector.cc
@@ -68,7 +68,7 @@ static void chttp2_connector_unref(grpc_exec_ctx* exec_ctx,
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);
+ if (c->endpoint != nullptr) grpc_endpoint_destroy(exec_ctx, c->endpoint);
gpr_free(c);
}
}
@@ -78,13 +78,13 @@ static void chttp2_connector_shutdown(grpc_exec_ctx* exec_ctx,
chttp2_connector* c = (chttp2_connector*)con;
gpr_mu_lock(&c->mu);
c->shutdown = true;
- if (c->handshake_mgr != NULL) {
+ if (c->handshake_mgr != nullptr) {
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) {
+ if (!c->connecting && c->endpoint != nullptr) {
grpc_endpoint_shutdown(exec_ctx, c->endpoint, GRPC_ERROR_REF(why));
}
gpr_mu_unlock(&c->mu);
@@ -117,18 +117,42 @@ static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
} else {
grpc_endpoint_delete_from_pollset_set(exec_ctx, args->endpoint,
c->args.interested_parties);
- c->result->transport =
- grpc_create_chttp2_transport(exec_ctx, args->args, args->endpoint, 1);
+ c->result->transport = grpc_create_chttp2_transport(exec_ctx, 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(exec_ctx, c->result->transport,
- args->read_buffer);
+ args->read_buffer, nullptr);
c->result->channel_args = args->args;
}
grpc_closure* notify = c->notify;
- c->notify = NULL;
+ c->notify = nullptr;
GRPC_CLOSURE_SCHED(exec_ctx, notify, error);
grpc_handshake_manager_destroy(exec_ctx, c->handshake_mgr);
- c->handshake_mgr = NULL;
+ c->handshake_mgr = nullptr;
gpr_mu_unlock(&c->mu);
chttp2_connector_unref(exec_ctx, (grpc_connector*)c);
}
@@ -141,9 +165,10 @@ static void start_handshake_locked(grpc_exec_ctx* exec_ctx,
grpc_endpoint_add_to_pollset_set(exec_ctx, c->endpoint,
c->args.interested_parties);
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.
+ exec_ctx, 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(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
@@ -159,15 +184,15 @@ static void connected(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
}
memset(c->result, 0, sizeof(*c->result));
grpc_closure* notify = c->notify;
- c->notify = NULL;
+ c->notify = nullptr;
GRPC_CLOSURE_SCHED(exec_ctx, notify, error);
- if (c->endpoint != NULL) {
+ if (c->endpoint != nullptr) {
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);
+ GPR_ASSERT(c->endpoint != nullptr);
start_handshake_locked(exec_ctx, c);
gpr_mu_unlock(&c->mu);
}
@@ -182,11 +207,11 @@ static void chttp2_connector_connect(grpc_exec_ctx* exec_ctx,
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);
+ GPR_ASSERT(c->notify == nullptr);
c->notify = notify;
c->args = *args;
c->result = result;
- GPR_ASSERT(c->endpoint == NULL);
+ 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);
diff --git a/src/core/ext/transport/chttp2/client/chttp2_connector.h b/src/core/ext/transport/chttp2/client/chttp2_connector.h
index 63f264e0ef..e258892cfc 100644
--- a/src/core/ext/transport/chttp2/client/chttp2_connector.h
+++ b/src/core/ext/transport/chttp2/client/chttp2_connector.h
@@ -19,16 +19,8 @@
#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_CLIENT_CHTTP2_CONNECTOR_H
#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_CLIENT_CHTTP2_CONNECTOR_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#include "src/core/ext/filters/client_channel/connector.h"
grpc_connector* grpc_chttp2_connector_create();
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_CLIENT_CHTTP2_CONNECTOR_H */
diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
index 26c7f0debf..028b69e5ff 100644
--- a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
+++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
@@ -49,9 +49,9 @@ 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) {
+ 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(
@@ -62,7 +62,7 @@ static grpc_channel* client_channel_factory_create_channel(
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_CLIENT_CHANNEL, nullptr);
grpc_channel_args_destroy(exec_ctx, new_args);
return channel;
}
@@ -86,7 +86,7 @@ grpc_channel* grpc_insecure_channel_create(const char* target,
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);
@@ -98,8 +98,8 @@ grpc_channel* grpc_insecure_channel_create(const char* target,
// 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");
+ 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.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc
index 0974a7c393..c6b149d0b1 100644
--- a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc
+++ b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc
@@ -53,19 +53,19 @@ grpc_channel* grpc_insecure_channel_create_from_fd(
&exec_ctx, grpc_fd_create(fd, "client"), args, "fd-client");
grpc_transport* transport =
- grpc_create_chttp2_transport(&exec_ctx, final_args, client, 1);
+ grpc_create_chttp2_transport(&exec_ctx, 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_chttp2_transport_start_reading(&exec_ctx, transport, nullptr, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
- 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
diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
index 68c1e1868c..dd2bc427a7 100644
--- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
+++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
@@ -47,51 +47,51 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
grpc_exec_ctx* exec_ctx, 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 =
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);
+ GPR_ASSERT(server_uri_str != nullptr);
grpc_uri* server_uri =
grpc_uri_parse(exec_ctx, server_uri_str, true /* supress errors */);
- GPR_ASSERT(server_uri != NULL);
+ 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 =
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 =
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);
+ 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 =
(const char*)grpc_slice_hash_table_get(targets_info, key);
- if (value != NULL) target_name_to_check = gpr_strdup(value);
+ if (value != nullptr) target_name_to_check = gpr_strdup(value);
grpc_slice_unref_internal(exec_ctx, 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);
@@ -101,10 +101,10 @@ 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,
@@ -114,18 +114,18 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
"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,
+ 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,
"lb_channel_create");
- if (new_args_from_connector != NULL) {
+ if (new_args_from_connector != nullptr) {
grpc_channel_args_destroy(exec_ctx, new_args_from_connector);
}
grpc_subchannel_args* final_sc_args =
@@ -140,11 +140,11 @@ static grpc_subchannel* client_channel_factory_create_subchannel(
const grpc_subchannel_args* args) {
grpc_subchannel_args* subchannel_args =
get_secure_naming_subchannel_args(exec_ctx, args);
- if (subchannel_args == NULL) {
+ 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 =
@@ -160,9 +160,9 @@ 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) {
+ 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(
@@ -173,7 +173,7 @@ static grpc_channel* client_channel_factory_create_channel(
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_CLIENT_CHANNEL, nullptr);
grpc_channel_args_destroy(exec_ctx, new_args);
return channel;
}
@@ -199,9 +199,9 @@ grpc_channel* grpc_secure_channel_create(grpc_channel_credentials* creds,
"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) {
+ 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[] = {
@@ -217,8 +217,8 @@ grpc_channel* grpc_secure_channel_create(grpc_channel_credentials* creds,
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 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.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc
index 98683acc59..49ee677464 100644
--- a/src/core/ext/transport/chttp2/server/chttp2_server.cc
+++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc
@@ -21,6 +21,7 @@
#include <grpc/grpc.h>
#include <inttypes.h>
+#include <limits.h>
#include <string.h>
#include <grpc/support/alloc.h>
@@ -31,6 +32,7 @@
#include "src/core/ext/filters/http/server/http_server_filter.h"
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
+#include "src/core/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"
@@ -53,12 +55,52 @@ typedef struct {
} 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(
+ grpc_exec_ctx* exec_ctx, server_connection_state* connection_state) {
+ if (gpr_unref(&connection_state->refs)) {
+ if (connection_state->transport != nullptr) {
+ GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, connection_state->transport,
+ "receive settings timeout");
+ }
+ gpr_free(connection_state);
+ }
+}
+
+static void on_timeout(grpc_exec_ctx* exec_ctx, 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(exec_ctx, &connection_state->transport->base, op);
+ }
+ server_connection_state_unref(exec_ctx, connection_state);
+}
+
+static void on_receive_settings(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
+ server_connection_state* connection_state = (server_connection_state*)arg;
+ if (error == GRPC_ERROR_NONE) {
+ grpc_timer_cancel(exec_ctx, &connection_state->timer);
+ }
+ server_connection_state_unref(exec_ctx, 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;
@@ -68,8 +110,7 @@ static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
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) {
+ 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
@@ -86,15 +127,31 @@ static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
// 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);
+ if (args->endpoint != nullptr) {
+ grpc_transport* transport = grpc_create_chttp2_transport(
+ exec_ctx, args->args, args->endpoint, false);
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);
+ // 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(
+ exec_ctx, transport, args->read_buffer,
+ &connection_state->on_receive_settings);
grpc_channel_args_destroy(exec_ctx, 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(exec_ctx, &connection_state->timer,
+ connection_state->deadline,
+ &connection_state->on_timeout);
}
}
grpc_handshake_manager_pending_list_remove(
@@ -102,9 +159,9 @@ static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
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);
+ grpc_tcp_server_unref(exec_ctx, connection_state->svr_state->tcp_server);
+ server_connection_state_unref(exec_ctx, connection_state);
}
static void on_accept(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
@@ -125,20 +182,25 @@ static void on_accept(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
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));
+ (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(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 grpc_millis deadline =
- grpc_exec_ctx_now(exec_ctx) + 120 * GPR_MS_PER_SEC;
+ const grpc_arg* timeout_arg =
+ grpc_channel_args_find(state->args, GRPC_ARG_SERVER_HANDSHAKE_TIMEOUT_MS);
+ connection_state->deadline =
+ grpc_exec_ctx_now(exec_ctx) +
+ grpc_channel_arg_get_integer(timeout_arg,
+ {120 * GPR_MS_PER_SEC, 1, INT_MAX});
grpc_handshake_manager_do_handshake(exec_ctx, connection_state->handshake_mgr,
- tcp, state->args, deadline, acceptor,
- on_handshake_done, connection_state);
+ nullptr /* interested_parties */, tcp,
+ state->args, connection_state->deadline,
+ acceptor, on_handshake_done,
+ connection_state);
}
/* Server callback: start listening on our ports */
@@ -166,7 +228,7 @@ static void tcp_server_shutdown_complete(grpc_exec_ctx* exec_ctx, void* arg,
// Flush queued work before destroying handshaker factory, since that
// may do a synchronous unref.
grpc_exec_ctx_flush(exec_ctx);
- if (destroy_done != NULL) {
+ if (destroy_done != nullptr) {
destroy_done->cb(exec_ctx, destroy_done->cb_arg, GRPC_ERROR_REF(error));
grpc_exec_ctx_flush(exec_ctx);
}
@@ -194,14 +256,14 @@ 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;
+ 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 = NULL;
- grpc_error** errors = NULL;
+ server_state* state = nullptr;
+ grpc_error** errors = nullptr;
size_t naddrs = 0;
*port_num = -1;
@@ -284,7 +346,7 @@ error:
*port_num = 0;
done:
- if (errors != NULL) {
+ if (errors != nullptr) {
for (i = 0; i < naddrs; i++) {
GRPC_ERROR_UNREF(errors[i]);
}
diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.h b/src/core/ext/transport/chttp2/server/chttp2_server.h
index 4e0e7aa617..68304fd4f7 100644
--- a/src/core/ext/transport/chttp2/server/chttp2_server.h
+++ b/src/core/ext/transport/chttp2/server/chttp2_server.h
@@ -23,18 +23,10 @@
#include "src/core/lib/iomgr/exec_ctx.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/// 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);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H */
diff --git a/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc b/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc
index e37d69e5e9..3fe05ce4ef 100644
--- a/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc
+++ b/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc
@@ -36,7 +36,7 @@
void grpc_server_add_insecure_channel_from_fd(grpc_server* server,
void* reserved, int fd) {
- GPR_ASSERT(reserved == NULL);
+ GPR_ASSERT(reserved == nullptr);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
char* name;
@@ -50,7 +50,7 @@ void grpc_server_add_insecure_channel_from_fd(grpc_server* server,
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 */);
+ &exec_ctx, server_args, server_endpoint, false /* is_client */);
grpc_pollset** pollsets;
size_t num_pollsets = 0;
@@ -60,8 +60,9 @@ void grpc_server_add_insecure_channel_from_fd(grpc_server* server,
grpc_endpoint_add_to_pollset(&exec_ctx, 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_server_setup_transport(&exec_ctx, server, transport, nullptr,
+ server_args);
+ grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
diff --git a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc
index 4b2e348780..ac3ea40f47 100644
--- a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc
+++ b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc
@@ -38,16 +38,16 @@ 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;
+ grpc_server_security_connector* sc = nullptr;
int port_num = 0;
grpc_security_status status;
- grpc_channel_args* args = NULL;
+ 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;
@@ -74,7 +74,7 @@ int grpc_server_add_secure_http2_port(grpc_server* server, const char* addr,
// Add server port.
err = grpc_chttp2_server_add_port(&exec_ctx, server, addr, args, &port_num);
done:
- if (sc != NULL) {
+ if (sc != nullptr) {
GRPC_SECURITY_CONNECTOR_UNREF(&exec_ctx, &sc->base, "server");
}
grpc_exec_ctx_finish(&exec_ctx);
diff --git a/src/core/ext/transport/chttp2/transport/bin_decoder.h b/src/core/ext/transport/chttp2/transport/bin_decoder.h
index a9c4c9a0f6..a78c305766 100644
--- a/src/core/ext/transport/chttp2/transport/bin_decoder.h
+++ b/src/core/ext/transport/chttp2/transport/bin_decoder.h
@@ -22,10 +22,6 @@
#include <grpc/slice.h>
#include <stdbool.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
struct grpc_base64_decode_context {
/* input/output: */
uint8_t* input_cur;
@@ -53,8 +49,4 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx* exec_ctx,
grpc_slice input,
size_t output_length);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H */
diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.h b/src/core/ext/transport/chttp2/transport/bin_encoder.h
index 0be3633354..a8f36a345a 100644
--- a/src/core/ext/transport/chttp2/transport/bin_encoder.h
+++ b/src/core/ext/transport/chttp2/transport/bin_encoder.h
@@ -21,10 +21,6 @@
#include <grpc/slice.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* base64 encode a slice. Returns a new slice, does not take ownership of the
input */
grpc_slice grpc_chttp2_base64_encode(grpc_slice input);
@@ -40,8 +36,4 @@ grpc_slice grpc_chttp2_huffman_compress(grpc_slice input);
return y; */
grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(grpc_slice input);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H */
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc b/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc
index ac9ae5c395..97c1878f34 100644
--- a/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc
+++ b/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc
@@ -20,13 +20,6 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/transport/metadata.h"
-extern "C" 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
-}
+void grpc_chttp2_plugin_init(void) {}
-extern "C" void grpc_chttp2_plugin_shutdown(void) {}
+void grpc_chttp2_plugin_shutdown(void) {}
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
index a955ec2589..63ac65ac78 100644
--- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
+++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
@@ -90,13 +90,9 @@ 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,
@@ -201,8 +197,8 @@ static void destruct_transport(grpc_exec_ctx* exec_ctx,
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);
@@ -235,7 +231,7 @@ static void destruct_transport(grpc_exec_ctx* exec_ctx,
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)) {
+ 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);
@@ -246,7 +242,7 @@ void grpc_chttp2_unref_transport(grpc_exec_ctx* exec_ctx,
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)) {
+ 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);
@@ -553,6 +549,7 @@ static void init_transport(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
/* 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 = GRPC_MILLIS_INF_PAST;
t->ping_recv_state.ping_strikes = 0;
@@ -575,7 +572,7 @@ static void init_transport(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
schedule_bdp_ping_locked(exec_ctx, t);
grpc_chttp2_act_on_flowctl_action(
- exec_ctx, t->flow_control->PeriodicUpdate(exec_ctx), t, NULL);
+ exec_ctx, t->flow_control->PeriodicUpdate(exec_ctx), t, nullptr);
}
grpc_chttp2_initiate_write(exec_ctx, t,
@@ -614,7 +611,7 @@ static void close_transport_locked(grpc_exec_ctx* exec_ctx,
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");
@@ -655,6 +652,11 @@ static void close_transport_locked(grpc_exec_ctx* exec_ctx,
GPR_ASSERT(t->write_state == GRPC_CHTTP2_WRITE_STATE_IDLE);
grpc_endpoint_shutdown(exec_ctx, t->ep, GRPC_ERROR_REF(error));
}
+ if (t->notify_on_receive_settings != nullptr) {
+ GRPC_CLOSURE_SCHED(exec_ctx, t->notify_on_receive_settings,
+ GRPC_ERROR_CANCELLED);
+ t->notify_on_receive_settings = nullptr;
+ }
GRPC_ERROR_UNREF(error);
}
@@ -729,7 +731,7 @@ static void destroy_stream_locked(grpc_exec_ctx* exec_ctx, void* sp,
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,
@@ -749,12 +751,12 @@ 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);
+ 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(exec_ctx, &s->data_parser);
grpc_chttp2_incoming_metadata_buffer_destroy(exec_ctx,
&s->metadata_buffer[0]);
@@ -781,13 +783,13 @@ static void destroy_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
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;
@@ -807,16 +809,16 @@ grpc_chttp2_stream* grpc_chttp2_parsing_lookup_stream(grpc_chttp2_transport* t,
grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_exec_ctx* exec_ctx,
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);
+ 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->accepting_stream = nullptr;
return accepting;
}
@@ -845,9 +847,9 @@ static void set_write_state(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
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) {
+ if (t->close_transport_on_writes_finished != nullptr) {
grpc_error* err = t->close_transport_on_writes_finished;
- t->close_transport_on_writes_finished = NULL;
+ t->close_transport_on_writes_finished = nullptr;
close_transport_locked(exec_ctx, t, err);
}
}
@@ -987,7 +989,7 @@ 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))
@@ -1221,7 +1223,7 @@ static grpc_closure* add_closure_barrier(grpc_closure* closure) {
static void null_then_run_closure(grpc_exec_ctx* exec_ctx,
grpc_closure** closure, grpc_error* error) {
grpc_closure* c = *closure;
- *closure = NULL;
+ *closure = nullptr;
GRPC_CLOSURE_RUN(exec_ctx, c, error);
}
@@ -1231,13 +1233,13 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx* exec_ctx,
grpc_closure** pclosure,
grpc_error* error, const char* desc) {
grpc_closure* closure = *pclosure;
- *pclosure = NULL;
- if (closure == NULL) {
+ *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)) {
+ if (grpc_http_trace.enabled()) {
const char* errstr = grpc_error_string(error);
gpr_log(
GPR_DEBUG,
@@ -1262,7 +1264,7 @@ 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)) {
@@ -1275,7 +1277,7 @@ 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) {
+ if (batch->idx.named.grpc_status != nullptr) {
return !grpc_mdelem_eq(batch->idx.named.grpc_status->md,
GRPC_MDELEM_GRPC_STATUS_0);
}
@@ -1306,7 +1308,7 @@ static void continue_fetching_send_locked(grpc_exec_ctx* exec_ctx,
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 */
@@ -1320,14 +1322,14 @@ static void continue_fetching_send_locked(grpc_exec_ctx* exec_ctx,
"fetching_send_message_finished");
} else {
grpc_chttp2_write_cb* cb = t->write_cb_pool;
- if (cb == NULL) {
+ 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;
+ s->fetching_send_message_finished = nullptr;
grpc_chttp2_write_cb** list =
s->fetching_send_message->flags & GRPC_WRITE_THROUGH
? &s->on_write_finished_cbs
@@ -1335,7 +1337,7 @@ static void continue_fetching_send_locked(grpc_exec_ctx* exec_ctx,
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)) {
@@ -1373,7 +1375,7 @@ static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
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));
@@ -1396,7 +1398,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
GRPC_STATS_INC_HTTP2_OP_BATCHES(exec_ctx);
- if (GRPC_TRACER_ON(grpc_http_trace)) {
+ 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);
@@ -1412,9 +1414,9 @@ 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) {
+ 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
@@ -1423,7 +1425,7 @@ 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;
}
@@ -1436,12 +1438,12 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
if (op->send_initial_metadata) {
GRPC_STATS_INC_HTTP2_OP_SEND_INITIAL_METADATA(exec_ctx);
- GPR_ASSERT(s->send_initial_metadata_finished == NULL);
+ 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
@@ -1502,7 +1504,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
}
}
} 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,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
@@ -1511,7 +1513,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
"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));
}
@@ -1538,7 +1540,7 @@ 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);
+ 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;
@@ -1566,7 +1568,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
if (op->send_trailing_metadata) {
GRPC_STATS_INC_HTTP2_OP_SEND_TRAILING_METADATA(exec_ctx);
- GPR_ASSERT(s->send_trailing_metadata_finished == NULL);
+ 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 =
@@ -1594,7 +1596,7 @@ 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,
grpc_metadata_batch_is_empty(
@@ -1616,14 +1618,14 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
if (op->recv_initial_metadata) {
GRPC_STATS_INC_HTTP2_OP_RECV_INITIAL_METADATA(exec_ctx);
- GPR_ASSERT(s->recv_initial_metadata_ready == NULL);
+ 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));
}
@@ -1633,7 +1635,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
if (op->recv_message) {
GRPC_STATS_INC_HTTP2_OP_RECV_MESSAGE(exec_ctx);
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;
@@ -1651,7 +1653,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
if (op->recv_trailing_metadata) {
GRPC_STATS_INC_HTTP2_OP_RECV_TRAILING_METADATA(exec_ctx);
- GPR_ASSERT(s->recv_trailing_metadata_finished == NULL);
+ 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;
@@ -1686,7 +1688,7 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
}
}
- if (GRPC_TRACER_ON(grpc_http_trace)) {
+ 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);
@@ -1761,8 +1763,8 @@ static void send_goaway(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
t->sent_goaway_state = GRPC_CHTTP2_GOAWAY_SEND_SCHEDULED;
grpc_http2_error_code http_error;
grpc_slice slice;
- grpc_error_get_status(exec_ctx, error, GRPC_MILLIS_INF_FUTURE, NULL, &slice,
- &http_error);
+ grpc_error_get_status(exec_ctx, 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,
@@ -1794,7 +1796,6 @@ static void perform_transport_op_locked(grpc_exec_ctx* exec_ctx,
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;
if (op->goaway_error) {
send_goaway(exec_ctx, t, op->goaway_error);
@@ -1815,19 +1816,19 @@ static void perform_transport_op_locked(grpc_exec_ctx* exec_ctx,
}
if (op->send_ping) {
- send_ping_locked(exec_ctx, t, NULL, op->send_ping);
+ send_ping_locked(exec_ctx, t, nullptr, op->send_ping);
grpc_chttp2_initiate_write(exec_ctx, 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,
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(exec_ctx, t, op->disconnect_with_error);
}
GRPC_CLOSURE_RUN(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
@@ -1856,7 +1857,7 @@ static void perform_transport_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
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 &&
+ 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);
@@ -1876,8 +1877,8 @@ 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;
+ 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);
if (!s->pending_byte_stream) {
@@ -1906,7 +1907,7 @@ 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,
@@ -1922,17 +1923,17 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx* exec_ctx,
}
error = grpc_deframe_unprocessed_incoming_frames(
exec_ctx, &s->data_parser, s, &s->decompressed_data_buffer,
- NULL, s->recv_message);
+ 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->unprocessed_incoming_frames_buffer, nullptr, s->recv_message);
}
if (error != GRPC_ERROR_NONE) {
s->seen_error = true;
@@ -1941,15 +1942,15 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx* exec_ctx,
grpc_slice_buffer_reset_and_unref_internal(
exec_ctx, &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) {
+ if (error == GRPC_ERROR_NONE && *s->recv_message != nullptr) {
null_then_run_closure(exec_ctx, &s->recv_message_ready, GRPC_ERROR_NONE);
} else if (s->published_metadata[1] != GRPC_METADATA_NOT_PUBLISHED) {
- *s->recv_message = NULL;
+ *s->recv_message = nullptr;
null_then_run_closure(exec_ctx, &s->recv_message_ready, GRPC_ERROR_NONE);
}
GRPC_ERROR_UNREF(error);
@@ -1960,7 +1961,7 @@ 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 &&
+ 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);
@@ -1972,7 +1973,7 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx* exec_ctx,
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;
@@ -1980,10 +1981,10 @@ 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)) {
+ 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(exec_ctx, &s->frame_storage);
grpc_slice_buffer_reset_and_unref_internal(
exec_ctx, &s->unprocessed_incoming_frames_buffer);
@@ -1995,12 +1996,12 @@ 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) {
+ s->recv_trailing_metadata_finished != nullptr) {
grpc_chttp2_incoming_metadata_buffer_publish(
exec_ctx, &s->metadata_buffer[1], s->recv_trailing_metadata);
grpc_chttp2_complete_closure_step(
@@ -2016,18 +2017,18 @@ static void remove_stream(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
(grpc_chttp2_stream*)grpc_chttp2_stream_map_delete(&t->stream_map, id);
GPR_ASSERT(s);
if (t->incoming_stream == s) {
- t->incoming_stream = NULL;
+ t->incoming_stream = nullptr;
grpc_chttp2_parsing_become_skip_parser(exec_ctx, t);
}
if (s->pending_byte_stream) {
- if (s->on_next != NULL) {
+ 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;
+ s->data_parser.parsing_frame = nullptr;
} else {
GRPC_ERROR_UNREF(s->byte_stream_error);
s->byte_stream_error = GRPC_ERROR_REF(error);
@@ -2064,8 +2065,8 @@ void grpc_chttp2_cancel_stream(grpc_exec_ctx* exec_ctx,
if (!s->read_closed || !s->write_closed) {
if (s->id != 0) {
grpc_http2_error_code http_error;
- grpc_error_get_status(exec_ctx, due_to_error, s->deadline, NULL, NULL,
- &http_error);
+ grpc_error_get_status(exec_ctx, 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));
@@ -2083,7 +2084,8 @@ void grpc_chttp2_fake_status(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
grpc_chttp2_stream* s, grpc_error* error) {
grpc_status_code status;
grpc_slice slice;
- grpc_error_get_status(exec_ctx, error, s->deadline, &status, &slice, NULL);
+ grpc_error_get_status(exec_ctx, error, s->deadline, &status, &slice, nullptr,
+ nullptr);
if (status != GRPC_STATUS_OK) {
s->seen_error = true;
}
@@ -2094,7 +2096,7 @@ 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",
@@ -2165,17 +2167,17 @@ void grpc_chttp2_fail_pending_writes(grpc_exec_ctx* exec_ctx,
grpc_chttp2_stream* s, grpc_error* error) {
error =
removal_error(error, s, "Pending writes failed due to stream closure");
- s->send_initial_metadata = NULL;
+ s->send_initial_metadata = nullptr;
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;
+ s->send_trailing_metadata = nullptr;
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;
+ s->fetching_send_message = nullptr;
grpc_chttp2_complete_closure_step(
exec_ctx, t, s, &s->fetching_send_message_finished, GRPC_ERROR_REF(error),
"fetching_send_message_finished");
@@ -2248,7 +2250,7 @@ static void close_from_api(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
grpc_status_code grpc_status;
grpc_slice slice;
grpc_error_get_status(exec_ctx, error, s->deadline, &grpc_status, &slice,
- NULL);
+ nullptr, nullptr);
GPR_ASSERT(grpc_status >= 0 && (int)grpc_status < 100);
@@ -2472,7 +2474,7 @@ static grpc_error* try_http_parsing(grpc_exec_ctx* exec_ctx,
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) {
@@ -2569,7 +2571,7 @@ static void read_action_locked(grpc_exec_ctx* exec_ctx, void* tp,
grpc_endpoint_read(exec_ctx, t->ep, &t->read_buffer,
&t->read_action_locked);
grpc_chttp2_act_on_flowctl_action(exec_ctx, t->flow_control->MakeAction(),
- t, NULL);
+ t, nullptr);
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keep_reading");
} else {
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "reading_action");
@@ -2594,7 +2596,7 @@ static void schedule_bdp_ping_locked(grpc_exec_ctx* exec_ctx,
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)) {
+ if (grpc_http_trace.enabled()) {
gpr_log(GPR_DEBUG, "%s: Start BDP ping err=%s", t->peer_string,
grpc_error_string(error));
}
@@ -2608,7 +2610,7 @@ static void start_bdp_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
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)) {
+ if (grpc_http_trace.enabled()) {
gpr_log(GPR_DEBUG, "%s: Complete BDP ping err=%s", t->peer_string,
grpc_error_string(error));
}
@@ -2820,7 +2822,7 @@ static void reset_byte_stream(grpc_exec_ctx* exec_ctx, void* arg,
} else {
GPR_ASSERT(error != GRPC_ERROR_NONE);
GRPC_CLOSURE_SCHED(exec_ctx, s->on_next, GRPC_ERROR_REF(error));
- s->on_next = NULL;
+ 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));
@@ -2859,9 +2861,9 @@ static void incoming_byte_stream_next_locked(grpc_exec_ctx* exec_ctx,
} else if (s->byte_stream_error != GRPC_ERROR_NONE) {
GRPC_CLOSURE_SCHED(exec_ctx, bs->next_action.on_complete,
GRPC_ERROR_REF(s->byte_stream_error));
- if (s->data_parser.parsing_frame != NULL) {
+ if (s->data_parser.parsing_frame != nullptr) {
incoming_byte_stream_unref(exec_ctx, s->data_parser.parsing_frame);
- s->data_parser.parsing_frame = NULL;
+ s->data_parser.parsing_frame = nullptr;
}
} else if (s->read_closed) {
if (bs->remaining_bytes != 0) {
@@ -2869,9 +2871,9 @@ static void incoming_byte_stream_next_locked(grpc_exec_ctx* exec_ctx,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message");
GRPC_CLOSURE_SCHED(exec_ctx, bs->next_action.on_complete,
GRPC_ERROR_REF(s->byte_stream_error));
- if (s->data_parser.parsing_frame != NULL) {
+ if (s->data_parser.parsing_frame != nullptr) {
incoming_byte_stream_unref(exec_ctx, s->data_parser.parsing_frame);
- s->data_parser.parsing_frame = NULL;
+ s->data_parser.parsing_frame = nullptr;
}
} else {
/* Should never reach here. */
@@ -2927,7 +2929,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.");
@@ -2939,7 +2941,7 @@ 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();
@@ -2947,7 +2949,7 @@ static grpc_error* incoming_byte_stream_pull(grpc_exec_ctx* exec_ctx,
}
error = grpc_deframe_unprocessed_incoming_frames(
exec_ctx, &s->data_parser, s, &s->unprocessed_incoming_frames_buffer,
- slice, NULL);
+ slice, nullptr);
if (error != GRPC_ERROR_NONE) {
return error;
}
@@ -2985,7 +2987,7 @@ static void incoming_byte_stream_publish_error(
GPR_ASSERT(error != GRPC_ERROR_NONE);
GRPC_CLOSURE_SCHED(exec_ctx, s->on_next, GRPC_ERROR_REF(error));
- s->on_next = NULL;
+ 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,
@@ -3006,7 +3008,7 @@ grpc_error* grpc_chttp2_incoming_byte_stream_push(
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;
@@ -3109,7 +3111,7 @@ static void benign_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* arg,
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);
}
@@ -3117,8 +3119,7 @@ static void benign_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* arg,
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",
@@ -3140,7 +3141,7 @@ static void destructive_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* arg,
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)) {
+ if (grpc_resource_quota_trace.enabled()) {
gpr_log(GPR_DEBUG, "HTTP2: %s - abandon stream id %d", t->peer_string,
s->id);
}
@@ -3235,22 +3236,23 @@ 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_endpoint* ep, bool 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);
+ init_transport(exec_ctx, 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) {
+void grpc_chttp2_transport_start_reading(
+ grpc_exec_ctx* exec_ctx, 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);
}
+ t->notify_on_receive_settings = notify_on_receive_settings;
GRPC_CLOSURE_SCHED(exec_ctx, &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 972104f62c..bd72e07bab 100644
--- a/src/core/ext/transport/chttp2/transport/chttp2_transport.h
+++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.h
@@ -23,30 +23,20 @@
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/transport/transport.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern grpc_tracer_flag grpc_http_trace;
-extern grpc_tracer_flag grpc_flowctl_trace;
-extern grpc_tracer_flag grpc_trace_http2_stream_state;
-
-#ifndef NDEBUG
-extern grpc_tracer_flag grpc_trace_chttp2_refcount;
-#endif
+extern grpc_core::TraceFlag grpc_http_trace;
+extern grpc_core::TraceFlag grpc_trace_http2_stream_state;
+extern grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_refcount;
grpc_transport* grpc_create_chttp2_transport(
grpc_exec_ctx* exec_ctx, const grpc_channel_args* channel_args,
- grpc_endpoint* ep, int is_client);
+ 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);
-
-#ifdef __cplusplus
-}
-#endif
+/// 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_exec_ctx* exec_ctx, 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.cc b/src/core/ext/transport/chttp2/transport/flow_control.cc
index 64f6b3c917..8a057bd9ff 100644
--- a/src/core/ext/transport/chttp2/transport/flow_control.cc
+++ b/src/core/ext/transport/chttp2/transport/flow_control.cc
@@ -31,6 +31,8 @@
#include "src/core/ext/transport/chttp2/transport/internal.h"
#include "src/core/lib/support/string.h"
+grpc_core::TraceFlag grpc_flowctl_trace(false, "flowctl");
+
namespace grpc_core {
namespace chttp2 {
@@ -312,7 +314,9 @@ double TransportFlowControl::SmoothLogBdp(grpc_exec_ctx* exec_ctx,
double bdp_error = value - pid_controller_.last_control_value();
const double dt = (double)(now - last_pid_update_) * 1e-3;
last_pid_update_ = now;
- return pid_controller_.Update(bdp_error, dt);
+ // Limit dt to 100ms
+ const double kMaxDt = 0.1;
+ return pid_controller_.Update(bdp_error, dt > kMaxDt ? kMaxDt : dt);
}
FlowControlAction::Urgency TransportFlowControl::DeltaUrgency(
diff --git a/src/core/ext/transport/chttp2/transport/flow_control.h b/src/core/ext/transport/chttp2/transport/flow_control.h
index 7dd348ed5f..2515c94309 100644
--- a/src/core/ext/transport/chttp2/transport/flow_control.h
+++ b/src/core/ext/transport/chttp2/transport/flow_control.h
@@ -19,6 +19,7 @@
#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>
@@ -30,7 +31,7 @@
struct grpc_chttp2_transport;
struct grpc_chttp2_stream;
-extern "C" grpc_tracer_flag grpc_flowctl_trace;
+extern grpc_core::TraceFlag grpc_flowctl_trace;
namespace grpc {
namespace testing {
@@ -118,7 +119,7 @@ class FlowControlTrace {
StreamFlowControl* sfc);
void Finish();
- const bool enabled_ = GRPC_TRACER_ON(grpc_flowctl_trace);
+ const bool enabled_ = grpc_flowctl_trace.enabled();
TransportFlowControl* tfc_;
StreamFlowControl* sfc_;
diff --git a/src/core/ext/transport/chttp2/transport/frame.h b/src/core/ext/transport/chttp2/transport/frame.h
index e7debdad79..dba4c004ec 100644
--- a/src/core/ext/transport/chttp2/transport/frame.h
+++ b/src/core/ext/transport/chttp2/transport/frame.h
@@ -24,10 +24,6 @@
#include "src/core/lib/iomgr/error.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* defined in internal.h */
typedef struct grpc_chttp2_stream grpc_chttp2_stream;
typedef struct grpc_chttp2_transport grpc_chttp2_transport;
@@ -47,8 +43,4 @@ typedef struct grpc_chttp2_transport grpc_chttp2_transport;
#define GRPC_CHTTP2_DATA_FLAG_PADDED 8
#define GRPC_CHTTP2_FLAG_HAS_PRIORITY 0x20
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H */
diff --git a/src/core/ext/transport/chttp2/transport/frame_data.cc b/src/core/ext/transport/chttp2/transport/frame_data.cc
index 7d2c7f5ab9..f0c3b55792 100644
--- a/src/core/ext/transport/chttp2/transport/frame_data.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_data.cc
@@ -32,13 +32,13 @@
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) {
+ if (parser->parsing_frame != nullptr) {
GRPC_ERROR_UNREF(grpc_chttp2_incoming_byte_stream_finished(
exec_ctx, parser->parsing_frame,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Parser destroyed"), false));
@@ -105,9 +105,9 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
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);
@@ -188,8 +188,8 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
/* 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;
@@ -203,7 +203,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
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 = nullptr;
p->state = GRPC_CHTTP2_DATA_FH_0;
}
s->pending_byte_stream = true;
@@ -216,8 +216,8 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
grpc_slice_unref_internal(exec_ctx, 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);
continue;
@@ -239,7 +239,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
grpc_slice_unref_internal(exec_ctx, 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);
return GRPC_ERROR_NONE;
@@ -273,7 +273,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
grpc_slice_unref_internal(exec_ctx, 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(
@@ -302,7 +302,7 @@ grpc_error* grpc_chttp2_data_parser_parse(grpc_exec_ctx* exec_ctx, void* parser,
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;
+ s->on_next = nullptr;
s->unprocessed_incoming_frames_decompressed = false;
} else {
grpc_slice_ref_internal(slice);
diff --git a/src/core/ext/transport/chttp2/transport/frame_data.h b/src/core/ext/transport/chttp2/transport/frame_data.h
index 96f823a0ad..4de553ea42 100644
--- a/src/core/ext/transport/chttp2/transport/frame_data.h
+++ b/src/core/ext/transport/chttp2/transport/frame_data.h
@@ -28,10 +28,6 @@
#include "src/core/lib/transport/byte_stream.h"
#include "src/core/lib/transport/transport.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef enum {
GRPC_CHTTP2_DATA_FH_0,
GRPC_CHTTP2_DATA_FH_1,
@@ -84,8 +80,4 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
grpc_slice_buffer* slices, grpc_slice* slice_out,
grpc_byte_stream** stream_out);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H */
diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.cc b/src/core/ext/transport/chttp2/transport/frame_goaway.cc
index 6be1d0e0f0..a2ce709a2e 100644
--- a/src/core/ext/transport/chttp2/transport/frame_goaway.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_goaway.cc
@@ -26,7 +26,7 @@
#include <grpc/support/string_util.h>
void grpc_chttp2_goaway_parser_init(grpc_chttp2_goaway_parser* p) {
- p->debug_data = NULL;
+ p->debug_data = nullptr;
}
void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser* p) {
@@ -137,7 +137,7 @@ grpc_error* grpc_chttp2_goaway_parser_parse(grpc_exec_ctx* exec_ctx,
grpc_chttp2_add_incoming_goaway(
exec_ctx, 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;
}
diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.h b/src/core/ext/transport/chttp2/transport/frame_goaway.h
index 9790d0b08d..743e763342 100644
--- a/src/core/ext/transport/chttp2/transport/frame_goaway.h
+++ b/src/core/ext/transport/chttp2/transport/frame_goaway.h
@@ -25,10 +25,6 @@
#include "src/core/ext/transport/chttp2/transport/frame.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef enum {
GRPC_CHTTP2_GOAWAY_LSI0,
GRPC_CHTTP2_GOAWAY_LSI1,
@@ -64,8 +60,4 @@ void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code,
grpc_slice debug_data,
grpc_slice_buffer* slice_buffer);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H */
diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.h b/src/core/ext/transport/chttp2/transport/frame_ping.h
index 034aad002e..76ca397709 100644
--- a/src/core/ext/transport/chttp2/transport/frame_ping.h
+++ b/src/core/ext/transport/chttp2/transport/frame_ping.h
@@ -23,10 +23,6 @@
#include "src/core/ext/transport/chttp2/transport/frame.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct {
uint8_t byte;
uint8_t is_ack;
@@ -45,8 +41,4 @@ grpc_error* grpc_chttp2_ping_parser_parse(grpc_exec_ctx* exec_ctx, void* parser,
/* Test-only function for disabling ping ack */
void grpc_set_disable_ping_ack(bool disable_ping_ack);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H */
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 3f5417e993..7dfc5d4578 100644
--- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h
+++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h
@@ -24,10 +24,6 @@
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/transport/transport.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct {
uint8_t byte;
uint8_t reason_bytes[4];
@@ -44,8 +40,4 @@ grpc_error* grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx* exec_ctx,
grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H */
diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.cc b/src/core/ext/transport/chttp2/transport/frame_settings.cc
index d33da721a5..de4340fea5 100644
--- a/src/core/ext/transport/chttp2/transport/frame_settings.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_settings.cc
@@ -131,6 +131,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(exec_ctx, t->notify_on_receive_settings,
+ GRPC_ERROR_NONE);
+ t->notify_on_receive_settings = nullptr;
+ }
}
return GRPC_ERROR_NONE;
}
@@ -204,20 +209,19 @@ grpc_error* grpc_chttp2_settings_parser_parse(grpc_exec_ctx* exec_ctx, void* p,
parser->incoming_settings[id] != parser->value) {
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->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 18bde92815..36e2ca83a0 100644
--- a/src/core/ext/transport/chttp2/transport/frame_settings.h
+++ b/src/core/ext/transport/chttp2/transport/frame_settings.h
@@ -25,10 +25,6 @@
#include "src/core/ext/transport/chttp2/transport/http2_settings.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef enum {
GRPC_CHTTP2_SPS_ID0,
GRPC_CHTTP2_SPS_ID1,
@@ -62,8 +58,4 @@ grpc_error* grpc_chttp2_settings_parser_parse(grpc_exec_ctx* exec_ctx,
grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H */
diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.cc b/src/core/ext/transport/chttp2/transport/frame_window_update.cc
index 62a4587ac6..08407a8e67 100644
--- a/src/core/ext/transport/chttp2/transport/frame_window_update.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_window_update.cc
@@ -79,7 +79,7 @@ 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);
}
@@ -95,7 +95,7 @@ grpc_error* grpc_chttp2_window_update_parser_parse(
GPR_ASSERT(is_last);
if (t->incoming_stream_id != 0) {
- if (s != NULL) {
+ 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);
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 daf7d2da6b..e031b585fa 100644
--- a/src/core/ext/transport/chttp2/transport/frame_window_update.h
+++ b/src/core/ext/transport/chttp2/transport/frame_window_update.h
@@ -24,10 +24,6 @@
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/transport/transport.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct {
uint8_t byte;
uint8_t is_connection_update;
@@ -43,8 +39,4 @@ 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);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H */
diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
index 3636440905..e76d92e31d 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
+++ 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 "C" 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
@@ -475,9 +473,9 @@ 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)) {
+ if (grpc_http_trace.enabled()) {
char* k = grpc_slice_to_c_string(GRPC_MDKEY(elem));
- char* v = NULL;
+ char* v = nullptr;
if (grpc_is_binary_header(GRPC_MDKEY(elem))) {
v = grpc_dump_slice(GRPC_MDVALUE(elem), GPR_DUMP_HEX);
} else {
@@ -669,7 +667,7 @@ 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);
}
}
diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.h b/src/core/ext/transport/chttp2/transport/hpack_encoder.h
index fd01d1621a..08921b19ec 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_encoder.h
+++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.h
@@ -34,9 +34,7 @@
/* maximum table size we'll actually use */
#define GRPC_CHTTP2_HPACKC_MAX_TABLE_SIZE (1024 * 1024)
-#ifdef __cplusplus
-extern "C" {
-#endif
+extern grpc_core::TraceFlag grpc_http_trace;
typedef struct {
uint32_t filter_elems_sum;
@@ -95,8 +93,4 @@ void grpc_chttp2_encode_header(grpc_exec_ctx* exec_ctx,
const grpc_encode_header_options* options,
grpc_slice_buffer* outbuf);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H */
diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc
index 1181402918..18cb27f199 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc
+++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc
@@ -651,9 +651,9 @@ 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)) {
+ if (grpc_http_trace.enabled()) {
char* k = grpc_slice_to_c_string(GRPC_MDKEY(md));
- char* v = NULL;
+ char* v = nullptr;
if (grpc_is_binary_header(GRPC_MDKEY(md))) {
v = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_HEX);
} else {
@@ -674,7 +674,7 @@ static grpc_error* on_hdr(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_parser* p,
grpc_error* err = grpc_chttp2_hptbl_add(exec_ctx, &p->table, md);
if (err != GRPC_ERROR_NONE) return err;
}
- if (p->on_header == NULL) {
+ if (p->on_header == nullptr) {
GRPC_MDELEM_UNREF(exec_ctx, md);
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("on_header callback not set");
}
@@ -1047,7 +1047,7 @@ static grpc_error* parse_lithdr_nvridx_v(grpc_exec_ctx* exec_ctx,
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)) {
+ if (grpc_http_trace.enabled()) {
gpr_log(GPR_INFO, "MAX TABLE SIZE: %d", p->index);
}
grpc_error* err =
@@ -1523,7 +1523,7 @@ static grpc_error* begin_parse_string(grpc_exec_ctx* exec_ctx,
uint8_t binary,
grpc_chttp2_hpack_parser_string* str) {
if (!p->huff && binary == NOT_BINARY && (end - cur) >= (intptr_t)p->strlen &&
- p->current_slice_refcount != NULL) {
+ p->current_slice_refcount != nullptr) {
GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED(exec_ctx);
str->copied = false;
str->data.referenced.refcount = p->current_slice_refcount;
@@ -1613,15 +1613,15 @@ static grpc_error* parse_value_string_with_literal_key(
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;
+ 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;
@@ -1659,7 +1659,7 @@ grpc_error* grpc_chttp2_hpack_parser_parse(grpc_exec_ctx* exec_ctx,
error = p->state(exec_ctx, p, start, target);
start = target;
}
- p->current_slice_refcount = NULL;
+ p->current_slice_refcount = nullptr;
return error;
}
@@ -1689,7 +1689,7 @@ 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 ||
+ 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) {
@@ -1705,7 +1705,7 @@ grpc_error* grpc_chttp2_header_parser_parse(grpc_exec_ctx* exec_ctx,
grpc_slice slice, int is_last) {
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);
@@ -1721,7 +1721,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);
@@ -1756,8 +1756,8 @@ grpc_error* grpc_chttp2_header_parser_parse(grpc_exec_ctx* exec_ctx,
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 838c482e4a..b4a2b14bdb 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_parser.h
+++ b/src/core/ext/transport/chttp2/transport/hpack_parser.h
@@ -27,10 +27,6 @@
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/transport/metadata.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_chttp2_hpack_parser grpc_chttp2_hpack_parser;
typedef grpc_error* (*grpc_chttp2_hpack_parser_state)(
@@ -115,8 +111,4 @@ grpc_error* grpc_chttp2_header_parser_parse(grpc_exec_ctx* exec_ctx,
grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H */
diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.cc b/src/core/ext/transport/chttp2/transport/hpack_table.cc
index 1a2bc9224e..75b83b80b6 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_table.cc
+++ b/src/core/ext/transport/chttp2/transport/hpack_table.cc
@@ -28,14 +28,14 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/support/murmur_hash.h"
-extern "C" grpc_tracer_flag grpc_http_trace;
+extern grpc_core::TraceFlag grpc_http_trace;
static struct {
const char* key;
const char* value;
} static_table[] = {
/* 0: */
- {NULL, NULL},
+ {nullptr, nullptr},
/* 1: */
{":authority", ""},
/* 2: */
@@ -246,7 +246,7 @@ void grpc_chttp2_hptbl_set_max_bytes(grpc_exec_ctx* exec_ctx,
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) {
@@ -270,7 +270,7 @@ grpc_error* grpc_chttp2_hptbl_set_current_table_size(grpc_exec_ctx* exec_ctx,
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) {
diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.h b/src/core/ext/transport/chttp2/transport/hpack_table.h
index ddc8888f86..aed7b13f0b 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_table.h
+++ b/src/core/ext/transport/chttp2/transport/hpack_table.h
@@ -24,10 +24,6 @@
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/transport/metadata.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* HPACK header table */
/* last index in the static table */
@@ -98,8 +94,4 @@ typedef struct {
grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find(
const grpc_chttp2_hptbl* tbl, grpc_mdelem md);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_TABLE_H */
diff --git a/src/core/ext/transport/chttp2/transport/http2_settings.h b/src/core/ext/transport/chttp2/transport/http2_settings.h
index 86069b498b..fd15b6977b 100644
--- a/src/core/ext/transport/chttp2/transport/http2_settings.h
+++ b/src/core/ext/transport/chttp2/transport/http2_settings.h
@@ -36,9 +36,6 @@ typedef enum {
#define GRPC_CHTTP2_NUM_SETTINGS 7
-#ifdef __cplusplus
-extern "C" {
-#endif
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);
@@ -60,8 +57,4 @@ typedef struct {
extern const grpc_chttp2_setting_parameters
grpc_chttp2_settings_parameters[GRPC_CHTTP2_NUM_SETTINGS];
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H */
diff --git a/src/core/ext/transport/chttp2/transport/huffsyms.h b/src/core/ext/transport/chttp2/transport/huffsyms.h
index 4002706bc0..2e2a5dacae 100644
--- a/src/core/ext/transport/chttp2/transport/huffsyms.h
+++ b/src/core/ext/transport/chttp2/transport/huffsyms.h
@@ -19,10 +19,6 @@
#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HUFFSYMS_H
#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HUFFSYMS_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* HPACK static huffman table */
#define GRPC_CHTTP2_NUM_HUFFSYMS 257
@@ -34,8 +30,4 @@ typedef struct {
extern const grpc_chttp2_huffsym grpc_chttp2_huffsyms[GRPC_CHTTP2_NUM_HUFFSYMS];
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HUFFSYMS_H */
diff --git a/src/core/ext/transport/chttp2/transport/incoming_metadata.cc b/src/core/ext/transport/chttp2/transport/incoming_metadata.cc
index 15f80fb8a1..4461f8c12c 100644
--- a/src/core/ext/transport/chttp2/transport/incoming_metadata.cc
+++ b/src/core/ext/transport/chttp2/transport/incoming_metadata.cc
@@ -51,7 +51,7 @@ grpc_error* grpc_chttp2_incoming_metadata_buffer_add(
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;
+ 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);
diff --git a/src/core/ext/transport/chttp2/transport/incoming_metadata.h b/src/core/ext/transport/chttp2/transport/incoming_metadata.h
index 7ccb4a0126..6f2b81ef6c 100644
--- a/src/core/ext/transport/chttp2/transport/incoming_metadata.h
+++ b/src/core/ext/transport/chttp2/transport/incoming_metadata.h
@@ -21,10 +21,6 @@
#include "src/core/lib/transport/transport.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct {
gpr_arena* arena;
grpc_metadata_batch batch;
@@ -49,8 +45,4 @@ grpc_error* grpc_chttp2_incoming_metadata_buffer_replace_or_add(
void grpc_chttp2_incoming_metadata_buffer_set_deadline(
grpc_chttp2_incoming_metadata_buffer* buffer, grpc_millis deadline);
-#ifdef __cplusplus
-}
-#endif
-
#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 60cc280c43..f6fd6795d0 100644
--- a/src/core/ext/transport/chttp2/transport/internal.h
+++ b/src/core/ext/transport/chttp2/transport/internal.h
@@ -42,10 +42,6 @@
#include "src/core/lib/transport/connectivity_state.h"
#include "src/core/lib/transport/transport_impl.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* streams are kept in various linked lists depending on what things need to
happen to them... this enum labels each list */
typedef enum {
@@ -245,6 +241,8 @@ struct grpc_chttp2_transport {
grpc_combiner* combiner;
+ grpc_closure* notify_on_receive_settings;
+
/** write execution state of the transport */
grpc_chttp2_write_state write_state;
/** is this the first write in a series of writes?
@@ -674,13 +672,13 @@ 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;
-#define GRPC_CHTTP2_IF_TRACING(stmt) \
- if (!(GRPC_TRACER_ON(grpc_http_trace))) \
- ; \
- else \
+#define GRPC_CHTTP2_IF_TRACING(stmt) \
+ if (!(grpc_http_trace.enabled())) \
+ ; \
+ else \
stmt
void grpc_chttp2_fake_status(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
@@ -778,8 +776,4 @@ void grpc_chttp2_fail_pending_writes(grpc_exec_ctx* exec_ctx,
void grpc_chttp2_config_default_keepalive_args(grpc_channel_args* args,
bool is_client);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INTERNAL_H */
diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc
index 6737c26e72..46ec3fbaa6 100644
--- a/src/core/ext/transport/chttp2/transport/parsing.cc
+++ b/src/core/ext/transport/chttp2/transport/parsing.cc
@@ -191,7 +191,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx,
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;
@@ -225,7 +225,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx,
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);
@@ -238,7 +238,7 @@ 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 =
@@ -252,10 +252,10 @@ grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx,
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,
@@ -312,7 +312,7 @@ static grpc_error* init_frame_parser(grpc_exec_ctx* exec_ctx,
case GRPC_CHTTP2_FRAME_GOAWAY:
return init_goaway_parser(exec_ctx, 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);
@@ -337,7 +337,7 @@ static grpc_error* init_skip_frame_parser(grpc_exec_ctx* exec_ctx,
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 {
@@ -369,7 +369,7 @@ static grpc_error* init_data_frame_parser(grpc_exec_ctx* exec_ctx,
if (err != GRPC_ERROR_NONE) {
goto error_handler;
}
- if (s == NULL) {
+ if (s == nullptr) {
return init_skip_frame_parser(exec_ctx, t, 0);
}
s->received_bytes += t->incoming_frame_size;
@@ -391,9 +391,9 @@ error_handler:
t->ping_policy.max_pings_without_data;
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) {
+ if (s != nullptr) {
grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, false, err);
}
grpc_slice_buffer_add(
@@ -415,9 +415,9 @@ static void on_initial_header(grpc_exec_ctx* exec_ctx, void* tp,
GPR_TIMER_BEGIN("on_initial_header", 0);
- GPR_ASSERT(s != NULL);
+ GPR_ASSERT(s != nullptr);
- if (GRPC_TRACER_ON(grpc_http_trace)) {
+ 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);
@@ -437,7 +437,7 @@ static void on_initial_header(grpc_exec_ctx* exec_ctx, void* tp,
grpc_millis* cached_timeout =
static_cast<grpc_millis*>(grpc_mdelem_get_user_data(md, free_timeout));
grpc_millis timeout;
- if (cached_timeout != NULL) {
+ if (cached_timeout != nullptr) {
timeout = *cached_timeout;
} else {
if (!grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout)) {
@@ -499,9 +499,9 @@ static void on_trailing_header(grpc_exec_ctx* exec_ctx, void* tp,
GPR_TIMER_BEGIN("on_trailing_header", 0);
- GPR_ASSERT(s != NULL);
+ GPR_ASSERT(s != nullptr);
- if (GRPC_TRACER_ON(grpc_http_trace)) {
+ 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);
@@ -575,7 +575,7 @@ static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx,
/* 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,
@@ -617,7 +617,7 @@ 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) {
+ 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);
@@ -625,12 +625,12 @@ static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx,
} 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;
+ t->incoming_stream = nullptr;
return init_skip_frame_parser(exec_ctx, t, 1);
}
t->parser = grpc_chttp2_header_parser_parse;
@@ -639,7 +639,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;
@@ -677,7 +677,7 @@ static grpc_error* init_window_update_frame_parser(grpc_exec_ctx* exec_ctx,
if (t->incoming_stream_id != 0) {
grpc_chttp2_stream* s = t->incoming_stream =
grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id);
- if (s == NULL) {
+ if (s == nullptr) {
return init_skip_frame_parser(exec_ctx, t, 0);
}
s->stats.incoming.framing_bytes += 9;
@@ -757,8 +757,8 @@ static grpc_error* parse_frame_slice(grpc_exec_ctx* exec_ctx,
grpc_error* err = t->parser(exec_ctx, 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)) {
+ } 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);
}
diff --git a/src/core/ext/transport/chttp2/transport/stream_lists.cc b/src/core/ext/transport/chttp2/transport/stream_lists.cc
index 8d25ab277d..c95d02541a 100644
--- a/src/core/ext/transport/chttp2/transport/stream_lists.cc
+++ b/src/core/ext/transport/chttp2/transport/stream_lists.cc
@@ -39,14 +39,13 @@ static const 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,
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,
@@ -58,19 +57,19 @@ static bool stream_list_pop(grpc_chttp2_transport* t,
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,
@@ -88,7 +87,7 @@ 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));
}
@@ -111,7 +110,7 @@ static void stream_list_add_tail(grpc_chttp2_transport* t,
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;
@@ -120,7 +119,7 @@ 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));
}
diff --git a/src/core/ext/transport/chttp2/transport/stream_map.cc b/src/core/ext/transport/chttp2/transport/stream_map.cc
index c863191795..e4f08f5a6c 100644
--- a/src/core/ext/transport/chttp2/transport/stream_map.cc
+++ b/src/core/ext/transport/chttp2/transport/stream_map.cc
@@ -62,7 +62,7 @@ void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map* map, uint32_t key,
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) {
@@ -92,7 +92,7 @@ static void** find(grpc_chttp2_stream_map* map, uint32_t key) {
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,29 +109,29 @@ 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* 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;
+ return pvalue != nullptr ? *pvalue : nullptr;
}
size_t grpc_chttp2_stream_map_size(grpc_chttp2_stream_map* map) {
@@ -140,11 +140,12 @@ size_t grpc_chttp2_stream_map_size(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];
}
diff --git a/src/core/ext/transport/chttp2/transport/stream_map.h b/src/core/ext/transport/chttp2/transport/stream_map.h
index c89d20047c..9fb8826e8e 100644
--- a/src/core/ext/transport/chttp2/transport/stream_map.h
+++ b/src/core/ext/transport/chttp2/transport/stream_map.h
@@ -23,10 +23,6 @@
#include <stddef.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Data structure to map a uint32_t to a data object (represented by a void*)
Represented as a sorted array of keys, and a corresponding array of values.
@@ -69,8 +65,4 @@ void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map* map,
void* value),
void* user_data);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_MAP_H */
diff --git a/src/core/ext/transport/chttp2/transport/varint.h b/src/core/ext/transport/chttp2/transport/varint.h
index d3a9d902c4..5a2b670f06 100644
--- a/src/core/ext/transport/chttp2/transport/varint.h
+++ b/src/core/ext/transport/chttp2/transport/varint.h
@@ -21,10 +21,6 @@
#include <grpc/support/port_platform.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Helpers for hpack varint encoding */
/* length of a value that needs varint tail encoding (it's bigger than can be
@@ -61,8 +57,4 @@ void grpc_chttp2_hpack_write_varint_tail(uint32_t tail_value, uint8_t* target,
} \
} while (0)
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_VARINT_H */
diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc
index 6154bdb682..cfaa0d0f70 100644
--- a/src/core/ext/transport/chttp2/transport/writing.cc
+++ b/src/core/ext/transport/chttp2/transport/writing.cc
@@ -51,8 +51,7 @@ static void maybe_initiate_ping(grpc_exec_ctx* exec_ctx,
}
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)) {
+ 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);
}
@@ -61,8 +60,7 @@ static void maybe_initiate_ping(grpc_exec_ctx* exec_ctx,
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)) {
+ 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,
@@ -71,21 +69,24 @@ static void maybe_initiate_ping(grpc_exec_ctx* exec_ctx,
return;
}
grpc_millis now = grpc_exec_ctx_now(exec_ctx);
+
+ 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 +
- 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 =
- t->ping_recv_state.last_ping_recv_time + 7200 * GPR_MS_PER_SEC;
- }
+ 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_TRACER_ON(grpc_http_trace) ||
- GRPC_TRACER_ON(grpc_bdp_estimator_trace)) {
+ 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",
- t->is_client ? "CLIENT" : "SERVER", t->peer_string);
+ "%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;
@@ -94,6 +95,7 @@ static void maybe_initiate_ping(grpc_exec_ctx* exec_ctx,
}
return;
}
+
pq->inflight_id = t->ping_ctr;
t->ping_ctr++;
GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pq->lists[GRPC_CHTTP2_PCL_INITIATE]);
@@ -103,8 +105,7 @@ static void maybe_initiate_ping(grpc_exec_ctx* exec_ctx,
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)) {
+ 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,
@@ -120,7 +121,7 @@ static bool update_list(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
grpc_error* error) {
bool sched_any = false;
grpc_chttp2_write_cb* cb = *list;
- *list = NULL;
+ *list = nullptr;
*ctr += send_bytes;
while (cb) {
grpc_chttp2_write_cb* next = cb->next;
@@ -322,7 +323,7 @@ class DataSendContext {
GPR_MIN(stream_remote_window(), t_->flow_control->remote_window()));
}
- bool AnyOutgoing() const { return max_outgoing() != 0; }
+ bool AnyOutgoing() const { return max_outgoing() > 0; }
void FlushCompressedBytes() {
uint32_t send_bytes =
@@ -330,24 +331,25 @@ class DataSendContext {
bool is_last_data_frame =
(send_bytes == s_->compressed_data_buffer.length &&
s_->flow_controlled_buffer.length == 0 &&
- s_->fetching_send_message == NULL);
- if (is_last_data_frame && s_->send_trailing_metadata != NULL &&
- s_->stream_compression_ctx != NULL) {
- if (!grpc_stream_compress(s_->stream_compression_ctx,
- &s_->flow_controlled_buffer,
- &s_->compressed_data_buffer, NULL, MAX_SIZE_T,
- GRPC_STREAM_COMPRESSION_FLUSH_FINISH)) {
+ 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 = NULL;
+ 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 != NULL &&
+ 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);
@@ -358,14 +360,14 @@ class DataSendContext {
}
void CompressMoreBytes() {
- if (s_->stream_compression_ctx == NULL) {
+ 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, NULL, MAX_SIZE_T,
+ &s_->compressed_data_buffer, nullptr, MAX_SIZE_T,
GRPC_STREAM_COMPRESSION_FLUSH_SYNC)) {
gpr_log(GPR_ERROR, "Stream compression failed.");
}
@@ -397,7 +399,7 @@ class StreamWriteContext {
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 != NULL,
+ s->sent_initial_metadata, s->send_initial_metadata != nullptr,
(int)(s->flow_control->local_window_delta() -
s->flow_control->announced_window_delta())));
}
@@ -429,13 +431,13 @@ class StreamWriteContext {
[GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], // max_frame_size
&s_->stats.outgoing // stats
};
- grpc_chttp2_encode_header(exec_ctx, &t_->hpack_compressor, NULL, 0,
+ grpc_chttp2_encode_header(exec_ctx, &t_->hpack_compressor, nullptr, 0,
s_->send_initial_metadata, &hopt, &t_->outbuf);
write_context_->ResetPingRecvClock();
write_context_->IncInitialMetadataWrites();
}
- s_->send_initial_metadata = NULL;
+ s_->send_initial_metadata = nullptr;
s_->sent_initial_metadata = true;
write_context_->NoteScheduledResults();
grpc_chttp2_complete_closure_step(
@@ -502,8 +504,8 @@ class StreamWriteContext {
void FlushTrailingMetadata(grpc_exec_ctx* exec_ctx) {
if (!s_->sent_initial_metadata) return;
- if (s_->send_trailing_metadata == NULL) return;
- if (s_->fetching_send_message != NULL) 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;
@@ -543,12 +545,12 @@ class StreamWriteContext {
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) {
+ 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 != NULL) {
+ 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;
@@ -556,7 +558,7 @@ class StreamWriteContext {
}
void SentLastFrame(grpc_exec_ctx* exec_ctx) {
- s_->send_trailing_metadata = NULL;
+ s_->send_trailing_metadata = nullptr;
s_->sent_trailing_metadata = true;
if (!t_->is_client && !s_->read_closed) {
diff --git a/src/core/ext/transport/cronet/transport/cronet_api_dummy.cc 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.cc
+++ 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.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc
index 0b1ddf8839..8836a3253c 100644
--- a/src/core/ext/transport/cronet/transport/cronet_transport.cc
+++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc
@@ -273,7 +273,7 @@ static void null_and_maybe_free_read_buffer(stream_obj* s) {
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) {
@@ -342,7 +342,7 @@ static void add_to_storage(struct stream_obj* s,
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) {
+ if (s->storage.head == nullptr || oas == nullptr) {
return;
}
if (s->storage.head == oas) {
@@ -352,7 +352,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--;
@@ -360,7 +360,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");
}
}
@@ -375,7 +375,7 @@ static void remove_from_storage(struct stream_obj* s,
*/
static void execute_from_storage(grpc_exec_ctx* exec_ctx, 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);
@@ -401,21 +401,21 @@ 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);
+ gpr_log(GPR_ERROR, "on_failed(%p, %d)", stream, net_error);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
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);
@@ -435,14 +435,14 @@ static void on_canceled(bidirectional_stream* stream) {
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);
@@ -462,7 +462,7 @@ static void on_succeeded(bidirectional_stream* stream) {
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);
@@ -484,7 +484,7 @@ static void on_stream_ready(bidirectional_stream* stream) {
/* 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 */
@@ -566,7 +566,7 @@ static void on_write_completed(bidirectional_stream* stream, const char* 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);
@@ -713,7 +713,7 @@ static void convert_metadata_to_cronet_headers(
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++;
}
@@ -765,7 +765,7 @@ 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;
}
}
@@ -785,7 +785,7 @@ static void parse_grpc_header(const uint8_t* data, int* length,
}
static bool header_has_authority(grpc_linked_mdelem* head) {
- while (head != NULL) {
+ while (head != nullptr) {
if (grpc_slice_eq(GRPC_MDKEY(head->md), GRPC_MDSTR_AUTHORITY)) {
return true;
}
@@ -993,7 +993,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx* exec_ctx,
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);
@@ -1002,9 +1002,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;
+ char* url = nullptr;
const char* method = "POST";
- s->header_array.headers = NULL;
+ 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,
@@ -1042,7 +1042,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx* exec_ctx,
if (1 != grpc_byte_stream_next(
exec_ctx, stream_op->payload->send_message.send_message,
stream_op->payload->send_message.send_message->length,
- NULL)) {
+ nullptr)) {
/* Should never reach here */
GPR_ASSERT(false);
}
@@ -1358,10 +1358,10 @@ static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
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));
@@ -1369,7 +1369,7 @@ 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;
@@ -1432,7 +1432,7 @@ static void destroy_transport(grpc_exec_ctx* exec_ctx, grpc_transport* gt) {}
static grpc_endpoint* get_endpoint(grpc_exec_ctx* exec_ctx,
grpc_transport* gt) {
- return NULL;
+ return nullptr;
}
static void perform_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
@@ -1491,5 +1491,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 7643fdb585..d9ff913326 100644
--- a/src/core/ext/transport/cronet/transport/cronet_transport.h
+++ b/src/core/ext/transport/cronet/transport/cronet_transport.h
@@ -21,16 +21,8 @@
#include "src/core/lib/transport/transport.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
grpc_transport* grpc_create_cronet_transport(void* engine, const char* target,
const grpc_channel_args* args,
void* reserved);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_EXT_TRANSPORT_CRONET_TRANSPORT_CRONET_TRANSPORT_H */
diff --git a/src/core/ext/transport/inproc/inproc_plugin.cc b/src/core/ext/transport/inproc/inproc_plugin.cc
index 5d8a1c74ab..83a7d8d52f 100644
--- a/src/core/ext/transport/inproc/inproc_plugin.cc
+++ b/src/core/ext/transport/inproc/inproc_plugin.cc
@@ -19,13 +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");
-extern "C" 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(); }
-extern "C" void grpc_inproc_plugin_shutdown(void) {
- grpc_inproc_transport_shutdown();
-}
+void grpc_inproc_plugin_shutdown(void) { grpc_inproc_transport_shutdown(); }
diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc
index a7a6db8bc2..d8d753e459 100644
--- a/src/core/ext/transport/inproc/inproc_transport.cc
+++ b/src/core/ext/transport/inproc/inproc_transport.cc
@@ -32,9 +32,9 @@
#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__); \
+#define INPROC_LOG(...) \
+ do { \
+ if (grpc_inproc_trace.enabled()) gpr_log(__VA_ARGS__); \
} while (0)
static grpc_slice g_empty_slice;
@@ -184,7 +184,7 @@ static void really_destroy_stream(grpc_exec_ctx* exec_ctx, inproc_stream* s) {
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;
+ 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));
@@ -199,19 +199,19 @@ 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 (grpc_inproc_trace.enabled()) {
+ log_metadata(metadata, s->t->is_client, outflags != nullptr);
}
- if (outflags != NULL) {
+ if (outflags != nullptr) {
*outflags = flags;
}
- if (markfilled != NULL) {
+ if (markfilled != nullptr) {
*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) {
+ (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(
@@ -250,7 +250,7 @@ static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
GRPC_CLOSURE_INIT(&s->op_closure, op_state_machine, s,
grpc_schedule_on_exec_ctx);
s->t = t;
- s->closure_at_destroy = NULL;
+ s->closure_at_destroy = nullptr;
s->other_side_closed = false;
s->initial_md_sent = s->trailing_md_sent = s->initial_md_recvd =
@@ -264,7 +264,7 @@ static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
s->deadline = GRPC_MILLIS_INF_FUTURE;
s->write_buffer_deadline = GRPC_MILLIS_INF_FUTURE;
- s->stream_list_prev = NULL;
+ s->stream_list_prev = nullptr;
gpr_mu_lock(&t->mu->mu);
s->listed = true;
ref_stream(s, "inproc_init_stream:list");
@@ -279,7 +279,7 @@ static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
ref_transport(t);
inproc_transport* st = t->other_side;
ref_transport(st);
- s->other_side = NULL; // will get filled in soon
+ 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
@@ -311,7 +311,7 @@ static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
}
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, nullptr,
&s->to_read_trailing_md_filled);
grpc_metadata_batch_clear(exec_ctx, &cs->write_buffer_trailing_md);
cs->write_buffer_trailing_md_filled = false;
@@ -335,12 +335,12 @@ static void close_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s) {
if (s->listed) {
inproc_stream* p = s->stream_list_prev;
inproc_stream* n = s->stream_list_next;
- if (p != NULL) {
+ if (p != nullptr) {
p->stream_list_next = n;
} else {
s->t->stream_list = n;
}
- if (n != NULL) {
+ if (n != nullptr) {
n->stream_list_prev = p;
}
s->listed = false;
@@ -354,14 +354,14 @@ static void close_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s) {
// 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) {
+ if (s->other_side != nullptr) {
// 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;
+ s->other_side = nullptr;
} else if (!s->other_side_closed) {
s->write_buffer_other_side_closed = true;
}
@@ -410,14 +410,15 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
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* 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(exec_ctx, s, &fake_md, 0, dest, nullptr, destfilled);
grpc_metadata_batch_destroy(exec_ctx, &fake_md);
- if (other != NULL) {
+ if (other != nullptr) {
if (other->cancel_other_error == GRPC_ERROR_NONE) {
other->cancel_other_error = GRPC_ERROR_REF(error);
}
@@ -451,12 +452,20 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
s->recv_initial_md_op->payload->recv_initial_metadata
.recv_initial_metadata,
s->recv_initial_md_op->payload->recv_initial_metadata.recv_flags,
- NULL);
+ nullptr);
grpc_metadata_batch_destroy(exec_ctx, &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);
@@ -469,7 +478,7 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
complete_if_batch_end_locked(
exec_ctx, s, error, s->recv_initial_md_op,
"fail_helper scheduling recv-initial-metadata-on-complete");
- s->recv_initial_md_op = NULL;
+ s->recv_initial_md_op = nullptr;
}
if (s->recv_message_op) {
INPROC_LOG(GPR_DEBUG, "fail_helper %p scheduling message-ready %p", s,
@@ -480,19 +489,19 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
complete_if_batch_end_locked(
exec_ctx, s, error, s->recv_message_op,
"fail_helper scheduling recv-message-on-complete");
- s->recv_message_op = NULL;
+ s->recv_message_op = nullptr;
}
if (s->send_message_op) {
complete_if_batch_end_locked(
exec_ctx, s, error, s->send_message_op,
"fail_helper scheduling send-message-on-complete");
- s->send_message_op = NULL;
+ s->send_message_op = nullptr;
}
if (s->send_trailing_md_op) {
complete_if_batch_end_locked(
exec_ctx, s, error, s->send_trailing_md_op,
"fail_helper scheduling send-trailng-md-on-complete");
- s->send_trailing_md_op = NULL;
+ s->send_trailing_md_op = nullptr;
}
if (s->recv_trailing_md_op) {
INPROC_LOG(GPR_DEBUG,
@@ -501,7 +510,7 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
complete_if_batch_end_locked(
exec_ctx, s, error, s->recv_trailing_md_op,
"fail_helper scheduling recv-trailing-metadata-on-complete");
- s->recv_trailing_md_op = NULL;
+ s->recv_trailing_md_op = nullptr;
}
close_other_side_locked(exec_ctx, s, "fail_helper:other_side");
close_stream_locked(exec_ctx, s);
@@ -554,8 +563,8 @@ static void message_transfer_locked(grpc_exec_ctx* exec_ctx,
exec_ctx, receiver, GRPC_ERROR_NONE, receiver->recv_message_op,
"message_transfer scheduling receiver on_complete");
- receiver->recv_message_op = NULL;
- sender->send_message_op = NULL;
+ receiver->recv_message_op = nullptr;
+ sender->send_message_op = nullptr;
}
static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
@@ -601,7 +610,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
complete_if_batch_end_locked(
exec_ctx, s, GRPC_ERROR_NONE, s->send_message_op,
"op_state_machine scheduling send-message-on-complete");
- s->send_message_op = NULL;
+ s->send_message_op = nullptr;
}
}
// Pause a send trailing metadata if there is still an outstanding
@@ -612,10 +621,11 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
(!s->send_message_op ||
(s->t->is_client &&
(s->trailing_md_recvd || s->to_read_trailing_md_filled)))) {
- 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;
+ 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);
@@ -627,7 +637,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
fill_in_metadata(exec_ctx, s,
s->send_trailing_md_op->payload->send_trailing_metadata
.send_trailing_metadata,
- 0, dest, NULL, destfilled);
+ 0, dest, nullptr, destfilled);
}
s->trailing_md_sent = true;
if (!s->t->is_client && s->trailing_md_recvd && s->recv_trailing_md_op) {
@@ -635,7 +645,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
"op_state_machine %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;
+ s->recv_trailing_md_op = nullptr;
needs_close = true;
}
}
@@ -643,7 +653,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
complete_if_batch_end_locked(
exec_ctx, s, GRPC_ERROR_NONE, s->send_trailing_md_op,
"op_state_machine scheduling send-trailing-metadata-on-complete");
- s->send_trailing_md_op = NULL;
+ s->send_trailing_md_op = nullptr;
}
if (s->recv_initial_md_op) {
if (s->initial_md_recvd) {
@@ -665,9 +675,15 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
s->recv_initial_md_op->payload->recv_initial_metadata
.recv_initial_metadata,
s->recv_initial_md_op->payload->recv_initial_metadata.recv_flags,
- NULL);
+ 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(exec_ctx, &s->to_read_initial_md);
s->to_read_initial_md_filled = false;
INPROC_LOG(GPR_DEBUG,
@@ -680,7 +696,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
complete_if_batch_end_locked(
exec_ctx, s, new_err, s->recv_initial_md_op,
"op_state_machine scheduling recv-initial-metadata-on-complete");
- s->recv_initial_md_op = NULL;
+ s->recv_initial_md_op = nullptr;
if (new_err != GRPC_ERROR_NONE) {
INPROC_LOG(GPR_DEBUG,
@@ -713,7 +729,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err));
goto done;
}
- if (s->recv_message_op != NULL) {
+ 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);
@@ -724,7 +740,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
complete_if_batch_end_locked(
exec_ctx, s, new_err, s->recv_message_op,
"op_state_machine scheduling recv-message-on-complete");
- s->recv_message_op = NULL;
+ 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
@@ -732,16 +748,16 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
complete_if_batch_end_locked(
exec_ctx, s, new_err, s->send_message_op,
"op_state_machine scheduling send-message-on-complete");
- s->send_message_op = NULL;
+ s->send_message_op = nullptr;
}
- if (s->recv_trailing_md_op != NULL) {
+ 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(exec_ctx, s, &s->to_read_trailing_md, 0,
s->recv_trailing_md_op->payload
->recv_trailing_metadata.recv_trailing_metadata,
- NULL, NULL);
+ nullptr, nullptr);
grpc_metadata_batch_clear(exec_ctx, &s->to_read_trailing_md);
s->to_read_trailing_md_filled = false;
@@ -756,7 +772,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
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;
+ s->recv_trailing_md_op = nullptr;
needs_close = true;
} else {
INPROC_LOG(GPR_DEBUG,
@@ -780,7 +796,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
complete_if_batch_end_locked(
exec_ctx, s, new_err, s->recv_message_op,
"op_state_machine scheduling recv-message-on-complete");
- s->recv_message_op = NULL;
+ s->recv_message_op = nullptr;
}
if (s->trailing_md_recvd && (s->trailing_md_sent || s->t->is_client) &&
s->send_message_op) {
@@ -789,7 +805,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
complete_if_batch_end_locked(
exec_ctx, s, new_err, s->send_message_op,
"op_state_machine scheduling send-message-on-complete");
- s->send_message_op = NULL;
+ 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) {
@@ -827,14 +843,15 @@ static bool cancel_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
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* 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(exec_ctx, s, &cancel_md, 0, dest, nullptr, destfilled);
grpc_metadata_batch_destroy(exec_ctx, &cancel_md);
- if (other != NULL) {
+ if (other != nullptr) {
if (other->cancel_other_error == GRPC_ERROR_NONE) {
other->cancel_other_error = GRPC_ERROR_REF(s->cancel_self_error);
}
@@ -851,7 +868,7 @@ static bool cancel_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
complete_if_batch_end_locked(
exec_ctx, s, s->cancel_self_error, s->recv_trailing_md_op,
"cancel_stream scheduling trailing-md-on-complete");
- s->recv_trailing_md_op = NULL;
+ s->recv_trailing_md_op = nullptr;
}
}
@@ -870,7 +887,7 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
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 (grpc_inproc_trace.enabled()) {
if (op->send_initial_metadata) {
log_metadata(op->payload->send_initial_metadata.send_initial_metadata,
s->t->is_client, true);
@@ -882,7 +899,7 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
}
grpc_error* error = GRPC_ERROR_NONE;
grpc_closure* on_complete = op->on_complete;
- if (on_complete == NULL) {
+ if (on_complete == nullptr) {
on_complete = &do_nothing_closure;
}
@@ -914,12 +931,14 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
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;
+ 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);
@@ -934,7 +953,7 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
}
if (s->t->is_client) {
grpc_millis* dl =
- (other == NULL) ? &s->write_buffer_deadline : &other->deadline;
+ (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;
@@ -973,11 +992,11 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
// 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 != NULL) ||
- (other->recv_trailing_md_op != NULL))) ||
+ ((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 != NULL)) ||
+ (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(exec_ctx, &s->op_closure, GRPC_ERROR_NONE);
@@ -990,6 +1009,15 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
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",
@@ -1031,7 +1059,7 @@ static void close_transport_locked(grpc_exec_ctx* exec_ctx,
if (!t->is_closed) {
t->is_closed = true;
/* Also end all streams on this transport */
- while (t->stream_list != NULL) {
+ while (t->stream_list != nullptr) {
// cancel_stream_locked also adjusts stream list
cancel_stream_locked(
exec_ctx, t->stream_list,
@@ -1110,7 +1138,7 @@ static void set_pollset_set(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
}
static grpc_endpoint* get_endpoint(grpc_exec_ctx* exec_ctx, grpc_transport* t) {
- return NULL;
+ return nullptr;
}
/*******************************************************************************
@@ -1120,9 +1148,9 @@ 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_CLOSURE_INIT(&do_nothing_closure, do_nothing, nullptr,
grpc_schedule_on_exec_ctx);
- g_empty_slice = grpc_slice_from_static_buffer(NULL, 0);
+ 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);
@@ -1173,8 +1201,8 @@ static void inproc_transports_create(grpc_exec_ctx* exec_ctx,
"inproc_client");
st->other_side = ct;
ct->other_side = st;
- st->stream_list = NULL;
- ct->stream_list = NULL;
+ st->stream_list = nullptr;
+ ct->stream_list = nullptr;
*server_transport = (grpc_transport*)st;
*client_transport = (grpc_transport*)ct;
}
@@ -1203,7 +1231,7 @@ grpc_channel* grpc_inproc_channel_create(grpc_server* server,
inproc_transports_create(&exec_ctx, &server_transport, server_args,
&client_transport, client_args);
- grpc_server_setup_transport(&exec_ctx, server, server_transport, NULL,
+ grpc_server_setup_transport(&exec_ctx, server, server_transport, nullptr,
server_args);
grpc_channel* channel =
grpc_channel_create(&exec_ctx, "inproc", client_args,
diff --git a/src/core/ext/transport/inproc/inproc_transport.h b/src/core/ext/transport/inproc/inproc_transport.h
index 6e83af3b4c..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);
-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.h b/src/core/lib/backoff/backoff.h
index 1067281403..0da9082e70 100644
--- a/src/core/lib/backoff/backoff.h
+++ b/src/core/lib/backoff/backoff.h
@@ -21,10 +21,6 @@
#include "src/core/lib/iomgr/exec_ctx.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct {
/// const: how long to wait after the first failure before retrying
grpc_millis initial_backoff;
@@ -76,8 +72,4 @@ grpc_backoff_result grpc_backoff_step(grpc_exec_ctx* exec_ctx,
/// grpc_backoff_begin.
void grpc_backoff_reset(grpc_backoff* backoff);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_BACKOFF_BACKOFF_H */
diff --git a/src/core/lib/channel/channel_args.cc b/src/core/lib/channel/channel_args.cc
index 23a604301e..735fcbe405 100644
--- a/src/core/lib/channel/channel_args.cc
+++ b/src/core/lib/channel/channel_args.cc
@@ -54,7 +54,7 @@ static grpc_arg copy_arg(const grpc_arg* src) {
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);
}
@@ -62,7 +62,7 @@ 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,
@@ -78,7 +78,7 @@ grpc_channel_args* grpc_channel_args_copy_and_add_and_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;
@@ -90,13 +90,13 @@ grpc_channel_args* grpc_channel_args_copy_and_add_and_remove(
(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);
// 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]);
@@ -112,7 +112,7 @@ grpc_channel_args* grpc_channel_args_copy_and_add_and_remove(
}
grpc_channel_args* grpc_channel_args_copy(const grpc_channel_args* src) {
- return grpc_channel_args_copy_and_add(src, NULL, 0);
+ return grpc_channel_args_copy_and_add(src, nullptr, 0);
}
grpc_channel_args* grpc_channel_args_union(const grpc_channel_args* a,
@@ -124,12 +124,12 @@ grpc_channel_args* grpc_channel_args_union(const grpc_channel_args* a,
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
+ 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_copy_and_add(nullptr, uniques, uniques_idx);
gpr_free(uniques);
return result;
}
@@ -212,7 +212,7 @@ 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) {
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)) {
@@ -226,7 +226,7 @@ grpc_compression_algorithm grpc_channel_args_get_compression_algorithm(
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;
+ if (a == nullptr) 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,
@@ -263,7 +263,7 @@ grpc_channel_args* grpc_channel_args_set_stream_compression_algorithm(
* 0. */
static int find_compression_algorithm_states_bitset(const grpc_channel_args* a,
int** states_arg) {
- if (a != NULL) {
+ if (a != nullptr) {
size_t i;
for (i = 0; i < a->num_args; ++i) {
if (a->args[i].type == GRPC_ARG_INTEGER &&
@@ -283,7 +283,7 @@ static int find_compression_algorithm_states_bitset(const grpc_channel_args* a,
* 0. */
static int find_stream_compression_algorithm_states_bitset(
const grpc_channel_args* a, int** states_arg) {
- if (a != NULL) {
+ if (a != nullptr) {
size_t i;
for (i = 0; i < a->num_args; ++i) {
if (a->args[i].type == GRPC_ARG_INTEGER &&
@@ -301,14 +301,14 @@ static int find_stream_compression_algorithm_states_bitset(
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;
+ 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 "
@@ -342,14 +342,14 @@ grpc_channel_args* grpc_channel_args_compression_algorithm_set_state(
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;
+ int* states_arg = nullptr;
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;
+ const char* algo_name = nullptr;
GPR_ASSERT(grpc_stream_compression_algorithm_name(algorithm, &algo_name) !=
0);
gpr_log(GPR_ERROR,
@@ -421,19 +421,19 @@ int grpc_channel_args_compare(const grpc_channel_args* a,
const grpc_arg* grpc_channel_args_find(const grpc_channel_args* args,
const char* name) {
- if (args != NULL) {
+ 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,
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;
@@ -452,7 +452,7 @@ int grpc_channel_arg_get_integer(const grpc_arg* arg,
}
bool grpc_channel_arg_get_bool(const grpc_arg* arg, bool default_value) {
- if (arg == NULL) return 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;
diff --git a/src/core/lib/channel/channel_args.h b/src/core/lib/channel/channel_args.h
index d36761da57..f6cb7fa73d 100644
--- a/src/core/lib/channel/channel_args.h
+++ b/src/core/lib/channel/channel_args.h
@@ -23,10 +23,6 @@
#include <grpc/grpc.h>
#include "src/core/lib/iomgr/socket_mutator.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
// Channel args are intentionally immutable, to avoid the need for locking.
/** Copy the arguments in \a src into a new instance */
@@ -153,8 +149,4 @@ 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);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_ARGS_H */
diff --git a/src/core/lib/channel/channel_stack.cc b/src/core/lib/channel/channel_stack.cc
index 3ab2e33d6d..7629d18789 100644
--- a/src/core/lib/channel/channel_stack.cc
+++ 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.
@@ -225,7 +225,7 @@ void grpc_call_stack_destroy(grpc_exec_ctx* exec_ctx, grpc_call_stack* stack,
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);
+ i == count - 1 ? then_schedule_closure : nullptr);
}
}
diff --git a/src/core/lib/channel/channel_stack.h b/src/core/lib/channel/channel_stack.h
index aa993112a0..1b6e5396a5 100644
--- a/src/core/lib/channel/channel_stack.h
+++ b/src/core/lib/channel/channel_stack.h
@@ -45,10 +45,6 @@
#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;
@@ -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:
@@ -285,13 +282,9 @@ 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.cc b/src/core/lib/channel/channel_stack_builder.cc
index 83748db3c2..77b7854f94 100644
--- a/src/core/lib/channel/channel_stack_builder.cc
+++ b/src/core/lib/channel/channel_stack_builder.cc
@@ -23,8 +23,8 @@
#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;
@@ -54,8 +54,8 @@ 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;
@@ -108,7 +108,7 @@ bool grpc_channel_stack_builder_iterator_is_end(
const char* grpc_channel_stack_builder_iterator_filter_name(
grpc_channel_stack_builder_iterator* iterator) {
- if (iterator->node->filter == NULL) return NULL;
+ if (iterator->node->filter == nullptr) return nullptr;
return iterator->node->filter->name;
}
@@ -128,7 +128,7 @@ bool grpc_channel_stack_builder_move_prev(
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);
+ 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)) {
@@ -145,14 +145,14 @@ bool grpc_channel_stack_builder_move_prev(
void grpc_channel_stack_builder_set_name(grpc_channel_stack_builder* builder,
const char* name) {
- GPR_ASSERT(builder->name == NULL);
+ 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) {
+ if (builder->args != nullptr) {
grpc_channel_args_destroy(exec_ctx, builder->args);
}
builder->args = grpc_channel_args_copy(args);
@@ -160,7 +160,7 @@ void grpc_channel_stack_builder_set_channel_arguments(
void grpc_channel_stack_builder_set_transport(
grpc_channel_stack_builder* builder, grpc_transport* transport) {
- GPR_ASSERT(builder->transport == NULL);
+ GPR_ASSERT(builder->transport == nullptr);
builder->transport = transport;
}
@@ -249,7 +249,7 @@ void grpc_channel_stack_builder_destroy(grpc_exec_ctx* exec_ctx,
gpr_free(p);
p = next;
}
- if (builder->args != NULL) {
+ if (builder->args != nullptr) {
grpc_channel_args_destroy(exec_ctx, builder->args);
}
gpr_free(builder->target);
@@ -285,19 +285,19 @@ grpc_error* grpc_channel_stack_builder_finish(
// and initialize it
grpc_error* error = grpc_channel_stack_init(
exec_ctx, initial_refs, destroy,
- destroy_arg == NULL ? *result : destroy_arg, filters, num_filters,
+ 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);
gpr_free(*result);
- *result = NULL;
+ *result = nullptr;
} else {
// run post-initialization functions
i = 0;
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);
}
diff --git a/src/core/lib/channel/channel_stack_builder.h b/src/core/lib/channel/channel_stack_builder.h
index 23134b7d10..10019542b1 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;
@@ -160,10 +156,6 @@ grpc_error* grpc_channel_stack_builder_finish(
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;
-
-#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.cc b/src/core/lib/channel/connected_channel.cc
index 49b9f140c0..af2f88ab2e 100644
--- a/src/core/lib/channel/connected_channel.cc
+++ b/src/core/lib/channel/connected_channel.cc
@@ -85,7 +85,7 @@ static callback_state* get_state_for_batch(
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
@@ -181,7 +181,7 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
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;
}
@@ -217,7 +217,7 @@ 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);
+ GPR_ASSERT(cd->transport == nullptr);
cd->transport = (grpc_transport*)t;
/* HACK(ctiller): increase call stack size for the channel to make space
@@ -233,9 +233,9 @@ static void bind_transport(grpc_channel_stack* channel_stack,
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);
+ GPR_ASSERT(arg_must_be_null == nullptr);
grpc_transport* t = grpc_channel_stack_builder_get_transport(builder);
- GPR_ASSERT(t != NULL);
+ GPR_ASSERT(t != nullptr);
return grpc_channel_stack_builder_append_filter(
builder, &grpc_connected_filter, bind_transport, t);
}
diff --git a/src/core/lib/channel/connected_channel.h b/src/core/lib/channel/connected_channel.h
index cca19737dc..cab8aad154 100644
--- a/src/core/lib/channel/connected_channel.h
+++ b/src/core/lib/channel/connected_channel.h
@@ -21,10 +21,6 @@
#include "src/core/lib/channel/channel_stack_builder.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
extern const grpc_channel_filter grpc_connected_filter;
bool grpc_add_connected_filter(grpc_exec_ctx* exec_ctx,
@@ -34,8 +30,4 @@ bool grpc_add_connected_filter(grpc_exec_ctx* exec_ctx,
/* Debug helper to dig the transport stream out of a call element */
grpc_stream* grpc_connected_channel_get_stream(grpc_call_element* elem);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_CHANNEL_CONNECTED_CHANNEL_H */
diff --git a/src/core/lib/channel/handshaker.cc b/src/core/lib/channel/handshaker.cc
index b27ee37e5b..58c30b165b 100644
--- a/src/core/lib/channel/handshaker.cc
+++ b/src/core/lib/channel/handshaker.cc
@@ -93,8 +93,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 +104,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);
@@ -117,7 +117,7 @@ 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) {
+ while (head != nullptr) {
grpc_handshake_manager_shutdown(exec_ctx, head, GRPC_ERROR_REF(why));
head = head->next;
}
@@ -231,14 +231,16 @@ static void on_timeout(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
void grpc_handshake_manager_do_handshake(
grpc_exec_ctx* exec_ctx, grpc_handshake_manager* mgr,
- grpc_endpoint* endpoint, const grpc_channel_args* channel_args,
- grpc_millis deadline, grpc_tcp_server_acceptor* acceptor,
- grpc_iomgr_cb_func on_handshake_done, void* user_data) {
+ grpc_pollset_set* interested_parties, grpc_endpoint* endpoint,
+ const grpc_channel_args* channel_args, 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;
diff --git a/src/core/lib/channel/handshaker.h b/src/core/lib/channel/handshaker.h
index 8ed38c15ba..8e4114dc64 100644
--- a/src/core/lib/channel/handshaker.h
+++ b/src/core/lib/channel/handshaker.h
@@ -26,10 +26,6 @@
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/tcp_server.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/// Handshakers are used to perform initial handshakes on a connection
/// before the client sends the initial request. Some examples of what
/// a handshaker can be used for includes support for HTTP CONNECT on
@@ -58,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;
@@ -135,11 +132,13 @@ void grpc_handshake_manager_shutdown(grpc_exec_ctx* exec_ctx,
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 !=
@@ -148,9 +147,10 @@ void grpc_handshake_manager_shutdown(grpc_exec_ctx* exec_ctx,
/// the arguments.
void grpc_handshake_manager_do_handshake(
grpc_exec_ctx* exec_ctx, grpc_handshake_manager* mgr,
- grpc_endpoint* endpoint, const grpc_channel_args* channel_args,
- grpc_millis deadline, grpc_tcp_server_acceptor* acceptor,
- grpc_iomgr_cb_func on_handshake_done, void* user_data);
+ grpc_pollset_set* interested_parties, grpc_endpoint* endpoint,
+ const grpc_channel_args* channel_args, 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
/// list starts with \a *head.
@@ -168,8 +168,4 @@ 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);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_H */
diff --git a/src/core/lib/channel/handshaker_factory.cc b/src/core/lib/channel/handshaker_factory.cc
index bf1188dbb9..015006ade0 100644
--- a/src/core/lib/channel/handshaker_factory.cc
+++ b/src/core/lib/channel/handshaker_factory.cc
@@ -23,8 +23,8 @@
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);
+ if (handshaker_factory != nullptr) {
+ GPR_ASSERT(handshaker_factory->vtable != nullptr);
handshaker_factory->vtable->add_handshakers(exec_ctx, handshaker_factory,
args, handshake_mgr);
}
@@ -32,8 +32,8 @@ void grpc_handshaker_factory_add_handshakers(
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);
+ if (handshaker_factory != nullptr) {
+ GPR_ASSERT(handshaker_factory->vtable != nullptr);
handshaker_factory->vtable->destroy(exec_ctx, handshaker_factory);
}
}
diff --git a/src/core/lib/channel/handshaker_factory.h b/src/core/lib/channel/handshaker_factory.h
index 63d9b5af72..ca7c26b50a 100644
--- a/src/core/lib/channel/handshaker_factory.h
+++ b/src/core/lib/channel/handshaker_factory.h
@@ -24,10 +24,6 @@
#include "src/core/lib/channel/handshaker.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
// A handshaker factory is used to create handshakers.
typedef struct grpc_handshaker_factory grpc_handshaker_factory;
@@ -52,8 +48,4 @@ void grpc_handshaker_factory_add_handshakers(
void grpc_handshaker_factory_destroy(
grpc_exec_ctx* exec_ctx, grpc_handshaker_factory* handshaker_factory);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_FACTORY_H */
diff --git a/src/core/lib/channel/handshaker_registry.h b/src/core/lib/channel/handshaker_registry.h
index ddd280bea8..a3b2ac1dc7 100644
--- a/src/core/lib/channel/handshaker_registry.h
+++ b/src/core/lib/channel/handshaker_registry.h
@@ -24,10 +24,6 @@
#include "src/core/lib/channel/handshaker_factory.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef enum {
HANDSHAKER_CLIENT = 0,
HANDSHAKER_SERVER,
@@ -49,8 +45,4 @@ void grpc_handshakers_add(grpc_exec_ctx* exec_ctx,
const grpc_channel_args* args,
grpc_handshake_manager* handshake_mgr);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_REGISTRY_H */
diff --git a/src/core/lib/compression/algorithm_metadata.h b/src/core/lib/compression/algorithm_metadata.h
index 17caf58f69..08feafc1bb 100644
--- a/src/core/lib/compression/algorithm_metadata.h
+++ b/src/core/lib/compression/algorithm_metadata.h
@@ -22,10 +22,6 @@
#include <grpc/compression.h>
#include "src/core/lib/transport/metadata.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/** Return compression algorithm based metadata value */
grpc_slice grpc_compression_algorithm_slice(
grpc_compression_algorithm algorithm);
@@ -53,8 +49,4 @@ grpc_compression_algorithm grpc_compression_algorithm_from_slice(
grpc_stream_compression_algorithm grpc_stream_compression_algorithm_from_slice(
grpc_slice str);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_COMPRESSION_ALGORITHM_METADATA_H */
diff --git a/src/core/lib/compression/message_compress.h b/src/core/lib/compression/message_compress.h
index fffe175fd2..ca8ca37f8e 100644
--- a/src/core/lib/compression/message_compress.h
+++ b/src/core/lib/compression/message_compress.h
@@ -22,10 +22,6 @@
#include <grpc/compression.h>
#include <grpc/slice_buffer.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* 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. */
@@ -40,8 +36,4 @@ int grpc_msg_decompress(grpc_exec_ctx* exec_ctx,
grpc_compression_algorithm algorithm,
grpc_slice_buffer* input, grpc_slice_buffer* output);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_COMPRESSION_MESSAGE_COMPRESS_H */
diff --git a/src/core/lib/compression/stream_compression.cc b/src/core/lib/compression/stream_compression.cc
index 8a57b33230..b4b3e524d0 100644
--- a/src/core/lib/compression/stream_compression.cc
+++ b/src/core/lib/compression/stream_compression.cc
@@ -21,7 +21,7 @@
#include "src/core/lib/compression/stream_compression.h"
#include "src/core/lib/compression/stream_compression_gzip.h"
-extern "C" const grpc_stream_compression_vtable
+extern const grpc_stream_compression_vtable
grpc_stream_compression_identity_vtable;
bool grpc_stream_compress(grpc_stream_compression_context* ctx,
@@ -51,7 +51,7 @@ 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;
}
}
diff --git a/src/core/lib/compression/stream_compression.h b/src/core/lib/compression/stream_compression.h
index b56c142543..8322835c4f 100644
--- a/src/core/lib/compression/stream_compression.h
+++ b/src/core/lib/compression/stream_compression.h
@@ -26,10 +26,6 @@
#include "src/core/lib/transport/static_metadata.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_stream_compression_vtable grpc_stream_compression_vtable;
/* Stream compression/decompression context */
@@ -115,8 +111,4 @@ void grpc_stream_compression_context_destroy(
int grpc_stream_compression_method_parse(
grpc_slice value, bool is_compress, grpc_stream_compression_method* method);
-#ifdef __cplusplus
-}
-#endif
-
#endif
diff --git a/src/core/lib/compression/stream_compression_gzip.cc b/src/core/lib/compression/stream_compression_gzip.cc
index 53ec7ca223..0c3fdd1269 100644
--- a/src/core/lib/compression/stream_compression_gzip.cc
+++ b/src/core/lib/compression/stream_compression_gzip.cc
@@ -137,7 +137,7 @@ static bool grpc_stream_compress_gzip(grpc_stream_compression_context* ctx,
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 =
@@ -158,7 +158,7 @@ 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,
@@ -167,7 +167,7 @@ static bool grpc_stream_decompress_gzip(grpc_stream_compression_context* ctx,
size_t* output_size,
size_t max_output_size,
bool* end_of_context) {
- if (ctx == NULL) {
+ if (ctx == nullptr) {
return false;
}
grpc_stream_compression_context_gzip* gzip_ctx =
@@ -186,8 +186,8 @@ grpc_stream_compression_context_create_gzip(
(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,7 +199,7 @@ 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;
@@ -208,7 +208,7 @@ grpc_stream_compression_context_create_gzip(
static void grpc_stream_compression_context_destroy_gzip(
grpc_stream_compression_context* ctx) {
- if (ctx == NULL) {
+ if (ctx == nullptr) {
return;
}
grpc_stream_compression_context_gzip* gzip_ctx =
diff --git a/src/core/lib/compression/stream_compression_gzip.h b/src/core/lib/compression/stream_compression_gzip.h
index a3f1b0406f..7cf49a0de9 100644
--- a/src/core/lib/compression/stream_compression_gzip.h
+++ b/src/core/lib/compression/stream_compression_gzip.h
@@ -21,14 +21,6 @@
#include "src/core/lib/compression/stream_compression.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
extern const grpc_stream_compression_vtable grpc_stream_compression_gzip_vtable;
-#ifdef __cplusplus
-}
-#endif
-
#endif
diff --git a/src/core/lib/compression/stream_compression_identity.cc b/src/core/lib/compression/stream_compression_identity.cc
index 5e8bfc09a6..af4051144c 100644
--- a/src/core/lib/compression/stream_compression_identity.cc
+++ b/src/core/lib/compression/stream_compression_identity.cc
@@ -52,7 +52,7 @@ static bool grpc_stream_compress_identity(grpc_stream_compression_context* ctx,
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);
@@ -63,7 +63,7 @@ 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) {
+ if (ctx == nullptr) {
return false;
}
grpc_stream_compression_pass_through(in, out, output_size, max_output_size);
diff --git a/src/core/lib/compression/stream_compression_identity.h b/src/core/lib/compression/stream_compression_identity.h
index 3a729fafad..41926e949e 100644
--- a/src/core/lib/compression/stream_compression_identity.h
+++ b/src/core/lib/compression/stream_compression_identity.h
@@ -21,15 +21,7 @@
#include "src/core/lib/compression/stream_compression.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
extern const grpc_stream_compression_vtable
grpc_stream_compression_identity_vtable;
-#ifdef __cplusplus
-}
-#endif
-
#endif
diff --git a/src/core/lib/debug/stats.cc b/src/core/lib/debug/stats.cc
index b32cf19028..7d2af71c47 100644
--- a/src/core/lib/debug/stats.cc
+++ b/src/core/lib/debug/stats.cc
@@ -27,7 +27,7 @@
#include "src/core/lib/support/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) {
@@ -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 1c19e72345..55db44e0c2 100644
--- a/src/core/lib/debug/stats.h
+++ b/src/core/lib/debug/stats.h
@@ -23,10 +23,6 @@
#include "src/core/lib/debug/stats_data.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_stats_data {
gpr_atm counters[GRPC_STATS_COUNTER_COUNT];
gpr_atm histograms[GRPC_STATS_HISTOGRAM_BUCKETS];
@@ -62,8 +58,4 @@ double grpc_stats_histo_percentile(const grpc_stats_data* data,
size_t grpc_stats_histo_count(const grpc_stats_data* data,
grpc_stats_histograms histogram);
-#ifdef __cplusplus
-}
-#endif
-
#endif
diff --git a/src/core/lib/debug/stats_data.h b/src/core/lib/debug/stats_data.h
index fbfcce83ba..8a5bc97389 100644
--- a/src/core/lib/debug/stats_data.h
+++ b/src/core/lib/debug/stats_data.h
@@ -24,10 +24,6 @@
#include <inttypes.h>
#include "src/core/lib/iomgr/exec_ctx.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef enum {
GRPC_STATS_COUNTER_CLIENT_CALLS_CREATED,
GRPC_STATS_COUNTER_SERVER_CALLS_CREATED,
@@ -502,8 +498,4 @@ extern const int* const grpc_stats_histo_bucket_boundaries[13];
extern void (*const grpc_stats_inc_histogram[13])(grpc_exec_ctx* exec_ctx,
int x);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_DEBUG_STATS_DATA_H */
diff --git a/src/core/lib/debug/trace.cc b/src/core/lib/debug/trace.cc
index b1ae1fa185..a76c1afb4c 100644
--- a/src/core/lib/debug/trace.cc
+++ b/src/core/lib/debug/trace.cc
@@ -27,26 +27,61 @@
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;
+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;
@@ -64,7 +99,7 @@ static void add(const char* beg, const char* end, char*** ss, size_t* ns) {
static void split(const char* s, char*** ss, size_t* ns) {
const char* c = strchr(s, ',');
- if (c == NULL) {
+ if (c == nullptr) {
add(s, s + strlen(s), ss, ns);
} else {
add(s, c, ss, ns);
@@ -73,16 +108,16 @@ static void split(const char* s, char*** ss, size_t* ns) {
}
static void parse(const char* s) {
- char** strings = NULL;
+ 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_tracer_set_enabled(strings[i] + 1, 0);
+ grpc_core::TraceFlagList::Set(strings[i] + 1, false);
} else {
- grpc_tracer_set_enabled(strings[i], 1);
+ grpc_core::TraceFlagList::Set(strings[i], true);
}
}
@@ -92,56 +127,16 @@ static void parse(const char* s) {
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) {
+ if (e != nullptr) {
parse(e);
gpr_free(e);
}
}
-void grpc_tracer_shutdown(void) {
- while (tracers) {
- tracer* t = tracers;
- tracers = t->next;
- gpr_free(t);
- }
-}
+void grpc_tracer_shutdown(void) {}
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;
+ 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 7447d5d94a..69ddd80222 100644
--- a/src/core/lib/debug/trace.h
+++ b/src/core/lib/debug/trace.h
@@ -23,9 +23,8 @@
#include <grpc/support/port_platform.h>
#include <stdbool.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+void grpc_tracer_init(const char* env_var_name);
+void grpc_tracer_shutdown(void);
#if defined(__has_feature)
#if __has_feature(thread_sanitizer)
@@ -33,31 +32,72 @@ extern "C" {
#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; }
-#ifdef __cplusplus
-}
+ private:
+ void set_enabled(bool enabled) {}
+};
#endif
+} // namespace grpc_core
+
#endif /* GRPC_CORE_LIB_DEBUG_TRACE_H */
diff --git a/src/core/lib/http/format_request.h b/src/core/lib/http/format_request.h
index 32054805b4..c1919651f9 100644
--- a/src/core/lib/http/format_request.h
+++ b/src/core/lib/http/format_request.h
@@ -22,10 +22,6 @@
#include <grpc/slice.h>
#include "src/core/lib/http/httpcli.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
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,
@@ -33,8 +29,4 @@ grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request* request,
grpc_slice grpc_httpcli_format_connect_request(
const grpc_httpcli_request* request);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_HTTP_FORMAT_REQUEST_H */
diff --git a/src/core/lib/http/httpcli.cc b/src/core/lib/http/httpcli.cc
index 493e6af95c..73b484b06d 100644
--- a/src/core/lib/http/httpcli.cc
+++ b/src/core/lib/http/httpcli.cc
@@ -60,8 +60,8 @@ typedef struct {
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 grpc_httpcli_get_override g_get_override = nullptr;
+static grpc_httpcli_post_override g_post_override = nullptr;
static void plaintext_handshake(grpc_exec_ctx* exec_ctx, void* arg,
grpc_endpoint* endpoint, const char* host,
@@ -93,10 +93,10 @@ static void finish(grpc_exec_ctx* exec_ctx, internal_request* req,
req->context->pollset_set);
GRPC_CLOSURE_SCHED(exec_ctx, req->on_done, error);
grpc_http_parser_destroy(&req->parser);
- if (req->addresses != NULL) {
+ if (req->addresses != nullptr) {
grpc_resolved_addresses_destroy(req->addresses);
}
- if (req->ep != NULL) {
+ if (req->ep != nullptr) {
grpc_endpoint_destroy(exec_ctx, req->ep);
}
grpc_slice_unref_internal(exec_ctx, req->request_text);
@@ -136,8 +136,8 @@ static void on_read(grpc_exec_ctx* exec_ctx, void* user_data,
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);
+ grpc_error* err = grpc_http_parser_parse(
+ &req->parser, req->incoming.slices[i], nullptr);
if (err != GRPC_ERROR_NONE) {
finish(exec_ctx, req, err);
return;
diff --git a/src/core/lib/http/httpcli.h b/src/core/lib/http/httpcli.h
index a3411341ad..6f675568bd 100644
--- a/src/core/lib/http/httpcli.h
+++ b/src/core/lib/http/httpcli.h
@@ -32,10 +32,6 @@
/* User agent this library reports */
#define GRPC_HTTPCLI_USER_AGENT "grpc-httpcli/0.0"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Tracks in-progress http requests
TODO(ctiller): allow caching and capturing multiple requests for the
same content and combining them */
@@ -127,8 +123,4 @@ typedef int (*grpc_httpcli_post_override)(
void grpc_httpcli_set_override(grpc_httpcli_get_override get,
grpc_httpcli_post_override post);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_HTTP_HTTPCLI_H */
diff --git a/src/core/lib/http/httpcli_security_connector.cc b/src/core/lib/http/httpcli_security_connector.cc
index d029323eac..dfcaee702b 100644
--- a/src/core/lib/http/httpcli_security_connector.cc
+++ b/src/core/lib/http/httpcli_security_connector.cc
@@ -42,11 +42,11 @@ 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) {
+ if (c->handshaker_factory != nullptr) {
tsi_ssl_client_handshaker_factory_unref(c->handshaker_factory);
- c->handshaker_factory = NULL;
+ c->handshaker_factory = nullptr;
}
- if (c->secure_peer_name != NULL) gpr_free(c->secure_peer_name);
+ if (c->secure_peer_name != nullptr) gpr_free(c->secure_peer_name);
gpr_free(sc);
}
@@ -55,8 +55,8 @@ static void httpcli_ssl_add_handshakers(grpc_exec_ctx* exec_ctx,
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_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) {
@@ -79,7 +79,7 @@ static void httpcli_ssl_check_peer(grpc_exec_ctx* exec_ctx,
grpc_error* error = GRPC_ERROR_NONE;
/* Check the peer name. */
- if (c->secure_peer_name != NULL &&
+ 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",
@@ -109,7 +109,7 @@ static grpc_security_status httpcli_ssl_channel_security_connector_create(
tsi_result result = TSI_OK;
grpc_httpcli_ssl_channel_security_connector* c;
- if (secure_peer_name != NULL && pem_root_certs == NULL) {
+ 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;
@@ -120,16 +120,16 @@ static grpc_security_status httpcli_ssl_channel_security_connector_create(
gpr_ref_init(&c->base.base.refcount, 1);
c->base.base.vtable = &httpcli_ssl_vtable;
- if (secure_peer_name != NULL) {
+ if (secure_peer_name != nullptr) {
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);
+ 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(exec_ctx, &c->base.base);
- *sc = NULL;
+ *sc = nullptr;
return GRPC_SECURITY_ERROR;
}
// We don't actually need a channel credentials object in this case,
@@ -157,7 +157,7 @@ static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
const char* msg = grpc_error_string(error);
gpr_log(GPR_ERROR, "Secure transport setup failed: %s", msg);
- c->func(exec_ctx, c->arg, NULL);
+ c->func(exec_ctx, c->arg, nullptr);
} else {
grpc_channel_args_destroy(exec_ctx, args->args);
grpc_slice_buffer_destroy_internal(exec_ctx, args->read_buffer);
@@ -175,15 +175,15 @@ static void ssl_handshake(grpc_exec_ctx* exec_ctx, 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 == NULL) {
+ if (pem_root_certs == nullptr) {
gpr_log(GPR_ERROR, "Could not get default pem root certs.");
- on_done(exec_ctx, arg, NULL);
+ on_done(exec_ctx, arg, nullptr);
gpr_free(c);
return;
}
c->func = on_done;
c->arg = arg;
- grpc_channel_security_connector* sc = NULL;
+ grpc_channel_security_connector* sc = nullptr;
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);
@@ -191,8 +191,9 @@ static void ssl_handshake(grpc_exec_ctx* exec_ctx, void* 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 */);
+ exec_ctx, c->handshake_mgr, nullptr /* interested_parties */, tcp,
+ nullptr /* channel_args */, deadline, nullptr /* acceptor */,
+ on_handshake_done, c /* user_data */);
GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, &sc->base, "httpcli");
}
diff --git a/src/core/lib/http/parser.cc b/src/core/lib/http/parser.cc
index 99a4919401..fb4eb234a7 100644
--- a/src/core/lib/http/parser.cc
+++ b/src/core/lib/http/parser.cc
@@ -25,7 +25,7 @@
#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);
@@ -152,9 +152,9 @@ 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};
+ 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);
@@ -240,8 +240,8 @@ static grpc_error* finish_line(grpc_http_parser* parser,
}
static grpc_error* addbyte_body(grpc_http_parser* parser, uint8_t byte) {
- size_t* body_length = NULL;
- char** body = NULL;
+ size_t* body_length = nullptr;
+ char** body = nullptr;
if (parser->type == GRPC_HTTP_RESPONSE) {
body_length = &parser->http.response->body_length;
@@ -294,7 +294,7 @@ static grpc_error* addbyte(grpc_http_parser* parser, uint8_t byte,
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(
@@ -352,7 +352,7 @@ grpc_error* grpc_http_parser_parse(grpc_http_parser* parser, grpc_slice slice,
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;
}
diff --git a/src/core/lib/http/parser.h b/src/core/lib/http/parser.h
index 3d28481c4c..5fef448019 100644
--- a/src/core/lib/http/parser.h
+++ b/src/core/lib/http/parser.h
@@ -27,10 +27,6 @@
/* Maximum length of a header string of the form 'Key: Value\r\n' */
#define GRPC_HTTP_PARSER_MAX_HEADER_LENGTH 4096
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* A single header to be passed in a request */
typedef struct grpc_http_header {
char* key;
@@ -111,10 +107,6 @@ 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);
-extern grpc_tracer_flag grpc_http1_trace;
-
-#ifdef __cplusplus
-}
-#endif
+extern grpc_core::TraceFlag grpc_http1_trace;
#endif /* GRPC_CORE_LIB_HTTP_PARSER_H */
diff --git a/src/core/lib/iomgr/block_annotate.h b/src/core/lib/iomgr/block_annotate.h
index fcbfe9eb1a..340ebcb1af 100644
--- a/src/core/lib/iomgr/block_annotate.h
+++ b/src/core/lib/iomgr/block_annotate.h
@@ -19,17 +19,9 @@
#ifndef GRPC_CORE_LIB_IOMGR_BLOCK_ANNOTATE_H
#define GRPC_CORE_LIB_IOMGR_BLOCK_ANNOTATE_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
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. */
diff --git a/src/core/lib/iomgr/call_combiner.cc b/src/core/lib/iomgr/call_combiner.cc
index d45719608b..b5910b42e4 100644
--- a/src/core/lib/iomgr/call_combiner.cc
+++ b/src/core/lib/iomgr/call_combiner.cc
@@ -24,8 +24,7 @@
#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) {
@@ -63,7 +62,7 @@ void grpc_call_combiner_start(grpc_exec_ctx* exec_ctx,
grpc_error* error DEBUG_ARGS,
const char* reason) {
GPR_TIMER_BEGIN("call_combiner_start", 0);
- if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
+ if (grpc_call_combiner_trace.enabled()) {
gpr_log(GPR_DEBUG,
"==> grpc_call_combiner_start() [%p] closure=%p [" DEBUG_FMT_STR
"%s] error=%s",
@@ -72,7 +71,7 @@ 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);
}
@@ -80,13 +79,13 @@ void grpc_call_combiner_start(grpc_exec_ctx* exec_ctx,
if (prev_size == 0) {
GRPC_STATS_INC_CALL_COMBINER_LOCKS_INITIATED(exec_ctx);
GPR_TIMER_MARK("call_combiner_initiate", 0);
- if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
+ 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);
} 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.
@@ -100,42 +99,42 @@ void grpc_call_combiner_stop(grpc_exec_ctx* exec_ctx,
grpc_call_combiner* call_combiner DEBUG_ARGS,
const char* reason) {
GPR_TIMER_BEGIN("call_combiner_stop", 0);
- if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
+ 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);
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);
@@ -152,7 +151,7 @@ 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",
@@ -163,7 +162,7 @@ void grpc_call_combiner_set_notify_on_cancel(grpc_exec_ctx* exec_ctx,
} 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);
}
@@ -172,7 +171,7 @@ 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);
@@ -201,7 +200,7 @@ 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);
diff --git a/src/core/lib/iomgr/call_combiner.h b/src/core/lib/iomgr/call_combiner.h
index 527f84fce0..c07af51c91 100644
--- a/src/core/lib/iomgr/call_combiner.h
+++ b/src/core/lib/iomgr/call_combiner.h
@@ -27,10 +27,6 @@
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/support/mpscq.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
// A simple, lock-free mechanism for serializing activity related to a
// single call. This is similar to a combiner but is more lightweight.
//
@@ -40,7 +36,7 @@ extern "C" {
// 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
@@ -122,8 +118,4 @@ void grpc_call_combiner_cancel(grpc_exec_ctx* exec_ctx,
grpc_call_combiner* call_combiner,
grpc_error* error);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_CALL_COMBINER_H */
diff --git a/src/core/lib/iomgr/closure.cc b/src/core/lib/iomgr/closure.cc
deleted file mode 100644
index 60e99d0e4e..0000000000
--- a/src/core/lib/iomgr/closure.cc
+++ /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 8b1188e2db..46793dd2c5 100644
--- a/src/core/lib/iomgr/closure.h
+++ b/src/core/lib/iomgr/closure.h
@@ -21,21 +21,19 @@
#include <grpc/support/port_platform.h>
+#include <assert.h>
#include <grpc/impl/codegen/exec_ctx_fwd.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
#include <stdbool.h>
#include "src/core/lib/iomgr/error.h"
+#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/support/mpscq.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
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;
@@ -85,8 +83,8 @@ struct grpc_closure {
/** Arguments to be passed to "cb". */
void* cb_arg;
- /** Scheduler to schedule against: NULL to schedule against current execution
- context */
+ /** 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 */
@@ -107,102 +105,262 @@ struct grpc_closure {
#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(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);
+}
+
+} // 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_exec_ctx* exec_ctx, grpc_closure* c,
+ grpc_error* error) {
+#else
+inline 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 != nullptr) {
+#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);
+}
/** 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)
#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)
#endif
+#ifndef NDEBUG
+inline void grpc_closure_sched(const char* file, int line,
+ grpc_exec_ctx* exec_ctx, grpc_closure* c,
+ grpc_error* error) {
+#else
+inline 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 != 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(exec_ctx, c, error);
+ } else {
+ GRPC_ERROR_UNREF(error);
+ }
+ GPR_TIMER_END("grpc_closure_sched", 0);
+}
+
/** 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)
#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)
#endif
+#ifndef NDEBUG
+inline void grpc_closure_list_sched(const char* file, int line,
+ grpc_exec_ctx* exec_ctx,
+ grpc_closure_list* list) {
+#else
+inline void grpc_closure_list_sched(grpc_exec_ctx* exec_ctx,
+ 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(exec_ctx, 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
-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)
#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)
#endif
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_CLOSURE_H */
diff --git a/src/core/lib/iomgr/combiner.cc b/src/core/lib/iomgr/combiner.cc
index ca9c00b935..15c009dd77 100644
--- a/src/core/lib/iomgr/combiner.cc
+++ b/src/core/lib/iomgr/combiner.cc
@@ -29,14 +29,13 @@
#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");
-
-#define GRPC_COMBINER_TRACE(fn) \
- do { \
- if (GRPC_TRACER_ON(grpc_combiner_trace)) { \
- fn; \
- } \
+grpc_core::TraceFlag grpc_combiner_trace(false, "combiner");
+
+#define GRPC_COMBINER_TRACE(fn) \
+ do { \
+ if (grpc_combiner_trace.enabled()) { \
+ fn; \
+ } \
} while (0)
#define STATE_UNORPHANED 1
@@ -106,7 +105,7 @@ static void start_destroy(grpc_exec_ctx* exec_ctx, grpc_combiner* 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), \
@@ -132,8 +131,8 @@ grpc_combiner* grpc_combiner_ref(grpc_combiner* lock GRPC_COMBINER_DEBUG_ARGS) {
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) {
+ lock->next_combiner_on_this_exec_ctx = nullptr;
+ if (exec_ctx->active_combiner == nullptr) {
exec_ctx->active_combiner = exec_ctx->last_combiner = lock;
} else {
exec_ctx->last_combiner->next_combiner_on_this_exec_ctx = lock;
@@ -145,7 +144,7 @@ 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) {
+ if (lock->next_combiner_on_this_exec_ctx == nullptr) {
exec_ctx->last_combiner = lock;
}
}
@@ -190,8 +189,8 @@ static void combiner_exec(grpc_exec_ctx* exec_ctx, grpc_closure* cl,
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;
+ if (exec_ctx->active_combiner == nullptr) {
+ exec_ctx->last_combiner = nullptr;
}
}
@@ -210,7 +209,7 @@ static void queue_offload(grpc_exec_ctx* exec_ctx, grpc_combiner* lock) {
bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx* exec_ctx) {
GPR_TIMER_BEGIN("combiner.continue_exec_ctx", 0);
grpc_combiner* lock = exec_ctx->active_combiner;
- if (lock == NULL) {
+ if (lock == nullptr) {
GPR_TIMER_END("combiner.continue_exec_ctx", 0);
return false;
}
@@ -244,7 +243,7 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx* exec_ctx) {
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);
@@ -263,10 +262,10 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx* exec_ctx) {
GPR_TIMER_END("combiner.exec1", 0);
} else {
grpc_closure* c = lock->final_list.head;
- GPR_ASSERT(c != NULL);
+ 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));
diff --git a/src/core/lib/iomgr/combiner.h b/src/core/lib/iomgr/combiner.h
index f8a8b9df62..0c05511331 100644
--- a/src/core/lib/iomgr/combiner.h
+++ b/src/core/lib/iomgr/combiner.h
@@ -26,10 +26,6 @@
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/support/mpscq.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
// Provides serialized access to some resource.
// Each action queued on a combiner is executed serially in a borrowed thread.
// The actual thread executing actions may change over time (but there will only
@@ -65,10 +61,6 @@ grpc_closure_scheduler* grpc_combiner_finally_scheduler(grpc_combiner* lock);
bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx* exec_ctx);
-extern grpc_tracer_flag grpc_combiner_trace;
-
-#ifdef __cplusplus
-}
-#endif
+extern grpc_core::TraceFlag grpc_combiner_trace;
#endif /* GRPC_CORE_LIB_IOMGR_COMBINER_H */
diff --git a/src/core/lib/iomgr/endpoint.h b/src/core/lib/iomgr/endpoint.h
index 1b0a9e725e..6ab0a6591c 100644
--- a/src/core/lib/iomgr/endpoint.h
+++ b/src/core/lib/iomgr/endpoint.h
@@ -26,10 +26,6 @@
#include "src/core/lib/iomgr/pollset_set.h"
#include "src/core/lib/iomgr/resource_quota.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* An endpoint caps a streaming channel between two communicating processes.
Examples may be: a tcp socket, <stdin+stdout>, or some shared memory. */
@@ -106,8 +102,4 @@ struct grpc_endpoint {
const grpc_endpoint_vtable* vtable;
};
-#ifdef __cplusplus
-}
-#endif
-
#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 219eea8550..506ffc88b4 100644
--- a/src/core/lib/iomgr/endpoint_pair.h
+++ b/src/core/lib/iomgr/endpoint_pair.h
@@ -21,10 +21,6 @@
#include "src/core/lib/iomgr/endpoint.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct {
grpc_endpoint* client;
grpc_endpoint* server;
@@ -33,8 +29,4 @@ typedef struct {
grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char* name,
grpc_channel_args* args);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_ENDPOINT_PAIR_H */
diff --git a/src/core/lib/iomgr/error.cc b/src/core/lib/iomgr/error.cc
index 123ff72851..e6d640c106 100644
--- a/src/core/lib/iomgr/error.cc
+++ b/src/core/lib/iomgr/error.cc
@@ -37,10 +37,9 @@
#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) {
switch (key) {
@@ -130,7 +129,7 @@ bool grpc_error_is_special(grpc_error* err) {
#ifndef NDEBUG
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);
@@ -183,7 +182,7 @@ static void error_destroy(grpc_error* err) {
#ifndef NDEBUG
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);
@@ -216,7 +215,7 @@ static uint8_t get_placement(grpc_error** err, size_t size) {
*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);
}
@@ -325,11 +324,11 @@ grpc_error* grpc_error_create(const char* file, int line, grpc_slice desc,
(uint8_t)(num_referencing * SLOTS_PER_LINKED_ERROR) + SURPLUS_CAPACITY);
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
@@ -411,7 +410,7 @@ static grpc_error* copy_error_and_unref(grpc_error* in) {
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
@@ -457,7 +456,7 @@ bool grpc_error_get_int(grpc_error* err, grpc_error_ints which, intptr_t* p) {
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;
}
@@ -468,7 +467,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;
}
@@ -618,7 +617,7 @@ static char* key_str(grpc_error_strs which) {
}
static char* fmt_str(grpc_slice slice) {
- char* s = NULL;
+ char* s = nullptr;
size_t sz = 0;
size_t cap = 0;
append_esc_str((const uint8_t*)GRPC_SLICE_START_PTR(slice),
@@ -688,7 +687,7 @@ 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;
+ char* s = nullptr;
size_t sz = 0;
size_t cap = 0;
append_chr('[', &s, &sz, &cap);
@@ -705,7 +704,7 @@ static int cmp_kvs(const void* a, const void* b) {
}
static char* finish_kvs(kv_pairs* kvs) {
- char* s = NULL;
+ char* s = nullptr;
size_t sz = 0;
size_t cap = 0;
@@ -733,7 +732,7 @@ const char* grpc_error_string(grpc_error* err) {
if (err == GRPC_ERROR_CANCELLED) return cancelled_error_string;
void* p = (void*)gpr_atm_acq_load(&err->atomics.error_string);
- if (p != NULL) {
+ if (p != nullptr) {
GPR_TIMER_END("grpc_error_string", 0);
return (const char*)p;
}
@@ -767,8 +766,8 @@ grpc_error* grpc_os_error(const char* file, int line, int err,
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))),
diff --git a/src/core/lib/iomgr/error.h b/src/core/lib/iomgr/error.h
index 36ba440c8a..4759ee0791 100644
--- a/src/core/lib/iomgr/error.h
+++ b/src/core/lib/iomgr/error.h
@@ -24,23 +24,18 @@
#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
@@ -184,9 +179,15 @@ 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_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
@@ -198,8 +199,4 @@ bool grpc_log_if_error(const char* what, grpc_error* error, const char* file,
#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 acf6e04e9c..6cb09c2cdb 100644
--- a/src/core/lib/iomgr/error_internal.h
+++ b/src/core/lib/iomgr/error_internal.h
@@ -23,10 +23,7 @@
#include <stdbool.h> // TODO, do we need this?
#include <grpc/support/sync.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "src/core/lib/iomgr/error.h"
typedef struct grpc_linked_error grpc_linked_error;
@@ -59,10 +56,6 @@ struct grpc_error {
intptr_t arena[0];
};
-bool grpc_error_is_special(grpc_error* err);
-
-#ifdef __cplusplus
-}
-#endif
+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.cc b/src/core/lib/iomgr/ev_epoll1_linux.cc
index 61da996781..0dda1d924c 100644
--- a/src/core/lib/iomgr/ev_epoll1_linux.cc
+++ b/src/core/lib/iomgr/ev_epoll1_linux.cc
@@ -235,7 +235,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); }
@@ -243,7 +243,7 @@ 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) {
+ while (fd_freelist != nullptr) {
grpc_fd* fd = fd_freelist;
fd_freelist = fd_freelist->freelist_next;
gpr_free(fd);
@@ -252,31 +252,33 @@ static void fd_global_shutdown(void) {
}
static grpc_fd* fd_create(int fd, const char* name) {
- grpc_fd* new_fd = NULL;
+ 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) {
+ 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;
- new_fd->read_closure.Init();
- new_fd->write_closure.Init();
+ 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;
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
@@ -317,7 +319,7 @@ 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);
+ bool is_release_fd = (release_fd != nullptr);
if (!fd->read_closure->IsShutdown()) {
fd_shutdown_internal(exec_ctx, fd,
@@ -336,8 +338,8 @@ static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_REF(error));
grpc_iomgr_unregister_object(&fd->iomgr_object);
- fd->read_closure.Destroy();
- fd->write_closure.Destroy();
+ fd->read_closure->DestroyEvent();
+ fd->write_closure->DestroyEvent();
gpr_mu_lock(&fd_freelist_mu);
fd->freelist_next = fd_freelist;
@@ -391,7 +393,7 @@ 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) {
+ if (pollset->root_worker == nullptr) {
pollset->root_worker = worker;
worker->next = worker->prev = worker;
return true;
@@ -411,7 +413,7 @@ 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;
@@ -468,13 +470,13 @@ static void pollset_init(grpc_pollset* pollset, gpr_mu** 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) {
@@ -496,7 +498,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);
@@ -509,7 +511,7 @@ static grpc_error* pollset_kick_all(grpc_exec_ctx* exec_ctx,
grpc_pollset* pollset) {
GPR_TIMER_BEGIN("pollset_kick_all", 0);
grpc_error* error = GRPC_ERROR_NONE;
- if (pollset->root_worker != NULL) {
+ if (pollset->root_worker != nullptr) {
grpc_pollset_worker* worker = pollset->root_worker;
do {
GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
@@ -543,18 +545,18 @@ static grpc_error* pollset_kick_all(grpc_exec_ctx* exec_ctx,
static void pollset_maybe_finish_shutdown(grpc_exec_ctx* exec_ctx,
grpc_pollset* pollset) {
- if (pollset->shutdown_closure != NULL && pollset->root_worker == NULL &&
+ 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;
+ pollset->shutdown_closure = nullptr;
}
}
static void pollset_shutdown(grpc_exec_ctx* exec_ctx, 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;
@@ -651,7 +653,7 @@ static grpc_error* do_epoll_wait(grpc_exec_ctx* exec_ctx, grpc_pollset* ps,
GRPC_STATS_INC_POLL_EVENTS_RETURNED(exec_ctx, 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);
}
@@ -667,13 +669,13 @@ static bool begin_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
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)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR, "PS:%p BEGIN_STARTS:%p", pollset, worker);
}
@@ -692,7 +694,7 @@ static bool begin_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
retry_lock_neighborhood:
gpr_mu_lock(&neighborhood->mu);
gpr_mu_lock(&pollset->mu);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR, "PS:%p BEGIN_REORG:%p kick_state=%s is_reassigning=%d",
pollset, worker, kick_state_string(worker->state),
is_reassigning);
@@ -716,7 +718,7 @@ static bool begin_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
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 &&
@@ -744,7 +746,7 @@ static bool begin_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
worker->initialized_cv = true;
gpr_cv_init(&worker->cv);
while (worker->state == UNKICKED && !pollset->shutting_down) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR, "PS:%p BEGIN_WAIT:%p kick_state=%s shutdown=%d",
pollset, worker, kick_state_string(worker->state),
pollset->shutting_down);
@@ -761,7 +763,7 @@ static bool begin_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
grpc_exec_ctx_invalidate_now(exec_ctx);
}
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR,
"PS:%p BEGIN_DONE:%p kick_state=%s shutdown=%d "
"kicked_without_poller: %d",
@@ -794,19 +796,19 @@ static bool check_neighborhood_for_available_poller(
bool found_worker = false;
do {
grpc_pollset* inspect = neighborhood->active_root;
- if (inspect == NULL) {
+ 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) {
+ 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);
}
@@ -817,7 +819,7 @@ static bool check_neighborhood_for_available_poller(
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");
}
}
@@ -835,17 +837,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);
@@ -857,17 +859,17 @@ static void end_worker(grpc_exec_ctx* exec_ctx, 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);
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);
@@ -921,7 +923,7 @@ static void end_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
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)) {
@@ -993,7 +995,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
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)) {
+ if (grpc_polling_trace.enabled()) {
gpr_strvec log;
gpr_strvec_init(&log);
char* tmp;
@@ -1002,31 +1004,31 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* 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_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) {
+ if (root_worker == nullptr) {
GRPC_STATS_INC_POLLSET_KICKED_WITHOUT_POLLER(exec_ctx);
pollset->kicked_without_poller = true;
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR, " .. kicked_without_poller");
}
goto done;
@@ -1034,14 +1036,14 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
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)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR, " .. 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)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR, " .. already kicked %p", next_worker);
}
SET_KICK_STATE(next_worker, KICKED);
@@ -1052,7 +1054,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
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)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR, " .. kicked %p", root_worker);
}
SET_KICK_STATE(root_worker, KICKED);
@@ -1060,7 +1062,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
goto done;
} else if (next_worker->state == UNKICKED) {
GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(exec_ctx);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR, " .. kicked %p", next_worker);
}
GPR_ASSERT(next_worker->initialized_cv);
@@ -1069,7 +1071,7 @@ 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,
" .. kicked root non-poller %p (initialized_cv=%d) (poller=%p)",
@@ -1083,7 +1085,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
goto done;
} else {
GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD(exec_ctx);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR, " .. non-root poller %p (root=%p)", next_worker,
root_worker);
}
@@ -1099,7 +1101,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
}
} else {
GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD(exec_ctx);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR, " .. kicked while waking up");
}
goto done;
@@ -1109,14 +1111,14 @@ 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)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR, " .. 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)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR, " .. mark %p kicked", specific_worker);
}
SET_KICK_STATE(specific_worker, KICKED);
@@ -1124,7 +1126,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
} 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)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR, " .. kick active poller");
}
SET_KICK_STATE(specific_worker, KICKED);
@@ -1132,7 +1134,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
goto done;
} else if (specific_worker->initialized_cv) {
GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(exec_ctx);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR, " .. kick waiting worker");
}
SET_KICK_STATE(specific_worker, KICKED);
@@ -1140,7 +1142,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
goto done;
} else {
GRPC_STATS_INC_POLLSET_KICKED_AGAIN(exec_ctx);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR, " .. kick non-waiting worker");
}
SET_KICK_STATE(specific_worker, KICKED);
@@ -1232,11 +1234,11 @@ static const grpc_event_engine_vtable vtable = {
const grpc_event_engine_vtable* grpc_init_epoll1_linux(bool explicit_request) {
if (!grpc_has_wakeup_fd()) {
gpr_log(GPR_ERROR, "Skipping epoll1 because of no wakeup fd.");
- return NULL;
+ return nullptr;
}
if (!epoll_set_init()) {
- return NULL;
+ return nullptr;
}
fd_global_init();
@@ -1244,7 +1246,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;
diff --git a/src/core/lib/iomgr/ev_epoll1_linux.h b/src/core/lib/iomgr/ev_epoll1_linux.h
index 3e66747f6c..9a1b96bd45 100644
--- a/src/core/lib/iomgr/ev_epoll1_linux.h
+++ b/src/core/lib/iomgr/ev_epoll1_linux.h
@@ -22,16 +22,8 @@
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/port.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
// a polling engine that utilizes a singleton epoll set and turnstile polling
const grpc_event_engine_vtable* grpc_init_epoll1_linux(bool explicit_request);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLL1_LINUX_H */
diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc
index caaee76b8c..62643df697 100644
--- a/src/core/lib/iomgr/ev_epollex_linux.cc
+++ b/src/core/lib/iomgr/ev_epollex_linux.cc
@@ -59,10 +59,8 @@
#define MAX_EPOLL_EVENTS 100
#define MAX_EPOLL_EVENTS_HANDLED_EACH_POLL_CALL 5
-#ifndef NDEBUG
-grpc_tracer_flag grpc_trace_pollable_refcount =
- GRPC_TRACER_INITIALIZER(false, "pollable_refcount");
-#endif
+grpc_core::DebugOnlyTraceFlag grpc_trace_pollable_refcount(false,
+ "pollable_refcount");
/*******************************************************************************
* pollable Declarations
@@ -254,7 +252,7 @@ static bool append_error(grpc_error** composite, grpc_error* error,
* becomes a spurious read notification on a reused fd.
*/
-static grpc_fd* fd_freelist = NULL;
+static grpc_fd* fd_freelist = nullptr;
static gpr_mu fd_freelist_mu;
#ifndef NDEBUG
@@ -263,7 +261,7 @@ static gpr_mu fd_freelist_mu;
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)) {
+ 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),
@@ -288,8 +286,8 @@ static void fd_destroy(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
fd->freelist_next = fd_freelist;
fd_freelist = fd;
- fd->read_closure.Destroy();
- fd->write_closure.Destroy();
+ fd->read_closure->DestroyEvent();
+ fd->write_closure->DestroyEvent();
gpr_mu_unlock(&fd_freelist_mu);
}
@@ -297,7 +295,7 @@ static void fd_destroy(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
#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)) {
+ 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),
@@ -322,7 +320,7 @@ 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) {
+ while (fd_freelist != nullptr) {
grpc_fd* fd = fd_freelist;
fd_freelist = fd_freelist->freelist_next;
gpr_free(fd);
@@ -331,36 +329,38 @@ static void fd_global_shutdown(void) {
}
static grpc_fd* fd_create(int fd, const char* name) {
- grpc_fd* new_fd = NULL;
+ 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) {
+ 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 = NULL;
+ new_fd->pollable_obj = nullptr;
gpr_atm_rel_store(&new_fd->refst, (gpr_atm)1);
new_fd->fd = fd;
- new_fd->read_closure.Init();
- new_fd->write_closure.Init();
+ 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;
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
@@ -384,7 +384,7 @@ static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
/* 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 if (!is_fd_closed) {
close(fd->fd);
@@ -440,7 +440,7 @@ static void fd_notify_on_write(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
*/
static grpc_error* pollable_create(pollable_type type, pollable** p) {
- *p = NULL;
+ *p = nullptr;
int epfd = epoll_create1(EPOLL_CLOEXEC);
if (epfd == -1) {
@@ -451,7 +451,7 @@ static grpc_error* pollable_create(pollable_type type, pollable** p) {
if (err != GRPC_ERROR_NONE) {
close(epfd);
gpr_free(*p);
- *p = NULL;
+ *p = nullptr;
return err;
}
struct epoll_event ev;
@@ -462,7 +462,7 @@ static grpc_error* pollable_create(pollable_type type, pollable** p) {
close(epfd);
grpc_wakeup_fd_destroy(&(*p)->wakeup);
gpr_free(*p);
- *p = NULL;
+ *p = nullptr;
return err;
}
@@ -470,10 +470,10 @@ static grpc_error* pollable_create(pollable_type type, pollable** p) {
gpr_ref_init(&(*p)->refs, 1);
gpr_mu_init(&(*p)->mu);
(*p)->epfd = epfd;
- (*p)->owner_fd = NULL;
- (*p)->pollset_set = NULL;
+ (*p)->owner_fd = nullptr;
+ (*p)->pollset_set = nullptr;
(*p)->next = (*p)->prev = *p;
- (*p)->root_worker = NULL;
+ (*p)->root_worker = nullptr;
(*p)->event_cursor = 0;
(*p)->event_count = 0;
return GRPC_ERROR_NONE;
@@ -483,7 +483,7 @@ static grpc_error* pollable_create(pollable_type type, pollable** p) {
static pollable* pollable_ref(pollable* p) {
#else
static pollable* pollable_ref(pollable* p, int line, const char* reason) {
- if (GRPC_TRACER_ON(grpc_trace_pollable_refcount)) {
+ 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);
@@ -497,14 +497,14 @@ static pollable* pollable_ref(pollable* p, int line, const char* reason) {
static void pollable_unref(pollable* p) {
#else
static void pollable_unref(pollable* p, int line, const char* reason) {
- if (p == NULL) return;
- if (GRPC_TRACER_ON(grpc_trace_pollable_refcount)) {
+ 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 != NULL && gpr_unref(&p->refs)) {
+ if (p != nullptr && gpr_unref(&p->refs)) {
close(p->epfd);
grpc_wakeup_fd_destroy(&p->wakeup);
gpr_free(p);
@@ -516,7 +516,7 @@ static grpc_error* pollable_add_fd(pollable* p, grpc_fd* fd) {
static const char* err_desc = "pollable_add_fd";
const int epfd = p->epfd;
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, "add fd %p (%d) to pollable %p", fd, fd->fd, p);
}
@@ -558,17 +558,17 @@ static void pollset_global_shutdown(void) {
/* pollset->mu must be held while calling this function */
static void pollset_maybe_finish_shutdown(grpc_exec_ctx* exec_ctx,
grpc_pollset* pollset) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ 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 != NULL && pollset->root_worker == NULL &&
+ if (pollset->shutdown_closure != nullptr && pollset->root_worker == nullptr &&
pollset->containing_pollset_set_count == 0) {
GRPC_CLOSURE_SCHED(exec_ctx, pollset->shutdown_closure, GRPC_ERROR_NONE);
- pollset->shutdown_closure = NULL;
+ pollset->shutdown_closure = nullptr;
}
}
@@ -579,16 +579,16 @@ static grpc_error* kick_one_worker(grpc_exec_ctx* exec_ctx,
grpc_pollset_worker* specific_worker) {
pollable* p = specific_worker->pollable_obj;
grpc_core::mu_guard lock(&p->mu);
- GPR_ASSERT(specific_worker != NULL);
+ GPR_ASSERT(specific_worker != nullptr);
if (specific_worker->kicked) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, "PS:%p kicked_specific_but_already_kicked", p);
}
GRPC_STATS_INC_POLLSET_KICKED_AGAIN(exec_ctx);
return GRPC_ERROR_NONE;
}
if (gpr_tls_get(&g_current_thread_worker) == (intptr_t)specific_worker) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, "PS:%p kicked_specific_but_awake", p);
}
GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD(exec_ctx);
@@ -597,7 +597,7 @@ static grpc_error* kick_one_worker(grpc_exec_ctx* exec_ctx,
}
if (specific_worker == p->root_worker) {
GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD(exec_ctx);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, "PS:%p kicked_specific_via_wakeup_fd", p);
}
specific_worker->kicked = true;
@@ -606,7 +606,7 @@ static grpc_error* kick_one_worker(grpc_exec_ctx* exec_ctx,
}
if (specific_worker->initialized_cv) {
GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(exec_ctx);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, "PS:%p kicked_specific_via_cv", p);
}
specific_worker->kicked = true;
@@ -621,17 +621,17 @@ static grpc_error* kick_one_worker(grpc_exec_ctx* exec_ctx,
static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
grpc_pollset_worker* specific_worker) {
GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ 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 == NULL) {
+ if (specific_worker == nullptr) {
if (gpr_tls_get(&g_current_thread_pollset) != (intptr_t)pollset) {
- if (pollset->root_worker == NULL) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ 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(exec_ctx);
@@ -657,7 +657,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
exec_ctx, pollset->root_worker->links[PWLINK_POLLSET].next);
}
} else {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, "PS:%p kicked_any_but_awake", pollset);
}
GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD(exec_ctx);
@@ -673,7 +673,7 @@ static grpc_error* pollset_kick_all(grpc_exec_ctx* exec_ctx,
grpc_error* error = GRPC_ERROR_NONE;
const char* err_desc = "pollset_kick_all";
grpc_pollset_worker* w = pollset->root_worker;
- if (w != NULL) {
+ if (w != nullptr) {
do {
GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
append_error(&error, kick_one_worker(exec_ctx, w), err_desc);
@@ -722,23 +722,23 @@ 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 == NULL) {
+ 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 = NULL;
+ fd->pollable_obj = nullptr;
}
}
}
if (error == GRPC_ERROR_NONE) {
- GPR_ASSERT(fd->pollable_obj != NULL);
+ GPR_ASSERT(fd->pollable_obj != nullptr);
*p = POLLABLE_REF(fd->pollable_obj, "pollset");
} else {
- GPR_ASSERT(fd->pollable_obj == NULL);
- *p = NULL;
+ GPR_ASSERT(fd->pollable_obj == nullptr);
+ *p = nullptr;
}
gpr_mu_unlock(&fd->pollable_mu);
return error;
@@ -747,7 +747,7 @@ static grpc_error* fd_get_or_become_pollable(grpc_fd* fd, pollable** p) {
/* 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);
+ GPR_ASSERT(pollset->shutdown_closure == nullptr);
pollset->shutdown_closure = closure;
GRPC_LOG_IF_ERROR("pollset_shutdown", pollset_kick_all(exec_ctx, pollset));
pollset_maybe_finish_shutdown(exec_ctx, pollset);
@@ -765,7 +765,7 @@ static grpc_error* pollable_process_events(grpc_exec_ctx* exec_ctx,
struct epoll_event* ev = &pollable_obj->events[n];
void* data_ptr = ev->data.ptr;
if (1 & (intptr_t)data_ptr) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, "PS:%p got pollset_wakeup %p", pollset, data_ptr);
}
append_error(&error,
@@ -777,7 +777,7 @@ static grpc_error* pollable_process_events(grpc_exec_ctx* exec_ctx,
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)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG,
"PS:%p got fd %p: cancel=%d read=%d "
"write=%d",
@@ -798,14 +798,14 @@ static grpc_error* pollable_process_events(grpc_exec_ctx* exec_ctx,
/* pollset_shutdown is guaranteed to be called before pollset_destroy. */
static void pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) {
POLLABLE_UNREF(pollset->active_pollable, "pollset");
- pollset->active_pollable = NULL;
+ pollset->active_pollable = nullptr;
}
static grpc_error* pollable_epoll(grpc_exec_ctx* exec_ctx, pollable* p,
grpc_millis deadline) {
int timeout = poll_deadline_to_millis_timeout(exec_ctx, deadline);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ 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);
@@ -825,7 +825,7 @@ static grpc_error* pollable_epoll(grpc_exec_ctx* exec_ctx, pollable* p,
if (r < 0) return GRPC_OS_ERROR(errno, "epoll_wait");
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, "POLLABLE:%p got %d events", p, r);
}
@@ -838,7 +838,7 @@ static grpc_error* pollable_epoll(grpc_exec_ctx* exec_ctx, pollable* p,
/* Return true if first in list */
static bool worker_insert(grpc_pollset_worker** root_worker,
grpc_pollset_worker* worker, pwlinks link) {
- if (*root_worker == NULL) {
+ if (*root_worker == nullptr) {
*root_worker = worker;
worker->links[link].next = worker->links[link].prev = worker;
return true;
@@ -859,7 +859,7 @@ static worker_remove_result worker_remove(grpc_pollset_worker** root_worker,
pwlinks link) {
if (worker == *root_worker) {
if (worker == worker->links[link].next) {
- *root_worker = NULL;
+ *root_worker = nullptr;
return WRR_EMPTIED;
} else {
*root_worker = worker->links[link].next;
@@ -880,7 +880,7 @@ static bool begin_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
grpc_pollset_worker** worker_hdl,
grpc_millis deadline) {
bool do_poll = (pollset->shutdown_closure == nullptr);
- if (worker_hdl != NULL) *worker_hdl = worker;
+ if (worker_hdl != nullptr) *worker_hdl = worker;
worker->initialized_cv = false;
worker->kicked = false;
worker->pollset = pollset;
@@ -893,7 +893,7 @@ static bool begin_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
worker->initialized_cv = true;
gpr_cv_init(&worker->cv);
gpr_mu_unlock(&pollset->mu);
- if (GRPC_TRACER_ON(grpc_polling_trace) &&
+ 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,
@@ -902,18 +902,18 @@ static bool begin_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
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_TRACER_ON(grpc_polling_trace)) {
+ 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_TRACER_ON(grpc_polling_trace)) {
+ 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_TRACER_ON(grpc_polling_trace) &&
+ } 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);
@@ -984,7 +984,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
#ifndef NDEBUG
WORKER_PTR->originator = gettid();
#endif
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG,
"PS:%p work hdl=%p worker=%p now=%" PRIdPTR " deadline=%" PRIdPTR
" kwp=%d pollable=%p",
@@ -1027,7 +1027,7 @@ static grpc_error* pollset_transition_pollable_from_empty_to_fd_locked(
grpc_exec_ctx* exec_ctx, 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_TRACER_ON(grpc_polling_trace)) {
+ 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);
@@ -1043,7 +1043,7 @@ static grpc_error* pollset_transition_pollable_from_fd_to_multi_locked(
grpc_exec_ctx* exec_ctx, 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_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(
GPR_DEBUG,
"PS:%p add fd %p (%d); transition pollable from fd %p to multipoller",
@@ -1053,12 +1053,12 @@ static grpc_error* pollset_transition_pollable_from_fd_to_multi_locked(
append_error(&error, pollset_kick_all(exec_ctx, pollset), err_desc);
grpc_fd* initial_fd = pollset->active_pollable->owner_fd;
POLLABLE_UNREF(pollset->active_pollable, "pollset");
- pollset->active_pollable = NULL;
+ 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 != NULL) {
+ if (and_add_fd != nullptr) {
append_error(&error,
pollable_add_fd(pollset->active_pollable, and_add_fd),
err_desc);
@@ -1124,7 +1124,7 @@ static grpc_error* pollset_as_multipollable_locked(grpc_exec_ctx* exec_ctx,
error = pollable_create(PO_MULTI, &pollset->active_pollable);
} else {
error = pollset_transition_pollable_from_fd_to_multi_locked(
- exec_ctx, pollset, NULL);
+ exec_ctx, pollset, nullptr);
}
gpr_mu_unlock(&po_at_start->owner_fd->orphan_mu);
break;
@@ -1134,7 +1134,7 @@ static grpc_error* pollset_as_multipollable_locked(grpc_exec_ctx* exec_ctx,
if (error != GRPC_ERROR_NONE) {
POLLABLE_UNREF(pollset->active_pollable, "pollset");
pollset->active_pollable = po_at_start;
- *pollable_obj = NULL;
+ *pollable_obj = nullptr;
} else {
*pollable_obj = POLLABLE_REF(pollset->active_pollable, "pollset_set");
POLLABLE_UNREF(po_at_start, "pollset_as_multipollable");
@@ -1156,7 +1156,7 @@ static void pollset_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
static grpc_pollset_set* pss_lock_adam(grpc_pollset_set* pss) {
gpr_mu_lock(&pss->mu);
- while (pss->parent != NULL) {
+ while (pss->parent != nullptr) {
gpr_mu_unlock(&pss->mu);
pss = pss->parent;
gpr_mu_lock(&pss->mu);
@@ -1172,7 +1172,7 @@ static grpc_pollset_set* pollset_set_create(void) {
}
static void pollset_set_unref(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss) {
- if (pss == NULL) return;
+ if (pss == nullptr) return;
if (!gpr_unref(&pss->refs)) return;
pollset_set_unref(exec_ctx, pss->parent);
gpr_mu_destroy(&pss->mu);
@@ -1193,7 +1193,7 @@ static void pollset_set_unref(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss) {
static void pollset_set_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss,
grpc_fd* fd) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ 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;
@@ -1217,7 +1217,7 @@ static void pollset_set_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss,
static void pollset_set_del_fd(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss,
grpc_fd* fd) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, "PSS:%p: del fd %p", pss, fd);
}
pss = pss_lock_adam(pss);
@@ -1238,7 +1238,7 @@ static void pollset_set_del_fd(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss,
static void pollset_set_del_pollset(grpc_exec_ctx* exec_ctx,
grpc_pollset_set* pss, grpc_pollset* ps) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, "PSS:%p: del pollset %p", pss, ps);
}
pss = pss_lock_adam(pss);
@@ -1289,16 +1289,16 @@ static grpc_error* add_fds_to_pollsets(grpc_exec_ctx* exec_ctx, grpc_fd** fds,
static void pollset_set_add_pollset(grpc_exec_ctx* exec_ctx,
grpc_pollset_set* pss, grpc_pollset* ps) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ 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 = NULL;
+ pollable* pollable_obj = nullptr;
gpr_mu_lock(&ps->mu);
if (!GRPC_LOG_IF_ERROR(err_desc, pollset_as_multipollable_locked(
exec_ctx, ps, &pollable_obj))) {
- GPR_ASSERT(pollable_obj == NULL);
+ GPR_ASSERT(pollable_obj == nullptr);
gpr_mu_unlock(&ps->mu);
return;
}
@@ -1326,7 +1326,7 @@ static void pollset_set_add_pollset(grpc_exec_ctx* exec_ctx,
static void pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
grpc_pollset_set* a,
grpc_pollset_set* b) {
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, "PSS: merge (%p, %p)", a, b);
}
grpc_error* error = GRPC_ERROR_NONE;
@@ -1343,9 +1343,9 @@ static void pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
gpr_mu* b_mu = &b->mu;
gpr_mu_lock(a_mu);
gpr_mu_lock(b_mu);
- if (a->parent != NULL) {
+ if (a->parent != nullptr) {
a = a->parent;
- } else if (b->parent != NULL) {
+ } else if (b->parent != nullptr) {
b = b->parent;
} else {
break; // exit loop, both pollsets locked
@@ -1360,7 +1360,7 @@ static void pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
if (b_size > a_size) {
GPR_SWAP(grpc_pollset_set*, a, b);
}
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, "PSS: parent %p to %p", b, a);
}
gpr_ref(&a->refs);
@@ -1394,8 +1394,8 @@ static void pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
a->pollset_count += b->pollset_count;
gpr_free(b->fds);
gpr_free(b->pollsets);
- b->fds = NULL;
- b->pollsets = NULL;
+ 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);
@@ -1448,29 +1448,25 @@ static const grpc_event_engine_vtable vtable = {
const grpc_event_engine_vtable* grpc_init_epollex_linux(
bool explicitly_requested) {
if (!explicitly_requested) {
- return NULL;
+ return nullptr;
}
if (!grpc_has_wakeup_fd()) {
gpr_log(GPR_ERROR, "Skipping epollex because of no wakeup fd.");
- return NULL;
+ return nullptr;
}
if (!grpc_is_epollexclusive_available()) {
gpr_log(GPR_INFO, "Skipping epollex because it is not supported.");
- return NULL;
+ return nullptr;
}
-#ifndef NDEBUG
- grpc_register_tracer(&grpc_trace_pollable_refcount);
-#endif
-
fd_global_init();
if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) {
pollset_global_shutdown();
fd_global_shutdown();
- return NULL;
+ return nullptr;
}
return &vtable;
diff --git a/src/core/lib/iomgr/ev_epollex_linux.h b/src/core/lib/iomgr/ev_epollex_linux.h
index 22b536c7d4..ffa7fc7f32 100644
--- a/src/core/lib/iomgr/ev_epollex_linux.h
+++ b/src/core/lib/iomgr/ev_epollex_linux.h
@@ -22,15 +22,7 @@
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/port.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
const grpc_event_engine_vtable* grpc_init_epollex_linux(
bool explicitly_requested);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLLEX_LINUX_H */
diff --git a/src/core/lib/iomgr/ev_epollsig_linux.cc b/src/core/lib/iomgr/ev_epollsig_linux.cc
index 42806e9d14..12c8483b8e 100644
--- a/src/core/lib/iomgr/ev_epollsig_linux.cc
+++ b/src/core/lib/iomgr/ev_epollsig_linux.cc
@@ -54,9 +54,9 @@
#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;
@@ -289,7 +289,7 @@ static void pi_unref(grpc_exec_ctx* exec_ctx, 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)) {
+ 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
@@ -301,7 +301,7 @@ static void pi_add_ref_dbg(polling_island* pi, const char* reason,
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)) {
+ 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
@@ -328,7 +328,7 @@ static void pi_unref(grpc_exec_ctx* exec_ctx, polling_island* pi) {
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) {
+ if (next != nullptr) {
PI_UNREF(exec_ctx, next, "pi_delete"); /* Recursive call */
}
}
@@ -414,7 +414,7 @@ static void polling_island_remove_all_fds_locked(polling_island* pi,
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 "
@@ -444,7 +444,7 @@ static void polling_island_remove_fd_locked(polling_island* pi, grpc_fd* fd,
/* If fd is already closed, then it would have been automatically been removed
from the epoll set */
if (!is_fd_closed) {
- err = epoll_ctl(pi->epoll_fd, EPOLL_CTL_DEL, fd->fd, NULL);
+ err = epoll_ctl(pi->epoll_fd, EPOLL_CTL_DEL, fd->fd, nullptr);
if (err < 0 && errno != ENOENT) {
gpr_asprintf(
&err_msg,
@@ -468,7 +468,7 @@ static void polling_island_remove_fd_locked(polling_island* pi, grpc_fd* fd,
static polling_island* polling_island_create(grpc_exec_ctx* exec_ctx,
grpc_fd* initial_fd,
grpc_error** error) {
- polling_island* pi = NULL;
+ polling_island* pi = nullptr;
const char* err_desc = "polling_island_create";
*error = GRPC_ERROR_NONE;
@@ -477,7 +477,7 @@ static polling_island* polling_island_create(grpc_exec_ctx* exec_ctx,
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);
@@ -491,14 +491,14 @@ 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;
+ pi = nullptr;
}
return pi;
}
@@ -519,7 +519,7 @@ static void polling_island_delete(grpc_exec_ctx* exec_ctx, polling_island* pi) {
* 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) {
+ while (next != nullptr) {
pi = next;
next = (polling_island*)gpr_atm_acq_load(&pi->merged_to);
}
@@ -537,18 +537,18 @@ static polling_island* polling_island_maybe_get_latest(polling_island* pi) {
...
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;
+ polling_island* next = nullptr;
while (true) {
next = (polling_island*)gpr_atm_acq_load(&pi->merged_to);
- if (next == NULL) {
+ 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) {
+ if (next == nullptr) {
/* pi is infact the last node and we have the pi->mu lock. we're done */
break;
}
@@ -588,8 +588,8 @@ static polling_island* polling_island_lock(polling_island* pi) {
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;
+ 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
@@ -607,13 +607,13 @@ static void polling_island_lock_pair(polling_island** p, polling_island** q) {
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) {
+ while (next_1 != nullptr) {
pi_1 = next_1;
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) {
+ while (next_2 != nullptr) {
pi_2 = next_2;
next_2 = (polling_island*)gpr_atm_acq_load(&pi_2->merged_to);
}
@@ -633,7 +633,7 @@ static void polling_island_lock_pair(polling_island** p, polling_island** q) {
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) {
+ if (next_1 == nullptr && next_2 == nullptr) {
break;
}
@@ -725,7 +725,7 @@ 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
@@ -733,7 +733,7 @@ static gpr_mu fd_freelist_mu;
#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_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),
@@ -750,7 +750,7 @@ static void ref_by(grpc_fd* fd, int n) {
#ifndef NDEBUG
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),
@@ -767,8 +767,8 @@ static void unref_by(grpc_fd* fd, int n) {
fd_freelist = fd;
grpc_iomgr_unregister_object(&fd->iomgr_object);
- fd->read_closure.Destroy();
- fd->write_closure.Destroy();
+ fd->read_closure->DestroyEvent();
+ fd->write_closure->DestroyEvent();
gpr_mu_unlock(&fd_freelist_mu);
} else {
@@ -797,7 +797,7 @@ 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) {
+ while (fd_freelist != nullptr) {
grpc_fd* fd = fd_freelist;
fd_freelist = fd_freelist->freelist_next;
gpr_mu_destroy(&fd->po.mu);
@@ -807,25 +807,27 @@ static void fd_global_shutdown(void) {
}
static grpc_fd* fd_create(int fd, const char* name) {
- grpc_fd* new_fd = NULL;
+ 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) {
+ 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
@@ -833,12 +835,12 @@ 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;
- new_fd->read_closure.Init();
- new_fd->write_closure.Init();
+ 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);
@@ -864,7 +866,7 @@ 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;
+ polling_island* unref_pi = nullptr;
gpr_mu_lock(&fd->po.mu);
fd->on_done_closure = on_done;
@@ -881,18 +883,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) {
+ 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);
@@ -904,7 +906,7 @@ static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
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
@@ -1009,7 +1011,7 @@ static grpc_pollset_worker* pop_front_worker(grpc_pollset* p) {
remove_worker(p, w);
return w;
} else {
- return NULL;
+ return nullptr;
}
}
@@ -1033,7 +1035,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* p,
GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
const char* err_desc = "Kick Failure";
grpc_pollset_worker* worker = specific_worker;
- if (worker != NULL) {
+ if (worker != nullptr) {
if (worker == GRPC_POLLSET_KICK_BROADCAST) {
if (pollset_has_workers(p)) {
GPR_TIMER_BEGIN("pollset_kick.broadcast", 0);
@@ -1063,7 +1065,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);
@@ -1081,7 +1083,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* p,
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
@@ -1091,7 +1093,7 @@ static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
pollset->shutting_down = false;
pollset->finish_shutdown_called = false;
- pollset->shutdown_done = NULL;
+ pollset->shutdown_done = nullptr;
}
static int poll_deadline_to_millis_timeout(grpc_exec_ctx* exec_ctx,
@@ -1126,10 +1128,10 @@ static void fd_become_writable(grpc_exec_ctx* exec_ctx, grpc_fd* fd) {
static void pollset_release_polling_island(grpc_exec_ctx* exec_ctx,
grpc_pollset* ps,
const char* reason) {
- if (ps->po.pi != NULL) {
+ if (ps->po.pi != nullptr) {
PI_UNREF(exec_ctx, ps->po.pi, reason);
}
- ps->po.pi = NULL;
+ ps->po.pi = nullptr;
}
static void finish_shutdown_locked(grpc_exec_ctx* exec_ctx,
@@ -1181,7 +1183,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx* exec_ctx,
struct epoll_event ep_ev[GRPC_EPOLL_MAX_EVENTS];
int epoll_fd = -1;
int ep_rv;
- polling_island* pi = NULL;
+ polling_island* pi = nullptr;
char* err_msg;
const char* err_desc = "pollset_work_and_unlock";
GPR_TIMER_BEGIN("pollset_work_and_unlock", 0);
@@ -1196,9 +1198,9 @@ 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(exec_ctx, nullptr, error);
+ if (pollset->po.pi == nullptr) {
GPR_TIMER_END("pollset_work_and_unlock", 0);
return; /* Fatal error. We cannot continue */
}
@@ -1280,10 +1282,10 @@ static void pollset_work_and_unlock(grpc_exec_ctx* exec_ctx,
}
}
- 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
@@ -1309,7 +1311,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
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);
@@ -1391,7 +1393,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
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);
@@ -1413,7 +1415,7 @@ static void add_poll_object(grpc_exec_ctx* exec_ctx, poll_obj* bag,
#endif
grpc_error* error = GRPC_ERROR_NONE;
- polling_island* pi_new = NULL;
+ polling_island* pi_new = nullptr;
gpr_mu_lock(&bag->mu);
gpr_mu_lock(&item->mu);
@@ -1440,7 +1442,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
@@ -1460,7 +1462,7 @@ retry:
/* 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)",
@@ -1477,7 +1479,7 @@ retry:
goto retry;
}
} else {
- pi_new = polling_island_create(exec_ctx, NULL, &error);
+ pi_new = polling_island_create(exec_ctx, nullptr, &error);
}
GRPC_POLLING_TRACE(
@@ -1490,7 +1492,7 @@ retry:
"add_poll_object: Same polling island. pi: %p (%s, %s)",
(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);
@@ -1506,7 +1508,7 @@ retry:
"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) {
+ } 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);
@@ -1530,7 +1532,7 @@ retry:
if (item->pi != pi_new) {
PI_ADD_REF(pi_new, poll_obj_string(item_type));
- if (item->pi != NULL) {
+ if (item->pi != nullptr) {
PI_UNREF(exec_ctx, item->pi, poll_obj_string(item_type));
}
item->pi = pi_new;
@@ -1538,7 +1540,7 @@ retry:
if (bag->pi != pi_new) {
PI_ADD_REF(pi_new, poll_obj_string(bag_type));
- if (bag->pi != NULL) {
+ if (bag->pi != nullptr) {
PI_UNREF(exec_ctx, bag->pi, poll_obj_string(bag_type));
}
bag->pi = pi_new;
@@ -1564,7 +1566,7 @@ static void pollset_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
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
@@ -1575,7 +1577,7 @@ static void pollset_set_destroy(grpc_exec_ctx* exec_ctx,
grpc_pollset_set* pss) {
gpr_mu_destroy(&pss->po.mu);
- if (pss->po.pi != NULL) {
+ if (pss->po.pi != nullptr) {
PI_UNREF(exec_ctx, pss->po.pi, "pss_destroy");
}
@@ -1712,17 +1714,17 @@ const grpc_event_engine_vtable* grpc_init_epollsig_linux(
/* If use of signals is disabled, we cannot use epoll engine*/
if (is_grpc_wakeup_signal_initialized && grpc_wakeup_signal < 0) {
gpr_log(GPR_ERROR, "Skipping epollsig because use of signals is disabled.");
- return NULL;
+ return nullptr;
}
if (!grpc_has_wakeup_fd()) {
gpr_log(GPR_ERROR, "Skipping epollsig because of no wakeup fd.");
- return NULL;
+ return nullptr;
}
if (!is_epoll_available()) {
gpr_log(GPR_ERROR, "Skipping epollsig because epoll is unavailable.");
- return NULL;
+ return nullptr;
}
if (!is_grpc_wakeup_signal_initialized) {
@@ -1731,19 +1733,19 @@ const grpc_event_engine_vtable* grpc_init_epollsig_linux(
} else {
gpr_log(GPR_ERROR,
"Skipping epollsig because uninitialized wakeup signal.");
- return NULL;
+ 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;
diff --git a/src/core/lib/iomgr/ev_epollsig_linux.h b/src/core/lib/iomgr/ev_epollsig_linux.h
index ca68595734..5b8aba9d9f 100644
--- a/src/core/lib/iomgr/ev_epollsig_linux.h
+++ b/src/core/lib/iomgr/ev_epollsig_linux.h
@@ -22,10 +22,6 @@
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/port.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
const grpc_event_engine_vtable* grpc_init_epollsig_linux(bool explicit_request);
#ifdef GRPC_LINUX_EPOLL
@@ -34,8 +30,4 @@ 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 __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLLSIG_LINUX_H */
diff --git a/src/core/lib/iomgr/ev_poll_posix.cc b/src/core/lib/iomgr/ev_poll_posix.cc
index 5745a2ae5b..e32e1ba42a 100644
--- a/src/core/lib/iomgr/ev_poll_posix.cc
+++ b/src/core/lib/iomgr/ev_poll_posix.cc
@@ -288,7 +288,7 @@ cv_fd_table g_cvfds;
#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_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),
@@ -305,7 +305,7 @@ static void ref_by(grpc_fd* fd, int n) {
#ifndef NDEBUG
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),
@@ -335,11 +335,11 @@ 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;
+ r->read_notifier_pollset = nullptr;
char* name2;
gpr_asprintf(&name2, "%s fd=%d", name, fd);
@@ -355,7 +355,7 @@ static bool fd_is_orphaned(grpc_fd* fd) {
/* 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;
+ grpc_pollset* notifier = nullptr;
gpr_mu_lock(&fd->mu);
notifier = fd->read_notifier_pollset;
@@ -401,7 +401,7 @@ static void wake_all_watchers_locked(grpc_exec_ctx* exec_ctx, grpc_fd* fd) {
}
static int has_watchers(grpc_fd* fd) {
- return fd->read_watcher != NULL || fd->write_watcher != NULL ||
+ return fd->read_watcher != nullptr || fd->write_watcher != nullptr ||
fd->inactive_watcher_root.next != &fd->inactive_watcher_root;
}
@@ -425,8 +425,8 @@ 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) {
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) {
@@ -565,9 +565,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;
@@ -576,7 +576,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;
}
@@ -584,12 +584,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;
@@ -609,7 +609,7 @@ static void fd_end_poll(grpc_exec_ctx* exec_ctx, grpc_fd_watcher* watcher,
int kick = 0;
grpc_fd* fd = watcher->fd;
- if (fd == NULL) {
+ if (fd == nullptr) {
return;
}
@@ -621,7 +621,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 */
@@ -629,9 +629,9 @@ 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;
@@ -640,7 +640,7 @@ static void fd_end_poll(grpc_exec_ctx* exec_ctx, grpc_fd_watcher* watcher,
if (set_ready_locked(exec_ctx, fd, &fd->read_closure)) {
kick = 1;
}
- if (read_notifier_pollset != NULL) {
+ if (read_notifier_pollset != nullptr) {
set_read_notifier_pollset_locked(exec_ctx, fd, read_notifier_pollset);
}
}
@@ -690,7 +690,7 @@ static grpc_pollset_worker* pop_front_worker(grpc_pollset* p) {
remove_worker(p, w);
return w;
} else {
- return NULL;
+ return nullptr;
}
}
@@ -722,7 +722,7 @@ static grpc_error* pollset_kick_ext(grpc_exec_ctx* exec_ctx, grpc_pollset* p,
GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
/* 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);
@@ -756,7 +756,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);
@@ -765,10 +765,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(
@@ -812,12 +812,12 @@ static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
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;
}
@@ -850,7 +850,7 @@ static void pollset_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
}
pollset->fds[pollset->fd_count++] = fd;
GRPC_FD_REF(fd, "multipoller");
- pollset_kick(exec_ctx, pollset, NULL);
+ pollset_kick(exec_ctx, pollset, nullptr);
exit:
gpr_mu_unlock(&pollset->mu);
}
@@ -892,9 +892,9 @@ 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 {
@@ -992,7 +992,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
r = grpc_poll_function(pfds, pfd_count, timeout);
GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(exec_ctx);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_DEBUG, "%p poll=%d", pollset, r);
}
@@ -1002,8 +1002,8 @@ 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(exec_ctx, &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()
@@ -1012,21 +1012,21 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* 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(exec_ctx, &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(exec_ctx, &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);
@@ -1083,7 +1083,7 @@ 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(exec_ctx, pollset, nullptr);
} else if (!pollset->called_shutdown && !pollset_has_observers(pollset)) {
pollset->called_shutdown = 1;
gpr_mu_unlock(&pollset->mu);
@@ -1101,7 +1101,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
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;
@@ -1319,7 +1319,7 @@ 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++;
}
@@ -1327,7 +1327,7 @@ static void cache_insert_locked(poll_args* args) {
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);
@@ -1358,12 +1358,12 @@ static poll_args* get_poller_locked(struct pollfd* fds, nfds_t count) {
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;
@@ -1373,8 +1373,8 @@ static poll_args* get_poller_locked(struct pollfd* fds, nfds_t count) {
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);
@@ -1382,7 +1382,7 @@ 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;
}
@@ -1405,7 +1405,7 @@ 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;
@@ -1419,11 +1419,11 @@ static void cache_poller_locked(poll_args* args) {
poll_cache.active_pollers =
(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* next = nullptr;
while (curr) {
next = curr->next;
cache_insert_locked(curr);
@@ -1520,10 +1520,10 @@ static int cvfd_poll(struct pollfd* fds, nfds_t nfds, int timeout) {
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->next = nullptr;
gpr_cv pollcv_cv;
gpr_cv_init(&pollcv_cv);
pollcv->cv = &pollcv_cv;
@@ -1534,7 +1534,7 @@ static int cvfd_poll(struct pollfd* fds, nfds_t nfds, int timeout) {
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]);
@@ -1573,7 +1573,7 @@ static int cvfd_poll(struct pollfd* fds, nfds_t nfds, int timeout) {
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;
}
@@ -1624,11 +1624,11 @@ 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;
+ 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];
}
@@ -1639,10 +1639,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.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);
@@ -1713,10 +1713,10 @@ static const grpc_event_engine_vtable vtable = {
const grpc_event_engine_vtable* grpc_init_poll_posix(bool explicit_request) {
if (!grpc_has_wakeup_fd()) {
gpr_log(GPR_ERROR, "Skipping poll because of no wakeup fd.");
- return NULL;
+ return nullptr;
}
if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) {
- return NULL;
+ return nullptr;
}
return &vtable;
}
@@ -1727,7 +1727,7 @@ const grpc_event_engine_vtable* grpc_init_poll_cv_posix(bool explicit_request) {
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 626e95bc8f..f6bc624d4f 100644
--- a/src/core/lib/iomgr/ev_poll_posix.h
+++ b/src/core/lib/iomgr/ev_poll_posix.h
@@ -21,15 +21,7 @@
#include "src/core/lib/iomgr/ev_posix.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
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);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H */
diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc
index a05279a4aa..031c97564a 100644
--- a/src/core/lib/iomgr/ev_posix.cc
+++ b/src/core/lib/iomgr/ev_posix.cc
@@ -36,13 +36,9 @@
#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
+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 */
@@ -51,7 +47,7 @@ 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;
+static const char* g_poll_strategy_name = nullptr;
typedef const grpc_event_engine_vtable* (*event_engine_factory_fn)(
bool explicit_request);
@@ -63,8 +59,6 @@ typedef struct {
namespace {
-extern "C" {
-
grpc_poll_function_type real_poll_function;
int dummy_poll(struct pollfd fds[], nfds_t nfds, int timeout) {
@@ -76,7 +70,6 @@ int dummy_poll(struct pollfd fds[], nfds_t nfds, int timeout) {
return -1;
}
}
-} // extern "C"
const grpc_event_engine_vtable* init_non_polling(bool explicit_request) {
if (!explicit_request) {
@@ -114,7 +107,7 @@ static void add(const char* beg, const char* end, char*** ss, size_t* ns) {
static void split(const char* s, char*** ss, size_t* ns) {
const char* c = strchr(s, ',');
- if (c == NULL) {
+ if (c == nullptr) {
add(s, s + strlen(s), ss, ns);
} else {
add(s, c, ss, ns);
@@ -153,18 +146,16 @@ const grpc_event_engine_vtable* grpc_get_event_engine_test_only() {
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) {
+ if (s == nullptr) {
s = gpr_strdup("all");
}
- char** strings = NULL;
+ char** strings = nullptr;
size_t nstrings = 0;
split(s, &strings, &nstrings);
- for (size_t i = 0; g_event_engine == NULL && i < nstrings; i++) {
+ for (size_t i = 0; g_event_engine == nullptr && i < nstrings; i++) {
try_engine(strings[i]);
}
@@ -173,7 +164,7 @@ void grpc_event_engine_init(void) {
}
gpr_free(strings);
- if (g_event_engine == NULL) {
+ if (g_event_engine == nullptr) {
gpr_log(GPR_ERROR, "No event engine could be initialized from %s", s);
abort();
}
@@ -182,7 +173,7 @@ void grpc_event_engine_init(void) {
void grpc_event_engine_shutdown(void) {
g_event_engine->shutdown_engine();
- g_event_engine = NULL;
+ g_event_engine = nullptr;
}
grpc_fd* grpc_fd_create(int fd, const char* name) {
diff --git a/src/core/lib/iomgr/ev_posix.h b/src/core/lib/iomgr/ev_posix.h
index d719b8f3c9..16fa10ca56 100644
--- a/src/core/lib/iomgr/ev_posix.h
+++ b/src/core/lib/iomgr/ev_posix.h
@@ -27,11 +27,7 @@
#include "src/core/lib/iomgr/pollset_set.h"
#include "src/core/lib/iomgr/wakeup_fd_posix.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-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;
@@ -162,8 +158,4 @@ extern grpc_poll_function_type grpc_poll_function;
void grpc_set_event_engine_test_only(const grpc_event_engine_vtable*);
const grpc_event_engine_vtable* grpc_get_event_engine_test_only();
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_EV_POSIX_H */
diff --git a/src/core/lib/iomgr/ev_windows.cc b/src/core/lib/iomgr/ev_windows.cc
index c24dfaeaf7..697697d0b0 100644
--- a/src/core/lib/iomgr/ev_windows.cc
+++ 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.cc b/src/core/lib/iomgr/exec_ctx.cc
index 0a0ed8a055..1777456342 100644
--- a/src/core/lib/iomgr/exec_ctx.cc
+++ b/src/core/lib/iomgr/exec_ctx.cc
@@ -47,7 +47,7 @@ bool grpc_always_ready_to_finish(grpc_exec_ctx* exec_ctx, void* arg_ignored) {
}
bool grpc_exec_ctx_has_work(grpc_exec_ctx* exec_ctx) {
- return exec_ctx->active_combiner != NULL ||
+ return exec_ctx->active_combiner != nullptr ||
!grpc_closure_list_empty(exec_ctx->closure_list);
}
@@ -60,7 +60,7 @@ 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)) {
+ 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,
@@ -69,7 +69,7 @@ static void exec_ctx_run(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
#endif
closure->cb(exec_ctx, closure->cb_arg, error);
#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_closure)) {
+ if (grpc_trace_closure.enabled()) {
gpr_log(GPR_DEBUG, "closure %p finished", closure);
}
#endif
@@ -82,8 +82,8 @@ bool grpc_exec_ctx_flush(grpc_exec_ctx* exec_ctx) {
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) {
+ exec_ctx->closure_list.head = exec_ctx->closure_list.tail = nullptr;
+ while (c != nullptr) {
grpc_closure* next = c->next_data.next;
grpc_error* error = c->error_data.error;
did_something = true;
@@ -94,7 +94,7 @@ bool grpc_exec_ctx_flush(grpc_exec_ctx* exec_ctx) {
break;
}
}
- GPR_ASSERT(exec_ctx->active_combiner == NULL);
+ GPR_ASSERT(exec_ctx->active_combiner == nullptr);
GPR_TIMER_END("grpc_exec_ctx_flush", 0);
return did_something;
}
@@ -104,23 +104,16 @@ static void exec_ctx_sched(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
grpc_closure_list_append(&exec_ctx->closure_list, closure, error);
}
-static gpr_timespec
- g_start_time[GPR_TIMESPAN + 1]; // assumes GPR_TIMESPAN is the
- // last enum value in
- // gpr_clock_type
+static gpr_timespec g_start_time;
void grpc_exec_ctx_global_init(void) {
- for (int i = 0; i < GPR_TIMESPAN; i++) {
- g_start_time[i] = gpr_now((gpr_clock_type)i);
- }
- // allows uniform treatment in conversion functions
- g_start_time[GPR_TIMESPAN] = gpr_time_0(GPR_TIMESPAN);
+ g_start_time = gpr_now(GPR_CLOCK_MONOTONIC);
}
void grpc_exec_ctx_global_shutdown(void) {}
static gpr_atm timespec_to_atm_round_down(gpr_timespec ts) {
- ts = gpr_time_sub(ts, g_start_time[ts.clock_type]);
+ 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;
@@ -129,7 +122,7 @@ static gpr_atm timespec_to_atm_round_down(gpr_timespec ts) {
}
static gpr_atm timespec_to_atm_round_up(gpr_timespec ts) {
- ts = gpr_time_sub(ts, g_start_time[ts.clock_type]);
+ 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;
@@ -164,16 +157,18 @@ gpr_timespec grpc_millis_to_timespec(grpc_millis millis,
if (clock_type == GPR_TIMESPAN) {
return gpr_time_from_millis(millis, GPR_TIMESPAN);
}
- return gpr_time_add(g_start_time[clock_type],
+ 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(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(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 = {
diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h
index bd27506152..b415d2c255 100644
--- a/src/core/lib/iomgr/exec_ctx.h
+++ b/src/core/lib/iomgr/exec_ctx.h
@@ -24,10 +24,6 @@
#include "src/core/lib/iomgr/closure.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef gpr_atm grpc_millis;
#define GRPC_MILLIS_INF_FUTURE GPR_ATM_MAX
@@ -124,8 +120,4 @@ 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);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_EXEC_CTX_H */
diff --git a/src/core/lib/iomgr/executor.cc b/src/core/lib/iomgr/executor.cc
index 2786492494..fabdbdf934 100644
--- a/src/core/lib/iomgr/executor.cc
+++ b/src/core/lib/iomgr/executor.cc
@@ -51,8 +51,7 @@ 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);
@@ -60,10 +59,10 @@ static size_t run_closures(grpc_exec_ctx* exec_ctx, grpc_closure_list list) {
size_t n = 0;
grpc_closure* c = list.head;
- while (c != NULL) {
+ while (c != nullptr) {
grpc_closure* next = c->next_data.next;
grpc_error* error = c->error_data.error;
- if (GRPC_TRACER_ON(executor_trace)) {
+ if (executor_trace.enabled()) {
#ifndef NDEBUG
gpr_log(GPR_DEBUG, "EXECUTOR: run %p [created by %s:%d]", c,
c->file_created, c->line_created);
@@ -105,8 +104,8 @@ void grpc_executor_set_threading(grpc_exec_ctx* exec_ctx, bool threading) {
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++) {
@@ -134,7 +133,6 @@ void grpc_executor_set_threading(grpc_exec_ctx* exec_ctx, bool threading) {
}
void grpc_executor_init(grpc_exec_ctx* exec_ctx) {
- grpc_register_tracer(&executor_trace);
gpr_atm_no_barrier_store(&g_cur_threads, 0);
grpc_executor_set_threading(exec_ctx, true);
}
@@ -148,11 +146,11 @@ static void executor_thread(void* 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_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, nullptr);
size_t subtract_depth = 0;
for (;;) {
- if (GRPC_TRACER_ON(executor_trace)) {
+ if (executor_trace.enabled()) {
gpr_log(GPR_DEBUG, "EXECUTOR[%d]: step (sub_depth=%" PRIdPTR ")",
(int)(ts - g_thread_state), subtract_depth);
}
@@ -163,7 +161,7 @@ static void executor_thread(void* arg) {
gpr_cv_wait(&ts->cv, &ts->mu, gpr_inf_future(GPR_CLOCK_REALTIME));
}
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));
}
@@ -174,7 +172,7 @@ static void executor_thread(void* arg) {
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));
}
@@ -196,7 +194,7 @@ static void executor_push(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
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);
@@ -208,7 +206,7 @@ static void executor_push(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
return;
}
thread_state* ts = (thread_state*)gpr_tls_get(&g_this_thread_state);
- if (ts == NULL) {
+ if (ts == nullptr) {
ts = &g_thread_state[GPR_HASH_POINTER(exec_ctx, cur_thread_count)];
} else {
GRPC_STATS_INC_EXECUTOR_SCHEDULED_TO_SELF(exec_ctx);
@@ -217,7 +215,7 @@ static void executor_push(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
bool try_new_thread;
for (;;) {
- if (GRPC_TRACER_ON(executor_trace)) {
+ if (executor_trace.enabled()) {
#ifndef NDEBUG
gpr_log(
GPR_DEBUG,
@@ -265,8 +263,8 @@ 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);
}
diff --git a/src/core/lib/iomgr/executor.h b/src/core/lib/iomgr/executor.h
index 8418ace06e..d349083eeb 100644
--- a/src/core/lib/iomgr/executor.h
+++ b/src/core/lib/iomgr/executor.h
@@ -21,10 +21,6 @@
#include "src/core/lib/iomgr/closure.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef enum {
GRPC_EXECUTOR_SHORT,
GRPC_EXECUTOR_LONG
@@ -49,8 +45,4 @@ bool grpc_executor_is_threaded();
grpc_executor_shutdown */
void grpc_executor_set_threading(grpc_exec_ctx* exec_ctx, bool enable);
-#ifdef __cplusplus
-}
-#endif
-
#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..f3cfd141b6
--- /dev/null
+++ b/src/core/lib/iomgr/fork_posix.cc
@@ -0,0 +1,90 @@
+/*
+ *
+ * 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/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/support/env.h"
+#include "src/core/lib/support/fork.h"
+#include "src/core/lib/support/thd_internal.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_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_timer_manager_set_threading(false);
+ grpc_executor_set_threading(&exec_ctx, false);
+ grpc_exec_ctx_finish(&exec_ctx);
+ 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_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_executor_set_threading(&exec_ctx, true);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
+}
+
+void grpc_postfork_child() {
+ if (grpc_is_initialized()) {
+ grpc_timer_manager_set_threading(true);
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_executor_set_threading(&exec_ctx, true);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
+}
+
+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 2e65b5ffbf..9f10b4afa7 100644
--- a/src/core/lib/iomgr/gethostname.h
+++ b/src/core/lib/iomgr/gethostname.h
@@ -19,16 +19,8 @@
#ifndef GRPC_CORE_LIB_IOMGR_GETHOSTNAME_H
#define GRPC_CORE_LIB_IOMGR_GETHOSTNAME_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
// Returns the hostname of the local machine.
// Caller takes ownership of result.
char* grpc_gethostname();
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_GETHOSTNAME_H */
diff --git a/src/core/lib/iomgr/gethostname_host_name_max.cc b/src/core/lib/iomgr/gethostname_host_name_max.cc
index 987ff1eac1..2487160916 100644
--- a/src/core/lib/iomgr/gethostname_host_name_max.cc
+++ b/src/core/lib/iomgr/gethostname_host_name_max.cc
@@ -30,7 +30,7 @@ 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/iocp_windows.h b/src/core/lib/iomgr/iocp_windows.h
index ff9b31efe2..0e9c3481f7 100644
--- a/src/core/lib/iomgr/iocp_windows.h
+++ b/src/core/lib/iomgr/iocp_windows.h
@@ -21,11 +21,11 @@
#include <grpc/support/sync.h>
-#include "src/core/lib/iomgr/socket_windows.h"
+#include "src/core/lib/iomgr/port.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+#ifdef GRPC_WINSOCK_SOCKET
+
+#include "src/core/lib/iomgr/socket_windows.h"
typedef enum {
GRPC_IOCP_WORK_WORK,
@@ -41,8 +41,6 @@ void grpc_iocp_flush(void);
void grpc_iocp_shutdown(void);
void grpc_iocp_add_socket(grpc_winsocket*);
-#ifdef __cplusplus
-}
#endif
#endif /* GRPC_CORE_LIB_IOMGR_IOCP_WINDOWS_H */
diff --git a/src/core/lib/iomgr/iomgr.cc b/src/core/lib/iomgr/iomgr.cc
index 86ea08e901..e077b35014 100644
--- a/src/core/lib/iomgr/iomgr.cc
+++ b/src/core/lib/iomgr/iomgr.cc
@@ -100,7 +100,7 @@ void grpc_iomgr_shutdown(grpc_exec_ctx* exec_ctx) {
}
exec_ctx->now_is_valid = true;
exec_ctx->now = GRPC_MILLIS_INF_FUTURE;
- if (grpc_timer_check(exec_ctx, NULL) == GRPC_TIMERS_FIRED) {
+ if (grpc_timer_check(exec_ctx, nullptr) == GRPC_TIMERS_FIRED) {
gpr_mu_unlock(&g_mu);
grpc_exec_ctx_flush(exec_ctx);
grpc_iomgr_platform_flush();
diff --git a/src/core/lib/iomgr/iomgr.h b/src/core/lib/iomgr/iomgr.h
index d1549c8c63..2f00c0343d 100644
--- a/src/core/lib/iomgr/iomgr.h
+++ b/src/core/lib/iomgr/iomgr.h
@@ -22,10 +22,6 @@
#include <grpc/impl/codegen/exec_ctx_fwd.h>
#include "src/core/lib/iomgr/port.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/** Initializes the iomgr. */
void grpc_iomgr_init(grpc_exec_ctx* exec_ctx);
@@ -36,8 +32,4 @@ void grpc_iomgr_start(grpc_exec_ctx* exec_ctx);
* exec_ctx. */
void grpc_iomgr_shutdown(grpc_exec_ctx* exec_ctx);
-#ifdef __cplusplus
-}
-#endif
-
#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 b818c68da0..20b3cb70d0 100644
--- a/src/core/lib/iomgr/iomgr_internal.h
+++ b/src/core/lib/iomgr/iomgr_internal.h
@@ -23,10 +23,6 @@
#include "src/core/lib/iomgr/iomgr.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_iomgr_object {
char* name;
struct grpc_iomgr_object* next;
@@ -44,8 +40,4 @@ void grpc_iomgr_platform_shutdown(void);
bool grpc_iomgr_abort_on_leaks(void);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_IOMGR_INTERNAL_H */
diff --git a/src/core/lib/iomgr/iomgr_posix.cc b/src/core/lib/iomgr/iomgr_posix.cc
index f5875a247e..f8f6fe2353 100644
--- a/src/core/lib/iomgr/iomgr_posix.cc
+++ 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.cc b/src/core/lib/iomgr/iomgr_uv.cc
index df5d23af3b..b8a10f2ae8 100644
--- a/src/core/lib/iomgr/iomgr_uv.cc
+++ b/src/core/lib/iomgr/iomgr_uv.cc
@@ -31,7 +31,7 @@ gpr_thd_id g_init_thread;
void grpc_iomgr_platform_init(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_pollset_global_init();
- grpc_register_tracer(&grpc_tcp_trace);
+
grpc_executor_set_threading(&exec_ctx, false);
g_init_thread = gpr_thd_currentid();
grpc_exec_ctx_finish(&exec_ctx);
diff --git a/src/core/lib/iomgr/iomgr_uv.h b/src/core/lib/iomgr/iomgr_uv.h
index bc42ca8c1c..3b4daaa73b 100644
--- a/src/core/lib/iomgr/iomgr_uv.h
+++ b/src/core/lib/iomgr/iomgr_uv.h
@@ -23,18 +23,10 @@
#include <grpc/support/thd.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* The thread ID of the thread on which grpc was initialized. Used to verify
* that all calls into libuv are made on that same thread */
extern gpr_thd_id g_init_thread;
-#ifdef __cplusplus
-}
-#endif
-
#ifdef GRPC_UV_THREAD_CHECK
#define GRPC_UV_ASSERT_SAME_THREAD() \
GPR_ASSERT(gpr_thd_currentid() == g_init_thread)
diff --git a/src/core/lib/iomgr/is_epollexclusive_available.cc b/src/core/lib/iomgr/is_epollexclusive_available.cc
index d08844c0df..e5803532e7 100644
--- a/src/core/lib/iomgr/is_epollexclusive_available.cc
+++ b/src/core/lib/iomgr/is_epollexclusive_available.cc
@@ -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/load_file.cc b/src/core/lib/iomgr/load_file.cc
index 97e448fb32..4a05de1410 100644
--- a/src/core/lib/iomgr/load_file.cc
+++ b/src/core/lib/iomgr/load_file.cc
@@ -30,7 +30,7 @@
grpc_error* grpc_load_file(const char* filename, int add_null_terminator,
grpc_slice* output) {
- unsigned char* contents = NULL;
+ unsigned char* contents = nullptr;
size_t contents_size = 0;
grpc_slice result = grpc_empty_slice();
FILE* file;
@@ -39,7 +39,7 @@ grpc_error* grpc_load_file(const char* filename, int add_null_terminator,
GRPC_SCHEDULING_START_BLOCKING_REGION;
file = fopen(filename, "rb");
- if (file == NULL) {
+ if (file == nullptr) {
error = GRPC_OS_ERROR(errno, "fopen");
goto end;
}
@@ -62,7 +62,7 @@ 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_set_str(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
diff --git a/src/core/lib/iomgr/load_file.h b/src/core/lib/iomgr/load_file.h
index 5b367c189d..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
-
#endif /* GRPC_CORE_LIB_IOMGR_LOAD_FILE_H */
diff --git a/src/core/lib/iomgr/lockfree_event.cc b/src/core/lib/iomgr/lockfree_event.cc
index 40e2ed6219..f0e798e8d8 100644
--- a/src/core/lib/iomgr/lockfree_event.cc
+++ b/src/core/lib/iomgr/lockfree_event.cc
@@ -22,7 +22,7 @@
#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:
@@ -57,7 +57,9 @@ extern grpc_tracer_flag grpc_polling_trace;
namespace grpc_core {
-LockfreeEvent::LockfreeEvent() {
+LockfreeEvent::LockfreeEvent() { InitEvent(); }
+
+void LockfreeEvent::InitEvent() {
/* Perform an atomic store to start the state machine.
Note carefully that LockfreeEvent *MAY* be used whilst in a destroyed
@@ -67,7 +69,7 @@ LockfreeEvent::LockfreeEvent() {
gpr_atm_no_barrier_store(&state_, kClosureNotReady);
}
-LockfreeEvent::~LockfreeEvent() {
+void LockfreeEvent::DestroyEvent() {
gpr_atm curr;
do {
curr = gpr_atm_no_barrier_load(&state_);
@@ -86,7 +88,7 @@ LockfreeEvent::~LockfreeEvent() {
void LockfreeEvent::NotifyOn(grpc_exec_ctx* exec_ctx, grpc_closure* closure) {
while (true) {
gpr_atm curr = gpr_atm_no_barrier_load(&state_);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR, "LockfreeEvent::NotifyOn: %p curr=%p closure=%p", this,
(void*)curr, closure);
}
@@ -153,7 +155,7 @@ bool LockfreeEvent::SetShutdown(grpc_exec_ctx* exec_ctx,
while (true) {
gpr_atm curr = gpr_atm_no_barrier_load(&state_);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR, "LockfreeEvent::SetShutdown: %p curr=%p err=%s",
&state_, (void*)curr, grpc_error_string(shutdown_err));
}
@@ -202,7 +204,7 @@ void LockfreeEvent::SetReady(grpc_exec_ctx* exec_ctx) {
while (true) {
gpr_atm curr = gpr_atm_no_barrier_load(&state_);
- if (GRPC_TRACER_ON(grpc_polling_trace)) {
+ if (grpc_polling_trace.enabled()) {
gpr_log(GPR_ERROR, "LockfreeEvent::SetReady: %p curr=%p", &state_,
(void*)curr);
}
diff --git a/src/core/lib/iomgr/lockfree_event.h b/src/core/lib/iomgr/lockfree_event.h
index c667dcd3bc..aec67a3399 100644
--- a/src/core/lib/iomgr/lockfree_event.h
+++ b/src/core/lib/iomgr/lockfree_event.h
@@ -30,11 +30,16 @@ namespace grpc_core {
class LockfreeEvent {
public:
LockfreeEvent();
- ~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;
}
diff --git a/src/core/lib/iomgr/polling_entity.cc b/src/core/lib/iomgr/polling_entity.cc
index f0ef2cfe3d..0ee4ea1255 100644
--- a/src/core/lib/iomgr/polling_entity.cc
+++ b/src/core/lib/iomgr/polling_entity.cc
@@ -41,7 +41,7 @@ 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(
@@ -49,7 +49,7 @@ grpc_pollset_set* grpc_polling_entity_pollset_set(
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) {
@@ -60,10 +60,10 @@ void grpc_polling_entity_add_to_pollset_set(grpc_exec_ctx* exec_ctx,
grpc_polling_entity* pollent,
grpc_pollset_set* pss_dst) {
if (pollent->tag == GRPC_POLLS_POLLSET) {
- GPR_ASSERT(pollent->pollent.pollset != NULL);
+ GPR_ASSERT(pollent->pollent.pollset != nullptr);
grpc_pollset_set_add_pollset(exec_ctx, pss_dst, pollent->pollent.pollset);
} else if (pollent->tag == GRPC_POLLS_POLLSET_SET) {
- GPR_ASSERT(pollent->pollent.pollset_set != NULL);
+ GPR_ASSERT(pollent->pollent.pollset_set != nullptr);
grpc_pollset_set_add_pollset_set(exec_ctx, pss_dst,
pollent->pollent.pollset_set);
} else {
@@ -76,10 +76,10 @@ void grpc_polling_entity_del_from_pollset_set(grpc_exec_ctx* exec_ctx,
grpc_polling_entity* pollent,
grpc_pollset_set* pss_dst) {
if (pollent->tag == GRPC_POLLS_POLLSET) {
- GPR_ASSERT(pollent->pollent.pollset != NULL);
+ GPR_ASSERT(pollent->pollent.pollset != nullptr);
grpc_pollset_set_del_pollset(exec_ctx, pss_dst, pollent->pollent.pollset);
} else if (pollent->tag == GRPC_POLLS_POLLSET_SET) {
- GPR_ASSERT(pollent->pollent.pollset_set != NULL);
+ GPR_ASSERT(pollent->pollent.pollset_set != nullptr);
grpc_pollset_set_del_pollset_set(exec_ctx, pss_dst,
pollent->pollent.pollset_set);
} else {
diff --git a/src/core/lib/iomgr/polling_entity.h b/src/core/lib/iomgr/polling_entity.h
index 867e085153..dbe579e60d 100644
--- a/src/core/lib/iomgr/polling_entity.h
+++ b/src/core/lib/iomgr/polling_entity.h
@@ -22,10 +22,6 @@
#include "src/core/lib/iomgr/pollset.h"
#include "src/core/lib/iomgr/pollset_set.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef enum grpc_pollset_tag {
GRPC_POLLS_NONE,
GRPC_POLLS_POLLSET,
@@ -68,8 +64,5 @@ void grpc_polling_entity_add_to_pollset_set(grpc_exec_ctx* exec_ctx,
void grpc_polling_entity_del_from_pollset_set(grpc_exec_ctx* exec_ctx,
grpc_polling_entity* pollent,
grpc_pollset_set* pss_dst);
-#ifdef __cplusplus
-}
-#endif
#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 c99b930e8e..d5d78f3101 100644
--- a/src/core/lib/iomgr/pollset.h
+++ b/src/core/lib/iomgr/pollset.h
@@ -25,13 +25,7 @@
#include "src/core/lib/iomgr/exec_ctx.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#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:
@@ -84,8 +78,4 @@ grpc_error* grpc_pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
grpc_pollset_worker* specific_worker)
GRPC_MUST_USE_RESULT;
-#ifdef __cplusplus
-}
-#endif
-
#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 0167a50a56..089c15cc94 100644
--- a/src/core/lib/iomgr/pollset_set.h
+++ b/src/core/lib/iomgr/pollset_set.h
@@ -21,10 +21,6 @@
#include "src/core/lib/iomgr/pollset.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* A grpc_pollset_set is a set of pollsets that are interested in an
action. Adding a pollset to a pollset_set automatically adds any
fd's (etc) that have been registered with the set_set to that pollset.
@@ -48,8 +44,4 @@ void grpc_pollset_set_del_pollset_set(grpc_exec_ctx* exec_ctx,
grpc_pollset_set* bag,
grpc_pollset_set* item);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_SET_H */
diff --git a/src/core/lib/iomgr/pollset_uv.cc b/src/core/lib/iomgr/pollset_uv.cc
index 1d54942c1d..16132f3a80 100644
--- a/src/core/lib/iomgr/pollset_uv.cc
+++ b/src/core/lib/iomgr/pollset_uv.cc
@@ -34,10 +34,7 @@
#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;
diff --git a/src/core/lib/iomgr/pollset_uv.h b/src/core/lib/iomgr/pollset_uv.h
index 5cc9faf4ff..566c110ca6 100644
--- a/src/core/lib/iomgr/pollset_uv.h
+++ b/src/core/lib/iomgr/pollset_uv.h
@@ -19,17 +19,9 @@
#ifndef GRPC_CORE_LIB_IOMGR_POLLSET_UV_H
#define GRPC_CORE_LIB_IOMGR_POLLSET_UV_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
extern int grpc_pollset_work_run_loop;
void grpc_pollset_global_init(void);
void grpc_pollset_global_shutdown(void);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_UV_H */
diff --git a/src/core/lib/iomgr/pollset_windows.cc b/src/core/lib/iomgr/pollset_windows.cc
index 5998b3f5bc..95dd7d7ddd 100644
--- a/src/core/lib/iomgr/pollset_windows.cc
+++ b/src/core/lib/iomgr/pollset_windows.cc
@@ -30,10 +30,7 @@
#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;
diff --git a/src/core/lib/iomgr/pollset_windows.h b/src/core/lib/iomgr/pollset_windows.h
index aaeb5f585f..93fe7d669b 100644
--- a/src/core/lib/iomgr/pollset_windows.h
+++ b/src/core/lib/iomgr/pollset_windows.h
@@ -21,11 +21,10 @@
#include <grpc/support/sync.h>
-#include "src/core/lib/iomgr/socket_windows.h"
+#include "src/core/lib/iomgr/port.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+#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
nature of the IO completion ports. A Windows "pollset" is merely a mutex
@@ -64,8 +63,6 @@ struct grpc_pollset {
void grpc_pollset_global_init(void);
void grpc_pollset_global_shutdown(void);
-#ifdef __cplusplus
-}
#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 1cc6d98491..9fae8c0052 100644
--- a/src/core/lib/iomgr/port.h
+++ b/src/core/lib/iomgr/port.h
@@ -30,6 +30,7 @@
#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
@@ -59,6 +60,7 @@
#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
@@ -90,6 +92,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 +106,7 @@
#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
diff --git a/src/core/lib/iomgr/resolve_address.h b/src/core/lib/iomgr/resolve_address.h
index 847e10f177..5105020404 100644
--- a/src/core/lib/iomgr/resolve_address.h
+++ b/src/core/lib/iomgr/resolve_address.h
@@ -25,10 +25,6 @@
#define GRPC_MAX_SOCKADDR_SIZE 128
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct {
char addr[GRPC_MAX_SOCKADDR_SIZE];
size_t len;
@@ -56,8 +52,4 @@ extern grpc_error* (*grpc_blocking_resolve_address)(
const char* name, const char* default_port,
grpc_resolved_addresses** addresses);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H */
diff --git a/src/core/lib/iomgr/resolve_address_posix.cc b/src/core/lib/iomgr/resolve_address_posix.cc
index e27c730204..fb5fa9d422 100644
--- a/src/core/lib/iomgr/resolve_address_posix.cc
+++ b/src/core/lib/iomgr/resolve_address_posix.cc
@@ -43,7 +43,7 @@ static grpc_error* blocking_resolve_address_impl(
const char* name, const char* default_port,
grpc_resolved_addresses** addresses) {
struct addrinfo hints;
- struct addrinfo *result = NULL, *resp;
+ struct addrinfo *result = nullptr, *resp;
char* host;
char* port;
int s;
@@ -57,14 +57,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));
@@ -115,13 +115,13 @@ static grpc_error* blocking_resolve_address_impl(
*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(
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++;
@@ -164,7 +164,7 @@ static void do_request_thread(grpc_exec_ctx* exec_ctx, void* rp,
}
void grpc_resolved_addresses_destroy(grpc_resolved_addresses* addrs) {
- if (addrs != NULL) {
+ if (addrs != nullptr) {
gpr_free(addrs->addrs);
}
gpr_free(addrs);
diff --git a/src/core/lib/iomgr/resource_quota.cc b/src/core/lib/iomgr/resource_quota.cc
index 5077554a56..ccd8d9f379 100644
--- a/src/core/lib/iomgr/resource_quota.cc
+++ b/src/core/lib/iomgr/resource_quota.cc
@@ -31,8 +31,7 @@
#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
@@ -166,7 +165,7 @@ 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) {
+ if (*root == nullptr) {
*root = resource_user;
resource_user->links[list].next = resource_user->links[list].prev =
resource_user;
@@ -183,7 +182,7 @@ 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) {
+ if (*root == nullptr) {
*root = resource_user;
resource_user->links[list].next = resource_user->links[list].prev =
resource_user;
@@ -197,18 +196,18 @@ static void rulist_add_tail(grpc_resource_user* resource_user,
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,
grpc_rulist list) {
grpc_resource_user** root = &resource_quota->roots[list];
grpc_resource_user* resource_user = *root;
- if (resource_user == NULL) {
- return NULL;
+ 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;
@@ -216,24 +215,24 @@ 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;
+ 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;
}
/*******************************************************************************
@@ -293,7 +292,7 @@ static bool rq_alloc(grpc_exec_ctx* exec_ctx,
while ((resource_user = rulist_pop_head(resource_quota,
GRPC_RULIST_AWAITING_ALLOCATION))) {
gpr_mu_lock(&resource_user->mu);
- if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
+ if (grpc_resource_quota_trace.enabled()) {
gpr_log(GPR_DEBUG,
"RQ: check allocation for user %p shutdown=%" PRIdPTR
" free_pool=%" PRId64,
@@ -319,14 +318,14 @@ static bool rq_alloc(grpc_exec_ctx* exec_ctx,
resource_user->free_pool = 0;
resource_quota->free_pool -= amt;
rq_update_estimate(resource_quota);
- if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
+ 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);
@@ -357,7 +356,7 @@ 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)) {
+ 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,
@@ -380,8 +379,8 @@ static bool rq_reclaim(grpc_exec_ctx* exec_ctx,
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)) {
+ 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");
@@ -392,7 +391,7 @@ static bool rq_reclaim(grpc_exec_ctx* exec_ctx,
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;
+ resource_user->reclaimers[destructive] = nullptr;
GRPC_CLOSURE_RUN(exec_ctx, c, GRPC_ERROR_NONE);
return true;
}
@@ -471,9 +470,9 @@ static bool ru_post_reclaimer(grpc_exec_ctx* exec_ctx,
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);
+ 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);
return false;
@@ -515,7 +514,7 @@ static void ru_post_destructive_reclaimer(grpc_exec_ctx* exec_ctx, void* ru,
}
static void ru_shutdown(grpc_exec_ctx* exec_ctx, void* ru, grpc_error* error) {
- if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
+ if (grpc_resource_quota_trace.enabled()) {
gpr_log(GPR_DEBUG, "RU shutdown %p", ru);
}
grpc_resource_user* resource_user = (grpc_resource_user*)ru;
@@ -523,8 +522,8 @@ static void ru_shutdown(grpc_exec_ctx* exec_ctx, void* ru, grpc_error* error) {
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;
+ 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) {
@@ -612,7 +611,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,
@@ -624,7 +623,7 @@ 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;
}
@@ -697,7 +696,7 @@ grpc_resource_quota* grpc_resource_quota_from_channel_args(
}
}
}
- return grpc_resource_quota_create(NULL);
+ return grpc_resource_quota_create(nullptr);
}
static void* rq_copy(void* rq) {
@@ -747,15 +746,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,
@@ -813,7 +812,7 @@ void grpc_resource_user_alloc(grpc_exec_ctx* exec_ctx,
ru_ref_by(resource_user, (gpr_atm)size);
resource_user->free_pool -= (int64_t)size;
resource_user->outstanding_allocations += (int64_t)size;
- if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
+ 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);
@@ -838,7 +837,7 @@ void grpc_resource_user_free(grpc_exec_ctx* exec_ctx,
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);
@@ -858,7 +857,7 @@ void grpc_resource_user_post_reclaimer(grpc_exec_ctx* exec_ctx,
grpc_resource_user* resource_user,
bool destructive,
grpc_closure* closure) {
- GPR_ASSERT(resource_user->new_reclaimers[destructive] == NULL);
+ 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],
@@ -867,7 +866,7 @@ void grpc_resource_user_post_reclaimer(grpc_exec_ctx* exec_ctx,
void grpc_resource_user_finish_reclamation(grpc_exec_ctx* exec_ctx,
grpc_resource_user* resource_user) {
- if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
+ if (grpc_resource_quota_trace.enabled()) {
gpr_log(GPR_DEBUG, "RQ %s %s: reclamation complete",
resource_user->resource_quota->name, resource_user->name);
}
@@ -896,10 +895,3 @@ void grpc_resource_user_alloc_slices(
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);
-}
diff --git a/src/core/lib/iomgr/resource_quota.h b/src/core/lib/iomgr/resource_quota.h
index fcdf9c2de5..787370307a 100644
--- a/src/core/lib/iomgr/resource_quota.h
+++ b/src/core/lib/iomgr/resource_quota.h
@@ -24,10 +24,6 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/** \file Tracks resource usage against a pool.
The current implementation tracks only memory usage, but in the future
@@ -65,7 +61,7 @@ extern "C" {
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);
@@ -154,8 +150,4 @@ grpc_slice grpc_resource_user_slice_malloc(grpc_exec_ctx* exec_ctx,
grpc_resource_user* resource_user,
size_t size);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_RESOURCE_QUOTA_H */
diff --git a/src/core/lib/iomgr/sockaddr_utils.cc b/src/core/lib/iomgr/sockaddr_utils.cc
index 2dbc5aa6e7..0c0a2fe5b2 100644
--- a/src/core/lib/iomgr/sockaddr_utils.cc
+++ b/src/core/lib/iomgr/sockaddr_utils.cc
@@ -41,14 +41,14 @@ int grpc_sockaddr_is_v4mapped(const grpc_resolved_address* resolved_addr,
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
+ 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;
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;
@@ -147,12 +147,12 @@ int grpc_sockaddr_to_string(char** out,
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;
}
@@ -167,8 +167,8 @@ int grpc_sockaddr_to_string(char** out,
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;
/* Enclose sin6_scope_id with the format defined in RFC 6784 section 2. */
@@ -192,18 +192,18 @@ char* grpc_sockaddr_to_uri(const grpc_resolved_address* resolved_addr) {
resolved_addr = &addr_normalized;
}
const char* scheme = grpc_sockaddr_get_uri_scheme(resolved_addr);
- if (scheme == NULL || strcmp("unix", scheme) == 0) {
+ 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(
@@ -217,7 +217,7 @@ 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) {
diff --git a/src/core/lib/iomgr/sockaddr_utils.h b/src/core/lib/iomgr/sockaddr_utils.h
index 090470d49e..e3bd51a4ad 100644
--- a/src/core/lib/iomgr/sockaddr_utils.h
+++ b/src/core/lib/iomgr/sockaddr_utils.h
@@ -21,10 +21,6 @@
#include "src/core/lib/iomgr/resolve_address.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Returns true if addr is an IPv4-mapped IPv6 address within the
::ffff:0.0.0.0/96 range, or false otherwise.
@@ -81,8 +77,4 @@ const char* grpc_sockaddr_get_uri_scheme(const grpc_resolved_address* addr);
int grpc_sockaddr_get_family(const grpc_resolved_address* resolved_addr);
-#ifdef __cplusplus
-}
-#endif
-
#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.h b/src/core/lib/iomgr/socket_factory_posix.h
index e8257b07c4..af57cc5b60 100644
--- a/src/core/lib/iomgr/socket_factory_posix.h
+++ b/src/core/lib/iomgr/socket_factory_posix.h
@@ -23,10 +23,6 @@
#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) */
@@ -68,8 +64,4 @@ 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);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_FACTORY_POSIX_H */
diff --git a/src/core/lib/iomgr/socket_mutator.h b/src/core/lib/iomgr/socket_mutator.h
index b4103f7e93..0a97cf657f 100644
--- a/src/core/lib/iomgr/socket_mutator.h
+++ b/src/core/lib/iomgr/socket_mutator.h
@@ -24,10 +24,6 @@
#include <stdbool.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/** The virtual table of grpc_socket_mutator */
typedef struct {
/** Mutates the socket opitons of \a fd */
@@ -60,8 +56,4 @@ 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);
-#ifdef __cplusplus
-}
-#endif
-
#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 4816ab6be7..9fd141b6de 100644
--- a/src/core/lib/iomgr/socket_utils.h
+++ b/src/core/lib/iomgr/socket_utils.h
@@ -21,15 +21,7 @@
#include <stddef.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* 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);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_H */
diff --git a/src/core/lib/iomgr/socket_utils_common_posix.cc b/src/core/lib/iomgr/socket_utils_common_posix.cc
index 88b757a4ae..2d4b8f0add 100644
--- a/src/core/lib/iomgr/socket_utils_common_posix.cc
+++ b/src/core/lib/iomgr/socket_utils_common_posix.cc
@@ -263,13 +263,13 @@ static grpc_error* error_for_fd(int fd, const grpc_resolved_address* addr) {
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);
+ 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,
int protocol) {
- return (factory != NULL)
+ return (factory != nullptr)
? grpc_socket_factory_socket(factory, domain, type, protocol)
: socket(domain, type, protocol);
}
@@ -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);
}
diff --git a/src/core/lib/iomgr/socket_utils_posix.h b/src/core/lib/iomgr/socket_utils_posix.h
index 7a9c8139e7..77df4205ff 100644
--- a/src/core/lib/iomgr/socket_utils_posix.h
+++ b/src/core/lib/iomgr/socket_utils_posix.h
@@ -29,10 +29,6 @@
#include "src/core/lib/iomgr/socket_factory_posix.h"
#include "src/core/lib/iomgr/socket_mutator.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* a wrapper for accept or accept4 */
int grpc_accept4(int sockfd, grpc_resolved_address* resolved_addr, int nonblock,
int cloexec);
@@ -133,8 +129,4 @@ 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);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_POSIX_H */
diff --git a/src/core/lib/iomgr/socket_windows.h b/src/core/lib/iomgr/socket_windows.h
index 6f6c7a7024..04e0a89d70 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>
@@ -28,10 +31,6 @@
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/iomgr_internal.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* This holds the data for an outstanding read or write on a socket.
The mutex to protect the concurrent access to that data is the one
inside the winsocket wrapper. */
@@ -111,8 +110,6 @@ void grpc_socket_become_ready(grpc_exec_ctx* exec_ctx,
grpc_winsocket* winsocket,
grpc_winsocket_callback_info* ci);
-#ifdef __cplusplus
-}
#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 c18d8a9316..75e2fe0f36 100644
--- a/src/core/lib/iomgr/tcp_client.h
+++ b/src/core/lib/iomgr/tcp_client.h
@@ -25,10 +25,6 @@
#include "src/core/lib/iomgr/pollset_set.h"
#include "src/core/lib/iomgr/resolve_address.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Asynchronously connect to an address (specified as (addr, len)), and call
cb with arg and the completed connection when done (or call cb with arg and
NULL on failure).
@@ -41,8 +37,4 @@ void grpc_tcp_client_connect(grpc_exec_ctx* exec_ctx, grpc_closure* on_connect,
const grpc_resolved_address* addr,
grpc_millis deadline);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_H */
diff --git a/src/core/lib/iomgr/tcp_client_posix.cc b/src/core/lib/iomgr/tcp_client_posix.cc
index e72d70c027..4cb2ac49d5 100644
--- a/src/core/lib/iomgr/tcp_client_posix.cc
+++ b/src/core/lib/iomgr/tcp_client_posix.cc
@@ -43,7 +43,7 @@
#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;
@@ -99,13 +99,13 @@ done:
static void tc_on_alarm(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
int done;
async_connect* ac = (async_connect*)acp;
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ 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) {
+ if (ac->fd != nullptr) {
grpc_fd_shutdown(
exec_ctx, ac->fd,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("connect() timed out"));
@@ -138,7 +138,7 @@ static void on_writable(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
GRPC_ERROR_REF(error);
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ 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,7 +147,7 @@ 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);
@@ -175,7 +175,7 @@ static void on_writable(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
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;
+ fd = nullptr;
break;
case ENOBUFS:
/* We will get one of these errors if we have run out of
@@ -208,11 +208,11 @@ static void on_writable(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
}
finish:
- if (fd != NULL) {
+ if (fd != nullptr) {
grpc_pollset_set_del_fd(exec_ctx, ac->interested_parties, fd);
- grpc_fd_orphan(exec_ctx, fd, NULL, NULL, false /* already_closed */,
+ grpc_fd_orphan(exec_ctx, fd, nullptr, nullptr, false /* already_closed */,
"tcp_client_orphan");
- fd = NULL;
+ fd = nullptr;
}
done = (--ac->refs == 0);
gpr_mu_unlock(&ac->mu);
@@ -256,7 +256,7 @@ static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx,
char* addr_str;
grpc_error* error;
- *ep = NULL;
+ *ep = nullptr;
/* Use dualstack sockets where available. */
if (grpc_sockaddr_to_v4mapped(addr, &addr6_v4mapped)) {
@@ -296,8 +296,8 @@ static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx,
}
if (errno != EWOULDBLOCK && errno != EINPROGRESS) {
- grpc_fd_orphan(exec_ctx, fdobj, NULL, NULL, false /* already_closed */,
- "tcp_client_connect_error");
+ grpc_fd_orphan(exec_ctx, fdobj, nullptr, nullptr,
+ false /* already_closed */, "tcp_client_connect_error");
GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_OS_ERROR(errno, "connect"));
goto done;
}
@@ -310,14 +310,14 @@ static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx,
ac->fd = fdobj;
ac->interested_parties = interested_parties;
ac->addr_str = addr_str;
- addr_str = NULL;
+ addr_str = nullptr;
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);
}
@@ -334,13 +334,11 @@ done:
}
// overridden by api_fuzzer.c
-extern "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,
grpc_millis deadline) = tcp_client_connect_impl;
-}
void grpc_tcp_client_connect(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
grpc_endpoint** ep,
diff --git a/src/core/lib/iomgr/tcp_client_posix.h b/src/core/lib/iomgr/tcp_client_posix.h
index 13d917891e..2b1fe79e90 100644
--- a/src/core/lib/iomgr/tcp_client_posix.h
+++ b/src/core/lib/iomgr/tcp_client_posix.h
@@ -23,16 +23,8 @@
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/tcp_client.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
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);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H */
diff --git a/src/core/lib/iomgr/tcp_client_uv.cc b/src/core/lib/iomgr/tcp_client_uv.cc
index 15345c8091..5cca0c9936 100644
--- a/src/core/lib/iomgr/tcp_client_uv.cc
+++ b/src/core/lib/iomgr/tcp_client_uv.cc
@@ -32,7 +32,7 @@
#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;
@@ -59,7 +59,7 @@ static void uv_tc_on_alarm(grpc_exec_ctx* exec_ctx, void* acp,
grpc_error* error) {
int done;
grpc_uv_tcp_connect* connect = (grpc_uv_tcp_connect*)acp;
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ 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);
@@ -147,7 +147,7 @@ static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx,
connect->connect_req.data = connect;
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);
}
@@ -161,13 +161,11 @@ static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx,
}
// overridden by api_fuzzer.c
-extern "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,
grpc_millis deadline) = tcp_client_connect_impl;
-}
void grpc_tcp_client_connect(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
grpc_endpoint** ep,
diff --git a/src/core/lib/iomgr/tcp_client_windows.cc b/src/core/lib/iomgr/tcp_client_windows.cc
index 103e6b78de..5e30725e90 100644
--- a/src/core/lib/iomgr/tcp_client_windows.cc
+++ b/src/core/lib/iomgr/tcp_client_windows.cc
@@ -226,13 +226,11 @@ failure:
}
// overridden by api_fuzzer.c
-extern "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,
grpc_millis deadline) = tcp_client_connect_impl;
-}
void grpc_tcp_client_connect(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
grpc_endpoint** ep,
diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc
index fbbb1762b7..d09cfca9af 100644
--- a/src/core/lib/iomgr/tcp_posix.cc
+++ b/src/core/lib/iomgr/tcp_posix.cc
@@ -61,7 +61,7 @@ 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 {
grpc_endpoint base;
@@ -81,9 +81,7 @@ typedef struct {
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 */
+ /** byte within outgoing_buffer->slices[0] to write next */
size_t outgoing_byte_idx;
grpc_closure* read_cb;
@@ -121,7 +119,7 @@ static void tcp_drop_uncovered_then_handle_write(grpc_exec_ctx* exec_ctx,
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)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p destroy", p);
}
grpc_pollset_destroy(exec_ctx, BACKUP_POLLER_POLLSET(p));
@@ -131,7 +129,7 @@ static void done_poller(grpc_exec_ctx* exec_ctx, void* bp,
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)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p run", p);
}
gpr_mu_lock(p->pollset_mu);
@@ -139,7 +137,7 @@ static void run_poller(grpc_exec_ctx* exec_ctx, void* bp,
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, deadline));
+ grpc_pollset_work(exec_ctx, 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 */
@@ -147,18 +145,18 @@ 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_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);
@@ -169,7 +167,7 @@ static void drop_uncovered(grpc_exec_ctx* exec_ctx, 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);
}
@@ -180,14 +178,14 @@ static void cover_self(grpc_exec_ctx* exec_ctx, 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_zalloc(sizeof(*p) + grpc_pollset_size());
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p create", p);
}
grpc_pollset_init(BACKUP_POLLER_POLLSET(p), &p->pollset_mu);
@@ -198,11 +196,12 @@ static void cover_self(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
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);
@@ -212,7 +211,7 @@ static void cover_self(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
}
static void notify_on_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ 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,
@@ -221,7 +220,7 @@ static void notify_on_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
}
static void notify_on_write(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "TCP:%p notify_on_write", tcp);
}
cover_self(exec_ctx, tcp);
@@ -233,7 +232,7 @@ static void notify_on_write(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
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)) {
+ 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);
@@ -310,7 +309,7 @@ static void tcp_free(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
#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)) {
+ 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,
@@ -323,7 +322,7 @@ static void tcp_unref(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
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,
@@ -354,7 +353,7 @@ static void call_read_cb(grpc_exec_ctx* exec_ctx, 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);
@@ -368,8 +367,8 @@ static void call_read_cb(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
}
}
- tcp->read_cb = NULL;
- tcp->incoming_buffer = NULL;
+ tcp->read_cb = nullptr;
+ tcp->incoming_buffer = nullptr;
GRPC_CLOSURE_RUN(exec_ctx, cb, error);
}
@@ -389,11 +388,11 @@ 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;
@@ -450,7 +449,7 @@ static void tcp_do_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
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)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "TCP:%p read_allocation_done: %s", tcp,
grpc_error_string(error));
}
@@ -469,13 +468,13 @@ static void tcp_continue_read(grpc_exec_ctx* exec_ctx, 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);
} 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);
@@ -486,7 +485,7 @@ static void tcp_handle_read(grpc_exec_ctx* exec_ctx, 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));
}
@@ -504,7 +503,7 @@ static void tcp_handle_read(grpc_exec_ctx* exec_ctx, void* arg /* grpc_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);
+ 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);
@@ -531,32 +530,35 @@ 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;
@@ -573,16 +575,25 @@ static bool tcp_flush(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
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(
+ exec_ctx, 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);
+ grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
+ tcp->outgoing_buffer);
return true;
} else {
*error = tcp_annotate_error(GRPC_OS_ERROR(errno, "sendmsg"), tcp);
+ grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
+ tcp->outgoing_buffer);
return true;
}
}
@@ -592,9 +603,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;
@@ -603,11 +614,13 @@ 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(exec_ctx,
+ tcp->outgoing_buffer);
return true;
}
- };
+ }
}
static void tcp_handle_write(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
@@ -617,21 +630,21 @@ static void tcp_handle_write(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
if (error != GRPC_ERROR_NONE) {
cb = tcp->write_cb;
- tcp->write_cb = NULL;
+ tcp->write_cb = nullptr;
cb->cb(exec_ctx, cb->cb_arg, error);
TCP_UNREF(exec_ctx, tcp, "write");
return;
}
if (!tcp_flush(exec_ctx, tcp, &error)) {
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "write: delayed");
}
notify_on_write(exec_ctx, tcp);
} else {
cb = tcp->write_cb;
- tcp->write_cb = NULL;
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ tcp->write_cb = nullptr;
+ if (grpc_tcp_trace.enabled()) {
const char* str = grpc_error_string(error);
gpr_log(GPR_DEBUG, "write: %s", str);
}
@@ -646,7 +659,7 @@ static void tcp_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
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++) {
@@ -658,7 +671,7 @@ 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);
@@ -671,18 +684,17 @@ static void tcp_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
return;
}
tcp->outgoing_buffer = buf;
- tcp->outgoing_slice_idx = 0;
tcp->outgoing_byte_idx = 0;
if (!tcp_flush(exec_ctx, 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);
} else {
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
const char* str = grpc_error_string(error);
gpr_log(GPR_DEBUG, "write: %s", str);
}
@@ -745,8 +757,8 @@ grpc_endpoint* grpc_tcp_create(grpc_exec_ctx* exec_ctx, grpc_fd* em_fd,
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)) {
@@ -785,11 +797,11 @@ grpc_endpoint* grpc_tcp_create(grpc_exec_ctx* exec_ctx, grpc_fd* em_fd,
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;
diff --git a/src/core/lib/iomgr/tcp_posix.h b/src/core/lib/iomgr/tcp_posix.h
index ff1060b0ff..09051b7ed6 100644
--- a/src/core/lib/iomgr/tcp_posix.h
+++ b/src/core/lib/iomgr/tcp_posix.h
@@ -33,11 +33,7 @@
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/ev_posix.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-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. */
@@ -57,8 +53,4 @@ int grpc_tcp_fd(grpc_endpoint* ep);
void grpc_tcp_destroy_and_release_fd(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
int* fd, grpc_closure* done);
-#ifdef __cplusplus
-}
-#endif
-
#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 ef983199b8..a1757a2b3e 100644
--- a/src/core/lib/iomgr/tcp_server.h
+++ b/src/core/lib/iomgr/tcp_server.h
@@ -25,10 +25,6 @@
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/resolve_address.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Forward decl of grpc_tcp_server */
typedef struct grpc_tcp_server grpc_tcp_server;
@@ -102,8 +98,4 @@ void grpc_tcp_server_unref(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s);
void grpc_tcp_server_shutdown_listeners(grpc_exec_ctx* exec_ctx,
grpc_tcp_server* s);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_TCP_SERVER_H */
diff --git a/src/core/lib/iomgr/tcp_server_posix.cc b/src/core/lib/iomgr/tcp_server_posix.cc
index 6fcbac03a2..6fed13c6c7 100644
--- a/src/core/lib/iomgr/tcp_server_posix.cc
+++ b/src/core/lib/iomgr/tcp_server_posix.cc
@@ -77,7 +77,7 @@ grpc_error* grpc_tcp_server_create(grpc_exec_ctx* exec_ctx,
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 +102,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);
@@ -120,7 +120,7 @@ static void finish_shutdown(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s) {
gpr_mu_lock(&s->mu);
GPR_ASSERT(s->shutdown);
gpr_mu_unlock(&s->mu);
- if (s->shutdown_complete != NULL) {
+ if (s->shutdown_complete != nullptr) {
GRPC_CLOSURE_SCHED(exec_ctx, s->shutdown_complete, GRPC_ERROR_NONE);
}
@@ -165,7 +165,7 @@ static void deactivated_all_ports(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s) {
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(exec_ctx, sp->emfd, &sp->destroyed_closure, nullptr,
false /* already_closed */, "tcp_listener_shutdown");
}
gpr_mu_unlock(&s->mu);
@@ -243,7 +243,7 @@ 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);
}
@@ -288,8 +288,8 @@ static grpc_error* add_wildcard_addrs_to_server(grpc_tcp_server* s,
grpc_resolved_address wild6;
unsigned fd_index = 0;
grpc_dualstack_mode dsmode;
- grpc_tcp_listener* sp = NULL;
- grpc_tcp_listener* sp2 = NULL;
+ 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;
@@ -314,7 +314,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;
}
@@ -346,7 +346,7 @@ 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;
+ grpc_tcp_listener* sp = nullptr;
char* addr_str;
char* name;
grpc_error* err;
@@ -383,7 +383,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);
@@ -404,7 +404,7 @@ grpc_error* grpc_tcp_server_add_port(grpc_tcp_server* s,
grpc_dualstack_mode dsmode;
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);
@@ -454,7 +454,7 @@ 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,
@@ -498,7 +498,7 @@ 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(
diff --git a/src/core/lib/iomgr/tcp_server_utils_posix.h b/src/core/lib/iomgr/tcp_server_utils_posix.h
index 608fba3346..6046f257f9 100644
--- a/src/core/lib/iomgr/tcp_server_utils_posix.h
+++ b/src/core/lib/iomgr/tcp_server_utils_posix.h
@@ -24,10 +24,6 @@
#include "src/core/lib/iomgr/socket_utils_posix.h"
#include "src/core/lib/iomgr/tcp_server.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* one listening port */
typedef struct grpc_tcp_listener {
int fd;
@@ -121,8 +117,4 @@ grpc_error* grpc_tcp_server_prepare_socket(int fd,
/* Ruturn true if the platform supports ifaddrs */
bool grpc_tcp_server_have_ifaddrs(void);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_TCP_SERVER_UTILS_POSIX_H */
diff --git a/src/core/lib/iomgr/tcp_server_utils_posix_common.cc b/src/core/lib/iomgr/tcp_server_utils_posix_common.cc
index 51e6731729..5139760634 100644
--- a/src/core/lib/iomgr/tcp_server_utils_posix_common.cc
+++ b/src/core/lib/iomgr/tcp_server_utils_posix_common.cc
@@ -47,7 +47,7 @@ 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) {
+ if (fp == nullptr) {
/* 2.4 kernel. */
s_max_accept_queue_size = SOMAXCONN;
return;
@@ -55,7 +55,7 @@ static void init_max_accept_queue_size(void) {
if (fgets(buf, sizeof buf, fp)) {
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;
}
}
@@ -79,7 +79,7 @@ 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* sp = nullptr;
int port = -1;
char* addr_str;
char* name;
@@ -94,8 +94,8 @@ static grpc_error* add_socket_to_server(grpc_tcp_server* s, int fd,
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->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);
diff --git a/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc b/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc
index b7437dbf4d..227bf94aa7 100644
--- a/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc
+++ b/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc
@@ -40,7 +40,7 @@ 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;
}
@@ -87,10 +87,10 @@ 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 = nullptr;
struct ifaddrs* ifa_it;
unsigned fd_index = 0;
- grpc_tcp_listener* sp = NULL;
+ 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
@@ -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;
+ grpc_tcp_listener* new_sp = nullptr;
const char* ifa_name = (ifa_it->ifa_name ? ifa_it->ifa_name : "<unknown>");
- if (ifa_it->ifa_addr == NULL) {
+ 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,7 +144,7 @@ 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;
+ 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_uv.cc b/src/core/lib/iomgr/tcp_server_uv.cc
index 0eed4d428f..ffadf0b1ab 100644
--- a/src/core/lib/iomgr/tcp_server_uv.cc
+++ b/src/core/lib/iomgr/tcp_server_uv.cc
@@ -213,7 +213,7 @@ static void finish_accept(grpc_exec_ctx* exec_ctx, grpc_tcp_listener* sp) {
} 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);
@@ -247,7 +247,7 @@ 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);
}
@@ -260,15 +260,36 @@ static void on_connect(uv_stream_t* server, int status) {
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) {
+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_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);
@@ -325,20 +346,48 @@ static grpc_error* add_socket_to_server(grpc_tcp_server* s, uv_tcp_t* handle,
return GRPC_ERROR_NONE;
}
+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_resolved_address addr6_v4mapped;
- grpc_resolved_address wildcard;
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_UV_ASSERT_SAME_THREAD();
@@ -367,43 +416,20 @@ 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 = (uv_tcp_t*)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)) {
+ if (grpc_tcp_trace.enabled()) {
char* port_string;
grpc_sockaddr_to_string(&port_string, addr, 0);
const char* str = grpc_error_string(error);
@@ -435,7 +461,7 @@ void grpc_tcp_server_start(grpc_exec_ctx* exec_ctx, grpc_tcp_server* server,
(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);
diff --git a/src/core/lib/iomgr/tcp_uv.cc b/src/core/lib/iomgr/tcp_uv.cc
index ac9ca4ea11..40f4006203 100644
--- a/src/core/lib/iomgr/tcp_uv.cc
+++ b/src/core/lib/iomgr/tcp_uv.cc
@@ -38,7 +38,7 @@
#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");
+grpc_core::TraceFlag grpc_tcp_trace(false, "tcp");
typedef struct {
grpc_endpoint base;
@@ -52,12 +52,12 @@ typedef struct {
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;
+ grpc_resource_user_slice_allocator slice_allocator;
bool shutting_down;
@@ -66,7 +66,6 @@ typedef struct {
} 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);
@@ -79,7 +78,7 @@ static void tcp_free(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
#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)) {
+ 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,
@@ -92,7 +91,7 @@ static void tcp_unref(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
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,
@@ -119,91 +118,117 @@ static void uv_close_callback(uv_handle_t* handle) {
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 = (grpc_tcp*)handle->data;
(void)suggested_size;
- buf->base = (char*)GRPC_SLICE_START_PTR(tcp->read_slice);
- buf->len = GRPC_SLICE_LENGTH(tcp->read_slice);
+ /* 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]);
grpc_exec_ctx_finish(&exec_ctx);
}
+static void call_read_cb(grpc_exec_ctx* exec_ctx, 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(exec_ctx, cb, error);
+}
+
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 = (grpc_tcp*)stream->data;
- grpc_closure* cb = tcp->read_cb;
+ grpc_slice_buffer garbage;
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");
+ grpc_slice_buffer_reset_and_unref_internal(&exec_ctx, tcp->read_slices);
} 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);
- }
+ 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(&exec_ctx, &garbage);
}
} else {
// nread < 0: Error
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("TCP Read failed");
+ grpc_slice_buffer_reset_and_unref_internal(&exec_ctx, tcp->read_slices);
}
- GRPC_CLOSURE_SCHED(&exec_ctx, cb, error);
+ call_read_cb(&exec_ctx, tcp, error);
grpc_exec_ctx_finish(&exec_ctx);
}
+static void tcp_read_allocation_done(grpc_exec_ctx* exec_ctx, 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 = 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)));
+ }
+ }
+ if (error != GRPC_ERROR_NONE) {
+ grpc_slice_buffer_reset_and_unref_internal(exec_ctx, tcp->read_slices);
+ call_read_cb(exec_ctx, tcp, GRPC_ERROR_REF(error));
+ TCP_UNREF(exec_ctx, 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_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);
- }
+ grpc_resource_user_alloc_slices(exec_ctx, &tcp->slice_allocator,
+ GRPC_TCP_DEFAULT_READ_SLICE_SIZE, 1,
+ tcp->read_slices);
}
static void write_callback(uv_write_t* req, int status) {
@@ -218,13 +243,11 @@ static void write_callback(uv_write_t* req, int status) {
} else {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("TCP Write failed");
}
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ 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_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);
}
@@ -240,7 +263,7 @@ static void uv_endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
uv_write_t* write_req;
GRPC_UV_ASSERT_SAME_THREAD();
- if (GRPC_TRACER_ON(grpc_tcp_trace)) {
+ if (grpc_tcp_trace.enabled()) {
size_t j;
for (j = 0; j < write_slices->count; j++) {
@@ -271,8 +294,6 @@ static void uv_endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
tcp->write_cb = cb;
buffer_count = (unsigned int)tcp->write_slices->count;
buffers = (uv_buf_t*)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);
@@ -320,7 +341,7 @@ 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)) {
+ if (grpc_tcp_trace.enabled()) {
const char* str = grpc_error_string(why);
gpr_log(GPR_DEBUG, "TCP %p shutdown why=%s", tcp->handle, str);
}
@@ -367,7 +388,7 @@ grpc_endpoint* grpc_tcp_create(uv_tcp_t* handle,
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)) {
+ if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_DEBUG, "Creating TCP endpoint %p", tcp);
}
@@ -381,8 +402,10 @@ grpc_endpoint* grpc_tcp_create(uv_tcp_t* handle,
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);
- tcp->read_slice = alloc_read_slice(&exec_ctx, tcp->resource_user);
+ 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);
diff --git a/src/core/lib/iomgr/tcp_uv.h b/src/core/lib/iomgr/tcp_uv.h
index 8a4914935a..fd6d19049a 100644
--- a/src/core/lib/iomgr/tcp_uv.h
+++ b/src/core/lib/iomgr/tcp_uv.h
@@ -32,22 +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
-#ifdef __cplusplus
-extern "C" {
-#endif
-
grpc_endpoint* grpc_tcp_create(uv_tcp_t* handle,
grpc_resource_quota* resource_quota,
char* peer_string);
-#ifdef __cplusplus
-}
-#endif
+#endif /* GRPC_UV */
#endif /* GRPC_CORE_LIB_IOMGR_TCP_UV_H */
diff --git a/src/core/lib/iomgr/tcp_windows.cc b/src/core/lib/iomgr/tcp_windows.cc
index 04922b4037..33868cdc7a 100644
--- a/src/core/lib/iomgr/tcp_windows.cc
+++ b/src/core/lib/iomgr/tcp_windows.cc
@@ -49,7 +49,7 @@
#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) {
int status;
@@ -124,7 +124,7 @@ static void tcp_free(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
#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)) {
+ 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,
@@ -137,7 +137,7 @@ static void tcp_unref(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
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,
diff --git a/src/core/lib/iomgr/tcp_windows.h b/src/core/lib/iomgr/tcp_windows.h
index aea5bab47d..28287e2795 100644
--- a/src/core/lib/iomgr/tcp_windows.h
+++ b/src/core/lib/iomgr/tcp_windows.h
@@ -29,13 +29,12 @@
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"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Create a tcp endpoint given a winsock handle.
* Takes ownership of the handle.
*/
@@ -45,8 +44,6 @@ grpc_endpoint* grpc_tcp_create(grpc_exec_ctx* exec_ctx, grpc_winsocket* socket,
grpc_error* grpc_tcp_prepare_socket(SOCKET sock);
-#ifdef __cplusplus
-}
#endif
#endif /* GRPC_CORE_LIB_IOMGR_TCP_WINDOWS_H */
diff --git a/src/core/lib/iomgr/time_averaged_stats.h b/src/core/lib/iomgr/time_averaged_stats.h
index d38ed272b6..8745f7fa13 100644
--- a/src/core/lib/iomgr/time_averaged_stats.h
+++ b/src/core/lib/iomgr/time_averaged_stats.h
@@ -19,10 +19,6 @@
#ifndef GRPC_CORE_LIB_IOMGR_TIME_AVERAGED_STATS_H
#define GRPC_CORE_LIB_IOMGR_TIME_AVERAGED_STATS_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* This tracks a time-decaying weighted average. It works by collecting
batches of samples and then mixing their average into a time-decaying
weighted mean. It is designed for batch operations where we do many adds
@@ -74,8 +70,4 @@ void grpc_time_averaged_stats_add_sample(grpc_time_averaged_stats* stats,
value. */
double grpc_time_averaged_stats_update_average(grpc_time_averaged_stats* stats);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_TIME_AVERAGED_STATS_H */
diff --git a/src/core/lib/iomgr/timer.h b/src/core/lib/iomgr/timer.h
index cd8334eceb..b9acce229e 100644
--- a/src/core/lib/iomgr/timer.h
+++ b/src/core/lib/iomgr/timer.h
@@ -32,10 +32,6 @@
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/iomgr.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_timer grpc_timer;
/* Initialize *timer. When expired or canceled, closure will be called with
@@ -106,8 +102,4 @@ void grpc_timer_consume_kick(void);
void grpc_kick_poller(void);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_TIMER_H */
diff --git a/src/core/lib/iomgr/timer_generic.cc b/src/core/lib/iomgr/timer_generic.cc
index 2333f180d4..fa95c43dbe 100644
--- a/src/core/lib/iomgr/timer_generic.cc
+++ b/src/core/lib/iomgr/timer_generic.cc
@@ -25,6 +25,7 @@
#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>
@@ -37,17 +38,12 @@
#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
-extern "C" {
-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
@@ -74,14 +70,16 @@ 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
@@ -90,7 +88,7 @@ static timer_shard* g_shard_queue[NUM_SHARDS];
#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] = {NULL};
+static grpc_timer* g_timer_ht[NUM_HASH_BUCKETS] = {nullptr};
static void init_timer_ht() {
for (int i = 0; i < NUM_HASH_BUCKETS; i++) {
@@ -103,7 +101,7 @@ static bool is_in_ht(grpc_timer* t) {
gpr_mu_lock(&g_hash_mu[i]);
grpc_timer* p = g_timer_ht[i];
- while (p != NULL && p != t) {
+ while (p != nullptr && p != t) {
p = p->hash_table_next;
}
gpr_mu_unlock(&g_hash_mu[i]);
@@ -117,7 +115,7 @@ static void add_to_ht(grpc_timer* t) {
gpr_mu_lock(&g_hash_mu[i]);
grpc_timer* p = g_timer_ht[i];
- while (p != NULL && p != t) {
+ while (p != nullptr && p != t) {
p = p->hash_table_next;
}
@@ -145,9 +143,9 @@ static void remove_from_ht(grpc_timer* t) {
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] != NULL) {
+ } else if (g_timer_ht[i] != nullptr) {
grpc_timer* p = g_timer_ht[i];
- while (p->hash_table_next != NULL && p->hash_table_next != t) {
+ while (p->hash_table_next != nullptr && p->hash_table_next != t) {
p = p->hash_table_next;
}
@@ -168,7 +166,7 @@ static void remove_from_ht(grpc_timer* t) {
abort();
}
- t->hash_table_next = NULL;
+ t->hash_table_next = nullptr;
}
/* If a timer is added to a timer shard (either heap or a list), it cannot
@@ -241,16 +239,19 @@ static gpr_atm compute_min_deadline(timer_shard* shard) {
void grpc_timer_list_init(grpc_exec_ctx* exec_ctx) {
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_shared_mutables.min_timer = grpc_exec_ctx_now(exec_ctx);
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++) {
+ 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,
@@ -267,17 +268,19 @@ void grpc_timer_list_init(grpc_exec_ctx* exec_ctx) {
}
void grpc_timer_list_shutdown(grpc_exec_ctx* exec_ctx) {
- int i;
+ size_t i;
run_some_expired_timers(
- exec_ctx, GPR_ATM_MAX, NULL,
+ exec_ctx, GPR_ATM_MAX, nullptr,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Timer list shutdown"));
- for (i = 0; i < NUM_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;
}
@@ -311,7 +314,7 @@ static void note_deadline_change(timer_shard* shard) {
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);
@@ -323,15 +326,15 @@ void grpc_timer_init_unset(grpc_timer* timer) { timer->pending = false; }
void grpc_timer_init(grpc_exec_ctx* exec_ctx, 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)];
+ timer_shard* shard = &g_shards[GPR_HASH_POINTER(timer, g_num_shards)];
timer->closure = closure;
timer->deadline = deadline;
#ifndef NDEBUG
- timer->hash_table_next = NULL;
+ timer->hash_table_next = nullptr;
#endif
- if (GRPC_TRACER_ON(grpc_timer_trace)) {
+ if (grpc_timer_trace.enabled()) {
gpr_log(GPR_DEBUG,
"TIMER %p: SET %" PRIdPTR " now %" PRIdPTR " call %p[%p]", timer,
deadline, grpc_exec_ctx_now(exec_ctx), closure, closure->cb);
@@ -367,7 +370,7 @@ void grpc_timer_init(grpc_exec_ctx* exec_ctx, grpc_timer* timer,
timer->heap_index = INVALID_HEAP_INDEX;
list_join(&shard->list, timer);
}
- if (GRPC_TRACER_ON(grpc_timer_trace)) {
+ if (grpc_timer_trace.enabled()) {
gpr_log(GPR_DEBUG,
" .. add to shard %d with queue_deadline_cap=%" PRIdPTR
" => is_first_timer=%s",
@@ -389,7 +392,7 @@ 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);
}
@@ -417,9 +420,9 @@ void grpc_timer_cancel(grpc_exec_ctx* exec_ctx, grpc_timer* timer) {
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");
}
@@ -460,7 +463,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);
}
@@ -468,7 +471,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);
}
@@ -485,23 +488,23 @@ static int refill_heap(timer_shard* shard, gpr_atm now) {
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)) {
+ 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);
@@ -526,7 +529,7 @@ static size_t pop_timers(grpc_exec_ctx* exec_ctx, timer_shard* shard,
}
*new_min_deadline = compute_min_deadline(shard);
gpr_mu_unlock(&shard->mu);
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG, " .. shard[%d] popped %" PRIdPTR,
(int)(shard - g_shards), n);
}
@@ -542,7 +545,7 @@ static grpc_timer_check_result run_some_expired_timers(grpc_exec_ctx* exec_ctx,
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;
}
@@ -550,7 +553,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);
@@ -568,7 +571,7 @@ static grpc_timer_check_result run_some_expired_timers(grpc_exec_ctx* exec_ctx,
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
@@ -610,10 +613,10 @@ grpc_timer_check_result grpc_timer_check(grpc_exec_ctx* exec_ctx,
mutable cacheline in the common case */
grpc_millis min_timer = gpr_tls_get(&g_last_seen_min_timer);
if (now < min_timer) {
- if (next != NULL) {
+ 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=%" PRIdPTR " min_timer=%" PRIdPTR, now,
min_timer);
@@ -627,9 +630,9 @@ grpc_timer_check_result grpc_timer_check(grpc_exec_ctx* exec_ctx,
: GRPC_ERROR_CREATE_FROM_STATIC_STRING("Shutting down timer system");
// tracing
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ if (grpc_timer_check_trace.enabled()) {
char* next_str;
- if (next == NULL) {
+ if (next == nullptr) {
next_str = gpr_strdup("NULL");
} else {
gpr_asprintf(&next_str, "%" PRIdPTR, *next);
@@ -645,9 +648,9 @@ grpc_timer_check_result grpc_timer_check(grpc_exec_ctx* exec_ctx,
grpc_timer_check_result r =
run_some_expired_timers(exec_ctx, now, next, shutdown_error);
// tracing
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ if (grpc_timer_check_trace.enabled()) {
char* next_str;
- if (next == NULL) {
+ if (next == nullptr) {
next_str = gpr_strdup("NULL");
} else {
gpr_asprintf(&next_str, "%" PRIdPTR, *next);
diff --git a/src/core/lib/iomgr/timer_heap.h b/src/core/lib/iomgr/timer_heap.h
index ae56e5a73e..436eef55a6 100644
--- a/src/core/lib/iomgr/timer_heap.h
+++ b/src/core/lib/iomgr/timer_heap.h
@@ -21,10 +21,6 @@
#include "src/core/lib/iomgr/timer.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct {
grpc_timer** timers;
uint32_t timer_count;
@@ -43,8 +39,4 @@ void grpc_timer_heap_pop(grpc_timer_heap* heap);
int grpc_timer_heap_is_empty(grpc_timer_heap* heap);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_TIMER_HEAP_H */
diff --git a/src/core/lib/iomgr/timer_manager.cc b/src/core/lib/iomgr/timer_manager.cc
index 16e9e7e707..87ed0e05dc 100644
--- a/src/core/lib/iomgr/timer_manager.cc
+++ b/src/core/lib/iomgr/timer_manager.cc
@@ -33,7 +33,7 @@ typedef struct completed_thread {
struct completed_thread* next;
} completed_thread;
-extern "C" grpc_tracer_flag grpc_timer_check_trace;
+extern grpc_core::TraceFlag grpc_timer_check_trace;
// global mutex
static gpr_mu g_mu;
@@ -62,11 +62,11 @@ static uint64_t g_timed_waiter_generation;
static void timer_thread(void* completed_thread_ptr);
static void gc_completed_threads(void) {
- if (g_completed_threads != NULL) {
+ if (g_completed_threads != nullptr) {
completed_thread* to_gc = g_completed_threads;
- g_completed_threads = NULL;
+ 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;
gpr_free(to_gc);
@@ -81,7 +81,7 @@ 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();
@@ -93,7 +93,7 @@ static void start_timer_thread_and_unlock(void) {
// 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);
}
@@ -115,7 +115,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);
@@ -123,7 +123,7 @@ static void run_some_timers(grpc_exec_ctx* exec_ctx) {
gpr_mu_unlock(&g_mu);
}
// without our lock, flush the exec_ctx
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG, "flush exec_ctx");
}
grpc_exec_ctx_flush(exec_ctx);
@@ -178,7 +178,7 @@ static bool wait_until(grpc_exec_ctx* exec_ctx, grpc_millis next) {
g_has_timed_waiter = true;
g_timed_waiter_deadline = next;
- if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
+ if (grpc_timer_check_trace.enabled()) {
grpc_millis wait_time = next - grpc_exec_ctx_now(exec_ctx);
gpr_log(GPR_DEBUG, "sleep for a %" PRIdPTR " milliseconds",
wait_time);
@@ -188,15 +188,14 @@ static bool wait_until(grpc_exec_ctx* exec_ctx, grpc_millis next) {
}
}
- if (GRPC_TRACER_ON(grpc_timer_check_trace) &&
- next == GRPC_MILLIS_INF_FUTURE) {
+ 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,
grpc_millis_to_timespec(next, GPR_CLOCK_REALTIME));
- 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);
@@ -225,6 +224,7 @@ static void timer_main_loop(grpc_exec_ctx* exec_ctx) {
for (;;) {
grpc_millis next = GRPC_MILLIS_INF_FUTURE;
grpc_exec_ctx_invalidate_now(exec_ctx);
+
// check timer state, updates next to the next time to run a check
switch (grpc_timer_check(exec_ctx, &next)) {
case GRPC_TIMERS_FIRED:
@@ -240,7 +240,7 @@ 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 = GRPC_MILLIS_INF_FUTURE;
@@ -266,7 +266,7 @@ 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");
}
}
@@ -275,7 +275,7 @@ 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);
+ GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, nullptr);
timer_main_loop(&exec_ctx);
grpc_exec_ctx_finish(&exec_ctx);
timer_thread_cleanup((completed_thread*)completed_thread_ptr);
@@ -299,7 +299,7 @@ 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 = GRPC_MILLIS_INF_FUTURE;
@@ -309,18 +309,18 @@ void grpc_timer_manager_init(void) {
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)) {
+ if (grpc_timer_check_trace.enabled()) {
gpr_log(GPR_DEBUG, "num timer threads: %d", g_thread_count);
}
gc_completed_threads();
diff --git a/src/core/lib/iomgr/timer_manager.h b/src/core/lib/iomgr/timer_manager.h
index 72960d6ffc..0ba502928a 100644
--- a/src/core/lib/iomgr/timer_manager.h
+++ b/src/core/lib/iomgr/timer_manager.h
@@ -21,10 +21,6 @@
#include <stdbool.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Timer Manager tries to keep one thread waiting for the next timeout at all
times */
@@ -38,8 +34,4 @@ void grpc_timer_manager_set_threading(bool enabled);
* disabled */
void grpc_timer_manager_tick(void);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_TIMER_MANAGER_H */
diff --git a/src/core/lib/iomgr/timer_uv.cc b/src/core/lib/iomgr/timer_uv.cc
index df40e54ae6..fac2026fa9 100644
--- a/src/core/lib/iomgr/timer_uv.cc
+++ b/src/core/lib/iomgr/timer_uv.cc
@@ -29,11 +29,8 @@
#include <uv.h>
-extern "C" {
-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); }
diff --git a/src/core/lib/iomgr/udp_server.cc b/src/core/lib/iomgr/udp_server.cc
index 8ce8b961ff..7b7d6946b1 100644
--- a/src/core/lib/iomgr/udp_server.cc
+++ b/src/core/lib/iomgr/udp_server.cc
@@ -47,6 +47,7 @@
#include "src/core/lib/channel/channel_args.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"
@@ -71,14 +72,22 @@ 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;
+ // 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 shutdown_fd_args {
- grpc_fd* fd;
+ grpc_udp_listener* sp;
gpr_mu* server_mu;
};
@@ -121,7 +130,7 @@ static grpc_socket_factory* get_socket_factory(const grpc_channel_args* args) {
return (grpc_socket_factory*)arg->value.pointer.p;
}
}
- return NULL;
+ return nullptr;
}
grpc_udp_server* grpc_udp_server_create(const grpc_channel_args* args) {
@@ -134,8 +143,8 @@ 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;
@@ -144,8 +153,17 @@ grpc_udp_server* grpc_udp_server_create(const grpc_channel_args* args) {
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;
+ 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(exec_ctx, 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(exec_ctx, sp->emfd, &sp->write_closure);
+ }
gpr_mu_unlock(shutdown_args->server_mu);
gpr_free(shutdown_args);
}
@@ -155,12 +173,13 @@ static void dummy_cb(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
}
static void finish_shutdown(grpc_exec_ctx* exec_ctx, grpc_udp_server* s) {
- if (s->shutdown_complete != NULL) {
+ if (s->shutdown_complete != nullptr) {
GRPC_CLOSURE_SCHED(exec_ctx, 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;
s->head = sp->next;
@@ -207,13 +226,14 @@ 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);
+ gpr_log(GPR_DEBUG, "Orphan fd %d", sp->fd);
sp->orphan_cb(exec_ctx, sp->emfd, &sp->orphan_fd_closure,
sp->server->user_data);
}
- grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL,
+ grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, nullptr,
false /* already_closed */, "udp_listener_shutdown");
}
gpr_mu_unlock(&s->mu);
@@ -233,13 +253,14 @@ 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;
+ args->sp = sp;
args->server_mu = &s->mu;
GRPC_CLOSURE_INIT(&sp->orphan_fd_closure, shutdown_fd, args,
grpc_schedule_on_exec_ctx);
@@ -256,7 +277,7 @@ void grpc_udp_server_destroy(grpc_exec_ctx* exec_ctx, grpc_udp_server* s,
static int bind_socket(grpc_socket_factory* socket_factory, int sockfd,
const grpc_resolved_address* addr) {
- return (socket_factory != NULL)
+ return (socket_factory != nullptr)
? grpc_socket_factory_bind(socket_factory, sockfd, addr)
: bind(sockfd, (struct sockaddr*)addr->addr, (socklen_t)addr->len);
}
@@ -329,6 +350,28 @@ error:
return -1;
}
+static void do_read(grpc_exec_ctx* exec_ctx, 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(exec_ctx, sp->emfd, sp->server->user_data)) {
+ /* There maybe more packets to read. Schedule read_more_cb_ closure to run
+ * after finishing this event loop. */
+ GRPC_CLOSURE_SCHED(exec_ctx, &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(exec_ctx, 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;
@@ -343,13 +386,51 @@ static void on_read(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
}
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(exec_ctx, sp->emfd, sp->server->user_data)) {
+ /* 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(exec_ctx, &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(exec_ctx, sp->emfd, &sp->read_closure);
+ }
+ gpr_mu_unlock(&sp->server->mu);
+}
+
+// Wrapper of grpc_fd_notify_on_write() with a grpc_closure callback interface.
+void fd_notify_on_write_wrapper(grpc_exec_ctx* exec_ctx, 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(exec_ctx, sp->emfd, &sp->write_closure);
+ sp->notify_on_write_armed = true;
+ }
+ 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);
+static void do_write(grpc_exec_ctx* exec_ctx, 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(exec_ctx, 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(exec_ctx, sp->emfd, sp->server->user_data,
+ &sp->notify_on_write_closure);
+ }
gpr_mu_unlock(&sp->server->mu);
}
@@ -367,12 +448,11 @@ static void on_write(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
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(exec_ctx, &sp->do_write_closure, GRPC_ERROR_NONE);
gpr_mu_unlock(&sp->server->mu);
}
@@ -394,8 +474,8 @@ static int add_socket_to_server(grpc_udp_server* s, int fd,
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->next = nullptr;
+ if (s->head == nullptr) {
s->head = sp;
} else {
s->tail->next = sp;
@@ -409,6 +489,7 @@ static int add_socket_to_server(grpc_udp_server* s, int fd,
sp->write_cb = write_cb;
sp->orphan_cb = orphan_cb;
sp->orphan_notified = false;
+ sp->already_shutdown = false;
GPR_ASSERT(sp->emfd);
gpr_mu_unlock(&s->mu);
gpr_free(name);
@@ -431,7 +512,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;
@@ -508,6 +589,7 @@ 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;
}
@@ -522,7 +604,7 @@ void grpc_udp_server_start(grpc_exec_ctx* exec_ctx, grpc_udp_server* s,
s->user_data = user_data;
sp = s->head;
- while (sp != NULL) {
+ while (sp != nullptr) {
for (i = 0; i < pollset_count; i++) {
grpc_pollset_add_fd(exec_ctx, pollsets[i], sp->emfd);
}
@@ -532,6 +614,7 @@ void grpc_udp_server_start(grpc_exec_ctx* exec_ctx, grpc_udp_server* s,
GRPC_CLOSURE_INIT(&sp->write_closure, on_write, sp,
grpc_schedule_on_exec_ctx);
+ sp->notify_on_write_armed = true;
grpc_fd_notify_on_write(exec_ctx, sp->emfd, &sp->write_closure);
/* Registered for both read and write callbacks: increment active_ports
diff --git a/src/core/lib/iomgr/udp_server.h b/src/core/lib/iomgr/udp_server.h
index bca0f049fb..1bd6922de6 100644
--- a/src/core/lib/iomgr/udp_server.h
+++ b/src/core/lib/iomgr/udp_server.h
@@ -23,10 +23,6 @@
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/resolve_address.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Forward decl of struct grpc_server */
/* This is not typedef'ed to avoid a typedef-redefinition error */
struct grpc_server;
@@ -34,13 +30,16 @@ 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,
+/* 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_exec_ctx* exec_ctx, grpc_fd* emfd,
void* user_data);
-/* Called when the socket is writeable. */
+/* 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_exec_ctx* exec_ctx, grpc_fd* emfd,
- void* user_data);
+ 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,
@@ -77,8 +76,4 @@ int grpc_udp_server_add_port(grpc_udp_server* s,
void grpc_udp_server_destroy(grpc_exec_ctx* exec_ctx, grpc_udp_server* server,
grpc_closure* on_done);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_UDP_SERVER_H */
diff --git a/src/core/lib/iomgr/unix_sockets_posix.cc b/src/core/lib/iomgr/unix_sockets_posix.cc
index 5d3689c38f..af862c00dc 100644
--- a/src/core/lib/iomgr/unix_sockets_posix.cc
+++ b/src/core/lib/iomgr/unix_sockets_posix.cc
@@ -39,7 +39,8 @@ void grpc_create_socketpair_if_unix(int sv[2]) {
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) {
+ if (strlen(name) >
+ GPR_ARRAY_SIZE(((struct sockaddr_un*)nullptr)->sun_path) - 1) {
char* err_msg;
grpc_error* err;
gpr_asprintf(&err_msg,
@@ -56,7 +57,7 @@ grpc_error* grpc_resolve_unix_domain_address(const char* name,
(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;
}
@@ -84,7 +85,7 @@ 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;
diff --git a/src/core/lib/iomgr/unix_sockets_posix.h b/src/core/lib/iomgr/unix_sockets_posix.h
index be3c33d9c2..1c079e6e76 100644
--- a/src/core/lib/iomgr/unix_sockets_posix.h
+++ b/src/core/lib/iomgr/unix_sockets_posix.h
@@ -25,10 +25,6 @@
#include "src/core/lib/iomgr/resolve_address.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
void grpc_create_socketpair_if_unix(int sv[2]);
grpc_error* grpc_resolve_unix_domain_address(
@@ -42,8 +38,4 @@ void grpc_unlink_if_unix_domain_socket(
char* grpc_sockaddr_to_uri_unix_if_possible(
const grpc_resolved_address* resolved_addr);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_UNIX_SOCKETS_POSIX_H */
diff --git a/src/core/lib/iomgr/wakeup_fd_cv.cc b/src/core/lib/iomgr/wakeup_fd_cv.cc
index 268e0175dd..5c1f16d3fc 100644
--- a/src/core/lib/iomgr/wakeup_fd_cv.cc
+++ b/src/core/lib/iomgr/wakeup_fd_cv.cc
@@ -46,7 +46,7 @@ static grpc_error* cv_fd_init(grpc_wakeup_fd* fd_info) {
(fd_node*)gpr_realloc(g_cvfds.cvfds, sizeof(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;
diff --git a/src/core/lib/iomgr/wakeup_fd_cv.h b/src/core/lib/iomgr/wakeup_fd_cv.h
index dcd7bdb560..017e41bfa8 100644
--- a/src/core/lib/iomgr/wakeup_fd_cv.h
+++ b/src/core/lib/iomgr/wakeup_fd_cv.h
@@ -40,10 +40,6 @@
#define GRPC_FD_TO_IDX(fd) (-(fd)-1)
#define GRPC_IDX_TO_FD(idx) (-(idx)-1)
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct cv_node {
gpr_cv* cv;
struct cv_node* next;
@@ -68,8 +64,4 @@ typedef struct cv_fd_table {
extern const grpc_wakeup_fd_vtable grpc_cv_wakeup_fd_vtable;
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_WAKEUP_FD_CV_H */
diff --git a/src/core/lib/iomgr/wakeup_fd_pipe.h b/src/core/lib/iomgr/wakeup_fd_pipe.h
index 9bbb5e2ff7..326a0c4e01 100644
--- a/src/core/lib/iomgr/wakeup_fd_pipe.h
+++ b/src/core/lib/iomgr/wakeup_fd_pipe.h
@@ -21,14 +21,6 @@
#include "src/core/lib/iomgr/wakeup_fd_posix.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
extern const grpc_wakeup_fd_vtable grpc_pipe_wakeup_fd_vtable;
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_WAKEUP_FD_PIPE_H */
diff --git a/src/core/lib/iomgr/wakeup_fd_posix.cc b/src/core/lib/iomgr/wakeup_fd_posix.cc
index dcad61b097..e8de208a25 100644
--- a/src/core/lib/iomgr/wakeup_fd_posix.cc
+++ b/src/core/lib/iomgr/wakeup_fd_posix.cc
@@ -25,7 +25,7 @@
#include "src/core/lib/iomgr/wakeup_fd_pipe.h"
#include "src/core/lib/iomgr/wakeup_fd_posix.h"
-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;
@@ -45,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; }
diff --git a/src/core/lib/iomgr/wakeup_fd_posix.h b/src/core/lib/iomgr/wakeup_fd_posix.h
index ae7849f98c..a9584d0d48 100644
--- a/src/core/lib/iomgr/wakeup_fd_posix.h
+++ b/src/core/lib/iomgr/wakeup_fd_posix.h
@@ -49,10 +49,6 @@
#include "src/core/lib/iomgr/error.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
void grpc_wakeup_fd_global_init(void);
void grpc_wakeup_fd_global_destroy(void);
@@ -95,8 +91,4 @@ void grpc_wakeup_fd_destroy(grpc_wakeup_fd* fd_info);
* wakeup_fd_nospecial.c if no such implementation exists. */
extern const grpc_wakeup_fd_vtable grpc_specialized_wakeup_fd_vtable;
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_IOMGR_WAKEUP_FD_POSIX_H */
diff --git a/src/core/lib/json/json.h b/src/core/lib/json/json.h
index c9fdec4ecb..bbd43025eb 100644
--- a/src/core/lib/json/json.h
+++ b/src/core/lib/json/json.h
@@ -23,10 +23,6 @@
#include "src/core/lib/json/json_common.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* A tree-like structure to hold json values. The key and value pointers
* are not owned by it.
*/
@@ -74,8 +70,4 @@ char* grpc_json_dump_to_string(grpc_json* json, int indent);
grpc_json* grpc_json_create(grpc_json_type type);
void grpc_json_destroy(grpc_json* json);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_JSON_JSON_H */
diff --git a/src/core/lib/json/json_reader.h b/src/core/lib/json/json_reader.h
index 2636d2b1d9..03185cb2b6 100644
--- a/src/core/lib/json/json_reader.h
+++ b/src/core/lib/json/json_reader.h
@@ -22,10 +22,6 @@
#include <grpc/support/port_platform.h>
#include "src/core/lib/json/json_common.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef enum {
GRPC_JSON_STATE_OBJECT_KEY_BEGIN,
GRPC_JSON_STATE_OBJECT_KEY_STRING,
@@ -146,8 +142,4 @@ void grpc_json_reader_init(grpc_json_reader* reader,
*/
int grpc_json_reader_is_complete(grpc_json_reader* reader);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_JSON_JSON_READER_H */
diff --git a/src/core/lib/json/json_string.cc b/src/core/lib/json/json_string.cc
index 8674d72b7e..a339eec81b 100644
--- a/src/core/lib/json/json_string.cc
+++ b/src/core/lib/json/json_string.cc
@@ -201,7 +201,7 @@ static void json_reader_container_begins(void* userdata, grpc_json_type type) {
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
@@ -280,13 +280,13 @@ static grpc_json_reader_vtable reader_vtable = {
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.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;
@@ -352,7 +352,7 @@ 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.h b/src/core/lib/json/json_writer.h
index 93eeb2031b..a4f2d4daeb 100644
--- a/src/core/lib/json/json_writer.h
+++ b/src/core/lib/json/json_writer.h
@@ -35,10 +35,6 @@
#include "src/core/lib/json/json_common.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_json_writer_vtable {
/* Adds a character to the output stream. */
void (*output_char)(void* userdata, char);
@@ -83,8 +79,4 @@ void grpc_json_writer_value_raw_with_len(grpc_json_writer* writer,
void grpc_json_writer_value_string(grpc_json_writer* writer,
const char* string);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_JSON_JSON_WRITER_H */
diff --git a/src/core/lib/profiling/basic_timers.cc b/src/core/lib/profiling/basic_timers.cc
index 3ec6280e6b..87dd4ab120 100644
--- a/src/core/lib/profiling/basic_timers.cc
+++ b/src/core/lib/profiling/basic_timers.cc
@@ -203,7 +203,8 @@ void gpr_timers_set_log_filename(const char* 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);
}
diff --git a/src/core/lib/profiling/timers.h b/src/core/lib/profiling/timers.h
index 8b6c254c21..9f11f771e6 100644
--- a/src/core/lib/profiling/timers.h
+++ b/src/core/lib/profiling/timers.h
@@ -19,10 +19,6 @@
#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);
@@ -84,9 +80,6 @@ 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 {
@@ -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.cc b/src/core/lib/security/context/security_context.cc
index b2b90e86e0..19c6148e43 100644
--- a/src/core/lib/security/context/security_context.cc
+++ b/src/core/lib/security/context/security_context.cc
@@ -29,17 +29,15 @@
#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_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)) {
@@ -48,7 +46,7 @@ grpc_call_error grpc_call_set_credentials(grpc_call* call,
}
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,
@@ -64,7 +62,7 @@ grpc_call_error grpc_call_set_credentials(grpc_call* call,
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,
@@ -91,7 +89,7 @@ void grpc_client_security_context_destroy(void* ctx) {
grpc_client_security_context* c = (grpc_client_security_context*)ctx;
grpc_call_credentials_unref(&exec_ctx, 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);
@@ -108,7 +106,7 @@ grpc_server_security_context* grpc_server_security_context_create(void) {
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);
@@ -116,13 +114,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 =
(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;
@@ -134,8 +132,8 @@ grpc_auth_context* grpc_auth_context_create(grpc_auth_context* chained) {
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)) {
+ 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,
@@ -152,8 +150,8 @@ grpc_auth_context* grpc_auth_context_ref(grpc_auth_context* 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)) {
+ 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,
@@ -166,7 +164,7 @@ void grpc_auth_context_unref(grpc_auth_context* ctx) {
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]);
}
@@ -191,9 +189,9 @@ int grpc_auth_context_set_peer_identity_property_name(grpc_auth_context* ctx,
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;
@@ -202,14 +200,14 @@ int grpc_auth_context_set_peer_identity_property_name(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) {
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;
}
@@ -217,18 +215,18 @@ grpc_auth_property_iterator grpc_auth_context_property_iterator(
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);
+ GPR_ASSERT(prop->name != nullptr);
if (strcmp(it->name, prop->name) == 0) {
return prop;
}
@@ -243,7 +241,7 @@ grpc_auth_property_iterator grpc_auth_context_find_properties_by_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;
@@ -252,7 +250,7 @@ grpc_auth_property_iterator grpc_auth_context_find_properties_by_name(
grpc_auth_property_iterator grpc_auth_context_peer_identity(
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);
}
@@ -326,11 +324,11 @@ grpc_arg grpc_auth_context_to_arg(grpc_auth_context* p) {
}
grpc_auth_context* grpc_auth_context_from_arg(const grpc_arg* arg) {
- if (strcmp(arg->key, GRPC_AUTH_CONTEXT_ARG) != 0) return NULL;
+ 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 (grpc_auth_context*)arg->value.pointer.p;
}
@@ -338,10 +336,10 @@ 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) {
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;
+ 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 4f049c4a3b..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 ---
@@ -116,8 +110,4 @@ 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
-
#endif /* GRPC_CORE_LIB_SECURITY_CONTEXT_SECURITY_CONTEXT_H */
diff --git a/src/core/lib/security/credentials/composite/composite_credentials.cc b/src/core/lib/security/credentials/composite/composite_credentials.cc
index 5eb7f9d09e..93dd721240 100644
--- a/src/core/lib/security/credentials/composite/composite_credentials.cc
+++ b/src/core/lib/security/credentials/composite/composite_credentials.cc
@@ -144,9 +144,9 @@ grpc_call_credentials* grpc_composite_call_credentials_create(
"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);
+ 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;
@@ -183,19 +183,19 @@ grpc_call_credentials* grpc_credentials_contains_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 =
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. -- */
@@ -217,14 +217,15 @@ static grpc_security_status composite_channel_create_security_connector(
(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) {
+ if (call_creds != nullptr) {
grpc_call_credentials* composite_call_creds =
- grpc_composite_call_credentials_create(c->call_creds, call_creds, NULL);
+ 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);
@@ -253,7 +254,8 @@ grpc_channel_credentials* grpc_composite_channel_credentials_create(
void* reserved) {
grpc_composite_channel_credentials* c =
(grpc_composite_channel_credentials*)gpr_zalloc(sizeof(*c));
- GPR_ASSERT(channel_creds != NULL && call_creds != NULL && reserved == NULL);
+ 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 efb5f4f0c4..11990d38ff 100644
--- a/src/core/lib/security/credentials/composite/composite_credentials.h
+++ b/src/core/lib/security/credentials/composite/composite_credentials.h
@@ -21,10 +21,6 @@
#include "src/core/lib/security/credentials/credentials.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct {
grpc_call_credentials** creds_array;
size_t num_creds;
@@ -57,9 +53,5 @@ typedef struct {
grpc_call_credentials_array inner;
} grpc_composite_call_credentials;
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_COMPOSITE_COMPOSITE_CREDENTIALS_H \
*/
diff --git a/src/core/lib/security/credentials/credentials.cc b/src/core/lib/security/credentials/credentials.cc
index e60d022f1b..90576e69b9 100644
--- a/src/core/lib/security/credentials/credentials.cc
+++ b/src/core/lib/security/credentials/credentials.cc
@@ -55,16 +55,16 @@ void grpc_credentials_metadata_request_destroy(
grpc_channel_credentials* grpc_channel_credentials_ref(
grpc_channel_credentials* creds) {
- if (creds == NULL) return NULL;
+ if (creds == nullptr) return nullptr;
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 (creds == nullptr) return;
if (gpr_unref(&creds->refcount)) {
- if (creds->vtable->destruct != NULL) {
+ if (creds->vtable->destruct != nullptr) {
creds->vtable->destruct(exec_ctx, creds);
}
gpr_free(creds);
@@ -79,16 +79,16 @@ void grpc_channel_credentials_release(grpc_channel_credentials* creds) {
}
grpc_call_credentials* grpc_call_credentials_ref(grpc_call_credentials* creds) {
- if (creds == NULL) return NULL;
+ if (creds == nullptr) return nullptr;
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 (creds == nullptr) return;
if (gpr_unref(&creds->refcount)) {
- if (creds->vtable->destruct != NULL) {
+ if (creds->vtable->destruct != nullptr) {
creds->vtable->destruct(exec_ctx, creds);
}
gpr_free(creds);
@@ -107,7 +107,7 @@ bool grpc_call_credentials_get_request_metadata(
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) {
+ if (creds == nullptr || creds->vtable->get_request_metadata == nullptr) {
return true;
}
return creds->vtable->get_request_metadata(
@@ -117,7 +117,8 @@ bool grpc_call_credentials_get_request_metadata(
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) {
+ if (creds == nullptr ||
+ creds->vtable->cancel_get_request_metadata == nullptr) {
return;
}
creds->vtable->cancel_get_request_metadata(exec_ctx, creds, md_array, error);
@@ -127,20 +128,20 @@ 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) {
+ *new_args = nullptr;
+ if (channel_creds == nullptr) {
return GRPC_SECURITY_ERROR;
}
- GPR_ASSERT(channel_creds->vtable->create_security_connector != NULL);
+ GPR_ASSERT(channel_creds->vtable->create_security_connector != nullptr);
return channel_creds->vtable->create_security_connector(
- exec_ctx, channel_creds, NULL, target, args, sc, new_args);
+ exec_ctx, 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 != NULL && channel_creds->vtable != NULL &&
- channel_creds->vtable->duplicate_without_call_credentials != NULL) {
+ 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 {
@@ -171,11 +172,11 @@ grpc_arg grpc_channel_credentials_to_arg(
grpc_channel_credentials* grpc_channel_credentials_from_arg(
const grpc_arg* arg) {
- if (strcmp(arg->key, GRPC_ARG_CHANNEL_CREDENTIALS)) return NULL;
+ 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 NULL;
+ return nullptr;
}
return (grpc_channel_credentials*)arg->value.pointer.p;
}
@@ -183,30 +184,31 @@ grpc_channel_credentials* grpc_channel_credentials_from_arg(
grpc_channel_credentials* grpc_channel_credentials_find_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_channel_credentials* credentials =
grpc_channel_credentials_from_arg(&args->args[i]);
- if (credentials != NULL) return credentials;
+ if (credentials != nullptr) return credentials;
}
- return NULL;
+ return nullptr;
}
grpc_server_credentials* grpc_server_credentials_ref(
grpc_server_credentials* creds) {
- if (creds == NULL) return NULL;
+ if (creds == nullptr) return nullptr;
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 (creds == nullptr) return;
if (gpr_unref(&creds->refcount)) {
- if (creds->vtable->destruct != NULL) {
+ if (creds->vtable->destruct != nullptr) {
creds->vtable->destruct(exec_ctx, creds);
}
- if (creds->processor.destroy != NULL && creds->processor.state != NULL) {
+ if (creds->processor.destroy != nullptr &&
+ creds->processor.state != nullptr) {
creds->processor.destroy(creds->processor.state);
}
gpr_free(creds);
@@ -223,7 +225,7 @@ void grpc_server_credentials_release(grpc_server_credentials* creds) {
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) {
+ if (creds == nullptr || creds->vtable->create_security_connector == nullptr) {
gpr_log(GPR_ERROR, "Server credentials cannot create security context.");
return GRPC_SECURITY_ERROR;
}
@@ -237,8 +239,9 @@ void 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) {
+ if (creds == nullptr) return;
+ if (creds->processor.destroy != nullptr &&
+ creds->processor.state != nullptr) {
creds->processor.destroy(creds->processor.state);
}
creds->processor = processor;
@@ -267,11 +270,11 @@ grpc_arg grpc_server_credentials_to_arg(grpc_server_credentials* p) {
}
grpc_server_credentials* grpc_server_credentials_from_arg(const grpc_arg* arg) {
- if (strcmp(arg->key, GRPC_SERVER_CREDENTIALS_ARG) != 0) return NULL;
+ 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 NULL;
+ return nullptr;
}
return (grpc_server_credentials*)arg->value.pointer.p;
}
@@ -279,11 +282,11 @@ 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) {
size_t i;
- if (args == NULL) return NULL;
+ 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 != NULL) return p;
+ if (p != nullptr) return p;
}
- return NULL;
+ return nullptr;
}
diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h
index c65b9660ea..bc1bd11c77 100644
--- a/src/core/lib/security/credentials/credentials.h
+++ b/src/core/lib/security/credentials/credentials.h
@@ -29,10 +29,6 @@
#include "src/core/lib/iomgr/polling_entity.h"
#include "src/core/lib/security/transport/security_connector.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
struct grpc_http_response;
/* --- Constants. --- */
@@ -256,8 +252,4 @@ grpc_credentials_metadata_request* grpc_credentials_metadata_request_create(
void grpc_credentials_metadata_request_destroy(
grpc_exec_ctx* exec_ctx, grpc_credentials_metadata_request* r);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_CREDENTIALS_H */
diff --git a/src/core/lib/security/credentials/fake/fake_credentials.cc b/src/core/lib/security/credentials/fake/fake_credentials.cc
index 17700f5651..a535a317ee 100644
--- a/src/core/lib/security/credentials/fake/fake_credentials.cc
+++ b/src/core/lib/security/credentials/fake/fake_credentials.cc
@@ -53,11 +53,11 @@ fake_transport_security_server_create_security_connector(
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(
void) {
@@ -89,11 +89,11 @@ 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. -- */
diff --git a/src/core/lib/security/credentials/fake/fake_credentials.h b/src/core/lib/security/credentials/fake/fake_credentials.h
index b8b58cc8fd..0e9ff155d8 100644
--- a/src/core/lib/security/credentials/fake/fake_credentials.h
+++ b/src/core/lib/security/credentials/fake/fake_credentials.h
@@ -21,10 +21,6 @@
#include "src/core/lib/security/credentials/credentials.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* -- Fake transport security credentials. -- */
/* Creates a fake transport security credentials object for testing. */
@@ -60,8 +56,4 @@ typedef struct {
bool is_async;
} grpc_md_only_test_credentials;
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_FAKE_FAKE_CREDENTIALS_H */
diff --git a/src/core/lib/security/credentials/google_default/credentials_generic.cc b/src/core/lib/security/credentials/google_default/credentials_generic.cc
index c2a336ff07..58ee080cf3 100644
--- a/src/core/lib/security/credentials/google_default/credentials_generic.cc
+++ b/src/core/lib/security/credentials/google_default/credentials_generic.cc
@@ -26,12 +26,12 @@
#include "src/core/lib/support/string.h"
char* grpc_get_well_known_google_credentials_file_path_impl(void) {
- char* result = NULL;
+ char* result = nullptr;
char* base = gpr_getenv(GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR);
- if (base == NULL) {
+ if (base == nullptr) {
gpr_log(GPR_ERROR, "Could not get " GRPC_GOOGLE_CREDENTIALS_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.cc b/src/core/lib/security/credentials/google_default/google_default_credentials.cc
index 3ce19e9a05..f586c7b604 100644
--- a/src/core/lib/security/credentials/google_default/google_default_credentials.cc
+++ b/src/core/lib/security/credentials/google_default/google_default_credentials.cc
@@ -43,7 +43,7 @@
/* -- 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;
@@ -80,8 +80,8 @@ 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(
+ exec_ctx, grpc_polling_entity_pollset(&detector->pollent), nullptr));
gpr_mu_unlock(g_polling_mu);
}
@@ -128,7 +128,7 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx* exec_ctx) {
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,
@@ -147,7 +147,7 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx* exec_ctx) {
grpc_pollset_shutdown(exec_ctx,
grpc_polling_entity_pollset(&detector.pollent),
&destroy_closure);
- g_polling_mu = NULL;
+ g_polling_mu = nullptr;
grpc_exec_ctx_flush(exec_ctx);
gpr_free(grpc_polling_entity_pollset(&detector.pollent));
@@ -159,13 +159,13 @@ 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;
+ 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) {
+ if (creds_path == nullptr) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("creds_path unset");
goto end;
}
@@ -175,7 +175,7 @@ static grpc_error* create_default_creds_from_path(
}
json = grpc_json_parse_string_with_len(
(char*)GRPC_SLICE_START_PTR(creds_data), GRPC_SLICE_LENGTH(creds_data));
- if (json == NULL) {
+ 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));
@@ -188,7 +188,7 @@ static grpc_error* create_default_creds_from_path(
result =
grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
exec_ctx, key, grpc_max_auth_token_lifetime());
- if (result == NULL) {
+ if (result == nullptr) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"grpc_service_account_jwt_access_credentials_create_from_auth_json_"
"key failed");
@@ -201,7 +201,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,17 +210,17 @@ 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);
+ GPR_ASSERT((result == nullptr) + (error == GRPC_ERROR_NONE) == 1);
+ if (creds_path != nullptr) gpr_free(creds_path);
grpc_slice_unref_internal(exec_ctx, creds_data);
- if (json != NULL) grpc_json_destroy(json);
+ 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_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;
@@ -232,7 +232,7 @@ 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;
}
@@ -257,8 +257,8 @@ grpc_channel_credentials* grpc_google_default_credentials_create(void) {
is_stack_running_on_compute_engine(&exec_ctx);
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,17 +267,17 @@ 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_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);
+ nullptr));
+ GPR_ASSERT(default_credentials != nullptr);
grpc_channel_credentials_unref(&exec_ctx, ssl_creds);
grpc_call_credentials_unref(&exec_ctx, call_creds);
result = default_credentials;
@@ -286,7 +286,7 @@ end:
}
}
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);
@@ -299,9 +299,9 @@ void grpc_flush_cached_google_default_credentials(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_once_init(&g_once, init_default_credentials);
gpr_mu_lock(&g_state_mu);
- if (default_credentials != NULL) {
+ if (default_credentials != nullptr) {
grpc_channel_credentials_unref(&exec_ctx, default_credentials);
- default_credentials = NULL;
+ default_credentials = nullptr;
}
compute_engine_detection_done = 0;
gpr_mu_unlock(&g_state_mu);
@@ -310,10 +310,10 @@ void grpc_flush_cached_google_default_credentials(void) {
/* -- 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();
+ 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 a0f8dc954e..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
@@ -23,10 +23,6 @@
#include "src/core/lib/security/credentials/credentials.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#define GRPC_GOOGLE_CLOUD_SDK_CONFIG_DIRECTORY "gcloud"
#define GRPC_GOOGLE_WELL_KNOWN_CREDENTIALS_FILE \
"application_default_credentials.json"
@@ -45,9 +41,5 @@ extern "C" {
void grpc_flush_cached_google_default_credentials(void);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_GOOGLE_DEFAULT_GOOGLE_DEFAULT_CREDENTIALS_H \
*/
diff --git a/src/core/lib/security/credentials/iam/iam_credentials.cc b/src/core/lib/security/credentials/iam/iam_credentials.cc
index 7410294a20..1741bf3068 100644
--- a/src/core/lib/security/credentials/iam/iam_credentials.cc
+++ b/src/core/lib/security/credentials/iam/iam_credentials.cc
@@ -61,9 +61,9 @@ grpc_call_credentials* grpc_google_iam_credentials_create(
"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);
+ 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;
diff --git a/src/core/lib/security/credentials/jwt/json_token.cc b/src/core/lib/security/credentials/jwt/json_token.cc
index e195ec7509..a152ddcaaf 100644
--- a/src/core/lib/security/credentials/jwt/json_token.cc
+++ b/src/core/lib/security/credentials/jwt/json_token.cc
@@ -52,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) &&
+ 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 result;
- BIO* bio = NULL;
+ 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;
}
@@ -90,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());
@@ -99,15 +100,16 @@ 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, (void*)"");
- 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;
}
@@ -117,29 +119,29 @@ grpc_auth_json_key grpc_auth_json_key_create_from_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;
+ 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;
}
}
@@ -159,11 +161,11 @@ static grpc_json* create_child(grpc_json* brother, grpc_json* parent,
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;
+ 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);
@@ -178,9 +180,9 @@ 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;
+ 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];
@@ -192,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. */
@@ -237,7 +239,7 @@ const EVP_MD* openssl_digest_from_algorithm(const char* algorithm) {
return EVP_sha256();
} else {
gpr_log(GPR_ERROR, "Unknown algorithm %s.", algorithm);
- return NULL;
+ return nullptr;
}
}
@@ -245,19 +247,19 @@ 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_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;
}
@@ -265,7 +267,7 @@ 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;
}
@@ -277,16 +279,16 @@ 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) {
+ if (g_jwt_encode_and_sign_override != nullptr) {
return g_jwt_encode_and_sign_override(json_key, audience, token_lifetime,
scope);
} else {
@@ -295,9 +297,9 @@ char* grpc_jwt_encode_and_sign(const grpc_auth_json_key* json_key,
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) {
+ 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 b2c3c09c25..9b774882b7 100644
--- a/src/core/lib/security/credentials/jwt/json_token.h
+++ b/src/core/lib/security/credentials/jwt/json_token.h
@@ -19,10 +19,6 @@
#ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JSON_TOKEN_H
#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JSON_TOKEN_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#include <grpc/slice.h>
#include <openssl/rsa.h>
@@ -74,8 +70,4 @@ typedef char* (*grpc_jwt_encode_and_sign_override)(
void grpc_jwt_encode_and_sign_set_override(
grpc_jwt_encode_and_sign_override func);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JSON_TOKEN_H */
diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.cc b/src/core/lib/security/credentials/jwt/jwt_credentials.cc
index e8baa7e053..77163c0cc1 100644
--- a/src/core/lib/security/credentials/jwt/jwt_credentials.cc
+++ b/src/core/lib/security/credentials/jwt/jwt_credentials.cc
@@ -34,9 +34,9 @@ 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);
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);
}
@@ -66,7 +66,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,
@@ -78,13 +78,13 @@ 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 = grpc_jwt_encode_and_sign(&c->key, context.service_url,
- c->jwt_lifetime, NULL);
- if (jwt != NULL) {
+ c->jwt_lifetime, nullptr);
+ if (jwt != nullptr) {
char* md_value;
gpr_asprintf(&md_value, "Bearer %s", jwt);
gpr_free(jwt);
@@ -126,7 +126,7 @@ grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
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 = (grpc_service_account_jwt_access_credentials*)gpr_zalloc(
sizeof(grpc_service_account_jwt_access_credentials));
@@ -172,7 +172,7 @@ static char* redact_private_key(const char* json_key) {
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)) {
+ if (grpc_api_trace.enabled()) {
char* clean_json = redact_private_key(json_key);
gpr_log(GPR_INFO,
"grpc_service_account_jwt_access_credentials_create("
@@ -185,7 +185,7 @@ grpc_call_credentials* grpc_service_account_jwt_access_credentials_create(
(int)token_lifetime.clock_type, reserved);
gpr_free(clean_json);
}
- GPR_ASSERT(reserved == NULL);
+ GPR_ASSERT(reserved == nullptr);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_call_credentials* creds =
grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.h b/src/core/lib/security/credentials/jwt/jwt_credentials.h
index d554613eed..85f068aac8 100644
--- a/src/core/lib/security/credentials/jwt/jwt_credentials.h
+++ b/src/core/lib/security/credentials/jwt/jwt_credentials.h
@@ -22,10 +22,6 @@
#include "src/core/lib/security/credentials/credentials.h"
#include "src/core/lib/security/credentials/jwt/json_token.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct {
grpc_call_credentials base;
@@ -49,8 +45,4 @@ 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);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_CREDENTIALS_H */
diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.cc b/src/core/lib/security/credentials/jwt/jwt_verifier.cc
index 0fce5f5555..3709b83c4e 100644
--- a/src/core/lib/security/credentials/jwt/jwt_verifier.cc
+++ b/src/core/lib/security/credentials/jwt/jwt_verifier.cc
@@ -70,7 +70,7 @@ 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;
}
}
@@ -82,11 +82,11 @@ static grpc_json* parse_json_part_from_jwt(grpc_exec_ctx* exec_ctx,
*buffer = grpc_base64_decode_with_len(exec_ctx, 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),
GRPC_SLICE_LENGTH(*buffer));
- if (json == NULL) {
+ if (json == nullptr) {
grpc_slice_unref_internal(exec_ctx, *buffer);
gpr_log(GPR_ERROR, "JSON parsing error.");
}
@@ -97,7 +97,7 @@ 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;
}
@@ -109,7 +109,7 @@ static gpr_timespec validate_time_field(const grpc_json* json,
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;
}
@@ -134,27 +134,27 @@ static jose_header* jose_header_from_json(grpc_exec_ctx* exec_ctx,
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;
}
@@ -165,7 +165,7 @@ 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;
+ return nullptr;
}
/* --- JWT claims. see http://tools.ietf.org/html/rfc7519#section-4.1 */
@@ -191,42 +191,42 @@ void grpc_jwt_claims_destroy(grpc_exec_ctx* exec_ctx, grpc_jwt_claims* claims) {
}
const grpc_json* grpc_jwt_claims_json(const grpc_jwt_claims* claims) {
- if (claims == NULL) return NULL;
+ if (claims == nullptr) return nullptr;
return claims->json;
}
const char* grpc_jwt_claims_subject(const grpc_jwt_claims* claims) {
- if (claims == NULL) return NULL;
+ if (claims == nullptr) return nullptr;
return claims->sub;
}
const char* grpc_jwt_claims_issuer(const grpc_jwt_claims* claims) {
- if (claims == NULL) return NULL;
+ if (claims == nullptr) return nullptr;
return claims->iss;
}
const char* grpc_jwt_claims_id(const grpc_jwt_claims* claims) {
- if (claims == NULL) return NULL;
+ if (claims == nullptr) return nullptr;
return claims->jti;
}
const char* grpc_jwt_claims_audience(const grpc_jwt_claims* claims) {
- if (claims == NULL) return NULL;
+ 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);
+ 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);
+ 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);
+ if (claims == nullptr) return gpr_inf_past(GPR_CLOCK_REALTIME);
return claims->nbf;
}
@@ -244,19 +244,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)
@@ -275,7 +275,7 @@ grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_exec_ctx* exec_ctx,
error:
grpc_jwt_claims_destroy(exec_ctx, claims);
- return NULL;
+ return nullptr;
}
grpc_jwt_verifier_status grpc_jwt_claims_check(const grpc_jwt_claims* claims,
@@ -283,7 +283,7 @@ grpc_jwt_verifier_status grpc_jwt_claims_check(const grpc_jwt_claims* claims,
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);
@@ -301,23 +301,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;
@@ -366,8 +366,8 @@ static verifier_cb_ctx* verifier_cb_ctx_create(
}
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);
+ if (ctx->audience != nullptr) gpr_free(ctx->audience);
+ if (ctx->claims != nullptr) 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);
@@ -399,20 +399,20 @@ struct grpc_jwt_verifier {
};
static grpc_json* json_from_http(const grpc_httpcli_response* response) {
- grpc_json* json = NULL;
+ 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;
@@ -421,26 +421,26 @@ static grpc_json* json_from_http(const grpc_httpcli_response* response) {
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) {
+ 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;
+ 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.");
}
@@ -451,17 +451,17 @@ end:
}
static BIGNUM* bignum_from_base64(grpc_exec_ctx* exec_ctx, const char* b64) {
- BIGNUM* result = NULL;
+ BIGNUM* result = nullptr;
grpc_slice bin;
- if (b64 == NULL) return NULL;
+ if (b64 == nullptr) return nullptr;
bin = grpc_base64_decode(exec_ctx, 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);
+ TSI_SIZE_AS_SIZE(GRPC_SLICE_LENGTH(bin)), nullptr);
grpc_slice_unref_internal(exec_ctx, bin);
return result;
}
@@ -474,19 +474,19 @@ static int RSA_set0_key(RSA* r, BIGNUM* n, BIGNUM* e, BIGNUM* d) {
* 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;
}
@@ -498,43 +498,43 @@ static int RSA_set0_key(RSA* r, BIGNUM* n, BIGNUM* e, BIGNUM* d) {
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;
+ 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;
+ 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;
+ 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. */
@@ -554,29 +554,30 @@ static EVP_PKEY* find_verification_key(grpc_exec_ctx* exec_ctx,
/* 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;
+ 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) {
+ for (jkey = jwk_keys->child; jkey != nullptr; jkey = jkey->next) {
grpc_json* key_prop;
- const char* alg = NULL;
- const char* kid = NULL;
- const char* kty = NULL;
+ 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;
@@ -588,7 +589,7 @@ 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);
}
@@ -596,7 +597,7 @@ static EVP_PKEY* find_verification_key(grpc_exec_ctx* exec_ctx,
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,
@@ -605,12 +606,12 @@ static int verify_jwt_signature(EVP_PKEY* key, const char* alg,
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;
}
@@ -635,17 +636,17 @@ 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;
+ 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) {
+ 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;
@@ -662,11 +663,11 @@ 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);
@@ -680,17 +681,17 @@ static void on_openid_config_retrieved(grpc_exec_ctx* exec_ctx, void* user_data,
grpc_json* json = json_from_http(response);
grpc_httpcli_request req;
const char* jwks_uri;
- grpc_resource_quota* resource_quota = NULL;
+ 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;
@@ -699,7 +700,7 @@ static void on_openid_config_retrieved(grpc_exec_ctx* exec_ctx, void* user_data,
req.handshaker = &grpc_httpcli_ssl;
req.host = gpr_strdup(jwks_uri);
req.http.path = (char*)strchr(jwks_uri, '/');
- if (req.http.path == NULL) {
+ if (req.http.path == nullptr) {
req.http.path = (char*)"";
} else {
*(req.host + (req.http.path - jwks_uri)) = '\0';
@@ -720,29 +721,29 @@ static void on_openid_config_retrieved(grpc_exec_ctx* exec_ctx, void* user_data,
return;
error:
- if (json != NULL) grpc_json_destroy(json);
+ if (json != nullptr) grpc_json_destroy(json);
ctx->user_cb(exec_ctx, ctx->user_data, GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR,
- NULL);
+ nullptr);
verifier_cb_ctx_destroy(exec_ctx, ctx);
}
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);
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;
@@ -757,16 +758,16 @@ static void verifier_put_mapping(grpc_jwt_verifier* v, const char* email_domain,
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;
+ if (at_sign == nullptr) return nullptr;
const char* email_domain = at_sign + 1;
- if (*email_domain == '\0') return NULL;
+ if (*email_domain == '\0') return nullptr;
const char* dot = strrchr(email_domain, '.');
- if (dot == NULL || dot == email_domain) return 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 = (const char*)gpr_memrchr((void*)email_domain, '.',
(size_t)(dot - email_domain));
- if (dot == NULL) return email_domain;
+ if (dot == nullptr) return email_domain;
return dot + 1;
}
@@ -775,21 +776,22 @@ 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;
+ char* path_prefix = nullptr;
const char* iss;
grpc_httpcli_request req;
- grpc_resource_quota* resource_quota = NULL;
+ 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;
}
@@ -800,17 +802,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) {
+ if (email_domain != nullptr) {
email_key_mapping* mapping;
- GPR_ASSERT(ctx->verifier != NULL);
+ 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';
@@ -822,7 +824,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;
@@ -849,7 +851,7 @@ static void retrieve_key_and_verify(grpc_exec_ctx* exec_ctx,
error:
ctx->user_cb(exec_ctx, ctx->user_data, GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR,
- NULL);
+ nullptr);
verifier_cb_ctx_destroy(exec_ctx, ctx);
}
@@ -859,33 +861,34 @@ void grpc_jwt_verifier_verify(grpc_exec_ctx* exec_ctx,
const char* audience,
grpc_jwt_verification_done_cb cb,
void* user_data) {
- const char* dot = NULL;
+ const char* dot = nullptr;
grpc_json* json;
- jose_header* header = NULL;
- grpc_jwt_claims* claims = NULL;
+ 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;
- 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;
+ if (dot == nullptr) goto error;
json = parse_json_part_from_jwt(exec_ctx, cur, (size_t)(dot - cur),
&header_buffer);
- if (json == NULL) goto error;
+ if (json == nullptr) goto error;
header = jose_header_from_json(exec_ctx, json, header_buffer);
- if (header == NULL) goto error;
+ if (header == nullptr) goto error;
cur = dot + 1;
dot = strchr(cur, '.');
- if (dot == NULL) goto error;
+ if (dot == nullptr) goto error;
json = parse_json_part_from_jwt(exec_ctx, cur, (size_t)(dot - cur),
&claims_buffer);
- if (json == NULL) goto error;
+ if (json == nullptr) goto error;
claims = grpc_jwt_claims_from_json(exec_ctx, json, claims_buffer);
- if (claims == NULL) goto error;
+ if (claims == nullptr) goto error;
signed_jwt_len = (size_t)(dot - jwt);
cur = dot + 1;
@@ -898,9 +901,9 @@ void grpc_jwt_verifier_verify(grpc_exec_ctx* exec_ctx,
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(exec_ctx, header);
+ if (claims != nullptr) grpc_jwt_claims_destroy(exec_ctx, claims);
+ cb(exec_ctx, user_data, GRPC_JWT_VERIFIER_BAD_FORMAT, nullptr);
}
grpc_jwt_verifier* grpc_jwt_verifier_create(
@@ -917,7 +920,7 @@ grpc_jwt_verifier* grpc_jwt_verifier_create(
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,
@@ -929,9 +932,9 @@ grpc_jwt_verifier* grpc_jwt_verifier_create(
void grpc_jwt_verifier_destroy(grpc_exec_ctx* exec_ctx, grpc_jwt_verifier* v) {
size_t i;
- if (v == NULL) return;
+ if (v == nullptr) return;
grpc_httpcli_context_destroy(exec_ctx, &v->http_ctx);
- if (v->mappings != NULL) {
+ 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 8083cf9beb..2aacd497c7 100644
--- a/src/core/lib/security/credentials/jwt/jwt_verifier.h
+++ b/src/core/lib/security/credentials/jwt/jwt_verifier.h
@@ -32,10 +32,6 @@
#define GRPC_GOOGLE_SERVICE_ACCOUNTS_KEY_URL_PREFIX \
"www.googleapis.com/robot/v1/metadata/x509"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* --- grpc_jwt_verifier_status. --- */
typedef enum {
@@ -126,8 +122,4 @@ 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);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_VERIFIER_H */
diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
index 2a44211228..ccefb4db9c 100644
--- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
+++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
@@ -33,7 +33,7 @@
int grpc_auth_refresh_token_is_valid(
const grpc_auth_refresh_token* refresh_token) {
- return (refresh_token != NULL) &&
+ return (refresh_token != nullptr) &&
strcmp(refresh_token->type, GRPC_AUTH_JSON_TYPE_INVALID);
}
@@ -45,13 +45,13 @@ grpc_auth_refresh_token grpc_auth_refresh_token_create_from_json(
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;
}
@@ -77,25 +77,25 @@ grpc_auth_refresh_token grpc_auth_refresh_token_create_from_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;
+ 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;
}
}
@@ -118,12 +118,12 @@ 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, grpc_millis* token_lifetime) {
- char* null_terminated_body = NULL;
- char* new_access_token = NULL;
+ 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;
@@ -138,16 +138,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* 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,24 +166,24 @@ 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 = strtol(expires_in->value, NULL, 10) * GPR_MS_PER_SEC;
+ *token_lifetime = strtol(expires_in->value, nullptr, 10) * GPR_MS_PER_SEC;
if (!GRPC_MDISNULL(*token_md)) GRPC_MDELEM_UNREF(exec_ctx, *token_md);
*token_md = grpc_mdelem_from_slices(
exec_ctx,
@@ -197,9 +197,9 @@ end:
GRPC_MDELEM_UNREF(exec_ctx, *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;
}
@@ -225,10 +225,10 @@ static void on_oauth2_token_fetcher_http_response(grpc_exec_ctx* exec_ctx,
: 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);
@@ -305,13 +305,13 @@ static void oauth2_token_fetcher_cancel_get_request_metadata(
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* 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;
@@ -380,7 +380,7 @@ grpc_call_credentials* grpc_google_compute_engine_credentials_create(
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;
@@ -411,7 +411,7 @@ static void refresh_token_fetch_oauth2(
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);
@@ -441,7 +441,7 @@ grpc_refresh_token_credentials_create_from_auth_refresh_token(
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 = (grpc_google_refresh_token_credentials*)gpr_zalloc(
sizeof(grpc_google_refresh_token_credentials));
@@ -455,7 +455,7 @@ 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}",
@@ -467,7 +467,7 @@ 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)) {
+ 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, "
@@ -475,7 +475,7 @@ grpc_call_credentials* grpc_google_refresh_token_credentials_create(
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);
}
@@ -517,7 +517,7 @@ grpc_call_credentials* grpc_access_token_credentials_create(
"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);
diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h
index 32d3ff760d..627783d648 100644
--- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h
+++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h
@@ -22,10 +22,6 @@
#include "src/core/lib/json/json.h"
#include "src/core/lib/security/credentials/credentials.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
// auth_refresh_token parsing.
typedef struct {
const char* type;
@@ -106,8 +102,4 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response(
grpc_exec_ctx* exec_ctx, const struct grpc_http_response* response,
grpc_mdelem* token_md, grpc_millis* token_lifetime);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_OAUTH2_OAUTH2_CREDENTIALS_H */
diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/src/core/lib/security/credentials/plugin/plugin_credentials.cc
index e75b00c01a..1f1efd078d 100644
--- a/src/core/lib/security/credentials/plugin/plugin_credentials.cc
+++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc
@@ -31,14 +31,13 @@
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/validate_metadata.h"
-grpc_tracer_flag grpc_plugin_credentials_trace =
- GRPC_TRACER_INITIALIZER(false, "plugin_credentials");
+grpc_core::TraceFlag grpc_plugin_credentials_trace(false, "plugin_credentials");
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) {
+ if (c->plugin.state != nullptr && c->plugin.destroy != nullptr) {
c->plugin.destroy(c->plugin.state);
}
}
@@ -46,12 +45,12 @@ static void plugin_destruct(grpc_exec_ctx* exec_ctx,
static void pending_request_remove_locked(
grpc_plugin_credentials* c,
grpc_plugin_credentials_pending_request* pending_request) {
- if (pending_request->prev == NULL) {
+ if (pending_request->prev == nullptr) {
c->pending_requests = pending_request->next;
} else {
pending_request->prev->next = pending_request->next;
}
- if (pending_request->next != NULL) {
+ if (pending_request->next != nullptr) {
pending_request->next->prev = pending_request->prev;
}
}
@@ -120,10 +119,10 @@ static void plugin_md_request_metadata_ready(void* request,
/* 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);
+ nullptr, nullptr);
grpc_plugin_credentials_pending_request* r =
(grpc_plugin_credentials_pending_request*)request;
- if (GRPC_TRACER_ON(grpc_plugin_credentials_trace)) {
+ if (grpc_plugin_credentials_trace.enabled()) {
gpr_log(GPR_INFO,
"plugin_credentials[%p]: request %p: plugin returned "
"asynchronously",
@@ -136,7 +135,7 @@ static void plugin_md_request_metadata_ready(void* request,
grpc_error* error =
process_plugin_result(&exec_ctx, r, md, num_md, status, error_details);
GRPC_CLOSURE_SCHED(&exec_ctx, r->on_request_metadata, error);
- } else if (GRPC_TRACER_ON(grpc_plugin_credentials_trace)) {
+ } else if (grpc_plugin_credentials_trace.enabled()) {
gpr_log(GPR_INFO,
"plugin_credentials[%p]: request %p: plugin was previously "
"cancelled",
@@ -155,7 +154,7 @@ static bool plugin_get_request_metadata(grpc_exec_ctx* exec_ctx,
grpc_error** error) {
grpc_plugin_credentials* c = (grpc_plugin_credentials*)creds;
bool retval = true; // Synchronous return.
- if (c->plugin.get_metadata != NULL) {
+ if (c->plugin.get_metadata != nullptr) {
// Create pending_request object.
grpc_plugin_credentials_pending_request* pending_request =
(grpc_plugin_credentials_pending_request*)gpr_zalloc(
@@ -165,14 +164,14 @@ static bool plugin_get_request_metadata(grpc_exec_ctx* exec_ctx,
pending_request->on_request_metadata = on_request_metadata;
// Add it to the pending list.
gpr_mu_lock(&c->mu);
- if (c->pending_requests != NULL) {
+ 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_TRACER_ON(grpc_plugin_credentials_trace)) {
+ if (grpc_plugin_credentials_trace.enabled()) {
gpr_log(GPR_INFO, "plugin_credentials[%p]: request %p: invoking plugin",
c, pending_request);
}
@@ -180,12 +179,12 @@ static bool plugin_get_request_metadata(grpc_exec_ctx* exec_ctx,
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 = NULL;
+ 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_TRACER_ON(grpc_plugin_credentials_trace)) {
+ if (grpc_plugin_credentials_trace.enabled()) {
gpr_log(GPR_INFO,
"plugin_credentials[%p]: request %p: plugin will return "
"asynchronously",
@@ -200,7 +199,7 @@ static bool plugin_get_request_metadata(grpc_exec_ctx* exec_ctx,
// asynchronously by plugin_cancel_get_request_metadata(), so return
// false. Otherwise, process the result.
if (pending_request->cancelled) {
- if (GRPC_TRACER_ON(grpc_plugin_credentials_trace)) {
+ if (grpc_plugin_credentials_trace.enabled()) {
gpr_log(GPR_INFO,
"plugin_credentials[%p]: request %p was cancelled, error "
"will be returned asynchronously",
@@ -208,7 +207,7 @@ static bool plugin_get_request_metadata(grpc_exec_ctx* exec_ctx,
}
retval = false;
} else {
- if (GRPC_TRACER_ON(grpc_plugin_credentials_trace)) {
+ if (grpc_plugin_credentials_trace.enabled()) {
gpr_log(GPR_INFO,
"plugin_credentials[%p]: request %p: plugin returned "
"synchronously",
@@ -235,9 +234,9 @@ static void plugin_cancel_get_request_metadata(
gpr_mu_lock(&c->mu);
for (grpc_plugin_credentials_pending_request* pending_request =
c->pending_requests;
- pending_request != NULL; pending_request = pending_request->next) {
+ pending_request != nullptr; pending_request = pending_request->next) {
if (pending_request->md_array == md_array) {
- if (GRPC_TRACER_ON(grpc_plugin_credentials_trace)) {
+ if (grpc_plugin_credentials_trace.enabled()) {
gpr_log(GPR_INFO, "plugin_credentials[%p]: cancelling request %p", c,
pending_request);
}
@@ -261,7 +260,7 @@ grpc_call_credentials* grpc_metadata_credentials_create_from_plugin(
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 == NULL);
+ GPR_ASSERT(reserved == nullptr);
c->base.type = plugin.type;
c->base.vtable = &plugin_vtable;
gpr_ref_init(&c->base.refcount, 1);
diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.h b/src/core/lib/security/credentials/plugin/plugin_credentials.h
index fc0955c695..e1467b0824 100644
--- a/src/core/lib/security/credentials/plugin/plugin_credentials.h
+++ b/src/core/lib/security/credentials/plugin/plugin_credentials.h
@@ -21,7 +21,7 @@
#include "src/core/lib/security/credentials/credentials.h"
-extern grpc_tracer_flag grpc_plugin_credentials_trace;
+extern grpc_core::TraceFlag grpc_plugin_credentials_trace;
struct grpc_plugin_credentials;
diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.cc b/src/core/lib/security/credentials/ssl/ssl_credentials.cc
index 79e223ddcb..39dd38cf88 100644
--- a/src/core/lib/security/credentials/ssl/ssl_credentials.cc
+++ b/src/core/lib/security/credentials/ssl/ssl_credentials.cc
@@ -33,7 +33,7 @@
void grpc_tsi_ssl_pem_key_cert_pairs_destroy(tsi_ssl_pem_key_cert_pair* kp,
size_t num_key_cert_pairs) {
- if (kp == NULL) return;
+ 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);
@@ -55,7 +55,7 @@ static grpc_security_status ssl_create_security_connector(
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;
+ 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 &&
@@ -77,17 +77,17 @@ static grpc_security_status ssl_create_security_connector(
}
static grpc_channel_credentials_vtable ssl_vtable = {
- ssl_destruct, ssl_create_security_connector, NULL};
+ 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 != NULL) {
+ if (pem_root_certs != nullptr) {
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);
+ 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 =
@@ -107,7 +107,7 @@ grpc_channel_credentials* grpc_ssl_credentials_create(
"pem_key_cert_pair=%p, "
"reserved=%p)",
3, (pem_root_certs, pem_key_cert_pair, reserved));
- GPR_ASSERT(reserved == NULL);
+ GPR_ASSERT(reserved == nullptr);
c->base.type = GRPC_CHANNEL_CREDENTIALS_TYPE_SSL;
c->base.vtable = &ssl_vtable;
gpr_ref_init(&c->base.refcount, 1);
@@ -145,15 +145,15 @@ static grpc_server_credentials_vtable ssl_server_vtable = {
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 = NULL;
+ tsi_ssl_pem_key_cert_pair* tsi_pairs = nullptr;
if (num_key_cert_pairs > 0) {
- GPR_ASSERT(pem_key_cert_pairs != NULL);
+ 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 != NULL);
- GPR_ASSERT(pem_key_cert_pairs[i].cert_chain != NULL);
+ 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);
}
@@ -166,7 +166,7 @@ static void ssl_build_server_config(
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 != NULL) {
+ 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(
@@ -181,18 +181,18 @@ grpc_ssl_server_certificate_config* grpc_ssl_server_certificate_config_create(
grpc_ssl_server_certificate_config* config =
(grpc_ssl_server_certificate_config*)gpr_zalloc(
sizeof(grpc_ssl_server_certificate_config));
- if (pem_root_certs != NULL) {
+ 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 != NULL);
+ 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 != NULL);
- GPR_ASSERT(pem_key_cert_pairs[i].cert_chain != NULL);
+ 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 =
@@ -203,7 +203,7 @@ grpc_ssl_server_certificate_config* grpc_ssl_server_certificate_config_create(
void grpc_ssl_server_certificate_config_destroy(
grpc_ssl_server_certificate_config* config) {
- if (config == NULL) return;
+ 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);
@@ -217,8 +217,8 @@ 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 = NULL;
- if (config == NULL) {
+ grpc_ssl_server_credentials_options* options = nullptr;
+ if (config == nullptr) {
gpr_log(GPR_ERROR, "Certificate config must not be NULL.");
goto done;
}
@@ -234,9 +234,9 @@ 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 == NULL) {
+ if (cb == nullptr) {
gpr_log(GPR_ERROR, "Invalid certificate config callback parameter.");
- return NULL;
+ return nullptr;
}
grpc_ssl_server_certificate_config_fetcher* fetcher =
@@ -277,7 +277,7 @@ grpc_server_credentials* grpc_ssl_server_credentials_create_ex(
5,
(pem_root_certs, pem_key_cert_pairs, (unsigned long)num_key_cert_pairs,
client_certificate_request, reserved));
- GPR_ASSERT(reserved == NULL);
+ GPR_ASSERT(reserved == nullptr);
grpc_ssl_server_certificate_config* cert_config =
grpc_ssl_server_certificate_config_create(
@@ -291,23 +291,23 @@ grpc_server_credentials* grpc_ssl_server_credentials_create_ex(
grpc_server_credentials* grpc_ssl_server_credentials_create_with_options(
grpc_ssl_server_credentials_options* options) {
- grpc_server_credentials* retval = NULL;
- grpc_ssl_server_credentials* c = NULL;
+ grpc_server_credentials* retval = nullptr;
+ grpc_ssl_server_credentials* c = nullptr;
- if (options == NULL) {
+ if (options == nullptr) {
gpr_log(GPR_ERROR,
"Invalid options trying to create SSL server credentials.");
goto done;
}
- if (options->certificate_config == NULL &&
- options->certificate_config_fetcher == NULL) {
+ 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 != NULL &&
- options->certificate_config_fetcher->cb == NULL) {
+ } 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;
}
@@ -318,7 +318,7 @@ grpc_server_credentials* grpc_ssl_server_credentials_create_with_options(
gpr_ref_init(&c->base.refcount, 1);
c->base.vtable = &ssl_server_vtable;
- if (options->certificate_config_fetcher != NULL) {
+ if (options->certificate_config_fetcher != nullptr) {
c->config.client_certificate_request = options->client_certificate_request;
c->certificate_config_fetcher = *options->certificate_config_fetcher;
} else {
@@ -337,7 +337,7 @@ done:
void grpc_ssl_server_credentials_options_destroy(
grpc_ssl_server_credentials_options* o) {
- if (o == NULL) return;
+ 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 82b9ce11f6..0003905857 100644
--- a/src/core/lib/security/credentials/ssl/ssl_credentials.h
+++ b/src/core/lib/security/credentials/ssl/ssl_credentials.h
@@ -20,10 +20,6 @@
#include "src/core/lib/security/credentials/credentials.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct {
grpc_channel_credentials base;
grpc_ssl_config config;
@@ -53,8 +49,4 @@ tsi_ssl_pem_key_cert_pair* grpc_convert_grpc_to_tsi_cert_pairs(
void grpc_tsi_ssl_pem_key_cert_pairs_destroy(tsi_ssl_pem_key_cert_pair* kp,
size_t num_key_cert_pairs);
-#ifdef __cplusplus
-}
-#endif
-
#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 6376929890..e999a027ae 100644
--- a/src/core/lib/security/transport/auth_filters.h
+++ b/src/core/lib/security/transport/auth_filters.h
@@ -22,10 +22,6 @@
#include <grpc/grpc_security.h>
#include "src/core/lib/channel/channel_stack.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
extern const grpc_channel_filter grpc_client_auth_filter;
extern const grpc_channel_filter grpc_server_auth_filter;
@@ -36,8 +32,4 @@ void grpc_auth_metadata_context_build(
void grpc_auth_metadata_context_reset(grpc_auth_metadata_context* context);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_AUTH_FILTERS_H */
diff --git a/src/core/lib/security/transport/client_auth_filter.cc b/src/core/lib/security/transport/client_auth_filter.cc
index 11f5a13ccc..326f4d7773 100644
--- a/src/core/lib/security/transport/client_auth_filter.cc
+++ b/src/core/lib/security/transport/client_auth_filter.cc
@@ -67,18 +67,18 @@ typedef struct {
void grpc_auth_metadata_context_reset(
grpc_auth_metadata_context* auth_md_context) {
- if (auth_md_context->service_url != NULL) {
+ if (auth_md_context->service_url != nullptr) {
gpr_free((char*)auth_md_context->service_url);
- auth_md_context->service_url = NULL;
+ auth_md_context->service_url = nullptr;
}
- if (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 = NULL;
+ auth_md_context->method_name = nullptr;
}
GRPC_AUTH_CONTEXT_UNREF(
(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) {
@@ -125,10 +125,10 @@ void grpc_auth_metadata_context_build(
grpc_auth_metadata_context* auth_md_context) {
char* service = grpc_slice_to_c_string(call_method);
char* last_slash = strrchr(service, '/');
- char* method_name = NULL;
- char* service_url = NULL;
+ char* method_name = nullptr;
+ char* service_url = nullptr;
grpc_auth_metadata_context_reset(auth_md_context);
- if (last_slash == NULL) {
+ if (last_slash == nullptr) {
gpr_log(GPR_ERROR, "No '/' found in fully qualified method name");
service[0] = '\0';
method_name = gpr_strdup("");
@@ -139,15 +139,15 @@ void grpc_auth_metadata_context_build(
method_name = gpr_strdup(last_slash + 1);
}
char* host_and_port = grpc_slice_to_c_string(call_host);
- if (url_scheme != NULL && strcmp(url_scheme, GRPC_SSL_URL_SCHEME) == 0) {
+ 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 != NULL && strcmp(port_delimiter + 1, "443") == 0) {
+ if (port_delimiter != nullptr && strcmp(port_delimiter + 1, "443") == 0) {
*port_delimiter = '\0';
}
}
- gpr_asprintf(&service_url, "%s://%s%s", url_scheme == NULL ? "" : url_scheme,
- host_and_port, service);
+ gpr_asprintf(&service_url, "%s://%s%s",
+ 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 =
@@ -179,18 +179,18 @@ static void send_security_metadata(grpc_exec_ctx* exec_ctx,
.value;
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);
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,
grpc_error_set_int(
@@ -209,7 +209,7 @@ static void send_security_metadata(grpc_exec_ctx* exec_ctx,
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);
@@ -278,8 +278,8 @@ static void auth_start_transport_stream_op_batch(
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 =
@@ -297,7 +297,7 @@ static void auth_start_transport_stream_op_batch(
if (batch->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.
*/
@@ -386,13 +386,13 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
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_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");
}
@@ -420,7 +420,7 @@ static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
/* grab pointers to our data from the channel element */
channel_data* chand = (channel_data*)elem->channel_data;
grpc_channel_security_connector* sc = chand->security_connector;
- if (sc != NULL) {
+ if (sc != nullptr) {
GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, &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.cc b/src/core/lib/security/transport/lb_targets_info.cc
index 1655e18f37..c07be35840 100644
--- a/src/core/lib/security/transport/lb_targets_info.cc
+++ b/src/core/lib/security/transport/lb_targets_info.cc
@@ -49,9 +49,9 @@ 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 (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 b4a0bc91da..7543d3c012 100644
--- a/src/core/lib/security/transport/lb_targets_info.h
+++ b/src/core/lib/security/transport/lb_targets_info.h
@@ -21,10 +21,6 @@
#include "src/core/lib/slice/slice_hash_table.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/** Return a channel argument containing \a targets_info. */
grpc_arg grpc_lb_targets_info_create_channel_arg(
grpc_slice_hash_table* targets_info);
@@ -33,8 +29,4 @@ grpc_arg grpc_lb_targets_info_create_channel_arg(
grpc_slice_hash_table* grpc_lb_targets_info_find_in_args(
const grpc_channel_args* args);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_LB_TARGETS_INFO_H */
diff --git a/src/core/lib/security/transport/secure_endpoint.cc b/src/core/lib/security/transport/secure_endpoint.cc
index 9a29e05715..4cd317a06d 100644
--- a/src/core/lib/security/transport/secure_endpoint.cc
+++ b/src/core/lib/security/transport/secure_endpoint.cc
@@ -61,8 +61,7 @@ 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;
@@ -86,7 +85,7 @@ static void destroy(grpc_exec_ctx* exec_ctx, secure_endpoint* secure_ep) {
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)) {
+ 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,
@@ -99,7 +98,7 @@ static void secure_endpoint_unref(grpc_exec_ctx* exec_ctx, secure_endpoint* 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)) {
+ 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,
@@ -131,7 +130,7 @@ static void flush_read_staging_buffer(secure_endpoint* ep, uint8_t** cur,
static void call_read_cb(grpc_exec_ctx* exec_ctx, secure_endpoint* ep,
grpc_error* error) {
- if (GRPC_TRACER_ON(grpc_trace_secure_endpoint)) {
+ 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],
@@ -140,7 +139,7 @@ static void call_read_cb(grpc_exec_ctx* exec_ctx, secure_endpoint* ep,
gpr_free(data);
}
}
- ep->read_buffer = NULL;
+ ep->read_buffer = nullptr;
GRPC_CLOSURE_SCHED(exec_ctx, ep->read_cb, error);
SECURE_ENDPOINT_UNREF(exec_ctx, ep, "read");
}
@@ -162,7 +161,7 @@ static void on_read(grpc_exec_ctx* exec_ctx, void* user_data,
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);
@@ -271,7 +270,7 @@ static void endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* secure_ep,
grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &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 =
grpc_dump_slice(slices->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII);
@@ -280,7 +279,7 @@ static void endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* secure_ep,
}
}
- 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);
@@ -434,7 +433,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 db8233f6e6..b2556a0182 100644
--- a/src/core/lib/security/transport/secure_endpoint.h
+++ b/src/core/lib/security/transport/secure_endpoint.h
@@ -22,14 +22,10 @@
#include <grpc/slice.h>
#include "src/core/lib/iomgr/endpoint.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
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
@@ -40,8 +36,4 @@ grpc_endpoint* grpc_secure_endpoint_create(
grpc_endpoint* to_wrap, grpc_slice* leftover_slices,
size_t leftover_nslices);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURE_ENDPOINT_H */
diff --git a/src/core/lib/security/transport/security_connector.cc b/src/core/lib/security/transport/security_connector.cc
index b5822d7454..c56e459aeb 100644
--- a/src/core/lib/security/transport/security_connector.cc
+++ b/src/core/lib/security/transport/security_connector.cc
@@ -44,10 +44,8 @@
#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
+grpc_core::DebugOnlyTraceFlag grpc_trace_security_connector_refcount(
+ false, "security_connector_refcount");
/* -- Constants. -- */
@@ -60,7 +58,7 @@ static const char* installed_roots_path =
/* -- Overridden default roots. -- */
-static grpc_ssl_roots_override_callback ssl_roots_override_cb = NULL;
+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;
@@ -74,11 +72,11 @@ void grpc_set_ssl_roots_override_callback(grpc_ssl_roots_override_callback cb) {
"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 const char* cipher_suites = nullptr;
static void init_cipher_suites(void) {
char* overridden = gpr_getenv("GRPC_SSL_CIPHER_SUITES");
- cipher_suites = overridden != NULL ? overridden : GRPC_SSL_CIPHER_SUITES;
+ cipher_suites = overridden != nullptr ? overridden : GRPC_SSL_CIPHER_SUITES;
}
static const char* ssl_cipher_suites(void) {
@@ -92,24 +90,24 @@ static const char* ssl_cipher_suites(void) {
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;
+ if (peer == nullptr) return nullptr;
for (i = 0; i < peer->property_count; i++) {
const tsi_peer_property* property = &peer->properties[i];
- if (name == NULL && property->name == NULL) {
+ if (name == nullptr && property->name == nullptr) {
return property;
}
- if (name != NULL && property->name != NULL &&
+ if (name != nullptr && property->name != nullptr &&
strcmp(property->name, name) == 0) {
return property;
}
}
- return NULL;
+ return nullptr;
}
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) {
+ if (connector != nullptr) {
connector->add_handshakers(exec_ctx, connector, handshake_mgr);
}
}
@@ -117,7 +115,7 @@ void grpc_channel_security_connector_add_handshakers(
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) {
+ if (connector != nullptr) {
connector->add_handshakers(exec_ctx, connector, handshake_mgr);
}
}
@@ -127,7 +125,7 @@ void grpc_security_connector_check_peer(grpc_exec_ctx* exec_ctx,
tsi_peer peer,
grpc_auth_context** auth_context,
grpc_closure* on_peer_checked) {
- if (sc == NULL) {
+ if (sc == nullptr) {
GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked,
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"cannot check peer -- no security connector"));
@@ -139,7 +137,7 @@ void grpc_security_connector_check_peer(grpc_exec_ctx* exec_ctx,
int grpc_security_connector_cmp(grpc_security_connector* sc,
grpc_security_connector* other) {
- if (sc == NULL || other == NULL) return GPR_ICMP(sc, 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);
@@ -147,8 +145,8 @@ int grpc_security_connector_cmp(grpc_security_connector* sc,
int grpc_channel_security_connector_cmp(grpc_channel_security_connector* sc1,
grpc_channel_security_connector* sc2) {
- GPR_ASSERT(sc1->channel_creds != NULL);
- GPR_ASSERT(sc2->channel_creds != NULL);
+ 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);
@@ -163,8 +161,8 @@ int grpc_channel_security_connector_cmp(grpc_channel_security_connector* sc1,
int grpc_server_security_connector_cmp(grpc_server_security_connector* sc1,
grpc_server_security_connector* sc2) {
- GPR_ASSERT(sc1->server_creds != NULL);
- GPR_ASSERT(sc2->server_creds != NULL);
+ 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);
@@ -174,7 +172,7 @@ 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) {
+ if (sc == nullptr || sc->check_call_host == nullptr) {
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"cannot check call host -- no security connector");
return true;
@@ -186,7 +184,7 @@ bool grpc_channel_security_connector_check_call_host(
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) {
+ if (sc == nullptr || sc->cancel_check_call_host == nullptr) {
GRPC_ERROR_UNREF(error);
return;
}
@@ -197,8 +195,8 @@ void grpc_channel_security_connector_cancel_check_call_host(
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)) {
+ 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,
@@ -218,8 +216,8 @@ 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)) {
+ 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,
@@ -257,11 +255,11 @@ grpc_arg grpc_security_connector_to_arg(grpc_security_connector* sc) {
}
grpc_security_connector* grpc_security_connector_from_arg(const grpc_arg* arg) {
- if (strcmp(arg->key, GRPC_ARG_SECURITY_CONNECTOR)) return NULL;
+ 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 NULL;
+ return nullptr;
}
return (grpc_security_connector*)arg->value.pointer.p;
}
@@ -269,13 +267,13 @@ grpc_security_connector* grpc_security_connector_from_arg(const grpc_arg* arg) {
grpc_security_connector* grpc_security_connector_find_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_security_connector* sc =
grpc_security_connector_from_arg(&args->args[i]);
- if (sc != NULL) return sc;
+ if (sc != nullptr) return sc;
}
- return NULL;
+ return nullptr;
}
static tsi_client_certificate_request_type
@@ -328,14 +326,14 @@ static void fake_server_destroy(grpc_exec_ctx* exec_ctx,
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;
+ 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] != NULL && strcmp(target, set[i]) == 0) found = true;
+ if (set[i] != nullptr && strcmp(target, set[i]) == 0) found = true;
}
for (size_t i = 0; i < set_size; ++i) {
gpr_free(set[i]);
@@ -347,8 +345,8 @@ static bool fake_check_target(const char* target_type, const char* target,
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;
+ 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,
@@ -394,18 +392,18 @@ static void fake_check_peer(grpc_exec_ctx* exec_ctx,
grpc_closure* on_peer_checked) {
const char* prop_name;
grpc_error* error = GRPC_ERROR_NONE;
- *auth_context = NULL;
+ *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 == NULL ||
+ 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 == NULL ? "<EMPTY>" : prop_name);
+ prop_name == nullptr ? "<EMPTY>" : prop_name);
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
goto end;
@@ -416,7 +414,7 @@ static void fake_check_peer(grpc_exec_ctx* exec_ctx,
"Invalid value for cert type property.");
goto end;
}
- *auth_context = grpc_auth_context_create(NULL);
+ *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);
@@ -452,7 +450,7 @@ static int fake_channel_cmp(grpc_security_connector* sc1,
if (c != 0) return c;
c = strcmp(c1->target, c2->target);
if (c != 0) return c;
- if (c1->expected_targets == NULL || c2->expected_targets == NULL) {
+ 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);
@@ -527,7 +525,7 @@ grpc_channel_security_connector* grpc_fake_channel_security_connector_create(
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);
+ c->is_lb_channel = (grpc_lb_targets_info_find_in_args(args) != nullptr);
return &c->base;
}
@@ -560,11 +558,11 @@ typedef struct {
static bool server_connector_has_cert_config_fetcher(
grpc_ssl_server_security_connector* c) {
- GPR_ASSERT(c != NULL);
+ GPR_ASSERT(c != nullptr);
grpc_ssl_server_credentials* server_creds =
(grpc_ssl_server_credentials*)c->base.server_creds;
- GPR_ASSERT(server_creds != NULL);
- return server_creds->certificate_config_fetcher.cb != NULL;
+ GPR_ASSERT(server_creds != nullptr);
+ return server_creds->certificate_config_fetcher.cb != nullptr;
}
static void ssl_channel_destroy(grpc_exec_ctx* exec_ctx,
@@ -574,9 +572,9 @@ static void ssl_channel_destroy(grpc_exec_ctx* exec_ctx,
grpc_channel_credentials_unref(exec_ctx, c->base.channel_creds);
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);
+ 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);
}
@@ -586,7 +584,7 @@ static void ssl_server_destroy(grpc_exec_ctx* exec_ctx,
(grpc_ssl_server_security_connector*)sc;
grpc_server_credentials_unref(exec_ctx, c->base.server_creds);
tsi_ssl_server_handshaker_factory_unref(c->server_handshaker_factory);
- c->server_handshaker_factory = NULL;
+ c->server_handshaker_factory = nullptr;
gpr_free(sc);
}
@@ -596,11 +594,11 @@ static void ssl_channel_add_handshakers(grpc_exec_ctx* exec_ctx,
grpc_ssl_channel_security_connector* c =
(grpc_ssl_channel_security_connector*)sc;
// Instantiate TSI handshaker.
- tsi_handshaker* tsi_hs = NULL;
+ tsi_handshaker* tsi_hs = nullptr;
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,
+ 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.",
@@ -615,7 +613,7 @@ static void ssl_channel_add_handshakers(grpc_exec_ctx* exec_ctx,
}
static const char** fill_alpn_protocol_strings(size_t* num_alpn_protocols) {
- GPR_ASSERT(num_alpn_protocols != NULL);
+ 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));
@@ -632,7 +630,7 @@ static const char** fill_alpn_protocol_strings(size_t* num_alpn_protocols) {
static bool try_replace_server_handshaker_factory(
grpc_ssl_server_security_connector* sc,
const grpc_ssl_server_certificate_config* config) {
- if (config == NULL) {
+ if (config == nullptr) {
gpr_log(GPR_ERROR,
"Server certificate config callback returned invalid (NULL) "
"config.");
@@ -645,7 +643,7 @@ static bool try_replace_server_handshaker_factory(
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 = NULL;
+ 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(
@@ -672,10 +670,10 @@ static bool try_replace_server_handshaker_factory(
* 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 = NULL;
+ grpc_ssl_server_certificate_config* certificate_config = nullptr;
bool status;
- GPR_ASSERT(sc != NULL);
+ GPR_ASSERT(sc != nullptr);
if (!server_connector_has_cert_config_fetcher(sc)) return false;
grpc_ssl_server_credentials* server_creds =
@@ -697,7 +695,7 @@ static bool try_fetch_ssl_server_credentials(
status = false;
}
- if (certificate_config != NULL) {
+ if (certificate_config != nullptr) {
grpc_ssl_server_certificate_config_destroy(certificate_config);
}
return status;
@@ -710,7 +708,7 @@ static void ssl_server_add_handshakers(grpc_exec_ctx* exec_ctx,
(grpc_ssl_server_security_connector*)sc;
// Instantiate TSI handshaker.
try_fetch_ssl_server_credentials(c);
- tsi_handshaker* tsi_hs = NULL;
+ 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) {
@@ -726,10 +724,10 @@ static void ssl_server_add_handshakers(grpc_exec_ctx* exec_ctx,
}
static int ssl_host_matches_name(const tsi_peer* peer, const char* peer_name) {
- char* allocated_name = NULL;
+ char* allocated_name = nullptr;
int r;
- if (strchr(peer_name, ':') != NULL) {
+ if (strchr(peer_name, ':') != nullptr) {
char* ignored_port;
gpr_split_host_port(peer_name, &allocated_name, &ignored_port);
gpr_free(ignored_port);
@@ -743,21 +741,21 @@ static int ssl_host_matches_name(const tsi_peer* peer, const char* peer_name) {
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;
+ 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(NULL);
+ 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 == NULL) continue;
+ 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 == NULL) {
+ 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,
@@ -772,7 +770,7 @@ grpc_auth_context* tsi_ssl_peer_to_auth_context(const tsi_peer* peer) {
prop->value.data, prop->value.length);
}
}
- if (peer_identity_property_name != NULL) {
+ if (peer_identity_property_name != nullptr) {
GPR_ASSERT(grpc_auth_context_set_peer_identity_property_name(
ctx, peer_identity_property_name) == 1);
}
@@ -785,7 +783,7 @@ static grpc_error* ssl_check_peer(grpc_security_connector* sc,
/* Check the ALPN. */
const tsi_peer_property* p =
tsi_peer_get_property_by_name(peer, TSI_SSL_ALPN_SELECTED_PROTOCOL);
- if (p == NULL) {
+ if (p == nullptr) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Cannot check peer: missing selected ALPN property.");
}
@@ -795,7 +793,7 @@ static grpc_error* ssl_check_peer(grpc_security_connector* sc,
}
/* Check the peer name if specified. */
- if (peer_name != NULL && !ssl_host_matches_name(peer, peer_name)) {
+ 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);
@@ -813,7 +811,7 @@ static void ssl_channel_check_peer(grpc_exec_ctx* exec_ctx,
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 != nullptr
? c->overridden_target_name
: c->target_name,
&peer, auth_context);
@@ -825,7 +823,7 @@ 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);
+ grpc_error* error = ssl_check_peer(sc, nullptr, &peer, auth_context);
tsi_peer_destruct(&peer);
GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked, error);
}
@@ -840,8 +838,8 @@ static int ssl_channel_cmp(grpc_security_connector* sc1,
if (c != 0) return c;
c = strcmp(c1->target_name, c2->target_name);
if (c != 0) return c;
- return (c1->overridden_target_name == NULL ||
- c2->overridden_target_name == NULL)
+ 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);
}
@@ -871,13 +869,13 @@ tsi_peer tsi_shallow_peer_from_ssl_auth_context(
memset(&peer, 0, sizeof(peer));
it = grpc_auth_context_property_iterator(auth_context);
- while (grpc_auth_property_iterator_next(&it) != NULL) max_num_props++;
+ 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)) != NULL) {
+ 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);
@@ -894,7 +892,7 @@ tsi_peer tsi_shallow_peer_from_ssl_auth_context(
}
void tsi_shallow_peer_destruct(tsi_peer* peer) {
- if (peer->properties != NULL) gpr_free(peer->properties);
+ if (peer->properties != nullptr) gpr_free(peer->properties);
}
static bool ssl_channel_check_call_host(grpc_exec_ctx* exec_ctx,
@@ -911,7 +909,8 @@ static bool ssl_channel_check_call_host(grpc_exec_ctx* exec_ctx,
/* 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) {
+ if (c->overridden_target_name != nullptr &&
+ strcmp(host, c->target_name) == 0) {
status = GRPC_SECURITY_OK;
}
if (status != GRPC_SECURITY_OK) {
@@ -941,7 +940,7 @@ static grpc_slice compute_default_pem_root_certs_once(void) {
/* 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) {
+ 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);
@@ -949,11 +948,11 @@ static grpc_slice compute_default_pem_root_certs_once(void) {
/* 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;
+ 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 != NULL);
+ GPR_ASSERT(pem_root_certs != nullptr);
result = grpc_slice_from_copied_buffer(
pem_root_certs,
strlen(pem_root_certs) + 1); // NULL terminator.
@@ -986,7 +985,7 @@ const char* grpc_get_default_ssl_roots(void) {
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
+ ? nullptr
: (const char*)GRPC_SLICE_START_PTR(default_pem_root_certs);
}
@@ -1004,13 +1003,13 @@ grpc_security_status grpc_ssl_channel_security_connector_create(
char* port;
bool has_key_cert_pair;
- if (config == NULL || target_name == NULL) {
+ 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 == NULL) {
+ if (config->pem_root_certs == nullptr) {
pem_root_certs = grpc_get_default_ssl_roots();
- if (pem_root_certs == NULL) {
+ if (pem_root_certs == nullptr) {
gpr_log(GPR_ERROR, "Could not get default pem root certs.");
goto error;
}
@@ -1032,22 +1031,22 @@ grpc_security_status grpc_ssl_channel_security_connector_create(
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) {
+ if (overridden_target_name != nullptr) {
c->overridden_target_name = gpr_strdup(overridden_target_name);
}
- has_key_cert_pair = config->pem_key_cert_pair != NULL &&
- config->pem_key_cert_pair->private_key != NULL &&
- config->pem_key_cert_pair->cert_chain != NULL;
+ 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 : NULL, pem_root_certs,
+ 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(exec_ctx, &c->base.base);
- *sc = NULL;
+ *sc = nullptr;
goto error;
}
*sc = &c->base;
@@ -1081,8 +1080,8 @@ grpc_security_status grpc_ssl_server_security_connector_create(
(grpc_ssl_server_credentials*)gsc;
grpc_security_status retval = GRPC_SECURITY_OK;
- GPR_ASSERT(server_credentials != NULL);
- GPR_ASSERT(sc != NULL);
+ GPR_ASSERT(server_credentials != nullptr);
+ GPR_ASSERT(sc != nullptr);
grpc_ssl_server_security_connector* c =
grpc_ssl_server_security_connector_initialize(gsc);
@@ -1115,8 +1114,8 @@ grpc_security_status grpc_ssl_server_security_connector_create(
if (retval == GRPC_SECURITY_OK) {
*sc = &c->base;
} else {
- if (c != NULL) ssl_server_destroy(exec_ctx, &c->base.base);
- if (sc != NULL) *sc = NULL;
+ if (c != nullptr) ssl_server_destroy(exec_ctx, &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 79fdbc1a66..03daba3a18 100644
--- a/src/core/lib/security/transport/security_connector.h
+++ b/src/core/lib/security/transport/security_connector.h
@@ -29,13 +29,7 @@
#include "src/core/tsi/ssl_transport_security.h"
#include "src/core/tsi/transport_security_interface.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef NDEBUG
-extern grpc_tracer_flag grpc_trace_security_connector_refcount;
-#endif
+extern grpc_core::DebugOnlyTraceFlag grpc_trace_security_connector_refcount;
/* --- status enum. --- */
@@ -261,8 +255,4 @@ tsi_peer tsi_shallow_peer_from_ssl_auth_context(
const grpc_auth_context* auth_context);
void tsi_shallow_peer_destruct(tsi_peer* peer);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURITY_CONNECTOR_H */
diff --git a/src/core/lib/security/transport/security_handshaker.cc b/src/core/lib/security/transport/security_handshaker.cc
index 63706f142b..7067b70cb6 100644
--- a/src/core/lib/security/transport/security_handshaker.cc
+++ b/src/core/lib/security/transport/security_handshaker.cc
@@ -65,16 +65,35 @@ typedef struct {
tsi_handshaker_result* handshaker_result;
} security_handshaker;
+static size_t move_read_buffer_into_handshake_buffer(grpc_exec_ctx* exec_ctx,
+ 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(exec_ctx, next_slice);
+ }
+ return bytes_in_read_buffer;
+}
+
static void security_handshaker_unref(grpc_exec_ctx* exec_ctx,
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) {
+ if (h->endpoint_to_destroy != nullptr) {
grpc_endpoint_destroy(exec_ctx, h->endpoint_to_destroy);
}
- if (h->read_buffer_to_destroy != NULL) {
+ if (h->read_buffer_to_destroy != nullptr) {
grpc_slice_buffer_destroy_internal(exec_ctx, h->read_buffer_to_destroy);
gpr_free(h->read_buffer_to_destroy);
}
@@ -91,11 +110,11 @@ static void security_handshaker_unref(grpc_exec_ctx* exec_ctx,
static void cleanup_args_for_failure_locked(grpc_exec_ctx* exec_ctx,
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;
+ h->args->read_buffer = nullptr;
grpc_channel_args_destroy(exec_ctx, h->args->args);
- h->args->args = NULL;
+ h->args->args = nullptr;
}
// If the handshake failed or we're shutting down, clean up and invoke the
@@ -135,9 +154,9 @@ static void on_peer_checked_inner(grpc_exec_ctx* exec_ctx,
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);
+ exec_ctx, 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(
@@ -147,10 +166,10 @@ static void on_peer_checked_inner(grpc_exec_ctx* exec_ctx,
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"),
@@ -160,7 +179,7 @@ static void on_peer_checked_inner(grpc_exec_ctx* exec_ctx,
}
}
// 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);
@@ -173,12 +192,10 @@ static void on_peer_checked_inner(grpc_exec_ctx* exec_ctx,
grpc_slice_unref_internal(exec_ctx, 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;
@@ -232,8 +249,8 @@ 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) {
@@ -244,7 +261,7 @@ static grpc_error* on_handshake_next_done_locked(
grpc_slice_buffer_add(&h->outgoing, to_send);
grpc_endpoint_write(exec_ctx, 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,
&h->on_handshake_data_received_from_peer);
@@ -280,9 +297,9 @@ 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) {
// 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,
@@ -312,23 +329,8 @@ static void on_handshake_data_received_from_peer(grpc_exec_ctx* exec_ctx,
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(exec_ctx, h);
// Call TSI handshaker.
error = do_handshaker_next_locked(exec_ctx, h, h->handshake_buffer,
bytes_received_size);
@@ -356,7 +358,7 @@ static void on_handshake_data_sent_to_peer(grpc_exec_ctx* exec_ctx, void* arg,
return;
}
// We may be done.
- if (h->handshaker_result == NULL) {
+ if (h->handshaker_result == nullptr) {
grpc_endpoint_read(exec_ctx, h->args->endpoint, h->args->read_buffer,
&h->on_handshake_data_received_from_peer);
} else {
@@ -405,7 +407,10 @@ static void security_handshaker_do_handshake(grpc_exec_ctx* exec_ctx,
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(exec_ctx, h);
+ grpc_error* error = do_handshaker_next_locked(
+ exec_ctx, h, h->handshake_buffer, bytes_received_size);
if (error != GRPC_ERROR_NONE) {
security_handshake_failed_locked(exec_ctx, h, error);
gpr_mu_unlock(&h->mu);
@@ -526,7 +531,7 @@ grpc_handshaker* grpc_security_handshaker_create(
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);
diff --git a/src/core/lib/security/transport/security_handshaker.h b/src/core/lib/security/transport/security_handshaker.h
index 174f70f0dd..6c3a0510ce 100644
--- a/src/core/lib/security/transport/security_handshaker.h
+++ b/src/core/lib/security/transport/security_handshaker.h
@@ -23,10 +23,6 @@
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/security/transport/security_connector.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/// Creates a security handshaker using \a handshaker.
grpc_handshaker* grpc_security_handshaker_create(
grpc_exec_ctx* exec_ctx, tsi_handshaker* handshaker,
@@ -35,8 +31,4 @@ grpc_handshaker* grpc_security_handshaker_create(
/// Registers security handshaker factories.
void grpc_security_register_handshaker_factories();
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURITY_HANDSHAKER_H */
diff --git a/src/core/lib/security/transport/server_auth_filter.cc b/src/core/lib/security/transport/server_auth_filter.cc
index e1307410d6..9cf368acd0 100644
--- a/src/core/lib/security/transport/server_auth_filter.cc
+++ b/src/core/lib/security/transport/server_auth_filter.cc
@@ -56,8 +56,8 @@ static grpc_metadata_array metadata_batch_to_md_array(
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);
@@ -98,7 +98,7 @@ static void on_md_processing_done_inner(grpc_exec_ctx* exec_ctx,
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...");
@@ -127,7 +127,7 @@ static void on_md_processing_done(
(gpr_atm)STATE_DONE)) {
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(
@@ -154,7 +154,7 @@ static void cancel_call(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
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(exec_ctx, elem, nullptr, 0, nullptr, 0,
GRPC_ERROR_REF(error));
}
GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "cancel_call");
@@ -167,7 +167,7 @@ static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx, void* arg,
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");
@@ -220,7 +220,7 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_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);
}
@@ -243,7 +243,7 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
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 =
diff --git a/src/core/lib/security/transport/tsi_error.h b/src/core/lib/security/transport/tsi_error.h
index 4e8418f3fd..8fa6c480ac 100644
--- a/src/core/lib/security/transport/tsi_error.h
+++ b/src/core/lib/security/transport/tsi_error.h
@@ -22,14 +22,6 @@
#include "src/core/lib/iomgr/error.h"
#include "src/core/tsi/transport_security_interface.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
grpc_error* grpc_set_tsi_error_result(grpc_error* error, tsi_result result);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_TSI_ERROR_H */
diff --git a/src/core/lib/security/util/json_util.cc b/src/core/lib/security/util/json_util.cc
index 365bd1537c..fef1a1f51d 100644
--- a/src/core/lib/security/util/json_util.cc
+++ b/src/core/lib/security/util/json_util.cc
@@ -26,12 +26,12 @@
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) {
+ 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;
}
@@ -40,7 +40,7 @@ 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;
+ 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 7538f76120..b7e46d4062 100644
--- a/src/core/lib/security/util/json_util.h
+++ b/src/core/lib/security/util/json_util.h
@@ -28,10 +28,6 @@
#define GRPC_AUTH_JSON_TYPE_SERVICE_ACCOUNT "service_account"
#define GRPC_AUTH_JSON_TYPE_AUTHORIZED_USER "authorized_user"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
// Gets a child property from a json node.
const char* grpc_json_get_string_property(const grpc_json* json,
const char* prop_name);
@@ -41,8 +37,4 @@ const char* grpc_json_get_string_property(const grpc_json* json,
bool grpc_copy_json_string_property(const grpc_json* json,
const char* prop_name, char** copied_value);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SECURITY_UTIL_JSON_UTIL_H */
diff --git a/src/core/lib/slice/b64.h b/src/core/lib/slice/b64.h
index 467f5d848a..f86c1d9901 100644
--- a/src/core/lib/slice/b64.h
+++ b/src/core/lib/slice/b64.h
@@ -21,10 +21,6 @@
#include <grpc/slice.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* 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 */
@@ -51,8 +47,4 @@ grpc_slice grpc_base64_decode(grpc_exec_ctx* exec_ctx, const char* b64,
grpc_slice grpc_base64_decode_with_len(grpc_exec_ctx* exec_ctx, const char* b64,
size_t b64_len, int url_safe);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SLICE_B64_H */
diff --git a/src/core/lib/slice/percent_encoding.h b/src/core/lib/slice/percent_encoding.h
index 22b5e8df31..a1009ff01f 100644
--- a/src/core/lib/slice/percent_encoding.h
+++ b/src/core/lib/slice/percent_encoding.h
@@ -30,10 +30,6 @@
#include <grpc/slice.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* URL percent encoding spec bitfield (usabel as 'unreserved_bytes' in
grpc_percent_encode_slice, grpc_strict_percent_decode_slice).
Flags [A-Za-z0-9-_.~] as unreserved bytes for the percent encoding routines
@@ -64,8 +60,4 @@ bool grpc_strict_percent_decode_slice(grpc_slice slice_in,
This cannot fail. */
grpc_slice grpc_permissive_percent_decode_slice(grpc_slice slice_in);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SLICE_PERCENT_ENCODING_H */
diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc
index d8e3200136..bbaf87ba23 100644
--- a/src/core/lib/slice/slice.cc
+++ b/src/core/lib/slice/slice.cc
@@ -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;
}
@@ -260,7 +260,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 +283,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 +295,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);
@@ -311,10 +311,10 @@ 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 +325,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);
@@ -365,10 +365,10 @@ grpc_slice grpc_slice_split_tail(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 +378,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;
@@ -431,7 +431,7 @@ 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 &&
@@ -454,7 +454,7 @@ 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);
+ return p == nullptr ? -1 : (int)(p - b);
}
int grpc_slice_slice(grpc_slice haystack, grpc_slice needle) {
diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc
index 3b71fdd4ea..5db54dad91 100644
--- a/src/core/lib/slice/slice_buffer.cc
+++ b/src/core/lib/slice/slice_buffer.cc
@@ -98,7 +98,7 @@ 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;
}
@@ -137,7 +137,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);
diff --git a/src/core/lib/slice/slice_hash_table.cc b/src/core/lib/slice/slice_hash_table.cc
index 6c2c9c201c..8f8e5a6b34 100644
--- a/src/core/lib/slice/slice_hash_table.cc
+++ b/src/core/lib/slice/slice_hash_table.cc
@@ -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;
@@ -77,13 +77,13 @@ 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)) {
+ 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)) {
@@ -108,16 +108,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 f86f25ea7c..85102bd67d 100644
--- a/src/core/lib/slice/slice_hash_table.h
+++ b/src/core/lib/slice/slice_hash_table.h
@@ -19,10 +19,6 @@
#include "src/core/lib/transport/metadata.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/** Hash table implementation.
*
* This implementation uses open addressing
@@ -71,8 +67,4 @@ void* grpc_slice_hash_table_get(const grpc_slice_hash_table* table,
int grpc_slice_hash_table_cmp(const grpc_slice_hash_table* a,
const grpc_slice_hash_table* b);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SLICE_SLICE_HASH_TABLE_H */
diff --git a/src/core/lib/slice/slice_intern.cc b/src/core/lib/slice/slice_intern.cc
index 50a0eba49c..e8949135c0 100644
--- a/src/core/lib/slice/slice_intern.cc
+++ b/src/core/lib/slice/slice_intern.cc
@@ -171,8 +171,8 @@ 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,
diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h
index 2439fc0826..ed0070d375 100644
--- a/src/core/lib/slice/slice_internal.h
+++ b/src/core/lib/slice/slice_internal.h
@@ -24,14 +24,13 @@
#include "src/core/lib/iomgr/exec_ctx.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
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_partial_unref_internal(grpc_exec_ctx* exec_ctx,
+ grpc_slice_buffer* sb,
+ size_t idx);
void grpc_slice_buffer_destroy_internal(grpc_exec_ctx* exec_ctx,
grpc_slice_buffer* sb);
@@ -50,8 +49,4 @@ grpc_slice grpc_slice_maybe_static_intern(grpc_slice slice,
uint32_t grpc_static_slice_hash(grpc_slice s);
int grpc_static_slice_eq(grpc_slice a, grpc_slice b);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H */
diff --git a/src/core/lib/slice/slice_string_helpers.h b/src/core/lib/slice/slice_string_helpers.h
index acbc41e711..7f51b11b9c 100644
--- a/src/core/lib/slice/slice_string_helpers.h
+++ b/src/core/lib/slice/slice_string_helpers.h
@@ -28,10 +28,6 @@
#include "src/core/lib/support/string.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Calls gpr_dump on a slice. */
char* grpc_dump_slice(grpc_slice slice, uint32_t flags);
@@ -41,8 +37,4 @@ 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);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SLICE_SLICE_STRING_HELPERS_H */
diff --git a/src/core/lib/slice/slice_traits.h b/src/core/lib/slice/slice_traits.h
index 7fdb6752cb..4b898bdcd4 100644
--- a/src/core/lib/slice/slice_traits.h
+++ b/src/core/lib/slice/slice_traits.h
@@ -22,16 +22,8 @@
#include <grpc/slice.h>
#include <stdbool.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
bool grpc_slice_is_legal_header(grpc_slice s);
bool grpc_slice_is_legal_nonbin_header(grpc_slice s);
bool grpc_slice_is_bin_suffixed(grpc_slice s);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SLICE_SLICE_TRAITS_H */
diff --git a/src/core/lib/support/abstract.h b/src/core/lib/support/abstract.h
new file mode 100644
index 0000000000..5498769a7d
--- /dev/null
+++ b/src/core/lib/support/abstract.h
@@ -0,0 +1,29 @@
+/*
+ *
+ * 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_SUPPORT_ABSTRACT_H
+#define GRPC_CORE_LIB_SUPPORT_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(); }
+
+#endif /* GRPC_CORE_LIB_SUPPORT_ABSTRACT_H */
diff --git a/src/core/lib/support/alloc.cc b/src/core/lib/support/alloc.cc
index aef4cb8d51..518bdb99f7 100644
--- a/src/core/lib/support/alloc.cc
+++ b/src/core/lib/support/alloc.cc
@@ -40,10 +40,10 @@ 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;
@@ -51,7 +51,7 @@ void gpr_set_allocation_functions(gpr_allocation_functions functions) {
void* gpr_malloc(size_t size) {
void* p;
- if (size == 0) return NULL;
+ if (size == 0) return nullptr;
GPR_TIMER_BEGIN("gpr_malloc", 0);
p = g_alloc_functions.malloc_fn(size);
if (!p) {
@@ -63,7 +63,7 @@ void* gpr_malloc(size_t size) {
void* gpr_zalloc(size_t size) {
void* p;
- if (size == 0) return NULL;
+ if (size == 0) return nullptr;
GPR_TIMER_BEGIN("gpr_zalloc", 0);
p = g_alloc_functions.zalloc_fn(size);
if (!p) {
@@ -80,7 +80,7 @@ void gpr_free(void* p) {
}
void* gpr_realloc(void* p, size_t size) {
- if ((size == 0) && (p == NULL)) return NULL;
+ if ((size == 0) && (p == nullptr)) return nullptr;
GPR_TIMER_BEGIN("gpr_realloc", 0);
p = g_alloc_functions.realloc_fn(p, size);
if (!p) {
diff --git a/src/core/lib/support/arena.cc b/src/core/lib/support/arena.cc
index 0b37a88230..5b9dd370d8 100644
--- a/src/core/lib/support/arena.cc
+++ b/src/core/lib/support/arena.cc
@@ -62,7 +62,7 @@ void* gpr_arena_alloc(gpr_arena* arena, size_t size) {
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) {
+ 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->size_begin = z->size_end;
diff --git a/src/core/lib/support/arena.h b/src/core/lib/support/arena.h
index 4d43c56bb9..cfe973a036 100644
--- a/src/core/lib/support/arena.h
+++ b/src/core/lib/support/arena.h
@@ -27,10 +27,6 @@
#include <stddef.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct gpr_arena gpr_arena;
// Create an arena, with \a initial_size bytes in the first allocated buffer
@@ -40,8 +36,4 @@ 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);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SUPPORT_ARENA_H */
diff --git a/src/core/lib/support/avl.cc b/src/core/lib/support/avl.cc
index 4ba101b74a..0b67a21f2f 100644
--- a/src/core/lib/support/avl.cc
+++ b/src/core/lib/support/avl.cc
@@ -28,7 +28,7 @@
gpr_avl gpr_avl_create(const gpr_avl_vtable* vtable) {
gpr_avl out;
out.vtable = vtable;
- out.root = NULL;
+ out.root = nullptr;
return out;
}
@@ -41,7 +41,7 @@ static gpr_avl_node* ref_node(gpr_avl_node* node) {
static void unref_node(const gpr_avl_vtable* vtable, gpr_avl_node* node,
void* user_data) {
- if (node == NULL) {
+ if (node == nullptr) {
return;
}
if (gpr_unref(&node->refs)) {
@@ -54,18 +54,18 @@ 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;
+ 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));
+ 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;
+ if (n == nullptr) return nullptr;
assert_invariants(n->left);
assert_invariants(n->right);
assert(calculate_height(n) == n->height);
@@ -92,8 +92,8 @@ 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);
@@ -108,12 +108,12 @@ 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;
+ 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) {
+ if (node != nullptr) {
*value = node->value;
return 1;
}
@@ -200,8 +200,8 @@ 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) {
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) {
@@ -228,14 +228,14 @@ gpr_avl gpr_avl_add(gpr_avl avl, void* key, void* value, void* user_data) {
}
static gpr_avl_node* in_order_head(gpr_avl_node* node) {
- while (node->left != NULL) {
+ while (node->left != nullptr) {
node = node->left;
}
return node;
}
static gpr_avl_node* in_order_tail(gpr_avl_node* node) {
- while (node->right != NULL) {
+ while (node->right != nullptr) {
node = node->right;
}
return node;
@@ -245,14 +245,14 @@ 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);
@@ -297,4 +297,4 @@ 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.cc b/src/core/lib/support/cmdline.cc
index d2785d2f30..da9f10a496 100644
--- a/src/core/lib/support/cmdline.cc
+++ b/src/core/lib/support/cmdline.cc
@@ -169,7 +169,7 @@ 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;
}
@@ -203,7 +203,7 @@ static arg* find_arg(gpr_cmdline* cl, char* name) {
if (!a) {
fprintf(stderr, "Unknown argument: %s\n", name);
- return NULL;
+ return nullptr;
}
return a;
@@ -246,9 +246,9 @@ static int value_state(gpr_cmdline* cl, char* str) {
}
static int normal_state(gpr_cmdline* cl, char* str) {
- char* eq = NULL;
- char* tmp = NULL;
- char* arg_name = NULL;
+ 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,7 +274,7 @@ 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) {
@@ -285,7 +285,7 @@ static int normal_state(gpr_cmdline* cl, char* str) {
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));
memcpy(arg_name, str, (size_t)(eq - str));
@@ -294,10 +294,10 @@ static int normal_state(gpr_cmdline* cl, char* str) {
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) {
diff --git a/src/core/lib/support/cpu_linux.cc b/src/core/lib/support/cpu_linux.cc
index 2280668442..21b1a71dc9 100644
--- a/src/core/lib/support/cpu_linux.cc
+++ b/src/core/lib/support/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.cc b/src/core/lib/support/cpu_posix.cc
index 503a96b4c8..bca14a0c12 100644
--- a/src/core/lib/support/cpu_posix.cc
+++ b/src/core/lib/support/cpu_posix.cc
@@ -18,21 +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) {
@@ -47,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/debug_location.h b/src/core/lib/support/debug_location.h
new file mode 100644
index 0000000000..0939da595d
--- /dev/null
+++ b/src/core/lib/support/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_SUPPORT_DEBUG_LOCATION_H
+#define GRPC_CORE_LIB_SUPPORT_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 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 DebugLocation()
+#endif
+
+} // namespace grpc_core
+
+#endif /* GRPC_CORE_LIB_SUPPORT_DEBUG_LOCATION_H */
diff --git a/src/core/lib/support/env.h b/src/core/lib/support/env.h
index f50d7bcb7a..2452fd330d 100644
--- a/src/core/lib/support/env.h
+++ b/src/core/lib/support/env.h
@@ -21,10 +21,6 @@
#include <stdio.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Env utility functions */
/* Gets the environment variable value with the specified name.
@@ -42,8 +38,4 @@ void gpr_setenv(const char* name, const char* value);
level of logging. So DO NOT USE THIS. */
const char* gpr_getenv_silent(const char* name, char** dst);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SUPPORT_ENV_H */
diff --git a/src/core/lib/support/env_linux.cc b/src/core/lib/support/env_linux.cc
index 012ef63eff..0af2de9f7e 100644
--- a/src/core/lib/support/env_linux.cc
+++ b/src/core/lib/support/env_linux.cc
@@ -39,8 +39,8 @@
#include "src/core/lib/support/string.h"
const char* gpr_getenv_silent(const char* name, char** dst) {
- const char* insecure_func_used = NULL;
- char* result = NULL;
+ const char* insecure_func_used = nullptr;
+ char* result = nullptr;
#if defined(GPR_BACKWARDS_COMPATIBILITY_MODE)
typedef char* (*getenv_type)(const char*);
static getenv_type getenv_func = NULL;
@@ -60,14 +60,14 @@ 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;
+ char* result = nullptr;
const char* insecure_func_used = gpr_getenv_silent(name, &result);
- if (insecure_func_used != NULL) {
+ if (insecure_func_used != nullptr) {
gpr_log(GPR_DEBUG, "Warning: insecure environment read function '%s' used",
insecure_func_used);
}
diff --git a/src/core/lib/support/fork.cc b/src/core/lib/support/fork.cc
new file mode 100644
index 0000000000..d59ca5584c
--- /dev/null
+++ b/src/core/lib/support/fork.cc
@@ -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.
+ *
+ */
+
+#include "src/core/lib/support/fork.h"
+
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/useful.h>
+
+#include "src/core/lib/support/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;
+ char* env = gpr_getenv("GRPC_ENABLE_FORK_SUPPORT");
+ if (env != NULL) {
+ static const char* truthy[] = {"yes", "Yes", "YES", "true",
+ "True", "TRUE", "1"};
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(truthy); i++) {
+ if (0 == strcmp(env, truthy[i])) {
+ fork_support_enabled = 1;
+ }
+ }
+ gpr_free(env);
+ }
+#endif
+ 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/support/fork.h b/src/core/lib/support/fork.h
new file mode 100644
index 0000000000..215d4214a6
--- /dev/null
+++ b/src/core/lib/support/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_SUPPORT_FORK_H
+#define GRPC_CORE_LIB_SUPPORT_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_SUPPORT_FORK_H */
diff --git a/src/core/lib/support/host_port.cc b/src/core/lib/support/host_port.cc
index 1927d5507d..cb8e3d4479 100644
--- a/src/core/lib/support/host_port.cc
+++ b/src/core/lib/support/host_port.cc
@@ -26,7 +26,7 @@
#include "src/core/lib/support/string.h"
int gpr_join_host_port(char** out, const char* host, int port) {
- if (host[0] != '[' && strchr(host, ':') != NULL) {
+ if (host[0] != '[' && strchr(host, ':') != nullptr) {
/* IPv6 literals must be enclosed in brackets. */
return gpr_asprintf(out, "[%s]:%d", host, port);
} else {
@@ -40,19 +40,19 @@ int gpr_split_host_port(const char* name, char** host, char** port) {
size_t host_len;
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) {
+ 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) {
+ if (colon != nullptr && strchr(colon + 1, ':') == nullptr) {
/* Exactly 1 colon. Split into host:port. */
host_start = name;
host_len = (size_t)(colon - name);
@@ -78,7 +78,7 @@ 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;
}
}
@@ -87,7 +87,7 @@ int gpr_split_host_port(const char* name, char** host, char** port) {
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.cc b/src/core/lib/support/log.cc
index 2140e4bd69..2a40745e97 100644
--- a/src/core/lib/support/log.cc
+++ b/src/core/lib/support/log.cc
@@ -27,7 +27,7 @@
#include <stdio.h>
#include <string.h>
-extern "C" 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;
@@ -64,11 +64,11 @@ void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print) {
}
void gpr_log_verbosity_init() {
- char* verbosity = NULL;
+ 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.cc b/src/core/lib/support/log_android.cc
index 73d24cd84d..0d3ac0fe52 100644
--- a/src/core/lib/support/log_android.cc
+++ b/src/core/lib/support/log_android.cc
@@ -39,8 +39,8 @@ static android_LogPriority severity_to_log_priority(gpr_log_severity severity) {
return ANDROID_LOG_DEFAULT;
}
-extern "C" 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* message = NULL;
va_list args;
va_start(args, format);
@@ -50,7 +50,7 @@ extern "C" void gpr_log(const char* file, int line, gpr_log_severity severity,
free(message);
}
-extern "C" void gpr_default_log(gpr_log_func_args* args) {
+void gpr_default_log(gpr_log_func_args* args) {
const char* final_slash;
const char* display_file;
char* output = NULL;
diff --git a/src/core/lib/support/log_linux.cc b/src/core/lib/support/log_linux.cc
index e9be970305..6b1f1c71e4 100644
--- a/src/core/lib/support/log_linux.cc
+++ b/src/core/lib/support/log_linux.cc
@@ -43,7 +43,7 @@ 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;
+ char* message = nullptr;
va_list args;
va_start(args, format);
if (vasprintf(&message, format, args) == -1) {
@@ -56,7 +56,7 @@ void gpr_log(const char* file, int line, gpr_log_severity severity,
free(message);
}
-extern "C" void gpr_default_log(gpr_log_func_args* args) {
+void gpr_default_log(gpr_log_func_args* args) {
const char* final_slash;
char* prefix;
const char* display_file;
@@ -69,7 +69,7 @@ extern "C" 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.cc b/src/core/lib/support/log_posix.cc
index e765f91390..9fab480a8d 100644
--- a/src/core/lib/support/log_posix.cc
+++ b/src/core/lib/support/log_posix.cc
@@ -56,7 +56,7 @@ void gpr_log(const char* file, int line, gpr_log_severity severity,
gpr_free(allocated);
}
-extern "C" void gpr_default_log(gpr_log_func_args* args) {
+void gpr_default_log(gpr_log_func_args* args) {
const char* final_slash;
const char* display_file;
char time_buffer[64];
diff --git a/src/core/lib/support/log_windows.cc b/src/core/lib/support/log_windows.cc
index d4481791e2..0013bf448f 100644
--- a/src/core/lib/support/log_windows.cc
+++ b/src/core/lib/support/log_windows.cc
@@ -65,7 +65,7 @@ void gpr_log(const char* file, int line, gpr_log_severity severity,
}
/* Simple starter implementation */
-extern "C" void gpr_default_log(gpr_log_func_args* args) {
+void gpr_default_log(gpr_log_func_args* args) {
const char* final_slash;
const char* display_file;
char time_buffer[64];
diff --git a/src/core/lib/support/manual_constructor.h b/src/core/lib/support/manual_constructor.h
index d753cf98a0..fda7653dbc 100644
--- a/src/core/lib/support/manual_constructor.h
+++ b/src/core/lib/support/manual_constructor.h
@@ -22,12 +22,147 @@
// 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:
diff --git a/src/core/lib/support/memory.h b/src/core/lib/support/memory.h
index 6b336681db..695418e3e1 100644
--- a/src/core/lib/support/memory.h
+++ b/src/core/lib/support/memory.h
@@ -76,7 +76,7 @@ class Allocator {
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 = 0) {
+ 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); }
diff --git a/src/core/lib/support/mpscq.cc b/src/core/lib/support/mpscq.cc
index b270777d5c..47e896d2df 100644
--- a/src/core/lib/support/mpscq.cc
+++ b/src/core/lib/support/mpscq.cc
@@ -49,15 +49,15 @@ gpr_mpscq_node* gpr_mpscq_pop_and_check_end(gpr_mpscq* q, bool* empty) {
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) {
+ if (next == nullptr) {
*empty = true;
- return NULL;
+ return nullptr;
}
q->tail = next;
tail = next;
next = (gpr_mpscq_node*)gpr_atm_acq_load(&tail->next);
}
- if (next != NULL) {
+ if (next != nullptr) {
*empty = false;
q->tail = next;
return tail;
@@ -66,17 +66,17 @@ gpr_mpscq_node* gpr_mpscq_pop_and_check_end(gpr_mpscq* q, bool* empty) {
if (tail != head) {
*empty = false;
// indicates a retry is in order: we're still adding
- return NULL;
+ return nullptr;
}
gpr_mpscq_push(q, &q->stub);
next = (gpr_mpscq_node*)gpr_atm_acq_load(&tail->next);
- if (next != NULL) {
+ if (next != nullptr) {
q->tail = next;
return tail;
}
// indicates a retry is in order: we're still adding
*empty = false;
- return NULL;
+ return nullptr;
}
void gpr_locked_mpscq_init(gpr_locked_mpscq* q) {
@@ -99,7 +99,7 @@ gpr_mpscq_node* gpr_locked_mpscq_try_pop(gpr_locked_mpscq* q) {
gpr_mu_unlock(&q->mu);
return n;
}
- return NULL;
+ return nullptr;
}
gpr_mpscq_node* gpr_locked_mpscq_pop(gpr_locked_mpscq* q) {
@@ -108,7 +108,7 @@ gpr_mpscq_node* gpr_locked_mpscq_pop(gpr_locked_mpscq* q) {
gpr_mpscq_node* n;
do {
n = gpr_mpscq_pop_and_check_end(&q->queue, &empty);
- } while (n == NULL && !empty);
+ } while (n == nullptr && !empty);
gpr_mu_unlock(&q->mu);
return n;
}
diff --git a/src/core/lib/support/mpscq.h b/src/core/lib/support/mpscq.h
index fb22742050..648ead1f5b 100644
--- a/src/core/lib/support/mpscq.h
+++ b/src/core/lib/support/mpscq.h
@@ -24,10 +24,6 @@
#include <stdbool.h>
#include <stddef.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
// 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
@@ -84,8 +80,5 @@ 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);
-#ifdef __cplusplus
-}
-#endif
#endif /* GRPC_CORE_LIB_SUPPORT_MPSCQ_H */
diff --git a/src/core/lib/support/murmur_hash.cc b/src/core/lib/support/murmur_hash.cc
index 4e08579a1d..2f0e71a53c 100644
--- a/src/core/lib/support/murmur_hash.cc
+++ b/src/core/lib/support/murmur_hash.cc
@@ -30,22 +30,19 @@
(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 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/support/murmur_hash.h
index d02bba6962..422770f103 100644
--- a/src/core/lib/support/murmur_hash.h
+++ b/src/core/lib/support/murmur_hash.h
@@ -23,15 +23,7 @@
#include <stddef.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* compute the hash of key (length len) */
uint32_t gpr_murmur_hash3(const void* key, size_t len, uint32_t seed);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SUPPORT_MURMUR_HASH_H */
diff --git a/src/core/lib/support/ref_counted.h b/src/core/lib/support/ref_counted.h
new file mode 100644
index 0000000000..4c662f9119
--- /dev/null
+++ b/src/core/lib/support/ref_counted.h
@@ -0,0 +1,122 @@
+/*
+ *
+ * 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_SUPPORT_REF_COUNTED_H
+#define GRPC_CORE_LIB_SUPPORT_REF_COUNTED_H
+
+#include <grpc/support/log.h>
+#include <grpc/support/sync.h>
+
+#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/support/debug_location.h"
+#include "src/core/lib/support/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;
+
+ 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;
+
+ protected:
+ // Allow Delete() to access destructor.
+ template <typename T>
+ friend void Delete(T*);
+
+ RefCountedWithTracing() : RefCountedWithTracing(nullptr) {}
+
+ explicit RefCountedWithTracing(TraceFlag* trace_flag)
+ : trace_flag_(trace_flag) {
+ gpr_ref_init(&refs_, 1);
+ }
+
+ virtual ~RefCountedWithTracing() {}
+
+ private:
+ TraceFlag* trace_flag_ = nullptr;
+ gpr_refcount refs_;
+};
+
+} // namespace grpc_core
+
+#endif /* GRPC_CORE_LIB_SUPPORT_REF_COUNTED_H */
diff --git a/src/core/lib/support/ref_counted_ptr.h b/src/core/lib/support/ref_counted_ptr.h
new file mode 100644
index 0000000000..dc2385e369
--- /dev/null
+++ b/src/core/lib/support/ref_counted_ptr.h
@@ -0,0 +1,90 @@
+/*
+ *
+ * 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_SUPPORT_REF_COUNTED_PTR_H
+#define GRPC_CORE_LIB_SUPPORT_REF_COUNTED_PTR_H
+
+#include <utility>
+
+#include "src/core/lib/support/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_; }
+
+ 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_SUPPORT_REF_COUNTED_PTR_H */
diff --git a/src/core/lib/support/stack_lockfree.cc b/src/core/lib/support/stack_lockfree.cc
deleted file mode 100644
index 7a4ede3b92..0000000000
--- a/src/core/lib/support/stack_lockfree.cc
+++ /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 337ecc2b17..0000000000
--- a/src/core/lib/support/stack_lockfree.h
+++ /dev/null
@@ -1,46 +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>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-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);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GRPC_CORE_LIB_SUPPORT_STACK_LOCKFREE_H */
diff --git a/src/core/lib/support/string.cc b/src/core/lib/support/string.cc
index 6dc4fbc921..e31ad72c68 100644
--- a/src/core/lib/support/string.cc
+++ b/src/core/lib/support/string.cc
@@ -35,7 +35,7 @@ char* gpr_strdup(const char* src) {
size_t len;
if (!src) {
- return NULL;
+ return nullptr;
}
len = strlen(src) + 1;
@@ -53,7 +53,7 @@ typedef struct {
} dump_out;
static dump_out dump_out_create(void) {
- dump_out r = {0, 0, NULL};
+ dump_out r = {0, 0, nullptr};
return r;
}
@@ -223,7 +223,7 @@ 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;
@@ -278,7 +278,7 @@ static void add_string_to_split(const char* beg, const char* end, char*** strs,
void gpr_string_split(const char* input, const char* sep, char*** strs,
size_t* nstrs) {
const char* next;
- *strs = NULL;
+ *strs = nullptr;
*nstrs = 0;
size_t capstrs = 0;
while ((next = strstr(input, sep))) {
@@ -289,7 +289,7 @@ void gpr_string_split(const char* input, const char* sep, char*** strs,
}
void* gpr_memrchr(const void* s, int c, size_t n) {
- if (s == NULL) return NULL;
+ if (s == nullptr) return nullptr;
char* b = (char*)s;
size_t i;
for (i = 0; i < n; i++) {
@@ -297,12 +297,12 @@ void* gpr_memrchr(const void* s, int c, size_t n) {
return &b[n - i - 1];
}
}
- return NULL;
+ return nullptr;
}
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"};
diff --git a/src/core/lib/support/string.h b/src/core/lib/support/string.h
index 0b18ffcec1..dd37f0b0e1 100644
--- a/src/core/lib/support/string.h
+++ b/src/core/lib/support/string.h
@@ -24,10 +24,6 @@
#include <grpc/support/port_platform.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* String utility functions */
/* Flags for gpr_dump function. */
@@ -109,8 +105,5 @@ 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
#endif /* GRPC_CORE_LIB_SUPPORT_STRING_H */
diff --git a/src/core/lib/support/string_posix.cc b/src/core/lib/support/string_posix.cc
index 79c81656cc..8b818e39b9 100644
--- a/src/core/lib/support/string_posix.cc
+++ b/src/core/lib/support/string_posix.cc
@@ -38,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;
}
@@ -65,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_windows.h b/src/core/lib/support/string_windows.h
index 6771647581..7c7f31e7aa 100644
--- a/src/core/lib/support/string_windows.h
+++ b/src/core/lib/support/string_windows.h
@@ -21,10 +21,6 @@
#include <grpc/support/port_platform.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#ifdef GPR_WINDOWS
/* These allocate new strings using gpr_malloc to convert from and to utf-8. */
@@ -33,8 +29,4 @@ LPSTR gpr_tchar_to_char(LPCTSTR input);
#endif /* GPR_WINDOWS */
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SUPPORT_STRING_WINDOWS_H */
diff --git a/src/core/lib/support/subprocess_posix.cc b/src/core/lib/support/subprocess_posix.cc
index 4d6972a0c4..dc046b6499 100644
--- a/src/core/lib/support/subprocess_posix.cc
+++ b/src/core/lib/support/subprocess_posix.cc
@@ -50,16 +50,16 @@ gpr_subprocess* gpr_subprocess_create(int argc, const char** argv) {
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[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->pid = pid;
diff --git a/src/core/lib/support/sync.cc b/src/core/lib/support/sync.cc
index 1c051a1ca4..347ffcd00e 100644
--- a/src/core/lib/support/sync.cc
+++ b/src/core/lib/support/sync.cc
@@ -61,7 +61,7 @@ void gpr_event_set(gpr_event* ev, void* value) {
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) {
@@ -70,12 +70,12 @@ void* gpr_event_get(gpr_event* ev) {
void* gpr_event_wait(gpr_event* ev, gpr_timespec abs_deadline) {
void* result = (void*)gpr_atm_acq_load(&ev->state);
- if (result == NULL) {
+ 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));
+ } while (result == nullptr && !gpr_cv_wait(&s->cv, &s->mu, abs_deadline));
gpr_mu_unlock(&s->mu);
}
return result;
diff --git a/src/core/lib/support/sync_posix.cc b/src/core/lib/support/sync_posix.cc
index 62d800b18c..dfdd233bf4 100644
--- a/src/core/lib/support/sync_posix.cc
+++ b/src/core/lib/support/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,9 @@ 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) {
+ GPR_ASSERT(pthread_cond_init(cv, nullptr) == 0);
+}
void gpr_cv_destroy(gpr_cv* cv) { GPR_ASSERT(pthread_cond_destroy(cv) == 0); }
diff --git a/src/core/lib/support/thd_internal.h b/src/core/lib/support/thd_internal.h
new file mode 100644
index 0000000000..38bffc847d
--- /dev/null
+++ b/src/core/lib/support/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_SUPPORT_THD_INTERNAL_H
+#define GRPC_CORE_LIB_SUPPORT_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_SUPPORT_THD_INTERNAL_H */
diff --git a/src/core/lib/support/thd_posix.cc b/src/core/lib/support/thd_posix.cc
index 297714e659..f0ed48dbfc 100644
--- a/src/core/lib/support/thd_posix.cc
+++ b/src/core/lib/support/thd_posix.cc
@@ -24,26 +24,53 @@
#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/support/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);
- return NULL;
+ dec_thd_count();
+ return nullptr;
}
-int gpr_thd_new(gpr_thd_id* t, void (*thd_body)(void* arg), void* arg,
+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;
@@ -51,9 +78,11 @@ int gpr_thd_new(gpr_thd_id* t, void (*thd_body)(void* arg), void* arg,
/* 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);
+ 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)) {
@@ -68,6 +97,7 @@ int gpr_thd_new(gpr_thd_id* t, void (*thd_body)(void* arg), void* arg,
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;
@@ -75,6 +105,48 @@ 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)pthread_self(); }
-void gpr_thd_join(gpr_thd_id t) { pthread_join((pthread_t)t, NULL); }
+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.cc b/src/core/lib/support/thd_windows.cc
index 5bda7f440c..f920770f32 100644
--- a/src/core/lib/support/thd_windows.cc
+++ b/src/core/lib/support/thd_windows.cc
@@ -50,6 +50,8 @@ static void destroy_thread(struct thd_info* t) {
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;
@@ -63,7 +65,8 @@ static DWORD WINAPI thread_body(void* v) {
return 0;
}
-int gpr_thd_new(gpr_thd_id* t, void (*thd_body)(void* arg), void* arg,
+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 = (struct thd_info*)gpr_malloc(sizeof(*info));
diff --git a/src/core/lib/support/time_posix.cc b/src/core/lib/support/time_posix.cc
index 3674ef7184..47a849480f 100644
--- a/src/core/lib/support/time_posix.cc
+++ b/src/core/lib/support/time_posix.cc
@@ -127,9 +127,7 @@ static gpr_timespec now_impl(gpr_clock_type clock) {
}
#endif
-extern "C" {
gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type) = now_impl;
-}
#ifdef GPR_LOW_LEVEL_COUNTERS
gpr_atm gpr_now_call_count;
@@ -158,7 +156,7 @@ void gpr_sleep_until(gpr_timespec until) {
delta = gpr_time_sub(until, now);
delta_ts = timespec_from_gpr(delta);
- ns_result = nanosleep(&delta_ts, NULL);
+ ns_result = nanosleep(&delta_ts, nullptr);
if (ns_result == 0) {
break;
}
diff --git a/src/core/lib/support/time_precise.h b/src/core/lib/support/time_precise.h
index 3befda3d86..35cd154dbd 100644
--- a/src/core/lib/support/time_precise.h
+++ b/src/core/lib/support/time_precise.h
@@ -21,15 +21,7 @@
#include <grpc/support/time.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
void gpr_precise_clock_init(void);
void gpr_precise_clock_now(gpr_timespec* clk);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SUPPORT_TIME_PRECISE_H */
diff --git a/src/core/lib/support/time_windows.cc b/src/core/lib/support/time_windows.cc
index 08c1b22964..fb17e5c079 100644
--- a/src/core/lib/support/time_windows.cc
+++ b/src/core/lib/support/time_windows.cc
@@ -68,9 +68,7 @@ static gpr_timespec now_impl(gpr_clock_type clock) {
return now_tv;
}
-extern "C" {
gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type) = now_impl;
-}
gpr_timespec gpr_now(gpr_clock_type clock_type) {
return gpr_now_impl(clock_type);
diff --git a/src/core/lib/support/tmpfile.h b/src/core/lib/support/tmpfile.h
index 437d871786..c5ceda8675 100644
--- a/src/core/lib/support/tmpfile.h
+++ b/src/core/lib/support/tmpfile.h
@@ -21,18 +21,10 @@
#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
-
#endif /* GRPC_CORE_LIB_SUPPORT_TMPFILE_H */
diff --git a/src/core/lib/support/tmpfile_posix.cc b/src/core/lib/support/tmpfile_posix.cc
index 2e14d28598..79c5c68874 100644
--- a/src/core/lib/support/tmpfile_posix.cc
+++ b/src/core/lib/support/tmpfile_posix.cc
@@ -34,14 +34,14 @@
#include "src/core/lib/support/string.h"
FILE* gpr_tmpfile(const char* prefix, char** tmp_filename) {
- FILE* result = NULL;
+ 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/surface/alarm.cc b/src/core/lib/surface/alarm.cc
index bc38692ec8..b1c9f7b164 100644
--- a/src/core/lib/surface/alarm.cc
+++ b/src/core/lib/surface/alarm.cc
@@ -27,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;
@@ -48,7 +46,7 @@ static void alarm_ref(grpc_alarm* alarm) { gpr_ref(&alarm->refs); }
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) {
+ if (alarm->cq != nullptr) {
GRPC_CQ_INTERNAL_UNREF(&exec_ctx, alarm->cq, "alarm");
}
grpc_exec_ctx_finish(&exec_ctx);
@@ -59,7 +57,7 @@ static void alarm_unref(grpc_alarm* 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)) {
+ 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,
@@ -71,7 +69,7 @@ static void alarm_ref_dbg(grpc_alarm* alarm, const char* reason,
static void alarm_unref_dbg(grpc_alarm* alarm, const char* reason,
const char* file, int line) {
- if (GRPC_TRACER_ON(grpc_trace_alarm_refcount)) {
+ 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,
@@ -103,14 +101,14 @@ 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;
diff --git a/src/core/lib/surface/alarm_internal.h b/src/core/lib/surface/alarm_internal.h
index 136b60547f..99e981234d 100644
--- a/src/core/lib/surface/alarm_internal.h
+++ b/src/core/lib/surface/alarm_internal.h
@@ -22,14 +22,10 @@
#include <grpc/support/log.h>
#include "src/core/lib/debug/trace.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+extern grpc_core::DebugOnlyTraceFlag grpc_trace_alarm_refcount;
#ifndef NDEBUG
-extern grpc_tracer_flag grpc_trace_alarm_refcount;
-
#define GRPC_ALARM_REF(a, reason) alarm_ref_dbg(a, reason, __FILE__, __LINE__)
#define GRPC_ALARM_UNREF(a, reason) \
alarm_unref_dbg(a, reason, __FILE__, __LINE__)
@@ -41,8 +37,4 @@ extern grpc_tracer_flag grpc_trace_alarm_refcount;
#endif /* defined(NDEBUG) */
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SURFACE_ALARM_INTERNAL_H */
diff --git a/src/core/lib/surface/api_trace.cc b/src/core/lib/surface/api_trace.cc
index 56973303da..7ab836a9ba 100644
--- a/src/core/lib/surface/api_trace.cc
+++ 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 105abdf629..a4e11ce154 100644
--- a/src/core/lib/surface/api_trace.h
+++ b/src/core/lib/surface/api_trace.h
@@ -22,11 +22,7 @@
#include <grpc/support/log.h>
#include "src/core/lib/debug/trace.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-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... */
@@ -47,12 +43,8 @@ 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); \
}
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SURFACE_API_TRACE_H */
diff --git a/src/core/lib/surface/byte_buffer.cc b/src/core/lib/surface/byte_buffer.cc
index a640f782a7..9e0636b4ce 100644
--- a/src/core/lib/surface/byte_buffer.cc
+++ b/src/core/lib/surface/byte_buffer.cc
@@ -66,7 +66,7 @@ grpc_byte_buffer* grpc_byte_buffer_copy(grpc_byte_buffer* bb) {
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) {
diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc
index 9fd4fdbef9..a2eb02bd85 100644
--- a/src/core/lib/surface/call.cc
+++ b/src/core/lib/surface/call.cc
@@ -234,6 +234,7 @@ struct grpc_call {
struct {
grpc_status_code* status;
grpc_slice* status_details;
+ const char** error_string;
} client;
struct {
int* cancelled;
@@ -259,10 +260,8 @@ 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)
@@ -286,7 +285,8 @@ static void receiving_slice_ready(grpc_exec_ctx* exec_ctx, void* bctlp,
static void get_final_status(grpc_exec_ctx* exec_ctx, grpc_call* call,
void (*set_value)(grpc_status_code code,
void* user_data),
- void* set_value_user_data, grpc_slice* details);
+ 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_exec_ctx* exec_ctx, grpc_call* call,
status_source source, grpc_error* error);
@@ -308,7 +308,7 @@ void* grpc_call_arena_alloc(grpc_call* call, size_t 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) {
+ 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)) {
@@ -346,7 +346,7 @@ grpc_error* grpc_call_create(grpc_exec_ctx* exec_ctx,
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;
+ call->is_client = args->server_transport_data == nullptr;
if (call->is_client) {
GRPC_STATS_INC_CLIENT_CALLS_CREATED(exec_ctx);
} else {
@@ -379,7 +379,7 @@ grpc_error* grpc_call_create(grpc_exec_ctx* exec_ctx,
bool immediately_cancel = false;
- if (args->parent != NULL) {
+ if (args->parent != nullptr) {
child_call* cc = call->child =
(child_call*)gpr_arena_alloc(arena, sizeof(child_call));
call->child->parent = args->parent;
@@ -407,7 +407,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 "
@@ -420,7 +420,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 {
@@ -455,15 +455,15 @@ grpc_error* grpc_call_create(grpc_exec_ctx* exec_ctx,
cancel_with_error(exec_ctx, call, STATUS_FROM_API_OVERRIDE,
GRPC_ERROR_CANCELLED);
}
- if (args->cq != NULL) {
+ if (args->cq != nullptr) {
GPR_ASSERT(
- args->pollset_set_alternative == NULL &&
+ args->pollset_set_alternative == nullptr &&
"Only one of 'cq' and 'pollset_set_alternative' should be non-NULL.");
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);
}
@@ -482,7 +482,7 @@ void grpc_call_set_completion_queue(grpc_exec_ctx* exec_ctx, 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();
}
@@ -528,11 +528,11 @@ static void destroy_call(grpc_exec_ctx* exec_ctx, void* call,
grpc_metadata_batch_destroy(
exec_ctx, &c->metadata_batch[1 /* is_receiving */][i /* is_initial */]);
}
- if (c->receiving_stream != NULL) {
+ if (c->receiving_stream != nullptr) {
grpc_byte_stream_destroy(exec_ctx, c->receiving_stream);
}
parent_call* pc = get_parent_call(c);
- if (pc != NULL) {
+ if (pc != nullptr) {
gpr_mu_destroy(&pc->child_list_mu);
}
for (ii = 0; ii < c->send_extra_metadata_count; ii++) {
@@ -548,7 +548,8 @@ static void destroy_call(grpc_exec_ctx* exec_ctx, void* call,
}
get_final_status(exec_ctx, c, set_status_value_directly,
- &c->final_info.final_status, NULL);
+ &c->final_info.final_status, nullptr,
+ c->final_info.error_string);
c->final_info.stats.latency =
gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), c->start_time);
@@ -580,7 +581,7 @@ void grpc_call_unref(grpc_call* c) {
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;
@@ -601,7 +602,8 @@ void grpc_call_unref(grpc_call* c) {
// 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(&exec_ctx, &c->call_combiner,
+ nullptr);
}
GRPC_CALL_INTERNAL_UNREF(&exec_ctx, c, "destroy");
grpc_exec_ctx_finish(&exec_ctx);
@@ -645,9 +647,9 @@ static void execute_batch(grpc_exec_ctx* exec_ctx, grpc_call* call,
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);
+ 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");
}
@@ -668,7 +670,7 @@ grpc_call_error grpc_call_cancel_with_status(grpc_call* c,
"grpc_call_cancel_with_status("
"c=%p, status=%d, description=%s, reserved=%p)",
4, (c, (int)status, description, reserved));
- GPR_ASSERT(reserved == NULL);
+ GPR_ASSERT(reserved == nullptr);
cancel_with_status(&exec_ctx, c, STATUS_FROM_API_OVERRIDE, status,
description);
grpc_exec_ctx_finish(&exec_ctx);
@@ -734,22 +736,21 @@ static void cancel_with_status(grpc_exec_ctx* exec_ctx, grpc_call* c,
* FINAL STATUS CODE MANIPULATION
*/
-static bool get_final_status_from(grpc_exec_ctx* exec_ctx, 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) {
+static bool get_final_status_from(
+ grpc_exec_ctx* exec_ctx, 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(exec_ctx, error, call->send_deadline, &code, &slice,
- NULL);
+ 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;
@@ -758,13 +759,14 @@ static bool get_final_status_from(grpc_exec_ctx* exec_ctx, grpc_call* call,
static void get_final_status(grpc_exec_ctx* exec_ctx, grpc_call* call,
void (*set_value)(grpc_status_code code,
void* user_data),
- void* set_value_user_data, grpc_slice* details) {
+ 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) {
@@ -782,7 +784,7 @@ static void get_final_status(grpc_exec_ctx* exec_ctx, grpc_call* call,
grpc_error_has_clear_grpc_status(status[i].error)) {
if (get_final_status_from(exec_ctx, call, status[i].error,
allow_ok_status != 0, set_value,
- set_value_user_data, details)) {
+ set_value_user_data, details, error_string)) {
return;
}
}
@@ -792,7 +794,7 @@ static void get_final_status(grpc_exec_ctx* exec_ctx, grpc_call* call,
if (status[i].is_set) {
if (get_final_status_from(exec_ctx, call, status[i].error,
allow_ok_status != 0, set_value,
- set_value_user_data, details)) {
+ set_value_user_data, details, error_string)) {
return;
}
}
@@ -869,7 +871,7 @@ static void set_encodings_accepted_by_peer(grpc_exec_ctx* exec_ctx,
accepted_user_data =
grpc_mdelem_get_user_data(mdel, destroy_encodings_accepted_by_peer);
- if (accepted_user_data != NULL) {
+ if (accepted_user_data != nullptr) {
call->encodings_accepted_by_peer =
(uint32_t)(((uintptr_t)accepted_user_data) - 1);
return;
@@ -916,7 +918,7 @@ static void set_stream_encodings_accepted_by_peer(grpc_exec_ctx* exec_ctx,
accepted_user_data =
grpc_mdelem_get_user_data(mdel, destroy_encodings_accepted_by_peer);
- if (accepted_user_data != NULL) {
+ if (accepted_user_data != nullptr) {
call->stream_encodings_accepted_by_peer =
(uint32_t)(((uintptr_t)accepted_user_data) - 1);
return;
@@ -1053,7 +1055,7 @@ static uint32_t decode_status(grpc_mdelem md) {
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)) {
@@ -1109,7 +1111,7 @@ static void publish_app_metadata(grpc_call* call, grpc_metadata_batch* b,
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);
@@ -1120,8 +1122,8 @@ static void publish_app_metadata(grpc_call* call, grpc_metadata_batch* b,
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) {
+ if (b->idx.named.content_encoding != nullptr) {
+ if (b->idx.named.grpc_encoding != nullptr) {
gpr_log(GPR_ERROR,
"Received both content-encoding and grpc-encoding header. "
"Ignoring grpc-encoding.");
@@ -1132,21 +1134,21 @@ static void recv_initial_filter(grpc_exec_ctx* exec_ctx, grpc_call* call,
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) {
+ } else if (b->idx.named.grpc_encoding != nullptr) {
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) {
+ 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);
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);
@@ -1159,7 +1161,7 @@ static void recv_initial_filter(grpc_exec_ctx* exec_ctx, grpc_call* call,
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) {
+ if (b->idx.named.grpc_status != nullptr) {
uint32_t status_code = decode_status(b->idx.named.grpc_status->md);
grpc_error* error =
status_code == GRPC_STATUS_OK
@@ -1168,7 +1170,7 @@ static void recv_trailing_filter(grpc_exec_ctx* exec_ctx, void* args,
"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)));
@@ -1241,13 +1243,13 @@ static batch_control* allocate_batch_control(grpc_call* call,
size_t num_ops) {
int slot = batch_slot_for_op(ops[0].op);
batch_control** pslot = &call->active_batches[slot];
- if (*pslot == NULL) {
+ if (*pslot == nullptr) {
*pslot =
(batch_control*)gpr_arena_alloc(call->arena, sizeof(batch_control));
}
batch_control* bctl = *pslot;
- if (bctl->call != NULL) {
- return NULL;
+ if (bctl->call != nullptr) {
+ return nullptr;
}
memset(bctl, 0, sizeof(*bctl));
bctl->call = call;
@@ -1259,7 +1261,7 @@ 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;
+ bctl->call = nullptr;
GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, "completion");
}
@@ -1271,14 +1273,14 @@ static grpc_error* consolidate_batch_errors(batch_control* bctl) {
/* Skip creating a composite error in the case that only one error was
logged */
grpc_error* e = bctl->errors[0];
- bctl->errors[0] = NULL;
+ bctl->errors[0] = nullptr;
return e;
} else {
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;
}
@@ -1311,11 +1313,11 @@ static void post_batch_completion(grpc_exec_ctx* exec_ctx,
/* 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) {
+ 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) {
@@ -1333,24 +1335,25 @@ static void post_batch_completion(grpc_exec_ctx* exec_ctx,
if (call->is_client) {
get_final_status(exec_ctx, 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(exec_ctx, 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 != NULL) {
+ *call->receiving_buffer != nullptr) {
grpc_byte_buffer_destroy(*call->receiving_buffer);
- *call->receiving_buffer = NULL;
+ *call->receiving_buffer = nullptr;
}
if (bctl->completion_data.notify_tag.is_closure) {
/* unrefs bctl->error */
- bctl->call = NULL;
+ bctl->call = nullptr;
GRPC_CLOSURE_RUN(
exec_ctx, (grpc_closure*)bctl->completion_data.notify_tag.tag, error);
GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, "completion");
@@ -1378,7 +1381,7 @@ static void continue_receiving_slices(grpc_exec_ctx* exec_ctx,
if (remaining == 0) {
call->receiving_message = 0;
grpc_byte_stream_destroy(exec_ctx, call->receiving_stream);
- call->receiving_stream = NULL;
+ call->receiving_stream = nullptr;
finish_batch_step(exec_ctx, bctl);
return;
}
@@ -1391,9 +1394,9 @@ static void continue_receiving_slices(grpc_exec_ctx* exec_ctx,
call->receiving_slice);
} else {
grpc_byte_stream_destroy(exec_ctx, call->receiving_stream);
- call->receiving_stream = NULL;
+ 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);
return;
@@ -1426,13 +1429,13 @@ 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;
+ 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);
if (release_error) {
@@ -1444,8 +1447,8 @@ static void receiving_slice_ready(grpc_exec_ctx* exec_ctx, void* bctlp,
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;
+ if (call->receiving_stream == nullptr) {
+ *call->receiving_buffer = nullptr;
call->receiving_message = 0;
finish_batch_step(exec_ctx, bctl);
} else {
@@ -1453,9 +1456,9 @@ static void process_data_after_md(grpc_exec_ctx* exec_ctx,
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);
+ nullptr, 0, call->incoming_compression_algorithm);
} 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);
@@ -1468,9 +1471,9 @@ static void receiving_stream_ready(grpc_exec_ctx* exec_ctx, void* bctlp,
batch_control* bctl = (batch_control*)bctlp;
grpc_call* call = bctl->call;
if (error != GRPC_ERROR_NONE) {
- if (call->receiving_stream != NULL) {
+ if (call->receiving_stream != nullptr) {
grpc_byte_stream_destroy(exec_ctx, call->receiving_stream);
- call->receiving_stream = NULL;
+ call->receiving_stream = nullptr;
}
add_batch_error(exec_ctx, bctl, GRPC_ERROR_REF(error), true);
cancel_with_error(exec_ctx, call, STATUS_FROM_SURFACE,
@@ -1479,7 +1482,7 @@ static void receiving_stream_ready(grpc_exec_ctx* exec_ctx, void* bctlp,
/* 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);
}
@@ -1505,7 +1508,7 @@ static void validate_filtered_metadata(grpc_exec_ctx* exec_ctx,
GRPC_STREAM_COMPRESS_NONE) {
const grpc_stream_compression_algorithm algo =
call->incoming_stream_compression_algorithm;
- char* error_msg = NULL;
+ char* error_msg = nullptr;
const grpc_compression_options compression_options =
grpc_channel_compression_options(call->channel);
if (algo >= GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT) {
@@ -1517,7 +1520,7 @@ static void validate_filtered_metadata(grpc_exec_ctx* exec_ctx,
} 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;
+ const char* algo_name = nullptr;
grpc_stream_compression_algorithm_name(algo, &algo_name);
gpr_asprintf(&error_msg, "Stream compression algorithm '%s' is disabled.",
algo_name);
@@ -1530,8 +1533,8 @@ static void validate_filtered_metadata(grpc_exec_ctx* exec_ctx,
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;
+ if (grpc_compression_trace.enabled()) {
+ const char* algo_name = nullptr;
grpc_stream_compression_algorithm_name(
call->incoming_stream_compression_algorithm, &algo_name);
gpr_log(
@@ -1545,7 +1548,7 @@ static void validate_filtered_metadata(grpc_exec_ctx* exec_ctx,
} else if (call->incoming_compression_algorithm != GRPC_COMPRESS_NONE) {
const grpc_compression_algorithm algo =
call->incoming_compression_algorithm;
- char* error_msg = NULL;
+ char* error_msg = nullptr;
const grpc_compression_options compression_options =
grpc_channel_compression_options(call->channel);
/* check if algorithm is known */
@@ -1558,7 +1561,7 @@ static void validate_filtered_metadata(grpc_exec_ctx* exec_ctx,
} else if (grpc_compression_options_is_algorithm_enabled(
&compression_options, algo) == 0) {
/* check if algorithm is supported by current channel config */
- const char* algo_name = NULL;
+ const char* algo_name = nullptr;
grpc_compression_algorithm_name(algo, &algo_name);
gpr_asprintf(&error_msg, "Compression algorithm '%s' is disabled.",
algo_name);
@@ -1573,8 +1576,8 @@ static void validate_filtered_metadata(grpc_exec_ctx* exec_ctx,
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;
+ if (grpc_compression_trace.enabled()) {
+ const char* algo_name = nullptr;
grpc_compression_algorithm_name(call->incoming_compression_algorithm,
&algo_name);
gpr_log(GPR_ERROR,
@@ -1622,7 +1625,7 @@ static void receiving_initial_metadata_ready(grpc_exec_ctx* exec_ctx,
}
}
- 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 */
@@ -1646,7 +1649,7 @@ static void receiving_initial_metadata_ready(grpc_exec_ctx* exec_ctx,
break;
}
}
- if (saved_rsr_closure != NULL) {
+ if (saved_rsr_closure != nullptr) {
GRPC_CLOSURE_RUN(exec_ctx, saved_rsr_closure, GRPC_ERROR_REF(error));
}
@@ -1687,7 +1690,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx* exec_ctx,
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,
+ 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);
@@ -1697,7 +1700,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx* exec_ctx,
}
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;
@@ -1710,7 +1713,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;
}
@@ -1815,7 +1818,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;
}
@@ -1891,7 +1894,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx* exec_ctx,
override_error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Error from server send 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_slice_ref_internal(
@@ -1910,8 +1913,8 @@ static grpc_call_error call_start_batch(grpc_exec_ctx* exec_ctx,
if (!prepare_application_metadata(
exec_ctx, 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);
}
@@ -1993,6 +1996,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 =
@@ -2082,7 +2087,7 @@ 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);
diff --git a/src/core/lib/surface/call.h b/src/core/lib/surface/call.h
index d4e596f84b..1d2e266717 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"
@@ -102,8 +98,7 @@ void grpc_call_context_set(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);
@@ -112,11 +107,7 @@ uint8_t grpc_call_is_client(grpc_call* call);
grpc_compression_algorithm grpc_call_compression_for_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_log_batch.cc b/src/core/lib/surface/call_log_batch.cc
index 030964675d..535a3d3282 100644
--- a/src/core/lib/surface/call_log_batch.cc
+++ b/src/core/lib/surface/call_log_batch.cc
@@ -27,7 +27,7 @@
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;
}
@@ -66,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));
@@ -99,7 +99,7 @@ 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;
diff --git a/src/core/lib/surface/call_test_only.h b/src/core/lib/surface/call_test_only.h
index 2ff4a487d5..90444f85b6 100644
--- a/src/core/lib/surface/call_test_only.h
+++ b/src/core/lib/surface/call_test_only.h
@@ -21,10 +21,6 @@
#include <grpc/grpc.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/** Return the compression algorithm from \a call.
*
* \warning This function should \b only be used in test code. */
@@ -54,8 +50,4 @@ uint32_t grpc_call_test_only_get_stream_encodings_accepted_by_peer(
grpc_stream_compression_algorithm
grpc_call_test_only_get_incoming_stream_encodings(grpc_call* call);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SURFACE_CALL_TEST_ONLY_H */
diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc
index 832cc07858..1be734cdb7 100644
--- a/src/core/lib/surface/channel.cc
+++ b/src/core/lib/surface/channel.cc
@@ -85,7 +85,7 @@ grpc_channel* grpc_channel_create_with_builder(
GRPC_STATS_INC_CLIENT_CHANNELS_CREATED(exec_ctx);
}
grpc_error* error = grpc_channel_stack_builder_finish(
- exec_ctx, builder, sizeof(grpc_channel), 1, destroy_channel, NULL,
+ exec_ctx, builder, sizeof(grpc_channel), 1, destroy_channel, nullptr,
(void**)&channel);
if (error != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "channel stack builder failed: %s",
@@ -99,7 +99,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,
@@ -206,7 +206,7 @@ grpc_channel* grpc_channel_create(grpc_exec_ctx* exec_ctx, const char* 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;
+ return nullptr;
}
return grpc_channel_create_with_builder(exec_ctx, builder,
channel_stack_type);
@@ -267,7 +267,7 @@ static grpc_call* grpc_channel_create_call_internal(
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)) {
@@ -283,7 +283,7 @@ 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;
@@ -302,12 +302,12 @@ grpc_call* grpc_channel_create_call(grpc_channel* channel,
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,
+ &exec_ctx, channel, parent_call, propagation_mask, cq, nullptr,
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,
+ host != nullptr ? grpc_mdelem_from_slices(&exec_ctx, GRPC_MDSTR_AUTHORITY,
+ grpc_slice_ref_internal(*host))
+ : GRPC_MDNULL,
grpc_timespec_to_millis_round_up(deadline));
grpc_exec_ctx_finish(&exec_ctx);
return call;
@@ -319,12 +319,12 @@ grpc_call* grpc_channel_create_pollset_set_call(
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,
+ exec_ctx, channel, parent_call, propagation_mask, nullptr, 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,
+ host != nullptr ? grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_AUTHORITY,
+ grpc_slice_ref_internal(*host))
+ : GRPC_MDNULL,
deadline);
}
@@ -372,8 +372,8 @@ grpc_call* grpc_channel_create_registered_call(
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),
+ &exec_ctx, 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));
grpc_exec_ctx_finish(&exec_ctx);
return call;
@@ -413,7 +413,7 @@ static void destroy_channel(grpc_exec_ctx* exec_ctx, void* arg,
}
void grpc_channel_destroy(grpc_channel* channel) {
- grpc_transport_op* op = grpc_make_transport_op(NULL);
+ grpc_transport_op* op = grpc_make_transport_op(nullptr);
grpc_channel_element* elem;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
GRPC_API_TRACE("grpc_channel_destroy(channel=%p)", 1, (channel));
diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h
index 063e685f6b..a2e53c777d 100644
--- a/src/core/lib/surface/channel.h
+++ b/src/core/lib/surface/channel.h
@@ -23,10 +23,6 @@
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/surface/channel_stack_type.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
grpc_channel* grpc_channel_create(grpc_exec_ctx* exec_ctx, const char* target,
const grpc_channel_args* args,
grpc_channel_stack_type channel_stack_type,
@@ -85,8 +81,4 @@ void grpc_channel_internal_unref(grpc_exec_ctx* exec_ctx,
grpc_compression_options grpc_channel_compression_options(
const grpc_channel* channel);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_H */
diff --git a/src/core/lib/surface/channel_init.cc b/src/core/lib/surface/channel_init.cc
index 17d8caf56f..b563537f35 100644
--- a/src/core/lib/surface/channel_init.cc
+++ b/src/core/lib/surface/channel_init.cc
@@ -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;
}
diff --git a/src/core/lib/surface/channel_init.h b/src/core/lib/surface/channel_init.h
index 9932781081..556ecc4147 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
@@ -74,8 +70,4 @@ bool grpc_channel_init_create_stack(grpc_exec_ctx* exec_ctx,
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.cc b/src/core/lib/surface/channel_ping.cc
index 5660bb812e..e8f47f01cf 100644
--- a/src/core/lib/surface/channel_ping.cc
+++ b/src/core/lib/surface/channel_ping.cc
@@ -48,12 +48,12 @@ 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);
+ 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);
+ GPR_ASSERT(reserved == nullptr);
pr->tag = tag;
pr->cq = cq;
GRPC_CLOSURE_INIT(&pr->closure, ping_done, pr, grpc_schedule_on_exec_ctx);
diff --git a/src/core/lib/surface/channel_stack_type.h b/src/core/lib/surface/channel_stack_type.h
index feecd3aa44..52f85a6406 100644
--- a/src/core/lib/surface/channel_stack_type.h
+++ b/src/core/lib/surface/channel_stack_type.h
@@ -21,10 +21,6 @@
#include <stdbool.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef enum {
// normal top-half client channel with load-balancing, connection management
GRPC_CLIENT_CHANNEL,
@@ -46,8 +42,4 @@ bool grpc_channel_stack_type_is_client(grpc_channel_stack_type type);
const char* grpc_channel_stack_type_string(grpc_channel_stack_type type);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_STACK_TYPE_H */
diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc
index 922df923ae..98d7e35943 100644
--- a/src/core/lib/surface/completion_queue.cc
+++ b/src/core/lib/surface/completion_queue.cc
@@ -40,14 +40,9 @@
#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
+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
@@ -113,8 +108,8 @@ static grpc_error* non_polling_poller_work(grpc_exec_ctx* exec_ctx,
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) {
+ if (worker != nullptr) *worker = (grpc_pollset_worker*)&w;
+ if (npp->root == nullptr) {
npp->root = w.next = w.prev = &w;
} else {
w.next = npp->root;
@@ -134,13 +129,13 @@ static grpc_error* non_polling_poller_work(grpc_exec_ctx* exec_ctx,
if (npp->shutdown) {
GRPC_CLOSURE_SCHED(exec_ctx, npp->shutdown, GRPC_ERROR_NONE);
}
- npp->root = NULL;
+ npp->root = nullptr;
}
}
w.next->prev = w.prev;
w.prev->next = w.next;
gpr_cv_destroy(&w.cv);
- if (worker != NULL) *worker = NULL;
+ if (worker != nullptr) *worker = nullptr;
return GRPC_ERROR_NONE;
}
@@ -148,8 +143,9 @@ 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) {
+ 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;
@@ -163,9 +159,9 @@ 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);
+ GPR_ASSERT(closure != nullptr);
p->shutdown = closure;
- if (p->root == NULL) {
+ if (p->root == nullptr) {
GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
} else {
non_polling_worker* w = p->root;
@@ -327,10 +323,11 @@ static void cq_destroy_pluck(void* data);
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},
+ 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, NULL,
+ cq_destroy_pluck, cq_begin_op_for_pluck, cq_end_op_for_pluck, nullptr,
cq_pluck},
};
@@ -338,18 +335,15 @@ static const cq_vtable g_cq_vtable[] = {
#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); \
+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(grpc_exec_ctx* exec_ctx, void* cq,
@@ -372,7 +366,7 @@ int grpc_completion_queue_thread_local_cache_flush(grpc_completion_queue* cq,
grpc_cq_completion* storage =
(grpc_cq_completion*)gpr_tls_get(&g_cached_event);
int ret = 0;
- if (storage != NULL &&
+ if (storage != nullptr &&
(grpc_completion_queue*)gpr_tls_get(&g_cached_cq) == cq) {
*tag = storage->tag;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
@@ -411,7 +405,7 @@ static bool cq_event_queue_push(grpc_cq_event_queue* q, grpc_cq_completion* c) {
}
static grpc_cq_completion* cq_event_queue_pop(grpc_cq_event_queue* q) {
- grpc_cq_completion* c = NULL;
+ grpc_cq_completion* c = nullptr;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
if (gpr_spinlock_trylock(&q->queue_lock)) {
@@ -421,7 +415,7 @@ static grpc_cq_completion* cq_event_queue_pop(grpc_cq_event_queue* q) {
c = (grpc_cq_completion*)gpr_mpscq_pop_and_check_end(&q->queue, &is_empty);
gpr_spinlock_unlock(&q->queue_lock);
- if (c == NULL && !is_empty) {
+ if (c == nullptr && !is_empty) {
GRPC_STATS_INC_CQ_EV_QUEUE_TRANSIENT_POP_FAILURES(&exec_ctx);
}
} else {
@@ -531,7 +525,7 @@ int grpc_get_cq_poll_num(grpc_completion_queue* cq) {
#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)) {
+ 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,
@@ -552,7 +546,7 @@ static void on_pollset_shutdown_done(grpc_exec_ctx* exec_ctx, void* arg,
#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)) {
+ 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,
@@ -654,16 +648,14 @@ static void cq_end_op_for_next(grpc_exec_ctx* exec_ctx,
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)) {
+ 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(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) {
+ if (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg);
}
}
@@ -697,7 +689,7 @@ static void cq_end_op_for_next(grpc_exec_ctx* exec_ctx,
if (is_first) {
gpr_mu_lock(cq->mu);
grpc_error* kick_error =
- cq->poller_vtable->kick(exec_ctx, POLLSET_FROM_CQ(cq), NULL);
+ cq->poller_vtable->kick(exec_ctx, POLLSET_FROM_CQ(cq), nullptr);
gpr_mu_unlock(cq->mu);
if (kick_error != GRPC_ERROR_NONE) {
@@ -743,16 +735,14 @@ static void cq_end_op_for_pluck(grpc_exec_ctx* exec_ctx,
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)) {
+ 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(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) {
+ if (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg);
}
}
@@ -775,7 +765,7 @@ static void cq_end_op_for_pluck(grpc_exec_ctx* exec_ctx,
cq_finish_shutdown_pluck(exec_ctx, cq);
gpr_mu_unlock(cq->mu);
} else {
- grpc_pollset_worker* pluck_worker = NULL;
+ 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;
@@ -822,7 +812,7 @@ 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_ASSERT(a->stolen_completion == nullptr);
gpr_atm current_last_seen_things_queued_ever =
gpr_atm_no_barrier_load(&cqd->things_queued_ever);
@@ -837,7 +827,7 @@ static bool cq_is_next_finished(grpc_exec_ctx* exec_ctx, void* arg) {
* 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) {
+ if (a->stolen_completion != nullptr) {
return true;
}
}
@@ -846,7 +836,7 @@ static bool cq_is_next_finished(grpc_exec_ctx* exec_ctx, void* arg) {
#ifndef NDEBUG
static void dump_pending_tags(grpc_completion_queue* cq) {
- if (!GRPC_TRACER_ON(grpc_trace_pending_tags)) return;
+ if (!grpc_trace_pending_tags.enabled()) return;
gpr_strvec v;
gpr_strvec_init(&v);
@@ -858,7 +848,7 @@ static void dump_pending_tags(grpc_completion_queue* cq) {
gpr_strvec_add(&v, s);
}
gpr_mu_unlock(cq->mu);
- char* out = gpr_strvec_flatten(&v, NULL);
+ char* out = gpr_strvec_flatten(&v, nullptr);
gpr_strvec_destroy(&v);
gpr_log(GPR_DEBUG, "%s", out);
gpr_free(out);
@@ -894,17 +884,17 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
gpr_atm_no_barrier_load(&cqd->things_queued_ever),
cq,
deadline_millis,
- NULL,
- NULL,
+ nullptr,
+ nullptr,
true};
grpc_exec_ctx exec_ctx =
GRPC_EXEC_CTX_INITIALIZER(0, cq_is_next_finished, &is_finished_arg);
for (;;) {
grpc_millis iteration_deadline = deadline_millis;
- if (is_finished_arg.stolen_completion != NULL) {
+ if (is_finished_arg.stolen_completion != nullptr) {
grpc_cq_completion* c = is_finished_arg.stolen_completion;
- is_finished_arg.stolen_completion = NULL;
+ is_finished_arg.stolen_completion = nullptr;
ret.type = GRPC_OP_COMPLETE;
ret.success = c->next & 1u;
ret.tag = c->tag;
@@ -914,7 +904,7 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
grpc_cq_completion* c = cq_event_queue_pop(&cqd->queue);
- if (c != NULL) {
+ if (c != nullptr) {
ret.type = GRPC_OP_COMPLETE;
ret.success = c->next & 1u;
ret.tag = c->tag;
@@ -960,7 +950,7 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
gpr_mu_lock(cq->mu);
cq->num_polls++;
grpc_error* err = cq->poller_vtable->work(&exec_ctx, POLLSET_FROM_CQ(cq),
- NULL, iteration_deadline);
+ nullptr, iteration_deadline);
gpr_mu_unlock(cq->mu);
if (err != GRPC_ERROR_NONE) {
@@ -979,14 +969,14 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
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);
+ cq->poller_vtable->kick(&exec_ctx, POLLSET_FROM_CQ(cq), nullptr);
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_ASSERT(is_finished_arg.stolen_completion == nullptr);
GPR_TIMER_END("grpc_completion_queue_next", 0);
@@ -1073,7 +1063,7 @@ static bool cq_is_pluck_finished(grpc_exec_ctx* exec_ctx, void* 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_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) {
@@ -1105,12 +1095,12 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
grpc_event ret;
grpc_cq_completion* c;
grpc_cq_completion* prev;
- grpc_pollset_worker* worker = NULL;
+ 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_TRACER_ON(grpc_cq_pluck_trace)) {
+ if (grpc_cq_pluck_trace.enabled()) {
GRPC_API_TRACE(
"grpc_completion_queue_pluck("
"cq=%p, tag=%p, "
@@ -1132,16 +1122,16 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
gpr_atm_no_barrier_load(&cqd->things_queued_ever),
cq,
deadline_millis,
- NULL,
+ nullptr,
tag,
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) {
+ if (is_finished_arg.stolen_completion != nullptr) {
gpr_mu_unlock(cq->mu);
c = is_finished_arg.stolen_completion;
- is_finished_arg.stolen_completion = NULL;
+ is_finished_arg.stolen_completion = nullptr;
ret.type = GRPC_OP_COMPLETE;
ret.success = c->next & 1u;
ret.tag = c->tag;
@@ -1214,7 +1204,7 @@ 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_ASSERT(is_finished_arg.stolen_completion == nullptr);
GPR_TIMER_END("grpc_completion_queue_pluck", 0);
@@ -1288,7 +1278,7 @@ void grpc_completion_queue_destroy(grpc_completion_queue* cq) {
}
grpc_pollset* grpc_cq_pollset(grpc_completion_queue* cq) {
- return cq->poller_vtable->can_get_pollset ? POLLSET_FROM_CQ(cq) : NULL;
+ return cq->poller_vtable->can_get_pollset ? POLLSET_FROM_CQ(cq) : nullptr;
}
bool grpc_cq_can_listen(grpc_completion_queue* cq) {
diff --git a/src/core/lib/surface/completion_queue.h b/src/core/lib/surface/completion_queue.h
index 0ed9875f58..13d3e5807d 100644
--- a/src/core/lib/surface/completion_queue.h
+++ b/src/core/lib/surface/completion_queue.h
@@ -27,18 +27,11 @@
/* 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;
@@ -98,8 +91,4 @@ int grpc_get_cq_poll_num(grpc_completion_queue* cc);
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.cc b/src/core/lib/surface/completion_queue_factory.cc
index aeecff5306..d0bb065c8f 100644
--- a/src/core/lib/surface/completion_queue_factory.cc
+++ 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/completion_queue_factory.h b/src/core/lib/surface/completion_queue_factory.h
index af8f3d60c3..89be8f8216 100644
--- a/src/core/lib/surface/completion_queue_factory.h
+++ b/src/core/lib/surface/completion_queue_factory.h
@@ -22,10 +22,6 @@
#include <grpc/grpc.h>
#include "src/core/lib/surface/completion_queue.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_completion_queue_factory_vtable {
grpc_completion_queue* (*create)(const grpc_completion_queue_factory*,
const grpc_completion_queue_attributes*);
@@ -37,8 +33,4 @@ struct grpc_completion_queue_factory {
grpc_completion_queue_factory_vtable* vtable;
};
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SURFACE_COMPLETION_QUEUE_FACTORY_H */
diff --git a/src/core/lib/surface/event_string.cc b/src/core/lib/surface/event_string.cc
index b92ee6ad07..5168edc9b5 100644
--- a/src/core/lib/surface/event_string.cc
+++ b/src/core/lib/surface/event_string.cc
@@ -42,7 +42,7 @@ 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 4bdb11f35e..cbf96da6c5 100644
--- a/src/core/lib/surface/event_string.h
+++ b/src/core/lib/surface/event_string.h
@@ -21,15 +21,7 @@
#include <grpc/grpc.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Returns a string describing an event. Must be later freed with gpr_free() */
char* grpc_event_string(grpc_event* ev);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SURFACE_EVENT_STRING_H */
diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc
index 233bd7a6b8..8ee1383fb8 100644
--- a/src/core/lib/surface/init.cc
+++ 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>
@@ -39,6 +40,8 @@
#include "src/core/lib/iomgr/timer_manager.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/support/fork.h"
+#include "src/core/lib/support/thd_internal.h"
#include "src/core/lib/surface/alarm_internal.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/call.h"
@@ -62,34 +65,36 @@ 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) {
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) {
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);
@@ -122,41 +127,18 @@ void grpc_init(void) {
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);
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();
}
}
@@ -178,13 +160,13 @@ 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);
+ GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, nullptr);
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) {
+ if (g_all_of_the_plugins[i].destroy != nullptr) {
g_all_of_the_plugins[i].destroy();
}
}
diff --git a/src/core/lib/surface/init.h b/src/core/lib/surface/init.h
index d429026327..9353208332 100644
--- a/src/core/lib/surface/init.h
+++ b/src/core/lib/surface/init.h
@@ -19,17 +19,9 @@
#ifndef GRPC_CORE_LIB_SURFACE_INIT_H
#define GRPC_CORE_LIB_SURFACE_INIT_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
void grpc_register_security_filters(void);
void grpc_security_pre_init(void);
void grpc_security_init(void);
int grpc_is_initialized(void);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SURFACE_INIT_H */
diff --git a/src/core/lib/surface/init_secure.cc b/src/core/lib/surface/init_secure.cc
index bcb91d7df8..3eee570fc2 100644
--- a/src/core/lib/surface/init_secure.cc
+++ b/src/core/lib/surface/init_secure.cc
@@ -24,6 +24,7 @@
#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"
@@ -33,18 +34,7 @@
#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) {
@@ -54,7 +44,7 @@ static bool maybe_prepend_client_auth_filter(
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);
}
}
}
@@ -69,7 +59,7 @@ static bool maybe_prepend_server_auth_filter(
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);
}
}
}
@@ -78,14 +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();
- grpc_register_tracer(&grpc_plugin_credentials_trace);
-}
+void grpc_security_init() { grpc_security_register_handshaker_factories(); }
diff --git a/src/core/lib/surface/lame_client.cc b/src/core/lib/surface/lame_client.cc
index add7be2e08..c32c9af50e 100644
--- a/src/core/lib/surface/lame_client.cc
+++ b/src/core/lib/surface/lame_client.cc
@@ -25,7 +25,6 @@
#include "src/core/lib/support/atomic.h"
-extern "C" {
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/support/string.h"
#include "src/core/lib/surface/api_trace.h"
@@ -33,7 +32,6 @@ extern "C" {
#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 {
@@ -68,7 +66,7 @@ static void fill_metadata(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
calld->details.md = grpc_mdelem_from_slices(
exec_ctx, 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;
@@ -106,13 +104,13 @@ static void lame_start_transport_op(grpc_exec_ctx* exec_ctx,
GRPC_CLOSURE_SCHED(exec_ctx, op->on_connectivity_state_change,
GRPC_ERROR_NONE);
}
- if (op->send_ping != NULL) {
+ if (op->send_ping != nullptr) {
GRPC_CLOSURE_SCHED(
exec_ctx, op->send_ping,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("lame client channel"));
}
GRPC_ERROR_UNREF(op->disconnect_with_error);
- if (op->on_consumed != NULL) {
+ if (op->on_consumed != nullptr) {
GRPC_CLOSURE_SCHED(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
}
}
@@ -146,7 +144,7 @@ static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
} // 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),
@@ -167,8 +165,8 @@ grpc_channel* grpc_lame_client_channel_create(const char* target,
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);
+ grpc_channel* channel = grpc_channel_create(
+ &exec_ctx, 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, "
diff --git a/src/core/lib/surface/lame_client.h b/src/core/lib/surface/lame_client.h
index 2f6f9cd046..3ce353f101 100644
--- a/src/core/lib/surface/lame_client.h
+++ b/src/core/lib/surface/lame_client.h
@@ -21,14 +21,6 @@
#include "src/core/lib/channel/channel_stack.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
extern const grpc_channel_filter grpc_lame_filter;
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SURFACE_LAME_CLIENT_H */
diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc
index da7ae17bef..0f8a057f31 100644
--- a/src/core/lib/surface/server.cc
+++ b/src/core/lib/surface/server.cc
@@ -60,8 +60,7 @@ typedef struct registered_method registered_method;
typedef enum { BATCH_CALL, REGISTERED_CALL } requested_call_type;
-grpc_tracer_flag grpc_server_channel_trace =
- GRPC_TRACER_INITIALIZER(false, "server_channel");
+grpc_core::TraceFlag grpc_server_channel_trace(false, "server_channel");
typedef struct requested_call {
gpr_mpscq_node request_link; /* must be first */
@@ -319,7 +318,7 @@ static void request_matcher_init(request_matcher* rm, grpc_server* server) {
static void request_matcher_destroy(request_matcher* rm) {
for (size_t i = 0; i < rm->server->cq_count; i++) {
- GPR_ASSERT(gpr_locked_mpscq_pop(&rm->requests_per_cq[i]) == NULL);
+ 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);
@@ -350,14 +349,8 @@ static void request_matcher_kill_requests(grpc_exec_ctx* exec_ctx,
grpc_error* error) {
requested_call* rc;
for (size_t i = 0; i < server->cq_count; i++) {
- /* Here we know:
- 1. no requests are being added (since the server is shut down)
- 2. no other threads are pulling (since the shut down process is single
- threaded)
- So, we can ignore the queue lock and just pop, with the guarantee that a
- NULL returned here truly means that the queue is empty */
- while ((rc = (requested_call*)gpr_mpscq_pop(
- &rm->requests_per_cq[i].queue)) != NULL) {
+ while ((rc = (requested_call*)gpr_locked_mpscq_pop(
+ &rm->requests_per_cq[i])) != nullptr) {
fail_call(exec_ctx, server, i, rc, GRPC_ERROR_REF(error));
}
}
@@ -379,7 +372,7 @@ static void server_delete(grpc_exec_ctx* exec_ctx, grpc_server* server) {
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);
@@ -427,14 +420,14 @@ static void finish_destroy_channel(grpc_exec_ctx* exec_ctx, void* cd,
static void destroy_channel(grpc_exec_ctx* exec_ctx, 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);
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) {
+ 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);
}
@@ -476,7 +469,7 @@ static void publish_call(grpc_exec_ctx* exec_ctx, grpc_server* server,
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:
@@ -510,7 +503,7 @@ static void publish_new_rpc(grpc_exec_ctx* exec_ctx, void* arg,
size_t cq_idx = (chand->cq_idx + i) % server->cq_count;
requested_call* rc =
(requested_call*)gpr_locked_mpscq_try_pop(&rm->requests_per_cq[cq_idx]);
- if (rc == NULL) {
+ if (rc == nullptr) {
continue;
} else {
GRPC_STATS_INC_SERVER_CQS_CHECKED(exec_ctx, i);
@@ -532,7 +525,7 @@ static void publish_new_rpc(grpc_exec_ctx* exec_ctx, void* arg,
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 == NULL) {
+ if (rc == nullptr) {
continue;
} else {
gpr_mu_unlock(&server->mu_call);
@@ -544,13 +537,13 @@ static void publish_new_rpc(grpc_exec_ctx* exec_ctx, void* arg,
}
gpr_atm_no_barrier_store(&calld->state, PENDING);
- if (rm->pending_head == NULL) {
+ 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);
}
@@ -727,8 +720,8 @@ static void server_on_recv_initial_metadata(grpc_exec_ctx* exec_ctx, void* ptr,
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(
@@ -764,7 +757,7 @@ static void server_mutate_op(grpc_call_element* elem,
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 =
@@ -838,8 +831,8 @@ static void channel_connectivity_changed(grpc_exec_ctx* exec_ctx, void* cd,
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(
@@ -896,10 +889,10 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
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,
@@ -999,9 +992,9 @@ grpc_server* grpc_server_create(const grpc_channel_args* args, void* reserved) {
}
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;
+ if (a == nullptr && b == nullptr) return 1;
+ if (a == nullptr) return 0;
+ if (b == nullptr) return 0;
return 0 == strcmp(a, b);
}
@@ -1017,19 +1010,19 @@ 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->method = gpr_strdup(method);
@@ -1108,10 +1101,10 @@ void grpc_server_setup_transport(grpc_exec_ctx* exec_ctx, grpc_server* s,
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);
+ channel = grpc_channel_create(exec_ctx, nullptr, args, GRPC_SERVER_CHANNEL,
+ transport);
chand = (channel_data*)grpc_channel_stack_element(
grpc_channel_get_channel_stack(channel), 0)
->channel_data;
@@ -1143,7 +1136,7 @@ void grpc_server_setup_transport(grpc_exec_ctx* exec_ctx, grpc_server* s,
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 {
@@ -1153,7 +1146,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;
@@ -1178,7 +1171,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;
@@ -1227,7 +1220,7 @@ void grpc_server_shutdown_and_notify(grpc_server* server,
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,
+ nullptr,
(grpc_cq_completion*)gpr_malloc(sizeof(grpc_cq_completion)));
gpr_mu_unlock(&server->mu_global);
goto done;
@@ -1328,8 +1321,8 @@ void grpc_server_add_listener(
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;
+ call_data* calld = nullptr;
+ request_matcher* rm = nullptr;
if (gpr_atm_acq_load(&server->shutdown_flag)) {
fail_call(exec_ctx, server, cq_idx, rc,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
@@ -1347,9 +1340,9 @@ static grpc_call_error queue_call_request(grpc_exec_ctx* exec_ctx,
/* 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) {
+ while ((calld = rm->pending_head) != nullptr) {
rc = (requested_call*)gpr_locked_mpscq_pop(&rm->requests_per_cq[cq_idx]);
- if (rc == NULL) break;
+ if (rc == nullptr) break;
rm->pending_head = calld->pending_next;
gpr_mu_unlock(&server->mu_call);
if (!gpr_atm_full_cas(&calld->state, PENDING, ACTIVATED)) {
@@ -1402,7 +1395,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;
@@ -1447,7 +1440,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;
@@ -1476,7 +1469,7 @@ done:
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;
+ *rc->call = nullptr;
rc->initial_metadata->count = 0;
GPR_ASSERT(error != GRPC_ERROR_NONE);
diff --git a/src/core/lib/surface/server.h b/src/core/lib/surface/server.h
index e3c43f957d..d7ec025d95 100644
--- a/src/core/lib/surface/server.h
+++ b/src/core/lib/surface/server.h
@@ -24,14 +24,10 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/transport/transport.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
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 */
@@ -58,8 +54,4 @@ int grpc_server_has_open_connections(grpc_server* server);
void grpc_server_get_pollsets(grpc_server* server, grpc_pollset*** pollsets,
size_t* pollset_count);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SURFACE_SERVER_H */
diff --git a/src/core/lib/surface/validate_metadata.h b/src/core/lib/surface/validate_metadata.h
index 9ca20692b5..ff074b00b2 100644
--- a/src/core/lib/surface/validate_metadata.h
+++ b/src/core/lib/surface/validate_metadata.h
@@ -22,15 +22,7 @@
#include <grpc/slice.h>
#include "src/core/lib/iomgr/error.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
grpc_error* grpc_validate_header_key_is_legal(grpc_slice slice);
grpc_error* grpc_validate_header_nonbin_value_is_legal(grpc_slice slice);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_SURFACE_VALIDATE_METADATA_H */
diff --git a/src/core/lib/surface/version.cc b/src/core/lib/surface/version.cc
index f4feadc640..7d36c6c9e1 100644
--- a/src/core/lib/surface/version.cc
+++ b/src/core/lib/surface/version.cc
@@ -23,4 +23,4 @@
const char* grpc_version_string(void) { return "5.0.0-dev"; }
-const char* grpc_g_stands_for(void) { return "generous"; }
+const char* grpc_g_stands_for(void) { return "glossy"; }
diff --git a/src/core/lib/transport/bdp_estimator.cc b/src/core/lib/transport/bdp_estimator.cc
index e09ae8e6a6..bb0e583045 100644
--- a/src/core/lib/transport/bdp_estimator.cc
+++ b/src/core/lib/transport/bdp_estimator.cc
@@ -23,8 +23,7 @@
#include <grpc/support/useful.h>
-grpc_tracer_flag grpc_bdp_estimator_trace =
- GRPC_TRACER_INITIALIZER(false, "bdp_estimator");
+grpc_core::TraceFlag grpc_bdp_estimator_trace(false, "bdp_estimator");
namespace grpc_core {
@@ -44,7 +43,7 @@ grpc_millis BdpEstimator::CompletePing(grpc_exec_ctx* exec_ctx) {
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_TRACER_ON(grpc_bdp_estimator_trace)) {
+ if (grpc_bdp_estimator_trace.enabled()) {
gpr_log(GPR_DEBUG,
"bdp[%s]:complete acc=%" PRId64 " est=%" PRId64
" dt=%lf bw=%lfMbs bw_est=%lfMbs",
@@ -55,7 +54,7 @@ grpc_millis BdpEstimator::CompletePing(grpc_exec_ctx* exec_ctx) {
if (accumulator_ > 2 * estimate_ / 3 && bw > bw_est_) {
estimate_ = GPR_MAX(accumulator_, estimate_ * 2);
bw_est_ = bw;
- if (GRPC_TRACER_ON(grpc_bdp_estimator_trace)) {
+ if (grpc_bdp_estimator_trace.enabled()) {
gpr_log(GPR_DEBUG, "bdp[%s]: estimate increased to %" PRId64, name_,
estimate_);
}
@@ -72,7 +71,7 @@ grpc_millis BdpEstimator::CompletePing(grpc_exec_ctx* exec_ctx) {
}
if (start_inter_ping_delay != inter_ping_delay_) {
stable_estimate_count_ = 0;
- if (GRPC_TRACER_ON(grpc_bdp_estimator_trace)) {
+ if (grpc_bdp_estimator_trace.enabled()) {
gpr_log(GPR_DEBUG, "bdp[%s]:update_inter_time to %dms", name_,
inter_ping_delay_);
}
diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h
index f7b94a81d3..df3a86c5f1 100644
--- a/src/core/lib/transport/bdp_estimator.h
+++ b/src/core/lib/transport/bdp_estimator.h
@@ -31,7 +31,7 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-extern grpc_tracer_flag grpc_bdp_estimator_trace;
+extern grpc_core::TraceFlag grpc_bdp_estimator_trace;
namespace grpc_core {
@@ -49,7 +49,7 @@ class BdpEstimator {
// grpc_bdp_estimator_add_incoming_bytes once a ping has been scheduled by a
// transport (but not necessarily started)
void SchedulePing() {
- if (GRPC_TRACER_ON(grpc_bdp_estimator_trace)) {
+ if (grpc_bdp_estimator_trace.enabled()) {
gpr_log(GPR_DEBUG, "bdp[%s]:sched acc=%" PRId64 " est=%" PRId64, name_,
accumulator_, estimate_);
}
@@ -62,7 +62,7 @@ class BdpEstimator {
// once
// the ping is on the wire
void StartPing() {
- if (GRPC_TRACER_ON(grpc_bdp_estimator_trace)) {
+ if (grpc_bdp_estimator_trace.enabled()) {
gpr_log(GPR_DEBUG, "bdp[%s]:start acc=%" PRId64 " est=%" PRId64, name_,
accumulator_, estimate_);
}
diff --git a/src/core/lib/transport/byte_stream.h b/src/core/lib/transport/byte_stream.h
index 54ad4b9796..6bca154cb5 100644
--- a/src/core/lib/transport/byte_stream.h
+++ b/src/core/lib/transport/byte_stream.h
@@ -28,10 +28,6 @@
/** Mask of all valid internal flags. */
#define GRPC_WRITE_INTERNAL_USED_MASK (GRPC_WRITE_INTERNAL_COMPRESS)
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_byte_stream grpc_byte_stream;
typedef struct {
@@ -139,8 +135,4 @@ void grpc_caching_byte_stream_init(grpc_caching_byte_stream* stream,
// Resets the byte stream to the start of the underlying stream.
void grpc_caching_byte_stream_reset(grpc_caching_byte_stream* stream);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_TRANSPORT_BYTE_STREAM_H */
diff --git a/src/core/lib/transport/connectivity_state.cc b/src/core/lib/transport/connectivity_state.cc
index bdaf0243f9..e7e5dbd1f1 100644
--- a/src/core/lib/transport/connectivity_state.cc
+++ b/src/core/lib/transport/connectivity_state.cc
@@ -24,8 +24,7 @@
#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) {
switch (state) {
@@ -48,7 +47,7 @@ void grpc_connectivity_state_init(grpc_connectivity_state_tracker* tracker,
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);
}
@@ -78,7 +77,7 @@ grpc_connectivity_state grpc_connectivity_state_check(
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));
}
@@ -90,11 +89,11 @@ grpc_connectivity_state grpc_connectivity_state_get(
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;
@@ -102,7 +101,7 @@ grpc_connectivity_state grpc_connectivity_state_get(
bool grpc_connectivity_state_has_watchers(
grpc_connectivity_state_tracker* connectivity_state) {
- return connectivity_state->watchers != NULL;
+ return connectivity_state->watchers != nullptr;
}
bool grpc_connectivity_state_notify_on_state_change(
@@ -111,8 +110,8 @@ bool grpc_connectivity_state_notify_on_state_change(
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 {
@@ -121,17 +120,17 @@ bool grpc_connectivity_state_notify_on_state_change(
grpc_connectivity_state_name(cur), notify);
}
}
- if (current == NULL) {
+ if (current == nullptr) {
grpc_connectivity_state_watcher* w = tracker->watchers;
- if (w != NULL && w->notify == notify) {
+ if (w != nullptr && w->notify == notify) {
GRPC_CLOSURE_SCHED(exec_ctx, notify, GRPC_ERROR_CANCELLED);
tracker->watchers = w->next;
gpr_free(w);
return false;
}
- while (w != NULL) {
+ while (w != nullptr) {
grpc_connectivity_state_watcher* rm_candidate = w->next;
- if (rm_candidate != NULL && rm_candidate->notify == notify) {
+ if (rm_candidate != nullptr && rm_candidate->notify == notify) {
GRPC_CLOSURE_SCHED(exec_ctx, notify, GRPC_ERROR_CANCELLED);
w->next = w->next->next;
gpr_free(rm_candidate);
@@ -165,7 +164,7 @@ void grpc_connectivity_state_set(grpc_exec_ctx* exec_ctx,
(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)) {
+ 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),
@@ -189,10 +188,10 @@ 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);
}
diff --git a/src/core/lib/transport/connectivity_state.h b/src/core/lib/transport/connectivity_state.h
index 792e27c43d..653637ebea 100644
--- a/src/core/lib/transport/connectivity_state.h
+++ b/src/core/lib/transport/connectivity_state.h
@@ -23,10 +23,6 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/iomgr/exec_ctx.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_connectivity_state_watcher {
/** we keep watchers in a linked list */
struct grpc_connectivity_state_watcher* next;
@@ -47,7 +43,7 @@ typedef struct {
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);
@@ -88,8 +84,4 @@ 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);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_TRANSPORT_CONNECTIVITY_STATE_H */
diff --git a/src/core/lib/transport/error_utils.cc b/src/core/lib/transport/error_utils.cc
index d968b04fd8..69c8ae6de3 100644
--- a/src/core/lib/transport/error_utils.cc
+++ b/src/core/lib/transport/error_utils.cc
@@ -18,16 +18,17 @@
#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,
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) {
@@ -36,18 +37,18 @@ static grpc_error* recursively_find_error_with_field(grpc_error* error,
if (result) return result;
slot = lerr->next;
}
- return NULL;
+ return nullptr;
}
void grpc_error_get_status(grpc_exec_ctx* exec_ctx, grpc_error* error,
grpc_millis deadline, grpc_status_code* code,
- grpc_slice* slice,
- grpc_http2_error_code* http_error) {
+ 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 =
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 =
@@ -56,7 +57,7 @@ void grpc_error_get_status(grpc_exec_ctx* exec_ctx, grpc_error* error,
// 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;
@@ -67,9 +68,13 @@ void grpc_error_get_status(grpc_exec_ctx* exec_ctx, grpc_error* error,
status = grpc_http2_error_to_grpc_status(
exec_ctx, (grpc_http2_error_code)integer, deadline);
}
- if (code != NULL) *code = status;
+ if (code != nullptr) *code = status;
- if (http_error != NULL) {
+ if (error_string != NULL && 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,
@@ -83,19 +88,17 @@ void grpc_error_get_status(grpc_exec_ctx* exec_ctx, grpc_error* error,
// 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)) {
+ if (grpc_error_get_int(error, GRPC_ERROR_INT_GRPC_STATUS, nullptr)) {
return true;
}
uint8_t slot = error->first_err;
diff --git a/src/core/lib/transport/error_utils.h b/src/core/lib/transport/error_utils.h
index 690e42058a..8b006ae992 100644
--- a/src/core/lib/transport/error_utils.h
+++ b/src/core/lib/transport/error_utils.h
@@ -23,20 +23,18 @@
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/transport/http2_errors.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/// 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_exec_ctx* exec_ctx, grpc_error* error,
grpc_millis deadline, grpc_status_code* code,
grpc_slice* slice,
- grpc_http2_error_code* http_status);
+ 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
@@ -44,8 +42,4 @@ void grpc_error_get_status(grpc_exec_ctx* exec_ctx, grpc_error* error,
/// GRPC_ERROR_CANCELLED
bool grpc_error_has_clear_grpc_status(grpc_error* error);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_TRANSPORT_ERROR_UTILS_H */
diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc
index ff11ddec13..0f30c7533d 100644
--- a/src/core/lib/transport/metadata.cc
+++ b/src/core/lib/transport/metadata.cc
@@ -48,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__)
@@ -149,7 +149,7 @@ static int is_mdelem_static(grpc_mdelem e) {
static void ref_md_locked(mdtab_shard* shard,
interned_metadata* md DEBUG_ARGS) {
#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_metadata)) {
+ 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,
@@ -241,7 +241,7 @@ grpc_mdelem grpc_mdelem_create(
grpc_exec_ctx* exec_ctx, 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);
}
@@ -252,7 +252,7 @@ grpc_mdelem grpc_mdelem_create(
allocated->value = grpc_slice_ref_internal(value);
gpr_atm_rel_store(&allocated->refcnt, 1);
#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_metadata)) {
+ 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'",
@@ -306,7 +306,7 @@ 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)) {
+ 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,
@@ -330,7 +330,7 @@ grpc_mdelem grpc_mdelem_create(
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_mdelem out = grpc_mdelem_create(exec_ctx, key, value, nullptr);
grpc_slice_unref_internal(exec_ctx, key);
grpc_slice_unref_internal(exec_ctx, value);
return out;
@@ -344,7 +344,7 @@ grpc_mdelem grpc_mdelem_from_grpc_metadata(grpc_exec_ctx* exec_ctx,
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);
+ changed ? nullptr : (grpc_mdelem_data*)metadata);
}
static size_t get_base64_encoded_size(size_t raw_length) {
@@ -373,7 +373,7 @@ grpc_mdelem grpc_mdelem_ref(grpc_mdelem gmd DEBUG_ARGS) {
case GRPC_MDELEM_STORAGE_INTERNED: {
interned_metadata* md = (interned_metadata*)GRPC_MDELEM_DATA(gmd);
#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_metadata)) {
+ 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,
@@ -395,7 +395,7 @@ grpc_mdelem grpc_mdelem_ref(grpc_mdelem gmd DEBUG_ARGS) {
case GRPC_MDELEM_STORAGE_ALLOCATED: {
allocated_metadata* md = (allocated_metadata*)GRPC_MDELEM_DATA(gmd);
#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_metadata)) {
+ 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,
@@ -425,7 +425,7 @@ void grpc_mdelem_unref(grpc_exec_ctx* exec_ctx, grpc_mdelem gmd DEBUG_ARGS) {
case GRPC_MDELEM_STORAGE_INTERNED: {
interned_metadata* md = (interned_metadata*)GRPC_MDELEM_DATA(gmd);
#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_metadata)) {
+ 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,
@@ -451,7 +451,7 @@ void grpc_mdelem_unref(grpc_exec_ctx* exec_ctx, grpc_mdelem gmd DEBUG_ARGS) {
case GRPC_MDELEM_STORAGE_ALLOCATED: {
allocated_metadata* md = (allocated_metadata*)GRPC_MDELEM_DATA(gmd);
#ifndef NDEBUG
- if (GRPC_TRACER_ON(grpc_trace_metadata)) {
+ 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,
@@ -478,7 +478,7 @@ 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];
@@ -488,12 +488,12 @@ void* grpc_mdelem_get_user_data(grpc_mdelem md, void (*destroy_func)(void*)) {
if (gpr_atm_acq_load(&im->destroy_user_data) == (gpr_atm)destroy_func) {
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*),
@@ -502,7 +502,7 @@ void* grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void*),
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) -
@@ -510,12 +510,12 @@ void* grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void*),
case GRPC_MDELEM_STORAGE_INTERNED: {
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);
@@ -526,7 +526,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 7e7e7b4c14..8d4868d031 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.
@@ -170,8 +164,4 @@ void grpc_mdelem_unref(grpc_exec_ctx* exec_ctx, grpc_mdelem md);
void grpc_mdctx_global_init(void);
void grpc_mdctx_global_shutdown(grpc_exec_ctx* exec_ctx);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_TRANSPORT_METADATA_H */
diff --git a/src/core/lib/transport/metadata_batch.cc b/src/core/lib/transport/metadata_batch.cc
index 90e84cd1e2..5817765aa3 100644
--- a/src/core/lib/transport/metadata_batch.cc
+++ b/src/core/lib/transport/metadata_batch.cc
@@ -32,17 +32,17 @@ static void assert_valid_list(grpc_mdelem_list* list) {
#ifndef NDEBUG
grpc_linked_mdelem* l;
- GPR_ASSERT((list->head == NULL) == (list->tail == NULL));
+ GPR_ASSERT((list->head == nullptr) == (list->tail == nullptr));
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));
+ 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 == NULL) == (l == list->head));
- GPR_ASSERT((l->next == NULL) == (l == list->tail));
+ 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++;
@@ -54,7 +54,7 @@ static void assert_valid_list(grpc_mdelem_list* list) {
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) {
+ 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);
@@ -104,7 +104,7 @@ static grpc_error* maybe_link_callout(grpc_metadata_batch* batch,
if (idx == GRPC_BATCH_CALLOUTS_COUNT) {
return GRPC_ERROR_NONE;
}
- if (batch->idx.array[idx] == NULL) {
+ 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;
@@ -122,8 +122,8 @@ static void maybe_unlink_callout(grpc_metadata_batch* batch,
return;
}
if (grpc_static_callout_is_default[idx]) --batch->list.default_count;
- GPR_ASSERT(batch->idx.array[idx] != NULL);
- batch->idx.array[idx] = NULL;
+ GPR_ASSERT(batch->idx.array[idx] != nullptr);
+ batch->idx.array[idx] = nullptr;
}
grpc_error* grpc_metadata_batch_add_head(grpc_exec_ctx* exec_ctx,
@@ -138,9 +138,9 @@ grpc_error* grpc_metadata_batch_add_head(grpc_exec_ctx* exec_ctx,
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->prev = nullptr;
storage->next = list->head;
- if (list->head != NULL) {
+ if (list->head != nullptr) {
list->head->prev = storage;
} else {
list->tail = storage;
@@ -177,9 +177,9 @@ 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) {
+ storage->next = nullptr;
+ storage->reserved = nullptr;
+ if (list->tail != nullptr) {
list->tail->next = storage;
} else {
list->head = storage;
@@ -206,12 +206,12 @@ grpc_error* grpc_metadata_batch_link_tail(grpc_exec_ctx* exec_ctx,
static void unlink_storage(grpc_mdelem_list* list,
grpc_linked_mdelem* storage) {
assert_valid_list(list);
- if (storage->prev != NULL) {
+ if (storage->prev != nullptr) {
storage->prev->next = storage->next;
} else {
list->head = storage->next;
}
- if (storage->next != NULL) {
+ if (storage->next != nullptr) {
storage->next->prev = storage->prev;
} else {
list->tail = storage->prev;
@@ -270,12 +270,13 @@ void grpc_metadata_batch_clear(grpc_exec_ctx* exec_ctx,
}
bool grpc_metadata_batch_is_empty(grpc_metadata_batch* batch) {
- return batch->list.head == NULL && batch->deadline == GRPC_MILLIS_INF_FUTURE;
+ 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 != NULL;
+ for (grpc_linked_mdelem* elem = batch->list.head; elem != nullptr;
elem = elem->next) {
size += GRPC_MDELEM_LENGTH(elem->md);
}
diff --git a/src/core/lib/transport/metadata_batch.h b/src/core/lib/transport/metadata_batch.h
index 7d17393249..adfb2d8069 100644
--- a/src/core/lib/transport/metadata_batch.h
+++ b/src/core/lib/transport/metadata_batch.h
@@ -28,10 +28,6 @@
#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;
@@ -146,8 +142,4 @@ void grpc_metadata_batch_assert_ok(grpc_metadata_batch* comd);
} while (0)
#endif
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_TRANSPORT_METADATA_BATCH_H */
diff --git a/src/core/lib/transport/service_config.cc b/src/core/lib/transport/service_config.cc
index 05907de7d7..adcec8c444 100644
--- a/src/core/lib/transport/service_config.cc
+++ b/src/core/lib/transport/service_config.cc
@@ -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,10 +110,10 @@ 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) {
+ 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 != NULL; name = name->next) {
+ for (grpc_json* name = field->child; name != nullptr; name = name->next) {
if (name->type != GRPC_JSON_OBJECT) return -1;
++num_names;
}
@@ -125,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;
}
@@ -159,18 +159,18 @@ static bool parse_json_method_config(
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 == NULL) goto done;
+ if (path == nullptr) goto done;
gpr_strvec_add(&paths, path);
}
}
@@ -196,26 +196,26 @@ grpc_slice_hash_table* grpc_service_config_create_method_config_table(
void (*unref_value)(grpc_exec_ctx* exec_ctx, 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) {
size_t count = count_names_in_method_config_json(method);
- if (count <= 0) return NULL;
+ 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, ref_value,
unref_value, entries, &idx)) {
@@ -224,17 +224,17 @@ grpc_slice_hash_table* grpc_service_config_create_method_config_table(
unref_value(exec_ctx, entries[i].value);
}
gpr_free(entries);
- return NULL;
+ 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, unref_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;
@@ -246,7 +246,7 @@ void* grpc_method_config_table_get(grpc_exec_ctx* exec_ctx,
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);
diff --git a/src/core/lib/transport/service_config.h b/src/core/lib/transport/service_config.h
index 405d0f5b41..75a290bfd8 100644
--- a/src/core/lib/transport/service_config.h
+++ b/src/core/lib/transport/service_config.h
@@ -22,10 +22,6 @@
#include "src/core/lib/json/json.h"
#include "src/core/lib/slice/slice_hash_table.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_service_config grpc_service_config;
grpc_service_config* grpc_service_config_create(const char* json_string);
@@ -64,8 +60,4 @@ void* grpc_method_config_table_get(grpc_exec_ctx* exec_ctx,
const grpc_slice_hash_table* table,
grpc_slice path);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_TRANSPORT_SERVICE_CONFIG_H */
diff --git a/src/core/lib/transport/static_metadata.h b/src/core/lib/transport/static_metadata.h
index 8e73d5f278..ce3a11b009 100644
--- a/src/core/lib/transport/static_metadata.h
+++ b/src/core/lib/transport/static_metadata.h
@@ -27,10 +27,6 @@
#ifndef GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H
#define GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#include "src/core/lib/transport/metadata.h"
#define GRPC_STATIC_MDSTR_COUNT 100
@@ -588,7 +584,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))
-#ifdef __cplusplus
-}
-#endif
+
#endif /* GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H */
diff --git a/src/core/lib/transport/status_conversion.h b/src/core/lib/transport/status_conversion.h
index b6fcebd4fa..3637b82801 100644
--- a/src/core/lib/transport/status_conversion.h
+++ b/src/core/lib/transport/status_conversion.h
@@ -23,10 +23,6 @@
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/transport/http2_errors.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* 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_exec_ctx* exec_ctx,
@@ -37,8 +33,4 @@ grpc_status_code grpc_http2_error_to_grpc_status(grpc_exec_ctx* exec_ctx,
grpc_status_code grpc_http2_status_to_grpc_status(int status);
int grpc_status_to_http2_status(grpc_status_code status);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_TRANSPORT_STATUS_CONVERSION_H */
diff --git a/src/core/lib/transport/timeout_encoding.h b/src/core/lib/transport/timeout_encoding.h
index 9c3c4599c9..8611f49b00 100644
--- a/src/core/lib/transport/timeout_encoding.h
+++ b/src/core/lib/transport/timeout_encoding.h
@@ -27,17 +27,9 @@
#define GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE (GPR_LTOA_MIN_BUFSIZE + 1)
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Encode/decode timeouts to the GRPC over HTTP/2 format;
encoding may round up arbitrarily */
void grpc_http2_encode_timeout(grpc_millis timeout, char* buffer);
int grpc_http2_decode_timeout(grpc_slice text, grpc_millis* timeout);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_TRANSPORT_TIMEOUT_ENCODING_H */
diff --git a/src/core/lib/transport/transport.cc b/src/core/lib/transport/transport.cc
index 021f1b799b..5bda1541a6 100644
--- a/src/core/lib/transport/transport.cc
+++ b/src/core/lib/transport/transport.cc
@@ -31,14 +31,12 @@
#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
+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_TRACER_ON(grpc_trace_stream_refcount)) {
+ 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,
@@ -53,7 +51,7 @@ void grpc_stream_ref(grpc_stream_refcount* refcount) {
#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)) {
+ 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,
@@ -103,7 +101,7 @@ 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.refcount = &refcount->slice_refcount;
res.data.refcounted.bytes = (uint8_t*)buffer;
res.data.refcounted.length = length;
return res;
@@ -184,9 +182,10 @@ void grpc_transport_set_pops(grpc_exec_ctx* exec_ctx, grpc_transport* transport,
grpc_polling_entity* pollent) {
grpc_pollset* pollset;
grpc_pollset_set* pollset_set;
- if ((pollset = grpc_polling_entity_pollset(pollent)) != NULL) {
+ if ((pollset = grpc_polling_entity_pollset(pollent)) != nullptr) {
transport->vtable->set_pollset(exec_ctx, transport, stream, pollset);
- } else if ((pollset_set = grpc_polling_entity_pollset_set(pollent)) != NULL) {
+ } else if ((pollset_set = grpc_polling_entity_pollset_set(pollent)) !=
+ nullptr) {
transport->vtable->set_pollset_set(exec_ctx, transport, stream,
pollset_set);
} else {
diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h
index 973018e5a5..b3cf04c22d 100644
--- a/src/core/lib/transport/transport.h
+++ b/src/core/lib/transport/transport.h
@@ -31,10 +31,6 @@
#include "src/core/lib/transport/byte_stream.h"
#include "src/core/lib/transport/metadata_batch.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* forward declarations */
typedef struct grpc_transport grpc_transport;
@@ -43,9 +39,7 @@ 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;
@@ -333,9 +327,6 @@ void grpc_transport_ping(grpc_transport* transport, grpc_closure* cb);
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);
@@ -352,8 +343,4 @@ grpc_transport_op* grpc_make_transport_op(grpc_closure* on_consumed);
grpc_transport_stream_op_batch* grpc_make_transport_stream_op(
grpc_closure* on_consumed);
-#ifdef __cplusplus
-}
-#endif
-
#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 22ad599e2e..46be61427e 100644
--- a/src/core/lib/transport/transport_impl.h
+++ b/src/core/lib/transport/transport_impl.h
@@ -21,10 +21,6 @@
#include "src/core/lib/transport/transport.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_transport_vtable {
/* Memory required for a single stream element - this is allocated by upper
layers and initialized by the transport */
@@ -73,8 +69,4 @@ struct grpc_transport {
const grpc_transport_vtable* vtable;
};
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H */
diff --git a/src/core/lib/transport/transport_op_string.cc b/src/core/lib/transport/transport_op_string.cc
index 24e74c10c5..e69ab02570 100644
--- a/src/core/lib/transport/transport_op_string.cc
+++ b/src/core/lib/transport/transport_op_string.cc
@@ -47,7 +47,7 @@ static void put_metadata(gpr_strvec* b, grpc_mdelem md) {
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) {
+ 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);
}
@@ -121,7 +121,7 @@ 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;
@@ -135,10 +135,10 @@ char* grpc_transport_op_string(grpc_transport_op* op) {
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));
@@ -175,25 +175,25 @@ 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 != 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;
diff --git a/src/core/plugin_registry/grpc_cronet_plugin_registry.cc b/src/core/plugin_registry/grpc_cronet_plugin_registry.cc
index e0422f6750..101e29c481 100644
--- a/src/core/plugin_registry/grpc_cronet_plugin_registry.cc
+++ b/src/core/plugin_registry/grpc_cronet_plugin_registry.cc
@@ -18,18 +18,18 @@
#include <grpc/grpc.h>
-extern "C" void grpc_http_filters_init(void);
-extern "C" void grpc_http_filters_shutdown(void);
-extern "C" void grpc_chttp2_plugin_init(void);
-extern "C" void grpc_chttp2_plugin_shutdown(void);
-extern "C" void grpc_deadline_filter_init(void);
-extern "C" void grpc_deadline_filter_shutdown(void);
-extern "C" void grpc_client_channel_init(void);
-extern "C" void grpc_client_channel_shutdown(void);
-extern "C" void grpc_tsi_gts_init(void);
-extern "C" void grpc_tsi_gts_shutdown(void);
-extern "C" void grpc_server_load_reporting_plugin_init(void);
-extern "C" 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_gts_init(void);
+void grpc_tsi_gts_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,
diff --git a/src/core/plugin_registry/grpc_plugin_registry.cc b/src/core/plugin_registry/grpc_plugin_registry.cc
index 339c9bb367..89be351785 100644
--- a/src/core/plugin_registry/grpc_plugin_registry.cc
+++ b/src/core/plugin_registry/grpc_plugin_registry.cc
@@ -18,40 +18,40 @@
#include <grpc/grpc.h>
-extern "C" void grpc_http_filters_init(void);
-extern "C" void grpc_http_filters_shutdown(void);
-extern "C" void grpc_chttp2_plugin_init(void);
-extern "C" void grpc_chttp2_plugin_shutdown(void);
-extern "C" void grpc_tsi_gts_init(void);
-extern "C" void grpc_tsi_gts_shutdown(void);
-extern "C" void grpc_deadline_filter_init(void);
-extern "C" void grpc_deadline_filter_shutdown(void);
-extern "C" void grpc_client_channel_init(void);
-extern "C" void grpc_client_channel_shutdown(void);
-extern "C" void grpc_inproc_plugin_init(void);
-extern "C" void grpc_inproc_plugin_shutdown(void);
-extern "C" void grpc_resolver_fake_init(void);
-extern "C" void grpc_resolver_fake_shutdown(void);
-extern "C" void grpc_lb_policy_grpclb_init(void);
-extern "C" void grpc_lb_policy_grpclb_shutdown(void);
-extern "C" void grpc_lb_policy_pick_first_init(void);
-extern "C" void grpc_lb_policy_pick_first_shutdown(void);
-extern "C" void grpc_lb_policy_round_robin_init(void);
-extern "C" void grpc_lb_policy_round_robin_shutdown(void);
-extern "C" void grpc_resolver_dns_ares_init(void);
-extern "C" void grpc_resolver_dns_ares_shutdown(void);
-extern "C" void grpc_resolver_dns_native_init(void);
-extern "C" void grpc_resolver_dns_native_shutdown(void);
-extern "C" void grpc_resolver_sockaddr_init(void);
-extern "C" void grpc_resolver_sockaddr_shutdown(void);
-extern "C" void grpc_server_load_reporting_plugin_init(void);
-extern "C" void grpc_server_load_reporting_plugin_shutdown(void);
-extern "C" void grpc_max_age_filter_init(void);
-extern "C" void grpc_max_age_filter_shutdown(void);
-extern "C" void grpc_message_size_filter_init(void);
-extern "C" void grpc_message_size_filter_shutdown(void);
-extern "C" void grpc_workaround_cronet_compression_filter_init(void);
-extern "C" 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_gts_init(void);
+void grpc_tsi_gts_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,
diff --git a/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc b/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc
index c9fc17d34d..d73f946241 100644
--- a/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc
+++ b/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc
@@ -18,38 +18,38 @@
#include <grpc/grpc.h>
-extern "C" void grpc_http_filters_init(void);
-extern "C" void grpc_http_filters_shutdown(void);
-extern "C" void grpc_chttp2_plugin_init(void);
-extern "C" void grpc_chttp2_plugin_shutdown(void);
-extern "C" void grpc_deadline_filter_init(void);
-extern "C" void grpc_deadline_filter_shutdown(void);
-extern "C" void grpc_client_channel_init(void);
-extern "C" void grpc_client_channel_shutdown(void);
-extern "C" void grpc_inproc_plugin_init(void);
-extern "C" void grpc_inproc_plugin_shutdown(void);
-extern "C" void grpc_resolver_dns_ares_init(void);
-extern "C" void grpc_resolver_dns_ares_shutdown(void);
-extern "C" void grpc_resolver_dns_native_init(void);
-extern "C" void grpc_resolver_dns_native_shutdown(void);
-extern "C" void grpc_resolver_sockaddr_init(void);
-extern "C" void grpc_resolver_sockaddr_shutdown(void);
-extern "C" void grpc_resolver_fake_init(void);
-extern "C" void grpc_resolver_fake_shutdown(void);
-extern "C" void grpc_server_load_reporting_plugin_init(void);
-extern "C" void grpc_server_load_reporting_plugin_shutdown(void);
-extern "C" void grpc_lb_policy_grpclb_init(void);
-extern "C" void grpc_lb_policy_grpclb_shutdown(void);
-extern "C" void grpc_lb_policy_pick_first_init(void);
-extern "C" void grpc_lb_policy_pick_first_shutdown(void);
-extern "C" void grpc_lb_policy_round_robin_init(void);
-extern "C" void grpc_lb_policy_round_robin_shutdown(void);
-extern "C" void grpc_max_age_filter_init(void);
-extern "C" void grpc_max_age_filter_shutdown(void);
-extern "C" void grpc_message_size_filter_init(void);
-extern "C" void grpc_message_size_filter_shutdown(void);
-extern "C" void grpc_workaround_cronet_compression_filter_init(void);
-extern "C" 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,
diff --git a/src/core/tsi/fake_transport_security.cc b/src/core/tsi/fake_transport_security.cc
index b12dde31fb..f2f365fc0f 100644
--- a/src/core/tsi/fake_transport_security.cc
+++ b/src/core/tsi/fake_transport_security.cc
@@ -122,7 +122,7 @@ static void store32_little_endian(uint32_t value, unsigned char* buf) {
}
static uint32_t read_frame_size(const grpc_slice_buffer* sb) {
- GPR_ASSERT(sb != NULL && sb->length >= TSI_FAKE_FRAME_HEADER_SIZE);
+ 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;
/* Copies the first 4 bytes to a temporary buffer. */
@@ -152,7 +152,7 @@ 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) {
+ if (frame->data == nullptr) {
frame->allocated_size = frame->size;
frame->data = (unsigned char*)gpr_malloc(frame->allocated_size);
} else if (frame->size > frame->allocated_size) {
@@ -174,7 +174,7 @@ static tsi_result tsi_fake_frame_decode(const unsigned char* 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 = (unsigned char*)gpr_malloc(frame->allocated_size);
}
@@ -246,7 +246,7 @@ 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);
+ if (frame->data != nullptr) gpr_free(frame->data);
}
/* --- tsi_frame_protector methods implementation. ---*/
@@ -402,7 +402,8 @@ 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) {
+ if (self == nullptr || unprotected_slices == nullptr ||
+ protected_slices == nullptr) {
return TSI_INVALID_ARGUMENT;
}
tsi_fake_zero_copy_grpc_protector* impl =
@@ -426,7 +427,8 @@ 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) {
+ if (self == nullptr || unprotected_slices == nullptr ||
+ protected_slices == nullptr) {
return TSI_INVALID_ARGUMENT;
}
tsi_fake_zero_copy_grpc_protector* impl =
@@ -459,7 +461,7 @@ static tsi_result fake_zero_copy_grpc_protector_unprotect(
static void fake_zero_copy_grpc_protector_destroy(
grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self) {
- if (self == NULL) return;
+ if (self == nullptr) 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);
@@ -536,8 +538,8 @@ 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) {
+ if ((unused_bytes_size > 0 && unused_bytes == nullptr) ||
+ handshaker_result == nullptr) {
return TSI_INVALID_ARGUMENT;
}
fake_handshaker_result* result =
@@ -573,7 +575,7 @@ static tsi_result fake_handshaker_get_bytes_to_send_to_peer(
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));
@@ -585,7 +587,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;
@@ -623,7 +625,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));
}
@@ -631,7 +633,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;
@@ -658,9 +660,9 @@ static tsi_result fake_handshaker_next(
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;
@@ -695,10 +697,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;
@@ -717,11 +719,11 @@ 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,
};
@@ -749,7 +751,7 @@ 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 == NULL)
+ impl->max_frame_size = (max_protected_frame_size == nullptr)
? TSI_FAKE_DEFAULT_FRAME_SIZE
: *max_protected_frame_size;
impl->base.vtable = &frame_protector_vtable;
@@ -762,7 +764,7 @@ tsi_zero_copy_grpc_protector* tsi_create_fake_zero_copy_grpc_protector(
(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 b90b9962f7..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"
@@ -44,8 +40,4 @@ tsi_frame_protector* tsi_create_fake_frame_protector(
tsi_zero_copy_grpc_protector* tsi_create_fake_zero_copy_grpc_protector(
size_t* max_protected_frame_size);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_TSI_FAKE_TRANSPORT_SECURITY_H */
diff --git a/src/core/tsi/gts_transport_security.cc b/src/core/tsi/gts_transport_security.cc
index 1dfd8c4df0..2b099773c4 100644
--- a/src/core/tsi/gts_transport_security.cc
+++ b/src/core/tsi/gts_transport_security.cc
@@ -24,14 +24,14 @@ static gts_shared_resource g_gts_resource;
gts_shared_resource* gts_get_shared_resource(void) { return &g_gts_resource; }
-extern "C" void grpc_tsi_gts_init() {
+void grpc_tsi_gts_init() {
memset(&g_gts_resource, 0, sizeof(gts_shared_resource));
gpr_mu_init(&g_gts_resource.mu);
}
-extern "C" void grpc_tsi_gts_shutdown() {
+void grpc_tsi_gts_shutdown() {
gpr_mu_destroy(&g_gts_resource.mu);
- if (g_gts_resource.cq == NULL) {
+ if (g_gts_resource.cq == nullptr) {
return;
}
grpc_completion_queue_destroy(g_gts_resource.cq);
diff --git a/src/core/tsi/gts_transport_security.h b/src/core/tsi/gts_transport_security.h
index 8bc2107270..23b2b66fb3 100644
--- a/src/core/tsi/gts_transport_security.h
+++ b/src/core/tsi/gts_transport_security.h
@@ -23,10 +23,6 @@
#include <grpc/support/sync.h>
#include <grpc/support/thd.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct gts_shared_resource {
gpr_thd_id thread_id;
grpc_channel* channel;
@@ -38,8 +34,4 @@ typedef struct gts_shared_resource {
* TSI handshakes. */
gts_shared_resource* gts_get_shared_resource(void);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_TSI_GTS_TRANSPORT_SECURITY_H */
diff --git a/src/core/tsi/ssl_transport_security.cc b/src/core/tsi/ssl_transport_security.cc
index c1c2de6ca9..f35caef640 100644
--- a/src/core/tsi/ssl_transport_security.cc
+++ b/src/core/tsi/ssl_transport_security.cc
@@ -115,7 +115,7 @@ 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) {
if (mode & CRYPTO_LOCK) {
@@ -175,7 +175,7 @@ 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)) {
+ 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));
}
@@ -223,11 +223,11 @@ static int looks_like_ip_address(const char* name) {
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_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;
}
@@ -239,12 +239,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;
@@ -267,7 +267,7 @@ static tsi_result peer_property_from_x509_common_name(
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;
@@ -275,7 +275,7 @@ 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;
@@ -315,7 +315,7 @@ static tsi_result add_subject_alt_names_properties_to_peer(
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) {
@@ -342,7 +342,7 @@ static tsi_result add_subject_alt_names_properties_to_peer(
}
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;
@@ -361,9 +361,9 @@ static tsi_result add_subject_alt_names_properties_to_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 =
- (GENERAL_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;
@@ -396,7 +396,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);
@@ -473,15 +473,15 @@ 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;
+ 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;
+ if (pem == nullptr) return TSI_OUT_OF_RESOURCES;
do {
- certificate = PEM_read_bio_X509_AUX(pem, NULL, NULL, (void*)"");
- if (certificate == NULL) {
+ certificate = PEM_read_bio_X509_AUX(pem, nullptr, nullptr, (void*)"");
+ if (certificate == nullptr) {
result = TSI_INVALID_ARGUMENT;
break;
}
@@ -491,8 +491,8 @@ static tsi_result ssl_ctx_use_certificate_chain(SSL_CTX* context,
}
while (1) {
X509* certificate_authority =
- PEM_read_bio_X509(pem, NULL, NULL, (void*)"");
- if (certificate_authority == NULL) {
+ PEM_read_bio_X509(pem, nullptr, nullptr, (void*)"");
+ if (certificate_authority == nullptr) {
ERR_clear_error();
break; /* Done reading. */
}
@@ -507,7 +507,7 @@ 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;
}
@@ -516,14 +516,14 @@ static tsi_result ssl_ctx_use_certificate_chain(SSL_CTX* context,
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;
+ 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;
+ if (pem == nullptr) return TSI_OUT_OF_RESOURCES;
do {
- private_key = PEM_read_bio_PrivateKey(pem, NULL, NULL, (void*)"");
- if (private_key == NULL) {
+ private_key = PEM_read_bio_PrivateKey(pem, nullptr, nullptr, (void*)"");
+ if (private_key == nullptr) {
result = TSI_INVALID_ARGUMENT;
break;
}
@@ -532,7 +532,7 @@ 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;
}
@@ -546,40 +546,40 @@ static tsi_result ssl_ctx_load_verification_certs(SSL_CTX* context,
*root_names) {
tsi_result result = TSI_OK;
size_t num_roots = 0;
- X509* root = NULL;
- X509_NAME* root_name = NULL;
+ 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);
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, (void*)"");
- 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.");
@@ -596,11 +596,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);
@@ -613,8 +613,8 @@ static tsi_result populate_ssl_context(
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) {
@@ -622,7 +622,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)) {
@@ -631,7 +631,8 @@ 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;
}
@@ -652,19 +653,19 @@ static tsi_result populate_ssl_context(
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;
+ X509* cert = nullptr;
BIO* pem;
pem = BIO_new_mem_buf((void*)pem_cert, (int)strlen(pem_cert));
- if (pem == NULL) return TSI_OUT_OF_RESOURCES;
+ if (pem == nullptr) return TSI_OUT_OF_RESOURCES;
- cert = PEM_read_bio_X509(pem, NULL, NULL, (void*)"");
- 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;
}
@@ -675,11 +676,12 @@ static tsi_result build_alpn_protocol_name_list(
unsigned char** protocol_name_list, size_t* protocol_name_list_length) {
uint16_t i;
unsigned char* current;
- *protocol_name_list = NULL;
+ *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;
@@ -687,7 +689,7 @@ static tsi_result build_alpn_protocol_name_list(
*protocol_name_list_length += length + 1;
}
*protocol_name_list = (unsigned char*)gpr_malloc(*protocol_name_list_length);
- if (*protocol_name_list == NULL) return TSI_OUT_OF_RESOURCES;
+ 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]);
@@ -846,8 +848,8 @@ static tsi_result ssl_protector_unprotect(
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);
+ if (impl->buffer != nullptr) gpr_free(impl->buffer);
+ if (impl->ssl != nullptr) SSL_free(impl->ssl);
gpr_free(self);
}
@@ -862,9 +864,9 @@ static const tsi_frame_protector_vtable frame_protector_vtable = {
static void tsi_ssl_handshaker_factory_destroy(
tsi_ssl_handshaker_factory* self) {
- if (self == NULL) return;
+ 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
@@ -874,26 +876,26 @@ static void tsi_ssl_handshaker_factory_destroy(
static tsi_ssl_handshaker_factory* tsi_ssl_handshaker_factory_ref(
tsi_ssl_handshaker_factory* self) {
- if (self == NULL) return NULL;
+ 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;
+ 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);
+ GPR_ASSERT(factory != nullptr);
factory->vtable = &handshaker_factory_vtable;
gpr_ref_init(&factory->refcount, 1);
@@ -906,7 +908,7 @@ static tsi_result ssl_handshaker_get_bytes_to_send_to_peer(tsi_handshaker* self,
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;
}
@@ -938,7 +940,7 @@ 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;
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);
@@ -983,11 +985,11 @@ static tsi_result ssl_handshaker_process_bytes_from_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) {
+ if (peer_cert != nullptr) {
result = peer_from_x509(peer_cert, 1, peer);
X509_free(peer_cert);
if (result != TSI_OK) return result;
@@ -995,12 +997,12 @@ 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 = (tsi_peer_property*)gpr_zalloc(
sizeof(*new_properties) * (peer->property_count + 1));
@@ -1014,7 +1016,7 @@ static tsi_result ssl_handshaker_extract_peer(tsi_handshaker* self,
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;
}
@@ -1030,7 +1032,7 @@ static tsi_result ssl_handshaker_create_frame_protector(
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 =
@@ -1046,7 +1048,7 @@ static tsi_result ssl_handshaker_create_frame_protector(
actual_max_output_protected_frame_size - TSI_SSL_MAX_PROTECTION_OVERHEAD;
protector_impl->buffer =
(unsigned char*)gpr_malloc(protector_impl->buffer_size);
- if (protector_impl->buffer == NULL) {
+ if (protector_impl->buffer == nullptr) {
gpr_log(GPR_ERROR,
"Could not allocated buffer for tsi_ssl_frame_protector.");
gpr_free(protector_impl);
@@ -1056,7 +1058,7 @@ static tsi_result ssl_handshaker_create_frame_protector(
/* 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. */
protector_impl->ssl = impl->ssl;
- impl->ssl = NULL;
+ impl->ssl = nullptr;
protector_impl->into_ssl = impl->into_ssl;
protector_impl->from_ssl = impl->from_ssl;
@@ -1079,7 +1081,7 @@ 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. --- */
@@ -1089,33 +1091,33 @@ static tsi_result create_tsi_ssl_handshaker(SSL_CTX* ctx, int is_client,
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) {
+ BIO* into_ssl = nullptr;
+ BIO* from_ssl = 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) {
+ if (into_ssl == nullptr || from_ssl == nullptr) {
gpr_log(GPR_ERROR, "BIO_new failed.");
SSL_free(ssl);
- if (into_ssl != NULL) BIO_free(into_ssl);
- if (from_ssl != NULL) BIO_free(into_ssl);
+ if (into_ssl != nullptr) BIO_free(into_ssl);
+ if (from_ssl != nullptr) BIO_free(into_ssl);
return TSI_OUT_OF_RESOURCES;
}
SSL_set_bio(ssl, into_ssl, from_ssl);
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);
@@ -1185,17 +1187,17 @@ tsi_result tsi_ssl_client_handshaker_factory_create_handshaker(
void tsi_ssl_client_handshaker_factory_unref(
tsi_ssl_client_handshaker_factory* self) {
- if (self == NULL) return;
+ 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;
+ if (factory == nullptr) 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);
+ 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);
}
@@ -1218,40 +1220,40 @@ tsi_result tsi_ssl_server_handshaker_factory_create_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;
+ 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;
+ 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;
+ const char* name_subdomain = nullptr;
size_t name_length = strlen(name);
size_t name_subdomain_length;
if (entry_length == 0) return 0;
@@ -1277,7 +1279,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. */
@@ -1285,7 +1287,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;
}
@@ -1302,7 +1304,7 @@ static int ssl_server_handshaker_factory_servername_callback(SSL* ssl, int* ap,
(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) {
+ if (servername == nullptr || strlen(servername) == 0) {
return SSL_TLSEXT_ERR_NOACK;
}
@@ -1349,18 +1351,18 @@ tsi_result tsi_create_ssl_client_handshaker_factory(
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;
+ 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;
}
@@ -1376,7 +1378,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;
@@ -1409,7 +1411,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;
@@ -1438,15 +1440,15 @@ tsi_result tsi_create_ssl_server_handshaker_factory_ex(
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;
+ 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;
}
@@ -1458,8 +1460,8 @@ tsi_result tsi_create_ssl_server_handshaker_factory_ex(
(SSL_CTX**)gpr_zalloc(num_key_cert_pairs * sizeof(SSL_CTX*));
impl->ssl_context_x509_subject_names =
(tsi_peer*)gpr_zalloc(num_key_cert_pairs * sizeof(tsi_peer));
- if (impl->ssl_contexts == NULL ||
- impl->ssl_context_x509_subject_names == NULL) {
+ if (impl->ssl_contexts == nullptr ||
+ impl->ssl_context_x509_subject_names == nullptr) {
tsi_ssl_handshaker_factory_unref(&impl->base);
return TSI_OUT_OF_RESOURCES;
}
@@ -1478,7 +1480,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;
@@ -1487,8 +1489,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);
@@ -1499,14 +1501,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(
@@ -1517,7 +1519,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. */
@@ -1556,13 +1558,13 @@ tsi_result tsi_create_ssl_server_handshaker_factory_ex(
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;
+ if (property->name == nullptr) continue;
if (strcmp(property->name,
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY) == 0) {
san_count++;
@@ -1584,7 +1586,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;
@@ -1598,8 +1600,8 @@ int tsi_ssl_peer_matches_name(const tsi_peer* peer, const char* name) {
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);
+ GPR_ASSERT(factory != nullptr);
+ GPR_ASSERT(factory->vtable != nullptr);
const tsi_ssl_handshaker_factory_vtable* orig_vtable = factory->vtable;
factory->vtable = new_vtable;
diff --git a/src/core/tsi/ssl_transport_security.h b/src/core/tsi/ssl_transport_security.h
index 595c4ccaec..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"
@@ -193,8 +189,4 @@ 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
-
#endif /* GRPC_CORE_TSI_SSL_TRANSPORT_SECURITY_H */
diff --git a/src/core/tsi/ssl_types.h b/src/core/tsi/ssl_types.h
index e0e967034b..3788643355 100644
--- a/src/core/tsi/ssl_types.h
+++ b/src/core/tsi/ssl_types.h
@@ -19,10 +19,6 @@
#ifndef GRPC_CORE_TSI_SSL_TYPES_H
#define GRPC_CORE_TSI_SSL_TYPES_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* A collection of macros to cast between various integer types that are
* used differently between BoringSSL and OpenSSL:
* TSI_INT_AS_SIZE(x): convert 'int x' to a length parameter for an OpenSSL
@@ -41,8 +37,4 @@ extern "C" {
#define TSI_SIZE_AS_SIZE(x) ((int)(x))
#endif
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_TSI_SSL_TYPES_H */
diff --git a/src/core/tsi/transport_security.cc b/src/core/tsi/transport_security.cc
index 78e7be249c..5abd2f0f68 100644
--- a/src/core/tsi/transport_security.cc
+++ b/src/core/tsi/transport_security.cc
@@ -26,7 +26,7 @@
/* --- Tracing. --- */
-grpc_tracer_flag tsi_tracing_enabled = GRPC_TRACER_INITIALIZER(false, "tsi");
+grpc_core::TraceFlag tsi_tracing_enabled(false, "tsi");
/* --- tsi_result common implementation. --- */
@@ -74,12 +74,13 @@ tsi_result tsi_frame_protector_protect(tsi_frame_protector* self,
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) {
+ 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);
@@ -88,11 +89,13 @@ tsi_result tsi_frame_protector_protect(tsi_frame_protector* self,
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) {
+ 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);
@@ -102,19 +105,20 @@ 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) {
+ 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;
+ if (self == nullptr) return;
self->vtable->destroy(self);
}
@@ -125,36 +129,38 @@ void tsi_frame_protector_destroy(tsi_frame_protector* self) {
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) {
+ 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) {
+ 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;
+ 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) {
+ if (self == nullptr || self->vtable == nullptr || peer == nullptr) {
return TSI_INVALID_ARGUMENT;
}
memset(peer, 0, sizeof(tsi_peer));
@@ -162,7 +168,7 @@ 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);
}
@@ -170,12 +176,12 @@ tsi_result tsi_handshaker_create_frame_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) {
@@ -189,16 +195,16 @@ tsi_result tsi_handshaker_next(
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;
+ 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;
+ if (self == nullptr) return;
self->vtable->destroy(self);
}
@@ -206,21 +212,21 @@ void tsi_handshaker_destroy(tsi_handshaker* self) {
tsi_result tsi_handshaker_result_extract_peer(const tsi_handshaker_result* self,
tsi_peer* peer) {
- if (self == NULL || self->vtable == NULL || peer == NULL) {
+ 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) {
+ 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);
}
@@ -228,16 +234,16 @@ tsi_result tsi_handshaker_result_create_frame_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) {
+ 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;
+ if (self == nullptr) return;
self->vtable->destroy(self);
}
@@ -259,20 +265,20 @@ static void tsi_peer_destroy_list_property(tsi_peer_property* children,
}
void tsi_peer_property_destruct(tsi_peer_property* property) {
- if (property->name != NULL) {
+ 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) {
+ 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;
}
@@ -280,7 +286,7 @@ void tsi_peer_destruct(tsi_peer* self) {
tsi_result tsi_construct_allocated_string_peer_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 = (char*)gpr_zalloc(value_length);
property->value.length = value_length;
diff --git a/src/core/tsi/transport_security.h b/src/core/tsi/transport_security.h
index d639f857fe..bf3a776b11 100644
--- a/src/core/tsi/transport_security.h
+++ b/src/core/tsi/transport_security.h
@@ -24,11 +24,7 @@
#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. */
@@ -126,8 +122,4 @@ tsi_result tsi_construct_string_peer_property_from_cstring(
/* Utils. */
char* tsi_strdup(const char* src); /* Sadly, no strdup in C89. */
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_TSI_TRANSPORT_SECURITY_H */
diff --git a/src/core/tsi/transport_security_adapter.cc b/src/core/tsi/transport_security_adapter.cc
index ec4e7d8cef..56dec55494 100644
--- a/src/core/tsi/transport_security_adapter.cc
+++ b/src/core/tsi/transport_security_adapter.cc
@@ -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,
@@ -77,7 +77,8 @@ static const tsi_handshaker_result_vtable result_vtable = {
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)) {
+ if (wrapped == nullptr ||
+ (unused_bytes_size > 0 && unused_bytes == nullptr)) {
return TSI_INVALID_ARGUMENT;
}
tsi_adapter_handshaker_result* impl =
@@ -89,7 +90,7 @@ static tsi_result tsi_adapter_create_handshaker_result(
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;
@@ -148,9 +149,9 @@ static tsi_result adapter_next(
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;
}
@@ -183,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;
+ 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;
@@ -209,7 +210,7 @@ static const tsi_handshaker_vtable handshaker_vtable = {
};
tsi_handshaker* tsi_create_adapter_handshaker(tsi_handshaker* wrapped) {
- GPR_ASSERT(wrapped != NULL);
+ GPR_ASSERT(wrapped != nullptr);
tsi_adapter_handshaker* impl =
(tsi_adapter_handshaker*)gpr_zalloc(sizeof(*impl));
impl->base.vtable = &handshaker_vtable;
@@ -220,7 +221,7 @@ tsi_handshaker* tsi_create_adapter_handshaker(tsi_handshaker* wrapped) {
}
tsi_handshaker* tsi_adapter_handshaker_get_wrapped(tsi_handshaker* adapter) {
- if (adapter == NULL) return NULL;
+ 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 232705f02c..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,
@@ -40,8 +36,4 @@ tsi_handshaker* tsi_create_adapter_handshaker(tsi_handshaker* wrapped);
the caller. */
tsi_handshaker* tsi_adapter_handshaker_get_wrapped(tsi_handshaker* adapter);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_CORE_TSI_TRANSPORT_SECURITY_ADAPTER_H */
diff --git a/src/core/tsi/transport_security_grpc.cc b/src/core/tsi/transport_security_grpc.cc
index 3c986475c4..875d367218 100644
--- a/src/core/tsi/transport_security_grpc.cc
+++ b/src/core/tsi/transport_security_grpc.cc
@@ -23,11 +23,11 @@ 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) {
+ if (exec_ctx == nullptr || self == nullptr || self->vtable == nullptr ||
+ protector == nullptr) {
return TSI_INVALID_ARGUMENT;
}
- if (self->vtable->create_zero_copy_grpc_protector == NULL) {
+ if (self->vtable->create_zero_copy_grpc_protector == nullptr) {
return TSI_UNIMPLEMENTED;
}
return self->vtable->create_zero_copy_grpc_protector(
@@ -42,11 +42,11 @@ 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) {
+ if (exec_ctx == nullptr || self == nullptr || self->vtable == nullptr ||
+ unprotected_slices == nullptr || protected_slices == 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(exec_ctx, self, unprotected_slices,
protected_slices);
}
@@ -55,17 +55,17 @@ 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) {
+ if (exec_ctx == nullptr || self == nullptr || self->vtable == nullptr ||
+ protected_slices == nullptr || unprotected_slices == 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(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;
+ if (self == nullptr) return;
self->vtable->destroy(exec_ctx, self);
}
diff --git a/src/core/tsi/transport_security_grpc.h b/src/core/tsi/transport_security_grpc.h
index 1c54693ec9..9fccfd79dd 100644
--- a/src/core/tsi/transport_security_grpc.h
+++ b/src/core/tsi/transport_security_grpc.h
@@ -22,10 +22,6 @@
#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. */
@@ -77,8 +73,4 @@ struct tsi_zero_copy_grpc_protector {
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 54942a6b2a..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 {
@@ -60,7 +56,7 @@ 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 --
@@ -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 9df531066e..08420817c8 100644
--- a/src/cpp/client/channel_cc.cc
+++ b/src/cpp/client/channel_cc.cc
@@ -61,11 +61,11 @@ 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;
@@ -89,14 +89,14 @@ 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()) {
@@ -134,7 +134,7 @@ void Channel::PerformOpsOnCall(internal::CallOpSetInterface* ops,
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) {
@@ -171,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 de67281dd4..93233153d0 100644
--- a/src/cpp/client/create_channel.cc
+++ b/src/cpp/client/create_channel.cc
@@ -39,11 +39,11 @@ std::shared_ptr<Channel> CreateCustomChannel(
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args) {
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(
- NULL, GRPC_STATUS_INVALID_ARGUMENT,
- "Invalid credentials."));
+ 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/common/channel_arguments.cc b/src/cpp/common/channel_arguments.cc
index f89f5f1f03..cae9ef953a 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() {
diff --git a/src/cpp/common/channel_filter.cc b/src/cpp/common/channel_filter.cc
index d1cfd2b48a..274079f8dd 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>
diff --git a/src/cpp/common/channel_filter.h b/src/cpp/common/channel_filter.h
index 4fb81ecb1e..9fe9cf0aea 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.
///
diff --git a/src/cpp/common/core_codegen.cc b/src/cpp/common/core_codegen.cc
index 3cbf08af9f..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 {
diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc
index e1e5e895f6..7f01a66dcf 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.8.0-dev"; }
+grpc::string Version() { return "1.9.0-dev"; }
} // namespace grpc
diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc
index 6480482774..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) {}
diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc
index f2cb6363f5..f0cbbdb86d 100644
--- a/src/cpp/server/server_context.cc
+++ b/src/cpp/server/server_context.cc
@@ -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;
}
@@ -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/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/ClientServerTest.cs b/src/csharp/Grpc.Core.Tests/ClientServerTest.cs
index 72d9035a6f..90dd365b07 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) =>
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..775c950c8c 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()));
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..b6bb0a9eae
--- /dev/null
+++ b/src/csharp/Grpc.Core.Tests/Internal/DefaultObjectPoolTest.cs
@@ -0,0 +1,79 @@
+#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 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 : IDisposable
+ {
+
+ 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/Channel.cs b/src/csharp/Grpc.Core/Channel.cs
index 1803920662..f9925a8a76 100644
--- a/src/csharp/Grpc.Core/Channel.cs
+++ b/src/csharp/Grpc.Core/Channel.cs
@@ -127,6 +127,20 @@ namespace Grpc.Core
}
}
+ // cached handler for watch connectivity state
+ static readonly BatchCompletionDelegate WatchConnectivityStateHandler = (success, ctx, state) =>
+ {
+ var tcs = (TaskCompletionSource<object>) state;
+ if (success)
+ {
+ tcs.SetResult(null);
+ }
+ else
+ {
+ tcs.SetCanceled();
+ }
+ };
+
/// <summary>
/// Returned tasks completes once channel state has become different from
/// given lastObservedState.
@@ -138,18 +152,8 @@ namespace Grpc.Core
"Shutdown is a terminal state. No further state changes can occur.");
var tcs = new TaskCompletionSource<object>();
var deadlineTimespec = deadline.HasValue ? Timespec.FromDateTime(deadline.Value) : Timespec.InfFuture;
- var handler = new BatchCompletionDelegate((success, ctx) =>
- {
- 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;
}
diff --git a/src/csharp/Grpc.Core/GrpcEnvironment.cs b/src/csharp/Grpc.Core/GrpcEnvironment.cs
index 80031cb7ef..2b1b5e32d7 100644
--- a/src/csharp/Grpc.Core/GrpcEnvironment.cs
+++ b/src/csharp/Grpc.Core/GrpcEnvironment.cs
@@ -33,6 +33,8 @@ namespace Grpc.Core
public class GrpcEnvironment
{
const int MinDefaultThreadPoolSize = 4;
+ const int DefaultBatchContextPoolSharedCapacity = 10000;
+ const int DefaultBatchContextPoolThreadLocalCapacity = 64;
static object staticLock = new object();
static GrpcEnvironment instance;
@@ -40,11 +42,14 @@ namespace Grpc.Core
static int? customThreadPoolSize;
static int? customCompletionQueueCount;
static bool inlineHandlers;
+ static int batchContextPoolSharedCapacity = DefaultBatchContextPoolSharedCapacity;
+ static int batchContextPoolThreadLocalCapacity = DefaultBatchContextPoolThreadLocalCapacity;
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 GrpcThreadPool threadPool;
readonly DebugStats debugStats = new DebugStats();
readonly AtomicCounter cqPickerCounter = new AtomicCounter();
@@ -186,7 +191,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 +208,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 +243,26 @@ 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>
/// 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 +274,7 @@ namespace Grpc.Core
private GrpcEnvironment()
{
GrpcNativeInit();
+ batchContextPool = new DefaultObjectPool<BatchContextSafeHandle>(() => BatchContextSafeHandle.Create(this.batchContextPool), batchContextPoolSharedCapacity, batchContextPoolThreadLocalCapacity);
threadPool = new GrpcThreadPool(this, GetThreadPoolSizeOrDefault(), GetCompletionQueueCountOrDefault(), inlineHandlers);
threadPool.Start();
}
@@ -264,6 +290,8 @@ namespace Grpc.Core
}
}
+ internal IObjectPool<BatchContextSafeHandle> BatchContextPool => batchContextPool;
+
internal bool IsAlive
{
get
@@ -325,6 +353,7 @@ namespace Grpc.Core
await Task.Run(() => ShuttingDown?.Invoke(this, null)).ConfigureAwait(false);
await threadPool.StopAsync().ConfigureAwait(false);
+ 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 09fb722c81..9946d1a6cf 100644
--- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs
+++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs
@@ -27,7 +27,7 @@ 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>>();
@@ -92,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();
}
}
@@ -138,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;
}
@@ -162,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;
@@ -188,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);
}
}
@@ -210,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);
}
}
@@ -256,7 +261,7 @@ namespace Grpc.Core.Internal
halfcloseRequested = true;
return TaskUtils.CompletedTask;
}
- call.StartSendCloseFromClient(HandleSendFinished);
+ call.StartSendCloseFromClient(SendCompletionCallback);
halfcloseRequested = true;
streamingWriteTcs = new TaskCompletionSource<object>();
@@ -516,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..83385ad7d3 100644
--- a/src/csharp/Grpc.Core/Internal/BatchContextSafeHandle.cs
+++ b/src/csharp/Grpc.Core/Internal/BatchContextSafeHandle.cs
@@ -20,23 +20,36 @@ 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
{
static readonly NativeMethods Native = NativeMethods.Get();
+ static readonly ILogger Logger = GrpcEnvironment.Logger.ForType<BatchContextSafeHandle>();
+
+ IObjectPool<BatchContextSafeHandle> ownedByPool;
+ CompletionCallbackData completionCallbackData;
private BatchContextSafeHandle()
{
}
- public static BatchContextSafeHandle Create()
+ public static BatchContextSafeHandle Create(IObjectPool<BatchContextSafeHandle> ownedByPool = null)
{
- return Native.grpcsharp_batch_context_create();
+ var ctx = Native.grpcsharp_batch_context_create();
+ ctx.ownedByPool = ownedByPool;
+ return ctx;
}
public IntPtr Handle
@@ -47,19 +60,26 @@ namespace Grpc.Core.Internal
}
}
+ 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 +106,53 @@ namespace Grpc.Core.Internal
{
return Native.grpcsharp_batch_context_recv_close_on_server_cancelled(this) != 0;
}
-
+
+ public void Recycle()
+ {
+ if (ownedByPool != null)
+ {
+ Native.grpcsharp_batch_context_reset(this);
+ ownedByPool.Return(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..cf3f3c0995 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,74 @@ 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 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)
{
- this.environment = environment;
+ this.environment = GrpcPreconditions.CheckNotNull(environment);
+ this.batchContextFactory = GrpcPreconditions.CheckNotNull(batchContextFactory);
}
- 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 void RegisterRequestCallCompletion(RequestCallContextSafeHandle ctx, RequestCallCompletionDelegate callback)
{
- get { return this.lastRegisteredKey; }
+ ctx.CompletionCallback = callback;
+ Register(ctx.Handle, 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..2f030f3e02
--- /dev/null
+++ b/src/csharp/Grpc.Core/Internal/DefaultObjectPool.cs
@@ -0,0 +1,196 @@
+#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, IDisposable
+ {
+ readonly object myLock = new object();
+ 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.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 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..f1b5a4f9ff 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());
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/csharp/Grpc.Core/Internal/IObjectPool.cs b/src/csharp/Grpc.Core/Internal/IObjectPool.cs
new file mode 100644
index 0000000000..f7d6e30a2a
--- /dev/null
+++ b/src/csharp/Grpc.Core/Internal/IObjectPool.cs
@@ -0,0 +1,35 @@
+#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.
+ /// </summary>
+ internal interface IObjectPool<T> : IDisposable
+ where T : class
+ {
+ T Lease();
+ void Return(T item);
+ }
+}
diff --git a/src/csharp/Grpc.Core/Internal/NativeMethods.cs b/src/csharp/Grpc.Core/Internal/NativeMethods.cs
index 22faa19d9b..43acb8f915 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;
@@ -167,6 +170,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);
@@ -309,6 +313,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();
@@ -420,7 +425,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..09f5c3e452 100644
--- a/src/csharp/Grpc.Core/Internal/RequestCallContextSafeHandle.cs
+++ b/src/csharp/Grpc.Core/Internal/RequestCallContextSafeHandle.cs
@@ -19,15 +19,17 @@
using System;
using System.Runtime.InteropServices;
using Grpc.Core;
+using Grpc.Core.Logging;
namespace Grpc.Core.Internal
{
/// <summary>
/// grpcsharp_request_call_context
/// </summary>
- internal class RequestCallContextSafeHandle : SafeHandleZeroIsInvalid
+ internal class RequestCallContextSafeHandle : SafeHandleZeroIsInvalid, IOpCompletionCallback
{
static readonly NativeMethods Native = NativeMethods.Get();
+ static readonly ILogger Logger = GrpcEnvironment.Logger.ForType<RequestCallContextSafeHandle>();
private RequestCallContextSafeHandle()
{
@@ -46,6 +48,8 @@ namespace Grpc.Core.Internal
}
}
+ public RequestCallCompletionDelegate CompletionCallback { get; set; }
+
// Gets data of server_rpc_new completion.
public ServerRpcNew GetServerRpcNew(Server server)
{
@@ -72,5 +76,22 @@ namespace Grpc.Core.Internal
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;
+ Dispose();
+ }
+ }
}
}
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..9b7ea884dd 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);
}
}
diff --git a/src/csharp/Grpc.Core/Server.cs b/src/csharp/Grpc.Core/Server.cs
index 77ad876bdf..71c7f108f3 100644
--- a/src/csharp/Grpc.Core/Server.cs
+++ b/src/csharp/Grpc.Core/Server.cs
@@ -387,7 +387,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/Version.csproj.include b/src/csharp/Grpc.Core/Version.csproj.include
index b9ceaf8254..2d9e4ba16a 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.8.0-dev</GrpcCsharpVersion>
+ <GrpcCsharpVersion>1.9.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 dab938821f..9b5da1c947 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.8.0.0";
+ public const string CurrentAssemblyFileVersion = "1.9.0.0";
/// <summary>
/// Current version of gRPC C#
/// </summary>
- public const string CurrentVersion = "1.8.0-dev";
+ public const string CurrentVersion = "1.9.0-dev";
}
}
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/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/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/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/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..eefdb50e39
--- /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()) : 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, () => BatchContextSafeHandle.Create());
+ 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..da4f35ff96 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());
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/build_packages_dotnetcli.bat b/src/csharp/build_packages_dotnetcli.bat
index ff013d5680..8f89e2846a 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.8.0-dev
+set VERSION=1.9.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 44a4791146..6a6cafe2bd 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.8.0-dev" -OutputDirectory ../../artifacts
-nuget pack Grpc.Tools.nuspec -Version "1.8.0-dev" -OutputDirectory ../../artifacts
+nuget pack Grpc.nuspec -Version "1.9.0-dev" -OutputDirectory ../../artifacts
+nuget pack Grpc.Tools.nuspec -Version "1.9.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 bcb3bfaee5..24d779e1e5 100644
--- a/src/csharp/ext/grpc_csharp_ext.c
+++ b/src/csharp/ext/grpc_csharp_ext.c
@@ -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,7 +213,15 @@ 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);
+ memset(ctx, 0, sizeof(grpcsharp_batch_context));
+}
+GPR_EXPORT void GPR_CALLTYPE
+grpcsharp_batch_context_destroy(grpcsharp_batch_context* ctx) {
+ if (!ctx) {
+ return;
+ }
+ grpcsharp_batch_context_reset(ctx);
gpr_free(ctx);
}
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..82573edecb 100644
--- a/src/csharp/tests.json
+++ b/src/csharp/tests.json
@@ -5,11 +5,13 @@
"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.ChannelCredentialsTest",
diff --git a/src/node/health_check/package.json b/src/node/health_check/package.json
new file mode 100644
index 0000000000..fca3a2a7a6
--- /dev/null
+++ b/src/node/health_check/package.json
@@ -0,0 +1,29 @@
+{
+ "name": "grpc-health-check",
+ "version": "1.7.2",
+ "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.2",
+ "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/tools/package.json b/src/node/tools/package.json
new file mode 100644
index 0000000000..99fd854067
--- /dev/null
+++ b/src/node/tools/package.json
@@ -0,0 +1,41 @@
+{
+ "name": "grpc-tools",
+ "version": "1.7.2",
+ "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 9065ab9f73..22501765f9 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.8.0-dev'
+ v = '1.9.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/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m
index b5ab611848..ac4596da25 100644
--- a/src/objective-c/GRPCClient/GRPCCall.m
+++ b/src/objective-c/GRPCClient/GRPCCall.m
@@ -299,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) = ^{
@@ -345,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];
@@ -441,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/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.m b/src/objective-c/GRPCClient/private/GRPCHost.m
index f73e9cbc50..a0f4118740 100644
--- a/src/objective-c/GRPCClient/private/GRPCHost.m
+++ b/src/objective-c/GRPCClient/private/GRPCHost.m
@@ -93,7 +93,7 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil;
if (!connectivityMonitor) {
connectivityMonitor =
[GRPCConnectivityMonitor monitorWithHost:hostURL.host];
- void (^handler)() = ^{
+ void (^handler)(void) = ^{
[GRPCHost flushChannelCache];
};
[connectivityMonitor handleLossWithHandler:handler
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..d26d13475d 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,13 +55,13 @@
}
- (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;
@@ -92,7 +92,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 +116,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 +271,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 db589d12de..69dd6266fd 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.8.0-dev"
+#define GRPC_OBJC_VERSION_STRING @"1.9.0-dev"
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/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm
index 453b0752c3..d5e668a858 100644
--- a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m
+++ b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm
@@ -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,7 +103,7 @@ 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);
}
@@ -171,7 +171,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 +207,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 +217,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..92bc20e5b9 100644
--- a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
+++ b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
@@ -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 5672bdad4c..3bab7f6671 100644
--- a/src/objective-c/tests/GRPCClientTests.m
+++ b/src/objective-c/tests/GRPCClientTests.m
@@ -95,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];
diff --git a/src/objective-c/tests/InteropTests.m b/src/objective-c/tests/InteropTests.m
index e5fcab26d8..0be8669aa2 100644
--- a/src/objective-c/tests/InteropTests.m
+++ b/src/objective-c/tests/InteropTests.m
@@ -86,6 +86,7 @@
}
+ (void)setUp {
+ NSLog(@"InteropTest Started, class: %@", [[self class] description]);
#ifdef GRPC_COMPILE_WITH_CRONET
// Cronet setup
[Cronet setHttp2Enabled:YES];
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 2f0c8cfe18..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,7 +140,7 @@
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>"; };
@@ -343,7 +343,7 @@
5E8A5DA51D3840B4000F8BC4 /* CoreCronetEnd2EndTests */ = {
isa = PBXGroup;
children = (
- 5E8A5DA61D3840B4000F8BC4 /* CoreCronetEnd2EndTests.m */,
+ 5E8A5DA61D3840B4000F8BC4 /* CoreCronetEnd2EndTests.mm */,
);
path = CoreCronetEnd2EndTests;
sourceTree = "<group>";
@@ -1196,7 +1196,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 5E8A5DA71D3840B4000F8BC4 /* CoreCronetEnd2EndTests.m in Sources */,
+ 5E8A5DA71D3840B4000F8BC4 /* CoreCronetEnd2EndTests.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1518,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";
@@ -1567,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";
@@ -1582,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";
@@ -1597,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..62c4e10b99 100755
--- a/src/objective-c/tests/run_tests.sh
+++ b/src/objective-c/tests/run_tests.sh
@@ -38,7 +38,7 @@ trap 'kill -9 `jobs -p` ; echo "EXIT TIME: $(date)"' EXIT
# 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 \
diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h
index 02515063fa..6e3a073020 100644
--- a/src/objective-c/tests/version.h
+++ b/src/objective-c/tests/version.h
@@ -23,5 +23,5 @@
// `tools/buildgen/generate_projects.sh`.
-#define GRPC_OBJC_VERSION_STRING @"1.8.0-dev"
+#define GRPC_OBJC_VERSION_STRING @"1.9.0-dev"
#define GRPC_C_VERSION_STRING @"5.0.0-dev"
diff --git a/src/php/composer.json b/src/php/composer.json
index 09471d23fe..43833980f9 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.8.0",
+ "version": "1.9.0",
"require": {
"php": ">=5.5.0",
"google/protobuf": "^v3.3.0"
diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h
index 93dd563cff..48131d72d1 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.8.0dev"
+#define PHP_GRPC_VERSION "1.9.0dev"
#endif /* VERSION_H */
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/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/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py
index c9f9ac27d9..564772527e 100644
--- a/src/python/grpcio/grpc/__init__.py
+++ b/src/python/grpcio/grpc/__init__.py
@@ -348,26 +348,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 +375,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,14 +400,14 @@ 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()
@@ -424,6 +422,21 @@ class ServerCredentials(object):
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 ###########################
@@ -1123,99 +1136,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.
+ 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
+ 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.
+ 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)
+ 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,
@@ -1252,6 +1252,61 @@ 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.
@@ -1334,7 +1389,8 @@ __all__ = ('FutureTimeoutError', 'FutureCancelledError', 'Future',
'ChannelConnectivity', 'StatusCode', 'RpcError', 'RpcContext',
'Call', 'ChannelCredentials', 'CallCredentials',
'AuthMetadataContext', 'AuthMetadataPluginCallback',
- 'AuthMetadataPlugin', 'ServerCredentials', 'UnaryUnaryMultiCallable',
+ 'AuthMetadataPlugin', 'ServerCertificateConfiguration',
+ 'ServerCredentials', 'UnaryUnaryMultiCallable',
'UnaryStreamMultiCallable', 'StreamUnaryMultiCallable',
'StreamStreamMultiCallable', 'Channel', 'ServicerContext',
'RpcMethodHandler', 'HandlerCallDetails', 'GenericRpcHandler',
@@ -1344,8 +1400,9 @@ __all__ = ('FutureTimeoutError', 'FutureCancelledError', 'Future',
'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',)
+ 'ssl_server_credentials', 'ssl_server_certificate_configuration',
+ 'dynamic_ssl_server_credentials', 'channel_ready_future',
+ 'insecure_channel', 'secure_channel', 'server',)
############################### Extension Shims ################################
diff --git a/src/python/grpcio/grpc/_auth.py b/src/python/grpcio/grpc/_auth.py
index c6542d0135..9a339b5900 100644
--- a/src/python/grpcio/grpc/_auth.py
+++ b/src/python/grpcio/grpc/_auth.py
@@ -63,7 +63,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/_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/call.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi
index 752fb330d0..6b3a276097 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi
@@ -72,13 +72,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.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi
index aeabdba021..4c397f8f64 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi
@@ -33,10 +33,10 @@ cdef class Channel:
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)
self.references.append(target)
self.references.append(arguments)
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi
index 41975cbe9e..7e9ea33ca0 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi
@@ -12,49 +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 _c_plugin(CredentialsMetadataPlugin plugin)
+cdef class CompositeCallCredentials(CallCredentials):
+ cdef readonly tuple _call_credentialses
-cdef class AuthMetadataContext:
+ cdef grpc_call_credentials *c(self)
- cdef grpc_auth_metadata_context context
+cdef class ChannelCredentials:
-cdef int 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) with gil
+ cdef grpc_channel_credentials *c(self)
-cdef void plugin_destroy_c_plugin_state(void *state) with gil
+ # TODO(https://github.com/grpc/grpc/issues/12531): remove.
+ cdef grpc_channel_credentials *c_credentials
+
+
+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 0fabda19ce..246a271893 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi
@@ -14,274 +14,237 @@
cimport cpython
+import grpc
import threading
-import traceback
-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:
+ def callback(Metadata metadata, grpc_status_code status, bytes error_details):
+ if status is StatusCode.ok:
+ cb(user_data, metadata.c_metadata, metadata.c_count, status, NULL)
+ 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 class CallCredentials:
+cdef void _destroy(void *state) with gil:
+ cpython.Py_DECREF(<object>state)
- def __cinit__(self):
- grpc_init()
- self.c_credentials = NULL
- self.references = []
- # 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
+cdef class MetadataPluginCallCredentials(CallCredentials):
- def __dealloc__(self):
- if self.c_credentials != NULL:
- grpc_call_credentials_release(self.c_credentials)
- grpc_shutdown()
+ 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 class ServerCredentials:
- def __cinit__(self):
- grpc_init()
- self.c_credentials = NULL
- self.references = []
+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
- def __dealloc__(self):
- if self.c_credentials != NULL:
- grpc_server_credentials_release(self.c_credentials)
- grpc_shutdown()
+cdef class CompositeCallCredentials(CallCredentials):
-cdef class CredentialsMetadataPlugin:
+ def __cinit__(self, call_credentialses):
+ self._call_credentialses = call_credentialses
- 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.
- """
- grpc_init()
- if not callable(plugin_callback):
- raise ValueError('expected callable plugin_callback')
- self.plugin_callback = plugin_callback
- self.plugin_name = name
+ cdef grpc_call_credentials *c(self):
+ return _composition(self._call_credentialses)
- def __dealloc__(self):
- grpc_shutdown()
+cdef class ChannelCredentials:
-cdef grpc_metadata_credentials_plugin _c_plugin(CredentialsMetadataPlugin plugin):
- cdef grpc_metadata_credentials_plugin c_plugin
- c_plugin.get_metadata = plugin_get_metadata
- c_plugin.destroy = plugin_destroy_c_plugin_state
- c_plugin.state = <void *>plugin
- c_plugin.type = plugin.plugin_name
- cpython.Py_INCREF(plugin)
- return c_plugin
+ cdef grpc_channel_credentials *c(self):
+ raise NotImplementedError()
-cdef class AuthMetadataContext:
+cdef class SSLChannelCredentials(ChannelCredentials):
- def __cinit__(self):
- grpc_init()
- self.context.service_url = NULL
- self.context.method_name = NULL
+ 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
- @property
- def service_url(self):
- return self.context.service_url
+ 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)
- @property
- def method_name(self):
- return self.context.method_name
- def __dealloc__(self):
- grpc_shutdown()
+cdef class CompositeChannelCredentials(ChannelCredentials):
+ def __cinit__(self, call_credentialses, channel_credentials):
+ self._call_credentialses = call_credentialses
+ self._channel_credentials = channel_credentials
-cdef int 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) 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
- def async_callback():
- 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())
- threading.Thread(group=None, target=async_callback).start()
- return 0 # Asynchronous return
+ 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 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
+cdef class ServerCertificateConfig:
-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)
- else:
- with nogil:
- credentials.c_credentials = grpc_ssl_credentials_create(
- c_pem_root_certificates, NULL, NULL)
- return credentials
+ def __cinit__(self):
+ grpc_init()
+ self.c_cert_config = NULL
+ self.c_pem_root_certs = NULL
+ self.c_ssl_pem_key_cert_pairs = NULL
+ self.references = []
-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 __dealloc__(self):
+ grpc_ssl_server_certificate_config_destroy(self.c_cert_config)
+ gpr_free(self.c_ssl_pem_key_cert_pairs)
+ grpc_shutdown()
-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
+cdef class ServerCredentials:
-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 __cinit__(self):
+ grpc_init()
+ self.c_credentials = NULL
+ self.references = []
+ self.initial_cert_config = None
+ self.cert_config_fetcher = None
+ self.initial_cert_config_fetched = False
-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
+ def __dealloc__(self):
+ if self.c_credentials != NULL:
+ grpc_server_credentials_release(self.c_credentials)
+ grpc_shutdown()
-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
+cdef const char* _get_c_pem_root_certs(pem_root_certs):
+ if pem_root_certs is None:
+ return NULL
+ else:
+ return pem_root_certs
-def call_credentials_metadata_plugin(CredentialsMetadataPlugin plugin):
- cdef CallCredentials credentials = CallCredentials()
- cdef grpc_metadata_credentials_plugin c_plugin = _c_plugin(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/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
index f115106e60..660263fc09 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
@@ -391,6 +391,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"
@@ -440,10 +476,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,
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi
index b8db27469f..5f3405936c 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi
@@ -14,8 +14,46 @@
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:
diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py
index 0887ac1722..993c49d4af 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.8.0.dev0"""
+__version__ = """1.9.0.dev0"""
diff --git a/src/python/grpcio/grpc/_plugin_wrapping.py b/src/python/grpcio/grpc/_plugin_wrapping.py
index bea2c0f139..cd17f4a049 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,79 @@ from grpc import _common
from grpc._cython import cygrpc
-class AuthMetadataContext(
+class _AuthMetadataContext(
collections.namedtuple('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(
+ _common.to_cygrpc_metadata(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..5b4812bffe 100644
--- a/src/python/grpcio/grpc/_server.py
+++ b/src/python/grpcio/grpc/_server.py
@@ -374,10 +374,10 @@ 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 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))
@@ -389,10 +389,10 @@ 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 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))
@@ -591,7 +591,13 @@ def _handle_call(rpc_event, generic_handlers, thread_pool,
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)
+ try:
+ method_handler = _find_method_handler(rpc_event, generic_handlers)
+ 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
diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py
index bb7d990078..d2a68f0902 100644
--- a/src/python/grpcio/grpc_core_dependencies.py
+++ b/src/python/grpcio/grpc_core_dependencies.py
@@ -29,7 +29,7 @@ CORE_SOURCE_FILES = [
'src/core/lib/support/env_linux.cc',
'src/core/lib/support/env_posix.cc',
'src/core/lib/support/env_windows.cc',
- 'src/core/lib/support/histogram.cc',
+ 'src/core/lib/support/fork.cc',
'src/core/lib/support/host_port.cc',
'src/core/lib/support/log.cc',
'src/core/lib/support/log_android.cc',
@@ -38,7 +38,6 @@ CORE_SOURCE_FILES = [
'src/core/lib/support/log_windows.cc',
'src/core/lib/support/mpscq.cc',
'src/core/lib/support/murmur_hash.cc',
- 'src/core/lib/support/stack_lockfree.cc',
'src/core/lib/support/string.cc',
'src/core/lib/support/string_posix.cc',
'src/core/lib/support/string_util_windows.cc',
@@ -80,7 +79,6 @@ CORE_SOURCE_FILES = [
'src/core/lib/http/httpcli.cc',
'src/core/lib/http/parser.cc',
'src/core/lib/iomgr/call_combiner.cc',
- 'src/core/lib/iomgr/closure.cc',
'src/core/lib/iomgr/combiner.cc',
'src/core/lib/iomgr/endpoint.cc',
'src/core/lib/iomgr/endpoint_pair_posix.cc',
@@ -95,6 +93,8 @@ CORE_SOURCE_FILES = [
'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',
diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py
index 61c4157375..8f07f3b30b 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.8.0.dev0'
+VERSION='1.9.0.dev0'
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 889297f020..0987d57261 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.8.0.dev0'
+VERSION='1.9.0.dev0'
diff --git a/src/python/grpcio_health_checking/setup.py b/src/python/grpcio_health_checking/setup.py
index 1f5e9c5130..c105f57509 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,26 @@ PACKAGE_DIRECTORIES = {
'': '.',
}
-SETUP_REQUIRES = (
- 'grpcio-tools>={version}'.format(version=grpc_version.VERSION),)
-
-INSTALL_REQUIRES = ('protobuf>=3.3.0',
+INSTALL_REQUIRES = ('protobuf>=3.5.0.post1',
'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_version.py b/src/python/grpcio_reflection/grpc_version.py
index 192f4cc217..95d2ff143a 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.8.0.dev0'
+VERSION='1.9.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..760b89373a 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,26 @@ PACKAGE_DIRECTORIES = {
'': '.',
}
-SETUP_REQUIRES = (
- 'grpcio-tools>={version}'.format(version=grpc_version.VERSION),)
-
-INSTALL_REQUIRES = ('protobuf>=3.3.0',
+INSTALL_REQUIRES = ('protobuf>=3.5.0.post1',
'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_version.py b/src/python/grpcio_testing/grpc_version.py
index 83470c2825..afc6dd83f2 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.8.0.dev0'
+VERSION='1.9.0.dev0'
diff --git a/src/python/grpcio_testing/setup.py b/src/python/grpcio_testing/setup.py
index 0cc336abd1..fa40424f6a 100644
--- a/src/python/grpcio_testing/setup.py
+++ b/src/python/grpcio_testing/setup.py
@@ -28,7 +28,7 @@ PACKAGE_DIRECTORIES = {
'': '.',
}
-INSTALL_REQUIRES = ('protobuf>=3.3.0',
+INSTALL_REQUIRES = ('protobuf>=3.5.0.post1',
'grpcio>={version}'.format(version=grpc_version.VERSION),)
setuptools.setup(
diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py
index 7065edd3bf..99ca3fd82d 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.8.0.dev0'
+VERSION='1.9.0.dev0'
diff --git a/src/python/grpcio_tests/setup.py b/src/python/grpcio_tests/setup.py
index debe14c40e..aeb4ea9c53 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!
diff --git a/src/python/grpcio_tests/tests/interop/client.py b/src/python/grpcio_tests/tests/interop/client.py
index e520c08290..383b5f033d 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()
diff --git a/src/python/grpcio_tests/tests/interop/server.py b/src/python/grpcio_tests/tests/interop/server.py
index 8ad1f5f7cd..eeb41a21d2 100644
--- a/src/python/grpcio_tests/tests/interop/server.py
+++ b/src/python/grpcio_tests/tests/interop/server.py
@@ -29,12 +29,13 @@ _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))
diff --git a/src/python/grpcio_tests/tests/tests.json b/src/python/grpcio_tests/tests/tests.json
index 8512d5b96f..34cbade92c 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",
@@ -46,6 +46,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..b14e8d5c75 100644
--- a/src/python/grpcio_tests/tests/unit/_api_test.py
+++ b/src/python/grpcio_tests/tests/unit/_api_test.py
@@ -30,18 +30,20 @@ class AllTest(unittest.TestCase):
'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',
+ 'AuthMetadataPlugin', 'ServerCertificateConfiguration',
+ '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',
+ 'ssl_server_credentials', 'ssl_server_certificate_configuration',
+ 'dynamic_ssl_server_credentials', 'channel_ready_future',
'insecure_channel', 'secure_channel', 'server',)
six.assertCountEqual(self, expected_grpc_code_elements,
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/_cython/cygrpc_test.py b/src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py
index 18d4a6df64..da94cf8028 100644
--- a/src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py
+++ b/src/python/grpcio_tests/tests/unit/_cython/cygrpc_test.py
@@ -28,7 +28,7 @@ _CALL_CREDENTIALS_METADATA_VALUE = 'call-creds-value'
_EMPTY_FLAGS = 0
-def _metadata_plugin_callback(context, callback):
+def _metadata_plugin(context, callback):
callback(
cygrpc.Metadata([
cygrpc.Metadatum(_CALL_CREDENTIALS_METADATA_KEY,
@@ -105,17 +105,9 @@ class TypeSmokeTest(unittest.TestCase):
channel = cygrpc.Channel(b'[::]:0', cygrpc.ChannelArgs([]))
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([]))
@@ -205,7 +197,7 @@ class ServerClientMixin(object):
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'
@@ -439,8 +431,8 @@ class SecureServerSecureClient(unittest.TestCase, ServerClientMixin):
cygrpc.SslPemKeyCertPair(resources.private_key(),
resources.certificate_chain())
], False)
- client_credentials = cygrpc.channel_credentials_ssl(
- resources.test_root_certificates(), None)
+ 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/_invocation_defects_test.py b/src/python/grpcio_tests/tests/unit/_invocation_defects_test.py
index 0a1e50c94c..2a1a49ce74 100644
--- a/src/python/grpcio_tests/tests/unit/_invocation_defects_test.py
+++ b/src/python/grpcio_tests/tests/unit/_invocation_defects_test.py
@@ -32,6 +32,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):
@@ -95,6 +96,9 @@ class _Handler(object):
yield request
self._control.control()
+ def defective_generic_rpc_handler(self):
+ raise test_control.Defect()
+
class _MethodHandler(grpc.RpcMethodHandler):
@@ -132,6 +136,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,6 +182,10 @@ 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):
@@ -235,6 +245,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/_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..005d16ea75
--- /dev/null
+++ b/src/python/grpcio_tests/tests/unit/_server_ssl_cert_config_test.py
@@ -0,0 +1,519 @@
+# 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.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 = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
+ 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 = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
+ 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/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
+R7YhQ431ZpJ2KGnYjVhYnZ2L3NjV3UYX3x5Z3OrDj9hybhucJB48DMQ1+loEabwK
+fSUJtcSPc8dCIibxVKidBFgaTPXtHy2MPXuhMhR7PCtMpE7RPUoYmdZLr9FNN1ty
+/RAbwBfuhGLbRI2qqJgbOzHJHaOY/FtShfooLz7lt4LIjPTARaNsulG2rbv+m3z9
+mhNjL+peV8gni/xyOYYTbdzZagLrtSHeTWsITvmVt0flMHkjHyv35rw23+hBlSjp
+6+S+0MmwuwxqBBccBSlZ9t3Xh1N+vFkb2UkCAwEAAaNjMGEwHQYDVR0OBBYEFJWE
+tQwTbTCgZWNN08VSxjdNA0oaMB8GA1UdIwQYMBaAFJWEtQwTbTCgZWNN08VSxjdN
+A0oaMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEB
+CwUAA4ICAQCNjPv/e3ozX1PuN5Tluf0yOmKCxKVCK3Pp98WkDzH4Rp1urEeYrGJL
+vBNcl17avOJ0e+zTVYPXFviFbsBsU/zaf+TqEujXabsdL+nvvCJ2mMqYn4wyDFjS
+zDNbGH6O0ENZz5NSY0/UGSOHYrYnYB94QRFLbbf0Y3PmBS2eRNjIUnv7ytPZNMi/
+piM+QhPb0Ebyk0rHQZ0RAJaC/wsEtqP8TGV/fx+AzG7zW/zxgPTrgIThy138tLQ+
+xCVDP9H2c17nVP6vjYzKnMZ94uGrGqUzV9vU7EqYl0uZflIf98pLfdKHnQ3heqds
+8KQPNKRxVvcc92qv2pQY951wb1fkhLutjHn7TUvrenyAngz+Vs19NxbqLPys1CTw
+iaL7vZ8VE/aEDm1tjt5SLM474tpATjk1+qMRaWnii8J5rTodYHP+Zu2GxyIrMiGq
+tfNZMYI0tETK1XmEo75E/3s9pmIeQNGKLFp+qL7xrVyN/2ffNv0at8kkqXluunK9
+/Ki0gKYlGFm4Eu8t/nHMqhBx/njYg6pLDuarLW6ftUV7aHd7qKcCWOWqK6gnH/vX
+3Apv31eltZBBVN69p3CFy2oMnjrom2Yn/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+YKvJ25oj8Jfr+4
+0baznyWTmOcfoviKrb7u2T9BPEEz5og+lXRDAsTFATGaQDX2LN3Dd9KIw+7sWY+g
+c3Zi13HHaWYhtmfJjzFbH1vDxHKCdSdgtPyEhqcJ4OC6wbgp/mQ01VlPAr08kRfk
+C8mTTS7atqc410irKViF3sWi4YNPf7LuBrjo75FIIOp+sQgZE6xwOuZ/9bT2Zx/I
+UtCCTqzVgZI0s5NVlINtWR6eyyxQ1uDKTs4xrQIDAQABAoIBAC56mDswxH4uAmlT
+yA2Da+a/R6n4jTBkDZ1mFKf93Dd3a7rZa6Lpylk+YAI9GdfiGiD/SbB7AKjLo0m9
+0dKx+ngdQbJ39v42obbT9HQ9o/poFaO91+QyvkDytZYuFHgPaidJjRo5e8qz9D1o
+v+4hoFGhCQvOB5BRLcFU+cc3etWr5t61sNL/kKCWEDd+MWWsOCHpdhEoWC+o25pC
+bhD3FG5xoz+8zL7WdNfke/4twfKoBJ/kq89bfIkl8eKpg387WBQY44RJF7/zVr7a
+9dsUuW2y/wVXslCHChjSrxhRlOyy5ssv3EgKh8gPkZ+oeKuONqAGw27nyKyvpjxS
+i62K+WECgYEA4oKpIS2D77RCC6rpYIK6KYfbUcNSOtHFvcbf0RH9Oi8vSRYum2ZA
+/ITdWSFgWkhT6iOSPuvZlu/EvueWDgNgW1ZVsTMFeapz1+Jwk7JRoBKF1dUEwELh
+jdAswdh0MLbgBYs6NXtVVkeK2ocgZtosmt1PUktl566NlyIyhOjH6vkCgYEAw5g0
+cteTpz+noKsfWcbnjyesuQy0caICfZIE01nKv9rKTF8BtCO6Qxj10iM2o00jW7Vl
+tZa/igjuqvozXAHBI3xegtrWV05urkjj3FB/Pyuqsx3wxhAdSNchQjdTjwUBQEzp
+3ztGSlDTRPpijnpW28lg8Kkr3weryaHvl0xM1VUCgYBqnTN8QU8rgT3g/gYw/fcf
+2ylY98V5mAkqBTSN1JjLTTBFh2JSlLOb5/HDpRkUBZ0xxKJuaVaWW67QaHLRj7dH
+5oAZErnOBXPXNmbkrfcLkAxclJJS6Gf/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/EJbnP7KbZNPBvKpQCDEqg9B2TPaC8WVjiqT6I88c+KcGuB8nADJdk
+o10iZC5AwbrXK4ELSCOvBpxYI5sjoFcv3lZ/oe4e650QO2L/ADmtwLaLYK6rZkwW
+Sd90yCGF7ZOTZTJZDwmWEl+ohi+2ow6sRMHKcSKUNfx9G5BB7TOzoqUxqH+moEds
+YpjVMEcKzQi2FmbRd+8Dlg2eGqA2V4faprGQwoYz8NqJZGa/KPpRvXE2VjSTDN6b
+rJ7mmui6eYN53mZEBRYogyoQHdFXhK02FgyoPEgR/wQlLLbQ+xxOcv02YsOljtza
+hl5LjeNUYPMjyhef0QpONp+5NcFhZf38DsSq5EWZLLxPScxwl0lBQkJTjo5ARuFl
+Mrv50RYrLwv4ImsiO2ftE7gAX4vNsgcixnCHd6rNzoGimf1+DSvDVJ9ujWo7HPN3
+7ONuoyjsU4mUJJpYXs8zHx5WSxaYiPJRcmG3LjcU5/A+Fs7bkqSrlEjJsG29xDrO
+vKR7hH+m6MwcIcXSh9wjjAIvHxAALdU9xaYE3hmVkoxew1mRBsYq34h2vpwGOY5r
+0njRQyGGZnVa8qkQd6P3U5fcvLOM8v9QImZqRDS2jAGZXYruo/RIgJpklVX7ZY0+
+CnGdz4YxgLyOBJCDu3aEgL1oON3mg2SsrVMCAwEAAaNjMGEwHQYDVR0OBBYEFOBO
+9R6yEY6KOE+aSClwD2BQtWXKMB8GA1UdIwQYMBaAFOBO9R6yEY6KOE+aSClwD2BQ
+tWXKMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEB
+CwUAA4ICAQBElio7lLZ2eNt0tDPVSkChksc0IJ2/DpjYjqJzqxF/jZ2oToaAn2Er
+9iHl8ggTLB5WrTQxO1ev7qOwQsk9hrgvZ+EQCBTbyDyfNwVjgftH5jdQGdbyrnuJ
+yaks1mnd8is5ZZQmmQSd7GVOMTYi/7yH0xI4DHQ386dwnf5eKdoOI7yrVufEMxRx
+tB3Wv8KrX4z47zsIO28H/O0T26oUkrd4PEqFwDa5HQr6iG7QQgoGD/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
+Gd9SpFAykyRyLQgHcR5hgD55mz+9fl1OfnMoAc7yTdPVLksDLmeFUlxcvCtLHysJ
+klIBX62c6LzbsVcfLg/DPJlQxFnkhJCRKen4fp7x9h62qqJkDFVXsiEFza9L1lsN
+4OwqU8i4RRgZ/xggM/s/wVBtynioeW9QADNmKZ1n6HVKkYwdOynbFSggYfFrL3HL
+54bC9roZUETin0G5wZ9QU+srgivT0a/KC3ourBYHXAI40iHuuOBf3syDVJ6xId/r
+3UO3qkiQ5q7pwglg+8Nx7Q3CFtGZY3ewxSSSDo6BOyweGYMsBaxMO3EyTqecyfXn
+3n4XPqwmDalWYQIDAQABo4HFMIHCMAkGA1UdEwQCMAAwEQYJYIZIAYb4QgEBBAQD
+AgWgMDMGCWCGSAGG+EIBDQQmFiRPcGVuU1NMIEdlbmVyYXRlZCBDbGllbnQgQ2Vy
+dGlmaWNhdGUwHQYDVR0OBBYEFP2bodoNQ1tCNEOALPnygGMUfNI+MB8GA1UdIwQY
+MBaAFOWzLd7eBJwSNbzRqNsD7MQDCHg/MA4GA1UdDwEB/wQEAwIF4DAdBgNVHSUE
+FjAUBggrBgEFBQcDAgYIKwYBBQUHAwQwDQYJKoZIhvcNAQELBQADggIBAHqUuCLt
+olOdR9p/g+KgGPnKuVgMn15Wc2VLCrbbl2P0fuCcNWmnBKqHHgQ1EJEpgnQ2N8m6
+tOGucX7IAzlZj36RP4lN3gZqFRSO/OiTOUYpE6Uv1hYRxeMzAYo5sBdCiiypjV9z
+H0Ew5NuWRf2/0nFWoywB9ktHcfD8lRFI3o8zUFXmE2JSUPQtKhW3tBkPPjYBlgzD
+RD8cq8dVK9P7i3tUENP+MNHJToNLFBqfA9De6bKnhCWHhZkfB0VeeSm4Ja9HkCg/
+DB+PAKMfbLCH5T8gCpEWxNlvj09r9mn37fNjtJPO/goAcNZNO2AURmb/ZQ4ggdry
+xb6lm832qplMUMWx//Ore0faEodlEc5d2kEtmcjj79gAypcLmm74q7CPt7xmniyd
+XvNT33S2tkh4dSirpCVwq0xyqOP3ZqTsTjudTveTBaTZNhTbCjDbaV7ga47TcH9/
++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+iYexRnaaGfOFR3co7jQ5QKar
+oK4UgJC3mVDZQEMBV0oljkpgVQMAVb4XQU7e+o25JOUkOoK6LdK/b/95khR0jTyD
+OBLqd4mCEzxNi+jZ0jLTLPk0c+DnGmRfoNUxnFb40R8QnEIEKwf+JKyl6p89oqOl
+pvIZFLZlUWIS4qL+993l1SCqPkWJOAdTg+s/Zh6DeAOhrUn9/wk0aQwZrK7wQQLJ
+4GGhxC/FfuUGsLqZszAVkP8jDEWnzhN2rw3V+C7v6lj4qHhUwqGHuYzCx2Hxl+B8
+UyBmZb9gXKVUtAvaZjaL2PDj1ZAxT0KVMlw1ZVrZu45OsHNQuBx/4uIAt6Rga8yt
+av1lsq+hFqwI4bU/oZC/oPMacOsB4qEkAA1101WjMc5bg6JOPWobwIqmUXQR1WJE
+j30e99HCpk1Cc2+9sUCzNu8KvU5kUY2K90zwqProvj5IfMuDetAVXsEjgW+ZqSho
+UMIpJ2M/hzAFl8Z5IRlG+YNfZNXl0FqJ5LzLAgMBAAGjZjBkMB0GA1UdDgQWBBTl
+sy3e3gScEjW80ajbA+zEAwh4PzAfBgNVHSMEGDAWgBTgTvUeshGOijhPmkgpcA9g
+ULVlyjASBgNVHRMBAf8ECDAGAQH/AgEAMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG
+9w0BAQsFAAOCAgEAOS7DtliOUPcVosRfyx9dHcSUc3O+uY8uKjSHhdIrxDJm4lwP
+Q6lKg5j8CdMVb+sDQmyBkqQIA/6E13corP6R283jO6W8D4A8kjOiQWpXfjW6OcP3
+4rrDEWhCdeLFSNJIYOFkr2qWJpI/k0VpyDnmY0YluS5WbNjg6zTzGelzhFbV7/S1
+cteNAZD0vHD8NmbLVDJjjIY3E/iwzoUzBncLYbDwqyVS1g6utWdSy8LEJxzzqqWJ
+pBKlNYILAdh8efBgvotafaxsn2nfjmVmekPn3KcQZuE4Kzv1EQ2PrHpGeJKwh6up
+YBL2tav5cAki8bWoGPr2oGmWUf9L2tB57SdWdaY60ifzmQaeGiWPZBSmAz7PRSrz
+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/O9DfJj6UaiCUayVE7UujXoke7AlKQEJcqvnD/CoTv2Y8jV1A6mPf6CTEI
+Sl1BMeFSmeFyvZll+xJ8Up1KfQZxKhtpP1s/rp6ZNlqSs1LM5+vcDHHZ6COTbq7t
+2vvcmGDTqeCLsqicBg1kJyMPRtqa0bNPj2bcVtcK0Ndfn6eL2hi+EoBy2nIXi6aG
+PpXf85b9bCLd5pZI80nHzFlhdvV+SxqrfwIDAQABo4IBBTCCAQEwCQYDVR0TBAIw
+ADARBglghkgBhvhCAQEEBAMCBkAwMwYJYIZIAYb4QgENBCYWJE9wZW5TU0wgR2Vu
+ZXJhdGVkIFNlcnZlciBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUoYjECaDz/ZELru/r
+jfTB1ShlVrAwaAYDVR0jBGEwX4AU5bMt3t4EnBI1vNGo2wPsxAMIeD+hQ6RBMD8x
+CzAJBgNVBAYTAnVzMQ4wDAYDVQQIDAVkdW1teTEOMAwGA1UECgwFZHVtbXkxEDAO
+BgNVBAMMB3Jvb3QgY2GCAhAAMA4GA1UdDwEB/wQEAwIFoDATBgNVHSUEDDAKBggr
+BgEFBQcDATANBgkqhkiG9w0BAQsFAAOCAgEAiiR2knMMym4O+3fD1KlYSnc2UR3v
+0FlRVAsr8wvTlVjJhx7DbRusBNJHWX66mUgK9x5OLnhyvyqlFVhR9AwlnxgfLWz9
+nnACeXzcjQZnKWFQWu8bJSC6Ene6rd1g2acK6SOjxavVbj7JVFnmlHF/naZUzvMl
+mJivYta4k7ob8UcX0I5TlJpzglU3UHyyJd5d9zhbF8wqbBq63zR2ovWci4pYCg+F
+jYcTGYVZJti3SHO+9/EqTC9x2KDNs3o0+rreJ3GuoonkInKZMQQZJQ6qILvkxlhT
+jyU5xlcaJ+0tSaiFK3eF0nXIpFYdZbIHYPCdLjh9AZ2dkFcAgSa/L8+tsVt60k8D
+HTO0Hz6dW5D2ckeebZvz5LACMN89gVzrc/rVkeg7QmpSbjkTSLC2KJS53hJzWcEI
+3KB73B9iY+ZYytcYBTYLizsAxd5g7j9z8UXrmVQ4mWbh2+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+GdUjpmiON3HBL8+ne3bLZ42uI+DSVe8d3irbqg2rqsiANf0gdimMW4nuI4
+rVxf8HrY43PdQn/Vby+7qLRE3tmIlpbTqJGRtWRjdeBBI91APCrRljjXrKqT6Zpa
+E6Daz3YIQvXkIT0q+WkeN1VmQbtRnk7kRsPNp15kSwpHfmv6o/vkO9OUb1n71P2F
+wnB0WDECgYEA8iltnKxXnjqwZ/vzIWzcd94j+mdZg/K2/JCOqjwMvpSGCvx2zUmq
+Y2nxO2K85AVeOm/Yt87SMODB6AQ9CsrVGEUAzzacvCJDb8oUhaOL5gypnyvZiGCy
+snzXfgB+v/xuGekIjs2y7E8h3GG40j0aNQnUY1Fuc6iaeJG4BtjkuQUCgYEA1rE4
+DrTSsUh3hLYQusIHZR8Lecrrd4QUZSMKLkWjobiSTw3m4mglx1s2G4eZ3WuzOyFq
+Dp3/b3yfT8prdPBGA6shHNFf+1TO1q1/pIt15dc3sFwxMkuunai8N4QZJRqZLbYq
+FkNFkZ20hFHcH/NHDsAsRL/0tJdEmJ2ruP+Qdq0CgYBsdPGKwgVb8J0hdU4nIkJ7
+zRoABFmrJwGdjIDY7Zwnnw2JzhjHSL7vV3ubRVWkKmNReNZvPEoXahJuf7d3JfDa
+tczvAV6hRBc/8hnO4Li/h9xQVatP0T83gYJiBIbAJaaKJDyY+Lex7p8TvRCx2Hvs
+VUKyWL5HPrQwW9M3/dwyoQKBgQCNQoPA4Wcz8Jt7PZQaXaoh9eBGHab6t3P366s6
+MOXudZQG4f3FgINC/ZfHW1x43PFL+btfrMOyJkxoYqZ7hdB7f3DFFlpR80Y46GVw
+7bYAKbBhoPdZwYQ+BhT5bjhhOnQJKK/egBrZKevpmDb+6sIZSYaXIbovzMv8otmn
+WrhB7QKBgAdl+KYBQULCUBp8qCQH5sAQoWErpyuD2FNN6LGknpPqn4DdujvwEP0Z
+OSvbauLkI0Qc9/MezKPTeYXlFqdbpItwyySJsUkiI3HhVYlBgDkZ7xb6uHIH5E6I
+bKgIW5JEf5I7Eu1iurORkXxCCGMkiQmEs4X5kSXXRYgXfNgAD0FX
+-----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/resources.py b/src/python/grpcio_tests/tests/unit/resources.py
index 823d2307d3..11ef9e8565 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,81 @@ 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/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..790fc23e92 100755
--- a/src/ruby/end2end/end2end_common.rb
+++ b/src/ruby/end2end/end2end_common.rb
@@ -40,12 +40,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 = GRPC::RpcServer.new(@rpc_server_args)
port = @srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
@srv.handle(@service_impl)
@@ -75,7 +76,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/multiple_killed_watching_threads_driver.rb b/src/ruby/end2end/multiple_killed_watching_threads_driver.rb
index 94d5e9da2d..59f6f275e4 100755
--- a/src/ruby/end2end/multiple_killed_watching_threads_driver.rb
+++ b/src/ruby/end2end/multiple_killed_watching_threads_driver.rb
@@ -26,6 +26,8 @@ def watch_state(ch)
fail "non-idle state: #{state}" unless state == IDLE
ch.watch_connectivity_state(IDLE, Time.now + 360)
end
+ # sleep to get the thread into the middle of a
+ # "watch connectivity state" call
sleep 0.1
thd.kill
end
diff --git a/src/ruby/end2end/sig_handling_client.rb b/src/ruby/end2end/sig_handling_client.rb
index 41b5f334be..129ad7cb7f 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 = GRPC::RpcServer.new(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/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c
index 648d515003..56f1d4c93f 100644
--- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c
+++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c
@@ -223,21 +223,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;
@@ -510,21 +495,6 @@ void grpc_rb_load_imports(HMODULE library) {
gpr_cmdline_usage_string_import = (gpr_cmdline_usage_string_type) GetProcAddress(library, "gpr_cmdline_usage_string");
gpr_cpu_num_cores_import = (gpr_cpu_num_cores_type) GetProcAddress(library, "gpr_cpu_num_cores");
gpr_cpu_current_cpu_import = (gpr_cpu_current_cpu_type) GetProcAddress(library, "gpr_cpu_current_cpu");
- gpr_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 ae1e1a0b30..fae77843f0 100644
--- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h
+++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h
@@ -36,7 +36,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>
@@ -337,7 +336,7 @@ extern grpc_composite_call_credentials_create_type grpc_composite_call_credentia
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);
@@ -589,7 +588,7 @@ extern gpr_free_aligned_type 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);
@@ -649,51 +648,6 @@ extern gpr_cpu_num_cores_type gpr_cpu_num_cores_import;
typedef unsigned(*gpr_cpu_current_cpu_type)(void);
extern gpr_cpu_current_cpu_type gpr_cpu_current_cpu_import;
#define gpr_cpu_current_cpu gpr_cpu_current_cpu_import
-typedef 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);
extern gpr_join_host_port_type gpr_join_host_port_import;
#define gpr_join_host_port gpr_join_host_port_import
@@ -712,7 +666,7 @@ extern gpr_log_message_type 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);
@@ -814,7 +768,7 @@ extern gpr_stats_inc_type gpr_stats_inc_import;
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);
diff --git a/src/ruby/lib/grpc/generic/interceptors.rb b/src/ruby/lib/grpc/generic/interceptors.rb
index 73faec4b9c..24482f3451 100644
--- a/src/ruby/lib/grpc/generic/interceptors.rb
+++ b/src/ruby/lib/grpc/generic/interceptors.rb
@@ -41,7 +41,7 @@ module GRPC
# @param [Method] method
# @param [Hash] metadata
#
- def request_response(request:, call:, method:, 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
@@ -55,7 +55,7 @@ module GRPC
# @param [Method] method
# @param [Hash] metadata
#
- def client_streamer(requests:, call:, method:, 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
@@ -69,7 +69,7 @@ module GRPC
# @param [Method] method
# @param [Hash] metadata
#
- def server_streamer(request:, call:, method:, 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
@@ -83,7 +83,7 @@ module GRPC
# @param [Method] method
# @param [Hash] metadata
#
- def bidi_streamer(requests:, call:, method:, 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
@@ -102,7 +102,7 @@ module GRPC
# @param [GRPC::ActiveCall::SingleReqView] call
# @param [Method] method
#
- def request_response(request:, call:, 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
@@ -114,7 +114,7 @@ module GRPC
# @param [GRPC::ActiveCall::MultiReqView] call
# @param [Method] method
#
- def client_streamer(call:, method:)
+ def client_streamer(call: nil, method: nil)
GRPC.logger.debug "Intercepting client streamer method #{method}" \
" with call #{call}"
yield
@@ -127,7 +127,7 @@ module GRPC
# @param [GRPC::ActiveCall::SingleReqView] call
# @param [Method] method
#
- def server_streamer(request:, call:, 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
@@ -140,7 +140,7 @@ module GRPC
# @param [GRPC::ActiveCall::MultiReqView] call
# @param [Method] method
#
- def bidi_streamer(requests:, call:, 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
diff --git a/src/ruby/lib/grpc/generic/rpc_server.rb b/src/ruby/lib/grpc/generic/rpc_server.rb
index d5fc11dc1c..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
@@ -202,17 +214,18 @@ module GRPC
# 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,
- connect_md_proc:nil,
- server_args:{},
- interceptors:[])
+ 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
diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb
index 3001579ce7..be1412511a 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.8.0.dev'
+ VERSION = '1.9.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/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/pb/health/checker_spec.rb b/src/ruby/spec/pb/health/checker_spec.rb
index 6c9e206c3f..c79ccfd2e0 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
diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb
index c584a7cf59..48aad39e08 100644
--- a/src/ruby/tools/version.rb
+++ b/src/ruby/tools/version.rb
@@ -14,6 +14,6 @@
module GRPC
module Tools
- VERSION = '1.8.0.dev'
+ VERSION = '1.9.0.dev'
end
end
diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template
index 2ed7c90757..f89371057f 100644
--- a/templates/CMakeLists.txt.template
+++ b/templates/CMakeLists.txt.template
@@ -280,6 +280,7 @@
elseif("<%text>${gRPC_SSL_PROVIDER}</%text>" STREQUAL "package")
find_package(OpenSSL REQUIRED)
set(_gRPC_SSL_LIBRARIES <%text>${OPENSSL_LIBRARIES}</%text>)
+ include_directories(<%text>${OPENSSL_INCLUDE_DIR}</%text>)
set(_gRPC_FIND_SSL "if(NOT OPENSSL_FOUND)\n find_package(OpenSSL)\nendif()")
endif()
@@ -522,7 +523,6 @@
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>${CMAKE_CURRENT_SOURCE_DIR}</%text>/third_party/abseil-cpp
% if lib.build in ['test', 'private'] and lib.language == 'c++':
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
@@ -594,7 +594,6 @@
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>${CMAKE_CURRENT_SOURCE_DIR}</%text>/third_party/abseil-cpp
% 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..3eb838857a 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
@@ -1268,6 +1268,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 $@`
diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template
index 3b935e96b0..cb4d556acf 100644
--- a/templates/gRPC-Core.podspec.template
+++ b/templates/gRPC-Core.podspec.template
@@ -61,6 +61,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
@@ -112,6 +116,7 @@
'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'
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 4b360cfb4c..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|
diff --git a/templates/src/core/plugin_registry.template b/templates/src/core/plugin_registry.template
index 8d7617129f..805ae9049f 100644
--- a/templates/src/core/plugin_registry.template
+++ b/templates/src/core/plugin_registry.template
@@ -25,8 +25,8 @@ template: |
#include <grpc/grpc.h>
%for plugin in selected.plugins:
- extern "C" void ${plugin}_init(void);
- extern "C" 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/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/test/core/surface/public_headers_must_be_c89.c.template b/templates/test/core/surface/public_headers_must_be_c89.c.template
index e2d3b1810a..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
@@ -48,10 +48,8 @@
#include <stdio.h>
int main(int argc, char **argv) {
- if(argc == 12345678) {
- % for fn in fns:
- printf("%lx", (unsigned long) ${fn});
- % endfor
- }
+ % for fn in fns:
+ printf("%lx", (unsigned long) ${fn});
+ % endfor
return 0;
}
diff --git a/templates/tools/dockerfile/python_deps.include b/templates/tools/dockerfile/python_deps.include
index bf1f57f267..cd1af22b43 100644
--- a/templates/tools/dockerfile/python_deps.include
+++ b/templates/tools/dockerfile/python_deps.include
@@ -11,4 +11,4 @@ RUN apt-get update && apt-get install -y ${'\\'}
# 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.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/sanity/Dockerfile.template b/templates/tools/dockerfile/test/sanity/Dockerfile.template
index bf34c0ab0f..fef569477e 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 ${"\\"}
diff --git a/test/core/bad_client/bad_client.cc b/test/core/bad_client/bad_client.cc
index b1944425ba..d8bb092e14 100644
--- a/test/core/bad_client/bad_client.cc
+++ b/test/core/bad_client/bad_client.cc
@@ -58,7 +58,7 @@ static void done_write(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
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,
+ grpc_server_setup_transport(&exec_ctx, a->server, transport, nullptr,
grpc_server_get_channel_args(a->server));
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -101,23 +101,24 @@ void grpc_run_bad_client_test(
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(&exec_ctx, nullptr, sfd.server, false);
server_setup_transport(&a, transport);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
+ grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
/* Bind everything into the same pollset */
@@ -128,7 +129,7 @@ void grpc_run_bad_client_test(
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);
@@ -152,14 +153,14 @@ void grpc_run_bad_client_test(
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 = 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);
@@ -175,9 +176,10 @@ void grpc_run_bad_client_test(
grpc_exec_ctx_finish(&exec_ctx);
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,
@@ -196,10 +198,11 @@ void grpc_run_bad_client_test(
GPR_ASSERT(
gpr_event_wait(&a.done_write, grpc_timeout_seconds_to_deadline(1)));
- 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)
+ 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);
diff --git a/test/core/bad_client/tests/badreq.cc b/test/core/bad_client/tests/badreq.cc
index 5273c831e5..c30244e0cd 100644
--- a/test/core/bad_client/tests/badreq.cc
+++ b/test/core/bad_client/tests/badreq.cc
@@ -31,7 +31,7 @@ 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);
}
}
@@ -41,7 +41,7 @@ int main(int argc, char** argv) {
/* invalid content type */
GRPC_RUN_BAD_CLIENT_TEST(
- verifier, NULL,
+ verifier, nullptr,
PFX_STR
"\x00\x00\xc2\x01\x04\x00\x00\x00\x01"
"\x10\x05:path\x08/foo/bar"
@@ -57,7 +57,7 @@ int main(int argc, char** argv) {
/* invalid te */
GRPC_RUN_BAD_CLIENT_TEST(
- verifier, NULL,
+ verifier, nullptr,
PFX_STR
"\x00\x00\xcb\x01\x04\x00\x00\x00\x01"
"\x10\x05:path\x08/foo/bar"
@@ -75,7 +75,7 @@ int main(int argc, char** argv) {
/* two path headers */
GRPC_RUN_BAD_CLIENT_TEST(
- verifier, NULL,
+ verifier, nullptr,
PFX_STR
"\x00\x00\xd9\x01\x04\x00\x00\x00\x01"
"\x10\x05:path\x08/foo/bar"
@@ -93,7 +93,7 @@ int main(int argc, char** argv) {
/* bad accept-encoding algorithm */
GRPC_RUN_BAD_CLIENT_TEST(
- verifier, NULL,
+ verifier, nullptr,
PFX_STR
"\x00\x00\xd2\x01\x04\x00\x00\x00\x01"
"\x10\x05:path\x08/foo/bar"
@@ -110,7 +110,7 @@ int main(int argc, char** argv) {
/* bad grpc-encoding algorithm */
GRPC_RUN_BAD_CLIENT_TEST(
- verifier, NULL,
+ verifier, nullptr,
PFX_STR
"\x00\x00\xf5\x01\x04\x00\x00\x00\x01"
"\x10\x05:path\x08/foo/bar"
diff --git a/test/core/bad_client/tests/connection_prefix.cc b/test/core/bad_client/tests/connection_prefix.cc
index a4fd734e04..47252f9f10 100644
--- a/test/core/bad_client/tests/connection_prefix.cc
+++ b/test/core/bad_client/tests/connection_prefix.cc
@@ -23,7 +23,7 @@ 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);
}
}
@@ -31,30 +31,31 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq,
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",
+ 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);
return 0;
}
diff --git a/test/core/bad_client/tests/head_of_line_blocking.cc b/test/core/bad_client/tests/head_of_line_blocking.cc
index aad335cf5b..bbc5611991 100644
--- a/test/core/bad_client/tests/head_of_line_blocking.cc
+++ b/test/core/bad_client/tests/head_of_line_blocking.cc
@@ -74,7 +74,7 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq,
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 +85,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);
@@ -129,7 +129,7 @@ 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);
return 0;
diff --git a/test/core/bad_client/tests/headers.cc b/test/core/bad_client/tests/headers.cc
index f96c6f0028..50bb72c493 100644
--- a/test/core/bad_client/tests/headers.cc
+++ b/test/core/bad_client/tests/headers.cc
@@ -27,7 +27,7 @@ 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);
}
}
@@ -36,275 +36,276 @@ int main(int argc, char** argv) {
grpc_test_init(argc, argv);
/* 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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"
@@ -312,19 +313,19 @@ int main(int argc, char** argv) {
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,
+ 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,
+ GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr,
PFX_STR
"\x00\x00\x19\x01\x04\x00\x00\x00\x01"
"\x10\x0cgrpc-timeout\x0a"
diff --git a/test/core/bad_client/tests/initial_settings_frame.cc b/test/core/bad_client/tests/initial_settings_frame.cc
index dde9d4b5d3..edc52f503e 100644
--- a/test/core/bad_client/tests/initial_settings_frame.cc
+++ b/test/core/bad_client/tests/initial_settings_frame.cc
@@ -26,7 +26,7 @@ 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);
}
}
@@ -35,73 +35,74 @@ int main(int argc, char** argv) {
grpc_test_init(argc, argv);
/* 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,
+ 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);
diff --git a/test/core/bad_client/tests/large_metadata.cc b/test/core/bad_client/tests/large_metadata.cc
index df7dd8f4b3..1ce0f28967 100644
--- a/test/core/bad_client/tests/large_metadata.cc
+++ b/test/core/bad_client/tests/large_metadata.cc
@@ -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);
diff --git a/test/core/bad_client/tests/server_registered_method.cc b/test/core/bad_client/tests/server_registered_method.cc
index b1b11235de..6613c94b41 100644
--- a/test/core/bad_client/tests/server_registered_method.cc
+++ b/test/core/bad_client/tests/server_registered_method.cc
@@ -47,7 +47,7 @@ static void verifier_succeeds(grpc_server* server, grpc_completion_queue* cq,
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);
@@ -70,7 +70,7 @@ 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);
}
}
@@ -80,45 +80,45 @@ int main(int argc, char** argv) {
/* 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,
+ 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,
+ 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,
+ verifier_succeeds, nullptr,
PFX_STR
"\x00\x00\x07\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x02\x00\x00",
0);
diff --git a/test/core/bad_client/tests/simple_request.cc b/test/core/bad_client/tests/simple_request.cc
index b9cc1e3259..9f4a03e69b 100644
--- a/test/core/bad_client/tests/simple_request.cc
+++ b/test/core/bad_client/tests/simple_request.cc
@@ -115,7 +115,7 @@ 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);
}
}
@@ -124,44 +124,44 @@ int main(int argc, char** argv) {
grpc_test_init(argc, argv);
/* 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,
+ 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,
+ 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);
return 0;
diff --git a/test/core/bad_client/tests/unknown_frame.cc b/test/core/bad_client/tests/unknown_frame.cc
index b8367a2b65..d962a4244d 100644
--- a/test/core/bad_client/tests/unknown_frame.cc
+++ b/test/core/bad_client/tests/unknown_frame.cc
@@ -27,7 +27,7 @@ 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);
}
}
@@ -36,7 +36,7 @@ int main(int argc, char** argv) {
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);
diff --git a/test/core/bad_client/tests/window_overflow.cc b/test/core/bad_client/tests/window_overflow.cc
index cb4b790de2..f4bd81828b 100644
--- a/test/core/bad_client/tests/window_overflow.cc
+++ b/test/core/bad_client/tests/window_overflow.cc
@@ -46,7 +46,7 @@ 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);
}
}
@@ -90,7 +90,7 @@ int main(int argc, char** argv) {
addbuf(message, sizeof(message));
}
}
- grpc_run_bad_client_test(verifier, NULL, g_buffer, g_count,
+ grpc_run_bad_client_test(verifier, nullptr, g_buffer, g_count,
GRPC_BAD_CLIENT_LARGE_REQUEST);
gpr_free(g_buffer);
diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc
index 3cfa2a4a2b..0e74a62f19 100644
--- a/test/core/bad_ssl/bad_ssl_test.cc
+++ b/test/core/bad_ssl/bad_ssl_test.cc
@@ -36,7 +36,7 @@ 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_ssl_credentials_create(nullptr, nullptr, nullptr);
grpc_channel* channel;
grpc_call* c;
@@ -46,7 +46,7 @@ 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);
+ grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
cq_verifier* cqv = cq_verifier_create(cq);
grpc_op ops[6];
@@ -64,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);
diff --git a/test/core/bad_ssl/server_common.cc b/test/core/bad_ssl/server_common.cc
index 0110ed5ad2..08842b8350 100644
--- a/test/core/bad_ssl/server_common.cc
+++ b/test/core/bad_ssl/server_common.cc
@@ -34,7 +34,7 @@ static void sigint_handler(int x) { got_sigint = 1; }
const char* bad_ssl_addr(int argc, char** argv) {
gpr_cmdline* cl;
- const char* addr = NULL;
+ 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);
@@ -48,17 +48,17 @@ void bad_ssl_run(grpc_server* server) {
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* 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,
@@ -69,12 +69,12 @@ void bad_ssl_run(grpc_server* server) {
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;
@@ -83,7 +83,7 @@ void bad_ssl_run(grpc_server* server) {
cq,
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_micros(1000000, GPR_TIMESPAN)),
- NULL);
+ nullptr);
switch (ev.type) {
case GRPC_OP_COMPLETE:
GPR_ASSERT(ev.tag == (void*)1);
@@ -98,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/servers/alpn.cc b/test/core/bad_ssl/servers/alpn.cc
index a207516a72..23954d82fd 100644
--- a/test/core/bad_ssl/servers/alpn.cc
+++ b/test/core/bad_ssl/servers/alpn.cc
@@ -58,9 +58,9 @@ int main(int argc, char** argv) {
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.cc b/test/core/bad_ssl/servers/cert.cc
index 4a8ac93452..a51dd34e4b 100644
--- a/test/core/bad_ssl/servers/cert.cc
+++ b/test/core/bad_ssl/servers/cert.cc
@@ -49,9 +49,9 @@ int main(int argc, char** argv) {
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/channel/channel_args_test.cc b/test/core/channel/channel_args_test.cc
index 4b4bd3e718..e8b3334185 100644
--- a/test/core/channel/channel_args_test.cc
+++ b/test/core/channel/channel_args_test.cc
@@ -43,7 +43,7 @@ static void test_create(void) {
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);
@@ -64,7 +64,7 @@ static void test_set_compression_algorithm(void) {
grpc_channel_args* ch_args;
ch_args =
- grpc_channel_args_set_compression_algorithm(NULL, GRPC_COMPRESS_GZIP);
+ grpc_channel_args_set_compression_algorithm(nullptr, GRPC_COMPRESS_GZIP);
GPR_ASSERT(ch_args->num_args == 1);
GPR_ASSERT(strcmp(ch_args->args[0].key,
GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM) == 0);
@@ -80,7 +80,7 @@ static void test_compression_algorithm_states(void) {
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);
@@ -129,9 +129,9 @@ static void test_compression_algorithm_states(void) {
static void test_set_socket_mutator(void) {
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);
diff --git a/test/core/channel/channel_stack_builder_test.cc b/test/core/channel/channel_stack_builder_test.cc
index 1571f6ec09..a67f0efafe 100644
--- a/test/core/channel/channel_stack_builder_test.cc
+++ b/test/core/channel/channel_stack_builder_test.cc
@@ -71,8 +71,8 @@ void set_arg_once_fn(grpc_channel_stack* channel_stack,
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_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.
diff --git a/test/core/channel/channel_stack_test.cc b/test/core/channel/channel_stack_test.cc
index 1b661ac2f4..988ea9bac9 100644
--- a/test/core/channel/channel_stack_test.cc
+++ b/test/core/channel/channel_stack_test.cc
@@ -74,8 +74,8 @@ static void free_channel(grpc_exec_ctx* exec_ctx, void* arg,
}
static void free_call(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
- grpc_call_stack_destroy(exec_ctx, static_cast<grpc_call_stack*>(arg), NULL,
- NULL);
+ grpc_call_stack_destroy(exec_ctx, static_cast<grpc_call_stack*>(arg), nullptr,
+ nullptr);
gpr_free(arg);
}
@@ -114,7 +114,7 @@ static void test_create_channel_stack(void) {
channel_stack = static_cast<grpc_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);
+ 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;
diff --git a/test/core/channel/minimal_stack_is_minimal_test.cc b/test/core/channel/minimal_stack_is_minimal_test.cc
index c54ff2e01b..e0cffa39a8 100644
--- a/test/core/channel/minimal_stack_is_minimal_test.cc
+++ b/test/core/channel/minimal_stack_is_minimal_test.cc
@@ -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();
@@ -120,7 +121,7 @@ static int check_stack(const char* file, int line, const char* 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) {
+ if (transport_name != nullptr) {
grpc_channel_stack_builder_set_transport(builder, &fake_transport);
}
{
@@ -139,12 +140,12 @@ static int check_stack(const char* file, int line, const char* transport_name,
va_start(args, channel_stack_type);
for (;;) {
char* a = va_arg(args, char*);
- if (a == NULL) break;
+ 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
@@ -153,11 +154,11 @@ static int check_stack(const char* file, int line, const char* transport_name,
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;
+ 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);
@@ -189,7 +190,7 @@ 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,
diff --git a/test/core/client_channel/lb_policies_test.cc b/test/core/client_channel/lb_policies_test.cc
index 3b907487b7..5f8d3b84cc 100644
--- a/test/core/client_channel/lb_policies_test.cc
+++ b/test/core/client_channel/lb_policies_test.cc
@@ -126,19 +126,19 @@ static gpr_timespec n_millis_time(int n) {
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) {
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 {
@@ -153,12 +153,12 @@ 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]);
@@ -187,13 +187,13 @@ static servers_fixture* setup_servers(const char* server_host,
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(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);
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;
@@ -203,10 +203,10 @@ 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]);
}
@@ -286,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;
@@ -297,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 =
@@ -315,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 =
@@ -352,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;
@@ -360,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) {
@@ -394,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);
@@ -443,22 +444,22 @@ 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;
@@ -478,7 +479,7 @@ void run_spec(const test_spec* spec) {
/* Create client. */
servers_hostports_str = gpr_strjoin_sep((const char**)f->servers_hostports,
- f->num_servers, ",", NULL);
+ f->num_servers, ",", nullptr);
gpr_asprintf(&client_hostport, "ipv4:%s", servers_hostports_str);
arg_array[0].type = GRPC_ARG_INTEGER;
@@ -491,7 +492,7 @@ void run_spec(const test_spec* spec) {
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);
@@ -517,7 +518,7 @@ static grpc_channel* create_client(const servers_fixture* f) {
grpc_channel_args args;
servers_hostports_str = gpr_strjoin_sep((const char**)f->servers_hostports,
- f->num_servers, ",", NULL);
+ f->num_servers, ",", nullptr);
gpr_asprintf(&client_hostport, "ipv4:%s", servers_hostports_str);
arg_array[0].type = GRPC_ARG_INTEGER;
@@ -534,7 +535,7 @@ static grpc_channel* create_client(const servers_fixture* f) {
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);
@@ -557,7 +558,7 @@ static void test_ping() {
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 */
@@ -577,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);
}
@@ -602,9 +603,8 @@ static void test_pending_calls(size_t concurrent_calls) {
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);
@@ -621,7 +621,7 @@ 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_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.
@@ -629,10 +629,10 @@ 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.
@@ -640,7 +640,7 @@ static void test_get_channel_info() {
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;
@@ -648,8 +648,8 @@ static void test_get_channel_info() {
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(NULL, &arg, 1);
- channel = grpc_insecure_channel_create("ipv4:127.0.0.1:1234", args, NULL);
+ 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);
@@ -659,7 +659,7 @@ static void test_get_channel_info() {
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.
@@ -884,7 +884,7 @@ 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);
@@ -970,8 +970,8 @@ int main(int argc, char** 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);
+ nullptr) == nullptr);
+ GPR_ASSERT(grpc_lb_policy_create(&exec_ctx, 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
diff --git a/test/core/client_channel/parse_address_test.cc b/test/core/client_channel/parse_address_test.cc
index 5ad6c6d015..94f76da920 100644
--- a/test/core/client_channel/parse_address_test.cc
+++ b/test/core/client_channel/parse_address_test.cc
@@ -62,8 +62,8 @@ static void test_grpc_parse_ipv4(const char* uri_text, const char* host,
GPR_ASSERT(1 == grpc_parse_ipv4(uri, &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);
@@ -81,8 +81,8 @@ static void test_grpc_parse_ipv6(const char* uri_text, const char* host,
GPR_ASSERT(1 == grpc_parse_ipv6(uri, &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);
diff --git a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
index a388b826cf..dcf315eba5 100644
--- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
+++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
@@ -72,11 +72,12 @@ static grpc_ares_request* my_dns_lookup_ares(
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);
+ *lb_addrs = grpc_lb_addresses_create(1, nullptr);
+ grpc_lb_addresses_set_address(*lb_addrs, 0, nullptr, 0, false, nullptr,
+ nullptr);
}
GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
- return NULL;
+ return nullptr;
}
static grpc_resolver* create_resolver(grpc_exec_ctx* exec_ctx,
@@ -107,7 +108,7 @@ static bool wait_loop(int deadline_seconds, gpr_event* ev) {
deadline_seconds--;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_timer_check(&exec_ctx, NULL);
+ grpc_timer_check(&exec_ctx, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
return false;
@@ -161,7 +162,7 @@ int main(int argc, char** argv) {
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_ASSERT(result == nullptr);
gpr_event ev2;
gpr_event_init(&ev2);
@@ -170,7 +171,7 @@ int main(int argc, char** argv) {
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);
+ GPR_ASSERT(result != nullptr);
grpc_channel_args_destroy(&exec_ctx, result);
GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test");
diff --git a/test/core/client_channel/resolvers/dns_resolver_test.cc b/test/core/client_channel/resolvers/dns_resolver_test.cc
index ef3c1b8216..4c040caeb9 100644
--- a/test/core/client_channel/resolvers/dns_resolver_test.cc
+++ b/test/core/client_channel/resolvers/dns_resolver_test.cc
@@ -39,7 +39,7 @@ static void test_succeeds(grpc_resolver_factory* factory, const char* string) {
args.uri = uri;
args.combiner = g_combiner;
resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
- GPR_ASSERT(resolver != NULL);
+ GPR_ASSERT(resolver != nullptr);
GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test_succeeds");
grpc_uri_destroy(uri);
grpc_exec_ctx_finish(&exec_ctx);
@@ -57,7 +57,7 @@ static void test_fails(grpc_resolver_factory* factory, const char* string) {
args.uri = uri;
args.combiner = g_combiner;
resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
- GPR_ASSERT(resolver == NULL);
+ GPR_ASSERT(resolver == nullptr);
grpc_uri_destroy(uri);
grpc_exec_ctx_finish(&exec_ctx);
}
diff --git a/test/core/client_channel/resolvers/fake_resolver_test.cc b/test/core/client_channel/resolvers/fake_resolver_test.cc
index 06e8ebdc88..d5538e9621 100644
--- a/test/core/client_channel/resolvers/fake_resolver_test.cc
+++ b/test/core/client_channel/resolvers/fake_resolver_test.cc
@@ -79,23 +79,23 @@ static void test_fake_resolver() {
grpc_fake_resolver_response_generator_create();
grpc_resolver* resolver =
build_fake_resolver(&exec_ctx, combiner, response_generator);
- GPR_ASSERT(resolver != NULL);
+ 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)};
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_channel_args_copy_and_add(nullptr, &addresses_arg, 1);
grpc_lb_addresses_destroy(&exec_ctx, addresses);
on_resolution_arg on_res_arg;
memset(&on_res_arg, 0, sizeof(on_res_arg));
@@ -112,25 +112,25 @@ static void test_fake_resolver() {
on_resolution);
grpc_exec_ctx_flush(&exec_ctx);
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)};
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_channel_args_copy_and_add(nullptr, &addresses_update_arg, 1);
grpc_lb_addresses_destroy(&exec_ctx, addresses_update);
// Setup expectations for the update.
@@ -148,7 +148,7 @@ static void test_fake_resolver() {
&on_res_arg_update.resolver_result, on_resolution);
grpc_exec_ctx_flush(&exec_ctx);
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.
@@ -158,7 +158,7 @@ static void test_fake_resolver() {
grpc_exec_ctx_flush(&exec_ctx);
GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
grpc_timeout_milliseconds_to_deadline(100)) ==
- NULL);
+ nullptr);
GRPC_COMBINER_UNREF(&exec_ctx, combiner, "test_fake_resolver");
GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test_fake_resolver");
diff --git a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc
index 028a786059..dfa2d12b5e 100644
--- a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc
+++ b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc
@@ -52,7 +52,7 @@ static void test_succeeds(grpc_resolver_factory* factory, const char* string) {
args.uri = uri;
args.combiner = g_combiner;
resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
- GPR_ASSERT(resolver != NULL);
+ GPR_ASSERT(resolver != nullptr);
on_resolution_arg on_res_arg;
memset(&on_res_arg, 0, sizeof(on_res_arg));
@@ -79,7 +79,7 @@ static void test_fails(grpc_resolver_factory* factory, const char* string) {
args.uri = uri;
args.combiner = g_combiner;
resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
- GPR_ASSERT(resolver == NULL);
+ GPR_ASSERT(resolver == nullptr);
grpc_uri_destroy(uri);
grpc_exec_ctx_finish(&exec_ctx);
}
diff --git a/test/core/client_channel/uri_parser_test.cc b/test/core/client_channel/uri_parser_test.cc
index 0bdf57ce4b..30183f9f57 100644
--- a/test/core/client_channel/uri_parser_test.cc
+++ b/test/core/client_channel/uri_parser_test.cc
@@ -42,7 +42,7 @@ static void test_succeeds(const char* uri_text, const char* scheme,
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));
+ GPR_ASSERT(nullptr == grpc_uri_parse(&exec_ctx, uri_text, 0));
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -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,12 +69,12 @@ 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);
@@ -111,8 +111,8 @@ 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);
diff --git a/test/core/compression/algorithm_test.cc b/test/core/compression/algorithm_test.cc
index bc3af410c5..2f1d8bc8eb 100644
--- a/test/core/compression/algorithm_test.cc
+++ b/test/core/compression/algorithm_test.cc
@@ -68,11 +68,11 @@ static void test_algorithm_failure(void) {
gpr_log(GPR_DEBUG, "test_algorithm_failure");
GPR_ASSERT(grpc_compression_algorithm_name(GRPC_COMPRESS_ALGORITHMS_COUNT,
- NULL) == 0);
+ nullptr) == 0);
GPR_ASSERT(
grpc_compression_algorithm_name(static_cast<grpc_compression_algorithm>(
GRPC_COMPRESS_ALGORITHMS_COUNT + 1),
- NULL) == 0);
+ 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);
diff --git a/test/core/compression/stream_compression_test.cc b/test/core/compression/stream_compression_test.cc
index 7cb583b88d..2f30b7fc19 100644
--- a/test/core/compression/stream_compression_test.cc
+++ b/test/core/compression/stream_compression_test.cc
@@ -66,7 +66,7 @@ static void test_stream_compression_simple_compress_decompress() {
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;
@@ -99,7 +99,7 @@ test_stream_compression_simple_compress_decompress_with_output_size_constraint()
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);
@@ -149,7 +149,7 @@ test_stream_compression_simple_compress_decompress_with_large_data() {
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;
@@ -180,7 +180,7 @@ static void test_stream_compression_drop_context() {
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);
@@ -189,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);
@@ -249,7 +249,7 @@ static void test_stream_compression_sync_flush() {
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));
@@ -268,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);
diff --git a/test/core/debug/stats_test.cc b/test/core/debug/stats_test.cc
index c4b0d502e3..5fae61f8f6 100644
--- a/test/core/debug/stats_test.cc
+++ b/test/core/debug/stats_test.cc
@@ -109,11 +109,12 @@ TEST_P(HistogramTest, IncHistogram) {
}
};
std::vector<int> test_values;
- for (int j = -1000;
- j < grpc_stats_histo_bucket_boundaries
- [kHistogram][grpc_stats_histo_buckets[kHistogram] - 1] +
- 1000;
- j++) {
+ // 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(
@@ -122,6 +123,14 @@ TEST_P(HistogramTest, IncHistogram) {
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) {
diff --git a/test/core/end2end/bad_server_response_test.cc b/test/core/end2end/bad_server_response_test.cc
index ea7857d8d7..0fdb637ead 100644
--- a/test/core/end2end/bad_server_response_test.cc
+++ b/test/core/end2end/bad_server_response_test.cc
@@ -135,8 +135,8 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
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);
+ 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;
@@ -161,15 +161,15 @@ static void start_rpc(int target_port, grpc_status_code expected_status,
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);
@@ -179,26 +179,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);
@@ -206,7 +206,7 @@ static void start_rpc(int target_port, grpc_status_code expected_status,
cq_verify(cqv);
GPR_ASSERT(status == expected_status);
- if (expected_detail != NULL) {
+ if (expected_detail != nullptr) {
GPR_ASSERT(-1 != grpc_slice_slice(details, grpc_slice_from_static_string(
expected_detail)));
}
@@ -224,7 +224,7 @@ static void cleanup_rpc(grpc_exec_ctx* exec_ctx) {
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);
@@ -262,7 +262,7 @@ static void poll_server_until_read_done(test_tcp_server* server,
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,
@@ -331,7 +331,7 @@ int main(int argc, char** argv) {
/* unparseable response */
run_test(UNPARSEABLE_RESP, sizeof(UNPARSEABLE_RESP) - 1, GRPC_STATUS_UNKNOWN,
- NULL);
+ nullptr);
/* http1 response */
run_test(HTTP1_RESP, sizeof(HTTP1_RESP) - 1, GRPC_STATUS_UNAVAILABLE,
diff --git a/test/core/end2end/connection_refused_test.cc b/test/core/end2end/connection_refused_test.cc
index cea06ae282..f3f2dda91d 100644
--- a/test/core/end2end/connection_refused_test.cc
+++ b/test/core/end2end/connection_refused_test.cc
@@ -53,11 +53,11 @@ 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;
@@ -80,12 +80,13 @@ static void run_test(bool wait_for_ready, bool use_service_config) {
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);
@@ -132,7 +134,7 @@ static void run_test(bool wait_for_ready, bool use_service_config) {
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- if (args != NULL) grpc_channel_args_destroy(&exec_ctx, args);
+ if (args != nullptr) grpc_channel_args_destroy(&exec_ctx, args);
grpc_exec_ctx_finish(&exec_ctx);
}
diff --git a/test/core/end2end/cq_verifier.cc b/test/core/end2end/cq_verifier.cc
index fd5193f42c..8686f4e7b7 100644
--- a/test/core/end2end/cq_verifier.cc
+++ b/test/core/end2end/cq_verifier.cc
@@ -64,7 +64,7 @@ struct 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;
}
@@ -203,7 +203,7 @@ static void expectation_to_strvec(gpr_strvec* buf, 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"));
}
@@ -215,7 +215,7 @@ static void fail_no_event_received(cq_verifier* v) {
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);
@@ -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);
@@ -250,32 +250,32 @@ static void verify_matches(expectation* e, grpc_event* ev) {
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* 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) {
+ 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);
@@ -290,9 +290,10 @@ void cq_verify_empty_timeout(cq_verifier* v, int timeout_sec) {
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);
gpr_log(GPR_ERROR, "unexpected event (expected nothing): %s", s);
diff --git a/test/core/end2end/cq_verifier.h b/test/core/end2end/cq_verifier.h
index 0b3b3fb349..959f849cb1 100644
--- a/test/core/end2end/cq_verifier.h
+++ b/test/core/end2end/cq_verifier.h
@@ -24,10 +24,6 @@
#include <grpc/grpc.h>
#include "test/core/util/test_config.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* A cq_verifier can verify that expected events arrive in a timely fashion
on a single completion queue */
@@ -63,8 +59,4 @@ int contains_metadata(grpc_metadata_array* array, const char* key,
int contains_metadata_slices(grpc_metadata_array* array, grpc_slice key,
grpc_slice value);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_TEST_CORE_END2END_CQ_VERIFIER_H */
diff --git a/test/core/end2end/cq_verifier_native.cc b/test/core/end2end/cq_verifier_native.cc
index a0a7c832e5..e93956b188 100644
--- a/test/core/end2end/cq_verifier_native.cc
+++ b/test/core/end2end/cq_verifier_native.cc
@@ -19,6 +19,8 @@
/* 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 */
@@ -27,13 +29,12 @@ struct cq_verifier {
grpc_completion_queue* cq;
/* start of expectation list */
expectation* first_expectation;
- uv_timer_t timer;
};
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;
}
@@ -53,7 +54,7 @@ void cq_verifier_set_first_expectation(cq_verifier* v, expectation* e) {
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/data/client_certs.cc b/test/core/end2end/data/client_certs.cc
index 7e0b10da5c..46fc13927c 100644
--- a/test/core/end2end/data/client_certs.cc
+++ b/test/core/end2end/data/client_certs.cc
@@ -16,7 +16,7 @@
*
*/
-extern "C" 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 @@ extern "C" const char test_self_signed_client_cert[] = {
0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
0x0a, 0x00};
-extern "C" 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 @@ extern "C" const char test_self_signed_client_key[] = {
0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x0a, 0x00};
-extern "C" 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 @@ extern "C" 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};
-extern "C" 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.cc b/test/core/end2end/data/server1_cert.cc
index dd09810732..0943244ecc 100644
--- a/test/core/end2end/data/server1_cert.cc
+++ b/test/core/end2end/data/server1_cert.cc
@@ -16,7 +16,7 @@
*
*/
-extern "C" 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.cc b/test/core/end2end/data/server1_key.cc
index 59dcaf6334..8f3ad15c26 100644
--- a/test/core/end2end/data/server1_key.cc
+++ b/test/core/end2end/data/server1_key.cc
@@ -16,7 +16,7 @@
*
*/
-extern "C" 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.cc b/test/core/end2end/data/test_root_cert.cc
index 36fca2e45f..b4771b2cb8 100644
--- a/test/core/end2end/data/test_root_cert.cc
+++ b/test/core/end2end/data/test_root_cert.cc
@@ -16,7 +16,7 @@
*
*/
-extern "C" 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.cc b/test/core/end2end/dualstack_socket_test.cc
index 1e02116e4c..ad2b24fdb0 100644
--- a/test/core/end2end/dualstack_socket_test.cc
+++ b/test/core/end2end/dualstack_socket_test.cc
@@ -48,7 +48,7 @@ static gpr_timespec ms_from_now(int ms) {
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, ms_from_now(5000), nullptr);
} while (ev.type != GRPC_QUEUE_SHUTDOWN);
}
@@ -93,9 +93,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) {
@@ -126,7 +126,7 @@ void test_connect(const char* server_host, const char* client_host, int port,
gpr_free(uri_part_str);
}
client_hostport = gpr_strjoin_sep((const char**)hosts_with_port,
- uri_parts.count, ",", NULL);
+ uri_parts.count, ",", nullptr);
for (i = 0; i < uri_parts.count; i++) {
gpr_free(hosts_with_port[i]);
}
@@ -136,7 +136,7 @@ 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");
@@ -155,9 +155,9 @@ void test_connect(const char* server_host, const char* client_host, int port,
/* 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));
@@ -165,25 +165,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) {
@@ -211,7 +211,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);
@@ -246,11 +247,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);
@@ -270,10 +271,10 @@ 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_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;
}
diff --git a/test/core/end2end/end2end_test_utils.cc b/test/core/end2end/end2end_test_utils.cc
index 35f086a7f6..51d2730f0e 100644
--- a/test/core/end2end/end2end_test_utils.cc
+++ b/test/core/end2end/end2end_test_utils.cc
@@ -27,19 +27,19 @@ const char* get_host_override_string(const char* str,
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,
grpc_end2end_test_config config) {
const char* r = get_host_override_string(str, config);
- if (r != NULL) {
+ 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,
diff --git a/test/core/end2end/end2end_tests.h b/test/core/end2end/end2end_tests.h
index 33943a7271..b42d90b55c 100644
--- a/test/core/end2end/end2end_tests.h
+++ b/test/core/end2end/end2end_tests.h
@@ -21,10 +21,6 @@
#include <grpc/grpc.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
typedef struct grpc_end2end_test_fixture grpc_end2end_test_fixture;
typedef struct grpc_end2end_test_config grpc_end2end_test_config;
@@ -78,8 +74,4 @@ const grpc_slice* get_host_override_slice(const char* str,
void validate_host_override_string(const char* pattern, grpc_slice str,
grpc_end2end_test_config config);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* GRPC_TEST_CORE_END2END_END2END_TESTS_H */
diff --git a/test/core/end2end/fixtures/h2_census.cc b/test/core/end2end/fixtures/h2_census.cc
index 4213140f4a..fed8ead5c8 100644
--- a/test/core/end2end/fixtures/h2_census.cc
+++ b/test/core/end2end/fixtures/h2_census.cc
@@ -51,8 +51,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
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;
}
@@ -71,7 +71,8 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f,
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;
@@ -89,13 +90,13 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
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_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);
}
diff --git a/test/core/end2end/fixtures/h2_compress.cc b/test/core/end2end/fixtures/h2_compress.cc
index 64e028b950..ea8990fd0a 100644
--- a/test/core/end2end/fixtures/h2_compress.cc
+++ b/test/core/end2end/fixtures/h2_compress.cc
@@ -55,8 +55,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_compression(
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;
}
@@ -65,22 +65,22 @@ 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 != NULL) {
+ if (ffd->client_args_compression != nullptr) {
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);
}
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);
+ 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 =
static_cast<fullstack_compression_fixture_data*>(f->fixture_data);
- if (ffd->server_args_compression != NULL) {
+ if (ffd->server_args_compression != nullptr) {
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);
@@ -90,8 +90,8 @@ void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture* f,
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);
}
diff --git a/test/core/end2end/fixtures/h2_fakesec.cc b/test/core/end2end/fixtures/h2_fakesec.cc
index fbf2f49729..87d4668d50 100644
--- a/test/core/end2end/fixtures/h2_fakesec.cc
+++ b/test/core/end2end/fixtures/h2_fakesec.cc
@@ -46,8 +46,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
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;
}
@@ -56,8 +56,8 @@ 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);
+ GPR_ASSERT(state == nullptr);
+ cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr);
}
static void chttp2_init_client_secure_fullstack(
@@ -66,8 +66,8 @@ static void chttp2_init_client_secure_fullstack(
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);
}
@@ -79,8 +79,8 @@ static void chttp2_init_server_secure_fullstack(
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);
@@ -103,7 +103,7 @@ static void chttp2_init_client_fake_secure_fullstack(
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) {
@@ -118,7 +118,8 @@ static void chttp2_init_server_fake_secure_fullstack(
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);
}
diff --git a/test/core/end2end/fixtures/h2_fd.cc b/test/core/end2end/fixtures/h2_fd.cc
index 7005b969a0..97f4b71bf0 100644
--- a/test/core/end2end/fixtures/h2_fd.cc
+++ b/test/core/end2end/fixtures/h2_fd.cc
@@ -58,8 +58,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
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);
@@ -84,12 +84,12 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
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_server_add_insecure_channel_from_fd(f->server, nullptr, sfd->fd_pair[1]);
grpc_exec_ctx_finish(&exec_ctx);
}
diff --git a/test/core/end2end/fixtures/h2_full+pipe.cc b/test/core/end2end/fixtures/h2_full+pipe.cc
index 0dd650b8e0..b080591e85 100644
--- a/test/core/end2end/fixtures/h2_full+pipe.cc
+++ b/test/core/end2end/fixtures/h2_full+pipe.cc
@@ -56,8 +56,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
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;
}
@@ -66,7 +66,8 @@ 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, NULL);
+ f->client =
+ grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr);
GPR_ASSERT(f->client);
}
@@ -77,8 +78,8 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
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);
}
diff --git a/test/core/end2end/fixtures/h2_full+trace.cc b/test/core/end2end/fixtures/h2_full+trace.cc
index 21372c6dee..a49de96009 100644
--- a/test/core/end2end/fixtures/h2_full+trace.cc
+++ b/test/core/end2end/fixtures/h2_full+trace.cc
@@ -56,8 +56,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
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;
}
@@ -66,7 +66,8 @@ 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, NULL);
+ f->client =
+ grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr);
GPR_ASSERT(f->client);
}
@@ -77,8 +78,8 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
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);
}
diff --git a/test/core/end2end/fixtures/h2_full+workarounds.cc b/test/core/end2end/fixtures/h2_full+workarounds.cc
index ebffe2125c..71a497d796 100644
--- a/test/core/end2end/fixtures/h2_full+workarounds.cc
+++ b/test/core/end2end/fixtures/h2_full+workarounds.cc
@@ -54,8 +54,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
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;
}
@@ -64,7 +64,8 @@ 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, NULL);
+ f->client =
+ grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr);
GPR_ASSERT(f->client);
}
@@ -85,8 +86,8 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
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);
diff --git a/test/core/end2end/fixtures/h2_full.cc b/test/core/end2end/fixtures/h2_full.cc
index 895af67930..6d15c28662 100644
--- a/test/core/end2end/fixtures/h2_full.cc
+++ b/test/core/end2end/fixtures/h2_full.cc
@@ -50,8 +50,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
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;
}
@@ -60,7 +60,8 @@ 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, NULL);
+ f->client =
+ grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr);
GPR_ASSERT(f->client);
}
@@ -71,8 +72,8 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
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);
}
diff --git a/test/core/end2end/fixtures/h2_http_proxy.cc b/test/core/end2end/fixtures/h2_http_proxy.cc
index a67ce82064..099367d91b 100644
--- a/test/core/end2end/fixtures/h2_http_proxy.cc
+++ b/test/core/end2end/fixtures/h2_http_proxy.cc
@@ -57,8 +57,8 @@ 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;
}
@@ -72,7 +72,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f,
/* If testing for proxy auth, add credentials to proxy uri */
const grpc_arg* proxy_auth_arg =
grpc_channel_args_find(client_args, GRPC_ARG_HTTP_PROXY_AUTH_CREDS);
- 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 {
@@ -81,7 +81,8 @@ 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);
}
@@ -92,8 +93,8 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
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);
}
diff --git a/test/core/end2end/fixtures/h2_load_reporting.cc b/test/core/end2end/fixtures/h2_load_reporting.cc
index b402fc5620..7486b6af78 100644
--- a/test/core/end2end/fixtures/h2_load_reporting.cc
+++ b/test/core/end2end/fixtures/h2_load_reporting.cc
@@ -52,8 +52,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_load_reporting(
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;
}
@@ -62,7 +62,8 @@ 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, NULL);
+ f->client =
+ grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr);
GPR_ASSERT(f->client);
}
@@ -75,13 +76,13 @@ void chttp2_init_server_load_reporting(grpc_end2end_test_fixture* f,
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_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);
}
diff --git a/test/core/end2end/fixtures/h2_oauth2.cc b/test/core/end2end/fixtures/h2_oauth2.cc
index 88e590a15f..1642cb0db9 100644
--- a/test/core/end2end/fixtures/h2_oauth2.cc
+++ b/test/core/end2end/fixtures/h2_oauth2.cc
@@ -49,7 +49,7 @@ static const grpc_metadata* find_metadata(const grpc_metadata* md,
return &md[i];
}
}
- return NULL;
+ return nullptr;
}
typedef struct {
@@ -64,15 +64,15 @@ static void process_oauth2_success(void* state, grpc_auth_context* ctx,
find_metadata(md, md_count, "authorization", oauth2_md);
test_processor_state* s;
- GPR_ASSERT(state != NULL);
+ 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,
@@ -82,11 +82,11 @@ static void process_oauth2_failure(void* state, grpc_auth_context* ctx,
const grpc_metadata* oauth2 =
find_metadata(md, md_count, "authorization", oauth2_md);
test_processor_state* s;
- GPR_ASSERT(state != NULL);
+ 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(
@@ -101,8 +101,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
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;
}
@@ -113,8 +113,8 @@ static void chttp2_init_client_secure_fullstack(
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);
}
@@ -126,8 +126,8 @@ static void chttp2_init_server_secure_fullstack(
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);
@@ -145,11 +145,12 @@ 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_ssl_credentials_create(test_root_cert, nullptr, nullptr);
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_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),
@@ -165,7 +166,7 @@ static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack(
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) {
@@ -200,8 +201,8 @@ static void chttp2_init_server_simple_ssl_secure_fullstack(
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);
diff --git a/test/core/end2end/fixtures/h2_proxy.cc b/test/core/end2end/fixtures/h2_proxy.cc
index 03ffa02e17..295654cb6a 100644
--- a/test/core/end2end/fixtures/h2_proxy.cc
+++ b/test/core/end2end/fixtures/h2_proxy.cc
@@ -42,14 +42,14 @@ typedef struct 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);
+ 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);
+ return grpc_insecure_channel_create(target, client_args, nullptr);
}
static const grpc_end2end_proxy_def proxy_def = {create_proxy_server,
@@ -65,8 +65,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
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;
}
@@ -76,7 +76,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f,
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);
}
@@ -87,8 +87,8 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
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);
diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.cc b/test/core/end2end/fixtures/h2_sockpair+trace.cc
index c5dfe40391..9319c401dc 100644
--- a/test/core/end2end/fixtures/h2_sockpair+trace.cc
+++ b/test/core/end2end/fixtures/h2_sockpair+trace.cc
@@ -53,7 +53,7 @@ static void server_setup_transport(void* ts, grpc_transport* transport) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(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,
+ grpc_server_setup_transport(&exec_ctx, f->server, transport, nullptr,
grpc_server_get_channel_args(f->server));
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -80,10 +80,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
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;
}
@@ -97,10 +97,10 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f,
cs.client_args = client_args;
cs.f = f;
transport =
- grpc_create_chttp2_transport(&exec_ctx, client_args, sfd->client, 1);
+ grpc_create_chttp2_transport(&exec_ctx, client_args, sfd->client, true);
client_setup_transport(&exec_ctx, &cs, transport);
GPR_ASSERT(f->client);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
+ grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -110,13 +110,13 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
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);
+ grpc_create_chttp2_transport(&exec_ctx, server_args, sfd->server, false);
server_setup_transport(f, transport);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
+ grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
diff --git a/test/core/end2end/fixtures/h2_sockpair.cc b/test/core/end2end/fixtures/h2_sockpair.cc
index f07722e52d..03566aada2 100644
--- a/test/core/end2end/fixtures/h2_sockpair.cc
+++ b/test/core/end2end/fixtures/h2_sockpair.cc
@@ -47,7 +47,7 @@ static void server_setup_transport(void* ts, grpc_transport* transport) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(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,
+ grpc_server_setup_transport(&exec_ctx, f->server, transport, nullptr,
grpc_server_get_channel_args(f->server));
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -74,10 +74,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
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;
}
@@ -91,10 +91,10 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f,
cs.client_args = client_args;
cs.f = f;
transport =
- grpc_create_chttp2_transport(&exec_ctx, client_args, sfd->client, 1);
+ grpc_create_chttp2_transport(&exec_ctx, client_args, sfd->client, true);
client_setup_transport(&exec_ctx, &cs, transport);
GPR_ASSERT(f->client);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
+ grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -104,13 +104,13 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
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);
+ grpc_create_chttp2_transport(&exec_ctx, server_args, sfd->server, false);
server_setup_transport(f, transport);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
+ grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.cc b/test/core/end2end/fixtures/h2_sockpair_1byte.cc
index 7d00c69a18..9adba00204 100644
--- a/test/core/end2end/fixtures/h2_sockpair_1byte.cc
+++ b/test/core/end2end/fixtures/h2_sockpair_1byte.cc
@@ -47,7 +47,7 @@ static void server_setup_transport(void* ts, grpc_transport* transport) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(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,
+ grpc_server_setup_transport(&exec_ctx, f->server, transport, nullptr,
grpc_server_get_channel_args(f->server));
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -74,8 +74,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
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);
grpc_arg a[3];
a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE);
@@ -102,10 +102,10 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f,
cs.client_args = client_args;
cs.f = f;
transport =
- grpc_create_chttp2_transport(&exec_ctx, client_args, sfd->client, 1);
+ grpc_create_chttp2_transport(&exec_ctx, client_args, sfd->client, true);
client_setup_transport(&exec_ctx, &cs, transport);
GPR_ASSERT(f->client);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
+ grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -115,13 +115,13 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
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);
+ grpc_create_chttp2_transport(&exec_ctx, server_args, sfd->server, false);
server_setup_transport(f, transport);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
+ grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
diff --git a/test/core/end2end/fixtures/h2_ssl.cc b/test/core/end2end/fixtures/h2_ssl.cc
index 70daefd333..3d7e2e327e 100644
--- a/test/core/end2end/fixtures/h2_ssl.cc
+++ b/test/core/end2end/fixtures/h2_ssl.cc
@@ -50,8 +50,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
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;
}
@@ -60,8 +60,8 @@ 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);
+ GPR_ASSERT(state == nullptr);
+ cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr);
}
static void chttp2_init_client_secure_fullstack(
@@ -70,8 +70,8 @@ static void chttp2_init_client_secure_fullstack(
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);
}
@@ -83,8 +83,8 @@ static void chttp2_init_server_secure_fullstack(
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);
@@ -101,7 +101,7 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) {
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_ssl_credentials_create(nullptr, nullptr, nullptr);
grpc_arg ssl_name_override = {
GRPC_ARG_STRING,
const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
@@ -118,7 +118,7 @@ static void chttp2_init_client_simple_ssl_secure_fullstack(
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) {
@@ -132,10 +132,11 @@ static void chttp2_init_server_simple_ssl_secure_fullstack(
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);
@@ -166,8 +167,8 @@ int main(int argc, char** argv) {
/* 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.cc b/test/core/end2end/fixtures/h2_ssl_proxy.cc
index b3488a29e5..f8d5a699e4 100644
--- a/test/core/end2end/fixtures/h2_ssl_proxy.cc
+++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc
@@ -41,11 +41,11 @@ typedef struct 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);
+ 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;
@@ -55,7 +55,7 @@ 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_ssl_credentials_create(nullptr, nullptr, nullptr);
grpc_arg ssl_name_override = {
GRPC_ARG_STRING,
const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
@@ -63,7 +63,7 @@ static grpc_channel* create_proxy_client(const char* target,
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;
@@ -87,8 +87,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
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;
}
@@ -97,8 +97,8 @@ 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);
+ GPR_ASSERT(state == nullptr);
+ cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr);
}
static void chttp2_init_client_secure_fullstack(
@@ -108,8 +108,8 @@ static void chttp2_init_client_secure_fullstack(
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);
}
@@ -121,8 +121,8 @@ static void chttp2_init_server_secure_fullstack(
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);
@@ -139,7 +139,7 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) {
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_ssl_credentials_create(nullptr, nullptr, nullptr);
grpc_arg ssl_name_override = {
GRPC_ARG_STRING,
const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG),
@@ -156,7 +156,7 @@ static void chttp2_init_client_simple_ssl_secure_fullstack(
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) {
@@ -170,10 +170,11 @@ static void chttp2_init_server_simple_ssl_secure_fullstack(
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);
@@ -205,8 +206,8 @@ int main(int argc, char** argv) {
/* 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.cc b/test/core/end2end/fixtures/h2_uds.cc
index ba433df57b..28f0a50e15 100644
--- a/test/core/end2end/fixtures/h2_uds.cc
+++ b/test/core/end2end/fixtures/h2_uds.cc
@@ -56,8 +56,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack(
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;
}
@@ -66,7 +66,8 @@ 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, NULL);
+ f->client =
+ grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr);
}
void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
@@ -76,8 +77,8 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
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);
}
diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc
index d29401fdc3..3904887026 100644
--- a/test/core/end2end/fixtures/http_proxy_fixture.cc
+++ b/test/core/end2end/fixtures/http_proxy_fixture.cc
@@ -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;
@@ -108,7 +122,7 @@ static void proxy_connection_unref(grpc_exec_ctx* exec_ctx,
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) {
+ if (conn->server_endpoint != nullptr) {
grpc_endpoint_destroy(exec_ctx, conn->server_endpoint);
}
grpc_pollset_set_destroy(exec_ctx, conn->pollset_set);
@@ -127,30 +141,63 @@ 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) {
+ 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(exec_ctx, conn->client_endpoint,
+ GRPC_ERROR_REF(error));
+ conn->client_shutdown = true;
+ }
+ if (shutdown_server && !conn->server_shutdown &&
+ (conn->server_endpoint != nullptr)) {
grpc_endpoint_shutdown(exec_ctx, conn->server_endpoint,
GRPC_ERROR_REF(error));
+ conn->server_shutdown = true;
}
+ // Unref the connection.
proxy_connection_unref(exec_ctx, 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) {
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(exec_ctx, conn, CLIENT_WRITE_FAILED,
+ "HTTP proxy client write", GRPC_ERROR_REF(error));
return;
}
// Clear write buffer (the data we just wrote).
@@ -160,6 +207,7 @@ 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);
+ conn->client_is_writing = true;
grpc_endpoint_write(exec_ctx, conn->client_endpoint,
&conn->client_write_buffer,
&conn->on_client_write_done);
@@ -173,9 +221,10 @@ static void on_client_write_done(grpc_exec_ctx* exec_ctx, void* arg,
static void on_server_write_done(grpc_exec_ctx* exec_ctx, 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(exec_ctx, conn, SERVER_WRITE_FAILED,
+ "HTTP proxy server write", GRPC_ERROR_REF(error));
return;
}
// Clear write buffer (the data we just wrote).
@@ -185,6 +234,7 @@ 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);
+ conn->server_is_writing = true;
grpc_endpoint_write(exec_ctx, conn->server_endpoint,
&conn->server_write_buffer,
&conn->on_server_write_done);
@@ -200,8 +250,8 @@ static void on_client_read_done(grpc_exec_ctx* exec_ctx, 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(exec_ctx, 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,13 +260,14 @@ 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");
+ conn->server_is_writing = true;
grpc_endpoint_write(exec_ctx, conn->server_endpoint,
&conn->server_write_buffer,
&conn->on_server_write_done);
@@ -232,8 +283,8 @@ static void on_server_read_done(grpc_exec_ctx* exec_ctx, 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(exec_ctx, 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,13 +293,14 @@ 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");
+ conn->client_is_writing = true;
grpc_endpoint_write(exec_ctx, conn->client_endpoint,
&conn->client_write_buffer,
&conn->on_client_write_done);
@@ -262,9 +314,10 @@ static void on_server_read_done(grpc_exec_ctx* exec_ctx, void* arg,
static void on_write_response_done(grpc_exec_ctx* exec_ctx, 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(exec_ctx, conn, SETUP_FAILED,
+ "HTTP proxy write response", GRPC_ERROR_REF(error));
return;
}
// Clear write buffer.
@@ -292,8 +345,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(exec_ctx, 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,6 +355,7 @@ 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);
+ conn->client_is_writing = true;
grpc_endpoint_write(exec_ctx, conn->client_endpoint,
&conn->client_write_buffer,
&conn->on_write_response_done);
@@ -315,8 +369,8 @@ static void on_server_connect_done(grpc_exec_ctx* exec_ctx, void* arg,
static bool proxy_auth_header_matches(grpc_exec_ctx* exec_ctx,
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;
}
@@ -341,18 +395,19 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* 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(exec_ctx, 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(exec_ctx, conn, SETUP_FAILED,
+ "HTTP proxy request parse",
+ GRPC_ERROR_REF(error));
GRPC_ERROR_UNREF(error);
return;
}
@@ -372,15 +427,15 @@ 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(exec_ctx, 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) {
@@ -393,19 +448,19 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
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(exec_ctx, 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(exec_ctx, conn, SETUP_FAILED,
+ "HTTP proxy DNS lookup", GRPC_ERROR_REF(error));
GRPC_ERROR_UNREF(error);
return;
}
@@ -415,7 +470,7 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
const grpc_millis deadline =
grpc_exec_ctx_now(exec_ctx) + 10 * GPR_MS_PER_SEC;
grpc_tcp_client_connect(exec_ctx, &conn->on_server_connect_done,
- &conn->server_endpoint, conn->pollset_set, NULL,
+ &conn->server_endpoint, conn->pollset_set, nullptr,
&resolved_addresses->addrs[0], deadline);
grpc_resolved_addresses_destroy(resolved_addresses);
}
@@ -450,9 +505,11 @@ 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);
@@ -469,7 +526,7 @@ static void thread_main(void* arg) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
do {
gpr_ref(&proxy->users);
- grpc_pollset_worker* worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
gpr_mu_lock(proxy->mu);
GRPC_LOG_IF_ERROR(
"grpc_pollset_work",
@@ -496,7 +553,7 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
// 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);
+ &exec_ctx, nullptr, proxy->channel_args, &proxy->server);
GPR_ASSERT(error == GRPC_ERROR_NONE);
// Bind to port.
grpc_resolved_address resolved_addr;
@@ -517,7 +574,8 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
// 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;
}
diff --git a/test/core/end2end/fixtures/inproc.cc b/test/core/end2end/fixtures/inproc.cc
index 5107ed2018..b748fbf09a 100644
--- a/test/core/end2end/fixtures/inproc.cc
+++ b/test/core/end2end/fixtures/inproc.cc
@@ -47,15 +47,15 @@ static grpc_end2end_test_fixture inproc_create_fixture(
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);
+ f->client = grpc_inproc_channel_create(f->server, client_args, nullptr);
GPR_ASSERT(f->client);
}
@@ -64,8 +64,8 @@ void inproc_init_server(grpc_end2end_test_fixture* f,
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);
}
diff --git a/test/core/end2end/fixtures/proxy.cc b/test/core/end2end/fixtures/proxy.cc
index 01c9e13538..b1698c804c 100644
--- a/test/core/end2end/fixtures/proxy.cc
+++ b/test/core/end2end/fixtures/proxy.cc
@@ -89,16 +89,17 @@ 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);
@@ -159,12 +160,13 @@ 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);
}
@@ -187,11 +189,11 @@ 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);
}
@@ -209,26 +211,26 @@ static void on_c2p_recv_msg(void* arg, int success) {
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 != NULL) {
+ if (pc->c2p_msg != nullptr) {
grpc_byte_buffer_destroy(pc->c2p_msg);
}
}
@@ -247,11 +249,11 @@ 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);
}
@@ -266,11 +268,11 @@ static void on_p2s_recv_msg(void* arg, int success) {
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);
@@ -292,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 =
@@ -301,7 +303,7 @@ 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);
}
@@ -329,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;
@@ -348,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;
@@ -357,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;
@@ -365,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;
@@ -376,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;
@@ -384,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);
@@ -394,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;
+ proxy->new_call = nullptr;
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
proxy->server, &proxy->new_call,
&proxy->new_call_details,
@@ -412,7 +416,7 @@ static void thread_main(void* 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");
diff --git a/test/core/end2end/fuzzers/api_fuzzer.cc b/test/core/end2end/fuzzers/api_fuzzer.cc
index 69a5670d22..75117218e4 100644
--- a/test/core/end2end/fuzzers/api_fuzzer.cc
+++ b/test/core/end2end/fuzzers/api_fuzzer.cc
@@ -56,7 +56,7 @@ static grpc_server* g_server;
static grpc_channel* g_channel;
static grpc_resource_quota* g_resource_quota;
-extern "C" gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type);
+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);
@@ -84,7 +84,7 @@ static uint8_t next_byte(input_stream* inp) {
static void end(input_stream* inp) { inp->cur = inp->end; }
static char* read_string(input_stream* inp, bool* special) {
- char* str = NULL;
+ char* str = nullptr;
size_t cap = 0;
size_t sz = 0;
char c;
@@ -96,7 +96,7 @@ static char* read_string(input_stream* inp, bool* special) {
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) {
@@ -109,10 +109,10 @@ 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 = static_cast<char*>(gpr_malloc(*length));
for (size_t i = 0; i < *length; i++) {
@@ -201,12 +201,12 @@ static grpc_channel_args* read_args(input_stream* inp) {
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:
@@ -248,11 +248,12 @@ 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];
}
@@ -272,8 +273,9 @@ static grpc_channel_credentials* read_ssl_channel_creds(input_stream* inp) {
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);
+ root_certs,
+ private_key != nullptr && certs != nullptr ? &key_cert_pair : nullptr,
+ nullptr);
cred_artifact_ctx_finish(&ctx);
return creds;
}
@@ -282,45 +284,46 @@ static grpc_call_credentials* read_call_creds(input_stream* inp) {
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) {
+ if (c1 != nullptr && c2 != nullptr) {
grpc_call_credentials* out =
- grpc_composite_call_credentials_create(c1, c2, NULL);
+ 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);
+ const char* access_token = read_cred_artifact(&ctx, inp, nullptr, 0);
grpc_call_credentials* out =
- access_token == NULL
- ? NULL
- : grpc_access_token_credentials_create(access_token, NULL);
+ 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;
}
@@ -336,9 +339,9 @@ static grpc_channel_credentials* read_channel_creds(input_stream* inp) {
case 1: {
grpc_channel_credentials* c1 = read_channel_creds(inp);
grpc_call_credentials* c2 = read_call_creds(inp);
- if (c1 != NULL && c2 != NULL) {
+ if (c1 != nullptr && c2 != nullptr) {
grpc_channel_credentials* out =
- grpc_composite_channel_credentials_create(c1, c2, NULL);
+ grpc_composite_channel_credentials_create(c1, c2, nullptr);
grpc_channel_credentials_release(c1);
grpc_call_credentials_release(c2);
return out;
@@ -346,17 +349,17 @@ 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;
}
}
@@ -378,7 +381,7 @@ static void finish_resolve(grpc_exec_ctx* exec_ctx, void* arg,
addr_req* r = static_cast<addr_req*>(arg);
if (error == GRPC_ERROR_NONE && 0 == strcmp(r->addr, "server")) {
- if (r->addrs != NULL) {
+ if (r->addrs != nullptr) {
grpc_resolved_addresses* addrs =
static_cast<grpc_resolved_addresses*>(gpr_malloc(sizeof(*addrs)));
addrs->naddrs = 1;
@@ -386,9 +389,10 @@ static void finish_resolve(grpc_exec_ctx* exec_ctx, void* arg,
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, false, 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);
@@ -411,7 +415,7 @@ void my_resolve_address(grpc_exec_ctx* exec_ctx, const char* addr,
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_MS_PER_SEC + grpc_exec_ctx_now(exec_ctx),
GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx));
@@ -425,19 +429,19 @@ grpc_ares_request* my_dns_lookup_ares(
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_MS_PER_SEC + grpc_exec_ctx_now(exec_ctx),
GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx));
- return NULL;
+ return nullptr;
}
////////////////////////////////////////////////////////////////////////////////
// client connection
// defined in tcp_client_posix.c
-extern "C" void (*grpc_tcp_client_connect_impl)(
+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, grpc_millis deadline);
@@ -455,18 +459,19 @@ typedef struct {
static void do_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
future_connect* fc = static_cast<future_connect*>(arg);
if (error != GRPC_ERROR_NONE) {
- *fc->ep = NULL;
+ *fc->ep = nullptr;
GRPC_CLOSURE_SCHED(exec_ctx, fc->closure, GRPC_ERROR_REF(error));
- } else if (g_server != NULL) {
+ } else if (g_server != nullptr) {
grpc_endpoint* client;
grpc_endpoint* server;
- grpc_passthru_endpoint_create(&client, &server, g_resource_quota, NULL);
+ 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_create_chttp2_transport(exec_ctx, nullptr, server, false);
+ grpc_server_setup_transport(exec_ctx, g_server, transport, nullptr,
+ nullptr);
+ grpc_chttp2_transport_start_reading(exec_ctx, transport, nullptr, nullptr);
GRPC_CLOSURE_SCHED(exec_ctx, fc->closure, GRPC_ERROR_NONE);
} else {
@@ -478,7 +483,7 @@ static void do_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
static void sched_connect(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
grpc_endpoint** ep, gpr_timespec deadline) {
if (gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) < 0) {
- *ep = NULL;
+ *ep = nullptr;
GRPC_CLOSURE_SCHED(
exec_ctx, closure,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connect deadline exceeded"));
@@ -551,7 +556,7 @@ static void validate_connectivity_watch(void* p, bool success) {
}
static void free_non_null(void* p) {
- GPR_ASSERT(p != NULL);
+ GPR_ASSERT(p != nullptr);
gpr_free(p);
}
@@ -594,7 +599,7 @@ static call_state* g_active_call;
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;
@@ -608,7 +613,7 @@ static call_state* new_call(call_state* sibling, call_state_type type) {
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) {
@@ -682,7 +687,7 @@ static void read_metadata(input_stream* inp, size_t* count,
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);
}
@@ -691,7 +696,7 @@ static void finished_request_call(void* csp, bool success) {
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);
@@ -708,16 +713,16 @@ static void finished_batch(void* p, bool success) {
--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))) {
@@ -738,7 +743,7 @@ static validator* make_finished_batch_validator(call_state* cs,
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);
+ 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;
@@ -753,28 +758,28 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
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,
@@ -784,12 +789,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
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;
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;
@@ -809,7 +814,7 @@ extern "C" 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 = static_cast<validator*>(ev.tag);
@@ -833,13 +838,13 @@ extern "C" 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);
+ 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);
+ 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);
@@ -854,9 +859,9 @@ extern "C" 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);
}
@@ -864,16 +869,16 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
}
// bring up a server
case 4: {
- if (g_server == NULL) {
+ if (g_server == nullptr) {
grpc_channel_args* args = read_args(&inp);
- g_server = grpc_server_create(args, NULL);
- GPR_ASSERT(g_server != NULL);
+ 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_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);
@@ -884,7 +889,7 @@ extern "C" 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,
@@ -898,7 +903,7 @@ extern "C" 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);
@@ -907,10 +912,10 @@ extern "C" 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);
}
@@ -918,7 +923,7 @@ extern "C" 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);
@@ -932,7 +937,7 @@ extern "C" 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) {
@@ -954,10 +959,10 @@ extern "C" 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;
}
@@ -977,7 +982,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
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);
}
@@ -993,7 +998,7 @@ extern "C" 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;
}
@@ -1026,7 +1031,7 @@ extern "C" 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;
@@ -1078,14 +1083,14 @@ extern "C" 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);
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);
@@ -1095,7 +1100,7 @@ extern "C" 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);
@@ -1103,8 +1108,8 @@ extern "C" 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);
}
@@ -1112,7 +1117,7 @@ extern "C" 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);
@@ -1121,7 +1126,7 @@ extern "C" 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);
@@ -1130,10 +1135,11 @@ extern "C" 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);
}
@@ -1141,21 +1147,21 @@ extern "C" 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;
}
@@ -1175,7 +1181,7 @@ extern "C" 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);
@@ -1189,14 +1195,15 @@ extern "C" 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);
+ 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);
+ 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);
@@ -1213,15 +1220,15 @@ extern "C" 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/client_fuzzer.cc b/test/core/end2end/fuzzers/client_fuzzer.cc
index d90ec40a27..5871f0f43e 100644
--- a/test/core/end2end/fuzzers/client_fuzzer.cc
+++ b/test/core/end2end/fuzzers/client_fuzzer.cc
@@ -52,21 +52,21 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
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_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
grpc_transport* transport =
- grpc_create_chttp2_transport(&exec_ctx, NULL, mock_endpoint, 1);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
+ grpc_create_chttp2_transport(&exec_ctx, nullptr, mock_endpoint, true);
+ grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr, nullptr);
grpc_channel* channel = grpc_channel_create(
- &exec_ctx, "test-target", NULL, GRPC_CLIENT_DIRECT_CHANNEL, transport);
+ &exec_ctx, "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, NULL, 0, cq, grpc_slice_from_static_string("/foo"), &host,
- gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ 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 = NULL;
+ grpc_byte_buffer* response_payload_recv = nullptr;
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array_init(&trailing_metadata_recv);
grpc_status_code status;
@@ -78,31 +78,31 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
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 = &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++;
grpc_call_error error =
- grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(1), NULL);
+ grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(1), nullptr);
int requested_calls = 1;
GPR_ASSERT(GRPC_CALL_OK == error);
@@ -113,7 +113,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t 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);
+ ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
switch (ev.type) {
case GRPC_QUEUE_TIMEOUT:
goto done;
@@ -127,15 +128,17 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
done:
if (requested_calls) {
- grpc_call_cancel(call, NULL);
+ 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), NULL);
+ 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), NULL);
+ ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
}
grpc_call_unref(call);
@@ -144,7 +147,7 @@ done:
grpc_metadata_array_destroy(&trailing_metadata_recv);
grpc_slice_unref(details);
grpc_channel_destroy(channel);
- if (response_payload_recv != NULL) {
+ if (response_payload_recv != nullptr) {
grpc_byte_buffer_destroy(response_payload_recv);
}
grpc_shutdown();
diff --git a/test/core/end2end/fuzzers/server_fuzzer.cc b/test/core/end2end/fuzzers/server_fuzzer.cc
index 87bccc70cd..67caf4e720 100644
--- a/test/core/end2end/fuzzers/server_fuzzer.cc
+++ b/test/core/end2end/fuzzers/server_fuzzer.cc
@@ -53,19 +53,19 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
&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);
+ 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(&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_create_chttp2_transport(&exec_ctx, nullptr, mock_endpoint, false);
+ grpc_server_setup_transport(&exec_ctx, server, transport, nullptr, nullptr);
+ grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr, nullptr);
- grpc_call* call1 = NULL;
+ grpc_call* call1 = nullptr;
grpc_call_details call_details1;
grpc_metadata_array request_metadata1;
grpc_call_details_init(&call_details1);
@@ -80,7 +80,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t 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);
+ ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
switch (ev.type) {
case GRPC_QUEUE_TIMEOUT:
goto done;
@@ -97,18 +98,20 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
}
done:
- if (call1 != NULL) grpc_call_unref(call1);
+ 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), NULL);
+ 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), NULL);
+ ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
+ nullptr);
GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
}
grpc_server_destroy(server);
diff --git a/test/core/end2end/goaway_server_test.cc b/test/core/end2end/goaway_server_test.cc
index 12a966d05a..2d0db967c3 100644
--- a/test/core/end2end/goaway_server_test.cc
+++ b/test/core/end2end/goaway_server_test.cc
@@ -106,19 +106,19 @@ static grpc_ares_request* my_dns_lookup_ares(
gpr_mu_unlock(&g_mu);
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Failure");
} else {
- *lb_addrs = grpc_lb_addresses_create(1, NULL);
+ *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;
+ return nullptr;
}
int main(int argc, char** argv) {
@@ -157,7 +157,7 @@ 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 */
@@ -176,24 +176,25 @@ int main(int argc, char** argv) {
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_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->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;
@@ -202,17 +203,17 @@ 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);
@@ -244,7 +245,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 */
@@ -256,20 +257,20 @@ int main(int argc, char** argv) {
/* 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_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->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;
@@ -278,18 +279,18 @@ 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);
@@ -313,14 +314,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/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc
index 8994b63e5f..9a98c07158 100644
--- a/test/core/end2end/h2_ssl_cert_test.cc
+++ b/test/core/end2end/h2_ssl_cert_test.cc
@@ -56,8 +56,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
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;
}
@@ -66,8 +66,8 @@ 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);
+ GPR_ASSERT(state == nullptr);
+ cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr);
}
static void chttp2_init_client_secure_fullstack(
@@ -76,8 +76,8 @@ static void chttp2_init_client_secure_fullstack(
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);
}
@@ -89,8 +89,8 @@ static void chttp2_init_server_secure_fullstack(
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);
@@ -106,7 +106,7 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) {
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) {
@@ -267,7 +267,7 @@ static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
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);
}
@@ -276,16 +276,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -308,9 +308,9 @@ static void simple_request_body(grpc_end2end_test_fixture f,
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));
@@ -318,9 +318,9 @@ 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 = GRPC_INITIAL_METADATA_WAIT_FOR_READY;
- 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), expected_result == SUCCESS);
@@ -367,8 +367,8 @@ int main(int argc, char** argv) {
/* 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);
diff --git a/test/core/end2end/invalid_call_argument_test.cc b/test/core/end2end/invalid_call_argument_test.cc
index c310a0e9ba..cb6b4c08ef 100644
--- a/test/core/end2end/invalid_call_argument_test.cc
+++ b/test/core/end2end/invalid_call_argument_test.cc
@@ -60,7 +60,7 @@ static void prepare_test(int 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 = GRPC_INITIAL_METADATA_WAIT_FOR_READY;
- 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));
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(g_state.server, &g_state.server_call,
&g_state.call_details,
@@ -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,7 +147,7 @@ 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();
}
@@ -162,7 +165,8 @@ 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();
}
@@ -176,11 +180,11 @@ 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_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,11 +192,12 @@ 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();
}
@@ -206,11 +211,12 @@ static void test_too_many_metadata() {
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();
}
@@ -224,16 +230,17 @@ static void test_send_null_message() {
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();
}
@@ -250,21 +257,22 @@ static void test_send_messages_at_the_same_time() {
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 = 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();
}
@@ -282,11 +290,12 @@ 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();
}
@@ -300,11 +309,11 @@ 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_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,11 +321,12 @@ 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();
}
@@ -324,17 +334,18 @@ 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_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();
}
@@ -342,22 +353,23 @@ 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_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();
}
@@ -369,13 +381,14 @@ static void test_recv_close_on_server_from_client() {
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();
}
@@ -392,25 +405,26 @@ 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();
}
@@ -423,11 +437,12 @@ static void test_send_close_from_client_on_server() {
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();
}
@@ -444,11 +459,12 @@ 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();
}
@@ -465,11 +481,12 @@ 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();
}
@@ -487,11 +504,12 @@ 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();
}
@@ -508,18 +526,19 @@ 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();
}
@@ -531,13 +550,14 @@ static void test_recv_close_on_server_with_invalid_flags() {
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();
}
@@ -549,18 +569,19 @@ static void test_recv_close_on_server_twice() {
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();
}
@@ -578,11 +599,12 @@ static void test_invalid_initial_metadata_reserved_key() {
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();
}
diff --git a/test/core/end2end/multiple_server_queues_test.cc b/test/core/end2end/multiple_server_queues_test.cc
index 8036ca54b2..dfa3b48b52 100644
--- a/test/core/end2end/multiple_server_queues_test.cc
+++ b/test/core/end2end/multiple_server_queues_test.cc
@@ -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.cc b/test/core/end2end/no_server_test.cc
index a69b7bc8d6..6113885171 100644
--- a/test/core/end2end/no_server_test.cc
+++ b/test/core/end2end/no_server_test.cc
@@ -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.cc b/test/core/end2end/tests/authority_not_supported.cc
index 62fb02ab56..9c8545058c 100644
--- a/test/core/end2end/tests/authority_not_supported.cc
+++ b/test/core/end2end/tests/authority_not_supported.cc
@@ -53,7 +53,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -62,16 +62,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -94,28 +94,28 @@ static void test_with_authority_header(grpc_end2end_test_config config) {
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);
+ 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_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.cc b/test/core/end2end/tests/bad_hostname.cc
index c54cb8ed34..97ef62b5e3 100644
--- a/test/core/end2end/tests/bad_hostname.cc
+++ b/test/core/end2end/tests/bad_hostname.cc
@@ -55,7 +55,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -64,16 +64,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -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.cc b/test/core/end2end/tests/bad_ping.cc
index 648061587c..30a1b8de77 100644
--- a/test/core/end2end/tests/bad_ping.cc
+++ b/test/core/end2end/tests/bad_ping.cc
@@ -37,20 +37,20 @@ 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) {
if (!f->server) return;
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
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) {
@@ -64,7 +64,7 @@ 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);
+ 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;
@@ -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 =
@@ -160,7 +160,7 @@ static void test_bad_ping(grpc_end2end_test_config config) {
// needed here.
int i;
for (i = 1; i <= MAX_PING_STRIKES + 1; i++) {
- grpc_channel_ping(f.client, f.cq, tag(200 + i), NULL);
+ 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);
@@ -173,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;
@@ -181,14 +181,14 @@ 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);
diff --git a/test/core/end2end/tests/binary_metadata.cc b/test/core/end2end/tests/binary_metadata.cc
index 52f0c70862..381671e331 100644
--- a/test/core/end2end/tests/binary_metadata.cc
+++ b/test/core/end2end/tests/binary_metadata.cc
@@ -53,7 +53,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -62,16 +62,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -102,33 +102,34 @@ static void test_request_response_with_metadata_and_payload(
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);
+ {{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_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.cc b/test/core/end2end/tests/call_creds.cc
index fc550b7733..e1c868232c 100644
--- a/test/core/end2end/tests/call_creds.cc
+++ b/test/core/end2end/tests/call_creds.cc
@@ -45,19 +45,19 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
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,
const_cast<char*>(FAIL_AUTH_CHECK_SERVER_ARG_NAME),
- {NULL}};
+ {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;
}
@@ -73,7 +73,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -82,16 +82,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -111,12 +111,12 @@ static void print_auth_context(int is_client, const grpc_auth_context* ctx) {
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);
}
}
@@ -141,42 +141,42 @@ static void request_response_with_payload_and_call_creds(
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);
@@ -191,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 =
@@ -229,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);
@@ -264,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;
@@ -277,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);
@@ -383,7 +383,7 @@ 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 =
@@ -394,14 +394,14 @@ static void test_request_with_server_rejecting_client_creds(
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);
@@ -417,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.cc b/test/core/end2end/tests/cancel_after_accept.cc
index e2ad5bd721..83439d71d2 100644
--- a/test/core/end2end/tests/cancel_after_accept.cc
+++ b/test/core/end2end/tests/cancel_after_accept.cc
@@ -63,7 +63,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -72,16 +72,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -109,8 +109,8 @@ 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 =
@@ -121,7 +121,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
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;
@@ -140,17 +140,17 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
}
grpc_end2end_test_fixture f = begin_test(config, "cancel_after_accept", mode,
- use_service_config, args, NULL);
+ 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);
@@ -165,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,
@@ -201,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);
@@ -244,7 +244,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
grpc_call_unref(c);
grpc_call_unref(s);
- if (args != NULL) {
+ if (args != nullptr) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_channel_args_destroy(&exec_ctx, args);
grpc_exec_ctx_finish(&exec_ctx);
diff --git a/test/core/end2end/tests/cancel_after_client_done.cc b/test/core/end2end/tests/cancel_after_client_done.cc
index 90db7f51b2..9b832d435d 100644
--- a/test/core/end2end/tests/cancel_after_client_done.cc
+++ b/test/core/end2end/tests/cancel_after_client_done.cc
@@ -56,7 +56,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -65,16 +65,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -94,8 +94,9 @@ static void test_cancel_after_accept_and_writes_closed(
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);
+ 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;
@@ -104,8 +105,8 @@ 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 =
@@ -118,10 +119,10 @@ static void test_cancel_after_accept_and_writes_closed(
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.cc b/test/core/end2end/tests/cancel_after_invoke.cc
index 7f0c4e7af9..d3891b160e 100644
--- a/test/core/end2end/tests/cancel_after_invoke.cc
+++ b/test/core/end2end/tests/cancel_after_invoke.cc
@@ -57,7 +57,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -65,17 +65,17 @@ 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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -95,7 +95,7 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config,
grpc_op* op;
grpc_call* c;
grpc_end2end_test_fixture f = begin_test(config, "test_cancel_after_invoke",
- mode, test_ops, NULL, NULL);
+ 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;
@@ -104,7 +104,7 @@ 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 =
@@ -112,10 +112,10 @@ static void test_cancel_after_invoke(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,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.cc b/test/core/end2end/tests/cancel_after_round_trip.cc
index 35b5214fac..ddcec67de5 100644
--- a/test/core/end2end/tests/cancel_after_round_trip.cc
+++ b/test/core/end2end/tests/cancel_after_round_trip.cc
@@ -63,7 +63,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -72,16 +72,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -109,8 +109,8 @@ 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 =
@@ -123,7 +123,7 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config,
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;
@@ -140,18 +140,19 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config,
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);
+ 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,7 +277,7 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config,
grpc_call_unref(c);
grpc_call_unref(s);
- if (args != NULL) {
+ if (args != nullptr) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_channel_args_destroy(&exec_ctx, args);
grpc_exec_ctx_finish(&exec_ctx);
diff --git a/test/core/end2end/tests/cancel_before_invoke.cc b/test/core/end2end/tests/cancel_before_invoke.cc
index 9504aae5e6..1112375176 100644
--- a/test/core/end2end/tests/cancel_before_invoke.cc
+++ b/test/core/end2end/tests/cancel_before_invoke.cc
@@ -55,7 +55,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -64,16 +64,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -93,7 +93,7 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config,
grpc_op* op;
grpc_call* c;
grpc_end2end_test_fixture f =
- begin_test(config, "cancel_before_invoke", test_ops, NULL, NULL);
+ 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;
@@ -102,7 +102,7 @@ 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 =
@@ -110,13 +110,13 @@ static void test_cancel_before_invoke(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);
- 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.cc b/test/core/end2end/tests/cancel_in_a_vacuum.cc
index 090ee2fbb2..a6c534eb08 100644
--- a/test/core/end2end/tests/cancel_in_a_vacuum.cc
+++ b/test/core/end2end/tests/cancel_in_a_vacuum.cc
@@ -56,7 +56,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -65,16 +65,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -92,18 +92,18 @@ static void test_cancel_in_a_vacuum(grpc_end2end_test_config config,
cancellation_mode mode) {
grpc_call* c;
grpc_end2end_test_fixture f =
- begin_test(config, "test_cancel_in_a_vacuum", mode, NULL, NULL);
+ 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_with_status.cc b/test/core/end2end/tests/cancel_with_status.cc
index bc3c4c3ebd..c867751d53 100644
--- a/test/core/end2end/tests/cancel_with_status.cc
+++ b/test/core/end2end/tests/cancel_with_status.cc
@@ -58,7 +58,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -66,17 +66,17 @@ 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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -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");
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.cc b/test/core/end2end/tests/compressed_payload.cc
index b5fc1898b5..a8ea0ff2e0 100644
--- a/test/core/end2end/tests/compressed_payload.cc
+++ b/test/core/end2end/tests/compressed_payload.cc
@@ -61,7 +61,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -70,16 +70,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -110,7 +110,7 @@ static void request_for_disabled_algorithm(
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;
@@ -125,9 +125,9 @@ 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;
server_args = grpc_channel_args_compression_algorithm_set_state(
@@ -140,10 +140,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,37 +159,37 @@ 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);
@@ -200,14 +200,14 @@ static void request_for_disabled_algorithm(
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);
@@ -216,9 +216,9 @@ 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);
@@ -229,9 +229,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 */
@@ -280,7 +280,7 @@ static void request_with_payload_template(
grpc_call* c;
grpc_call* s;
grpc_slice request_payload_slice;
- grpc_byte_buffer* request_payload = NULL;
+ grpc_byte_buffer* request_payload = nullptr;
grpc_channel_args* client_args;
grpc_channel_args* server_args;
grpc_end2end_test_fixture f;
@@ -289,7 +289,7 @@ static void request_with_payload_template(
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_byte_buffer* response_payload;
grpc_byte_buffer* response_payload_recv;
grpc_call_details call_details;
@@ -312,19 +312,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 +339,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 +349,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 =
@@ -399,14 +399,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 +419,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 +432,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 +451,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 +462,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 +496,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 +509,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);
@@ -551,7 +554,7 @@ static void test_invoke_request_with_exceptionally_uncompressed_payload(
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_COMPRESS_NONE, GRPC_COMPRESS_GZIP, nullptr, false,
/* ignored */ GRPC_COMPRESS_LEVEL_NONE, false);
}
@@ -560,8 +563,8 @@ 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(
@@ -569,8 +572,8 @@ static void test_invoke_request_with_compressed_payload(
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_GZIP, nullptr, false,
+ /* ignored */ GRPC_COMPRESS_LEVEL_NONE, false);
}
static void test_invoke_request_with_send_message_before_initial_metadata(
@@ -578,8 +581,8 @@ static void test_invoke_request_with_send_message_before_initial_metadata(
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_GZIP, nullptr, false,
+ /* ignored */ GRPC_COMPRESS_LEVEL_NONE, true);
}
static void test_invoke_request_with_server_level(
@@ -587,7 +590,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(
@@ -630,9 +633,10 @@ static void test_invoke_request_with_compressed_payload_md_override(
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);
+ request_for_disabled_algorithm(config,
+ "test_invoke_request_with_disabled_algorithm",
+ 0, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP,
+ GRPC_STATUS_UNIMPLEMENTED, nullptr);
}
void compressed_payload(grpc_end2end_test_config config) {
diff --git a/test/core/end2end/tests/connectivity.cc b/test/core/end2end/tests/connectivity.cc
index 4f302d11dc..da65080bc0 100644
--- a/test/core/end2end/tests/connectivity.cc
+++ b/test/core/end2end/tests/connectivity.cc
@@ -39,14 +39,14 @@ static void child_thread(void* arg) {
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);
child_events ce;
@@ -68,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));
@@ -115,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.cc b/test/core/end2end/tests/default_host.cc
index 166f22aec9..85f92b0ab0 100644
--- a/test/core/end2end/tests/default_host.cc
+++ b/test/core/end2end/tests/default_host.cc
@@ -55,7 +55,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -64,16 +64,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -103,13 +103,13 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
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.cc b/test/core/end2end/tests/disappearing_server.cc
index a0b34dd805..29fb19463f 100644
--- a/test/core/end2end/tests/disappearing_server.cc
+++ b/test/core/end2end/tests/disappearing_server.cc
@@ -41,20 +41,20 @@ static gpr_timespec five_seconds_from_now(void) {
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) {
if (!f->server) return;
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
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) {
@@ -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);
+ 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.cc b/test/core/end2end/tests/empty_batch.cc
index 59d0025239..b249c141de 100644
--- a/test/core/end2end/tests/empty_batch.cc
+++ b/test/core/end2end/tests/empty_batch.cc
@@ -55,7 +55,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -64,16 +64,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -91,17 +91,17 @@ static void empty_batch_body(grpc_end2end_test_config config,
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.cc b/test/core/end2end/tests/filter_call_init_fails.cc
index ecf0cc3aca..6eed68a2f9 100644
--- a/test/core/end2end/tests/filter_call_init_fails.cc
+++ b/test/core/end2end/tests/filter_call_init_fails.cc
@@ -63,7 +63,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -72,16 +72,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -104,14 +104,14 @@ static void test_server_channel_filter(grpc_end2end_test_config config) {
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);
+ 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_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 =
@@ -200,24 +200,24 @@ static void test_client_channel_filter(grpc_end2end_test_config config) {
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);
+ 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_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);
@@ -290,24 +290,24 @@ static void test_client_subchannel_filter(grpc_end2end_test_config config) {
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);
+ 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_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);
@@ -449,7 +449,7 @@ static bool maybe_add_server_channel_filter(grpc_exec_ctx* exec_ctx,
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 {
@@ -469,7 +469,7 @@ static bool maybe_add_client_channel_filter(grpc_exec_ctx* exec_ctx,
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 {
@@ -488,7 +488,7 @@ static bool maybe_add_client_subchannel_filter(
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 +498,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.cc b/test/core/end2end/tests/filter_causes_close.cc
index b6cceabdd5..793f590686 100644
--- a/test/core/end2end/tests/filter_causes_close.cc
+++ b/test/core/end2end/tests/filter_causes_close.cc
@@ -58,7 +58,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -67,16 +67,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -98,14 +98,14 @@ static void test_request(grpc_end2end_test_config config) {
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);
+ begin_test(config, "filter_causes_close", 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_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 =
@@ -262,7 +262,7 @@ static bool maybe_add_filter(grpc_exec_ctx* exec_ctx,
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;
}
@@ -270,7 +270,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.cc b/test/core/end2end/tests/filter_latency.cc
index e8ec188ec3..c4d96ebfe2 100644
--- a/test/core/end2end/tests/filter_latency.cc
+++ b/test/core/end2end/tests/filter_latency.cc
@@ -65,7 +65,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -74,16 +74,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -105,14 +105,14 @@ static void test_request(grpc_end2end_test_config config) {
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);
+ begin_test(config, "filter_latency", 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_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);
@@ -321,8 +321,8 @@ static bool maybe_add_filter(grpc_exec_ctx* exec_ctx,
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 {
diff --git a/test/core/end2end/tests/graceful_server_shutdown.cc b/test/core/end2end/tests/graceful_server_shutdown.cc
index 22bdac4032..bf11b49fa4 100644
--- a/test/core/end2end/tests/graceful_server_shutdown.cc
+++ b/test/core/end2end/tests/graceful_server_shutdown.cc
@@ -53,20 +53,20 @@ static gpr_timespec five_seconds_from_now(void) {
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) {
if (!f->server) return;
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
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) {
@@ -84,8 +84,9 @@ 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);
+ 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;
@@ -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.cc b/test/core/end2end/tests/high_initial_seqno.cc
index 72f1d0fd3d..d390a954e5 100644
--- a/test/core/end2end/tests/high_initial_seqno.cc
+++ b/test/core/end2end/tests/high_initial_seqno.cc
@@ -57,7 +57,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -66,16 +66,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -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);
@@ -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.cc b/test/core/end2end/tests/hpack_size.cc
index b2c683ec8e..7ac5fefa22 100644
--- a/test/core/end2end/tests/hpack_size.cc
+++ b/test/core/end2end/tests/hpack_size.cc
@@ -197,7 +197,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -206,16 +206,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -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);
@@ -372,8 +372,8 @@ static void test_size(grpc_end2end_test_config config, int encode_size,
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.cc b/test/core/end2end/tests/idempotent_request.cc
index 4f61caa6df..e39975382a 100644
--- a/test/core/end2end/tests/idempotent_request.cc
+++ b/test/core/end2end/tests/idempotent_request.cc
@@ -55,7 +55,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -64,16 +64,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -105,14 +105,14 @@ 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);
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.cc b/test/core/end2end/tests/invoke_large_request.cc
index ade61ac91d..8a67e3c2b1 100644
--- a/test/core/end2end/tests/invoke_large_request.cc
+++ b/test/core/end2end/tests/invoke_large_request.cc
@@ -50,7 +50,7 @@ static gpr_timespec n_seconds_from_now(int n) {
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);
}
@@ -59,16 +59,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -121,8 +121,8 @@ static void test_invoke_large_request(grpc_end2end_test_config config,
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.cc b/test/core/end2end/tests/keepalive_timeout.cc
index d071254a98..822565510f 100644
--- a/test/core/end2end/tests/keepalive_timeout.cc
+++ b/test/core/end2end/tests/keepalive_timeout.cc
@@ -57,7 +57,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -66,16 +66,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -112,14 +112,14 @@ static void test_keepalive_timeout(grpc_end2end_test_config config) {
keepalive_arg_elems};
grpc_end2end_test_fixture f =
- begin_test(config, "keepalive_timeout", &keepalive_args, NULL);
+ begin_test(config, "keepalive_timeout", &keepalive_args, 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_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,7 +185,7 @@ 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);
diff --git a/test/core/end2end/tests/large_metadata.cc b/test/core/end2end/tests/large_metadata.cc
index 4afd9f31ba..8ddf433ac0 100644
--- a/test/core/end2end/tests/large_metadata.cc
+++ b/test/core/end2end/tests/large_metadata.cc
@@ -53,7 +53,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -62,16 +62,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -107,7 +107,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
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;
@@ -116,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");
@@ -138,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 =
@@ -178,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);
@@ -198,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;
@@ -206,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.cc b/test/core/end2end/tests/load_reporting_hook.cc
index 5c2c3b497c..faabec34cb 100644
--- a/test/core/end2end/tests/load_reporting_hook.cc
+++ b/test/core/end2end/tests/load_reporting_hook.cc
@@ -80,7 +80,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -89,16 +89,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -130,8 +130,8 @@ static void request_response_with_payload(
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);
@@ -273,10 +273,10 @@ 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_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";
diff --git a/test/core/end2end/tests/max_concurrent_streams.cc b/test/core/end2end/tests/max_concurrent_streams.cc
index b8b49d65fb..c0539739e1 100644
--- a/test/core/end2end/tests/max_concurrent_streams.cc
+++ b/test/core/end2end/tests/max_concurrent_streams.cc
@@ -53,7 +53,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -62,16 +62,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -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);
@@ -228,7 +228,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
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);
@@ -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);
@@ -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.cc b/test/core/end2end/tests/max_connection_age.cc
index b5d4dcf963..ddccfc3b51 100644
--- a/test/core/end2end/tests/max_connection_age.cc
+++ b/test/core/end2end/tests/max_connection_age.cc
@@ -51,20 +51,20 @@ 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) {
if (!f->server) return;
grpc_server_destroy(f->server);
- f->server = NULL;
+ f->server = nullptr;
}
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) {
@@ -78,7 +78,7 @@ 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);
+ 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;
@@ -92,7 +92,7 @@ static void test_max_age_forcibly_close(grpc_end2end_test_config config) {
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, NULL);
+ config.init_client(&f, nullptr);
config.init_server(&f, &server_args);
grpc_call* c;
@@ -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);
@@ -221,7 +221,7 @@ 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);
+ 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;
@@ -235,7 +235,7 @@ static void test_max_age_gracefully_close(grpc_end2end_test_config config) {
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, NULL);
+ config.init_client(&f, nullptr);
config.init_server(&f, &server_args);
grpc_call* c;
@@ -253,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);
@@ -268,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 =
@@ -310,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;
@@ -318,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.cc b/test/core/end2end/tests/max_connection_idle.cc
index d850e4267b..293ff7d1f2 100644
--- a/test/core/end2end/tests/max_connection_idle.cc
+++ b/test/core/end2end/tests/max_connection_idle.cc
@@ -38,7 +38,7 @@ 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);
}
@@ -61,14 +61,14 @@ static void simple_request_body(grpc_end2end_test_config config,
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,7 +167,7 @@ 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);
diff --git a/test/core/end2end/tests/max_message_length.cc b/test/core/end2end/tests/max_message_length.cc
index 3d677f1d8f..f1ac27fa7c 100644
--- a/test/core/end2end/tests/max_message_length.cc
+++ b/test/core/end2end/tests/max_message_length.cc
@@ -45,7 +45,7 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
// 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;
@@ -62,7 +62,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -70,17 +70,17 @@ 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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -106,8 +106,8 @@ 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;
+ grpc_call* c = nullptr;
+ grpc_call* s = nullptr;
cq_verifier* cqv;
grpc_op ops[6];
grpc_op* op;
@@ -115,7 +115,7 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
grpc_slice_from_copied_string("hello world");
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,8 +125,8 @@ 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);
@@ -153,7 +153,7 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
" \"maxRequestMessageBytes\": 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;
@@ -162,7 +162,7 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
: 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 {
@@ -174,18 +174,20 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
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);
+ if (client_args != nullptr)
+ grpc_channel_args_destroy(&exec_ctx, client_args);
+ if (server_args != nullptr)
+ grpc_channel_args_destroy(&exec_ctx, server_args);
grpc_exec_ctx_finish(&exec_ctx);
}
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);
@@ -198,30 +200,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) {
@@ -242,14 +244,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);
@@ -278,7 +280,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);
@@ -299,8 +301,8 @@ 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;
+ grpc_call* c = nullptr;
+ grpc_call* s = nullptr;
cq_verifier* cqv;
grpc_op ops[6];
grpc_op* op;
@@ -308,7 +310,7 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
grpc_slice_from_copied_string("hello world");
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;
@@ -318,8 +320,8 @@ 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);
@@ -344,7 +346,7 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
" \"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;
@@ -353,7 +355,7 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
: 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 {
@@ -365,17 +367,19 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
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);
+ if (client_args != nullptr)
+ grpc_channel_args_destroy(&exec_ctx, client_args);
+ if (server_args != nullptr)
+ grpc_channel_args_destroy(&exec_ctx, server_args);
grpc_exec_ctx_finish(&exec_ctx);
}
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);
@@ -388,30 +392,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 =
@@ -426,17 +430,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;
@@ -444,9 +448,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);
@@ -473,7 +477,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.cc b/test/core/end2end/tests/negative_deadline.cc
index 0d56038684..b793964b48 100644
--- a/test/core/end2end/tests/negative_deadline.cc
+++ b/test/core/end2end/tests/negative_deadline.cc
@@ -55,7 +55,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -64,16 +64,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -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.cc b/test/core/end2end/tests/network_status_change.cc
index 088563cb2c..7d0318fda6 100644
--- a/test/core/end2end/tests/network_status_change.cc
+++ b/test/core/end2end/tests/network_status_change.cc
@@ -56,7 +56,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -65,16 +65,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -96,14 +96,14 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) {
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);
+ 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_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.cc b/test/core/end2end/tests/no_logging.cc
index 1a7b57cd84..bf8651221a 100644
--- a/test/core/end2end/tests/no_logging.cc
+++ b/test/core/end2end/tests/no_logging.cc
@@ -36,10 +36,10 @@ enum { TIMEOUT = 200000 };
static void* tag(intptr_t t) { return (void*)t; }
-extern "C" 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;
+ char* message = nullptr;
gpr_asprintf(&message, "Unwanted log: %s", args->message);
args->message = message;
gpr_default_log(args);
@@ -83,7 +83,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -92,16 +92,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -133,14 +133,14 @@ 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);
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.cc b/test/core/end2end/tests/no_op.cc
index 98cf5eb9dc..18c2367ac4 100644
--- a/test/core/end2end/tests/no_op.cc
+++ b/test/core/end2end/tests/no_op.cc
@@ -53,7 +53,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -62,16 +62,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* 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.cc b/test/core/end2end/tests/payload.cc
index 0ff9461a47..2e9513b9cb 100644
--- a/test/core/end2end/tests/payload.cc
+++ b/test/core/end2end/tests/payload.cc
@@ -53,7 +53,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -62,16 +62,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -121,8 +121,8 @@ static void request_response_with_payload(grpc_end2end_test_config config,
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.cc b/test/core/end2end/tests/ping.cc
index 88f62c0a2b..725a425fbf 100644
--- a/test/core/end2end/tests/ping.cc
+++ b/test/core/end2end/tests/ping.cc
@@ -32,7 +32,7 @@ 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);
+ 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;
@@ -62,7 +62,7 @@ static void test_ping(grpc_end2end_test_config config,
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.cc b/test/core/end2end/tests/ping_pong_streaming.cc
index 3c2e76b9f9..ec7981fdcb 100644
--- a/test/core/end2end/tests/ping_pong_streaming.cc
+++ b/test/core/end2end/tests/ping_pong_streaming.cc
@@ -53,7 +53,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -62,16 +62,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -88,7 +88,7 @@ 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);
+ begin_test(config, "test_pingpong_streaming", nullptr, nullptr);
grpc_call* c;
grpc_call* s;
cq_verifier* cqv = cq_verifier_create(f.cq);
@@ -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.cc b/test/core/end2end/tests/proxy_auth.cc
index d5dce7c6de..e4b91ab879 100644
--- a/test/core/end2end/tests/proxy_auth.cc
+++ b/test/core/end2end/tests/proxy_auth.cc
@@ -60,7 +60,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -69,16 +69,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -110,14 +110,14 @@ 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);
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);
@@ -223,7 +223,7 @@ static void test_invoke_proxy_auth(grpc_end2end_test_config config) {
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.cc b/test/core/end2end/tests/registered_call.cc
index b43ca04766..440d817cf1 100644
--- a/test/core/end2end/tests/registered_call.cc
+++ b/test/core/end2end/tests/registered_call.cc
@@ -55,7 +55,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -64,16 +64,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -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);
+ 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);
+ 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.cc b/test/core/end2end/tests/request_with_flags.cc
index 77c931844c..984d8b10f1 100644
--- a/test/core/end2end/tests/request_with_flags.cc
+++ b/test/core/end2end/tests/request_with_flags.cc
@@ -54,7 +54,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -63,16 +63,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -94,14 +94,14 @@ static void test_invoke_request_with_flags(
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);
+ 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_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.cc b/test/core/end2end/tests/request_with_payload.cc
index 946144239c..b3b9ee5726 100644
--- a/test/core/end2end/tests/request_with_payload.cc
+++ b/test/core/end2end/tests/request_with_payload.cc
@@ -53,7 +53,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -62,16 +62,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -93,14 +93,14 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
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);
+ 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_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.cc b/test/core/end2end/tests/resource_quota_server.cc
index dd00c9843f..0ee014f97d 100644
--- a/test/core/end2end/tests/resource_quota_server.cc
+++ b/test/core/end2end/tests/resource_quota_server.cc
@@ -53,7 +53,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -62,16 +62,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -124,7 +124,7 @@ void resource_quota_server(grpc_end2end_test_config config) {
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
@@ -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.cc b/test/core/end2end/tests/server_finishes_request.cc
index 50544a6759..46b874b569 100644
--- a/test/core/end2end/tests/server_finishes_request.cc
+++ b/test/core/end2end/tests/server_finishes_request.cc
@@ -55,7 +55,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -64,16 +64,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -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.cc b/test/core/end2end/tests/shutdown_finishes_calls.cc
index 26a53e5161..fce23f3b6a 100644
--- a/test/core/end2end/tests/shutdown_finishes_calls.cc
+++ b/test/core/end2end/tests/shutdown_finishes_calls.cc
@@ -53,14 +53,14 @@ static gpr_timespec five_seconds_from_now(void) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -77,8 +77,9 @@ 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);
+ 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;
@@ -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 */
diff --git a/test/core/end2end/tests/shutdown_finishes_tags.cc b/test/core/end2end/tests/shutdown_finishes_tags.cc
index 0275a1e4ef..de64eba612 100644
--- a/test/core/end2end/tests/shutdown_finishes_tags.cc
+++ b/test/core/end2end/tests/shutdown_finishes_tags.cc
@@ -53,14 +53,14 @@ static gpr_timespec five_seconds_from_now(void) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -76,7 +76,7 @@ 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);
+ 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;
@@ -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.cc b/test/core/end2end/tests/simple_cacheable_request.cc
index e2ee7bf35a..d8034dcf6d 100644
--- a/test/core/end2end/tests/simple_cacheable_request.cc
+++ b/test/core/end2end/tests/simple_cacheable_request.cc
@@ -55,7 +55,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -64,16 +64,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -102,30 +102,30 @@ static void test_cacheable_request_response_with_metadata_and_payload(
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);
+ 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_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.cc b/test/core/end2end/tests/simple_delayed_request.cc
index eef36c9710..0ad224f579 100644
--- a/test/core/end2end/tests/simple_delayed_request.cc
+++ b/test/core/end2end/tests/simple_delayed_request.cc
@@ -41,7 +41,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -50,16 +50,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -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);
@@ -199,9 +199,9 @@ static void test_simple_delayed_request_short(grpc_end2end_test_config config) {
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);
}
@@ -219,9 +219,9 @@ static void test_simple_delayed_request_long(grpc_end2end_test_config config) {
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.cc b/test/core/end2end/tests/simple_metadata.cc
index 3b3d5ad64c..1a741169d4 100644
--- a/test/core/end2end/tests/simple_metadata.cc
+++ b/test/core/end2end/tests/simple_metadata.cc
@@ -53,7 +53,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -62,16 +62,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -100,29 +100,30 @@ static void test_request_response_with_metadata_and_payload(
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);
+ {{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_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.cc b/test/core/end2end/tests/simple_request.cc
index d48010ba87..7eb7467981 100644
--- a/test/core/end2end/tests/simple_request.cc
+++ b/test/core/end2end/tests/simple_request.cc
@@ -56,7 +56,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -65,16 +65,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -99,6 +99,7 @@ static void simple_request_body(grpc_end2end_test_config config,
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;
@@ -112,14 +113,14 @@ 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);
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);
@@ -133,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 =
@@ -162,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);
@@ -175,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;
@@ -183,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);
@@ -199,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);
@@ -206,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);
@@ -239,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);
@@ -248,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.cc b/test/core/end2end/tests/stream_compression_compressed_payload.cc
index 3fe5200045..d73346468a 100644
--- a/test/core/end2end/tests/stream_compression_compressed_payload.cc
+++ b/test/core/end2end/tests/stream_compression_compressed_payload.cc
@@ -61,7 +61,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -70,16 +70,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -110,7 +110,7 @@ static void request_for_disabled_algorithm(
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;
@@ -125,9 +125,9 @@ static void request_for_disabled_algorithm(
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);
+ nullptr, requested_client_compression_algorithm);
server_args = grpc_channel_args_set_stream_compression_algorithm(
- NULL, GRPC_STREAM_COMPRESS_NONE);
+ nullptr, GRPC_STREAM_COMPRESS_NONE);
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
server_args = grpc_channel_args_stream_compression_algorithm_set_state(
@@ -140,10 +140,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,37 +159,37 @@ 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);
@@ -200,14 +200,14 @@ static void request_for_disabled_algorithm(
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);
@@ -216,9 +216,9 @@ 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);
@@ -229,10 +229,10 @@ 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_stream_compression_algorithm_name(algorithm_to_disable, &algo_name));
- char* expected_details = NULL;
+ char* expected_details = nullptr;
gpr_asprintf(&expected_details,
"Stream compression algorithm '%s' is disabled.", algo_name);
/* and we expect a specific reason for it */
@@ -285,7 +285,7 @@ static void request_with_payload_template(
grpc_call* c;
grpc_call* s;
grpc_slice request_payload_slice;
- grpc_byte_buffer* request_payload = NULL;
+ grpc_byte_buffer* request_payload = nullptr;
grpc_channel_args* client_args;
grpc_channel_args* server_args;
grpc_end2end_test_fixture f;
@@ -294,7 +294,7 @@ static void request_with_payload_template(
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_byte_buffer* response_payload;
grpc_byte_buffer* response_payload_recv;
grpc_call_details call_details;
@@ -317,13 +317,13 @@ static void request_with_payload_template(
grpc_slice_from_copied_string(response_str);
client_args = grpc_channel_args_set_stream_compression_algorithm(
- NULL, default_client_channel_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);
+ nullptr, default_server_channel_compression_algorithm);
}
f = begin_test(config, test_name, client_args, server_args);
@@ -331,10 +331,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 +349,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 +359,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 =
@@ -418,14 +418,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++) {
@@ -438,9 +438,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 +451,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 +468,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 +479,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 +504,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 +517,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);
@@ -559,7 +562,7 @@ static void test_invoke_request_with_compressed_payload(
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_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_GZIP, nullptr,
false, /* ignored */
GRPC_STREAM_COMPRESS_LEVEL_NONE, false, false, GRPC_COMPRESS_NONE);
}
@@ -569,7 +572,7 @@ static void test_invoke_request_with_send_message_before_initial_metadata(
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,
+ GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_GZIP, nullptr,
false, /* ignored */
GRPC_STREAM_COMPRESS_LEVEL_NONE, true, false, GRPC_COMPRESS_NONE);
}
@@ -580,8 +583,8 @@ static void test_invoke_request_with_server_level(
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);
+ /* ignored */ nullptr, true, GRPC_STREAM_COMPRESS_LEVEL_HIGH, false,
+ false, GRPC_COMPRESS_NONE);
}
static void test_invoke_request_with_compressed_payload_md_override(
@@ -626,7 +629,7 @@ static void test_invoke_request_with_disabled_algorithm(
request_for_disabled_algorithm(
config, "test_invoke_request_with_disabled_algorithm", 0,
GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_GZIP,
- GRPC_STATUS_UNIMPLEMENTED, NULL);
+ GRPC_STATUS_UNIMPLEMENTED, nullptr);
}
static void test_stream_compression_override_message_compression(
@@ -638,7 +641,7 @@ static void test_stream_compression_override_message_compression(
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);
+ /* ignored */ nullptr, true, level, false, true, GRPC_COMPRESS_GZIP);
}
void stream_compression_compressed_payload(grpc_end2end_test_config config) {
diff --git a/test/core/end2end/tests/stream_compression_payload.cc b/test/core/end2end/tests/stream_compression_payload.cc
index 038f0be738..924961ea55 100644
--- a/test/core/end2end/tests/stream_compression_payload.cc
+++ b/test/core/end2end/tests/stream_compression_payload.cc
@@ -56,7 +56,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -65,16 +65,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -124,8 +124,8 @@ static void request_response_with_payload(grpc_end2end_test_config config,
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 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);
@@ -150,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 =
@@ -193,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);
@@ -211,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;
@@ -224,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);
@@ -266,10 +266,10 @@ 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);
+ nullptr, GRPC_STREAM_COMPRESS_GZIP);
grpc_channel_args* server_args =
grpc_channel_args_set_stream_compression_algorithm(
- NULL, GRPC_STREAM_COMPRESS_GZIP);
+ nullptr, GRPC_STREAM_COMPRESS_GZIP);
grpc_end2end_test_fixture f =
begin_test(config, "test_invoke_request_response_with_payload",
client_args, server_args);
@@ -288,7 +288,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.cc b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc
index a5321bfc61..d3b526f04e 100644
--- a/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc
+++ b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc
@@ -56,7 +56,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -65,16 +65,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -92,10 +92,10 @@ 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);
+ nullptr, GRPC_STREAM_COMPRESS_GZIP);
grpc_channel_args* server_args =
grpc_channel_args_set_stream_compression_algorithm(
- NULL, GRPC_STREAM_COMPRESS_GZIP);
+ nullptr, GRPC_STREAM_COMPRESS_GZIP);
grpc_end2end_test_fixture f =
begin_test(config, "test_pingpong_streaming", client_args, server_args);
grpc_call* c;
@@ -123,10 +123,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 +139,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 +168,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 +187,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 +202,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 +215,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 +237,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 +250,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/streaming_error_response.cc b/test/core/end2end/tests/streaming_error_response.cc
index f87fd2c4c3..fe53fda9ef 100644
--- a/test/core/end2end/tests/streaming_error_response.cc
+++ b/test/core/end2end/tests/streaming_error_response.cc
@@ -58,7 +58,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -67,16 +67,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -99,16 +99,17 @@ static void test(grpc_end2end_test_config config, bool request_status_early) {
grpc_slice response_payload2_slice = grpc_slice_from_copied_string("world");
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);
+ 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_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_call_error error;
@@ -117,10 +118,10 @@ static void test(grpc_end2end_test_config config, bool request_status_early) {
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,7 +180,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_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);
@@ -190,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);
@@ -208,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);
@@ -225,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.cc b/test/core/end2end/tests/trailing_metadata.cc
index 0da02a56db..afc56c8dfa 100644
--- a/test/core/end2end/tests/trailing_metadata.cc
+++ b/test/core/end2end/tests/trailing_metadata.cc
@@ -53,7 +53,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -62,16 +62,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -100,37 +100,38 @@ static void test_request_response_with_metadata_and_payload(
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);
+ {{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_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.cc b/test/core/end2end/tests/workaround_cronet_compression.cc
index 8f8ca16a9e..bc4d5079d8 100644
--- a/test/core/end2end/tests/workaround_cronet_compression.cc
+++ b/test/core/end2end/tests/workaround_cronet_compression.cc
@@ -61,7 +61,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -70,16 +70,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -114,7 +114,7 @@ static void request_with_payload_template(
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_byte_buffer* response_payload;
grpc_byte_buffer* response_payload_recv;
grpc_call_details call_details;
@@ -137,9 +137,9 @@ 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;
@@ -158,10 +158,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 +172,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 =
@@ -222,14 +222,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 +241,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 +256,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 +274,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 +308,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 +321,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);
@@ -365,7 +367,7 @@ typedef struct workaround_cronet_compression_config {
} workaround_cronet_compression_config;
static workaround_cronet_compression_config workaround_configs[] = {
- {NULL, GRPC_COMPRESS_GZIP},
+ {nullptr, GRPC_COMPRESS_GZIP},
{const_cast<char*>(
"grpc-objc/1.3.0-dev grpc-c/3.0.0-dev (ios; cronet_http; gentle)"),
GRPC_COMPRESS_NONE},
@@ -384,7 +386,7 @@ static void test_workaround_cronet_compression(
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,
+ 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.cc b/test/core/end2end/tests/write_buffering.cc
index 5e92e598b3..40821dd6f0 100644
--- a/test/core/end2end/tests/write_buffering.cc
+++ b/test/core/end2end/tests/write_buffering.cc
@@ -53,7 +53,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -62,16 +62,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -96,15 +96,15 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
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);
+ 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_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.cc b/test/core/end2end/tests/write_buffering_at_end.cc
index 01dacdfd12..1b9dc9632b 100644
--- a/test/core/end2end/tests/write_buffering_at_end.cc
+++ b/test/core/end2end/tests/write_buffering_at_end.cc
@@ -53,7 +53,7 @@ static gpr_timespec five_seconds_from_now(void) {
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);
}
@@ -62,16 +62,16 @@ static void shutdown_server(grpc_end2end_test_fixture* f) {
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) {
if (!f->client) return;
grpc_channel_destroy(f->client);
- f->client = NULL;
+ f->client = nullptr;
}
static void end_test(grpc_end2end_test_fixture* f) {
@@ -93,15 +93,15 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
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);
+ 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_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/client.cc b/test/core/fling/client.cc
index 64d1dc5089..69fb6dc7c7 100644
--- a/test/core/fling/client.cc
+++ b/test/core/fling/client.cc
@@ -22,15 +22,15 @@
#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_histogram* histogram;
static grpc_byte_buffer* the_buffer;
static grpc_channel* channel;
static grpc_completion_queue* cq;
@@ -40,7 +40,7 @@ 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;
@@ -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);
+ 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);
}
@@ -155,7 +155,7 @@ int main(int argc, char** argv) {
gpr_cmdline* cl;
grpc_event event;
const char* scenario_name = "ping-pong-request";
- scenario sc = {NULL, NULL, NULL};
+ scenario sc = {nullptr, nullptr, nullptr};
gpr_timers_set_log_filename("latency_trace.fling_client.txt");
@@ -192,10 +192,10 @@ int main(int argc, char** argv) {
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 +213,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 +225,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_stream_test.cc b/test/core/fling/fling_stream_test.cc
index 620427e12a..b476f2e128 100644
--- a/test/core/fling/fling_stream_test.cc
+++ b/test/core/fling/fling_stream_test.cc
@@ -58,7 +58,7 @@ int main(int argc, char** argv) {
gpr_join_host_port(&args[2], "127.0.0.1", port);
args[3] = const_cast<char*>("--scenario=ping-pong-stream");
args[4] = const_cast<char*>("--no-secure");
- args[5] = 0;
+ 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_test.cc b/test/core/fling/fling_test.cc
index 1d4263ab01..0e8b3c1028 100644
--- a/test/core/fling/fling_test.cc
+++ b/test/core/fling/fling_test.cc
@@ -58,7 +58,7 @@ int main(int argc, const char** argv) {
gpr_join_host_port(&args[2], "127.0.0.1", port);
args[3] = const_cast<char*>("--scenario=ping-pong-request");
args[4] = const_cast<char*>("--no-secure");
- args[5] = 0;
+ 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.cc b/test/core/fling/server.cc
index 4dfb30f107..f3a8a1ccf8 100644
--- a/test/core/fling/server.cc
+++ b/test/core/fling/server.cc
@@ -46,9 +46,9 @@ 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;
@@ -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,14 +105,14 @@ 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);
}
@@ -122,7 +122,7 @@ static void send_initial_metadata(void) {
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,7 +132,7 @@ 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);
}
@@ -141,11 +141,11 @@ static void start_write_op(void) {
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);
}
@@ -155,11 +155,11 @@ static void start_send_status(void) {
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);
}
@@ -170,14 +170,14 @@ static void sigint_handler(int x) { _exit(0); }
int main(int argc, char** argv) {
grpc_event ev;
call_state* s;
- char* addr_buf = NULL;
+ char* addr_buf = nullptr;
gpr_cmdline* cl;
grpc_completion_queue* shutdown_cq;
int shutdown_started = 0;
int shutdown_finished = 0;
int secure = 0;
- const char* addr = NULL;
+ const char* addr = nullptr;
char* fake_argv[1];
@@ -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);
+ 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,13 +231,13 @@ 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);
@@ -247,13 +247,13 @@ int main(int argc, char** argv) {
cq,
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_micros(1000000, GPR_TIMESPAN)),
- NULL);
+ 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. */
@@ -270,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 {
@@ -281,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:
@@ -301,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/handshake/BUILD b/test/core/handshake/BUILD
index aea4a27e99..a3276b9343 100644
--- a/test/core/handshake/BUILD
+++ b/test/core/handshake/BUILD
@@ -35,6 +35,18 @@ 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.cc"],
@@ -45,6 +57,25 @@ grpc_cc_test(
"//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.cc b/test/core/handshake/client_ssl.cc
index b8cfd627a9..2302e3da2f 100644
--- a/test/core/handshake/client_ssl.cc
+++ b/test/core/handshake/client_ssl.cc
@@ -231,7 +231,8 @@ static bool client_ssl_test(char* server_alpn_preferred) {
gpr_thd_id thdid;
gpr_thd_options_set_joinable(&thdopt);
server_args args = {server_socket, server_alpn_preferred};
- GPR_ASSERT(gpr_thd_new(&thdid, server_thread, &args, &thdopt));
+ 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;
@@ -246,7 +247,7 @@ static bool client_ssl_test(char* server_alpn_preferred) {
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);
+ 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.
@@ -260,7 +261,7 @@ static bool client_ssl_test(char* server_alpn_preferred) {
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_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 */);
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..2810082837
--- /dev/null
+++ b/test/core/handshake/readahead_handshaker_server_ssl.cc
@@ -0,0 +1,103 @@
+/*
+ *
+ * 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_exec_ctx* ctx,
+ grpc_handshaker* handshaker) {
+ gpr_free(handshaker);
+}
+
+static void readahead_handshaker_shutdown(grpc_exec_ctx* ctx,
+ grpc_handshaker* handshaker,
+ grpc_error* error) {}
+
+static void readahead_handshaker_do_handshake(
+ grpc_exec_ctx* ctx, grpc_handshaker* handshaker,
+ grpc_tcp_server_acceptor* acceptor, grpc_closure* on_handshake_done,
+ grpc_handshaker_args* args) {
+ grpc_endpoint_read(ctx, 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_exec_ctx* ctx) {
+ 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_exec_ctx* exec_ctx, grpc_handshaker_factory* hf,
+ const grpc_channel_args* args, grpc_handshake_manager* handshake_mgr) {
+ grpc_handshake_manager_add(handshake_mgr,
+ readahead_handshaker_create(exec_ctx));
+}
+
+static void readahead_handshaker_factory_destroy(
+ grpc_exec_ctx* exec_ctx, 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
index bb92c8435a..736d3e578e 100644
--- a/test/core/handshake/server_ssl.cc
+++ b/test/core/handshake/server_ssl.cc
@@ -34,206 +34,7 @@
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
-#define SSL_CERT_PATH "src/core/tsi/test_creds/server1.pem"
-#define SSL_KEY_PATH "src/core/tsi/test_creds/server1.key"
-#define SSL_CA_PATH "src/core/tsi/test_creds/ca.pem"
-
-// Handshake completed signal to server thread.
-static gpr_event client_handshake_complete;
-
-static int create_socket(int port) {
- int s;
- struct sockaddr_in addr;
-
- addr.sin_family = AF_INET;
- addr.sin_port = htons((uint16_t)port);
- addr.sin_addr.s_addr = htonl(INADDR_ANY);
-
- s = socket(AF_INET, SOCK_STREAM, 0);
- if (s < 0) {
- perror("Unable to create socket");
- return -1;
- }
-
- if (connect(s, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
- perror("Unable to connect");
- return -1;
- }
-
- return s;
-}
-
-// Simple gRPC server. This listens until client_handshake_complete occurs.
-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;
- grpc_slice ca_slice, cert_slice, key_slice;
- GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
- grpc_load_file(SSL_CA_PATH, 1, &ca_slice)));
- GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
- 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);
-
- // Start server listening on local port.
- char* addr;
- gpr_asprintf(&addr, "127.0.0.1:%d", port);
- grpc_server* server = grpc_server_create(NULL, NULL);
- 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_server_register_completion_queue(server, cq, NULL);
- grpc_server_start(server);
-
- // Wait a bounded number of time until client_handshake_complete is set,
- // sleeping between polls.
- 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);
- GPR_ASSERT(ev.type == GRPC_QUEUE_TIMEOUT);
- }
-
- gpr_log(GPR_INFO, "Shutting down server");
- grpc_server_shutdown_and_notify(server, cq, NULL);
- 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);
- GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
-
- grpc_server_destroy(server);
- grpc_completion_queue_destroy(cq);
- grpc_server_credentials_release(ssl_creds);
- grpc_slice_unref(cert_slice);
- grpc_slice_unref(key_slice);
- grpc_slice_unref(ca_slice);
-}
-
-// This test launches a gRPC server on a separate thread and then establishes a
-// 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 success = true;
-
- grpc_init();
- int port = grpc_pick_unused_port_or_die();
- gpr_event_init(&client_handshake_complete);
-
- // Launch the gRPC server thread.
- 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));
-
- SSL_load_error_strings();
- OpenSSL_add_ssl_algorithms();
-
- 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);
- abort();
- }
-
- // Load key pair.
- if (SSL_CTX_use_certificate_file(ctx, SSL_CERT_PATH, SSL_FILETYPE_PEM) < 0) {
- ERR_print_errors_fp(stderr);
- abort();
- }
- if (SSL_CTX_use_PrivateKey_file(ctx, SSL_KEY_PATH, SSL_FILETYPE_PEM) < 0) {
- ERR_print_errors_fp(stderr);
- abort();
- }
-
- // Set the cipher list to match the one expressed in
- // src/core/tsi/ssl_transport_security.c.
- 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)) {
- ERR_print_errors_fp(stderr);
- gpr_log(GPR_ERROR, "Couldn't set server cipher list.");
- abort();
- }
-
- // Configure ALPN list the client will send to the server. This must match the
- // wire format, see documentation for SSL_CTX_set_alpn_protos.
- unsigned int alpn_protos_len = 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 =
- 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;
- memcpy(p, alpn_list[i], len);
- p += len;
- }
- GPR_ASSERT(SSL_CTX_set_alpn_protos(ctx, alpn_protos, alpn_protos_len) == 0);
-
- // Try and connect to server. We allow a bounded number of retries as we might
- // be racing with the server setup on its separate thread.
- int retries = 10;
- int sock = -1;
- while (sock == -1 && retries-- > 0) {
- sock = create_socket(port);
- if (sock < 0) {
- sleep(1);
- }
- }
- GPR_ASSERT(sock > 0);
- gpr_log(GPR_INFO, "Connected to server on port %d", port);
-
- // Establish a SSL* and connect at SSL layer.
- SSL* ssl = SSL_new(ctx);
- GPR_ASSERT(ssl);
- SSL_set_fd(ssl, sock);
- if (SSL_connect(ssl) <= 0) {
- ERR_print_errors_fp(stderr);
- gpr_log(GPR_ERROR, "Handshake failed.");
- success = false;
- } else {
- gpr_log(GPR_INFO, "Handshake successful.");
- // Validate ALPN preferred by server matches alpn_expected.
- 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) {
- gpr_log(GPR_ERROR, "Unexpected ALPN protocol preference");
- success = false;
- }
- }
- gpr_event_set(&client_handshake_complete, &client_handshake_complete);
-
- SSL_free(ssl);
- gpr_free(alpn_protos);
- SSL_CTX_free(ctx);
- EVP_cleanup();
- close(sock);
-
- gpr_thd_join(thdid);
-
- grpc_shutdown();
-
- return success;
-}
+#include "test/core/handshake/server_ssl_common.h"
int main(int argc, char* argv[]) {
// Handshake succeeeds when the client supplies the standard ALPN list.
diff --git a/test/core/handshake/server_ssl_common.cc b/test/core/handshake/server_ssl_common.cc
new file mode 100644
index 0000000000..0bf453a204
--- /dev/null
+++ b/test/core/handshake/server_ssl_common.cc
@@ -0,0 +1,239 @@
+/*
+ *
+ * Copyright 2016 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "test/core/handshake/server_ssl_common.h"
+
+#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"
+
+#define SSL_CERT_PATH "src/core/tsi/test_creds/server1.pem"
+#define SSL_KEY_PATH "src/core/tsi/test_creds/server1.key"
+#define SSL_CA_PATH "src/core/tsi/test_creds/ca.pem"
+
+// Handshake completed signal to server thread.
+static gpr_event client_handshake_complete;
+
+static int create_socket(int port) {
+ int s;
+ struct sockaddr_in addr;
+
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons((uint16_t)port);
+ addr.sin_addr.s_addr = htonl(INADDR_ANY);
+
+ s = socket(AF_INET, SOCK_STREAM, 0);
+ if (s < 0) {
+ perror("Unable to create socket");
+ return -1;
+ }
+
+ if (connect(s, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
+ perror("Unable to connect");
+ return -1;
+ }
+
+ return s;
+}
+
+// Simple gRPC server. This listens until client_handshake_complete occurs.
+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;
+ grpc_slice ca_slice, cert_slice, key_slice;
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
+ grpc_load_file(SSL_CA_PATH, 1, &ca_slice)));
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
+ 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, nullptr);
+
+ // Start server listening on local port.
+ char* addr;
+ gpr_asprintf(&addr, "127.0.0.1:%d", port);
+ 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(nullptr);
+
+ grpc_server_register_completion_queue(server, cq, nullptr);
+ grpc_server_start(server);
+
+ // Wait a bounded number of time until client_handshake_complete is set,
+ // sleeping between polls.
+ 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, nullptr);
+ GPR_ASSERT(ev.type == GRPC_QUEUE_TIMEOUT);
+ }
+
+ gpr_log(GPR_INFO, "Shutting down server");
+ 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, nullptr);
+ GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
+
+ grpc_server_destroy(server);
+ grpc_completion_queue_destroy(cq);
+ grpc_server_credentials_release(ssl_creds);
+ grpc_slice_unref(cert_slice);
+ grpc_slice_unref(key_slice);
+ grpc_slice_unref(ca_slice);
+}
+
+// This test launches a gRPC server on a separate thread and then establishes a
+// 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).
+bool server_ssl_test(const char* alpn_list[], unsigned int alpn_list_len,
+ const char* alpn_expected) {
+ bool success = true;
+
+ grpc_init();
+ int port = grpc_pick_unused_port_or_die();
+ gpr_event_init(&client_handshake_complete);
+
+ // Launch the gRPC server thread.
+ gpr_thd_options thdopt = gpr_thd_options_default();
+ gpr_thd_id thdid;
+ gpr_thd_options_set_joinable(&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);
+ if (!ctx) {
+ perror("Unable to create SSL context");
+ ERR_print_errors_fp(stderr);
+ abort();
+ }
+
+ // Load key pair.
+ if (SSL_CTX_use_certificate_file(ctx, SSL_CERT_PATH, SSL_FILETYPE_PEM) < 0) {
+ ERR_print_errors_fp(stderr);
+ abort();
+ }
+ if (SSL_CTX_use_PrivateKey_file(ctx, SSL_KEY_PATH, SSL_FILETYPE_PEM) < 0) {
+ ERR_print_errors_fp(stderr);
+ abort();
+ }
+
+ // Set the cipher list to match the one expressed in
+ // src/core/tsi/ssl_transport_security.c.
+ 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)) {
+ ERR_print_errors_fp(stderr);
+ gpr_log(GPR_ERROR, "Couldn't set server cipher list.");
+ abort();
+ }
+
+ // Configure ALPN list the client will send to the server. This must match the
+ // wire format, see documentation for SSL_CTX_set_alpn_protos.
+ unsigned int alpn_protos_len = 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 =
+ 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;
+ memcpy(p, alpn_list[i], len);
+ p += len;
+ }
+ GPR_ASSERT(SSL_CTX_set_alpn_protos(ctx, alpn_protos, alpn_protos_len) == 0);
+
+ // Try and connect to server. We allow a bounded number of retries as we might
+ // be racing with the server setup on its separate thread.
+ int retries = 10;
+ int sock = -1;
+ while (sock == -1 && retries-- > 0) {
+ sock = create_socket(port);
+ if (sock < 0) {
+ sleep(1);
+ }
+ }
+ GPR_ASSERT(sock > 0);
+ gpr_log(GPR_INFO, "Connected to server on port %d", port);
+
+ // Establish a SSL* and connect at SSL layer.
+ SSL* ssl = SSL_new(ctx);
+ GPR_ASSERT(ssl);
+ SSL_set_fd(ssl, sock);
+ if (SSL_connect(ssl) <= 0) {
+ ERR_print_errors_fp(stderr);
+ gpr_log(GPR_ERROR, "Handshake failed.");
+ success = false;
+ } else {
+ gpr_log(GPR_INFO, "Handshake successful.");
+ // Validate ALPN preferred by server matches alpn_expected.
+ 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) {
+ gpr_log(GPR_ERROR, "Unexpected ALPN protocol preference");
+ success = false;
+ }
+ }
+ gpr_event_set(&client_handshake_complete, &client_handshake_complete);
+
+ SSL_free(ssl);
+ gpr_free(alpn_protos);
+ SSL_CTX_free(ctx);
+ EVP_cleanup();
+ close(sock);
+
+ gpr_thd_join(thdid);
+
+ grpc_shutdown();
+
+ return success;
+}
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/format_request_test.cc b/test/core/http/format_request_test.cc
index 253e59135d..684738a997 100644
--- a/test/core/http/format_request_test.cc
+++ b/test/core/http/format_request_test.cc
@@ -89,7 +89,7 @@ static void test_format_post_request_no_body(void) {
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"
diff --git a/test/core/http/httpcli_test.cc b/test/core/http/httpcli_test.cc
index ac3c6a2ce5..81e9374819 100644
--- a/test/core/http/httpcli_test.cc
+++ b/test/core/http/httpcli_test.cc
@@ -53,7 +53,8 @@ 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(exec_ctx, grpc_polling_entity_pollset(&g_pops),
+ nullptr)));
gpr_mu_unlock(g_mu);
}
@@ -83,7 +84,7 @@ static void test_get(int port) {
grpc_resource_quota_unref_internal(&exec_ctx, 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),
@@ -124,7 +125,7 @@ static void test_post(int port) {
grpc_resource_quota_unref_internal(&exec_ctx, 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),
diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc
index bf851b1175..da8405c049 100644
--- a/test/core/http/httpscli_test.cc
+++ b/test/core/http/httpscli_test.cc
@@ -53,7 +53,8 @@ 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(exec_ctx, grpc_polling_entity_pollset(&g_pops),
+ nullptr)));
gpr_mu_unlock(g_mu);
}
@@ -84,7 +85,7 @@ static void test_get(int port) {
grpc_resource_quota_unref_internal(&exec_ctx, 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),
@@ -126,7 +127,7 @@ static void test_post(int port) {
grpc_resource_quota_unref_internal(&exec_ctx, 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),
diff --git a/test/core/http/parser_test.cc b/test/core/http/parser_test.cc
index d0d2559cdf..0b60e369b7 100644
--- a/test/core/http/parser_test.cc
+++ b/test/core/http/parser_test.cc
@@ -49,7 +49,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]);
}
@@ -60,7 +60,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 {
@@ -107,7 +107,7 @@ static void test_succeeds(grpc_slice_split_mode split_mode,
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]);
}
@@ -115,7 +115,7 @@ static void test_succeeds(grpc_slice_split_mode split_mode,
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 {
@@ -162,7 +162,7 @@ static void test_fails(grpc_slice_split_mode split_mode,
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]);
}
@@ -195,7 +195,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]);
}
@@ -228,7 +228,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"
@@ -243,7 +243,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"
diff --git a/test/core/http/request_fuzzer.cc b/test/core/http/request_fuzzer.cc
index dfdb5792ac..368ac1b49d 100644
--- a/test/core/http/request_fuzzer.cc
+++ b/test/core/http/request_fuzzer.cc
@@ -33,7 +33,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
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_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);
diff --git a/test/core/http/response_fuzzer.cc b/test/core/http/response_fuzzer.cc
index 89ee676b49..2a793fddd4 100644
--- a/test/core/http/response_fuzzer.cc
+++ b/test/core/http/response_fuzzer.cc
@@ -32,7 +32,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
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_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);
diff --git a/test/core/iomgr/combiner_test.cc b/test/core/iomgr/combiner_test.cc
index 5a825368f7..33d892fa06 100644
--- a/test/core/iomgr/combiner_test.cc
+++ b/test/core/iomgr/combiner_test.cc
@@ -51,7 +51,7 @@ static void test_execute_one(void) {
GRPC_ERROR_NONE);
grpc_exec_ctx_flush(&exec_ctx);
GPR_ASSERT(gpr_event_wait(&done, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
GRPC_COMBINER_UNREF(&exec_ctx, lock, "test_execute_one");
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -112,11 +112,12 @@ 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;
@@ -150,7 +151,7 @@ static void test_execute_finally(void) {
GRPC_ERROR_NONE);
grpc_exec_ctx_flush(&exec_ctx);
GPR_ASSERT(gpr_event_wait(&got_in_finally,
- grpc_timeout_seconds_to_deadline(5)) != NULL);
+ grpc_timeout_seconds_to_deadline(5)) != nullptr);
GRPC_COMBINER_UNREF(&exec_ctx, lock, "test_execute_finally");
grpc_exec_ctx_finish(&exec_ctx);
}
diff --git a/test/core/iomgr/endpoint_tests.cc b/test/core/iomgr/endpoint_tests.cc
index 8e859ba909..026e34105d 100644
--- a/test/core/iomgr/endpoint_tests.cc
+++ b/test/core/iomgr/endpoint_tests.cc
@@ -127,7 +127,7 @@ static void read_and_write_test_read_handler(grpc_exec_ctx* exec_ctx,
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_pollset_kick(exec_ctx, g_pollset, nullptr));
gpr_mu_unlock(g_mu);
} else if (error == GRPC_ERROR_NONE) {
grpc_endpoint_read(exec_ctx, state->read_ep, &state->incoming,
@@ -139,7 +139,7 @@ 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;
+ grpc_slice* slices = nullptr;
size_t nslices;
if (error == GRPC_ERROR_NONE) {
@@ -164,7 +164,7 @@ static void read_and_write_test_write_handler(grpc_exec_ctx* exec_ctx,
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_pollset_kick(exec_ctx, g_pollset, nullptr));
gpr_mu_unlock(g_mu);
}
@@ -237,7 +237,7 @@ static void read_and_write_test(grpc_endpoint_test_config config,
gpr_mu_lock(g_mu);
while (!state.read_done || !state.write_done) {
- grpc_pollset_worker* worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(grpc_exec_ctx_now(&exec_ctx) < deadline);
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
@@ -258,8 +258,8 @@ static void inc_on_failure(grpc_exec_ctx* exec_ctx, 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)));
+ GPR_ASSERT(GRPC_LOG_IF_ERROR(
+ "kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
@@ -271,7 +271,7 @@ static void wait_for_fail_count(grpc_exec_ctx* exec_ctx, int* fail_count,
grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10));
while (grpc_exec_ctx_now(exec_ctx) < 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, deadline)));
@@ -332,6 +332,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/ev_epollsig_linux_test.cc b/test/core/iomgr/ev_epollsig_linux_test.cc
index 3ee607d97e..94f387164a 100644
--- a/test/core/iomgr/ev_epollsig_linux_test.cc
+++ b/test/core/iomgr/ev_epollsig_linux_test.cc
@@ -80,7 +80,7 @@ static void test_fd_cleanup(grpc_exec_ctx* exec_ctx, test_fd* tfds,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_fd_cleanup"));
grpc_exec_ctx_flush(exec_ctx);
- grpc_fd_orphan(exec_ctx, tfds[i].fd, NULL, &release_fd,
+ grpc_fd_orphan(exec_ctx, tfds[i].fd, nullptr, &release_fd,
false /* already_closed */, "test_fd_cleanup");
grpc_exec_ctx_flush(exec_ctx);
@@ -137,7 +137,7 @@ static void test_add_fd_to_pollset() {
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);
@@ -269,7 +269,7 @@ static void test_threading(void) {
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)));
@@ -295,7 +295,7 @@ static void test_threading(void) {
{
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_fd_orphan(&exec_ctx, shared.wakeup_desc, nullptr, nullptr,
false /* already_closed */, "done");
grpc_pollset_shutdown(&exec_ctx, shared.pollset,
GRPC_CLOSURE_CREATE(destroy_pollset, shared.pollset,
@@ -306,13 +306,13 @@ static void test_threading(void) {
}
int main(int argc, char** argv) {
- const char* poll_strategy = NULL;
+ 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) {
+ if (poll_strategy != nullptr && strcmp(poll_strategy, "epollsig") == 0) {
test_add_fd_to_pollset();
test_threading();
} else {
diff --git a/test/core/iomgr/fd_conservation_posix_test.cc b/test/core/iomgr/fd_conservation_posix_test.cc
index b76c247fb8..f46430c611 100644
--- a/test/core/iomgr/fd_conservation_posix_test.cc
+++ b/test/core/iomgr/fd_conservation_posix_test.cc
@@ -42,7 +42,7 @@ int main(int argc, char** argv) {
grpc_resource_quota_create("fd_conservation_posix_test");
for (i = 0; i < 100; i++) {
- p = grpc_iomgr_create_endpoint_pair("test", NULL);
+ p = grpc_iomgr_create_endpoint_pair("test", nullptr);
grpc_endpoint_destroy(&exec_ctx, p.client);
grpc_endpoint_destroy(&exec_ctx, p.server);
grpc_exec_ctx_flush(&exec_ctx);
diff --git a/test/core/iomgr/fd_posix_test.cc b/test/core/iomgr/fd_posix_test.cc
index c70187ce91..a03d841ecd 100644
--- a/test/core/iomgr/fd_posix_test.cc
+++ b/test/core/iomgr/fd_posix_test.cc
@@ -115,8 +115,8 @@ static void session_shutdown_cb(grpc_exec_ctx* exec_ctx, void* arg, /*session */
bool success) {
session* se = static_cast<session*>(arg);
server* sv = se->sv;
- grpc_fd_orphan(exec_ctx, se->em_fd, NULL, NULL, false /* already_closed */,
- "a");
+ grpc_fd_orphan(exec_ctx, 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,
@@ -173,13 +173,13 @@ static void listen_shutdown_cb(grpc_exec_ctx* exec_ctx, 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(exec_ctx, 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(exec_ctx, g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
@@ -250,7 +250,7 @@ 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_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
GRPC_MILLIS_INF_FUTURE)));
@@ -292,11 +292,11 @@ static void client_init(client* cl) {
static void client_session_shutdown_cb(grpc_exec_ctx* exec_ctx,
void* arg /*client */, int success) {
client* cl = static_cast<client*>(arg);
- grpc_fd_orphan(exec_ctx, cl->em_fd, NULL, NULL, false /* already_closed */,
- "c");
+ grpc_fd_orphan(exec_ctx, 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(exec_ctx, g_pollset, nullptr)));
}
/* Write as much as possible, then register notify_on_write. */
@@ -366,7 +366,7 @@ static void client_start(grpc_exec_ctx* exec_ctx, client* cl, int port) {
static void client_wait_and_shutdown(client* cl) {
gpr_mu_lock(g_mu);
while (!cl->done) {
- grpc_pollset_worker* worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
@@ -402,7 +402,7 @@ 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) {}
@@ -413,8 +413,8 @@ static void first_read_callback(grpc_exec_ctx* exec_ctx,
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(exec_ctx, g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
@@ -425,8 +425,8 @@ static void second_read_callback(grpc_exec_ctx* exec_ctx,
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(exec_ctx, g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
@@ -470,8 +470,8 @@ static void test_grpc_fd_change(void) {
/* 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,
GRPC_MILLIS_INF_FUTURE)));
@@ -494,8 +494,8 @@ static void test_grpc_fd_change(void) {
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,
GRPC_MILLIS_INF_FUTURE)));
@@ -507,7 +507,8 @@ static void test_grpc_fd_change(void) {
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_fd_orphan(&exec_ctx, em_fd, nullptr, nullptr, false /* already_closed */,
+ "d");
grpc_exec_ctx_finish(&exec_ctx);
destroy_change_data(&a);
destroy_change_data(&b);
diff --git a/test/core/iomgr/load_file_test.cc b/test/core/iomgr/load_file_test.cc
index 2c9e7c33f4..9f360badcc 100644
--- a/test/core/iomgr/load_file_test.cc
+++ b/test/core/iomgr/load_file_test.cc
@@ -33,7 +33,7 @@
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;
@@ -42,8 +42,8 @@ static void test_load_empty_file(void) {
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,7 +62,7 @@ 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;
@@ -70,8 +70,8 @@ static void test_load_failure(void) {
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,7 +84,7 @@ 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;
@@ -94,8 +94,8 @@ static void test_load_small_file(void) {
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);
@@ -117,7 +117,7 @@ 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;
@@ -131,8 +131,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);
diff --git a/test/core/iomgr/pollset_set_test.cc b/test/core/iomgr/pollset_set_test.cc
index 8d0198cace..719eab91fe 100644
--- a/test/core/iomgr/pollset_set_test.cc
+++ b/test/core/iomgr/pollset_set_test.cc
@@ -52,7 +52,7 @@ void cleanup_test_pollset_sets(grpc_exec_ctx* exec_ctx,
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;
+ pollset_sets[i].pss = nullptr;
}
}
@@ -89,7 +89,7 @@ static void cleanup_test_pollsets(grpc_exec_ctx* exec_ctx,
grpc_exec_ctx_flush(exec_ctx);
gpr_free(pollsets[i].ps);
- pollsets[i].ps = NULL;
+ pollsets[i].ps = nullptr;
}
}
@@ -141,7 +141,7 @@ static void cleanup_test_fds(grpc_exec_ctx* exec_ctx, test_fd* tfds,
* 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,
+ grpc_fd_orphan(exec_ctx, tfds[i].fd, nullptr, &release_fd,
false /* already_closed */, "test_fd_cleanup");
grpc_exec_ctx_flush(exec_ctx);
@@ -439,7 +439,7 @@ int main(int argc, char** argv) {
grpc_init();
const char* poll_strategy = grpc_get_poll_strategy_name();
- if (poll_strategy != NULL &&
+ if (poll_strategy != nullptr &&
(strcmp(poll_strategy, "epollsig") == 0 ||
strcmp(poll_strategy, "epoll-threadpool") == 0)) {
pollset_set_test_basic();
diff --git a/test/core/iomgr/resolve_address_posix_test.cc b/test/core/iomgr/resolve_address_posix_test.cc
index ba89fc8ad5..836de423bd 100644
--- a/test/core/iomgr/resolve_address_posix_test.cc
+++ b/test/core/iomgr/resolve_address_posix_test.cc
@@ -54,7 +54,7 @@ void args_init(grpc_exec_ctx* exec_ctx, args_struct* args) {
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;
+ args->addrs = nullptr;
}
void args_finish(grpc_exec_ctx* exec_ctx, args_struct* args) {
@@ -63,7 +63,7 @@ void args_finish(grpc_exec_ctx* exec_ctx, args_struct* args) {
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_CLOSURE_INIT(&do_nothing_cb, do_nothing, nullptr,
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()
@@ -89,7 +89,7 @@ static void actually_poll(void* argsp) {
grpc_millis time_left = deadline - grpc_exec_ctx_now(&exec_ctx);
gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left);
GPR_ASSERT(time_left >= 0);
- grpc_pollset_worker* worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
gpr_mu_lock(args->mu);
GRPC_LOG_IF_ERROR("pollset_work",
grpc_pollset_work(&exec_ctx, args->pollset, &worker,
@@ -104,14 +104,14 @@ static void actually_poll(void* argsp) {
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);
+ gpr_thd_new(&id, "grpc_poll_pollset", actually_poll, args, nullptr);
}
static void must_succeed(grpc_exec_ctx* exec_ctx, void* argsp,
grpc_error* err) {
args_struct* args = static_cast<args_struct*>(argsp);
GPR_ASSERT(err == GRPC_ERROR_NONE);
- GPR_ASSERT(args->addrs != NULL);
+ GPR_ASSERT(args->addrs != nullptr);
GPR_ASSERT(args->addrs->naddrs > 0);
gpr_atm_rel_store(&args->done_atm, 1);
}
@@ -128,7 +128,7 @@ static void test_unix_socket(void) {
args_init(&exec_ctx, &args);
poll_pollset_until_request_done(&args);
grpc_resolve_address(
- &exec_ctx, "unix:/path/name", NULL, args.pollset_set,
+ &exec_ctx, "unix:/path/name", nullptr, args.pollset_set,
GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
args_finish(&exec_ctx, &args);
@@ -141,7 +141,7 @@ static void test_unix_socket_path_name_too_long(void) {
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;
+ 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);
@@ -150,7 +150,7 @@ static void test_unix_socket_path_name_too_long(void) {
poll_pollset_until_request_done(&args);
grpc_resolve_address(
- &exec_ctx, path_name, NULL, args.pollset_set,
+ &exec_ctx, path_name, nullptr, args.pollset_set,
GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
gpr_free(path_name);
diff --git a/test/core/iomgr/resolve_address_test.cc b/test/core/iomgr/resolve_address_test.cc
index 0aa3e5f0f0..1c5aa38a95 100644
--- a/test/core/iomgr/resolve_address_test.cc
+++ b/test/core/iomgr/resolve_address_test.cc
@@ -47,7 +47,7 @@ void args_init(grpc_exec_ctx* exec_ctx, args_struct* args) {
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;
+ args->addrs = nullptr;
gpr_atm_rel_store(&args->done_atm, 0);
}
@@ -57,7 +57,7 @@ void args_finish(grpc_exec_ctx* exec_ctx, args_struct* args) {
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_CLOSURE_INIT(&do_nothing_cb, do_nothing, nullptr,
grpc_schedule_on_exec_ctx);
gpr_mu_lock(args->mu);
grpc_pollset_shutdown(exec_ctx, args->pollset, &do_nothing_cb);
@@ -84,7 +84,7 @@ static void poll_pollset_until_request_done(args_struct* args) {
grpc_millis time_left = deadline - grpc_exec_ctx_now(&exec_ctx);
gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left);
GPR_ASSERT(time_left >= 0);
- grpc_pollset_worker* worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
gpr_mu_lock(args->mu);
GRPC_LOG_IF_ERROR("pollset_work",
grpc_pollset_work(&exec_ctx, args->pollset, &worker,
@@ -100,12 +100,12 @@ static void must_succeed(grpc_exec_ctx* exec_ctx, void* argsp,
grpc_error* err) {
args_struct* args = static_cast<args_struct*>(argsp);
GPR_ASSERT(err == GRPC_ERROR_NONE);
- GPR_ASSERT(args->addrs != NULL);
+ 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(exec_ctx, args->pollset, NULL));
+ grpc_pollset_kick(exec_ctx, args->pollset, nullptr));
gpr_mu_unlock(args->mu);
}
@@ -115,7 +115,7 @@ static void must_fail(grpc_exec_ctx* exec_ctx, void* argsp, grpc_error* err) {
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_pollset_kick(exec_ctx, args->pollset, nullptr));
gpr_mu_unlock(args->mu);
}
@@ -124,7 +124,7 @@ static void test_localhost(void) {
args_struct args;
args_init(&exec_ctx, &args);
grpc_resolve_address(
- &exec_ctx, "localhost:1", NULL, args.pollset_set,
+ &exec_ctx, "localhost:1", nullptr, args.pollset_set,
GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
grpc_exec_ctx_flush(&exec_ctx);
@@ -166,7 +166,7 @@ static void test_missing_default_port(void) {
args_struct args;
args_init(&exec_ctx, &args);
grpc_resolve_address(
- &exec_ctx, "localhost", NULL, args.pollset_set,
+ &exec_ctx, "localhost", nullptr, args.pollset_set,
GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
grpc_exec_ctx_flush(&exec_ctx);
@@ -180,7 +180,7 @@ static void test_ipv6_with_port(void) {
args_struct args;
args_init(&exec_ctx, &args);
grpc_resolve_address(
- &exec_ctx, "[2001:db8::1]:1", NULL, args.pollset_set,
+ &exec_ctx, "[2001:db8::1]:1", nullptr, args.pollset_set,
GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
grpc_exec_ctx_flush(&exec_ctx);
@@ -222,7 +222,7 @@ static void test_invalid_ip_addresses(void) {
args_struct args;
args_init(&exec_ctx, &args);
grpc_resolve_address(
- &exec_ctx, kCases[i], NULL, args.pollset_set,
+ &exec_ctx, kCases[i], nullptr, args.pollset_set,
GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
grpc_exec_ctx_flush(&exec_ctx);
diff --git a/test/core/iomgr/resource_quota_test.cc b/test/core/iomgr/resource_quota_test.cc
index 8a2faaed02..6851702e67 100644
--- a/test/core/iomgr/resource_quota_test.cc
+++ b/test/core/iomgr/resource_quota_test.cc
@@ -121,7 +121,7 @@ static void test_instant_alloc_then_free(void) {
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_alloc(&exec_ctx, usr, 1024, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
{
@@ -141,7 +141,7 @@ static void test_instant_alloc_free_pair(void) {
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_alloc(&exec_ctx, usr, 1024, nullptr);
grpc_resource_user_free(&exec_ctx, usr, 1024);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -162,7 +162,7 @@ static void test_simple_async_alloc(void) {
grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
}
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
@@ -186,10 +186,11 @@ static void test_async_alloc_blocked_by_size(void) {
grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
grpc_exec_ctx_finish(&exec_ctx);
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;
@@ -213,7 +214,7 @@ static void test_scavenge(void) {
grpc_resource_user_alloc(&exec_ctx, usr1, 1024, set_event(&ev));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
{
@@ -228,7 +229,7 @@ static void test_scavenge(void) {
grpc_resource_user_alloc(&exec_ctx, usr2, 1024, set_event(&ev));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
{
@@ -254,7 +255,7 @@ static void test_scavenge_blocked(void) {
grpc_resource_user_alloc(&exec_ctx, usr1, 1024, set_event(&ev));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
{
@@ -263,14 +264,14 @@ static void test_scavenge_blocked(void) {
grpc_resource_user_alloc(&exec_ctx, usr2, 1024, set_event(&ev));
grpc_exec_ctx_finish(&exec_ctx);
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);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
{
@@ -296,7 +297,7 @@ static void test_blocked_until_scheduled_reclaim(void) {
grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
gpr_event reclaim_done;
@@ -315,9 +316,9 @@ static void test_blocked_until_scheduled_reclaim(void) {
grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
grpc_exec_ctx_finish(&exec_ctx);
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);
;
}
{
@@ -343,7 +344,7 @@ static void test_blocked_until_scheduled_reclaim_and_scavenge(void) {
grpc_resource_user_alloc(&exec_ctx, usr1, 1024, set_event(&ev));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
gpr_event reclaim_done;
@@ -362,9 +363,9 @@ static void test_blocked_until_scheduled_reclaim_and_scavenge(void) {
grpc_resource_user_alloc(&exec_ctx, usr2, 1024, set_event(&ev));
grpc_exec_ctx_finish(&exec_ctx);
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);
;
}
{
@@ -390,7 +391,7 @@ static void test_blocked_until_scheduled_destructive_reclaim(void) {
grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
gpr_event reclaim_done;
@@ -409,9 +410,9 @@ static void test_blocked_until_scheduled_destructive_reclaim(void) {
grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
grpc_exec_ctx_finish(&exec_ctx);
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);
;
}
{
@@ -443,17 +444,17 @@ static void test_unused_reclaim_is_cancelled(void) {
grpc_exec_ctx_finish(&exec_ctx);
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) {
@@ -473,7 +474,7 @@ static void test_benign_reclaim_is_preferred(void) {
grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
{
@@ -487,10 +488,10 @@ static void test_benign_reclaim_is_preferred(void) {
grpc_exec_ctx_finish(&exec_ctx);
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;
@@ -499,12 +500,12 @@ static void test_benign_reclaim_is_preferred(void) {
grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
grpc_exec_ctx_finish(&exec_ctx);
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;
@@ -514,9 +515,9 @@ static void test_benign_reclaim_is_preferred(void) {
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) {
@@ -536,7 +537,7 @@ static void test_multiple_reclaims_can_be_triggered(void) {
grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
- NULL);
+ nullptr);
;
}
{
@@ -550,10 +551,10 @@ static void test_multiple_reclaims_can_be_triggered(void) {
grpc_exec_ctx_finish(&exec_ctx);
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;
@@ -562,11 +563,11 @@ static void test_multiple_reclaims_can_be_triggered(void) {
grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
grpc_exec_ctx_finish(&exec_ctx);
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);
;
}
{
@@ -577,9 +578,9 @@ static void test_multiple_reclaims_can_be_triggered(void) {
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) {
@@ -591,7 +592,7 @@ static void test_resource_user_stays_allocated_until_memory_released(void) {
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_alloc(&exec_ctx, usr, 1024, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
{
@@ -630,7 +631,7 @@ test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released(
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(gpr_event_wait(&reclaimer_cancelled,
grpc_timeout_milliseconds_to_deadline(100)) ==
- NULL);
+ nullptr);
}
{
gpr_event allocated;
@@ -638,11 +639,11 @@ test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released(
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);
+ 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;
@@ -650,14 +651,15 @@ test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released(
grpc_exec_ctx_finish(&exec_ctx);
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);
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);
@@ -676,7 +678,7 @@ static void test_reclaimers_can_be_posted_repeatedly(void) {
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_timeout_seconds_to_deadline(5)) != nullptr);
}
for (int i = 0; i < 10; i++) {
gpr_event reclaimer_done;
@@ -689,7 +691,7 @@ static void test_reclaimers_can_be_posted_repeatedly(void) {
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(gpr_event_wait(&reclaimer_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
- NULL);
+ nullptr);
}
{
gpr_event allocated;
@@ -697,10 +699,11 @@ static void test_reclaimers_can_be_posted_repeatedly(void) {
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);
+ 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);
}
}
{
diff --git a/test/core/iomgr/sockaddr_utils_test.cc b/test/core/iomgr/sockaddr_utils_test.cc
index 40f2157ba3..a445714851 100644
--- a/test/core/iomgr/sockaddr_utils_test.cc
+++ b/test/core/iomgr/sockaddr_utils_test.cc
@@ -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) {
@@ -176,7 +176,7 @@ static void expect_sockaddr_str(const char* expected,
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);
@@ -188,7 +188,7 @@ static void expect_sockaddr_uri(const char* expected,
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);
}
@@ -238,7 +238,7 @@ static void test_sockaddr_to_string(void) {
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) {
diff --git a/test/core/iomgr/tcp_client_posix_test.cc b/test/core/iomgr/tcp_client_posix_test.cc
index 206fa5de01..9fb1a2d770 100644
--- a/test/core/iomgr/tcp_client_posix_test.cc
+++ b/test/core/iomgr/tcp_client_posix_test.cc
@@ -44,7 +44,7 @@ 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 grpc_millis test_deadline(void) {
return grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10));
@@ -54,26 +54,26 @@ 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)));
+ GPR_ASSERT(GRPC_LOG_IF_ERROR(
+ "pollset_kick", grpc_pollset_kick(&exec_ctx, g_pollset, nullptr)));
grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_unlock(g_mu);
}
static void must_succeed(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) {
- GPR_ASSERT(g_connecting != NULL);
+ 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;
+ g_connecting = nullptr;
finish_connection();
}
static void must_fail(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
- GPR_ASSERT(g_connecting == NULL);
+ GPR_ASSERT(g_connecting == nullptr);
GPR_ASSERT(error != GRPC_ERROR_NONE);
finish_connection();
}
@@ -107,9 +107,9 @@ void test_succeeds(void) {
/* 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, GRPC_MILLIS_INF_FUTURE);
+ GRPC_CLOSURE_INIT(&done, must_succeed, nullptr, grpc_schedule_on_exec_ctx);
+ grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, g_pollset_set,
+ nullptr, &resolved_addr, GRPC_MILLIS_INF_FUTURE);
/* await the connection */
do {
@@ -122,7 +122,7 @@ 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,
@@ -156,15 +156,15 @@ 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, GRPC_MILLIS_INF_FUTURE);
+ GRPC_CLOSURE_INIT(&done, must_fail, nullptr, grpc_schedule_on_exec_ctx);
+ grpc_tcp_client_connect(&exec_ctx, &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;
+ grpc_pollset_worker* worker = nullptr;
grpc_millis polling_deadline = test_deadline();
switch (grpc_timer_check(&exec_ctx, &polling_deadline)) {
case GRPC_TIMERS_FIRED:
diff --git a/test/core/iomgr/tcp_posix_test.cc b/test/core/iomgr/tcp_posix_test.cc
index 51ab0bfc6a..7986dc2b19 100644
--- a/test/core/iomgr/tcp_posix_test.cc
+++ b/test/core/iomgr/tcp_posix_test.cc
@@ -147,8 +147,8 @@ 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(exec_ctx, g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
} else {
grpc_endpoint_read(exec_ctx, state->ep, &state->incoming, &state->read_cb);
@@ -192,7 +192,7 @@ static void read_test(size_t num_bytes, size_t slice_size) {
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, deadline)));
@@ -245,7 +245,7 @@ static void large_read_test(size_t slice_size) {
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, deadline)));
@@ -297,8 +297,8 @@ static void write_done(grpc_exec_ctx* exec_ctx,
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(exec_ctx, g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
@@ -315,7 +315,7 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) {
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",
@@ -386,7 +386,7 @@ static void write_test(size_t num_bytes, size_t slice_size) {
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;
}
@@ -408,8 +408,8 @@ static void write_test(size_t num_bytes, size_t slice_size) {
void on_fd_released(grpc_exec_ctx* exec_ctx, 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(exec_ctx, g_pollset, nullptr)));
}
/* Do a read_test, then release fd and try to read/write again. Verify that
@@ -457,7 +457,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
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, deadline)));
@@ -475,7 +475,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
grpc_exec_ctx_flush(&exec_ctx);
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, deadline)));
diff --git a/test/core/iomgr/tcp_server_posix_test.cc b/test/core/iomgr/tcp_server_posix_test.cc
index 6efa74c706..48d8d425a5 100644
--- a/test/core/iomgr/tcp_server_posix_test.cc
+++ b/test/core/iomgr/tcp_server_posix_test.cc
@@ -78,7 +78,7 @@ 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) {
@@ -95,7 +95,7 @@ static const char* sock_family_name(int family) {
}
static void on_connect_result_init(on_connect_result* result) {
- result->server = NULL;
+ result->server = nullptr;
result->port_index = 0;
result->fd_index = 0;
result->server_fd = -1;
@@ -113,11 +113,11 @@ static void on_connect_result_set(on_connect_result* result,
static void server_weak_ref_shutdown(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) {
server_weak_ref* weak_ref = static_cast<server_weak_ref*>(arg);
- weak_ref->server = NULL;
+ weak_ref->server = nullptr;
}
static void server_weak_ref_init(server_weak_ref* weak_ref) {
- weak_ref->server = NULL;
+ weak_ref->server = nullptr;
GRPC_CLOSURE_INIT(&weak_ref->server_shutdown, server_weak_ref_shutdown,
weak_ref, grpc_schedule_on_exec_ctx);
}
@@ -134,7 +134,7 @@ static void server_weak_ref_set(server_weak_ref* weak_ref,
}
static void test_addr_init_str(test_addr* addr) {
- char* str = NULL;
+ 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)));
@@ -159,8 +159,8 @@ 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(exec_ctx, g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
@@ -168,7 +168,7 @@ 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_create(&exec_ctx, nullptr, nullptr, &s));
grpc_tcp_server_unref(&exec_ctx, s);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -177,9 +177,9 @@ 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_tcp_server_create(&exec_ctx, 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_start(&exec_ctx, s, nullptr, 0, on_connect, nullptr);
grpc_tcp_server_unref(&exec_ctx, s);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -190,7 +190,7 @@ static void test_no_op_with_port(void) {
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));
+ grpc_tcp_server_create(&exec_ctx, nullptr, nullptr, &s));
LOG_TEST("test_no_op_with_port");
memset(&resolved_addr, 0, sizeof(resolved_addr));
@@ -211,7 +211,7 @@ static void test_no_op_with_port_and_start(void) {
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));
+ grpc_tcp_server_create(&exec_ctx, nullptr, nullptr, &s));
LOG_TEST("test_no_op_with_port_and_start");
int port = -1;
@@ -222,7 +222,7 @@ 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(&exec_ctx, s, nullptr, 0, on_connect, nullptr);
grpc_tcp_server_unref(&exec_ctx, s);
grpc_exec_ctx_finish(&exec_ctx);
@@ -255,7 +255,7 @@ static grpc_error* tcp_connect(grpc_exec_ctx* exec_ctx, const test_addr* remote,
gpr_log(GPR_DEBUG, "wait");
while (g_nconnects == nconnects_before &&
deadline > grpc_exec_ctx_now(exec_ctx)) {
- grpc_pollset_worker* worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
grpc_error* err;
if ((err = grpc_pollset_work(exec_ctx, g_pollset, &worker, deadline)) !=
GRPC_ERROR_NONE) {
@@ -307,7 +307,7 @@ static void test_connect(size_t num_connects,
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(&exec_ctx, nullptr, channel_args, &s));
unsigned port_num;
server_weak_ref weak_ref;
server_weak_ref_init(&weak_ref);
@@ -316,8 +316,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 +352,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(&exec_ctx, 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;
@@ -417,14 +417,14 @@ 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);
/* 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,
@@ -440,7 +440,7 @@ int main(int argc, char** argv) {
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 = nullptr;
struct ifaddrs* ifa_it;
// Zalloc dst_addrs to avoid oversized frames.
test_addrs* dst_addrs =
@@ -455,14 +455,14 @@ int main(int argc, char** argv) {
test_no_op_with_port();
test_no_op_with_port_and_start();
- if (getifaddrs(&ifa) != 0 || ifa == NULL) {
+ 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 != NULL && dst_addrs->naddrs < MAX_ADDRS;
+ for (ifa_it = ifa; ifa_it != nullptr && dst_addrs->naddrs < MAX_ADDRS;
ifa_it = ifa_it->ifa_next) {
- if (ifa_it->ifa_addr == NULL) {
+ 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);
@@ -480,15 +480,15 @@ int main(int argc, char** argv) {
++dst_addrs->naddrs;
}
freeifaddrs(ifa);
- ifa = NULL;
+ ifa = nullptr;
/* Connect to same addresses as listeners. */
- test_connect(1, NULL, NULL, false);
- test_connect(10, NULL, NULL, false);
+ test_connect(1, nullptr, nullptr, false);
+ test_connect(10, nullptr, nullptr, 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(1, nullptr, dst_addrs, true);
/* Test connect(2) with dst_addrs. */
test_connect(1, &channel_args, dst_addrs, false);
diff --git a/test/core/iomgr/timer_heap_test.cc b/test/core/iomgr/timer_heap_test.cc
index 20a383371d..f0ab4343cb 100644
--- a/test/core/iomgr/timer_heap_test.cc
+++ b/test/core/iomgr/timer_heap_test.cc
@@ -146,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]];
}
@@ -174,7 +174,7 @@ static void test2(void) {
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) {
+ if (el != nullptr) {
el->elem.deadline = random_deadline();
grpc_timer_heap_add(&pq, &el->elem);
el->inserted = true;
@@ -184,7 +184,7 @@ 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) {
+ if (el != nullptr) {
grpc_timer_heap_remove(&pq, &el->elem);
el->inserted = false;
num_inserted--;
@@ -207,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) {
diff --git a/test/core/iomgr/timer_list_test.cc b/test/core/iomgr/timer_list_test.cc
index 8783c5c6d7..d74ea4fc96 100644
--- a/test/core/iomgr/timer_list_test.cc
+++ b/test/core/iomgr/timer_list_test.cc
@@ -28,11 +28,12 @@
#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 "C" grpc_tracer_flag grpc_timer_trace;
-extern "C" grpc_tracer_flag grpc_timer_check_trace;
+extern grpc_core::TraceFlag grpc_timer_trace;
+extern grpc_core::TraceFlag grpc_timer_check_trace;
static int cb_called[MAX_CB][2];
@@ -48,8 +49,8 @@ static void add_test(void) {
gpr_log(GPR_INFO, "add_test");
grpc_timer_list_init(&exec_ctx);
- grpc_timer_trace.value = 1;
- grpc_timer_check_trace.value = 1;
+ 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_exec_ctx_now(&exec_ctx);
@@ -70,7 +71,7 @@ static void add_test(void) {
/* collect timers. Only the first batch should be ready. */
exec_ctx.now = start + 500;
- GPR_ASSERT(grpc_timer_check(&exec_ctx, NULL) == GRPC_TIMERS_FIRED);
+ GPR_ASSERT(grpc_timer_check(&exec_ctx, nullptr) == GRPC_TIMERS_FIRED);
grpc_exec_ctx_finish(&exec_ctx);
for (i = 0; i < 20; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 10));
@@ -78,7 +79,7 @@ static void add_test(void) {
}
exec_ctx.now = start + 600;
- GPR_ASSERT(grpc_timer_check(&exec_ctx, NULL) ==
+ GPR_ASSERT(grpc_timer_check(&exec_ctx, nullptr) ==
GRPC_TIMERS_CHECKED_AND_EMPTY);
grpc_exec_ctx_finish(&exec_ctx);
for (i = 0; i < 30; i++) {
@@ -88,7 +89,7 @@ static void add_test(void) {
/* collect the rest of the timers */
exec_ctx.now = start + 1500;
- GPR_ASSERT(grpc_timer_check(&exec_ctx, NULL) == GRPC_TIMERS_FIRED);
+ GPR_ASSERT(grpc_timer_check(&exec_ctx, nullptr) == GRPC_TIMERS_FIRED);
grpc_exec_ctx_finish(&exec_ctx);
for (i = 0; i < 30; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 20));
@@ -96,7 +97,7 @@ static void add_test(void) {
}
exec_ctx.now = start + 1600;
- GPR_ASSERT(grpc_timer_check(&exec_ctx, NULL) ==
+ GPR_ASSERT(grpc_timer_check(&exec_ctx, nullptr) ==
GRPC_TIMERS_CHECKED_AND_EMPTY);
for (i = 0; i < 30; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 20));
@@ -117,8 +118,8 @@ void destruction_test(void) {
exec_ctx.now_is_valid = true;
exec_ctx.now = 0;
grpc_timer_list_init(&exec_ctx);
- grpc_timer_trace.value = 1;
- grpc_timer_check_trace.value = 1;
+ 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(
@@ -137,7 +138,7 @@ void destruction_test(void) {
&exec_ctx, &timers[4], 1,
GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)4, grpc_schedule_on_exec_ctx));
exec_ctx.now = 2;
- GPR_ASSERT(grpc_timer_check(&exec_ctx, NULL) == GRPC_TIMERS_FIRED);
+ GPR_ASSERT(grpc_timer_check(&exec_ctx, nullptr) == GRPC_TIMERS_FIRED);
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(1 == cb_called[4][1]);
grpc_timer_cancel(&exec_ctx, &timers[0]);
diff --git a/test/core/iomgr/udp_server_test.cc b/test/core/iomgr/udp_server_test.cc
index 4e8f234a8b..6e17be9cd6 100644
--- a/test/core/iomgr/udp_server_test.cc
+++ b/test/core/iomgr/udp_server_test.cc
@@ -50,7 +50,7 @@ static int g_number_of_writes = 0;
static int g_number_of_bytes_read = 0;
static int g_number_of_orphan_calls = 0;
-static void on_read(grpc_exec_ctx* exec_ctx, grpc_fd* emfd, void* user_data) {
+static bool on_read(grpc_exec_ctx* exec_ctx, grpc_fd* emfd, void* user_data) {
char read_buffer[512];
ssize_t byte_count;
@@ -61,17 +61,19 @@ 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(exec_ctx, 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_exec_ctx* exec_ctx, 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(exec_ctx, g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
@@ -79,6 +81,7 @@ static void on_fd_orphaned(grpc_exec_ctx* exec_ctx, 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(exec_ctx, closure, GRPC_ERROR_NONE);
g_number_of_orphan_calls++;
}
@@ -128,17 +131,17 @@ static test_socket_factory* test_socket_factory_create(void) {
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_udp_server* s = grpc_udp_server_create(nullptr);
+ grpc_udp_server_destroy(&exec_ctx, s, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
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_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_udp_server_start(&exec_ctx, s, nullptr, 0, nullptr);
+ grpc_udp_server_destroy(&exec_ctx, s, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -147,7 +150,7 @@ static void test_no_op_with_port(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_resolved_address resolved_addr;
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
- grpc_udp_server* s = grpc_udp_server_create(NULL);
+ grpc_udp_server* s = grpc_udp_server_create(nullptr);
LOG_TEST("test_no_op_with_port");
memset(&resolved_addr, 0, sizeof(resolved_addr));
@@ -156,7 +159,7 @@ static void test_no_op_with_port(void) {
GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_read, on_write,
on_fd_orphaned));
- grpc_udp_server_destroy(&exec_ctx, s, NULL);
+ grpc_udp_server_destroy(&exec_ctx, s, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
/* The server had a single FD, which should have been orphaned. */
@@ -173,7 +176,7 @@ static void test_no_op_with_port_and_socket_factory(void) {
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_channel_args_copy_and_add(nullptr, &socket_factory_arg, 1);
grpc_udp_server* s = grpc_udp_server_create(channel_args);
grpc_channel_args_destroy(&exec_ctx, channel_args);
@@ -187,7 +190,7 @@ static void test_no_op_with_port_and_socket_factory(void) {
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_udp_server_destroy(&exec_ctx, s, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
grpc_socket_factory_unref(&socket_factory->base);
@@ -200,7 +203,7 @@ static void test_no_op_with_port_and_start(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_resolved_address resolved_addr;
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
- grpc_udp_server* s = grpc_udp_server_create(NULL);
+ 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));
@@ -209,9 +212,9 @@ static void test_no_op_with_port_and_start(void) {
GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_read, on_write,
on_fd_orphaned));
- grpc_udp_server_start(&exec_ctx, s, NULL, 0, NULL);
+ grpc_udp_server_start(&exec_ctx, s, nullptr, 0, nullptr);
- grpc_udp_server_destroy(&exec_ctx, s, NULL);
+ grpc_udp_server_destroy(&exec_ctx, s, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
/* The server had a single FD, which is orphaned exactly once in *
@@ -224,9 +227,8 @@ static void test_receive(int number_of_clients) {
grpc_resolved_address resolved_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;
grpc_millis deadline;
grpc_pollset* pollsets[1];
LOG_TEST("test_receive");
@@ -248,7 +250,7 @@ static void test_receive(int number_of_clients) {
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(&exec_ctx, s, pollsets, 1, nullptr);
gpr_mu_lock(g_mu);
@@ -256,16 +258,16 @@ static void test_receive(int number_of_clients) {
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,
(socklen_t)resolved_addr.len) == 0);
GPR_ASSERT(5 == write(clifd, "hello", 5));
- while (g_number_of_reads == number_of_reads_before &&
+ while (g_number_of_bytes_read < (number_of_bytes_read_before + 5) &&
deadline > grpc_exec_ctx_now(&exec_ctx)) {
- 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, deadline)));
@@ -273,22 +275,18 @@ static void test_receive(int number_of_clients) {
grpc_exec_ctx_flush(&exec_ctx);
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_udp_server_destroy(&exec_ctx, s, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
/* 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);
}
static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
diff --git a/test/core/iomgr/wakeup_fd_cv_test.cc b/test/core/iomgr/wakeup_fd_cv_test.cc
index dc1d77a0ab..d4e05bd7ef 100644
--- a/test/core/iomgr/wakeup_fd_cv_test.cc
+++ b/test/core/iomgr/wakeup_fd_cv_test.cc
@@ -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);
diff --git a/test/core/json/json_rewrite.cc b/test/core/json/json_rewrite.cc
index 98e76e9772..6891a57f9f 100644
--- a/test/core/json/json_rewrite.cc
+++ b/test/core/json/json_rewrite.cc
@@ -205,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;
@@ -232,8 +232,8 @@ int main(int argc, char** argv) {
int indent = 2;
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.cc b/test/core/json/json_rewrite_test.cc
index 47b4f01e8b..3104afc442 100644
--- a/test/core/json/json_rewrite_test.cc
+++ b/test/core/json/json_rewrite_test.cc
@@ -226,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;
diff --git a/test/core/json/json_stream_error_test.cc b/test/core/json/json_stream_error_test.cc
index 975ccd2b42..b367d3fbf7 100644
--- a/test/core/json/json_stream_error_test.cc
+++ b/test/core/json/json_stream_error_test.cc
@@ -37,13 +37,13 @@ static void string_clear(void* userdata) {
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);
diff --git a/test/core/json/json_test.cc b/test/core/json/json_test.cc
index 9e4d351dd7..18b9c55ee7 100644
--- a/test/core/json/json_test.cc
+++ b/test/core/json/json_test.cc
@@ -70,70 +70,70 @@ 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() {
diff --git a/test/core/memory_usage/client.cc b/test/core/memory_usage/client.cc
index 74ec4b0738..eb90067970 100644
--- a/test/core/memory_usage/client.cc
+++ b/test/core/memory_usage/client.cc
@@ -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);
@@ -173,7 +174,7 @@ 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;
}
@@ -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;
@@ -254,7 +255,7 @@ int main(int argc, char** argv) {
cq,
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_micros(10000, GPR_TIMESPAN)),
- NULL);
+ nullptr);
} while (event.type != GRPC_QUEUE_TIMEOUT);
// second step - recv status and destroy call
@@ -274,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);
@@ -320,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/server.cc b/test/core/memory_usage/server.cc
index 04e55db30d..60ebcece3e 100644
--- a/test/core/memory_usage/server.cc
+++ b/test/core/memory_usage/server.cc
@@ -45,8 +45,8 @@ 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; }
@@ -88,7 +88,8 @@ static void send_initial_metadata_unary(void* tag) {
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));
+ metadata_ops, 1, tag,
+ nullptr));
}
static void send_status(void* tag) {
@@ -99,7 +100,8 @@ static void send_status(void* tag) {
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));
+ &status_op, 1, tag,
+ nullptr));
}
static void send_snapshot(void* tag, struct grpc_memory_counters* snapshot) {
@@ -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;
@@ -135,7 +137,7 @@ static void send_snapshot(void* tag, struct grpc_memory_counters* snapshot) {
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_batch((*(fling_call*)tag).call, snapshot_ops,
- (size_t)(op - snapshot_ops), tag, NULL));
+ (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. */
@@ -144,14 +146,14 @@ static void sigint_handler(int x) { _exit(0); }
int main(int argc, char** argv) {
grpc_memory_counters_init();
grpc_event ev;
- char* addr_buf = NULL;
+ char* addr_buf = nullptr;
gpr_cmdline* cl;
grpc_completion_queue* shutdown_cq;
int shutdown_started = 0;
int shutdown_finished = 0;
int secure = 0;
- const char* addr = NULL;
+ const char* addr = nullptr;
char* fake_argv[1];
@@ -168,13 +170,13 @@ 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();
@@ -182,23 +184,23 @@ int main(int argc, char** argv) {
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);
+ 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,12 +219,12 @@ 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;
@@ -231,7 +233,7 @@ int main(int argc, char** argv) {
cq,
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_micros(1000000, GPR_TIMESPAN)),
- NULL);
+ nullptr);
fling_call* s = static_cast<fling_call*>(ev.tag);
switch (ev.type) {
case GRPC_OP_COMPLETE:
@@ -294,8 +296,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/network_benchmarks/low_level_ping_pong.cc b/test/core/network_benchmarks/low_level_ping_pong.cc
index 722652148c..96b0745f52 100644
--- a/test/core/network_benchmarks/low_level_ping_pong.cc
+++ 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;
@@ -275,14 +275,14 @@ static void server_thread_wrap(void* 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) {
@@ -293,7 +293,7 @@ static double now(void) {
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,13 +316,13 @@ 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 */
@@ -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;
@@ -583,7 +583,7 @@ static int run_benchmark(const 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;
}
@@ -626,10 +626,10 @@ int main(int argc, char** argv) {
thread_args* server_args =
static_cast<thread_args*>(gpr_malloc(sizeof(thread_args)));
int msg_size = -1;
- const char* read_strategy = NULL;
- const 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 =
@@ -647,12 +647,12 @@ 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) {
@@ -666,7 +666,7 @@ 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);
return -1;
}
diff --git a/test/core/security/auth_context_test.cc b/test/core/security/auth_context_test.cc
index 3ab9190689..d8e41326c0 100644
--- a/test/core/security/auth_context_test.cc
+++ b/test/core/security/auth_context_test.cc
@@ -25,31 +25,31 @@
#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");
@@ -64,25 +64,25 @@ static void test_simple_context(void) {
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* chained = grpc_auth_context_create(nullptr);
grpc_auth_context* ctx = grpc_auth_context_create(chained);
grpc_auth_property_iterator it;
size_t i;
@@ -108,14 +108,14 @@ static void test_chained_context(void) {
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,7 +124,7 @@ 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");
}
diff --git a/test/core/security/create_jwt.cc b/test/core/security/create_jwt.cc
index 95f3615074..867a8ba575 100644
--- a/test/core/security/create_jwt.cc
+++ b/test/core/security/create_jwt.cc
@@ -42,10 +42,10 @@ void create_jwt(const char* json_key_file_path, const char* service_url,
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");
exit(1);
}
@@ -54,9 +54,9 @@ void create_jwt(const char* json_key_file_path, const char* service_url,
}
int main(int argc, char** argv) {
- const char* scope = NULL;
- const char* json_key_file_path = NULL;
- const char* service_url = NULL;
+ 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_add_string(cl, "json_key", "File path of the json key.",
@@ -70,17 +70,17 @@ 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");
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");
exit(1);
}
- } else if (service_url == NULL) {
+ } else if (service_url == nullptr) {
fprintf(stderr, "Need one of --service_url or --scope options.\n");
exit(1);
}
diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc
index 9b575c4bc5..64d383ad0a 100644
--- a/test/core/security/credentials_test.cc
+++ b/test/core/security/credentials_test.cc
@@ -151,7 +151,7 @@ static void test_empty_md_array(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
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);
@@ -403,9 +403,9 @@ static void test_google_iam_creds(void) {
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
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};
+ nullptr);
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
+ nullptr, nullptr};
run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
grpc_call_credentials_unref(&exec_ctx, creds);
grpc_exec_ctx_finish(&exec_ctx);
@@ -417,9 +417,9 @@ static void test_access_token_creds(void) {
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_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);
@@ -432,7 +432,7 @@ static grpc_security_status check_channel_oauth2_create_security_connector(
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;
}
@@ -441,18 +441,18 @@ static void test_channel_oauth2_composite_creds(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_channel_args* new_args;
grpc_channel_credentials_vtable vtable = {
- NULL, check_channel_oauth2_create_security_connector, NULL};
+ 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_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,
+ &exec_ctx, channel_oauth2_creds, nullptr, nullptr, nullptr,
&new_args) == GRPC_SECURITY_OK);
grpc_channel_credentials_release(channel_oauth2_creds);
grpc_exec_ctx_finish(&exec_ctx);
@@ -468,16 +468,16 @@ static void test_oauth2_google_iam_composite_creds(void) {
test_google_iam_authority_selector}};
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_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(
test_google_iam_authorization_token, test_google_iam_authority_selector,
- NULL);
+ nullptr);
grpc_call_credentials* composite_creds =
grpc_composite_call_credentials_create(oauth2_creds, google_iam_creds,
- NULL);
+ nullptr);
grpc_call_credentials_unref(&exec_ctx, oauth2_creds);
grpc_call_credentials_unref(&exec_ctx, google_iam_creds);
GPR_ASSERT(
@@ -502,7 +502,7 @@ check_channel_oauth2_google_iam_create_security_connector(
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);
@@ -517,27 +517,28 @@ 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_channel_credentials_vtable vtable = {
- NULL, check_channel_oauth2_google_iam_create_security_connector, NULL};
+ 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_access_token_credentials_create("blah", nullptr);
grpc_channel_credentials* channel_oauth2_creds =
grpc_composite_channel_credentials_create(channel_creds, oauth2_creds,
- NULL);
+ nullptr);
grpc_call_credentials* google_iam_creds = grpc_google_iam_credentials_create(
test_google_iam_authorization_token, test_google_iam_authority_selector,
- NULL);
+ 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,
+ &exec_ctx, channel_oauth2_iam_creds, nullptr, nullptr, nullptr,
&new_args) == GRPC_SECURITY_OK);
grpc_channel_credentials_release(channel_oauth2_iam_creds);
@@ -581,7 +582,7 @@ 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, grpc_millis deadline,
grpc_closure* on_done, grpc_httpcli_response* response) {
- GPR_ASSERT("HTTP POST should not be called" == NULL);
+ GPR_ASSERT("HTTP POST should not be called" == nullptr);
return 1;
}
@@ -590,7 +591,7 @@ static int httpcli_get_should_not_be_called(grpc_exec_ctx* exec_ctx,
grpc_millis deadline,
grpc_closure* on_done,
grpc_httpcli_response* response) {
- GPR_ASSERT("HTTP GET should not be called" == NULL);
+ GPR_ASSERT("HTTP GET should not be called" == nullptr);
return 1;
}
@@ -599,9 +600,9 @@ static void test_compute_engine_creds_success(void) {
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_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 =
@@ -620,7 +621,7 @@ static void test_compute_engine_creds_success(void) {
grpc_exec_ctx_flush(&exec_ctx);
grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_httpcli_set_override(NULL, NULL);
+ grpc_httpcli_set_override(nullptr, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -629,24 +630,24 @@ static void test_compute_engine_creds_failure(void) {
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};
+ 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(NULL);
+ 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_httpcli_set_override(nullptr, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
static void validate_refresh_token_http_request(
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",
@@ -689,10 +690,10 @@ static void test_refresh_token_creds_success(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
expected_md emd[] = {
{"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}};
- 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_call_credentials* creds = grpc_google_refresh_token_credentials_create(
- test_refresh_token_str, NULL);
+ test_refresh_token_str, nullptr);
/* First request: http get should be called. */
request_metadata_state* state =
@@ -711,7 +712,7 @@ static void test_refresh_token_creds_success(void) {
grpc_exec_ctx_flush(&exec_ctx);
grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_httpcli_set_override(NULL, NULL);
+ grpc_httpcli_set_override(nullptr, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -720,16 +721,16 @@ static void test_refresh_token_creds_failure(void) {
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};
+ 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, NULL);
+ 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_httpcli_set_override(nullptr, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -737,22 +738,22 @@ static void validate_jwt_encode_and_sign_params(
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()));
}
@@ -769,19 +770,19 @@ static char* encode_and_sign_jwt_failure(const grpc_auth_json_key* json_key,
gpr_timespec token_lifetime,
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;
+ 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);
+ GPR_ASSERT(creds != nullptr);
GPR_ASSERT(strcmp(creds->type, GRPC_CALL_CREDENTIALS_TYPE_JWT) == 0);
return (grpc_service_account_jwt_access_credentials*)creds;
}
@@ -792,7 +793,7 @@ static void test_jwt_creds_lifetime(void) {
// Max lifetime.
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);
@@ -801,7 +802,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);
@@ -810,7 +811,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);
@@ -821,14 +822,14 @@ 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};
+ 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_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 =
@@ -857,27 +858,28 @@ static void test_jwt_creds_success(void) {
grpc_call_credentials_unref(&exec_ctx, creds);
gpr_free(json_key_string);
gpr_free(expected_md_value);
- grpc_jwt_encode_and_sign_set_override(NULL);
+ grpc_jwt_encode_and_sign_set_override(nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
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};
+ 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."), NULL, 0);
+ 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);
gpr_free(json_key_string);
grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_jwt_encode_and_sign_set_override(NULL);
+ grpc_jwt_encode_and_sign_set_override(nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -886,8 +888,8 @@ static void set_google_default_creds_env_var_with_file_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);
+ 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);
@@ -905,7 +907,7 @@ static void test_google_default_creds_auth_key(void) {
gpr_free(json_key);
creds = (grpc_composite_channel_credentials*)
grpc_google_default_credentials_create();
- GPR_ASSERT(creds != NULL);
+ GPR_ASSERT(creds != nullptr);
jwt = (grpc_service_account_jwt_access_credentials*)creds->call_creds;
GPR_ASSERT(
strcmp(jwt->key.client_id,
@@ -925,7 +927,7 @@ static void test_google_default_creds_refresh_token(void) {
"refresh_token_google_default_creds", test_refresh_token_str);
creds = (grpc_composite_channel_credentials*)
grpc_google_default_credentials_create();
- GPR_ASSERT(creds != NULL);
+ 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);
@@ -951,7 +953,7 @@ static int default_creds_gce_detection_httpcli_get_success_override(
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;
@@ -959,8 +961,8 @@ static void test_google_default_creds_gce(void) {
{"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}};
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(
@@ -975,8 +977,8 @@ static void test_google_default_creds_gce(void) {
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);
@@ -994,8 +996,8 @@ static void test_google_default_creds_gce(void) {
/* 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_httpcli_set_override(nullptr, nullptr);
+ grpc_override_well_known_credentials_path_getter(nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -1021,16 +1023,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 {
@@ -1049,8 +1051,8 @@ static int plugin_get_metadata_success(
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;
@@ -1074,8 +1076,8 @@ static int plugin_get_metadata_failure(
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;
*status = GRPC_STATUS_UNAUTHENTICATED;
@@ -1092,8 +1094,8 @@ 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};
+ 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));
@@ -1102,7 +1104,7 @@ static void test_metadata_plugin_success(void) {
plugin.destroy = plugin_destroy;
grpc_call_credentials* creds =
- grpc_metadata_credentials_create_from_plugin(plugin, NULL);
+ 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);
GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE);
@@ -1115,14 +1117,14 @@ 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};
+ 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);
+ GRPC_ERROR_CREATE_FROM_COPIED_STRING(expected_error), nullptr, 0);
gpr_free(expected_error);
plugin.state = &state;
@@ -1130,7 +1132,7 @@ static void test_metadata_plugin_failure(void) {
plugin.destroy = plugin_destroy;
grpc_call_credentials* creds =
- grpc_metadata_credentials_create_from_plugin(plugin, NULL);
+ 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);
GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE);
@@ -1143,12 +1145,12 @@ static void test_get_well_known_google_credentials_file_path(void) {
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 */
@@ -1168,10 +1170,10 @@ static void test_channel_creds_duplicate_without_call_creds(void) {
grpc_channel_credentials_unref(&exec_ctx, dup);
grpc_call_credentials* call_creds =
- grpc_access_token_credentials_create("blah", NULL);
+ grpc_access_token_credentials_create("blah", nullptr);
grpc_channel_credentials* composite_creds =
grpc_composite_channel_credentials_create(channel_creds, call_creds,
- NULL);
+ nullptr);
grpc_call_credentials_unref(&exec_ctx, call_creds);
dup = grpc_channel_credentials_duplicate_without_call_credentials(
composite_creds);
@@ -1234,8 +1236,8 @@ static void test_auth_metadata_context(void) {
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, NULL,
- &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.",
@@ -1248,7 +1250,7 @@ static void test_auth_metadata_context(void) {
test_cases[i].desired_method_name, auth_md_context.method_name);
GPR_ASSERT(false);
}
- GPR_ASSERT(auth_md_context.channel_auth_context == NULL);
+ 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);
diff --git a/test/core/security/fetch_oauth2.cc b/test/core/security/fetch_oauth2.cc
index fa8036e581..cb28a0487c 100644
--- a/test/core/security/fetch_oauth2.cc
+++ b/test/core/security/fetch_oauth2.cc
@@ -38,16 +38,16 @@ static grpc_call_credentials* create_refresh_token_creds(
"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;
- const char* json_refresh_token_file_path = NULL;
- char* token = NULL;
+ 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;
+ 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.",
@@ -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.cc b/test/core/security/json_token_test.cc
index a06e1d05ce..0b6ccd5e37 100644
--- a/test/core/security/json_token_test.cc
+++ b/test/core/security/json_token_test.cc
@@ -78,7 +78,8 @@ 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;
+ 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 = static_cast<char*>(gpr_malloc(result_len + 1));
@@ -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);
}
@@ -230,9 +231,9 @@ static grpc_json* parse_json_part_from_jwt(const char* str, size_t len,
static void check_jwt_header(grpc_json* header) {
grpc_json* ptr;
- grpc_json* alg = NULL;
- grpc_json* typ = NULL;
- grpc_json* kid = NULL;
+ 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,15 +244,15 @@ 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);
@@ -262,12 +263,12 @@ static void check_jwt_claim(grpc_json* claim, const char* expected_audience,
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* 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) {
@@ -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,30 +295,30 @@ 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);
@@ -335,19 +336,20 @@ static void check_jwt_signature(const char* b64_signature, RSA* rsa_key,
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);
+ if (key != nullptr) EVP_PKEY_free(key);
+ if (md_ctx != nullptr) EVP_MD_CTX_destroy(md_ctx);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -360,7 +362,7 @@ static char* service_account_creds_jwt_encode_and_sign(
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) {
@@ -368,15 +370,15 @@ static void service_account_creds_check_jwt_claim(grpc_json* claim) {
}
static void jwt_creds_check_jwt_claim(grpc_json* claim) {
- check_jwt_claim(claim, test_service_url, NULL);
+ 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* 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);
@@ -384,27 +386,27 @@ static void test_jwt_encode_and_sign(
size_t offset = 0;
char* jwt = jwt_encode_and_sign_func(&json_key);
const char* dot = strchr(jwt, '.');
- GPR_ASSERT(dot != NULL);
+ 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 +429,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);
diff --git a/test/core/security/jwt_verifier_test.cc b/test/core/security/jwt_verifier_test.cc
index 6858b36141..df0ebe5607 100644
--- a/test/core/security/jwt_verifier_test.cc
+++ b/test/core/security/jwt_verifier_test.cc
@@ -173,13 +173,13 @@ typedef struct {
static void test_jwt_issuer_email_domain(void) {
const char* d = grpc_jwt_issuer_email_domain("https://foo.com");
- GPR_ASSERT(d == NULL);
+ 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,11 +196,11 @@ 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) {
@@ -208,10 +208,10 @@ static void test_claims_success(void) {
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);
+ GPR_ASSERT(json != nullptr);
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(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);
@@ -231,10 +231,10 @@ static void test_expired_claims_failure(void) {
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);
+ GPR_ASSERT(json != nullptr);
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(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);
@@ -255,7 +255,7 @@ static void test_invalid_claims_failure(void) {
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);
+ GPR_ASSERT(grpc_jwt_claims_from_json(&exec_ctx, json, s) == nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -264,10 +264,10 @@ static void test_bad_audience_claims_failure(void) {
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);
+ GPR_ASSERT(json != nullptr);
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(claims != nullptr);
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://bar.com") ==
GRPC_JWT_VERIFIER_BAD_AUDIENCE);
grpc_jwt_claims_destroy(&exec_ctx, claims);
@@ -279,10 +279,10 @@ static void test_bad_subject_claims_failure(void) {
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);
+ GPR_ASSERT(json != nullptr);
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(claims != nullptr);
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://foo.com") ==
GRPC_JWT_VERIFIER_BAD_SUBJECT);
grpc_jwt_claims_destroy(&exec_ctx, claims);
@@ -326,7 +326,7 @@ 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, grpc_millis deadline,
grpc_closure* on_done, grpc_httpcli_response* response) {
- GPR_ASSERT("HTTP POST should not be called" == NULL);
+ GPR_ASSERT("HTTP POST should not be called" == nullptr);
return 1;
}
@@ -349,7 +349,7 @@ static void on_verification_success(grpc_exec_ctx* exec_ctx, void* user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_OK);
- GPR_ASSERT(claims != NULL);
+ 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);
@@ -357,8 +357,8 @@ static void on_verification_success(grpc_exec_ctx* exec_ctx, void* user_data,
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;
+ 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);
@@ -366,15 +366,15 @@ static void test_jwt_verifier_google_email_issuer_success(void) {
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,
+ GPR_ASSERT(jwt != nullptr);
+ grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
on_verification_success, (void*)expected_user_data);
grpc_jwt_verifier_destroy(&exec_ctx, verifier);
grpc_exec_ctx_finish(&exec_ctx);
gpr_free(jwt);
- grpc_httpcli_set_override(NULL, NULL);
+ grpc_httpcli_set_override(nullptr, nullptr);
}
static int httpcli_get_custom_keys_for_email(
@@ -392,7 +392,7 @@ static int httpcli_get_custom_keys_for_email(
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* 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);
@@ -400,15 +400,15 @@ static void test_jwt_verifier_custom_email_issuer_success(void) {
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,
+ GPR_ASSERT(jwt != nullptr);
+ grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
on_verification_success, (void*)expected_user_data);
grpc_jwt_verifier_destroy(&exec_ctx, verifier);
grpc_exec_ctx_finish(&exec_ctx);
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,
@@ -440,8 +440,8 @@ static int httpcli_get_openid_config(grpc_exec_ctx* exec_ctx,
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;
+ 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);
@@ -449,15 +449,15 @@ static void test_jwt_verifier_url_issuer_success(void) {
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,
+ GPR_ASSERT(jwt != nullptr);
+ grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
on_verification_success, (void*)expected_user_data);
grpc_jwt_verifier_destroy(&exec_ctx, verifier);
grpc_exec_ctx_finish(&exec_ctx);
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,
@@ -465,7 +465,7 @@ static void on_verification_key_retrieval_error(grpc_exec_ctx* exec_ctx,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR);
- GPR_ASSERT(claims == NULL);
+ GPR_ASSERT(claims == nullptr);
GPR_ASSERT(user_data == (void*)expected_user_data);
}
@@ -481,8 +481,8 @@ static int httpcli_get_bad_json(grpc_exec_ctx* exec_ctx,
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;
+ 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);
@@ -490,22 +490,22 @@ static void test_jwt_verifier_url_issuer_bad_config(void) {
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(&exec_ctx, 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);
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;
+ 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);
@@ -513,16 +513,16 @@ static void test_jwt_verifier_bad_json_key(void) {
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(&exec_ctx, 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);
gpr_free(jwt);
- grpc_httpcli_set_override(NULL, NULL);
+ grpc_httpcli_set_override(nullptr, nullptr);
}
static void corrupt_jwt_sig(char* jwt) {
@@ -530,7 +530,7 @@ static void corrupt_jwt_sig(char* jwt) {
char* bad_b64_sig;
uint8_t* sig_bytes;
char* last_dot = strrchr(jwt, '.');
- GPR_ASSERT(last_dot != NULL);
+ GPR_ASSERT(last_dot != nullptr);
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
sig = grpc_base64_decode(&exec_ctx, last_dot + 1, 1);
@@ -551,14 +551,14 @@ static void on_verification_bad_signature(grpc_exec_ctx* exec_ctx,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_BAD_SIGNATURE);
- GPR_ASSERT(claims == NULL);
+ 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;
+ 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);
@@ -566,17 +566,17 @@ static void test_jwt_verifier_bad_signature(void) {
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(&exec_ctx, verifier, nullptr, jwt, expected_audience,
on_verification_bad_signature,
(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_httpcli_set_override(nullptr, nullptr);
}
static int httpcli_get_should_not_be_called(grpc_exec_ctx* exec_ctx,
@@ -592,21 +592,21 @@ static void on_verification_bad_format(grpc_exec_ctx* exec_ctx, void* user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_BAD_FORMAT);
- GPR_ASSERT(claims == NULL);
+ 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_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",
+ grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, "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_httpcli_set_override(nullptr, nullptr);
}
/* find verification key: bad jks, cannot find key in jks */
diff --git a/test/core/security/oauth2_utils.cc b/test/core/security/oauth2_utils.cc
index fda3d96e18..602041eecc 100644
--- a/test/core/security/oauth2_utils.cc
+++ b/test/core/security/oauth2_utils.cc
@@ -42,7 +42,7 @@ typedef struct {
static void on_oauth2_response(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) {
oauth2_request* request = (oauth2_request*)arg;
- char* token = NULL;
+ char* token = nullptr;
grpc_slice token_slice;
if (error != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "Fetching token failed: %s", grpc_error_string(error));
@@ -61,7 +61,7 @@ static void on_oauth2_response(grpc_exec_ctx* exec_ctx, void* arg,
GRPC_LOG_IF_ERROR(
"pollset_kick",
grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&request->pops),
- NULL));
+ nullptr));
gpr_mu_unlock(request->mu);
}
@@ -74,14 +74,14 @@ char* grpc_test_fetch_oauth2_token_with_credentials(
memset(&request, 0, sizeof(request));
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
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_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,
@@ -99,7 +99,7 @@ char* grpc_test_fetch_oauth2_token_with_credentials(
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,
diff --git a/test/core/security/print_google_default_creds_token.cc b/test/core/security/print_google_default_creds_token.cc
index a57180b57d..f4acf023bd 100644
--- a/test/core/security/print_google_default_creds_token.cc
+++ b/test/core/security/print_google_default_creds_token.cc
@@ -58,7 +58,7 @@ static void on_metadata_response(grpc_exec_ctx* exec_ctx, void* arg,
GRPC_LOG_IF_ERROR(
"pollset_kick",
grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&sync->pops),
- NULL));
+ nullptr));
gpr_mu_unlock(sync->mu);
}
@@ -66,7 +66,7 @@ int main(int argc, char** argv) {
int result = 0;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
synchronizer sync;
- grpc_channel_credentials* creds = NULL;
+ 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");
@@ -81,7 +81,7 @@ 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");
result = 1;
goto end;
@@ -107,7 +107,7 @@ int main(int argc, char** argv) {
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,
diff --git a/test/core/security/secure_endpoint_test.cc b/test/core/security/secure_endpoint_test.cc
index 11d1e5fcf4..a12af02479 100644
--- a/test/core/security/secure_endpoint_test.cc
+++ b/test/core/security/secure_endpoint_test.cc
@@ -40,15 +40,17 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
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_create_fake_frame_protector(nullptr);
tsi_frame_protector* fake_write_protector =
- tsi_create_fake_frame_protector(NULL);
+ 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(NULL)
- : NULL;
+ 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(NULL)
- : NULL;
+ use_zero_copy_protector
+ ? tsi_create_fake_zero_copy_grpc_protector(nullptr)
+ : nullptr;
grpc_endpoint_test_fixture f;
grpc_endpoint_pair tcp;
@@ -64,7 +66,7 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
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;
@@ -114,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);
+ tcp.server, nullptr, 0);
grpc_exec_ctx_finish(&exec_ctx);
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);
}
diff --git a/test/core/security/security_connector_test.cc b/test/core/security/security_connector_test.cc
index a0c1e93532..9a68e176db 100644
--- a/test/core/security/security_connector_test.cc
+++ b/test/core/security/security_connector_test.cc
@@ -39,13 +39,13 @@ 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;
+ 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;
}
@@ -89,7 +89,7 @@ static void test_unauthenticated_ssl_peer(void) {
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));
@@ -112,7 +112,7 @@ static int check_identity(const grpc_auth_context* 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;
@@ -136,7 +136,7 @@ static int check_x509_cn(const grpc_auth_context* ctx,
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) {
+ if (prop == nullptr) {
gpr_log(GPR_ERROR, "CN property not found.");
return 0;
}
@@ -144,7 +144,7 @@ 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;
}
@@ -156,7 +156,7 @@ static int check_x509_pem_cert(const grpc_auth_context* ctx,
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) {
+ 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;
}
@@ -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));
@@ -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));
@@ -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)));
@@ -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)));
diff --git a/test/core/security/ssl_credentials_test.cc b/test/core/security/ssl_credentials_test.cc
index 76ee32b001..9edcf42d3a 100644
--- a/test/core/security/ssl_credentials_test.cc
+++ b/test/core/security/ssl_credentials_test.cc
@@ -36,14 +36,14 @@ static void test_convert_grpc_to_tsi_cert_pairs() {
{
tsi_ssl_pem_key_cert_pair* tsi_pairs =
grpc_convert_grpc_to_tsi_cert_pairs(grpc_pairs, 0);
- GPR_ASSERT(tsi_pairs == NULL);
+ 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 != NULL);
+ 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);
diff --git a/test/core/security/ssl_server_fuzzer.cc b/test/core/security/ssl_server_fuzzer.cc
index 5c5153b505..d83ebb18d2 100644
--- a/test/core/security/ssl_server_fuzzer.cc
+++ b/test/core/security/ssl_server_fuzzer.cc
@@ -78,10 +78,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
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);
+ ca_cert, &pem_key_cert_pair, 1, 0, nullptr);
// Create security connector
- grpc_server_security_connector* sc = NULL;
+ grpc_server_security_connector* sc = nullptr;
grpc_security_status status =
grpc_server_credentials_create_security_connector(&exec_ctx, creds, &sc);
GPR_ASSERT(status == GRPC_SECURITY_OK);
@@ -92,8 +92,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
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);
+ &exec_ctx, handshake_mgr, nullptr /* interested_parties */, mock_endpoint,
+ nullptr /* channel_args */, deadline, nullptr /* 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
diff --git a/test/core/security/verify_jwt.cc b/test/core/security/verify_jwt.cc
index e0e22d16f9..787d58bc37 100644
--- a/test/core/security/verify_jwt.cc
+++ b/test/core/security/verify_jwt.cc
@@ -52,14 +52,14 @@ static void on_jwt_verification_done(grpc_exec_ctx* exec_ctx, void* user_data,
sync->success = (status == GRPC_JWT_VERIFIER_OK);
if (sync->success) {
char* claims_str;
- GPR_ASSERT(claims != NULL);
+ GPR_ASSERT(claims != nullptr);
claims_str =
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);
} else {
- GPR_ASSERT(claims == NULL);
+ GPR_ASSERT(claims == nullptr);
fprintf(stderr, "Verification failed with error %s\n",
grpc_jwt_verifier_status_to_string(status));
}
@@ -67,7 +67,7 @@ static void on_jwt_verification_done(grpc_exec_ctx* exec_ctx, void* user_data,
gpr_mu_lock(sync->mu);
sync->is_done = 1;
GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, sync->pollset, NULL));
+ grpc_pollset_kick(exec_ctx, sync->pollset, nullptr));
gpr_mu_unlock(sync->mu);
}
@@ -75,8 +75,8 @@ int main(int argc, char** argv) {
synchronizer sync;
grpc_jwt_verifier* verifier;
gpr_cmdline* cl;
- const char* jwt = NULL;
- const char* aud = NULL;
+ const char* jwt = nullptr;
+ const char* aud = nullptr;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_init();
@@ -84,11 +84,11 @@ int main(int argc, char** argv) {
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();
@@ -101,7 +101,7 @@ int main(int argc, char** argv) {
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,
GRPC_MILLIS_INF_FUTURE)))
diff --git a/test/core/slice/slice_hash_table_test.cc b/test/core/slice/slice_hash_table_test.cc
index a2006b3c10..0ee4e8617d 100644
--- a/test/core/slice/slice_hash_table_test.cc
+++ b/test/core/slice/slice_hash_table_test.cc
@@ -46,7 +46,7 @@ static void check_values(const test_entry* input, size_t num_entries,
grpc_slice key = grpc_slice_from_static_string(input[i].key);
const char* actual =
static_cast<const char*>(grpc_slice_hash_table_get(table, key));
- GPR_ASSERT(actual != NULL);
+ GPR_ASSERT(actual != nullptr);
GPR_ASSERT(strcmp(actual, input[i].value) == 0);
grpc_slice_unref(key);
}
@@ -55,7 +55,7 @@ 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);
}
@@ -116,7 +116,7 @@ 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);
diff --git a/test/core/slice/slice_test.cc b/test/core/slice/slice_test.cc
index aec5636376..02f6b1ea79 100644
--- a/test/core/slice/slice_test.cc
+++ b/test/core/slice/slice_test.cc
@@ -50,10 +50,10 @@ static void test_slice_malloc_returns_something_sensible(void) {
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++) {
diff --git a/test/core/statistics/census_log_tests.cc b/test/core/statistics/census_log_tests.cc
deleted file mode 100644
index e6eda5486c..0000000000
--- a/test/core/statistics/census_log_tests.cc
+++ /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 <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 "src/core/ext/census/census_log.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/hash_table_test.cc b/test/core/statistics/hash_table_test.cc
deleted file mode 100644
index b660006b8a..0000000000
--- a/test/core/statistics/hash_table_test.cc
+++ /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 = static_cast<uint64_t*>(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 = static_cast<char*>(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 = static_cast<char*>(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 = static_cast<char*>(gpr_malloc(10));
- strcpy(val2, "v2");
- census_ht_insert(ht, key, val2);
- GPR_ASSERT(census_ht_get_size(ht) == 1);
- val2 = static_cast<char*>(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 = static_cast<int*>(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 = static_cast<int*>(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 = static_cast<int*>(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 = static_cast<int*>(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/trace_test.cc b/test/core/statistics/trace_test.cc
deleted file mode 100644
index ecbfed09ee..0000000000
--- a/test/core/statistics/trace_test.cc
+++ /dev/null
@@ -1,239 +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 "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.cc b/test/core/statistics/window_stats_test.cc
deleted file mode 100644
index b17c61a47b..0000000000
--- a/test/core/statistics/window_stats_test.cc
+++ /dev/null
@@ -1,304 +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, GPR_CLOCK_MONOTONIC};
-const gpr_timespec kSecInterval = {1, 0, GPR_CLOCK_MONOTONIC};
-const gpr_timespec kMinInterval = {60, 0 GPR_CLOCK_MONOTONIC};
-const gpr_timespec kHourInterval = {3600, 0, GPR_CLOCK_MONOTONIC};
-const gpr_timespec kPrimeInterval = {0, 101, GPR_CLOCK_MONOTONIC};
-
-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, GPR_CLOCK_MONOTONIC};
- 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, GPR_CLOCK_MONOTONIC};
- 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, GPR_CLOCK_MONOTONIC}; /* 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, GPR_CLOCK_MONOTONIC};
- census_window_stats_sums result;
- test_stat sum;
- int i;
- gpr_timespec increment = {0, 0, GPR_CLOCK_MONOTONIC};
- 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, GPR_CLOCK_MONOTONIC};
- census_window_stats_sums result;
- test_stat sum;
- int i;
- const int count = 100000;
- gpr_timespec increment = {0, 0, GPR_CLOCK_MONOTONIC};
- gpr_timespec temp = gpr_inf_future(GPR_CLOCK_REALTIME);
- 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/BUILD b/test/core/support/BUILD
index 9d042fdc9f..4372b49b54 100644
--- a/test/core/support/BUILD
+++ b/test/core/support/BUILD
@@ -69,16 +69,6 @@ grpc_cc_test(
)
grpc_cc_test(
- name = "histogram_test",
- srcs = ["histogram_test.cc"],
- language = "C++",
- deps = [
- "//:gpr",
- "//test/core/util:gpr_test_util",
- ],
-)
-
-grpc_cc_test(
name = "host_port_test",
srcs = ["host_port_test.cc"],
language = "C++",
@@ -119,8 +109,8 @@ grpc_cc_test(
)
grpc_cc_test(
- name = "stack_lockfree_test",
- srcs = ["stack_lockfree_test.cc"],
+ name = "string_test",
+ srcs = ["string_test.cc"],
language = "C++",
deps = [
"//:gpr",
@@ -129,8 +119,8 @@ grpc_cc_test(
)
grpc_cc_test(
- name = "string_test",
- srcs = ["string_test.cc"],
+ name = "manual_constructor_test",
+ srcs = ["manual_constructor_test.cc"],
language = "C++",
deps = [
"//:gpr",
@@ -201,24 +191,51 @@ grpc_cc_test(
grpc_cc_test(
name = "memory_test",
srcs = ["memory_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
language = "C++",
deps = [
"//:grpc",
"//test/core/util:gpr_test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(
name = "vector_test",
srcs = ["vector_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
language = "C++",
deps = [
"//:grpc",
"//test/core/util:gpr_test_util",
],
+)
+
+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/support/alloc_test.cc b/test/core/support/alloc_test.cc
index ee590366b9..6074c6e6e7 100644
--- a/test/core/support/alloc_test.cc
+++ b/test/core/support/alloc_test.cc
@@ -30,11 +30,12 @@ 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};
+ 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)0xcafed00d == gpr_realloc(nullptr, 0xcafed00d));
gpr_free(&addr_to_free);
GPR_ASSERT(addr_to_free == (intptr_t)0xdeadd00d);
diff --git a/test/core/support/arena_test.cc b/test/core/support/arena_test.cc
index 6c666af096..ada0f43854 100644
--- a/test/core/support/arena_test.cc
+++ b/test/core/support/arena_test.cc
@@ -44,7 +44,7 @@ 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);
@@ -100,7 +100,8 @@ 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);
diff --git a/test/core/support/avl_test.cc b/test/core/support/avl_test.cc
index cd3a852e9d..345db557b9 100644
--- a/test/core/support/avl_test.cc
+++ b/test/core/support/avl_test.cc
@@ -45,19 +45,19 @@ static const gpr_avl_vtable int_int_vtable = {destroy, int_copy, int_compare,
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_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, NULL) == NULL);
+ 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, NULL);
+ avl = gpr_avl_remove(avl, k, nullptr);
gpr_free(k);
return avl;
}
@@ -66,94 +66,94 @@ 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);
+ 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, NULL);
+ 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), 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(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, NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(3), box(2), NULL);
- avl = gpr_avl_add(avl, box(4), box(3), NULL);
+ 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, NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(4), box(2), NULL);
- avl = gpr_avl_add(avl, box(5), box(3), NULL);
+ 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, NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(5), box(2), NULL);
- avl = gpr_avl_add(avl, box(4), box(3), NULL);
+ 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, NULL);
+ 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), 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);
+ 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, NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(1), box(2), NULL);
+ 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, NULL);
+ gpr_avl_unref(avl, nullptr);
}
static void test_remove(void) {
@@ -161,36 +161,36 @@ static void test_remove(void) {
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);
+ 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, 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);
+ 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, NULL);
+ gpr_avl_unref(avl, nullptr);
check_negget(avl3, 3);
check_get(avl3, 4, 2);
check_get(avl3, 5, 3);
- gpr_avl_unref(avl3, NULL);
+ gpr_avl_unref(avl3, nullptr);
check_get(avl4, 3, 1);
check_negget(avl4, 4);
check_get(avl4, 5, 3);
- gpr_avl_unref(avl4, NULL);
+ gpr_avl_unref(avl4, nullptr);
check_get(avl5, 3, 1);
check_get(avl5, 4, 2);
check_negget(avl5, 5);
- gpr_avl_unref(avl5, NULL);
+ gpr_avl_unref(avl5, nullptr);
check_get(avln, 3, 1);
check_get(avln, 4, 2);
check_get(avln, 5, 3);
- gpr_avl_unref(avln, NULL);
+ gpr_avl_unref(avln, nullptr);
}
static void test_badcase1(void) {
@@ -199,44 +199,44 @@ static void test_badcase1(void) {
gpr_log(GPR_DEBUG, "test_badcase1");
avl = gpr_avl_create(&int_int_vtable);
- avl = gpr_avl_add(avl, box(88), box(1), NULL);
+ 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), 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 = 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(806), box(16), NULL);
- avl = gpr_avl_add(avl, box(827), box(17), NULL);
+ 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), 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 = 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), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(184), box(32), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(827), box(34), nullptr);
check_get(avl, 830, 25);
- gpr_avl_unref(avl, NULL);
+ gpr_avl_unref(avl, nullptr);
}
static void test_badcase2(void) {
@@ -245,254 +245,254 @@ static void test_badcase2(void) {
gpr_log(GPR_DEBUG, "test_badcase2");
avl = gpr_avl_create(&int_int_vtable);
- avl = gpr_avl_add(avl, box(288), box(1), NULL);
+ avl = gpr_avl_add(avl, box(288), box(1), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(242), box(11), NULL);
- avl = gpr_avl_add(avl, box(142), box(12), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(622), box(18), NULL);
+ 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), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(572), box(29), nullptr);
avl = remove_int(avl, 817);
- avl = gpr_avl_add(avl, box(970), box(31), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(670), box(35), NULL);
- avl = gpr_avl_add(avl, box(69), box(36), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(141), box(39), nullptr);
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 = 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), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(458), box(51), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(871), box(60), nullptr);
avl = remove_int(avl, 641);
- avl = gpr_avl_add(avl, box(462), box(62), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(2), box(69), nullptr);
avl = remove_int(avl, 138);
- avl = gpr_avl_add(avl, box(669), box(71), NULL);
+ avl = gpr_avl_add(avl, box(669), box(71), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(141), box(78), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(40), box(81), nullptr);
avl = remove_int(avl, 689);
- avl = gpr_avl_add(avl, box(823), box(83), NULL);
+ avl = gpr_avl_add(avl, box(823), box(83), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(56), box(88), nullptr);
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 = 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), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(576), box(102), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(276), box(105), nullptr);
avl = remove_int(avl, 856);
- avl = gpr_avl_add(avl, box(750), box(107), NULL);
+ avl = gpr_avl_add(avl, box(750), box(107), nullptr);
avl = remove_int(avl, 871);
- avl = gpr_avl_add(avl, box(301), box(109), NULL);
+ 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(271), box(119), NULL);
+ 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(352), box(127), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(3), box(131), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(864), box(135), NULL);
- avl = gpr_avl_add(avl, box(863), box(136), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(440), box(138), nullptr);
avl = remove_int(avl, 516);
- avl = gpr_avl_add(avl, box(116), box(140), NULL);
+ avl = gpr_avl_add(avl, box(116), box(140), nullptr);
avl = remove_int(avl, 380);
- avl = gpr_avl_add(avl, box(878), box(142), NULL);
+ avl = gpr_avl_add(avl, box(878), box(142), nullptr);
avl = remove_int(avl, 439);
- avl = gpr_avl_add(avl, box(994), box(144), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(696), box(147), nullptr);
avl = remove_int(avl, 8);
- avl = gpr_avl_add(avl, box(881), box(149), NULL);
+ 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), 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 = 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(783), box(160), nullptr);
avl = remove_int(avl, 21);
- avl = gpr_avl_add(avl, box(866), box(162), NULL);
+ avl = gpr_avl_add(avl, box(866), box(162), nullptr);
avl = remove_int(avl, 919);
- avl = gpr_avl_add(avl, box(435), box(164), NULL);
+ avl = gpr_avl_add(avl, box(435), box(164), nullptr);
avl = remove_int(avl, 385);
- avl = gpr_avl_add(avl, box(475), box(166), NULL);
+ avl = gpr_avl_add(avl, box(475), box(166), nullptr);
avl = remove_int(avl, 339);
- avl = gpr_avl_add(avl, box(615), box(168), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(852), box(173), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(672), box(176), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(353), box(182), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(991), box(184), nullptr);
avl = remove_int(avl, 330);
- avl = gpr_avl_add(avl, box(873), box(186), NULL);
+ avl = gpr_avl_add(avl, box(873), box(186), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(683), box(193), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(411), box(197), NULL);
- avl = gpr_avl_add(avl, box(697), box(198), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(213), box(200), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(104), box(208), nullptr);
avl = remove_int(avl, 842);
- avl = gpr_avl_add(avl, box(48), box(210), NULL);
+ avl = gpr_avl_add(avl, box(48), box(210), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(789), box(218), nullptr);
avl = remove_int(avl, 924);
- avl = gpr_avl_add(avl, box(53), box(220), NULL);
+ avl = gpr_avl_add(avl, box(53), box(220), nullptr);
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 = 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), NULL);
+ 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), 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 = 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), 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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(894), box(240), nullptr);
avl = remove_int(avl, 749);
- avl = gpr_avl_add(avl, box(71), box(242), NULL);
+ avl = gpr_avl_add(avl, box(71), box(242), nullptr);
avl = remove_int(avl, 68);
- avl = gpr_avl_add(avl, box(388), box(244), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(993), box(248), NULL);
+ 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);
@@ -501,37 +501,37 @@ static void test_badcase2(void) {
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(388), box(260), nullptr);
avl = remove_int(avl, 987);
- avl = gpr_avl_add(avl, box(336), box(262), NULL);
+ avl = gpr_avl_add(avl, box(336), box(262), nullptr);
avl = remove_int(avl, 855);
- avl = gpr_avl_add(avl, box(668), box(264), NULL);
+ avl = gpr_avl_add(avl, box(668), box(264), nullptr);
avl = remove_int(avl, 648);
- avl = gpr_avl_add(avl, box(193), box(266), NULL);
+ avl = gpr_avl_add(avl, box(193), box(266), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(502), box(274), NULL);
- avl = gpr_avl_add(avl, box(846), box(275), NULL);
+ 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), 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 = 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), 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 = 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);
@@ -539,524 +539,524 @@ static void test_badcase2(void) {
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 = gpr_avl_add(avl, box(876), box(295), nullptr);
avl = remove_int(avl, 354);
- avl = gpr_avl_add(avl, box(134), box(297), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(699), box(307), NULL);
+ 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), 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 = 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(421), box(323), nullptr);
avl = remove_int(avl, 514);
- avl = gpr_avl_add(avl, box(701), box(325), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(543), box(330), NULL);
- avl = gpr_avl_add(avl, box(147), box(331), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(514), box(338), nullptr);
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 = 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(802), box(347), NULL);
+ 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), 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 = 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), 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 = 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(316), box(365), nullptr);
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 = 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), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(655), box(381), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(191), box(385), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(234), box(392), nullptr);
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 = 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(388), box(402), NULL);
+ 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), 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 = 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), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(597), box(419), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(736), box(421), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(788), box(429), NULL);
- avl = gpr_avl_add(avl, box(224), box(430), NULL);
+ 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), 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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(340), box(437), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(323), box(444), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(525), box(447), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(340), box(450), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(667), box(454), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(711), box(457), nullptr);
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 = 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(968), box(466), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(675), box(472), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(380), box(474), nullptr);
avl = remove_int(avl, 825);
- avl = gpr_avl_add(avl, box(668), box(476), NULL);
+ avl = gpr_avl_add(avl, box(668), box(476), nullptr);
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 = 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), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(524), box(496), NULL);
+ 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), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(663), box(506), nullptr);
avl = remove_int(avl, 882);
- avl = gpr_avl_add(avl, box(745), box(508), NULL);
+ avl = gpr_avl_add(avl, box(745), box(508), nullptr);
avl = remove_int(avl, 352);
- avl = gpr_avl_add(avl, box(10), box(510), NULL);
+ avl = gpr_avl_add(avl, box(10), box(510), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(952), box(518), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(77), box(524), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(410), box(532), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(906), box(535), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(867), box(541), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(947), box(544), nullptr);
avl = remove_int(avl, 990);
- avl = gpr_avl_add(avl, box(816), box(546), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(786), box(552), NULL);
- avl = gpr_avl_add(avl, box(526), box(553), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(749), box(559), NULL);
- avl = gpr_avl_add(avl, box(194), box(560), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(102), box(562), nullptr);
avl = remove_int(avl, 189);
- avl = gpr_avl_add(avl, box(927), box(564), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(694), box(567), nullptr);
avl = remove_int(avl, 750);
- avl = gpr_avl_add(avl, box(357), box(569), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(640), box(572), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(158), box(580), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(180), box(583), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(679), box(590), NULL);
+ 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), 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 = 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), 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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(275), box(608), nullptr);
avl = remove_int(avl, 32);
- avl = gpr_avl_add(avl, box(939), box(610), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(40), box(618), nullptr);
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 = 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), NULL);
+ 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), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(6), box(642), NULL);
- avl = gpr_avl_add(avl, box(680), box(643), NULL);
+ 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), NULL);
+ 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), 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 = 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), 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 = 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), 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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(974), box(668), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(589), box(674), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(25), box(685), NULL);
+ 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), NULL);
+ 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(509), box(700), NULL);
- avl = gpr_avl_add(avl, box(973), box(701), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(532), box(703), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(163), box(710), NULL);
- avl = gpr_avl_add(avl, box(502), box(711), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(697), box(713), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(751), box(719), NULL);
- avl = gpr_avl_add(avl, box(478), box(720), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(927), box(723), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(133), box(731), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(729), box(734), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(505), box(737), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(1002), box(740), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(348), box(747), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(923), box(751), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(179), box(755), NULL);
+ 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(319), box(766), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(302), box(773), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(538), box(780), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(155), box(785), nullptr);
avl = remove_int(avl, 889);
- avl = gpr_avl_add(avl, box(653), box(787), NULL);
+ avl = gpr_avl_add(avl, box(653), box(787), nullptr);
avl = remove_int(avl, 386);
- avl = gpr_avl_add(avl, box(142), box(789), NULL);
+ 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), 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 = 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), NULL);
+ 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), 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 = 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), NULL);
+ 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);
@@ -1065,72 +1065,72 @@ static void test_badcase2(void) {
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(232), box(829), NULL);
+ 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(907), box(839), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(689), box(847), NULL);
+ 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), 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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(135), box(855), nullptr);
avl = remove_int(avl, 529);
- avl = gpr_avl_add(avl, box(366), box(857), NULL);
+ avl = gpr_avl_add(avl, box(366), box(857), nullptr);
avl = remove_int(avl, 272);
- avl = gpr_avl_add(avl, box(921), box(859), NULL);
+ avl = gpr_avl_add(avl, box(921), box(859), nullptr);
avl = remove_int(avl, 497);
- avl = gpr_avl_add(avl, box(712), box(861), NULL);
+ 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), 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 = 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(984), box(880), NULL);
- avl = gpr_avl_add(avl, box(830), box(881), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(672), box(883), nullptr);
avl = remove_int(avl, 968);
- gpr_avl_unref(avl, NULL);
+ gpr_avl_unref(avl, nullptr);
}
static void test_badcase3(void) {
@@ -1140,191 +1140,191 @@ static void test_badcase3(void) {
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(540), box(6), nullptr);
avl = remove_int(avl, 1008);
- avl = gpr_avl_add(avl, box(502), box(8), NULL);
+ 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), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(441), box(21), NULL);
- avl = gpr_avl_add(avl, box(719), box(22), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(458), box(24), nullptr);
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 = 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), 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 = 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), 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 = 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(805), box(47), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(447), box(54), nullptr);
avl = remove_int(avl, 718);
- avl = gpr_avl_add(avl, box(724), box(56), NULL);
+ avl = gpr_avl_add(avl, box(724), box(56), nullptr);
avl = remove_int(avl, 215);
- avl = gpr_avl_add(avl, box(550), box(58), NULL);
+ avl = gpr_avl_add(avl, box(550), box(58), nullptr);
avl = remove_int(avl, 932);
- avl = gpr_avl_add(avl, box(47), box(60), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(387), box(64), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(991), box(71), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(727), box(77), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(203), box(80), nullptr);
avl = remove_int(avl, 231);
- avl = gpr_avl_add(avl, box(461), box(82), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(184), box(85), nullptr);
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 = 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), NULL);
+ 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(793), box(103), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(483), box(111), NULL);
- avl = gpr_avl_add(avl, box(84), box(112), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(920), box(115), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(526), box(118), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(918), box(121), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(742), box(124), NULL);
- avl = gpr_avl_add(avl, box(718), box(125), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(976), box(130), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(205), box(135), NULL);
- avl = gpr_avl_add(avl, box(584), box(136), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(333), box(143), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(837), box(146), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(116), box(154), NULL);
- avl = gpr_avl_add(avl, box(446), box(155), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(434), box(164), NULL);
- avl = gpr_avl_add(avl, box(277), box(165), NULL);
+ 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), 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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(237), box(172), nullptr);
avl = remove_int(avl, 327);
- avl = gpr_avl_add(avl, box(499), box(174), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(442), box(181), nullptr);
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 = 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);
@@ -1334,125 +1334,125 @@ static void test_badcase3(void) {
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(72), box(199), nullptr);
avl = remove_int(avl, 629);
- avl = gpr_avl_add(avl, box(522), box(201), NULL);
+ avl = gpr_avl_add(avl, box(522), box(201), nullptr);
avl = remove_int(avl, 679);
- avl = gpr_avl_add(avl, box(407), box(203), NULL);
+ avl = gpr_avl_add(avl, box(407), box(203), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(616), box(210), NULL);
- avl = gpr_avl_add(avl, box(690), box(211), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(697), box(214), nullptr);
avl = remove_int(avl, 779);
- avl = gpr_avl_add(avl, box(241), box(216), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(800), box(222), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(125), box(231), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(914), box(234), NULL);
- avl = gpr_avl_add(avl, box(197), box(235), NULL);
+ 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), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(769), box(245), NULL);
- avl = gpr_avl_add(avl, box(631), box(246), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(31), box(249), NULL);
+ 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(220), box(258), NULL);
- avl = gpr_avl_add(avl, box(373), box(259), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(906), box(267), nullptr);
avl = remove_int(avl, 711);
- avl = gpr_avl_add(avl, box(632), box(269), NULL);
+ avl = gpr_avl_add(avl, box(632), box(269), nullptr);
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 = 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(606), box(281), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(758), box(284), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(845), box(290), nullptr);
avl = remove_int(avl, 160);
- avl = gpr_avl_add(avl, box(690), box(292), NULL);
+ avl = gpr_avl_add(avl, box(690), box(292), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(113), box(299), nullptr);
avl = remove_int(avl, 305);
- avl = gpr_avl_add(avl, box(10), box(301), NULL);
+ 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), 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 = 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), NULL);
+ 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);
@@ -1460,372 +1460,372 @@ static void test_badcase3(void) {
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(449), box(327), nullptr);
avl = remove_int(avl, 821);
- avl = gpr_avl_add(avl, box(845), box(329), NULL);
+ avl = gpr_avl_add(avl, box(845), box(329), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(729), box(337), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(164), box(342), NULL);
- avl = gpr_avl_add(avl, box(1), box(343), NULL);
+ 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), 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 = 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), 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 = 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(113), box(365), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(121), box(368), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(916), box(372), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(463), box(379), NULL);
- avl = gpr_avl_add(avl, box(472), box(380), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(840), box(382), nullptr);
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 = 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), NULL);
+ 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(705), box(397), NULL);
- avl = gpr_avl_add(avl, box(94), box(398), NULL);
+ 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), 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 = 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(599), box(409), nullptr);
avl = remove_int(avl, 413);
- avl = gpr_avl_add(avl, box(867), box(411), NULL);
+ avl = gpr_avl_add(avl, box(867), box(411), nullptr);
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 = 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(326), box(421), nullptr);
avl = remove_int(avl, 848);
- avl = gpr_avl_add(avl, box(235), box(423), NULL);
+ avl = gpr_avl_add(avl, box(235), box(423), nullptr);
avl = remove_int(avl, 617);
- avl = gpr_avl_add(avl, box(565), box(425), NULL);
+ avl = gpr_avl_add(avl, box(565), box(425), nullptr);
avl = remove_int(avl, 469);
- avl = gpr_avl_add(avl, box(988), box(427), NULL);
+ avl = gpr_avl_add(avl, box(988), box(427), nullptr);
avl = remove_int(avl, 957);
- avl = gpr_avl_add(avl, box(426), box(429), NULL);
+ avl = gpr_avl_add(avl, box(426), box(429), nullptr);
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 = 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(728), box(443), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(239), box(446), NULL);
+ 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), 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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(856), box(454), nullptr);
avl = remove_int(avl, 332);
- avl = gpr_avl_add(avl, box(679), box(456), NULL);
+ avl = gpr_avl_add(avl, box(679), box(456), nullptr);
avl = remove_int(avl, 18);
- avl = gpr_avl_add(avl, box(837), box(458), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(75), box(465), nullptr);
avl = remove_int(avl, 41);
- avl = gpr_avl_add(avl, box(310), box(467), NULL);
+ avl = gpr_avl_add(avl, box(310), box(467), nullptr);
avl = remove_int(avl, 855);
- avl = gpr_avl_add(avl, box(20), box(469), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(96), box(475), NULL);
+ 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), 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 = 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(837), box(490), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(1005), box(492), nullptr);
avl = remove_int(avl, 21);
- avl = gpr_avl_add(avl, box(396), box(494), NULL);
+ avl = gpr_avl_add(avl, box(396), box(494), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(188), box(499), nullptr);
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 = 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), 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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(545), box(515), nullptr);
avl = remove_int(avl, 59);
- avl = gpr_avl_add(avl, box(168), box(517), NULL);
+ avl = gpr_avl_add(avl, box(168), box(517), nullptr);
avl = remove_int(avl, 337);
- avl = gpr_avl_add(avl, box(69), box(519), NULL);
+ avl = gpr_avl_add(avl, box(69), box(519), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(664), box(526), NULL);
- avl = gpr_avl_add(avl, box(547), box(527), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(859), box(530), NULL);
- avl = gpr_avl_add(avl, box(49), box(531), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(326), box(535), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(162), box(538), NULL);
- avl = gpr_avl_add(avl, box(189), box(539), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(608), box(542), nullptr);
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 = 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(939), box(551), NULL);
- avl = gpr_avl_add(avl, box(344), box(552), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(636), box(555), nullptr);
avl = remove_int(avl, 558);
- avl = gpr_avl_add(avl, box(923), box(557), NULL);
+ avl = gpr_avl_add(avl, box(923), box(557), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(725), box(564), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(512), box(572), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(602), box(581), nullptr);
avl = remove_int(avl, 251);
- avl = gpr_avl_add(avl, box(303), box(583), NULL);
+ avl = gpr_avl_add(avl, box(303), box(583), nullptr);
avl = remove_int(avl, 837);
- avl = gpr_avl_add(avl, box(714), box(585), NULL);
+ avl = gpr_avl_add(avl, box(714), box(585), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(296), box(592), nullptr);
avl = remove_int(avl, 129);
- avl = gpr_avl_add(avl, box(656), box(594), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(846), box(598), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(575), box(604), NULL);
- avl = gpr_avl_add(avl, box(620), box(605), NULL);
+ 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(1008), box(614), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(339), box(617), NULL);
- avl = gpr_avl_add(avl, box(197), box(618), NULL);
+ 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), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(71), box(629), nullptr);
avl = remove_int(avl, 205);
- avl = gpr_avl_add(avl, box(501), box(631), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(330), box(637), nullptr);
avl = remove_int(avl, 264);
- avl = gpr_avl_add(avl, box(69), box(639), NULL);
+ avl = gpr_avl_add(avl, box(69), box(639), nullptr);
avl = remove_int(avl, 73);
- avl = gpr_avl_add(avl, box(745), box(641), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(899), box(646), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(445), box(650), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(708), box(655), nullptr);
avl = remove_int(avl, 922);
- avl = gpr_avl_add(avl, box(743), box(657), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(319), box(664), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(320), box(673), NULL);
- avl = gpr_avl_add(avl, box(115), box(674), NULL);
+ 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), 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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(156), box(685), nullptr);
avl = remove_int(avl, 696);
- avl = gpr_avl_add(avl, box(546), box(687), NULL);
+ 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);
@@ -1839,22 +1839,22 @@ static void test_badcase3(void) {
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 = gpr_avl_add(avl, box(500), box(701), nullptr);
avl = remove_int(avl, 924);
- avl = gpr_avl_add(avl, box(825), box(703), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(846), box(711), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(398), box(714), NULL);
+ 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), NULL);
+ 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);
@@ -1863,51 +1863,51 @@ static void test_badcase3(void) {
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 = 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), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(807), box(736), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(332), box(744), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(334), box(748), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(812), box(760), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(285), box(768), NULL);
- avl = gpr_avl_add(avl, box(472), box(769), NULL);
+ 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);
@@ -1915,48 +1915,48 @@ static void test_badcase3(void) {
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 = 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), NULL);
+ 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), NULL);
+ 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), NULL);
+ 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), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(946), box(802), nullptr);
avl = remove_int(avl, 145);
- avl = gpr_avl_add(avl, box(628), box(804), NULL);
+ avl = gpr_avl_add(avl, box(628), box(804), nullptr);
avl = remove_int(avl, 972);
- avl = gpr_avl_add(avl, box(728), box(806), NULL);
+ avl = gpr_avl_add(avl, box(728), box(806), nullptr);
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 = 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), NULL);
+ 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), NULL);
+ 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);
@@ -1965,138 +1965,138 @@ static void test_badcase3(void) {
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 = gpr_avl_add(avl, box(267), box(827), nullptr);
avl = remove_int(avl, 812);
- avl = gpr_avl_add(avl, box(577), box(829), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(941), box(834), NULL);
+ 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), 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 = 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(62), box(845), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(992), box(856), NULL);
- avl = gpr_avl_add(avl, box(818), box(857), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(508), box(863), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(219), box(874), NULL);
- avl = gpr_avl_add(avl, box(465), box(875), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(543), box(878), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(560), box(880), nullptr);
avl = remove_int(avl, 898);
- avl = gpr_avl_add(avl, box(455), box(882), NULL);
+ avl = gpr_avl_add(avl, box(455), box(882), nullptr);
avl = remove_int(avl, 313);
- avl = gpr_avl_add(avl, box(215), box(884), NULL);
+ avl = gpr_avl_add(avl, box(215), box(884), nullptr);
avl = remove_int(avl, 846);
- avl = gpr_avl_add(avl, box(608), box(886), NULL);
+ avl = gpr_avl_add(avl, box(608), box(886), nullptr);
avl = remove_int(avl, 248);
- avl = gpr_avl_add(avl, box(575), box(888), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(329), box(894), NULL);
- avl = gpr_avl_add(avl, box(326), box(895), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(141), box(899), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(777), box(902), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(828), box(906), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(573), box(912), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(692), box(915), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(167), box(921), nullptr);
avl = remove_int(avl, 328);
- avl = gpr_avl_add(avl, box(89), box(923), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(58), box(928), NULL);
- avl = gpr_avl_add(avl, box(70), box(929), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(846), box(932), nullptr);
avl = remove_int(avl, 642);
- avl = gpr_avl_add(avl, box(777), box(934), NULL);
+ avl = gpr_avl_add(avl, box(777), box(934), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(584), box(943), NULL);
+ 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(247), box(953), NULL);
- avl = gpr_avl_add(avl, box(389), box(954), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(936), box(957), NULL);
- avl = gpr_avl_add(avl, box(309), box(958), NULL);
+ 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);
@@ -2104,15 +2104,15 @@ static void test_badcase3(void) {
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 = gpr_avl_add(avl, box(365), box(966), nullptr);
avl = remove_int(avl, 82);
- avl = gpr_avl_add(avl, box(728), box(968), NULL);
+ avl = gpr_avl_add(avl, box(728), box(968), nullptr);
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 = 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), NULL);
+ 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);
@@ -2121,125 +2121,125 @@ static void test_badcase3(void) {
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(211), box(987), NULL);
- avl = gpr_avl_add(avl, box(589), box(988), NULL);
+ 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), NULL);
+ 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), 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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(362), box(1002), nullptr);
avl = remove_int(avl, 215);
- avl = gpr_avl_add(avl, box(624), box(1004), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(240), box(1009), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(857), box(1012), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(740), box(1016), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(625), box(1023), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(62), box(1029), NULL);
- avl = gpr_avl_add(avl, box(432), box(1030), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(644), box(1036), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(783), box(1042), NULL);
+ 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(168), box(1052), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(53), box(1056), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(966), box(1061), nullptr);
avl = remove_int(avl, 158);
- avl = gpr_avl_add(avl, box(406), box(1063), NULL);
+ avl = gpr_avl_add(avl, box(406), box(1063), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(489), box(1073), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(971), box(1075), nullptr);
avl = remove_int(avl, 660);
- avl = gpr_avl_add(avl, box(255), box(1077), NULL);
+ avl = gpr_avl_add(avl, box(255), box(1077), nullptr);
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 = 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(1014), box(1089), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(851), box(1092), nullptr);
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 = 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), NULL);
+ 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), NULL);
+ 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);
@@ -2248,114 +2248,114 @@ static void test_badcase3(void) {
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 = gpr_avl_add(avl, box(965), box(1110), nullptr);
avl = remove_int(avl, 622);
- avl = gpr_avl_add(avl, box(352), box(1112), NULL);
+ avl = gpr_avl_add(avl, box(352), box(1112), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(98), box(1118), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(402), box(1126), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(625), box(1129), NULL);
+ 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), NULL);
+ 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), 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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(531), box(1144), nullptr);
avl = remove_int(avl, 806);
- avl = gpr_avl_add(avl, box(455), box(1146), NULL);
+ avl = gpr_avl_add(avl, box(455), box(1146), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(81), box(1152), NULL);
- avl = gpr_avl_add(avl, box(59), box(1153), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(822), box(1157), NULL);
- avl = gpr_avl_add(avl, box(354), box(1158), NULL);
+ 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), 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 = 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(975), box(1175), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(753), box(1182), nullptr);
avl = remove_int(avl, 404);
- avl = gpr_avl_add(avl, box(294), box(1184), NULL);
+ avl = gpr_avl_add(avl, box(294), box(1184), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(345), box(1191), nullptr);
avl = remove_int(avl, 0);
- avl = gpr_avl_add(avl, box(230), box(1193), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(697), box(1200), NULL);
- avl = gpr_avl_add(avl, box(376), box(1201), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(888), box(1203), nullptr);
avl = remove_int(avl, 55);
- avl = gpr_avl_add(avl, box(85), box(1205), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(169), box(1210), NULL);
- avl = gpr_avl_add(avl, box(156), box(1211), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(76), box(1216), NULL);
- avl = gpr_avl_add(avl, box(756), box(1217), NULL);
+ 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);
@@ -2364,37 +2364,37 @@ static void test_badcase3(void) {
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(504), box(1233), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(813), box(1236), NULL);
- avl = gpr_avl_add(avl, box(795), box(1237), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(799), box(1239), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(458), box(1247), NULL);
+ 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(673), box(1256), NULL);
+ 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);
@@ -2402,448 +2402,448 @@ static void test_badcase3(void) {
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 = 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(309), box(1272), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(450), box(1275), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(238), box(1279), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(140), box(1287), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(127), box(1296), NULL);
- avl = gpr_avl_add(avl, box(279), box(1297), NULL);
+ 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), 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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(313), box(1312), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(866), box(1317), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(847), box(1323), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(360), box(1328), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(493), box(1330), nullptr);
avl = remove_int(avl, 516);
- avl = gpr_avl_add(avl, box(361), box(1332), NULL);
+ avl = gpr_avl_add(avl, box(361), box(1332), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(333), box(1337), nullptr);
avl = remove_int(avl, 481);
- avl = gpr_avl_add(avl, box(501), box(1339), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(234), box(1343), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(702), box(1349), NULL);
- avl = gpr_avl_add(avl, box(149), box(1350), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(455), box(1358), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(109), box(1362), NULL);
- avl = gpr_avl_add(avl, box(452), box(1363), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(159), box(1365), nullptr);
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 = 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(229), box(1373), nullptr);
avl = remove_int(avl, 772);
- avl = gpr_avl_add(avl, box(181), box(1375), NULL);
+ avl = gpr_avl_add(avl, box(181), box(1375), nullptr);
avl = remove_int(avl, 175);
- avl = gpr_avl_add(avl, box(817), box(1377), NULL);
+ avl = gpr_avl_add(avl, box(817), box(1377), nullptr);
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 = 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(293), box(1389), NULL);
+ 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), 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 = 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(440), box(1409), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(660), box(1416), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(35), box(1419), NULL);
- avl = gpr_avl_add(avl, box(871), box(1420), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(215), box(1423), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(975), box(1425), nullptr);
avl = remove_int(avl, 987);
- avl = gpr_avl_add(avl, box(58), box(1427), NULL);
+ avl = gpr_avl_add(avl, box(58), box(1427), nullptr);
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 = 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), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(636), box(1446), nullptr);
avl = remove_int(avl, 152);
- avl = gpr_avl_add(avl, box(61), box(1448), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(672), box(1452), NULL);
- avl = gpr_avl_add(avl, box(66), box(1453), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(495), box(1459), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(414), box(1462), NULL);
+ 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(202), box(1478), NULL);
- avl = gpr_avl_add(avl, box(312), box(1479), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(954), box(1482), NULL);
- avl = gpr_avl_add(avl, box(637), box(1483), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(862), box(1491), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(237), box(1497), NULL);
+ 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), NULL);
+ 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), 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 = 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), 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 = 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(373), box(1525), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(329), box(1527), nullptr);
avl = remove_int(avl, 397);
- avl = gpr_avl_add(avl, box(884), box(1529), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(232), box(1533), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(888), box(1535), nullptr);
avl = remove_int(avl, 242);
- avl = gpr_avl_add(avl, box(941), box(1537), NULL);
+ avl = gpr_avl_add(avl, box(941), box(1537), nullptr);
avl = remove_int(avl, 415);
- avl = gpr_avl_add(avl, box(992), box(1539), NULL);
+ avl = gpr_avl_add(avl, box(992), box(1539), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(5), box(1546), nullptr);
avl = remove_int(avl, 429);
- avl = gpr_avl_add(avl, box(412), box(1548), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(108), box(1552), NULL);
- avl = gpr_avl_add(avl, box(750), box(1553), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(628), box(1559), NULL);
- avl = gpr_avl_add(avl, box(480), box(1560), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(469), box(1567), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(915), box(1570), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(117), box(1572), nullptr);
avl = remove_int(avl, 62);
- avl = gpr_avl_add(avl, box(382), box(1574), NULL);
+ avl = gpr_avl_add(avl, box(382), box(1574), nullptr);
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 = 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), 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 = 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(860), box(1589), NULL);
- avl = gpr_avl_add(avl, box(173), box(1590), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(639), box(1596), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(91), box(1602), NULL);
+ 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(295), box(1616), NULL);
+ 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), 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 = 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), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(133), box(1633), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(201), box(1636), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(986), box(1640), NULL);
- avl = gpr_avl_add(avl, box(622), box(1641), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(502), box(1646), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(450), box(1652), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(959), box(1659), NULL);
+ 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), 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 = 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), 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 = 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(648), box(1680), NULL);
- avl = gpr_avl_add(avl, box(761), box(1681), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(194), box(1684), nullptr);
avl = remove_int(avl, 233);
- avl = gpr_avl_add(avl, box(888), box(1686), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(463), box(1695), NULL);
- avl = gpr_avl_add(avl, box(233), box(1696), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(607), box(1703), nullptr);
avl = remove_int(avl, 329);
- avl = gpr_avl_add(avl, box(716), box(1705), NULL);
+ 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);
@@ -2851,402 +2851,402 @@ static void test_badcase3(void) {
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(585), box(1718), nullptr);
avl = remove_int(avl, 121);
- avl = gpr_avl_add(avl, box(534), box(1720), NULL);
+ avl = gpr_avl_add(avl, box(534), box(1720), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(768), box(1726), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(449), box(1729), NULL);
- avl = gpr_avl_add(avl, box(586), box(1730), NULL);
+ 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), 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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(789), box(1740), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(327), box(1750), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(122), box(1752), nullptr);
avl = remove_int(avl, 606);
- avl = gpr_avl_add(avl, box(485), box(1754), NULL);
+ avl = gpr_avl_add(avl, box(485), box(1754), nullptr);
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 = 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), 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 = 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), 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 = 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(913), box(1773), nullptr);
avl = remove_int(avl, 480);
- avl = gpr_avl_add(avl, box(489), box(1775), NULL);
+ avl = gpr_avl_add(avl, box(489), box(1775), nullptr);
avl = remove_int(avl, 845);
- avl = gpr_avl_add(avl, box(896), box(1777), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(3), box(1781), NULL);
+ 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(612), box(1790), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(1014), box(1795), nullptr);
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 = 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), 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 = 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(563), box(1813), nullptr);
avl = remove_int(avl, 182);
- avl = gpr_avl_add(avl, box(816), box(1815), NULL);
+ 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), 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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(466), box(1823), nullptr);
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 = 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), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(803), box(1840), nullptr);
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 = 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), 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 = 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(933), box(1858), NULL);
- avl = gpr_avl_add(avl, box(97), box(1859), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(864), box(1862), nullptr);
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 = 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), 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 = 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(588), box(1885), nullptr);
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 = 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(952), box(1901), NULL);
- avl = gpr_avl_add(avl, box(510), box(1902), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(475), box(1906), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(538), box(1909), nullptr);
avl = remove_int(avl, 47);
- avl = gpr_avl_add(avl, box(89), box(1911), NULL);
+ avl = gpr_avl_add(avl, box(89), box(1911), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(996), box(1919), nullptr);
avl = remove_int(avl, 380);
- avl = gpr_avl_add(avl, box(957), box(1921), NULL);
+ avl = gpr_avl_add(avl, box(957), box(1921), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(181), box(1929), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(906), box(1937), NULL);
- avl = gpr_avl_add(avl, box(44), box(1938), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(258), box(1942), NULL);
+ 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), 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 = 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(954), box(1954), NULL);
+ 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), NULL);
+ 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(1013), box(1968), NULL);
- avl = gpr_avl_add(avl, box(778), box(1969), NULL);
+ 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), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(412), box(1986), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(408), box(1992), NULL);
- avl = gpr_avl_add(avl, box(841), box(1993), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(597), box(1996), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(191), box(2000), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(849), box(2006), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(306), box(2008), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(470), box(2013), nullptr);
avl = remove_int(avl, 951);
- avl = gpr_avl_add(avl, box(388), box(2015), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(218), box(2020), nullptr);
avl = remove_int(avl, 671);
- avl = gpr_avl_add(avl, box(1020), box(2022), NULL);
+ avl = gpr_avl_add(avl, box(1020), box(2022), nullptr);
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 = 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(143), box(2035), NULL);
- avl = gpr_avl_add(avl, box(670), box(2036), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(46), box(2038), nullptr);
avl = remove_int(avl, 970);
- avl = gpr_avl_add(avl, box(353), box(2040), NULL);
+ avl = gpr_avl_add(avl, box(353), box(2040), nullptr);
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 = 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), 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 = 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(473), box(2064), NULL);
- avl = gpr_avl_add(avl, box(992), box(2065), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(35), box(2071), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(855), box(2073), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(849), box(2079), nullptr);
avl = remove_int(avl, 597);
- avl = gpr_avl_add(avl, box(472), box(2081), NULL);
+ 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), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(851), box(2091), nullptr);
avl = remove_int(avl, 705);
- avl = gpr_avl_add(avl, box(26), box(2093), NULL);
+ avl = gpr_avl_add(avl, box(26), box(2093), nullptr);
avl = remove_int(avl, 973);
- avl = gpr_avl_add(avl, box(923), box(2095), NULL);
+ avl = gpr_avl_add(avl, box(923), box(2095), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(279), box(2100), nullptr);
avl = remove_int(avl, 203);
- avl = gpr_avl_add(avl, box(411), box(2102), NULL);
+ avl = gpr_avl_add(avl, box(411), box(2102), nullptr);
avl = remove_int(avl, 950);
- avl = gpr_avl_add(avl, box(6), box(2104), NULL);
+ 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), NULL);
+ 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);
@@ -3255,259 +3255,259 @@ static void test_badcase3(void) {
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(727), box(2120), nullptr);
avl = remove_int(avl, 295);
- avl = gpr_avl_add(avl, box(645), box(2122), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(651), box(2126), NULL);
- avl = gpr_avl_add(avl, box(804), box(2127), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(867), box(2129), nullptr);
avl = remove_int(avl, 384);
- avl = gpr_avl_add(avl, box(819), box(2131), NULL);
+ avl = gpr_avl_add(avl, box(819), box(2131), nullptr);
avl = remove_int(avl, 674);
- avl = gpr_avl_add(avl, box(76), box(2133), NULL);
+ avl = gpr_avl_add(avl, box(76), box(2133), nullptr);
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 = 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(918), box(2147), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(264), box(2154), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(571), box(2158), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(94), box(2162), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(432), box(2167), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(425), box(2172), nullptr);
avl = remove_int(avl, 769);
- avl = gpr_avl_add(avl, box(656), box(2174), NULL);
+ avl = gpr_avl_add(avl, box(656), box(2174), nullptr);
avl = remove_int(avl, 29);
- avl = gpr_avl_add(avl, box(464), box(2176), NULL);
+ avl = gpr_avl_add(avl, box(464), box(2176), nullptr);
avl = remove_int(avl, 713);
- avl = gpr_avl_add(avl, box(800), box(2178), NULL);
+ avl = gpr_avl_add(avl, box(800), box(2178), nullptr);
avl = remove_int(avl, 621);
- avl = gpr_avl_add(avl, box(962), box(2180), NULL);
+ avl = gpr_avl_add(avl, box(962), box(2180), nullptr);
avl = remove_int(avl, 448);
- avl = gpr_avl_add(avl, box(878), box(2182), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(429), box(2186), NULL);
- avl = gpr_avl_add(avl, box(598), box(2187), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(809), box(2190), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(788), box(2194), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(344), box(2197), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(444), box(2200), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(703), box(2203), nullptr);
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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(413), box(2211), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(930), box(2222), NULL);
- avl = gpr_avl_add(avl, box(36), box(2223), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(596), box(2226), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(493), box(2233), NULL);
- avl = gpr_avl_add(avl, box(839), box(2234), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(337), box(2236), nullptr);
avl = remove_int(avl, 322);
- avl = gpr_avl_add(avl, box(16), box(2238), NULL);
+ 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), NULL);
+ 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), 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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(1019), box(2253), nullptr);
avl = remove_int(avl, 955);
- avl = gpr_avl_add(avl, box(270), box(2255), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(400), box(2259), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(263), box(2261), nullptr);
avl = remove_int(avl, 704);
- avl = gpr_avl_add(avl, box(757), box(2263), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(464), box(2268), NULL);
- avl = gpr_avl_add(avl, box(817), box(2269), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(412), box(2271), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(491), box(2279), NULL);
+ 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), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(1021), box(2290), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(324), box(2294), NULL);
+ 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), 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 = 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(953), box(2310), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(751), box(2318), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(217), box(2320), nullptr);
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 = 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), 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 = 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), NULL);
- avl = gpr_avl_add(avl, box(58), box(2334), NULL);
- avl = gpr_avl_add(avl, box(127), box(2335), NULL);
+ 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), NULL);
+ 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), NULL);
+ 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), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(442), box(2349), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(10), box(2352), nullptr);
avl = remove_int(avl, 189);
- avl = gpr_avl_add(avl, box(742), box(2354), NULL);
+ avl = gpr_avl_add(avl, box(742), box(2354), nullptr);
avl = remove_int(avl, 108);
- avl = gpr_avl_add(avl, box(1014), box(2356), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(180), box(2360), nullptr);
avl = remove_int(avl, 472);
- avl = gpr_avl_add(avl, box(567), box(2362), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(1009), box(2366), NULL);
+ 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), NULL);
+ 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);
@@ -3515,51 +3515,51 @@ static void test_badcase3(void) {
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(925), box(2383), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(613), box(2390), nullptr);
avl = remove_int(avl, 289);
- avl = gpr_avl_add(avl, box(980), box(2392), NULL);
+ avl = gpr_avl_add(avl, box(980), box(2392), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(918), box(2398), NULL);
+ 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), NULL);
+ 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), NULL);
+ avl = gpr_avl_add(avl, box(160), box(2405), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(708), box(2411), NULL);
- avl = gpr_avl_add(avl, box(624), box(2412), NULL);
+ 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), NULL);
+ 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), NULL);
+ 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);
@@ -3569,33 +3569,33 @@ static void test_badcase3(void) {
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(285), box(2436), NULL);
+ 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), NULL);
- avl = gpr_avl_add(avl, box(776), box(2440), NULL);
+ 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), 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 = 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), NULL);
+ avl = gpr_avl_add(avl, box(270), box(2447), nullptr);
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 = 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), NULL);
- avl = gpr_avl_add(avl, box(626), box(2453), NULL);
+ 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, NULL);
+ gpr_avl_unref(avl, nullptr);
}
static void test_stress(int amount_of_stress) {
@@ -3604,11 +3604,11 @@ static void test_stress(int amount_of_stress) {
int deletions = 0;
gpr_avl avl;
- unsigned seed = (unsigned)time(NULL);
+ unsigned seed = (unsigned)time(nullptr);
gpr_log(GPR_DEBUG, "test_stress amount=%d seed=%u", amount_of_stress, seed);
- srand((unsigned)time(NULL));
+ srand((unsigned)time(nullptr));
avl = gpr_avl_create(&int_int_vtable);
memset(added, 0, sizeof(added));
@@ -3620,7 +3620,7 @@ static void test_stress(int amount_of_stress) {
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);
+ avl = gpr_avl_add(avl, box(idx), box(i), nullptr);
} else {
deletions += (added[idx] != 0);
added[idx] = 0;
@@ -3636,7 +3636,7 @@ static void test_stress(int amount_of_stress) {
}
}
- gpr_avl_unref(avl, NULL);
+ gpr_avl_unref(avl, nullptr);
}
int main(int argc, char* argv[]) {
diff --git a/test/core/support/cmdline_test.cc b/test/core/support/cmdline_test.cc
index 5afaa2a60a..172efda8a0 100644
--- a/test/core/support/cmdline_test.cc
+++ b/test/core/support/cmdline_test.cc
@@ -35,8 +35,8 @@ static void test_simple_int(void) {
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);
@@ -50,8 +50,8 @@ static void test_eq_int(void) {
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);
@@ -66,8 +66,8 @@ static void test_2dash_int(void) {
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);
@@ -81,8 +81,8 @@ static void test_2dash_eq_int(void) {
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);
@@ -90,62 +90,62 @@ static void test_2dash_eq_int(void) {
}
static void test_simple_string(void) {
- const char* x = NULL;
+ 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) {
- const char* x = NULL;
+ 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) {
- const char* x = NULL;
+ 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) {
- const char* x = NULL;
+ 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);
@@ -158,8 +158,8 @@ static void test_flag_on(void) {
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);
@@ -173,8 +173,8 @@ static void test_flag_no(void) {
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);
@@ -188,8 +188,8 @@ static void test_flag_val_1(void) {
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);
@@ -203,8 +203,8 @@ static void test_flag_val_0(void) {
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);
@@ -218,8 +218,8 @@ static void test_flag_val_true(void) {
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);
@@ -233,8 +233,8 @@ static void test_flag_val_false(void) {
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);
@@ -242,7 +242,7 @@ static void test_flag_val_false(void) {
}
static void test_many(void) {
- const char* str = NULL;
+ const char* str = nullptr;
int x = 0;
int flag = 2;
gpr_cmdline* cl;
@@ -253,10 +253,10 @@ static void test_many(void) {
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"));
@@ -266,7 +266,7 @@ static void test_many(void) {
static void extra_arg_cb(void* user_data, const char* arg) {
int* count = static_cast<int*>(user_data);
- GPR_ASSERT(arg != NULL);
+ GPR_ASSERT(arg != nullptr);
GPR_ASSERT(strlen(arg) == 1);
GPR_ASSERT(arg[0] == 'a' + *count);
++*count;
@@ -280,7 +280,7 @@ static void test_extra(void) {
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,7 +297,7 @@ static void test_extra_dashdash(void) {
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);
@@ -309,18 +309,18 @@ static void test_usage(void) {
gpr_cmdline* cl;
char* usage;
- const 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,
@@ -340,7 +340,7 @@ static void test_usage(void) {
static void test_help(void) {
gpr_cmdline* cl;
- const char* str = NULL;
+ const char* str = nullptr;
int x = 0;
int flag = 2;
@@ -348,13 +348,13 @@ static void test_help(void) {
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));
@@ -364,7 +364,7 @@ static void test_help(void) {
static void test_badargs1(void) {
gpr_cmdline* cl;
- const char* str = NULL;
+ const char* str = nullptr;
int x = 0;
int flag = 2;
@@ -372,13 +372,13 @@ static void test_badargs1(void) {
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));
@@ -389,7 +389,7 @@ static void test_badargs1(void) {
static void test_badargs2(void) {
gpr_cmdline* cl;
- const char* str = NULL;
+ const char* str = nullptr;
int x = 0;
int flag = 2;
@@ -398,13 +398,13 @@ static void test_badargs2(void) {
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));
@@ -415,7 +415,7 @@ static void test_badargs2(void) {
static void test_badargs3(void) {
gpr_cmdline* cl;
- const char* str = NULL;
+ const char* str = nullptr;
int x = 0;
int flag = 2;
@@ -423,13 +423,13 @@ static void test_badargs3(void) {
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));
@@ -440,7 +440,7 @@ static void test_badargs3(void) {
static void test_badargs4(void) {
gpr_cmdline* cl;
- const char* str = NULL;
+ const char* str = nullptr;
int x = 0;
int flag = 2;
@@ -448,13 +448,13 @@ static void test_badargs4(void) {
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));
diff --git a/test/core/support/cpu_test.cc b/test/core/support/cpu_test.cc
index c69ce55a73..6e04feedaa 100644
--- a/test/core/support/cpu_test.cc
+++ b/test/core/support/cpu_test.cc
@@ -110,7 +110,8 @@ static void cpu_test(void) {
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) {
diff --git a/test/core/support/env_test.cc b/test/core/support/env_test.cc
index 54009536b4..b12c04d06f 100644
--- a/test/core/support/env_test.cc
+++ b/test/core/support/env_test.cc
@@ -37,7 +37,7 @@ static void test_setenv_getenv(void) {
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);
}
diff --git a/test/core/support/histogram_test.cc b/test/core/support/histogram_test.cc
deleted file mode 100644
index 86b7d599e6..0000000000
--- a/test/core/support/histogram_test.cc
+++ /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/log_test.cc b/test/core/support/log_test.cc
index 9602bbb090..7dba35c13e 100644
--- a/test/core/support/log_test.cc
+++ b/test/core/support/log_test.cc
@@ -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/manual_constructor_test.cc b/test/core/support/manual_constructor_test.cc
new file mode 100644
index 0000000000..714f8b21a0
--- /dev/null
+++ b/test/core/support/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/support/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/support/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/mpscq_test.cc b/test/core/support/mpscq_test.cc
index d5b7bf21c1..1b83f7d5be 100644
--- a/test/core/support/mpscq_test.cc
+++ b/test/core/support/mpscq_test.cc
@@ -45,7 +45,7 @@ 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);
@@ -85,14 +85,15 @@ 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);
while (num_done != GPR_ARRAY_SIZE(thds)) {
gpr_mpscq_node* n;
- while ((n = gpr_mpscq_pop(&q)) == NULL) {
+ while ((n = gpr_mpscq_pop(&q)) == nullptr) {
spins++;
}
test_node* tn = (test_node*)n;
@@ -129,7 +130,7 @@ static void pull_thread(void* arg) {
return;
}
gpr_mpscq_node* n;
- while ((n = gpr_mpscq_pop(pa->q)) == NULL) {
+ while ((n = gpr_mpscq_pop(pa->q)) == nullptr) {
pa->spins++;
}
test_node* tn = (test_node*)n;
@@ -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,7 +171,8 @@ 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);
for (size_t i = 0; i < GPR_ARRAY_SIZE(pull_thds); i++) {
diff --git a/test/core/support/ref_counted_ptr_test.cc b/test/core/support/ref_counted_ptr_test.cc
new file mode 100644
index 0000000000..1830edc4e5
--- /dev/null
+++ b/test/core/support/ref_counted_ptr_test.cc
@@ -0,0 +1,172 @@
+/*
+ *
+ * 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/support/ref_counted_ptr.h"
+
+#include <gtest/gtest.h>
+
+#include <grpc/support/log.h>
+
+#include "src/core/lib/support/memory.h"
+#include "src/core/lib/support/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(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/support/ref_counted_test.cc b/test/core/support/ref_counted_test.cc
new file mode 100644
index 0000000000..be9b6ff7c2
--- /dev/null
+++ b/test/core/support/ref_counted_test.cc
@@ -0,0 +1,72 @@
+/*
+ *
+ * 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/support/ref_counted.h"
+
+#include <gtest/gtest.h>
+
+#include "src/core/lib/support/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();
+}
+
+TraceFlag 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/support/spinlock_test.cc b/test/core/support/spinlock_test.cc
index 3639802cd7..58d5fcd42b 100644
--- a/test/core/support/spinlock_test.cc
+++ b/test/core/support/spinlock_test.cc
@@ -67,7 +67,8 @@ static void test_create_threads(struct test* m, void (*body)(void* arg)) {
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));
}
}
diff --git a/test/core/support/stack_lockfree_test.cc b/test/core/support/stack_lockfree_test.cc
deleted file mode 100644
index e6d0c9b795..0000000000
--- a/test/core/support/stack_lockfree_test.cc
+++ /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/support/string_test.cc b/test/core/support/string_test.cc
index 4bae158a15..fd7f7cde59 100644
--- a/test/core/support/string_test.cc
+++ b/test/core/support/string_test.cc
@@ -41,7 +41,7 @@ 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,
@@ -271,9 +271,9 @@ 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(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"));
@@ -289,7 +289,7 @@ 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"));
}
diff --git a/test/core/support/sync_test.cc b/test/core/support/sync_test.cc
index 416e94d06d..3f534de820 100644
--- a/test/core/support/sync_test.cc
+++ b/test/core/support/sync_test.cc
@@ -189,7 +189,7 @@ 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));
}
}
@@ -242,9 +242,9 @@ static void test(const char* name, void (*body)(void* m),
iterations <<= 1;
fprintf(stderr, " %ld", (long)iterations);
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);
@@ -333,7 +333,7 @@ static void inc_with_1ms_delay_event(void* v /*=m*/) {
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);
@@ -438,16 +438,16 @@ static void refcheck(void* v /*=m*/) {
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.cc b/test/core/support/thd_test.cc
index f70a3b4fe2..b755bf18f3 100644
--- a/test/core/support/thd_test.cc
+++ b/test/core/support/thd_test.cc
@@ -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]);
diff --git a/test/core/support/tls_test.cc b/test/core/support/tls_test.cc
index b1b4737432..743b10f090 100644
--- a/test/core/support/tls_test.cc
+++ b/test/core/support/tls_test.cc
@@ -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/surface/alarm_test.cc b/test/core/surface/alarm_test.cc
index 88b0b31478..8950603b41 100644
--- a/test/core/surface/alarm_test.cc
+++ b/test/core/surface/alarm_test.cc
@@ -34,7 +34,8 @@ static void* create_test_tag(void) {
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);
+ ev =
+ grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), nullptr);
GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN);
grpc_completion_queue_destroy(cc);
}
@@ -43,54 +44,57 @@ static void test_alarm(void) {
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);
+ 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);
+ 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);
+ 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);
diff --git a/test/core/surface/channel_create_test.cc b/test/core/surface/channel_create_test.cc
index 4627c57438..f358b0fc8d 100644
--- a/test/core/surface/channel_create_test.cc
+++ b/test/core/surface/channel_create_test.cc
@@ -32,8 +32,8 @@ void test_unknown_scheme_target(void) {
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 =
diff --git a/test/core/surface/completion_queue_test.cc b/test/core/surface/completion_queue_test.cc
index 277ffde553..c6e13d2386 100644
--- a/test/core/surface/completion_queue_test.cc
+++ b/test/core/surface/completion_queue_test.cc
@@ -40,12 +40,12 @@ static void shutdown_and_destroy(grpc_completion_queue* 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));
}
}
}
@@ -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);
}
}
@@ -113,8 +113,9 @@ 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);
}
@@ -142,13 +143,14 @@ static void test_cq_end_op(void) {
exec_ctx = init_exec_ctx; // Reset 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);
+ 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);
@@ -179,14 +181,15 @@ static void test_cq_tls_cache_full(void) {
exec_ctx = init_exec_ctx; // Reset 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);
grpc_completion_queue_thread_local_cache_init(cc);
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);
+ 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_QUEUE_TIMEOUT);
GPR_ASSERT(
@@ -194,7 +197,8 @@ static void test_cq_tls_cache_full(void) {
GPR_ASSERT(res_tag == tag);
GPR_ASSERT(ok);
- 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_QUEUE_TIMEOUT);
shutdown_and_destroy(cc);
@@ -220,7 +224,7 @@ static void test_cq_tls_cache_empty(void) {
exec_ctx = init_exec_ctx; // Reset 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_completion_queue_thread_local_cache_flush(cc, &res_tag, &ok) == 0);
@@ -245,10 +249,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);
}
@@ -267,11 +271,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);
}
@@ -304,29 +308,30 @@ static void test_pluck(void) {
exec_ctx = init_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]);
+ 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]);
+ 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]);
}
@@ -349,10 +354,10 @@ 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);
}
diff --git a/test/core/surface/completion_queue_threading_test.cc b/test/core/surface/completion_queue_threading_test.cc
index 043c5c1617..126d363f83 100644
--- a/test/core/surface/completion_queue_threading_test.cc
+++ b/test/core/surface/completion_queue_threading_test.cc
@@ -41,12 +41,12 @@ static void shutdown_and_destroy(grpc_completion_queue* 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: {
@@ -70,7 +70,7 @@ struct thread_state {
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) {
@@ -86,7 +86,7 @@ static void test_too_many_plucks(void) {
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 +96,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]);
+ do_nothing_end_completion, nullptr, &completions[i]);
}
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
@@ -163,7 +164,7 @@ static void producer_thread(void* arg) {
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,
+ free_completion, nullptr,
static_cast<grpc_cq_completion*>(
gpr_malloc(sizeof(grpc_cq_completion))));
opt->events_triggered++;
@@ -191,8 +192,8 @@ static void consumer_thread(void* arg) {
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);
@@ -214,7 +215,7 @@ static void test_threading(size_t producers, size_t consumers) {
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;
@@ -234,8 +235,9 @@ 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());
}
diff --git a/test/core/surface/concurrent_connectivity_test.cc b/test/core/surface/concurrent_connectivity_test.cc
index 6f6a71e6f5..2ff1ca3d79 100644
--- a/test/core/surface/concurrent_connectivity_test.cc
+++ 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; }
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);
@@ -93,8 +96,9 @@ struct server_thread_args {
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);
}
@@ -109,7 +113,7 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* vargs, grpc_endpoint* tcp,
grpc_endpoint_destroy(exec_ctx, tcp);
gpr_mu_lock(args->mu);
GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, args->pollset, NULL));
+ grpc_pollset_kick(exec_ctx, args->pollset, nullptr));
gpr_mu_unlock(args->mu);
}
@@ -121,7 +125,7 @@ void bad_server_thread(void* vargs) {
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_error* error = grpc_tcp_server_create(&exec_ctx, nullptr, nullptr, &s);
GPR_ASSERT(error == GRPC_ERROR_NONE);
memset(&resolved_addr, 0, sizeof(resolved_addr));
addr->ss_family = AF_INET;
@@ -137,7 +141,7 @@ void bad_server_thread(void* vargs) {
while (gpr_atm_acq_load(&args->stop) == 0) {
grpc_millis deadline = grpc_exec_ctx_now(&exec_ctx) + 100;
- grpc_pollset_worker* worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, args->pollset, &worker, deadline))) {
@@ -178,7 +182,8 @@ int run_concurrent_connectivity_test() {
/* 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]);
@@ -189,15 +194,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]);
@@ -214,11 +220,13 @@ int run_concurrent_connectivity_test() {
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]);
@@ -238,8 +246,9 @@ int run_concurrent_connectivity_test() {
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 =
@@ -247,10 +256,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 */
@@ -274,7 +284,8 @@ int run_concurrent_watches_with_short_timeouts_test() {
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]);
diff --git a/test/core/surface/invalid_channel_args_test.cc b/test/core/surface/invalid_channel_args_test.cc
index 6a58a32e3c..7c5f1f0352 100644
--- a/test/core/surface/invalid_channel_args_test.cc
+++ b/test/core/surface/invalid_channel_args_test.cc
@@ -24,7 +24,7 @@
#include <grpc/support/string_util.h>
#include "test/core/util/test_config.h"
-static char* g_last_log_error_message = NULL;
+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) {
@@ -44,13 +44,13 @@ static void log_error_sink(gpr_log_func_args* args) {
}
static void verify_last_error(const char* message) {
- if (message == NULL) {
- GPR_ASSERT(g_last_log_error_message == NULL);
+ 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) {
@@ -61,13 +61,13 @@ static char* compose_error_string(const char* key, const char* message) {
static void one_test(grpc_channel_args* args, char* expected_error_message) {
grpc_channel* chan =
- grpc_insecure_channel_create("nonexistant:54321", args, NULL);
+ 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;
diff --git a/test/core/surface/lame_client_test.cc b/test/core/surface/lame_client_test.cc
index c374adc08d..f3df7f35a7 100644
--- a/test/core/surface/lame_client_test.cc
+++ b/test/core/surface/lame_client_test.cc
@@ -50,14 +50,14 @@ void test_transport_op(grpc_channel* channel) {
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);
- 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);
@@ -93,12 +93,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 +108,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 +129,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.cc b/test/core/surface/num_external_connectivity_watchers_test.cc
index 89dc364fb8..f78d333673 100644
--- a/test/core/surface/num_external_connectivity_watchers_test.cc
+++ b/test/core/surface/num_external_connectivity_watchers_test.cc
@@ -50,8 +50,8 @@ static void channel_idle_start_watch(grpc_channel* 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);
+ 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);
@@ -73,7 +73,7 @@ static void run_timeouts_test(const test_fixture* fixture) {
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_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();
@@ -127,7 +127,7 @@ static void run_channel_shutdown_before_timeout_test(
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_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);
@@ -141,16 +141,16 @@ static void run_channel_shutdown_before_timeout_test(
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();
@@ -158,7 +158,7 @@ static void run_channel_shutdown_before_timeout_test(
}
static grpc_channel* insecure_test_create_channel(const char* addr) {
- return grpc_insecure_channel_create(addr, NULL, NULL);
+ return grpc_insecure_channel_create(addr, nullptr, nullptr);
}
static const test_fixture insecure_test = {
@@ -168,15 +168,15 @@ static const test_fixture insecure_test = {
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_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(NULL, &ssl_name_override, 1);
+ grpc_channel_args_copy_and_add(nullptr, &ssl_name_override, 1);
grpc_channel* channel =
- grpc_secure_channel_create(ssl_creds, addr, new_client_args, NULL);
+ 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);
diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c
index db9f902dbf..8d2384ba61 100644
--- a/test/core/surface/public_headers_must_be_c89.c
+++ b/test/core/surface/public_headers_must_be_c89.c
@@ -20,6 +20,7 @@
#include <grpc/byte_buffer_reader.h>
#include <grpc/census.h>
#include <grpc/compression.h>
+#include <grpc/fork.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/grpc_security_constants.h>
@@ -29,6 +30,7 @@
#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>
@@ -66,288 +67,271 @@
#include <stdio.h>
int main(int argc, char **argv) {
- if(argc == 12345678) {
- printf("%lx", (unsigned long) grpc_compression_algorithm_parse);
- printf("%lx", (unsigned long) grpc_compression_algorithm_name);
- printf("%lx", (unsigned long) grpc_stream_compression_algorithm_name);
- printf("%lx", (unsigned long) grpc_compression_algorithm_for_level);
- printf("%lx", (unsigned long) grpc_stream_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_options_is_stream_compression_algorithm_enabled);
- 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_histogram_create);
- printf("%lx", (unsigned long) gpr_histogram_destroy);
- printf("%lx", (unsigned long) gpr_histogram_add);
- printf("%lx", (unsigned long) gpr_histogram_merge);
- printf("%lx", (unsigned long) gpr_histogram_percentile);
- printf("%lx", (unsigned long) gpr_histogram_mean);
- printf("%lx", (unsigned long) gpr_histogram_stddev);
- printf("%lx", (unsigned long) gpr_histogram_variance);
- printf("%lx", (unsigned long) gpr_histogram_maximum);
- printf("%lx", (unsigned long) gpr_histogram_minimum);
- printf("%lx", (unsigned long) gpr_histogram_count);
- printf("%lx", (unsigned long) gpr_histogram_sum);
- printf("%lx", (unsigned long) gpr_histogram_sum_of_squares);
- printf("%lx", (unsigned long) gpr_histogram_get_contents);
- printf("%lx", (unsigned long) gpr_histogram_merge_contents);
- 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);
- }
+ printf("%lx", (unsigned long) grpc_compression_algorithm_parse);
+ printf("%lx", (unsigned long) grpc_compression_algorithm_name);
+ printf("%lx", (unsigned long) grpc_stream_compression_algorithm_name);
+ printf("%lx", (unsigned long) grpc_compression_algorithm_for_level);
+ printf("%lx", (unsigned long) grpc_stream_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_options_is_stream_compression_algorithm_enabled);
+ 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.cc b/test/core/surface/secure_channel_create_test.cc
index f3163c1d80..c31c61430c 100644
--- a/test/core/surface/secure_channel_create_test.cc
+++ b/test/core/surface/secure_channel_create_test.cc
@@ -33,7 +33,7 @@ void test_unknown_scheme_target(void) {
grpc_channel_credentials* creds =
grpc_fake_transport_security_credentials_create();
grpc_channel* chan =
- grpc_secure_channel_create(creds, "blah://blah", NULL, NULL);
+ 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"));
@@ -46,12 +46,13 @@ void test_unknown_scheme_target(void) {
void test_security_connector_already_in_arg(void) {
grpc_arg arg;
arg.type = GRPC_ARG_POINTER;
- arg.value.pointer.p = NULL;
+ 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* 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"));
@@ -61,7 +62,8 @@ void test_security_connector_already_in_arg(void) {
}
void test_null_creds(void) {
- grpc_channel* chan = grpc_secure_channel_create(NULL, NULL, NULL, NULL);
+ 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"));
diff --git a/test/core/surface/sequential_connectivity_test.cc b/test/core/surface/sequential_connectivity_test.cc
index 9ffbc82667..11d0aa705d 100644
--- a/test/core/surface/sequential_connectivity_test.cc
+++ b/test/core/surface/sequential_connectivity_test.cc
@@ -45,9 +45,9 @@ typedef struct {
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);
}
@@ -59,20 +59,20 @@ static void run_test(const test_fixture* fixture) {
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_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_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++) {
@@ -126,7 +126,7 @@ static void insecure_test_add_port(grpc_server* server, const char* addr) {
}
static grpc_channel* insecure_test_create_channel(const char* addr) {
- return grpc_insecure_channel_create(addr, NULL, NULL);
+ return grpc_insecure_channel_create(addr, nullptr, nullptr);
}
static const test_fixture insecure_test = {
@@ -138,23 +138,23 @@ static const test_fixture insecure_test = {
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_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(NULL, &ssl_name_override, 1);
+ grpc_channel_args_copy_and_add(nullptr, &ssl_name_override, 1);
grpc_channel* channel =
- grpc_secure_channel_create(ssl_creds, addr, new_client_args, NULL);
+ 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);
diff --git a/test/core/surface/server_chttp2_test.cc b/test/core/surface/server_chttp2_test.cc
index b0ffb1de3c..96eaa6a7a9 100644
--- a/test/core/surface/server_chttp2_test.cc
+++ 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);
@@ -44,9 +44,9 @@ void test_add_same_port_twice() {
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);
+ 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);
@@ -55,9 +55,9 @@ 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);
}
diff --git a/test/core/surface/server_test.cc b/test/core/surface/server_test.cc
index 240969a121..969b8cb11b 100644
--- a/test/core/surface/server_test.cc
+++ 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);
+ grpc_server* server = grpc_server_create(nullptr, nullptr);
void* method;
void* method_old;
- method =
- grpc_server_register_method(server, NULL, NULL, GRPC_SRM_PAYLOAD_NONE, 0);
- GPR_ASSERT(method == NULL);
+ 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);
}
@@ -74,24 +76,24 @@ void test_bind_server_twice(void) {
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);
+ 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_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);
@@ -104,7 +106,7 @@ void test_bind_server_to_addr(const char* host, bool secure) {
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_fake_transport_security_server_credentials_create();
@@ -113,21 +115,21 @@ void test_bind_server_to_addr(const char* host, bool secure) {
} 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_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;
}
diff --git a/test/core/transport/bdp_estimator_test.cc b/test/core/transport/bdp_estimator_test.cc
index 2a6fa95162..d1272607f2 100644
--- a/test/core/transport/bdp_estimator_test.cc
+++ b/test/core/transport/bdp_estimator_test.cc
@@ -29,7 +29,7 @@
#include "src/core/lib/support/string.h"
#include "test/core/util/test_config.h"
-extern "C" gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type);
+extern gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type);
namespace grpc_core {
namespace testing {
diff --git a/test/core/transport/byte_stream_test.cc b/test/core/transport/byte_stream_test.cc
index e62a697284..0e34fd7651 100644
--- a/test/core/transport/byte_stream_test.cc
+++ b/test/core/transport/byte_stream_test.cc
@@ -53,7 +53,7 @@ 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) {
@@ -89,7 +89,7 @@ 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(
@@ -142,7 +142,7 @@ 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.
@@ -183,7 +183,7 @@ 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(
@@ -234,7 +234,7 @@ 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(
diff --git a/test/core/transport/chttp2/BUILD b/test/core/transport/chttp2/BUILD
index 1ea7d0341d..6eff716b01 100644
--- a/test/core/transport/chttp2/BUILD
+++ b/test/core/transport/chttp2/BUILD
@@ -115,6 +115,21 @@ 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.cc"],
language = "C++",
diff --git a/test/core/transport/chttp2/hpack_encoder_test.cc b/test/core/transport/chttp2/hpack_encoder_test.cc
index a7e44abc2b..2d18b72504 100644
--- a/test/core/transport/chttp2/hpack_encoder_test.cc
+++ b/test/core/transport/chttp2/hpack_encoder_test.cc
@@ -39,7 +39,7 @@
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;
@@ -80,8 +80,8 @@ static void verify(grpc_exec_ctx* exec_ctx, const verify_params params,
exec_ctx, 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];
@@ -106,7 +106,7 @@ static void verify(grpc_exec_ctx* exec_ctx, const verify_params params,
16384, /* max_frame_size */
&stats /* stats */
};
- grpc_chttp2_encode_header(exec_ctx, &g_compressor, NULL, 0, &b, &hopt,
+ grpc_chttp2_encode_header(exec_ctx, &g_compressor, nullptr, 0, &b, &hopt,
&output);
merged = grpc_slice_merge(output.slices, output.count);
grpc_slice_buffer_destroy_internal(exec_ctx, &output);
@@ -220,8 +220,8 @@ static void verify_table_size_change_match_elem_size(grpc_exec_ctx* exec_ctx,
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;
@@ -235,7 +235,7 @@ static void verify_table_size_change_match_elem_size(grpc_exec_ctx* exec_ctx,
use_true_binary, /* use_true_binary_metadata */
16384, /* max_frame_size */
&stats /* stats */};
- grpc_chttp2_encode_header(exec_ctx, &g_compressor, NULL, 0, &b, &hopt,
+ grpc_chttp2_encode_header(exec_ctx, &g_compressor, nullptr, 0, &b, &hopt,
&output);
grpc_slice_buffer_destroy_internal(exec_ctx, &output);
grpc_metadata_batch_destroy(exec_ctx, &b);
diff --git a/test/core/transport/chttp2/hpack_parser_test.cc b/test/core/transport/chttp2/hpack_parser_test.cc
index 434b46eb2e..82fb20aced 100644
--- a/test/core/transport/chttp2/hpack_parser_test.cc
+++ b/test/core/transport/chttp2/hpack_parser_test.cc
@@ -73,7 +73,7 @@ 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);
}
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..670eae1f79
--- /dev/null
+++ b/test/core/transport/chttp2/settings_timeout_test.cc
@@ -0,0 +1,258 @@
+/*
+ *
+ * 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 <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_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ 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(&exec_ctx, pollset_set, pollset_);
+ EventState state;
+ grpc_tcp_client_connect(&exec_ctx, state.closure(), &endpoint_, pollset_set,
+ nullptr /* channel_args */, server_addresses->addrs,
+ 1000);
+ ASSERT_TRUE(PollUntilDone(
+ &exec_ctx, &state,
+ grpc_timespec_to_millis_round_up(gpr_inf_future(GPR_CLOCK_MONOTONIC))));
+ ASSERT_EQ(GRPC_ERROR_NONE, state.error());
+ grpc_pollset_set_destroy(&exec_ctx, pollset_set);
+ grpc_endpoint_add_to_pollset(&exec_ctx, endpoint_, pollset_);
+ grpc_resolved_addresses_destroy(server_addresses);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
+
+ // Reads until an error is returned.
+ // Returns true if an error was encountered before the deadline.
+ bool ReadUntilError() {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ 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_exec_ctx_now(&exec_ctx) + 3000;
+ while (true) {
+ EventState state;
+ grpc_endpoint_read(&exec_ctx, endpoint_, &read_buffer, state.closure());
+ if (!PollUntilDone(&exec_ctx, &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(&exec_ctx, &read_buffer);
+ }
+ grpc_endpoint_shutdown(&exec_ctx, endpoint_,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("shutdown"));
+ grpc_slice_buffer_destroy_internal(&exec_ctx, &read_buffer);
+ grpc_exec_ctx_finish(&exec_ctx);
+ return retval;
+ }
+
+ void Shutdown() {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_endpoint_destroy(&exec_ctx, endpoint_);
+ grpc_pollset_shutdown(&exec_ctx, pollset_,
+ GRPC_CLOSURE_CREATE(&Client::PollsetDestroy, pollset_,
+ grpc_schedule_on_exec_ctx));
+ grpc_exec_ctx_finish(&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(grpc_exec_ctx* exec_ctx, 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(grpc_exec_ctx* exec_ctx, 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(exec_ctx, pollset_, &worker,
+ grpc_exec_ctx_now(exec_ctx) + 1000));
+ gpr_mu_unlock(mu_);
+ if (state != nullptr && state->done()) return true;
+ if (grpc_exec_ctx_now(exec_ctx) >= deadline) return false;
+ }
+ }
+
+ static void PollsetDestroy(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
+ grpc_pollset* pollset = (grpc_pollset*)arg;
+ grpc_pollset_destroy(exec_ctx, 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.cc b/test/core/transport/chttp2/stream_map_test.cc
index 23a7b3f4c2..9b21cb2364 100644
--- a/test/core/transport/chttp2/stream_map_test.cc
+++ 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);
}
@@ -56,13 +56,13 @@ static void test_double_deletion(void) {
GPR_ASSERT(1 == grpc_chttp2_stream_map_size(&map));
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);
}
@@ -81,8 +81,8 @@ static void test_basic_add_find(uint32_t n) {
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);
@@ -103,14 +103,14 @@ static void check_delete_evens(grpc_chttp2_stream_map* map, uint32_t n) {
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));
}
}
diff --git a/test/core/transport/connectivity_state_test.cc b/test/core/transport/connectivity_state_test.cc
index 8cd7b30b66..11046e126e 100644
--- a/test/core/transport/connectivity_state_test.cc
+++ b/test/core/transport/connectivity_state_test.cc
@@ -23,6 +23,7 @@
#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)
@@ -84,7 +85,7 @@ static void test_subscribe_then_unsubscribe(void) {
grpc_exec_ctx_flush(&exec_ctx);
GPR_ASSERT(state == GRPC_CHANNEL_IDLE);
GPR_ASSERT(g_counter == 0);
- grpc_connectivity_state_notify_on_state_change(&exec_ctx, &tracker, NULL,
+ grpc_connectivity_state_notify_on_state_change(&exec_ctx, &tracker, nullptr,
closure);
grpc_exec_ctx_flush(&exec_ctx);
GPR_ASSERT(state == GRPC_CHANNEL_IDLE);
@@ -136,7 +137,7 @@ static void test_subscribe_with_failure_then_destroy(void) {
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
- grpc_connectivity_state_trace.value = 1;
+ grpc_core::testing::grpc_tracer_enable_flag(&grpc_connectivity_state_trace);
test_connectivity_state_name();
test_check();
test_subscribe_then_unsubscribe();
diff --git a/test/core/transport/stream_owned_slice_test.cc b/test/core/transport/stream_owned_slice_test.cc
index 0b592a0496..e82df2117d 100644
--- a/test/core/transport/stream_owned_slice_test.cc
+++ b/test/core/transport/stream_owned_slice_test.cc
@@ -29,7 +29,7 @@ int main(int argc, char** argv) {
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));
diff --git a/test/core/tsi/fake_transport_security_test.cc b/test/core/tsi/fake_transport_security_test.cc
index 32b0f898af..73643fc9fd 100644
--- a/test/core/tsi/fake_transport_security_test.cc
+++ b/test/core/tsi/fake_transport_security_test.cc
@@ -41,12 +41,12 @@ static void fake_test_setup_handshakers(tsi_test_fixture* fixture) {
}
static void validate_handshaker_peers(tsi_handshaker_result* result) {
- GPR_ASSERT(result != NULL);
+ GPR_ASSERT(result != nullptr);
tsi_peer peer;
GPR_ASSERT(tsi_handshaker_result_extract_peer(result, &peer) == TSI_OK);
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);
diff --git a/test/core/tsi/ssl_transport_security_test.cc b/test/core/tsi/ssl_transport_security_test.cc
index 0903ce8625..8939c0434b 100644
--- a/test/core/tsi/ssl_transport_security_test.cc
+++ b/test/core/tsi/ssl_transport_security_test.cc
@@ -82,19 +82,19 @@ typedef struct 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);
+ 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,11 +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,
+ 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 ||
@@ -125,18 +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, num_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,15 +147,15 @@ static void ssl_test_setup_handshakers(tsi_test_fixture* fixture) {
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);
+ 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);
+ GPR_ASSERT(alpn_property != nullptr);
const char* expected_match = "baz";
GPR_ASSERT(memcmp(alpn_property->value.data, expected_match,
alpn_property->value.length) == 0);
@@ -165,12 +166,12 @@ 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(
peer, TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY);
- GPR_ASSERT(property != NULL);
+ GPR_ASSERT(property != nullptr);
return property;
}
@@ -182,7 +183,7 @@ void check_server0_peer(tsi_peer* peer) {
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);
@@ -226,8 +227,8 @@ void check_server1_peer(tsi_peer* 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);
+ 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 ==
@@ -244,8 +245,8 @@ static void check_client_peer(ssl_tsi_test_fixture* ssl_fixture,
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);
+ 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 =
@@ -256,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(
@@ -270,7 +271,7 @@ 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);
}
}
@@ -281,7 +282,7 @@ static void ssl_test_pem_key_cert_pair_destroy(tsi_ssl_pem_key_cert_pair kp) {
static void ssl_test_destruct(tsi_test_fixture* fixture) {
ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
- if (ssl_fixture == NULL) {
+ if (ssl_fixture == nullptr) {
return;
}
/* Destroy ssl_alpn_lib. */
@@ -397,7 +398,7 @@ 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;
}
@@ -548,9 +549,9 @@ static bool handshaker_factory_destructor_called;
static void ssl_tsi_test_handshaker_factory_destructor(
tsi_ssl_handshaker_factory* factory) {
- GPR_ASSERT(factory != NULL);
+ 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);
}
}
@@ -565,8 +566,8 @@ void test_tsi_ssl_client_handshaker_factory_refcounting() {
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(
@@ -609,7 +610,7 @@ 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;
@@ -644,8 +645,8 @@ void test_tsi_ssl_client_handshaker_factory_bad_params() {
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);
}
diff --git a/test/core/tsi/transport_security_test.cc b/test/core/tsi/transport_security_test.cc
index 39adf2fab6..c788ad96ad 100644
--- a/test/core/tsi/transport_security_test.cc
+++ b/test/core/tsi/transport_security_test.cc
@@ -54,29 +54,29 @@ typedef struct {
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,107 +84,111 @@ 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"},
};
@@ -202,7 +206,7 @@ typedef struct {
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;
}
@@ -211,7 +215,7 @@ static parsed_names parse_names(const char* names_str) {
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);
@@ -230,8 +234,8 @@ static parsed_names parse_names(const char* names_str) {
static void destruct_parsed_names(parsed_names* pdn) {
name_list* nl = pdn->names;
- if (pdn->buffer != NULL) gpr_free(pdn->buffer);
- while (nl != NULL) {
+ 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);
@@ -264,7 +268,7 @@ 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) {
+ while (nl != nullptr) {
char* processed = processed_name(nl->name);
GPR_ASSERT(tsi_construct_string_peer_property(
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, processed,
@@ -274,7 +278,7 @@ static tsi_peer peer_from_cert_name_test_entry(
}
nl = ip_entries.names;
- while (nl != NULL) {
+ while (nl != nullptr) {
char* processed = processed_name(nl->name);
GPR_ASSERT(tsi_construct_string_peer_property(
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, processed,
@@ -294,8 +298,8 @@ char* cert_name_test_entry_to_string(const cert_name_test_entry* entry) {
"%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;
}
@@ -344,25 +348,26 @@ 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) {
@@ -370,7 +375,7 @@ static void test_handshaker_invalid_state(void) {
tsi_peer peer;
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);
}
diff --git a/test/core/tsi/transport_security_test_lib.cc b/test/core/tsi/transport_security_test_lib.cc
index af8316873e..3537366de9 100644
--- a/test/core/tsi/transport_security_test_lib.cc
+++ b/test/core/tsi/transport_security_test_lib.cc
@@ -55,8 +55,8 @@ typedef struct handshaker_args {
static handshaker_args* handshaker_args_create(tsi_test_fixture* fixture,
bool is_client) {
- GPR_ASSERT(fixture != NULL);
- GPR_ASSERT(fixture->config != NULL);
+ GPR_ASSERT(fixture != nullptr);
+ GPR_ASSERT(fixture->config != nullptr);
handshaker_args* args =
static_cast<handshaker_args*>(gpr_zalloc(sizeof(*args)));
args->fixture = fixture;
@@ -77,9 +77,9 @@ static void handshaker_args_destroy(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);
+ GPR_ASSERT(fixture != nullptr);
+ GPR_ASSERT(fixture->vtable != nullptr);
+ GPR_ASSERT(fixture->vtable->setup_handshakers != nullptr);
fixture->vtable->setup_handshakers(fixture);
}
@@ -90,7 +90,7 @@ static void check_unused_bytes(tsi_test_fixture* fixture) {
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);
@@ -99,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);
+ 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;
@@ -123,14 +124,14 @@ 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,
bool is_client) {
- GPR_ASSERT(fixture != NULL);
- GPR_ASSERT(buf != NULL);
+ GPR_ASSERT(fixture != nullptr);
+ GPR_ASSERT(buf != nullptr);
uint8_t* channel =
is_client ? fixture->server_channel : fixture->client_channel;
- GPR_ASSERT(channel != NULL);
+ 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);
@@ -138,14 +139,15 @@ static void send_bytes_to_peer(tsi_test_fixture* fixture,
}
static void maybe_append_unused_bytes(handshaker_args* args) {
- GPR_ASSERT(args != NULL);
- GPR_ASSERT(args->fixture != NULL);
+ 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,
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;
}
}
@@ -154,18 +156,18 @@ static void maybe_append_unused_bytes(handshaker_args* args) {
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);
+ 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);
+ 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
: &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;
@@ -179,9 +181,9 @@ 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);
+ 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));
@@ -189,7 +191,7 @@ static void send_message_to_peer(tsi_test_fixture* fixture,
is_client ? config->client_message_size : config->server_message_size;
uint8_t* message =
is_client ? config->client_message : config->server_message;
- GPR_ASSERT(message != NULL);
+ 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. */
@@ -230,11 +232,11 @@ static void receive_message_from_peer(tsi_test_fixture* fixture,
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);
+ 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;
@@ -287,8 +289,8 @@ grpc_error* on_handshake_next_done(tsi_result result, void* user_data,
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);
+ 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. */
@@ -303,10 +305,10 @@ grpc_error* on_handshake_next_done(tsi_result result, void* user_data,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshake failed"), result);
}
/* Update handshaker result. */
- if (handshaker_result != NULL) {
+ 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. */
@@ -315,7 +317,7 @@ 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);
@@ -331,11 +333,11 @@ static void on_handshake_next_done_wrapper(
}
static bool is_handshake_finished_properly(handshaker_args* args) {
- GPR_ASSERT(args != NULL);
- GPR_ASSERT(args->fixture != NULL);
+ GPR_ASSERT(args != nullptr);
+ GPR_ASSERT(args->fixture != nullptr);
tsi_test_fixture* fixture = args->fixture;
- if ((args->is_client && fixture->client_result != NULL) ||
- (!args->is_client && fixture->server_result != NULL)) {
+ if ((args->is_client && fixture->client_result != nullptr) ||
+ (!args->is_client && fixture->server_result != nullptr)) {
return true;
}
return false;
@@ -343,16 +345,16 @@ static bool is_handshake_finished_properly(handshaker_args* args) {
static void do_handshaker_next(handshaker_args* args) {
/* Initialization. */
- GPR_ASSERT(args != NULL);
- GPR_ASSERT(args->fixture != NULL);
+ 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. */
@@ -399,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. */
@@ -409,11 +412,11 @@ void tsi_test_do_handshake(tsi_test_fixture* fixture) {
void tsi_test_do_round_trip(tsi_test_fixture* fixture) {
/* Initialization. */
- GPR_ASSERT(fixture != NULL);
- GPR_ASSERT(fixture->config != NULL);
+ GPR_ASSERT(fixture != nullptr);
+ GPR_ASSERT(fixture->config != nullptr);
tsi_test_frame_protector_config* config = fixture->config;
- tsi_frame_protector* client_frame_protector = NULL;
- tsi_frame_protector* server_frame_protector = NULL;
+ tsi_frame_protector* client_frame_protector = nullptr;
+ tsi_frame_protector* server_frame_protector = nullptr;
/* Perform handshake. */
tsi_test_do_handshake(fixture);
/* Create frame protectors.*/
@@ -422,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 =
@@ -430,7 +433,7 @@ 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. */
@@ -536,7 +539,7 @@ void tsi_test_frame_protector_config_set_buffer_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;
@@ -548,7 +551,7 @@ 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);
+ GPR_ASSERT(config != nullptr);
gpr_free(config->client_message);
gpr_free(config->server_message);
gpr_free(config);
@@ -574,7 +577,7 @@ void tsi_test_fixture_init(tsi_test_fixture* fixture) {
}
void tsi_test_fixture_destroy(tsi_test_fixture* fixture) {
- GPR_ASSERT(fixture != NULL);
+ GPR_ASSERT(fixture != nullptr);
tsi_test_frame_protector_config_destroy(fixture->config);
tsi_handshaker_destroy(fixture->client_handshaker);
tsi_handshaker_destroy(fixture->server_handshaker);
@@ -582,8 +585,8 @@ 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);
diff --git a/test/core/util/BUILD b/test/core/util/BUILD
index bc6fe9dd64..2237cfc173 100644
--- a/test/core/util/BUILD
+++ b/test/core/util/BUILD
@@ -16,7 +16,10 @@ 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",
@@ -49,18 +52,22 @@ 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",
@@ -69,13 +76,14 @@ grpc_cc_library(
"reconnect_server.h",
"slice_splitter.h",
"test_tcp_server.h",
+ "tracer_util.h",
"trickle_endpoint.h",
],
language = "C++",
deps = [
":gpr_test_util",
+ ":grpc_debugger_macros",
"//:grpc_common",
- ":grpc_debugger_macros"
],
)
@@ -103,14 +111,25 @@ grpc_cc_library(
grpc_cc_library(
name = "fuzzer_corpus_test",
+ testonly = 1,
srcs = ["fuzzer_corpus_test.cc"],
+ external_deps = [
+ "gtest",
+ "gflags",
+ ],
deps = [
":gpr_test_util",
"//:grpc",
],
- external_deps = [
- "gtest",
- "gflags",
+)
+
+grpc_cc_test(
+ name = "histogram_test",
+ srcs = ["histogram_test.cc"],
+ language = "C++",
+ deps = [
+ ":grpc_test_util",
+ "//:gpr",
],
)
@@ -118,3 +137,8 @@ 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.cc b/test/core/util/debugger_macros.cc
index d344c3fb74..f1e4ffd3af 100644
--- a/test/core/util/debugger_macros.cc
+++ b/test/core/util/debugger_macros.cc
@@ -37,16 +37,16 @@ grpc_stream* grpc_transport_stream_from_call(grpc_call* call) {
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) {
+ if (scc == nullptr) {
fprintf(stderr, "No subchannel-call");
- return NULL;
+ 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;
+ return nullptr;
}
}
}
diff --git a/test/core/util/fuzzer_corpus_test.cc b/test/core/util/fuzzer_corpus_test.cc
index a5e99a1bac..7849321257 100644
--- a/test/core/util/fuzzer_corpus_test.cc
+++ b/test/core/util/fuzzer_corpus_test.cc
@@ -29,8 +29,15 @@
#include "test/core/util/test_config.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);
-extern "C" bool squelch;
-extern "C" bool leak_check;
+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");
@@ -65,7 +72,7 @@ class ExampleGenerator
struct dirent* ep;
dp = opendir(FLAGS_directory.c_str());
- if (dp != NULL) {
+ if (dp != nullptr) {
while ((ep = readdir(dp)) != nullptr) {
if (ep->d_type == DT_REG) {
examples_.push_back(FLAGS_directory + "/" + ep->d_name);
@@ -129,7 +136,7 @@ INSTANTIATE_TEST_CASE_P(
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
- ::gflags::ParseCommandLineFlags(&argc, &argv, true);
+ 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 55b6f1c1a5..b8b270ecd0 100644
--- a/test/core/util/grpc_fuzzer.bzl
+++ b/test/core/util/grpc_fuzzer.bzl
@@ -19,8 +19,7 @@ def grpc_fuzzer(name, corpus, srcs = [], deps = [], **kwargs):
name = name,
srcs = srcs,
deps = deps + ["//test/core/util:fuzzer_corpus_test"],
- data = [corpus],
- args = ['--directory', '$(location %s)' % corpus],
+ data = native.glob([corpus + "/**"]),
external_deps = [
'gtest',
],
diff --git a/src/core/lib/support/histogram.cc b/test/core/util/histogram.cc
index 73c821a28b..2f916f831d 100644
--- a/src/core/lib/support/histogram.cc
+++ 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 */
@@ -55,25 +55,25 @@ struct gpr_histogram {
};
/* 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;
@@ -91,12 +91,12 @@ gpr_histogram* gpr_histogram_create(double resolution,
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;
@@ -190,38 +190,38 @@ static double threshold_for_count_below(gpr_histogram* h, double count_below) {
}
}
-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.cc b/test/core/util/memory_counters.cc
index ff85a63803..32d7b89c9a 100644
--- a/test/core/util/memory_counters.cc
+++ b/test/core/util/memory_counters.cc
@@ -43,7 +43,7 @@ static void guard_free(void* vptr);
static void* guard_malloc(size_t size) {
size_t* ptr;
- if (!size) return NULL;
+ 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);
@@ -55,12 +55,12 @@ static void* guard_malloc(size_t size) {
static void* guard_realloc(void* vptr, size_t size) {
size_t* ptr = (size_t*)vptr;
- if (vptr == NULL) {
+ 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);
@@ -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.cc b/test/core/util/mock_endpoint.cc
index a467dcdc18..d9545efa49 100644
--- a/test/core/util/mock_endpoint.cc
+++ b/test/core/util/mock_endpoint.cc
@@ -81,7 +81,7 @@ static void me_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
GRPC_CLOSURE_SCHED(exec_ctx, 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);
@@ -130,7 +130,7 @@ grpc_endpoint* grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice),
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;
}
@@ -138,10 +138,10 @@ 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;
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;
+ m->on_read = nullptr;
} else {
grpc_slice_buffer_add(&m->read_buffer, slice);
}
diff --git a/test/core/util/parse_hexstring.cc b/test/core/util/parse_hexstring.cc
index 6dee0f163a..622642a298 100644
--- a/test/core/util/parse_hexstring.cc
+++ b/test/core/util/parse_hexstring.cc
@@ -21,7 +21,7 @@
grpc_slice parse_hexstring(const char* hexstring) {
size_t nibbles = 0;
- const char* p = 0;
+ const char* p = nullptr;
uint8_t* out;
uint8_t temp;
grpc_slice slice;
diff --git a/test/core/util/passthru_endpoint.cc b/test/core/util/passthru_endpoint.cc
index acce902010..a9efe22b69 100644
--- a/test/core/util/passthru_endpoint.cc
+++ b/test/core/util/passthru_endpoint.cc
@@ -85,12 +85,12 @@ static void me_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
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;
+ m->on_read = nullptr;
} else {
for (size_t i = 0; i < slices->count; i++) {
grpc_slice_buffer_add(&m->read_buffer,
@@ -120,14 +120,14 @@ static void me_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
GRPC_CLOSURE_SCHED(
exec_ctx, 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,
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);
@@ -182,7 +182,7 @@ static void half_init(half* m, passthru_endpoint* parent,
m->base.vtable = &vtable;
m->parent = parent;
grpc_slice_buffer_init(&m->read_buffer);
- m->on_read = NULL;
+ m->on_read = nullptr;
char* name;
gpr_asprintf(&name, "passthru_endpoint_%s_%" PRIxPTR, half_name,
(intptr_t)parent);
@@ -197,7 +197,7 @@ void grpc_passthru_endpoint_create(grpc_endpoint** client,
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/port.cc b/test/core/util/port.cc
index c5bebe08e7..9d02b673ed 100644
--- a/test/core/util/port.cc
+++ 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,7 +71,7 @@ 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++;
@@ -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.cc b/test/core/util/port_server_client.cc
index 927bc91d38..edec50b424 100644
--- a/test/core/util/port_server_client.cc
+++ b/test/core/util/port_server_client.cc
@@ -55,7 +55,7 @@ static void freed_port_from_server(grpc_exec_ctx* exec_ctx, void* arg,
GRPC_LOG_IF_ERROR(
"pollset_kick",
grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&pr->pops),
- NULL));
+ nullptr));
gpr_mu_unlock(pr->mu);
}
@@ -96,7 +96,7 @@ void grpc_free_port_using_server(int port) {
grpc_exec_ctx_flush(&exec_ctx);
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),
@@ -155,7 +155,7 @@ static void got_port_from_server(grpc_exec_ctx* exec_ctx, void* arg,
GRPC_LOG_IF_ERROR(
"pollset_kick",
grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&pr->pops),
- NULL));
+ nullptr));
gpr_mu_unlock(pr->mu);
return;
}
@@ -192,7 +192,7 @@ static void got_port_from_server(grpc_exec_ctx* exec_ctx, void* arg,
GRPC_LOG_IF_ERROR(
"pollset_kick",
grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&pr->pops),
- NULL));
+ nullptr));
gpr_mu_unlock(pr->mu);
}
@@ -231,7 +231,7 @@ int grpc_pick_port_using_server(void) {
grpc_exec_ctx_flush(&exec_ctx);
gpr_mu_lock(pr.mu);
while (pr.port == -1) {
- 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),
diff --git a/test/core/util/reconnect_server.cc b/test/core/util/reconnect_server.cc
index c7c0595d7f..4775b074eb 100644
--- a/test/core/util/reconnect_server.cc
+++ b/test/core/util/reconnect_server.cc
@@ -70,10 +70,10 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
grpc_endpoint_destroy(exec_ctx, 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) {
@@ -84,8 +84,8 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
}
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 {
@@ -97,9 +97,9 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
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;
}
@@ -118,9 +118,9 @@ void reconnect_server_clear_timestamps(reconnect_server* server) {
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) {
diff --git a/test/core/util/run_with_poller.sh b/test/core/util/run_with_poller.sh
new file mode 100755
index 0000000000..05791457a2
--- /dev/null
+++ b/test/core/util/run_with_poller.sh
@@ -0,0 +1,19 @@
+#!/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
+export GRPC_POLL_STRATEGY=$1
+shift
+$@
diff --git a/test/core/util/slice_splitter.cc b/test/core/util/slice_splitter.cc
index e25e1d862a..7225b6dc03 100644
--- a/test/core/util/slice_splitter.cc
+++ b/test/core/util/slice_splitter.cc
@@ -105,7 +105,7 @@ void grpc_split_slice_buffer(grpc_slice_split_mode mode, grpc_slice_buffer* src,
}
grpc_slice grpc_slice_merge(grpc_slice* slices, size_t nslices) {
- uint8_t* out = NULL;
+ uint8_t* out = nullptr;
size_t length = 0;
size_t capacity = 0;
size_t i;
diff --git a/test/core/util/test_config.cc b/test/core/util/test_config.cc
index 3106fb01ea..9ebb52d83e 100644
--- a/test/core/util/test_config.cc
+++ b/test/core/util/test_config.cc
@@ -203,7 +203,7 @@ static void install_crash_handler() {
#define SIGNAL_NAMES_LENGTH 32
static const char* const signal_names[] = {
- NULL, "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP",
+ nullptr, "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP",
"SIGABRT", "SIGBUS", "SIGFPE", "SIGKILL", "SIGUSR1", "SIGSEGV",
"SIGUSR2", "SIGPIPE", "SIGALRM", "SIGTERM", "SIGSTKFLT", "SIGCHLD",
"SIGCONT", "SIGSTOP", "SIGTSTP", "SIGTTIN", "SIGTTOU", "SIGURG",
@@ -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() {}
@@ -380,7 +380,7 @@ 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")) {
+ 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 4383fbfce8..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
-
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
-
#endif /* GRPC_TEST_CORE_UTIL_TEST_CONFIG_H */
diff --git a/test/core/util/test_tcp_server.cc b/test/core/util/test_tcp_server.cc
index 925209d255..da34da6fd0 100644
--- a/test/core/util/test_tcp_server.cc
+++ b/test/core/util/test_tcp_server.cc
@@ -42,7 +42,7 @@ static void on_server_destroyed(grpc_exec_ctx* exec_ctx, void* 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;
@@ -63,7 +63,7 @@ void test_tcp_server_start(test_tcp_server* server, int 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);
+ &exec_ctx, &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);
@@ -78,7 +78,7 @@ void test_tcp_server_start(test_tcp_server* server, int port) {
}
void test_tcp_server_poll(test_tcp_server* server, int seconds) {
- grpc_pollset_worker* worker = NULL;
+ grpc_pollset_worker* worker = nullptr;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_millis deadline = grpc_timespec_to_millis_round_up(
grpc_timeout_seconds_to_deadline(seconds));
@@ -101,7 +101,7 @@ void test_tcp_server_destroy(test_tcp_server* server) {
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_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));
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/test/core/util/tracer_util.h b/test/core/util/tracer_util.h
new file mode 100644
index 0000000000..0b432ffa46
--- /dev/null
+++ b/test/core/util/tracer_util.h
@@ -0,0 +1,32 @@
+/*
+ *
+ * Copyright 2015 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef GRPC_TEST_CORE_UTIL_TRACER_UTIL_H
+#define GRPC_TEST_CORE_UTIL_TRACER_UTIL_H
+
+namespace grpc_core {
+class TraceFlag;
+
+namespace testing {
+// enables the TraceFlag passed to it. Used for testing purposes.
+void grpc_tracer_enable_flag(grpc_core::TraceFlag* flag);
+
+} // namespace testing
+} // namespace grpc_core
+
+#endif /* GRPC_TEST_CORE_UTIL_TRACER_UTIL_H */
diff --git a/test/core/util/trickle_endpoint.cc b/test/core/util/trickle_endpoint.cc
index c8b54b481d..4544fb7f49 100644
--- a/test/core/util/trickle_endpoint.cc
+++ b/test/core/util/trickle_endpoint.cc
@@ -53,10 +53,11 @@ static void te_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
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)) {
+ if (te->write_cb != nullptr &&
+ (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;
+ te->write_cb = nullptr;
}
}
@@ -64,7 +65,7 @@ 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;
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);
}
@@ -159,7 +160,7 @@ grpc_endpoint* grpc_trickle_endpoint_create(grpc_endpoint* wrap,
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);
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..0954b28df0
--- /dev/null
+++ b/test/cpp/client/client_channel_stress_test.cc
@@ -0,0 +1,327 @@
+/*
+ *
+ * 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 <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::random_shuffle(random_backend_indices.begin(),
+ random_backend_indices.end());
+ // 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::random_shuffle(addresses.begin(), addresses.end());
+ 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_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ 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);
+ 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(
+ &exec_ctx, response_generator_, &fake_result);
+ grpc_lb_addresses_destroy(&exec_ctx, addresses);
+ grpc_exec_ctx_finish(&exec_ctx);
+ }
+
+ 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/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/common/auth_property_iterator_test.cc b/test/cpp/common/auth_property_iterator_test.cc
index 4a097e8739..fce409aa2f 100644
--- a/test/cpp/common/auth_property_iterator_test.cc
+++ b/test/cpp/common/auth_property_iterator_test.cc
@@ -40,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/secure_auth_context_test.cc b/test/cpp/common/secure_auth_context_test.cc
index 0cc32c1853..7a0530c20a 100644
--- a/test/cpp/common/secure_auth_context_test.cc
+++ b/test/cpp/common/secure_auth_context_test.cc
@@ -42,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");
@@ -60,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/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index 5b6e9aa312..1ea087e706 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -466,7 +466,7 @@ TEST_P(AsyncEnd2endTest, ReconnectChannel) {
// It needs 2 pollset_works to reconnect the channel with polling engine
// "poll"
char* s = gpr_getenv("GRPC_POLL_STRATEGY");
- if (s != NULL && 0 == strcmp(s, "poll")) {
+ if (s != nullptr && 0 == strcmp(s, "poll")) {
poller_slowdown_factor = 2;
}
gpr_free(s);
diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc
index 95630a7714..f8bb12fde1 100644
--- a/test/cpp/end2end/client_lb_end2end_test.cc
+++ b/test/cpp/end2end/client_lb_end2end_test.cc
@@ -113,22 +113,23 @@ 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_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);
+ 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_channel_args_copy_and_add(nullptr, &fake_addresses, 1);
grpc_fake_resolver_response_generator_set_response(
&exec_ctx, response_generator_, fake_result);
grpc_channel_args_destroy(&exec_ctx, fake_result);
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index 82ca39466e..c71034bbe8 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -711,7 +711,7 @@ TEST_P(End2endTest, ReconnectChannel) {
// It needs 2 pollset_works to reconnect the channel with polling engine
// "poll"
char* s = gpr_getenv("GRPC_POLL_STRATEGY");
- if (s != NULL && 0 == strcmp(s, "poll")) {
+ if (s != nullptr && 0 == strcmp(s, "poll")) {
poller_slowdown_factor = 2;
}
gpr_free(s);
@@ -1148,7 +1148,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);
diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc
index c15ab88da1..bbf3da4663 100644
--- a/test/cpp/end2end/grpclb_end2end_test.cc
+++ b/test/cpp/end2end/grpclb_end2end_test.cc
@@ -353,11 +353,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 {
@@ -370,6 +365,14 @@ class GrpclbEnd2endTest : public ::testing::Test {
grpc_fake_resolver_response_generator_unref(response_generator_);
}
+ 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);
@@ -581,6 +584,7 @@ class SingleBalancerTest : public GrpclbEnd2endTest {
};
TEST_F(SingleBalancerTest, Vanilla) {
+ SetNextResolutionAllBalancers();
const size_t kNumRpcsPerAddress = 100;
ScheduleResponseForBalancer(
0, BalancerServiceImpl::BuildResponseForBackends(GetBackendPorts(), {}),
@@ -608,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();
@@ -645,6 +650,7 @@ TEST_F(SingleBalancerTest, InitiallyEmptyServerlist) {
}
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;
@@ -711,6 +717,7 @@ TEST_F(SingleBalancerTest, Fallback) {
}
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;
@@ -818,6 +825,7 @@ TEST_F(SingleBalancerTest, FallbackUpdate) {
}
TEST_F(SingleBalancerTest, BackendsRestart) {
+ SetNextResolutionAllBalancers();
const size_t kNumRpcsPerAddress = 100;
ScheduleResponseForBalancer(
0, BalancerServiceImpl::BuildResponseForBackends(GetBackendPorts(), {}),
@@ -857,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(
@@ -919,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]};
@@ -989,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]};
@@ -1030,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);
@@ -1055,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.
@@ -1064,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;
@@ -1107,6 +1127,7 @@ 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;
@@ -1122,6 +1143,7 @@ TEST_F(SingleBalancerTest, DropAllFirst) {
}
TEST_F(SingleBalancerTest, DropAll) {
+ SetNextResolutionAllBalancers();
ScheduleResponseForBalancer(
0, BalancerServiceImpl::BuildResponseForBackends(GetBackendPorts(), {}),
0);
@@ -1152,6 +1174,7 @@ class SingleBalancerWithClientLoadReportingTest : public GrpclbEnd2endTest {
};
TEST_F(SingleBalancerWithClientLoadReportingTest, Vanilla) {
+ SetNextResolutionAllBalancers();
const size_t kNumRpcsPerAddress = 100;
ScheduleResponseForBalancer(
0, BalancerServiceImpl::BuildResponseForBackends(GetBackendPorts(), {}),
@@ -1186,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;
diff --git a/test/cpp/grpclb/grpclb_api_test.cc b/test/cpp/grpclb/grpclb_api_test.cc
index 54b5708e6a..03778e1fc5 100644
--- a/test/cpp/grpclb/grpclb_api_test.cc
+++ b/test/cpp/grpclb/grpclb_api_test.cc
@@ -48,7 +48,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;
}
diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc
index d032c0dfcc..62ae495177 100644
--- a/test/cpp/grpclb/grpclb_test.cc
+++ b/test/cpp/grpclb/grpclb_test.cc
@@ -149,7 +149,7 @@ 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);
}
@@ -188,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);
@@ -222,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);
@@ -252,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);
@@ -274,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);
@@ -318,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);
@@ -341,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);
@@ -359,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",
@@ -388,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 {
@@ -422,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);
@@ -459,10 +463,10 @@ 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;
@@ -474,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++) {
@@ -498,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);
@@ -522,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);
@@ -550,20 +554,20 @@ 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;
- char* expected_target_names = NULL;
+ 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_create();
- grpc_lb_addresses* addresses = grpc_lb_addresses_create(1, NULL);
+ 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);
+ 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);
@@ -571,22 +575,22 @@ static void setup_client(const server_fixture* lb_server,
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_channel_args_copy_and_add(nullptr, &fake_addresses, 1);
grpc_lb_addresses_destroy(&exec_ctx, 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);
+ 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_secure_channel_create(fake_creds, cf->server_uri, args, nullptr);
grpc_fake_resolver_response_generator_set_response(
&exec_ctx, response_generator, fake_result);
grpc_channel_args_destroy(&exec_ctx, fake_result);
@@ -600,16 +604,16 @@ 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) {
int assigned_port;
- sf->cq = grpc_completion_queue_create_for_next(NULL);
+ 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;
@@ -623,8 +627,8 @@ static void setup_server(const char* host, server_fixture* sf) {
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);
@@ -638,17 +642,17 @@ static void teardown_server(server_fixture* sf) {
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_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);
@@ -689,14 +693,15 @@ 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;
}
diff --git a/test/cpp/interop/http2_client.cc b/test/cpp/interop/http2_client.cc
index 1e04e57d09..2de7abcf17 100644
--- a/test/cpp/interop/http2_client.cc
+++ b/test/cpp/interop/http2_client.cc
@@ -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_server.cc b/test/cpp/interop/interop_server.cc
index a24cdc7d2d..30bd8bfef8 100644
--- a/test/cpp/interop/interop_server.cc
+++ b/test/cpp/interop/interop_server.cc
@@ -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/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 991fc88ad2..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.");
@@ -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;
diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc
index ec5c1275d1..a45c577320 100644
--- a/test/cpp/microbenchmarks/bm_call_create.cc
+++ b/test/cpp/microbenchmarks/bm_call_create.cc
@@ -91,7 +91,7 @@ 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 {
@@ -105,14 +105,14 @@ template <class Fixture>
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);
@@ -161,7 +161,7 @@ static void BM_LameChannelCallCreateCore(benchmark::State& state) {
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;
@@ -170,14 +170,14 @@ 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);
+ cq = grpc_completion_queue_create_for_next(nullptr);
void* rc = grpc_channel_register_call(
- channel, "/grpc.testing.EchoTestService/Echo", NULL, NULL);
+ 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);
+ 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 =
@@ -210,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);
@@ -235,7 +235,7 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State& state) {
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;
@@ -244,14 +244,14 @@ 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);
+ cq = grpc_completion_queue_create_for_next(nullptr);
void* rc = grpc_channel_register_call(
- channel, "/grpc.testing.EchoTestService/Echo", NULL, NULL);
+ 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);
+ 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 =
@@ -271,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;
@@ -289,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);
@@ -538,7 +538,7 @@ static void BM_IsolatedFilter(benchmark::State& state) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
size_t channel_size = grpc_channel_stack_size(
- filters.size() == 0 ? NULL : &filters[0], filters.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(
@@ -559,8 +559,8 @@ static void BM_IsolatedFilter(benchmark::State& state) {
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;
@@ -569,9 +569,9 @@ static void BM_IsolatedFilter(benchmark::State& state) {
while (state.KeepRunning()) {
GPR_TIMER_SCOPE("BenchmarkCycle", 0);
GRPC_ERROR_UNREF(grpc_call_stack_init(&exec_ctx, channel_stack, 1,
- DoNothing, NULL, &call_args));
+ DoNothing, nullptr, &call_args));
typename TestOp::Op op(&exec_ctx, &test_op_data, call_stack);
- grpc_call_stack_destroy(&exec_ctx, call_stack, &final_info, NULL);
+ grpc_call_stack_destroy(&exec_ctx, call_stack, &final_info, nullptr);
op.Finish(&exec_ctx);
grpc_exec_ctx_flush(&exec_ctx);
// recreate arena every 64k iterations to avoid oom
@@ -708,14 +708,15 @@ class IsolatedCallFixture : public TrackCounters {
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);
}
- cq_ = grpc_completion_queue_create_for_next(NULL);
+ cq_ = grpc_completion_queue_create_for_next(nullptr);
}
void Finish(benchmark::State& state) {
@@ -735,13 +736,13 @@ class IsolatedCallFixture : public TrackCounters {
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);
}
@@ -750,11 +751,11 @@ BENCHMARK(BM_IsolatedCall_NoOp);
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* recv_message = nullptr;
grpc_status_code status_code;
grpc_slice status_details = grpc_empty_slice();
grpc_metadata_array recv_initial_metadata;
@@ -780,10 +781,10 @@ static void BM_IsolatedCall_Unary(benchmark::State& state) {
GPR_TIMER_SCOPE("BenchmarkCycle", 0);
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);
@@ -796,8 +797,8 @@ BENCHMARK(BM_IsolatedCall_Unary);
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_metadata_array recv_initial_metadata;
@@ -812,18 +813,18 @@ static void BM_IsolatedCall_StreamingSend(benchmark::State& state) {
&recv_initial_metadata;
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 45f5382fde..3fff8b02d6 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
@@ -85,7 +85,7 @@ static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) {
(size_t)1024,
&stats,
};
- grpc_chttp2_encode_header(&exec_ctx, &c, NULL, 0, &b, &hopt, &outbuf);
+ grpc_chttp2_encode_header(&exec_ctx, &c, nullptr, 0, &b, &hopt, &outbuf);
grpc_slice_buffer_reset_and_unref_internal(&exec_ctx, &outbuf);
grpc_exec_ctx_flush(&exec_ctx);
}
@@ -136,7 +136,7 @@ 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(&exec_ctx, &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++) {
@@ -775,7 +775,7 @@ static void OnHeaderNew(grpc_exec_ctx* exec_ctx, void* user_data,
grpc_millis* cached_timeout =
static_cast<grpc_millis*>(grpc_mdelem_get_user_data(md, free_timeout));
grpc_millis timeout;
- if (cached_timeout != NULL) {
+ if (cached_timeout != nullptr) {
timeout = *cached_timeout;
} else {
if (!grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout)) {
diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc
index 154cc91778..be4da4d0bd 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc
@@ -100,7 +100,7 @@ class DummyEndpoint : public grpc_endpoint {
GRPC_CLOSURE_SCHED(exec_ctx, 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_exec_ctx* exec_ctx, grpc_endpoint* ep,
grpc_pollset* pollset) {}
@@ -137,7 +137,7 @@ class Fixture {
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);
+ grpc_chttp2_transport_start_reading(exec_ctx(), t_, nullptr, nullptr);
FlushExecCtx();
}
@@ -222,7 +222,7 @@ class Stream {
}
grpc_transport_init_stream(f_->exec_ctx(), f_->transport(),
static_cast<grpc_stream*>(stream_), &refcount_,
- NULL, arena_);
+ nullptr, arena_);
}
void DestroyThen(grpc_exec_ctx* exec_ctx, grpc_closure* closure) {
@@ -586,7 +586,7 @@ static void BM_TransportStreamRecv(benchmark::State& state) {
});
drain_start = MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) {
- if (recv_stream == NULL) {
+ if (recv_stream == nullptr) {
GPR_ASSERT(!state.KeepRunning());
return;
}
diff --git a/test/cpp/microbenchmarks/bm_closure.cc b/test/cpp/microbenchmarks/bm_closure.cc
index 458a2ceb13..2434d4e84e 100644
--- a/test/cpp/microbenchmarks/bm_closure.cc
+++ b/test/cpp/microbenchmarks/bm_closure.cc
@@ -59,7 +59,7 @@ static void BM_ClosureInitAgainstExecCtx(benchmark::State& state) {
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);
}
@@ -72,7 +72,7 @@ static void BM_ClosureInitAgainstCombiner(benchmark::State& state) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
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);
@@ -83,7 +83,7 @@ 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_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
while (state.KeepRunning()) {
GRPC_CLOSURE_RUN(&exec_ctx, &c, GRPC_ERROR_NONE);
@@ -100,7 +100,7 @@ static void BM_ClosureCreateAndRun(benchmark::State& state) {
while (state.KeepRunning()) {
GRPC_CLOSURE_RUN(
&exec_ctx,
- GRPC_CLOSURE_CREATE(DoNothing, NULL, grpc_schedule_on_exec_ctx),
+ GRPC_CLOSURE_CREATE(DoNothing, nullptr, grpc_schedule_on_exec_ctx),
GRPC_ERROR_NONE);
}
grpc_exec_ctx_finish(&exec_ctx);
@@ -115,7 +115,7 @@ static void BM_ClosureInitAndRun(benchmark::State& state) {
while (state.KeepRunning()) {
GRPC_CLOSURE_RUN(
&exec_ctx,
- GRPC_CLOSURE_INIT(&c, DoNothing, NULL, grpc_schedule_on_exec_ctx),
+ GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx),
GRPC_ERROR_NONE);
}
grpc_exec_ctx_finish(&exec_ctx);
@@ -126,7 +126,7 @@ 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_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
while (state.KeepRunning()) {
GRPC_CLOSURE_SCHED(&exec_ctx, &c, GRPC_ERROR_NONE);
@@ -141,8 +141,8 @@ 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_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
+ GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
while (state.KeepRunning()) {
GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
@@ -159,9 +159,9 @@ 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_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_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
while (state.KeepRunning()) {
GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
@@ -182,7 +182,7 @@ static void BM_AcquireMutex(benchmark::State& state) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
while (state.KeepRunning()) {
gpr_mu_lock(&mu);
- DoNothing(&exec_ctx, NULL, GRPC_ERROR_NONE);
+ DoNothing(&exec_ctx, nullptr, GRPC_ERROR_NONE);
gpr_mu_unlock(&mu);
}
grpc_exec_ctx_finish(&exec_ctx);
@@ -198,7 +198,7 @@ static void BM_TryAcquireMutex(benchmark::State& state) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
while (state.KeepRunning()) {
if (gpr_mu_trylock(&mu)) {
- DoNothing(&exec_ctx, NULL, GRPC_ERROR_NONE);
+ DoNothing(&exec_ctx, nullptr, GRPC_ERROR_NONE);
gpr_mu_unlock(&mu);
} else {
abort();
@@ -216,7 +216,7 @@ static void BM_AcquireSpinlock(benchmark::State& state) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
while (state.KeepRunning()) {
gpr_spinlock_lock(&mu);
- DoNothing(&exec_ctx, NULL, GRPC_ERROR_NONE);
+ DoNothing(&exec_ctx, nullptr, GRPC_ERROR_NONE);
gpr_spinlock_unlock(&mu);
}
grpc_exec_ctx_finish(&exec_ctx);
@@ -231,7 +231,7 @@ static void BM_TryAcquireSpinlock(benchmark::State& state) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
while (state.KeepRunning()) {
if (gpr_spinlock_trylock(&mu)) {
- DoNothing(&exec_ctx, NULL, GRPC_ERROR_NONE);
+ DoNothing(&exec_ctx, nullptr, GRPC_ERROR_NONE);
gpr_spinlock_unlock(&mu);
} else {
abort();
@@ -246,7 +246,7 @@ 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_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_combiner_scheduler(combiner));
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
while (state.KeepRunning()) {
GRPC_CLOSURE_SCHED(&exec_ctx, &c, GRPC_ERROR_NONE);
@@ -263,8 +263,8 @@ 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_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_combiner_scheduler(combiner));
+ GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_combiner_scheduler(combiner));
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
while (state.KeepRunning()) {
GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
@@ -283,9 +283,9 @@ 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_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_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
while (state.KeepRunning()) {
GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
@@ -305,8 +305,10 @@ 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_CLOSURE_INIT(&c1, DoNothing, nullptr,
+ grpc_combiner_scheduler(combiner1));
+ GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr,
+ grpc_combiner_scheduler(combiner2));
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
while (state.KeepRunning()) {
GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
@@ -328,10 +330,14 @@ 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_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_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
while (state.KeepRunning()) {
GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc
index dac702b08b..f0dede7333 100644
--- a/test/cpp/microbenchmarks/bm_cq.cc
+++ b/test/cpp/microbenchmarks/bm_cq.cc
@@ -47,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);
@@ -59,7 +59,8 @@ 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);
}
@@ -83,7 +84,7 @@ static void BM_Pass1Cpp(benchmark::State& state) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
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);
+ DoneWithCompletionOnStack, nullptr, &completion);
grpc_exec_ctx_finish(&exec_ctx);
void* tag;
bool ok;
@@ -96,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);
+ GPR_ASSERT(grpc_cq_begin_op(cq, nullptr));
+ grpc_cq_end_op(&exec_ctx, cq, nullptr, GRPC_ERROR_NONE,
+ DoneWithCompletionOnStack, nullptr, &completion);
grpc_exec_ctx_finish(&exec_ctx);
- grpc_completion_queue_next(cq, deadline, NULL);
+ grpc_completion_queue_next(cq, deadline, nullptr);
}
grpc_completion_queue_destroy(cq);
track_counters.Finish(state);
@@ -115,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);
+ GPR_ASSERT(grpc_cq_begin_op(cq, nullptr));
+ grpc_cq_end_op(&exec_ctx, cq, nullptr, GRPC_ERROR_NONE,
+ DoneWithCompletionOnStack, nullptr, &completion);
grpc_exec_ctx_finish(&exec_ctx);
- grpc_completion_queue_pluck(cq, NULL, deadline, NULL);
+ grpc_completion_queue_pluck(cq, nullptr, deadline, nullptr);
}
grpc_completion_queue_destroy(cq);
track_counters.Finish(state);
@@ -134,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 8d4349a297..7ccebb55ee 100644
--- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
+++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
@@ -80,7 +80,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* ps,
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(exec_ctx, 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);
gpr_mu_lock(&ps->mu);
@@ -108,7 +108,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() {
@@ -116,7 +116,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 */
}
@@ -151,7 +151,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 aa7822653f..bbd8b3c339 100644
--- a/test/cpp/microbenchmarks/bm_error.cc
+++ b/test/cpp/microbenchmarks/bm_error.cc
@@ -251,7 +251,7 @@ static void BM_ErrorGetStatus(benchmark::State& state) {
grpc_status_code status;
grpc_slice slice;
grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(),
- &status, &slice, NULL);
+ &status, &slice, nullptr, nullptr);
}
grpc_exec_ctx_finish(&exec_ctx);
track_counters.Finish(state);
@@ -265,7 +265,7 @@ static void BM_ErrorGetStatusCode(benchmark::State& state) {
while (state.KeepRunning()) {
grpc_status_code status;
grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(),
- &status, NULL, NULL);
+ &status, nullptr, nullptr, nullptr);
}
grpc_exec_ctx_finish(&exec_ctx);
track_counters.Finish(state);
@@ -278,8 +278,8 @@ static void BM_ErrorHttpError(benchmark::State& state) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
while (state.KeepRunning()) {
grpc_http2_error_code error;
- grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(), NULL,
- NULL, &error);
+ grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(),
+ nullptr, nullptr, &error, nullptr);
}
grpc_exec_ctx_finish(&exec_ctx);
track_counters.Finish(state);
diff --git a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
index f75c3e4436..5e72213823 100644
--- a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
+++ b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
@@ -216,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++;
}
}
@@ -445,7 +445,7 @@ BENCHMARK(BM_PumpUnbalancedUnary_Trickle)->Apply(UnaryTrickleArgs);
} // namespace testing
} // namespace grpc
-extern "C" gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type);
+extern gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type);
int main(int argc, char** argv) {
::benchmark::Initialize(&argc, argv);
diff --git a/test/cpp/microbenchmarks/bm_metadata.cc b/test/cpp/microbenchmarks/bm_metadata.cc
index 1ed05f7466..73bce08466 100644
--- a/test/cpp/microbenchmarks/bm_metadata.cc
+++ b/test/cpp/microbenchmarks/bm_metadata.cc
@@ -92,7 +92,7 @@ static void BM_MetadataFromNonInternedSlices(benchmark::State& state) {
gpr_slice v = grpc_slice_from_static_string("value");
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, NULL));
+ GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr));
}
grpc_exec_ctx_finish(&exec_ctx);
track_counters.Finish(state);
@@ -105,7 +105,7 @@ static void BM_MetadataFromInternedSlices(benchmark::State& state) {
gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value"));
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, NULL));
+ GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr));
}
grpc_exec_ctx_finish(&exec_ctx);
grpc_slice_unref(k);
@@ -120,9 +120,9 @@ static void BM_MetadataFromInternedSlicesAlreadyInIndex(
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_mdelem seed = grpc_mdelem_create(&exec_ctx, k, v, nullptr);
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, NULL));
+ GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr));
}
GRPC_MDELEM_UNREF(&exec_ctx, seed);
grpc_exec_ctx_finish(&exec_ctx);
@@ -138,7 +138,7 @@ static void BM_MetadataFromInternedKey(benchmark::State& state) {
gpr_slice v = grpc_slice_from_static_string("value");
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, NULL));
+ GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr));
}
grpc_exec_ctx_finish(&exec_ctx);
grpc_slice_unref(k);
@@ -209,7 +209,7 @@ static void BM_MetadataFromStaticMetadataStrings(benchmark::State& state) {
gpr_slice v = GRPC_MDSTR_200;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, NULL));
+ GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr));
}
grpc_exec_ctx_finish(&exec_ctx);
grpc_slice_unref(k);
@@ -224,7 +224,7 @@ static void BM_MetadataFromStaticMetadataStringsNotIndexed(
gpr_slice v = GRPC_MDSTR_GZIP;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, NULL));
+ GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr));
}
grpc_exec_ctx_finish(&exec_ctx);
grpc_slice_unref(k);
@@ -273,7 +273,7 @@ static void BM_MetadataRefUnrefAllocated(benchmark::State& state) {
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"), NULL);
+ grpc_slice_from_static_string("b"), nullptr);
while (state.KeepRunning()) {
GRPC_MDELEM_UNREF(&exec_ctx, GRPC_MDELEM_REF(el));
}
@@ -287,7 +287,7 @@ static void BM_MetadataRefUnrefStatic(benchmark::State& state) {
TrackCounters track_counters;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_mdelem el =
- grpc_mdelem_create(&exec_ctx, GRPC_MDSTR_STATUS, GRPC_MDSTR_200, NULL);
+ grpc_mdelem_create(&exec_ctx, GRPC_MDSTR_STATUS, GRPC_MDSTR_200, nullptr);
while (state.KeepRunning()) {
GRPC_MDELEM_UNREF(&exec_ctx, GRPC_MDELEM_REF(el));
}
diff --git a/test/cpp/microbenchmarks/bm_pollset.cc b/test/cpp/microbenchmarks/bm_pollset.cc
index 92d76f307e..4da79693f1 100644
--- a/test/cpp/microbenchmarks/bm_pollset.cc
+++ b/test/cpp/microbenchmarks/bm_pollset.cc
@@ -117,7 +117,7 @@ static void BM_PollEmptyPollset(benchmark::State& state) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_mu_lock(mu);
while (state.KeepRunning()) {
- GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, NULL, 0));
+ GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, nullptr, 0));
}
grpc_closure shutdown_ps_closure;
GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps,
@@ -145,7 +145,8 @@ static void BM_PollAddFd(benchmark::State& state) {
grpc_pollset_add_fd(&exec_ctx, ps, fd);
grpc_exec_ctx_flush(&exec_ctx);
}
- grpc_fd_orphan(&exec_ctx, fd, NULL, NULL, false /* already_closed */, "xxx");
+ grpc_fd_orphan(&exec_ctx, 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);
@@ -240,10 +241,10 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) {
gpr_mu_lock(mu);
while (!done) {
GRPC_ERROR_UNREF(
- grpc_pollset_work(&exec_ctx, ps, NULL, GRPC_MILLIS_INF_FUTURE));
+ grpc_pollset_work(&exec_ctx, ps, nullptr, GRPC_MILLIS_INF_FUTURE));
}
- grpc_fd_orphan(&exec_ctx, wakeup, NULL, NULL, false /* already_closed */,
- "done");
+ grpc_fd_orphan(&exec_ctx, 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,
diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h
index 71bbb393db..7e20843875 100644
--- a/test/cpp/microbenchmarks/fullstack_fixtures.h
+++ b/test/cpp/microbenchmarks/fullstack_fixtures.h
@@ -174,7 +174,7 @@ 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 */);
+ &exec_ctx, server_args, endpoints.server, false /* is_client */);
grpc_pollset** pollsets;
size_t num_pollsets = 0;
@@ -185,8 +185,9 @@ class EndpointPairFixture : public BaseFixture {
}
grpc_server_setup_transport(&exec_ctx, server_->c_server(),
- server_transport_, NULL, server_args);
- grpc_chttp2_transport_start_reading(&exec_ctx, server_transport_, NULL);
+ server_transport_, nullptr, server_args);
+ grpc_chttp2_transport_start_reading(&exec_ctx, server_transport_, nullptr,
+ nullptr);
}
/* create channel */
@@ -196,13 +197,14 @@ class EndpointPairFixture : public BaseFixture {
fixture_configuration.ApplyCommonChannelArguments(&args);
grpc_channel_args c_args = args.c_channel_args();
- client_transport_ =
- grpc_create_chttp2_transport(&exec_ctx, &c_args, endpoints.client, 1);
+ client_transport_ = grpc_create_chttp2_transport(&exec_ctx, &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_chttp2_transport_start_reading(&exec_ctx, client_transport_, nullptr,
+ nullptr);
channel_ = CreateChannelInternal("", channel);
}
@@ -244,7 +246,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) {}
};
diff --git a/test/cpp/microbenchmarks/helpers.h b/test/cpp/microbenchmarks/helpers.h
index 07be589df6..afa3e0f3ca 100644
--- a/test/cpp/microbenchmarks/helpers.h
+++ b/test/cpp/microbenchmarks/helpers.h
@@ -54,10 +54,10 @@ 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 {
diff --git a/test/cpp/naming/README.md b/test/cpp/naming/README.md
index e33184620c..e0dd208465 100644
--- a/test/cpp/naming/README.md
+++ b/test/cpp/naming/README.md
@@ -31,7 +31,7 @@ After making a change to `resolver_test_record_groups.yaml`:
3. From the repo root, run:
```
-$ test/cpp/naming/create_dns_private_zone.sh
+$ test/cpp/naming/create_private_dns_zone.sh
$ test/cpp/naming/private_dns_zone_init.sh
```
diff --git a/test/cpp/naming/create_private_dns_zone.sh b/test/cpp/naming/create_private_dns_zone.sh
index 3d7520b90a..55a4cfe36e 100755
--- a/test/cpp/naming/create_private_dns_zone.sh
+++ b/test/cpp/naming/create_private_dns_zone.sh
@@ -20,8 +20,8 @@ set -ex
cd $(dirname $0)/../../..
gcloud alpha dns managed-zones create \
- resolver-tests-version-1-grpctestingexp-zone-id \
- --dns-name=resolver-tests-version-1.grpctestingexp. \
+ 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/private_dns_zone_init.sh b/test/cpp/naming/private_dns_zone_init.sh
index 4eaf750ab7..8fa5a8a475 100755
--- a/test/cpp/naming/private_dns_zone_init.sh
+++ b/test/cpp/naming/private_dns_zone_init.sh
@@ -19,197 +19,197 @@ set -ex
cd $(dirname $0)/../../..
-gcloud dns record-sets transaction start -z=resolver-tests-version-1-grpctestingexp-zone-id
+gcloud dns record-sets transaction start -z=resolver-tests-version-4-grpctestingexp-zone-id
gcloud dns record-sets transaction add \
- -z=resolver-tests-version-1-grpctestingexp-zone-id \
- --name=_grpclb._tcp.srv-ipv4-single-target.resolver-tests-version-1.grpctestingexp. \
+ -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-1.grpctestingexp."
+ "0 0 1234 ipv4-single-target.resolver-tests-version-4.grpctestingexp."
gcloud dns record-sets transaction add \
- -z=resolver-tests-version-1-grpctestingexp-zone-id \
- --name=ipv4-single-target.resolver-tests-version-1.grpctestingexp. \
+ -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-1-grpctestingexp-zone-id \
- --name=_grpclb._tcp.srv-ipv4-multi-target.resolver-tests-version-1.grpctestingexp. \
+ -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-1.grpctestingexp."
+ "0 0 1234 ipv4-multi-target.resolver-tests-version-4.grpctestingexp."
gcloud dns record-sets transaction add \
- -z=resolver-tests-version-1-grpctestingexp-zone-id \
- --name=ipv4-multi-target.resolver-tests-version-1.grpctestingexp. \
+ -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-1-grpctestingexp-zone-id \
- --name=_grpclb._tcp.srv-ipv6-single-target.resolver-tests-version-1.grpctestingexp. \
+ -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-1.grpctestingexp."
+ "0 0 1234 ipv6-single-target.resolver-tests-version-4.grpctestingexp."
gcloud dns record-sets transaction add \
- -z=resolver-tests-version-1-grpctestingexp-zone-id \
- --name=ipv6-single-target.resolver-tests-version-1.grpctestingexp. \
+ -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-1-grpctestingexp-zone-id \
- --name=_grpclb._tcp.srv-ipv6-multi-target.resolver-tests-version-1.grpctestingexp. \
+ -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-1.grpctestingexp."
+ "0 0 1234 ipv6-multi-target.resolver-tests-version-4.grpctestingexp."
gcloud dns record-sets transaction add \
- -z=resolver-tests-version-1-grpctestingexp-zone-id \
- --name=ipv6-multi-target.resolver-tests-version-1.grpctestingexp. \
+ -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-1-grpctestingexp-zone-id \
- --name=srv-ipv4-simple-service-config.resolver-tests-version-1.grpctestingexp. \
+ -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-1-grpctestingexp-zone-id \
- --name=ipv4-simple-service-config.resolver-tests-version-1.grpctestingexp. \
- --type=A \
+ -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 \
- "1.2.3.4"
+ "0 0 1234 ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp."
gcloud dns record-sets transaction add \
- -z=resolver-tests-version-1-grpctestingexp-zone-id \
- --name=_grpclb._tcp.srv-ipv4-simple-service-config.resolver-tests-version-1.grpctestingexp. \
- --type=SRV \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp. \
+ --type=A \
--ttl=2100 \
- "0 0 1234 ipv4-simple-service-config.resolver-tests-version-1.grpctestingexp."
+ "1.2.3.4"
gcloud dns record-sets transaction add \
- -z=resolver-tests-version-1-grpctestingexp-zone-id \
- --name=ipv4-no-srv-simple-service-config.resolver-tests-version-1.grpctestingexp. \
+ -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-1-grpctestingexp-zone-id \
- --name=ipv4-no-srv-simple-service-config.resolver-tests-version-1.grpctestingexp. \
+ -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-1-grpctestingexp-zone-id \
- --name=ipv4-no-config-for-cpp.resolver-tests-version-1.grpctestingexp. \
- --type=A \
+ -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 \
- "1.2.3.4"
+ '"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-1-grpctestingexp-zone-id \
- --name=ipv4-no-config-for-cpp.resolver-tests-version-1.grpctestingexp. \
- --type=TXT \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp. \
+ --type=A \
--ttl=2100 \
- '"grpc_config=[{\"clientLanguage\":[\"python\"],\"serviceConfig\":{\"loadBalancingPolicy\":\"round_robin\",\"methodConfig\":[{\"name\":[{\"method\":\"Foo\",\"service\":\"PythonService\",\"waitForReady\":true}]}]}}]"'
+ "1.2.3.4"
gcloud dns record-sets transaction add \
- -z=resolver-tests-version-1-grpctestingexp-zone-id \
- --name=ipv4-cpp-config-has-zero-percentage.resolver-tests-version-1.grpctestingexp. \
+ -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-1-grpctestingexp-zone-id \
- --name=ipv4-cpp-config-has-zero-percentage.resolver-tests-version-1.grpctestingexp. \
+ -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-1-grpctestingexp-zone-id \
- --name=ipv4-second-language-is-cpp.resolver-tests-version-1.grpctestingexp. \
- --type=A \
+ -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 \
- "1.2.3.4"
+ '"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-1-grpctestingexp-zone-id \
- --name=ipv4-second-language-is-cpp.resolver-tests-version-1.grpctestingexp. \
- --type=TXT \
+ -z=resolver-tests-version-4-grpctestingexp-zone-id \
+ --name=ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp. \
+ --type=A \
--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}]}]}}]"'
+ "1.2.3.4"
gcloud dns record-sets transaction add \
- -z=resolver-tests-version-1-grpctestingexp-zone-id \
- --name=ipv4-config-with-percentages.resolver-tests-version-1.grpctestingexp. \
+ -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-1-grpctestingexp-zone-id \
- --name=ipv4-config-with-percentages.resolver-tests-version-1.grpctestingexp. \
+ -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-1-grpctestingexp-zone-id \
- --name=_grpclb._tcp.srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-1.grpctestingexp. \
+ -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-1.grpctestingexp."
+ "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-1-grpctestingexp-zone-id \
- --name=balancer-for-ipv4-has-backend-and-balancer.resolver-tests-version-1.grpctestingexp. \
+ -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-1-grpctestingexp-zone-id \
- --name=srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-1.grpctestingexp. \
+ -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-1-grpctestingexp-zone-id \
- --name=_grpclb._tcp.srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-1.grpctestingexp. \
+ -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-1.grpctestingexp."
+ "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-1-grpctestingexp-zone-id \
- --name=balancer-for-ipv6-has-backend-and-balancer.resolver-tests-version-1.grpctestingexp. \
+ -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-1-grpctestingexp-zone-id \
- --name=srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-1.grpctestingexp. \
+ -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-1-grpctestingexp-zone-id
-gcloud dns record-sets transaction execute -z=resolver-tests-version-1-grpctestingexp-zone-id
-gcloud dns record-sets list -z=resolver-tests-version-1-grpctestingexp-zone-id
+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 94adbcbd35..6f1f0c44b9 100644
--- a/test/cpp/naming/resolver_component_test.cc
+++ b/test/cpp/naming/resolver_component_test.cc
@@ -157,7 +157,7 @@ void ArgsInit(grpc_exec_ctx* exec_ctx, ArgsStruct* args) {
grpc_pollset_set_add_pollset(exec_ctx, 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) {}
@@ -167,7 +167,8 @@ void ArgsFinish(grpc_exec_ctx* exec_ctx, ArgsStruct* args) {
grpc_pollset_set_del_pollset(exec_ctx, args->pollset_set, args->pollset);
grpc_pollset_set_destroy(exec_ctx, args->pollset_set);
grpc_closure DoNothing_cb;
- GRPC_CLOSURE_INIT(&DoNothing_cb, DoNothing, NULL, grpc_schedule_on_exec_ctx);
+ GRPC_CLOSURE_INIT(&DoNothing_cb, DoNothing, nullptr,
+ grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(exec_ctx, args->pollset, &DoNothing_cb);
// exec_ctx needs to be flushed before calling grpc_pollset_destroy()
grpc_channel_args_destroy(exec_ctx, args->channel_args);
@@ -194,7 +195,7 @@ 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_pollset_worker* worker = nullptr;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_mu_lock(args->mu);
GRPC_LOG_IF_ERROR("pollset_work",
@@ -212,12 +213,12 @@ void CheckServiceConfigResultLocked(grpc_channel_args* channel_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);
}
}
@@ -226,11 +227,11 @@ void CheckLBPolicyResultLocked(grpc_channel_args* channel_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);
}
}
@@ -240,7 +241,7 @@ void CheckResolverResultLocked(grpc_exec_ctx* exec_ctx, void* 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;
@@ -272,7 +273,7 @@ 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_pollset_kick(exec_ctx, args->pollset, nullptr));
gpr_mu_unlock(args->mu);
}
@@ -284,12 +285,12 @@ TEST(ResolverComponentTest, TestResolvesRelevantRecords) {
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,
+ grpc_resolver* resolver = grpc_resolver_create(&exec_ctx, whole_uri, nullptr,
args.pollset_set, args.lock);
gpr_free(whole_uri);
grpc_closure on_resolver_result_changed;
diff --git a/test/cpp/naming/resolver_component_tests_runner.sh b/test/cpp/naming/resolver_component_tests_runner.sh
index 407db5ed66..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-version-1.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-version-1.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-version-1.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-version-1.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-version-1.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-version-1.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-version-1.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-version-1.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-version-1.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-version-1.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-version-1.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-version-1.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-version-1.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 7ea005cc1d..0beb27de1b 100644
--- a/test/cpp/naming/resolver_component_tests_runner_invoker.cc
+++ b/test/cpp/naming/resolver_component_tests_runner_invoker.cc
@@ -60,8 +60,8 @@ 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 {
diff --git a/test/cpp/naming/resolver_gce_integration_tests_runner.sh b/test/cpp/naming/resolver_gce_integration_tests_runner.sh
index b20d18d9d1..091f9efbbd 100755
--- a/test/cpp/naming/resolver_gce_integration_tests_runner.sh
+++ b/test/cpp/naming/resolver_gce_integration_tests_runner.sh
@@ -34,191 +34,191 @@ 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-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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-1.grpctestingexp. FAILED"
+ 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-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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-1.grpctestingexp. FAILED"
+ 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-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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-1.grpctestingexp. FAILED"
+ 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-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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-1.grpctestingexp. FAILED"
+ 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-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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-1.grpctestingexp. FAILED"
+ 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-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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-1.grpctestingexp. FAILED"
+ 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-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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-1.grpctestingexp. FAILED"
+ 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-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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-1.grpctestingexp. FAILED"
+ echo "Sanity check: dig AAAA ipv6-multi-target.resolver-tests-version-4.grpctestingexp. FAILED"
exit 1
fi
ONE_FAILED=0
-dig TXT srv-ipv4-simple-service-config.resolver-tests-version-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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 srv-ipv4-simple-service-config.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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 A ipv4-simple-service-config.resolver-tests-version-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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 A ipv4-simple-service-config.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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 SRV _grpclb._tcp.srv-ipv4-simple-service-config.resolver-tests-version-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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 SRV _grpclb._tcp.srv-ipv4-simple-service-config.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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-1.grpctestingexp. FAILED"
+ 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 ipv4-no-srv-simple-service-config.resolver-tests-version-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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 ipv4-no-srv-simple-service-config.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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 A ipv4-no-config-for-cpp.resolver-tests-version-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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 A ipv4-no-config-for-cpp.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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 TXT ipv4-no-config-for-cpp.resolver-tests-version-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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 TXT ipv4-no-config-for-cpp.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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-1.grpctestingexp. FAILED"
+ 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 ipv4-cpp-config-has-zero-percentage.resolver-tests-version-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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 ipv4-cpp-config-has-zero-percentage.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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 A ipv4-second-language-is-cpp.resolver-tests-version-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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 A ipv4-second-language-is-cpp.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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 TXT ipv4-second-language-is-cpp.resolver-tests-version-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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 TXT ipv4-second-language-is-cpp.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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-1.grpctestingexp. FAILED"
+ echo "Sanity check: dig A ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp. FAILED"
exit 1
fi
ONE_FAILED=0
-dig TXT ipv4-config-with-percentages.resolver-tests-version-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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 ipv4-config-with-percentages.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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-1.grpctestingexp. FAILED"
+ 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-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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-1.grpctestingexp. FAILED"
+ 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-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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-1.grpctestingexp. FAILED"
+ 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-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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-1.grpctestingexp. FAILED"
+ 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-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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-1.grpctestingexp. FAILED"
+ 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-1.grpctestingexp. | grep 'ANSWER SECTION' || ONE_FAILED=1
+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-1.grpctestingexp. FAILED"
+ echo "Sanity check: dig AAAA srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. FAILED"
exit 1
fi
@@ -226,133 +226,133 @@ echo "Sanity check PASSED. Run resolver tests:"
ONE_FAILED=0
bins/$CONFIG/resolver_component_test \
- --target_name='srv-ipv4-single-target.resolver-tests-version-1.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='' || ONE_FAILED=1
if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: srv-ipv4-single-target.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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-1.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='' || ONE_FAILED=1
if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: srv-ipv4-multi-target.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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-1.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='' || ONE_FAILED=1
if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: srv-ipv6-single-target.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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-1.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='' || ONE_FAILED=1
if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: srv-ipv6-multi-target.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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-1.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' || ONE_FAILED=1
if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: srv-ipv4-simple-service-config.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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-1.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' || ONE_FAILED=1
if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: ipv4-no-srv-simple-service-config.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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-1.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='' || ONE_FAILED=1
if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: ipv4-no-config-for-cpp.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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-1.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='' || ONE_FAILED=1
if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: ipv4-cpp-config-has-zero-percentage.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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-1.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' || ONE_FAILED=1
if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: ipv4-second-language-is-cpp.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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-1.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' || ONE_FAILED=1
if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: ipv4-config-with-percentages.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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-1.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='' || ONE_FAILED=1
if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-1.grpctestingexp. FAILED"
+ 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-1.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='' || ONE_FAILED=1
if [[ "$ONE_FAILED" != 0 ]]; then
- echo "Test based on target record: srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-1.grpctestingexp. FAILED"
+ echo "Test based on target record: srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp. FAILED"
EXIT_CODE=1
fi
diff --git a/test/cpp/naming/resolver_test_record_groups.yaml b/test/cpp/naming/resolver_test_record_groups.yaml
index 2b3204335c..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_tests_common_zone_name: resolver-tests-version-1.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/performance/writes_per_rpc_test.cc b/test/cpp/performance/writes_per_rpc_test.cc
index 6c23245021..1c6f44dd7d 100644
--- a/test/cpp/performance/writes_per_rpc_test.cc
+++ b/test/cpp/performance/writes_per_rpc_test.cc
@@ -89,7 +89,7 @@ class EndpointPairFixture {
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 */);
+ &exec_ctx, server_args, endpoints.server, false /* is_client */);
grpc_pollset** pollsets;
size_t num_pollsets = 0;
@@ -100,8 +100,9 @@ class EndpointPairFixture {
}
grpc_server_setup_transport(&exec_ctx, server_->c_server(), transport,
- NULL, server_args);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL);
+ nullptr, server_args);
+ grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr,
+ nullptr);
}
/* create channel */
@@ -111,12 +112,13 @@ class EndpointPairFixture {
ApplyCommonChannelArguments(&args);
grpc_channel_args c_args = args.c_channel_args();
- grpc_transport* transport =
- grpc_create_chttp2_transport(&exec_ctx, &c_args, endpoints.client, 1);
+ grpc_transport* transport = grpc_create_chttp2_transport(
+ &exec_ctx, &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);
+ grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr,
+ nullptr);
channel_ = CreateChannelInternal("", channel);
}
diff --git a/test/cpp/qps/BUILD b/test/cpp/qps/BUILD
index 0d91d52f22..f1abb19e64 100644
--- a/test/cpp/qps/BUILD
+++ b/test/cpp/qps/BUILD
@@ -106,7 +106,7 @@ grpc_cc_library(
"histogram.h",
"stats.h",
],
- deps = ["//:gpr"],
+ deps = ["//test/core/util:grpc_test_util"],
)
grpc_cc_test(
diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc
index f7cdfc2bd7..07888214e7 100644
--- a/test/cpp/qps/client_async.cc
+++ b/test/cpp/qps/client_async.cc
@@ -236,6 +236,22 @@ class AsyncClient : public ClientImpl<StubType, RequestType> {
this->EndThreads(); // this needed for resolution
}
+ 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 nullptr;
+ }
+ return ctx;
+ }
+
void ThreadFunc(size_t thread_idx, Client::Thread* t) override final {
void* got_tag;
bool ok;
@@ -245,9 +261,13 @@ class AsyncClient : public ClientImpl<StubType, RequestType> {
if (!cli_cqs_[cq_[thread_idx]]->Next(&got_tag, &ok)) {
return;
}
- ClientRpcContext* ctx = ClientRpcContext::detag(got_tag);
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)) {
@@ -260,19 +280,9 @@ class AsyncClient : public ClientImpl<StubType, RequestType> {
},
&got_tag, &ok, gpr_inf_future(GPR_CLOCK_REALTIME))) {
t->UpdateHistogram(entry_ptr);
- // Got a regular event, so process it
- ctx = ClientRpcContext::detag(got_tag);
- // Proceed while holding a lock to make sure that
- // this thread isn't supposed to shut down
shutdown_mu->lock();
- if (shutdown_state_[thread_idx]->shutdown) {
- ctx->TryCancel();
- delete ctx;
- while (cli_cqs_[cq_[thread_idx]]->Next(&got_tag, &ok)) {
- ctx = ClientRpcContext::detag(got_tag);
- ctx->TryCancel();
- delete ctx;
- }
+ ctx = ProcessTag(thread_idx, got_tag);
+ if (ctx == nullptr) {
shutdown_mu->unlock();
return;
}
diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc
index 9f20b148eb..82a3f0042d 100644
--- a/test/cpp/qps/client_sync.cc
+++ b/test/cpp/qps/client_sync.cc
@@ -60,21 +60,20 @@ class SynchronousClient
SetupLoadTest(config, num_threads_);
}
- virtual ~SynchronousClient(){};
+ virtual ~SynchronousClient() {}
- virtual void InitThreadFuncImpl(size_t thread_idx) = 0;
+ 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 {
- InitThreadFuncImpl(thread_idx);
+ 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) {
- gpr_log(GPR_ERROR, "Finishing client thread due to RPC error");
- }
if (!thread_still_ok || ThreadCompleted()) {
return;
}
@@ -109,9 +108,6 @@ class SynchronousClient
size_t num_threads_;
std::vector<SimpleResponse> responses_;
-
- private:
- void DestroyMultithreading() override final { EndThreads(); }
};
class SynchronousUnaryClient final : public SynchronousClient {
@@ -122,7 +118,7 @@ class SynchronousUnaryClient final : public SynchronousClient {
}
~SynchronousUnaryClient() {}
- void InitThreadFuncImpl(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)) {
@@ -140,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>
@@ -149,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_;
@@ -182,27 +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) {}
- ~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);
}
});
}
@@ -211,10 +208,36 @@ class SynchronousStreamingPingPongClient final
}
}
- void InitThreadFuncImpl(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();
- 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 {
+ return false;
+ }
messages_issued_[thread_idx] = 0;
+ return true;
}
bool ThreadFuncImpl(HistogramEntry* entry, size_t thread_idx) override {
@@ -239,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;
}
@@ -251,25 +280,24 @@ class SynchronousStreamingFromClientClient final
SynchronousStreamingFromClientClient(const ClientConfig& config)
: SynchronousStreamingClient(config), last_issue_(num_threads_) {}
~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();
- }
+ CleanupAllStreams(
+ [this](size_t thread_idx) { stream_[thread_idx]->WritesDone(); });
}
- void InitThreadFuncImpl(size_t thread_idx) override {
+ private:
+ std::vector<double> last_issue_;
+
+ bool InitThreadFuncImpl(size_t thread_idx) override {
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 {
+ return false;
+ }
last_issue_[thread_idx] = UsageTimer::Now();
+ return true;
}
bool ThreadFuncImpl(HistogramEntry* entry, size_t thread_idx) override {
@@ -287,13 +315,16 @@ 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
@@ -301,12 +332,24 @@ class SynchronousStreamingFromServerClient final
public:
SynchronousStreamingFromServerClient(const ClientConfig& config)
: SynchronousStreamingClient(config), last_recv_(num_threads_) {}
- void InitThreadFuncImpl(size_t thread_idx) override {
+ ~SynchronousStreamingFromServerClient() {}
+
+ private:
+ std::vector<double> last_recv_;
+
+ bool InitThreadFuncImpl(size_t thread_idx) override {
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 {
+ return false;
+ }
last_recv_[thread_idx] = UsageTimer::Now();
+ return true;
}
+
bool ThreadFuncImpl(HistogramEntry* entry, size_t thread_idx) override {
GPR_TIMER_SCOPE("SynchronousStreamingFromServerClient::ThreadFunc", 0);
if (stream_[thread_idx]->Read(&responses_[thread_idx])) {
@@ -317,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
@@ -333,24 +379,22 @@ class SynchronousStreamingBothWaysClient final
SynchronousStreamingBothWaysClient(const ClientConfig& config)
: 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(); });
}
- void InitThreadFuncImpl(size_t thread_idx) override {
+ private:
+ bool InitThreadFuncImpl(size_t thread_idx) override {
auto* stub = channels_[thread_idx % channels_.size()].get_stub();
- stream_[thread_idx] = stub->StreamingBothWays(&context_[thread_idx]);
+ 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 ThreadFuncImpl(HistogramEntry* entry, size_t thread_idx) override {
// TODO (vjpai): Do this
return true;
diff --git a/test/cpp/qps/histogram.h b/test/cpp/qps/histogram.h
index e31d5d78a8..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,7 +68,7 @@ class Histogram {
Histogram(const Histogram&);
Histogram& operator=(const Histogram&);
- gpr_histogram* impl_;
+ grpc_histogram* impl_;
};
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/qps/json_run_localhost.cc b/test/cpp/qps/json_run_localhost.cc
index 4b788eae73..db8b2a3943 100644
--- a/test/cpp/qps/json_run_localhost.cc
+++ b/test/cpp/qps/json_run_localhost.cc
@@ -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) {
diff --git a/test/cpp/qps/qps_interarrival_test.cc b/test/cpp/qps/qps_interarrival_test.cc
index 461bf624ce..625b7db426 100644
--- a/test/cpp/qps/qps_interarrival_test.cc
+++ b/test/cpp/qps/qps_interarrival_test.cc
@@ -20,7 +20,7 @@
#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"
@@ -31,21 +31,21 @@ using grpc::testing::RandomDistInterface;
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;
diff --git a/test/cpp/qps/qps_json_driver.cc b/test/cpp/qps/qps_json_driver.cc
index 1672527426..b2449da69c 100644
--- a/test/cpp/qps/qps_json_driver.cc
+++ b/test/cpp/qps/qps_json_driver.cc
@@ -181,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_worker.cc b/test/cpp/qps/qps_worker.cc
index c288b03ec5..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"
diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc
index 23c7e85283..72ae772147 100644
--- a/test/cpp/qps/server_async.cc
+++ b/test/cpp/qps/server_async.cc
@@ -79,7 +79,7 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
auto port_num = port();
// Negative port number means inproc server, so no listen port needed
if (port_num >= 0) {
- char* server_address = NULL;
+ char* server_address = nullptr;
gpr_join_host_port(&server_address, "::", port_num);
builder.AddListeningPort(server_address,
Server::CreateServerCredentials(config));
diff --git a/test/cpp/qps/server_sync.cc b/test/cpp/qps/server_sync.cc
index 4ef57bd08b..ea89a30e2e 100644
--- a/test/cpp/qps/server_sync.cc
+++ b/test/cpp/qps/server_sync.cc
@@ -159,7 +159,7 @@ class SynchronousServer final : public grpc::testing::Server {
auto port_num = port();
// Negative port number means inproc server, so no listen port needed
if (port_num >= 0) {
- char* server_address = NULL;
+ char* server_address = nullptr;
gpr_join_host_port(&server_address, "::", port_num);
builder.AddListeningPort(server_address,
Server::CreateServerCredentials(config));
diff --git a/test/cpp/thread_manager/thread_manager_test.cc b/test/cpp/thread_manager/thread_manager_test.cc
index af90d44495..8282d46694 100644
--- a/test/cpp/thread_manager/thread_manager_test.cc
+++ b/test/cpp/thread_manager/thread_manager_test.cc
@@ -111,7 +111,7 @@ void ThreadManagerTest::PerformTest() {
} // namespace grpc
int main(int argc, char** argv) {
- std::srand(std::time(NULL));
+ 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/grpc_tool.cc b/test/cpp/util/grpc_tool.cc
index cd6084ac6d..a6d08cd83c 100644
--- a/test/cpp/util/grpc_tool.cc
+++ b/test/cpp/util/grpc_tool.cc
@@ -230,7 +230,7 @@ const Command* FindCommand(const grpc::string& name) {
return &ops[i];
}
}
- return NULL;
+ return nullptr;
}
} // namespace
@@ -245,13 +245,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;
@@ -281,11 +281,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;
}
diff --git a/test/cpp/util/grpc_tool_test.cc b/test/cpp/util/grpc_tool_test.cc
index d0b3d7b81b..1c07b2a8ef 100644
--- a/test/cpp/util/grpc_tool_test.cc
+++ b/test/cpp/util/grpc_tool_test.cc
@@ -395,7 +395,7 @@ 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();
}
@@ -421,9 +421,9 @@ TEST_F(GrpcToolTest, CallCommandBatch) {
// Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage:
// "Hello2"\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();
}
@@ -448,8 +448,8 @@ TEST_F(GrpcToolTest, CallCommandBatchWithBadRequest) {
FLAGS_batch = false;
// Expected output: "message: "Hello0"\nmessage: "Hello2"\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();
}
@@ -473,8 +473,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();
}
@@ -498,7 +498,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();
@@ -521,8 +521,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();
@@ -547,9 +547,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();
}
@@ -573,8 +573,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();
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..047846b0f1
--- /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 ../..
+
+# Build helloworld example using cmake
+cd examples/cpp/helloworld
+mkdir cmake
+cd cmake
+mkdir build
+cd build
+cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ../.. || 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/third_party/cares/cares.BUILD b/third_party/cares/cares.BUILD
index 8cc01b64c4..85ca506ab0 100644
--- a/third_party/cares/cares.BUILD
+++ b/third_party/cares/cares.BUILD
@@ -8,7 +8,7 @@ config_setting(
config_setting(
name = "android",
values = {
- "crosstool_top": "//external:android/crosstool",
+ "crosstool_top": "//external:android/crosstool",
},
)
@@ -18,120 +18,128 @@ 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",
+ srcs = ["@cares_local_files//:ares_build_h"],
+ outs = ["ares_build.h"],
+ cmd = "cat $(location @cares_local_files//:ares_build_h) > $@",
+)
+
+# cc_library(
+# name = "ares_build_h",
+# hdrs = ["ares_build.h"],
+# data = [":ares_build"],
+# includes = ["."],
+# )
+
+genrule(
+ name = "ares_config",
+ srcs = ["@cares_local_files//:ares_config_h"],
+ outs = ["ares_config.h"],
+ cmd = "cat $(location @cares_local_files//:ares_config_h) > $@",
+)
+
+# cc_library(
+# name = "ares_config_h",
+# hdrs = ["ares_config.h"],
+# data = [":ares_config"],
+# includes = ["."],
+# )
+
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({
- ":ios_x86_64": ["config_darwin/ares_config.h"],
- ":ios_armv7": ["config_darwin/ares_config.h"],
- ":ios_armv7s": ["config_darwin/ares_config.h"],
- ":ios_arm64": ["config_darwin/ares_config.h"],
- ":darwin": ["config_darwin/ares_config.h"],
- ":android": ["config_android/ares_config.h"],
- "//conditions:default": ["config_linux/ares_config.h"],
- }),
- includes = [
- ".",
- "cares"
- ] + select({
- ":ios_x86_64": ["config_darwin"],
- ":ios_armv7": ["config_darwin"],
- ":ios_armv7s": ["config_darwin"],
- ":ios_arm64": ["config_darwin"],
- ":darwin": ["config_darwin"],
- ":android": ["config_android"],
- "//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",
@@ -139,4 +147,13 @@ cc_library(
"-DNOMINMAX",
"-DHAVE_CONFIG_H",
],
+ data = [
+ ":ares_build",
+ ":ares_config",
+ ],
+ includes = ["."],
+ linkstatic = 1,
+ visibility = [
+ "//visibility:public",
+ ],
)
diff --git a/third_party/cares/cares_local_files.BUILD b/third_party/cares/cares_local_files.BUILD
new file mode 100644
index 0000000000..fe59447beb
--- /dev/null
+++ b/third_party/cares/cares_local_files.BUILD
@@ -0,0 +1,57 @@
+package(
+ default_visibility = ["//visibility:public"],
+)
+
+config_setting(
+ name = "darwin",
+ 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"},
+)
+
+filegroup(
+ name = "ares_build_h",
+ srcs = ["ares_build.h"],
+)
+
+filegroup(
+ name = "ares_config_h",
+ srcs = select({
+ ":ios_x86_64": ["config_darwin/ares_config.h"],
+ ":ios_armv7": ["config_darwin/ares_config.h"],
+ ":ios_armv7s": ["config_darwin/ares_config.h"],
+ ":ios_arm64": ["config_darwin/ares_config.h"],
+ ":darwin": ["config_darwin/ares_config.h"],
+ ":android": ["config_android/ares_config.h"],
+ "//conditions:default": ["config_linux/ares_config.h"],
+ }),
+)
diff --git a/third_party/protobuf b/third_party/protobuf
-Subproject 80a37e0782d2d702d52234b62dd4b9ec74fd2c9
+Subproject 2761122b810fe8861004ae785cc3ab39f384d34
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..c554f03971
--- /dev/null
+++ b/tools/bazel.rc
@@ -0,0 +1,48 @@
+build --client_env=CC=clang
+
+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/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/distrib/python/check_grpcio_tools.py b/tools/distrib/python/check_grpcio_tools.py
index c5afa713e6..b56ccaea7a 100755
--- a/tools/distrib/python/check_grpcio_tools.py
+++ b/tools/distrib/python/check_grpcio_tools.py
@@ -14,17 +14,21 @@
# 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))
- raise SystemExit(1)
+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/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py
index db92b10c60..f613025be3 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.8.0.dev0'
+VERSION='1.9.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..8d95cb5a28 100644
--- a/tools/distrib/python/grpcio_tools/setup.py
+++ b/tools/distrib/python/grpcio_tools/setup.py
@@ -209,7 +209,7 @@ setuptools.setup(
ext_modules=extension_modules(),
packages=setuptools.find_packages('.'),
install_requires=[
- 'protobuf>=3.3.0',
+ '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..c865f0bcc0 100755
--- a/tools/distrib/python/make_grpcio_tools.py
+++ b/tools/distrib/python/make_grpcio_tools.py
@@ -28,7 +28,7 @@ import traceback
import uuid
DEPS_FILE_CONTENT="""
-# 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.
@@ -48,8 +48,13 @@ 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/'
@@ -63,6 +68,7 @@ GRPC_PYTHON_ROOT = os.path.join(GRPC_ROOT, 'tools', 'distrib',
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')
@@ -78,6 +84,14 @@ BAZEL_DEPS = os.path.join(GRPC_ROOT, 'tools', 'distrib', 'python', 'bazel_deps.s
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])
@@ -94,11 +108,13 @@ def get_deps():
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))
+ 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):
diff --git a/tools/distrib/run_clang_tidy.py b/tools/distrib/run_clang_tidy.py
new file mode 100755
index 0000000000..d002a04de9
--- /dev/null
+++ b/tools/distrib/run_clang_tidy.py
@@ -0,0 +1,70 @@
+#!/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',
+]
+
+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))
+
+jobset.run(jobs, maxjobs=args.jobs)
diff --git a/tools/dockerfile/interoptest/grpc_interop_csharp/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_csharp/Dockerfile
index ea82476b65..af2ab90b76 100644
--- a/tools/dockerfile/interoptest/grpc_interop_csharp/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_csharp/Dockerfile
@@ -62,7 +62,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 ea82476b65..af2ab90b76 100644
--- a/tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_csharpcoreclr/Dockerfile
@@ -62,7 +62,7 @@ RUN apt-get update && apt-get install -y \
# 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.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_cxx/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_cxx/Dockerfile
index 38d377ce2f..ec5338b4fc 100644
--- a/tools/dockerfile/interoptest/grpc_interop_cxx/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_cxx/Dockerfile
@@ -62,7 +62,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 73c41a4838..a775961ff7 100644
--- a/tools/dockerfile/interoptest/grpc_interop_go/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_go/Dockerfile
@@ -30,7 +30,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 7c083de365..c296c8c674 100644
--- a/tools/dockerfile/interoptest/grpc_interop_go1.7/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_go1.7/Dockerfile
@@ -30,7 +30,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 61efc18df9..9ac0b97341 100644
--- a/tools/dockerfile/interoptest/grpc_interop_go1.8/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_go1.8/Dockerfile
@@ -30,7 +30,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 278b09a666..92a2faa605 100644
--- a/tools/dockerfile/interoptest/grpc_interop_http2/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_http2/Dockerfile
@@ -30,7 +30,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 d56632440f..34b4e39df4 100644
--- a/tools/dockerfile/interoptest/grpc_interop_java/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_java/Dockerfile
@@ -45,7 +45,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 d56632440f..34b4e39df4 100644
--- a/tools/dockerfile/interoptest/grpc_interop_java_oracle8/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_java_oracle8/Dockerfile
@@ -45,7 +45,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 f4c3e4103e..17671a384e 100644
--- a/tools/dockerfile/interoptest/grpc_interop_node/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_node/Dockerfile
@@ -62,7 +62,7 @@ RUN apt-get update && apt-get install -y \
# 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.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_python/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile
index d165307031..07f419f880 100644
--- a/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_python/Dockerfile
@@ -62,7 +62,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 2217b10b8b..543e207c64 100644
--- a/tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile
@@ -62,7 +62,7 @@ RUN apt-get update && apt-get install -y \
# 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.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/csharp_jessie_x64/Dockerfile b/tools/dockerfile/test/csharp_jessie_x64/Dockerfile
index 3e31e67f5f..0fae21de63 100644
--- a/tools/dockerfile/test/csharp_jessie_x64/Dockerfile
+++ b/tools/dockerfile/test/csharp_jessie_x64/Dockerfile
@@ -66,7 +66,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 af5e7d6f14..13a0ea1002 100644
--- a/tools/dockerfile/test/cxx_alpine_x64/Dockerfile
+++ b/tools/dockerfile/test/cxx_alpine_x64/Dockerfile
@@ -38,7 +38,7 @@ RUN apk update && apk add \
# 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.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 3492dd72c5..dff4c96e9a 100644
--- a/tools/dockerfile/test/cxx_jessie_x64/Dockerfile
+++ b/tools/dockerfile/test/cxx_jessie_x64/Dockerfile
@@ -66,7 +66,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 f8cbf35d39..ea1d645628 100644
--- a/tools/dockerfile/test/cxx_jessie_x86/Dockerfile
+++ b/tools/dockerfile/test/cxx_jessie_x86/Dockerfile
@@ -66,7 +66,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 6966d6b8d3..990dac9128 100644
--- a/tools/dockerfile/test/cxx_ubuntu1404_x64/Dockerfile
+++ b/tools/dockerfile/test/cxx_ubuntu1404_x64/Dockerfile
@@ -66,7 +66,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 016034aa50..c8943cada9 100644
--- a/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile
+++ b/tools/dockerfile/test/cxx_ubuntu1604_x64/Dockerfile
@@ -66,7 +66,7 @@ RUN apt-get update && apt-get install -y \
# 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.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/fuzzer/Dockerfile b/tools/dockerfile/test/fuzzer/Dockerfile
index 50104ad7ae..52666eab99 100644
--- a/tools/dockerfile/test/fuzzer/Dockerfile
+++ b/tools/dockerfile/test/fuzzer/Dockerfile
@@ -66,7 +66,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 8e29fcb88c..362c061f6d 100644
--- a/tools/dockerfile/test/multilang_jessie_x64/Dockerfile
+++ b/tools/dockerfile/test/multilang_jessie_x64/Dockerfile
@@ -141,7 +141,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 d0e5af64cc..9f19e76bf5 100644
--- a/tools/dockerfile/test/node_jessie_x64/Dockerfile
+++ b/tools/dockerfile/test/node_jessie_x64/Dockerfile
@@ -77,7 +77,7 @@ RUN apt-get update && apt-get install -y \
# 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.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/test/php7_jessie_x64/Dockerfile b/tools/dockerfile/test/php7_jessie_x64/Dockerfile
index 1399502840..865bf695fe 100644
--- a/tools/dockerfile/test/php7_jessie_x64/Dockerfile
+++ b/tools/dockerfile/test/php7_jessie_x64/Dockerfile
@@ -77,7 +77,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 56dc6045e1..fb653d365a 100644
--- a/tools/dockerfile/test/php_jessie_x64/Dockerfile
+++ b/tools/dockerfile/test/php_jessie_x64/Dockerfile
@@ -66,7 +66,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 7584ab8767..87acef9cb6 100644
--- a/tools/dockerfile/test/python_alpine_x64/Dockerfile
+++ b/tools/dockerfile/test/python_alpine_x64/Dockerfile
@@ -38,7 +38,7 @@ RUN apk update && apk add \
# 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.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 8d89f5022f..914e343373 100644
--- a/tools/dockerfile/test/python_jessie_x64/Dockerfile
+++ b/tools/dockerfile/test/python_jessie_x64/Dockerfile
@@ -66,7 +66,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 f8cbdc5726..379f26ad91 100644
--- a/tools/dockerfile/test/python_pyenv_x64/Dockerfile
+++ b/tools/dockerfile/test/python_pyenv_x64/Dockerfile
@@ -66,7 +66,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 5d7f80bf88..63e42fd2da 100644
--- a/tools/dockerfile/test/ruby_jessie_x64/Dockerfile
+++ b/tools/dockerfile/test/ruby_jessie_x64/Dockerfile
@@ -66,7 +66,7 @@ RUN apt-get update && apt-get install -y \
# 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.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 da663d5686..e4a2972c0e 100644
--- a/tools/dockerfile/test/sanity/Dockerfile
+++ b/tools/dockerfile/test/sanity/Dockerfile
@@ -66,7 +66,11 @@ RUN apt-get update && apt-get install -y \
# 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.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
diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++
index eb27eed075..e62278cb9f 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.8.0-dev
+PROJECT_NUMBER = 1.9.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,7 @@ include/grpc++/support/time.h \
include/grpc/byte_buffer.h \
include/grpc/byte_buffer_reader.h \
include/grpc/compression.h \
+include/grpc/fork.h \
include/grpc/grpc.h \
include/grpc/grpc_posix.h \
include/grpc/grpc_security_constants.h \
@@ -887,6 +888,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 \
@@ -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 c9c64399f7..d09b325c97 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.8.0-dev
+PROJECT_NUMBER = 1.9.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,7 @@ include/grpc++/support/time.h \
include/grpc/byte_buffer.h \
include/grpc/byte_buffer_reader.h \
include/grpc/compression.h \
+include/grpc/fork.h \
include/grpc/grpc.h \
include/grpc/grpc_posix.h \
include/grpc/grpc_security_constants.h \
@@ -888,6 +889,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 \
@@ -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 \
@@ -1026,22 +1027,26 @@ 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/abstract.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/debug_location.h \
src/core/lib/support/env.h \
+src/core/lib/support/fork.h \
src/core/lib/support/manual_constructor.h \
src/core/lib/support/memory.h \
src/core/lib/support/mpscq.h \
src/core/lib/support/murmur_hash.h \
+src/core/lib/support/ref_counted.h \
+src/core/lib/support/ref_counted_ptr.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/thd_internal.h \
src/core/lib/support/time_precise.h \
src/core/lib/support/tmpfile.h \
-src/core/lib/support/vector.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 c8fd2ee48b..6ce9041747 100644
--- a/tools/doxygen/Doxyfile.core
+++ b/tools/doxygen/Doxyfile.core
@@ -774,6 +774,7 @@ 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 \
@@ -800,6 +801,7 @@ include/grpc/byte_buffer.h \
include/grpc/byte_buffer_reader.h \
include/grpc/census.h \
include/grpc/compression.h \
+include/grpc/fork.h \
include/grpc/grpc.h \
include/grpc/grpc_posix.h \
include/grpc/grpc_security.h \
@@ -817,6 +819,8 @@ 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 \
@@ -849,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 b9844f8b89..1aff0075a6 100644
--- a/tools/doxygen/Doxyfile.core.internal
+++ b/tools/doxygen/Doxyfile.core.internal
@@ -774,6 +774,7 @@ 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 \
@@ -800,6 +801,7 @@ include/grpc/byte_buffer.h \
include/grpc/byte_buffer_reader.h \
include/grpc/census.h \
include/grpc/compression.h \
+include/grpc/fork.h \
include/grpc/grpc.h \
include/grpc/grpc_posix.h \
include/grpc/grpc_security.h \
@@ -817,6 +819,8 @@ 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 \
@@ -849,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 \
@@ -1073,7 +1076,6 @@ src/core/lib/iomgr/README.md \
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.cc \
src/core/lib/iomgr/closure.h \
src/core/lib/iomgr/combiner.cc \
src/core/lib/iomgr/combiner.h \
@@ -1101,6 +1103,8 @@ src/core/lib/iomgr/exec_ctx.cc \
src/core/lib/iomgr/exec_ctx.h \
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.cc \
src/core/lib/iomgr/gethostname_host_name_max.cc \
@@ -1268,6 +1272,7 @@ src/core/lib/slice/slice_intern.cc \
src/core/lib/slice/slice_internal.h \
src/core/lib/slice/slice_string_helpers.cc \
src/core/lib/slice/slice_string_helpers.h \
+src/core/lib/support/abstract.h \
src/core/lib/support/alloc.cc \
src/core/lib/support/arena.cc \
src/core/lib/support/arena.h \
@@ -1281,11 +1286,13 @@ src/core/lib/support/cpu_iphone.cc \
src/core/lib/support/cpu_linux.cc \
src/core/lib/support/cpu_posix.cc \
src/core/lib/support/cpu_windows.cc \
+src/core/lib/support/debug_location.h \
src/core/lib/support/env.h \
src/core/lib/support/env_linux.cc \
src/core/lib/support/env_posix.cc \
src/core/lib/support/env_windows.cc \
-src/core/lib/support/histogram.cc \
+src/core/lib/support/fork.cc \
+src/core/lib/support/fork.h \
src/core/lib/support/host_port.cc \
src/core/lib/support/log.cc \
src/core/lib/support/log_android.cc \
@@ -1298,9 +1305,9 @@ src/core/lib/support/mpscq.cc \
src/core/lib/support/mpscq.h \
src/core/lib/support/murmur_hash.cc \
src/core/lib/support/murmur_hash.h \
+src/core/lib/support/ref_counted.h \
+src/core/lib/support/ref_counted_ptr.h \
src/core/lib/support/spinlock.h \
-src/core/lib/support/stack_lockfree.cc \
-src/core/lib/support/stack_lockfree.h \
src/core/lib/support/string.cc \
src/core/lib/support/string.h \
src/core/lib/support/string_posix.cc \
@@ -1313,6 +1320,7 @@ src/core/lib/support/sync.cc \
src/core/lib/support/sync_posix.cc \
src/core/lib/support/sync_windows.cc \
src/core/lib/support/thd.cc \
+src/core/lib/support/thd_internal.h \
src/core/lib/support/thd_posix.cc \
src/core/lib/support/thd_windows.cc \
src/core/lib/support/time.cc \
@@ -1325,7 +1333,6 @@ src/core/lib/support/tmpfile.h \
src/core/lib/support/tmpfile_msys.cc \
src/core/lib/support/tmpfile_posix.cc \
src/core/lib/support/tmpfile_windows.cc \
-src/core/lib/support/vector.h \
src/core/lib/support/wrap_memcpy.cc \
src/core/lib/surface/README.md \
src/core/lib/surface/alarm.cc \
diff --git a/tools/gce/linux_kokoro_performance_worker_init.sh b/tools/gce/linux_kokoro_performance_worker_init.sh
index ac3d39383b..460f639f9f 100755
--- a/tools/gce/linux_kokoro_performance_worker_init.sh
+++ b/tools/gce/linux_kokoro_performance_worker_init.sh
@@ -114,6 +114,19 @@ 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
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/linux/grpc_bazel_on_foundry.sh b/tools/internal_ci/linux/grpc_bazel_on_foundry.sh
new file mode 100644
index 0000000000..e328be8aab
--- /dev/null
+++ b/tools/internal_ci/linux/grpc_bazel_on_foundry.sh
@@ -0,0 +1,55 @@
+#!/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=SHA1 \
+ 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:aa20628a902f06a11a015caa94b0432eb60690de2d2525bd046b9eea046f5d8a" }' \
+ --crosstool_top=@bazel_toolchains//configs/debian8_clang/0.2.0/bazel_0.7.0:toolchain \
+ --define GRPC_PORT_ISOLATED_RUNTIME=1 \
+ -- //test/...
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/interop_matrix/README.md b/tools/interop_matrix/README.md
index 588afe4fd4..40c02a1bc7 100644
--- a/tools/interop_matrix/README.md
+++ b/tools/interop_matrix/README.md
@@ -8,8 +8,8 @@ from specific releases/tag, are used to test version compatiblity between gRPC r
## 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 java release `v1.9.9`, do
- - `tools/interop_matrix/create_matrix_images.py --git_checkout --release=v1.9.9 --language=java`
+- 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_java_oracle8` should show an image entry with tag `v1.9.9`.
diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py
index 6bd7ff6406..c9a4996029 100644
--- a/tools/interop_matrix/client_matrix.py
+++ b/tools/interop_matrix/client_matrix.py
@@ -19,6 +19,7 @@ def get_github_repo(lang):
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')
@@ -27,7 +28,7 @@ LANG_RUNTIME_MATRIX = {
'cxx': ['cxx'], # This is actually debian8.
'go': ['go1.7', 'go1.8'],
'java': ['java_oracle8'],
- #'python': ['python'], # All python versions fail the tests due to timeout.
+ 'python': ['python'],
'node': ['node'],
'ruby': ['ruby'],
'php': ['php', 'php7'],
@@ -44,6 +45,7 @@ LANG_RELEASE_MATRIX = {
'v1.3.9',
'v1.4.2',
'v1.6.6',
+ 'v1.7.2',
],
'go': [
'v1.0.5',
@@ -53,6 +55,10 @@ LANG_RELEASE_MATRIX = {
'v1.5.2',
'v1.6.0',
'v1.7.0',
+ 'v1.7.1',
+ 'v1.7.2',
+ 'v1.7.3',
+ 'v1.8.0',
],
'java': [
'v1.0.3',
@@ -63,15 +69,17 @@ LANG_RELEASE_MATRIX = {
'v1.5.0',
'v1.6.1',
'v1.7.0',
+ 'v1.8.0',
+ ],
+ 'python': [
+ 'v1.0.x',
+ 'v1.1.4',
+ 'v1.2.5',
+ 'v1.3.9',
+ 'v1.4.2',
+ 'v1.6.6',
+ 'v1.7.2',
],
- #'python': [
- #'v1.0.x', #Fail to run the test. #13230.
- # 'v1.1.4',
- # 'v1.2.5',
- # 'v1.3.9',
- # 'v1.4.2',
- # 'v1.6.6',
- #],
'node': [
'v1.0.1',
'v1.1.4',
@@ -79,6 +87,7 @@ LANG_RELEASE_MATRIX = {
'v1.3.9',
'v1.4.2',
'v1.6.6',
+ #'v1.7.1', Failing tests.
],
'ruby': [
# Ruby v1.0.x doesn't have the fix #8914, therefore not supported.
@@ -87,6 +96,7 @@ LANG_RELEASE_MATRIX = {
'v1.3.9',
'v1.4.2',
'v1.6.6',
+ 'v1.7.2',
],
'php': [
'v1.0.1',
@@ -95,13 +105,15 @@ LANG_RELEASE_MATRIX = {
'v1.3.9',
'v1.4.2',
'v1.6.6',
+ 'v1.7.2',
],
'csharp': [
#'v1.0.1',
- #'v1.1.4', Fail to build.
- #'v1.2.5', Fail to run test with csharp image.
+ 'v1.1.4',
+ 'v1.2.5',
'v1.3.9',
'v1.4.2',
'v1.6.6',
+ 'v1.7.2',
],
}
diff --git a/tools/interop_matrix/create_matrix_images.py b/tools/interop_matrix/create_matrix_images.py
index 21040eadf2..493a7d5364 100755
--- a/tools/interop_matrix/create_matrix_images.py
+++ b/tools/interop_matrix/create_matrix_images.py
@@ -77,6 +77,15 @@ 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()
@@ -133,7 +142,7 @@ def build_image_jobspec(runtime, env, gcr_tag, stack_base):
}
build_env.update(env)
build_job = jobset.JobSpec(
- cmdline=[os.path.join(stack_base, _IMAGE_BUILDER)],
+ cmdline=[_IMAGE_BUILDER],
environ=build_env,
shortname='build_docker_%s' % runtime,
timeout_seconds=30*60)
@@ -227,6 +236,11 @@ def checkout_grpc_stack(lang, release):
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))
diff --git a/tools/interop_matrix/run_interop_matrix_tests.py b/tools/interop_matrix/run_interop_matrix_tests.py
index dce1033add..4265bc5355 100755
--- a/tools/interop_matrix/run_interop_matrix_tests.py
+++ b/tools/interop_matrix/run_interop_matrix_tests.py
@@ -100,7 +100,7 @@ def find_all_images_for_lang(lang):
jobset.message('SKIPPED',
'%s for %s is not defined' % (args.release, lang),
do_newline=True)
- return []
+ return {}
releases = [args.release]
# Images tuples keyed by runtime.
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/node__v1.0.1 b/tools/interop_matrix/testcases/node__v1.0.1
index fca9821544..6faf321391 100644
--- a/tools/interop_matrix/testcases/node__v1.0.1
+++ b/tools/interop_matrix/testcases/node__v1.0.1
@@ -1,21 +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=grpc-test.sandbox.googleapis.com --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=grpc-test.sandbox.googleapis.com --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=grpc-test.sandbox.googleapis.com --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=grpc-test.sandbox.googleapis.com --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=grpc-test.sandbox.googleapis.com --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=grpc-test.sandbox.googleapis.com --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=grpc-test.sandbox.googleapis.com --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=grpc-test.sandbox.googleapis.com --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=grpc-test.sandbox.googleapis.com --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=grpc-test4.sandbox.googleapis.com --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=grpc-test4.sandbox.googleapis.com --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=grpc-test4.sandbox.googleapis.com --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=grpc-test4.sandbox.googleapis.com --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=grpc-test4.sandbox.googleapis.com --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=grpc-test4.sandbox.googleapis.com --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=grpc-test4.sandbox.googleapis.com --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=grpc-test4.sandbox.googleapis.com --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=grpc-test4.sandbox.googleapis.com --server_host_override=grpc-test4.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_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/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/run_tests/artifacts/build_artifact_ruby.sh b/tools/run_tests/artifacts/build_artifact_ruby.sh
index 993aaaedbd..9165a22484 100755
--- a/tools/run_tests/artifacts/build_artifact_ruby.sh
+++ b/tools/run_tests/artifacts/build_artifact_ruby.sh
@@ -42,6 +42,7 @@ tools/run_tests/helper_scripts/bundle_install_wrapper.sh
set -ex
+export DOCKERHUB_ORGANIZATION=grpctesting
rake gem:native
if [ "$SYSTEM" == "Darwin" ] ; then
diff --git a/tools/run_tests/artifacts/distribtest_targets.py b/tools/run_tests/artifacts/distribtest_targets.py
index 9959651b6c..7ba0e0ebc9 100644
--- a/tools/run_tests/artifacts/distribtest_targets.py
+++ b/tools/run_tests/artifacts/distribtest_targets.py
@@ -49,7 +49,8 @@ def create_docker_jobspec(name, dockerfile_dir, shell_command, environ={},
def create_jobspec(name, cmdline, environ=None, shell=False,
flake_retries=0, timeout_retries=0,
- use_workspace=False):
+ use_workspace=False,
+ timeout_seconds=10*60):
"""Creates jobspec."""
environ = environ.copy()
if use_workspace:
@@ -60,7 +61,7 @@ def create_jobspec(name, cmdline, environ=None, shell=False,
cmdline=cmdline,
environ=environ,
shortname='distribtest.%s' % (name),
- timeout_seconds=10*60,
+ timeout_seconds=timeout_seconds,
flake_retries=flake_retries,
timeout_retries=timeout_retries,
shell=shell)
@@ -214,7 +215,10 @@ 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)
+ 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
@@ -231,6 +235,12 @@ class CppDistribTest(object):
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.")
@@ -242,6 +252,7 @@ def targets():
"""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'),
diff --git a/tools/run_tests/generated/configs.json b/tools/run_tests/generated/configs.json
index abbe76d60c..fee8290efe 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"
diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json
index 6cd9a04056..3958d8e9e4 100644
--- a/tools/run_tests/generated/sources_and_headers.json
+++ b/tools/run_tests/generated/sources_and_headers.json
@@ -711,21 +711,6 @@
"headers": [],
"is_filegroup": false,
"language": "c",
- "name": "gpr_histogram_test",
- "src": [
- "test/core/support/histogram_test.cc"
- ],
- "third_party": false,
- "type": "target"
- },
- {
- "deps": [
- "gpr",
- "gpr_test_util"
- ],
- "headers": [],
- "is_filegroup": false,
- "language": "c",
"name": "gpr_host_port_test",
"src": [
"test/core/support/host_port_test.cc"
@@ -756,9 +741,9 @@
"headers": [],
"is_filegroup": false,
"language": "c",
- "name": "gpr_mpscq_test",
+ "name": "gpr_manual_constructor_test",
"src": [
- "test/core/support/mpscq_test.cc"
+ "test/core/support/manual_constructor_test.cc"
],
"third_party": false,
"type": "target"
@@ -771,9 +756,9 @@
"headers": [],
"is_filegroup": false,
"language": "c",
- "name": "gpr_spinlock_test",
+ "name": "gpr_mpscq_test",
"src": [
- "test/core/support/spinlock_test.cc"
+ "test/core/support/mpscq_test.cc"
],
"third_party": false,
"type": "target"
@@ -786,9 +771,9 @@
"headers": [],
"is_filegroup": false,
"language": "c",
- "name": "gpr_stack_lockfree_test",
+ "name": "gpr_spinlock_test",
"src": [
- "test/core/support/stack_lockfree_test.cc"
+ "test/core/support/spinlock_test.cc"
],
"third_party": false,
"type": "target"
@@ -1207,12 +1192,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.cc"
+ "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"
@@ -2871,6 +2896,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",
@@ -2895,6 +2937,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++",
@@ -3860,6 +3925,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/support/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/support/ref_counted_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
+ "gpr_test_util",
+ "grpc",
+ "grpc++",
"grpc++_test_util",
"grpc_test_util"
],
@@ -4204,25 +4307,6 @@
"gpr_test_util",
"grpc",
"grpc++",
- "grpc++_test",
- "grpc_test_util"
- ],
- "headers": [],
- "is_filegroup": false,
- "language": "c++",
- "name": "vector_test",
- "src": [
- "test/core/support/vector_test.cc"
- ],
- "third_party": false,
- "type": "target"
- },
- {
- "deps": [
- "gpr",
- "gpr_test_util",
- "grpc",
- "grpc++",
"grpc++_test_util",
"grpc_test_util"
],
@@ -7698,7 +7782,7 @@
"src/core/lib/support/env_linux.cc",
"src/core/lib/support/env_posix.cc",
"src/core/lib/support/env_windows.cc",
- "src/core/lib/support/histogram.cc",
+ "src/core/lib/support/fork.cc",
"src/core/lib/support/host_port.cc",
"src/core/lib/support/log.cc",
"src/core/lib/support/log_android.cc",
@@ -7707,7 +7791,6 @@
"src/core/lib/support/log_windows.cc",
"src/core/lib/support/mpscq.cc",
"src/core/lib/support/murmur_hash.cc",
- "src/core/lib/support/stack_lockfree.cc",
"src/core/lib/support/string.cc",
"src/core/lib/support/string_posix.cc",
"src/core/lib/support/string_util_windows.cc",
@@ -7746,7 +7829,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",
@@ -7766,19 +7848,21 @@
"include/grpc/support/tls_pthread.h",
"include/grpc/support/useful.h",
"src/core/lib/profiling/timers.h",
+ "src/core/lib/support/abstract.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/env.h",
+ "src/core/lib/support/fork.h",
"src/core/lib/support/manual_constructor.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/thd_internal.h",
"src/core/lib/support/time_precise.h",
"src/core/lib/support/tmpfile.h"
],
@@ -7794,7 +7878,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",
@@ -7814,19 +7897,21 @@
"include/grpc/support/tls_pthread.h",
"include/grpc/support/useful.h",
"src/core/lib/profiling/timers.h",
+ "src/core/lib/support/abstract.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/env.h",
+ "src/core/lib/support/fork.h",
"src/core/lib/support/manual_constructor.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/thd_internal.h",
"src/core/lib/support/time_precise.h",
"src/core/lib/support/tmpfile.h"
],
@@ -7840,6 +7925,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",
@@ -7857,6 +7943,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",
@@ -7930,7 +8017,6 @@
"src/core/lib/http/httpcli.cc",
"src/core/lib/http/parser.cc",
"src/core/lib/iomgr/call_combiner.cc",
- "src/core/lib/iomgr/closure.cc",
"src/core/lib/iomgr/combiner.cc",
"src/core/lib/iomgr/endpoint.cc",
"src/core/lib/iomgr/endpoint_pair_posix.cc",
@@ -7945,6 +8031,8 @@
"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",
@@ -8057,6 +8145,7 @@
"include/grpc/byte_buffer.h",
"include/grpc/byte_buffer_reader.h",
"include/grpc/compression.h",
+ "include/grpc/fork.h",
"include/grpc/grpc.h",
"include/grpc/grpc_posix.h",
"include/grpc/grpc_security_constants.h",
@@ -8156,7 +8245,9 @@
"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/vector.h",
+ "src/core/lib/support/debug_location.h",
+ "src/core/lib/support/ref_counted.h",
+ "src/core/lib/support/ref_counted_ptr.h",
"src/core/lib/surface/alarm_internal.h",
"src/core/lib/surface/api_trace.h",
"src/core/lib/surface/call.h",
@@ -8193,6 +8284,7 @@
"include/grpc/byte_buffer.h",
"include/grpc/byte_buffer_reader.h",
"include/grpc/compression.h",
+ "include/grpc/fork.h",
"include/grpc/grpc.h",
"include/grpc/grpc_posix.h",
"include/grpc/grpc_security_constants.h",
@@ -8292,7 +8384,9 @@
"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/vector.h",
+ "src/core/lib/support/debug_location.h",
+ "src/core/lib/support/ref_counted.h",
+ "src/core/lib/support/ref_counted_ptr.h",
"src/core/lib/surface/alarm_internal.h",
"src/core/lib/surface/api_trace.h",
"src/core/lib/surface/call.h",
@@ -8848,6 +8942,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",
@@ -8855,6 +8950,7 @@
"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,
@@ -8875,6 +8971,8 @@
"test/core/util/debugger_macros.h",
"test/core/util/grpc_profiler.cc",
"test/core/util/grpc_profiler.h",
+ "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.cc",
@@ -8885,10 +8983,13 @@
"test/core/util/passthru_endpoint.h",
"test/core/util/port.cc",
"test/core/util/port.h",
+ "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.cc",
"test/core/util/slice_splitter.h",
+ "test/core/util/tracer_util.cc",
+ "test/core/util/tracer_util.h",
"test/core/util/trickle_endpoint.cc",
"test/core/util/trickle_endpoint.h"
],
diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json
index 5df5a7477b..6ffc7f412d 100644
--- a/tools/run_tests/generated/tests.json
+++ b/tools/run_tests/generated/tests.json
@@ -854,7 +854,7 @@
"flaky": false,
"gtest": false,
"language": "c",
- "name": "gpr_histogram_test",
+ "name": "gpr_host_port_test",
"platforms": [
"linux",
"mac",
@@ -878,7 +878,7 @@
"flaky": false,
"gtest": false,
"language": "c",
- "name": "gpr_host_port_test",
+ "name": "gpr_log_test",
"platforms": [
"linux",
"mac",
@@ -896,13 +896,13 @@
"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",
@@ -968,30 +968,6 @@
"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",
- "posix",
- "windows"
- ],
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
@@ -1507,6 +1483,50 @@
"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",
"posix",
@@ -3356,6 +3376,30 @@
"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",
+ "posix",
+ "windows"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "gtest": true,
+ "language": "c++",
"name": "cli_call_test",
"platforms": [
"linux",
@@ -3371,6 +3415,30 @@
"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",
"posix"
],
"cpu_cost": 0.1,
@@ -4070,6 +4138,54 @@
"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",
+ "posix",
+ "windows"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "gtest": true,
+ "language": "c++",
"name": "secure_auth_context_test",
"platforms": [
"linux",
@@ -4394,30 +4510,6 @@
"ci_platforms": [
"linux",
"mac",
- "posix",
- "windows"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "gtest": true,
- "language": "c++",
- "name": "vector_test",
- "platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
- ],
- "uses_polling": true
- },
- {
- "args": [],
- "benchmark": false,
- "ci_platforms": [
- "linux",
- "mac",
"posix"
],
"cpu_cost": 0.5,
diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py
index b20d6ce88e..8f46ea99fd 100755
--- a/tools/run_tests/run_interop_tests.py
+++ b/tools/run_tests/run_interop_tests.py
@@ -319,14 +319,16 @@ class NodeLanguage:
def client_cmd(self, args):
return ['packages/grpc-native-core/deps/grpc/tools/run_tests/interop/with_nvm.sh',
- 'node', 'test/interop/interop_client.js'] + args
+ 'node', '--require', './test/fixtures/native_native',
+ 'test/interop/interop_client.js'] + args
def cloud_to_prod_env(self):
return {}
def server_cmd(self, args):
return ['packages/grpc-native-core/deps/grpc/tools/run_tests/interop/with_nvm.sh',
- 'node', 'test/interop/interop_server.js'] + args
+ 'node', '--require', './test/fixtures/native_native',
+ 'test/interop/interop_server.js'] + args
def global_env(self):
return {}
@@ -572,6 +574,7 @@ def manual_cmdline(docker_cmdline, docker_image):
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
@@ -1242,7 +1245,7 @@ try:
_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:
diff --git a/tools/run_tests/run_performance_tests.py b/tools/run_tests/run_performance_tests.py
index 1bbab9e894..aa305be466 100755
--- a/tools/run_tests/run_performance_tests.py
+++ b/tools/run_tests/run_performance_tests.py
@@ -196,7 +196,7 @@ def archive_repo(languages):
def prepare_remote_hosts(hosts, prepare_local=False):
"""Prepares remote hosts (and maybe prepare localhost as well)."""
- prepare_timeout = 5*60
+ prepare_timeout = 10*60
prepare_jobs = []
for host in hosts:
user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, host)
@@ -229,6 +229,8 @@ def prepare_remote_hosts(hosts, prepare_local=False):
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)
@@ -245,7 +247,7 @@ def build_on_remote_hosts(hosts, languages=scenario_config.LANGUAGES.keys(), bui
cmdline=['tools/run_tests/performance/build_performance.sh'] + languages,
shortname='local_build',
environ = {'CONFIG': 'opt'},
- timeout_seconds=build_timeout))
+ timeout_seconds=local_build_timeout))
jobset.message('START', 'Building.', do_newline=True)
num_failures, _ = jobset.run(
build_jobs, newline_on_success=True, maxjobs=10)
@@ -483,9 +485,15 @@ def main():
'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'
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index 766c1c0b7c..471f5d99e7 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -1231,7 +1231,7 @@ if not args.disable_auto_set_flakes:
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])
+ print("Unexpected error getting flaky tests: %s" % traceback.format_exc())
if args.force_default_poller:
_POLLING_STRATEGIES = {}
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..776c78b03f
--- /dev/null
+++ b/tools/run_tests/sanity/check_bazel_workspace.py
@@ -0,0 +1,49 @@
+#!/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}
+
+# Parse git hashes from Bazel WORKSPACE {new_}http_archive rules
+with open('WORKSPACE', 'r') as f:
+ workspace_rules = [expr.value for expr in ast.parse(f.read()).body]
+
+http_archive_rules = [rule for rule in workspace_rules if rule.func.id.endswith('http_archive')]
+archive_urls = [kw.value.s for rule in http_archive_rules for kw in rule.keywords if kw.arg == 'url']
+workspace_git_hashes = {re.search(git_hash_pattern, url).group() for url in archive_urls}
+
+# 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)
+
+sys.exit(0)
diff --git a/tools/run_tests/sanity/check_clang_tidy.sh b/tools/run_tests/sanity/check_clang_tidy.sh
new file mode 100755
index 0000000000..42ab511a20
--- /dev/null
+++ b/tools/run_tests/sanity/check_clang_tidy.sh
@@ -0,0 +1,21 @@
+#!/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 buildtests \
+ -j `python -c 'import multiprocessing; print multiprocessing.cpu_count()'`
+find src/core src/cpp test/core test/cpp -name '*.h' -or -name '*.cc' | \
+ xargs tools/distrib/run_clang_tidy.py $*
diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh
index 1f7b078ff7..b573d21f4f 100755
--- a/tools/run_tests/sanity/check_submodules.sh
+++ b/tools/run_tests/sanity/check_submodules.sh
@@ -31,7 +31,7 @@ cat << EOF | awk '{ print $1 }' | sort > $want_submodules
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
diff --git a/tools/run_tests/sanity/check_unsecure.sh b/tools/run_tests/sanity/check_unsecure.sh
new file mode 100755
index 0000000000..8584cbe36b
--- /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/sanity_tests.yaml b/tools/run_tests/sanity/sanity_tests.yaml
index 4bc4b7c56f..3ce864a8bd 100644
--- a/tools/run_tests/sanity/sanity_tests.yaml
+++ b/tools/run_tests/sanity/sanity_tests.yaml
@@ -1,10 +1,12 @@
# 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_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
@@ -17,4 +19,5 @@
- script: tools/distrib/pylint_code.sh
- script: tools/distrib/yapf_code.sh
- script: tools/distrib/python/check_grpcio_tools.py
-
+- script: tools/run_tests/sanity/check_clang_tidy.sh
+ cpu_cost: 1000