aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/grpc++/support/channel_arguments.h2
-rw-r--r--include/grpc/impl/codegen/grpc_types.h2
-rw-r--r--include/grpc/impl/codegen/slice.h2
-rw-r--r--include/grpc/slice_buffer.h3
-rw-r--r--src/core/ext/filters/client_channel/backup_poller.cc47
-rw-r--r--src/core/ext/filters/client_channel/backup_poller.h4
-rw-r--r--src/core/ext/filters/client_channel/channel_connectivity.cc52
-rw-r--r--src/core/ext/filters/client_channel/client_channel.cc400
-rw-r--r--src/core/ext/filters/client_channel/client_channel.h8
-rw-r--r--src/core/ext/filters/client_channel/client_channel_factory.cc23
-rw-r--r--src/core/ext/filters/client_channel/client_channel_factory.h19
-rw-r--r--src/core/ext/filters/client_channel/client_channel_plugin.cc13
-rw-r--r--src/core/ext/filters/client_channel/connector.cc13
-rw-r--r--src/core/ext/filters/client_channel/connector.h14
-rw-r--r--src/core/ext/filters/client_channel/http_connect_handshaker.cc84
-rw-r--r--src/core/ext/filters/client_channel/http_proxy.cc18
-rw-r--r--src/core/ext/filters/client_channel/lb_policy.cc68
-rw-r--r--src/core/ext/filters/client_channel/lb_policy.h71
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc27
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc421
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc6
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h4
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc10
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc174
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc143
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc54
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/subchannel_list.h18
-rw-r--r--src/core/ext/filters/client_channel/lb_policy_factory.cc15
-rw-r--r--src/core/ext/filters/client_channel/lb_policy_factory.h11
-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.h2
-rw-r--r--src/core/ext/filters/client_channel/proxy_mapper.cc14
-rw-r--r--src/core/ext/filters/client_channel/proxy_mapper.h14
-rw-r--r--src/core/ext/filters/client_channel/proxy_mapper_registry.cc30
-rw-r--r--src/core/ext/filters/client_channel/proxy_mapper_registry.h6
-rw-r--r--src/core/ext/filters/client_channel/resolver.cc24
-rw-r--r--src/core/ext/filters/client_channel/resolver.h31
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc94
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h6
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc52
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc70
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h12
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc20
-rw-r--r--src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc90
-rw-r--r--src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc52
-rw-r--r--src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h2
-rw-r--r--src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc55
-rw-r--r--src/core/ext/filters/client_channel/resolver_factory.cc5
-rw-r--r--src/core/ext/filters/client_channel/resolver_factory.h6
-rw-r--r--src/core/ext/filters/client_channel/resolver_registry.cc27
-rw-r--r--src/core/ext/filters/client_channel/resolver_registry.h7
-rw-r--r--src/core/ext/filters/client_channel/subchannel.cc239
-rw-r--r--src/core/ext/filters/client_channel/subchannel.h75
-rw-r--r--src/core/ext/filters/client_channel/subchannel_index.cc63
-rw-r--r--src/core/ext/filters/client_channel/subchannel_index.h12
-rw-r--r--src/core/ext/filters/client_channel/uri_parser.cc28
-rw-r--r--src/core/ext/filters/client_channel/uri_parser.h3
-rw-r--r--src/core/ext/filters/deadline/deadline_filter.cc112
-rw-r--r--src/core/ext/filters/deadline/deadline_filter.h10
-rw-r--r--src/core/ext/filters/http/client/http_client_filter.cc125
-rw-r--r--src/core/ext/filters/http/http_filters_plugin.cc6
-rw-r--r--src/core/ext/filters/http/message_compress/message_compress_filter.cc126
-rw-r--r--src/core/ext/filters/http/server/http_server_filter.cc118
-rw-r--r--src/core/ext/filters/load_reporting/server_load_reporting_filter.cc33
-rw-r--r--src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc2
-rw-r--r--src/core/ext/filters/max_age/max_age_filter.cc101
-rw-r--r--src/core/ext/filters/message_size/message_size_filter.cc36
-rw-r--r--src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc23
-rw-r--r--src/core/ext/transport/chttp2/client/chttp2_connector.cc68
-rw-r--r--src/core/ext/transport/chttp2/client/insecure/channel_create.cc32
-rw-r--r--src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc16
-rw-r--r--src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc51
-rw-r--r--src/core/ext/transport/chttp2/server/chttp2_server.cc79
-rw-r--r--src/core/ext/transport/chttp2/server/chttp2_server.h3
-rw-r--r--src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc6
-rw-r--r--src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc17
-rw-r--r--src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc11
-rw-r--r--src/core/ext/transport/chttp2/transport/bin_decoder.cc14
-rw-r--r--src/core/ext/transport/chttp2/transport/bin_decoder.h5
-rw-r--r--src/core/ext/transport/chttp2/transport/bin_encoder.h2
-rw-r--r--src/core/ext/transport/chttp2/transport/chttp2_transport.cc1082
-rw-r--r--src/core/ext/transport/chttp2/transport/chttp2_transport.h6
-rw-r--r--src/core/ext/transport/chttp2/transport/flow_control.cc15
-rw-r--r--src/core/ext/transport/chttp2/transport/flow_control.h7
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_data.cc62
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_data.h7
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_goaway.cc5
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_goaway.h3
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_ping.cc11
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_ping.h2
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_rst_stream.cc5
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_rst_stream.h3
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_settings.cc3
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_settings.h3
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_window_update.cc16
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_window_update.h8
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_encoder.cc144
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_encoder.h6
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_parser.cc546
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_parser.h17
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_table.cc32
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_table.h13
-rw-r--r--src/core/ext/transport/chttp2/transport/incoming_metadata.cc19
-rw-r--r--src/core/ext/transport/chttp2/transport/incoming_metadata.h9
-rw-r--r--src/core/ext/transport/chttp2/transport/internal.h106
-rw-r--r--src/core/ext/transport/chttp2/transport/parsing.cc185
-rw-r--r--src/core/ext/transport/chttp2/transport/writing.cc121
-rw-r--r--src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc5
-rw-r--r--src/core/ext/transport/cronet/transport/cronet_transport.cc173
-rw-r--r--src/core/ext/transport/inproc/inproc_transport.cc342
-rw-r--r--src/core/lib/backoff/backoff.cc10
-rw-r--r--src/core/lib/backoff/backoff.h6
-rw-r--r--src/core/lib/channel/channel_args.cc16
-rw-r--r--src/core/lib/channel/channel_args.h9
-rw-r--r--src/core/lib/channel/channel_stack.cc46
-rw-r--r--src/core/lib/channel/channel_stack.h64
-rw-r--r--src/core/lib/channel/channel_stack_builder.cc25
-rw-r--r--src/core/lib/channel/channel_stack_builder.h11
-rw-r--r--src/core/lib/channel/connected_channel.cc57
-rw-r--r--src/core/lib/channel/connected_channel.h3
-rw-r--r--src/core/lib/channel/handshaker.cc80
-rw-r--r--src/core/lib/channel/handshaker.h36
-rw-r--r--src/core/lib/channel/handshaker_factory.cc12
-rw-r--r--src/core/lib/channel/handshaker_factory.h12
-rw-r--r--src/core/lib/channel/handshaker_registry.cc22
-rw-r--r--src/core/lib/channel/handshaker_registry.h5
-rw-r--r--src/core/lib/compression/message_compress.cc42
-rw-r--r--src/core/lib/compression/message_compress.h6
-rw-r--r--src/core/lib/compression/stream_compression_gzip.cc20
-rw-r--r--src/core/lib/debug/stats.cc6
-rw-r--r--src/core/lib/debug/stats.h20
-rw-r--r--src/core/lib/debug/stats_data.cc201
-rw-r--r--src/core/lib/debug/stats_data.h540
-rw-r--r--src/core/lib/http/httpcli.cc127
-rw-r--r--src/core/lib/http/httpcli.h27
-rw-r--r--src/core/lib/http/httpcli_security_connector.cc55
-rw-r--r--src/core/lib/iomgr/block_annotate.h23
-rw-r--r--src/core/lib/iomgr/call_combiner.cc31
-rw-r--r--src/core/lib/iomgr/call_combiner.h40
-rw-r--r--src/core/lib/iomgr/closure.cc29
-rw-r--r--src/core/lib/iomgr/closure.h49
-rw-r--r--src/core/lib/iomgr/combiner.cc128
-rw-r--r--src/core/lib/iomgr/combiner.h12
-rw-r--r--src/core/lib/iomgr/endpoint.cc36
-rw-r--r--src/core/lib/iomgr/endpoint.h41
-rw-r--r--src/core/lib/iomgr/endpoint_pair_posix.cc7
-rw-r--r--src/core/lib/iomgr/endpoint_pair_windows.cc10
-rw-r--r--src/core/lib/iomgr/error.cc6
-rw-r--r--src/core/lib/iomgr/ev_epoll1_linux.cc198
-rw-r--r--src/core/lib/iomgr/ev_epollex_linux.cc240
-rw-r--r--src/core/lib/iomgr/ev_epollsig_linux.cc182
-rw-r--r--src/core/lib/iomgr/ev_poll_posix.cc199
-rw-r--r--src/core/lib/iomgr/ev_posix.cc78
-rw-r--r--src/core/lib/iomgr/ev_posix.h72
-rw-r--r--src/core/lib/iomgr/exec_ctx.cc137
-rw-r--r--src/core/lib/iomgr/exec_ctx.h168
-rw-r--r--src/core/lib/iomgr/executor.cc58
-rw-r--r--src/core/lib/iomgr/executor.h6
-rw-r--r--src/core/lib/iomgr/iocp_windows.cc30
-rw-r--r--src/core/lib/iomgr/iocp_windows.h3
-rw-r--r--src/core/lib/iomgr/iomgr.cc27
-rw-r--r--src/core/lib/iomgr/iomgr.h6
-rw-r--r--src/core/lib/iomgr/iomgr_uv.cc5
-rw-r--r--src/core/lib/iomgr/load_file.cc2
-rw-r--r--src/core/lib/iomgr/lockfree_event.cc15
-rw-r--r--src/core/lib/iomgr/lockfree_event.h6
-rw-r--r--src/core/lib/iomgr/polling_entity.cc16
-rw-r--r--src/core/lib/iomgr/polling_entity.h6
-rw-r--r--src/core/lib/iomgr/pollset.h9
-rw-r--r--src/core/lib/iomgr/pollset_set.h15
-rw-r--r--src/core/lib/iomgr/pollset_set_uv.cc15
-rw-r--r--src/core/lib/iomgr/pollset_set_windows.cc15
-rw-r--r--src/core/lib/iomgr/pollset_uv.cc15
-rw-r--r--src/core/lib/iomgr/pollset_windows.cc27
-rw-r--r--src/core/lib/iomgr/resolve_address.h3
-rw-r--r--src/core/lib/iomgr/resolve_address_posix.cc19
-rw-r--r--src/core/lib/iomgr/resolve_address_uv.cc15
-rw-r--r--src/core/lib/iomgr/resolve_address_windows.cc14
-rw-r--r--src/core/lib/iomgr/resource_quota.cc187
-rw-r--r--src/core/lib/iomgr/resource_quota.h25
-rw-r--r--src/core/lib/iomgr/socket_factory_posix.cc2
-rw-r--r--src/core/lib/iomgr/socket_mutator.cc2
-rw-r--r--src/core/lib/iomgr/socket_windows.cc19
-rw-r--r--src/core/lib/iomgr/socket_windows.h9
-rw-r--r--src/core/lib/iomgr/tcp_client.h3
-rw-r--r--src/core/lib/iomgr/tcp_client_posix.cc64
-rw-r--r--src/core/lib/iomgr/tcp_client_posix.h3
-rw-r--r--src/core/lib/iomgr/tcp_client_uv.cc37
-rw-r--r--src/core/lib/iomgr/tcp_client_windows.cc45
-rw-r--r--src/core/lib/iomgr/tcp_posix.cc251
-rw-r--r--src/core/lib/iomgr/tcp_posix.h7
-rw-r--r--src/core/lib/iomgr/tcp_server.h15
-rw-r--r--src/core/lib/iomgr/tcp_server_posix.cc64
-rw-r--r--src/core/lib/iomgr/tcp_server_uv.cc57
-rw-r--r--src/core/lib/iomgr/tcp_server_windows.cc58
-rw-r--r--src/core/lib/iomgr/tcp_uv.cc93
-rw-r--r--src/core/lib/iomgr/tcp_windows.cc93
-rw-r--r--src/core/lib/iomgr/tcp_windows.h2
-rw-r--r--src/core/lib/iomgr/timer.h13
-rw-r--r--src/core/lib/iomgr/timer_generic.cc47
-rw-r--r--src/core/lib/iomgr/timer_manager.cc33
-rw-r--r--src/core/lib/iomgr/timer_uv.cc26
-rw-r--r--src/core/lib/iomgr/udp_server.cc60
-rw-r--r--src/core/lib/iomgr/udp_server.h17
-rw-r--r--src/core/lib/security/context/security_context.cc17
-rw-r--r--src/core/lib/security/credentials/composite/composite_credentials.cc51
-rw-r--r--src/core/lib/security/credentials/credentials.cc73
-rw-r--r--src/core/lib/security/credentials/credentials.h59
-rw-r--r--src/core/lib/security/credentials/credentials_metadata.cc4
-rw-r--r--src/core/lib/security/credentials/fake/fake_credentials.cc36
-rw-r--r--src/core/lib/security/credentials/google_default/google_default_credentials.cc58
-rw-r--r--src/core/lib/security/credentials/iam/iam_credentials.cc22
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_credentials.cc34
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_credentials.h3
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_verifier.cc126
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_verifier.h14
-rw-r--r--src/core/lib/security/credentials/oauth2/oauth2_credentials.cc102
-rw-r--r--src/core/lib/security/credentials/oauth2/oauth2_credentials.h7
-rw-r--r--src/core/lib/security/credentials/plugin/plugin_credentials.cc51
-rw-r--r--src/core/lib/security/credentials/ssl/ssl_credentials.cc21
-rw-r--r--src/core/lib/security/transport/client_auth_filter.cc85
-rw-r--r--src/core/lib/security/transport/lb_targets_info.cc4
-rw-r--r--src/core/lib/security/transport/secure_endpoint.cc120
-rw-r--r--src/core/lib/security/transport/security_connector.cc144
-rw-r--r--src/core/lib/security/transport/security_connector.h53
-rw-r--r--src/core/lib/security/transport/security_handshaker.cc189
-rw-r--r--src/core/lib/security/transport/security_handshaker.h3
-rw-r--r--src/core/lib/security/transport/server_auth_filter.cc55
-rw-r--r--src/core/lib/slice/b64.cc11
-rw-r--r--src/core/lib/slice/b64.h7
-rw-r--r--src/core/lib/slice/slice.cc17
-rw-r--r--src/core/lib/slice/slice_buffer.cc27
-rw-r--r--src/core/lib/slice/slice_hash_table.cc12
-rw-r--r--src/core/lib/slice/slice_hash_table.h6
-rw-r--r--src/core/lib/slice/slice_intern.cc7
-rw-r--r--src/core/lib/slice/slice_internal.h8
-rw-r--r--src/core/lib/surface/alarm.cc25
-rw-r--r--src/core/lib/surface/byte_buffer.cc5
-rw-r--r--src/core/lib/surface/byte_buffer_reader.cc16
-rw-r--r--src/core/lib/surface/call.cc420
-rw-r--r--src/core/lib/surface/call.h24
-rw-r--r--src/core/lib/surface/call_details.cc7
-rw-r--r--src/core/lib/surface/channel.cc115
-rw-r--r--src/core/lib/surface/channel.h27
-rw-r--r--src/core/lib/surface/channel_init.cc5
-rw-r--r--src/core/lib/surface/channel_init.h6
-rw-r--r--src/core/lib/surface/channel_ping.cc14
-rw-r--r--src/core/lib/surface/completion_queue.cc328
-rw-r--r--src/core/lib/surface/completion_queue.h21
-rw-r--r--src/core/lib/surface/init.cc26
-rw-r--r--src/core/lib/surface/init_secure.cc4
-rw-r--r--src/core/lib/surface/lame_client.cc53
-rw-r--r--src/core/lib/surface/server.cc322
-rw-r--r--src/core/lib/surface/server.h15
-rw-r--r--src/core/lib/transport/bdp_estimator.cc4
-rw-r--r--src/core/lib/transport/bdp_estimator.h2
-rw-r--r--src/core/lib/transport/byte_stream.cc62
-rw-r--r--src/core/lib/transport/byte_stream.h27
-rw-r--r--src/core/lib/transport/connectivity_state.cc22
-rw-r--r--src/core/lib/transport/connectivity_state.h10
-rw-r--r--src/core/lib/transport/error_utils.cc9
-rw-r--r--src/core/lib/transport/error_utils.h5
-rw-r--r--src/core/lib/transport/metadata.cc40
-rw-r--r--src/core/lib/transport/metadata.h20
-rw-r--r--src/core/lib/transport/metadata_batch.cc79
-rw-r--r--src/core/lib/transport/metadata_batch.h42
-rw-r--r--src/core/lib/transport/service_config.cc24
-rw-r--r--src/core/lib/transport/service_config.h8
-rw-r--r--src/core/lib/transport/static_metadata.cc2
-rw-r--r--src/core/lib/transport/status_conversion.cc5
-rw-r--r--src/core/lib/transport/status_conversion.h3
-rw-r--r--src/core/lib/transport/transport.cc84
-rw-r--r--src/core/lib/transport/transport.h33
-rw-r--r--src/core/lib/transport/transport_impl.h27
-rw-r--r--src/core/tsi/fake_transport_security.cc17
-rw-r--r--src/core/tsi/transport_security.h2
-rw-r--r--src/core/tsi/transport_security_grpc.cc29
-rw-r--r--src/core/tsi/transport_security_grpc.h22
-rw-r--r--src/cpp/common/channel_arguments.cc11
-rw-r--r--src/cpp/common/channel_filter.cc29
-rw-r--r--src/cpp/common/channel_filter.h62
-rw-r--r--src/ruby/ext/grpc/rb_grpc_imports.generated.h2
-rw-r--r--test/core/backoff/backoff_test.cc96
-rw-r--r--test/core/bad_client/bad_client.cc46
-rw-r--r--test/core/channel/channel_args_test.cc26
-rw-r--r--test/core/channel/channel_stack_builder_test.cc24
-rw-r--r--test/core/channel/channel_stack_test.cc45
-rw-r--r--test/core/channel/minimal_stack_is_minimal_test.cc15
-rw-r--r--test/core/client_channel/lb_policies_test.cc14
-rw-r--r--test/core/client_channel/parse_address_test.cc15
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc55
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_test.cc21
-rw-r--r--test/core/client_channel/resolvers/fake_resolver_test.cc54
-rw-r--r--test/core/client_channel/resolvers/sockaddr_resolver_test.cc28
-rw-r--r--test/core/client_channel/uri_fuzzer_test.cc6
-rw-r--r--test/core/client_channel/uri_parser_test.cc28
-rw-r--r--test/core/compression/algorithm_test.cc12
-rw-r--r--test/core/compression/message_compress_test.cc62
-rw-r--r--test/core/debug/stats_test.cc15
-rw-r--r--test/core/end2end/bad_server_response_test.cc35
-rw-r--r--test/core/end2end/connection_refused_test.cc5
-rw-r--r--test/core/end2end/fixtures/h2_census.cc10
-rw-r--r--test/core/end2end/fixtures/h2_compress.cc17
-rw-r--r--test/core/end2end/fixtures/h2_fd.cc8
-rw-r--r--test/core/end2end/fixtures/h2_full+workarounds.cc5
-rw-r--r--test/core/end2end/fixtures/h2_load_reporting.cc5
-rw-r--r--test/core/end2end/fixtures/h2_oauth2.cc7
-rw-r--r--test/core/end2end/fixtures/h2_sockpair+trace.cc36
-rw-r--r--test/core/end2end/fixtures/h2_sockpair.cc33
-rw-r--r--test/core/end2end/fixtures/h2_sockpair_1byte.cc33
-rw-r--r--test/core/end2end/fixtures/h2_ssl.cc5
-rw-r--r--test/core/end2end/fixtures/h2_ssl_proxy.cc10
-rw-r--r--test/core/end2end/fixtures/http_proxy_fixture.cc177
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer.cc83
-rw-r--r--test/core/end2end/fuzzers/client_fuzzer.cc17
-rw-r--r--test/core/end2end/fuzzers/server_fuzzer.cc17
-rw-r--r--test/core/end2end/goaway_server_test.cc28
-rw-r--r--test/core/end2end/h2_ssl_cert_test.cc5
-rw-r--r--test/core/end2end/tests/cancel_after_accept.cc5
-rw-r--r--test/core/end2end/tests/cancel_after_round_trip.cc5
-rw-r--r--test/core/end2end/tests/compressed_payload.cc19
-rw-r--r--test/core/end2end/tests/filter_call_init_fails.cc19
-rw-r--r--test/core/end2end/tests/filter_causes_close.cc24
-rw-r--r--test/core/end2end/tests/filter_latency.cc18
-rw-r--r--test/core/end2end/tests/load_reporting_hook.cc5
-rw-r--r--test/core/end2end/tests/max_message_length.cc18
-rw-r--r--test/core/end2end/tests/stream_compression_compressed_payload.cc19
-rw-r--r--test/core/end2end/tests/stream_compression_payload.cc7
-rw-r--r--test/core/end2end/tests/stream_compression_ping_pong_streaming.cc7
-rw-r--r--test/core/end2end/tests/workaround_cronet_compression.cc12
-rw-r--r--test/core/handshake/readahead_handshaker_server_ssl.cc16
-rw-r--r--test/core/http/httpcli_test.cc47
-rw-r--r--test/core/http/httpscli_test.cc47
-rw-r--r--test/core/iomgr/combiner_test.cc51
-rw-r--r--test/core/iomgr/endpoint_pair_test.cc18
-rw-r--r--test/core/iomgr/endpoint_tests.cc99
-rw-r--r--test/core/iomgr/ev_epollsig_linux_test.cc87
-rw-r--r--test/core/iomgr/fd_conservation_posix_test.cc11
-rw-r--r--test/core/iomgr/fd_posix_test.cc141
-rw-r--r--test/core/iomgr/pollset_set_test.cc216
-rw-r--r--test/core/iomgr/resolve_address_posix_test.cc59
-rw-r--r--test/core/iomgr/resolve_address_test.cc135
-rw-r--r--test/core/iomgr/resource_quota_test.cc354
-rw-r--r--test/core/iomgr/tcp_client_posix_test.cc64
-rw-r--r--test/core/iomgr/tcp_client_uv_test.cc62
-rw-r--r--test/core/iomgr/tcp_posix_test.cc138
-rw-r--r--test/core/iomgr/tcp_server_posix_test.cc86
-rw-r--r--test/core/iomgr/tcp_server_uv_test.cc90
-rw-r--r--test/core/iomgr/timer_list_test.cc72
-rw-r--r--test/core/iomgr/udp_server_test.cc73
-rw-r--r--test/core/security/credentials_test.cc303
-rw-r--r--test/core/security/json_token_test.cc14
-rw-r--r--test/core/security/jwt_verifier_test.cc146
-rw-r--r--test/core/security/oauth2_utils.cc30
-rw-r--r--test/core/security/print_google_default_creds_token.cc22
-rw-r--r--test/core/security/secure_endpoint_test.cc46
-rw-r--r--test/core/security/ssl_server_fuzzer.cc33
-rw-r--r--test/core/security/verify_jwt.cc23
-rw-r--r--test/core/slice/b64_test.cc43
-rw-r--r--test/core/slice/slice_hash_table_test.cc37
-rw-r--r--test/core/surface/byte_buffer_reader_test.cc6
-rw-r--r--test/core/surface/channel_create_test.cc3
-rw-r--r--test/core/surface/completion_queue_test.cc39
-rw-r--r--test/core/surface/completion_queue_threading_test.cc19
-rw-r--r--test/core/surface/concurrent_connectivity_test.cc35
-rw-r--r--test/core/surface/lame_client_test.cc13
-rw-r--r--test/core/surface/num_external_connectivity_watchers_test.cc5
-rw-r--r--test/core/surface/secure_channel_create_test.cc17
-rw-r--r--test/core/surface/sequential_connectivity_test.cc5
-rw-r--r--test/core/transport/bdp_estimator_test.cc7
-rw-r--r--test/core/transport/byte_stream_test.cc110
-rw-r--r--test/core/transport/chttp2/bin_decoder_test.cc102
-rw-r--r--test/core/transport/chttp2/hpack_encoder_test.cc91
-rw-r--r--test/core/transport/chttp2/hpack_parser_fuzzer_test.cc14
-rw-r--r--test/core/transport/chttp2/hpack_parser_test.cc41
-rw-r--r--test/core/transport/chttp2/hpack_table_test.cc72
-rw-r--r--test/core/transport/connectivity_state_test.cc48
-rw-r--r--test/core/transport/metadata_test.cc135
-rw-r--r--test/core/transport/status_conversion_test.cc11
-rw-r--r--test/core/transport/stream_owned_slice_test.cc2
-rw-r--r--test/core/util/mock_endpoint.cc36
-rw-r--r--test/core/util/mock_endpoint.h3
-rw-r--r--test/core/util/passthru_endpoint.cc45
-rw-r--r--test/core/util/port_server_client.cc70
-rw-r--r--test/core/util/reconnect_server.cc6
-rw-r--r--test/core/util/test_tcp_server.cc36
-rw-r--r--test/core/util/trickle_endpoint.cc56
-rw-r--r--test/core/util/trickle_endpoint.h3
-rw-r--r--test/cpp/common/channel_filter_test.cc4
-rw-r--r--test/cpp/end2end/client_lb_end2end_test.cc13
-rw-r--r--test/cpp/end2end/filter_end2end_test.cc7
-rw-r--r--test/cpp/end2end/grpclb_end2end_test.cc11
-rw-r--r--test/cpp/grpclb/grpclb_test.cc17
-rw-r--r--test/cpp/microbenchmarks/bm_call_create.cc139
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_hpack.cc136
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_transport.cc270
-rw-r--r--test/cpp/microbenchmarks/bm_closure.cc196
-rw-r--r--test/cpp/microbenchmarks/bm_cq.cc26
-rw-r--r--test/cpp/microbenchmarks/bm_cq_multiple_threads.cc22
-rw-r--r--test/cpp/microbenchmarks/bm_error.cc24
-rw-r--r--test/cpp/microbenchmarks/bm_fullstack_trickle.cc8
-rw-r--r--test/cpp/microbenchmarks/bm_metadata.cc115
-rw-r--r--test/cpp/microbenchmarks/bm_pollset.cc53
-rw-r--r--test/cpp/microbenchmarks/fullstack_fixtures.h25
-rw-r--r--test/cpp/naming/resolver_component_test.cc50
-rw-r--r--test/cpp/performance/writes_per_rpc_test.cc20
-rwxr-xr-xtools/codegen/core/gen_stats_data.py24
407 files changed, 9171 insertions, 11803 deletions
diff --git a/include/grpc++/support/channel_arguments.h b/include/grpc++/support/channel_arguments.h
index 9dc505f008..c9879d8a28 100644
--- a/include/grpc++/support/channel_arguments.h
+++ b/include/grpc++/support/channel_arguments.h
@@ -122,7 +122,7 @@ class ChannelArguments {
/// Default pointer argument operations.
struct PointerVtableMembers {
static void* Copy(void* in) { return in; }
- static void Destroy(grpc_exec_ctx* exec_ctx, void* in) {}
+ static void Destroy(void* in) {}
static int Compare(void* a, void* b) {
if (a < b) return -1;
if (a > b) return 1;
diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h
index 03be610d25..326529e638 100644
--- a/include/grpc/impl/codegen/grpc_types.h
+++ b/include/grpc/impl/codegen/grpc_types.h
@@ -85,7 +85,7 @@ typedef enum {
typedef struct grpc_arg_pointer_vtable {
void* (*copy)(void* p);
- void (*destroy)(grpc_exec_ctx* exec_ctx, void* p);
+ void (*destroy)(void* p);
int (*cmp)(void* p, void* q);
} grpc_arg_pointer_vtable;
diff --git a/include/grpc/impl/codegen/slice.h b/include/grpc/impl/codegen/slice.h
index 11997fcb56..ad026b685e 100644
--- a/include/grpc/impl/codegen/slice.h
+++ b/include/grpc/impl/codegen/slice.h
@@ -43,7 +43,7 @@ typedef struct grpc_slice grpc_slice;
typedef struct grpc_slice_refcount_vtable {
void (*ref)(void*);
- void (*unref)(grpc_exec_ctx* exec_ctx, void*);
+ void (*unref)(void*);
int (*eq)(grpc_slice a, grpc_slice b);
uint32_t (*hash)(grpc_slice slice);
} grpc_slice_refcount_vtable;
diff --git a/include/grpc/slice_buffer.h b/include/grpc/slice_buffer.h
index 6510c151b3..30833d02db 100644
--- a/include/grpc/slice_buffer.h
+++ b/include/grpc/slice_buffer.h
@@ -67,8 +67,7 @@ GPRAPI void grpc_slice_buffer_move_first_no_ref(grpc_slice_buffer* src,
size_t n,
grpc_slice_buffer* dst);
/** move the first n bytes of src into dst (copying them) */
-GPRAPI void grpc_slice_buffer_move_first_into_buffer(grpc_exec_ctx* exec_ctx,
- grpc_slice_buffer* src,
+GPRAPI void grpc_slice_buffer_move_first_into_buffer(grpc_slice_buffer* src,
size_t n, void* dst);
/** take the first slice in the slice buffer */
GPRAPI grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer* src);
diff --git a/src/core/ext/filters/client_channel/backup_poller.cc b/src/core/ext/filters/client_channel/backup_poller.cc
index ed437d255c..339a79b0fb 100644
--- a/src/core/ext/filters/client_channel/backup_poller.cc
+++ b/src/core/ext/filters/client_channel/backup_poller.cc
@@ -69,20 +69,19 @@ static void init_globals() {
gpr_free(env);
}
-static void backup_poller_shutdown_unref(grpc_exec_ctx* exec_ctx,
- backup_poller* p) {
+static void backup_poller_shutdown_unref(backup_poller* p) {
if (gpr_unref(&p->shutdown_refs)) {
- grpc_pollset_destroy(exec_ctx, p->pollset);
+ grpc_pollset_destroy(p->pollset);
gpr_free(p->pollset);
gpr_free(p);
}
}
-static void done_poller(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
- backup_poller_shutdown_unref(exec_ctx, (backup_poller*)arg);
+static void done_poller(void* arg, grpc_error* error) {
+ backup_poller_shutdown_unref((backup_poller*)arg);
}
-static void g_poller_unref(grpc_exec_ctx* exec_ctx) {
+static void g_poller_unref() {
if (gpr_unref(&g_poller->refs)) {
gpr_mu_lock(&g_poller_mu);
backup_poller* p = g_poller;
@@ -90,40 +89,40 @@ static void g_poller_unref(grpc_exec_ctx* exec_ctx) {
gpr_mu_unlock(&g_poller_mu);
gpr_mu_lock(p->pollset_mu);
p->shutting_down = true;
- grpc_pollset_shutdown(exec_ctx, p->pollset,
- GRPC_CLOSURE_INIT(&p->shutdown_closure, done_poller,
- p, grpc_schedule_on_exec_ctx));
+ grpc_pollset_shutdown(
+ p->pollset, GRPC_CLOSURE_INIT(&p->shutdown_closure, done_poller, p,
+ grpc_schedule_on_exec_ctx));
gpr_mu_unlock(p->pollset_mu);
- grpc_timer_cancel(exec_ctx, &p->polling_timer);
+ grpc_timer_cancel(&p->polling_timer);
}
}
-static void run_poller(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void run_poller(void* arg, grpc_error* error) {
backup_poller* p = (backup_poller*)arg;
if (error != GRPC_ERROR_NONE) {
if (error != GRPC_ERROR_CANCELLED) {
GRPC_LOG_IF_ERROR("run_poller", GRPC_ERROR_REF(error));
}
- backup_poller_shutdown_unref(exec_ctx, p);
+ backup_poller_shutdown_unref(p);
return;
}
gpr_mu_lock(p->pollset_mu);
if (p->shutting_down) {
gpr_mu_unlock(p->pollset_mu);
- backup_poller_shutdown_unref(exec_ctx, p);
+ backup_poller_shutdown_unref(p);
return;
}
- grpc_error* err = grpc_pollset_work(exec_ctx, p->pollset, nullptr,
- grpc_exec_ctx_now(exec_ctx));
+ grpc_error* err =
+ grpc_pollset_work(p->pollset, nullptr, grpc_core::ExecCtx::Get()->Now());
gpr_mu_unlock(p->pollset_mu);
GRPC_LOG_IF_ERROR("Run client channel backup poller", err);
- grpc_timer_init(exec_ctx, &p->polling_timer,
- grpc_exec_ctx_now(exec_ctx) + g_poll_interval_ms,
+ grpc_timer_init(&p->polling_timer,
+ grpc_core::ExecCtx::Get()->Now() + g_poll_interval_ms,
&p->run_poller_closure);
}
void grpc_client_channel_start_backup_polling(
- grpc_exec_ctx* exec_ctx, grpc_pollset_set* interested_parties) {
+ grpc_pollset_set* interested_parties) {
gpr_once_init(&g_once, init_globals);
if (g_poll_interval_ms == 0) {
return;
@@ -139,8 +138,8 @@ void grpc_client_channel_start_backup_polling(
gpr_ref_init(&g_poller->shutdown_refs, 2);
GRPC_CLOSURE_INIT(&g_poller->run_poller_closure, run_poller, g_poller,
grpc_schedule_on_exec_ctx);
- grpc_timer_init(exec_ctx, &g_poller->polling_timer,
- grpc_exec_ctx_now(exec_ctx) + g_poll_interval_ms,
+ grpc_timer_init(&g_poller->polling_timer,
+ grpc_core::ExecCtx::Get()->Now() + g_poll_interval_ms,
&g_poller->run_poller_closure);
}
@@ -152,14 +151,14 @@ void grpc_client_channel_start_backup_polling(
grpc_pollset* pollset = g_poller->pollset;
gpr_mu_unlock(&g_poller_mu);
- grpc_pollset_set_add_pollset(exec_ctx, interested_parties, pollset);
+ grpc_pollset_set_add_pollset(interested_parties, pollset);
}
void grpc_client_channel_stop_backup_polling(
- grpc_exec_ctx* exec_ctx, grpc_pollset_set* interested_parties) {
+ grpc_pollset_set* interested_parties) {
if (g_poll_interval_ms == 0) {
return;
}
- grpc_pollset_set_del_pollset(exec_ctx, interested_parties, g_poller->pollset);
- g_poller_unref(exec_ctx);
+ grpc_pollset_set_del_pollset(interested_parties, g_poller->pollset);
+ g_poller_unref();
}
diff --git a/src/core/ext/filters/client_channel/backup_poller.h b/src/core/ext/filters/client_channel/backup_poller.h
index e993d50639..551e0331dc 100644
--- a/src/core/ext/filters/client_channel/backup_poller.h
+++ b/src/core/ext/filters/client_channel/backup_poller.h
@@ -25,10 +25,10 @@
/* Start polling \a interested_parties periodically in the timer thread */
void grpc_client_channel_start_backup_polling(
- grpc_exec_ctx* exec_ctx, grpc_pollset_set* interested_parties);
+ grpc_pollset_set* interested_parties);
/* Stop polling \a interested_parties */
void grpc_client_channel_stop_backup_polling(
- grpc_exec_ctx* exec_ctx, grpc_pollset_set* interested_parties);
+ grpc_pollset_set* interested_parties);
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_BACKUP_POLLER_H */
diff --git a/src/core/ext/filters/client_channel/channel_connectivity.cc b/src/core/ext/filters/client_channel/channel_connectivity.cc
index d3627a237f..f6b8536757 100644
--- a/src/core/ext/filters/client_channel/channel_connectivity.cc
+++ b/src/core/ext/filters/client_channel/channel_connectivity.cc
@@ -33,22 +33,22 @@ grpc_connectivity_state grpc_channel_check_connectivity_state(
/* forward through to the underlying client channel */
grpc_channel_element* client_channel_elem =
grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_connectivity_state state;
GRPC_API_TRACE(
"grpc_channel_check_connectivity_state(channel=%p, try_to_connect=%d)", 2,
(channel, try_to_connect));
if (client_channel_elem->filter == &grpc_client_channel_filter) {
- state = grpc_client_channel_check_connectivity_state(
- &exec_ctx, client_channel_elem, try_to_connect);
- grpc_exec_ctx_finish(&exec_ctx);
+ state = grpc_client_channel_check_connectivity_state(client_channel_elem,
+ try_to_connect);
+
return state;
}
gpr_log(GPR_ERROR,
"grpc_channel_check_connectivity_state called on something that is "
"not a client channel, but '%s'",
client_channel_elem->filter->name);
- grpc_exec_ctx_finish(&exec_ctx);
+
return GRPC_CHANNEL_SHUTDOWN;
}
@@ -73,12 +73,11 @@ typedef struct {
void* tag;
} state_watcher;
-static void delete_state_watcher(grpc_exec_ctx* exec_ctx, state_watcher* w) {
+static void delete_state_watcher(state_watcher* w) {
grpc_channel_element* client_channel_elem = grpc_channel_stack_last_element(
grpc_channel_get_channel_stack(w->channel));
if (client_channel_elem->filter == &grpc_client_channel_filter) {
- GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, w->channel,
- "watch_channel_connectivity");
+ GRPC_CHANNEL_INTERNAL_UNREF(w->channel, "watch_channel_connectivity");
} else {
abort();
}
@@ -86,8 +85,7 @@ static void delete_state_watcher(grpc_exec_ctx* exec_ctx, state_watcher* w) {
gpr_free(w);
}
-static void finished_completion(grpc_exec_ctx* exec_ctx, void* pw,
- grpc_cq_completion* ignored) {
+static void finished_completion(void* pw, grpc_cq_completion* ignored) {
bool should_delete = false;
state_watcher* w = (state_watcher*)pw;
gpr_mu_lock(&w->mu);
@@ -102,19 +100,19 @@ static void finished_completion(grpc_exec_ctx* exec_ctx, void* pw,
gpr_mu_unlock(&w->mu);
if (should_delete) {
- delete_state_watcher(exec_ctx, w);
+ delete_state_watcher(w);
}
}
-static void partly_done(grpc_exec_ctx* exec_ctx, state_watcher* w,
- bool due_to_completion, grpc_error* error) {
+static void partly_done(state_watcher* w, bool due_to_completion,
+ grpc_error* error) {
if (due_to_completion) {
- grpc_timer_cancel(exec_ctx, &w->alarm);
+ grpc_timer_cancel(&w->alarm);
} else {
grpc_channel_element* client_channel_elem = grpc_channel_stack_last_element(
grpc_channel_get_channel_stack(w->channel));
grpc_client_channel_watch_connectivity_state(
- exec_ctx, client_channel_elem,
+ client_channel_elem,
grpc_polling_entity_create_from_pollset(grpc_cq_pollset(w->cq)),
nullptr, &w->on_complete, nullptr);
}
@@ -149,7 +147,7 @@ static void partly_done(grpc_exec_ctx* exec_ctx, state_watcher* w,
w->error = error;
}
w->phase = CALLING_BACK_AND_FINISHED;
- grpc_cq_end_op(exec_ctx, w->cq, w->tag, w->error, finished_completion, w,
+ grpc_cq_end_op(w->cq, w->tag, w->error, finished_completion, w,
&w->completion_storage);
break;
case CALLING_BACK_AND_FINISHED:
@@ -161,14 +159,12 @@ static void partly_done(grpc_exec_ctx* exec_ctx, state_watcher* w,
GRPC_ERROR_UNREF(error);
}
-static void watch_complete(grpc_exec_ctx* exec_ctx, void* pw,
- grpc_error* error) {
- partly_done(exec_ctx, (state_watcher*)pw, true, GRPC_ERROR_REF(error));
+static void watch_complete(void* pw, grpc_error* error) {
+ partly_done((state_watcher*)pw, true, GRPC_ERROR_REF(error));
}
-static void timeout_complete(grpc_exec_ctx* exec_ctx, void* pw,
- grpc_error* error) {
- partly_done(exec_ctx, (state_watcher*)pw, false, GRPC_ERROR_REF(error));
+static void timeout_complete(void* pw, grpc_error* error) {
+ partly_done((state_watcher*)pw, false, GRPC_ERROR_REF(error));
}
int grpc_channel_num_external_connectivity_watchers(grpc_channel* channel) {
@@ -183,12 +179,10 @@ typedef struct watcher_timer_init_arg {
gpr_timespec deadline;
} watcher_timer_init_arg;
-static void watcher_timer_init(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error_ignored) {
+static void watcher_timer_init(void* arg, grpc_error* error_ignored) {
watcher_timer_init_arg* wa = (watcher_timer_init_arg*)arg;
- grpc_timer_init(exec_ctx, &wa->w->alarm,
- grpc_timespec_to_millis_round_up(wa->deadline),
+ grpc_timer_init(&wa->w->alarm, grpc_timespec_to_millis_round_up(wa->deadline),
&wa->w->on_timeout);
gpr_free(wa);
}
@@ -204,7 +198,7 @@ void grpc_channel_watch_connectivity_state(
gpr_timespec deadline, grpc_completion_queue* cq, void* tag) {
grpc_channel_element* client_channel_elem =
grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
state_watcher* w = (state_watcher*)gpr_malloc(sizeof(*w));
GRPC_API_TRACE(
@@ -241,12 +235,10 @@ void grpc_channel_watch_connectivity_state(
if (client_channel_elem->filter == &grpc_client_channel_filter) {
GRPC_CHANNEL_INTERNAL_REF(channel, "watch_channel_connectivity");
grpc_client_channel_watch_connectivity_state(
- &exec_ctx, client_channel_elem,
+ client_channel_elem,
grpc_polling_entity_create_from_pollset(grpc_cq_pollset(cq)), &w->state,
&w->on_complete, &w->watcher_timer_init);
} else {
abort();
}
-
- grpc_exec_ctx_finish(&exec_ctx);
}
diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc
index 8b8d512432..2d5e04abbc 100644
--- a/src/core/ext/filters/client_channel/client_channel.cc
+++ b/src/core/ext/filters/client_channel/client_channel.cc
@@ -92,8 +92,7 @@ static void method_parameters_unref(method_parameters* method_params) {
static void* method_parameters_ref_wrapper(void* value) {
return method_parameters_ref((method_parameters*)value);
}
-static void method_parameters_unref_wrapper(grpc_exec_ctx* exec_ctx,
- void* value) {
+static void method_parameters_unref_wrapper(void* value) {
method_parameters_unref((method_parameters*)value);
}
@@ -221,12 +220,11 @@ typedef struct {
grpc_lb_policy* lb_policy;
} lb_policy_connectivity_watcher;
-static void watch_lb_policy_locked(grpc_exec_ctx* exec_ctx, channel_data* chand,
+static void watch_lb_policy_locked(channel_data* chand,
grpc_lb_policy* lb_policy,
grpc_connectivity_state current_state);
-static void set_channel_connectivity_state_locked(grpc_exec_ctx* exec_ctx,
- channel_data* chand,
+static void set_channel_connectivity_state_locked(channel_data* chand,
grpc_connectivity_state state,
grpc_error* error,
const char* reason) {
@@ -238,12 +236,12 @@ static void set_channel_connectivity_state_locked(grpc_exec_ctx* exec_ctx,
if (state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
/* cancel picks with wait_for_ready=false */
grpc_lb_policy_cancel_picks_locked(
- exec_ctx, chand->lb_policy,
+ chand->lb_policy,
/* mask= */ GRPC_INITIAL_METADATA_WAIT_FOR_READY,
/* check= */ 0, GRPC_ERROR_REF(error));
} else if (state == GRPC_CHANNEL_SHUTDOWN) {
/* cancel all picks */
- grpc_lb_policy_cancel_picks_locked(exec_ctx, chand->lb_policy,
+ grpc_lb_policy_cancel_picks_locked(chand->lb_policy,
/* mask= */ 0, /* check= */ 0,
GRPC_ERROR_REF(error));
}
@@ -252,12 +250,10 @@ static void set_channel_connectivity_state_locked(grpc_exec_ctx* exec_ctx,
gpr_log(GPR_DEBUG, "chand=%p: setting connectivity state to %s", chand,
grpc_connectivity_state_name(state));
}
- grpc_connectivity_state_set(exec_ctx, &chand->state_tracker, state, error,
- reason);
+ grpc_connectivity_state_set(&chand->state_tracker, state, error, reason);
}
-static void on_lb_policy_state_changed_locked(grpc_exec_ctx* exec_ctx,
- void* arg, grpc_error* error) {
+static void on_lb_policy_state_changed_locked(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 */
@@ -269,21 +265,21 @@ static void on_lb_policy_state_changed_locked(grpc_exec_ctx* exec_ctx,
if (publish_state == GRPC_CHANNEL_SHUTDOWN &&
w->chand->resolver != nullptr) {
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");
+ grpc_resolver_channel_saw_error_locked(w->chand->resolver);
+ GRPC_LB_POLICY_UNREF(w->chand->lb_policy, "channel");
w->chand->lb_policy = nullptr;
}
- set_channel_connectivity_state_locked(exec_ctx, w->chand, publish_state,
+ set_channel_connectivity_state_locked(w->chand, publish_state,
GRPC_ERROR_REF(error), "lb_changed");
if (w->state != GRPC_CHANNEL_SHUTDOWN) {
- watch_lb_policy_locked(exec_ctx, w->chand, w->lb_policy, w->state);
+ watch_lb_policy_locked(w->chand, w->lb_policy, w->state);
}
}
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, w->chand->owning_stack, "watch_lb_policy");
+ GRPC_CHANNEL_STACK_UNREF(w->chand->owning_stack, "watch_lb_policy");
gpr_free(w);
}
-static void watch_lb_policy_locked(grpc_exec_ctx* exec_ctx, channel_data* chand,
+static void watch_lb_policy_locked(channel_data* chand,
grpc_lb_policy* lb_policy,
grpc_connectivity_state current_state) {
lb_policy_connectivity_watcher* w =
@@ -294,19 +290,18 @@ static void watch_lb_policy_locked(grpc_exec_ctx* exec_ctx, channel_data* chand,
grpc_combiner_scheduler(chand->combiner));
w->state = current_state;
w->lb_policy = lb_policy;
- grpc_lb_policy_notify_on_state_change_locked(exec_ctx, lb_policy, &w->state,
+ grpc_lb_policy_notify_on_state_change_locked(lb_policy, &w->state,
&w->on_changed);
}
-static void start_resolving_locked(grpc_exec_ctx* exec_ctx,
- channel_data* chand) {
+static void start_resolving_locked(channel_data* chand) {
if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
gpr_log(GPR_DEBUG, "chand=%p: starting name resolution", chand);
}
GPR_ASSERT(!chand->started_resolving);
chand->started_resolving = true;
GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver");
- grpc_resolver_next_locked(exec_ctx, chand->resolver, &chand->resolver_result,
+ grpc_resolver_next_locked(chand->resolver, &chand->resolver_result,
&chand->on_resolver_result_changed);
}
@@ -370,8 +365,7 @@ static void parse_retry_throttle_params(const grpc_json* field, void* arg) {
}
}
-static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
- void* arg, grpc_error* error) {
+static void on_resolver_result_changed_locked(void* arg, grpc_error* error) {
channel_data* chand = (channel_data*)arg;
if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
gpr_log(GPR_DEBUG, "chand=%p: got resolver result: error=%s", chand,
@@ -437,11 +431,10 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
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);
+ grpc_lb_policy_update_locked(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);
+ new_lb_policy = grpc_lb_policy_create(lb_policy_name, &lb_policy_args);
if (new_lb_policy == nullptr) {
gpr_log(GPR_ERROR, "could not create LB policy \"%s\"", lb_policy_name);
}
@@ -459,8 +452,7 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
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);
+ grpc_uri* uri = grpc_uri_parse(channel_arg->value.string, true);
GPR_ASSERT(uri->path[0] != '\0');
service_config_parsing_state parsing_state;
memset(&parsing_state, 0, sizeof(parsing_state));
@@ -471,7 +463,7 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
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,
+ service_config, method_parameters_create_from_json,
method_parameters_ref_wrapper, method_parameters_unref_wrapper);
grpc_service_config_destroy(service_config);
}
@@ -480,7 +472,7 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
// 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);
+ grpc_channel_args_destroy(chand->resolver_result);
chand->resolver_result = nullptr;
}
if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
@@ -512,7 +504,7 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
chand->retry_throttle_data = retry_throttle_data;
// Swap out the method params table.
if (chand->method_params_table != nullptr) {
- grpc_slice_hash_table_unref(exec_ctx, chand->method_params_table);
+ grpc_slice_hash_table_unref(chand->method_params_table);
}
chand->method_params_table = method_params_table;
// If we have a new LB policy or are shutting down (in which case
@@ -528,10 +520,9 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
gpr_log(GPR_DEBUG, "chand=%p: unreffing lb_policy=%p", chand,
chand->lb_policy);
}
- grpc_pollset_set_del_pollset_set(exec_ctx,
- chand->lb_policy->interested_parties,
+ grpc_pollset_set_del_pollset_set(chand->lb_policy->interested_parties,
chand->interested_parties);
- GRPC_LB_POLICY_UNREF(exec_ctx, chand->lb_policy, "channel");
+ GRPC_LB_POLICY_UNREF(chand->lb_policy, "channel");
}
chand->lb_policy = new_lb_policy;
}
@@ -545,21 +536,20 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
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");
+ grpc_resolver_shutdown_locked(chand->resolver);
+ GRPC_RESOLVER_UNREF(chand->resolver, "channel");
chand->resolver = nullptr;
}
set_channel_connectivity_state_locked(
- exec_ctx, chand, GRPC_CHANNEL_SHUTDOWN,
+ chand, GRPC_CHANNEL_SHUTDOWN,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Got resolver result after disconnection", &error, 1),
"resolver_gone");
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->owning_stack, "resolver");
+ GRPC_CHANNEL_STACK_UNREF(chand->owning_stack, "resolver");
grpc_closure_list_fail_all(&chand->waiting_for_resolver_result_closures,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Channel disconnected", &error, 1));
- GRPC_CLOSURE_LIST_SCHED(exec_ctx,
- &chand->waiting_for_resolver_result_closures);
+ GRPC_CLOSURE_LIST_SCHED(&chand->waiting_for_resolver_result_closures);
} else { // Not shutting down.
grpc_connectivity_state state = GRPC_CHANNEL_TRANSIENT_FAILURE;
grpc_error* state_error =
@@ -569,33 +559,28 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
gpr_log(GPR_DEBUG, "chand=%p: initializing new LB policy", chand);
}
GRPC_ERROR_UNREF(state_error);
- state = grpc_lb_policy_check_connectivity_locked(exec_ctx, new_lb_policy,
- &state_error);
- grpc_pollset_set_add_pollset_set(exec_ctx,
- new_lb_policy->interested_parties,
+ state =
+ grpc_lb_policy_check_connectivity_locked(new_lb_policy, &state_error);
+ grpc_pollset_set_add_pollset_set(new_lb_policy->interested_parties,
chand->interested_parties);
- GRPC_CLOSURE_LIST_SCHED(exec_ctx,
- &chand->waiting_for_resolver_result_closures);
+ GRPC_CLOSURE_LIST_SCHED(&chand->waiting_for_resolver_result_closures);
if (chand->exit_idle_when_lb_policy_arrives) {
- grpc_lb_policy_exit_idle_locked(exec_ctx, new_lb_policy);
+ grpc_lb_policy_exit_idle_locked(new_lb_policy);
chand->exit_idle_when_lb_policy_arrives = false;
}
- watch_lb_policy_locked(exec_ctx, chand, new_lb_policy, state);
+ watch_lb_policy_locked(chand, new_lb_policy, state);
}
if (!lb_policy_updated) {
- set_channel_connectivity_state_locked(exec_ctx, chand, state,
- GRPC_ERROR_REF(state_error),
- "new_lb+resolver");
+ set_channel_connectivity_state_locked(
+ chand, state, GRPC_ERROR_REF(state_error), "new_lb+resolver");
}
- grpc_resolver_next_locked(exec_ctx, chand->resolver,
- &chand->resolver_result,
+ grpc_resolver_next_locked(chand->resolver, &chand->resolver_result,
&chand->on_resolver_result_changed);
GRPC_ERROR_UNREF(state_error);
}
}
-static void start_transport_op_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error_ignored) {
+static void start_transport_op_locked(void* arg, grpc_error* error_ignored) {
grpc_transport_op* op = (grpc_transport_op*)arg;
grpc_channel_element* elem =
(grpc_channel_element*)op->handler_private.extra_arg;
@@ -603,7 +588,7 @@ static void start_transport_op_locked(grpc_exec_ctx* exec_ctx, void* arg,
if (op->on_connectivity_state_change != nullptr) {
grpc_connectivity_state_notify_on_state_change(
- exec_ctx, &chand->state_tracker, op->connectivity_state,
+ &chand->state_tracker, op->connectivity_state,
op->on_connectivity_state_change);
op->on_connectivity_state_change = nullptr;
op->connectivity_state = nullptr;
@@ -611,11 +596,10 @@ static void start_transport_op_locked(grpc_exec_ctx* exec_ctx, void* arg,
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"));
+ GRPC_CLOSURE_SCHED(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);
+ grpc_lb_policy_ping_one_locked(chand->lb_policy, op->send_ping);
op->bind_pollset = nullptr;
}
op->send_ping = nullptr;
@@ -624,54 +608,48 @@ static void start_transport_op_locked(grpc_exec_ctx* exec_ctx, void* arg,
if (op->disconnect_with_error != GRPC_ERROR_NONE) {
if (chand->resolver != nullptr) {
set_channel_connectivity_state_locked(
- exec_ctx, chand, GRPC_CHANNEL_SHUTDOWN,
+ chand, GRPC_CHANNEL_SHUTDOWN,
GRPC_ERROR_REF(op->disconnect_with_error), "disconnect");
- grpc_resolver_shutdown_locked(exec_ctx, chand->resolver);
- GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel");
+ grpc_resolver_shutdown_locked(chand->resolver);
+ GRPC_RESOLVER_UNREF(chand->resolver, "channel");
chand->resolver = nullptr;
if (!chand->started_resolving) {
grpc_closure_list_fail_all(&chand->waiting_for_resolver_result_closures,
GRPC_ERROR_REF(op->disconnect_with_error));
- GRPC_CLOSURE_LIST_SCHED(exec_ctx,
- &chand->waiting_for_resolver_result_closures);
+ GRPC_CLOSURE_LIST_SCHED(&chand->waiting_for_resolver_result_closures);
}
if (chand->lb_policy != nullptr) {
- grpc_pollset_set_del_pollset_set(exec_ctx,
- chand->lb_policy->interested_parties,
+ grpc_pollset_set_del_pollset_set(chand->lb_policy->interested_parties,
chand->interested_parties);
- GRPC_LB_POLICY_UNREF(exec_ctx, chand->lb_policy, "channel");
+ GRPC_LB_POLICY_UNREF(chand->lb_policy, "channel");
chand->lb_policy = nullptr;
}
}
GRPC_ERROR_UNREF(op->disconnect_with_error);
}
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->owning_stack, "start_transport_op");
+ GRPC_CHANNEL_STACK_UNREF(chand->owning_stack, "start_transport_op");
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(op->on_consumed, GRPC_ERROR_NONE);
}
-static void cc_start_transport_op(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static void cc_start_transport_op(grpc_channel_element* elem,
grpc_transport_op* op) {
channel_data* chand = (channel_data*)elem->channel_data;
GPR_ASSERT(op->set_accept_stream == false);
if (op->bind_pollset != nullptr) {
- grpc_pollset_set_add_pollset(exec_ctx, chand->interested_parties,
- op->bind_pollset);
+ grpc_pollset_set_add_pollset(chand->interested_parties, op->bind_pollset);
}
op->handler_private.extra_arg = elem;
GRPC_CHANNEL_STACK_REF(chand->owning_stack, "start_transport_op");
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_INIT(&op->handler_private.closure, start_transport_op_locked,
op, grpc_combiner_scheduler(chand->combiner)),
GRPC_ERROR_NONE);
}
-static void cc_get_channel_info(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static void cc_get_channel_info(grpc_channel_element* elem,
const grpc_channel_info* info) {
channel_data* chand = (channel_data*)elem->channel_data;
gpr_mu_lock(&chand->info_mu);
@@ -690,8 +668,7 @@ static void cc_get_channel_info(grpc_exec_ctx* exec_ctx,
}
/* Constructor for channel_data */
-static grpc_error* cc_init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* cc_init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
channel_data* chand = (channel_data*)elem->channel_data;
GPR_ASSERT(args->is_last);
@@ -712,7 +689,7 @@ static grpc_error* cc_init_channel_elem(grpc_exec_ctx* exec_ctx,
chand->interested_parties = grpc_pollset_set_create();
grpc_connectivity_state_init(&chand->state_tracker, GRPC_CHANNEL_IDLE,
"client_channel");
- grpc_client_channel_start_backup_polling(exec_ctx, chand->interested_parties);
+ grpc_client_channel_start_backup_polling(chand->interested_parties);
// Record client channel factory.
const grpc_arg* arg = grpc_channel_args_find(args->channel_args,
GRPC_ARG_CLIENT_CHANNEL_FACTORY);
@@ -740,15 +717,15 @@ static grpc_error* cc_init_channel_elem(grpc_exec_ctx* exec_ctx,
}
char* proxy_name = nullptr;
grpc_channel_args* new_args = nullptr;
- grpc_proxy_mappers_map_name(exec_ctx, arg->value.string, args->channel_args,
+ grpc_proxy_mappers_map_name(arg->value.string, args->channel_args,
&proxy_name, &new_args);
// Instantiate resolver.
chand->resolver = grpc_resolver_create(
- exec_ctx, proxy_name != nullptr ? proxy_name : arg->value.string,
+ proxy_name != nullptr ? proxy_name : arg->value.string,
new_args != nullptr ? new_args : args->channel_args,
chand->interested_parties, chand->combiner);
if (proxy_name != nullptr) gpr_free(proxy_name);
- if (new_args != nullptr) grpc_channel_args_destroy(exec_ctx, new_args);
+ if (new_args != nullptr) grpc_channel_args_destroy(new_args);
if (chand->resolver == nullptr) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("resolver creation failed");
}
@@ -757,32 +734,28 @@ static grpc_error* cc_init_channel_elem(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-static void shutdown_resolver_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void shutdown_resolver_locked(void* arg, grpc_error* error) {
grpc_resolver* resolver = (grpc_resolver*)arg;
- grpc_resolver_shutdown_locked(exec_ctx, resolver);
- GRPC_RESOLVER_UNREF(exec_ctx, resolver, "channel");
+ grpc_resolver_shutdown_locked(resolver);
+ GRPC_RESOLVER_UNREF(resolver, "channel");
}
/* Destructor for channel_data */
-static void cc_destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {
+static void cc_destroy_channel_elem(grpc_channel_element* elem) {
channel_data* chand = (channel_data*)elem->channel_data;
if (chand->resolver != nullptr) {
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_CREATE(shutdown_resolver_locked, chand->resolver,
grpc_combiner_scheduler(chand->combiner)),
GRPC_ERROR_NONE);
}
if (chand->client_channel_factory != nullptr) {
- grpc_client_channel_factory_unref(exec_ctx, chand->client_channel_factory);
+ grpc_client_channel_factory_unref(chand->client_channel_factory);
}
if (chand->lb_policy != nullptr) {
- grpc_pollset_set_del_pollset_set(exec_ctx,
- chand->lb_policy->interested_parties,
+ grpc_pollset_set_del_pollset_set(chand->lb_policy->interested_parties,
chand->interested_parties);
- GRPC_LB_POLICY_UNREF(exec_ctx, chand->lb_policy, "channel");
+ GRPC_LB_POLICY_UNREF(chand->lb_policy, "channel");
}
gpr_free(chand->info_lb_policy_name);
gpr_free(chand->info_service_config_json);
@@ -790,12 +763,12 @@ static void cc_destroy_channel_elem(grpc_exec_ctx* exec_ctx,
grpc_server_retry_throttle_data_unref(chand->retry_throttle_data);
}
if (chand->method_params_table != nullptr) {
- grpc_slice_hash_table_unref(exec_ctx, chand->method_params_table);
+ grpc_slice_hash_table_unref(chand->method_params_table);
}
- grpc_client_channel_stop_backup_polling(exec_ctx, chand->interested_parties);
- grpc_connectivity_state_destroy(exec_ctx, &chand->state_tracker);
- grpc_pollset_set_destroy(exec_ctx, chand->interested_parties);
- GRPC_COMBINER_UNREF(exec_ctx, chand->combiner, "client_channel");
+ grpc_client_channel_stop_backup_polling(chand->interested_parties);
+ grpc_connectivity_state_destroy(&chand->state_tracker);
+ grpc_pollset_set_destroy(chand->interested_parties);
+ GRPC_COMBINER_UNREF(chand->combiner, "client_channel");
gpr_mu_destroy(&chand->info_mu);
gpr_mu_destroy(&chand->external_connectivity_watcher_list_mu);
}
@@ -882,21 +855,18 @@ static void waiting_for_pick_batches_add(
}
// This is called via the call combiner, so access to calld is synchronized.
-static void fail_pending_batch_in_call_combiner(grpc_exec_ctx* exec_ctx,
- void* arg, grpc_error* error) {
+static void fail_pending_batch_in_call_combiner(void* arg, grpc_error* error) {
call_data* calld = (call_data*)arg;
if (calld->waiting_for_pick_batches_count > 0) {
--calld->waiting_for_pick_batches_count;
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx,
calld->waiting_for_pick_batches[calld->waiting_for_pick_batches_count],
GRPC_ERROR_REF(error), calld->call_combiner);
}
}
// This is called via the call combiner, so access to calld is synchronized.
-static void waiting_for_pick_batches_fail(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void waiting_for_pick_batches_fail(grpc_call_element* elem,
grpc_error* error) {
call_data* calld = (call_data*)elem->call_data;
if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
@@ -909,37 +879,34 @@ static void waiting_for_pick_batches_fail(grpc_exec_ctx* exec_ctx,
GRPC_CLOSURE_INIT(&calld->handle_pending_batch_in_call_combiner[i],
fail_pending_batch_in_call_combiner, calld,
grpc_schedule_on_exec_ctx);
- GRPC_CALL_COMBINER_START(exec_ctx, calld->call_combiner,
- &calld->handle_pending_batch_in_call_combiner[i],
- GRPC_ERROR_REF(error),
- "waiting_for_pick_batches_fail");
+ GRPC_CALL_COMBINER_START(
+ calld->call_combiner, &calld->handle_pending_batch_in_call_combiner[i],
+ GRPC_ERROR_REF(error), "waiting_for_pick_batches_fail");
}
if (calld->initial_metadata_batch != nullptr) {
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, calld->initial_metadata_batch, GRPC_ERROR_REF(error),
+ calld->initial_metadata_batch, GRPC_ERROR_REF(error),
calld->call_combiner);
} else {
- GRPC_CALL_COMBINER_STOP(exec_ctx, calld->call_combiner,
+ GRPC_CALL_COMBINER_STOP(calld->call_combiner,
"waiting_for_pick_batches_fail");
}
GRPC_ERROR_UNREF(error);
}
// This is called via the call combiner, so access to calld is synchronized.
-static void run_pending_batch_in_call_combiner(grpc_exec_ctx* exec_ctx,
- void* arg, grpc_error* ignored) {
+static void run_pending_batch_in_call_combiner(void* arg, grpc_error* ignored) {
call_data* calld = (call_data*)arg;
if (calld->waiting_for_pick_batches_count > 0) {
--calld->waiting_for_pick_batches_count;
grpc_subchannel_call_process_op(
- exec_ctx, calld->subchannel_call,
+ calld->subchannel_call,
calld->waiting_for_pick_batches[calld->waiting_for_pick_batches_count]);
}
}
// This is called via the call combiner, so access to calld is synchronized.
-static void waiting_for_pick_batches_resume(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem) {
+static void waiting_for_pick_batches_resume(grpc_call_element* elem) {
channel_data* chand = (channel_data*)elem->channel_data;
call_data* calld = (call_data*)elem->call_data;
if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
@@ -953,20 +920,18 @@ static void waiting_for_pick_batches_resume(grpc_exec_ctx* exec_ctx,
GRPC_CLOSURE_INIT(&calld->handle_pending_batch_in_call_combiner[i],
run_pending_batch_in_call_combiner, calld,
grpc_schedule_on_exec_ctx);
- GRPC_CALL_COMBINER_START(exec_ctx, calld->call_combiner,
- &calld->handle_pending_batch_in_call_combiner[i],
- GRPC_ERROR_NONE,
- "waiting_for_pick_batches_resume");
+ GRPC_CALL_COMBINER_START(
+ calld->call_combiner, &calld->handle_pending_batch_in_call_combiner[i],
+ GRPC_ERROR_NONE, "waiting_for_pick_batches_resume");
}
GPR_ASSERT(calld->initial_metadata_batch != nullptr);
- grpc_subchannel_call_process_op(exec_ctx, calld->subchannel_call,
+ grpc_subchannel_call_process_op(calld->subchannel_call,
calld->initial_metadata_batch);
}
// Applies service config to the call. Must be invoked once we know
// that the resolver has returned results to the channel.
-static void apply_service_config_to_call_locked(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem) {
+static void apply_service_config_to_call_locked(grpc_call_element* elem) {
channel_data* chand = (channel_data*)elem->channel_data;
call_data* calld = (call_data*)elem->call_data;
if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
@@ -979,7 +944,7 @@ static void apply_service_config_to_call_locked(grpc_exec_ctx* exec_ctx,
}
if (chand->method_params_table != nullptr) {
calld->method_params = (method_parameters*)grpc_method_config_table_get(
- exec_ctx, chand->method_params_table, calld->path);
+ chand->method_params_table, calld->path);
if (calld->method_params != nullptr) {
method_parameters_ref(calld->method_params);
// If the deadline from the service config is shorter than the one
@@ -991,15 +956,14 @@ static void apply_service_config_to_call_locked(grpc_exec_ctx* exec_ctx,
calld->method_params->timeout;
if (per_method_deadline < calld->deadline) {
calld->deadline = per_method_deadline;
- grpc_deadline_state_reset(exec_ctx, elem, calld->deadline);
+ grpc_deadline_state_reset(elem, calld->deadline);
}
}
}
}
}
-static void create_subchannel_call_locked(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void create_subchannel_call_locked(grpc_call_element* elem,
grpc_error* error) {
channel_data* chand = (channel_data*)elem->channel_data;
call_data* calld = (call_data*)elem->call_data;
@@ -1013,24 +977,22 @@ static void create_subchannel_call_locked(grpc_exec_ctx* exec_ctx,
calld->call_combiner // call_combiner
};
grpc_error* new_error = grpc_connected_subchannel_create_call(
- exec_ctx, calld->connected_subchannel, &call_args,
- &calld->subchannel_call);
+ calld->connected_subchannel, &call_args, &calld->subchannel_call);
if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
gpr_log(GPR_DEBUG, "chand=%p calld=%p: create subchannel_call=%p: error=%s",
chand, calld, calld->subchannel_call, grpc_error_string(new_error));
}
if (new_error != GRPC_ERROR_NONE) {
new_error = grpc_error_add_child(new_error, error);
- waiting_for_pick_batches_fail(exec_ctx, elem, new_error);
+ waiting_for_pick_batches_fail(elem, new_error);
} else {
- waiting_for_pick_batches_resume(exec_ctx, elem);
+ waiting_for_pick_batches_resume(elem);
}
GRPC_ERROR_UNREF(error);
}
// Invoked when a pick is completed, on both success or failure.
-static void pick_done_locked(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_error* error) {
+static void pick_done_locked(grpc_call_element* elem, grpc_error* error) {
call_data* calld = (call_data*)elem->call_data;
channel_data* chand = (channel_data*)elem->channel_data;
if (calld->connected_subchannel == nullptr) {
@@ -1046,10 +1008,10 @@ static void pick_done_locked(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
"chand=%p calld=%p: failed to create subchannel: error=%s", chand,
calld, grpc_error_string(calld->error));
}
- waiting_for_pick_batches_fail(exec_ctx, elem, GRPC_ERROR_REF(calld->error));
+ waiting_for_pick_batches_fail(elem, GRPC_ERROR_REF(calld->error));
} else {
/* Create call on subchannel. */
- create_subchannel_call_locked(exec_ctx, elem, GRPC_ERROR_REF(error));
+ create_subchannel_call_locked(elem, GRPC_ERROR_REF(error));
}
GRPC_ERROR_UNREF(error);
}
@@ -1058,19 +1020,17 @@ static void pick_done_locked(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
// either (a) the pick was deferred pending a resolver result or (b) the
// pick was done asynchronously. Removes the call's polling entity from
// chand->interested_parties before invoking pick_done_locked().
-static void async_pick_done_locked(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem, grpc_error* error) {
+static void async_pick_done_locked(grpc_call_element* elem, grpc_error* error) {
channel_data* chand = (channel_data*)elem->channel_data;
call_data* calld = (call_data*)elem->call_data;
- grpc_polling_entity_del_from_pollset_set(exec_ctx, calld->pollent,
+ grpc_polling_entity_del_from_pollset_set(calld->pollent,
chand->interested_parties);
- pick_done_locked(exec_ctx, elem, error);
+ pick_done_locked(elem, error);
}
// Note: This runs under the client_channel combiner, but will NOT be
// holding the call combiner.
-static void pick_callback_cancel_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void pick_callback_cancel_locked(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
channel_data* chand = (channel_data*)elem->channel_data;
call_data* calld = (call_data*)elem->call_data;
@@ -1079,17 +1039,15 @@ static void pick_callback_cancel_locked(grpc_exec_ctx* exec_ctx, void* arg,
gpr_log(GPR_DEBUG, "chand=%p calld=%p: cancelling pick from LB policy %p",
chand, calld, calld->lb_policy);
}
- grpc_lb_policy_cancel_pick_locked(exec_ctx, calld->lb_policy,
- &calld->connected_subchannel,
- GRPC_ERROR_REF(error));
+ grpc_lb_policy_cancel_pick_locked(
+ calld->lb_policy, &calld->connected_subchannel, GRPC_ERROR_REF(error));
}
- GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "pick_callback_cancel");
+ GRPC_CALL_STACK_UNREF(calld->owning_call, "pick_callback_cancel");
}
// Callback invoked by grpc_lb_policy_pick_locked() for async picks.
// Unrefs the LB policy and invokes async_pick_done_locked().
-static void pick_callback_done_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void pick_callback_done_locked(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
channel_data* chand = (channel_data*)elem->channel_data;
call_data* calld = (call_data*)elem->call_data;
@@ -1098,23 +1056,22 @@ static void pick_callback_done_locked(grpc_exec_ctx* exec_ctx, void* arg,
chand, calld);
}
GPR_ASSERT(calld->lb_policy != nullptr);
- GRPC_LB_POLICY_UNREF(exec_ctx, calld->lb_policy, "pick_subchannel");
+ GRPC_LB_POLICY_UNREF(calld->lb_policy, "pick_subchannel");
calld->lb_policy = nullptr;
- async_pick_done_locked(exec_ctx, elem, GRPC_ERROR_REF(error));
+ async_pick_done_locked(elem, GRPC_ERROR_REF(error));
}
// Takes a ref to chand->lb_policy and calls grpc_lb_policy_pick_locked().
// If the pick was completed synchronously, unrefs the LB policy and
// returns true.
-static bool pick_callback_start_locked(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem) {
+static bool pick_callback_start_locked(grpc_call_element* elem) {
channel_data* chand = (channel_data*)elem->channel_data;
call_data* calld = (call_data*)elem->call_data;
if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
gpr_log(GPR_DEBUG, "chand=%p calld=%p: starting pick on lb_policy=%p",
chand, calld, chand->lb_policy);
}
- apply_service_config_to_call_locked(exec_ctx, elem);
+ apply_service_config_to_call_locked(elem);
// If the application explicitly set wait_for_ready, use that.
// Otherwise, if the service config specified a value for this
// method, use that.
@@ -1144,7 +1101,7 @@ static bool pick_callback_start_locked(grpc_exec_ctx* exec_ctx,
GRPC_CLOSURE_INIT(&calld->lb_pick_closure, pick_callback_done_locked, elem,
grpc_combiner_scheduler(chand->combiner));
const bool pick_done = grpc_lb_policy_pick_locked(
- exec_ctx, chand->lb_policy, &inputs, &calld->connected_subchannel,
+ chand->lb_policy, &inputs, &calld->connected_subchannel,
calld->subchannel_call_context, nullptr, &calld->lb_pick_closure);
if (pick_done) {
/* synchronous grpc_lb_policy_pick call. Unref the LB policy. */
@@ -1152,12 +1109,12 @@ static bool pick_callback_start_locked(grpc_exec_ctx* exec_ctx,
gpr_log(GPR_DEBUG, "chand=%p calld=%p: pick completed synchronously",
chand, calld);
}
- GRPC_LB_POLICY_UNREF(exec_ctx, calld->lb_policy, "pick_subchannel");
+ GRPC_LB_POLICY_UNREF(calld->lb_policy, "pick_subchannel");
calld->lb_policy = nullptr;
} else {
GRPC_CALL_STACK_REF(calld->owning_call, "pick_callback_cancel");
grpc_call_combiner_set_notify_on_cancel(
- exec_ctx, calld->call_combiner,
+ calld->call_combiner,
GRPC_CLOSURE_INIT(&calld->lb_pick_cancel_closure,
pick_callback_cancel_locked, elem,
grpc_combiner_scheduler(chand->combiner)));
@@ -1174,8 +1131,7 @@ typedef struct {
// Note: This runs under the client_channel combiner, but will NOT be
// holding the call combiner.
-static void pick_after_resolver_result_cancel_locked(grpc_exec_ctx* exec_ctx,
- void* arg,
+static void pick_after_resolver_result_cancel_locked(void* arg,
grpc_error* error) {
pick_after_resolver_result_args* args = (pick_after_resolver_result_args*)arg;
if (args->finished) {
@@ -1203,16 +1159,13 @@ static void pick_after_resolver_result_cancel_locked(grpc_exec_ctx* exec_ctx,
// it's safe to call async_pick_done_locked() here -- we are
// essentially calling it here instead of calling it in
// pick_after_resolver_result_done_locked().
- async_pick_done_locked(exec_ctx, elem,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Pick cancelled", &error, 1));
+ async_pick_done_locked(elem, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Pick cancelled", &error, 1));
}
-static void pick_after_resolver_result_start_locked(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem);
+static void pick_after_resolver_result_start_locked(grpc_call_element* elem);
-static void pick_after_resolver_result_done_locked(grpc_exec_ctx* exec_ctx,
- void* arg,
+static void pick_after_resolver_result_done_locked(void* arg,
grpc_error* error) {
pick_after_resolver_result_args* args = (pick_after_resolver_result_args*)arg;
if (args->finished) {
@@ -1232,19 +1185,19 @@ static void pick_after_resolver_result_done_locked(grpc_exec_ctx* exec_ctx,
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));
+ async_pick_done_locked(elem, GRPC_ERROR_REF(error));
} else if (chand->lb_policy != nullptr) {
if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
gpr_log(GPR_DEBUG, "chand=%p calld=%p: resolver returned, doing pick",
chand, calld);
}
- if (pick_callback_start_locked(exec_ctx, elem)) {
+ if (pick_callback_start_locked(elem)) {
// Even if the LB policy returns a result synchronously, we have
// already added our polling entity to chand->interested_parties
// in order to wait for the resolver result, so we need to
// remove it here. Therefore, we call async_pick_done_locked()
// instead of pick_done_locked().
- async_pick_done_locked(exec_ctx, elem, GRPC_ERROR_NONE);
+ async_pick_done_locked(elem, GRPC_ERROR_NONE);
}
}
// TODO(roth): It should be impossible for chand->lb_policy to be NULL
@@ -1262,19 +1215,18 @@ static void pick_after_resolver_result_done_locked(grpc_exec_ctx* exec_ctx,
"trying again",
chand, calld);
}
- pick_after_resolver_result_start_locked(exec_ctx, elem);
+ pick_after_resolver_result_start_locked(elem);
} else {
if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
gpr_log(GPR_DEBUG, "chand=%p calld=%p: resolver disconnected", chand,
calld);
}
async_pick_done_locked(
- exec_ctx, elem, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Disconnected"));
+ elem, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Disconnected"));
}
}
-static void pick_after_resolver_result_start_locked(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem) {
+static void pick_after_resolver_result_start_locked(grpc_call_element* elem) {
channel_data* chand = (channel_data*)elem->channel_data;
call_data* calld = (call_data*)elem->call_data;
if (GRPC_TRACER_ON(grpc_client_channel_trace)) {
@@ -1290,47 +1242,46 @@ static void pick_after_resolver_result_start_locked(grpc_exec_ctx* exec_ctx,
grpc_closure_list_append(&chand->waiting_for_resolver_result_closures,
&args->closure, GRPC_ERROR_NONE);
grpc_call_combiner_set_notify_on_cancel(
- exec_ctx, calld->call_combiner,
+ calld->call_combiner,
GRPC_CLOSURE_INIT(&args->cancel_closure,
pick_after_resolver_result_cancel_locked, args,
grpc_combiner_scheduler(chand->combiner)));
}
-static void start_pick_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* ignored) {
+static void start_pick_locked(void* arg, grpc_error* ignored) {
grpc_call_element* elem = (grpc_call_element*)arg;
call_data* calld = (call_data*)elem->call_data;
channel_data* chand = (channel_data*)elem->channel_data;
GPR_ASSERT(calld->connected_subchannel == nullptr);
if (chand->lb_policy != nullptr) {
// We already have an LB policy, so ask it for a pick.
- if (pick_callback_start_locked(exec_ctx, elem)) {
+ if (pick_callback_start_locked(elem)) {
// Pick completed synchronously.
- pick_done_locked(exec_ctx, elem, GRPC_ERROR_NONE);
+ pick_done_locked(elem, GRPC_ERROR_NONE);
return;
}
} else {
// We do not yet have an LB policy, so wait for a resolver result.
if (chand->resolver == nullptr) {
- pick_done_locked(exec_ctx, elem,
+ pick_done_locked(elem,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Disconnected"));
return;
}
if (!chand->started_resolving) {
- start_resolving_locked(exec_ctx, chand);
+ start_resolving_locked(chand);
}
- pick_after_resolver_result_start_locked(exec_ctx, elem);
+ pick_after_resolver_result_start_locked(elem);
}
// We need to wait for either a resolver result or for an async result
// from the LB policy. Add the polling entity from call_data to the
// channel_data's interested_parties, so that the I/O of the LB policy
// and resolver can be done under it. The polling entity will be
// removed in async_pick_done_locked().
- grpc_polling_entity_add_to_pollset_set(exec_ctx, calld->pollent,
+ grpc_polling_entity_add_to_pollset_set(calld->pollent,
chand->interested_parties);
}
-static void on_complete(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void on_complete(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
call_data* calld = (call_data*)elem->call_data;
if (calld->retry_throttle_data != nullptr) {
@@ -1346,18 +1297,15 @@ static void on_complete(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
calld->retry_throttle_data);
}
}
- GRPC_CLOSURE_RUN(exec_ctx, calld->original_on_complete,
- GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_RUN(calld->original_on_complete, GRPC_ERROR_REF(error));
}
static void cc_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* batch) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
call_data* calld = (call_data*)elem->call_data;
channel_data* chand = (channel_data*)elem->channel_data;
if (chand->deadline_checking_enabled) {
- grpc_deadline_state_client_start_transport_stream_op_batch(exec_ctx, elem,
- batch);
+ grpc_deadline_state_client_start_transport_stream_op_batch(elem, batch);
}
GPR_TIMER_BEGIN("cc_start_transport_stream_op_batch", 0);
// If we've previously been cancelled, immediately fail any new batches.
@@ -1367,7 +1315,7 @@ static void cc_start_transport_stream_op_batch(
chand, calld, grpc_error_string(calld->error));
}
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, batch, GRPC_ERROR_REF(calld->error), calld->call_combiner);
+ batch, GRPC_ERROR_REF(calld->error), calld->call_combiner);
goto done;
}
if (batch->cancel_stream) {
@@ -1385,11 +1333,10 @@ static void cc_start_transport_stream_op_batch(
// If we have a subchannel call, send the cancellation batch down.
// Otherwise, fail all pending batches.
if (calld->subchannel_call != nullptr) {
- grpc_subchannel_call_process_op(exec_ctx, calld->subchannel_call, batch);
+ grpc_subchannel_call_process_op(calld->subchannel_call, batch);
} else {
waiting_for_pick_batches_add(calld, batch);
- waiting_for_pick_batches_fail(exec_ctx, elem,
- GRPC_ERROR_REF(calld->error));
+ waiting_for_pick_batches_fail(elem, GRPC_ERROR_REF(calld->error));
}
goto done;
}
@@ -1412,7 +1359,7 @@ static void cc_start_transport_stream_op_batch(
"chand=%p calld=%p: sending batch to subchannel_call=%p", chand,
calld, calld->subchannel_call);
}
- grpc_subchannel_call_process_op(exec_ctx, calld->subchannel_call, batch);
+ grpc_subchannel_call_process_op(calld->subchannel_call, batch);
goto done;
}
// We do not yet have a subchannel call.
@@ -1426,7 +1373,6 @@ static void cc_start_transport_stream_op_batch(
chand, calld);
}
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_INIT(&batch->handler_private.closure, start_pick_locked,
elem, grpc_combiner_scheduler(chand->combiner)),
GRPC_ERROR_NONE);
@@ -1437,7 +1383,7 @@ static void cc_start_transport_stream_op_batch(
"chand=%p calld=%p: saved batch, yeilding call combiner", chand,
calld);
}
- GRPC_CALL_COMBINER_STOP(exec_ctx, calld->call_combiner,
+ GRPC_CALL_COMBINER_STOP(calld->call_combiner,
"batch does not include send_initial_metadata");
}
done:
@@ -1445,8 +1391,7 @@ done:
}
/* Constructor for call_data */
-static grpc_error* cc_init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* cc_init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
call_data* calld = (call_data*)elem->call_data;
channel_data* chand = (channel_data*)elem->channel_data;
@@ -1458,23 +1403,22 @@ static grpc_error* cc_init_call_elem(grpc_exec_ctx* exec_ctx,
calld->owning_call = args->call_stack;
calld->call_combiner = args->call_combiner;
if (chand->deadline_checking_enabled) {
- grpc_deadline_state_init(exec_ctx, elem, args->call_stack,
- args->call_combiner, calld->deadline);
+ grpc_deadline_state_init(elem, args->call_stack, args->call_combiner,
+ calld->deadline);
}
return GRPC_ERROR_NONE;
}
/* Destructor for call_data */
-static void cc_destroy_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void cc_destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* then_schedule_closure) {
call_data* calld = (call_data*)elem->call_data;
channel_data* chand = (channel_data*)elem->channel_data;
if (chand->deadline_checking_enabled) {
- grpc_deadline_state_destroy(exec_ctx, elem);
+ grpc_deadline_state_destroy(elem);
}
- grpc_slice_unref_internal(exec_ctx, calld->path);
+ grpc_slice_unref_internal(calld->path);
if (calld->method_params != nullptr) {
method_parameters_unref(calld->method_params);
}
@@ -1483,14 +1427,13 @@ static void cc_destroy_call_elem(grpc_exec_ctx* exec_ctx,
grpc_subchannel_call_set_cleanup_closure(calld->subchannel_call,
then_schedule_closure);
then_schedule_closure = nullptr;
- GRPC_SUBCHANNEL_CALL_UNREF(exec_ctx, calld->subchannel_call,
+ GRPC_SUBCHANNEL_CALL_UNREF(calld->subchannel_call,
"client_channel_destroy_call");
}
GPR_ASSERT(calld->lb_policy == nullptr);
GPR_ASSERT(calld->waiting_for_pick_batches_count == 0);
if (calld->connected_subchannel != nullptr) {
- GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, calld->connected_subchannel,
- "picked");
+ GRPC_CONNECTED_SUBCHANNEL_UNREF(calld->connected_subchannel, "picked");
}
for (size_t i = 0; i < GRPC_CONTEXT_COUNT; ++i) {
if (calld->subchannel_call_context[i].value != nullptr) {
@@ -1498,11 +1441,10 @@ static void cc_destroy_call_elem(grpc_exec_ctx* exec_ctx,
calld->subchannel_call_context[i].value);
}
}
- GRPC_CLOSURE_SCHED(exec_ctx, then_schedule_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(then_schedule_closure, GRPC_ERROR_NONE);
}
-static void cc_set_pollset_or_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void cc_set_pollset_or_pollset_set(grpc_call_element* elem,
grpc_polling_entity* pollent) {
call_data* calld = (call_data*)elem->call_data;
calld->pollent = pollent;
@@ -1526,29 +1468,27 @@ const grpc_channel_filter grpc_client_channel_filter = {
"client-channel",
};
-static void try_to_connect_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error_ignored) {
+static void try_to_connect_locked(void* arg, grpc_error* error_ignored) {
channel_data* chand = (channel_data*)arg;
if (chand->lb_policy != nullptr) {
- grpc_lb_policy_exit_idle_locked(exec_ctx, chand->lb_policy);
+ grpc_lb_policy_exit_idle_locked(chand->lb_policy);
} else {
chand->exit_idle_when_lb_policy_arrives = true;
if (!chand->started_resolving && chand->resolver != nullptr) {
- start_resolving_locked(exec_ctx, chand);
+ start_resolving_locked(chand);
}
}
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->owning_stack, "try_to_connect");
+ GRPC_CHANNEL_STACK_UNREF(chand->owning_stack, "try_to_connect");
}
grpc_connectivity_state grpc_client_channel_check_connectivity_state(
- grpc_exec_ctx* exec_ctx, grpc_channel_element* elem, int try_to_connect) {
+ grpc_channel_element* elem, int try_to_connect) {
channel_data* chand = (channel_data*)elem->channel_data;
grpc_connectivity_state out =
grpc_connectivity_state_check(&chand->state_tracker);
if (out == GRPC_CHANNEL_IDLE && try_to_connect) {
GRPC_CHANNEL_STACK_REF(chand->owning_stack, "try_to_connect");
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_CREATE(try_to_connect_locked, chand,
grpc_combiner_scheduler(chand->combiner)),
GRPC_ERROR_NONE);
@@ -1629,50 +1569,49 @@ int grpc_client_channel_num_external_connectivity_watchers(
return count;
}
-static void on_external_watch_complete_locked(grpc_exec_ctx* exec_ctx,
- void* arg, grpc_error* error) {
+static void on_external_watch_complete_locked(void* arg, grpc_error* error) {
external_connectivity_watcher* w = (external_connectivity_watcher*)arg;
grpc_closure* follow_up = w->on_complete;
- grpc_polling_entity_del_from_pollset_set(exec_ctx, &w->pollent,
+ grpc_polling_entity_del_from_pollset_set(&w->pollent,
w->chand->interested_parties);
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, w->chand->owning_stack,
+ GRPC_CHANNEL_STACK_UNREF(w->chand->owning_stack,
"external_connectivity_watcher");
external_connectivity_watcher_list_remove(w->chand, w);
gpr_free(w);
- GRPC_CLOSURE_RUN(exec_ctx, follow_up, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_RUN(follow_up, GRPC_ERROR_REF(error));
}
-static void watch_connectivity_state_locked(grpc_exec_ctx* exec_ctx, void* arg,
+static void watch_connectivity_state_locked(void* arg,
grpc_error* error_ignored) {
external_connectivity_watcher* w = (external_connectivity_watcher*)arg;
external_connectivity_watcher* found = nullptr;
if (w->state != nullptr) {
external_connectivity_watcher_list_append(w->chand, w);
- GRPC_CLOSURE_RUN(exec_ctx, w->watcher_timer_init, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_RUN(w->watcher_timer_init, GRPC_ERROR_NONE);
GRPC_CLOSURE_INIT(&w->my_closure, on_external_watch_complete_locked, w,
grpc_combiner_scheduler(w->chand->combiner));
- grpc_connectivity_state_notify_on_state_change(
- exec_ctx, &w->chand->state_tracker, w->state, &w->my_closure);
+ grpc_connectivity_state_notify_on_state_change(&w->chand->state_tracker,
+ w->state, &w->my_closure);
} else {
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, nullptr, &found->my_closure);
+ &found->chand->state_tracker, nullptr, &found->my_closure);
}
- grpc_polling_entity_del_from_pollset_set(exec_ctx, &w->pollent,
+ grpc_polling_entity_del_from_pollset_set(&w->pollent,
w->chand->interested_parties);
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, w->chand->owning_stack,
+ GRPC_CHANNEL_STACK_UNREF(w->chand->owning_stack,
"external_connectivity_watcher");
gpr_free(w);
}
}
void grpc_client_channel_watch_connectivity_state(
- grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
- grpc_polling_entity pollent, grpc_connectivity_state* state,
- grpc_closure* closure, grpc_closure* watcher_timer_init) {
+ grpc_channel_element* elem, grpc_polling_entity pollent,
+ grpc_connectivity_state* state, grpc_closure* closure,
+ grpc_closure* watcher_timer_init) {
channel_data* chand = (channel_data*)elem->channel_data;
external_connectivity_watcher* w =
(external_connectivity_watcher*)gpr_zalloc(sizeof(*w));
@@ -1681,12 +1620,11 @@ void grpc_client_channel_watch_connectivity_state(
w->on_complete = closure;
w->state = state;
w->watcher_timer_init = watcher_timer_init;
- grpc_polling_entity_add_to_pollset_set(exec_ctx, &w->pollent,
+ grpc_polling_entity_add_to_pollset_set(&w->pollent,
chand->interested_parties);
GRPC_CHANNEL_STACK_REF(w->chand->owning_stack,
"external_connectivity_watcher");
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_INIT(&w->my_closure, watch_connectivity_state_locked, w,
grpc_combiner_scheduler(chand->combiner)),
GRPC_ERROR_NONE);
diff --git a/src/core/ext/filters/client_channel/client_channel.h b/src/core/ext/filters/client_channel/client_channel.h
index 27862cf239..b84e7e8c62 100644
--- a/src/core/ext/filters/client_channel/client_channel.h
+++ b/src/core/ext/filters/client_channel/client_channel.h
@@ -42,15 +42,15 @@ extern "C" {
extern const grpc_channel_filter grpc_client_channel_filter;
grpc_connectivity_state grpc_client_channel_check_connectivity_state(
- grpc_exec_ctx* exec_ctx, grpc_channel_element* elem, int try_to_connect);
+ grpc_channel_element* elem, int try_to_connect);
int grpc_client_channel_num_external_connectivity_watchers(
grpc_channel_element* elem);
void grpc_client_channel_watch_connectivity_state(
- grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
- grpc_polling_entity pollent, grpc_connectivity_state* state,
- grpc_closure* on_complete, grpc_closure* watcher_timer_init);
+ grpc_channel_element* elem, grpc_polling_entity pollent,
+ grpc_connectivity_state* state, grpc_closure* on_complete,
+ grpc_closure* watcher_timer_init);
/* Debug helper: pull the subchannel call from a call stack element */
grpc_subchannel_call* grpc_client_channel_get_subchannel_call(
diff --git a/src/core/ext/filters/client_channel/client_channel_factory.cc b/src/core/ext/filters/client_channel/client_channel_factory.cc
index 57eac8f875..60c95d7dc9 100644
--- a/src/core/ext/filters/client_channel/client_channel_factory.cc
+++ b/src/core/ext/filters/client_channel/client_channel_factory.cc
@@ -23,23 +23,19 @@ void grpc_client_channel_factory_ref(grpc_client_channel_factory* factory) {
factory->vtable->ref(factory);
}
-void grpc_client_channel_factory_unref(grpc_exec_ctx* exec_ctx,
- grpc_client_channel_factory* factory) {
- factory->vtable->unref(exec_ctx, factory);
+void grpc_client_channel_factory_unref(grpc_client_channel_factory* factory) {
+ factory->vtable->unref(factory);
}
grpc_subchannel* grpc_client_channel_factory_create_subchannel(
- grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* factory,
- const grpc_subchannel_args* args) {
- return factory->vtable->create_subchannel(exec_ctx, factory, args);
+ grpc_client_channel_factory* factory, const grpc_subchannel_args* args) {
+ return factory->vtable->create_subchannel(factory, args);
}
grpc_channel* grpc_client_channel_factory_create_channel(
- grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* factory,
- const char* target, grpc_client_channel_type type,
- const grpc_channel_args* args) {
- return factory->vtable->create_client_channel(exec_ctx, factory, target, type,
- args);
+ grpc_client_channel_factory* factory, const char* target,
+ grpc_client_channel_type type, const grpc_channel_args* args) {
+ return factory->vtable->create_client_channel(factory, target, type, args);
}
static void* factory_arg_copy(void* factory) {
@@ -47,9 +43,8 @@ static void* factory_arg_copy(void* factory) {
return factory;
}
-static void factory_arg_destroy(grpc_exec_ctx* exec_ctx, void* factory) {
- grpc_client_channel_factory_unref(exec_ctx,
- (grpc_client_channel_factory*)factory);
+static void factory_arg_destroy(void* factory) {
+ grpc_client_channel_factory_unref((grpc_client_channel_factory*)factory);
}
static int factory_arg_cmp(void* factory1, void* factory2) {
diff --git a/src/core/ext/filters/client_channel/client_channel_factory.h b/src/core/ext/filters/client_channel/client_channel_factory.h
index db8645cd00..cc36a924ee 100644
--- a/src/core/ext/filters/client_channel/client_channel_factory.h
+++ b/src/core/ext/filters/client_channel/client_channel_factory.h
@@ -49,31 +49,26 @@ struct grpc_client_channel_factory {
struct grpc_client_channel_factory_vtable {
void (*ref)(grpc_client_channel_factory* factory);
- void (*unref)(grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* factory);
- grpc_subchannel* (*create_subchannel)(grpc_exec_ctx* exec_ctx,
- grpc_client_channel_factory* factory,
+ void (*unref)(grpc_client_channel_factory* factory);
+ grpc_subchannel* (*create_subchannel)(grpc_client_channel_factory* factory,
const grpc_subchannel_args* args);
- grpc_channel* (*create_client_channel)(grpc_exec_ctx* exec_ctx,
- grpc_client_channel_factory* factory,
+ grpc_channel* (*create_client_channel)(grpc_client_channel_factory* factory,
const char* target,
grpc_client_channel_type type,
const grpc_channel_args* args);
};
void grpc_client_channel_factory_ref(grpc_client_channel_factory* factory);
-void grpc_client_channel_factory_unref(grpc_exec_ctx* exec_ctx,
- grpc_client_channel_factory* factory);
+void grpc_client_channel_factory_unref(grpc_client_channel_factory* factory);
/** Create a new grpc_subchannel */
grpc_subchannel* grpc_client_channel_factory_create_subchannel(
- grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* factory,
- const grpc_subchannel_args* args);
+ grpc_client_channel_factory* factory, const grpc_subchannel_args* args);
/** Create a new grpc_channel */
grpc_channel* grpc_client_channel_factory_create_channel(
- grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* factory,
- const char* target, grpc_client_channel_type type,
- const grpc_channel_args* args);
+ grpc_client_channel_factory* factory, const char* target,
+ grpc_client_channel_type type, const grpc_channel_args* args);
grpc_arg grpc_client_channel_factory_create_channel_arg(
grpc_client_channel_factory* factory);
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 eebef6827c..f30b3b2c27 100644
--- a/src/core/ext/filters/client_channel/client_channel_plugin.cc
+++ b/src/core/ext/filters/client_channel/client_channel_plugin.cc
@@ -34,14 +34,12 @@
#include "src/core/ext/filters/client_channel/subchannel_index.h"
#include "src/core/lib/surface/channel_init.h"
-static bool append_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder, void* arg) {
+static bool append_filter(grpc_channel_stack_builder* builder, void* arg) {
return grpc_channel_stack_builder_append_filter(
builder, (const grpc_channel_filter*)arg, nullptr, nullptr);
}
-static bool set_default_host_if_unset(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+static bool set_default_host_if_unset(grpc_channel_stack_builder* builder,
void* unused) {
const grpc_channel_args* args =
grpc_channel_stack_builder_get_channel_arguments(builder);
@@ -52,15 +50,14 @@ 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));
+ grpc_channel_stack_builder_get_target(builder));
if (default_authority != nullptr) {
grpc_arg arg = grpc_channel_arg_string_create(
(char*)GRPC_ARG_DEFAULT_AUTHORITY, default_authority);
grpc_channel_args* new_args = grpc_channel_args_copy_and_add(args, &arg, 1);
- grpc_channel_stack_builder_set_channel_arguments(exec_ctx, builder,
- new_args);
+ grpc_channel_stack_builder_set_channel_arguments(builder, new_args);
gpr_free(default_authority);
- grpc_channel_args_destroy(exec_ctx, new_args);
+ grpc_channel_args_destroy(new_args);
}
return true;
}
diff --git a/src/core/ext/filters/client_channel/connector.cc b/src/core/ext/filters/client_channel/connector.cc
index c258468e58..c8bf2f3e1c 100644
--- a/src/core/ext/filters/client_channel/connector.cc
+++ b/src/core/ext/filters/client_channel/connector.cc
@@ -23,18 +23,17 @@ grpc_connector* grpc_connector_ref(grpc_connector* connector) {
return connector;
}
-void grpc_connector_unref(grpc_exec_ctx* exec_ctx, grpc_connector* connector) {
- connector->vtable->unref(exec_ctx, connector);
+void grpc_connector_unref(grpc_connector* connector) {
+ connector->vtable->unref(connector);
}
-void grpc_connector_connect(grpc_exec_ctx* exec_ctx, grpc_connector* connector,
+void grpc_connector_connect(grpc_connector* connector,
const grpc_connect_in_args* in_args,
grpc_connect_out_args* out_args,
grpc_closure* notify) {
- connector->vtable->connect(exec_ctx, connector, in_args, out_args, notify);
+ connector->vtable->connect(connector, in_args, out_args, notify);
}
-void grpc_connector_shutdown(grpc_exec_ctx* exec_ctx, grpc_connector* connector,
- grpc_error* why) {
- connector->vtable->shutdown(exec_ctx, connector, why);
+void grpc_connector_shutdown(grpc_connector* connector, grpc_error* why) {
+ connector->vtable->shutdown(connector, why);
}
diff --git a/src/core/ext/filters/client_channel/connector.h b/src/core/ext/filters/client_channel/connector.h
index 12dc59bcdf..40f0b723af 100644
--- a/src/core/ext/filters/client_channel/connector.h
+++ b/src/core/ext/filters/client_channel/connector.h
@@ -53,26 +53,24 @@ typedef struct {
struct grpc_connector_vtable {
void (*ref)(grpc_connector* connector);
- void (*unref)(grpc_exec_ctx* exec_ctx, grpc_connector* connector);
+ void (*unref)(grpc_connector* connector);
/** Implementation of grpc_connector_shutdown */
- void (*shutdown)(grpc_exec_ctx* exec_ctx, grpc_connector* connector,
- grpc_error* why);
+ void (*shutdown)(grpc_connector* connector, grpc_error* why);
/** Implementation of grpc_connector_connect */
- void (*connect)(grpc_exec_ctx* exec_ctx, grpc_connector* connector,
+ void (*connect)(grpc_connector* connector,
const grpc_connect_in_args* in_args,
grpc_connect_out_args* out_args, grpc_closure* notify);
};
grpc_connector* grpc_connector_ref(grpc_connector* connector);
-void grpc_connector_unref(grpc_exec_ctx* exec_ctx, grpc_connector* connector);
+void grpc_connector_unref(grpc_connector* connector);
/** Connect using the connector: max one outstanding call at a time */
-void grpc_connector_connect(grpc_exec_ctx* exec_ctx, grpc_connector* connector,
+void grpc_connector_connect(grpc_connector* connector,
const grpc_connect_in_args* in_args,
grpc_connect_out_args* out_args,
grpc_closure* notify);
/** Cancel any pending connection */
-void grpc_connector_shutdown(grpc_exec_ctx* exec_ctx, grpc_connector* connector,
- grpc_error* why);
+void grpc_connector_shutdown(grpc_connector* connector, grpc_error* why);
#ifdef __cplusplus
}
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 b7cb2e3eba..556a3bc6a1 100644
--- a/src/core/ext/filters/client_channel/http_connect_handshaker.cc
+++ b/src/core/ext/filters/client_channel/http_connect_handshaker.cc
@@ -61,41 +61,38 @@ typedef struct http_connect_handshaker {
} http_connect_handshaker;
// Unref and clean up handshaker.
-static void http_connect_handshaker_unref(grpc_exec_ctx* exec_ctx,
- http_connect_handshaker* handshaker) {
+static void http_connect_handshaker_unref(http_connect_handshaker* handshaker) {
if (gpr_unref(&handshaker->refcount)) {
gpr_mu_destroy(&handshaker->mu);
if (handshaker->endpoint_to_destroy != nullptr) {
- grpc_endpoint_destroy(exec_ctx, handshaker->endpoint_to_destroy);
+ grpc_endpoint_destroy(handshaker->endpoint_to_destroy);
}
if (handshaker->read_buffer_to_destroy != nullptr) {
- grpc_slice_buffer_destroy_internal(exec_ctx,
- handshaker->read_buffer_to_destroy);
+ grpc_slice_buffer_destroy_internal(handshaker->read_buffer_to_destroy);
gpr_free(handshaker->read_buffer_to_destroy);
}
- grpc_slice_buffer_destroy_internal(exec_ctx, &handshaker->write_buffer);
+ grpc_slice_buffer_destroy_internal(&handshaker->write_buffer);
grpc_http_parser_destroy(&handshaker->http_parser);
grpc_http_response_destroy(&handshaker->http_response);
gpr_free(handshaker);
}
}
-// Set args fields to NULL, saving the endpoint and read buffer for
+// Set args fields to nullptr, saving the endpoint and read buffer for
// later destruction.
static void cleanup_args_for_failure_locked(
- grpc_exec_ctx* exec_ctx, http_connect_handshaker* handshaker) {
+ http_connect_handshaker* handshaker) {
handshaker->endpoint_to_destroy = handshaker->args->endpoint;
handshaker->args->endpoint = nullptr;
handshaker->read_buffer_to_destroy = handshaker->args->read_buffer;
handshaker->args->read_buffer = nullptr;
- grpc_channel_args_destroy(exec_ctx, handshaker->args->args);
+ grpc_channel_args_destroy(handshaker->args->args);
handshaker->args->args = nullptr;
}
// If the handshake failed or we're shutting down, clean up and invoke the
// callback with the error.
-static void handshake_failed_locked(grpc_exec_ctx* exec_ctx,
- http_connect_handshaker* handshaker,
+static void handshake_failed_locked(http_connect_handshaker* handshaker,
grpc_error* error) {
if (error == GRPC_ERROR_NONE) {
// If we were shut down after an endpoint operation succeeded but
@@ -108,34 +105,32 @@ static void handshake_failed_locked(grpc_exec_ctx* exec_ctx,
// before destroying them, even if we know that there are no
// pending read/write callbacks. This should be fixed, at which
// point this can be removed.
- grpc_endpoint_shutdown(exec_ctx, handshaker->args->endpoint,
- GRPC_ERROR_REF(error));
+ grpc_endpoint_shutdown(handshaker->args->endpoint, GRPC_ERROR_REF(error));
// Not shutting down, so the handshake failed. Clean up before
// invoking the callback.
- cleanup_args_for_failure_locked(exec_ctx, handshaker);
+ cleanup_args_for_failure_locked(handshaker);
// Set shutdown to true so that subsequent calls to
// http_connect_handshaker_shutdown() do nothing.
handshaker->shutdown = true;
}
// Invoke callback.
- GRPC_CLOSURE_SCHED(exec_ctx, handshaker->on_handshake_done, error);
+ GRPC_CLOSURE_SCHED(handshaker->on_handshake_done, error);
}
// Callback invoked when finished writing HTTP CONNECT request.
-static void on_write_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_write_done(void* arg, grpc_error* error) {
http_connect_handshaker* handshaker = (http_connect_handshaker*)arg;
gpr_mu_lock(&handshaker->mu);
if (error != GRPC_ERROR_NONE || handshaker->shutdown) {
// If the write failed or we're shutting down, clean up and invoke the
// callback with the error.
- handshake_failed_locked(exec_ctx, handshaker, GRPC_ERROR_REF(error));
+ handshake_failed_locked(handshaker, GRPC_ERROR_REF(error));
gpr_mu_unlock(&handshaker->mu);
- http_connect_handshaker_unref(exec_ctx, handshaker);
+ http_connect_handshaker_unref(handshaker);
} else {
// Otherwise, read the response.
// The read callback inherits our ref to the handshaker.
- grpc_endpoint_read(exec_ctx, handshaker->args->endpoint,
+ grpc_endpoint_read(handshaker->args->endpoint,
handshaker->args->read_buffer,
&handshaker->response_read_closure);
gpr_mu_unlock(&handshaker->mu);
@@ -143,14 +138,13 @@ static void on_write_done(grpc_exec_ctx* exec_ctx, void* arg,
}
// Callback invoked for reading HTTP CONNECT response.
-static void on_read_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_read_done(void* arg, grpc_error* error) {
http_connect_handshaker* handshaker = (http_connect_handshaker*)arg;
gpr_mu_lock(&handshaker->mu);
if (error != GRPC_ERROR_NONE || handshaker->shutdown) {
// If the read failed or we're shutting down, clean up and invoke the
// callback with the error.
- handshake_failed_locked(exec_ctx, handshaker, GRPC_ERROR_REF(error));
+ handshake_failed_locked(handshaker, GRPC_ERROR_REF(error));
goto done;
}
// Add buffer to parser.
@@ -161,7 +155,7 @@ static void on_read_done(grpc_exec_ctx* exec_ctx, void* arg,
handshaker->args->read_buffer->slices[i],
&body_start_offset);
if (error != GRPC_ERROR_NONE) {
- handshake_failed_locked(exec_ctx, handshaker, error);
+ handshake_failed_locked(handshaker, error);
goto done;
}
if (handshaker->http_parser.state == GRPC_HTTP_BODY) {
@@ -180,7 +174,7 @@ static void on_read_done(grpc_exec_ctx* exec_ctx, void* arg,
&handshaker->args->read_buffer->slices[i + 1],
handshaker->args->read_buffer->count - i - 1);
grpc_slice_buffer_swap(handshaker->args->read_buffer, &tmp_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &tmp_buffer);
+ grpc_slice_buffer_destroy_internal(&tmp_buffer);
break;
}
}
@@ -197,9 +191,8 @@ static void on_read_done(grpc_exec_ctx* exec_ctx, void* arg,
// complete (e.g., handling chunked transfer encoding or looking
// at the Content-Length: header).
if (handshaker->http_parser.state != GRPC_HTTP_BODY) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
- handshaker->args->read_buffer);
- grpc_endpoint_read(exec_ctx, handshaker->args->endpoint,
+ grpc_slice_buffer_reset_and_unref_internal(handshaker->args->read_buffer);
+ grpc_endpoint_read(handshaker->args->endpoint,
handshaker->args->read_buffer,
&handshaker->response_read_closure);
gpr_mu_unlock(&handshaker->mu);
@@ -213,48 +206,44 @@ static void on_read_done(grpc_exec_ctx* exec_ctx, void* arg,
handshaker->http_response.status);
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
- handshake_failed_locked(exec_ctx, handshaker, error);
+ handshake_failed_locked(handshaker, error);
goto done;
}
// Success. Invoke handshake-done callback.
- GRPC_CLOSURE_SCHED(exec_ctx, handshaker->on_handshake_done, error);
+ GRPC_CLOSURE_SCHED(handshaker->on_handshake_done, error);
done:
// Set shutdown to true so that subsequent calls to
// http_connect_handshaker_shutdown() do nothing.
handshaker->shutdown = true;
gpr_mu_unlock(&handshaker->mu);
- http_connect_handshaker_unref(exec_ctx, handshaker);
+ http_connect_handshaker_unref(handshaker);
}
//
// Public handshaker methods
//
-static void http_connect_handshaker_destroy(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker_in) {
+static void http_connect_handshaker_destroy(grpc_handshaker* handshaker_in) {
http_connect_handshaker* handshaker = (http_connect_handshaker*)handshaker_in;
- http_connect_handshaker_unref(exec_ctx, handshaker);
+ http_connect_handshaker_unref(handshaker);
}
-static void http_connect_handshaker_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker_in,
+static void http_connect_handshaker_shutdown(grpc_handshaker* handshaker_in,
grpc_error* why) {
http_connect_handshaker* handshaker = (http_connect_handshaker*)handshaker_in;
gpr_mu_lock(&handshaker->mu);
if (!handshaker->shutdown) {
handshaker->shutdown = true;
- grpc_endpoint_shutdown(exec_ctx, handshaker->args->endpoint,
- GRPC_ERROR_REF(why));
- cleanup_args_for_failure_locked(exec_ctx, handshaker);
+ grpc_endpoint_shutdown(handshaker->args->endpoint, GRPC_ERROR_REF(why));
+ cleanup_args_for_failure_locked(handshaker);
}
gpr_mu_unlock(&handshaker->mu);
GRPC_ERROR_UNREF(why);
}
static void http_connect_handshaker_do_handshake(
- grpc_exec_ctx* exec_ctx, grpc_handshaker* handshaker_in,
- grpc_tcp_server_acceptor* acceptor, grpc_closure* on_handshake_done,
- grpc_handshaker_args* args) {
+ grpc_handshaker* handshaker_in, grpc_tcp_server_acceptor* acceptor,
+ grpc_closure* on_handshake_done, grpc_handshaker_args* args) {
http_connect_handshaker* handshaker = (http_connect_handshaker*)handshaker_in;
// Check for HTTP CONNECT channel arg.
// If not found, invoke on_handshake_done without doing anything.
@@ -266,7 +255,7 @@ static void http_connect_handshaker_do_handshake(
gpr_mu_lock(&handshaker->mu);
handshaker->shutdown = true;
gpr_mu_unlock(&handshaker->mu);
- GRPC_CLOSURE_SCHED(exec_ctx, on_handshake_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_handshake_done, GRPC_ERROR_NONE);
return;
}
GPR_ASSERT(arg->type == GRPC_ARG_STRING);
@@ -324,7 +313,7 @@ static void http_connect_handshaker_do_handshake(
gpr_free(header_strings);
// Take a new ref to be held by the write callback.
gpr_ref(&handshaker->refcount);
- grpc_endpoint_write(exec_ctx, args->endpoint, &handshaker->write_buffer,
+ grpc_endpoint_write(args->endpoint, &handshaker->write_buffer,
&handshaker->request_done_closure);
gpr_mu_unlock(&handshaker->mu);
}
@@ -355,14 +344,13 @@ static grpc_handshaker* grpc_http_connect_handshaker_create() {
//
static void handshaker_factory_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory* factory,
- const grpc_channel_args* args, grpc_handshake_manager* handshake_mgr) {
+ grpc_handshaker_factory* factory, const grpc_channel_args* args,
+ grpc_handshake_manager* handshake_mgr) {
grpc_handshake_manager_add(handshake_mgr,
grpc_http_connect_handshaker_create());
}
-static void handshaker_factory_destroy(grpc_exec_ctx* exec_ctx,
- grpc_handshaker_factory* factory) {}
+static void handshaker_factory_destroy(grpc_handshaker_factory* factory) {}
static const grpc_handshaker_factory_vtable handshaker_factory_vtable = {
handshaker_factory_add_handshakers, handshaker_factory_destroy};
diff --git a/src/core/ext/filters/client_channel/http_proxy.cc b/src/core/ext/filters/client_channel/http_proxy.cc
index 405d8c0e55..2eafeee702 100644
--- a/src/core/ext/filters/client_channel/http_proxy.cc
+++ b/src/core/ext/filters/client_channel/http_proxy.cc
@@ -36,19 +36,18 @@
/**
* Parses the 'http_proxy' env var and returns the proxy hostname to resolve or
- * NULL on error. Also sets 'user_cred' to user credentials if present in the
+ * nullptr on error. Also sets 'user_cred' to user credentials if present in the
* 'http_proxy' env var, otherwise leaves it unchanged. It is caller's
* responsibility to gpr_free user_cred.
*/
-static char* get_http_proxy_server(grpc_exec_ctx* exec_ctx, char** user_cred) {
+static char* get_http_proxy_server(char** user_cred) {
GPR_ASSERT(user_cred != nullptr);
char* proxy_name = nullptr;
char* uri_str = gpr_getenv("http_proxy");
char** authority_strs = nullptr;
size_t authority_nstrs;
if (uri_str == nullptr) return nullptr;
- grpc_uri* uri =
- grpc_uri_parse(exec_ctx, uri_str, false /* suppress_errors */);
+ grpc_uri* uri = grpc_uri_parse(uri_str, false /* suppress_errors */);
if (uri == nullptr || uri->authority == nullptr) {
gpr_log(GPR_ERROR, "cannot parse value of 'http_proxy' env var");
goto done;
@@ -82,18 +81,16 @@ done:
return proxy_name;
}
-static bool proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
- grpc_proxy_mapper* mapper,
+static bool proxy_mapper_map_name(grpc_proxy_mapper* mapper,
const char* server_uri,
const grpc_channel_args* args,
char** name_to_resolve,
grpc_channel_args** new_args) {
char* user_cred = nullptr;
- *name_to_resolve = get_http_proxy_server(exec_ctx, &user_cred);
+ *name_to_resolve = get_http_proxy_server(&user_cred);
if (*name_to_resolve == nullptr) return false;
char* no_proxy_str = nullptr;
- grpc_uri* uri =
- grpc_uri_parse(exec_ctx, server_uri, false /* suppress_errors */);
+ grpc_uri* uri = grpc_uri_parse(server_uri, false /* suppress_errors */);
if (uri == nullptr || uri->path[0] == '\0') {
gpr_log(GPR_ERROR,
"'http_proxy' environment variable set, but cannot "
@@ -174,8 +171,7 @@ no_use_proxy:
return false;
}
-static bool proxy_mapper_map_address(grpc_exec_ctx* exec_ctx,
- grpc_proxy_mapper* mapper,
+static bool proxy_mapper_map_address(grpc_proxy_mapper* mapper,
const grpc_resolved_address* address,
const grpc_channel_args* args,
grpc_resolved_address** new_address,
diff --git a/src/core/ext/filters/client_channel/lb_policy.cc b/src/core/ext/filters/client_channel/lb_policy.cc
index 387c26ed5c..c48c845573 100644
--- a/src/core/ext/filters/client_channel/lb_policy.cc
+++ b/src/core/ext/filters/client_channel/lb_policy.cc
@@ -65,15 +65,13 @@ void grpc_lb_policy_ref(grpc_lb_policy* policy REF_FUNC_EXTRA_ARGS) {
ref_mutate(policy, 1 << WEAK_REF_BITS, 0 REF_MUTATE_PASS_ARGS("STRONG_REF"));
}
-static void shutdown_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void shutdown_locked(void* arg, grpc_error* error) {
grpc_lb_policy* policy = (grpc_lb_policy*)arg;
- policy->vtable->shutdown_locked(exec_ctx, policy);
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, policy, "strong-unref");
+ policy->vtable->shutdown_locked(policy);
+ GRPC_LB_POLICY_WEAK_UNREF(policy, "strong-unref");
}
-void grpc_lb_policy_unref(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy* policy REF_FUNC_EXTRA_ARGS) {
+void grpc_lb_policy_unref(grpc_lb_policy* policy REF_FUNC_EXTRA_ARGS) {
gpr_atm old_val =
ref_mutate(policy, (gpr_atm)1 - (gpr_atm)(1 << WEAK_REF_BITS),
1 REF_MUTATE_PASS_ARGS("STRONG_UNREF"));
@@ -81,13 +79,11 @@ void grpc_lb_policy_unref(grpc_exec_ctx* exec_ctx,
gpr_atm check = 1 << WEAK_REF_BITS;
if ((old_val & mask) == check) {
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_CREATE(shutdown_locked, policy,
grpc_combiner_scheduler(policy->combiner)),
GRPC_ERROR_NONE);
} else {
- grpc_lb_policy_weak_unref(exec_ctx,
- policy REF_FUNC_PASS_ARGS("strong-unref"));
+ grpc_lb_policy_weak_unref(policy REF_FUNC_PASS_ARGS("strong-unref"));
}
}
@@ -95,71 +91,61 @@ void grpc_lb_policy_weak_ref(grpc_lb_policy* policy REF_FUNC_EXTRA_ARGS) {
ref_mutate(policy, 1, 0 REF_MUTATE_PASS_ARGS("WEAK_REF"));
}
-void grpc_lb_policy_weak_unref(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy* policy REF_FUNC_EXTRA_ARGS) {
+void grpc_lb_policy_weak_unref(grpc_lb_policy* policy REF_FUNC_EXTRA_ARGS) {
gpr_atm old_val =
ref_mutate(policy, -(gpr_atm)1, 1 REF_MUTATE_PASS_ARGS("WEAK_UNREF"));
if (old_val == 1) {
- grpc_pollset_set_destroy(exec_ctx, policy->interested_parties);
+ grpc_pollset_set_destroy(policy->interested_parties);
grpc_combiner* combiner = policy->combiner;
- policy->vtable->destroy(exec_ctx, policy);
- GRPC_COMBINER_UNREF(exec_ctx, combiner, "lb_policy");
+ policy->vtable->destroy(policy);
+ GRPC_COMBINER_UNREF(combiner, "lb_policy");
}
}
-int grpc_lb_policy_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
+int grpc_lb_policy_pick_locked(grpc_lb_policy* policy,
const grpc_lb_policy_pick_args* pick_args,
grpc_connected_subchannel** target,
grpc_call_context_element* context,
void** user_data, grpc_closure* on_complete) {
- return policy->vtable->pick_locked(exec_ctx, policy, pick_args, target,
- context, user_data, on_complete);
+ return policy->vtable->pick_locked(policy, pick_args, target, context,
+ user_data, on_complete);
}
-void grpc_lb_policy_cancel_pick_locked(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy* policy,
+void grpc_lb_policy_cancel_pick_locked(grpc_lb_policy* policy,
grpc_connected_subchannel** target,
grpc_error* error) {
- policy->vtable->cancel_pick_locked(exec_ctx, policy, target, error);
+ policy->vtable->cancel_pick_locked(policy, target, error);
}
-void grpc_lb_policy_cancel_picks_locked(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy* policy,
+void grpc_lb_policy_cancel_picks_locked(grpc_lb_policy* policy,
uint32_t initial_metadata_flags_mask,
uint32_t initial_metadata_flags_eq,
grpc_error* error) {
- policy->vtable->cancel_picks_locked(exec_ctx, policy,
- initial_metadata_flags_mask,
+ policy->vtable->cancel_picks_locked(policy, initial_metadata_flags_mask,
initial_metadata_flags_eq, error);
}
-void grpc_lb_policy_exit_idle_locked(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy* policy) {
- policy->vtable->exit_idle_locked(exec_ctx, policy);
+void grpc_lb_policy_exit_idle_locked(grpc_lb_policy* policy) {
+ policy->vtable->exit_idle_locked(policy);
}
-void grpc_lb_policy_ping_one_locked(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy* policy,
+void grpc_lb_policy_ping_one_locked(grpc_lb_policy* policy,
grpc_closure* closure) {
- policy->vtable->ping_one_locked(exec_ctx, policy, closure);
+ policy->vtable->ping_one_locked(policy, closure);
}
void grpc_lb_policy_notify_on_state_change_locked(
- grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
- grpc_connectivity_state* state, grpc_closure* closure) {
- policy->vtable->notify_on_state_change_locked(exec_ctx, policy, state,
- closure);
+ grpc_lb_policy* policy, grpc_connectivity_state* state,
+ grpc_closure* closure) {
+ policy->vtable->notify_on_state_change_locked(policy, state, closure);
}
grpc_connectivity_state grpc_lb_policy_check_connectivity_locked(
- grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
- grpc_error** connectivity_error) {
- return policy->vtable->check_connectivity_locked(exec_ctx, policy,
- connectivity_error);
+ grpc_lb_policy* policy, grpc_error** connectivity_error) {
+ return policy->vtable->check_connectivity_locked(policy, connectivity_error);
}
-void grpc_lb_policy_update_locked(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy* policy,
+void grpc_lb_policy_update_locked(grpc_lb_policy* policy,
const grpc_lb_policy_args* lb_policy_args) {
- policy->vtable->update_locked(exec_ctx, policy, lb_policy_args);
+ policy->vtable->update_locked(policy, lb_policy_args);
}
diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h
index 590094e67e..4501df0946 100644
--- a/src/core/ext/filters/client_channel/lb_policy.h
+++ b/src/core/ext/filters/client_channel/lb_policy.h
@@ -59,48 +59,45 @@ typedef struct grpc_lb_policy_pick_args {
} grpc_lb_policy_pick_args;
struct grpc_lb_policy_vtable {
- void (*destroy)(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy);
- void (*shutdown_locked)(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy);
+ void (*destroy)(grpc_lb_policy* policy);
+ void (*shutdown_locked)(grpc_lb_policy* policy);
/** \see grpc_lb_policy_pick */
- int (*pick_locked)(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
+ int (*pick_locked)(grpc_lb_policy* policy,
const grpc_lb_policy_pick_args* pick_args,
grpc_connected_subchannel** target,
grpc_call_context_element* context, void** user_data,
grpc_closure* on_complete);
/** \see grpc_lb_policy_cancel_pick */
- void (*cancel_pick_locked)(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
+ void (*cancel_pick_locked)(grpc_lb_policy* policy,
grpc_connected_subchannel** target,
grpc_error* error);
/** \see grpc_lb_policy_cancel_picks */
- void (*cancel_picks_locked)(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
+ void (*cancel_picks_locked)(grpc_lb_policy* policy,
uint32_t initial_metadata_flags_mask,
uint32_t initial_metadata_flags_eq,
grpc_error* error);
/** \see grpc_lb_policy_ping_one */
- void (*ping_one_locked)(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
- grpc_closure* closure);
+ void (*ping_one_locked)(grpc_lb_policy* policy, grpc_closure* closure);
/** Try to enter a READY connectivity state */
- void (*exit_idle_locked)(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy);
+ void (*exit_idle_locked)(grpc_lb_policy* policy);
/** check the current connectivity of the lb_policy */
grpc_connectivity_state (*check_connectivity_locked)(
- grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
- grpc_error** connectivity_error);
+ grpc_lb_policy* policy, grpc_error** connectivity_error);
/** call notify when the connectivity state of a channel changes from *state.
Updates *state with the new state of the policy. Calling with a NULL \a
state cancels the subscription. */
- void (*notify_on_state_change_locked)(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy* policy,
+ void (*notify_on_state_change_locked)(grpc_lb_policy* policy,
grpc_connectivity_state* state,
grpc_closure* closure);
- void (*update_locked)(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
+ void (*update_locked)(grpc_lb_policy* policy,
const grpc_lb_policy_args* args);
};
@@ -109,33 +106,33 @@ struct grpc_lb_policy_vtable {
/* Strong references: the policy will shutdown when they reach zero */
#define GRPC_LB_POLICY_REF(p, r) \
grpc_lb_policy_ref((p), __FILE__, __LINE__, (r))
-#define GRPC_LB_POLICY_UNREF(exec_ctx, p, r) \
- grpc_lb_policy_unref((exec_ctx), (p), __FILE__, __LINE__, (r))
+#define GRPC_LB_POLICY_UNREF(p, r) \
+ grpc_lb_policy_unref((p), __FILE__, __LINE__, (r))
/* Weak references: they don't prevent the shutdown of the LB policy. When no
* strong references are left but there are still weak ones, shutdown is called.
* Once the weak reference also reaches zero, the LB policy is destroyed. */
#define GRPC_LB_POLICY_WEAK_REF(p, r) \
grpc_lb_policy_weak_ref((p), __FILE__, __LINE__, (r))
-#define GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, p, r) \
- grpc_lb_policy_weak_unref((exec_ctx), (p), __FILE__, __LINE__, (r))
+#define GRPC_LB_POLICY_WEAK_UNREF(p, r) \
+ grpc_lb_policy_weak_unref((p), __FILE__, __LINE__, (r))
void grpc_lb_policy_ref(grpc_lb_policy* policy, const char* file, int line,
const char* reason);
-void grpc_lb_policy_unref(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
- const char* file, int line, const char* reason);
+void grpc_lb_policy_unref(grpc_lb_policy* policy, const char* file, int line,
+ const char* reason);
void grpc_lb_policy_weak_ref(grpc_lb_policy* policy, const char* file, int line,
const char* reason);
-void grpc_lb_policy_weak_unref(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
- const char* file, int line, const char* reason);
+void grpc_lb_policy_weak_unref(grpc_lb_policy* policy, const char* file,
+ int line, const char* reason);
#else
#define GRPC_LB_POLICY_REF(p, r) grpc_lb_policy_ref((p))
-#define GRPC_LB_POLICY_UNREF(cl, p, r) grpc_lb_policy_unref((cl), (p))
+#define GRPC_LB_POLICY_UNREF(p, r) grpc_lb_policy_unref((p))
#define GRPC_LB_POLICY_WEAK_REF(p, r) grpc_lb_policy_weak_ref((p))
-#define GRPC_LB_POLICY_WEAK_UNREF(cl, p, r) grpc_lb_policy_weak_unref((cl), (p))
+#define GRPC_LB_POLICY_WEAK_UNREF(p, r) grpc_lb_policy_weak_unref((p))
void grpc_lb_policy_ref(grpc_lb_policy* policy);
-void grpc_lb_policy_unref(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy);
+void grpc_lb_policy_unref(grpc_lb_policy* policy);
void grpc_lb_policy_weak_ref(grpc_lb_policy* policy);
-void grpc_lb_policy_weak_unref(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy);
+void grpc_lb_policy_weak_unref(grpc_lb_policy* policy);
#endif
/** called by concrete implementations to initialize the base struct */
@@ -160,7 +157,7 @@ void grpc_lb_policy_init(grpc_lb_policy* policy,
Any IO should be done under the \a interested_parties \a grpc_pollset_set
in the \a grpc_lb_policy struct. */
-int grpc_lb_policy_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
+int grpc_lb_policy_pick_locked(grpc_lb_policy* policy,
const grpc_lb_policy_pick_args* pick_args,
grpc_connected_subchannel** target,
grpc_call_context_element* context,
@@ -168,44 +165,38 @@ int grpc_lb_policy_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
/** Perform a connected subchannel ping (see \a grpc_connected_subchannel_ping)
against one of the connected subchannels managed by \a policy. */
-void grpc_lb_policy_ping_one_locked(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy* policy,
+void grpc_lb_policy_ping_one_locked(grpc_lb_policy* policy,
grpc_closure* closure);
/** Cancel picks for \a target.
The \a on_complete callback of the pending picks will be invoked with \a
*target set to NULL. */
-void grpc_lb_policy_cancel_pick_locked(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy* policy,
+void grpc_lb_policy_cancel_pick_locked(grpc_lb_policy* policy,
grpc_connected_subchannel** target,
grpc_error* error);
/** Cancel all pending picks for which their \a initial_metadata_flags (as given
in the call to \a grpc_lb_policy_pick) matches \a initial_metadata_flags_eq
when AND'd with \a initial_metadata_flags_mask */
-void grpc_lb_policy_cancel_picks_locked(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy* policy,
+void grpc_lb_policy_cancel_picks_locked(grpc_lb_policy* policy,
uint32_t initial_metadata_flags_mask,
uint32_t initial_metadata_flags_eq,
grpc_error* error);
/** Try to enter a READY connectivity state */
-void grpc_lb_policy_exit_idle_locked(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy* policy);
+void grpc_lb_policy_exit_idle_locked(grpc_lb_policy* policy);
/* Call notify when the connectivity state of a channel changes from \a *state.
* Updates \a *state with the new state of the policy */
void grpc_lb_policy_notify_on_state_change_locked(
- grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
- grpc_connectivity_state* state, grpc_closure* closure);
+ grpc_lb_policy* policy, grpc_connectivity_state* state,
+ grpc_closure* closure);
grpc_connectivity_state grpc_lb_policy_check_connectivity_locked(
- grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
- grpc_error** connectivity_error);
+ grpc_lb_policy* policy, grpc_error** connectivity_error);
/** Update \a policy with \a lb_policy_args. */
-void grpc_lb_policy_update_locked(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy* policy,
+void grpc_lb_policy_update_locked(grpc_lb_policy* policy,
const grpc_lb_policy_args* lb_policy_args);
#ifdef __cplusplus
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 6d9fadaf30..3eedb08ecc 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
@@ -25,14 +25,12 @@
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/profiling/timers.h"
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
typedef struct {
// Stats object to update.
@@ -47,28 +45,24 @@ typedef struct {
bool recv_initial_metadata_succeeded;
} call_data;
-static void on_complete_for_send(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_complete_for_send(void* arg, grpc_error* error) {
call_data* calld = (call_data*)arg;
if (error == GRPC_ERROR_NONE) {
calld->send_initial_metadata_succeeded = true;
}
- GRPC_CLOSURE_RUN(exec_ctx, calld->original_on_complete_for_send,
- GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_RUN(calld->original_on_complete_for_send, GRPC_ERROR_REF(error));
}
-static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void recv_initial_metadata_ready(void* arg, grpc_error* error) {
call_data* calld = (call_data*)arg;
if (error == GRPC_ERROR_NONE) {
calld->recv_initial_metadata_succeeded = true;
}
- GRPC_CLOSURE_RUN(exec_ctx, calld->original_recv_initial_metadata_ready,
+ GRPC_CLOSURE_RUN(calld->original_recv_initial_metadata_ready,
GRPC_ERROR_REF(error));
}
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
call_data* calld = (call_data*)elem->call_data;
// Get stats object from context and take a ref.
@@ -81,7 +75,7 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
call_data* calld = (call_data*)elem->call_data;
@@ -96,8 +90,7 @@ static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
}
static void start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* batch) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
call_data* calld = (call_data*)elem->call_data;
GPR_TIMER_BEGIN("clr_start_transport_stream_op_batch", 0);
// Intercept send_initial_metadata.
@@ -118,7 +111,7 @@ static void start_transport_stream_op_batch(
&calld->recv_initial_metadata_ready;
}
// Chain to next filter.
- grpc_call_next_op(exec_ctx, elem, batch);
+ grpc_call_next_op(elem, batch);
GPR_TIMER_END("clr_start_transport_stream_op_batch", 0);
}
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 040941a34d..46de9b45af 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
@@ -131,12 +131,12 @@ grpc_tracer_flag grpc_lb_glb_trace = GRPC_TRACER_INITIALIZER(false, "glb");
/* add lb_token of selected subchannel (address) to the call's initial
* metadata */
static grpc_error* initial_metadata_add_lb_token(
- grpc_exec_ctx* exec_ctx, grpc_metadata_batch* initial_metadata,
+ grpc_metadata_batch* initial_metadata,
grpc_linked_mdelem* lb_token_mdelem_storage, grpc_mdelem lb_token) {
GPR_ASSERT(lb_token_mdelem_storage != nullptr);
GPR_ASSERT(!GRPC_MDISNULL(lb_token));
- return grpc_metadata_batch_add_tail(exec_ctx, initial_metadata,
- lb_token_mdelem_storage, lb_token);
+ return grpc_metadata_batch_add_tail(initial_metadata, lb_token_mdelem_storage,
+ lb_token);
}
static void destroy_client_stats(void* arg) {
@@ -186,20 +186,19 @@ typedef struct wrapped_rr_closure_arg {
/* The \a on_complete closure passed as part of the pick requires keeping a
* reference to its associated round robin instance. We wrap this closure in
* order to unref the round robin instance upon its invocation */
-static void wrapped_rr_closure(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void wrapped_rr_closure(void* arg, grpc_error* error) {
wrapped_rr_closure_arg* wc_arg = (wrapped_rr_closure_arg*)arg;
GPR_ASSERT(wc_arg->wrapped_closure != nullptr);
- GRPC_CLOSURE_SCHED(exec_ctx, wc_arg->wrapped_closure, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(wc_arg->wrapped_closure, GRPC_ERROR_REF(error));
if (wc_arg->rr_policy != nullptr) {
- /* if *target is NULL, no pick has been made by the RR policy (eg, all
+ /* if *target is nullptr, 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 != nullptr) {
if (!GRPC_MDISNULL(wc_arg->lb_token)) {
- initial_metadata_add_lb_token(exec_ctx, wc_arg->initial_metadata,
+ initial_metadata_add_lb_token(wc_arg->initial_metadata,
wc_arg->lb_token_mdelem_storage,
GRPC_MDELEM_REF(wc_arg->lb_token));
} else {
@@ -221,7 +220,7 @@ static void wrapped_rr_closure(grpc_exec_ctx* exec_ctx, void* arg,
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");
+ GRPC_LB_POLICY_UNREF(wc_arg->rr_policy, "wrapped_rr_closure");
}
GPR_ASSERT(wc_arg->free_when_done != nullptr);
gpr_free(wc_arg->free_when_done);
@@ -241,8 +240,8 @@ typedef struct pending_pick {
/* original pick()'s arguments */
grpc_lb_policy_pick_args pick_args;
- /* output argument where to store the pick()ed connected subchannel, or NULL
- * upon error. */
+ /* output argument where to store the pick()ed connected subchannel, or
+ * nullptr upon error. */
grpc_connected_subchannel** target;
/* args for wrapped_on_complete */
@@ -328,8 +327,8 @@ typedef struct glb_lb_policy {
/** connectivity state of the LB channel */
grpc_connectivity_state lb_channel_connectivity;
- /** stores the deserialized response from the LB. May be NULL until one such
- * response has arrived. */
+ /** stores the deserialized response from the LB. May be nullptr until one
+ * such response has arrived. */
grpc_grpclb_serverlist* serverlist;
/** Index into serverlist for next pick.
@@ -459,9 +458,9 @@ static void* lb_token_copy(void* token) {
? nullptr
: (void*)GRPC_MDELEM_REF(grpc_mdelem{(uintptr_t)token}).payload;
}
-static void lb_token_destroy(grpc_exec_ctx* exec_ctx, void* token) {
+static void lb_token_destroy(void* token) {
if (token != nullptr) {
- GRPC_MDELEM_UNREF(exec_ctx, grpc_mdelem{(uintptr_t)token});
+ GRPC_MDELEM_UNREF(grpc_mdelem{(uintptr_t)token});
}
}
static int lb_token_cmp(void* token1, void* token2) {
@@ -497,7 +496,7 @@ static void parse_server(const grpc_grpclb_server* server,
/* Returns addresses extracted from \a serverlist. */
static grpc_lb_addresses* process_serverlist_locked(
- grpc_exec_ctx* exec_ctx, const grpc_grpclb_serverlist* serverlist) {
+ const grpc_grpclb_serverlist* serverlist) {
size_t num_valid = 0;
/* first pass: count how many are valid in order to allocate the necessary
* memory in a single block */
@@ -528,9 +527,9 @@ static grpc_lb_addresses* process_serverlist_locked(
strnlen(server->load_balance_token, lb_token_max_length);
grpc_slice lb_token_mdstr = grpc_slice_from_copied_buffer(
server->load_balance_token, lb_token_length);
- user_data = (void*)grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_LB_TOKEN,
- lb_token_mdstr)
- .payload;
+ user_data =
+ (void*)grpc_mdelem_from_slices(GRPC_MDSTR_LB_TOKEN, lb_token_mdstr)
+ .payload;
} else {
char* uri = grpc_sockaddr_to_uri(&addr);
gpr_log(GPR_INFO,
@@ -552,7 +551,7 @@ static grpc_lb_addresses* process_serverlist_locked(
/* Returns the backend addresses extracted from the given addresses */
static grpc_lb_addresses* extract_backend_addresses_locked(
- grpc_exec_ctx* exec_ctx, const grpc_lb_addresses* addresses) {
+ const grpc_lb_addresses* addresses) {
/* first pass: count the number of backend addresses */
size_t num_backends = 0;
for (size_t i = 0; i < addresses->num_addresses; ++i) {
@@ -577,8 +576,8 @@ static grpc_lb_addresses* extract_backend_addresses_locked(
}
static void update_lb_connectivity_status_locked(
- grpc_exec_ctx* exec_ctx, glb_lb_policy* glb_policy,
- grpc_connectivity_state rr_state, grpc_error* rr_state_error) {
+ glb_lb_policy* glb_policy, grpc_connectivity_state rr_state,
+ grpc_error* rr_state_error) {
const grpc_connectivity_state curr_glb_state =
grpc_connectivity_state_check(&glb_policy->state_tracker);
@@ -630,7 +629,7 @@ static void update_lb_connectivity_status_locked(
glb_policy, grpc_connectivity_state_name(rr_state),
glb_policy->rr_policy);
}
- grpc_connectivity_state_set(exec_ctx, &glb_policy->state_tracker, rr_state,
+ grpc_connectivity_state_set(&glb_policy->state_tracker, rr_state,
rr_state_error,
"update_lb_connectivity_status_locked");
}
@@ -641,9 +640,9 @@ static void update_lb_connectivity_status_locked(
* If \a force_async is true, then we will manually schedule the
* completion callback even if the pick is available immediately. */
static bool pick_from_internal_rr_locked(
- grpc_exec_ctx* exec_ctx, glb_lb_policy* glb_policy,
- const grpc_lb_policy_pick_args* pick_args, bool force_async,
- grpc_connected_subchannel** target, wrapped_rr_closure_arg* wc_arg) {
+ glb_lb_policy* glb_policy, const grpc_lb_policy_pick_args* pick_args,
+ bool force_async, grpc_connected_subchannel** target,
+ wrapped_rr_closure_arg* wc_arg) {
// Check for drops if we are not using fallback backend addresses.
if (glb_policy->serverlist != nullptr) {
// Look at the index into the serverlist to see if we should drop this call.
@@ -658,7 +657,7 @@ static bool pick_from_internal_rr_locked(
gpr_log(GPR_INFO, "[grpclb %p] Unreffing RR %p for drop", glb_policy,
wc_arg->rr_policy);
}
- GRPC_LB_POLICY_UNREF(exec_ctx, wc_arg->rr_policy, "glb_pick_sync");
+ GRPC_LB_POLICY_UNREF(wc_arg->rr_policy, "glb_pick_sync");
// Update client load reporting stats to indicate the number of
// dropped calls. Note that we have to do this here instead of in
// the client_load_reporting filter, because we do not create a
@@ -670,7 +669,7 @@ static bool pick_from_internal_rr_locked(
grpc_grpclb_client_stats_unref(wc_arg->client_stats);
if (force_async) {
GPR_ASSERT(wc_arg->wrapped_closure != nullptr);
- GRPC_CLOSURE_SCHED(exec_ctx, wc_arg->wrapped_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(wc_arg->wrapped_closure, GRPC_ERROR_NONE);
gpr_free(wc_arg->free_when_done);
return false;
}
@@ -680,7 +679,7 @@ static bool pick_from_internal_rr_locked(
}
// Pick via the RR policy.
const bool pick_done = grpc_lb_policy_pick_locked(
- exec_ctx, wc_arg->rr_policy, pick_args, target, wc_arg->context,
+ wc_arg->rr_policy, pick_args, target, wc_arg->context,
(void**)&wc_arg->lb_token, &wc_arg->wrapper_closure);
if (pick_done) {
/* synchronous grpc_lb_policy_pick call. Unref the RR policy. */
@@ -688,9 +687,9 @@ static bool pick_from_internal_rr_locked(
gpr_log(GPR_INFO, "[grpclb %p] Unreffing RR %p", glb_policy,
wc_arg->rr_policy);
}
- GRPC_LB_POLICY_UNREF(exec_ctx, wc_arg->rr_policy, "glb_pick_sync");
+ GRPC_LB_POLICY_UNREF(wc_arg->rr_policy, "glb_pick_sync");
/* add the load reporting initial metadata */
- initial_metadata_add_lb_token(exec_ctx, pick_args->initial_metadata,
+ initial_metadata_add_lb_token(pick_args->initial_metadata,
pick_args->lb_token_mdelem_storage,
GRPC_MDELEM_REF(wc_arg->lb_token));
// Pass on client stats via context. Passes ownership of the reference.
@@ -699,7 +698,7 @@ static bool pick_from_internal_rr_locked(
wc_arg->context[GRPC_GRPCLB_CLIENT_STATS].destroy = destroy_client_stats;
if (force_async) {
GPR_ASSERT(wc_arg->wrapped_closure != nullptr);
- GRPC_CLOSURE_SCHED(exec_ctx, wc_arg->wrapped_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(wc_arg->wrapped_closure, GRPC_ERROR_NONE);
gpr_free(wc_arg->free_when_done);
return false;
}
@@ -712,12 +711,11 @@ static bool pick_from_internal_rr_locked(
return pick_done;
}
-static grpc_lb_policy_args* lb_policy_args_create(grpc_exec_ctx* exec_ctx,
- glb_lb_policy* glb_policy) {
+static grpc_lb_policy_args* lb_policy_args_create(glb_lb_policy* glb_policy) {
grpc_lb_addresses* addresses;
if (glb_policy->serverlist != nullptr) {
GPR_ASSERT(glb_policy->serverlist->num_servers > 0);
- addresses = process_serverlist_locked(exec_ctx, glb_policy->serverlist);
+ addresses = process_serverlist_locked(glb_policy->serverlist);
} else {
// If rr_handover_locked() is invoked when we haven't received any
// serverlist from the balancer, we use the fallback backends returned by
@@ -737,24 +735,21 @@ static grpc_lb_policy_args* lb_policy_args_create(grpc_exec_ctx* exec_ctx,
args->args = grpc_channel_args_copy_and_add_and_remove(
glb_policy->args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), &arg,
1);
- grpc_lb_addresses_destroy(exec_ctx, addresses);
+ grpc_lb_addresses_destroy(addresses);
return args;
}
-static void lb_policy_args_destroy(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy_args* args) {
- grpc_channel_args_destroy(exec_ctx, args->args);
+static void lb_policy_args_destroy(grpc_lb_policy_args* args) {
+ grpc_channel_args_destroy(args->args);
gpr_free(args);
}
-static void glb_rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx,
- void* arg, grpc_error* error);
-static void create_rr_locked(grpc_exec_ctx* exec_ctx, glb_lb_policy* glb_policy,
+static void glb_rr_connectivity_changed_locked(void* arg, grpc_error* error);
+static void create_rr_locked(glb_lb_policy* glb_policy,
grpc_lb_policy_args* args) {
GPR_ASSERT(glb_policy->rr_policy == nullptr);
- grpc_lb_policy* new_rr_policy =
- grpc_lb_policy_create(exec_ctx, "round_robin", args);
+ grpc_lb_policy* new_rr_policy = grpc_lb_policy_create("round_robin", args);
if (new_rr_policy == nullptr) {
gpr_log(GPR_ERROR,
"[grpclb %p] Failure creating a RoundRobin policy for serverlist "
@@ -769,16 +764,14 @@ static void create_rr_locked(grpc_exec_ctx* exec_ctx, glb_lb_policy* glb_policy,
glb_policy->rr_policy = new_rr_policy;
grpc_error* rr_state_error = nullptr;
const grpc_connectivity_state rr_state =
- grpc_lb_policy_check_connectivity_locked(exec_ctx, glb_policy->rr_policy,
+ grpc_lb_policy_check_connectivity_locked(glb_policy->rr_policy,
&rr_state_error);
/* Connectivity state is a function of the RR policy updated/created */
- update_lb_connectivity_status_locked(exec_ctx, glb_policy, rr_state,
- rr_state_error);
+ update_lb_connectivity_status_locked(glb_policy, rr_state, rr_state_error);
/* Add the gRPC LB's interested_parties pollset_set to that of the newly
* created RR policy. This will make the RR policy progress upon activity on
* gRPC LB, which in turn is tied to the application's call */
- grpc_pollset_set_add_pollset_set(exec_ctx,
- glb_policy->rr_policy->interested_parties,
+ grpc_pollset_set_add_pollset_set(glb_policy->rr_policy->interested_parties,
glb_policy->base.interested_parties);
/* Allocate the data for the tracking of the new RR policy's connectivity.
@@ -793,10 +786,10 @@ static void create_rr_locked(grpc_exec_ctx* exec_ctx, glb_lb_policy* glb_policy,
/* Subscribe to changes to the connectivity of the new RR */
GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "glb_rr_connectivity_cb");
- grpc_lb_policy_notify_on_state_change_locked(exec_ctx, glb_policy->rr_policy,
+ grpc_lb_policy_notify_on_state_change_locked(glb_policy->rr_policy,
&rr_connectivity->state,
&rr_connectivity->on_change);
- grpc_lb_policy_exit_idle_locked(exec_ctx, glb_policy->rr_policy);
+ grpc_lb_policy_exit_idle_locked(glb_policy->rr_policy);
/* Update picks and pings in wait */
pending_pick* pp;
@@ -811,7 +804,7 @@ static void create_rr_locked(grpc_exec_ctx* exec_ctx, glb_lb_policy* glb_policy,
"[grpclb %p] Pending pick about to (async) PICK from RR %p",
glb_policy, glb_policy->rr_policy);
}
- pick_from_internal_rr_locked(exec_ctx, glb_policy, &pp->pick_args,
+ pick_from_internal_rr_locked(glb_policy, &pp->pick_args,
true /* force_async */, pp->target,
&pp->wrapped_on_complete_arg);
}
@@ -825,40 +818,37 @@ static void create_rr_locked(grpc_exec_ctx* exec_ctx, glb_lb_policy* glb_policy,
gpr_log(GPR_INFO, "[grpclb %p] Pending ping about to PING from RR %p",
glb_policy, glb_policy->rr_policy);
}
- grpc_lb_policy_ping_one_locked(exec_ctx, glb_policy->rr_policy,
+ grpc_lb_policy_ping_one_locked(glb_policy->rr_policy,
&pping->wrapped_notify_arg.wrapper_closure);
}
}
-/* glb_policy->rr_policy may be NULL (initial handover) */
-static void rr_handover_locked(grpc_exec_ctx* exec_ctx,
- glb_lb_policy* glb_policy) {
+/* glb_policy->rr_policy may be nullptr (initial handover) */
+static void rr_handover_locked(glb_lb_policy* glb_policy) {
if (glb_policy->shutting_down) return;
- grpc_lb_policy_args* args = lb_policy_args_create(exec_ctx, glb_policy);
+ grpc_lb_policy_args* args = lb_policy_args_create(glb_policy);
GPR_ASSERT(args != nullptr);
if (glb_policy->rr_policy != nullptr) {
if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
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);
+ grpc_lb_policy_update_locked(glb_policy->rr_policy, args);
} else {
- create_rr_locked(exec_ctx, glb_policy, args);
+ create_rr_locked(glb_policy, args);
if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
gpr_log(GPR_DEBUG, "[grpclb %p] Created new RR policy %p", glb_policy,
glb_policy->rr_policy);
}
}
- lb_policy_args_destroy(exec_ctx, args);
+ lb_policy_args_destroy(args);
}
-static void glb_rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx,
- void* arg, grpc_error* error) {
+static void glb_rr_connectivity_changed_locked(void* arg, grpc_error* error) {
rr_connectivity_data* rr_connectivity = (rr_connectivity_data*)arg;
glb_lb_policy* glb_policy = rr_connectivity->glb_policy;
if (glb_policy->shutting_down) {
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
- "glb_rr_connectivity_cb");
+ GRPC_LB_POLICY_WEAK_UNREF(&glb_policy->base, "glb_rr_connectivity_cb");
gpr_free(rr_connectivity);
return;
}
@@ -866,25 +856,22 @@ static void glb_rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx,
/* An RR policy that has transitioned into the SHUTDOWN connectivity state
* should not be considered for picks or updates: the SHUTDOWN state is a
* sink, policies can't transition back from it. .*/
- GRPC_LB_POLICY_UNREF(exec_ctx, glb_policy->rr_policy,
- "rr_connectivity_shutdown");
+ GRPC_LB_POLICY_UNREF(glb_policy->rr_policy, "rr_connectivity_shutdown");
glb_policy->rr_policy = nullptr;
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
- "glb_rr_connectivity_cb");
+ GRPC_LB_POLICY_WEAK_UNREF(&glb_policy->base, "glb_rr_connectivity_cb");
gpr_free(rr_connectivity);
return;
}
/* rr state != SHUTDOWN && !glb_policy->shutting down: biz as usual */
- update_lb_connectivity_status_locked(
- exec_ctx, glb_policy, rr_connectivity->state, GRPC_ERROR_REF(error));
+ update_lb_connectivity_status_locked(glb_policy, rr_connectivity->state,
+ GRPC_ERROR_REF(error));
/* Resubscribe. Reuse the "glb_rr_connectivity_cb" weak ref. */
- grpc_lb_policy_notify_on_state_change_locked(exec_ctx, glb_policy->rr_policy,
+ grpc_lb_policy_notify_on_state_change_locked(glb_policy->rr_policy,
&rr_connectivity->state,
&rr_connectivity->on_change);
}
-static void destroy_balancer_name(grpc_exec_ctx* exec_ctx,
- void* balancer_name) {
+static void destroy_balancer_name(void* balancer_name) {
gpr_free(balancer_name);
}
@@ -911,7 +898,7 @@ static int balancer_name_cmp_fn(void* a, void* b) {
* above the grpclb policy.
* - \a args: other args inherited from the grpclb policy. */
static grpc_channel_args* build_lb_channel_args(
- grpc_exec_ctx* exec_ctx, const grpc_lb_addresses* addresses,
+ const grpc_lb_addresses* addresses,
grpc_fake_resolver_response_generator* response_generator,
const grpc_channel_args* args) {
size_t num_grpclb_addrs = 0;
@@ -954,7 +941,7 @@ static grpc_channel_args* build_lb_channel_args(
gpr_free(targets_info_entries);
grpc_channel_args* lb_channel_args =
- grpc_lb_policy_grpclb_build_lb_channel_args(exec_ctx, targets_info,
+ grpc_lb_policy_grpclb_build_lb_channel_args(targets_info,
response_generator, args);
grpc_arg lb_channel_addresses_arg =
@@ -962,34 +949,34 @@ static grpc_channel_args* build_lb_channel_args(
grpc_channel_args* result = grpc_channel_args_copy_and_add(
lb_channel_args, &lb_channel_addresses_arg, 1);
- grpc_slice_hash_table_unref(exec_ctx, targets_info);
- grpc_channel_args_destroy(exec_ctx, lb_channel_args);
- grpc_lb_addresses_destroy(exec_ctx, lb_addresses);
+ grpc_slice_hash_table_unref(targets_info);
+ grpc_channel_args_destroy(lb_channel_args);
+ grpc_lb_addresses_destroy(lb_addresses);
return result;
}
-static void glb_destroy(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
+static void glb_destroy(grpc_lb_policy* pol) {
glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
GPR_ASSERT(glb_policy->pending_picks == nullptr);
GPR_ASSERT(glb_policy->pending_pings == nullptr);
gpr_free((void*)glb_policy->server_name);
- grpc_channel_args_destroy(exec_ctx, glb_policy->args);
+ grpc_channel_args_destroy(glb_policy->args);
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);
+ grpc_connectivity_state_destroy(&glb_policy->state_tracker);
if (glb_policy->serverlist != nullptr) {
grpc_grpclb_destroy_serverlist(glb_policy->serverlist);
}
if (glb_policy->fallback_backend_addresses != nullptr) {
- grpc_lb_addresses_destroy(exec_ctx, glb_policy->fallback_backend_addresses);
+ grpc_lb_addresses_destroy(glb_policy->fallback_backend_addresses);
}
grpc_fake_resolver_response_generator_unref(glb_policy->response_generator);
grpc_subchannel_index_unref();
gpr_free(glb_policy);
}
-static void glb_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
+static void glb_shutdown_locked(grpc_lb_policy* pol) {
glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
glb_policy->shutting_down = true;
@@ -1007,11 +994,11 @@ static void glb_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
/* lb_on_server_status_received will pick up the cancel and clean up */
}
if (glb_policy->retry_timer_active) {
- grpc_timer_cancel(exec_ctx, &glb_policy->lb_call_retry_timer);
+ grpc_timer_cancel(&glb_policy->lb_call_retry_timer);
glb_policy->retry_timer_active = false;
}
if (glb_policy->fallback_timer_active) {
- grpc_timer_cancel(exec_ctx, &glb_policy->lb_fallback_timer);
+ grpc_timer_cancel(&glb_policy->lb_fallback_timer);
glb_policy->fallback_timer_active = false;
}
@@ -1020,7 +1007,7 @@ static void glb_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
pending_ping* pping = glb_policy->pending_pings;
glb_policy->pending_pings = nullptr;
if (glb_policy->rr_policy != nullptr) {
- GRPC_LB_POLICY_UNREF(exec_ctx, glb_policy->rr_policy, "glb_shutdown");
+ GRPC_LB_POLICY_UNREF(glb_policy->rr_policy, "glb_shutdown");
}
// We destroy the LB channel here because
// glb_lb_channel_on_connectivity_changed_cb needs a valid glb_policy
@@ -1031,14 +1018,14 @@ static void glb_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
glb_policy->lb_channel = nullptr;
}
grpc_connectivity_state_set(
- exec_ctx, &glb_policy->state_tracker, GRPC_CHANNEL_SHUTDOWN,
+ &glb_policy->state_tracker, GRPC_CHANNEL_SHUTDOWN,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Shutdown"), "glb_shutdown");
while (pp != nullptr) {
pending_pick* next = pp->next;
*pp->target = nullptr;
GRPC_CLOSURE_SCHED(
- exec_ctx, &pp->wrapped_on_complete_arg.wrapper_closure,
+ &pp->wrapped_on_complete_arg.wrapper_closure,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Shutdown"));
gpr_free(pp);
pp = next;
@@ -1047,7 +1034,7 @@ static void glb_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
while (pping != nullptr) {
pending_ping* next = pping->next;
GRPC_CLOSURE_SCHED(
- exec_ctx, &pping->wrapped_notify_arg.wrapper_closure,
+ &pping->wrapped_notify_arg.wrapper_closure,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Shutdown"));
gpr_free(pping);
pping = next;
@@ -1063,8 +1050,8 @@ static void glb_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
// pick needs also be cancelled by the RR instance.
// - Otherwise, without an RR instance, picks stay pending at this policy's
// level (grpclb), inside the glb_policy->pending_picks list. To cancel these,
-// we invoke the completion closure and set *target to NULL right here.
-static void glb_cancel_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
+// we invoke the completion closure and set *target to nullptr right here.
+static void glb_cancel_pick_locked(grpc_lb_policy* pol,
grpc_connected_subchannel** target,
grpc_error* error) {
glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
@@ -1074,7 +1061,7 @@ static void glb_cancel_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
pending_pick* next = pp->next;
if (pp->target == target) {
*target = nullptr;
- GRPC_CLOSURE_SCHED(exec_ctx, &pp->wrapped_on_complete_arg.wrapper_closure,
+ GRPC_CLOSURE_SCHED(&pp->wrapped_on_complete_arg.wrapper_closure,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Pick Cancelled", &error, 1));
} else {
@@ -1084,7 +1071,7 @@ static void glb_cancel_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
pp = next;
}
if (glb_policy->rr_policy != nullptr) {
- grpc_lb_policy_cancel_pick_locked(exec_ctx, glb_policy->rr_policy, target,
+ grpc_lb_policy_cancel_pick_locked(glb_policy->rr_policy, target,
GRPC_ERROR_REF(error));
}
GRPC_ERROR_UNREF(error);
@@ -1099,9 +1086,8 @@ static void glb_cancel_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
// pick needs also be cancelled by the RR instance.
// - Otherwise, without an RR instance, picks stay pending at this policy's
// level (grpclb), inside the glb_policy->pending_picks list. To cancel these,
-// we invoke the completion closure and set *target to NULL right here.
-static void glb_cancel_picks_locked(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy* pol,
+// we invoke the completion closure and set *target to nullptr right here.
+static void glb_cancel_picks_locked(grpc_lb_policy* pol,
uint32_t initial_metadata_flags_mask,
uint32_t initial_metadata_flags_eq,
grpc_error* error) {
@@ -1112,7 +1098,7 @@ static void glb_cancel_picks_locked(grpc_exec_ctx* exec_ctx,
pending_pick* next = pp->next;
if ((pp->pick_args.initial_metadata_flags & initial_metadata_flags_mask) ==
initial_metadata_flags_eq) {
- GRPC_CLOSURE_SCHED(exec_ctx, &pp->wrapped_on_complete_arg.wrapper_closure,
+ GRPC_CLOSURE_SCHED(&pp->wrapped_on_complete_arg.wrapper_closure,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Pick Cancelled", &error, 1));
} else {
@@ -1123,52 +1109,49 @@ static void glb_cancel_picks_locked(grpc_exec_ctx* exec_ctx,
}
if (glb_policy->rr_policy != nullptr) {
grpc_lb_policy_cancel_picks_locked(
- exec_ctx, glb_policy->rr_policy, initial_metadata_flags_mask,
+ glb_policy->rr_policy, initial_metadata_flags_mask,
initial_metadata_flags_eq, GRPC_ERROR_REF(error));
}
GRPC_ERROR_UNREF(error);
}
-static void lb_on_fallback_timer_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error);
-static void query_for_backends_locked(grpc_exec_ctx* exec_ctx,
- glb_lb_policy* glb_policy);
-static void start_picking_locked(grpc_exec_ctx* exec_ctx,
- glb_lb_policy* glb_policy) {
+static void lb_on_fallback_timer_locked(void* arg, grpc_error* error);
+static void query_for_backends_locked(glb_lb_policy* glb_policy);
+static void start_picking_locked(glb_lb_policy* glb_policy) {
/* start a timer to fall back */
if (glb_policy->lb_fallback_timeout_ms > 0 &&
glb_policy->serverlist == nullptr && !glb_policy->fallback_timer_active) {
grpc_millis deadline =
- grpc_exec_ctx_now(exec_ctx) + glb_policy->lb_fallback_timeout_ms;
+ grpc_core::ExecCtx::Get()->Now() + glb_policy->lb_fallback_timeout_ms;
GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "grpclb_fallback_timer");
GRPC_CLOSURE_INIT(&glb_policy->lb_on_fallback, lb_on_fallback_timer_locked,
glb_policy,
grpc_combiner_scheduler(glb_policy->base.combiner));
glb_policy->fallback_timer_active = true;
- grpc_timer_init(exec_ctx, &glb_policy->lb_fallback_timer, deadline,
+ grpc_timer_init(&glb_policy->lb_fallback_timer, deadline,
&glb_policy->lb_on_fallback);
}
glb_policy->started_picking = true;
grpc_backoff_reset(&glb_policy->lb_call_backoff_state);
- query_for_backends_locked(exec_ctx, glb_policy);
+ query_for_backends_locked(glb_policy);
}
-static void glb_exit_idle_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
+static void glb_exit_idle_locked(grpc_lb_policy* pol) {
glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
if (!glb_policy->started_picking) {
- start_picking_locked(exec_ctx, glb_policy);
+ start_picking_locked(glb_policy);
}
}
-static int glb_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
+static int glb_pick_locked(grpc_lb_policy* pol,
const grpc_lb_policy_pick_args* pick_args,
grpc_connected_subchannel** target,
grpc_call_context_element* context, void** user_data,
grpc_closure* on_complete) {
if (pick_args->lb_token_mdelem_storage == nullptr) {
*target = nullptr;
- GRPC_CLOSURE_SCHED(exec_ctx, on_complete,
+ GRPC_CLOSURE_SCHED(on_complete,
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"No mdelem storage for the LB token. Load reporting "
"won't work without it. Failing"));
@@ -1178,8 +1161,8 @@ static int glb_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
bool pick_done = false;
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, nullptr);
+ grpc_lb_policy_check_connectivity_locked(glb_policy->rr_policy,
+ nullptr);
// The glb_policy->rr_policy may have transitioned to SHUTDOWN but the
// callback registered to capture this event
// (glb_rr_connectivity_changed_locked) may not have been invoked yet. We
@@ -1216,11 +1199,10 @@ static int glb_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
wc_arg->initial_metadata = pick_args->initial_metadata;
wc_arg->free_when_done = wc_arg;
wc_arg->glb_policy = pol;
- pick_done =
- pick_from_internal_rr_locked(exec_ctx, glb_policy, pick_args,
- false /* force_async */, target, wc_arg);
+ pick_done = pick_from_internal_rr_locked(
+ glb_policy, pick_args, false /* force_async */, target, wc_arg);
}
- } else { // glb_policy->rr_policy == NULL
+ } else { // glb_policy->rr_policy == nullptr
if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
gpr_log(GPR_DEBUG,
"[grpclb %p] No RR policy. Adding to grpclb's pending picks",
@@ -1229,7 +1211,7 @@ static int glb_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
add_pending_pick(&glb_policy->pending_picks, pick_args, target, context,
on_complete);
if (!glb_policy->started_picking) {
- start_picking_locked(exec_ctx, glb_policy);
+ start_picking_locked(glb_policy);
}
pick_done = false;
}
@@ -1237,37 +1219,33 @@ static int glb_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
}
static grpc_connectivity_state glb_check_connectivity_locked(
- grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
- grpc_error** connectivity_error) {
+ grpc_lb_policy* pol, grpc_error** connectivity_error) {
glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
return grpc_connectivity_state_get(&glb_policy->state_tracker,
connectivity_error);
}
-static void glb_ping_one_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
- grpc_closure* closure) {
+static void glb_ping_one_locked(grpc_lb_policy* pol, grpc_closure* closure) {
glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
if (glb_policy->rr_policy) {
- grpc_lb_policy_ping_one_locked(exec_ctx, glb_policy->rr_policy, closure);
+ grpc_lb_policy_ping_one_locked(glb_policy->rr_policy, closure);
} else {
add_pending_ping(&glb_policy->pending_pings, closure);
if (!glb_policy->started_picking) {
- start_picking_locked(exec_ctx, glb_policy);
+ start_picking_locked(glb_policy);
}
}
}
-static void glb_notify_on_state_change_locked(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy* pol,
+static void glb_notify_on_state_change_locked(grpc_lb_policy* pol,
grpc_connectivity_state* current,
grpc_closure* notify) {
glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
- grpc_connectivity_state_notify_on_state_change(
- exec_ctx, &glb_policy->state_tracker, current, notify);
+ grpc_connectivity_state_notify_on_state_change(&glb_policy->state_tracker,
+ current, notify);
}
-static void lb_call_on_retry_timer_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void lb_call_on_retry_timer_locked(void* arg, grpc_error* error) {
glb_lb_policy* glb_policy = (glb_lb_policy*)arg;
glb_policy->retry_timer_active = false;
if (!glb_policy->shutting_down && glb_policy->lb_call == nullptr &&
@@ -1275,28 +1253,26 @@ static void lb_call_on_retry_timer_locked(grpc_exec_ctx* exec_ctx, void* arg,
if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
gpr_log(GPR_INFO, "[grpclb %p] Restarting call to LB server", glb_policy);
}
- query_for_backends_locked(exec_ctx, glb_policy);
+ query_for_backends_locked(glb_policy);
}
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base, "grpclb_retry_timer");
+ GRPC_LB_POLICY_WEAK_UNREF(&glb_policy->base, "grpclb_retry_timer");
}
-static void maybe_restart_lb_call(grpc_exec_ctx* exec_ctx,
- glb_lb_policy* glb_policy) {
+static void maybe_restart_lb_call(glb_lb_policy* glb_policy) {
if (glb_policy->started_picking && glb_policy->updating_lb_call) {
if (glb_policy->retry_timer_active) {
- grpc_timer_cancel(exec_ctx, &glb_policy->lb_call_retry_timer);
+ grpc_timer_cancel(&glb_policy->lb_call_retry_timer);
}
- if (!glb_policy->shutting_down) start_picking_locked(exec_ctx, glb_policy);
+ if (!glb_policy->shutting_down) start_picking_locked(glb_policy);
glb_policy->updating_lb_call = false;
} else if (!glb_policy->shutting_down) {
/* if we aren't shutting down, restart the LB client call after some time */
- grpc_millis next_try =
- grpc_backoff_step(exec_ctx, &glb_policy->lb_call_backoff_state)
- .next_attempt_start_time;
+ grpc_millis next_try = grpc_backoff_step(&glb_policy->lb_call_backoff_state)
+ .next_attempt_start_time;
if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
gpr_log(GPR_DEBUG, "[grpclb %p] Connection to LB server lost...",
glb_policy);
- grpc_millis timeout = next_try - grpc_exec_ctx_now(exec_ctx);
+ grpc_millis timeout = next_try - grpc_core::ExecCtx::Get()->Now();
if (timeout > 0) {
gpr_log(GPR_DEBUG,
"[grpclb %p] ... retry_timer_active in %" PRIuPTR "ms.",
@@ -1311,40 +1287,37 @@ static void maybe_restart_lb_call(grpc_exec_ctx* exec_ctx,
lb_call_on_retry_timer_locked, glb_policy,
grpc_combiner_scheduler(glb_policy->base.combiner));
glb_policy->retry_timer_active = true;
- grpc_timer_init(exec_ctx, &glb_policy->lb_call_retry_timer, next_try,
+ grpc_timer_init(&glb_policy->lb_call_retry_timer, next_try,
&glb_policy->lb_on_call_retry);
}
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
+ GRPC_LB_POLICY_WEAK_UNREF(&glb_policy->base,
"lb_on_server_status_received_locked");
}
-static void send_client_load_report_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error);
+static void send_client_load_report_locked(void* arg, grpc_error* error);
-static void schedule_next_client_load_report(grpc_exec_ctx* exec_ctx,
- glb_lb_policy* glb_policy) {
+static void schedule_next_client_load_report(glb_lb_policy* glb_policy) {
const grpc_millis next_client_load_report_time =
- grpc_exec_ctx_now(exec_ctx) + glb_policy->client_stats_report_interval;
+ grpc_core::ExecCtx::Get()->Now() +
+ glb_policy->client_stats_report_interval;
GRPC_CLOSURE_INIT(&glb_policy->client_load_report_closure,
send_client_load_report_locked, glb_policy,
grpc_combiner_scheduler(glb_policy->base.combiner));
- grpc_timer_init(exec_ctx, &glb_policy->client_load_report_timer,
+ grpc_timer_init(&glb_policy->client_load_report_timer,
next_client_load_report_time,
&glb_policy->client_load_report_closure);
}
-static void client_load_report_done_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void client_load_report_done_locked(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 = 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");
+ GRPC_LB_POLICY_WEAK_UNREF(&glb_policy->base, "client_load_report");
return;
}
- schedule_next_client_load_report(exec_ctx, glb_policy);
+ schedule_next_client_load_report(glb_policy);
}
static bool load_report_counters_are_zero(grpc_grpclb_request* request) {
@@ -1359,15 +1332,13 @@ static bool load_report_counters_are_zero(grpc_grpclb_request* request) {
(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) {
+static void send_client_load_report_locked(void* arg, grpc_error* error) {
glb_lb_policy* glb_policy = (glb_lb_policy*)arg;
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");
+ GRPC_LB_POLICY_WEAK_UNREF(&glb_policy->base, "client_load_report");
if (glb_policy->lb_call == nullptr) {
- maybe_restart_lb_call(exec_ctx, glb_policy);
+ maybe_restart_lb_call(glb_policy);
}
return;
}
@@ -1380,7 +1351,7 @@ static void send_client_load_report_locked(grpc_exec_ctx* exec_ctx, void* arg,
if (load_report_counters_are_zero(request)) {
if (glb_policy->last_client_load_report_counters_were_zero) {
grpc_grpclb_request_destroy(request);
- schedule_next_client_load_report(exec_ctx, glb_policy);
+ schedule_next_client_load_report(glb_policy);
return;
}
glb_policy->last_client_load_report_counters_were_zero = true;
@@ -1390,7 +1361,7 @@ static void send_client_load_report_locked(grpc_exec_ctx* exec_ctx, void* arg,
grpc_slice request_payload_slice = grpc_grpclb_request_encode(request);
glb_policy->client_load_report_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_slice_unref_internal(exec_ctx, request_payload_slice);
+ grpc_slice_unref_internal(request_payload_slice);
grpc_grpclb_request_destroy(request);
// Send load report message.
grpc_op op;
@@ -1401,20 +1372,16 @@ static void send_client_load_report_locked(grpc_exec_ctx* exec_ctx, void* arg,
client_load_report_done_locked, glb_policy,
grpc_combiner_scheduler(glb_policy->base.combiner));
grpc_call_error call_error = grpc_call_start_batch_and_execute(
- exec_ctx, glb_policy->lb_call, &op, 1,
- &glb_policy->client_load_report_closure);
+ glb_policy->lb_call, &op, 1, &glb_policy->client_load_report_closure);
if (call_error != GRPC_CALL_OK) {
gpr_log(GPR_ERROR, "[grpclb %p] call_error=%d", glb_policy, call_error);
GPR_ASSERT(GRPC_CALL_OK == call_error);
}
}
-static void lb_on_server_status_received_locked(grpc_exec_ctx* exec_ctx,
- void* arg, grpc_error* error);
-static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error);
-static void lb_call_init_locked(grpc_exec_ctx* exec_ctx,
- glb_lb_policy* glb_policy) {
+static void lb_on_server_status_received_locked(void* arg, grpc_error* error);
+static void lb_on_response_received_locked(void* arg, grpc_error* error);
+static void lb_call_init_locked(glb_lb_policy* glb_policy) {
GPR_ASSERT(glb_policy->server_name != nullptr);
GPR_ASSERT(glb_policy->server_name[0] != '\0');
GPR_ASSERT(glb_policy->lb_call == nullptr);
@@ -1427,13 +1394,13 @@ static void lb_call_init_locked(grpc_exec_ctx* exec_ctx,
grpc_millis deadline =
glb_policy->lb_call_timeout_ms == 0
? GRPC_MILLIS_INF_FUTURE
- : grpc_exec_ctx_now(exec_ctx) + glb_policy->lb_call_timeout_ms;
+ : grpc_core::ExecCtx::Get()->Now() + glb_policy->lb_call_timeout_ms;
glb_policy->lb_call = grpc_channel_create_pollset_set_call(
- exec_ctx, glb_policy->lb_channel, nullptr, GRPC_PROPAGATE_DEFAULTS,
+ glb_policy->lb_channel, nullptr, GRPC_PROPAGATE_DEFAULTS,
glb_policy->base.interested_parties,
GRPC_MDSTR_SLASH_GRPC_DOT_LB_DOT_V1_DOT_LOADBALANCER_SLASH_BALANCELOAD,
&host, deadline, nullptr);
- grpc_slice_unref_internal(exec_ctx, host);
+ grpc_slice_unref_internal(host);
if (glb_policy->client_stats != nullptr) {
grpc_grpclb_client_stats_unref(glb_policy->client_stats);
@@ -1448,7 +1415,7 @@ static void lb_call_init_locked(grpc_exec_ctx* exec_ctx,
grpc_slice request_payload_slice = grpc_grpclb_request_encode(request);
glb_policy->lb_request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_slice_unref_internal(exec_ctx, request_payload_slice);
+ grpc_slice_unref_internal(request_payload_slice);
grpc_grpclb_request_destroy(request);
GRPC_CLOSURE_INIT(&glb_policy->lb_on_server_status_received,
@@ -1469,8 +1436,7 @@ static void lb_call_init_locked(grpc_exec_ctx* exec_ctx,
glb_policy->last_client_load_report_counters_were_zero = false;
}
-static void lb_call_destroy_locked(grpc_exec_ctx* exec_ctx,
- glb_lb_policy* glb_policy) {
+static void lb_call_destroy_locked(glb_lb_policy* glb_policy) {
GPR_ASSERT(glb_policy->lb_call != nullptr);
grpc_call_unref(glb_policy->lb_call);
glb_policy->lb_call = nullptr;
@@ -1479,22 +1445,21 @@ static void lb_call_destroy_locked(grpc_exec_ctx* exec_ctx,
grpc_metadata_array_destroy(&glb_policy->lb_trailing_metadata_recv);
grpc_byte_buffer_destroy(glb_policy->lb_request_payload);
- grpc_slice_unref_internal(exec_ctx, glb_policy->lb_call_status_details);
+ grpc_slice_unref_internal(glb_policy->lb_call_status_details);
if (glb_policy->client_load_report_timer_pending) {
- grpc_timer_cancel(exec_ctx, &glb_policy->client_load_report_timer);
+ grpc_timer_cancel(&glb_policy->client_load_report_timer);
}
}
/*
* Auxiliary functions and LB client callbacks.
*/
-static void query_for_backends_locked(grpc_exec_ctx* exec_ctx,
- glb_lb_policy* glb_policy) {
+static void query_for_backends_locked(glb_lb_policy* glb_policy) {
GPR_ASSERT(glb_policy->lb_channel != nullptr);
if (glb_policy->shutting_down) return;
- lb_call_init_locked(exec_ctx, glb_policy);
+ lb_call_init_locked(glb_policy);
if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
gpr_log(GPR_INFO,
@@ -1525,8 +1490,8 @@ static void query_for_backends_locked(grpc_exec_ctx* exec_ctx,
op->flags = 0;
op->reserved = nullptr;
op++;
- call_error = grpc_call_start_batch_and_execute(
- exec_ctx, glb_policy->lb_call, ops, (size_t)(op - ops), nullptr);
+ call_error = grpc_call_start_batch_and_execute(glb_policy->lb_call, ops,
+ (size_t)(op - ops), nullptr);
GPR_ASSERT(GRPC_CALL_OK == call_error);
op = ops;
@@ -1544,7 +1509,7 @@ static void query_for_backends_locked(grpc_exec_ctx* exec_ctx,
GRPC_LB_POLICY_WEAK_REF(&glb_policy->base,
"lb_on_server_status_received_locked");
call_error = grpc_call_start_batch_and_execute(
- exec_ctx, glb_policy->lb_call, ops, (size_t)(op - ops),
+ glb_policy->lb_call, ops, (size_t)(op - ops),
&glb_policy->lb_on_server_status_received);
GPR_ASSERT(GRPC_CALL_OK == call_error);
@@ -1558,13 +1523,12 @@ static void query_for_backends_locked(grpc_exec_ctx* exec_ctx,
* lb_on_response_received_locked */
GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "lb_on_response_received_locked");
call_error = grpc_call_start_batch_and_execute(
- exec_ctx, glb_policy->lb_call, ops, (size_t)(op - ops),
+ glb_policy->lb_call, ops, (size_t)(op - ops),
&glb_policy->lb_on_response_received);
GPR_ASSERT(GRPC_CALL_OK == call_error);
}
-static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void lb_on_response_received_locked(void* arg, grpc_error* error) {
glb_lb_policy* glb_policy = (glb_lb_policy*)arg;
grpc_op ops[2];
memset(ops, 0, sizeof(ops));
@@ -1598,7 +1562,7 @@ static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg,
* send_client_load_report_locked() */
glb_policy->client_load_report_timer_pending = true;
GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "client_load_report");
- schedule_next_client_load_report(exec_ctx, glb_policy);
+ schedule_next_client_load_report(glb_policy);
} else if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
gpr_log(GPR_INFO,
"[grpclb %p] Received initial LB response message; client load "
@@ -1643,11 +1607,10 @@ static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg,
grpc_grpclb_destroy_serverlist(glb_policy->serverlist);
} else {
/* or dispose of the fallback */
- grpc_lb_addresses_destroy(exec_ctx,
- glb_policy->fallback_backend_addresses);
+ grpc_lb_addresses_destroy(glb_policy->fallback_backend_addresses);
glb_policy->fallback_backend_addresses = nullptr;
if (glb_policy->fallback_timer_active) {
- grpc_timer_cancel(exec_ctx, &glb_policy->lb_fallback_timer);
+ grpc_timer_cancel(&glb_policy->lb_fallback_timer);
glb_policy->fallback_timer_active = false;
}
}
@@ -1656,7 +1619,7 @@ static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg,
* update or in glb_destroy() */
glb_policy->serverlist = serverlist;
glb_policy->serverlist_index = 0;
- rr_handover_locked(exec_ctx, glb_policy);
+ rr_handover_locked(glb_policy);
}
} else {
if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
@@ -1666,14 +1629,14 @@ static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg,
}
grpc_grpclb_destroy_serverlist(serverlist);
}
- } else { /* serverlist == NULL */
+ } else { /* serverlist == nullptr */
gpr_log(GPR_ERROR,
"[grpclb %p] Invalid LB response received: '%s'. Ignoring.",
glb_policy,
grpc_dump_slice(response_slice, GPR_DUMP_ASCII | GPR_DUMP_HEX));
}
}
- grpc_slice_unref_internal(exec_ctx, response_slice);
+ grpc_slice_unref_internal(response_slice);
if (!glb_policy->shutting_down) {
/* keep listening for serverlist updates */
op->op = GRPC_OP_RECV_MESSAGE;
@@ -1684,23 +1647,22 @@ static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg,
/* reuse the "lb_on_response_received_locked" weak ref taken in
* query_for_backends_locked() */
const grpc_call_error call_error = grpc_call_start_batch_and_execute(
- exec_ctx, glb_policy->lb_call, ops, (size_t)(op - ops),
+ glb_policy->lb_call, ops, (size_t)(op - ops),
&glb_policy->lb_on_response_received); /* loop */
GPR_ASSERT(GRPC_CALL_OK == call_error);
} else {
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
+ GRPC_LB_POLICY_WEAK_UNREF(&glb_policy->base,
"lb_on_response_received_locked_shutdown");
}
} else { /* empty payload: call cancelled. */
/* dispose of the "lb_on_response_received_locked" weak ref taken in
* query_for_backends_locked() and reused in every reception loop */
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
+ GRPC_LB_POLICY_WEAK_UNREF(&glb_policy->base,
"lb_on_response_received_locked_empty_payload");
}
}
-static void lb_on_fallback_timer_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void lb_on_fallback_timer_locked(void* arg, grpc_error* error) {
glb_lb_policy* glb_policy = (glb_lb_policy*)arg;
glb_policy->fallback_timer_active = false;
/* If we receive a serverlist after the timer fires but before this callback
@@ -1713,15 +1675,13 @@ static void lb_on_fallback_timer_locked(grpc_exec_ctx* exec_ctx, void* arg,
glb_policy);
}
GPR_ASSERT(glb_policy->fallback_backend_addresses != nullptr);
- rr_handover_locked(exec_ctx, glb_policy);
+ rr_handover_locked(glb_policy);
}
}
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
- "grpclb_fallback_timer");
+ GRPC_LB_POLICY_WEAK_UNREF(&glb_policy->base, "grpclb_fallback_timer");
}
-static void lb_on_server_status_received_locked(grpc_exec_ctx* exec_ctx,
- void* arg, grpc_error* error) {
+static void lb_on_server_status_received_locked(void* arg, grpc_error* error) {
glb_lb_policy* glb_policy = (glb_lb_policy*)arg;
GPR_ASSERT(glb_policy->lb_call != nullptr);
if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
@@ -1735,29 +1695,28 @@ static void lb_on_server_status_received_locked(grpc_exec_ctx* exec_ctx,
gpr_free(status_details);
}
/* We need to perform cleanups no matter what. */
- lb_call_destroy_locked(exec_ctx, glb_policy);
+ lb_call_destroy_locked(glb_policy);
// If the load report timer is still pending, we wait for it to be
// called before restarting the call. Otherwise, we restart the call
// here.
if (!glb_policy->client_load_report_timer_pending) {
- maybe_restart_lb_call(exec_ctx, glb_policy);
+ maybe_restart_lb_call(glb_policy);
}
}
-static void fallback_update_locked(grpc_exec_ctx* exec_ctx,
- glb_lb_policy* glb_policy,
+static void fallback_update_locked(glb_lb_policy* glb_policy,
const grpc_lb_addresses* addresses) {
GPR_ASSERT(glb_policy->fallback_backend_addresses != nullptr);
- grpc_lb_addresses_destroy(exec_ctx, glb_policy->fallback_backend_addresses);
+ grpc_lb_addresses_destroy(glb_policy->fallback_backend_addresses);
glb_policy->fallback_backend_addresses =
- extract_backend_addresses_locked(exec_ctx, addresses);
+ extract_backend_addresses_locked(addresses);
if (glb_policy->started_picking && glb_policy->lb_fallback_timeout_ms > 0 &&
!glb_policy->fallback_timer_active) {
- rr_handover_locked(exec_ctx, glb_policy);
+ rr_handover_locked(glb_policy);
}
}
-static void glb_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
+static void glb_update_locked(grpc_lb_policy* policy,
const grpc_lb_policy_args* args) {
glb_lb_policy* glb_policy = (glb_lb_policy*)policy;
const grpc_arg* arg =
@@ -1767,7 +1726,7 @@ static void glb_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
// If we don't have a current channel to the LB, go into TRANSIENT
// FAILURE.
grpc_connectivity_state_set(
- exec_ctx, &glb_policy->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ &glb_policy->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing update in args"),
"glb_update_missing");
} else {
@@ -1784,16 +1743,16 @@ static void glb_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
// If a non-empty serverlist hasn't been received from the balancer,
// propagate the update to fallback_backend_addresses.
if (glb_policy->serverlist == nullptr) {
- fallback_update_locked(exec_ctx, glb_policy, addresses);
+ fallback_update_locked(glb_policy, addresses);
}
GPR_ASSERT(glb_policy->lb_channel != nullptr);
// Propagate updates to the LB channel (pick_first) through the fake
// resolver.
grpc_channel_args* lb_channel_args = build_lb_channel_args(
- exec_ctx, addresses, glb_policy->response_generator, args->args);
+ addresses, glb_policy->response_generator, args->args);
grpc_fake_resolver_response_generator_set_response(
- exec_ctx, glb_policy->response_generator, lb_channel_args);
- grpc_channel_args_destroy(exec_ctx, lb_channel_args);
+ glb_policy->response_generator, lb_channel_args);
+ grpc_channel_args_destroy(lb_channel_args);
// Start watching the LB channel connectivity for connection, if not
// already doing so.
if (!glb_policy->watching_lb_channel) {
@@ -1805,7 +1764,7 @@ static void glb_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
glb_policy->watching_lb_channel = true;
GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "watch_lb_channel_connectivity");
grpc_client_channel_watch_connectivity_state(
- exec_ctx, client_channel_elem,
+ client_channel_elem,
grpc_polling_entity_create_from_pollset_set(
glb_policy->base.interested_parties),
&glb_policy->lb_channel_connectivity,
@@ -1816,8 +1775,7 @@ static void glb_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
// Invoked as part of the update process. It continues watching the LB channel
// until it shuts down or becomes READY. It's invoked even if the LB channel
// stayed READY throughout the update (for example if the update is identical).
-static void glb_lb_channel_on_connectivity_changed_cb(grpc_exec_ctx* exec_ctx,
- void* arg,
+static void glb_lb_channel_on_connectivity_changed_cb(void* arg,
grpc_error* error) {
glb_lb_policy* glb_policy = (glb_lb_policy*)arg;
if (glb_policy->shutting_down) goto done;
@@ -1833,7 +1791,7 @@ static void glb_lb_channel_on_connectivity_changed_cb(grpc_exec_ctx* exec_ctx,
grpc_channel_get_channel_stack(glb_policy->lb_channel));
GPR_ASSERT(client_channel_elem->filter == &grpc_client_channel_filter);
grpc_client_channel_watch_connectivity_state(
- exec_ctx, client_channel_elem,
+ client_channel_elem,
grpc_polling_entity_create_from_pollset_set(
glb_policy->base.interested_parties),
&glb_policy->lb_channel_connectivity,
@@ -1852,16 +1810,16 @@ static void glb_lb_channel_on_connectivity_changed_cb(grpc_exec_ctx* exec_ctx,
// lb_call.
} else if (glb_policy->started_picking && !glb_policy->shutting_down) {
if (glb_policy->retry_timer_active) {
- grpc_timer_cancel(exec_ctx, &glb_policy->lb_call_retry_timer);
+ grpc_timer_cancel(&glb_policy->lb_call_retry_timer);
glb_policy->retry_timer_active = false;
}
- start_picking_locked(exec_ctx, glb_policy);
+ start_picking_locked(glb_policy);
}
/* fallthrough */
case GRPC_CHANNEL_SHUTDOWN:
done:
glb_policy->watching_lb_channel = false;
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
+ GRPC_LB_POLICY_WEAK_UNREF(&glb_policy->base,
"watch_lb_channel_connectivity_cb_shutdown");
break;
}
@@ -1880,8 +1838,7 @@ static const grpc_lb_policy_vtable glb_lb_policy_vtable = {
glb_notify_on_state_change_locked,
glb_update_locked};
-static grpc_lb_policy* glb_create(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy_factory* factory,
+static grpc_lb_policy* glb_create(grpc_lb_policy_factory* factory,
grpc_lb_policy_args* args) {
/* Count the number of gRPC-LB addresses. There must be at least one. */
const grpc_arg* arg =
@@ -1902,7 +1859,7 @@ static grpc_lb_policy* glb_create(grpc_exec_ctx* exec_ctx,
arg = grpc_channel_args_find(args->args, GRPC_ARG_SERVER_URI);
GPR_ASSERT(arg != nullptr);
GPR_ASSERT(arg->type == GRPC_ARG_STRING);
- grpc_uri* uri = grpc_uri_parse(exec_ctx, arg->value.string, true);
+ grpc_uri* uri = grpc_uri_parse(arg->value.string, true);
GPR_ASSERT(uri->path[0] != '\0');
glb_policy->server_name =
gpr_strdup(uri->path[0] == '/' ? uri->path + 1 : uri->path);
@@ -1935,26 +1892,26 @@ static grpc_lb_policy* glb_create(grpc_exec_ctx* exec_ctx,
/* Extract the backend addresses (may be empty) from the resolver for
* fallback. */
glb_policy->fallback_backend_addresses =
- extract_backend_addresses_locked(exec_ctx, addresses);
+ extract_backend_addresses_locked(addresses);
/* Create a client channel over them to communicate with a LB service */
glb_policy->response_generator =
grpc_fake_resolver_response_generator_create();
grpc_channel_args* lb_channel_args = build_lb_channel_args(
- exec_ctx, addresses, glb_policy->response_generator, args->args);
+ addresses, glb_policy->response_generator, args->args);
char* uri_str;
gpr_asprintf(&uri_str, "fake:///%s", glb_policy->server_name);
glb_policy->lb_channel = grpc_lb_policy_grpclb_create_lb_channel(
- exec_ctx, uri_str, args->client_channel_factory, lb_channel_args);
+ uri_str, args->client_channel_factory, lb_channel_args);
/* Propagate initial resolution */
grpc_fake_resolver_response_generator_set_response(
- exec_ctx, glb_policy->response_generator, lb_channel_args);
- grpc_channel_args_destroy(exec_ctx, lb_channel_args);
+ glb_policy->response_generator, lb_channel_args);
+ grpc_channel_args_destroy(lb_channel_args);
gpr_free(uri_str);
if (glb_policy->lb_channel == nullptr) {
gpr_free((void*)glb_policy->server_name);
- grpc_channel_args_destroy(exec_ctx, glb_policy->args);
+ grpc_channel_args_destroy(glb_policy->args);
gpr_free(glb_policy);
return nullptr;
}
@@ -1985,7 +1942,7 @@ grpc_lb_policy_factory* grpc_glb_lb_factory_create() {
// Only add client_load_reporting filter if the grpclb LB policy is used.
static bool maybe_add_client_load_reporting_filter(
- grpc_exec_ctx* exec_ctx, grpc_channel_stack_builder* builder, void* arg) {
+ grpc_channel_stack_builder* builder, void* arg) {
const grpc_channel_args* args =
grpc_channel_stack_builder_get_channel_arguments(builder);
const grpc_arg* channel_arg =
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc
index aacaec197d..a8ecea4212 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.cc
@@ -26,17 +26,17 @@
#include "src/core/lib/support/string.h"
grpc_channel* grpc_lb_policy_grpclb_create_lb_channel(
- grpc_exec_ctx* exec_ctx, const char* lb_service_target_addresses,
+ const char* lb_service_target_addresses,
grpc_client_channel_factory* client_channel_factory,
grpc_channel_args* args) {
grpc_channel* lb_channel = grpc_client_channel_factory_create_channel(
- exec_ctx, client_channel_factory, lb_service_target_addresses,
+ client_channel_factory, lb_service_target_addresses,
GRPC_CLIENT_CHANNEL_TYPE_LOAD_BALANCING, args);
return lb_channel;
}
grpc_channel_args* grpc_lb_policy_grpclb_build_lb_channel_args(
- grpc_exec_ctx* exec_ctx, grpc_slice_hash_table* targets_info,
+ grpc_slice_hash_table* targets_info,
grpc_fake_resolver_response_generator* response_generator,
const grpc_channel_args* args) {
const grpc_arg to_add[] = {
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..d14def4910 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
@@ -35,12 +35,12 @@ extern "C" {
* \a client_channel_factory will be used for the creation of the LB channel,
* alongside the channel args passed in \a args. */
grpc_channel* grpc_lb_policy_grpclb_create_lb_channel(
- grpc_exec_ctx* exec_ctx, const char* lb_service_target_addresses,
+ const char* lb_service_target_addresses,
grpc_client_channel_factory* client_channel_factory,
grpc_channel_args* args);
grpc_channel_args* grpc_lb_policy_grpclb_build_lb_channel_args(
- grpc_exec_ctx* exec_ctx, grpc_slice_hash_table* targets_info,
+ grpc_slice_hash_table* targets_info,
grpc_fake_resolver_response_generator* response_generator,
const grpc_channel_args* args);
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 8eaa90e97b..76bcddf945 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
@@ -29,7 +29,7 @@
#include "src/core/lib/support/string.h"
grpc_channel* grpc_lb_policy_grpclb_create_lb_channel(
- grpc_exec_ctx* exec_ctx, const char* lb_service_target_addresses,
+ const char* lb_service_target_addresses,
grpc_client_channel_factory* client_channel_factory,
grpc_channel_args* args) {
grpc_channel_args* new_args = args;
@@ -50,19 +50,19 @@ grpc_channel* grpc_lb_policy_grpclb_create_lb_channel(
new_args = grpc_channel_args_copy_and_add_and_remove(
args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), args_to_add,
GPR_ARRAY_SIZE(args_to_add));
- grpc_channel_credentials_unref(exec_ctx, creds_sans_call_creds);
+ grpc_channel_credentials_unref(creds_sans_call_creds);
}
grpc_channel* lb_channel = grpc_client_channel_factory_create_channel(
- exec_ctx, client_channel_factory, lb_service_target_addresses,
+ client_channel_factory, lb_service_target_addresses,
GRPC_CLIENT_CHANNEL_TYPE_LOAD_BALANCING, new_args);
if (channel_credentials != nullptr) {
- grpc_channel_args_destroy(exec_ctx, new_args);
+ grpc_channel_args_destroy(new_args);
}
return lb_channel;
}
grpc_channel_args* grpc_lb_policy_grpclb_build_lb_channel_args(
- grpc_exec_ctx* exec_ctx, grpc_slice_hash_table* targets_info,
+ grpc_slice_hash_table* targets_info,
grpc_fake_resolver_response_generator* response_generator,
const grpc_channel_args* args) {
const grpc_arg to_add[] = {
diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
index dbd4754e87..159a087ee0 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
@@ -58,12 +58,12 @@ typedef struct {
grpc_connectivity_state_tracker state_tracker;
} pick_first_lb_policy;
-static void pf_destroy(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
+static void pf_destroy(grpc_lb_policy* pol) {
pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
GPR_ASSERT(p->subchannel_list == nullptr);
GPR_ASSERT(p->latest_pending_subchannel_list == nullptr);
GPR_ASSERT(p->pending_picks == nullptr);
- grpc_connectivity_state_destroy(exec_ctx, &p->state_tracker);
+ grpc_connectivity_state_destroy(&p->state_tracker);
gpr_free(p);
grpc_subchannel_index_unref();
if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
@@ -71,8 +71,7 @@ static void pf_destroy(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
}
}
-static void shutdown_locked(grpc_exec_ctx* exec_ctx, pick_first_lb_policy* p,
- grpc_error* error) {
+static void shutdown_locked(pick_first_lb_policy* p, grpc_error* error) {
if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
gpr_log(GPR_DEBUG, "Pick First %p Shutting down", p);
}
@@ -81,31 +80,30 @@ static void shutdown_locked(grpc_exec_ctx* exec_ctx, pick_first_lb_policy* p,
while ((pp = p->pending_picks) != nullptr) {
p->pending_picks = pp->next;
*pp->target = nullptr;
- GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(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");
+ grpc_connectivity_state_set(&p->state_tracker, GRPC_CHANNEL_SHUTDOWN,
+ GRPC_ERROR_REF(error), "shutdown");
if (p->subchannel_list != nullptr) {
- grpc_lb_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
+ grpc_lb_subchannel_list_shutdown_and_unref(p->subchannel_list,
"pf_shutdown");
p->subchannel_list = nullptr;
}
if (p->latest_pending_subchannel_list != nullptr) {
grpc_lb_subchannel_list_shutdown_and_unref(
- exec_ctx, p->latest_pending_subchannel_list, "pf_shutdown");
+ p->latest_pending_subchannel_list, "pf_shutdown");
p->latest_pending_subchannel_list = nullptr;
}
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,
+static void pf_shutdown_locked(grpc_lb_policy* pol) {
+ shutdown_locked((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,
+static void pf_cancel_pick_locked(grpc_lb_policy* pol,
grpc_connected_subchannel** target,
grpc_error* error) {
pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
@@ -115,7 +113,7 @@ static void pf_cancel_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
pending_pick* next = pp->next;
if (pp->target == target) {
*target = nullptr;
- GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete,
+ GRPC_CLOSURE_SCHED(pp->on_complete,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Pick Cancelled", &error, 1));
gpr_free(pp);
@@ -128,7 +126,7 @@ static void pf_cancel_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
GRPC_ERROR_UNREF(error);
}
-static void pf_cancel_picks_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
+static void pf_cancel_picks_locked(grpc_lb_policy* pol,
uint32_t initial_metadata_flags_mask,
uint32_t initial_metadata_flags_eq,
grpc_error* error) {
@@ -139,7 +137,7 @@ static void pf_cancel_picks_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
pending_pick* next = pp->next;
if ((pp->initial_metadata_flags & initial_metadata_flags_mask) ==
initial_metadata_flags_eq) {
- GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete,
+ GRPC_CLOSURE_SCHED(pp->on_complete,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Pick Cancelled", &error, 1));
gpr_free(pp);
@@ -152,8 +150,7 @@ static void pf_cancel_picks_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
GRPC_ERROR_UNREF(error);
}
-static void start_picking_locked(grpc_exec_ctx* exec_ctx,
- pick_first_lb_policy* p) {
+static void start_picking_locked(pick_first_lb_policy* p) {
p->started_picking = true;
if (p->subchannel_list != nullptr &&
p->subchannel_list->num_subchannels > 0) {
@@ -161,18 +158,18 @@ static void start_picking_locked(grpc_exec_ctx* exec_ctx,
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]);
+ &p->subchannel_list->subchannels[0]);
}
}
-static void pf_exit_idle_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
+static void pf_exit_idle_locked(grpc_lb_policy* pol) {
pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
if (!p->started_picking) {
- start_picking_locked(exec_ctx, p);
+ start_picking_locked(p);
}
}
-static int pf_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
+static int pf_pick_locked(grpc_lb_policy* pol,
const grpc_lb_policy_pick_args* pick_args,
grpc_connected_subchannel** target,
grpc_call_context_element* context, void** user_data,
@@ -186,7 +183,7 @@ static int pf_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
}
// No subchannel selected yet, so handle asynchronously.
if (!p->started_picking) {
- start_picking_locked(exec_ctx, p);
+ start_picking_locked(p);
}
pending_pick* pp = (pending_pick*)gpr_malloc(sizeof(*pp));
pp->next = p->pending_picks;
@@ -197,48 +194,43 @@ static int pf_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
return 0;
}
-static void destroy_unselected_subchannels_locked(grpc_exec_ctx* exec_ctx,
- pick_first_lb_policy* p) {
+static void destroy_unselected_subchannels_locked(pick_first_lb_policy* p) {
for (size_t i = 0; i < p->subchannel_list->num_subchannels; ++i) {
grpc_lb_subchannel_data* sd = &p->subchannel_list->subchannels[i];
if (p->selected != sd) {
- grpc_lb_subchannel_data_unref_subchannel(exec_ctx, sd,
+ grpc_lb_subchannel_data_unref_subchannel(sd,
"selected_different_subchannel");
}
}
}
static grpc_connectivity_state pf_check_connectivity_locked(
- grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol, grpc_error** error) {
+ grpc_lb_policy* pol, grpc_error** error) {
pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
return grpc_connectivity_state_get(&p->state_tracker, error);
}
-static void pf_notify_on_state_change_locked(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy* pol,
+static void pf_notify_on_state_change_locked(grpc_lb_policy* pol,
grpc_connectivity_state* current,
grpc_closure* notify) {
pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
- grpc_connectivity_state_notify_on_state_change(exec_ctx, &p->state_tracker,
- current, notify);
+ grpc_connectivity_state_notify_on_state_change(&p->state_tracker, current,
+ notify);
}
-static void pf_ping_one_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
- grpc_closure* closure) {
+static void pf_ping_one_locked(grpc_lb_policy* pol, grpc_closure* closure) {
pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
if (p->selected) {
- grpc_connected_subchannel_ping(exec_ctx, p->selected->connected_subchannel,
- closure);
+ grpc_connected_subchannel_ping(p->selected->connected_subchannel, closure);
} else {
- GRPC_CLOSURE_SCHED(exec_ctx, closure,
+ GRPC_CLOSURE_SCHED(closure,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Not connected"));
}
}
-static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error);
+static void pf_connectivity_changed_locked(void* arg, grpc_error* error);
-static void pf_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
+static void pf_update_locked(grpc_lb_policy* policy,
const grpc_lb_policy_args* args) {
pick_first_lb_policy* p = (pick_first_lb_policy*)policy;
const grpc_arg* arg =
@@ -247,7 +239,7 @@ static void pf_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
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,
+ &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing update in args"),
"pf_update_missing");
} else {
@@ -266,17 +258,17 @@ static void pf_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
(void*)p, (unsigned long)addresses->num_addresses);
}
grpc_lb_subchannel_list* subchannel_list = grpc_lb_subchannel_list_create(
- exec_ctx, &p->base, &grpc_lb_pick_first_trace, addresses, args,
+ &p->base, &grpc_lb_pick_first_trace, addresses, args,
pf_connectivity_changed_locked);
if (subchannel_list->num_subchannels == 0) {
// Empty update or no valid subchannels. Unsubscribe from all current
// subchannels and put the channel in TRANSIENT_FAILURE.
grpc_connectivity_state_set(
- exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty update"),
"pf_update_empty");
if (p->subchannel_list != nullptr) {
- grpc_lb_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
+ grpc_lb_subchannel_list_shutdown_and_unref(p->subchannel_list,
"sl_shutdown_empty_update");
}
p->subchannel_list = subchannel_list; // Empty list.
@@ -287,7 +279,7 @@ static void pf_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
// We don't yet have a selected subchannel, so replace the current
// subchannel list immediately.
if (p->subchannel_list != nullptr) {
- grpc_lb_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
+ grpc_lb_subchannel_list_shutdown_and_unref(p->subchannel_list,
"pf_update_before_selected");
}
p->subchannel_list = subchannel_list;
@@ -312,19 +304,19 @@ static void pf_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
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, "pf_update_includes_selected");
}
p->subchannel_list = subchannel_list;
- destroy_unselected_subchannels_locked(exec_ctx, p);
+ destroy_unselected_subchannels_locked(p);
grpc_lb_subchannel_list_ref_for_connectivity_watch(
subchannel_list, "connectivity_watch+replace_selected");
- grpc_lb_subchannel_data_start_connectivity_watch(exec_ctx, sd);
+ grpc_lb_subchannel_data_start_connectivity_watch(sd);
// If there was a previously pending update (which may or may
// not have contained the currently selected subchannel), drop
// it, so that it doesn't override what we've done here.
if (p->latest_pending_subchannel_list != nullptr) {
grpc_lb_subchannel_list_shutdown_and_unref(
- exec_ctx, p->latest_pending_subchannel_list,
+ p->latest_pending_subchannel_list,
"pf_update_includes_selected+outdated");
p->latest_pending_subchannel_list = nullptr;
}
@@ -344,8 +336,7 @@ static void pf_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
(void*)subchannel_list);
}
grpc_lb_subchannel_list_shutdown_and_unref(
- exec_ctx, p->latest_pending_subchannel_list,
- "sl_outdated_dont_smash");
+ p->latest_pending_subchannel_list, "sl_outdated_dont_smash");
}
p->latest_pending_subchannel_list = subchannel_list;
}
@@ -355,12 +346,11 @@ static void pf_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
grpc_lb_subchannel_list_ref_for_connectivity_watch(
subchannel_list, "connectivity_watch+update");
grpc_lb_subchannel_data_start_connectivity_watch(
- exec_ctx, &subchannel_list->subchannels[0]);
+ &subchannel_list->subchannels[0]);
}
}
-static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void pf_connectivity_changed_locked(void* arg, grpc_error* error) {
grpc_lb_subchannel_data* sd = (grpc_lb_subchannel_data*)arg;
pick_first_lb_policy* p = (pick_first_lb_policy*)sd->subchannel_list->policy;
if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
@@ -378,18 +368,18 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
}
// If the policy is shutting down, unref and return.
if (p->shutdown) {
- grpc_lb_subchannel_data_stop_connectivity_watch(exec_ctx, sd);
- grpc_lb_subchannel_data_unref_subchannel(exec_ctx, sd, "pf_shutdown");
- grpc_lb_subchannel_list_unref_for_connectivity_watch(
- exec_ctx, sd->subchannel_list, "pf_shutdown");
+ grpc_lb_subchannel_data_stop_connectivity_watch(sd);
+ grpc_lb_subchannel_data_unref_subchannel(sd, "pf_shutdown");
+ grpc_lb_subchannel_list_unref_for_connectivity_watch(sd->subchannel_list,
+ "pf_shutdown");
return;
}
// If the subchannel list is shutting down, stop watching.
if (sd->subchannel_list->shutting_down || error == GRPC_ERROR_CANCELLED) {
- grpc_lb_subchannel_data_stop_connectivity_watch(exec_ctx, sd);
- grpc_lb_subchannel_data_unref_subchannel(exec_ctx, sd, "pf_sl_shutdown");
- grpc_lb_subchannel_list_unref_for_connectivity_watch(
- exec_ctx, sd->subchannel_list, "pf_sl_shutdown");
+ grpc_lb_subchannel_data_stop_connectivity_watch(sd);
+ grpc_lb_subchannel_data_unref_subchannel(sd, "pf_sl_shutdown");
+ grpc_lb_subchannel_list_unref_for_connectivity_watch(sd->subchannel_list,
+ "pf_sl_shutdown");
return;
}
// If we're still here, the notification must be for a subchannel in
@@ -406,28 +396,28 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
p->latest_pending_subchannel_list != nullptr) {
p->selected = nullptr;
grpc_lb_subchannel_list_shutdown_and_unref(
- exec_ctx, p->subchannel_list, "selected_not_ready+switch_to_update");
+ p->subchannel_list, "selected_not_ready+switch_to_update");
p->subchannel_list = p->latest_pending_subchannel_list;
p->latest_pending_subchannel_list = nullptr;
grpc_connectivity_state_set(
- exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ &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;
}
- grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
+ grpc_connectivity_state_set(&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);
+ grpc_lb_subchannel_data_start_connectivity_watch(sd);
} else {
- grpc_lb_subchannel_data_stop_connectivity_watch(exec_ctx, sd);
+ grpc_lb_subchannel_data_stop_connectivity_watch(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));
+ sd->subchannel_list, "pf_selected_shutdown");
+ shutdown_locked(p, GRPC_ERROR_REF(error));
}
}
return;
@@ -447,15 +437,14 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
// p->subchannel_list.
if (sd->subchannel_list == p->latest_pending_subchannel_list) {
GPR_ASSERT(p->subchannel_list != nullptr);
- grpc_lb_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
+ grpc_lb_subchannel_list_shutdown_and_unref(p->subchannel_list,
"finish_update");
p->subchannel_list = p->latest_pending_subchannel_list;
p->latest_pending_subchannel_list = nullptr;
}
// Cases 1 and 2.
- grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
- GRPC_CHANNEL_READY, GRPC_ERROR_NONE,
- "connecting_ready");
+ grpc_connectivity_state_set(&p->state_tracker, GRPC_CHANNEL_READY,
+ GRPC_ERROR_NONE, "connecting_ready");
sd->connected_subchannel = GRPC_CONNECTED_SUBCHANNEL_REF(
grpc_subchannel_get_connected_subchannel(sd->subchannel),
"connected");
@@ -465,7 +454,7 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
(void*)sd->subchannel);
}
// Drop all other subchannels, since we are now connected.
- destroy_unselected_subchannels_locked(exec_ctx, p);
+ destroy_unselected_subchannels_locked(p);
// Update any calls that were waiting for a pick.
pending_pick* pp;
while ((pp = p->pending_picks)) {
@@ -477,15 +466,15 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
"Servicing pending pick with selected subchannel %p",
(void*)p->selected);
}
- GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(pp->on_complete, GRPC_ERROR_NONE);
gpr_free(pp);
}
// Renew notification.
- grpc_lb_subchannel_data_start_connectivity_watch(exec_ctx, sd);
+ grpc_lb_subchannel_data_start_connectivity_watch(sd);
break;
}
case GRPC_CHANNEL_TRANSIENT_FAILURE: {
- grpc_lb_subchannel_data_stop_connectivity_watch(exec_ctx, sd);
+ grpc_lb_subchannel_data_stop_connectivity_watch(sd);
do {
sd->subchannel_list->checking_subchannel =
(sd->subchannel_list->checking_subchannel + 1) %
@@ -498,29 +487,28 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
if (sd->subchannel_list->checking_subchannel == 0 &&
sd->subchannel_list == p->subchannel_list) {
grpc_connectivity_state_set(
- exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
GRPC_ERROR_REF(error), "connecting_transient_failure");
}
// Reuses the connectivity refs from the previous watch.
- grpc_lb_subchannel_data_start_connectivity_watch(exec_ctx, sd);
+ grpc_lb_subchannel_data_start_connectivity_watch(sd);
break;
}
case GRPC_CHANNEL_CONNECTING:
case GRPC_CHANNEL_IDLE: {
// Only update connectivity state in case 1.
if (sd->subchannel_list == p->subchannel_list) {
- grpc_connectivity_state_set(
- exec_ctx, &p->state_tracker, GRPC_CHANNEL_CONNECTING,
- GRPC_ERROR_REF(error), "connecting_changed");
+ grpc_connectivity_state_set(&p->state_tracker, GRPC_CHANNEL_CONNECTING,
+ GRPC_ERROR_REF(error),
+ "connecting_changed");
}
// Renew notification.
- grpc_lb_subchannel_data_start_connectivity_watch(exec_ctx, sd);
+ grpc_lb_subchannel_data_start_connectivity_watch(sd);
break;
}
case GRPC_CHANNEL_SHUTDOWN: {
- grpc_lb_subchannel_data_stop_connectivity_watch(exec_ctx, sd);
- grpc_lb_subchannel_data_unref_subchannel(exec_ctx, sd,
- "pf_candidate_shutdown");
+ grpc_lb_subchannel_data_stop_connectivity_watch(sd);
+ grpc_lb_subchannel_data_unref_subchannel(sd, "pf_candidate_shutdown");
// Advance to next subchannel and check its state.
grpc_lb_subchannel_data* original_sd = sd;
do {
@@ -532,19 +520,18 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
} 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));
+ sd->subchannel_list, "pf_candidate_shutdown");
+ shutdown_locked(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_connectivity_state_set(&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);
+ grpc_lb_subchannel_data_start_connectivity_watch(sd);
break;
}
}
@@ -566,15 +553,14 @@ static void pick_first_factory_ref(grpc_lb_policy_factory* factory) {}
static void pick_first_factory_unref(grpc_lb_policy_factory* factory) {}
-static grpc_lb_policy* create_pick_first(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy_factory* factory,
+static grpc_lb_policy* create_pick_first(grpc_lb_policy_factory* factory,
grpc_lb_policy_args* args) {
GPR_ASSERT(args->client_channel_factory != nullptr);
pick_first_lb_policy* p = (pick_first_lb_policy*)gpr_zalloc(sizeof(*p));
if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
gpr_log(GPR_DEBUG, "Pick First %p created.", (void*)p);
}
- pf_update_locked(exec_ctx, &p->base, args);
+ pf_update_locked(&p->base, args);
grpc_lb_policy_init(&p->base, &pick_first_lb_policy_vtable, args->combiner);
grpc_subchannel_index_ref();
return &p->base;
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 6ea1f025df..2382f066e8 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
@@ -155,7 +155,7 @@ 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) {
+static void rr_destroy(grpc_lb_policy* pol) {
round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
gpr_log(GPR_DEBUG, "[RR %p] Destroying Round Robin policy at %p",
@@ -163,13 +163,12 @@ static void rr_destroy(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
}
GPR_ASSERT(p->subchannel_list == nullptr);
GPR_ASSERT(p->latest_pending_subchannel_list == nullptr);
- grpc_connectivity_state_destroy(exec_ctx, &p->state_tracker);
+ grpc_connectivity_state_destroy(&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) {
+static void shutdown_locked(round_robin_lb_policy* p, grpc_error* error) {
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
gpr_log(GPR_DEBUG, "[RR %p] Shutting down", p);
}
@@ -178,33 +177,30 @@ static void shutdown_locked(grpc_exec_ctx* exec_ctx, round_robin_lb_policy* p,
while ((pp = p->pending_picks) != nullptr) {
p->pending_picks = pp->next;
*pp->target = nullptr;
- GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(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");
+ grpc_connectivity_state_set(&p->state_tracker, GRPC_CHANNEL_SHUTDOWN,
+ GRPC_ERROR_REF(error), "rr_shutdown");
if (p->subchannel_list != nullptr) {
- grpc_lb_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
+ grpc_lb_subchannel_list_shutdown_and_unref(p->subchannel_list,
"sl_shutdown_rr_shutdown");
p->subchannel_list = nullptr;
}
if (p->latest_pending_subchannel_list != nullptr) {
grpc_lb_subchannel_list_shutdown_and_unref(
- exec_ctx, p->latest_pending_subchannel_list,
- "sl_shutdown_pending_rr_shutdown");
+ p->latest_pending_subchannel_list, "sl_shutdown_pending_rr_shutdown");
p->latest_pending_subchannel_list = nullptr;
}
GRPC_ERROR_UNREF(error);
}
-static void rr_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
+static void rr_shutdown_locked(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"));
+ shutdown_locked(p, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Shutdown"));
}
-static void rr_cancel_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
+static void rr_cancel_pick_locked(grpc_lb_policy* pol,
grpc_connected_subchannel** target,
grpc_error* error) {
round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
@@ -214,7 +210,7 @@ static void rr_cancel_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
pending_pick* next = pp->next;
if (pp->target == target) {
*target = nullptr;
- GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete,
+ GRPC_CLOSURE_SCHED(pp->on_complete,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Pick cancelled", &error, 1));
gpr_free(pp);
@@ -227,7 +223,7 @@ static void rr_cancel_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
GRPC_ERROR_UNREF(error);
}
-static void rr_cancel_picks_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
+static void rr_cancel_picks_locked(grpc_lb_policy* pol,
uint32_t initial_metadata_flags_mask,
uint32_t initial_metadata_flags_eq,
grpc_error* error) {
@@ -239,7 +235,7 @@ static void rr_cancel_picks_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
if ((pp->initial_metadata_flags & initial_metadata_flags_mask) ==
initial_metadata_flags_eq) {
*pp->target = nullptr;
- GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete,
+ GRPC_CLOSURE_SCHED(pp->on_complete,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Pick cancelled", &error, 1));
gpr_free(pp);
@@ -252,25 +248,24 @@ static void rr_cancel_picks_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
GRPC_ERROR_UNREF(error);
}
-static void start_picking_locked(grpc_exec_ctx* exec_ctx,
- round_robin_lb_policy* p) {
+static void start_picking_locked(round_robin_lb_policy* p) {
p->started_picking = true;
for (size_t i = 0; i < p->subchannel_list->num_subchannels; i++) {
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]);
+ &p->subchannel_list->subchannels[i]);
}
}
-static void rr_exit_idle_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) {
+static void rr_exit_idle_locked(grpc_lb_policy* pol) {
round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
if (!p->started_picking) {
- start_picking_locked(exec_ctx, p);
+ start_picking_locked(p);
}
}
-static int rr_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
+static int rr_pick_locked(grpc_lb_policy* pol,
const grpc_lb_policy_pick_args* pick_args,
grpc_connected_subchannel** target,
grpc_call_context_element* context, void** user_data,
@@ -307,7 +302,7 @@ static int rr_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
}
/* no pick currently available. Save for later in list of pending picks */
if (!p->started_picking) {
- start_picking_locked(exec_ctx, p);
+ start_picking_locked(p);
}
pending_pick* pp = (pending_pick*)gpr_malloc(sizeof(*pp));
pp->next = p->pending_picks;
@@ -352,7 +347,7 @@ static void update_state_counters_locked(grpc_lb_subchannel_data* sd) {
* 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) {
+ 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).
*
@@ -377,20 +372,18 @@ static grpc_connectivity_state update_lb_connectivity_status_locked(
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 */
- grpc_connectivity_state_set(exec_ctx, &p->state_tracker, GRPC_CHANNEL_READY,
+ grpc_connectivity_state_set(&p->state_tracker, GRPC_CHANNEL_READY,
GRPC_ERROR_NONE, "rr_ready");
new_state = GRPC_CHANNEL_READY;
} else if (sd->curr_connectivity_state ==
GRPC_CHANNEL_CONNECTING) { /* 2) CONNECTING */
- grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
- GRPC_CHANNEL_CONNECTING, GRPC_ERROR_NONE,
- "rr_connecting");
+ grpc_connectivity_state_set(&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");
+ grpc_connectivity_state_set(&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)) {
@@ -400,13 +393,13 @@ static grpc_connectivity_state update_lb_connectivity_status_locked(
}
} else if (subchannel_list->num_transient_failures ==
p->subchannel_list->num_subchannels) { /* 4) TRANSIENT_FAILURE */
- grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
+ grpc_connectivity_state_set(&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_connectivity_state_set(&p->state_tracker, GRPC_CHANNEL_IDLE,
GRPC_ERROR_NONE, "rr_idle");
new_state = GRPC_CHANNEL_IDLE;
}
@@ -414,8 +407,7 @@ static grpc_connectivity_state update_lb_connectivity_status_locked(
return new_state;
}
-static void rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void rr_connectivity_changed_locked(void* arg, grpc_error* error) {
grpc_lb_subchannel_data* sd = (grpc_lb_subchannel_data*)arg;
round_robin_lb_policy* p =
(round_robin_lb_policy*)sd->subchannel_list->policy;
@@ -433,18 +425,18 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
}
// If the policy is shutting down, unref and return.
if (p->shutdown) {
- grpc_lb_subchannel_data_stop_connectivity_watch(exec_ctx, sd);
- grpc_lb_subchannel_data_unref_subchannel(exec_ctx, sd, "rr_shutdown");
- grpc_lb_subchannel_list_unref_for_connectivity_watch(
- exec_ctx, sd->subchannel_list, "rr_shutdown");
+ grpc_lb_subchannel_data_stop_connectivity_watch(sd);
+ grpc_lb_subchannel_data_unref_subchannel(sd, "rr_shutdown");
+ grpc_lb_subchannel_list_unref_for_connectivity_watch(sd->subchannel_list,
+ "rr_shutdown");
return;
}
// If the subchannel list is shutting down, stop watching.
if (sd->subchannel_list->shutting_down || error == GRPC_ERROR_CANCELLED) {
- grpc_lb_subchannel_data_stop_connectivity_watch(exec_ctx, sd);
- grpc_lb_subchannel_data_unref_subchannel(exec_ctx, sd, "rr_sl_shutdown");
- grpc_lb_subchannel_list_unref_for_connectivity_watch(
- exec_ctx, sd->subchannel_list, "rr_sl_shutdown");
+ grpc_lb_subchannel_data_stop_connectivity_watch(sd);
+ grpc_lb_subchannel_data_unref_subchannel(sd, "rr_sl_shutdown");
+ grpc_lb_subchannel_list_unref_for_connectivity_watch(sd->subchannel_list,
+ "rr_sl_shutdown");
return;
}
// If we're still here, the notification must be for a subchannel in
@@ -458,17 +450,16 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
// Update state counters and determine 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));
+ update_lb_connectivity_status_locked(sd, GRPC_ERROR_REF(error));
// If the sd's new state is SHUTDOWN, unref the subchannel, and if the new
// policy's state is SHUTDOWN, clean up.
if (sd->curr_connectivity_state == GRPC_CHANNEL_SHUTDOWN) {
- grpc_lb_subchannel_data_stop_connectivity_watch(exec_ctx, sd);
- grpc_lb_subchannel_data_unref_subchannel(exec_ctx, sd,
- "rr_connectivity_shutdown");
+ grpc_lb_subchannel_data_stop_connectivity_watch(sd);
+ grpc_lb_subchannel_data_unref_subchannel(sd, "rr_connectivity_shutdown");
grpc_lb_subchannel_list_unref_for_connectivity_watch(
- exec_ctx, sd->subchannel_list, "rr_connectivity_shutdown");
+ sd->subchannel_list, "rr_connectivity_shutdown");
if (new_policy_connectivity_state == GRPC_CHANNEL_SHUTDOWN) {
- shutdown_locked(exec_ctx, p, GRPC_ERROR_REF(error));
+ shutdown_locked(p, GRPC_ERROR_REF(error));
}
} else { // sd not in SHUTDOWN
if (sd->curr_connectivity_state == GRPC_CHANNEL_READY) {
@@ -497,8 +488,8 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
}
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");
+ grpc_lb_subchannel_list_shutdown_and_unref(p->subchannel_list,
+ "sl_phase_out_shutdown");
}
p->subchannel_list = p->latest_pending_subchannel_list;
p->latest_pending_subchannel_list = nullptr;
@@ -530,32 +521,30 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
(void*)p, (void*)selected->subchannel,
(void*)p->subchannel_list, (unsigned long)next_ready_index);
}
- GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(pp->on_complete, GRPC_ERROR_NONE);
gpr_free(pp);
}
}
// Renew notification.
- grpc_lb_subchannel_data_start_connectivity_watch(exec_ctx, sd);
+ grpc_lb_subchannel_data_start_connectivity_watch(sd);
}
}
static grpc_connectivity_state rr_check_connectivity_locked(
- grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol, grpc_error** error) {
+ grpc_lb_policy* pol, grpc_error** error) {
round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
return grpc_connectivity_state_get(&p->state_tracker, error);
}
-static void rr_notify_on_state_change_locked(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy* pol,
+static void rr_notify_on_state_change_locked(grpc_lb_policy* pol,
grpc_connectivity_state* current,
grpc_closure* notify) {
round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
- grpc_connectivity_state_notify_on_state_change(exec_ctx, &p->state_tracker,
- current, notify);
+ grpc_connectivity_state_notify_on_state_change(&p->state_tracker, current,
+ notify);
}
-static void rr_ping_one_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
- grpc_closure* closure) {
+static void rr_ping_one_locked(grpc_lb_policy* pol, grpc_closure* closure) {
round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
const size_t next_ready_index = get_next_ready_subchannel_index_locked(p);
if (next_ready_index < p->subchannel_list->num_subchannels) {
@@ -563,16 +552,15 @@ static void rr_ping_one_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol,
&p->subchannel_list->subchannels[next_ready_index];
grpc_connected_subchannel* target = GRPC_CONNECTED_SUBCHANNEL_REF(
selected->connected_subchannel, "rr_ping");
- grpc_connected_subchannel_ping(exec_ctx, target, closure);
- GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, target, "rr_ping");
+ grpc_connected_subchannel_ping(target, closure);
+ GRPC_CONNECTED_SUBCHANNEL_UNREF(target, "rr_ping");
} else {
- GRPC_CLOSURE_SCHED(
- exec_ctx, closure,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Round Robin not connected"));
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Round Robin not connected"));
}
}
-static void rr_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
+static void rr_update_locked(grpc_lb_policy* policy,
const grpc_lb_policy_args* args) {
round_robin_lb_policy* p = (round_robin_lb_policy*)policy;
const grpc_arg* arg =
@@ -583,7 +571,7 @@ static void rr_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
// Otherwise, keep using the current subchannel list (ignore this update).
if (p->subchannel_list == nullptr) {
grpc_connectivity_state_set(
- exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing update in args"),
"rr_update_missing");
}
@@ -595,15 +583,15 @@ static void rr_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
addresses->num_addresses);
}
grpc_lb_subchannel_list* subchannel_list = grpc_lb_subchannel_list_create(
- exec_ctx, &p->base, &grpc_lb_round_robin_trace, addresses, args,
+ &p->base, &grpc_lb_round_robin_trace, addresses, args,
rr_connectivity_changed_locked);
if (subchannel_list->num_subchannels == 0) {
grpc_connectivity_state_set(
- exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty update"),
"rr_update_empty");
if (p->subchannel_list != nullptr) {
- grpc_lb_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list,
+ grpc_lb_subchannel_list_shutdown_and_unref(p->subchannel_list,
"sl_shutdown_empty_update");
}
p->subchannel_list = subchannel_list; // empty list
@@ -619,7 +607,7 @@ static void rr_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
(void*)subchannel_list);
}
grpc_lb_subchannel_list_shutdown_and_unref(
- exec_ctx, p->latest_pending_subchannel_list, "sl_outdated");
+ p->latest_pending_subchannel_list, "sl_outdated");
}
p->latest_pending_subchannel_list = subchannel_list;
for (size_t i = 0; i < subchannel_list->num_subchannels; ++i) {
@@ -630,14 +618,14 @@ static void rr_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy,
grpc_lb_subchannel_list_ref_for_connectivity_watch(subchannel_list,
"connectivity_watch");
grpc_lb_subchannel_data_start_connectivity_watch(
- exec_ctx, &subchannel_list->subchannels[i]);
+ &subchannel_list->subchannels[i]);
}
} else {
// The policy isn't picking yet. Save the update for later, disposing of
// previous version if any.
if (p->subchannel_list != nullptr) {
grpc_lb_subchannel_list_shutdown_and_unref(
- exec_ctx, p->subchannel_list, "rr_update_before_started_picking");
+ p->subchannel_list, "rr_update_before_started_picking");
}
p->subchannel_list = subchannel_list;
}
@@ -659,8 +647,7 @@ static void round_robin_factory_ref(grpc_lb_policy_factory* factory) {}
static void round_robin_factory_unref(grpc_lb_policy_factory* factory) {}
-static grpc_lb_policy* round_robin_create(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy_factory* factory,
+static grpc_lb_policy* round_robin_create(grpc_lb_policy_factory* factory,
grpc_lb_policy_args* args) {
GPR_ASSERT(args->client_channel_factory != nullptr);
round_robin_lb_policy* p = (round_robin_lb_policy*)gpr_zalloc(sizeof(*p));
@@ -668,7 +655,7 @@ static grpc_lb_policy* round_robin_create(grpc_exec_ctx* exec_ctx,
grpc_subchannel_index_ref();
grpc_connectivity_state_init(&p->state_tracker, GRPC_CHANNEL_IDLE,
"round_robin");
- rr_update_locked(exec_ctx, &p->base, args);
+ rr_update_locked(&p->base, args);
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
gpr_log(GPR_DEBUG, "[RR %p] Created with %lu subchannels", (void*)p,
(unsigned long)p->subchannel_list->num_subchannels);
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 27d9598ac4..e804a98ce7 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
@@ -28,8 +28,7 @@
#include "src/core/lib/iomgr/sockaddr_utils.h"
#include "src/core/lib/transport/connectivity_state.h"
-void grpc_lb_subchannel_data_unref_subchannel(grpc_exec_ctx* exec_ctx,
- grpc_lb_subchannel_data* sd,
+void grpc_lb_subchannel_data_unref_subchannel(grpc_lb_subchannel_data* sd,
const char* reason) {
if (sd->subchannel != nullptr) {
if (GRPC_TRACER_ON(*sd->subchannel_list->tracer)) {
@@ -41,23 +40,22 @@ void grpc_lb_subchannel_data_unref_subchannel(grpc_exec_ctx* exec_ctx,
(size_t)(sd - sd->subchannel_list->subchannels),
sd->subchannel_list->num_subchannels, sd->subchannel);
}
- GRPC_SUBCHANNEL_UNREF(exec_ctx, sd->subchannel, reason);
+ GRPC_SUBCHANNEL_UNREF(sd->subchannel, reason);
sd->subchannel = nullptr;
if (sd->connected_subchannel != nullptr) {
- GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, sd->connected_subchannel,
- reason);
+ GRPC_CONNECTED_SUBCHANNEL_UNREF(sd->connected_subchannel, reason);
sd->connected_subchannel = nullptr;
}
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_vtable->destroy(sd->user_data);
sd->user_data = nullptr;
}
}
}
void grpc_lb_subchannel_data_start_connectivity_watch(
- grpc_exec_ctx* exec_ctx, grpc_lb_subchannel_data* sd) {
+ grpc_lb_subchannel_data* sd) {
if (GRPC_TRACER_ON(*sd->subchannel_list->tracer)) {
gpr_log(GPR_DEBUG,
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
@@ -69,13 +67,13 @@ void grpc_lb_subchannel_data_start_connectivity_watch(
}
sd->connectivity_notification_pending = true;
grpc_subchannel_notify_on_state_change(
- exec_ctx, sd->subchannel, sd->subchannel_list->policy->interested_parties,
+ sd->subchannel, sd->subchannel_list->policy->interested_parties,
&sd->pending_connectivity_state_unsafe,
&sd->connectivity_changed_closure);
}
void grpc_lb_subchannel_data_stop_connectivity_watch(
- grpc_exec_ctx* exec_ctx, grpc_lb_subchannel_data* sd) {
+ grpc_lb_subchannel_data* sd) {
if (GRPC_TRACER_ON(*sd->subchannel_list->tracer)) {
gpr_log(GPR_DEBUG,
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
@@ -90,7 +88,7 @@ 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_lb_policy* p, grpc_tracer_flag* 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 =
@@ -124,8 +122,8 @@ grpc_lb_subchannel_list* grpc_lb_subchannel_list_create(
gpr_free(addr_arg.value.string);
sc_args.args = new_args;
grpc_subchannel* subchannel = grpc_client_channel_factory_create_subchannel(
- exec_ctx, args->client_channel_factory, &sc_args);
- grpc_channel_args_destroy(exec_ctx, new_args);
+ args->client_channel_factory, &sc_args);
+ grpc_channel_args_destroy(new_args);
if (subchannel == nullptr) {
// Subchannel could not be created.
if (GRPC_TRACER_ON(*tracer)) {
@@ -172,8 +170,7 @@ grpc_lb_subchannel_list* grpc_lb_subchannel_list_create(
return subchannel_list;
}
-static void subchannel_list_destroy(grpc_exec_ctx* exec_ctx,
- grpc_lb_subchannel_list* subchannel_list) {
+static void subchannel_list_destroy(grpc_lb_subchannel_list* subchannel_list) {
if (GRPC_TRACER_ON(*subchannel_list->tracer)) {
gpr_log(GPR_DEBUG, "[%s %p] Destroying subchannel_list %p",
subchannel_list->tracer->name, subchannel_list->policy,
@@ -181,8 +178,7 @@ static void subchannel_list_destroy(grpc_exec_ctx* exec_ctx,
}
for (size_t i = 0; i < subchannel_list->num_subchannels; i++) {
grpc_lb_subchannel_data* sd = &subchannel_list->subchannels[i];
- grpc_lb_subchannel_data_unref_subchannel(exec_ctx, sd,
- "subchannel_list_destroy");
+ grpc_lb_subchannel_data_unref_subchannel(sd, "subchannel_list_destroy");
}
gpr_free(subchannel_list->subchannels);
gpr_free(subchannel_list);
@@ -200,8 +196,7 @@ void grpc_lb_subchannel_list_ref(grpc_lb_subchannel_list* subchannel_list,
}
}
-void grpc_lb_subchannel_list_unref(grpc_exec_ctx* exec_ctx,
- grpc_lb_subchannel_list* subchannel_list,
+void grpc_lb_subchannel_list_unref(grpc_lb_subchannel_list* subchannel_list,
const char* reason) {
const bool done = gpr_unref(&subchannel_list->refcount);
if (GRPC_TRACER_ON(*subchannel_list->tracer)) {
@@ -212,7 +207,7 @@ void grpc_lb_subchannel_list_unref(grpc_exec_ctx* exec_ctx,
reason);
}
if (done) {
- subchannel_list_destroy(exec_ctx, subchannel_list);
+ subchannel_list_destroy(subchannel_list);
}
}
@@ -223,14 +218,13 @@ void grpc_lb_subchannel_list_ref_for_connectivity_watch(
}
void grpc_lb_subchannel_list_unref_for_connectivity_watch(
- grpc_exec_ctx* exec_ctx, grpc_lb_subchannel_list* subchannel_list,
- const char* reason) {
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, subchannel_list->policy, reason);
- grpc_lb_subchannel_list_unref(exec_ctx, subchannel_list, reason);
+ grpc_lb_subchannel_list* subchannel_list, const char* reason) {
+ GRPC_LB_POLICY_WEAK_UNREF(subchannel_list->policy, reason);
+ grpc_lb_subchannel_list_unref(subchannel_list, reason);
}
static void subchannel_data_cancel_connectivity_watch(
- grpc_exec_ctx* exec_ctx, grpc_lb_subchannel_data* sd, const char* reason) {
+ grpc_lb_subchannel_data* sd, const char* reason) {
if (GRPC_TRACER_ON(*sd->subchannel_list->tracer)) {
gpr_log(GPR_DEBUG,
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
@@ -240,14 +234,12 @@ static void subchannel_data_cancel_connectivity_watch(
(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, nullptr,
- nullptr,
+ grpc_subchannel_notify_on_state_change(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) {
+ grpc_lb_subchannel_list* subchannel_list, const char* reason) {
if (GRPC_TRACER_ON(*subchannel_list->tracer)) {
gpr_log(GPR_DEBUG, "[%s %p] Shutting down subchannel_list %p (%s)",
subchannel_list->tracer->name, subchannel_list->policy,
@@ -261,10 +253,10 @@ void grpc_lb_subchannel_list_shutdown_and_unref(
// the callback is responsible for unreffing the subchannel.
// Otherwise, unref the subchannel directly.
if (sd->connectivity_notification_pending) {
- subchannel_data_cancel_connectivity_watch(exec_ctx, sd, reason);
+ subchannel_data_cancel_connectivity_watch(sd, reason);
} else if (sd->subchannel != nullptr) {
- grpc_lb_subchannel_data_unref_subchannel(exec_ctx, sd, reason);
+ grpc_lb_subchannel_data_unref_subchannel(sd, reason);
}
}
- grpc_lb_subchannel_list_unref(exec_ctx, subchannel_list, reason);
+ grpc_lb_subchannel_list_unref(subchannel_list, reason);
}
diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h
index e18ad490e8..70a43fe132 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
@@ -69,8 +69,7 @@ typedef struct {
} grpc_lb_subchannel_data;
/// Unrefs the subchannel contained in sd.
-void grpc_lb_subchannel_data_unref_subchannel(grpc_exec_ctx* exec_ctx,
- grpc_lb_subchannel_data* sd,
+void grpc_lb_subchannel_data_unref_subchannel(grpc_lb_subchannel_data* sd,
const char* reason);
/// Starts watching the connectivity state of the subchannel.
@@ -78,11 +77,11 @@ void grpc_lb_subchannel_data_unref_subchannel(grpc_exec_ctx* exec_ctx,
/// grpc_lb_subchannel_data_stop_connectivity_watch() or again call
/// grpc_lb_subchannel_data_start_connectivity_watch().
void grpc_lb_subchannel_data_start_connectivity_watch(
- grpc_exec_ctx* exec_ctx, grpc_lb_subchannel_data* sd);
+ grpc_lb_subchannel_data* sd);
/// Stops watching the connectivity state of the subchannel.
void grpc_lb_subchannel_data_stop_connectivity_watch(
- grpc_exec_ctx* exec_ctx, grpc_lb_subchannel_data* sd);
+ grpc_lb_subchannel_data* sd);
struct grpc_lb_subchannel_list {
/** backpointer to owning policy */
@@ -121,15 +120,14 @@ 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_lb_policy* p, grpc_tracer_flag* tracer,
const grpc_lb_addresses* addresses, const grpc_lb_policy_args* args,
grpc_iomgr_cb_func connectivity_changed_cb);
void grpc_lb_subchannel_list_ref(grpc_lb_subchannel_list* subchannel_list,
const char* reason);
-void grpc_lb_subchannel_list_unref(grpc_exec_ctx* exec_ctx,
- grpc_lb_subchannel_list* subchannel_list,
+void grpc_lb_subchannel_list_unref(grpc_lb_subchannel_list* subchannel_list,
const char* reason);
/// Takes and releases refs needed for a connectivity notification.
@@ -137,14 +135,12 @@ void grpc_lb_subchannel_list_unref(grpc_exec_ctx* exec_ctx,
void grpc_lb_subchannel_list_ref_for_connectivity_watch(
grpc_lb_subchannel_list* subchannel_list, const char* reason);
void grpc_lb_subchannel_list_unref_for_connectivity_watch(
- grpc_exec_ctx* exec_ctx, grpc_lb_subchannel_list* subchannel_list,
- const char* reason);
+ grpc_lb_subchannel_list* subchannel_list, const char* reason);
/// Mark subchannel_list as discarded. Unsubscribes all its subchannels. The
/// connectivity state notification callback will ultimately unref it.
void grpc_lb_subchannel_list_shutdown_and_unref(
- grpc_exec_ctx* exec_ctx, grpc_lb_subchannel_list* subchannel_list,
- const char* reason);
+ grpc_lb_subchannel_list* subchannel_list, const char* reason);
#ifdef __cplusplus
}
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 d43f9fd1b9..dbf69fdcba 100644
--- a/src/core/ext/filters/client_channel/lb_policy_factory.cc
+++ b/src/core/ext/filters/client_channel/lb_policy_factory.cc
@@ -112,13 +112,11 @@ int grpc_lb_addresses_cmp(const grpc_lb_addresses* addresses1,
return 0;
}
-void grpc_lb_addresses_destroy(grpc_exec_ctx* exec_ctx,
- grpc_lb_addresses* addresses) {
+void grpc_lb_addresses_destroy(grpc_lb_addresses* addresses) {
for (size_t i = 0; i < addresses->num_addresses; ++i) {
gpr_free(addresses->addresses[i].balancer_name);
if (addresses->addresses[i].user_data != nullptr) {
- addresses->user_data_vtable->destroy(exec_ctx,
- addresses->addresses[i].user_data);
+ addresses->user_data_vtable->destroy(addresses->addresses[i].user_data);
}
}
gpr_free(addresses->addresses);
@@ -128,8 +126,8 @@ void grpc_lb_addresses_destroy(grpc_exec_ctx* exec_ctx,
static void* lb_addresses_copy(void* addresses) {
return grpc_lb_addresses_copy((grpc_lb_addresses*)addresses);
}
-static void lb_addresses_destroy(grpc_exec_ctx* exec_ctx, void* addresses) {
- grpc_lb_addresses_destroy(exec_ctx, (grpc_lb_addresses*)addresses);
+static void lb_addresses_destroy(void* addresses) {
+ grpc_lb_addresses_destroy((grpc_lb_addresses*)addresses);
}
static int lb_addresses_cmp(void* addresses1, void* addresses2) {
return grpc_lb_addresses_cmp((grpc_lb_addresses*)addresses1,
@@ -162,8 +160,7 @@ void grpc_lb_policy_factory_unref(grpc_lb_policy_factory* factory) {
}
grpc_lb_policy* grpc_lb_policy_factory_create_lb_policy(
- grpc_exec_ctx* exec_ctx, grpc_lb_policy_factory* factory,
- grpc_lb_policy_args* args) {
+ grpc_lb_policy_factory* factory, grpc_lb_policy_args* args) {
if (factory == nullptr) return nullptr;
- return factory->vtable->create_lb_policy(exec_ctx, factory, args);
+ return factory->vtable->create_lb_policy(factory, args);
}
diff --git a/src/core/ext/filters/client_channel/lb_policy_factory.h b/src/core/ext/filters/client_channel/lb_policy_factory.h
index 360a42b177..8c1efac042 100644
--- a/src/core/ext/filters/client_channel/lb_policy_factory.h
+++ b/src/core/ext/filters/client_channel/lb_policy_factory.h
@@ -54,7 +54,7 @@ typedef struct grpc_lb_address {
typedef struct grpc_lb_user_data_vtable {
void* (*copy)(void*);
- void (*destroy)(grpc_exec_ctx* exec_ctx, void*);
+ void (*destroy)(void*);
int (*cmp)(void*, void*);
} grpc_lb_user_data_vtable;
@@ -95,8 +95,7 @@ int grpc_lb_addresses_cmp(const grpc_lb_addresses* addresses1,
const grpc_lb_addresses* addresses2);
/** Destroys \a addresses. */
-void grpc_lb_addresses_destroy(grpc_exec_ctx* exec_ctx,
- grpc_lb_addresses* addresses);
+void grpc_lb_addresses_destroy(grpc_lb_addresses* addresses);
/** Returns a channel arg containing \a addresses. */
grpc_arg grpc_lb_addresses_create_channel_arg(
@@ -118,8 +117,7 @@ struct grpc_lb_policy_factory_vtable {
void (*unref)(grpc_lb_policy_factory* factory);
/** Implementation of grpc_lb_policy_factory_create_lb_policy */
- grpc_lb_policy* (*create_lb_policy)(grpc_exec_ctx* exec_ctx,
- grpc_lb_policy_factory* factory,
+ grpc_lb_policy* (*create_lb_policy)(grpc_lb_policy_factory* factory,
grpc_lb_policy_args* args);
/** Name for the LB policy this factory implements */
@@ -131,8 +129,7 @@ void grpc_lb_policy_factory_unref(grpc_lb_policy_factory* factory);
/** Create a lb_policy instance. */
grpc_lb_policy* grpc_lb_policy_factory_create_lb_policy(
- grpc_exec_ctx* exec_ctx, grpc_lb_policy_factory* factory,
- grpc_lb_policy_args* args);
+ grpc_lb_policy_factory* factory, grpc_lb_policy_args* args);
#ifdef __cplusplus
}
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 6e710e86d9..edd0330c6a 100644
--- a/src/core/ext/filters/client_channel/lb_policy_registry.cc
+++ b/src/core/ext/filters/client_channel/lb_policy_registry.cc
@@ -61,10 +61,10 @@ static grpc_lb_policy_factory* lookup_factory(const char* name) {
return nullptr;
}
-grpc_lb_policy* grpc_lb_policy_create(grpc_exec_ctx* exec_ctx, const char* name,
+grpc_lb_policy* grpc_lb_policy_create(const char* name,
grpc_lb_policy_args* args) {
grpc_lb_policy_factory* factory = lookup_factory(name);
grpc_lb_policy* lb_policy =
- grpc_lb_policy_factory_create_lb_policy(exec_ctx, factory, args);
+ grpc_lb_policy_factory_create_lb_policy(factory, args);
return lb_policy;
}
diff --git a/src/core/ext/filters/client_channel/lb_policy_registry.h b/src/core/ext/filters/client_channel/lb_policy_registry.h
index 055f751b57..b66b4d56bb 100644
--- a/src/core/ext/filters/client_channel/lb_policy_registry.h
+++ b/src/core/ext/filters/client_channel/lb_policy_registry.h
@@ -38,7 +38,7 @@ void grpc_register_lb_policy(grpc_lb_policy_factory* factory);
*
* If \a name is NULL, the default factory from \a grpc_lb_policy_registry_init
* will be returned. */
-grpc_lb_policy* grpc_lb_policy_create(grpc_exec_ctx* exec_ctx, const char* name,
+grpc_lb_policy* grpc_lb_policy_create(const char* name,
grpc_lb_policy_args* args);
#ifdef __cplusplus
diff --git a/src/core/ext/filters/client_channel/proxy_mapper.cc b/src/core/ext/filters/client_channel/proxy_mapper.cc
index c6ea5fc680..be85cfcced 100644
--- a/src/core/ext/filters/client_channel/proxy_mapper.cc
+++ b/src/core/ext/filters/client_channel/proxy_mapper.cc
@@ -23,24 +23,22 @@ void grpc_proxy_mapper_init(const grpc_proxy_mapper_vtable* vtable,
mapper->vtable = vtable;
}
-bool grpc_proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
- grpc_proxy_mapper* mapper,
+bool grpc_proxy_mapper_map_name(grpc_proxy_mapper* mapper,
const char* server_uri,
const grpc_channel_args* args,
char** name_to_resolve,
grpc_channel_args** new_args) {
- return mapper->vtable->map_name(exec_ctx, mapper, server_uri, args,
- name_to_resolve, new_args);
+ return mapper->vtable->map_name(mapper, server_uri, args, name_to_resolve,
+ new_args);
}
-bool grpc_proxy_mapper_map_address(grpc_exec_ctx* exec_ctx,
- grpc_proxy_mapper* mapper,
+bool grpc_proxy_mapper_map_address(grpc_proxy_mapper* mapper,
const grpc_resolved_address* address,
const grpc_channel_args* args,
grpc_resolved_address** new_address,
grpc_channel_args** new_args) {
- return mapper->vtable->map_address(exec_ctx, mapper, address, args,
- new_address, new_args);
+ return mapper->vtable->map_address(mapper, address, args, new_address,
+ new_args);
}
void grpc_proxy_mapper_destroy(grpc_proxy_mapper* mapper) {
diff --git a/src/core/ext/filters/client_channel/proxy_mapper.h b/src/core/ext/filters/client_channel/proxy_mapper.h
index bb8259f854..d4a3793e8a 100644
--- a/src/core/ext/filters/client_channel/proxy_mapper.h
+++ b/src/core/ext/filters/client_channel/proxy_mapper.h
@@ -36,14 +36,14 @@ typedef struct {
/// If no proxy is needed, returns false.
/// Otherwise, sets \a name_to_resolve, optionally sets \a new_args,
/// and returns true.
- bool (*map_name)(grpc_exec_ctx* exec_ctx, grpc_proxy_mapper* mapper,
- const char* server_uri, const grpc_channel_args* args,
- char** name_to_resolve, grpc_channel_args** new_args);
+ bool (*map_name)(grpc_proxy_mapper* mapper, const char* server_uri,
+ const grpc_channel_args* args, char** name_to_resolve,
+ grpc_channel_args** new_args);
/// Determines the proxy address to use to contact \a address.
/// If no proxy is needed, returns false.
/// Otherwise, sets \a new_address, optionally sets \a new_args, and
/// returns true.
- bool (*map_address)(grpc_exec_ctx* exec_ctx, grpc_proxy_mapper* mapper,
+ bool (*map_address)(grpc_proxy_mapper* mapper,
const grpc_resolved_address* address,
const grpc_channel_args* args,
grpc_resolved_address** new_address,
@@ -59,15 +59,13 @@ struct grpc_proxy_mapper {
void grpc_proxy_mapper_init(const grpc_proxy_mapper_vtable* vtable,
grpc_proxy_mapper* mapper);
-bool grpc_proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
- grpc_proxy_mapper* mapper,
+bool grpc_proxy_mapper_map_name(grpc_proxy_mapper* mapper,
const char* server_uri,
const grpc_channel_args* args,
char** name_to_resolve,
grpc_channel_args** new_args);
-bool grpc_proxy_mapper_map_address(grpc_exec_ctx* exec_ctx,
- grpc_proxy_mapper* mapper,
+bool grpc_proxy_mapper_map_address(grpc_proxy_mapper* mapper,
const grpc_resolved_address* address,
const grpc_channel_args* args,
grpc_resolved_address** new_address,
diff --git a/src/core/ext/filters/client_channel/proxy_mapper_registry.cc b/src/core/ext/filters/client_channel/proxy_mapper_registry.cc
index 09967eea3c..51778a20cc 100644
--- a/src/core/ext/filters/client_channel/proxy_mapper_registry.cc
+++ b/src/core/ext/filters/client_channel/proxy_mapper_registry.cc
@@ -46,14 +46,13 @@ static void grpc_proxy_mapper_list_register(grpc_proxy_mapper_list* list,
++list->num_mappers;
}
-static bool grpc_proxy_mapper_list_map_name(grpc_exec_ctx* exec_ctx,
- grpc_proxy_mapper_list* list,
+static bool grpc_proxy_mapper_list_map_name(grpc_proxy_mapper_list* list,
const char* server_uri,
const grpc_channel_args* args,
char** name_to_resolve,
grpc_channel_args** new_args) {
for (size_t i = 0; i < list->num_mappers; ++i) {
- if (grpc_proxy_mapper_map_name(exec_ctx, list->list[i], server_uri, args,
+ if (grpc_proxy_mapper_map_name(list->list[i], server_uri, args,
name_to_resolve, new_args)) {
return true;
}
@@ -62,12 +61,12 @@ static bool grpc_proxy_mapper_list_map_name(grpc_exec_ctx* exec_ctx,
}
static bool grpc_proxy_mapper_list_map_address(
- grpc_exec_ctx* exec_ctx, grpc_proxy_mapper_list* list,
- const grpc_resolved_address* address, const grpc_channel_args* args,
- grpc_resolved_address** new_address, grpc_channel_args** new_args) {
+ grpc_proxy_mapper_list* list, const grpc_resolved_address* address,
+ const grpc_channel_args* args, grpc_resolved_address** new_address,
+ grpc_channel_args** new_args) {
for (size_t i = 0; i < list->num_mappers; ++i) {
- if (grpc_proxy_mapper_map_address(exec_ctx, list->list[i], address, args,
- new_address, new_args)) {
+ if (grpc_proxy_mapper_map_address(list->list[i], address, args, new_address,
+ new_args)) {
return true;
}
}
@@ -105,20 +104,17 @@ void grpc_proxy_mapper_register(bool at_start, grpc_proxy_mapper* mapper) {
grpc_proxy_mapper_list_register(&g_proxy_mapper_list, at_start, mapper);
}
-bool grpc_proxy_mappers_map_name(grpc_exec_ctx* exec_ctx,
- const char* server_uri,
+bool grpc_proxy_mappers_map_name(const char* server_uri,
const grpc_channel_args* args,
char** name_to_resolve,
grpc_channel_args** new_args) {
- return grpc_proxy_mapper_list_map_name(exec_ctx, &g_proxy_mapper_list,
- server_uri, args, name_to_resolve,
- new_args);
+ return grpc_proxy_mapper_list_map_name(&g_proxy_mapper_list, server_uri, args,
+ name_to_resolve, new_args);
}
-bool grpc_proxy_mappers_map_address(grpc_exec_ctx* exec_ctx,
- const grpc_resolved_address* address,
+bool grpc_proxy_mappers_map_address(const grpc_resolved_address* address,
const grpc_channel_args* args,
grpc_resolved_address** new_address,
grpc_channel_args** new_args) {
- return grpc_proxy_mapper_list_map_address(
- exec_ctx, &g_proxy_mapper_list, address, args, new_address, new_args);
+ return grpc_proxy_mapper_list_map_address(&g_proxy_mapper_list, address, args,
+ new_address, new_args);
}
diff --git a/src/core/ext/filters/client_channel/proxy_mapper_registry.h b/src/core/ext/filters/client_channel/proxy_mapper_registry.h
index 39c607cefc..efe1df48a6 100644
--- a/src/core/ext/filters/client_channel/proxy_mapper_registry.h
+++ b/src/core/ext/filters/client_channel/proxy_mapper_registry.h
@@ -33,14 +33,12 @@ void grpc_proxy_mapper_registry_shutdown();
/// the list. Otherwise, it will be added to the end.
void grpc_proxy_mapper_register(bool at_start, grpc_proxy_mapper* mapper);
-bool grpc_proxy_mappers_map_name(grpc_exec_ctx* exec_ctx,
- const char* server_uri,
+bool grpc_proxy_mappers_map_name(const char* server_uri,
const grpc_channel_args* args,
char** name_to_resolve,
grpc_channel_args** new_args);
-bool grpc_proxy_mappers_map_address(grpc_exec_ctx* exec_ctx,
- const grpc_resolved_address* address,
+bool grpc_proxy_mappers_map_address(const grpc_resolved_address* address,
const grpc_channel_args* args,
grpc_resolved_address** new_address,
grpc_channel_args** new_args);
diff --git a/src/core/ext/filters/client_channel/resolver.cc b/src/core/ext/filters/client_channel/resolver.cc
index 7e84b98cb9..fdb10d908e 100644
--- a/src/core/ext/filters/client_channel/resolver.cc
+++ b/src/core/ext/filters/client_channel/resolver.cc
@@ -48,8 +48,8 @@ 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) {
+void grpc_resolver_unref(grpc_resolver* resolver, const char* file, int line,
+ const char* reason) {
if (GRPC_TRACER_ON(grpc_trace_resolver_refcount)) {
gpr_atm old_refs = gpr_atm_no_barrier_load(&resolver->refs.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
@@ -57,27 +57,25 @@ void grpc_resolver_unref(grpc_exec_ctx* exec_ctx, grpc_resolver* resolver,
old_refs, old_refs - 1, reason);
}
#else
-void grpc_resolver_unref(grpc_exec_ctx* exec_ctx, grpc_resolver* resolver) {
+void grpc_resolver_unref(grpc_resolver* resolver) {
#endif
if (gpr_unref(&resolver->refs)) {
grpc_combiner* combiner = resolver->combiner;
- resolver->vtable->destroy(exec_ctx, resolver);
- GRPC_COMBINER_UNREF(exec_ctx, combiner, "resolver");
+ resolver->vtable->destroy(resolver);
+ GRPC_COMBINER_UNREF(combiner, "resolver");
}
}
-void grpc_resolver_shutdown_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver) {
- resolver->vtable->shutdown_locked(exec_ctx, resolver);
+void grpc_resolver_shutdown_locked(grpc_resolver* resolver) {
+ resolver->vtable->shutdown_locked(resolver);
}
-void grpc_resolver_channel_saw_error_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver) {
- resolver->vtable->channel_saw_error_locked(exec_ctx, resolver);
+void grpc_resolver_channel_saw_error_locked(grpc_resolver* resolver) {
+ resolver->vtable->channel_saw_error_locked(resolver);
}
-void grpc_resolver_next_locked(grpc_exec_ctx* exec_ctx, grpc_resolver* resolver,
+void grpc_resolver_next_locked(grpc_resolver* resolver,
grpc_channel_args** result,
grpc_closure* on_complete) {
- resolver->vtable->next_locked(exec_ctx, resolver, result, on_complete);
+ resolver->vtable->next_locked(resolver, result, on_complete);
}
diff --git a/src/core/ext/filters/client_channel/resolver.h b/src/core/ext/filters/client_channel/resolver.h
index a0eb0bcfdf..30b0afaf74 100644
--- a/src/core/ext/filters/client_channel/resolver.h
+++ b/src/core/ext/filters/client_channel/resolver.h
@@ -41,43 +41,40 @@ struct grpc_resolver {
};
struct grpc_resolver_vtable {
- void (*destroy)(grpc_exec_ctx* exec_ctx, grpc_resolver* resolver);
- void (*shutdown_locked)(grpc_exec_ctx* exec_ctx, grpc_resolver* resolver);
- void (*channel_saw_error_locked)(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver);
- void (*next_locked)(grpc_exec_ctx* exec_ctx, grpc_resolver* resolver,
- grpc_channel_args** result, grpc_closure* on_complete);
+ void (*destroy)(grpc_resolver* resolver);
+ void (*shutdown_locked)(grpc_resolver* resolver);
+ void (*channel_saw_error_locked)(grpc_resolver* resolver);
+ void (*next_locked)(grpc_resolver* resolver, grpc_channel_args** result,
+ grpc_closure* on_complete);
};
#ifndef NDEBUG
#define GRPC_RESOLVER_REF(p, r) grpc_resolver_ref((p), __FILE__, __LINE__, (r))
-#define GRPC_RESOLVER_UNREF(e, p, r) \
- grpc_resolver_unref((e), (p), __FILE__, __LINE__, (r))
+#define GRPC_RESOLVER_UNREF(p, r) \
+ grpc_resolver_unref((p), __FILE__, __LINE__, (r))
void grpc_resolver_ref(grpc_resolver* policy, const char* file, int line,
const char* reason);
-void grpc_resolver_unref(grpc_exec_ctx* exec_ctx, grpc_resolver* policy,
- const char* file, int line, const char* reason);
+void grpc_resolver_unref(grpc_resolver* policy, const char* file, int line,
+ const char* reason);
#else
#define GRPC_RESOLVER_REF(p, r) grpc_resolver_ref((p))
-#define GRPC_RESOLVER_UNREF(e, p, r) grpc_resolver_unref((e), (p))
+#define GRPC_RESOLVER_UNREF(p, r) grpc_resolver_unref((p))
void grpc_resolver_ref(grpc_resolver* policy);
-void grpc_resolver_unref(grpc_exec_ctx* exec_ctx, grpc_resolver* policy);
+void grpc_resolver_unref(grpc_resolver* policy);
#endif
void grpc_resolver_init(grpc_resolver* resolver,
const grpc_resolver_vtable* vtable,
grpc_combiner* combiner);
-void grpc_resolver_shutdown_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver);
+void grpc_resolver_shutdown_locked(grpc_resolver* resolver);
/** Notification that the channel has seen an error on some address.
Can be used as a hint that re-resolution is desirable soon.
Must be called from the combiner passed as a resolver_arg at construction
time.*/
-void grpc_resolver_channel_saw_error_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver);
+void grpc_resolver_channel_saw_error_locked(grpc_resolver* resolver);
/** Get the next result from the resolver. Expected to set \a *result with
new channel args and then schedule \a on_complete for execution.
@@ -87,7 +84,7 @@ void grpc_resolver_channel_saw_error_locked(grpc_exec_ctx* exec_ctx,
Must be called from the combiner passed as a resolver_arg at construction
time.*/
-void grpc_resolver_next_locked(grpc_exec_ctx* exec_ctx, grpc_resolver* resolver,
+void grpc_resolver_next_locked(grpc_resolver* resolver,
grpc_channel_args** result,
grpc_closure* on_complete);
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 07737b19d2..f6990e5a5c 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
@@ -97,17 +97,14 @@ typedef struct {
char* service_config_json;
} ares_dns_resolver;
-static void dns_ares_destroy(grpc_exec_ctx* exec_ctx, grpc_resolver* r);
+static void dns_ares_destroy(grpc_resolver* r);
-static void dns_ares_start_resolving_locked(grpc_exec_ctx* exec_ctx,
- ares_dns_resolver* r);
-static void dns_ares_maybe_finish_next_locked(grpc_exec_ctx* exec_ctx,
- ares_dns_resolver* r);
+static void dns_ares_start_resolving_locked(ares_dns_resolver* r);
+static void dns_ares_maybe_finish_next_locked(ares_dns_resolver* r);
-static void dns_ares_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_resolver* r);
-static void dns_ares_channel_saw_error_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* r);
-static void dns_ares_next_locked(grpc_exec_ctx* exec_ctx, grpc_resolver* r,
+static void dns_ares_shutdown_locked(grpc_resolver* r);
+static void dns_ares_channel_saw_error_locked(grpc_resolver* r);
+static void dns_ares_next_locked(grpc_resolver* r,
grpc_channel_args** target_result,
grpc_closure* on_complete);
@@ -115,43 +112,39 @@ static const grpc_resolver_vtable dns_ares_resolver_vtable = {
dns_ares_destroy, dns_ares_shutdown_locked,
dns_ares_channel_saw_error_locked, dns_ares_next_locked};
-static void dns_ares_shutdown_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver) {
+static void dns_ares_shutdown_locked(grpc_resolver* resolver) {
ares_dns_resolver* r = (ares_dns_resolver*)resolver;
if (r->have_retry_timer) {
- grpc_timer_cancel(exec_ctx, &r->retry_timer);
+ grpc_timer_cancel(&r->retry_timer);
}
if (r->pending_request != nullptr) {
- grpc_cancel_ares_request(exec_ctx, r->pending_request);
+ grpc_cancel_ares_request(r->pending_request);
}
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"));
+ GRPC_CLOSURE_SCHED(r->next_completion, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Resolver Shutdown"));
r->next_completion = nullptr;
}
}
-static void dns_ares_channel_saw_error_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver) {
+static void dns_ares_channel_saw_error_locked(grpc_resolver* resolver) {
ares_dns_resolver* r = (ares_dns_resolver*)resolver;
if (!r->resolving) {
grpc_backoff_reset(&r->backoff_state);
- dns_ares_start_resolving_locked(exec_ctx, r);
+ dns_ares_start_resolving_locked(r);
}
}
-static void dns_ares_on_retry_timer_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void dns_ares_on_retry_timer_locked(void* arg, grpc_error* error) {
ares_dns_resolver* r = (ares_dns_resolver*)arg;
r->have_retry_timer = false;
if (error == GRPC_ERROR_NONE) {
if (!r->resolving) {
- dns_ares_start_resolving_locked(exec_ctx, r);
+ dns_ares_start_resolving_locked(r);
}
}
- GRPC_RESOLVER_UNREF(exec_ctx, &r->base, "retry-timer");
+ GRPC_RESOLVER_UNREF(&r->base, "retry-timer");
}
static bool value_in_json_array(grpc_json* array, const char* value) {
@@ -226,8 +219,7 @@ static char* choose_service_config(char* service_config_choice_json) {
return service_config;
}
-static void dns_ares_on_resolved_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void dns_ares_on_resolved_locked(void* arg, grpc_error* error) {
ares_dns_resolver* r = (ares_dns_resolver*)arg;
grpc_channel_args* result = nullptr;
GPR_ASSERT(r->resolving);
@@ -268,13 +260,13 @@ static void dns_ares_on_resolved_locked(grpc_exec_ctx* exec_ctx, void* arg,
num_args_to_add);
if (service_config != nullptr) grpc_service_config_destroy(service_config);
gpr_free(service_config_string);
- grpc_lb_addresses_destroy(exec_ctx, r->lb_addresses);
+ grpc_lb_addresses_destroy(r->lb_addresses);
} else {
const char* msg = grpc_error_string(error);
gpr_log(GPR_DEBUG, "dns resolution failed: %s", msg);
grpc_millis next_try =
- grpc_backoff_step(exec_ctx, &r->backoff_state).next_attempt_start_time;
- grpc_millis timeout = next_try - grpc_exec_ctx_now(exec_ctx);
+ grpc_backoff_step(&r->backoff_state).next_attempt_start_time;
+ grpc_millis timeout = next_try - grpc_core::ExecCtx::Get()->Now();
gpr_log(GPR_INFO, "dns resolution failed (will retry): %s",
grpc_error_string(error));
GPR_ASSERT(!r->have_retry_timer);
@@ -285,20 +277,19 @@ static void dns_ares_on_resolved_locked(grpc_exec_ctx* exec_ctx, void* arg,
} else {
gpr_log(GPR_DEBUG, "retrying immediately");
}
- grpc_timer_init(exec_ctx, &r->retry_timer, next_try,
+ grpc_timer_init(&r->retry_timer, next_try,
&r->dns_ares_on_retry_timer_locked);
}
if (r->resolved_result != nullptr) {
- grpc_channel_args_destroy(exec_ctx, r->resolved_result);
+ grpc_channel_args_destroy(r->resolved_result);
}
r->resolved_result = result;
r->resolved_version++;
- dns_ares_maybe_finish_next_locked(exec_ctx, r);
- GRPC_RESOLVER_UNREF(exec_ctx, &r->base, "dns-resolving");
+ dns_ares_maybe_finish_next_locked(r);
+ GRPC_RESOLVER_UNREF(&r->base, "dns-resolving");
}
-static void dns_ares_next_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver,
+static void dns_ares_next_locked(grpc_resolver* resolver,
grpc_channel_args** target_result,
grpc_closure* on_complete) {
gpr_log(GPR_DEBUG, "dns_ares_next is called.");
@@ -308,56 +299,53 @@ static void dns_ares_next_locked(grpc_exec_ctx* exec_ctx,
r->target_result = target_result;
if (r->resolved_version == 0 && !r->resolving) {
grpc_backoff_reset(&r->backoff_state);
- dns_ares_start_resolving_locked(exec_ctx, r);
+ dns_ares_start_resolving_locked(r);
} else {
- dns_ares_maybe_finish_next_locked(exec_ctx, r);
+ dns_ares_maybe_finish_next_locked(r);
}
}
-static void dns_ares_start_resolving_locked(grpc_exec_ctx* exec_ctx,
- ares_dns_resolver* r) {
+static void dns_ares_start_resolving_locked(ares_dns_resolver* r) {
GRPC_RESOLVER_REF(&r->base, "dns-resolving");
GPR_ASSERT(!r->resolving);
r->resolving = true;
r->lb_addresses = nullptr;
r->service_config_json = nullptr;
r->pending_request = grpc_dns_lookup_ares(
- exec_ctx, r->dns_server, r->name_to_resolve, r->default_port,
- r->interested_parties, &r->dns_ares_on_resolved_locked, &r->lb_addresses,
+ r->dns_server, r->name_to_resolve, r->default_port, r->interested_parties,
+ &r->dns_ares_on_resolved_locked, &r->lb_addresses,
true /* check_grpclb */,
r->request_service_config ? &r->service_config_json : nullptr);
}
-static void dns_ares_maybe_finish_next_locked(grpc_exec_ctx* exec_ctx,
- ares_dns_resolver* r) {
+static void dns_ares_maybe_finish_next_locked(ares_dns_resolver* r) {
if (r->next_completion != nullptr &&
r->resolved_version != r->published_version) {
*r->target_result = r->resolved_result == nullptr
? nullptr
: grpc_channel_args_copy(r->resolved_result);
gpr_log(GPR_DEBUG, "dns_ares_maybe_finish_next_locked");
- GRPC_CLOSURE_SCHED(exec_ctx, r->next_completion, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(r->next_completion, GRPC_ERROR_NONE);
r->next_completion = nullptr;
r->published_version = r->resolved_version;
}
}
-static void dns_ares_destroy(grpc_exec_ctx* exec_ctx, grpc_resolver* gr) {
+static void dns_ares_destroy(grpc_resolver* gr) {
gpr_log(GPR_DEBUG, "dns_ares_destroy");
ares_dns_resolver* r = (ares_dns_resolver*)gr;
if (r->resolved_result != nullptr) {
- grpc_channel_args_destroy(exec_ctx, r->resolved_result);
+ grpc_channel_args_destroy(r->resolved_result);
}
- grpc_pollset_set_destroy(exec_ctx, r->interested_parties);
+ grpc_pollset_set_destroy(r->interested_parties);
gpr_free(r->dns_server);
gpr_free(r->name_to_resolve);
gpr_free(r->default_port);
- grpc_channel_args_destroy(exec_ctx, r->channel_args);
+ grpc_channel_args_destroy(r->channel_args);
gpr_free(r);
}
-static grpc_resolver* dns_ares_create(grpc_exec_ctx* exec_ctx,
- grpc_resolver_args* args,
+static grpc_resolver* dns_ares_create(grpc_resolver_args* args,
const char* default_port) {
/* Get name from args. */
const char* path = args->uri->path;
@@ -378,8 +366,7 @@ static grpc_resolver* dns_ares_create(grpc_exec_ctx* exec_ctx,
arg, (grpc_integer_options){false, false, true});
r->interested_parties = grpc_pollset_set_create();
if (args->pollset_set != nullptr) {
- grpc_pollset_set_add_pollset_set(exec_ctx, r->interested_parties,
- args->pollset_set);
+ grpc_pollset_set_add_pollset_set(r->interested_parties, args->pollset_set);
}
grpc_backoff_init(
&r->backoff_state, GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS * 1000,
@@ -404,9 +391,8 @@ static void dns_ares_factory_ref(grpc_resolver_factory* factory) {}
static void dns_ares_factory_unref(grpc_resolver_factory* factory) {}
static grpc_resolver* dns_factory_create_resolver(
- grpc_exec_ctx* exec_ctx, grpc_resolver_factory* factory,
- grpc_resolver_args* args) {
- return dns_ares_create(exec_ctx, args, "https");
+ grpc_resolver_factory* factory, grpc_resolver_args* args) {
+ return dns_ares_create(args, "https");
}
static char* dns_ares_factory_get_default_host_name(
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 0062aa561a..5b5ceef9c4 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
@@ -32,8 +32,7 @@ typedef struct grpc_ares_ev_driver grpc_ares_ev_driver;
/* Start \a ev_driver. It will keep working until all IO on its ares_channel is
done, or grpc_ares_ev_driver_destroy() is called. It may notify the callbacks
bound to its ares_channel when necessary. */
-void grpc_ares_ev_driver_start(grpc_exec_ctx* exec_ctx,
- grpc_ares_ev_driver* ev_driver);
+void grpc_ares_ev_driver_start(grpc_ares_ev_driver* ev_driver);
/* Returns the ares_channel owned by \a ev_driver. To bind a c-ares query to
\a ev_driver, use the ares_channel owned by \a ev_driver as the arg of the
@@ -51,8 +50,7 @@ grpc_error* grpc_ares_ev_driver_create(grpc_ares_ev_driver** ev_driver,
void grpc_ares_ev_driver_destroy(grpc_ares_ev_driver* ev_driver);
/* Shutdown all the grpc_fds used by \a ev_driver */
-void grpc_ares_ev_driver_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_ares_ev_driver* ev_driver);
+void grpc_ares_ev_driver_shutdown(grpc_ares_ev_driver* ev_driver);
#ifdef __cplusplus
}
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 4cb068a41d..40e264504c 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
@@ -77,8 +77,7 @@ struct grpc_ares_ev_driver {
bool shutting_down;
};
-static void grpc_ares_notify_on_event_locked(grpc_exec_ctx* exec_ctx,
- grpc_ares_ev_driver* ev_driver);
+static void grpc_ares_notify_on_event_locked(grpc_ares_ev_driver* ev_driver);
static grpc_ares_ev_driver* grpc_ares_ev_driver_ref(
grpc_ares_ev_driver* ev_driver) {
@@ -98,7 +97,7 @@ static void grpc_ares_ev_driver_unref(grpc_ares_ev_driver* ev_driver) {
}
}
-static void fd_node_destroy(grpc_exec_ctx* exec_ctx, fd_node* fdn) {
+static void fd_node_destroy(fd_node* fdn) {
gpr_log(GPR_DEBUG, "delete fd: %d", grpc_fd_wrapped_fd(fdn->fd));
GPR_ASSERT(!fdn->readable_registered);
GPR_ASSERT(!fdn->writable_registered);
@@ -106,21 +105,20 @@ 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, nullptr, nullptr, true /* already_closed */,
+ grpc_fd_orphan(fdn->fd, nullptr, nullptr, true /* already_closed */,
"c-ares query finished");
gpr_free(fdn);
}
-static void fd_node_shutdown(grpc_exec_ctx* exec_ctx, fd_node* fdn) {
+static void fd_node_shutdown(fd_node* fdn) {
gpr_mu_lock(&fdn->mu);
fdn->shutting_down = true;
if (!fdn->readable_registered && !fdn->writable_registered) {
gpr_mu_unlock(&fdn->mu);
- fd_node_destroy(exec_ctx, fdn);
+ fd_node_destroy(fdn);
} else {
grpc_fd_shutdown(
- exec_ctx, fdn->fd,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("c-ares fd shutdown"));
+ fdn->fd, GRPC_ERROR_CREATE_FROM_STATIC_STRING("c-ares fd shutdown"));
gpr_mu_unlock(&fdn->mu);
}
}
@@ -160,15 +158,13 @@ void grpc_ares_ev_driver_destroy(grpc_ares_ev_driver* ev_driver) {
grpc_ares_ev_driver_unref(ev_driver);
}
-void grpc_ares_ev_driver_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_ares_ev_driver* ev_driver) {
+void grpc_ares_ev_driver_shutdown(grpc_ares_ev_driver* ev_driver) {
gpr_mu_lock(&ev_driver->mu);
ev_driver->shutting_down = true;
fd_node* fn = ev_driver->fds;
while (fn != nullptr) {
- grpc_fd_shutdown(
- exec_ctx, fn->fd,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("grpc_ares_ev_driver_shutdown"));
+ grpc_fd_shutdown(fn->fd, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "grpc_ares_ev_driver_shutdown"));
fn = fn->next;
}
gpr_mu_unlock(&ev_driver->mu);
@@ -199,8 +195,7 @@ static bool grpc_ares_is_fd_still_readable(grpc_ares_ev_driver* ev_driver,
return ioctl(fd, FIONREAD, &bytes_available) == 0 && bytes_available > 0;
}
-static void on_readable_cb(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_readable_cb(void* arg, grpc_error* error) {
fd_node* fdn = (fd_node*)arg;
grpc_ares_ev_driver* ev_driver = fdn->ev_driver;
gpr_mu_lock(&fdn->mu);
@@ -208,7 +203,7 @@ static void on_readable_cb(grpc_exec_ctx* exec_ctx, void* arg,
fdn->readable_registered = false;
if (fdn->shutting_down && !fdn->writable_registered) {
gpr_mu_unlock(&fdn->mu);
- fd_node_destroy(exec_ctx, fdn);
+ fd_node_destroy(fdn);
grpc_ares_ev_driver_unref(ev_driver);
return;
}
@@ -229,13 +224,12 @@ static void on_readable_cb(grpc_exec_ctx* exec_ctx, void* arg,
ares_cancel(ev_driver->channel);
}
gpr_mu_lock(&ev_driver->mu);
- grpc_ares_notify_on_event_locked(exec_ctx, ev_driver);
+ grpc_ares_notify_on_event_locked(ev_driver);
gpr_mu_unlock(&ev_driver->mu);
grpc_ares_ev_driver_unref(ev_driver);
}
-static void on_writable_cb(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_writable_cb(void* arg, grpc_error* error) {
fd_node* fdn = (fd_node*)arg;
grpc_ares_ev_driver* ev_driver = fdn->ev_driver;
gpr_mu_lock(&fdn->mu);
@@ -243,7 +237,7 @@ static void on_writable_cb(grpc_exec_ctx* exec_ctx, void* arg,
fdn->writable_registered = false;
if (fdn->shutting_down && !fdn->readable_registered) {
gpr_mu_unlock(&fdn->mu);
- fd_node_destroy(exec_ctx, fdn);
+ fd_node_destroy(fdn);
grpc_ares_ev_driver_unref(ev_driver);
return;
}
@@ -262,7 +256,7 @@ static void on_writable_cb(grpc_exec_ctx* exec_ctx, void* arg,
ares_cancel(ev_driver->channel);
}
gpr_mu_lock(&ev_driver->mu);
- grpc_ares_notify_on_event_locked(exec_ctx, ev_driver);
+ grpc_ares_notify_on_event_locked(ev_driver);
gpr_mu_unlock(&ev_driver->mu);
grpc_ares_ev_driver_unref(ev_driver);
}
@@ -273,8 +267,7 @@ ares_channel* grpc_ares_ev_driver_get_channel(grpc_ares_ev_driver* ev_driver) {
// Get the file descriptors used by the ev_driver's ares channel, register
// driver_closure with these filedescriptors.
-static void grpc_ares_notify_on_event_locked(grpc_exec_ctx* exec_ctx,
- grpc_ares_ev_driver* ev_driver) {
+static void grpc_ares_notify_on_event_locked(grpc_ares_ev_driver* ev_driver) {
fd_node* new_list = nullptr;
if (!ev_driver->shutting_down) {
ares_socket_t socks[ARES_GETSOCK_MAXNUM];
@@ -300,7 +293,7 @@ static void grpc_ares_notify_on_event_locked(grpc_exec_ctx* exec_ctx,
grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&fdn->write_closure, on_writable_cb, fdn,
grpc_schedule_on_exec_ctx);
- grpc_pollset_set_add_fd(exec_ctx, ev_driver->pollset_set, fdn->fd);
+ grpc_pollset_set_add_fd(ev_driver->pollset_set, fdn->fd);
gpr_free(fd_name);
}
fdn->next = new_list;
@@ -312,7 +305,7 @@ static void grpc_ares_notify_on_event_locked(grpc_exec_ctx* exec_ctx,
!fdn->readable_registered) {
grpc_ares_ev_driver_ref(ev_driver);
gpr_log(GPR_DEBUG, "notify read on: %d", grpc_fd_wrapped_fd(fdn->fd));
- grpc_fd_notify_on_read(exec_ctx, fdn->fd, &fdn->read_closure);
+ grpc_fd_notify_on_read(fdn->fd, &fdn->read_closure);
fdn->readable_registered = true;
}
// Register write_closure if the socket is writable and write_closure
@@ -322,7 +315,7 @@ static void grpc_ares_notify_on_event_locked(grpc_exec_ctx* exec_ctx,
gpr_log(GPR_DEBUG, "notify write on: %d",
grpc_fd_wrapped_fd(fdn->fd));
grpc_ares_ev_driver_ref(ev_driver);
- grpc_fd_notify_on_write(exec_ctx, fdn->fd, &fdn->write_closure);
+ grpc_fd_notify_on_write(fdn->fd, &fdn->write_closure);
fdn->writable_registered = true;
}
gpr_mu_unlock(&fdn->mu);
@@ -335,7 +328,7 @@ static void grpc_ares_notify_on_event_locked(grpc_exec_ctx* exec_ctx,
while (ev_driver->fds != nullptr) {
fd_node* cur = ev_driver->fds;
ev_driver->fds = ev_driver->fds->next;
- fd_node_shutdown(exec_ctx, cur);
+ fd_node_shutdown(cur);
}
ev_driver->fds = new_list;
// If the ev driver has no working fd, all the tasks are done.
@@ -345,12 +338,11 @@ static void grpc_ares_notify_on_event_locked(grpc_exec_ctx* exec_ctx,
}
}
-void grpc_ares_ev_driver_start(grpc_exec_ctx* exec_ctx,
- grpc_ares_ev_driver* ev_driver) {
+void grpc_ares_ev_driver_start(grpc_ares_ev_driver* ev_driver) {
gpr_mu_lock(&ev_driver->mu);
if (!ev_driver->working) {
ev_driver->working = true;
- grpc_ares_notify_on_event_locked(exec_ctx, ev_driver);
+ grpc_ares_notify_on_event_locked(ev_driver);
}
gpr_mu_unlock(&ev_driver->mu);
}
diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
index 7846576c11..d4b7f0b6c9 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
@@ -96,24 +96,12 @@ static void grpc_ares_request_ref(grpc_ares_request* r) {
gpr_ref(&r->pending_queries);
}
-static void grpc_ares_request_unref(grpc_exec_ctx* exec_ctx,
- grpc_ares_request* r) {
+static void grpc_ares_request_unref(grpc_ares_request* r) {
/* If there are no pending queries, invoke on_done callback and destroy the
request */
if (gpr_unref(&r->pending_queries)) {
/* TODO(zyc): Sort results with RFC6724 before invoking on_done. */
- if (exec_ctx == 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
- acquire locks in on_done. ares_dns_resolver is using combiner to
- protect resources needed by on_done. */
- grpc_exec_ctx new_exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CLOSURE_SCHED(&new_exec_ctx, r->on_done, r->error);
- grpc_exec_ctx_finish(&new_exec_ctx);
- } else {
- GRPC_CLOSURE_SCHED(exec_ctx, r->on_done, r->error);
- }
+ GRPC_CLOSURE_SCHED(r->on_done, r->error);
gpr_mu_destroy(&r->mu);
grpc_ares_ev_driver_destroy(r->ev_driver);
gpr_free(r);
@@ -133,9 +121,8 @@ static grpc_ares_hostbyname_request* create_hostbyname_request(
return hr;
}
-static void destroy_hostbyname_request(grpc_exec_ctx* exec_ctx,
- grpc_ares_hostbyname_request* hr) {
- grpc_ares_request_unref(exec_ctx, hr->parent_request);
+static void destroy_hostbyname_request(grpc_ares_hostbyname_request* hr) {
+ grpc_ares_request_unref(hr->parent_request);
gpr_free(hr->host);
gpr_free(hr);
}
@@ -220,13 +207,13 @@ static void on_hostbyname_done_cb(void* arg, int status, int timeouts,
}
}
gpr_mu_unlock(&r->mu);
- destroy_hostbyname_request(nullptr, hr);
+ destroy_hostbyname_request(hr);
}
static void on_srv_query_done_cb(void* arg, int status, int timeouts,
unsigned char* abuf, int alen) {
grpc_ares_request* r = (grpc_ares_request*)arg;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_DEBUG, "on_query_srv_done_cb");
if (status == ARES_SUCCESS) {
gpr_log(GPR_DEBUG, "on_query_srv_done_cb ARES_SUCCESS");
@@ -246,7 +233,7 @@ static void on_srv_query_done_cb(void* arg, int status, int timeouts,
r, srv_it->host, htons(srv_it->port), true /* is_balancer */);
ares_gethostbyname(*channel, hr->host, AF_INET, on_hostbyname_done_cb,
hr);
- grpc_ares_ev_driver_start(&exec_ctx, r->ev_driver);
+ grpc_ares_ev_driver_start(r->ev_driver);
}
}
if (reply != nullptr) {
@@ -264,8 +251,7 @@ static void on_srv_query_done_cb(void* arg, int status, int timeouts,
r->error = grpc_error_add_child(error, r->error);
}
}
- grpc_ares_request_unref(&exec_ctx, r);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_ares_request_unref(r);
}
static const char g_service_config_attribute_prefix[] = "grpc_config=";
@@ -323,14 +309,13 @@ fail:
}
done:
gpr_mu_unlock(&r->mu);
- grpc_ares_request_unref(nullptr, r);
+ grpc_ares_request_unref(r);
}
static grpc_ares_request* grpc_dns_lookup_ares_impl(
- grpc_exec_ctx* exec_ctx, const char* dns_server, const char* name,
- const char* default_port, grpc_pollset_set* interested_parties,
- grpc_closure* on_done, grpc_lb_addresses** addrs, bool check_grpclb,
- char** service_config_json) {
+ const char* dns_server, const char* name, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json) {
grpc_error* error = GRPC_ERROR_NONE;
grpc_ares_hostbyname_request* hr = nullptr;
grpc_ares_request* r = nullptr;
@@ -437,28 +422,28 @@ static grpc_ares_request* grpc_dns_lookup_ares_impl(
gpr_free(config_name);
}
/* TODO(zyc): Handle CNAME records here. */
- grpc_ares_ev_driver_start(exec_ctx, r->ev_driver);
- grpc_ares_request_unref(exec_ctx, r);
+ grpc_ares_ev_driver_start(r->ev_driver);
+ grpc_ares_request_unref(r);
gpr_free(host);
gpr_free(port);
return r;
error_cleanup:
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
+ GRPC_CLOSURE_SCHED(on_done, error);
gpr_free(host);
gpr_free(port);
return nullptr;
}
grpc_ares_request* (*grpc_dns_lookup_ares)(
- grpc_exec_ctx* exec_ctx, const char* dns_server, const char* name,
- const char* default_port, grpc_pollset_set* interested_parties,
- grpc_closure* on_done, grpc_lb_addresses** addrs, bool check_grpclb,
+ const char* dns_server, const char* name, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** addrs, bool check_grpclb,
char** service_config_json) = grpc_dns_lookup_ares_impl;
-void grpc_cancel_ares_request(grpc_exec_ctx* exec_ctx, grpc_ares_request* r) {
+void grpc_cancel_ares_request(grpc_ares_request* r) {
if (grpc_dns_lookup_ares == grpc_dns_lookup_ares_impl) {
- grpc_ares_ev_driver_shutdown(exec_ctx, r->ev_driver);
+ grpc_ares_ev_driver_shutdown(r->ev_driver);
}
}
@@ -501,8 +486,7 @@ typedef struct grpc_resolve_address_ares_request {
grpc_closure on_dns_lookup_done;
} grpc_resolve_address_ares_request;
-static void on_dns_lookup_done_cb(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_dns_lookup_done_cb(void* arg, grpc_error* error) {
grpc_resolve_address_ares_request* r =
(grpc_resolve_address_ares_request*)arg;
grpc_resolved_addresses** resolved_addresses = r->addrs_out;
@@ -520,14 +504,12 @@ static void on_dns_lookup_done_cb(grpc_exec_ctx* exec_ctx, void* arg,
&r->lb_addrs->addresses[i].address, sizeof(grpc_resolved_address));
}
}
- GRPC_CLOSURE_SCHED(exec_ctx, r->on_resolve_address_done,
- GRPC_ERROR_REF(error));
- grpc_lb_addresses_destroy(exec_ctx, r->lb_addrs);
+ GRPC_CLOSURE_SCHED(r->on_resolve_address_done, GRPC_ERROR_REF(error));
+ grpc_lb_addresses_destroy(r->lb_addrs);
gpr_free(r);
}
-static void grpc_resolve_address_ares_impl(grpc_exec_ctx* exec_ctx,
- const char* name,
+static void grpc_resolve_address_ares_impl(const char* name,
const char* default_port,
grpc_pollset_set* interested_parties,
grpc_closure* on_done,
@@ -539,14 +521,14 @@ 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, nullptr /* dns_server */, name, default_port,
+ grpc_dns_lookup_ares(nullptr /* dns_server */, name, default_port,
interested_parties, &r->on_dns_lookup_done, &r->lb_addrs,
false /* check_grpclb */,
nullptr /* service_config_json */);
}
void (*grpc_resolve_address_ares)(
- grpc_exec_ctx* exec_ctx, const char* name, const char* default_port,
+ const char* name, const char* default_port,
grpc_pollset_set* interested_parties, grpc_closure* on_done,
grpc_resolved_addresses** addrs) = grpc_resolve_address_ares_impl;
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..46f2a894df 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
@@ -36,8 +36,7 @@ typedef struct grpc_ares_request grpc_ares_request;
must be called at least once before this function. \a on_done may be
called directly in this function without being scheduled with \a exec_ctx,
so it must not try to acquire locks that are being held by the caller. */
-extern void (*grpc_resolve_address_ares)(grpc_exec_ctx* exec_ctx,
- const char* name,
+extern void (*grpc_resolve_address_ares)(const char* name,
const char* default_port,
grpc_pollset_set* interested_parties,
grpc_closure* on_done,
@@ -51,14 +50,13 @@ extern void (*grpc_resolve_address_ares)(grpc_exec_ctx* exec_ctx,
scheduled with \a exec_ctx, so it must not try to acquire locks that are
being held by the caller. */
extern grpc_ares_request* (*grpc_dns_lookup_ares)(
- grpc_exec_ctx* exec_ctx, const char* dns_server, const char* name,
- const char* default_port, grpc_pollset_set* interested_parties,
- grpc_closure* on_done, grpc_lb_addresses** addresses, bool check_grpclb,
+ const char* dns_server, const char* name, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** addresses, bool check_grpclb,
char** service_config_json);
/* Cancel the pending grpc_ares_request \a request */
-void grpc_cancel_ares_request(grpc_exec_ctx* exec_ctx,
- grpc_ares_request* request);
+void grpc_cancel_ares_request(grpc_ares_request* request);
/* Initialize gRPC ares wrapper. Must be called at least once before
grpc_resolve_address_ares(). */
diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc
index a68a7c47fb..a184cf2d57 100644
--- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc
+++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc
@@ -26,34 +26,32 @@ struct grpc_ares_request {
};
static grpc_ares_request* grpc_dns_lookup_ares_impl(
- grpc_exec_ctx* exec_ctx, const char* dns_server, const char* name,
- const char* default_port, grpc_pollset_set* interested_parties,
- grpc_closure* on_done, grpc_lb_addresses** addrs, bool check_grpclb,
- char** service_config_json) {
+ const char* dns_server, const char* name, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json) {
return NULL;
}
grpc_ares_request* (*grpc_dns_lookup_ares)(
- grpc_exec_ctx* exec_ctx, const char* dns_server, const char* name,
- const char* default_port, grpc_pollset_set* interested_parties,
- grpc_closure* on_done, grpc_lb_addresses** addrs, bool check_grpclb,
+ const char* dns_server, const char* name, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** addrs, bool check_grpclb,
char** service_config_json) = grpc_dns_lookup_ares_impl;
-void grpc_cancel_ares_request(grpc_exec_ctx* exec_ctx, grpc_ares_request* r) {}
+void grpc_cancel_ares_request(grpc_ares_request* r) {}
grpc_error* grpc_ares_init(void) { return GRPC_ERROR_NONE; }
void grpc_ares_cleanup(void) {}
-static void grpc_resolve_address_ares_impl(grpc_exec_ctx* exec_ctx,
- const char* name,
+static void grpc_resolve_address_ares_impl(const char* name,
const char* default_port,
grpc_pollset_set* interested_parties,
grpc_closure* on_done,
grpc_resolved_addresses** addrs) {}
void (*grpc_resolve_address_ares)(
- grpc_exec_ctx* exec_ctx, const char* name, const char* default_port,
+ const char* name, const char* default_port,
grpc_pollset_set* interested_parties, grpc_closure* on_done,
grpc_resolved_addresses** addrs) = grpc_resolve_address_ares_impl;
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 589c74807f..deda28a3c1 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
@@ -76,49 +76,42 @@ typedef struct {
grpc_resolved_addresses* addresses;
} dns_resolver;
-static void dns_destroy(grpc_exec_ctx* exec_ctx, grpc_resolver* r);
+static void dns_destroy(grpc_resolver* r);
-static void dns_start_resolving_locked(grpc_exec_ctx* exec_ctx,
- dns_resolver* r);
-static void dns_maybe_finish_next_locked(grpc_exec_ctx* exec_ctx,
- dns_resolver* r);
+static void dns_start_resolving_locked(dns_resolver* r);
+static void dns_maybe_finish_next_locked(dns_resolver* r);
-static void dns_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_resolver* r);
-static void dns_channel_saw_error_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* r);
-static void dns_next_locked(grpc_exec_ctx* exec_ctx, grpc_resolver* r,
- grpc_channel_args** target_result,
+static void dns_shutdown_locked(grpc_resolver* r);
+static void dns_channel_saw_error_locked(grpc_resolver* r);
+static void dns_next_locked(grpc_resolver* r, grpc_channel_args** target_result,
grpc_closure* on_complete);
static const grpc_resolver_vtable dns_resolver_vtable = {
dns_destroy, dns_shutdown_locked, dns_channel_saw_error_locked,
dns_next_locked};
-static void dns_shutdown_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver) {
+static void dns_shutdown_locked(grpc_resolver* resolver) {
dns_resolver* r = (dns_resolver*)resolver;
if (r->have_retry_timer) {
- grpc_timer_cancel(exec_ctx, &r->retry_timer);
+ grpc_timer_cancel(&r->retry_timer);
}
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"));
+ GRPC_CLOSURE_SCHED(r->next_completion, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Resolver Shutdown"));
r->next_completion = nullptr;
}
}
-static void dns_channel_saw_error_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver) {
+static void dns_channel_saw_error_locked(grpc_resolver* resolver) {
dns_resolver* r = (dns_resolver*)resolver;
if (!r->resolving) {
grpc_backoff_reset(&r->backoff_state);
- dns_start_resolving_locked(exec_ctx, r);
+ dns_start_resolving_locked(r);
}
}
-static void dns_next_locked(grpc_exec_ctx* exec_ctx, grpc_resolver* resolver,
+static void dns_next_locked(grpc_resolver* resolver,
grpc_channel_args** target_result,
grpc_closure* on_complete) {
dns_resolver* r = (dns_resolver*)resolver;
@@ -127,28 +120,26 @@ static void dns_next_locked(grpc_exec_ctx* exec_ctx, grpc_resolver* resolver,
r->target_result = target_result;
if (r->resolved_version == 0 && !r->resolving) {
grpc_backoff_reset(&r->backoff_state);
- dns_start_resolving_locked(exec_ctx, r);
+ dns_start_resolving_locked(r);
} else {
- dns_maybe_finish_next_locked(exec_ctx, r);
+ dns_maybe_finish_next_locked(r);
}
}
-static void dns_on_retry_timer_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void dns_on_retry_timer_locked(void* arg, grpc_error* error) {
dns_resolver* r = (dns_resolver*)arg;
r->have_retry_timer = false;
if (error == GRPC_ERROR_NONE) {
if (!r->resolving) {
- dns_start_resolving_locked(exec_ctx, r);
+ dns_start_resolving_locked(r);
}
}
- GRPC_RESOLVER_UNREF(exec_ctx, &r->base, "retry-timer");
+ GRPC_RESOLVER_UNREF(&r->base, "retry-timer");
}
-static void dns_on_resolved_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void dns_on_resolved_locked(void* arg, grpc_error* error) {
dns_resolver* r = (dns_resolver*)arg;
grpc_channel_args* result = nullptr;
GPR_ASSERT(r->resolving);
@@ -168,11 +159,11 @@ static void dns_on_resolved_locked(grpc_exec_ctx* exec_ctx, void* arg,
grpc_arg new_arg = grpc_lb_addresses_create_channel_arg(addresses);
result = grpc_channel_args_copy_and_add(r->channel_args, &new_arg, 1);
grpc_resolved_addresses_destroy(r->addresses);
- grpc_lb_addresses_destroy(exec_ctx, addresses);
+ grpc_lb_addresses_destroy(addresses);
} else {
grpc_millis next_try =
- grpc_backoff_step(exec_ctx, &r->backoff_state).next_attempt_start_time;
- grpc_millis timeout = next_try - grpc_exec_ctx_now(exec_ctx);
+ grpc_backoff_step(&r->backoff_state).next_attempt_start_time;
+ grpc_millis timeout = next_try - grpc_core::ExecCtx::Get()->Now();
gpr_log(GPR_INFO, "dns resolution failed (will retry): %s",
grpc_error_string(error));
GPR_ASSERT(!r->have_retry_timer);
@@ -185,59 +176,56 @@ static void dns_on_resolved_locked(grpc_exec_ctx* exec_ctx, void* arg,
}
GRPC_CLOSURE_INIT(&r->on_retry, dns_on_retry_timer_locked, r,
grpc_combiner_scheduler(r->base.combiner));
- grpc_timer_init(exec_ctx, &r->retry_timer, next_try, &r->on_retry);
+ grpc_timer_init(&r->retry_timer, next_try, &r->on_retry);
}
if (r->resolved_result != nullptr) {
- grpc_channel_args_destroy(exec_ctx, r->resolved_result);
+ grpc_channel_args_destroy(r->resolved_result);
}
r->resolved_result = result;
r->resolved_version++;
- dns_maybe_finish_next_locked(exec_ctx, r);
+ dns_maybe_finish_next_locked(r);
GRPC_ERROR_UNREF(error);
- GRPC_RESOLVER_UNREF(exec_ctx, &r->base, "dns-resolving");
+ GRPC_RESOLVER_UNREF(&r->base, "dns-resolving");
}
-static void dns_start_resolving_locked(grpc_exec_ctx* exec_ctx,
- dns_resolver* r) {
+static void dns_start_resolving_locked(dns_resolver* r) {
GRPC_RESOLVER_REF(&r->base, "dns-resolving");
GPR_ASSERT(!r->resolving);
r->resolving = true;
r->addresses = nullptr;
grpc_resolve_address(
- exec_ctx, r->name_to_resolve, r->default_port, r->interested_parties,
+ r->name_to_resolve, r->default_port, r->interested_parties,
GRPC_CLOSURE_CREATE(dns_on_resolved_locked, r,
grpc_combiner_scheduler(r->base.combiner)),
&r->addresses);
}
-static void dns_maybe_finish_next_locked(grpc_exec_ctx* exec_ctx,
- dns_resolver* r) {
+static void dns_maybe_finish_next_locked(dns_resolver* r) {
if (r->next_completion != nullptr &&
r->resolved_version != r->published_version) {
*r->target_result = r->resolved_result == nullptr
? nullptr
: grpc_channel_args_copy(r->resolved_result);
- GRPC_CLOSURE_SCHED(exec_ctx, r->next_completion, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(r->next_completion, GRPC_ERROR_NONE);
r->next_completion = nullptr;
r->published_version = r->resolved_version;
}
}
-static void dns_destroy(grpc_exec_ctx* exec_ctx, grpc_resolver* gr) {
+static void dns_destroy(grpc_resolver* gr) {
dns_resolver* r = (dns_resolver*)gr;
if (r->resolved_result != nullptr) {
- grpc_channel_args_destroy(exec_ctx, r->resolved_result);
+ grpc_channel_args_destroy(r->resolved_result);
}
- grpc_pollset_set_destroy(exec_ctx, r->interested_parties);
+ grpc_pollset_set_destroy(r->interested_parties);
gpr_free(r->name_to_resolve);
gpr_free(r->default_port);
- grpc_channel_args_destroy(exec_ctx, r->channel_args);
+ grpc_channel_args_destroy(r->channel_args);
gpr_free(r);
}
-static grpc_resolver* dns_create(grpc_exec_ctx* exec_ctx,
- grpc_resolver_args* args,
+static grpc_resolver* dns_create(grpc_resolver_args* args,
const char* default_port) {
if (0 != strcmp(args->uri->authority, "")) {
gpr_log(GPR_ERROR, "authority based dns uri's not supported");
@@ -254,8 +242,7 @@ static grpc_resolver* dns_create(grpc_exec_ctx* exec_ctx,
r->channel_args = grpc_channel_args_copy(args->args);
r->interested_parties = grpc_pollset_set_create();
if (args->pollset_set != nullptr) {
- grpc_pollset_set_add_pollset_set(exec_ctx, r->interested_parties,
- args->pollset_set);
+ grpc_pollset_set_add_pollset_set(r->interested_parties, args->pollset_set);
}
grpc_backoff_init(
&r->backoff_state, GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS * 1000,
@@ -274,9 +261,8 @@ static void dns_factory_ref(grpc_resolver_factory* factory) {}
static void dns_factory_unref(grpc_resolver_factory* factory) {}
static grpc_resolver* dns_factory_create_resolver(
- grpc_exec_ctx* exec_ctx, grpc_resolver_factory* factory,
- grpc_resolver_args* args) {
- return dns_create(exec_ctx, args, "https");
+ grpc_resolver_factory* factory, grpc_resolver_args* args) {
+ return dns_create(args, "https");
}
static char* dns_factory_get_default_host_name(grpc_resolver_factory* factory,
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 85d7090144..74840811d9 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
@@ -67,57 +67,52 @@ typedef struct {
grpc_channel_args** target_result;
} fake_resolver;
-static void fake_resolver_destroy(grpc_exec_ctx* exec_ctx, grpc_resolver* gr) {
+static void fake_resolver_destroy(grpc_resolver* gr) {
fake_resolver* r = (fake_resolver*)gr;
- grpc_channel_args_destroy(exec_ctx, r->next_results);
- grpc_channel_args_destroy(exec_ctx, r->results_upon_error);
- grpc_channel_args_destroy(exec_ctx, r->channel_args);
+ grpc_channel_args_destroy(r->next_results);
+ grpc_channel_args_destroy(r->results_upon_error);
+ grpc_channel_args_destroy(r->channel_args);
gpr_free(r);
}
-static void fake_resolver_shutdown_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver) {
+static void fake_resolver_shutdown_locked(grpc_resolver* resolver) {
fake_resolver* r = (fake_resolver*)resolver;
if (r->next_completion != nullptr) {
*r->target_result = nullptr;
- GRPC_CLOSURE_SCHED(
- exec_ctx, r->next_completion,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resolver Shutdown"));
+ GRPC_CLOSURE_SCHED(r->next_completion, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Resolver Shutdown"));
r->next_completion = nullptr;
}
}
-static void fake_resolver_maybe_finish_next_locked(grpc_exec_ctx* exec_ctx,
- fake_resolver* r) {
+static void fake_resolver_maybe_finish_next_locked(fake_resolver* r) {
if (r->next_completion != nullptr && r->next_results != nullptr) {
*r->target_result =
grpc_channel_args_union(r->next_results, r->channel_args);
- grpc_channel_args_destroy(exec_ctx, r->next_results);
+ grpc_channel_args_destroy(r->next_results);
r->next_results = nullptr;
- GRPC_CLOSURE_SCHED(exec_ctx, r->next_completion, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(r->next_completion, GRPC_ERROR_NONE);
r->next_completion = nullptr;
}
}
-static void fake_resolver_channel_saw_error_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver) {
+static void fake_resolver_channel_saw_error_locked(grpc_resolver* resolver) {
fake_resolver* r = (fake_resolver*)resolver;
if (r->next_results == nullptr && r->results_upon_error != nullptr) {
// Pretend we re-resolved.
r->next_results = grpc_channel_args_copy(r->results_upon_error);
}
- fake_resolver_maybe_finish_next_locked(exec_ctx, r);
+ fake_resolver_maybe_finish_next_locked(r);
}
-static void fake_resolver_next_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver,
+static void fake_resolver_next_locked(grpc_resolver* resolver,
grpc_channel_args** target_result,
grpc_closure* on_complete) {
fake_resolver* r = (fake_resolver*)resolver;
GPR_ASSERT(!r->next_completion);
r->next_completion = on_complete;
r->target_result = target_result;
- fake_resolver_maybe_finish_next_locked(exec_ctx, r);
+ fake_resolver_maybe_finish_next_locked(r);
}
static const grpc_resolver_vtable fake_resolver_vtable = {
@@ -157,33 +152,31 @@ typedef struct set_response_closure_arg {
grpc_channel_args* next_response;
} set_response_closure_arg;
-static void set_response_closure_fn(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void set_response_closure_fn(void* arg, grpc_error* error) {
set_response_closure_arg* closure_arg = (set_response_closure_arg*)arg;
grpc_fake_resolver_response_generator* generator = closure_arg->generator;
fake_resolver* r = generator->resolver;
if (r->next_results != nullptr) {
- grpc_channel_args_destroy(exec_ctx, r->next_results);
+ grpc_channel_args_destroy(r->next_results);
}
r->next_results = closure_arg->next_response;
if (r->results_upon_error != nullptr) {
- grpc_channel_args_destroy(exec_ctx, r->results_upon_error);
+ grpc_channel_args_destroy(r->results_upon_error);
}
r->results_upon_error = grpc_channel_args_copy(closure_arg->next_response);
gpr_free(closure_arg);
- fake_resolver_maybe_finish_next_locked(exec_ctx, r);
+ fake_resolver_maybe_finish_next_locked(r);
}
void grpc_fake_resolver_response_generator_set_response(
- grpc_exec_ctx* exec_ctx, grpc_fake_resolver_response_generator* generator,
+ grpc_fake_resolver_response_generator* generator,
grpc_channel_args* next_response) {
GPR_ASSERT(generator->resolver != nullptr);
set_response_closure_arg* closure_arg =
(set_response_closure_arg*)gpr_zalloc(sizeof(*closure_arg));
closure_arg->generator = generator;
closure_arg->next_response = grpc_channel_args_copy(next_response);
- GRPC_CLOSURE_SCHED(exec_ctx,
- GRPC_CLOSURE_INIT(&closure_arg->set_response_closure,
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_INIT(&closure_arg->set_response_closure,
set_response_closure_fn, closure_arg,
grpc_combiner_scheduler(
generator->resolver->base.combiner)),
@@ -195,7 +188,7 @@ static void* response_generator_arg_copy(void* p) {
(grpc_fake_resolver_response_generator*)p);
}
-static void response_generator_arg_destroy(grpc_exec_ctx* exec_ctx, void* p) {
+static void response_generator_arg_destroy(void* p) {
grpc_fake_resolver_response_generator_unref(
(grpc_fake_resolver_response_generator*)p);
}
@@ -232,8 +225,7 @@ static void fake_resolver_factory_ref(grpc_resolver_factory* factory) {}
static void fake_resolver_factory_unref(grpc_resolver_factory* factory) {}
-static grpc_resolver* fake_resolver_create(grpc_exec_ctx* exec_ctx,
- grpc_resolver_factory* factory,
+static grpc_resolver* fake_resolver_create(grpc_resolver_factory* factory,
grpc_resolver_args* args) {
fake_resolver* r = (fake_resolver*)gpr_zalloc(sizeof(*r));
r->channel_args = grpc_channel_args_copy(args->args);
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..e2008e948e 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
@@ -43,7 +43,7 @@ grpc_fake_resolver_response_generator_create();
// Instruct the fake resolver associated with the \a response_generator instance
// to trigger a new resolution for \a uri and \a args.
void grpc_fake_resolver_response_generator_set_response(
- grpc_exec_ctx* exec_ctx, grpc_fake_resolver_response_generator* generator,
+ grpc_fake_resolver_response_generator* generator,
grpc_channel_args* next_response);
// Return a \a grpc_arg for a \a grpc_fake_resolver_response_generator instance.
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 1da8ab9161..26fd607f59 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
@@ -52,15 +52,13 @@ typedef struct {
grpc_channel_args** target_result;
} sockaddr_resolver;
-static void sockaddr_destroy(grpc_exec_ctx* exec_ctx, grpc_resolver* r);
+static void sockaddr_destroy(grpc_resolver* r);
-static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx* exec_ctx,
- sockaddr_resolver* r);
+static void sockaddr_maybe_finish_next_locked(sockaddr_resolver* r);
-static void sockaddr_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_resolver* r);
-static void sockaddr_channel_saw_error_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* r);
-static void sockaddr_next_locked(grpc_exec_ctx* exec_ctx, grpc_resolver* r,
+static void sockaddr_shutdown_locked(grpc_resolver* r);
+static void sockaddr_channel_saw_error_locked(grpc_resolver* r);
+static void sockaddr_next_locked(grpc_resolver* r,
grpc_channel_args** target_result,
grpc_closure* on_complete);
@@ -68,52 +66,47 @@ static const grpc_resolver_vtable sockaddr_resolver_vtable = {
sockaddr_destroy, sockaddr_shutdown_locked,
sockaddr_channel_saw_error_locked, sockaddr_next_locked};
-static void sockaddr_shutdown_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver) {
+static void sockaddr_shutdown_locked(grpc_resolver* resolver) {
sockaddr_resolver* r = (sockaddr_resolver*)resolver;
if (r->next_completion != nullptr) {
*r->target_result = nullptr;
- GRPC_CLOSURE_SCHED(
- exec_ctx, r->next_completion,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resolver Shutdown"));
+ GRPC_CLOSURE_SCHED(r->next_completion, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Resolver Shutdown"));
r->next_completion = nullptr;
}
}
-static void sockaddr_channel_saw_error_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver) {
+static void sockaddr_channel_saw_error_locked(grpc_resolver* resolver) {
sockaddr_resolver* r = (sockaddr_resolver*)resolver;
r->published = false;
- sockaddr_maybe_finish_next_locked(exec_ctx, r);
+ sockaddr_maybe_finish_next_locked(r);
}
-static void sockaddr_next_locked(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver,
+static void sockaddr_next_locked(grpc_resolver* resolver,
grpc_channel_args** target_result,
grpc_closure* on_complete) {
sockaddr_resolver* r = (sockaddr_resolver*)resolver;
GPR_ASSERT(!r->next_completion);
r->next_completion = on_complete;
r->target_result = target_result;
- sockaddr_maybe_finish_next_locked(exec_ctx, r);
+ sockaddr_maybe_finish_next_locked(r);
}
-static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx* exec_ctx,
- sockaddr_resolver* r) {
+static void sockaddr_maybe_finish_next_locked(sockaddr_resolver* r) {
if (r->next_completion != nullptr && !r->published) {
r->published = true;
grpc_arg arg = grpc_lb_addresses_create_channel_arg(r->addresses);
*r->target_result =
grpc_channel_args_copy_and_add(r->channel_args, &arg, 1);
- GRPC_CLOSURE_SCHED(exec_ctx, r->next_completion, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(r->next_completion, GRPC_ERROR_NONE);
r->next_completion = nullptr;
}
}
-static void sockaddr_destroy(grpc_exec_ctx* exec_ctx, grpc_resolver* gr) {
+static void sockaddr_destroy(grpc_resolver* gr) {
sockaddr_resolver* r = (sockaddr_resolver*)gr;
- grpc_lb_addresses_destroy(exec_ctx, r->addresses);
- grpc_channel_args_destroy(exec_ctx, r->channel_args);
+ grpc_lb_addresses_destroy(r->addresses);
+ grpc_channel_args_destroy(r->channel_args);
gpr_free(r);
}
@@ -142,8 +135,7 @@ char* unix_get_default_authority(grpc_resolver_factory* factory,
static void do_nothing(void* ignored) {}
-static grpc_resolver* sockaddr_create(grpc_exec_ctx* exec_ctx,
- grpc_resolver_args* args,
+static grpc_resolver* sockaddr_create(grpc_resolver_args* args,
bool parse(const grpc_uri* uri,
grpc_resolved_address* dst)) {
if (0 != strcmp(args->uri->authority, "")) {
@@ -170,10 +162,10 @@ static grpc_resolver* sockaddr_create(grpc_exec_ctx* exec_ctx,
gpr_free(part_str);
if (errors_found) break;
}
- grpc_slice_buffer_destroy_internal(exec_ctx, &path_parts);
- grpc_slice_unref_internal(exec_ctx, path_slice);
+ grpc_slice_buffer_destroy_internal(&path_parts);
+ grpc_slice_unref_internal(path_slice);
if (errors_found) {
- grpc_lb_addresses_destroy(exec_ctx, addresses);
+ grpc_lb_addresses_destroy(addresses);
return nullptr;
}
/* Instantiate resolver. */
@@ -195,9 +187,8 @@ static void sockaddr_factory_unref(grpc_resolver_factory* factory) {}
#define DECL_FACTORY(name) \
static grpc_resolver* name##_factory_create_resolver( \
- grpc_exec_ctx* exec_ctx, grpc_resolver_factory* factory, \
- grpc_resolver_args* args) { \
- return sockaddr_create(exec_ctx, args, grpc_parse_##name); \
+ grpc_resolver_factory* factory, grpc_resolver_args* args) { \
+ return sockaddr_create(args, grpc_parse_##name); \
} \
static const grpc_resolver_factory_vtable name##_factory_vtable = { \
sockaddr_factory_ref, sockaddr_factory_unref, \
diff --git a/src/core/ext/filters/client_channel/resolver_factory.cc b/src/core/ext/filters/client_channel/resolver_factory.cc
index 1a289d9771..9b3ec2f1c4 100644
--- a/src/core/ext/filters/client_channel/resolver_factory.cc
+++ b/src/core/ext/filters/client_channel/resolver_factory.cc
@@ -28,10 +28,9 @@ void grpc_resolver_factory_unref(grpc_resolver_factory* factory) {
/** Create a resolver instance for a name */
grpc_resolver* grpc_resolver_factory_create_resolver(
- grpc_exec_ctx* exec_ctx, grpc_resolver_factory* factory,
- grpc_resolver_args* args) {
+ grpc_resolver_factory* factory, grpc_resolver_args* args) {
if (factory == nullptr) return nullptr;
- return factory->vtable->create_resolver(exec_ctx, factory, args);
+ return factory->vtable->create_resolver(factory, args);
}
char* grpc_resolver_factory_get_default_authority(
diff --git a/src/core/ext/filters/client_channel/resolver_factory.h b/src/core/ext/filters/client_channel/resolver_factory.h
index 62555a4f01..d73748e916 100644
--- a/src/core/ext/filters/client_channel/resolver_factory.h
+++ b/src/core/ext/filters/client_channel/resolver_factory.h
@@ -47,8 +47,7 @@ struct grpc_resolver_factory_vtable {
void (*unref)(grpc_resolver_factory* factory);
/** Implementation of grpc_resolver_factory_create_resolver */
- grpc_resolver* (*create_resolver)(grpc_exec_ctx* exec_ctx,
- grpc_resolver_factory* factory,
+ grpc_resolver* (*create_resolver)(grpc_resolver_factory* factory,
grpc_resolver_args* args);
/** Implementation of grpc_resolver_factory_get_default_authority */
@@ -63,8 +62,7 @@ void grpc_resolver_factory_unref(grpc_resolver_factory* resolver);
/** Create a resolver instance for a name */
grpc_resolver* grpc_resolver_factory_create_resolver(
- grpc_exec_ctx* exec_ctx, grpc_resolver_factory* factory,
- grpc_resolver_args* args);
+ grpc_resolver_factory* factory, grpc_resolver_args* args);
/** Return a (freshly allocated with gpr_malloc) string representing
the default authority to use for this scheme. */
diff --git a/src/core/ext/filters/client_channel/resolver_registry.cc b/src/core/ext/filters/client_channel/resolver_registry.cc
index 5da6114a3d..3f8451de6b 100644
--- a/src/core/ext/filters/client_channel/resolver_registry.cc
+++ b/src/core/ext/filters/client_channel/resolver_registry.cc
@@ -92,23 +92,22 @@ static grpc_resolver_factory* lookup_factory_by_uri(grpc_uri* uri) {
return lookup_factory(uri->scheme);
}
-static grpc_resolver_factory* resolve_factory(grpc_exec_ctx* exec_ctx,
- const char* target,
+static grpc_resolver_factory* resolve_factory(const char* target,
grpc_uri** uri,
char** canonical_target) {
grpc_resolver_factory* factory = nullptr;
GPR_ASSERT(uri != nullptr);
- *uri = grpc_uri_parse(exec_ctx, target, 1);
+ *uri = grpc_uri_parse(target, 1);
factory = lookup_factory_by_uri(*uri);
if (factory == nullptr) {
grpc_uri_destroy(*uri);
gpr_asprintf(canonical_target, "%s%s", g_default_resolver_prefix, target);
- *uri = grpc_uri_parse(exec_ctx, *canonical_target, 1);
+ *uri = grpc_uri_parse(*canonical_target, 1);
factory = lookup_factory_by_uri(*uri);
if (factory == nullptr) {
- grpc_uri_destroy(grpc_uri_parse(exec_ctx, target, 0));
- grpc_uri_destroy(grpc_uri_parse(exec_ctx, *canonical_target, 0));
+ grpc_uri_destroy(grpc_uri_parse(target, 0));
+ grpc_uri_destroy(grpc_uri_parse(*canonical_target, 0));
gpr_log(GPR_ERROR, "don't know how to resolve '%s' or '%s'", target,
*canonical_target);
}
@@ -116,14 +115,14 @@ static grpc_resolver_factory* resolve_factory(grpc_exec_ctx* exec_ctx,
return factory;
}
-grpc_resolver* grpc_resolver_create(grpc_exec_ctx* exec_ctx, const char* target,
+grpc_resolver* grpc_resolver_create(const char* target,
const grpc_channel_args* args,
grpc_pollset_set* pollset_set,
grpc_combiner* combiner) {
grpc_uri* uri = nullptr;
char* canonical_target = nullptr;
grpc_resolver_factory* factory =
- resolve_factory(exec_ctx, target, &uri, &canonical_target);
+ resolve_factory(target, &uri, &canonical_target);
grpc_resolver* resolver;
grpc_resolver_args resolver_args;
memset(&resolver_args, 0, sizeof(resolver_args));
@@ -131,29 +130,27 @@ grpc_resolver* grpc_resolver_create(grpc_exec_ctx* exec_ctx, const char* target,
resolver_args.args = args;
resolver_args.pollset_set = pollset_set;
resolver_args.combiner = combiner;
- resolver =
- grpc_resolver_factory_create_resolver(exec_ctx, factory, &resolver_args);
+ resolver = grpc_resolver_factory_create_resolver(factory, &resolver_args);
grpc_uri_destroy(uri);
gpr_free(canonical_target);
return resolver;
}
-char* grpc_get_default_authority(grpc_exec_ctx* exec_ctx, const char* target) {
+char* grpc_get_default_authority(const char* target) {
grpc_uri* uri = nullptr;
char* canonical_target = nullptr;
grpc_resolver_factory* factory =
- resolve_factory(exec_ctx, target, &uri, &canonical_target);
+ resolve_factory(target, &uri, &canonical_target);
char* authority = grpc_resolver_factory_get_default_authority(factory, uri);
grpc_uri_destroy(uri);
gpr_free(canonical_target);
return authority;
}
-char* grpc_resolver_factory_add_default_prefix_if_needed(
- grpc_exec_ctx* exec_ctx, const char* target) {
+char* grpc_resolver_factory_add_default_prefix_if_needed(const char* target) {
grpc_uri* uri = nullptr;
char* canonical_target = nullptr;
- resolve_factory(exec_ctx, target, &uri, &canonical_target);
+ resolve_factory(target, &uri, &canonical_target);
grpc_uri_destroy(uri);
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..3eae94afa8 100644
--- a/src/core/ext/filters/client_channel/resolver_registry.h
+++ b/src/core/ext/filters/client_channel/resolver_registry.h
@@ -52,7 +52,7 @@ void grpc_register_resolver_type(grpc_resolver_factory* factory);
(typically the set of arguments passed in from the client API).
\a pollset_set is used to drive IO in the name resolution process, it
should not be NULL. */
-grpc_resolver* grpc_resolver_create(grpc_exec_ctx* exec_ctx, const char* target,
+grpc_resolver* grpc_resolver_create(const char* target,
const grpc_channel_args* args,
grpc_pollset_set* pollset_set,
grpc_combiner* combiner);
@@ -63,12 +63,11 @@ grpc_resolver_factory* grpc_resolver_factory_lookup(const char* name);
/** Given a target, return a (freshly allocated with gpr_malloc) string
representing the default authority to pass from a client. */
-char* grpc_get_default_authority(grpc_exec_ctx* exec_ctx, const char* target);
+char* grpc_get_default_authority(const char* target);
/** Returns a newly allocated string containing \a target, adding the
default prefix if needed. */
-char* grpc_resolver_factory_add_default_prefix_if_needed(
- grpc_exec_ctx* exec_ctx, const char* target);
+char* grpc_resolver_factory_add_default_prefix_if_needed(const char* target);
#ifdef __cplusplus
}
diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc
index 2720e68040..df53622e54 100644
--- a/src/core/ext/filters/client_channel/subchannel.cc
+++ b/src/core/ext/filters/client_channel/subchannel.cc
@@ -139,8 +139,7 @@ struct grpc_subchannel_call {
#define CALLSTACK_TO_SUBCHANNEL_CALL(callstack) \
(((grpc_subchannel_call*)(callstack)) - 1)
-static void subchannel_connected(grpc_exec_ctx* exec_ctx, void* subchannel,
- grpc_error* error);
+static void subchannel_connected(void* subchannel, grpc_error* error);
#ifndef NDEBUG
#define REF_REASON reason
@@ -157,10 +156,9 @@ static void subchannel_connected(grpc_exec_ctx* exec_ctx, void* subchannel,
* connection implementation
*/
-static void connection_destroy(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void connection_destroy(void* arg, grpc_error* error) {
grpc_connected_subchannel* c = (grpc_connected_subchannel*)arg;
- grpc_channel_stack_destroy(exec_ctx, CHANNEL_STACK_FROM_CONNECTION(c));
+ grpc_channel_stack_destroy(CHANNEL_STACK_FROM_CONNECTION(c));
gpr_free(c);
}
@@ -170,26 +168,23 @@ grpc_connected_subchannel* grpc_connected_subchannel_ref(
return c;
}
-void grpc_connected_subchannel_unref(grpc_exec_ctx* exec_ctx,
- grpc_connected_subchannel* c
- GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, CHANNEL_STACK_FROM_CONNECTION(c),
- REF_REASON);
+void grpc_connected_subchannel_unref(
+ grpc_connected_subchannel* c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
+ GRPC_CHANNEL_STACK_UNREF(CHANNEL_STACK_FROM_CONNECTION(c), REF_REASON);
}
/*
* grpc_subchannel implementation
*/
-static void subchannel_destroy(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void subchannel_destroy(void* arg, grpc_error* error) {
grpc_subchannel* c = (grpc_subchannel*)arg;
gpr_free((void*)c->filters);
- grpc_channel_args_destroy(exec_ctx, c->args);
- grpc_connectivity_state_destroy(exec_ctx, &c->state_tracker);
- grpc_connector_unref(exec_ctx, c->connector);
- grpc_pollset_set_destroy(exec_ctx, c->pollset_set);
- grpc_subchannel_key_destroy(exec_ctx, c->key);
+ grpc_channel_args_destroy(c->args);
+ grpc_connectivity_state_destroy(&c->state_tracker);
+ grpc_connector_unref(c->connector);
+ grpc_pollset_set_destroy(c->pollset_set);
+ grpc_subchannel_key_destroy(c->key);
gpr_mu_destroy(&c->mu);
gpr_free(c);
}
@@ -241,59 +236,54 @@ grpc_subchannel* grpc_subchannel_ref_from_weak_ref(
}
}
-static void disconnect(grpc_exec_ctx* exec_ctx, grpc_subchannel* c) {
+static void disconnect(grpc_subchannel* c) {
grpc_connected_subchannel* con;
- grpc_subchannel_index_unregister(exec_ctx, c->key, c);
+ grpc_subchannel_index_unregister(c->key, c);
gpr_mu_lock(&c->mu);
GPR_ASSERT(!c->disconnected);
c->disconnected = true;
- grpc_connector_shutdown(
- exec_ctx, c->connector,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Subchannel disconnected"));
+ grpc_connector_shutdown(c->connector, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Subchannel disconnected"));
con = GET_CONNECTED_SUBCHANNEL(c, no_barrier);
if (con != nullptr) {
- GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, con, "connection");
+ GRPC_CONNECTED_SUBCHANNEL_UNREF(con, "connection");
gpr_atm_no_barrier_store(&c->connected_subchannel, (gpr_atm)0xdeadbeef);
}
gpr_mu_unlock(&c->mu);
}
-void grpc_subchannel_unref(grpc_exec_ctx* exec_ctx,
- grpc_subchannel* c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
+void grpc_subchannel_unref(grpc_subchannel* c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
gpr_atm old_refs;
// add a weak ref and subtract a strong ref (atomically)
old_refs = ref_mutate(c, (gpr_atm)1 - (gpr_atm)(1 << INTERNAL_REF_BITS),
1 REF_MUTATE_PURPOSE("STRONG_UNREF"));
if ((old_refs & STRONG_REF_MASK) == (1 << INTERNAL_REF_BITS)) {
- disconnect(exec_ctx, c);
+ disconnect(c);
}
- GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "strong-unref");
+ GRPC_SUBCHANNEL_WEAK_UNREF(c, "strong-unref");
}
-void grpc_subchannel_weak_unref(grpc_exec_ctx* exec_ctx,
- grpc_subchannel* c
- GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
+void grpc_subchannel_weak_unref(
+ grpc_subchannel* c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
gpr_atm old_refs;
old_refs = ref_mutate(c, -(gpr_atm)1, 1 REF_MUTATE_PURPOSE("WEAK_UNREF"));
if (old_refs == 1) {
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_CREATE(subchannel_destroy, c, grpc_schedule_on_exec_ctx),
GRPC_ERROR_NONE);
}
}
-grpc_subchannel* grpc_subchannel_create(grpc_exec_ctx* exec_ctx,
- grpc_connector* connector,
+grpc_subchannel* grpc_subchannel_create(grpc_connector* connector,
const grpc_subchannel_args* args) {
grpc_subchannel_key* key = grpc_subchannel_key_create(args);
- grpc_subchannel* c = grpc_subchannel_index_find(exec_ctx, key);
+ grpc_subchannel* c = grpc_subchannel_index_find(key);
if (c) {
- grpc_subchannel_key_destroy(exec_ctx, key);
+ grpc_subchannel_key_destroy(key);
return c;
}
- GRPC_STATS_INC_CLIENT_SUBCHANNELS_CREATED(exec_ctx);
+ GRPC_STATS_INC_CLIENT_SUBCHANNELS_CREATED();
c = (grpc_subchannel*)gpr_zalloc(sizeof(*c));
c->key = key;
gpr_atm_no_barrier_store(&c->ref_pair, 1 << INTERNAL_REF_BITS);
@@ -311,10 +301,10 @@ grpc_subchannel* grpc_subchannel_create(grpc_exec_ctx* exec_ctx,
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_get_subchannel_address_arg(args->args, addr);
grpc_resolved_address* new_address = nullptr;
grpc_channel_args* new_args = nullptr;
- if (grpc_proxy_mappers_map_address(exec_ctx, addr, args->args, &new_address,
+ if (grpc_proxy_mappers_map_address(addr, args->args, &new_address,
&new_args)) {
GPR_ASSERT(new_address != nullptr);
gpr_free(addr);
@@ -327,7 +317,7 @@ grpc_subchannel* grpc_subchannel_create(grpc_exec_ctx* exec_ctx,
new_args != nullptr ? new_args : args->args, keys_to_remove,
GPR_ARRAY_SIZE(keys_to_remove), &new_arg, 1);
gpr_free(new_arg.value.string);
- if (new_args != nullptr) grpc_channel_args_destroy(exec_ctx, new_args);
+ if (new_args != nullptr) grpc_channel_args_destroy(new_args);
c->root_external_state_watcher.next = c->root_external_state_watcher.prev =
&c->root_external_state_watcher;
GRPC_CLOSURE_INIT(&c->connected, subchannel_connected, c,
@@ -373,21 +363,19 @@ grpc_subchannel* grpc_subchannel_create(grpc_exec_ctx* exec_ctx,
min_backoff_ms, max_backoff_ms);
gpr_mu_init(&c->mu);
- return grpc_subchannel_index_register(exec_ctx, key, c);
+ return grpc_subchannel_index_register(key, c);
}
-static void continue_connect_locked(grpc_exec_ctx* exec_ctx,
- grpc_subchannel* c) {
+static void continue_connect_locked(grpc_subchannel* c) {
grpc_connect_in_args args;
args.interested_parties = c->pollset_set;
args.deadline = c->backoff_result.current_deadline;
args.channel_args = c->args;
- grpc_connectivity_state_set(exec_ctx, &c->state_tracker,
- GRPC_CHANNEL_CONNECTING, GRPC_ERROR_NONE,
- "state_change");
- grpc_connector_connect(exec_ctx, c->connector, &args, &c->connecting_result,
+ grpc_connectivity_state_set(&c->state_tracker, GRPC_CHANNEL_CONNECTING,
+ GRPC_ERROR_NONE, "state_change");
+ grpc_connector_connect(c->connector, &args, &c->connecting_result,
&c->connected);
}
@@ -400,24 +388,23 @@ grpc_connectivity_state grpc_subchannel_check_connectivity(grpc_subchannel* c,
return state;
}
-static void on_external_state_watcher_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_external_state_watcher_done(void* arg, grpc_error* error) {
external_state_watcher* w = (external_state_watcher*)arg;
grpc_closure* follow_up = w->notify;
if (w->pollset_set != nullptr) {
- grpc_pollset_set_del_pollset_set(exec_ctx, w->subchannel->pollset_set,
+ grpc_pollset_set_del_pollset_set(w->subchannel->pollset_set,
w->pollset_set);
}
gpr_mu_lock(&w->subchannel->mu);
w->next->prev = w->prev;
w->prev->next = w->next;
gpr_mu_unlock(&w->subchannel->mu);
- GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, w->subchannel, "external_state_watcher");
+ GRPC_SUBCHANNEL_WEAK_UNREF(w->subchannel, "external_state_watcher");
gpr_free(w);
- GRPC_CLOSURE_RUN(exec_ctx, follow_up, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_RUN(follow_up, GRPC_ERROR_REF(error));
}
-static void on_alarm(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void on_alarm(void* arg, grpc_error* error) {
grpc_subchannel* c = (grpc_subchannel*)arg;
gpr_mu_lock(&c->mu);
c->have_alarm = false;
@@ -429,18 +416,17 @@ static void on_alarm(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
}
if (error == GRPC_ERROR_NONE) {
gpr_log(GPR_INFO, "Failed to connect to channel, retrying");
- c->backoff_result = grpc_backoff_step(exec_ctx, &c->backoff_state);
- continue_connect_locked(exec_ctx, c);
+ c->backoff_result = grpc_backoff_step(&c->backoff_state);
+ continue_connect_locked(c);
gpr_mu_unlock(&c->mu);
} else {
gpr_mu_unlock(&c->mu);
- GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting");
+ GRPC_SUBCHANNEL_WEAK_UNREF(c, "connecting");
}
GRPC_ERROR_UNREF(error);
}
-static void maybe_start_connecting_locked(grpc_exec_ctx* exec_ctx,
- grpc_subchannel* c) {
+static void maybe_start_connecting_locked(grpc_subchannel* c) {
if (c->disconnected) {
/* Don't try to connect if we're already disconnected */
return;
@@ -466,28 +452,28 @@ static void maybe_start_connecting_locked(grpc_exec_ctx* exec_ctx,
if (!c->backoff_begun) {
c->backoff_begun = true;
- c->backoff_result = grpc_backoff_begin(exec_ctx, &c->backoff_state);
- continue_connect_locked(exec_ctx, c);
+ c->backoff_result = grpc_backoff_begin(&c->backoff_state);
+ continue_connect_locked(c);
} else {
GPR_ASSERT(!c->have_alarm);
c->have_alarm = true;
const grpc_millis time_til_next =
- c->backoff_result.next_attempt_start_time - grpc_exec_ctx_now(exec_ctx);
+ c->backoff_result.next_attempt_start_time -
+ grpc_core::ExecCtx::Get()->Now();
if (time_til_next <= 0) {
gpr_log(GPR_INFO, "Retry immediately");
} else {
gpr_log(GPR_INFO, "Retry in %" PRIdPTR " milliseconds", time_til_next);
}
GRPC_CLOSURE_INIT(&c->on_alarm, on_alarm, c, grpc_schedule_on_exec_ctx);
- grpc_timer_init(exec_ctx, &c->alarm,
- c->backoff_result.next_attempt_start_time, &c->on_alarm);
+ grpc_timer_init(&c->alarm, c->backoff_result.next_attempt_start_time,
+ &c->on_alarm);
}
}
void grpc_subchannel_notify_on_state_change(
- grpc_exec_ctx* exec_ctx, grpc_subchannel* c,
- grpc_pollset_set* interested_parties, grpc_connectivity_state* state,
- grpc_closure* notify) {
+ grpc_subchannel* c, grpc_pollset_set* interested_parties,
+ grpc_connectivity_state* state, grpc_closure* notify) {
external_state_watcher* w;
if (state == nullptr) {
@@ -495,8 +481,8 @@ void grpc_subchannel_notify_on_state_change(
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, nullptr, &w->closure);
+ grpc_connectivity_state_notify_on_state_change(&c->state_tracker,
+ nullptr, &w->closure);
}
}
gpr_mu_unlock(&c->mu);
@@ -508,31 +494,28 @@ void grpc_subchannel_notify_on_state_change(
GRPC_CLOSURE_INIT(&w->closure, on_external_state_watcher_done, w,
grpc_schedule_on_exec_ctx);
if (interested_parties != nullptr) {
- grpc_pollset_set_add_pollset_set(exec_ctx, c->pollset_set,
- interested_parties);
+ grpc_pollset_set_add_pollset_set(c->pollset_set, interested_parties);
}
GRPC_SUBCHANNEL_WEAK_REF(c, "external_state_watcher");
gpr_mu_lock(&c->mu);
w->next = &c->root_external_state_watcher;
w->prev = w->next->prev;
w->next->prev = w->prev->next = w;
- grpc_connectivity_state_notify_on_state_change(exec_ctx, &c->state_tracker,
- state, &w->closure);
- maybe_start_connecting_locked(exec_ctx, c);
+ grpc_connectivity_state_notify_on_state_change(&c->state_tracker, state,
+ &w->closure);
+ maybe_start_connecting_locked(c);
gpr_mu_unlock(&c->mu);
}
}
void grpc_connected_subchannel_process_transport_op(
- grpc_exec_ctx* exec_ctx, grpc_connected_subchannel* con,
- grpc_transport_op* op) {
+ grpc_connected_subchannel* con, grpc_transport_op* op) {
grpc_channel_stack* channel_stack = CHANNEL_STACK_FROM_CONNECTION(con);
grpc_channel_element* top_elem = grpc_channel_stack_element(channel_stack, 0);
- top_elem->filter->start_transport_op(exec_ctx, top_elem, op);
+ top_elem->filter->start_transport_op(top_elem, op);
}
-static void subchannel_on_child_state_changed(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
+static void subchannel_on_child_state_changed(void* p, grpc_error* error) {
state_watcher* sw = (state_watcher*)p;
grpc_subchannel* c = sw->subchannel;
gpr_mu* mu = &c->mu;
@@ -544,24 +527,22 @@ static void subchannel_on_child_state_changed(grpc_exec_ctx* exec_ctx, void* p,
/* any errors on a subchannel ==> we're done, create a new one */
sw->connectivity_state = GRPC_CHANNEL_SHUTDOWN;
}
- grpc_connectivity_state_set(exec_ctx, &c->state_tracker,
- sw->connectivity_state, GRPC_ERROR_REF(error),
- "reflect_child");
+ grpc_connectivity_state_set(&c->state_tracker, sw->connectivity_state,
+ GRPC_ERROR_REF(error), "reflect_child");
if (sw->connectivity_state != GRPC_CHANNEL_SHUTDOWN) {
grpc_connected_subchannel_notify_on_state_change(
- exec_ctx, GET_CONNECTED_SUBCHANNEL(c, no_barrier), nullptr,
+ GET_CONNECTED_SUBCHANNEL(c, no_barrier), nullptr,
&sw->connectivity_state, &sw->closure);
GRPC_SUBCHANNEL_WEAK_REF(c, "state_watcher");
sw = nullptr;
}
gpr_mu_unlock(mu);
- GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "state_watcher");
+ GRPC_SUBCHANNEL_WEAK_UNREF(c, "state_watcher");
gpr_free(sw);
}
-static void connected_subchannel_state_op(grpc_exec_ctx* exec_ctx,
- grpc_connected_subchannel* con,
+static void connected_subchannel_state_op(grpc_connected_subchannel* con,
grpc_pollset_set* interested_parties,
grpc_connectivity_state* state,
grpc_closure* closure) {
@@ -571,29 +552,25 @@ static void connected_subchannel_state_op(grpc_exec_ctx* exec_ctx,
op->on_connectivity_state_change = closure;
op->bind_pollset_set = interested_parties;
elem = grpc_channel_stack_element(CHANNEL_STACK_FROM_CONNECTION(con), 0);
- elem->filter->start_transport_op(exec_ctx, elem, op);
+ elem->filter->start_transport_op(elem, op);
}
void grpc_connected_subchannel_notify_on_state_change(
- grpc_exec_ctx* exec_ctx, grpc_connected_subchannel* con,
- grpc_pollset_set* interested_parties, grpc_connectivity_state* state,
- grpc_closure* closure) {
- connected_subchannel_state_op(exec_ctx, con, interested_parties, state,
- closure);
+ grpc_connected_subchannel* con, grpc_pollset_set* interested_parties,
+ grpc_connectivity_state* state, grpc_closure* closure) {
+ connected_subchannel_state_op(con, interested_parties, state, closure);
}
-void grpc_connected_subchannel_ping(grpc_exec_ctx* exec_ctx,
- grpc_connected_subchannel* con,
+void grpc_connected_subchannel_ping(grpc_connected_subchannel* con,
grpc_closure* closure) {
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);
- elem->filter->start_transport_op(exec_ctx, elem, op);
+ elem->filter->start_transport_op(elem, op);
}
-static bool publish_transport_locked(grpc_exec_ctx* exec_ctx,
- grpc_subchannel* c) {
+static bool publish_transport_locked(grpc_subchannel* c) {
grpc_connected_subchannel* con;
grpc_channel_stack* stk;
state_watcher* sw_subchannel;
@@ -601,19 +578,18 @@ static bool publish_transport_locked(grpc_exec_ctx* exec_ctx,
/* construct channel stack */
grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create();
grpc_channel_stack_builder_set_channel_arguments(
- exec_ctx, builder, c->connecting_result.channel_args);
+ builder, c->connecting_result.channel_args);
grpc_channel_stack_builder_set_transport(builder,
c->connecting_result.transport);
- if (!grpc_channel_init_create_stack(exec_ctx, builder,
- GRPC_CLIENT_SUBCHANNEL)) {
- grpc_channel_stack_builder_destroy(exec_ctx, builder);
+ if (!grpc_channel_init_create_stack(builder, GRPC_CLIENT_SUBCHANNEL)) {
+ grpc_channel_stack_builder_destroy(builder);
return false;
}
grpc_error* error = grpc_channel_stack_builder_finish(
- exec_ctx, builder, 0, 1, connection_destroy, nullptr, (void**)&con);
+ builder, 0, 1, connection_destroy, nullptr, (void**)&con);
if (error != GRPC_ERROR_NONE) {
- grpc_transport_destroy(exec_ctx, c->connecting_result.transport);
+ grpc_transport_destroy(c->connecting_result.transport);
gpr_log(GPR_ERROR, "error initializing subchannel stack: %s",
grpc_error_string(error));
GRPC_ERROR_UNREF(error);
@@ -631,7 +607,7 @@ static bool publish_transport_locked(grpc_exec_ctx* exec_ctx,
if (c->disconnected) {
gpr_free(sw_subchannel);
- grpc_channel_stack_destroy(exec_ctx, stk);
+ grpc_channel_stack_destroy(stk);
gpr_free(con);
return false;
}
@@ -647,19 +623,18 @@ static bool publish_transport_locked(grpc_exec_ctx* exec_ctx,
/* setup subchannel watching connected subchannel for changes; subchannel
ref for connecting is donated to the state watcher */
GRPC_SUBCHANNEL_WEAK_REF(c, "state_watcher");
- GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting");
+ GRPC_SUBCHANNEL_WEAK_UNREF(c, "connecting");
grpc_connected_subchannel_notify_on_state_change(
- exec_ctx, con, c->pollset_set, &sw_subchannel->connectivity_state,
+ con, c->pollset_set, &sw_subchannel->connectivity_state,
&sw_subchannel->closure);
/* signal completion */
- grpc_connectivity_state_set(exec_ctx, &c->state_tracker, GRPC_CHANNEL_READY,
+ grpc_connectivity_state_set(&c->state_tracker, GRPC_CHANNEL_READY,
GRPC_ERROR_NONE, "connected");
return true;
}
-static void subchannel_connected(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void subchannel_connected(void* arg, grpc_error* error) {
grpc_subchannel* c = (grpc_subchannel*)arg;
grpc_channel_args* delete_channel_args = c->connecting_result.channel_args;
@@ -667,13 +642,13 @@ static void subchannel_connected(grpc_exec_ctx* exec_ctx, void* arg,
gpr_mu_lock(&c->mu);
c->connecting = false;
if (c->connecting_result.transport != nullptr &&
- publish_transport_locked(exec_ctx, c)) {
+ publish_transport_locked(c)) {
/* do nothing, transport was published */
} else if (c->disconnected) {
- GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting");
+ GRPC_SUBCHANNEL_WEAK_UNREF(c, "connecting");
} else {
grpc_connectivity_state_set(
- exec_ctx, &c->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ &c->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Connect Failed", &error, 1),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE),
@@ -682,27 +657,26 @@ static void subchannel_connected(grpc_exec_ctx* exec_ctx, void* arg,
const char* errmsg = grpc_error_string(error);
gpr_log(GPR_INFO, "Connect failed: %s", errmsg);
- maybe_start_connecting_locked(exec_ctx, c);
- GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting");
+ maybe_start_connecting_locked(c);
+ GRPC_SUBCHANNEL_WEAK_UNREF(c, "connecting");
}
gpr_mu_unlock(&c->mu);
- GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connected");
- grpc_channel_args_destroy(exec_ctx, delete_channel_args);
+ GRPC_SUBCHANNEL_WEAK_UNREF(c, "connected");
+ grpc_channel_args_destroy(delete_channel_args);
}
/*
* grpc_subchannel_call implementation
*/
-static void subchannel_call_destroy(grpc_exec_ctx* exec_ctx, void* call,
- grpc_error* error) {
+static void subchannel_call_destroy(void* call, grpc_error* error) {
grpc_subchannel_call* c = (grpc_subchannel_call*)call;
GPR_ASSERT(c->schedule_closure_after_destroy != nullptr);
GPR_TIMER_BEGIN("grpc_subchannel_call_unref.destroy", 0);
grpc_connected_subchannel* connection = c->connection;
- grpc_call_stack_destroy(exec_ctx, SUBCHANNEL_CALL_TO_CALL_STACK(c), nullptr,
+ grpc_call_stack_destroy(SUBCHANNEL_CALL_TO_CALL_STACK(c), nullptr,
c->schedule_closure_after_destroy);
- GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, connection, "subchannel_call");
+ GRPC_CONNECTED_SUBCHANNEL_UNREF(connection, "subchannel_call");
GPR_TIMER_END("grpc_subchannel_call_unref.destroy", 0);
}
@@ -718,20 +692,18 @@ void grpc_subchannel_call_ref(
GRPC_CALL_STACK_REF(SUBCHANNEL_CALL_TO_CALL_STACK(c), REF_REASON);
}
-void grpc_subchannel_call_unref(grpc_exec_ctx* exec_ctx,
- grpc_subchannel_call* c
- GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
- GRPC_CALL_STACK_UNREF(exec_ctx, SUBCHANNEL_CALL_TO_CALL_STACK(c), REF_REASON);
+void grpc_subchannel_call_unref(
+ grpc_subchannel_call* c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
+ GRPC_CALL_STACK_UNREF(SUBCHANNEL_CALL_TO_CALL_STACK(c), REF_REASON);
}
-void grpc_subchannel_call_process_op(grpc_exec_ctx* exec_ctx,
- grpc_subchannel_call* call,
+void grpc_subchannel_call_process_op(grpc_subchannel_call* call,
grpc_transport_stream_op_batch* batch) {
GPR_TIMER_BEGIN("grpc_subchannel_call_process_op", 0);
grpc_call_stack* call_stack = SUBCHANNEL_CALL_TO_CALL_STACK(call);
grpc_call_element* top_elem = grpc_call_stack_element(call_stack, 0);
GRPC_CALL_LOG_OP(GPR_INFO, top_elem, batch);
- top_elem->filter->start_transport_stream_op_batch(exec_ctx, top_elem, batch);
+ top_elem->filter->start_transport_stream_op_batch(top_elem, batch);
GPR_TIMER_END("grpc_subchannel_call_process_op", 0);
}
@@ -746,7 +718,7 @@ const grpc_subchannel_key* grpc_subchannel_get_key(
}
grpc_error* grpc_connected_subchannel_create_call(
- grpc_exec_ctx* exec_ctx, grpc_connected_subchannel* con,
+ grpc_connected_subchannel* con,
const grpc_connected_subchannel_call_args* args,
grpc_subchannel_call** call) {
grpc_channel_stack* chanstk = CHANNEL_STACK_FROM_CONNECTION(con);
@@ -764,14 +736,14 @@ grpc_error* grpc_connected_subchannel_create_call(
args->arena, /* arena */
args->call_combiner /* call_combiner */
};
- grpc_error* error = grpc_call_stack_init(
- exec_ctx, chanstk, 1, subchannel_call_destroy, *call, &call_args);
+ grpc_error* error = grpc_call_stack_init(chanstk, 1, subchannel_call_destroy,
+ *call, &call_args);
if (error != GRPC_ERROR_NONE) {
const char* error_string = grpc_error_string(error);
gpr_log(GPR_ERROR, "error: %s", error_string);
return error;
}
- grpc_call_stack_set_pollset_or_pollset_set(exec_ctx, callstk, args->pollent);
+ grpc_call_stack_set_pollset_or_pollset_set(callstk, args->pollent);
return GRPC_ERROR_NONE;
}
@@ -780,21 +752,20 @@ grpc_call_stack* grpc_subchannel_call_get_call_stack(
return SUBCHANNEL_CALL_TO_CALL_STACK(subchannel_call);
}
-static void grpc_uri_to_sockaddr(grpc_exec_ctx* exec_ctx, const char* uri_str,
+static void grpc_uri_to_sockaddr(const char* uri_str,
grpc_resolved_address* addr) {
- grpc_uri* uri = grpc_uri_parse(exec_ctx, uri_str, 0 /* suppress_errors */);
+ grpc_uri* uri = grpc_uri_parse(uri_str, 0 /* suppress_errors */);
GPR_ASSERT(uri != nullptr);
if (!grpc_parse_uri(uri, addr)) memset(addr, 0, sizeof(*addr));
grpc_uri_destroy(uri);
}
-void grpc_get_subchannel_address_arg(grpc_exec_ctx* exec_ctx,
- const grpc_channel_args* args,
+void grpc_get_subchannel_address_arg(const grpc_channel_args* args,
grpc_resolved_address* addr) {
const char* addr_uri_str = grpc_get_subchannel_address_uri_arg(args);
memset(addr, 0, sizeof(*addr));
if (*addr_uri_str != '\0') {
- grpc_uri_to_sockaddr(exec_ctx, addr_uri_str, addr);
+ grpc_uri_to_sockaddr(addr_uri_str, addr);
}
}
diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h
index 970f182ff0..e65d043b0b 100644
--- a/src/core/ext/filters/client_channel/subchannel.h
+++ b/src/core/ext/filters/client_channel/subchannel.h
@@ -46,36 +46,34 @@ typedef struct grpc_subchannel_key grpc_subchannel_key;
grpc_subchannel_ref((p), __FILE__, __LINE__, (r))
#define GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(p, r) \
grpc_subchannel_ref_from_weak_ref((p), __FILE__, __LINE__, (r))
-#define GRPC_SUBCHANNEL_UNREF(cl, p, r) \
- grpc_subchannel_unref((cl), (p), __FILE__, __LINE__, (r))
+#define GRPC_SUBCHANNEL_UNREF(p, r) \
+ grpc_subchannel_unref((p), __FILE__, __LINE__, (r))
#define GRPC_SUBCHANNEL_WEAK_REF(p, r) \
grpc_subchannel_weak_ref((p), __FILE__, __LINE__, (r))
-#define GRPC_SUBCHANNEL_WEAK_UNREF(cl, p, r) \
- grpc_subchannel_weak_unref((cl), (p), __FILE__, __LINE__, (r))
+#define GRPC_SUBCHANNEL_WEAK_UNREF(p, r) \
+ grpc_subchannel_weak_unref((p), __FILE__, __LINE__, (r))
#define GRPC_CONNECTED_SUBCHANNEL_REF(p, r) \
grpc_connected_subchannel_ref((p), __FILE__, __LINE__, (r))
-#define GRPC_CONNECTED_SUBCHANNEL_UNREF(cl, p, r) \
- grpc_connected_subchannel_unref((cl), (p), __FILE__, __LINE__, (r))
+#define GRPC_CONNECTED_SUBCHANNEL_UNREF(p, r) \
+ grpc_connected_subchannel_unref((p), __FILE__, __LINE__, (r))
#define GRPC_SUBCHANNEL_CALL_REF(p, r) \
grpc_subchannel_call_ref((p), __FILE__, __LINE__, (r))
-#define GRPC_SUBCHANNEL_CALL_UNREF(cl, p, r) \
- grpc_subchannel_call_unref((cl), (p), __FILE__, __LINE__, (r))
+#define GRPC_SUBCHANNEL_CALL_UNREF(p, r) \
+ grpc_subchannel_call_unref((p), __FILE__, __LINE__, (r))
#define GRPC_SUBCHANNEL_REF_EXTRA_ARGS \
, const char *file, int line, const char *reason
#else
#define GRPC_SUBCHANNEL_REF(p, r) grpc_subchannel_ref((p))
#define GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(p, r) \
grpc_subchannel_ref_from_weak_ref((p))
-#define GRPC_SUBCHANNEL_UNREF(cl, p, r) grpc_subchannel_unref((cl), (p))
+#define GRPC_SUBCHANNEL_UNREF(p, r) grpc_subchannel_unref((p))
#define GRPC_SUBCHANNEL_WEAK_REF(p, r) grpc_subchannel_weak_ref((p))
-#define GRPC_SUBCHANNEL_WEAK_UNREF(cl, p, r) \
- grpc_subchannel_weak_unref((cl), (p))
+#define GRPC_SUBCHANNEL_WEAK_UNREF(p, r) grpc_subchannel_weak_unref((p))
#define GRPC_CONNECTED_SUBCHANNEL_REF(p, r) grpc_connected_subchannel_ref((p))
-#define GRPC_CONNECTED_SUBCHANNEL_UNREF(cl, p, r) \
- grpc_connected_subchannel_unref((cl), (p))
+#define GRPC_CONNECTED_SUBCHANNEL_UNREF(p, r) \
+ grpc_connected_subchannel_unref((p))
#define GRPC_SUBCHANNEL_CALL_REF(p, r) grpc_subchannel_call_ref((p))
-#define GRPC_SUBCHANNEL_CALL_UNREF(cl, p, r) \
- grpc_subchannel_call_unref((cl), (p))
+#define GRPC_SUBCHANNEL_CALL_UNREF(p, r) grpc_subchannel_call_unref((p))
#define GRPC_SUBCHANNEL_REF_EXTRA_ARGS
#endif
@@ -83,24 +81,20 @@ grpc_subchannel* grpc_subchannel_ref(
grpc_subchannel* channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
grpc_subchannel* grpc_subchannel_ref_from_weak_ref(
grpc_subchannel* channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
-void grpc_subchannel_unref(grpc_exec_ctx* exec_ctx,
- grpc_subchannel* channel
- GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
+void grpc_subchannel_unref(
+ grpc_subchannel* channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
grpc_subchannel* grpc_subchannel_weak_ref(
grpc_subchannel* channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
-void grpc_subchannel_weak_unref(grpc_exec_ctx* exec_ctx,
- grpc_subchannel* channel
- GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
+void grpc_subchannel_weak_unref(
+ grpc_subchannel* channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
grpc_connected_subchannel* grpc_connected_subchannel_ref(
grpc_connected_subchannel* channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
-void grpc_connected_subchannel_unref(grpc_exec_ctx* exec_ctx,
- grpc_connected_subchannel* channel
- GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
+void grpc_connected_subchannel_unref(
+ grpc_connected_subchannel* channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
void grpc_subchannel_call_ref(
grpc_subchannel_call* call GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
-void grpc_subchannel_call_unref(grpc_exec_ctx* exec_ctx,
- grpc_subchannel_call* call
- GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
+void grpc_subchannel_call_unref(
+ grpc_subchannel_call* call GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
/** construct a subchannel call */
typedef struct {
@@ -114,14 +108,13 @@ typedef struct {
} grpc_connected_subchannel_call_args;
grpc_error* grpc_connected_subchannel_create_call(
- grpc_exec_ctx* exec_ctx, grpc_connected_subchannel* connected_subchannel,
+ grpc_connected_subchannel* connected_subchannel,
const grpc_connected_subchannel_call_args* args,
grpc_subchannel_call** subchannel_call);
/** process a transport level op */
void grpc_connected_subchannel_process_transport_op(
- grpc_exec_ctx* exec_ctx, grpc_connected_subchannel* subchannel,
- grpc_transport_op* op);
+ grpc_connected_subchannel* subchannel, grpc_transport_op* op);
/** poll the current connectivity state of a channel */
grpc_connectivity_state grpc_subchannel_check_connectivity(
@@ -130,15 +123,12 @@ grpc_connectivity_state grpc_subchannel_check_connectivity(
/** Calls notify when the connectivity state of a channel becomes different
from *state. Updates *state with the new state of the channel. */
void grpc_subchannel_notify_on_state_change(
- grpc_exec_ctx* exec_ctx, grpc_subchannel* channel,
- grpc_pollset_set* interested_parties, grpc_connectivity_state* state,
- grpc_closure* notify);
+ grpc_subchannel* channel, grpc_pollset_set* interested_parties,
+ grpc_connectivity_state* state, grpc_closure* notify);
void grpc_connected_subchannel_notify_on_state_change(
- grpc_exec_ctx* exec_ctx, grpc_connected_subchannel* channel,
- grpc_pollset_set* interested_parties, grpc_connectivity_state* state,
- grpc_closure* notify);
-void grpc_connected_subchannel_ping(grpc_exec_ctx* exec_ctx,
- grpc_connected_subchannel* channel,
+ grpc_connected_subchannel* channel, grpc_pollset_set* interested_parties,
+ grpc_connectivity_state* state, grpc_closure* notify);
+void grpc_connected_subchannel_ping(grpc_connected_subchannel* channel,
grpc_closure* notify);
/** retrieve the grpc_connected_subchannel - or NULL if called before
@@ -151,8 +141,7 @@ const grpc_subchannel_key* grpc_subchannel_get_key(
const grpc_subchannel* subchannel);
/** continue processing a transport op */
-void grpc_subchannel_call_process_op(grpc_exec_ctx* exec_ctx,
- grpc_subchannel_call* subchannel_call,
+void grpc_subchannel_call_process_op(grpc_subchannel_call* subchannel_call,
grpc_transport_stream_op_batch* op);
/** Must be called once per call. Sets the 'then_schedule_closure' argument for
@@ -176,13 +165,11 @@ struct grpc_subchannel_args {
};
/** create a subchannel given a connector */
-grpc_subchannel* grpc_subchannel_create(grpc_exec_ctx* exec_ctx,
- grpc_connector* connector,
+grpc_subchannel* grpc_subchannel_create(grpc_connector* connector,
const grpc_subchannel_args* args);
/// Sets \a addr from \a args.
-void grpc_get_subchannel_address_arg(grpc_exec_ctx* exec_ctx,
- const grpc_channel_args* args,
+void grpc_get_subchannel_address_arg(const grpc_channel_args* args,
grpc_resolved_address* addr);
/// Returns the URI string for the address to connect to.
diff --git a/src/core/ext/filters/client_channel/subchannel_index.cc b/src/core/ext/filters/client_channel/subchannel_index.cc
index ae39ca394e..8c6e7a2182 100644
--- a/src/core/ext/filters/client_channel/subchannel_index.cc
+++ b/src/core/ext/filters/client_channel/subchannel_index.cc
@@ -81,16 +81,14 @@ int grpc_subchannel_key_compare(const grpc_subchannel_key* a,
return grpc_channel_args_compare(a->args.args, b->args.args);
}
-void grpc_subchannel_key_destroy(grpc_exec_ctx* exec_ctx,
- grpc_subchannel_key* k) {
+void grpc_subchannel_key_destroy(grpc_subchannel_key* k) {
gpr_free((grpc_channel_args*)k->args.filters);
- grpc_channel_args_destroy(exec_ctx, (grpc_channel_args*)k->args.args);
+ grpc_channel_args_destroy((grpc_channel_args*)k->args.args);
gpr_free(k);
}
static void sck_avl_destroy(void* p, void* user_data) {
- grpc_exec_ctx* exec_ctx = (grpc_exec_ctx*)user_data;
- grpc_subchannel_key_destroy(exec_ctx, (grpc_subchannel_key*)p);
+ grpc_subchannel_key_destroy((grpc_subchannel_key*)p);
}
static void* sck_avl_copy(void* p, void* unused) {
@@ -103,8 +101,7 @@ static long sck_avl_compare(void* a, void* b, void* unused) {
}
static void scv_avl_destroy(void* p, void* user_data) {
- grpc_exec_ctx* exec_ctx = (grpc_exec_ctx*)user_data;
- GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, (grpc_subchannel*)p, "subchannel_index");
+ GRPC_SUBCHANNEL_WEAK_UNREF((grpc_subchannel*)p, "subchannel_index");
}
static void* scv_avl_copy(void* p, void* unused) {
@@ -135,32 +132,29 @@ void grpc_subchannel_index_shutdown(void) {
void grpc_subchannel_index_unref(void) {
if (gpr_unref(&g_refcount)) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_mu_destroy(&g_mu);
- gpr_avl_unref(g_subchannel_index, &exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ gpr_avl_unref(g_subchannel_index, grpc_core::ExecCtx::Get());
}
}
void grpc_subchannel_index_ref(void) { gpr_ref_non_zero(&g_refcount); }
-grpc_subchannel* grpc_subchannel_index_find(grpc_exec_ctx* exec_ctx,
- grpc_subchannel_key* key) {
+grpc_subchannel* grpc_subchannel_index_find(grpc_subchannel_key* key) {
// Lock, and take a reference to the subchannel index.
// We don't need to do the search under a lock as avl's are immutable.
gpr_mu_lock(&g_mu);
- gpr_avl index = gpr_avl_ref(g_subchannel_index, exec_ctx);
+ gpr_avl index = gpr_avl_ref(g_subchannel_index, grpc_core::ExecCtx::Get());
gpr_mu_unlock(&g_mu);
grpc_subchannel* c = GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(
- (grpc_subchannel*)gpr_avl_get(index, key, exec_ctx), "index_find");
- gpr_avl_unref(index, exec_ctx);
+ (grpc_subchannel*)gpr_avl_get(index, key, grpc_core::ExecCtx::Get()),
+ "index_find");
+ gpr_avl_unref(index, grpc_core::ExecCtx::Get());
return c;
}
-grpc_subchannel* grpc_subchannel_index_register(grpc_exec_ctx* exec_ctx,
- grpc_subchannel_key* key,
+grpc_subchannel* grpc_subchannel_index_register(grpc_subchannel_key* key,
grpc_subchannel* constructed) {
grpc_subchannel* c = nullptr;
bool need_to_unref_constructed;
@@ -171,11 +165,11 @@ grpc_subchannel* grpc_subchannel_index_register(grpc_exec_ctx* exec_ctx,
// Compare and swap loop:
// - take a reference to the current index
gpr_mu_lock(&g_mu);
- gpr_avl index = gpr_avl_ref(g_subchannel_index, exec_ctx);
+ gpr_avl index = gpr_avl_ref(g_subchannel_index, grpc_core::ExecCtx::Get());
gpr_mu_unlock(&g_mu);
// - Check to see if a subchannel already exists
- c = (grpc_subchannel*)gpr_avl_get(index, key, exec_ctx);
+ c = (grpc_subchannel*)gpr_avl_get(index, key, grpc_core::ExecCtx::Get());
if (c != nullptr) {
c = GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(c, "index_register");
}
@@ -184,9 +178,11 @@ grpc_subchannel* grpc_subchannel_index_register(grpc_exec_ctx* exec_ctx,
need_to_unref_constructed = true;
} else {
// no -> update the avl and compare/swap
- gpr_avl updated = gpr_avl_add(
- gpr_avl_ref(index, exec_ctx), subchannel_key_copy(key),
- GRPC_SUBCHANNEL_WEAK_REF(constructed, "index_register"), exec_ctx);
+ gpr_avl updated =
+ gpr_avl_add(gpr_avl_ref(index, grpc_core::ExecCtx::Get()),
+ subchannel_key_copy(key),
+ GRPC_SUBCHANNEL_WEAK_REF(constructed, "index_register"),
+ grpc_core::ExecCtx::Get());
// it may happen (but it's expected to be unlikely)
// that some other thread has changed the index:
@@ -198,41 +194,42 @@ grpc_subchannel* grpc_subchannel_index_register(grpc_exec_ctx* exec_ctx,
}
gpr_mu_unlock(&g_mu);
- gpr_avl_unref(updated, exec_ctx);
+ gpr_avl_unref(updated, grpc_core::ExecCtx::Get());
}
- gpr_avl_unref(index, exec_ctx);
+ gpr_avl_unref(index, grpc_core::ExecCtx::Get());
}
if (need_to_unref_constructed) {
- GRPC_SUBCHANNEL_UNREF(exec_ctx, constructed, "index_register");
+ GRPC_SUBCHANNEL_UNREF(constructed, "index_register");
}
return c;
}
-void grpc_subchannel_index_unregister(grpc_exec_ctx* exec_ctx,
- grpc_subchannel_key* key,
+void grpc_subchannel_index_unregister(grpc_subchannel_key* key,
grpc_subchannel* constructed) {
bool done = false;
while (!done) {
// Compare and swap loop:
// - take a reference to the current index
gpr_mu_lock(&g_mu);
- gpr_avl index = gpr_avl_ref(g_subchannel_index, exec_ctx);
+ gpr_avl index = gpr_avl_ref(g_subchannel_index, grpc_core::ExecCtx::Get());
gpr_mu_unlock(&g_mu);
// Check to see if this key still refers to the previously
// registered subchannel
- grpc_subchannel* c = (grpc_subchannel*)gpr_avl_get(index, key, exec_ctx);
+ grpc_subchannel* c =
+ (grpc_subchannel*)gpr_avl_get(index, key, grpc_core::ExecCtx::Get());
if (c != constructed) {
- gpr_avl_unref(index, exec_ctx);
+ gpr_avl_unref(index, grpc_core::ExecCtx::Get());
break;
}
// compare and swap the update (some other thread may have
// mutated the index behind us)
gpr_avl updated =
- gpr_avl_remove(gpr_avl_ref(index, exec_ctx), key, exec_ctx);
+ gpr_avl_remove(gpr_avl_ref(index, grpc_core::ExecCtx::Get()), key,
+ grpc_core::ExecCtx::Get());
gpr_mu_lock(&g_mu);
if (index.root == g_subchannel_index.root) {
@@ -241,8 +238,8 @@ void grpc_subchannel_index_unregister(grpc_exec_ctx* exec_ctx,
}
gpr_mu_unlock(&g_mu);
- gpr_avl_unref(updated, exec_ctx);
- gpr_avl_unref(index, exec_ctx);
+ gpr_avl_unref(updated, grpc_core::ExecCtx::Get());
+ gpr_avl_unref(index, grpc_core::ExecCtx::Get());
}
}
diff --git a/src/core/ext/filters/client_channel/subchannel_index.h b/src/core/ext/filters/client_channel/subchannel_index.h
index 47f9c7bb1e..19f77833d1 100644
--- a/src/core/ext/filters/client_channel/subchannel_index.h
+++ b/src/core/ext/filters/client_channel/subchannel_index.h
@@ -33,26 +33,22 @@ grpc_subchannel_key* grpc_subchannel_key_create(
const grpc_subchannel_args* args);
/** Destroy a subchannel key */
-void grpc_subchannel_key_destroy(grpc_exec_ctx* exec_ctx,
- grpc_subchannel_key* key);
+void grpc_subchannel_key_destroy(grpc_subchannel_key* key);
/** Given a subchannel key, find the subchannel registered for it.
Returns NULL if no such channel exists.
Thread-safe. */
-grpc_subchannel* grpc_subchannel_index_find(grpc_exec_ctx* exec_ctx,
- grpc_subchannel_key* key);
+grpc_subchannel* grpc_subchannel_index_find(grpc_subchannel_key* key);
/** Register a subchannel against a key.
Takes ownership of \a constructed.
Returns the registered subchannel. This may be different from
\a constructed in the case of a registration race. */
-grpc_subchannel* grpc_subchannel_index_register(grpc_exec_ctx* exec_ctx,
- grpc_subchannel_key* key,
+grpc_subchannel* grpc_subchannel_index_register(grpc_subchannel_key* key,
grpc_subchannel* constructed);
/** Remove \a constructed as the registered subchannel for \a key. */
-void grpc_subchannel_index_unregister(grpc_exec_ctx* exec_ctx,
- grpc_subchannel_key* key,
+void grpc_subchannel_index_unregister(grpc_subchannel_key* key,
grpc_subchannel* constructed);
int grpc_subchannel_key_compare(const grpc_subchannel_key* a,
diff --git a/src/core/ext/filters/client_channel/uri_parser.cc b/src/core/ext/filters/client_channel/uri_parser.cc
index b76dcbe4e3..3428f4b54c 100644
--- a/src/core/ext/filters/client_channel/uri_parser.cc
+++ b/src/core/ext/filters/client_channel/uri_parser.cc
@@ -56,8 +56,8 @@ static grpc_uri* bad_uri(const char* uri_text, size_t pos, const char* section,
}
/** Returns a copy of percent decoded \a src[begin, end) */
-static char* decode_and_copy_component(grpc_exec_ctx* exec_ctx, const char* src,
- size_t begin, size_t end) {
+static char* decode_and_copy_component(const char* src, size_t begin,
+ size_t end) {
grpc_slice component =
(begin == NOT_SET || end == NOT_SET)
? grpc_empty_slice()
@@ -65,8 +65,8 @@ static char* decode_and_copy_component(grpc_exec_ctx* exec_ctx, const char* src,
grpc_slice decoded_component =
grpc_permissive_percent_decode_slice(component);
char* out = grpc_dump_slice(decoded_component, GPR_DUMP_ASCII);
- grpc_slice_unref_internal(exec_ctx, component);
- grpc_slice_unref_internal(exec_ctx, decoded_component);
+ grpc_slice_unref_internal(component);
+ grpc_slice_unref_internal(decoded_component);
return out;
}
@@ -184,8 +184,7 @@ static void parse_query_parts(grpc_uri* uri) {
}
}
-grpc_uri* grpc_uri_parse(grpc_exec_ctx* exec_ctx, const char* uri_text,
- bool suppress_errors) {
+grpc_uri* grpc_uri_parse(const char* uri_text, bool suppress_errors) {
grpc_uri* uri;
size_t scheme_begin = 0;
size_t scheme_end = NOT_SET;
@@ -273,16 +272,13 @@ grpc_uri* grpc_uri_parse(grpc_exec_ctx* exec_ctx, const char* uri_text,
}
uri = (grpc_uri*)gpr_zalloc(sizeof(*uri));
- uri->scheme =
- decode_and_copy_component(exec_ctx, uri_text, scheme_begin, scheme_end);
- uri->authority = decode_and_copy_component(exec_ctx, uri_text,
- authority_begin, authority_end);
- uri->path =
- decode_and_copy_component(exec_ctx, uri_text, path_begin, path_end);
- uri->query =
- decode_and_copy_component(exec_ctx, uri_text, query_begin, query_end);
- uri->fragment = decode_and_copy_component(exec_ctx, uri_text, fragment_begin,
- fragment_end);
+ uri->scheme = decode_and_copy_component(uri_text, scheme_begin, scheme_end);
+ uri->authority =
+ decode_and_copy_component(uri_text, authority_begin, authority_end);
+ uri->path = decode_and_copy_component(uri_text, path_begin, path_end);
+ uri->query = decode_and_copy_component(uri_text, query_begin, query_end);
+ uri->fragment =
+ decode_and_copy_component(uri_text, fragment_begin, fragment_end);
parse_query_parts(uri);
return uri;
diff --git a/src/core/ext/filters/client_channel/uri_parser.h b/src/core/ext/filters/client_channel/uri_parser.h
index cd877ade8d..29f61f09ae 100644
--- a/src/core/ext/filters/client_channel/uri_parser.h
+++ b/src/core/ext/filters/client_channel/uri_parser.h
@@ -41,8 +41,7 @@ typedef struct {
} grpc_uri;
/** parse a uri, return NULL on failure */
-grpc_uri* grpc_uri_parse(grpc_exec_ctx* exec_ctx, const char* uri_text,
- bool suppress_errors);
+grpc_uri* grpc_uri_parse(const char* uri_text, bool suppress_errors);
/** return the part of a query string after the '=' in "?key=xxx&...", or NULL
* if key is not present */
diff --git a/src/core/ext/filters/deadline/deadline_filter.cc b/src/core/ext/filters/deadline/deadline_filter.cc
index 849ce7153e..7e7af7f7c0 100644
--- a/src/core/ext/filters/deadline/deadline_filter.cc
+++ b/src/core/ext/filters/deadline/deadline_filter.cc
@@ -36,18 +36,16 @@
// The on_complete callback used when sending a cancel_error batch down the
// filter stack. Yields the call combiner when the batch returns.
-static void yield_call_combiner(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* ignored) {
+static void yield_call_combiner(void* arg, grpc_error* ignored) {
grpc_deadline_state* deadline_state = (grpc_deadline_state*)arg;
- GRPC_CALL_COMBINER_STOP(exec_ctx, deadline_state->call_combiner,
+ GRPC_CALL_COMBINER_STOP(deadline_state->call_combiner,
"got on_complete from cancel_stream batch");
- GRPC_CALL_STACK_UNREF(exec_ctx, deadline_state->call_stack, "deadline_timer");
+ GRPC_CALL_STACK_UNREF(deadline_state->call_stack, "deadline_timer");
}
// This is called via the call combiner, so access to deadline_state is
// synchronized.
-static void send_cancel_op_in_call_combiner(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void send_cancel_op_in_call_combiner(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
grpc_transport_stream_op_batch* batch = grpc_make_transport_stream_op(
@@ -55,37 +53,34 @@ static void send_cancel_op_in_call_combiner(grpc_exec_ctx* exec_ctx, void* arg,
deadline_state, grpc_schedule_on_exec_ctx));
batch->cancel_stream = true;
batch->payload->cancel_stream.cancel_error = GRPC_ERROR_REF(error);
- elem->filter->start_transport_stream_op_batch(exec_ctx, elem, batch);
+ elem->filter->start_transport_stream_op_batch(elem, batch);
}
// Timer callback.
-static void timer_callback(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void timer_callback(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
if (error != GRPC_ERROR_CANCELLED) {
error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Deadline Exceeded"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_DEADLINE_EXCEEDED);
- grpc_call_combiner_cancel(exec_ctx, deadline_state->call_combiner,
+ grpc_call_combiner_cancel(deadline_state->call_combiner,
GRPC_ERROR_REF(error));
GRPC_CLOSURE_INIT(&deadline_state->timer_callback,
send_cancel_op_in_call_combiner, elem,
grpc_schedule_on_exec_ctx);
- GRPC_CALL_COMBINER_START(exec_ctx, deadline_state->call_combiner,
+ GRPC_CALL_COMBINER_START(deadline_state->call_combiner,
&deadline_state->timer_callback, error,
"deadline exceeded -- sending cancel_stream op");
} else {
- GRPC_CALL_STACK_UNREF(exec_ctx, deadline_state->call_stack,
- "deadline_timer");
+ GRPC_CALL_STACK_UNREF(deadline_state->call_stack, "deadline_timer");
}
}
// Starts the deadline timer.
// This is called via the call combiner, so access to deadline_state is
// synchronized.
-static void start_timer_if_needed(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void start_timer_if_needed(grpc_call_element* elem,
grpc_millis deadline) {
if (deadline == GRPC_MILLIS_INF_FUTURE) {
return;
@@ -113,17 +108,16 @@ static void start_timer_if_needed(grpc_exec_ctx* exec_ctx,
}
GPR_ASSERT(closure != nullptr);
GRPC_CALL_STACK_REF(deadline_state->call_stack, "deadline_timer");
- grpc_timer_init(exec_ctx, &deadline_state->timer, deadline, closure);
+ grpc_timer_init(&deadline_state->timer, deadline, closure);
}
// Cancels the deadline timer.
// This is called via the call combiner, so access to deadline_state is
// synchronized.
-static void cancel_timer_if_needed(grpc_exec_ctx* exec_ctx,
- grpc_deadline_state* deadline_state) {
+static void cancel_timer_if_needed(grpc_deadline_state* deadline_state) {
if (deadline_state->timer_state == GRPC_DEADLINE_STATE_PENDING) {
deadline_state->timer_state = GRPC_DEADLINE_STATE_FINISHED;
- grpc_timer_cancel(exec_ctx, &deadline_state->timer);
+ grpc_timer_cancel(&deadline_state->timer);
} else {
// timer was either in STATE_INITAL (nothing to cancel)
// OR in STATE_FINISHED (again nothing to cancel)
@@ -131,12 +125,11 @@ static void cancel_timer_if_needed(grpc_exec_ctx* exec_ctx,
}
// Callback run when the call is complete.
-static void on_complete(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void on_complete(void* arg, grpc_error* error) {
grpc_deadline_state* deadline_state = (grpc_deadline_state*)arg;
- cancel_timer_if_needed(exec_ctx, deadline_state);
+ cancel_timer_if_needed(deadline_state);
// Invoke the next callback.
- GRPC_CLOSURE_RUN(exec_ctx, deadline_state->next_on_complete,
- GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_RUN(deadline_state->next_on_complete, GRPC_ERROR_REF(error));
}
// Inject our own on_complete callback into op.
@@ -156,8 +149,7 @@ struct start_timer_after_init_state {
grpc_millis deadline;
grpc_closure closure;
};
-static void start_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void start_timer_after_init(void* arg, grpc_error* error) {
struct start_timer_after_init_state* state =
(struct start_timer_after_init_state*)arg;
grpc_deadline_state* deadline_state =
@@ -166,18 +158,18 @@ static void start_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg,
// We are initially called without holding the call combiner, so we
// need to bounce ourselves into it.
state->in_call_combiner = true;
- GRPC_CALL_COMBINER_START(exec_ctx, deadline_state->call_combiner,
- &state->closure, GRPC_ERROR_REF(error),
+ GRPC_CALL_COMBINER_START(deadline_state->call_combiner, &state->closure,
+ GRPC_ERROR_REF(error),
"scheduling deadline timer");
return;
}
- start_timer_if_needed(exec_ctx, state->elem, state->deadline);
+ start_timer_if_needed(state->elem, state->deadline);
gpr_free(state);
- GRPC_CALL_COMBINER_STOP(exec_ctx, deadline_state->call_combiner,
+ GRPC_CALL_COMBINER_STOP(deadline_state->call_combiner,
"done scheduling deadline timer");
}
-void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+void grpc_deadline_state_init(grpc_call_element* elem,
grpc_call_stack* call_stack,
grpc_call_combiner* call_combiner,
grpc_millis deadline) {
@@ -200,29 +192,27 @@ void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
state->deadline = deadline;
GRPC_CLOSURE_INIT(&state->closure, start_timer_after_init, state,
grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_SCHED(exec_ctx, &state->closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&state->closure, GRPC_ERROR_NONE);
}
}
-void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem) {
+void grpc_deadline_state_destroy(grpc_call_element* elem) {
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
- cancel_timer_if_needed(exec_ctx, deadline_state);
+ cancel_timer_if_needed(deadline_state);
}
-void grpc_deadline_state_reset(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+void grpc_deadline_state_reset(grpc_call_element* elem,
grpc_millis new_deadline) {
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
- cancel_timer_if_needed(exec_ctx, deadline_state);
- start_timer_if_needed(exec_ctx, elem, new_deadline);
+ cancel_timer_if_needed(deadline_state);
+ start_timer_if_needed(elem, new_deadline);
}
void grpc_deadline_state_client_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* op) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
if (op->cancel_stream) {
- cancel_timer_if_needed(exec_ctx, deadline_state);
+ cancel_timer_if_needed(deadline_state);
} else {
// Make sure we know when the call is complete, so that we can cancel
// the timer.
@@ -237,16 +227,14 @@ void grpc_deadline_state_client_start_transport_stream_op_batch(
//
// Constructor for channel_data. Used for both client and server filters.
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
GPR_ASSERT(!args->is_last);
return GRPC_ERROR_NONE;
}
// Destructor for channel_data. Used for both client and server filters.
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
// Call data used for both client and server filter.
typedef struct base_call_data {
@@ -266,50 +254,45 @@ typedef struct server_call_data {
} server_call_data;
// Constructor for call_data. Used for both client and server filters.
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
- grpc_deadline_state_init(exec_ctx, elem, args->call_stack,
- args->call_combiner, args->deadline);
+ grpc_deadline_state_init(elem, args->call_stack, args->call_combiner,
+ args->deadline);
return GRPC_ERROR_NONE;
}
// Destructor for call_data. Used for both client and server filters.
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
- grpc_deadline_state_destroy(exec_ctx, elem);
+ grpc_deadline_state_destroy(elem);
}
// Method for starting a call op for client filter.
static void client_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* op) {
- grpc_deadline_state_client_start_transport_stream_op_batch(exec_ctx, elem,
- op);
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
+ grpc_deadline_state_client_start_transport_stream_op_batch(elem, op);
// Chain to next filter.
- grpc_call_next_op(exec_ctx, elem, op);
+ grpc_call_next_op(elem, op);
}
// Callback for receiving initial metadata on the server.
-static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void recv_initial_metadata_ready(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
server_call_data* calld = (server_call_data*)elem->call_data;
// Get deadline from metadata and start the timer if needed.
- start_timer_if_needed(exec_ctx, elem, calld->recv_initial_metadata->deadline);
+ start_timer_if_needed(elem, calld->recv_initial_metadata->deadline);
// Invoke the next callback.
calld->next_recv_initial_metadata_ready->cb(
- exec_ctx, calld->next_recv_initial_metadata_ready->cb_arg, error);
+ calld->next_recv_initial_metadata_ready->cb_arg, error);
}
// Method for starting a call op for server filter.
static void server_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* op) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
server_call_data* calld = (server_call_data*)elem->call_data;
if (op->cancel_stream) {
- cancel_timer_if_needed(exec_ctx, &calld->base.deadline_state);
+ cancel_timer_if_needed(&calld->base.deadline_state);
} else {
// If we're receiving initial metadata, we need to get the deadline
// from the recv_initial_metadata_ready callback. So we inject our
@@ -335,7 +318,7 @@ static void server_start_transport_stream_op_batch(
}
}
// Chain to next filter.
- grpc_call_next_op(exec_ctx, elem, op);
+ grpc_call_next_op(elem, op);
}
const grpc_channel_filter grpc_client_deadline_filter = {
@@ -372,8 +355,7 @@ bool grpc_deadline_checking_enabled(const grpc_channel_args* channel_args) {
!grpc_channel_args_want_minimal_stack(channel_args));
}
-static bool maybe_add_deadline_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+static bool maybe_add_deadline_filter(grpc_channel_stack_builder* builder,
void* arg) {
return grpc_deadline_checking_enabled(
grpc_channel_stack_builder_get_channel_arguments(builder))
diff --git a/src/core/ext/filters/deadline/deadline_filter.h b/src/core/ext/filters/deadline/deadline_filter.h
index e665dc53ee..0998614db3 100644
--- a/src/core/ext/filters/deadline/deadline_filter.h
+++ b/src/core/ext/filters/deadline/deadline_filter.h
@@ -53,13 +53,12 @@ typedef struct grpc_deadline_state {
//
// assumes elem->call_data is zero'd
-void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+void grpc_deadline_state_init(grpc_call_element* elem,
grpc_call_stack* call_stack,
grpc_call_combiner* call_combiner,
grpc_millis deadline);
-void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem);
+void grpc_deadline_state_destroy(grpc_call_element* elem);
// Cancels the existing timer and starts a new one with new_deadline.
//
@@ -70,7 +69,7 @@ void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx,
// deadline may result in the timer being called twice.
//
// Note: Must be called while holding the call combiner.
-void grpc_deadline_state_reset(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+void grpc_deadline_state_reset(grpc_call_element* elem,
grpc_millis new_deadline);
// To be called from the client-side filter's start_transport_stream_op_batch()
@@ -82,8 +81,7 @@ void grpc_deadline_state_reset(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
//
// Note: Must be called while holding the call combiner.
void grpc_deadline_state_client_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* op);
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op);
// Should deadline checking be performed (according to channel args)
bool grpc_deadline_checking_enabled(const grpc_channel_args* args);
diff --git a/src/core/ext/filters/http/client/http_client_filter.cc b/src/core/ext/filters/http/client/http_client_filter.cc
index a625369b02..a1fb10f5b8 100644
--- a/src/core/ext/filters/http/client/http_client_filter.cc
+++ b/src/core/ext/filters/http/client/http_client_filter.cc
@@ -68,12 +68,11 @@ typedef struct channel_data {
size_t max_payload_size_for_get;
} channel_data;
-static grpc_error* client_filter_incoming_metadata(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* client_filter_incoming_metadata(grpc_call_element* elem,
grpc_metadata_batch* b) {
if (b->idx.named.status != nullptr) {
if (grpc_mdelem_eq(b->idx.named.status->md, GRPC_MDELEM_STATUS_200)) {
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.status);
+ grpc_metadata_batch_remove(b, b->idx.named.status);
} else {
char* val = grpc_dump_slice(GRPC_MDVALUE(b->idx.named.status->md),
GPR_DUMP_ASCII);
@@ -98,10 +97,9 @@ static grpc_error* client_filter_incoming_metadata(grpc_exec_ctx* exec_ctx,
GRPC_MDVALUE(b->idx.named.grpc_message->md));
if (grpc_slice_is_equivalent(pct_decoded_msg,
GRPC_MDVALUE(b->idx.named.grpc_message->md))) {
- grpc_slice_unref_internal(exec_ctx, pct_decoded_msg);
+ grpc_slice_unref_internal(pct_decoded_msg);
} else {
- grpc_metadata_batch_set_value(exec_ctx, b->idx.named.grpc_message,
- pct_decoded_msg);
+ grpc_metadata_batch_set_value(b->idx.named.grpc_message, pct_decoded_msg);
}
}
@@ -131,60 +129,53 @@ static grpc_error* client_filter_incoming_metadata(grpc_exec_ctx* exec_ctx,
gpr_free(val);
}
}
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.content_type);
+ grpc_metadata_batch_remove(b, b->idx.named.content_type);
}
return GRPC_ERROR_NONE;
}
-static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx,
- void* user_data, grpc_error* error) {
+static void recv_initial_metadata_ready(void* user_data, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)user_data;
call_data* calld = (call_data*)elem->call_data;
if (error == GRPC_ERROR_NONE) {
- error = client_filter_incoming_metadata(exec_ctx, elem,
- calld->recv_initial_metadata);
+ error = client_filter_incoming_metadata(elem, calld->recv_initial_metadata);
} else {
GRPC_ERROR_REF(error);
}
- GRPC_CLOSURE_RUN(exec_ctx, calld->original_recv_initial_metadata_ready,
- error);
+ GRPC_CLOSURE_RUN(calld->original_recv_initial_metadata_ready, error);
}
-static void recv_trailing_metadata_on_complete(grpc_exec_ctx* exec_ctx,
- void* user_data,
+static void recv_trailing_metadata_on_complete(void* user_data,
grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)user_data;
call_data* calld = (call_data*)elem->call_data;
if (error == GRPC_ERROR_NONE) {
- error = client_filter_incoming_metadata(exec_ctx, elem,
- calld->recv_trailing_metadata);
+ error =
+ client_filter_incoming_metadata(elem, calld->recv_trailing_metadata);
} else {
GRPC_ERROR_REF(error);
}
- GRPC_CLOSURE_RUN(exec_ctx, calld->original_recv_trailing_metadata_on_complete,
- error);
+ GRPC_CLOSURE_RUN(calld->original_recv_trailing_metadata_on_complete, error);
}
-static void send_message_on_complete(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void send_message_on_complete(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
call_data* calld = (call_data*)elem->call_data;
- grpc_byte_stream_cache_destroy(exec_ctx, &calld->send_message_cache);
- GRPC_CLOSURE_RUN(exec_ctx, calld->original_send_message_on_complete,
+ grpc_byte_stream_cache_destroy(&calld->send_message_cache);
+ GRPC_CLOSURE_RUN(calld->original_send_message_on_complete,
GRPC_ERROR_REF(error));
}
// Pulls a slice from the send_message byte stream, updating
// calld->send_message_bytes_read.
-static grpc_error* pull_slice_from_send_message(grpc_exec_ctx* exec_ctx,
- call_data* calld) {
+static grpc_error* pull_slice_from_send_message(call_data* calld) {
grpc_slice incoming_slice;
grpc_error* error = grpc_byte_stream_pull(
- exec_ctx, &calld->send_message_caching_stream.base, &incoming_slice);
+ &calld->send_message_caching_stream.base, &incoming_slice);
if (error == GRPC_ERROR_NONE) {
calld->send_message_bytes_read += GRPC_SLICE_LENGTH(incoming_slice);
- grpc_slice_unref_internal(exec_ctx, incoming_slice);
+ grpc_slice_unref_internal(incoming_slice);
}
return error;
}
@@ -194,12 +185,10 @@ static grpc_error* pull_slice_from_send_message(grpc_exec_ctx* exec_ctx,
// calld->send_message_caching_stream.base.length, then we have completed
// reading from the byte stream; otherwise, an async read has been dispatched
// and on_send_message_next_done() will be invoked when it is complete.
-static grpc_error* read_all_available_send_message_data(grpc_exec_ctx* exec_ctx,
- call_data* calld) {
- while (grpc_byte_stream_next(exec_ctx,
- &calld->send_message_caching_stream.base,
+static grpc_error* read_all_available_send_message_data(call_data* calld) {
+ while (grpc_byte_stream_next(&calld->send_message_caching_stream.base,
~(size_t)0, &calld->on_send_message_next_done)) {
- grpc_error* error = pull_slice_from_send_message(exec_ctx, calld);
+ grpc_error* error = pull_slice_from_send_message(calld);
if (error != GRPC_ERROR_NONE) return error;
if (calld->send_message_bytes_read ==
calld->send_message_caching_stream.base.length) {
@@ -210,19 +199,18 @@ static grpc_error* read_all_available_send_message_data(grpc_exec_ctx* exec_ctx,
}
// Async callback for grpc_byte_stream_next().
-static void on_send_message_next_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_send_message_next_done(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
call_data* calld = (call_data*)elem->call_data;
if (error != GRPC_ERROR_NONE) {
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, calld->send_message_batch, error, calld->call_combiner);
+ calld->send_message_batch, error, calld->call_combiner);
return;
}
- error = pull_slice_from_send_message(exec_ctx, calld);
+ error = pull_slice_from_send_message(calld);
if (error != GRPC_ERROR_NONE) {
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, calld->send_message_batch, error, calld->call_combiner);
+ calld->send_message_batch, error, calld->call_combiner);
return;
}
// There may or may not be more to read, but we don't care. If we got
@@ -230,7 +218,7 @@ static void on_send_message_next_done(grpc_exec_ctx* exec_ctx, void* arg,
// synchronously, so we were not able to do a cached call. Instead,
// we just reset the byte stream and then send down the batch as-is.
grpc_caching_byte_stream_reset(&calld->send_message_caching_stream);
- grpc_call_next_op(exec_ctx, elem, calld->send_message_batch);
+ grpc_call_next_op(elem, calld->send_message_batch);
}
static char* slice_buffer_to_string(grpc_slice_buffer* slice_buffer) {
@@ -248,8 +236,7 @@ static char* slice_buffer_to_string(grpc_slice_buffer* slice_buffer) {
// Modifies the path entry in the batch's send_initial_metadata to
// append the base64-encoded query for a GET request.
-static grpc_error* update_path_for_get(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* update_path_for_get(grpc_call_element* elem,
grpc_transport_stream_op_batch* batch) {
call_data* calld = (call_data*)elem->call_data;
grpc_slice path_slice =
@@ -282,24 +269,22 @@ static grpc_error* update_path_for_get(grpc_exec_ctx* exec_ctx,
grpc_slice_sub_no_ref(path_with_query_slice, 0, strlen(t));
/* substitute previous path with the new path+query */
grpc_mdelem mdelem_path_and_query =
- grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_PATH, path_with_query_slice);
+ grpc_mdelem_from_slices(GRPC_MDSTR_PATH, path_with_query_slice);
grpc_metadata_batch* b =
batch->payload->send_initial_metadata.send_initial_metadata;
- return grpc_metadata_batch_substitute(exec_ctx, b, b->idx.named.path,
+ return grpc_metadata_batch_substitute(b, b->idx.named.path,
mdelem_path_and_query);
}
-static void remove_if_present(grpc_exec_ctx* exec_ctx,
- grpc_metadata_batch* batch,
+static void remove_if_present(grpc_metadata_batch* batch,
grpc_metadata_batch_callouts_index idx) {
if (batch->idx.array[idx] != nullptr) {
- grpc_metadata_batch_remove(exec_ctx, batch, batch->idx.array[idx]);
+ grpc_metadata_batch_remove(batch, batch->idx.array[idx]);
}
}
static void hc_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* batch) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
call_data* calld = (call_data*)elem->call_data;
channel_data* channeld = (channel_data*)elem->channel_data;
GPR_TIMER_BEGIN("hc_start_transport_stream_op_batch", 0);
@@ -345,17 +330,16 @@ static void hc_start_transport_stream_op_batch(
calld->original_send_message_on_complete = batch->on_complete;
batch->on_complete = &calld->send_message_on_complete;
calld->send_message_batch = batch;
- error = read_all_available_send_message_data(exec_ctx, calld);
+ error = read_all_available_send_message_data(calld);
if (error != GRPC_ERROR_NONE) goto done;
// If all the data has been read, then we can use GET.
if (calld->send_message_bytes_read ==
calld->send_message_caching_stream.base.length) {
method = GRPC_MDELEM_METHOD_GET;
- error = update_path_for_get(exec_ctx, elem, batch);
+ error = update_path_for_get(elem, batch);
if (error != GRPC_ERROR_NONE) goto done;
batch->send_message = false;
- grpc_byte_stream_destroy(exec_ctx,
- &calld->send_message_caching_stream.base);
+ grpc_byte_stream_destroy(&calld->send_message_caching_stream.base);
} else {
// Not all data is available. The batch will be sent down
// asynchronously in on_send_message_next_done().
@@ -372,41 +356,41 @@ static void hc_start_transport_stream_op_batch(
}
remove_if_present(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
GRPC_BATCH_METHOD);
remove_if_present(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
GRPC_BATCH_SCHEME);
remove_if_present(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
GRPC_BATCH_TE);
remove_if_present(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
GRPC_BATCH_CONTENT_TYPE);
remove_if_present(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
GRPC_BATCH_USER_AGENT);
/* Send : prefixed headers, which have to be before any application
layer headers. */
error = grpc_metadata_batch_add_head(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
&calld->method, method);
if (error != GRPC_ERROR_NONE) goto done;
error = grpc_metadata_batch_add_head(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
&calld->scheme, channeld->static_scheme);
if (error != GRPC_ERROR_NONE) goto done;
error = grpc_metadata_batch_add_tail(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
&calld->te_trailers, GRPC_MDELEM_TE_TRAILERS);
if (error != GRPC_ERROR_NONE) goto done;
error = grpc_metadata_batch_add_tail(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
&calld->content_type, GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC);
if (error != GRPC_ERROR_NONE) goto done;
error = grpc_metadata_batch_add_tail(
- exec_ctx, batch->payload->send_initial_metadata.send_initial_metadata,
+ batch->payload->send_initial_metadata.send_initial_metadata,
&calld->user_agent, GRPC_MDELEM_REF(channeld->user_agent));
if (error != GRPC_ERROR_NONE) goto done;
}
@@ -414,16 +398,15 @@ static void hc_start_transport_stream_op_batch(
done:
if (error != GRPC_ERROR_NONE) {
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, calld->send_message_batch, error, calld->call_combiner);
+ calld->send_message_batch, error, calld->call_combiner);
} else if (!batch_will_be_handled_asynchronously) {
- grpc_call_next_op(exec_ctx, elem, batch);
+ grpc_call_next_op(elem, batch);
}
GPR_TIMER_END("hc_start_transport_stream_op_batch", 0);
}
/* Constructor for call_data */
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
call_data* calld = (call_data*)elem->call_data;
calld->call_combiner = args->call_combiner;
@@ -441,7 +424,7 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
}
/* Destructor for call_data */
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {}
@@ -533,8 +516,7 @@ static grpc_slice user_agent_from_args(const grpc_channel_args* args,
}
/* Constructor for channel_data */
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
channel_data* chand = (channel_data*)elem->channel_data;
GPR_ASSERT(!args->is_last);
@@ -543,17 +525,16 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
chand->max_payload_size_for_get =
max_payload_size_from_args(args->channel_args);
chand->user_agent = grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_USER_AGENT,
+ GRPC_MDSTR_USER_AGENT,
user_agent_from_args(args->channel_args,
args->optional_transport->vtable->name));
return GRPC_ERROR_NONE;
}
/* Destructor for channel data */
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {
+static void destroy_channel_elem(grpc_channel_element* elem) {
channel_data* chand = (channel_data*)elem->channel_data;
- GRPC_MDELEM_UNREF(exec_ctx, chand->user_agent);
+ GRPC_MDELEM_UNREF(chand->user_agent);
}
const grpc_channel_filter grpc_http_client_filter = {
diff --git a/src/core/ext/filters/http/http_filters_plugin.cc b/src/core/ext/filters/http/http_filters_plugin.cc
index 69dbde409c..9d47f6889a 100644
--- a/src/core/ext/filters/http/http_filters_plugin.cc
+++ b/src/core/ext/filters/http/http_filters_plugin.cc
@@ -40,8 +40,7 @@ static bool is_building_http_like_transport(
return t != nullptr && strstr(t->vtable->name, "http");
}
-static bool maybe_add_optional_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+static bool maybe_add_optional_filter(grpc_channel_stack_builder* builder,
void* arg) {
if (!is_building_http_like_transport(builder)) return true;
optional_filter* filtarg = (optional_filter*)arg;
@@ -55,8 +54,7 @@ static bool maybe_add_optional_filter(grpc_exec_ctx* exec_ctx,
: true;
}
-static bool maybe_add_required_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+static bool maybe_add_required_filter(grpc_channel_stack_builder* builder,
void* arg) {
return is_building_http_like_transport(builder)
? grpc_channel_stack_builder_prepend_filter(
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 8d95133d8f..bf9e12840d 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
@@ -100,12 +100,11 @@ static bool skip_compression(grpc_call_element* elem, uint32_t flags,
/** Filter initial metadata */
static grpc_error* process_send_initial_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_metadata_batch* initial_metadata,
+ grpc_call_element* elem, grpc_metadata_batch* initial_metadata,
bool* has_compression_algorithm) GRPC_MUST_USE_RESULT;
static grpc_error* process_send_initial_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_metadata_batch* initial_metadata, bool* has_compression_algorithm) {
+ grpc_call_element* elem, grpc_metadata_batch* initial_metadata,
+ bool* has_compression_algorithm) {
call_data* calld = (call_data*)elem->call_data;
channel_data* channeld = (channel_data*)elem->channel_data;
*has_compression_algorithm = false;
@@ -137,13 +136,13 @@ static grpc_error* process_send_initial_metadata(
}
*has_compression_algorithm = true;
grpc_metadata_batch_remove(
- exec_ctx, initial_metadata,
+ 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 != nullptr) {
grpc_metadata_batch_remove(
- exec_ctx, initial_metadata,
+ initial_metadata,
initial_metadata->idx.named.grpc_internal_encoding_request);
}
} else if (initial_metadata->idx.named.grpc_internal_encoding_request !=
@@ -160,7 +159,7 @@ static grpc_error* process_send_initial_metadata(
}
*has_compression_algorithm = true;
grpc_metadata_batch_remove(
- exec_ctx, initial_metadata,
+ initial_metadata,
initial_metadata->idx.named.grpc_internal_encoding_request);
} else {
/* If no algorithm was found in the metadata and we aren't
@@ -181,12 +180,11 @@ static grpc_error* process_send_initial_metadata(
/* hint compression algorithm */
if (stream_compression_algorithm != GRPC_STREAM_COMPRESS_NONE) {
error = grpc_metadata_batch_add_tail(
- exec_ctx, initial_metadata,
- &calld->stream_compression_algorithm_storage,
+ initial_metadata, &calld->stream_compression_algorithm_storage,
grpc_stream_compression_encoding_mdelem(stream_compression_algorithm));
} else if (calld->compression_algorithm != GRPC_COMPRESS_NONE) {
error = grpc_metadata_batch_add_tail(
- exec_ctx, initial_metadata, &calld->compression_algorithm_storage,
+ initial_metadata, &calld->compression_algorithm_storage,
grpc_compression_encoding_mdelem(calld->compression_algorithm));
}
@@ -194,7 +192,7 @@ static grpc_error* process_send_initial_metadata(
/* convey supported compression algorithms */
error = grpc_metadata_batch_add_tail(
- exec_ctx, initial_metadata, &calld->accept_encoding_storage,
+ initial_metadata, &calld->accept_encoding_storage,
GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(
channeld->supported_compression_algorithms));
@@ -203,7 +201,7 @@ static grpc_error* process_send_initial_metadata(
/* Do not overwrite accept-encoding header if it already presents. */
if (!initial_metadata->idx.named.accept_encoding) {
error = grpc_metadata_batch_add_tail(
- exec_ctx, initial_metadata, &calld->accept_stream_encoding_storage,
+ initial_metadata, &calld->accept_stream_encoding_storage,
GRPC_MDELEM_ACCEPT_STREAM_ENCODING_FOR_ALGORITHMS(
channeld->supported_stream_compression_algorithms));
}
@@ -211,17 +209,15 @@ static grpc_error* process_send_initial_metadata(
return error;
}
-static void send_message_on_complete(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void send_message_on_complete(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
call_data* calld = (call_data*)elem->call_data;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &calld->slices);
- GRPC_CLOSURE_RUN(exec_ctx, calld->original_send_message_on_complete,
+ grpc_slice_buffer_reset_and_unref_internal(&calld->slices);
+ GRPC_CLOSURE_RUN(calld->original_send_message_on_complete,
GRPC_ERROR_REF(error));
}
-static void send_message_batch_continue(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem) {
+static void send_message_batch_continue(grpc_call_element* elem) {
call_data* calld = (call_data*)elem->call_data;
// Note: The call to grpc_call_next_op() results in yielding the
// call combiner, so we need to clear calld->send_message_batch
@@ -229,19 +225,18 @@ static void send_message_batch_continue(grpc_exec_ctx* exec_ctx,
grpc_transport_stream_op_batch* send_message_batch =
calld->send_message_batch;
calld->send_message_batch = nullptr;
- grpc_call_next_op(exec_ctx, elem, send_message_batch);
+ grpc_call_next_op(elem, send_message_batch);
}
-static void finish_send_message(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem) {
+static void finish_send_message(grpc_call_element* elem) {
call_data* calld = (call_data*)elem->call_data;
// Compress the data if appropriate.
grpc_slice_buffer tmp;
grpc_slice_buffer_init(&tmp);
uint32_t send_flags =
calld->send_message_batch->payload->send_message.send_message->flags;
- bool did_compress = grpc_msg_compress(exec_ctx, calld->compression_algorithm,
- &calld->slices, &tmp);
+ bool did_compress =
+ grpc_msg_compress(calld->compression_algorithm, &calld->slices, &tmp);
if (did_compress) {
if (GRPC_TRACER_ON(grpc_compression_trace)) {
const char* algo_name;
@@ -268,11 +263,11 @@ static void finish_send_message(grpc_exec_ctx* exec_ctx,
algo_name, calld->slices.length);
}
}
- grpc_slice_buffer_destroy_internal(exec_ctx, &tmp);
+ grpc_slice_buffer_destroy_internal(&tmp);
// Swap out the original byte stream with our new one and send the
// batch down.
grpc_byte_stream_destroy(
- exec_ctx, calld->send_message_batch->payload->send_message.send_message);
+ calld->send_message_batch->payload->send_message.send_message);
grpc_slice_buffer_stream_init(&calld->replacement_stream, &calld->slices,
send_flags);
calld->send_message_batch->payload->send_message.send_message =
@@ -280,27 +275,24 @@ static void finish_send_message(grpc_exec_ctx* exec_ctx,
calld->original_send_message_on_complete =
calld->send_message_batch->on_complete;
calld->send_message_batch->on_complete = &calld->send_message_on_complete;
- send_message_batch_continue(exec_ctx, elem);
+ send_message_batch_continue(elem);
}
-static void fail_send_message_batch_in_call_combiner(grpc_exec_ctx* exec_ctx,
- void* arg,
+static void fail_send_message_batch_in_call_combiner(void* arg,
grpc_error* error) {
call_data* calld = (call_data*)arg;
if (calld->send_message_batch != nullptr) {
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, calld->send_message_batch, GRPC_ERROR_REF(error),
- calld->call_combiner);
+ calld->send_message_batch, GRPC_ERROR_REF(error), calld->call_combiner);
calld->send_message_batch = nullptr;
}
}
// Pulls a slice from the send_message byte stream and adds it to calld->slices.
-static grpc_error* pull_slice_from_send_message(grpc_exec_ctx* exec_ctx,
- call_data* calld) {
+static grpc_error* pull_slice_from_send_message(call_data* calld) {
grpc_slice incoming_slice;
grpc_error* error = grpc_byte_stream_pull(
- exec_ctx, calld->send_message_batch->payload->send_message.send_message,
+ calld->send_message_batch->payload->send_message.send_message,
&incoming_slice);
if (error == GRPC_ERROR_NONE) {
grpc_slice_buffer_add(&calld->slices, incoming_slice);
@@ -312,69 +304,65 @@ static grpc_error* pull_slice_from_send_message(grpc_exec_ctx* exec_ctx,
// If all data has been read, invokes finish_send_message(). Otherwise,
// an async call to grpc_byte_stream_next() has been started, which will
// eventually result in calling on_send_message_next_done().
-static void continue_reading_send_message(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem) {
+static void continue_reading_send_message(grpc_call_element* elem) {
call_data* calld = (call_data*)elem->call_data;
while (grpc_byte_stream_next(
- exec_ctx, calld->send_message_batch->payload->send_message.send_message,
- ~(size_t)0, &calld->on_send_message_next_done)) {
- grpc_error* error = pull_slice_from_send_message(exec_ctx, calld);
+ calld->send_message_batch->payload->send_message.send_message, ~(size_t)0,
+ &calld->on_send_message_next_done)) {
+ grpc_error* error = pull_slice_from_send_message(calld);
if (error != GRPC_ERROR_NONE) {
// Closure callback; does not take ownership of error.
- fail_send_message_batch_in_call_combiner(exec_ctx, calld, error);
+ fail_send_message_batch_in_call_combiner(calld, error);
GRPC_ERROR_UNREF(error);
return;
}
if (calld->slices.length ==
calld->send_message_batch->payload->send_message.send_message->length) {
- finish_send_message(exec_ctx, elem);
+ finish_send_message(elem);
break;
}
}
}
// Async callback for grpc_byte_stream_next().
-static void on_send_message_next_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_send_message_next_done(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
call_data* calld = (call_data*)elem->call_data;
if (error != GRPC_ERROR_NONE) {
// Closure callback; does not take ownership of error.
- fail_send_message_batch_in_call_combiner(exec_ctx, calld, error);
+ fail_send_message_batch_in_call_combiner(calld, error);
return;
}
- error = pull_slice_from_send_message(exec_ctx, calld);
+ error = pull_slice_from_send_message(calld);
if (error != GRPC_ERROR_NONE) {
// Closure callback; does not take ownership of error.
- fail_send_message_batch_in_call_combiner(exec_ctx, calld, error);
+ fail_send_message_batch_in_call_combiner(calld, error);
GRPC_ERROR_UNREF(error);
return;
}
if (calld->slices.length ==
calld->send_message_batch->payload->send_message.send_message->length) {
- finish_send_message(exec_ctx, elem);
+ finish_send_message(elem);
} else {
- continue_reading_send_message(exec_ctx, elem);
+ continue_reading_send_message(elem);
}
}
-static void start_send_message_batch(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* unused) {
+static void start_send_message_batch(void* arg, grpc_error* unused) {
grpc_call_element* elem = (grpc_call_element*)arg;
call_data* calld = (call_data*)elem->call_data;
if (skip_compression(
elem,
calld->send_message_batch->payload->send_message.send_message->flags,
calld->send_initial_metadata_state == HAS_COMPRESSION_ALGORITHM)) {
- send_message_batch_continue(exec_ctx, elem);
+ send_message_batch_continue(elem);
} else {
- continue_reading_send_message(exec_ctx, elem);
+ continue_reading_send_message(elem);
}
}
static void compress_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* batch) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
call_data* calld = (call_data*)elem->call_data;
GPR_TIMER_BEGIN("compress_start_transport_stream_op_batch", 0);
// Handle cancel_stream.
@@ -385,21 +373,19 @@ static void compress_start_transport_stream_op_batch(
if (calld->send_message_batch != nullptr) {
if (calld->send_initial_metadata_state == INITIAL_METADATA_UNSEEN) {
GRPC_CALL_COMBINER_START(
- exec_ctx, calld->call_combiner,
+ calld->call_combiner,
GRPC_CLOSURE_CREATE(fail_send_message_batch_in_call_combiner, calld,
grpc_schedule_on_exec_ctx),
GRPC_ERROR_REF(calld->cancel_error), "failing send_message op");
} else {
grpc_byte_stream_shutdown(
- exec_ctx,
calld->send_message_batch->payload->send_message.send_message,
GRPC_ERROR_REF(calld->cancel_error));
}
}
} else if (calld->cancel_error != GRPC_ERROR_NONE) {
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, batch, GRPC_ERROR_REF(calld->cancel_error),
- calld->call_combiner);
+ batch, GRPC_ERROR_REF(calld->cancel_error), calld->call_combiner);
goto done;
}
// Handle send_initial_metadata.
@@ -407,11 +393,10 @@ static void compress_start_transport_stream_op_batch(
GPR_ASSERT(calld->send_initial_metadata_state == INITIAL_METADATA_UNSEEN);
bool has_compression_algorithm;
grpc_error* error = process_send_initial_metadata(
- exec_ctx, elem,
- batch->payload->send_initial_metadata.send_initial_metadata,
+ elem, batch->payload->send_initial_metadata.send_initial_metadata,
&has_compression_algorithm);
if (error != GRPC_ERROR_NONE) {
- grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, batch, error,
+ grpc_transport_stream_op_batch_finish_with_failure(batch, error,
calld->call_combiner);
goto done;
}
@@ -425,7 +410,7 @@ static void compress_start_transport_stream_op_batch(
// the call stack) will release the call combiner for each batch it sees.
if (calld->send_message_batch != nullptr) {
GRPC_CALL_COMBINER_START(
- exec_ctx, calld->call_combiner,
+ calld->call_combiner,
&calld->start_send_message_batch_in_call_combiner, GRPC_ERROR_NONE,
"starting send_message after send_initial_metadata");
}
@@ -440,22 +425,21 @@ static void compress_start_transport_stream_op_batch(
// send_initial_metadata.
if (calld->send_initial_metadata_state == INITIAL_METADATA_UNSEEN) {
GRPC_CALL_COMBINER_STOP(
- exec_ctx, calld->call_combiner,
+ calld->call_combiner,
"send_message batch pending send_initial_metadata");
goto done;
}
- start_send_message_batch(exec_ctx, elem, GRPC_ERROR_NONE);
+ start_send_message_batch(elem, GRPC_ERROR_NONE);
} else {
// Pass control down the stack.
- grpc_call_next_op(exec_ctx, elem, batch);
+ grpc_call_next_op(elem, batch);
}
done:
GPR_TIMER_END("compress_start_transport_stream_op_batch", 0);
}
/* Constructor for call_data */
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
call_data* calld = (call_data*)elem->call_data;
calld->call_combiner = args->call_combiner;
@@ -471,17 +455,16 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
}
/* Destructor for call_data */
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
call_data* calld = (call_data*)elem->call_data;
- grpc_slice_buffer_destroy_internal(exec_ctx, &calld->slices);
+ grpc_slice_buffer_destroy_internal(&calld->slices);
GRPC_ERROR_UNREF(calld->cancel_error);
}
/* Constructor for channel_data */
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
channel_data* channeld = (channel_data*)elem->channel_data;
@@ -531,8 +514,7 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
}
/* Destructor for channel data */
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
const grpc_channel_filter grpc_message_compress_filter = {
compress_start_transport_stream_op_batch,
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 4f3897915c..b872dc98f5 100644
--- a/src/core/ext/filters/http/server/http_server_filter.cc
+++ b/src/core/ext/filters/http/server/http_server_filter.cc
@@ -66,8 +66,7 @@ typedef struct channel_data {
uint8_t unused;
} channel_data;
-static grpc_error* server_filter_outgoing_metadata(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* server_filter_outgoing_metadata(grpc_call_element* elem,
grpc_metadata_batch* b) {
if (b->idx.named.grpc_message != nullptr) {
grpc_slice pct_encoded_msg = grpc_percent_encode_slice(
@@ -75,10 +74,9 @@ static grpc_error* server_filter_outgoing_metadata(grpc_exec_ctx* exec_ctx,
grpc_compatible_percent_encoding_unreserved_bytes);
if (grpc_slice_is_equivalent(pct_encoded_msg,
GRPC_MDVALUE(b->idx.named.grpc_message->md))) {
- grpc_slice_unref_internal(exec_ctx, pct_encoded_msg);
+ grpc_slice_unref_internal(pct_encoded_msg);
} else {
- grpc_metadata_batch_set_value(exec_ctx, b->idx.named.grpc_message,
- pct_encoded_msg);
+ grpc_metadata_batch_set_value(b->idx.named.grpc_message, pct_encoded_msg);
}
}
return GRPC_ERROR_NONE;
@@ -93,8 +91,7 @@ static void add_error(const char* error_name, grpc_error** cumulative,
*cumulative = grpc_error_add_child(*cumulative, new_err);
}
-static grpc_error* server_filter_incoming_metadata(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* server_filter_incoming_metadata(grpc_call_element* elem,
grpc_metadata_batch* b) {
call_data* calld = (call_data*)elem->call_data;
grpc_error* error = GRPC_ERROR_NONE;
@@ -123,7 +120,7 @@ static grpc_error* server_filter_incoming_metadata(grpc_exec_ctx* exec_ctx,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"),
b->idx.named.method->md));
}
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.method);
+ grpc_metadata_batch_remove(b, b->idx.named.method);
} else {
add_error(
error_name, &error,
@@ -139,7 +136,7 @@ static grpc_error* server_filter_incoming_metadata(grpc_exec_ctx* exec_ctx,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"),
b->idx.named.te->md));
}
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.te);
+ grpc_metadata_batch_remove(b, b->idx.named.te);
} else {
add_error(error_name, &error,
grpc_error_set_str(
@@ -156,7 +153,7 @@ static grpc_error* server_filter_incoming_metadata(grpc_exec_ctx* exec_ctx,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"),
b->idx.named.scheme->md));
}
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.scheme);
+ grpc_metadata_batch_remove(b, b->idx.named.scheme);
} else {
add_error(
error_name, &error,
@@ -191,7 +188,7 @@ static grpc_error* server_filter_incoming_metadata(grpc_exec_ctx* exec_ctx,
gpr_free(val);
}
}
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.content_type);
+ grpc_metadata_batch_remove(b, b->idx.named.content_type);
}
if (b->idx.named.path == nullptr) {
@@ -218,22 +215,21 @@ static grpc_error* server_filter_incoming_metadata(grpc_exec_ctx* exec_ctx,
/* substitute path metadata with just the path (not query) */
grpc_mdelem mdelem_path_without_query = grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_PATH, grpc_slice_sub(path_slice, 0, offset));
+ GRPC_MDSTR_PATH, grpc_slice_sub(path_slice, 0, offset));
- grpc_metadata_batch_substitute(exec_ctx, b, b->idx.named.path,
+ grpc_metadata_batch_substitute(b, b->idx.named.path,
mdelem_path_without_query);
/* decode payload from query and add to the slice buffer to be returned */
const int k_url_safe = 1;
- grpc_slice_buffer_add(
- &calld->read_slice_buffer,
- grpc_base64_decode_with_len(
- exec_ctx, (const char*)GRPC_SLICE_START_PTR(query_slice),
- GRPC_SLICE_LENGTH(query_slice), k_url_safe));
+ grpc_slice_buffer_add(&calld->read_slice_buffer,
+ grpc_base64_decode_with_len(
+ (const char*)GRPC_SLICE_START_PTR(query_slice),
+ GRPC_SLICE_LENGTH(query_slice), k_url_safe));
grpc_slice_buffer_stream_init(&calld->read_stream,
&calld->read_slice_buffer, 0);
calld->seen_path_with_query = true;
- grpc_slice_unref_internal(exec_ctx, query_slice);
+ grpc_slice_unref_internal(query_slice);
} else {
gpr_log(GPR_ERROR, "GET request without QUERY");
}
@@ -242,14 +238,14 @@ static grpc_error* server_filter_incoming_metadata(grpc_exec_ctx* exec_ctx,
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);
+ grpc_metadata_batch_remove(b, el);
add_error(error_name, &error,
grpc_metadata_batch_add_head(
- exec_ctx, b, el,
+ b, el,
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_AUTHORITY,
+ GRPC_MDSTR_AUTHORITY,
grpc_slice_ref_internal(GRPC_MDVALUE(md)))));
- GRPC_MDELEM_UNREF(exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
}
if (b->idx.named.authority == nullptr) {
@@ -263,21 +259,18 @@ static grpc_error* server_filter_incoming_metadata(grpc_exec_ctx* exec_ctx,
return error;
}
-static void hs_on_recv(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_error* err) {
+static void hs_on_recv(void* user_data, grpc_error* err) {
grpc_call_element* elem = (grpc_call_element*)user_data;
call_data* calld = (call_data*)elem->call_data;
if (err == GRPC_ERROR_NONE) {
- err = server_filter_incoming_metadata(exec_ctx, elem,
- calld->recv_initial_metadata);
+ err = server_filter_incoming_metadata(elem, calld->recv_initial_metadata);
} else {
GRPC_ERROR_REF(err);
}
- GRPC_CLOSURE_RUN(exec_ctx, calld->on_done_recv, err);
+ GRPC_CLOSURE_RUN(calld->on_done_recv, err);
}
-static void hs_on_complete(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_error* err) {
+static void hs_on_complete(void* user_data, grpc_error* err) {
grpc_call_element* elem = (grpc_call_element*)user_data;
call_data* calld = (call_data*)elem->call_data;
/* Call recv_message_ready if we got the payload via the path field */
@@ -287,17 +280,16 @@ static void hs_on_complete(grpc_exec_ctx* exec_ctx, void* user_data,
: (grpc_byte_stream*)&calld->read_stream;
// Re-enter call combiner for recv_message_ready, since the surface
// code will release the call combiner for each callback it receives.
- GRPC_CALL_COMBINER_START(exec_ctx, calld->call_combiner,
- calld->recv_message_ready, GRPC_ERROR_REF(err),
+ GRPC_CALL_COMBINER_START(calld->call_combiner, calld->recv_message_ready,
+ GRPC_ERROR_REF(err),
"resuming recv_message_ready from on_complete");
calld->recv_message_ready = nullptr;
calld->payload_bin_delivered = true;
}
- GRPC_CLOSURE_RUN(exec_ctx, calld->on_complete, GRPC_ERROR_REF(err));
+ GRPC_CLOSURE_RUN(calld->on_complete, GRPC_ERROR_REF(err));
}
-static void hs_recv_message_ready(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_error* err) {
+static void hs_recv_message_ready(void* user_data, grpc_error* err) {
grpc_call_element* elem = (grpc_call_element*)user_data;
call_data* calld = (call_data*)elem->call_data;
if (calld->seen_path_with_query) {
@@ -305,15 +297,14 @@ static void hs_recv_message_ready(grpc_exec_ctx* exec_ctx, void* user_data,
// returned in hs_on_complete callback.
// Note that we release the call combiner here, so that other
// callbacks can run.
- GRPC_CALL_COMBINER_STOP(exec_ctx, calld->call_combiner,
+ GRPC_CALL_COMBINER_STOP(calld->call_combiner,
"pausing recv_message_ready until on_complete");
} else {
- GRPC_CLOSURE_RUN(exec_ctx, calld->recv_message_ready, GRPC_ERROR_REF(err));
+ GRPC_CLOSURE_RUN(calld->recv_message_ready, GRPC_ERROR_REF(err));
}
}
-static grpc_error* hs_mutate_op(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* hs_mutate_op(grpc_call_element* elem,
grpc_transport_stream_op_batch* op) {
/* grab pointers to our data from the call element */
call_data* calld = (call_data*)elem->call_data;
@@ -321,21 +312,19 @@ static grpc_error* hs_mutate_op(grpc_exec_ctx* exec_ctx,
if (op->send_initial_metadata) {
grpc_error* error = GRPC_ERROR_NONE;
static const char* error_name = "Failed sending initial metadata";
+ add_error(error_name, &error,
+ grpc_metadata_batch_add_head(
+ op->payload->send_initial_metadata.send_initial_metadata,
+ &calld->status, GRPC_MDELEM_STATUS_200));
+ add_error(error_name, &error,
+ grpc_metadata_batch_add_tail(
+ op->payload->send_initial_metadata.send_initial_metadata,
+ &calld->content_type,
+ GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC));
add_error(
error_name, &error,
- grpc_metadata_batch_add_head(
- exec_ctx, op->payload->send_initial_metadata.send_initial_metadata,
- &calld->status, GRPC_MDELEM_STATUS_200));
- add_error(
- error_name, &error,
- grpc_metadata_batch_add_tail(
- exec_ctx, op->payload->send_initial_metadata.send_initial_metadata,
- &calld->content_type,
- GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC));
- add_error(error_name, &error,
- server_filter_outgoing_metadata(
- exec_ctx, elem,
- op->payload->send_initial_metadata.send_initial_metadata));
+ server_filter_outgoing_metadata(
+ elem, op->payload->send_initial_metadata.send_initial_metadata));
if (error != GRPC_ERROR_NONE) return error;
}
@@ -367,8 +356,7 @@ static grpc_error* hs_mutate_op(grpc_exec_ctx* exec_ctx,
if (op->send_trailing_metadata) {
grpc_error* error = server_filter_outgoing_metadata(
- exec_ctx, elem,
- op->payload->send_trailing_metadata.send_trailing_metadata);
+ elem, op->payload->send_trailing_metadata.send_trailing_metadata);
if (error != GRPC_ERROR_NONE) return error;
}
@@ -376,23 +364,21 @@ static grpc_error* hs_mutate_op(grpc_exec_ctx* exec_ctx,
}
static void hs_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* op) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
call_data* calld = (call_data*)elem->call_data;
GPR_TIMER_BEGIN("hs_start_transport_stream_op_batch", 0);
- grpc_error* error = hs_mutate_op(exec_ctx, elem, op);
+ grpc_error* error = hs_mutate_op(elem, op);
if (error != GRPC_ERROR_NONE) {
- grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, op, error,
+ grpc_transport_stream_op_batch_finish_with_failure(op, error,
calld->call_combiner);
} else {
- grpc_call_next_op(exec_ctx, elem, op);
+ grpc_call_next_op(elem, op);
}
GPR_TIMER_END("hs_start_transport_stream_op_batch", 0);
}
/* Constructor for call_data */
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
/* grab pointers to our data from the call element */
call_data* calld = (call_data*)elem->call_data;
@@ -409,24 +395,22 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
}
/* Destructor for call_data */
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
call_data* calld = (call_data*)elem->call_data;
- grpc_slice_buffer_destroy_internal(exec_ctx, &calld->read_slice_buffer);
+ grpc_slice_buffer_destroy_internal(&calld->read_slice_buffer);
}
/* Constructor for channel_data */
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
GPR_ASSERT(!args->is_last);
return GRPC_ERROR_NONE;
}
/* Destructor for channel data */
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
const grpc_channel_filter grpc_http_server_filter = {
hs_start_transport_stream_op_batch,
diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc b/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc
index 762198f034..f50a928fcd 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
@@ -54,8 +54,7 @@ typedef struct channel_data {
intptr_t id; /**< an id unique to the channel */
} channel_data;
-static void on_initial_md_ready(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_error* err) {
+static void on_initial_md_ready(void* user_data, grpc_error* err) {
grpc_call_element* elem = (grpc_call_element*)user_data;
call_data* calld = (call_data*)elem->call_data;
@@ -73,20 +72,19 @@ static void on_initial_md_ready(grpc_exec_ctx* exec_ctx, void* user_data,
GRPC_MDVALUE(calld->recv_initial_metadata->idx.named.lb_token->md));
calld->have_initial_md_string = true;
grpc_metadata_batch_remove(
- exec_ctx, calld->recv_initial_metadata,
+ calld->recv_initial_metadata,
calld->recv_initial_metadata->idx.named.lb_token);
}
} else {
GRPC_ERROR_REF(err);
}
calld->ops_recv_initial_metadata_ready->cb(
- exec_ctx, calld->ops_recv_initial_metadata_ready->cb_arg, err);
+ calld->ops_recv_initial_metadata_ready->cb_arg, err);
GRPC_ERROR_UNREF(err);
}
/* Constructor for call_data */
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
call_data* calld = (call_data*)elem->call_data;
calld->id = (intptr_t)args->call_stack;
@@ -108,7 +106,7 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
}
/* Destructor for call_data */
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
call_data* calld = (call_data*)elem->call_data;
@@ -125,19 +123,18 @@ static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
*/
if (calld->have_initial_md_string) {
- grpc_slice_unref_internal(exec_ctx, calld->initial_md_string);
+ grpc_slice_unref_internal(calld->initial_md_string);
}
if (calld->have_trailing_md_string) {
- grpc_slice_unref_internal(exec_ctx, calld->trailing_md_string);
+ grpc_slice_unref_internal(calld->trailing_md_string);
}
if (calld->have_service_method) {
- grpc_slice_unref_internal(exec_ctx, calld->service_method);
+ grpc_slice_unref_internal(calld->service_method);
}
}
/* Constructor for channel_data */
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
GPR_ASSERT(!args->is_last);
@@ -158,8 +155,7 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
}
/* Destructor for channel data */
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {
+static void destroy_channel_elem(grpc_channel_element* elem) {
/* TODO(dgq): do something with the data
channel_data *chand = elem->channel_data;
grpc_load_reporting_call_data lr_call_data = {
@@ -173,8 +169,7 @@ static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
*/
}
-static grpc_filtered_mdelem lr_trailing_md_filter(grpc_exec_ctx* exec_ctx,
- void* user_data,
+static grpc_filtered_mdelem lr_trailing_md_filter(void* user_data,
grpc_mdelem md) {
grpc_call_element* elem = (grpc_call_element*)user_data;
call_data* calld = (call_data*)elem->call_data;
@@ -186,8 +181,7 @@ static grpc_filtered_mdelem lr_trailing_md_filter(grpc_exec_ctx* exec_ctx,
}
static void lr_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* op) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
GPR_TIMER_BEGIN("lr_start_transport_stream_op_batch", 0);
call_data* calld = (call_data*)elem->call_data;
@@ -203,12 +197,11 @@ static void lr_start_transport_stream_op_batch(
GRPC_LOG_IF_ERROR(
"grpc_metadata_batch_filter",
grpc_metadata_batch_filter(
- exec_ctx,
op->payload->send_trailing_metadata.send_trailing_metadata,
lr_trailing_md_filter, elem,
"LR trailing metadata filtering error"));
}
- grpc_call_next_op(exec_ctx, elem, op);
+ grpc_call_next_op(elem, op);
GPR_TIMER_END("lr_start_transport_stream_op_batch", 0);
}
diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc b/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc
index ab8387967c..622ab7a3ac 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
@@ -38,7 +38,7 @@ static bool is_load_reporting_enabled(const grpc_channel_args* a) {
}
static bool maybe_add_server_load_reporting_filter(
- grpc_exec_ctx* exec_ctx, grpc_channel_stack_builder* builder, void* arg) {
+ grpc_channel_stack_builder* builder, void* arg) {
const grpc_channel_args* args =
grpc_channel_stack_builder_get_channel_arguments(builder);
const grpc_channel_filter* filter = (const grpc_channel_filter*)arg;
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 001f9f3906..eceb5ababa 100644
--- a/src/core/ext/filters/max_age/max_age_filter.cc
+++ b/src/core/ext/filters/max_age/max_age_filter.cc
@@ -88,73 +88,69 @@ typedef struct channel_data {
/* Increase the nubmer of active calls. Before the increasement, if there are no
calls, the max_idle_timer should be cancelled. */
-static void increase_call_count(grpc_exec_ctx* exec_ctx, channel_data* chand) {
+static void increase_call_count(channel_data* chand) {
if (gpr_atm_full_fetch_add(&chand->call_count, 1) == 0) {
- grpc_timer_cancel(exec_ctx, &chand->max_idle_timer);
+ grpc_timer_cancel(&chand->max_idle_timer);
}
}
/* Decrease the nubmer of active calls. After the decrement, if there are no
calls, the max_idle_timer should be started. */
-static void decrease_call_count(grpc_exec_ctx* exec_ctx, channel_data* chand) {
+static void decrease_call_count(channel_data* chand) {
if (gpr_atm_full_fetch_add(&chand->call_count, -1) == 1) {
GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_idle_timer");
- grpc_timer_init(exec_ctx, &chand->max_idle_timer,
- grpc_exec_ctx_now(exec_ctx) + chand->max_connection_idle,
- &chand->close_max_idle_channel);
+ grpc_timer_init(
+ &chand->max_idle_timer,
+ grpc_core::ExecCtx::Get()->Now() + chand->max_connection_idle,
+ &chand->close_max_idle_channel);
}
}
-static void start_max_idle_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void start_max_idle_timer_after_init(void* arg, grpc_error* error) {
channel_data* chand = (channel_data*)arg;
/* Decrease call_count. If there are no active calls at this time,
max_idle_timer will start here. If the number of active calls is not 0,
max_idle_timer will start after all the active calls end. */
- decrease_call_count(exec_ctx, chand);
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack,
+ decrease_call_count(chand);
+ GRPC_CHANNEL_STACK_UNREF(chand->channel_stack,
"max_age start_max_idle_timer_after_init");
}
-static void start_max_age_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void start_max_age_timer_after_init(void* arg, grpc_error* error) {
channel_data* chand = (channel_data*)arg;
gpr_mu_lock(&chand->max_age_timer_mu);
chand->max_age_timer_pending = true;
GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_age_timer");
- grpc_timer_init(exec_ctx, &chand->max_age_timer,
- grpc_exec_ctx_now(exec_ctx) + chand->max_connection_age,
+ grpc_timer_init(&chand->max_age_timer,
+ grpc_core::ExecCtx::Get()->Now() + chand->max_connection_age,
&chand->close_max_age_channel);
gpr_mu_unlock(&chand->max_age_timer_mu);
grpc_transport_op* op = grpc_make_transport_op(nullptr);
op->on_connectivity_state_change = &chand->channel_connectivity_changed,
op->connectivity_state = &chand->connectivity_state;
- grpc_channel_next_op(exec_ctx,
- grpc_channel_stack_element(chand->channel_stack, 0), op);
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack,
+ grpc_channel_next_op(grpc_channel_stack_element(chand->channel_stack, 0), op);
+ GRPC_CHANNEL_STACK_UNREF(chand->channel_stack,
"max_age start_max_age_timer_after_init");
}
-static void start_max_age_grace_timer_after_goaway_op(grpc_exec_ctx* exec_ctx,
- void* arg,
+static void start_max_age_grace_timer_after_goaway_op(void* arg,
grpc_error* error) {
channel_data* chand = (channel_data*)arg;
gpr_mu_lock(&chand->max_age_timer_mu);
chand->max_age_grace_timer_pending = true;
GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_age_grace_timer");
grpc_timer_init(
- exec_ctx, &chand->max_age_grace_timer,
+ &chand->max_age_grace_timer,
chand->max_connection_age_grace == GRPC_MILLIS_INF_FUTURE
? GRPC_MILLIS_INF_FUTURE
- : grpc_exec_ctx_now(exec_ctx) + chand->max_connection_age_grace,
+ : grpc_core::ExecCtx::Get()->Now() + chand->max_connection_age_grace,
&chand->force_close_max_age_channel);
gpr_mu_unlock(&chand->max_age_timer_mu);
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack,
+ GRPC_CHANNEL_STACK_UNREF(chand->channel_stack,
"max_age start_max_age_grace_timer_after_goaway_op");
}
-static void close_max_idle_channel(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void close_max_idle_channel(void* arg, grpc_error* error) {
channel_data* chand = (channel_data*)arg;
if (error == GRPC_ERROR_NONE) {
/* Prevent the max idle timer from being set again */
@@ -165,16 +161,14 @@ static void close_max_idle_channel(grpc_exec_ctx* exec_ctx, void* arg,
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_NO_ERROR);
grpc_channel_element* elem =
grpc_channel_stack_element(chand->channel_stack, 0);
- elem->filter->start_transport_op(exec_ctx, elem, op);
+ elem->filter->start_transport_op(elem, op);
} else if (error != GRPC_ERROR_CANCELLED) {
GRPC_LOG_IF_ERROR("close_max_idle_channel", error);
}
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack,
- "max_age max_idle_timer");
+ GRPC_CHANNEL_STACK_UNREF(chand->channel_stack, "max_age max_idle_timer");
}
-static void close_max_age_channel(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void close_max_age_channel(void* arg, grpc_error* error) {
channel_data* chand = (channel_data*)arg;
gpr_mu_lock(&chand->max_age_timer_mu);
chand->max_age_timer_pending = false;
@@ -189,16 +183,14 @@ static void close_max_age_channel(grpc_exec_ctx* exec_ctx, void* arg,
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_NO_ERROR);
grpc_channel_element* elem =
grpc_channel_stack_element(chand->channel_stack, 0);
- elem->filter->start_transport_op(exec_ctx, elem, op);
+ elem->filter->start_transport_op(elem, op);
} else if (error != GRPC_ERROR_CANCELLED) {
GRPC_LOG_IF_ERROR("close_max_age_channel", error);
}
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack,
- "max_age max_age_timer");
+ GRPC_CHANNEL_STACK_UNREF(chand->channel_stack, "max_age max_age_timer");
}
-static void force_close_max_age_channel(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void force_close_max_age_channel(void* arg, grpc_error* error) {
channel_data* chand = (channel_data*)arg;
gpr_mu_lock(&chand->max_age_timer_mu);
chand->max_age_grace_timer_pending = false;
@@ -209,38 +201,36 @@ static void force_close_max_age_channel(grpc_exec_ctx* exec_ctx, void* arg,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel reaches max age");
grpc_channel_element* elem =
grpc_channel_stack_element(chand->channel_stack, 0);
- elem->filter->start_transport_op(exec_ctx, elem, op);
+ elem->filter->start_transport_op(elem, op);
} else if (error != GRPC_ERROR_CANCELLED) {
GRPC_LOG_IF_ERROR("force_close_max_age_channel", error);
}
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack,
- "max_age max_age_grace_timer");
+ GRPC_CHANNEL_STACK_UNREF(chand->channel_stack, "max_age max_age_grace_timer");
}
-static void channel_connectivity_changed(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void channel_connectivity_changed(void* arg, grpc_error* error) {
channel_data* chand = (channel_data*)arg;
if (chand->connectivity_state != GRPC_CHANNEL_SHUTDOWN) {
grpc_transport_op* op = grpc_make_transport_op(nullptr);
op->on_connectivity_state_change = &chand->channel_connectivity_changed,
op->connectivity_state = &chand->connectivity_state;
- grpc_channel_next_op(
- exec_ctx, grpc_channel_stack_element(chand->channel_stack, 0), op);
+ grpc_channel_next_op(grpc_channel_stack_element(chand->channel_stack, 0),
+ op);
} else {
gpr_mu_lock(&chand->max_age_timer_mu);
if (chand->max_age_timer_pending) {
- grpc_timer_cancel(exec_ctx, &chand->max_age_timer);
+ grpc_timer_cancel(&chand->max_age_timer);
chand->max_age_timer_pending = false;
}
if (chand->max_age_grace_timer_pending) {
- grpc_timer_cancel(exec_ctx, &chand->max_age_grace_timer);
+ grpc_timer_cancel(&chand->max_age_grace_timer);
chand->max_age_grace_timer_pending = false;
}
gpr_mu_unlock(&chand->max_age_timer_mu);
/* If there are no active calls, this increasement will cancel
max_idle_timer, and prevent max_idle_timer from being started in the
future. */
- increase_call_count(exec_ctx, chand);
+ increase_call_count(chand);
}
}
@@ -263,25 +253,23 @@ add_random_max_connection_age_jitter_and_convert_to_grpc_millis(int value) {
}
/* Constructor for call_data. */
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
channel_data* chand = (channel_data*)elem->channel_data;
- increase_call_count(exec_ctx, chand);
+ increase_call_count(chand);
return GRPC_ERROR_NONE;
}
/* Destructor for call_data. */
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
channel_data* chand = (channel_data*)elem->channel_data;
- decrease_call_count(exec_ctx, chand);
+ decrease_call_count(chand);
}
/* Constructor for channel_data. */
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
channel_data* chand = (channel_data*)elem->channel_data;
gpr_mu_init(&chand->max_age_timer_mu);
@@ -351,8 +339,7 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
initialization is done. */
GRPC_CHANNEL_STACK_REF(chand->channel_stack,
"max_age start_max_age_timer_after_init");
- GRPC_CLOSURE_SCHED(exec_ctx, &chand->start_max_age_timer_after_init,
- GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&chand->start_max_age_timer_after_init, GRPC_ERROR_NONE);
}
/* Initialize the number of calls as 1, so that the max_idle_timer will not
@@ -361,15 +348,14 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
if (chand->max_connection_idle != GRPC_MILLIS_INF_FUTURE) {
GRPC_CHANNEL_STACK_REF(chand->channel_stack,
"max_age start_max_idle_timer_after_init");
- GRPC_CLOSURE_SCHED(exec_ctx, &chand->start_max_idle_timer_after_init,
+ GRPC_CLOSURE_SCHED(&chand->start_max_idle_timer_after_init,
GRPC_ERROR_NONE);
}
return GRPC_ERROR_NONE;
}
/* Destructor for channel_data. */
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
const grpc_channel_filter grpc_max_age_filter = {
grpc_call_next_op,
@@ -384,8 +370,7 @@ const grpc_channel_filter grpc_max_age_filter = {
grpc_channel_next_get_info,
"max_age"};
-static bool maybe_add_max_age_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+static bool maybe_add_max_age_filter(grpc_channel_stack_builder* builder,
void* arg) {
const grpc_channel_args* channel_args =
grpc_channel_stack_builder_get_channel_arguments(builder);
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 2e81d09961..2563a8417c 100644
--- a/src/core/ext/filters/message_size/message_size_filter.cc
+++ b/src/core/ext/filters/message_size/message_size_filter.cc
@@ -47,8 +47,7 @@ static void* refcounted_message_size_limits_ref(void* value) {
return value;
}
-static void refcounted_message_size_limits_unref(grpc_exec_ctx* exec_ctx,
- void* value) {
+static void refcounted_message_size_limits_unref(void* value) {
refcounted_message_size_limits* limits =
(refcounted_message_size_limits*)value;
if (gpr_unref(&limits->refs)) {
@@ -108,8 +107,7 @@ typedef struct channel_data {
// Callback invoked when we receive a message. Here we check the max
// receive message size.
-static void recv_message_ready(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_error* error) {
+static void recv_message_ready(void* user_data, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)user_data;
call_data* calld = (call_data*)elem->call_data;
if (*calld->recv_message != nullptr && calld->limits.max_recv_size >= 0 &&
@@ -132,13 +130,12 @@ static void recv_message_ready(grpc_exec_ctx* exec_ctx, void* user_data,
GRPC_ERROR_REF(error);
}
// Invoke the next callback.
- GRPC_CLOSURE_RUN(exec_ctx, calld->next_recv_message_ready, error);
+ GRPC_CLOSURE_RUN(calld->next_recv_message_ready, error);
}
// Start transport stream op.
static void start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* op) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
call_data* calld = (call_data*)elem->call_data;
// Check max send message size.
if (op->send_message && calld->limits.max_send_size >= 0 &&
@@ -149,7 +146,7 @@ static void start_transport_stream_op_batch(
op->payload->send_message.send_message->length,
calld->limits.max_send_size);
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, op,
+ op,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(message_string),
GRPC_ERROR_INT_GRPC_STATUS,
GRPC_STATUS_RESOURCE_EXHAUSTED),
@@ -165,12 +162,11 @@ static void start_transport_stream_op_batch(
op->payload->recv_message.recv_message_ready = &calld->recv_message_ready;
}
// Chain to the next filter.
- grpc_call_next_op(exec_ctx, elem, op);
+ grpc_call_next_op(elem, op);
}
// Constructor for call_data.
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
channel_data* chand = (channel_data*)elem->channel_data;
call_data* calld = (call_data*)elem->call_data;
@@ -186,7 +182,7 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
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);
+ chand->method_limit_table, args->path);
if (limits != nullptr) {
if (limits->limits.max_send_size >= 0 &&
(limits->limits.max_send_size < calld->limits.max_send_size ||
@@ -204,7 +200,7 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
}
// Destructor for call_data.
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {}
@@ -241,8 +237,7 @@ message_size_limits get_message_size_limits(
}
// Constructor for channel_data.
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
GPR_ASSERT(!args->is_last);
channel_data* chand = (channel_data*)elem->channel_data;
@@ -257,8 +252,7 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
if (service_config != nullptr) {
chand->method_limit_table =
grpc_service_config_create_method_config_table(
- exec_ctx, service_config,
- refcounted_message_size_limits_create_from_json,
+ service_config, refcounted_message_size_limits_create_from_json,
refcounted_message_size_limits_ref,
refcounted_message_size_limits_unref);
grpc_service_config_destroy(service_config);
@@ -268,10 +262,9 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
}
// Destructor for channel_data.
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {
+static void destroy_channel_elem(grpc_channel_element* elem) {
channel_data* chand = (channel_data*)elem->channel_data;
- grpc_slice_hash_table_unref(exec_ctx, chand->method_limit_table);
+ grpc_slice_hash_table_unref(chand->method_limit_table);
}
const grpc_channel_filter grpc_message_size_filter = {
@@ -287,8 +280,7 @@ const grpc_channel_filter grpc_message_size_filter = {
grpc_channel_next_get_info,
"message_size"};
-static bool maybe_add_message_size_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+static bool maybe_add_message_size_filter(grpc_channel_stack_builder* builder,
void* arg) {
const grpc_channel_args* channel_args =
grpc_channel_stack_builder_get_channel_arguments(builder);
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 6bbb4d5739..ce83391458 100644
--- a/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc
+++ b/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc
@@ -50,8 +50,7 @@ static bool get_user_agent_mdelem(const grpc_metadata_batch* batch,
}
// Callback invoked when we receive an initial metadata.
-static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx,
- void* user_data, grpc_error* error) {
+static void recv_initial_metadata_ready(void* user_data, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)user_data;
call_data* calld = (call_data*)elem->call_data;
@@ -67,14 +66,13 @@ static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx,
}
// Invoke the next callback.
- GRPC_CLOSURE_RUN(exec_ctx, calld->next_recv_initial_metadata_ready,
+ GRPC_CLOSURE_RUN(calld->next_recv_initial_metadata_ready,
GRPC_ERROR_REF(error));
}
// Start transport stream op.
static void start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* op) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
call_data* calld = (call_data*)elem->call_data;
// Inject callback for receiving initial metadata
@@ -96,12 +94,11 @@ static void start_transport_stream_op_batch(
}
// Chain to the next filter.
- grpc_call_next_op(exec_ctx, elem, op);
+ grpc_call_next_op(elem, op);
}
// Constructor for call_data.
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
call_data* calld = (call_data*)elem->call_data;
calld->next_recv_initial_metadata_ready = nullptr;
@@ -113,20 +110,18 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
}
// Destructor for call_data.
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {}
// Constructor for channel_data.
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
// Destructor for channel_data.
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
// Parse the user agent
static bool parse_user_agent(grpc_mdelem md) {
@@ -181,7 +176,7 @@ const grpc_channel_filter grpc_workaround_cronet_compression_filter = {
"workaround_cronet_compression"};
static bool register_workaround_cronet_compression(
- grpc_exec_ctx* exec_ctx, grpc_channel_stack_builder* builder, void* arg) {
+ grpc_channel_stack_builder* builder, void* arg) {
const grpc_channel_args* channel_args =
grpc_channel_stack_builder_get_channel_arguments(builder);
const grpc_arg* a = grpc_channel_args_find(
diff --git a/src/core/ext/transport/chttp2/client/chttp2_connector.cc b/src/core/ext/transport/chttp2/client/chttp2_connector.cc
index 77cc313480..9771bd636a 100644
--- a/src/core/ext/transport/chttp2/client/chttp2_connector.cc
+++ b/src/core/ext/transport/chttp2/client/chttp2_connector.cc
@@ -61,38 +61,34 @@ static void chttp2_connector_ref(grpc_connector* con) {
gpr_ref(&c->refs);
}
-static void chttp2_connector_unref(grpc_exec_ctx* exec_ctx,
- grpc_connector* con) {
+static void chttp2_connector_unref(grpc_connector* con) {
chttp2_connector* c = (chttp2_connector*)con;
if (gpr_unref(&c->refs)) {
gpr_mu_destroy(&c->mu);
// If handshaking is not yet in progress, destroy the endpoint.
// Otherwise, the handshaker will do this for us.
- if (c->endpoint != nullptr) grpc_endpoint_destroy(exec_ctx, c->endpoint);
+ if (c->endpoint != nullptr) grpc_endpoint_destroy(c->endpoint);
gpr_free(c);
}
}
-static void chttp2_connector_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_connector* con, grpc_error* why) {
+static void chttp2_connector_shutdown(grpc_connector* con, grpc_error* why) {
chttp2_connector* c = (chttp2_connector*)con;
gpr_mu_lock(&c->mu);
c->shutdown = true;
if (c->handshake_mgr != nullptr) {
- grpc_handshake_manager_shutdown(exec_ctx, c->handshake_mgr,
- GRPC_ERROR_REF(why));
+ grpc_handshake_manager_shutdown(c->handshake_mgr, GRPC_ERROR_REF(why));
}
// If handshaking is not yet in progress, shutdown the endpoint.
// Otherwise, the handshaker will do this for us.
if (!c->connecting && c->endpoint != nullptr) {
- grpc_endpoint_shutdown(exec_ctx, c->endpoint, GRPC_ERROR_REF(why));
+ grpc_endpoint_shutdown(c->endpoint, GRPC_ERROR_REF(why));
}
gpr_mu_unlock(&c->mu);
GRPC_ERROR_UNREF(why);
}
-static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_handshake_done(void* arg, grpc_error* error) {
grpc_handshaker_args* args = (grpc_handshaker_args*)arg;
chttp2_connector* c = (chttp2_connector*)args->user_data;
gpr_mu_lock(&c->mu);
@@ -105,48 +101,46 @@ static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
// before destroying them, even if we know that there are no
// pending read/write callbacks. This should be fixed, at which
// point this can be removed.
- grpc_endpoint_shutdown(exec_ctx, args->endpoint, GRPC_ERROR_REF(error));
- grpc_endpoint_destroy(exec_ctx, args->endpoint);
- grpc_channel_args_destroy(exec_ctx, args->args);
- grpc_slice_buffer_destroy_internal(exec_ctx, args->read_buffer);
+ grpc_endpoint_shutdown(args->endpoint, GRPC_ERROR_REF(error));
+ grpc_endpoint_destroy(args->endpoint);
+ grpc_channel_args_destroy(args->args);
+ grpc_slice_buffer_destroy_internal(args->read_buffer);
gpr_free(args->read_buffer);
} else {
error = GRPC_ERROR_REF(error);
}
memset(c->result, 0, sizeof(*c->result));
} else {
- grpc_endpoint_delete_from_pollset_set(exec_ctx, args->endpoint,
+ grpc_endpoint_delete_from_pollset_set(args->endpoint,
c->args.interested_parties);
c->result->transport =
- grpc_create_chttp2_transport(exec_ctx, args->args, args->endpoint, 1);
+ grpc_create_chttp2_transport(args->args, args->endpoint, 1);
GPR_ASSERT(c->result->transport);
- grpc_chttp2_transport_start_reading(exec_ctx, c->result->transport,
+ grpc_chttp2_transport_start_reading(c->result->transport,
args->read_buffer);
c->result->channel_args = args->args;
}
grpc_closure* notify = c->notify;
c->notify = nullptr;
- GRPC_CLOSURE_SCHED(exec_ctx, notify, error);
- grpc_handshake_manager_destroy(exec_ctx, c->handshake_mgr);
+ GRPC_CLOSURE_SCHED(notify, error);
+ grpc_handshake_manager_destroy(c->handshake_mgr);
c->handshake_mgr = nullptr;
gpr_mu_unlock(&c->mu);
- chttp2_connector_unref(exec_ctx, (grpc_connector*)c);
+ chttp2_connector_unref((grpc_connector*)c);
}
-static void start_handshake_locked(grpc_exec_ctx* exec_ctx,
- chttp2_connector* c) {
+static void start_handshake_locked(chttp2_connector* c) {
c->handshake_mgr = grpc_handshake_manager_create();
- grpc_handshakers_add(exec_ctx, HANDSHAKER_CLIENT, c->args.channel_args,
+ grpc_handshakers_add(HANDSHAKER_CLIENT, c->args.channel_args,
c->handshake_mgr);
- grpc_endpoint_add_to_pollset_set(exec_ctx, c->endpoint,
- c->args.interested_parties);
+ grpc_endpoint_add_to_pollset_set(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, nullptr /* acceptor */, on_handshake_done, c);
+ c->handshake_mgr, 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) {
+static void connected(void* arg, grpc_error* error) {
chttp2_connector* c = (chttp2_connector*)arg;
gpr_mu_lock(&c->mu);
GPR_ASSERT(c->connecting);
@@ -160,27 +154,26 @@ 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 = nullptr;
- GRPC_CLOSURE_SCHED(exec_ctx, notify, error);
+ GRPC_CLOSURE_SCHED(notify, error);
if (c->endpoint != nullptr) {
- grpc_endpoint_shutdown(exec_ctx, c->endpoint, GRPC_ERROR_REF(error));
+ grpc_endpoint_shutdown(c->endpoint, GRPC_ERROR_REF(error));
}
gpr_mu_unlock(&c->mu);
- chttp2_connector_unref(exec_ctx, (grpc_connector*)arg);
+ chttp2_connector_unref((grpc_connector*)arg);
} else {
GPR_ASSERT(c->endpoint != nullptr);
- start_handshake_locked(exec_ctx, c);
+ start_handshake_locked(c);
gpr_mu_unlock(&c->mu);
}
}
-static void chttp2_connector_connect(grpc_exec_ctx* exec_ctx,
- grpc_connector* con,
+static void chttp2_connector_connect(grpc_connector* con,
const grpc_connect_in_args* args,
grpc_connect_out_args* result,
grpc_closure* notify) {
chttp2_connector* c = (chttp2_connector*)con;
grpc_resolved_address addr;
- grpc_get_subchannel_address_arg(exec_ctx, args->channel_args, &addr);
+ grpc_get_subchannel_address_arg(args->channel_args, &addr);
gpr_mu_lock(&c->mu);
GPR_ASSERT(c->notify == nullptr);
c->notify = notify;
@@ -191,9 +184,8 @@ static void chttp2_connector_connect(grpc_exec_ctx* exec_ctx,
GRPC_CLOSURE_INIT(&c->connected, connected, c, grpc_schedule_on_exec_ctx);
GPR_ASSERT(!c->connecting);
c->connecting = true;
- grpc_tcp_client_connect(exec_ctx, &c->connected, &c->endpoint,
- args->interested_parties, args->channel_args, &addr,
- args->deadline);
+ grpc_tcp_client_connect(&c->connected, &c->endpoint, args->interested_parties,
+ args->channel_args, &addr, args->deadline);
gpr_mu_unlock(&c->mu);
}
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 028b69e5ff..9cf7bf884b 100644
--- a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
+++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
@@ -34,21 +34,19 @@ static void client_channel_factory_ref(
grpc_client_channel_factory* cc_factory) {}
static void client_channel_factory_unref(
- grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory) {}
+ grpc_client_channel_factory* cc_factory) {}
static grpc_subchannel* client_channel_factory_create_subchannel(
- grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory,
- const grpc_subchannel_args* args) {
+ grpc_client_channel_factory* cc_factory, const grpc_subchannel_args* args) {
grpc_connector* connector = grpc_chttp2_connector_create();
- grpc_subchannel* s = grpc_subchannel_create(exec_ctx, connector, args);
- grpc_connector_unref(exec_ctx, connector);
+ grpc_subchannel* s = grpc_subchannel_create(connector, args);
+ grpc_connector_unref(connector);
return s;
}
static grpc_channel* client_channel_factory_create_channel(
- grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory,
- const char* target, grpc_client_channel_type type,
- const grpc_channel_args* args) {
+ grpc_client_channel_factory* cc_factory, const char* target,
+ grpc_client_channel_type type, const grpc_channel_args* args) {
if (target == nullptr) {
gpr_log(GPR_ERROR, "cannot create channel with NULL target name");
return nullptr;
@@ -56,14 +54,14 @@ static grpc_channel* client_channel_factory_create_channel(
// Add channel arg containing the server URI.
grpc_arg arg = grpc_channel_arg_string_create(
(char*)GRPC_ARG_SERVER_URI,
- grpc_resolver_factory_add_default_prefix_if_needed(exec_ctx, target));
+ grpc_resolver_factory_add_default_prefix_if_needed(target));
const char* to_remove[] = {GRPC_ARG_SERVER_URI};
grpc_channel_args* new_args =
grpc_channel_args_copy_and_add_and_remove(args, to_remove, 1, &arg, 1);
gpr_free(arg.value.string);
- grpc_channel* channel = grpc_channel_create(exec_ctx, target, new_args,
- GRPC_CLIENT_CHANNEL, nullptr);
- grpc_channel_args_destroy(exec_ctx, new_args);
+ grpc_channel* channel =
+ grpc_channel_create(target, new_args, GRPC_CLIENT_CHANNEL, nullptr);
+ grpc_channel_args_destroy(new_args);
return channel;
}
@@ -82,7 +80,7 @@ static grpc_client_channel_factory client_channel_factory = {
grpc_channel* grpc_insecure_channel_create(const char* target,
const grpc_channel_args* args,
void* reserved) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GRPC_API_TRACE(
"grpc_insecure_channel_create(target=%s, args=%p, reserved=%p)", 3,
(target, args, reserved));
@@ -93,11 +91,11 @@ grpc_channel* grpc_insecure_channel_create(const char* target,
grpc_channel_args* new_args = grpc_channel_args_copy_and_add(args, &arg, 1);
// Create channel.
grpc_channel* channel = client_channel_factory_create_channel(
- &exec_ctx, &client_channel_factory, target,
- GRPC_CLIENT_CHANNEL_TYPE_REGULAR, new_args);
+ &client_channel_factory, target, GRPC_CLIENT_CHANNEL_TYPE_REGULAR,
+ new_args);
// Clean up.
- grpc_channel_args_destroy(&exec_ctx, new_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(new_args);
+
return channel != nullptr ? channel
: grpc_lame_client_channel_create(
target, GRPC_STATUS_INTERNAL,
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 e748d28964..bdd8d93bd3 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
@@ -37,7 +37,7 @@
grpc_channel* grpc_insecure_channel_create_from_fd(
const char* target, int fd, const grpc_channel_args* args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GRPC_API_TRACE("grpc_insecure_channel_create(target=%p, fd=%d, args=%p)", 3,
(target, fd, args));
@@ -50,17 +50,15 @@ grpc_channel* grpc_insecure_channel_create_from_fd(
GPR_ASSERT(fcntl(fd, F_SETFL, flags | O_NONBLOCK) == 0);
grpc_endpoint* client = grpc_tcp_client_create_from_fd(
- &exec_ctx, grpc_fd_create(fd, "client"), args, "fd-client");
+ 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(final_args, client, 1);
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, nullptr);
-
- grpc_exec_ctx_finish(&exec_ctx);
+ target, final_args, GRPC_CLIENT_DIRECT_CHANNEL, transport);
+ grpc_channel_args_destroy(final_args);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
return channel != nullptr ? channel
: grpc_lame_client_channel_create(
@@ -73,7 +71,7 @@ grpc_channel* grpc_insecure_channel_create_from_fd(
grpc_channel* grpc_insecure_channel_create_from_fd(
const char* target, int fd, const grpc_channel_args* args) {
GPR_ASSERT(0);
- return NULL;
+ return nullptr;
}
#endif // GPR_SUPPORT_CHANNELS_FROM_FD
diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
index dd2bc427a7..e0264cadc5 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
@@ -41,10 +41,10 @@ static void client_channel_factory_ref(
grpc_client_channel_factory* cc_factory) {}
static void client_channel_factory_unref(
- grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory) {}
+ grpc_client_channel_factory* cc_factory) {}
static grpc_subchannel_args* get_secure_naming_subchannel_args(
- grpc_exec_ctx* exec_ctx, const grpc_subchannel_args* args) {
+ const grpc_subchannel_args* args) {
grpc_channel_credentials* channel_credentials =
grpc_channel_credentials_find_in_args(args->args);
if (channel_credentials == nullptr) {
@@ -68,7 +68,7 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
const char* server_uri_str = server_uri_arg->value.string;
GPR_ASSERT(server_uri_str != nullptr);
grpc_uri* server_uri =
- grpc_uri_parse(exec_ctx, server_uri_str, true /* supress errors */);
+ grpc_uri_parse(server_uri_str, true /* supress errors */);
GPR_ASSERT(server_uri != nullptr);
const char* server_uri_path;
server_uri_path =
@@ -81,7 +81,7 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
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 */);
+ grpc_uri_parse(target_uri_str, false /* suppress errors */);
GPR_ASSERT(target_uri != nullptr);
if (target_uri->path[0] != '\0') { // "path" may be empty
const grpc_slice key = grpc_slice_from_static_string(
@@ -89,7 +89,7 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
const char* value =
(const char*)grpc_slice_hash_table_get(targets_info, key);
if (value != nullptr) target_name_to_check = gpr_strdup(value);
- grpc_slice_unref_internal(exec_ctx, key);
+ grpc_slice_unref_internal(key);
}
if (target_name_to_check == nullptr) {
// If the target name to check hasn't already been set, fall back to using
@@ -107,7 +107,7 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
grpc_channel_args* new_args_from_connector = nullptr;
const grpc_security_status security_status =
grpc_channel_credentials_create_security_connector(
- exec_ctx, channel_credentials, target_name_to_check, args->args,
+ channel_credentials, target_name_to_check, args->args,
&subchannel_security_connector, &new_args_from_connector);
if (security_status != GRPC_SECURITY_OK) {
gpr_log(GPR_ERROR,
@@ -123,10 +123,10 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
grpc_channel_args* new_args = grpc_channel_args_copy_and_add(
new_args_from_connector != nullptr ? new_args_from_connector : args->args,
&new_security_connector_arg, 1);
- GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, &subchannel_security_connector->base,
+ GRPC_SECURITY_CONNECTOR_UNREF(&subchannel_security_connector->base,
"lb_channel_create");
if (new_args_from_connector != nullptr) {
- grpc_channel_args_destroy(exec_ctx, new_args_from_connector);
+ grpc_channel_args_destroy(new_args_from_connector);
}
grpc_subchannel_args* final_sc_args =
(grpc_subchannel_args*)gpr_malloc(sizeof(*final_sc_args));
@@ -136,10 +136,9 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
}
static grpc_subchannel* client_channel_factory_create_subchannel(
- grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory,
- const grpc_subchannel_args* args) {
+ grpc_client_channel_factory* cc_factory, const grpc_subchannel_args* args) {
grpc_subchannel_args* subchannel_args =
- get_secure_naming_subchannel_args(exec_ctx, args);
+ get_secure_naming_subchannel_args(args);
if (subchannel_args == nullptr) {
gpr_log(
GPR_ERROR,
@@ -147,19 +146,16 @@ static grpc_subchannel* client_channel_factory_create_subchannel(
return nullptr;
}
grpc_connector* connector = grpc_chttp2_connector_create();
- grpc_subchannel* s =
- grpc_subchannel_create(exec_ctx, connector, subchannel_args);
- grpc_connector_unref(exec_ctx, connector);
- grpc_channel_args_destroy(exec_ctx,
- (grpc_channel_args*)subchannel_args->args);
+ grpc_subchannel* s = grpc_subchannel_create(connector, subchannel_args);
+ grpc_connector_unref(connector);
+ grpc_channel_args_destroy((grpc_channel_args*)subchannel_args->args);
gpr_free(subchannel_args);
return s;
}
static grpc_channel* client_channel_factory_create_channel(
- grpc_exec_ctx* exec_ctx, grpc_client_channel_factory* cc_factory,
- const char* target, grpc_client_channel_type type,
- const grpc_channel_args* args) {
+ grpc_client_channel_factory* cc_factory, const char* target,
+ grpc_client_channel_type type, const grpc_channel_args* args) {
if (target == nullptr) {
gpr_log(GPR_ERROR, "cannot create channel with NULL target name");
return nullptr;
@@ -167,14 +163,14 @@ static grpc_channel* client_channel_factory_create_channel(
// Add channel arg containing the server URI.
grpc_arg arg = grpc_channel_arg_string_create(
(char*)GRPC_ARG_SERVER_URI,
- grpc_resolver_factory_add_default_prefix_if_needed(exec_ctx, target));
+ grpc_resolver_factory_add_default_prefix_if_needed(target));
const char* to_remove[] = {GRPC_ARG_SERVER_URI};
grpc_channel_args* new_args =
grpc_channel_args_copy_and_add_and_remove(args, to_remove, 1, &arg, 1);
gpr_free(arg.value.string);
- grpc_channel* channel = grpc_channel_create(exec_ctx, target, new_args,
- GRPC_CLIENT_CHANNEL, nullptr);
- grpc_channel_args_destroy(exec_ctx, new_args);
+ grpc_channel* channel =
+ grpc_channel_create(target, new_args, GRPC_CLIENT_CHANNEL, nullptr);
+ grpc_channel_args_destroy(new_args);
return channel;
}
@@ -194,7 +190,7 @@ grpc_channel* grpc_secure_channel_create(grpc_channel_credentials* creds,
const char* target,
const grpc_channel_args* args,
void* reserved) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GRPC_API_TRACE(
"grpc_secure_channel_create(creds=%p, target=%s, args=%p, "
"reserved=%p)",
@@ -211,11 +207,10 @@ grpc_channel* grpc_secure_channel_create(grpc_channel_credentials* creds,
args, args_to_add, GPR_ARRAY_SIZE(args_to_add));
// Create channel.
channel = client_channel_factory_create_channel(
- &exec_ctx, &client_channel_factory, target,
- GRPC_CLIENT_CHANNEL_TYPE_REGULAR, new_args);
+ &client_channel_factory, target, GRPC_CLIENT_CHANNEL_TYPE_REGULAR,
+ new_args);
// Clean up.
- grpc_channel_args_destroy(&exec_ctx, new_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(new_args);
}
return channel != nullptr ? channel
: grpc_lame_client_channel_create(
diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc
index 93be5e4081..08d919144e 100644
--- a/src/core/ext/transport/chttp2/server/chttp2_server.cc
+++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc
@@ -59,8 +59,7 @@ typedef struct {
grpc_handshake_manager* handshake_mgr;
} server_connection_state;
-static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_handshake_done(void* arg, grpc_error* error) {
grpc_handshaker_args* args = (grpc_handshaker_args*)arg;
server_connection_state* connection_state =
(server_connection_state*)args->user_data;
@@ -76,10 +75,10 @@ static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
// before destroying them, even if we know that there are no
// pending read/write callbacks. This should be fixed, at which
// point this can be removed.
- grpc_endpoint_shutdown(exec_ctx, args->endpoint, GRPC_ERROR_NONE);
- grpc_endpoint_destroy(exec_ctx, args->endpoint);
- grpc_channel_args_destroy(exec_ctx, args->args);
- grpc_slice_buffer_destroy_internal(exec_ctx, args->read_buffer);
+ grpc_endpoint_shutdown(args->endpoint, GRPC_ERROR_NONE);
+ grpc_endpoint_destroy(args->endpoint);
+ grpc_channel_args_destroy(args->args);
+ grpc_slice_buffer_destroy_internal(args->read_buffer);
gpr_free(args->read_buffer);
}
} else {
@@ -88,34 +87,33 @@ static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
// code, so we can just clean up here without creating a transport.
if (args->endpoint != nullptr) {
grpc_transport* transport =
- grpc_create_chttp2_transport(exec_ctx, args->args, args->endpoint, 0);
+ grpc_create_chttp2_transport(args->args, args->endpoint, 0);
grpc_server_setup_transport(
- exec_ctx, connection_state->svr_state->server, transport,
+ connection_state->svr_state->server, transport,
connection_state->accepting_pollset, args->args);
- grpc_chttp2_transport_start_reading(exec_ctx, transport,
- args->read_buffer);
- grpc_channel_args_destroy(exec_ctx, args->args);
+ grpc_chttp2_transport_start_reading(transport, args->read_buffer);
+ grpc_channel_args_destroy(args->args);
}
}
grpc_handshake_manager_pending_list_remove(
&connection_state->svr_state->pending_handshake_mgrs,
connection_state->handshake_mgr);
gpr_mu_unlock(&connection_state->svr_state->mu);
- grpc_handshake_manager_destroy(exec_ctx, connection_state->handshake_mgr);
- grpc_tcp_server_unref(exec_ctx, connection_state->svr_state->tcp_server);
+ grpc_handshake_manager_destroy(connection_state->handshake_mgr);
+ grpc_tcp_server_unref(connection_state->svr_state->tcp_server);
gpr_free(connection_state->acceptor);
gpr_free(connection_state);
}
-static void on_accept(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
+static void on_accept(void* arg, grpc_endpoint* tcp,
grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) {
server_state* state = (server_state*)arg;
gpr_mu_lock(&state->mu);
if (state->shutdown) {
gpr_mu_unlock(&state->mu);
- grpc_endpoint_shutdown(exec_ctx, tcp, GRPC_ERROR_NONE);
- grpc_endpoint_destroy(exec_ctx, tcp);
+ grpc_endpoint_shutdown(tcp, GRPC_ERROR_NONE);
+ grpc_endpoint_destroy(tcp);
gpr_free(acceptor);
return;
}
@@ -130,55 +128,53 @@ static void on_accept(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
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,
+ grpc_handshakers_add(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;
- grpc_handshake_manager_do_handshake(exec_ctx, connection_state->handshake_mgr,
- tcp, state->args, deadline, acceptor,
+ grpc_core::ExecCtx::Get()->Now() + 120 * GPR_MS_PER_SEC;
+ grpc_handshake_manager_do_handshake(connection_state->handshake_mgr, tcp,
+ state->args, deadline, acceptor,
on_handshake_done, connection_state);
}
/* Server callback: start listening on our ports */
-static void server_start_listener(grpc_exec_ctx* exec_ctx, grpc_server* server,
- void* arg, grpc_pollset** pollsets,
+static void server_start_listener(grpc_server* server, void* arg,
+ grpc_pollset** pollsets,
size_t pollset_count) {
server_state* state = (server_state*)arg;
gpr_mu_lock(&state->mu);
state->shutdown = false;
gpr_mu_unlock(&state->mu);
- grpc_tcp_server_start(exec_ctx, state->tcp_server, pollsets, pollset_count,
- on_accept, state);
+ grpc_tcp_server_start(state->tcp_server, pollsets, pollset_count, on_accept,
+ state);
}
-static void tcp_server_shutdown_complete(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void tcp_server_shutdown_complete(void* arg, grpc_error* error) {
server_state* state = (server_state*)arg;
/* ensure all threads have unlocked */
gpr_mu_lock(&state->mu);
grpc_closure* destroy_done = state->server_destroy_listener_done;
GPR_ASSERT(state->shutdown);
grpc_handshake_manager_pending_list_shutdown_all(
- exec_ctx, state->pending_handshake_mgrs, GRPC_ERROR_REF(error));
+ state->pending_handshake_mgrs, GRPC_ERROR_REF(error));
gpr_mu_unlock(&state->mu);
// Flush queued work before destroying handshaker factory, since that
// may do a synchronous unref.
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
if (destroy_done != nullptr) {
- destroy_done->cb(exec_ctx, destroy_done->cb_arg, GRPC_ERROR_REF(error));
- grpc_exec_ctx_flush(exec_ctx);
+ destroy_done->cb(destroy_done->cb_arg, GRPC_ERROR_REF(error));
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_channel_args_destroy(exec_ctx, state->args);
+ grpc_channel_args_destroy(state->args);
gpr_mu_destroy(&state->mu);
gpr_free(state);
}
/* Server callback: destroy the tcp listener (so we don't generate further
callbacks) */
-static void server_destroy_listener(grpc_exec_ctx* exec_ctx,
- grpc_server* server, void* arg,
+static void server_destroy_listener(grpc_server* server, void* arg,
grpc_closure* destroy_done) {
server_state* state = (server_state*)arg;
gpr_mu_lock(&state->mu);
@@ -186,12 +182,11 @@ static void server_destroy_listener(grpc_exec_ctx* exec_ctx,
state->server_destroy_listener_done = destroy_done;
grpc_tcp_server* tcp_server = state->tcp_server;
gpr_mu_unlock(&state->mu);
- grpc_tcp_server_shutdown_listeners(exec_ctx, tcp_server);
- grpc_tcp_server_unref(exec_ctx, tcp_server);
+ grpc_tcp_server_shutdown_listeners(tcp_server);
+ grpc_tcp_server_unref(tcp_server);
}
-grpc_error* grpc_chttp2_server_add_port(grpc_exec_ctx* exec_ctx,
- grpc_server* server, const char* addr,
+grpc_error* grpc_chttp2_server_add_port(grpc_server* server, const char* addr,
grpc_channel_args* args,
int* port_num) {
grpc_resolved_addresses* resolved = nullptr;
@@ -215,8 +210,8 @@ grpc_error* grpc_chttp2_server_add_port(grpc_exec_ctx* exec_ctx,
GRPC_CLOSURE_INIT(&state->tcp_server_shutdown_complete,
tcp_server_shutdown_complete, state,
grpc_schedule_on_exec_ctx);
- err = grpc_tcp_server_create(exec_ctx, &state->tcp_server_shutdown_complete,
- args, &tcp_server);
+ err = grpc_tcp_server_create(&state->tcp_server_shutdown_complete, args,
+ &tcp_server);
if (err != GRPC_ERROR_NONE) {
goto error;
}
@@ -265,7 +260,7 @@ grpc_error* grpc_chttp2_server_add_port(grpc_exec_ctx* exec_ctx,
grpc_resolved_addresses_destroy(resolved);
/* Register with the server only upon success */
- grpc_server_add_listener(exec_ctx, server, state, server_start_listener,
+ grpc_server_add_listener(server, state, server_start_listener,
server_destroy_listener);
goto done;
@@ -276,9 +271,9 @@ error:
grpc_resolved_addresses_destroy(resolved);
}
if (tcp_server) {
- grpc_tcp_server_unref(exec_ctx, tcp_server);
+ grpc_tcp_server_unref(tcp_server);
} else {
- grpc_channel_args_destroy(exec_ctx, args);
+ grpc_channel_args_destroy(args);
gpr_free(state);
}
*port_num = 0;
diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.h b/src/core/ext/transport/chttp2/server/chttp2_server.h
index 4e0e7aa617..f0cf669ff0 100644
--- a/src/core/ext/transport/chttp2/server/chttp2_server.h
+++ b/src/core/ext/transport/chttp2/server/chttp2_server.h
@@ -29,8 +29,7 @@ extern "C" {
/// 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_error* grpc_chttp2_server_add_port(grpc_server* server, const char* addr,
grpc_channel_args* args, int* port_num);
#ifdef __cplusplus
diff --git a/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc b/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc
index 8984896538..826886c961 100644
--- a/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc
+++ b/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc
@@ -26,12 +26,12 @@
#include "src/core/lib/surface/server.h"
int grpc_server_add_insecure_http2_port(grpc_server* server, const char* addr) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
int port_num = 0;
GRPC_API_TRACE("grpc_server_add_insecure_http2_port(server=%p, addr=%s)", 2,
(server, addr));
grpc_error* err = grpc_chttp2_server_add_port(
- &exec_ctx, server, addr,
+ server, addr,
grpc_channel_args_copy(grpc_server_get_channel_args(server)), &port_num);
if (err != GRPC_ERROR_NONE) {
const char* msg = grpc_error_string(err);
@@ -39,6 +39,6 @@ int grpc_server_add_insecure_http2_port(grpc_server* server, const char* addr) {
GRPC_ERROR_UNREF(err);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
return port_num;
}
diff --git a/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc b/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc
index 007d1be50c..56789ab53d 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
@@ -38,32 +38,29 @@ void grpc_server_add_insecure_channel_from_fd(grpc_server* server,
void* reserved, int fd) {
GPR_ASSERT(reserved == nullptr);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
char* name;
gpr_asprintf(&name, "fd:%d", fd);
- grpc_endpoint* server_endpoint =
- grpc_tcp_create(&exec_ctx, grpc_fd_create(fd, name),
- grpc_server_get_channel_args(server), name);
+ grpc_endpoint* server_endpoint = grpc_tcp_create(
+ grpc_fd_create(fd, name), grpc_server_get_channel_args(server), name);
gpr_free(name);
const grpc_channel_args* server_args = grpc_server_get_channel_args(server);
grpc_transport* transport = grpc_create_chttp2_transport(
- &exec_ctx, server_args, server_endpoint, 0 /* is_client */);
+ server_args, server_endpoint, 0 /* is_client */);
grpc_pollset** pollsets;
size_t num_pollsets = 0;
grpc_server_get_pollsets(server, &pollsets, &num_pollsets);
for (size_t i = 0; i < num_pollsets; i++) {
- grpc_endpoint_add_to_pollset(&exec_ctx, server_endpoint, pollsets[i]);
+ grpc_endpoint_add_to_pollset(server_endpoint, pollsets[i]);
}
- grpc_server_setup_transport(&exec_ctx, server, transport, nullptr,
- server_args);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_server_setup_transport(server, transport, nullptr, server_args);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
}
#else // !GPR_SUPPORT_CHANNELS_FROM_FD
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 ac3ea40f47..7b426c18fb 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
@@ -36,7 +36,7 @@
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_core::ExecCtx _local_exec_ctx;
grpc_error* err = GRPC_ERROR_NONE;
grpc_server_security_connector* sc = nullptr;
int port_num = 0;
@@ -52,8 +52,7 @@ int grpc_server_add_secure_http2_port(grpc_server* server, const char* addr,
"No credentials specified for secure server port (creds==NULL)");
goto done;
}
- status =
- grpc_server_credentials_create_security_connector(&exec_ctx, creds, &sc);
+ status = grpc_server_credentials_create_security_connector(creds, &sc);
if (status != GRPC_SECURITY_OK) {
char* msg;
gpr_asprintf(&msg,
@@ -72,12 +71,12 @@ int grpc_server_add_secure_http2_port(grpc_server* server, const char* addr,
grpc_channel_args_copy_and_add(grpc_server_get_channel_args(server),
args_to_add, GPR_ARRAY_SIZE(args_to_add));
// Add server port.
- err = grpc_chttp2_server_add_port(&exec_ctx, server, addr, args, &port_num);
+ err = grpc_chttp2_server_add_port(server, addr, args, &port_num);
done:
if (sc != nullptr) {
- GRPC_SECURITY_CONNECTOR_UNREF(&exec_ctx, &sc->base, "server");
+ GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "server");
}
- grpc_exec_ctx_finish(&exec_ctx);
+
if (err != GRPC_ERROR_NONE) {
const char* msg = grpc_error_string(err);
gpr_log(GPR_ERROR, "%s", msg);
diff --git a/src/core/ext/transport/chttp2/transport/bin_decoder.cc b/src/core/ext/transport/chttp2/transport/bin_decoder.cc
index 3ccae7afc3..984cd4ca78 100644
--- a/src/core/ext/transport/chttp2/transport/bin_decoder.cc
+++ b/src/core/ext/transport/chttp2/transport/bin_decoder.cc
@@ -130,8 +130,7 @@ bool grpc_base64_decode_partial(struct grpc_base64_decode_context* ctx) {
return true;
}
-grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx* exec_ctx,
- grpc_slice input) {
+grpc_slice grpc_chttp2_base64_decode(grpc_slice input) {
size_t input_length = GRPC_SLICE_LENGTH(input);
size_t output_length = input_length / 4 * 3;
struct grpc_base64_decode_context ctx;
@@ -167,7 +166,7 @@ grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx* exec_ctx,
char* s = grpc_slice_to_c_string(input);
gpr_log(GPR_ERROR, "Base64 decoding failed, input string:\n%s\n", s);
gpr_free(s);
- grpc_slice_unref_internal(exec_ctx, output);
+ grpc_slice_unref_internal(output);
return grpc_empty_slice();
}
GPR_ASSERT(ctx.output_cur == GRPC_SLICE_END_PTR(output));
@@ -175,8 +174,7 @@ grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx* exec_ctx,
return output;
}
-grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx* exec_ctx,
- grpc_slice input,
+grpc_slice grpc_chttp2_base64_decode_with_length(grpc_slice input,
size_t output_length) {
size_t input_length = GRPC_SLICE_LENGTH(input);
grpc_slice output = GRPC_SLICE_MALLOC(output_length);
@@ -189,7 +187,7 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx* exec_ctx,
"grpc_chttp2_base64_decode_with_length has a length of %d, which "
"has a tail of 1 byte.\n",
(int)input_length);
- grpc_slice_unref_internal(exec_ctx, output);
+ grpc_slice_unref_internal(output);
return grpc_empty_slice();
}
@@ -199,7 +197,7 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx* exec_ctx,
"than the max possible output length %d.\n",
(int)output_length,
(int)(input_length / 4 * 3 + tail_xtra[input_length % 4]));
- grpc_slice_unref_internal(exec_ctx, output);
+ grpc_slice_unref_internal(output);
return grpc_empty_slice();
}
@@ -213,7 +211,7 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx* exec_ctx,
char* s = grpc_slice_to_c_string(input);
gpr_log(GPR_ERROR, "Base64 decoding failed, input string:\n%s\n", s);
gpr_free(s);
- grpc_slice_unref_internal(exec_ctx, output);
+ grpc_slice_unref_internal(output);
return grpc_empty_slice();
}
GPR_ASSERT(ctx.output_cur == GRPC_SLICE_END_PTR(output));
diff --git a/src/core/ext/transport/chttp2/transport/bin_decoder.h b/src/core/ext/transport/chttp2/transport/bin_decoder.h
index a9c4c9a0f6..b49bcf3f67 100644
--- a/src/core/ext/transport/chttp2/transport/bin_decoder.h
+++ b/src/core/ext/transport/chttp2/transport/bin_decoder.h
@@ -44,13 +44,12 @@ bool grpc_base64_decode_partial(struct grpc_base64_decode_context* ctx);
/* base64 decode a slice with pad chars. Returns a new slice, does not take
ownership of the input. Returns an empty slice if decoding is failed. */
-grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx* exec_ctx, grpc_slice input);
+grpc_slice grpc_chttp2_base64_decode(grpc_slice input);
/* base64 decode a slice without pad chars, data length is needed. Returns a new
slice, does not take ownership of the input. Returns an empty slice if
decoding is failed. */
-grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx* exec_ctx,
- grpc_slice input,
+grpc_slice grpc_chttp2_base64_decode_with_length(grpc_slice input,
size_t output_length);
#ifdef __cplusplus
diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.h b/src/core/ext/transport/chttp2/transport/bin_encoder.h
index 0be3633354..2b71af2846 100644
--- a/src/core/ext/transport/chttp2/transport/bin_encoder.h
+++ b/src/core/ext/transport/chttp2/transport/bin_encoder.h
@@ -36,7 +36,7 @@ grpc_slice grpc_chttp2_huffman_compress(grpc_slice input);
/* equivalent to:
grpc_slice x = grpc_chttp2_base64_encode(input);
grpc_slice y = grpc_chttp2_huffman_compress(x);
- grpc_slice_unref_internal(exec_ctx, x);
+ grpc_slice_unref_internal( x);
return y; */
grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(grpc_slice input);
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
index 43788bfc5c..ec9e4c2223 100644
--- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
+++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
@@ -99,105 +99,77 @@ grpc_tracer_flag grpc_trace_chttp2_refcount =
#endif
/* forward declarations of various callbacks that we'll build closures around */
-static void write_action_begin_locked(grpc_exec_ctx* exec_ctx, void* t,
- grpc_error* error);
-static void write_action(grpc_exec_ctx* exec_ctx, void* t, grpc_error* error);
-static void write_action_end_locked(grpc_exec_ctx* exec_ctx, void* t,
- grpc_error* error);
+static void write_action_begin_locked(void* t, grpc_error* error);
+static void write_action(void* t, grpc_error* error);
+static void write_action_end_locked(void* t, grpc_error* error);
-static void read_action_locked(grpc_exec_ctx* exec_ctx, void* t,
- grpc_error* error);
+static void read_action_locked(void* t, grpc_error* error);
-static void complete_fetch_locked(grpc_exec_ctx* exec_ctx, void* gs,
- grpc_error* error);
+static void complete_fetch_locked(void* gs, grpc_error* error);
/** Set a transport level setting, and push it to our peer */
-static void queue_setting_update(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+static void queue_setting_update(grpc_chttp2_transport* t,
grpc_chttp2_setting_id id, uint32_t value);
-static void close_from_api(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
- grpc_chttp2_stream* s, grpc_error* error);
+static void close_from_api(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+ grpc_error* error);
/** Start new streams that have been created if we can */
-static void maybe_start_some_streams(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t);
+static void maybe_start_some_streams(grpc_chttp2_transport* t);
-static void connectivity_state_set(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+static void connectivity_state_set(grpc_chttp2_transport* t,
grpc_connectivity_state state,
grpc_error* error, const char* reason);
-static void incoming_byte_stream_destroy_locked(grpc_exec_ctx* exec_ctx,
- void* byte_stream,
+static void incoming_byte_stream_destroy_locked(void* byte_stream,
grpc_error* error_ignored);
static void incoming_byte_stream_publish_error(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_byte_stream* bs,
- grpc_error* error);
-static void incoming_byte_stream_unref(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_incoming_byte_stream* bs);
-
-static void benign_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* t,
- grpc_error* error);
-static void destructive_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* t,
- grpc_error* error);
-
-static void post_benign_reclaimer(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t);
-static void post_destructive_reclaimer(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t);
-
-static void close_transport_locked(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t, grpc_error* error);
-static void end_all_the_calls(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
- grpc_error* error);
-
-static void schedule_bdp_ping_locked(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t);
-static void start_bdp_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
- grpc_error* error);
-static void finish_bdp_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
- grpc_error* error);
-static void next_bdp_ping_timer_expired_locked(grpc_exec_ctx* exec_ctx,
- void* tp, grpc_error* error);
-
-static void cancel_pings(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
- grpc_error* error);
-static void send_ping_locked(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+ grpc_chttp2_incoming_byte_stream* bs, grpc_error* error);
+static void incoming_byte_stream_unref(grpc_chttp2_incoming_byte_stream* bs);
+
+static void benign_reclaimer_locked(void* t, grpc_error* error);
+static void destructive_reclaimer_locked(void* t, grpc_error* error);
+
+static void post_benign_reclaimer(grpc_chttp2_transport* t);
+static void post_destructive_reclaimer(grpc_chttp2_transport* t);
+
+static void close_transport_locked(grpc_chttp2_transport* t, grpc_error* error);
+static void end_all_the_calls(grpc_chttp2_transport* t, grpc_error* error);
+
+static void schedule_bdp_ping_locked(grpc_chttp2_transport* t);
+static void start_bdp_ping_locked(void* tp, grpc_error* error);
+static void finish_bdp_ping_locked(void* tp, grpc_error* error);
+static void next_bdp_ping_timer_expired_locked(void* tp, grpc_error* error);
+
+static void cancel_pings(grpc_chttp2_transport* t, grpc_error* error);
+static void send_ping_locked(grpc_chttp2_transport* t,
grpc_closure* on_initiate,
grpc_closure* on_complete);
-static void retry_initiate_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
- grpc_error* error);
+static void retry_initiate_ping_locked(void* tp, grpc_error* error);
/** keepalive-relevant functions */
-static void init_keepalive_ping_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error);
-static void start_keepalive_ping_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error);
-static void finish_keepalive_ping_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error);
-static void keepalive_watchdog_fired_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error);
-
-static void reset_byte_stream(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error);
+static void init_keepalive_ping_locked(void* arg, grpc_error* error);
+static void start_keepalive_ping_locked(void* arg, grpc_error* error);
+static void finish_keepalive_ping_locked(void* arg, grpc_error* error);
+static void keepalive_watchdog_fired_locked(void* arg, grpc_error* error);
+
+static void reset_byte_stream(void* arg, grpc_error* error);
/*******************************************************************************
* CONSTRUCTION/DESTRUCTION/REFCOUNTING
*/
-static void destruct_transport(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t) {
+static void destruct_transport(grpc_chttp2_transport* t) {
size_t i;
- grpc_endpoint_destroy(exec_ctx, t->ep);
+ grpc_endpoint_destroy(t->ep);
- grpc_slice_buffer_destroy_internal(exec_ctx, &t->qbuf);
+ grpc_slice_buffer_destroy_internal(&t->qbuf);
- grpc_slice_buffer_destroy_internal(exec_ctx, &t->outbuf);
- grpc_chttp2_hpack_compressor_destroy(exec_ctx, &t->hpack_compressor);
+ grpc_slice_buffer_destroy_internal(&t->outbuf);
+ grpc_chttp2_hpack_compressor_destroy(&t->hpack_compressor);
- grpc_slice_buffer_destroy_internal(exec_ctx, &t->read_buffer);
- grpc_chttp2_hpack_parser_destroy(exec_ctx, &t->hpack_parser);
+ grpc_slice_buffer_destroy_internal(&t->read_buffer);
+ grpc_chttp2_hpack_parser_destroy(&t->hpack_parser);
grpc_chttp2_goaway_parser_destroy(&t->goaway_parser);
for (i = 0; i < STREAM_LIST_COUNT; i++) {
@@ -210,12 +182,11 @@ static void destruct_transport(grpc_exec_ctx* exec_ctx,
GPR_ASSERT(grpc_chttp2_stream_map_size(&t->stream_map) == 0);
grpc_chttp2_stream_map_destroy(&t->stream_map);
- grpc_connectivity_state_destroy(exec_ctx, &t->channel_callback.state_tracker);
+ grpc_connectivity_state_destroy(&t->channel_callback.state_tracker);
- GRPC_COMBINER_UNREF(exec_ctx, t->combiner, "chttp2_transport");
+ GRPC_COMBINER_UNREF(t->combiner, "chttp2_transport");
- cancel_pings(exec_ctx, t,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport destroyed"));
+ cancel_pings(t, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport destroyed"));
while (t->write_cb_pool) {
grpc_chttp2_write_cb* next = t->write_cb_pool->next;
@@ -232,8 +203,7 @@ static void destruct_transport(grpc_exec_ctx* exec_ctx,
}
#ifndef NDEBUG
-void grpc_chttp2_unref_transport(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t, const char* reason,
+void grpc_chttp2_unref_transport(grpc_chttp2_transport* t, const char* reason,
const char* file, int line) {
if (GRPC_TRACER_ON(grpc_trace_chttp2_refcount)) {
gpr_atm val = gpr_atm_no_barrier_load(&t->refs.count);
@@ -241,7 +211,7 @@ void grpc_chttp2_unref_transport(grpc_exec_ctx* exec_ctx,
t, val, val - 1, reason, file, line);
}
if (!gpr_unref(&t->refs)) return;
- destruct_transport(exec_ctx, t);
+ destruct_transport(t);
}
void grpc_chttp2_ref_transport(grpc_chttp2_transport* t, const char* reason,
@@ -254,10 +224,9 @@ void grpc_chttp2_ref_transport(grpc_chttp2_transport* t, const char* reason,
gpr_ref(&t->refs);
}
#else
-void grpc_chttp2_unref_transport(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t) {
+void grpc_chttp2_unref_transport(grpc_chttp2_transport* t) {
if (!gpr_unref(&t->refs)) return;
- destruct_transport(exec_ctx, t);
+ destruct_transport(t);
}
void grpc_chttp2_ref_transport(grpc_chttp2_transport* t) { gpr_ref(&t->refs); }
@@ -265,7 +234,7 @@ void grpc_chttp2_ref_transport(grpc_chttp2_transport* t) { gpr_ref(&t->refs); }
static const grpc_transport_vtable* get_vtable(void);
-static void init_transport(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+static void init_transport(grpc_chttp2_transport* t,
const grpc_channel_args* channel_args,
grpc_endpoint* ep, bool is_client) {
size_t i;
@@ -324,7 +293,7 @@ static void init_transport(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
t->goaway_error = GRPC_ERROR_NONE;
grpc_chttp2_goaway_parser_init(&t->goaway_parser);
- grpc_chttp2_hpack_parser_init(exec_ctx, &t->hpack_parser);
+ grpc_chttp2_hpack_parser_init(&t->hpack_parser);
grpc_slice_buffer_init(&t->read_buffer);
@@ -355,14 +324,13 @@ static void init_transport(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
/* configure http2 the way we like it */
if (is_client) {
- queue_setting_update(exec_ctx, t, GRPC_CHTTP2_SETTINGS_ENABLE_PUSH, 0);
- queue_setting_update(exec_ctx, t,
- GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, 0);
+ queue_setting_update(t, GRPC_CHTTP2_SETTINGS_ENABLE_PUSH, 0);
+ queue_setting_update(t, GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, 0);
}
- queue_setting_update(exec_ctx, t, GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE,
+ queue_setting_update(t, GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE,
DEFAULT_MAX_HEADER_LIST_SIZE);
- queue_setting_update(exec_ctx, t,
- GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA, 1);
+ queue_setting_update(t, GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA,
+ 1);
t->ping_policy.max_pings_without_data = g_default_max_pings_without_data;
t->ping_policy.min_sent_ping_interval_without_data =
@@ -537,7 +505,7 @@ static void init_transport(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
int value = grpc_channel_arg_get_integer(
&channel_args->args[i], settings_map[j].integer_options);
if (value >= 0) {
- queue_setting_update(exec_ctx, t, settings_map[j].setting_id,
+ queue_setting_update(t, settings_map[j].setting_id,
(uint32_t)value);
}
}
@@ -548,7 +516,7 @@ static void init_transport(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
}
}
- t->flow_control.Init(exec_ctx, t, enable_bdp);
+ t->flow_control.Init(t, enable_bdp);
/* No pings allowed before receiving a header or data frame. */
t->ping_state.pings_before_data_required = 0;
@@ -561,8 +529,8 @@ static void init_transport(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
if (t->keepalive_time != GRPC_MILLIS_INF_FUTURE) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING;
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
- grpc_timer_init(exec_ctx, &t->keepalive_ping_timer,
- grpc_exec_ctx_now(exec_ctx) + t->keepalive_time,
+ grpc_timer_init(&t->keepalive_ping_timer,
+ grpc_core::ExecCtx::Get()->Now() + t->keepalive_time,
&t->init_keepalive_ping_locked);
} else {
/* Use GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED to indicate there are no
@@ -572,42 +540,37 @@ static void init_transport(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
if (enable_bdp) {
GRPC_CHTTP2_REF_TRANSPORT(t, "bdp_ping");
- schedule_bdp_ping_locked(exec_ctx, t);
+ schedule_bdp_ping_locked(t);
- grpc_chttp2_act_on_flowctl_action(
- exec_ctx, t->flow_control->PeriodicUpdate(exec_ctx), t, nullptr);
+ grpc_chttp2_act_on_flowctl_action(t->flow_control->PeriodicUpdate(), t,
+ nullptr);
}
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_INITIAL_WRITE);
- post_benign_reclaimer(exec_ctx, t);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_INITIAL_WRITE);
+ post_benign_reclaimer(t);
}
-static void destroy_transport_locked(grpc_exec_ctx* exec_ctx, void* tp,
- grpc_error* error) {
+static void destroy_transport_locked(void* tp, grpc_error* error) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
t->destroying = 1;
close_transport_locked(
- exec_ctx, t,
- grpc_error_set_int(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport destroyed"),
- GRPC_ERROR_INT_OCCURRED_DURING_WRITE, t->write_state));
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "destroy");
+ t, grpc_error_set_int(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport destroyed"),
+ GRPC_ERROR_INT_OCCURRED_DURING_WRITE, t->write_state));
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "destroy");
}
-static void destroy_transport(grpc_exec_ctx* exec_ctx, grpc_transport* gt) {
+static void destroy_transport(grpc_transport* gt) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
- GRPC_CLOSURE_SCHED(exec_ctx,
- GRPC_CLOSURE_CREATE(destroy_transport_locked, t,
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(destroy_transport_locked, t,
grpc_combiner_scheduler(t->combiner)),
GRPC_ERROR_NONE);
}
-static void close_transport_locked(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+static void close_transport_locked(grpc_chttp2_transport* t,
grpc_error* error) {
- end_all_the_calls(exec_ctx, t, GRPC_ERROR_REF(error));
- cancel_pings(exec_ctx, t, GRPC_ERROR_REF(error));
+ end_all_the_calls(t, GRPC_ERROR_REF(error));
+ cancel_pings(t, GRPC_ERROR_REF(error));
if (t->closed_with_error == GRPC_ERROR_NONE) {
if (!grpc_error_has_clear_grpc_status(error)) {
error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS,
@@ -625,21 +588,21 @@ static void close_transport_locked(grpc_exec_ctx* exec_ctx,
}
GPR_ASSERT(error != GRPC_ERROR_NONE);
t->closed_with_error = GRPC_ERROR_REF(error);
- connectivity_state_set(exec_ctx, t, GRPC_CHANNEL_SHUTDOWN,
- GRPC_ERROR_REF(error), "close_transport");
+ connectivity_state_set(t, GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_REF(error),
+ "close_transport");
if (t->ping_state.is_delayed_ping_timer_set) {
- grpc_timer_cancel(exec_ctx, &t->ping_state.delayed_ping_timer);
+ grpc_timer_cancel(&t->ping_state.delayed_ping_timer);
}
if (t->have_next_bdp_ping_timer) {
- grpc_timer_cancel(exec_ctx, &t->next_bdp_ping_timer);
+ grpc_timer_cancel(&t->next_bdp_ping_timer);
}
switch (t->keepalive_state) {
case GRPC_CHTTP2_KEEPALIVE_STATE_WAITING:
- grpc_timer_cancel(exec_ctx, &t->keepalive_ping_timer);
+ grpc_timer_cancel(&t->keepalive_ping_timer);
break;
case GRPC_CHTTP2_KEEPALIVE_STATE_PINGING:
- grpc_timer_cancel(exec_ctx, &t->keepalive_ping_timer);
- grpc_timer_cancel(exec_ctx, &t->keepalive_watchdog_timer);
+ grpc_timer_cancel(&t->keepalive_ping_timer);
+ grpc_timer_cancel(&t->keepalive_watchdog_timer);
break;
case GRPC_CHTTP2_KEEPALIVE_STATE_DYING:
case GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED:
@@ -650,10 +613,10 @@ static void close_transport_locked(grpc_exec_ctx* exec_ctx,
/* flush writable stream list to avoid dangling references */
grpc_chttp2_stream* s;
while (grpc_chttp2_list_pop_writable_stream(t, &s)) {
- GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "chttp2_writing:close");
+ GRPC_CHTTP2_STREAM_UNREF(s, "chttp2_writing:close");
}
GPR_ASSERT(t->write_state == GRPC_CHTTP2_WRITE_STATE_IDLE);
- grpc_endpoint_shutdown(exec_ctx, t->ep, GRPC_ERROR_REF(error));
+ grpc_endpoint_shutdown(t->ep, GRPC_ERROR_REF(error));
}
GRPC_ERROR_UNREF(error);
}
@@ -662,22 +625,21 @@ static void close_transport_locked(grpc_exec_ctx* exec_ctx,
void grpc_chttp2_stream_ref(grpc_chttp2_stream* s, const char* reason) {
grpc_stream_ref(s->refcount, reason);
}
-void grpc_chttp2_stream_unref(grpc_exec_ctx* exec_ctx, grpc_chttp2_stream* s,
- const char* reason) {
- grpc_stream_unref(exec_ctx, s->refcount, reason);
+void grpc_chttp2_stream_unref(grpc_chttp2_stream* s, const char* reason) {
+ grpc_stream_unref(s->refcount, reason);
}
#else
void grpc_chttp2_stream_ref(grpc_chttp2_stream* s) {
grpc_stream_ref(s->refcount);
}
-void grpc_chttp2_stream_unref(grpc_exec_ctx* exec_ctx, grpc_chttp2_stream* s) {
- grpc_stream_unref(exec_ctx, s->refcount);
+void grpc_chttp2_stream_unref(grpc_chttp2_stream* s) {
+ grpc_stream_unref(s->refcount);
}
#endif
-static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
- grpc_stream* gs, grpc_stream_refcount* refcount,
- const void* server_data, gpr_arena* arena) {
+static int init_stream(grpc_transport* gt, grpc_stream* gs,
+ grpc_stream_refcount* refcount, const void* server_data,
+ gpr_arena* arena) {
GPR_TIMER_BEGIN("init_stream", 0);
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
grpc_chttp2_stream* s = (grpc_chttp2_stream*)gs;
@@ -711,7 +673,7 @@ static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
s->id = (uint32_t)(uintptr_t)server_data;
*t->accepting_stream = s;
grpc_chttp2_stream_map_add(&t->stream_map, s->id, s);
- post_destructive_reclaimer(exec_ctx, t);
+ post_destructive_reclaimer(t);
}
s->flow_control.Init(t->flow_control.get(), s);
@@ -720,8 +682,7 @@ static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
return 0;
}
-static void destroy_stream_locked(grpc_exec_ctx* exec_ctx, void* sp,
- grpc_error* error) {
+static void destroy_stream_locked(void* sp, grpc_error* error) {
grpc_chttp2_stream* s = (grpc_chttp2_stream*)sp;
grpc_chttp2_transport* t = s->t;
@@ -732,11 +693,10 @@ static void destroy_stream_locked(grpc_exec_ctx* exec_ctx, void* sp,
GPR_ASSERT(grpc_chttp2_stream_map_find(&t->stream_map, s->id) == nullptr);
}
- grpc_slice_buffer_destroy_internal(exec_ctx,
- &s->unprocessed_incoming_frames_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &s->frame_storage);
- grpc_slice_buffer_destroy_internal(exec_ctx, &s->compressed_data_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &s->decompressed_data_buffer);
+ grpc_slice_buffer_destroy_internal(&s->unprocessed_incoming_frames_buffer);
+ grpc_slice_buffer_destroy_internal(&s->frame_storage);
+ grpc_slice_buffer_destroy_internal(&s->compressed_data_buffer);
+ grpc_slice_buffer_destroy_internal(&s->decompressed_data_buffer);
grpc_chttp2_list_remove_stalled_by_transport(t, s);
grpc_chttp2_list_remove_stalled_by_stream(t, s);
@@ -755,27 +715,24 @@ static void destroy_stream_locked(grpc_exec_ctx* exec_ctx, void* sp,
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]);
- grpc_chttp2_incoming_metadata_buffer_destroy(exec_ctx,
- &s->metadata_buffer[1]);
- grpc_slice_buffer_destroy_internal(exec_ctx, &s->flow_controlled_buffer);
+ grpc_chttp2_data_parser_destroy(&s->data_parser);
+ grpc_chttp2_incoming_metadata_buffer_destroy(&s->metadata_buffer[0]);
+ grpc_chttp2_incoming_metadata_buffer_destroy(&s->metadata_buffer[1]);
+ grpc_slice_buffer_destroy_internal(&s->flow_controlled_buffer);
GRPC_ERROR_UNREF(s->read_closed_error);
GRPC_ERROR_UNREF(s->write_closed_error);
GRPC_ERROR_UNREF(s->byte_stream_error);
s->flow_control.Destroy();
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "stream");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "stream");
GPR_TIMER_END("destroy_stream", 0);
- GRPC_CLOSURE_SCHED(exec_ctx, s->destroy_stream_arg, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(s->destroy_stream_arg, GRPC_ERROR_NONE);
}
-static void destroy_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
- grpc_stream* gs,
+static void destroy_stream(grpc_transport* gt, grpc_stream* gs,
grpc_closure* then_schedule_closure) {
GPR_TIMER_BEGIN("destroy_stream", 0);
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
@@ -792,7 +749,6 @@ static void destroy_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
s->destroy_stream_arg = then_schedule_closure;
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_INIT(&s->destroy_stream, destroy_stream_locked, s,
grpc_combiner_scheduler(t->combiner)),
GRPC_ERROR_NONE);
@@ -804,8 +760,7 @@ grpc_chttp2_stream* grpc_chttp2_parsing_lookup_stream(grpc_chttp2_transport* t,
return (grpc_chttp2_stream*)grpc_chttp2_stream_map_find(&t->stream_map, id);
}
-grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_chttp2_transport* t,
uint32_t id) {
if (t->channel_callback.accept_stream == nullptr) {
return nullptr;
@@ -813,8 +768,7 @@ grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_exec_ctx* exec_ctx,
grpc_chttp2_stream* accepting;
GPR_ASSERT(t->accepting_stream == nullptr);
t->accepting_stream = &accepting;
- t->channel_callback.accept_stream(exec_ctx,
- t->channel_callback.accept_stream_user_data,
+ t->channel_callback.accept_stream(t->channel_callback.accept_stream_user_data,
&t->base, (void*)(uintptr_t)id);
t->accepting_stream = nullptr;
return accepting;
@@ -836,7 +790,7 @@ static const char* write_state_name(grpc_chttp2_write_state st) {
GPR_UNREACHABLE_CODE(return "UNKNOWN");
}
-static void set_write_state(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+static void set_write_state(grpc_chttp2_transport* t,
grpc_chttp2_write_state st, const char* reason) {
GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_DEBUG, "W:%p %s state %s -> %s [%s]", t,
t->is_client ? "CLIENT" : "SERVER",
@@ -844,108 +798,100 @@ static void set_write_state(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
write_state_name(st), reason));
t->write_state = st;
if (st == GRPC_CHTTP2_WRITE_STATE_IDLE) {
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &t->run_after_write);
+ GRPC_CLOSURE_LIST_SCHED(&t->run_after_write);
if (t->close_transport_on_writes_finished != nullptr) {
grpc_error* err = t->close_transport_on_writes_finished;
t->close_transport_on_writes_finished = nullptr;
- close_transport_locked(exec_ctx, t, err);
+ close_transport_locked(t, err);
}
}
}
static void inc_initiate_write_reason(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_initiate_write_reason reason) {
+ grpc_chttp2_initiate_write_reason reason) {
switch (reason) {
case GRPC_CHTTP2_INITIATE_WRITE_INITIAL_WRITE:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_INITIAL_WRITE(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_INITIAL_WRITE();
break;
case GRPC_CHTTP2_INITIATE_WRITE_START_NEW_STREAM:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_START_NEW_STREAM(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_START_NEW_STREAM();
break;
case GRPC_CHTTP2_INITIATE_WRITE_SEND_MESSAGE:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_MESSAGE(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_MESSAGE();
break;
case GRPC_CHTTP2_INITIATE_WRITE_SEND_INITIAL_METADATA:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_INITIAL_METADATA(
- exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_INITIAL_METADATA();
break;
case GRPC_CHTTP2_INITIATE_WRITE_SEND_TRAILING_METADATA:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_TRAILING_METADATA(
- exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_TRAILING_METADATA();
break;
case GRPC_CHTTP2_INITIATE_WRITE_RETRY_SEND_PING:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_RETRY_SEND_PING(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_RETRY_SEND_PING();
break;
case GRPC_CHTTP2_INITIATE_WRITE_CONTINUE_PINGS:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_CONTINUE_PINGS(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_CONTINUE_PINGS();
break;
case GRPC_CHTTP2_INITIATE_WRITE_GOAWAY_SENT:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_GOAWAY_SENT(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_GOAWAY_SENT();
break;
case GRPC_CHTTP2_INITIATE_WRITE_RST_STREAM:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_RST_STREAM(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_RST_STREAM();
break;
case GRPC_CHTTP2_INITIATE_WRITE_CLOSE_FROM_API:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_CLOSE_FROM_API(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_CLOSE_FROM_API();
break;
case GRPC_CHTTP2_INITIATE_WRITE_STREAM_FLOW_CONTROL:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_STREAM_FLOW_CONTROL(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_STREAM_FLOW_CONTROL();
break;
case GRPC_CHTTP2_INITIATE_WRITE_TRANSPORT_FLOW_CONTROL:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL(
- exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL();
break;
case GRPC_CHTTP2_INITIATE_WRITE_SEND_SETTINGS:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_SETTINGS(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_SETTINGS();
break;
case GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_SETTING:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_SETTING(
- exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_SETTING();
break;
case GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_UPDATE:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_UPDATE(
- exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_UPDATE();
break;
case GRPC_CHTTP2_INITIATE_WRITE_APPLICATION_PING:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_APPLICATION_PING(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_APPLICATION_PING();
break;
case GRPC_CHTTP2_INITIATE_WRITE_KEEPALIVE_PING:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_KEEPALIVE_PING(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_KEEPALIVE_PING();
break;
case GRPC_CHTTP2_INITIATE_WRITE_TRANSPORT_FLOW_CONTROL_UNSTALLED:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL_UNSTALLED(
- exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL_UNSTALLED();
break;
case GRPC_CHTTP2_INITIATE_WRITE_PING_RESPONSE:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_PING_RESPONSE(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_PING_RESPONSE();
break;
case GRPC_CHTTP2_INITIATE_WRITE_FORCE_RST_STREAM:
- GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FORCE_RST_STREAM(exec_ctx);
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FORCE_RST_STREAM();
break;
}
}
-void grpc_chttp2_initiate_write(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+void grpc_chttp2_initiate_write(grpc_chttp2_transport* t,
grpc_chttp2_initiate_write_reason reason) {
GPR_TIMER_BEGIN("grpc_chttp2_initiate_write", 0);
switch (t->write_state) {
case GRPC_CHTTP2_WRITE_STATE_IDLE:
- inc_initiate_write_reason(exec_ctx, reason);
- set_write_state(exec_ctx, t, GRPC_CHTTP2_WRITE_STATE_WRITING,
+ inc_initiate_write_reason(reason);
+ set_write_state(t, GRPC_CHTTP2_WRITE_STATE_WRITING,
grpc_chttp2_initiate_write_reason_string(reason));
t->is_first_write_in_batch = true;
GRPC_CHTTP2_REF_TRANSPORT(t, "writing");
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_INIT(&t->write_action_begin_locked,
write_action_begin_locked, t,
grpc_combiner_finally_scheduler(t->combiner)),
GRPC_ERROR_NONE);
break;
case GRPC_CHTTP2_WRITE_STATE_WRITING:
- set_write_state(exec_ctx, t, GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE,
+ set_write_state(t, GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE,
grpc_chttp2_initiate_write_reason_string(reason));
break;
case GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE:
@@ -954,8 +900,7 @@ void grpc_chttp2_initiate_write(grpc_exec_ctx* exec_ctx,
GPR_TIMER_END("grpc_chttp2_initiate_write", 0);
}
-void grpc_chttp2_mark_stream_writable(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+void grpc_chttp2_mark_stream_writable(grpc_chttp2_transport* t,
grpc_chttp2_stream* s) {
if (t->closed_with_error == GRPC_ERROR_NONE &&
grpc_chttp2_list_add_writable_stream(t, s)) {
@@ -1005,8 +950,7 @@ static const char* begin_writing_desc(bool partial, bool inlined) {
GPR_UNREACHABLE_CODE(return "bad state tuple");
}
-static void write_action_begin_locked(grpc_exec_ctx* exec_ctx, void* gt,
- grpc_error* error_ignored) {
+static void write_action_begin_locked(void* gt, grpc_error* error_ignored) {
GPR_TIMER_BEGIN("write_action_begin_locked", 0);
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
GPR_ASSERT(t->write_state != GRPC_CHTTP2_WRITE_STATE_IDLE);
@@ -1014,62 +958,59 @@ static void write_action_begin_locked(grpc_exec_ctx* exec_ctx, void* gt,
if (t->closed_with_error != GRPC_ERROR_NONE) {
r.writing = false;
} else {
- r = grpc_chttp2_begin_write(exec_ctx, t);
+ r = grpc_chttp2_begin_write(t);
}
if (r.writing) {
if (r.partial) {
- GRPC_STATS_INC_HTTP2_PARTIAL_WRITES(exec_ctx);
+ GRPC_STATS_INC_HTTP2_PARTIAL_WRITES();
}
if (!t->is_first_write_in_batch) {
- GRPC_STATS_INC_HTTP2_WRITES_CONTINUED(exec_ctx);
+ GRPC_STATS_INC_HTTP2_WRITES_CONTINUED();
}
grpc_closure_scheduler* scheduler =
write_scheduler(t, r.early_results_scheduled, r.partial);
if (scheduler != grpc_schedule_on_exec_ctx) {
- GRPC_STATS_INC_HTTP2_WRITES_OFFLOADED(exec_ctx);
+ GRPC_STATS_INC_HTTP2_WRITES_OFFLOADED();
}
set_write_state(
- exec_ctx, t,
+ t,
r.partial ? GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE
: GRPC_CHTTP2_WRITE_STATE_WRITING,
begin_writing_desc(r.partial, scheduler == grpc_schedule_on_exec_ctx));
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_INIT(&t->write_action, write_action, t, scheduler),
GRPC_ERROR_NONE);
} else {
- GRPC_STATS_INC_HTTP2_SPURIOUS_WRITES_BEGUN(exec_ctx);
- set_write_state(exec_ctx, t, GRPC_CHTTP2_WRITE_STATE_IDLE,
- "begin writing nothing");
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "writing");
+ GRPC_STATS_INC_HTTP2_SPURIOUS_WRITES_BEGUN();
+ set_write_state(t, GRPC_CHTTP2_WRITE_STATE_IDLE, "begin writing nothing");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "writing");
}
GPR_TIMER_END("write_action_begin_locked", 0);
}
-static void write_action(grpc_exec_ctx* exec_ctx, void* gt, grpc_error* error) {
+static void write_action(void* gt, grpc_error* error) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
GPR_TIMER_BEGIN("write_action", 0);
grpc_endpoint_write(
- exec_ctx, t->ep, &t->outbuf,
+ t->ep, &t->outbuf,
GRPC_CLOSURE_INIT(&t->write_action_end_locked, write_action_end_locked, t,
grpc_combiner_scheduler(t->combiner)));
GPR_TIMER_END("write_action", 0);
}
-static void write_action_end_locked(grpc_exec_ctx* exec_ctx, void* tp,
- grpc_error* error) {
+static void write_action_end_locked(void* tp, grpc_error* error) {
GPR_TIMER_BEGIN("terminate_writing_with_lock", 0);
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
if (error != GRPC_ERROR_NONE) {
- close_transport_locked(exec_ctx, t, GRPC_ERROR_REF(error));
+ close_transport_locked(t, GRPC_ERROR_REF(error));
}
if (t->sent_goaway_state == GRPC_CHTTP2_GOAWAY_SEND_SCHEDULED) {
t->sent_goaway_state = GRPC_CHTTP2_GOAWAY_SENT;
if (grpc_chttp2_stream_map_size(&t->stream_map) == 0) {
close_transport_locked(
- exec_ctx, t, GRPC_ERROR_CREATE_FROM_STATIC_STRING("goaway sent"));
+ t, GRPC_ERROR_CREATE_FROM_STATIC_STRING("goaway sent"));
}
}
@@ -1078,17 +1019,14 @@ static void write_action_end_locked(grpc_exec_ctx* exec_ctx, void* tp,
GPR_UNREACHABLE_CODE(break);
case GRPC_CHTTP2_WRITE_STATE_WRITING:
GPR_TIMER_MARK("state=writing", 0);
- set_write_state(exec_ctx, t, GRPC_CHTTP2_WRITE_STATE_IDLE,
- "finish writing");
+ set_write_state(t, GRPC_CHTTP2_WRITE_STATE_IDLE, "finish writing");
break;
case GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE:
GPR_TIMER_MARK("state=writing_stale_no_poller", 0);
- set_write_state(exec_ctx, t, GRPC_CHTTP2_WRITE_STATE_WRITING,
- "continue writing");
+ set_write_state(t, GRPC_CHTTP2_WRITE_STATE_WRITING, "continue writing");
t->is_first_write_in_batch = false;
GRPC_CHTTP2_REF_TRANSPORT(t, "writing");
GRPC_CLOSURE_RUN(
- exec_ctx,
GRPC_CLOSURE_INIT(&t->write_action_begin_locked,
write_action_begin_locked, t,
grpc_combiner_finally_scheduler(t->combiner)),
@@ -1096,16 +1034,15 @@ static void write_action_end_locked(grpc_exec_ctx* exec_ctx, void* tp,
break;
}
- grpc_chttp2_end_write(exec_ctx, t, GRPC_ERROR_REF(error));
+ grpc_chttp2_end_write(t, GRPC_ERROR_REF(error));
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "writing");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "writing");
GPR_TIMER_END("terminate_writing_with_lock", 0);
}
// Dirties an HTTP2 setting to be sent out next time a writing path occurs.
// If the change needs to occur immediately, manually initiate a write.
-static void queue_setting_update(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+static void queue_setting_update(grpc_chttp2_transport* t,
grpc_chttp2_setting_id id, uint32_t value) {
const grpc_chttp2_setting_parameters* sp =
&grpc_chttp2_settings_parameters[id];
@@ -1120,8 +1057,7 @@ static void queue_setting_update(grpc_exec_ctx* exec_ctx,
}
}
-void grpc_chttp2_add_incoming_goaway(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t,
uint32_t goaway_error,
grpc_slice goaway_text) {
// GRPC_CHTTP2_IF_TRACING(
@@ -1156,12 +1092,11 @@ void grpc_chttp2_add_incoming_goaway(grpc_exec_ctx* exec_ctx,
/* lie: use transient failure from the transport to indicate goaway has been
* received */
- connectivity_state_set(exec_ctx, t, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ connectivity_state_set(t, GRPC_CHANNEL_TRANSIENT_FAILURE,
GRPC_ERROR_REF(t->goaway_error), "got_goaway");
}
-static void maybe_start_some_streams(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t) {
+static void maybe_start_some_streams(grpc_chttp2_transport* t) {
grpc_chttp2_stream* s;
/* start streams where we have free grpc_chttp2_stream ids and free
* concurrency */
@@ -1181,22 +1116,21 @@ static void maybe_start_some_streams(grpc_exec_ctx* exec_ctx,
if (t->next_stream_id >= MAX_CLIENT_STREAM_ID) {
connectivity_state_set(
- exec_ctx, t, GRPC_CHANNEL_TRANSIENT_FAILURE,
+ t, GRPC_CHANNEL_TRANSIENT_FAILURE,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Stream IDs exhausted"),
"no_more_stream_ids");
}
grpc_chttp2_stream_map_add(&t->stream_map, s->id, s);
- post_destructive_reclaimer(exec_ctx, t);
- grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_START_NEW_STREAM);
+ post_destructive_reclaimer(t);
+ grpc_chttp2_mark_stream_writable(t, s);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_START_NEW_STREAM);
}
/* cancel out streams that will never be started */
while (t->next_stream_id >= MAX_CLIENT_STREAM_ID &&
grpc_chttp2_list_pop_waiting_for_concurrency(t, &s)) {
grpc_chttp2_cancel_stream(
- exec_ctx, t, s,
+ t, s,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Stream IDs exhausted"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
@@ -1218,15 +1152,13 @@ static grpc_closure* add_closure_barrier(grpc_closure* closure) {
return closure;
}
-static void null_then_run_closure(grpc_exec_ctx* exec_ctx,
- grpc_closure** closure, grpc_error* error) {
+static void null_then_run_closure(grpc_closure** closure, grpc_error* error) {
grpc_closure* c = *closure;
*closure = nullptr;
- GRPC_CLOSURE_RUN(exec_ctx, c, error);
+ GRPC_CLOSURE_RUN(c, error);
}
-void grpc_chttp2_complete_closure_step(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+void grpc_chttp2_complete_closure_step(grpc_chttp2_transport* t,
grpc_chttp2_stream* s,
grpc_closure** pclosure,
grpc_error* error, const char* desc) {
@@ -1266,7 +1198,7 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx* exec_ctx,
}
if ((t->write_state == GRPC_CHTTP2_WRITE_STATE_IDLE) ||
!(closure->next_data.scratch & CLOSURE_BARRIER_MAY_COVER_WRITE)) {
- GRPC_CLOSURE_RUN(exec_ctx, closure, closure->error_data.error);
+ GRPC_CLOSURE_RUN(closure, closure->error_data.error);
} else {
grpc_closure_list_append(&t->run_after_write, closure,
closure->error_data.error);
@@ -1282,28 +1214,24 @@ static bool contains_non_ok_status(grpc_metadata_batch* batch) {
return false;
}
-static void maybe_become_writable_due_to_send_msg(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+static void maybe_become_writable_due_to_send_msg(grpc_chttp2_transport* t,
grpc_chttp2_stream* s) {
if (s->id != 0 && (!s->write_buffering ||
s->flow_controlled_buffer.length > t->write_buffer_size)) {
- grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_SEND_MESSAGE);
+ grpc_chttp2_mark_stream_writable(t, s);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_SEND_MESSAGE);
}
}
-static void add_fetched_slice_locked(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+static void add_fetched_slice_locked(grpc_chttp2_transport* t,
grpc_chttp2_stream* s) {
s->fetched_send_message_length +=
(uint32_t)GRPC_SLICE_LENGTH(s->fetching_slice);
grpc_slice_buffer_add(&s->flow_controlled_buffer, s->fetching_slice);
- maybe_become_writable_due_to_send_msg(exec_ctx, t, s);
+ maybe_become_writable_due_to_send_msg(t, s);
}
-static void continue_fetching_send_locked(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+static void continue_fetching_send_locked(grpc_chttp2_transport* t,
grpc_chttp2_stream* s) {
for (;;) {
if (s->fetching_send_message == nullptr) {
@@ -1312,11 +1240,11 @@ static void continue_fetching_send_locked(grpc_exec_ctx* exec_ctx,
return; /* early out */
}
if (s->fetched_send_message_length == s->fetching_send_message->length) {
- grpc_byte_stream_destroy(exec_ctx, s->fetching_send_message);
+ grpc_byte_stream_destroy(s->fetching_send_message);
int64_t notify_offset = s->next_message_end_offset;
if (notify_offset <= s->flow_controlled_bytes_written) {
grpc_chttp2_complete_closure_step(
- exec_ctx, t, s, &s->fetching_send_message_finished, GRPC_ERROR_NONE,
+ t, s, &s->fetching_send_message_finished, GRPC_ERROR_NONE,
"fetching_send_message_finished");
} else {
grpc_chttp2_write_cb* cb = t->write_cb_pool;
@@ -1337,39 +1265,37 @@ static void continue_fetching_send_locked(grpc_exec_ctx* exec_ctx,
}
s->fetching_send_message = nullptr;
return; /* early out */
- } else if (grpc_byte_stream_next(exec_ctx, s->fetching_send_message,
- UINT32_MAX, &s->complete_fetch_locked)) {
- grpc_error* error = grpc_byte_stream_pull(
- exec_ctx, s->fetching_send_message, &s->fetching_slice);
+ } else if (grpc_byte_stream_next(s->fetching_send_message, UINT32_MAX,
+ &s->complete_fetch_locked)) {
+ grpc_error* error =
+ grpc_byte_stream_pull(s->fetching_send_message, &s->fetching_slice);
if (error != GRPC_ERROR_NONE) {
- grpc_byte_stream_destroy(exec_ctx, s->fetching_send_message);
- grpc_chttp2_cancel_stream(exec_ctx, t, s, error);
+ grpc_byte_stream_destroy(s->fetching_send_message);
+ grpc_chttp2_cancel_stream(t, s, error);
} else {
- add_fetched_slice_locked(exec_ctx, t, s);
+ add_fetched_slice_locked(t, s);
}
}
}
}
-static void complete_fetch_locked(grpc_exec_ctx* exec_ctx, void* gs,
- grpc_error* error) {
+static void complete_fetch_locked(void* gs, grpc_error* error) {
grpc_chttp2_stream* s = (grpc_chttp2_stream*)gs;
grpc_chttp2_transport* t = s->t;
if (error == GRPC_ERROR_NONE) {
- error = grpc_byte_stream_pull(exec_ctx, s->fetching_send_message,
- &s->fetching_slice);
+ error = grpc_byte_stream_pull(s->fetching_send_message, &s->fetching_slice);
if (error == GRPC_ERROR_NONE) {
- add_fetched_slice_locked(exec_ctx, t, s);
- continue_fetching_send_locked(exec_ctx, t, s);
+ add_fetched_slice_locked(t, s);
+ continue_fetching_send_locked(t, s);
}
}
if (error != GRPC_ERROR_NONE) {
- grpc_byte_stream_destroy(exec_ctx, s->fetching_send_message);
- grpc_chttp2_cancel_stream(exec_ctx, t, s, error);
+ grpc_byte_stream_destroy(s->fetching_send_message);
+ grpc_chttp2_cancel_stream(t, s, error);
}
}
-static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
+static void do_nothing(void* arg, grpc_error* error) {}
static void log_metadata(const grpc_metadata_batch* md_batch, uint32_t id,
bool is_client, bool is_initial) {
@@ -1384,7 +1310,7 @@ static void log_metadata(const grpc_metadata_batch* md_batch, uint32_t id,
}
}
-static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
+static void perform_stream_op_locked(void* stream_op,
grpc_error* error_ignored) {
GPR_TIMER_BEGIN("perform_stream_op_locked", 0);
@@ -1394,7 +1320,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
grpc_transport_stream_op_batch_payload* op_payload = op->payload;
grpc_chttp2_transport* t = s->t;
- GRPC_STATS_INC_HTTP2_OP_BATCHES(exec_ctx);
+ GRPC_STATS_INC_HTTP2_OP_BATCHES();
if (GRPC_TRACER_ON(grpc_http_trace)) {
char* str = grpc_transport_stream_op_batch_string(op);
@@ -1429,13 +1355,12 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
}
if (op->cancel_stream) {
- GRPC_STATS_INC_HTTP2_OP_CANCEL(exec_ctx);
- grpc_chttp2_cancel_stream(exec_ctx, t, s,
- op_payload->cancel_stream.cancel_error);
+ GRPC_STATS_INC_HTTP2_OP_CANCEL();
+ grpc_chttp2_cancel_stream(t, s, op_payload->cancel_stream.cancel_error);
}
if (op->send_initial_metadata) {
- GRPC_STATS_INC_HTTP2_OP_SEND_INITIAL_METADATA(exec_ctx);
+ GRPC_STATS_INC_HTTP2_OP_SEND_INITIAL_METADATA();
GPR_ASSERT(s->send_initial_metadata_finished == nullptr);
on_complete->next_data.scratch |= CLOSURE_BARRIER_MAY_COVER_WRITE;
@@ -1463,7 +1388,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
}
if (metadata_size > metadata_peer_limit) {
grpc_chttp2_cancel_stream(
- exec_ctx, t, s,
+ t, s,
grpc_error_set_int(
grpc_error_set_int(
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
@@ -1482,10 +1407,10 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
if (t->closed_with_error == GRPC_ERROR_NONE) {
GPR_ASSERT(s->id == 0);
grpc_chttp2_list_add_waiting_for_concurrency(t, s);
- maybe_start_some_streams(exec_ctx, t);
+ maybe_start_some_streams(t);
} else {
grpc_chttp2_cancel_stream(
- exec_ctx, t, s,
+ t, s,
grpc_error_set_int(
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Transport closed", &t->closed_with_error, 1),
@@ -1493,18 +1418,18 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
}
} else {
GPR_ASSERT(s->id != 0);
- grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
+ grpc_chttp2_mark_stream_writable(t, s);
if (!(op->send_message &&
(op->payload->send_message.send_message->flags &
GRPC_WRITE_BUFFER_HINT))) {
grpc_chttp2_initiate_write(
- exec_ctx, t, GRPC_CHTTP2_INITIATE_WRITE_SEND_INITIAL_METADATA);
+ t, GRPC_CHTTP2_INITIATE_WRITE_SEND_INITIAL_METADATA);
}
}
} else {
s->send_initial_metadata = nullptr;
grpc_chttp2_complete_closure_step(
- exec_ctx, t, s, &s->send_initial_metadata_finished,
+ t, s, &s->send_initial_metadata_finished,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Attempt to send initial metadata after stream was closed",
&s->write_closed_error, 1),
@@ -1518,9 +1443,9 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
}
if (op->send_message) {
- GRPC_STATS_INC_HTTP2_OP_SEND_MESSAGE(exec_ctx);
+ GRPC_STATS_INC_HTTP2_OP_SEND_MESSAGE();
GRPC_STATS_INC_HTTP2_SEND_MESSAGE_SIZE(
- exec_ctx, op->payload->send_message.send_message->length);
+ op->payload->send_message.send_message->length);
on_complete->next_data.scratch |= CLOSURE_BARRIER_MAY_COVER_WRITE;
s->fetching_send_message_finished = add_closure_barrier(op->on_complete);
if (s->write_closed) {
@@ -1530,7 +1455,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
// recv_message failure, breaking out of its loop, and then
// starting recv_trailing_metadata.
grpc_chttp2_complete_closure_step(
- exec_ctx, t, s, &s->fetching_send_message_finished,
+ t, s, &s->fetching_send_message_finished,
t->is_client && s->received_trailing_metadata
? GRPC_ERROR_NONE
: GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
@@ -1559,13 +1484,13 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
} else {
s->write_buffering = false;
}
- continue_fetching_send_locked(exec_ctx, t, s);
- maybe_become_writable_due_to_send_msg(exec_ctx, t, s);
+ continue_fetching_send_locked(t, s);
+ maybe_become_writable_due_to_send_msg(t, s);
}
}
if (op->send_trailing_metadata) {
- GRPC_STATS_INC_HTTP2_OP_SEND_TRAILING_METADATA(exec_ctx);
+ GRPC_STATS_INC_HTTP2_OP_SEND_TRAILING_METADATA();
GPR_ASSERT(s->send_trailing_metadata_finished == nullptr);
on_complete->next_data.scratch |= CLOSURE_BARRIER_MAY_COVER_WRITE;
s->send_trailing_metadata_finished = add_closure_barrier(on_complete);
@@ -1579,7 +1504,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
[GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE];
if (metadata_size > metadata_peer_limit) {
grpc_chttp2_cancel_stream(
- exec_ctx, t, s,
+ t, s,
grpc_error_set_int(
grpc_error_set_int(
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
@@ -1596,7 +1521,7 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
if (s->write_closed) {
s->send_trailing_metadata = nullptr;
grpc_chttp2_complete_closure_step(
- exec_ctx, t, s, &s->send_trailing_metadata_finished,
+ t, s, &s->send_trailing_metadata_finished,
grpc_metadata_batch_is_empty(
op->payload->send_trailing_metadata.send_trailing_metadata)
? GRPC_ERROR_NONE
@@ -1607,15 +1532,15 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
} else if (s->id != 0) {
/* TODO(ctiller): check if there's flow control for any outstanding
bytes before going writable */
- grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
+ grpc_chttp2_mark_stream_writable(t, s);
grpc_chttp2_initiate_write(
- exec_ctx, t, GRPC_CHTTP2_INITIATE_WRITE_SEND_TRAILING_METADATA);
+ t, GRPC_CHTTP2_INITIATE_WRITE_SEND_TRAILING_METADATA);
}
}
}
if (op->recv_initial_metadata) {
- GRPC_STATS_INC_HTTP2_OP_RECV_INITIAL_METADATA(exec_ctx);
+ GRPC_STATS_INC_HTTP2_OP_RECV_INITIAL_METADATA();
GPR_ASSERT(s->recv_initial_metadata_ready == nullptr);
s->recv_initial_metadata_ready =
op_payload->recv_initial_metadata.recv_initial_metadata_ready;
@@ -1627,11 +1552,11 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
gpr_atm_rel_store(op_payload->recv_initial_metadata.peer_string,
(gpr_atm)gpr_strdup(t->peer_string));
}
- grpc_chttp2_maybe_complete_recv_initial_metadata(exec_ctx, t, s);
+ grpc_chttp2_maybe_complete_recv_initial_metadata(t, s);
}
if (op->recv_message) {
- GRPC_STATS_INC_HTTP2_OP_RECV_MESSAGE(exec_ctx);
+ GRPC_STATS_INC_HTTP2_OP_RECV_MESSAGE();
size_t already_received;
GPR_ASSERT(s->recv_message_ready == nullptr);
GPR_ASSERT(!s->pending_byte_stream);
@@ -1642,32 +1567,30 @@ static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
already_received = s->frame_storage.length;
s->flow_control->IncomingByteStreamUpdate(GRPC_HEADER_SIZE_IN_BYTES,
already_received);
- grpc_chttp2_act_on_flowctl_action(exec_ctx,
- s->flow_control->MakeAction(), t, s);
+ grpc_chttp2_act_on_flowctl_action(s->flow_control->MakeAction(), t, s);
}
}
- grpc_chttp2_maybe_complete_recv_message(exec_ctx, t, s);
+ grpc_chttp2_maybe_complete_recv_message(t, s);
}
if (op->recv_trailing_metadata) {
- GRPC_STATS_INC_HTTP2_OP_RECV_TRAILING_METADATA(exec_ctx);
+ GRPC_STATS_INC_HTTP2_OP_RECV_TRAILING_METADATA();
GPR_ASSERT(s->recv_trailing_metadata_finished == nullptr);
s->recv_trailing_metadata_finished = add_closure_barrier(on_complete);
s->recv_trailing_metadata =
op_payload->recv_trailing_metadata.recv_trailing_metadata;
s->final_metadata_requested = true;
- grpc_chttp2_maybe_complete_recv_trailing_metadata(exec_ctx, t, s);
+ grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s);
}
- grpc_chttp2_complete_closure_step(exec_ctx, t, s, &on_complete,
- GRPC_ERROR_NONE, "op->on_complete");
+ grpc_chttp2_complete_closure_step(t, s, &on_complete, GRPC_ERROR_NONE,
+ "op->on_complete");
GPR_TIMER_END("perform_stream_op_locked", 0);
- GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "perform_stream_op");
+ GRPC_CHTTP2_STREAM_UNREF(s, "perform_stream_op");
}
-static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
- grpc_stream* gs,
+static void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
grpc_transport_stream_op_batch* op) {
GPR_TIMER_BEGIN("perform_stream_op", 0);
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
@@ -1695,32 +1618,29 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
op->handler_private.extra_arg = gs;
GRPC_CHTTP2_STREAM_REF(s, "perform_stream_op");
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_INIT(&op->handler_private.closure, perform_stream_op_locked,
op, grpc_combiner_scheduler(t->combiner)),
GRPC_ERROR_NONE);
GPR_TIMER_END("perform_stream_op", 0);
}
-static void cancel_pings(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
- grpc_error* error) {
+static void cancel_pings(grpc_chttp2_transport* t, grpc_error* error) {
/* callback remaining pings: they're not allowed to call into the transpot,
and maybe they hold resources that need to be freed */
grpc_chttp2_ping_queue* pq = &t->ping_queue;
GPR_ASSERT(error != GRPC_ERROR_NONE);
for (size_t j = 0; j < GRPC_CHTTP2_PCL_COUNT; j++) {
grpc_closure_list_fail_all(&pq->lists[j], GRPC_ERROR_REF(error));
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pq->lists[j]);
+ GRPC_CLOSURE_LIST_SCHED(&pq->lists[j]);
}
GRPC_ERROR_UNREF(error);
}
-static void send_ping_locked(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+static void send_ping_locked(grpc_chttp2_transport* t,
grpc_closure* on_initiate, grpc_closure* on_ack) {
if (t->closed_with_error != GRPC_ERROR_NONE) {
- GRPC_CLOSURE_SCHED(exec_ctx, on_initiate,
- GRPC_ERROR_REF(t->closed_with_error));
- GRPC_CLOSURE_SCHED(exec_ctx, on_ack, GRPC_ERROR_REF(t->closed_with_error));
+ GRPC_CLOSURE_SCHED(on_initiate, GRPC_ERROR_REF(t->closed_with_error));
+ GRPC_CLOSURE_SCHED(on_ack, GRPC_ERROR_REF(t->closed_with_error));
return;
}
grpc_chttp2_ping_queue* pq = &t->ping_queue;
@@ -1730,18 +1650,15 @@ static void send_ping_locked(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
GRPC_ERROR_NONE);
}
-static void retry_initiate_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
- grpc_error* error) {
+static void retry_initiate_ping_locked(void* tp, grpc_error* error) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
t->ping_state.is_delayed_ping_timer_set = false;
if (error == GRPC_ERROR_NONE) {
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_RETRY_SEND_PING);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_RETRY_SEND_PING);
}
}
-void grpc_chttp2_ack_ping(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
- uint64_t id) {
+void grpc_chttp2_ack_ping(grpc_chttp2_transport* t, uint64_t id) {
grpc_chttp2_ping_queue* pq = &t->ping_queue;
if (pq->inflight_id != id) {
char* from = grpc_endpoint_get_peer(t->ep);
@@ -1749,47 +1666,41 @@ void grpc_chttp2_ack_ping(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
gpr_free(from);
return;
}
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pq->lists[GRPC_CHTTP2_PCL_INFLIGHT]);
+ GRPC_CLOSURE_LIST_SCHED(&pq->lists[GRPC_CHTTP2_PCL_INFLIGHT]);
if (!grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_NEXT])) {
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_CONTINUE_PINGS);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_CONTINUE_PINGS);
}
}
-static void send_goaway(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
- grpc_error* error) {
+static void send_goaway(grpc_chttp2_transport* t, grpc_error* error) {
t->sent_goaway_state = GRPC_CHTTP2_GOAWAY_SEND_SCHEDULED;
grpc_http2_error_code http_error;
grpc_slice slice;
- grpc_error_get_status(exec_ctx, error, GRPC_MILLIS_INF_FUTURE, nullptr,
- &slice, &http_error);
+ grpc_error_get_status(error, GRPC_MILLIS_INF_FUTURE, nullptr, &slice,
+ &http_error);
grpc_chttp2_goaway_append(t->last_new_stream_id, (uint32_t)http_error,
grpc_slice_ref_internal(slice), &t->qbuf);
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_GOAWAY_SENT);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_GOAWAY_SENT);
GRPC_ERROR_UNREF(error);
}
-void grpc_chttp2_add_ping_strike(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t) {
+void grpc_chttp2_add_ping_strike(grpc_chttp2_transport* t) {
t->ping_recv_state.ping_strikes++;
if (++t->ping_recv_state.ping_strikes > t->ping_policy.max_ping_strikes &&
t->ping_policy.max_ping_strikes != 0) {
- send_goaway(exec_ctx, t,
+ send_goaway(t,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("too_many_pings"),
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM));
/*The transport will be closed after the write is done */
close_transport_locked(
- exec_ctx, t,
- grpc_error_set_int(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many pings"),
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
+ t, grpc_error_set_int(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many pings"),
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
}
}
-static void perform_transport_op_locked(grpc_exec_ctx* exec_ctx,
- void* stream_op,
+static void perform_transport_op_locked(void* stream_op,
grpc_error* error_ignored) {
grpc_transport_op* op = (grpc_transport_op*)stream_op;
grpc_chttp2_transport* t =
@@ -1797,7 +1708,7 @@ static void perform_transport_op_locked(grpc_exec_ctx* exec_ctx,
grpc_error* close_transport = op->disconnect_with_error;
if (op->goaway_error) {
- send_goaway(exec_ctx, t, op->goaway_error);
+ send_goaway(t, op->goaway_error);
}
if (op->set_accept_stream) {
@@ -1807,43 +1718,40 @@ static void perform_transport_op_locked(grpc_exec_ctx* exec_ctx,
}
if (op->bind_pollset) {
- grpc_endpoint_add_to_pollset(exec_ctx, t->ep, op->bind_pollset);
+ grpc_endpoint_add_to_pollset(t->ep, op->bind_pollset);
}
if (op->bind_pollset_set) {
- grpc_endpoint_add_to_pollset_set(exec_ctx, t->ep, op->bind_pollset_set);
+ grpc_endpoint_add_to_pollset_set(t->ep, op->bind_pollset_set);
}
if (op->send_ping) {
- send_ping_locked(exec_ctx, t, nullptr, op->send_ping);
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_APPLICATION_PING);
+ send_ping_locked(t, nullptr, op->send_ping);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_APPLICATION_PING);
}
if (op->on_connectivity_state_change != nullptr) {
grpc_connectivity_state_notify_on_state_change(
- exec_ctx, &t->channel_callback.state_tracker, op->connectivity_state,
+ &t->channel_callback.state_tracker, op->connectivity_state,
op->on_connectivity_state_change);
}
if (close_transport != GRPC_ERROR_NONE) {
- close_transport_locked(exec_ctx, t, close_transport);
+ close_transport_locked(t, close_transport);
}
- GRPC_CLOSURE_RUN(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_RUN(op->on_consumed, GRPC_ERROR_NONE);
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "transport_op");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "transport_op");
}
-static void perform_transport_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
- grpc_transport_op* op) {
+static void perform_transport_op(grpc_transport* gt, grpc_transport_op* op) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
char* msg = grpc_transport_op_string(op);
gpr_free(msg);
op->handler_private.extra_arg = gt;
GRPC_CHTTP2_REF_TRANSPORT(t, "transport_op");
- GRPC_CLOSURE_SCHED(exec_ctx,
- GRPC_CLOSURE_INIT(&op->handler_private.closure,
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_INIT(&op->handler_private.closure,
perform_transport_op_locked, op,
grpc_combiner_scheduler(t->combiner)),
GRPC_ERROR_NONE);
@@ -1853,36 +1761,33 @@ static void perform_transport_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
* INPUT PROCESSING - GENERAL
*/
-void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_chttp2_transport* t,
grpc_chttp2_stream* s) {
if (s->recv_initial_metadata_ready != nullptr &&
s->published_metadata[0] != GRPC_METADATA_NOT_PUBLISHED) {
if (s->seen_error) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &s->frame_storage);
+ grpc_slice_buffer_reset_and_unref_internal(&s->frame_storage);
if (!s->pending_byte_stream) {
grpc_slice_buffer_reset_and_unref_internal(
- exec_ctx, &s->unprocessed_incoming_frames_buffer);
+ &s->unprocessed_incoming_frames_buffer);
}
}
- grpc_chttp2_incoming_metadata_buffer_publish(
- exec_ctx, &s->metadata_buffer[0], s->recv_initial_metadata);
- null_then_run_closure(exec_ctx, &s->recv_initial_metadata_ready,
- GRPC_ERROR_NONE);
+ grpc_chttp2_incoming_metadata_buffer_publish(&s->metadata_buffer[0],
+ s->recv_initial_metadata);
+ null_then_run_closure(&s->recv_initial_metadata_ready, GRPC_ERROR_NONE);
}
}
-void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+void grpc_chttp2_maybe_complete_recv_message(grpc_chttp2_transport* t,
grpc_chttp2_stream* s) {
grpc_error* error = GRPC_ERROR_NONE;
if (s->recv_message_ready != nullptr) {
*s->recv_message = nullptr;
if (s->final_metadata_requested && s->seen_error) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &s->frame_storage);
+ grpc_slice_buffer_reset_and_unref_internal(&s->frame_storage);
if (!s->pending_byte_stream) {
grpc_slice_buffer_reset_and_unref_internal(
- exec_ctx, &s->unprocessed_incoming_frames_buffer);
+ &s->unprocessed_incoming_frames_buffer);
}
}
if (!s->pending_byte_stream) {
@@ -1909,10 +1814,9 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx* exec_ctx,
&s->decompressed_data_buffer, nullptr,
GRPC_HEADER_SIZE_IN_BYTES - s->decompressed_header_bytes,
&end_of_context)) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
- &s->frame_storage);
+ grpc_slice_buffer_reset_and_unref_internal(&s->frame_storage);
grpc_slice_buffer_reset_and_unref_internal(
- exec_ctx, &s->unprocessed_incoming_frames_buffer);
+ &s->unprocessed_incoming_frames_buffer);
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Stream decompression error.");
} else {
@@ -1921,8 +1825,8 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx* exec_ctx,
s->decompressed_header_bytes = 0;
}
error = grpc_deframe_unprocessed_incoming_frames(
- exec_ctx, &s->data_parser, s, &s->decompressed_data_buffer,
- nullptr, s->recv_message);
+ &s->data_parser, s, &s->decompressed_data_buffer, nullptr,
+ s->recv_message);
if (end_of_context) {
grpc_stream_compression_context_destroy(
s->stream_decompression_ctx);
@@ -1931,15 +1835,14 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx* exec_ctx,
}
} else {
error = grpc_deframe_unprocessed_incoming_frames(
- exec_ctx, &s->data_parser, s,
- &s->unprocessed_incoming_frames_buffer, nullptr, s->recv_message);
+ &s->data_parser, s, &s->unprocessed_incoming_frames_buffer,
+ nullptr, s->recv_message);
}
if (error != GRPC_ERROR_NONE) {
s->seen_error = true;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
- &s->frame_storage);
+ grpc_slice_buffer_reset_and_unref_internal(&s->frame_storage);
grpc_slice_buffer_reset_and_unref_internal(
- exec_ctx, &s->unprocessed_incoming_frames_buffer);
+ &s->unprocessed_incoming_frames_buffer);
break;
} else if (*s->recv_message != nullptr) {
break;
@@ -1947,26 +1850,25 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx* exec_ctx,
}
}
if (error == GRPC_ERROR_NONE && *s->recv_message != nullptr) {
- null_then_run_closure(exec_ctx, &s->recv_message_ready, GRPC_ERROR_NONE);
+ null_then_run_closure(&s->recv_message_ready, GRPC_ERROR_NONE);
} else if (s->published_metadata[1] != GRPC_METADATA_NOT_PUBLISHED) {
*s->recv_message = nullptr;
- null_then_run_closure(exec_ctx, &s->recv_message_ready, GRPC_ERROR_NONE);
+ null_then_run_closure(&s->recv_message_ready, GRPC_ERROR_NONE);
}
GRPC_ERROR_UNREF(error);
}
}
-void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_chttp2_transport* t,
grpc_chttp2_stream* s) {
- grpc_chttp2_maybe_complete_recv_message(exec_ctx, t, s);
+ grpc_chttp2_maybe_complete_recv_message(t, s);
if (s->recv_trailing_metadata_finished != nullptr && s->read_closed &&
s->write_closed) {
if (s->seen_error) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &s->frame_storage);
+ grpc_slice_buffer_reset_and_unref_internal(&s->frame_storage);
if (!s->pending_byte_stream) {
grpc_slice_buffer_reset_and_unref_internal(
- exec_ctx, &s->unprocessed_incoming_frames_buffer);
+ &s->unprocessed_incoming_frames_buffer);
}
}
bool pending_data = s->pending_byte_stream ||
@@ -1984,9 +1886,9 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx* exec_ctx,
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(&s->frame_storage);
grpc_slice_buffer_reset_and_unref_internal(
- exec_ctx, &s->unprocessed_incoming_frames_buffer);
+ &s->unprocessed_incoming_frames_buffer);
s->seen_error = true;
} else {
if (s->unprocessed_incoming_frames_buffer.length > 0) {
@@ -2001,23 +1903,23 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx* exec_ctx,
}
if (s->read_closed && s->frame_storage.length == 0 && !pending_data &&
s->recv_trailing_metadata_finished != nullptr) {
- grpc_chttp2_incoming_metadata_buffer_publish(
- exec_ctx, &s->metadata_buffer[1], s->recv_trailing_metadata);
+ grpc_chttp2_incoming_metadata_buffer_publish(&s->metadata_buffer[1],
+ s->recv_trailing_metadata);
grpc_chttp2_complete_closure_step(
- exec_ctx, t, s, &s->recv_trailing_metadata_finished, GRPC_ERROR_NONE,
+ t, s, &s->recv_trailing_metadata_finished, GRPC_ERROR_NONE,
"recv_trailing_metadata_finished");
}
}
}
-static void remove_stream(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
- uint32_t id, grpc_error* error) {
+static void remove_stream(grpc_chttp2_transport* t, uint32_t id,
+ grpc_error* error) {
grpc_chttp2_stream* s =
(grpc_chttp2_stream*)grpc_chttp2_stream_map_delete(&t->stream_map, id);
GPR_ASSERT(s);
if (t->incoming_stream == s) {
t->incoming_stream = nullptr;
- grpc_chttp2_parsing_become_skip_parser(exec_ctx, t);
+ grpc_chttp2_parsing_become_skip_parser(t);
}
if (s->pending_byte_stream) {
if (s->on_next != nullptr) {
@@ -2025,8 +1927,8 @@ static void remove_stream(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
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);
+ incoming_byte_stream_publish_error(bs, error);
+ incoming_byte_stream_unref(bs);
s->data_parser.parsing_frame = nullptr;
} else {
GRPC_ERROR_UNREF(s->byte_stream_error);
@@ -2035,55 +1937,52 @@ static void remove_stream(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
}
if (grpc_chttp2_stream_map_size(&t->stream_map) == 0) {
- post_benign_reclaimer(exec_ctx, t);
+ post_benign_reclaimer(t);
if (t->sent_goaway_state == GRPC_CHTTP2_GOAWAY_SENT) {
close_transport_locked(
- exec_ctx, t,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Last stream closed after sending GOAWAY", &error, 1));
+ t, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Last stream closed after sending GOAWAY", &error, 1));
}
}
if (grpc_chttp2_list_remove_writable_stream(t, s)) {
- GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "chttp2_writing:remove_stream");
+ GRPC_CHTTP2_STREAM_UNREF(s, "chttp2_writing:remove_stream");
}
GRPC_ERROR_UNREF(error);
- maybe_start_some_streams(exec_ctx, t);
+ maybe_start_some_streams(t);
}
-void grpc_chttp2_cancel_stream(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+void grpc_chttp2_cancel_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
grpc_error* due_to_error) {
if (!t->is_client && !s->sent_trailing_metadata &&
grpc_error_has_clear_grpc_status(due_to_error)) {
- close_from_api(exec_ctx, t, s, due_to_error);
+ close_from_api(t, s, due_to_error);
return;
}
if (!s->read_closed || !s->write_closed) {
if (s->id != 0) {
grpc_http2_error_code http_error;
- grpc_error_get_status(exec_ctx, due_to_error, s->deadline, nullptr,
- nullptr, &http_error);
+ grpc_error_get_status(due_to_error, s->deadline, nullptr, nullptr,
+ &http_error);
grpc_slice_buffer_add(
&t->qbuf, grpc_chttp2_rst_stream_create(s->id, (uint32_t)http_error,
&s->stats.outgoing));
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_RST_STREAM);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_RST_STREAM);
}
}
if (due_to_error != GRPC_ERROR_NONE && !s->seen_error) {
s->seen_error = true;
}
- grpc_chttp2_mark_stream_closed(exec_ctx, t, s, 1, 1, due_to_error);
+ grpc_chttp2_mark_stream_closed(t, s, 1, 1, due_to_error);
}
-void grpc_chttp2_fake_status(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
- grpc_chttp2_stream* s, grpc_error* error) {
+void grpc_chttp2_fake_status(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+ grpc_error* error) {
grpc_status_code status;
grpc_slice slice;
- grpc_error_get_status(exec_ctx, error, s->deadline, &status, &slice, nullptr);
+ grpc_error_get_status(error, s->deadline, &status, &slice, nullptr);
if (status != GRPC_STATUS_OK) {
s->seen_error = true;
}
@@ -2099,20 +1998,20 @@ void grpc_chttp2_fake_status(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
gpr_ltoa(status, status_string);
GRPC_LOG_IF_ERROR("add_status",
grpc_chttp2_incoming_metadata_buffer_replace_or_add(
- exec_ctx, &s->metadata_buffer[1],
+ &s->metadata_buffer[1],
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_GRPC_STATUS,
+ GRPC_MDSTR_GRPC_STATUS,
grpc_slice_from_copied_string(status_string))));
if (!GRPC_SLICE_IS_EMPTY(slice)) {
GRPC_LOG_IF_ERROR(
"add_status_message",
grpc_chttp2_incoming_metadata_buffer_replace_or_add(
- exec_ctx, &s->metadata_buffer[1],
- grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_GRPC_MESSAGE,
+ &s->metadata_buffer[1],
+ grpc_mdelem_from_slices(GRPC_MDSTR_GRPC_MESSAGE,
grpc_slice_ref_internal(slice))));
}
s->published_metadata[1] = GRPC_METADATA_SYNTHESIZED_FROM_FAKE;
- grpc_chttp2_maybe_complete_recv_trailing_metadata(exec_ctx, t, s);
+ grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s);
}
GRPC_ERROR_UNREF(error);
@@ -2145,14 +2044,12 @@ static grpc_error* removal_error(grpc_error* extra_error, grpc_chttp2_stream* s,
return error;
}
-static void flush_write_list(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
- grpc_chttp2_stream* s, grpc_chttp2_write_cb** list,
- grpc_error* error) {
+static void flush_write_list(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+ grpc_chttp2_write_cb** list, grpc_error* error) {
while (*list) {
grpc_chttp2_write_cb* cb = *list;
*list = cb->next;
- grpc_chttp2_complete_closure_step(exec_ctx, t, s, &cb->closure,
- GRPC_ERROR_REF(error),
+ grpc_chttp2_complete_closure_step(t, s, &cb->closure, GRPC_ERROR_REF(error),
"on_write_finished_cb");
cb->next = t->write_cb_pool;
t->write_cb_pool = cb;
@@ -2160,37 +2057,34 @@ static void flush_write_list(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
GRPC_ERROR_UNREF(error);
}
-void grpc_chttp2_fail_pending_writes(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+void grpc_chttp2_fail_pending_writes(grpc_chttp2_transport* t,
grpc_chttp2_stream* s, grpc_error* error) {
error =
removal_error(error, s, "Pending writes failed due to stream closure");
s->send_initial_metadata = nullptr;
- grpc_chttp2_complete_closure_step(
- exec_ctx, t, s, &s->send_initial_metadata_finished, GRPC_ERROR_REF(error),
- "send_initial_metadata_finished");
+ grpc_chttp2_complete_closure_step(t, s, &s->send_initial_metadata_finished,
+ GRPC_ERROR_REF(error),
+ "send_initial_metadata_finished");
s->send_trailing_metadata = nullptr;
- grpc_chttp2_complete_closure_step(
- exec_ctx, t, s, &s->send_trailing_metadata_finished,
- GRPC_ERROR_REF(error), "send_trailing_metadata_finished");
+ grpc_chttp2_complete_closure_step(t, s, &s->send_trailing_metadata_finished,
+ GRPC_ERROR_REF(error),
+ "send_trailing_metadata_finished");
s->fetching_send_message = nullptr;
- grpc_chttp2_complete_closure_step(
- exec_ctx, t, s, &s->fetching_send_message_finished, GRPC_ERROR_REF(error),
- "fetching_send_message_finished");
- flush_write_list(exec_ctx, t, s, &s->on_write_finished_cbs,
- GRPC_ERROR_REF(error));
- flush_write_list(exec_ctx, t, s, &s->on_flow_controlled_cbs, error);
+ grpc_chttp2_complete_closure_step(t, s, &s->fetching_send_message_finished,
+ GRPC_ERROR_REF(error),
+ "fetching_send_message_finished");
+ flush_write_list(t, s, &s->on_write_finished_cbs, GRPC_ERROR_REF(error));
+ flush_write_list(t, s, &s->on_flow_controlled_cbs, error);
}
-void grpc_chttp2_mark_stream_closed(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+void grpc_chttp2_mark_stream_closed(grpc_chttp2_transport* t,
grpc_chttp2_stream* s, int close_reads,
int close_writes, grpc_error* error) {
if (s->read_closed && s->write_closed) {
/* already closed */
- grpc_chttp2_maybe_complete_recv_trailing_metadata(exec_ctx, t, s);
+ grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s);
GRPC_ERROR_UNREF(error);
return;
}
@@ -2204,20 +2098,20 @@ void grpc_chttp2_mark_stream_closed(grpc_exec_ctx* exec_ctx,
if (close_writes && !s->write_closed) {
s->write_closed_error = GRPC_ERROR_REF(error);
s->write_closed = true;
- grpc_chttp2_fail_pending_writes(exec_ctx, t, s, GRPC_ERROR_REF(error));
+ grpc_chttp2_fail_pending_writes(t, s, GRPC_ERROR_REF(error));
}
if (s->read_closed && s->write_closed) {
became_closed = true;
grpc_error* overall_error =
removal_error(GRPC_ERROR_REF(error), s, "Stream removed");
if (s->id != 0) {
- remove_stream(exec_ctx, t, s->id, GRPC_ERROR_REF(overall_error));
+ remove_stream(t, s->id, GRPC_ERROR_REF(overall_error));
} else {
/* Purge streams waiting on concurrency still waiting for id assignment */
grpc_chttp2_list_remove_waiting_for_concurrency(t, s);
}
if (overall_error != GRPC_ERROR_NONE) {
- grpc_chttp2_fake_status(exec_ctx, t, s, overall_error);
+ grpc_chttp2_fake_status(t, s, overall_error);
}
}
if (closed_read) {
@@ -2226,18 +2120,18 @@ void grpc_chttp2_mark_stream_closed(grpc_exec_ctx* exec_ctx,
s->published_metadata[i] = GPRC_METADATA_PUBLISHED_AT_CLOSE;
}
}
- grpc_chttp2_maybe_complete_recv_initial_metadata(exec_ctx, t, s);
- grpc_chttp2_maybe_complete_recv_message(exec_ctx, t, s);
+ grpc_chttp2_maybe_complete_recv_initial_metadata(t, s);
+ grpc_chttp2_maybe_complete_recv_message(t, s);
}
if (became_closed) {
- grpc_chttp2_maybe_complete_recv_trailing_metadata(exec_ctx, t, s);
- GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "chttp2");
+ grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s);
+ GRPC_CHTTP2_STREAM_UNREF(s, "chttp2");
}
GRPC_ERROR_UNREF(error);
}
-static void close_from_api(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
- grpc_chttp2_stream* s, grpc_error* error) {
+static void close_from_api(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+ grpc_error* error) {
grpc_slice hdr;
grpc_slice status_hdr;
grpc_slice http_status_hdr;
@@ -2247,8 +2141,7 @@ static void close_from_api(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
uint32_t len = 0;
grpc_status_code grpc_status;
grpc_slice slice;
- grpc_error_get_status(exec_ctx, error, s->deadline, &grpc_status, &slice,
- nullptr);
+ grpc_error_get_status(error, s->deadline, &grpc_status, &slice, nullptr);
GPR_ASSERT(grpc_status >= 0 && (int)grpc_status < 100);
@@ -2390,13 +2283,11 @@ static void close_from_api(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
&t->qbuf, grpc_chttp2_rst_stream_create(s->id, GRPC_HTTP2_NO_ERROR,
&s->stats.outgoing));
- grpc_chttp2_mark_stream_closed(exec_ctx, t, s, 1, 1, error);
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_CLOSE_FROM_API);
+ grpc_chttp2_mark_stream_closed(t, s, 1, 1, error);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_CLOSE_FROM_API);
}
typedef struct {
- grpc_exec_ctx* exec_ctx;
grpc_error* error;
grpc_chttp2_transport* t;
} cancel_stream_cb_args;
@@ -2404,13 +2295,11 @@ typedef struct {
static void cancel_stream_cb(void* user_data, uint32_t key, void* stream) {
cancel_stream_cb_args* args = (cancel_stream_cb_args*)user_data;
grpc_chttp2_stream* s = (grpc_chttp2_stream*)stream;
- grpc_chttp2_cancel_stream(args->exec_ctx, args->t, s,
- GRPC_ERROR_REF(args->error));
+ grpc_chttp2_cancel_stream(args->t, s, GRPC_ERROR_REF(args->error));
}
-static void end_all_the_calls(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
- grpc_error* error) {
- cancel_stream_cb_args args = {exec_ctx, error, t};
+static void end_all_the_calls(grpc_chttp2_transport* t, grpc_error* error) {
+ cancel_stream_cb_args args = {error, t};
grpc_chttp2_stream_map_for_each(&t->stream_map, cancel_stream_cb, &args);
GRPC_ERROR_UNREF(error);
}
@@ -2420,14 +2309,14 @@ static void end_all_the_calls(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
*/
template <class F>
-static void WithUrgency(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+static void WithUrgency(grpc_chttp2_transport* t,
grpc_core::chttp2::FlowControlAction::Urgency urgency,
grpc_chttp2_initiate_write_reason reason, F action) {
switch (urgency) {
case grpc_core::chttp2::FlowControlAction::Urgency::NO_ACTION_NEEDED:
break;
case grpc_core::chttp2::FlowControlAction::Urgency::UPDATE_IMMEDIATELY:
- grpc_chttp2_initiate_write(exec_ctx, t, reason);
+ grpc_chttp2_initiate_write(t, reason);
// fallthrough
case grpc_core::chttp2::FlowControlAction::Urgency::QUEUE_UPDATE:
action();
@@ -2436,31 +2325,27 @@ static void WithUrgency(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
}
void grpc_chttp2_act_on_flowctl_action(
- grpc_exec_ctx* exec_ctx, const grpc_core::chttp2::FlowControlAction& action,
+ const grpc_core::chttp2::FlowControlAction& action,
grpc_chttp2_transport* t, grpc_chttp2_stream* s) {
- WithUrgency(
- exec_ctx, t, action.send_stream_update(),
- GRPC_CHTTP2_INITIATE_WRITE_STREAM_FLOW_CONTROL,
- [exec_ctx, t, s]() { grpc_chttp2_mark_stream_writable(exec_ctx, t, s); });
- WithUrgency(exec_ctx, t, action.send_transport_update(),
+ WithUrgency(t, action.send_stream_update(),
+ GRPC_CHTTP2_INITIATE_WRITE_STREAM_FLOW_CONTROL,
+ [t, s]() { grpc_chttp2_mark_stream_writable(t, s); });
+ WithUrgency(t, action.send_transport_update(),
GRPC_CHTTP2_INITIATE_WRITE_TRANSPORT_FLOW_CONTROL, []() {});
- WithUrgency(exec_ctx, t, action.send_initial_window_update(),
- GRPC_CHTTP2_INITIATE_WRITE_SEND_SETTINGS,
- [exec_ctx, t, &action]() {
- queue_setting_update(exec_ctx, t,
+ WithUrgency(t, action.send_initial_window_update(),
+ GRPC_CHTTP2_INITIATE_WRITE_SEND_SETTINGS, [t, &action]() {
+ queue_setting_update(t,
GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE,
action.initial_window_size());
});
- WithUrgency(
- exec_ctx, t, action.send_max_frame_size_update(),
- GRPC_CHTTP2_INITIATE_WRITE_SEND_SETTINGS, [exec_ctx, t, &action]() {
- queue_setting_update(exec_ctx, t, GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE,
- action.max_frame_size());
- });
+ WithUrgency(t, action.send_max_frame_size_update(),
+ GRPC_CHTTP2_INITIATE_WRITE_SEND_SETTINGS, [t, &action]() {
+ queue_setting_update(t, GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE,
+ action.max_frame_size());
+ });
}
-static grpc_error* try_http_parsing(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t) {
+static grpc_error* try_http_parsing(grpc_chttp2_transport* t) {
grpc_http_parser parser;
size_t i = 0;
grpc_error* error = GRPC_ERROR_NONE;
@@ -2489,8 +2374,7 @@ static grpc_error* try_http_parsing(grpc_exec_ctx* exec_ctx,
return error;
}
-static void read_action_locked(grpc_exec_ctx* exec_ctx, void* tp,
- grpc_error* error) {
+static void read_action_locked(void* tp, grpc_error* error) {
GPR_TIMER_BEGIN("reading_action_locked", 0);
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
@@ -2514,11 +2398,10 @@ static void read_action_locked(grpc_exec_ctx* exec_ctx, void* tp,
for (; i < t->read_buffer.count && errors[1] == GRPC_ERROR_NONE; i++) {
t->flow_control->bdp_estimator()->AddIncomingBytes(
(int64_t)GRPC_SLICE_LENGTH(t->read_buffer.slices[i]));
- errors[1] =
- grpc_chttp2_perform_read(exec_ctx, t, t->read_buffer.slices[i]);
+ errors[1] = grpc_chttp2_perform_read(t, t->read_buffer.slices[i]);
}
if (errors[1] != GRPC_ERROR_NONE) {
- errors[2] = try_http_parsing(exec_ctx, t);
+ errors[2] = try_http_parsing(t);
GRPC_ERROR_UNREF(error);
error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failed parsing HTTP/2", errors, GPR_ARRAY_SIZE(errors));
@@ -2533,10 +2416,9 @@ static void read_action_locked(grpc_exec_ctx* exec_ctx, void* tp,
if (t->initial_window_update > 0) {
grpc_chttp2_stream* s;
while (grpc_chttp2_list_pop_stalled_by_stream(t, &s)) {
- grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
+ grpc_chttp2_mark_stream_writable(t, s);
grpc_chttp2_initiate_write(
- exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_SETTING);
+ t, GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_SETTING);
}
}
t->initial_window_update = 0;
@@ -2557,22 +2439,21 @@ static void read_action_locked(grpc_exec_ctx* exec_ctx, void* tp,
error = grpc_error_add_child(error, GRPC_ERROR_REF(t->goaway_error));
}
- close_transport_locked(exec_ctx, t, GRPC_ERROR_REF(error));
+ close_transport_locked(t, GRPC_ERROR_REF(error));
t->endpoint_reading = 0;
} else if (t->closed_with_error == GRPC_ERROR_NONE) {
keep_reading = true;
GRPC_CHTTP2_REF_TRANSPORT(t, "keep_reading");
}
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &t->read_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(&t->read_buffer);
if (keep_reading) {
- grpc_endpoint_read(exec_ctx, t->ep, &t->read_buffer,
- &t->read_action_locked);
- grpc_chttp2_act_on_flowctl_action(exec_ctx, t->flow_control->MakeAction(),
- t, nullptr);
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keep_reading");
+ grpc_endpoint_read(t->ep, &t->read_buffer, &t->read_action_locked);
+ grpc_chttp2_act_on_flowctl_action(t->flow_control->MakeAction(), t,
+ nullptr);
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "keep_reading");
} else {
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "reading_action");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "reading_action");
}
GPR_TIMER_END("post_reading_action_locked", 0);
@@ -2584,15 +2465,12 @@ static void read_action_locked(grpc_exec_ctx* exec_ctx, void* tp,
// t is reffed prior to calling the first time, and once the callback chain
// that kicks off finishes, it's unreffed
-static void schedule_bdp_ping_locked(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t) {
+static void schedule_bdp_ping_locked(grpc_chttp2_transport* t) {
t->flow_control->bdp_estimator()->SchedulePing();
- send_ping_locked(exec_ctx, t, &t->start_bdp_ping_locked,
- &t->finish_bdp_ping_locked);
+ send_ping_locked(t, &t->start_bdp_ping_locked, &t->finish_bdp_ping_locked);
}
-static void start_bdp_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
- grpc_error* error) {
+static void start_bdp_ping_locked(void* tp, grpc_error* error) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
if (GRPC_TRACER_ON(grpc_http_trace)) {
gpr_log(GPR_DEBUG, "%s: Start BDP ping err=%s", t->peer_string,
@@ -2600,42 +2478,39 @@ static void start_bdp_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
}
/* Reset the keepalive ping timer */
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING) {
- grpc_timer_cancel(exec_ctx, &t->keepalive_ping_timer);
+ grpc_timer_cancel(&t->keepalive_ping_timer);
}
t->flow_control->bdp_estimator()->StartPing();
}
-static void finish_bdp_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
- grpc_error* error) {
+static void finish_bdp_ping_locked(void* tp, grpc_error* error) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
if (GRPC_TRACER_ON(grpc_http_trace)) {
gpr_log(GPR_DEBUG, "%s: Complete BDP ping err=%s", t->peer_string,
grpc_error_string(error));
}
if (error != GRPC_ERROR_NONE) {
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "bdp_ping");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "bdp_ping");
return;
}
- grpc_millis next_ping =
- t->flow_control->bdp_estimator()->CompletePing(exec_ctx);
- grpc_chttp2_act_on_flowctl_action(
- exec_ctx, t->flow_control->PeriodicUpdate(exec_ctx), t, nullptr);
+ grpc_millis next_ping = t->flow_control->bdp_estimator()->CompletePing();
+ grpc_chttp2_act_on_flowctl_action(t->flow_control->PeriodicUpdate(), t,
+ nullptr);
GPR_ASSERT(!t->have_next_bdp_ping_timer);
t->have_next_bdp_ping_timer = true;
- grpc_timer_init(exec_ctx, &t->next_bdp_ping_timer, next_ping,
+ grpc_timer_init(&t->next_bdp_ping_timer, next_ping,
&t->next_bdp_ping_timer_expired_locked);
}
-static void next_bdp_ping_timer_expired_locked(grpc_exec_ctx* exec_ctx,
- void* tp, grpc_error* error) {
+static void next_bdp_ping_timer_expired_locked(void* tp, grpc_error* error) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
GPR_ASSERT(t->have_next_bdp_ping_timer);
t->have_next_bdp_ping_timer = false;
if (error != GRPC_ERROR_NONE) {
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "bdp_ping");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "bdp_ping");
return;
}
- schedule_bdp_ping_locked(exec_ctx, t);
+ schedule_bdp_ping_locked(t);
}
void grpc_chttp2_config_default_keepalive_args(grpc_channel_args* args,
@@ -2696,8 +2571,7 @@ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args* args,
}
}
-static void init_keepalive_ping_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void init_keepalive_ping_locked(void* arg, grpc_error* error) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
GPR_ASSERT(t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING);
if (t->destroying || t->closed_with_error != GRPC_ERROR_NONE) {
@@ -2707,59 +2581,55 @@ static void init_keepalive_ping_locked(grpc_exec_ctx* exec_ctx, void* arg,
grpc_chttp2_stream_map_size(&t->stream_map) > 0) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_PINGING;
GRPC_CHTTP2_REF_TRANSPORT(t, "keepalive ping end");
- send_ping_locked(exec_ctx, t, &t->start_keepalive_ping_locked,
+ send_ping_locked(t, &t->start_keepalive_ping_locked,
&t->finish_keepalive_ping_locked);
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_KEEPALIVE_PING);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_KEEPALIVE_PING);
} else {
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
- grpc_timer_init(exec_ctx, &t->keepalive_ping_timer,
- grpc_exec_ctx_now(exec_ctx) + t->keepalive_time,
+ grpc_timer_init(&t->keepalive_ping_timer,
+ grpc_core::ExecCtx::Get()->Now() + t->keepalive_time,
&t->init_keepalive_ping_locked);
}
} else if (error == GRPC_ERROR_CANCELLED) {
/* The keepalive ping timer may be cancelled by bdp */
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
- grpc_timer_init(exec_ctx, &t->keepalive_ping_timer,
- grpc_exec_ctx_now(exec_ctx) + t->keepalive_time,
+ grpc_timer_init(&t->keepalive_ping_timer,
+ grpc_core::ExecCtx::Get()->Now() + t->keepalive_time,
&t->init_keepalive_ping_locked);
}
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "init keepalive ping");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "init keepalive ping");
}
-static void start_keepalive_ping_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void start_keepalive_ping_locked(void* arg, grpc_error* error) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
GRPC_CHTTP2_REF_TRANSPORT(t, "keepalive watchdog");
- grpc_timer_init(exec_ctx, &t->keepalive_watchdog_timer,
- grpc_exec_ctx_now(exec_ctx) + t->keepalive_time,
+ grpc_timer_init(&t->keepalive_watchdog_timer,
+ grpc_core::ExecCtx::Get()->Now() + t->keepalive_time,
&t->keepalive_watchdog_fired_locked);
}
-static void finish_keepalive_ping_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void finish_keepalive_ping_locked(void* arg, grpc_error* error) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) {
if (error == GRPC_ERROR_NONE) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING;
- grpc_timer_cancel(exec_ctx, &t->keepalive_watchdog_timer);
+ grpc_timer_cancel(&t->keepalive_watchdog_timer);
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
- grpc_timer_init(exec_ctx, &t->keepalive_ping_timer,
- grpc_exec_ctx_now(exec_ctx) + t->keepalive_time,
+ grpc_timer_init(&t->keepalive_ping_timer,
+ grpc_core::ExecCtx::Get()->Now() + t->keepalive_time,
&t->init_keepalive_ping_locked);
}
}
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keepalive ping end");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "keepalive ping end");
}
-static void keepalive_watchdog_fired_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void keepalive_watchdog_fired_locked(void* arg, grpc_error* error) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) {
if (error == GRPC_ERROR_NONE) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING;
close_transport_locked(
- exec_ctx, t,
+ t,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"keepalive watchdog timeout"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_INTERNAL));
@@ -2772,71 +2642,67 @@ static void keepalive_watchdog_fired_locked(grpc_exec_ctx* exec_ctx, void* arg,
t->keepalive_state, GRPC_CHTTP2_KEEPALIVE_STATE_PINGING);
}
}
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keepalive watchdog");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "keepalive watchdog");
}
/*******************************************************************************
* CALLBACK LOOP
*/
-static void connectivity_state_set(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+static void connectivity_state_set(grpc_chttp2_transport* t,
grpc_connectivity_state state,
grpc_error* error, const char* reason) {
GRPC_CHTTP2_IF_TRACING(
gpr_log(GPR_DEBUG, "set connectivity_state=%d", state));
- grpc_connectivity_state_set(exec_ctx, &t->channel_callback.state_tracker,
- state, error, reason);
+ grpc_connectivity_state_set(&t->channel_callback.state_tracker, state, error,
+ reason);
}
/*******************************************************************************
* POLLSET STUFF
*/
-static void set_pollset(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
- grpc_stream* gs, grpc_pollset* pollset) {
+static void set_pollset(grpc_transport* gt, grpc_stream* gs,
+ grpc_pollset* pollset) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
- grpc_endpoint_add_to_pollset(exec_ctx, t->ep, pollset);
+ grpc_endpoint_add_to_pollset(t->ep, pollset);
}
-static void set_pollset_set(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
- grpc_stream* gs, grpc_pollset_set* pollset_set) {
+static void set_pollset_set(grpc_transport* gt, grpc_stream* gs,
+ grpc_pollset_set* pollset_set) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
- grpc_endpoint_add_to_pollset_set(exec_ctx, t->ep, pollset_set);
+ grpc_endpoint_add_to_pollset_set(t->ep, pollset_set);
}
/*******************************************************************************
* BYTE STREAM
*/
-static void reset_byte_stream(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void reset_byte_stream(void* arg, grpc_error* error) {
grpc_chttp2_stream* s = (grpc_chttp2_stream*)arg;
s->pending_byte_stream = false;
if (error == GRPC_ERROR_NONE) {
- grpc_chttp2_maybe_complete_recv_message(exec_ctx, s->t, s);
- grpc_chttp2_maybe_complete_recv_trailing_metadata(exec_ctx, s->t, s);
+ grpc_chttp2_maybe_complete_recv_message(s->t, s);
+ grpc_chttp2_maybe_complete_recv_trailing_metadata(s->t, s);
} else {
GPR_ASSERT(error != GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(exec_ctx, s->on_next, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(s->on_next, GRPC_ERROR_REF(error));
s->on_next = nullptr;
GRPC_ERROR_UNREF(s->byte_stream_error);
s->byte_stream_error = GRPC_ERROR_NONE;
- grpc_chttp2_cancel_stream(exec_ctx, s->t, s, GRPC_ERROR_REF(error));
+ grpc_chttp2_cancel_stream(s->t, s, GRPC_ERROR_REF(error));
s->byte_stream_error = GRPC_ERROR_REF(error);
}
}
-static void incoming_byte_stream_unref(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_incoming_byte_stream* bs) {
+static void incoming_byte_stream_unref(grpc_chttp2_incoming_byte_stream* bs) {
if (gpr_unref(&bs->refs)) {
gpr_free(bs);
}
}
-static void incoming_byte_stream_next_locked(grpc_exec_ctx* exec_ctx,
- void* argp,
+static void incoming_byte_stream_next_locked(void* argp,
grpc_error* error_ignored) {
grpc_chttp2_incoming_byte_stream* bs =
(grpc_chttp2_incoming_byte_stream*)argp;
@@ -2847,30 +2713,29 @@ static void incoming_byte_stream_next_locked(grpc_exec_ctx* exec_ctx,
if (!s->read_closed) {
s->flow_control->IncomingByteStreamUpdate(bs->next_action.max_size_hint,
cur_length);
- grpc_chttp2_act_on_flowctl_action(exec_ctx, s->flow_control->MakeAction(),
- t, s);
+ grpc_chttp2_act_on_flowctl_action(s->flow_control->MakeAction(), t, s);
}
GPR_ASSERT(s->unprocessed_incoming_frames_buffer.length == 0);
if (s->frame_storage.length > 0) {
grpc_slice_buffer_swap(&s->frame_storage,
&s->unprocessed_incoming_frames_buffer);
s->unprocessed_incoming_frames_decompressed = false;
- GRPC_CLOSURE_SCHED(exec_ctx, bs->next_action.on_complete, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(bs->next_action.on_complete, GRPC_ERROR_NONE);
} else if (s->byte_stream_error != GRPC_ERROR_NONE) {
- GRPC_CLOSURE_SCHED(exec_ctx, bs->next_action.on_complete,
+ GRPC_CLOSURE_SCHED(bs->next_action.on_complete,
GRPC_ERROR_REF(s->byte_stream_error));
if (s->data_parser.parsing_frame != nullptr) {
- incoming_byte_stream_unref(exec_ctx, s->data_parser.parsing_frame);
+ incoming_byte_stream_unref(s->data_parser.parsing_frame);
s->data_parser.parsing_frame = nullptr;
}
} else if (s->read_closed) {
if (bs->remaining_bytes != 0) {
s->byte_stream_error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message");
- GRPC_CLOSURE_SCHED(exec_ctx, bs->next_action.on_complete,
+ GRPC_CLOSURE_SCHED(bs->next_action.on_complete,
GRPC_ERROR_REF(s->byte_stream_error));
if (s->data_parser.parsing_frame != nullptr) {
- incoming_byte_stream_unref(exec_ctx, s->data_parser.parsing_frame);
+ incoming_byte_stream_unref(s->data_parser.parsing_frame);
s->data_parser.parsing_frame = nullptr;
}
} else {
@@ -2880,11 +2745,10 @@ static void incoming_byte_stream_next_locked(grpc_exec_ctx* exec_ctx,
} else {
s->on_next = bs->next_action.on_complete;
}
- incoming_byte_stream_unref(exec_ctx, bs);
+ incoming_byte_stream_unref(bs);
}
-static bool incoming_byte_stream_next(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream,
+static bool incoming_byte_stream_next(grpc_byte_stream* byte_stream,
size_t max_size_hint,
grpc_closure* on_complete) {
GPR_TIMER_BEGIN("incoming_byte_stream_next", 0);
@@ -2899,7 +2763,6 @@ static bool incoming_byte_stream_next(grpc_exec_ctx* exec_ctx,
bs->next_action.max_size_hint = max_size_hint;
bs->next_action.on_complete = on_complete;
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_INIT(&bs->next_action.closure,
incoming_byte_stream_next_locked, bs,
grpc_combiner_scheduler(bs->transport->combiner)),
@@ -2909,8 +2772,7 @@ static bool incoming_byte_stream_next(grpc_exec_ctx* exec_ctx,
}
}
-static grpc_error* incoming_byte_stream_pull(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream,
+static grpc_error* incoming_byte_stream_pull(grpc_byte_stream* byte_stream,
grpc_slice* slice) {
GPR_TIMER_BEGIN("incoming_byte_stream_pull", 0);
grpc_chttp2_incoming_byte_stream* bs =
@@ -2946,31 +2808,28 @@ 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, nullptr);
+ &s->data_parser, s, &s->unprocessed_incoming_frames_buffer, slice,
+ nullptr);
if (error != GRPC_ERROR_NONE) {
return error;
}
} else {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message");
- GRPC_CLOSURE_SCHED(exec_ctx, &s->reset_byte_stream, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(&s->reset_byte_stream, GRPC_ERROR_REF(error));
return error;
}
GPR_TIMER_END("incoming_byte_stream_pull", 0);
return GRPC_ERROR_NONE;
}
-static void incoming_byte_stream_destroy_locked(grpc_exec_ctx* exec_ctx,
- void* byte_stream,
+static void incoming_byte_stream_destroy_locked(void* byte_stream,
grpc_error* error_ignored);
-static void incoming_byte_stream_destroy(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream) {
+static void incoming_byte_stream_destroy(grpc_byte_stream* byte_stream) {
GPR_TIMER_BEGIN("incoming_byte_stream_destroy", 0);
grpc_chttp2_incoming_byte_stream* bs =
(grpc_chttp2_incoming_byte_stream*)byte_stream;
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_INIT(&bs->destroy_action,
incoming_byte_stream_destroy_locked, bs,
grpc_combiner_scheduler(bs->transport->combiner)),
@@ -2979,30 +2838,28 @@ static void incoming_byte_stream_destroy(grpc_exec_ctx* exec_ctx,
}
static void incoming_byte_stream_publish_error(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_byte_stream* bs,
- grpc_error* error) {
+ grpc_chttp2_incoming_byte_stream* bs, grpc_error* error) {
grpc_chttp2_stream* s = bs->stream;
GPR_ASSERT(error != GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(exec_ctx, s->on_next, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(s->on_next, GRPC_ERROR_REF(error));
s->on_next = nullptr;
GRPC_ERROR_UNREF(s->byte_stream_error);
s->byte_stream_error = GRPC_ERROR_REF(error);
- grpc_chttp2_cancel_stream(exec_ctx, bs->transport, bs->stream,
- GRPC_ERROR_REF(error));
+ grpc_chttp2_cancel_stream(bs->transport, bs->stream, GRPC_ERROR_REF(error));
}
grpc_error* grpc_chttp2_incoming_byte_stream_push(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_byte_stream* bs,
- grpc_slice slice, grpc_slice* slice_out) {
+ grpc_chttp2_incoming_byte_stream* bs, grpc_slice slice,
+ grpc_slice* slice_out) {
grpc_chttp2_stream* s = bs->stream;
if (bs->remaining_bytes < GRPC_SLICE_LENGTH(slice)) {
grpc_error* error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many bytes in stream");
- GRPC_CLOSURE_SCHED(exec_ctx, &s->reset_byte_stream, GRPC_ERROR_REF(error));
- grpc_slice_unref_internal(exec_ctx, slice);
+ GRPC_CLOSURE_SCHED(&s->reset_byte_stream, GRPC_ERROR_REF(error));
+ grpc_slice_unref_internal(slice);
return error;
} else {
bs->remaining_bytes -= (uint32_t)GRPC_SLICE_LENGTH(slice);
@@ -3014,8 +2871,8 @@ grpc_error* grpc_chttp2_incoming_byte_stream_push(
}
grpc_error* grpc_chttp2_incoming_byte_stream_finished(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_byte_stream* bs,
- grpc_error* error, bool reset_on_error) {
+ grpc_chttp2_incoming_byte_stream* bs, grpc_error* error,
+ bool reset_on_error) {
grpc_chttp2_stream* s = bs->stream;
if (error == GRPC_ERROR_NONE) {
@@ -3024,27 +2881,25 @@ grpc_error* grpc_chttp2_incoming_byte_stream_finished(
}
}
if (error != GRPC_ERROR_NONE && reset_on_error) {
- GRPC_CLOSURE_SCHED(exec_ctx, &s->reset_byte_stream, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(&s->reset_byte_stream, GRPC_ERROR_REF(error));
}
- incoming_byte_stream_unref(exec_ctx, bs);
+ incoming_byte_stream_unref(bs);
return error;
}
-static void incoming_byte_stream_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream,
+static void incoming_byte_stream_shutdown(grpc_byte_stream* byte_stream,
grpc_error* error) {
grpc_chttp2_incoming_byte_stream* bs =
(grpc_chttp2_incoming_byte_stream*)byte_stream;
GRPC_ERROR_UNREF(grpc_chttp2_incoming_byte_stream_finished(
- exec_ctx, bs, error, true /* reset_on_error */));
+ bs, error, true /* reset_on_error */));
}
static const grpc_byte_stream_vtable grpc_chttp2_incoming_byte_stream_vtable = {
incoming_byte_stream_next, incoming_byte_stream_pull,
incoming_byte_stream_shutdown, incoming_byte_stream_destroy};
-static void incoming_byte_stream_destroy_locked(grpc_exec_ctx* exec_ctx,
- void* byte_stream,
+static void incoming_byte_stream_destroy_locked(void* byte_stream,
grpc_error* error_ignored) {
grpc_chttp2_incoming_byte_stream* bs =
(grpc_chttp2_incoming_byte_stream*)byte_stream;
@@ -3052,15 +2907,15 @@ static void incoming_byte_stream_destroy_locked(grpc_exec_ctx* exec_ctx,
grpc_chttp2_transport* t = s->t;
GPR_ASSERT(bs->base.vtable == &grpc_chttp2_incoming_byte_stream_vtable);
- incoming_byte_stream_unref(exec_ctx, bs);
+ incoming_byte_stream_unref(bs);
s->pending_byte_stream = false;
- grpc_chttp2_maybe_complete_recv_message(exec_ctx, t, s);
- grpc_chttp2_maybe_complete_recv_trailing_metadata(exec_ctx, t, s);
+ grpc_chttp2_maybe_complete_recv_message(t, s);
+ grpc_chttp2_maybe_complete_recv_trailing_metadata(t, s);
}
grpc_chttp2_incoming_byte_stream* grpc_chttp2_incoming_byte_stream_create(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t, grpc_chttp2_stream* s,
- uint32_t frame_size, uint32_t flags) {
+ grpc_chttp2_transport* t, grpc_chttp2_stream* s, uint32_t frame_size,
+ uint32_t flags) {
grpc_chttp2_incoming_byte_stream* incoming_byte_stream =
(grpc_chttp2_incoming_byte_stream*)gpr_malloc(
sizeof(*incoming_byte_stream));
@@ -3080,30 +2935,25 @@ grpc_chttp2_incoming_byte_stream* grpc_chttp2_incoming_byte_stream_create(
* RESOURCE QUOTAS
*/
-static void post_benign_reclaimer(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t) {
+static void post_benign_reclaimer(grpc_chttp2_transport* t) {
if (!t->benign_reclaimer_registered) {
t->benign_reclaimer_registered = true;
GRPC_CHTTP2_REF_TRANSPORT(t, "benign_reclaimer");
- grpc_resource_user_post_reclaimer(exec_ctx,
- grpc_endpoint_get_resource_user(t->ep),
+ grpc_resource_user_post_reclaimer(grpc_endpoint_get_resource_user(t->ep),
false, &t->benign_reclaimer_locked);
}
}
-static void post_destructive_reclaimer(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t) {
+static void post_destructive_reclaimer(grpc_chttp2_transport* t) {
if (!t->destructive_reclaimer_registered) {
t->destructive_reclaimer_registered = true;
GRPC_CHTTP2_REF_TRANSPORT(t, "destructive_reclaimer");
- grpc_resource_user_post_reclaimer(exec_ctx,
- grpc_endpoint_get_resource_user(t->ep),
+ grpc_resource_user_post_reclaimer(grpc_endpoint_get_resource_user(t->ep),
true, &t->destructive_reclaimer_locked);
}
}
-static void benign_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void benign_reclaimer_locked(void* arg, grpc_error* error) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
if (error == GRPC_ERROR_NONE &&
grpc_chttp2_stream_map_size(&t->stream_map) == 0) {
@@ -3113,7 +2963,7 @@ static void benign_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* arg,
gpr_log(GPR_DEBUG, "HTTP2: %s - send goaway to free memory",
t->peer_string);
}
- send_goaway(exec_ctx, t,
+ send_goaway(t,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Buffers full"),
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM));
@@ -3127,13 +2977,12 @@ static void benign_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* arg,
t->benign_reclaimer_registered = false;
if (error != GRPC_ERROR_CANCELLED) {
grpc_resource_user_finish_reclamation(
- exec_ctx, grpc_endpoint_get_resource_user(t->ep));
+ grpc_endpoint_get_resource_user(t->ep));
}
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "benign_reclaimer");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "benign_reclaimer");
}
-static void destructive_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void destructive_reclaimer_locked(void* arg, grpc_error* error) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
size_t n = grpc_chttp2_stream_map_size(&t->stream_map);
t->destructive_reclaimer_registered = false;
@@ -3145,7 +2994,7 @@ static void destructive_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* arg,
s->id);
}
grpc_chttp2_cancel_stream(
- exec_ctx, t, s,
+ t, s,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Buffers full"),
GRPC_ERROR_INT_HTTP2_ERROR,
GRPC_HTTP2_ENHANCE_YOUR_CALM));
@@ -3154,14 +3003,14 @@ static void destructive_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* arg,
there are more streams left, we can immediately post a new
reclaimer in case the resource quota needs to free more
memory */
- post_destructive_reclaimer(exec_ctx, t);
+ post_destructive_reclaimer(t);
}
}
if (error != GRPC_ERROR_CANCELLED) {
grpc_resource_user_finish_reclamation(
- exec_ctx, grpc_endpoint_get_resource_user(t->ep));
+ grpc_endpoint_get_resource_user(t->ep));
}
- GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "destructive_reclaimer");
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "destructive_reclaimer");
}
/*******************************************************************************
@@ -3215,8 +3064,7 @@ const char* grpc_chttp2_initiate_write_reason_string(
GPR_UNREACHABLE_CODE(return "unknown");
}
-static grpc_endpoint* chttp2_get_endpoint(grpc_exec_ctx* exec_ctx,
- grpc_transport* t) {
+static grpc_endpoint* chttp2_get_endpoint(grpc_transport* t) {
return ((grpc_chttp2_transport*)t)->ep;
}
@@ -3234,16 +3082,14 @@ static const grpc_transport_vtable vtable = {sizeof(grpc_chttp2_stream),
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) {
+ const grpc_channel_args* channel_args, grpc_endpoint* ep, int is_client) {
grpc_chttp2_transport* t =
(grpc_chttp2_transport*)gpr_zalloc(sizeof(grpc_chttp2_transport));
- init_transport(exec_ctx, t, channel_args, ep, is_client != 0);
+ init_transport(t, channel_args, ep, is_client != 0);
return &t->base;
}
-void grpc_chttp2_transport_start_reading(grpc_exec_ctx* exec_ctx,
- grpc_transport* transport,
+void grpc_chttp2_transport_start_reading(grpc_transport* transport,
grpc_slice_buffer* read_buffer) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)transport;
GRPC_CHTTP2_REF_TRANSPORT(
@@ -3252,5 +3098,5 @@ void grpc_chttp2_transport_start_reading(grpc_exec_ctx* exec_ctx,
grpc_slice_buffer_move_into(read_buffer, &t->read_buffer);
gpr_free(read_buffer);
}
- GRPC_CLOSURE_SCHED(exec_ctx, &t->read_action_locked, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&t->read_action_locked, GRPC_ERROR_NONE);
}
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.h b/src/core/ext/transport/chttp2/transport/chttp2_transport.h
index 972104f62c..39a4de53cf 100644
--- a/src/core/ext/transport/chttp2/transport/chttp2_transport.h
+++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.h
@@ -36,13 +36,11 @@ extern grpc_tracer_flag grpc_trace_chttp2_refcount;
#endif
grpc_transport* grpc_create_chttp2_transport(
- grpc_exec_ctx* exec_ctx, const grpc_channel_args* channel_args,
- grpc_endpoint* ep, int is_client);
+ const grpc_channel_args* channel_args, grpc_endpoint* ep, int 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,
+void grpc_chttp2_transport_start_reading(grpc_transport* transport,
grpc_slice_buffer* read_buffer);
#ifdef __cplusplus
diff --git a/src/core/ext/transport/chttp2/transport/flow_control.cc b/src/core/ext/transport/chttp2/transport/flow_control.cc
index 64f6b3c917..14f089859e 100644
--- a/src/core/ext/transport/chttp2/transport/flow_control.cc
+++ b/src/core/ext/transport/chttp2/transport/flow_control.cc
@@ -147,8 +147,7 @@ void FlowControlAction::Trace(grpc_chttp2_transport* t) const {
gpr_free(mf_str);
}
-TransportFlowControl::TransportFlowControl(grpc_exec_ctx* exec_ctx,
- const grpc_chttp2_transport* t,
+TransportFlowControl::TransportFlowControl(const grpc_chttp2_transport* t,
bool enable_bdp_probe)
: t_(t),
enable_bdp_probe_(enable_bdp_probe),
@@ -161,7 +160,7 @@ TransportFlowControl::TransportFlowControl(grpc_exec_ctx* exec_ctx,
.set_min_control_value(-1)
.set_max_control_value(25)
.set_integral_range(10)),
- last_pid_update_(grpc_exec_ctx_now(exec_ctx)) {}
+ last_pid_update_(grpc_core::ExecCtx::Get()->Now()) {}
uint32_t TransportFlowControl::MaybeSendUpdate(bool writing_anyway) {
FlowControlTrace trace("t updt sent", this, nullptr);
@@ -306,9 +305,8 @@ double TransportFlowControl::TargetLogBdp() {
1 + log2(bdp_estimator_.EstimateBdp()));
}
-double TransportFlowControl::SmoothLogBdp(grpc_exec_ctx* exec_ctx,
- double value) {
- grpc_millis now = grpc_exec_ctx_now(exec_ctx);
+double TransportFlowControl::SmoothLogBdp(double value) {
+ grpc_millis now = grpc_core::ExecCtx::Get()->Now();
double bdp_error = value - pid_controller_.last_control_value();
const double dt = (double)(now - last_pid_update_) * 1e-3;
last_pid_update_ = now;
@@ -327,15 +325,14 @@ FlowControlAction::Urgency TransportFlowControl::DeltaUrgency(
}
}
-FlowControlAction TransportFlowControl::PeriodicUpdate(
- grpc_exec_ctx* exec_ctx) {
+FlowControlAction TransportFlowControl::PeriodicUpdate() {
FlowControlAction action;
if (enable_bdp_probe_) {
// get bdp estimate and update initial_window accordingly.
// target might change based on how much memory pressure we are under
// TODO(ncteisen): experiment with setting target to be huge under low
// memory pressure.
- const double target = pow(2, SmoothLogBdp(exec_ctx, TargetLogBdp()));
+ const double target = pow(2, SmoothLogBdp(TargetLogBdp()));
// Though initial window 'could' drop to 0, we keep the floor at 128
target_initial_window_size_ = (int32_t)GPR_CLAMP(target, 128, INT32_MAX);
diff --git a/src/core/ext/transport/chttp2/transport/flow_control.h b/src/core/ext/transport/chttp2/transport/flow_control.h
index 7dd348ed5f..c705a22d2e 100644
--- a/src/core/ext/transport/chttp2/transport/flow_control.h
+++ b/src/core/ext/transport/chttp2/transport/flow_control.h
@@ -133,8 +133,7 @@ class FlowControlTrace {
class TransportFlowControl {
public:
- TransportFlowControl(grpc_exec_ctx* exec_ctx, const grpc_chttp2_transport* t,
- bool enable_bdp_probe);
+ TransportFlowControl(const grpc_chttp2_transport* t, bool enable_bdp_probe);
~TransportFlowControl() {}
bool bdp_probe() const { return enable_bdp_probe_; }
@@ -152,7 +151,7 @@ class TransportFlowControl {
// Call periodically (at a low-ish rate, 100ms - 10s makes sense)
// to perform more complex flow control calculations and return an action
// to let chttp2 change its parameters
- FlowControlAction PeriodicUpdate(grpc_exec_ctx* exec_ctx);
+ FlowControlAction PeriodicUpdate();
void StreamSentData(int64_t size) { remote_window_ -= size; }
@@ -211,7 +210,7 @@ class TransportFlowControl {
private:
friend class ::grpc::testing::TrickledCHTTP2;
double TargetLogBdp();
- double SmoothLogBdp(grpc_exec_ctx* exec_ctx, double value);
+ double SmoothLogBdp(double value);
FlowControlAction::Urgency DeltaUrgency(int32_t value,
grpc_chttp2_setting_id setting_id);
diff --git a/src/core/ext/transport/chttp2/transport/frame_data.cc b/src/core/ext/transport/chttp2/transport/frame_data.cc
index f0c3b55792..9b3a6acc9e 100644
--- a/src/core/ext/transport/chttp2/transport/frame_data.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_data.cc
@@ -36,11 +36,10 @@ grpc_error* grpc_chttp2_data_parser_init(grpc_chttp2_data_parser* parser) {
return GRPC_ERROR_NONE;
}
-void grpc_chttp2_data_parser_destroy(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_data_parser* parser) {
+void grpc_chttp2_data_parser_destroy(grpc_chttp2_data_parser* parser) {
if (parser->parsing_frame != nullptr) {
GRPC_ERROR_UNREF(grpc_chttp2_incoming_byte_stream_finished(
- exec_ctx, parser->parsing_frame,
+ parser->parsing_frame,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Parser destroyed"), false));
}
GRPC_ERROR_UNREF(parser->error);
@@ -98,7 +97,7 @@ void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer* inbuf,
}
grpc_error* grpc_deframe_unprocessed_incoming_frames(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_data_parser* p, grpc_chttp2_stream* s,
+ grpc_chttp2_data_parser* p, grpc_chttp2_stream* s,
grpc_slice_buffer* slices, grpc_slice* slice_out,
grpc_byte_stream** stream_out) {
grpc_error* error = GRPC_ERROR_NONE;
@@ -118,14 +117,14 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
char* msg;
if (cur == end) {
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
continue;
}
switch (p->state) {
case GRPC_CHTTP2_DATA_ERROR:
p->state = GRPC_CHTTP2_DATA_ERROR;
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
return GRPC_ERROR_REF(p->error);
case GRPC_CHTTP2_DATA_FH_0:
s->stats.incoming.framing_bytes++;
@@ -150,12 +149,12 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
p->error =
grpc_error_set_int(p->error, GRPC_ERROR_INT_OFFSET, cur - beg);
p->state = GRPC_CHTTP2_DATA_ERROR;
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
return GRPC_ERROR_REF(p->error);
}
if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_1;
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
continue;
}
/* fallthrough */
@@ -164,7 +163,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
p->frame_size = ((uint32_t)*cur) << 24;
if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_2;
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
continue;
}
/* fallthrough */
@@ -173,7 +172,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
p->frame_size |= ((uint32_t)*cur) << 16;
if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_3;
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
continue;
}
/* fallthrough */
@@ -182,7 +181,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
p->frame_size |= ((uint32_t)*cur) << 8;
if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_4;
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
continue;
}
/* fallthrough */
@@ -198,11 +197,11 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
message_flags |= GRPC_WRITE_INTERNAL_COMPRESS;
}
p->parsing_frame = grpc_chttp2_incoming_byte_stream_create(
- exec_ctx, t, s, p->frame_size, message_flags);
+ t, s, p->frame_size, message_flags);
*stream_out = &p->parsing_frame->base;
if (p->parsing_frame->remaining_bytes == 0) {
GRPC_ERROR_UNREF(grpc_chttp2_incoming_byte_stream_finished(
- exec_ctx, p->parsing_frame, GRPC_ERROR_NONE, true));
+ p->parsing_frame, GRPC_ERROR_NONE, true));
p->parsing_frame = nullptr;
p->state = GRPC_CHTTP2_DATA_FH_0;
}
@@ -213,64 +212,64 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
slices,
grpc_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
}
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
return GRPC_ERROR_NONE;
case GRPC_CHTTP2_DATA_FRAME: {
GPR_ASSERT(p->parsing_frame != nullptr);
GPR_ASSERT(slice_out != nullptr);
if (cur == end) {
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
continue;
}
uint32_t remaining = (uint32_t)(end - cur);
if (remaining == p->frame_size) {
s->stats.incoming.data_bytes += remaining;
if (GRPC_ERROR_NONE != (error = grpc_chttp2_incoming_byte_stream_push(
- exec_ctx, p->parsing_frame,
+ p->parsing_frame,
grpc_slice_sub(slice, (size_t)(cur - beg),
(size_t)(end - beg)),
slice_out))) {
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
return error;
}
if (GRPC_ERROR_NONE !=
(error = grpc_chttp2_incoming_byte_stream_finished(
- exec_ctx, p->parsing_frame, GRPC_ERROR_NONE, true))) {
- grpc_slice_unref_internal(exec_ctx, slice);
+ p->parsing_frame, GRPC_ERROR_NONE, true))) {
+ grpc_slice_unref_internal(slice);
return error;
}
p->parsing_frame = nullptr;
p->state = GRPC_CHTTP2_DATA_FH_0;
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
return GRPC_ERROR_NONE;
} else if (remaining < p->frame_size) {
s->stats.incoming.data_bytes += remaining;
if (GRPC_ERROR_NONE != (error = grpc_chttp2_incoming_byte_stream_push(
- exec_ctx, p->parsing_frame,
+ p->parsing_frame,
grpc_slice_sub(slice, (size_t)(cur - beg),
(size_t)(end - beg)),
slice_out))) {
return error;
}
p->frame_size -= remaining;
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
return GRPC_ERROR_NONE;
} else {
GPR_ASSERT(remaining > p->frame_size);
s->stats.incoming.data_bytes += p->frame_size;
if (GRPC_ERROR_NONE !=
(grpc_chttp2_incoming_byte_stream_push(
- exec_ctx, p->parsing_frame,
+ p->parsing_frame,
grpc_slice_sub(slice, (size_t)(cur - beg),
(size_t)(cur + p->frame_size - beg)),
slice_out))) {
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
return error;
}
if (GRPC_ERROR_NONE !=
(error = grpc_chttp2_incoming_byte_stream_finished(
- exec_ctx, p->parsing_frame, GRPC_ERROR_NONE, true))) {
- grpc_slice_unref_internal(exec_ctx, slice);
+ p->parsing_frame, GRPC_ERROR_NONE, true))) {
+ grpc_slice_unref_internal(slice);
return error;
}
p->parsing_frame = nullptr;
@@ -279,7 +278,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
grpc_slice_buffer_undo_take_first(
slices,
grpc_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
return GRPC_ERROR_NONE;
}
}
@@ -289,19 +288,19 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
return GRPC_ERROR_NONE;
}
-grpc_error* grpc_chttp2_data_parser_parse(grpc_exec_ctx* exec_ctx, void* parser,
+grpc_error* grpc_chttp2_data_parser_parse(void* parser,
grpc_chttp2_transport* t,
grpc_chttp2_stream* s,
grpc_slice slice, int is_last) {
if (!s->pending_byte_stream) {
grpc_slice_ref_internal(slice);
grpc_slice_buffer_add(&s->frame_storage, slice);
- grpc_chttp2_maybe_complete_recv_message(exec_ctx, t, s);
+ grpc_chttp2_maybe_complete_recv_message(t, s);
} else if (s->on_next) {
GPR_ASSERT(s->frame_storage.length == 0);
grpc_slice_ref_internal(slice);
grpc_slice_buffer_add(&s->unprocessed_incoming_frames_buffer, slice);
- GRPC_CLOSURE_SCHED(exec_ctx, s->on_next, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(s->on_next, GRPC_ERROR_NONE);
s->on_next = nullptr;
s->unprocessed_incoming_frames_decompressed = false;
} else {
@@ -310,8 +309,7 @@ grpc_error* grpc_chttp2_data_parser_parse(grpc_exec_ctx* exec_ctx, void* parser,
}
if (is_last && s->received_last_frame) {
- grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, false,
- GRPC_ERROR_NONE);
+ grpc_chttp2_mark_stream_closed(t, s, true, false, GRPC_ERROR_NONE);
}
return GRPC_ERROR_NONE;
diff --git a/src/core/ext/transport/chttp2/transport/frame_data.h b/src/core/ext/transport/chttp2/transport/frame_data.h
index 96f823a0ad..928e56ff80 100644
--- a/src/core/ext/transport/chttp2/transport/frame_data.h
+++ b/src/core/ext/transport/chttp2/transport/frame_data.h
@@ -58,8 +58,7 @@ typedef struct {
/* initialize per-stream state for data frame parsing */
grpc_error* grpc_chttp2_data_parser_init(grpc_chttp2_data_parser* parser);
-void grpc_chttp2_data_parser_destroy(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_data_parser* parser);
+void grpc_chttp2_data_parser_destroy(grpc_chttp2_data_parser* parser);
/* start processing a new data frame */
grpc_error* grpc_chttp2_data_parser_begin_frame(grpc_chttp2_data_parser* parser,
@@ -69,7 +68,7 @@ grpc_error* grpc_chttp2_data_parser_begin_frame(grpc_chttp2_data_parser* parser,
/* handle a slice of a data frame - is_last indicates the last slice of a
frame */
-grpc_error* grpc_chttp2_data_parser_parse(grpc_exec_ctx* exec_ctx, void* parser,
+grpc_error* grpc_chttp2_data_parser_parse(void* parser,
grpc_chttp2_transport* t,
grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
@@ -80,7 +79,7 @@ void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer* inbuf,
grpc_slice_buffer* outbuf);
grpc_error* grpc_deframe_unprocessed_incoming_frames(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_data_parser* p, grpc_chttp2_stream* s,
+ grpc_chttp2_data_parser* p, grpc_chttp2_stream* s,
grpc_slice_buffer* slices, grpc_slice* slice_out,
grpc_byte_stream** stream_out);
diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.cc b/src/core/ext/transport/chttp2/transport/frame_goaway.cc
index a2ce709a2e..b60b4227fe 100644
--- a/src/core/ext/transport/chttp2/transport/frame_goaway.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_goaway.cc
@@ -52,8 +52,7 @@ grpc_error* grpc_chttp2_goaway_parser_begin_frame(grpc_chttp2_goaway_parser* p,
return GRPC_ERROR_NONE;
}
-grpc_error* grpc_chttp2_goaway_parser_parse(grpc_exec_ctx* exec_ctx,
- void* parser,
+grpc_error* grpc_chttp2_goaway_parser_parse(void* parser,
grpc_chttp2_transport* t,
grpc_chttp2_stream* s,
grpc_slice slice, int is_last) {
@@ -135,7 +134,7 @@ grpc_error* grpc_chttp2_goaway_parser_parse(grpc_exec_ctx* exec_ctx,
p->state = GRPC_CHTTP2_GOAWAY_DEBUG;
if (is_last) {
grpc_chttp2_add_incoming_goaway(
- exec_ctx, t, (uint32_t)p->error_code,
+ t, (uint32_t)p->error_code,
grpc_slice_new(p->debug_data, p->debug_length, gpr_free));
p->debug_data = nullptr;
}
diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.h b/src/core/ext/transport/chttp2/transport/frame_goaway.h
index 9790d0b08d..be1cf318e1 100644
--- a/src/core/ext/transport/chttp2/transport/frame_goaway.h
+++ b/src/core/ext/transport/chttp2/transport/frame_goaway.h
@@ -54,8 +54,7 @@ void grpc_chttp2_goaway_parser_init(grpc_chttp2_goaway_parser* p);
void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser* p);
grpc_error* grpc_chttp2_goaway_parser_begin_frame(
grpc_chttp2_goaway_parser* parser, uint32_t length, uint8_t flags);
-grpc_error* grpc_chttp2_goaway_parser_parse(grpc_exec_ctx* exec_ctx,
- void* parser,
+grpc_error* grpc_chttp2_goaway_parser_parse(void* parser,
grpc_chttp2_transport* t,
grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.cc b/src/core/ext/transport/chttp2/transport/frame_ping.cc
index d0feb51922..298a56721a 100644
--- a/src/core/ext/transport/chttp2/transport/frame_ping.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_ping.cc
@@ -68,7 +68,7 @@ grpc_error* grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser* parser,
return GRPC_ERROR_NONE;
}
-grpc_error* grpc_chttp2_ping_parser_parse(grpc_exec_ctx* exec_ctx, void* parser,
+grpc_error* grpc_chttp2_ping_parser_parse(void* parser,
grpc_chttp2_transport* t,
grpc_chttp2_stream* s,
grpc_slice slice, int is_last) {
@@ -86,10 +86,10 @@ grpc_error* grpc_chttp2_ping_parser_parse(grpc_exec_ctx* exec_ctx, void* parser,
if (p->byte == 8) {
GPR_ASSERT(is_last);
if (p->is_ack) {
- grpc_chttp2_ack_ping(exec_ctx, t, p->opaque_8bytes);
+ grpc_chttp2_ack_ping(t, p->opaque_8bytes);
} else {
if (!t->is_client) {
- grpc_millis now = grpc_exec_ctx_now(exec_ctx);
+ grpc_millis now = grpc_core::ExecCtx::Get()->Now();
grpc_millis next_allowed_ping =
t->ping_recv_state.last_ping_recv_time +
t->ping_policy.min_recv_ping_interval_without_data;
@@ -104,7 +104,7 @@ grpc_error* grpc_chttp2_ping_parser_parse(grpc_exec_ctx* exec_ctx, void* parser,
}
if (next_allowed_ping > now) {
- grpc_chttp2_add_ping_strike(exec_ctx, t);
+ grpc_chttp2_add_ping_strike(t);
}
t->ping_recv_state.last_ping_recv_time = now;
@@ -116,8 +116,7 @@ grpc_error* grpc_chttp2_ping_parser_parse(grpc_exec_ctx* exec_ctx, void* parser,
t->ping_acks, t->ping_ack_capacity * sizeof(*t->ping_acks));
}
t->ping_acks[t->ping_ack_count++] = p->opaque_8bytes;
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_PING_RESPONSE);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_PING_RESPONSE);
}
}
}
diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.h b/src/core/ext/transport/chttp2/transport/frame_ping.h
index 034aad002e..2da35fff6f 100644
--- a/src/core/ext/transport/chttp2/transport/frame_ping.h
+++ b/src/core/ext/transport/chttp2/transport/frame_ping.h
@@ -37,7 +37,7 @@ grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint64_t opaque_8bytes);
grpc_error* grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser* parser,
uint32_t length, uint8_t flags);
-grpc_error* grpc_chttp2_ping_parser_parse(grpc_exec_ctx* exec_ctx, void* parser,
+grpc_error* grpc_chttp2_ping_parser_parse(void* parser,
grpc_chttp2_transport* t,
grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc b/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc
index 05a7f056a4..fee576678d 100644
--- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc
@@ -69,8 +69,7 @@ grpc_error* grpc_chttp2_rst_stream_parser_begin_frame(
return GRPC_ERROR_NONE;
}
-grpc_error* grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx* exec_ctx,
- void* parser,
+grpc_error* grpc_chttp2_rst_stream_parser_parse(void* parser,
grpc_chttp2_transport* t,
grpc_chttp2_stream* s,
grpc_slice slice, int is_last) {
@@ -103,7 +102,7 @@ grpc_error* grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx* exec_ctx,
GRPC_ERROR_INT_HTTP2_ERROR, (intptr_t)reason);
gpr_free(message);
}
- grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, true, error);
+ grpc_chttp2_mark_stream_closed(t, s, true, true, error);
}
return GRPC_ERROR_NONE;
diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h
index 3f5417e993..30bd0b2803 100644
--- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h
+++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h
@@ -38,8 +38,7 @@ grpc_slice grpc_chttp2_rst_stream_create(uint32_t stream_id, uint32_t code,
grpc_error* grpc_chttp2_rst_stream_parser_begin_frame(
grpc_chttp2_rst_stream_parser* parser, uint32_t length, uint8_t flags);
-grpc_error* grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx* exec_ctx,
- void* parser,
+grpc_error* grpc_chttp2_rst_stream_parser_parse(void* parser,
grpc_chttp2_transport* t,
grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.cc b/src/core/ext/transport/chttp2/transport/frame_settings.cc
index d33da721a5..0761a6e6b3 100644
--- a/src/core/ext/transport/chttp2/transport/frame_settings.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_settings.cc
@@ -108,8 +108,7 @@ grpc_error* grpc_chttp2_settings_parser_begin_frame(
}
}
-grpc_error* grpc_chttp2_settings_parser_parse(grpc_exec_ctx* exec_ctx, void* p,
- grpc_chttp2_transport* t,
+grpc_error* grpc_chttp2_settings_parser_parse(void* p, grpc_chttp2_transport* t,
grpc_chttp2_stream* s,
grpc_slice slice, int is_last) {
grpc_chttp2_settings_parser* parser = (grpc_chttp2_settings_parser*)p;
diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.h b/src/core/ext/transport/chttp2/transport/frame_settings.h
index 18bde92815..642b187ce0 100644
--- a/src/core/ext/transport/chttp2/transport/frame_settings.h
+++ b/src/core/ext/transport/chttp2/transport/frame_settings.h
@@ -56,8 +56,7 @@ grpc_slice grpc_chttp2_settings_ack_create(void);
grpc_error* grpc_chttp2_settings_parser_begin_frame(
grpc_chttp2_settings_parser* parser, uint32_t length, uint8_t flags,
uint32_t* settings);
-grpc_error* grpc_chttp2_settings_parser_parse(grpc_exec_ctx* exec_ctx,
- void* parser,
+grpc_error* grpc_chttp2_settings_parser_parse(void* parser,
grpc_chttp2_transport* t,
grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
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 08407a8e67..418ca144ce 100644
--- a/src/core/ext/transport/chttp2/transport/frame_window_update.cc
+++ b/src/core/ext/transport/chttp2/transport/frame_window_update.cc
@@ -64,9 +64,11 @@ grpc_error* grpc_chttp2_window_update_parser_begin_frame(
return GRPC_ERROR_NONE;
}
-grpc_error* grpc_chttp2_window_update_parser_parse(
- grpc_exec_ctx* exec_ctx, void* parser, grpc_chttp2_transport* t,
- grpc_chttp2_stream* s, grpc_slice slice, int is_last) {
+grpc_error* grpc_chttp2_window_update_parser_parse(void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
+ grpc_slice slice,
+ int is_last) {
uint8_t* const beg = GRPC_SLICE_START_PTR(slice);
uint8_t* const end = GRPC_SLICE_END_PTR(slice);
uint8_t* cur = beg;
@@ -98,10 +100,9 @@ grpc_error* grpc_chttp2_window_update_parser_parse(
if (s != nullptr) {
s->flow_control->RecvUpdate(received_update);
if (grpc_chttp2_list_remove_stalled_by_stream(t, s)) {
- grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
+ grpc_chttp2_mark_stream_writable(t, s);
grpc_chttp2_initiate_write(
- exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_UPDATE);
+ t, GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_UPDATE);
}
}
} else {
@@ -110,8 +111,7 @@ grpc_error* grpc_chttp2_window_update_parser_parse(
bool is_zero = t->flow_control->remote_window() <= 0;
if (was_zero && !is_zero) {
grpc_chttp2_initiate_write(
- exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_TRANSPORT_FLOW_CONTROL_UNSTALLED);
+ t, GRPC_CHTTP2_INITIATE_WRITE_TRANSPORT_FLOW_CONTROL_UNSTALLED);
}
}
}
diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.h b/src/core/ext/transport/chttp2/transport/frame_window_update.h
index daf7d2da6b..f53c6cd5fa 100644
--- a/src/core/ext/transport/chttp2/transport/frame_window_update.h
+++ b/src/core/ext/transport/chttp2/transport/frame_window_update.h
@@ -39,9 +39,11 @@ grpc_slice grpc_chttp2_window_update_create(
grpc_error* grpc_chttp2_window_update_parser_begin_frame(
grpc_chttp2_window_update_parser* parser, uint32_t length, uint8_t flags);
-grpc_error* grpc_chttp2_window_update_parser_parse(
- grpc_exec_ctx* exec_ctx, void* parser, grpc_chttp2_transport* t,
- grpc_chttp2_stream* s, grpc_slice slice, int is_last);
+grpc_error* grpc_chttp2_window_update_parser_parse(void* parser,
+ grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s,
+ grpc_slice slice,
+ int is_last);
#ifdef __cplusplus
}
diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
index e6e4ff24a3..0da7d3ba57 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
+++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
@@ -208,14 +208,12 @@ static uint32_t prepare_space_for_new_elem(grpc_chttp2_hpack_compressor* c,
}
/* dummy function */
-static void add_nothing(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_compressor* c, grpc_mdelem elem,
+static void add_nothing(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem,
size_t elem_size) {}
// Add a key to the dynamic table. Both key and value will be added to table at
// the decoder.
-static void add_key_with_index(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_compressor* c,
+static void add_key_with_index(grpc_chttp2_hpack_compressor* c,
grpc_mdelem elem, uint32_t new_index) {
if (new_index == 0) {
return;
@@ -242,14 +240,12 @@ static void add_key_with_index(grpc_exec_ctx* exec_ctx,
c->indices_keys[HASH_FRAGMENT_3(key_hash)] = new_index;
} else if (c->indices_keys[HASH_FRAGMENT_2(key_hash)] <
c->indices_keys[HASH_FRAGMENT_3(key_hash)]) {
- grpc_slice_unref_internal(exec_ctx,
- c->entries_keys[HASH_FRAGMENT_2(key_hash)]);
+ grpc_slice_unref_internal(c->entries_keys[HASH_FRAGMENT_2(key_hash)]);
c->entries_keys[HASH_FRAGMENT_2(key_hash)] =
grpc_slice_ref_internal(GRPC_MDKEY(elem));
c->indices_keys[HASH_FRAGMENT_2(key_hash)] = new_index;
} else {
- grpc_slice_unref_internal(exec_ctx,
- c->entries_keys[HASH_FRAGMENT_3(key_hash)]);
+ grpc_slice_unref_internal(c->entries_keys[HASH_FRAGMENT_3(key_hash)]);
c->entries_keys[HASH_FRAGMENT_3(key_hash)] =
grpc_slice_ref_internal(GRPC_MDKEY(elem));
c->indices_keys[HASH_FRAGMENT_3(key_hash)] = new_index;
@@ -257,8 +253,7 @@ static void add_key_with_index(grpc_exec_ctx* exec_ctx,
}
/* add an element to the decoder table */
-static void add_elem_with_index(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_compressor* c,
+static void add_elem_with_index(grpc_chttp2_hpack_compressor* c,
grpc_mdelem elem, uint32_t new_index) {
if (new_index == 0) {
return;
@@ -288,35 +283,34 @@ static void add_elem_with_index(grpc_exec_ctx* exec_ctx,
} else if (c->indices_elems[HASH_FRAGMENT_2(elem_hash)] <
c->indices_elems[HASH_FRAGMENT_3(elem_hash)]) {
/* not there: replace oldest */
- GRPC_MDELEM_UNREF(exec_ctx, c->entries_elems[HASH_FRAGMENT_2(elem_hash)]);
+ GRPC_MDELEM_UNREF(c->entries_elems[HASH_FRAGMENT_2(elem_hash)]);
c->entries_elems[HASH_FRAGMENT_2(elem_hash)] = GRPC_MDELEM_REF(elem);
c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index;
} else {
/* not there: replace oldest */
- GRPC_MDELEM_UNREF(exec_ctx, c->entries_elems[HASH_FRAGMENT_3(elem_hash)]);
+ GRPC_MDELEM_UNREF(c->entries_elems[HASH_FRAGMENT_3(elem_hash)]);
c->entries_elems[HASH_FRAGMENT_3(elem_hash)] = GRPC_MDELEM_REF(elem);
c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index;
}
- add_key_with_index(exec_ctx, c, elem, new_index);
+ add_key_with_index(c, elem, new_index);
}
-static void add_elem(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_compressor* c,
- grpc_mdelem elem, size_t elem_size) {
+static void add_elem(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem,
+ size_t elem_size) {
uint32_t new_index = prepare_space_for_new_elem(c, elem_size);
- add_elem_with_index(exec_ctx, c, elem, new_index);
+ add_elem_with_index(c, elem, new_index);
}
-static void add_key(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_compressor* c,
- grpc_mdelem elem, size_t elem_size) {
+static void add_key(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem,
+ size_t elem_size) {
uint32_t new_index = prepare_space_for_new_elem(c, elem_size);
- add_key_with_index(exec_ctx, c, elem, new_index);
+ add_key_with_index(c, elem, new_index);
}
-static void emit_indexed(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_compressor* c, uint32_t elem_index,
+static void emit_indexed(grpc_chttp2_hpack_compressor* c, uint32_t elem_index,
framer_state* st) {
- GRPC_STATS_INC_HPACK_SEND_INDEXED(exec_ctx);
+ GRPC_STATS_INC_HPACK_SEND_INDEXED();
uint32_t len = GRPC_CHTTP2_VARINT_LENGTH(elem_index, 1);
GRPC_CHTTP2_WRITE_VARINT(elem_index, 1, 0x80, add_tiny_header_data(st, len),
len);
@@ -328,18 +322,17 @@ typedef struct {
bool insert_null_before_wire_value;
} wire_value;
-static wire_value get_wire_value(grpc_exec_ctx* exec_ctx, grpc_mdelem elem,
- bool true_binary_enabled) {
+static wire_value get_wire_value(grpc_mdelem elem, bool true_binary_enabled) {
wire_value wire_val;
if (grpc_is_binary_header(GRPC_MDKEY(elem))) {
if (true_binary_enabled) {
- GRPC_STATS_INC_HPACK_SEND_BINARY(exec_ctx);
+ GRPC_STATS_INC_HPACK_SEND_BINARY();
wire_val.huffman_prefix = 0x00;
wire_val.insert_null_before_wire_value = true;
wire_val.data = grpc_slice_ref_internal(GRPC_MDVALUE(elem));
} else {
- GRPC_STATS_INC_HPACK_SEND_BINARY_BASE64(exec_ctx);
+ GRPC_STATS_INC_HPACK_SEND_BINARY_BASE64();
wire_val.huffman_prefix = 0x80;
wire_val.insert_null_before_wire_value = false;
wire_val.data =
@@ -347,7 +340,7 @@ static wire_value get_wire_value(grpc_exec_ctx* exec_ctx, grpc_mdelem elem,
}
} else {
/* TODO(ctiller): opportunistically compress non-binary headers */
- GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(exec_ctx);
+ GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED();
wire_val.huffman_prefix = 0x00;
wire_val.insert_null_before_wire_value = false;
wire_val.data = grpc_slice_ref_internal(GRPC_MDVALUE(elem));
@@ -364,14 +357,12 @@ static void add_wire_value(framer_state* st, wire_value v) {
add_header_data(st, v.data);
}
-static void emit_lithdr_incidx(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_compressor* c,
+static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor* c,
uint32_t key_index, grpc_mdelem elem,
framer_state* st) {
- GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX(exec_ctx);
+ GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX();
uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2);
- wire_value value =
- get_wire_value(exec_ctx, elem, st->use_true_binary_metadata);
+ wire_value value = get_wire_value(elem, st->use_true_binary_metadata);
size_t len_val = wire_value_length(value);
uint32_t len_val_len;
GPR_ASSERT(len_val <= UINT32_MAX);
@@ -383,14 +374,12 @@ static void emit_lithdr_incidx(grpc_exec_ctx* exec_ctx,
add_wire_value(st, value);
}
-static void emit_lithdr_noidx(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_compressor* c,
+static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor* c,
uint32_t key_index, grpc_mdelem elem,
framer_state* st) {
- GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX(exec_ctx);
+ GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX();
uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4);
- wire_value value =
- get_wire_value(exec_ctx, elem, st->use_true_binary_metadata);
+ wire_value value = get_wire_value(elem, st->use_true_binary_metadata);
size_t len_val = wire_value_length(value);
uint32_t len_val_len;
GPR_ASSERT(len_val <= UINT32_MAX);
@@ -402,16 +391,14 @@ static void emit_lithdr_noidx(grpc_exec_ctx* exec_ctx,
add_wire_value(st, value);
}
-static void emit_lithdr_incidx_v(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_compressor* c,
+static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor* c,
uint32_t unused_index, grpc_mdelem elem,
framer_state* st) {
GPR_ASSERT(unused_index == 0);
- GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX_V(exec_ctx);
- GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(exec_ctx);
+ GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX_V();
+ GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED();
uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(GRPC_MDKEY(elem));
- wire_value value =
- get_wire_value(exec_ctx, elem, st->use_true_binary_metadata);
+ wire_value value = get_wire_value(elem, st->use_true_binary_metadata);
uint32_t len_val = (uint32_t)wire_value_length(value);
uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
@@ -426,16 +413,14 @@ static void emit_lithdr_incidx_v(grpc_exec_ctx* exec_ctx,
add_wire_value(st, value);
}
-static void emit_lithdr_noidx_v(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_compressor* c,
+static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor* c,
uint32_t unused_index, grpc_mdelem elem,
framer_state* st) {
GPR_ASSERT(unused_index == 0);
- GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX_V(exec_ctx);
- GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(exec_ctx);
+ GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX_V();
+ GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED();
uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(GRPC_MDKEY(elem));
- wire_value value =
- get_wire_value(exec_ctx, elem, st->use_true_binary_metadata);
+ wire_value value = get_wire_value(elem, st->use_true_binary_metadata);
uint32_t len_val = (uint32_t)wire_value_length(value);
uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
@@ -464,8 +449,8 @@ static uint32_t dynidx(grpc_chttp2_hpack_compressor* c, uint32_t elem_index) {
}
/* encode an mdelem */
-static void hpack_enc(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_compressor* c,
- grpc_mdelem elem, framer_state* st) {
+static void hpack_enc(grpc_chttp2_hpack_compressor* c, grpc_mdelem elem,
+ framer_state* st) {
GPR_ASSERT(GRPC_SLICE_LENGTH(GRPC_MDKEY(elem)) > 0);
if (GRPC_SLICE_START_PTR(GRPC_MDKEY(elem))[0] != ':') { /* regular header */
st->seen_regular_header = 1;
@@ -498,7 +483,7 @@ static void hpack_enc(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_compressor* c,
// Key is not interned, emit literals.
if (!key_interned) {
- emit_lithdr_noidx_v(exec_ctx, c, 0, elem, st);
+ emit_lithdr_noidx_v(c, 0, elem, st);
return;
}
@@ -517,16 +502,16 @@ static void hpack_enc(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_compressor* c,
if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem) &&
c->indices_elems[HASH_FRAGMENT_2(elem_hash)] > c->tail_remote_index) {
/* HIT: complete element (first cuckoo hash) */
- emit_indexed(exec_ctx, c,
- dynidx(c, c->indices_elems[HASH_FRAGMENT_2(elem_hash)]), st);
+ emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_2(elem_hash)]),
+ st);
return;
}
if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_3(elem_hash)], elem) &&
c->indices_elems[HASH_FRAGMENT_3(elem_hash)] > c->tail_remote_index) {
/* HIT: complete element (second cuckoo hash) */
- emit_indexed(exec_ctx, c,
- dynidx(c, c->indices_elems[HASH_FRAGMENT_3(elem_hash)]), st);
+ emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_3(elem_hash)]),
+ st);
return;
}
}
@@ -540,10 +525,10 @@ static void hpack_enc(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_compressor* c,
decoder_space_usage < MAX_DECODER_SPACE_USAGE &&
c->filter_elems[HASH_FRAGMENT_1(elem_hash)] >=
c->filter_elems_sum / ONE_ON_ADD_PROBABILITY;
- void (*maybe_add)(grpc_exec_ctx*, grpc_chttp2_hpack_compressor*, grpc_mdelem,
- size_t) = should_add_elem ? add_elem : add_nothing;
- void (*emit)(grpc_exec_ctx*, grpc_chttp2_hpack_compressor*, uint32_t,
- grpc_mdelem, framer_state*) =
+ void (*maybe_add)(grpc_chttp2_hpack_compressor*, grpc_mdelem, size_t) =
+ should_add_elem ? add_elem : add_nothing;
+ void (*emit)(grpc_chttp2_hpack_compressor*, uint32_t, grpc_mdelem,
+ framer_state*) =
should_add_elem ? emit_lithdr_incidx : emit_lithdr_noidx;
/* no hits for the elem... maybe there's a key? */
@@ -552,8 +537,8 @@ static void hpack_enc(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_compressor* c,
GRPC_MDKEY(elem)) &&
indices_key > c->tail_remote_index) {
/* HIT: key (first cuckoo hash) */
- emit(exec_ctx, c, dynidx(c, indices_key), elem, st);
- maybe_add(exec_ctx, c, elem, decoder_space_usage);
+ emit(c, dynidx(c, indices_key), elem, st);
+ maybe_add(c, elem, decoder_space_usage);
return;
}
@@ -562,8 +547,8 @@ static void hpack_enc(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_compressor* c,
GRPC_MDKEY(elem)) &&
indices_key > c->tail_remote_index) {
/* HIT: key (first cuckoo hash) */
- emit(exec_ctx, c, dynidx(c, indices_key), elem, st);
- maybe_add(exec_ctx, c, elem, decoder_space_usage);
+ emit(c, dynidx(c, indices_key), elem, st);
+ maybe_add(c, elem, decoder_space_usage);
return;
}
@@ -574,24 +559,23 @@ static void hpack_enc(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_compressor* c,
: emit_lithdr_noidx_v;
maybe_add =
should_add_elem ? add_elem : (should_add_key ? add_key : add_nothing);
- emit(exec_ctx, c, 0, elem, st);
- maybe_add(exec_ctx, c, elem, decoder_space_usage);
+ emit(c, 0, elem, st);
+ maybe_add(c, elem, decoder_space_usage);
}
#define STRLEN_LIT(x) (sizeof(x) - 1)
#define TIMEOUT_KEY "grpc-timeout"
-static void deadline_enc(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_compressor* c, grpc_millis deadline,
+static void deadline_enc(grpc_chttp2_hpack_compressor* c, grpc_millis deadline,
framer_state* st) {
char timeout_str[GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE];
grpc_mdelem mdelem;
- grpc_http2_encode_timeout(deadline - grpc_exec_ctx_now(exec_ctx),
+ grpc_http2_encode_timeout(deadline - grpc_core::ExecCtx::Get()->Now(),
timeout_str);
- mdelem = grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_GRPC_TIMEOUT,
+ mdelem = grpc_mdelem_from_slices(GRPC_MDSTR_GRPC_TIMEOUT,
grpc_slice_from_copied_string(timeout_str));
- hpack_enc(exec_ctx, c, mdelem, st);
- GRPC_MDELEM_UNREF(exec_ctx, mdelem);
+ hpack_enc(c, mdelem, st);
+ GRPC_MDELEM_UNREF(mdelem);
}
static uint32_t elems_for_bytes(uint32_t bytes) { return (bytes + 31) / 32; }
@@ -611,14 +595,13 @@ void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor* c) {
}
}
-void grpc_chttp2_hpack_compressor_destroy(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_compressor* c) {
+void grpc_chttp2_hpack_compressor_destroy(grpc_chttp2_hpack_compressor* c) {
int i;
for (i = 0; i < GRPC_CHTTP2_HPACKC_NUM_VALUES; i++) {
if (c->entries_keys[i].refcount != &terminal_slice_refcount) {
- grpc_slice_unref_internal(exec_ctx, c->entries_keys[i]);
+ grpc_slice_unref_internal(c->entries_keys[i]);
}
- GRPC_MDELEM_UNREF(exec_ctx, c->entries_elems[i]);
+ GRPC_MDELEM_UNREF(c->entries_elems[i]);
}
gpr_free(c->table_elem_size);
}
@@ -674,8 +657,7 @@ void grpc_chttp2_hpack_compressor_set_max_table_size(
}
}
-void grpc_chttp2_encode_header(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_compressor* c,
+void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor* c,
grpc_mdelem** extra_headers,
size_t extra_headers_size,
grpc_metadata_batch* metadata,
@@ -701,15 +683,15 @@ void grpc_chttp2_encode_header(grpc_exec_ctx* exec_ctx,
emit_advertise_table_size_change(c, &st);
}
for (size_t i = 0; i < extra_headers_size; ++i) {
- hpack_enc(exec_ctx, c, *extra_headers[i], &st);
+ hpack_enc(c, *extra_headers[i], &st);
}
grpc_metadata_batch_assert_ok(metadata);
for (grpc_linked_mdelem* l = metadata->list.head; l; l = l->next) {
- hpack_enc(exec_ctx, c, l->md, &st);
+ hpack_enc(c, l->md, &st);
}
grpc_millis deadline = metadata->deadline;
if (deadline != GRPC_MILLIS_INF_FUTURE) {
- deadline_enc(exec_ctx, c, deadline, &st);
+ deadline_enc(c, deadline, &st);
}
finish_frame(&st, 1, options->is_eof);
diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.h b/src/core/ext/transport/chttp2/transport/hpack_encoder.h
index fd01d1621a..81bd266e51 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_encoder.h
+++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.h
@@ -72,8 +72,7 @@ typedef struct {
} grpc_chttp2_hpack_compressor;
void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor* c);
-void grpc_chttp2_hpack_compressor_destroy(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_compressor* c);
+void grpc_chttp2_hpack_compressor_destroy(grpc_chttp2_hpack_compressor* c);
void grpc_chttp2_hpack_compressor_set_max_table_size(
grpc_chttp2_hpack_compressor* c, uint32_t max_table_size);
void grpc_chttp2_hpack_compressor_set_max_usable_size(
@@ -87,8 +86,7 @@ typedef struct {
grpc_transport_one_way_stats* stats;
} grpc_encode_header_options;
-void grpc_chttp2_encode_header(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_compressor* c,
+void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor* c,
grpc_mdelem** extra_headers,
size_t extra_headers_size,
grpc_metadata_batch* metadata,
diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc
index 960610eee0..bd9d4c2e34 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc
+++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc
@@ -61,96 +61,69 @@ typedef enum {
a set of indirect jumps, and so not waste stack space. */
/* forward declarations for parsing states */
-static grpc_error* parse_begin(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+static grpc_error* parse_begin(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
const uint8_t* end);
-static grpc_error* parse_error(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+static grpc_error* parse_error(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
const uint8_t* end, grpc_error* error);
-static grpc_error* still_parse_error(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* still_parse_error(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end);
-static grpc_error* parse_illegal_op(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_illegal_op(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end);
-static grpc_error* parse_string_prefix(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_string_prefix(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end);
-static grpc_error* parse_key_string(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_key_string(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end);
static grpc_error* parse_value_string_with_indexed_key(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_parser* p, const uint8_t* cur,
- const uint8_t* end);
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end);
static grpc_error* parse_value_string_with_literal_key(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_parser* p, const uint8_t* cur,
- const uint8_t* end);
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end);
-static grpc_error* parse_value0(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+static grpc_error* parse_value0(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
const uint8_t* end);
-static grpc_error* parse_value1(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+static grpc_error* parse_value1(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
const uint8_t* end);
-static grpc_error* parse_value2(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+static grpc_error* parse_value2(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
const uint8_t* end);
-static grpc_error* parse_value3(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+static grpc_error* parse_value3(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
const uint8_t* end);
-static grpc_error* parse_value4(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+static grpc_error* parse_value4(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
const uint8_t* end);
-static grpc_error* parse_value5up(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_value5up(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end);
-static grpc_error* parse_indexed_field(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_indexed_field(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end);
-static grpc_error* parse_indexed_field_x(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_indexed_field_x(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end);
-static grpc_error* parse_lithdr_incidx(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_lithdr_incidx(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end);
-static grpc_error* parse_lithdr_incidx_x(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_lithdr_incidx_x(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end);
-static grpc_error* parse_lithdr_incidx_v(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_lithdr_incidx_v(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end);
-static grpc_error* parse_lithdr_notidx(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_lithdr_notidx(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end);
-static grpc_error* parse_lithdr_notidx_x(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_lithdr_notidx_x(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end);
-static grpc_error* parse_lithdr_notidx_v(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_lithdr_notidx_v(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end);
-static grpc_error* parse_lithdr_nvridx(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_lithdr_nvridx(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end);
-static grpc_error* parse_lithdr_nvridx_x(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_lithdr_nvridx_x(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end);
-static grpc_error* parse_lithdr_nvridx_v(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_lithdr_nvridx_v(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end);
-static grpc_error* parse_max_tbl_size(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_max_tbl_size(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end);
-static grpc_error* parse_max_tbl_size_x(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_max_tbl_size_x(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end);
/* we translate the first byte of a hpack field into one of these decoding
@@ -649,8 +622,8 @@ 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) {
+static grpc_error* on_hdr(grpc_chttp2_hpack_parser* p, grpc_mdelem md,
+ int add_to_table) {
if (GRPC_TRACER_ON(grpc_http_trace)) {
char* k = grpc_slice_to_c_string(GRPC_MDKEY(md));
char* v = nullptr;
@@ -671,26 +644,25 @@ static grpc_error* on_hdr(grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_parser* p,
if (add_to_table) {
GPR_ASSERT(GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_INTERNED ||
GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_STATIC);
- grpc_error* err = grpc_chttp2_hptbl_add(exec_ctx, &p->table, md);
+ grpc_error* err = grpc_chttp2_hptbl_add(&p->table, md);
if (err != GRPC_ERROR_NONE) return err;
}
if (p->on_header == nullptr) {
- GRPC_MDELEM_UNREF(exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("on_header callback not set");
}
- p->on_header(exec_ctx, p->on_header_user_data, md);
+ p->on_header(p->on_header_user_data, md);
return GRPC_ERROR_NONE;
}
-static grpc_slice take_string(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_slice take_string(grpc_chttp2_hpack_parser* p,
grpc_chttp2_hpack_parser_string* str,
bool intern) {
grpc_slice s;
if (!str->copied) {
if (intern) {
s = grpc_slice_intern(str->data.referenced);
- grpc_slice_unref_internal(exec_ctx, str->data.referenced);
+ grpc_slice_unref_internal(str->data.referenced);
} else {
s = str->data.referenced;
}
@@ -708,85 +680,77 @@ static grpc_slice take_string(grpc_exec_ctx* exec_ctx,
}
/* jump to the next state */
-static grpc_error* parse_next(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+static grpc_error* parse_next(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
const uint8_t* end) {
p->state = *p->next_state++;
- return p->state(exec_ctx, p, cur, end);
+ return p->state(p, cur, end);
}
/* begin parsing a header: all functionality is encoded into lookup tables
above */
-static grpc_error* parse_begin(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+static grpc_error* parse_begin(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
const uint8_t* end) {
if (cur == end) {
p->state = parse_begin;
return GRPC_ERROR_NONE;
}
- return first_byte_action[first_byte_lut[*cur]](exec_ctx, p, cur, end);
+ return first_byte_action[first_byte_lut[*cur]](p, cur, end);
}
/* stream dependency and prioritization data: we just skip it */
-static grpc_error* parse_stream_weight(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_stream_weight(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end) {
if (cur == end) {
p->state = parse_stream_weight;
return GRPC_ERROR_NONE;
}
- return p->after_prioritization(exec_ctx, p, cur + 1, end);
+ return p->after_prioritization(p, cur + 1, end);
}
-static grpc_error* parse_stream_dep3(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_stream_dep3(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end) {
if (cur == end) {
p->state = parse_stream_dep3;
return GRPC_ERROR_NONE;
}
- return parse_stream_weight(exec_ctx, p, cur + 1, end);
+ return parse_stream_weight(p, cur + 1, end);
}
-static grpc_error* parse_stream_dep2(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_stream_dep2(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end) {
if (cur == end) {
p->state = parse_stream_dep2;
return GRPC_ERROR_NONE;
}
- return parse_stream_dep3(exec_ctx, p, cur + 1, end);
+ return parse_stream_dep3(p, cur + 1, end);
}
-static grpc_error* parse_stream_dep1(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_stream_dep1(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end) {
if (cur == end) {
p->state = parse_stream_dep1;
return GRPC_ERROR_NONE;
}
- return parse_stream_dep2(exec_ctx, p, cur + 1, end);
+ return parse_stream_dep2(p, cur + 1, end);
}
-static grpc_error* parse_stream_dep0(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_stream_dep0(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end) {
if (cur == end) {
p->state = parse_stream_dep0;
return GRPC_ERROR_NONE;
}
- return parse_stream_dep1(exec_ctx, p, cur + 1, end);
+ return parse_stream_dep1(p, cur + 1, end);
}
/* emit an indexed field; jumps to begin the next field on completion */
-static grpc_error* finish_indexed_field(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* finish_indexed_field(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end) {
grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
@@ -798,24 +762,22 @@ static grpc_error* finish_indexed_field(grpc_exec_ctx* exec_ctx,
GRPC_ERROR_INT_SIZE, (intptr_t)p->table.num_ents);
}
GRPC_MDELEM_REF(md);
- GRPC_STATS_INC_HPACK_RECV_INDEXED(exec_ctx);
- grpc_error* err = on_hdr(exec_ctx, p, md, 0);
+ GRPC_STATS_INC_HPACK_RECV_INDEXED();
+ grpc_error* err = on_hdr(p, md, 0);
if (err != GRPC_ERROR_NONE) return err;
- return parse_begin(exec_ctx, p, cur, end);
+ return parse_begin(p, cur, end);
}
/* parse an indexed field with index < 127 */
-static grpc_error* parse_indexed_field(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_indexed_field(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end) {
p->dynamic_table_update_allowed = 0;
p->index = (*cur) & 0x7f;
- return finish_indexed_field(exec_ctx, p, cur + 1, end);
+ return finish_indexed_field(p, cur + 1, end);
}
/* parse an indexed field with index >= 127 */
-static grpc_error* parse_indexed_field_x(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_indexed_field_x(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
@@ -824,56 +786,52 @@ static grpc_error* parse_indexed_field_x(grpc_exec_ctx* exec_ctx,
p->next_state = and_then;
p->index = 0x7f;
p->parsing.value = &p->index;
- return parse_value0(exec_ctx, p, cur + 1, end);
+ return parse_value0(p, cur + 1, end);
}
/* finish a literal header with incremental indexing */
-static grpc_error* finish_lithdr_incidx(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* finish_lithdr_incidx(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end) {
grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
GPR_ASSERT(!GRPC_MDISNULL(md)); /* handled in string parsing */
- GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX(exec_ctx);
- grpc_error* err = on_hdr(
- exec_ctx, p,
- grpc_mdelem_from_slices(exec_ctx, grpc_slice_ref_internal(GRPC_MDKEY(md)),
- take_string(exec_ctx, p, &p->value, true)),
- 1);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- return parse_begin(exec_ctx, p, cur, end);
+ GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX();
+ grpc_error* err =
+ on_hdr(p,
+ grpc_mdelem_from_slices(grpc_slice_ref_internal(GRPC_MDKEY(md)),
+ take_string(p, &p->value, true)),
+ 1);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ return parse_begin(p, cur, end);
}
/* finish a literal header with incremental indexing with no index */
-static grpc_error* finish_lithdr_incidx_v(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* finish_lithdr_incidx_v(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end) {
- GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX_V(exec_ctx);
- grpc_error* err = on_hdr(
- exec_ctx, p,
- grpc_mdelem_from_slices(exec_ctx, take_string(exec_ctx, p, &p->key, true),
- take_string(exec_ctx, p, &p->value, true)),
- 1);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- return parse_begin(exec_ctx, p, cur, end);
+ GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX_V();
+ grpc_error* err =
+ on_hdr(p,
+ grpc_mdelem_from_slices(take_string(p, &p->key, true),
+ take_string(p, &p->value, true)),
+ 1);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ return parse_begin(p, cur, end);
}
/* parse a literal header with incremental indexing; index < 63 */
-static grpc_error* parse_lithdr_incidx(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_lithdr_incidx(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_value_string_with_indexed_key, finish_lithdr_incidx};
p->dynamic_table_update_allowed = 0;
p->next_state = and_then;
p->index = (*cur) & 0x3f;
- return parse_string_prefix(exec_ctx, p, cur + 1, end);
+ return parse_string_prefix(p, cur + 1, end);
}
/* parse a literal header with incremental indexing; index >= 63 */
-static grpc_error* parse_lithdr_incidx_x(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_lithdr_incidx_x(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
@@ -883,12 +841,11 @@ static grpc_error* parse_lithdr_incidx_x(grpc_exec_ctx* exec_ctx,
p->next_state = and_then;
p->index = 0x3f;
p->parsing.value = &p->index;
- return parse_value0(exec_ctx, p, cur + 1, end);
+ return parse_value0(p, cur + 1, end);
}
/* parse a literal header with incremental indexing; index = 0 */
-static grpc_error* parse_lithdr_incidx_v(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_lithdr_incidx_v(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
@@ -896,56 +853,52 @@ static grpc_error* parse_lithdr_incidx_v(grpc_exec_ctx* exec_ctx,
parse_value_string_with_literal_key, finish_lithdr_incidx_v};
p->dynamic_table_update_allowed = 0;
p->next_state = and_then;
- return parse_string_prefix(exec_ctx, p, cur + 1, end);
+ return parse_string_prefix(p, cur + 1, end);
}
/* finish a literal header without incremental indexing */
-static grpc_error* finish_lithdr_notidx(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* finish_lithdr_notidx(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end) {
grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
GPR_ASSERT(!GRPC_MDISNULL(md)); /* handled in string parsing */
- GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX(exec_ctx);
- grpc_error* err = on_hdr(
- exec_ctx, p,
- grpc_mdelem_from_slices(exec_ctx, grpc_slice_ref_internal(GRPC_MDKEY(md)),
- take_string(exec_ctx, p, &p->value, false)),
- 0);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- return parse_begin(exec_ctx, p, cur, end);
+ GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX();
+ grpc_error* err =
+ on_hdr(p,
+ grpc_mdelem_from_slices(grpc_slice_ref_internal(GRPC_MDKEY(md)),
+ take_string(p, &p->value, false)),
+ 0);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ return parse_begin(p, cur, end);
}
/* finish a literal header without incremental indexing with index = 0 */
-static grpc_error* finish_lithdr_notidx_v(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* finish_lithdr_notidx_v(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end) {
- GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX_V(exec_ctx);
- grpc_error* err = on_hdr(
- exec_ctx, p,
- grpc_mdelem_from_slices(exec_ctx, take_string(exec_ctx, p, &p->key, true),
- take_string(exec_ctx, p, &p->value, false)),
- 0);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- return parse_begin(exec_ctx, p, cur, end);
+ GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX_V();
+ grpc_error* err =
+ on_hdr(p,
+ grpc_mdelem_from_slices(take_string(p, &p->key, true),
+ take_string(p, &p->value, false)),
+ 0);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ return parse_begin(p, cur, end);
}
/* parse a literal header without incremental indexing; index < 15 */
-static grpc_error* parse_lithdr_notidx(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_lithdr_notidx(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_value_string_with_indexed_key, finish_lithdr_notidx};
p->dynamic_table_update_allowed = 0;
p->next_state = and_then;
p->index = (*cur) & 0xf;
- return parse_string_prefix(exec_ctx, p, cur + 1, end);
+ return parse_string_prefix(p, cur + 1, end);
}
/* parse a literal header without incremental indexing; index >= 15 */
-static grpc_error* parse_lithdr_notidx_x(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_lithdr_notidx_x(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
@@ -955,12 +908,11 @@ static grpc_error* parse_lithdr_notidx_x(grpc_exec_ctx* exec_ctx,
p->next_state = and_then;
p->index = 0xf;
p->parsing.value = &p->index;
- return parse_value0(exec_ctx, p, cur + 1, end);
+ return parse_value0(p, cur + 1, end);
}
/* parse a literal header without incremental indexing; index == 0 */
-static grpc_error* parse_lithdr_notidx_v(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_lithdr_notidx_v(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
@@ -968,56 +920,52 @@ static grpc_error* parse_lithdr_notidx_v(grpc_exec_ctx* exec_ctx,
parse_value_string_with_literal_key, finish_lithdr_notidx_v};
p->dynamic_table_update_allowed = 0;
p->next_state = and_then;
- return parse_string_prefix(exec_ctx, p, cur + 1, end);
+ return parse_string_prefix(p, cur + 1, end);
}
/* finish a literal header that is never indexed */
-static grpc_error* finish_lithdr_nvridx(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* finish_lithdr_nvridx(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end) {
grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
GPR_ASSERT(!GRPC_MDISNULL(md)); /* handled in string parsing */
- GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX(exec_ctx);
- grpc_error* err = on_hdr(
- exec_ctx, p,
- grpc_mdelem_from_slices(exec_ctx, grpc_slice_ref_internal(GRPC_MDKEY(md)),
- take_string(exec_ctx, p, &p->value, false)),
- 0);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- return parse_begin(exec_ctx, p, cur, end);
+ GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX();
+ grpc_error* err =
+ on_hdr(p,
+ grpc_mdelem_from_slices(grpc_slice_ref_internal(GRPC_MDKEY(md)),
+ take_string(p, &p->value, false)),
+ 0);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ return parse_begin(p, cur, end);
}
/* finish a literal header that is never indexed with an extra value */
-static grpc_error* finish_lithdr_nvridx_v(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* finish_lithdr_nvridx_v(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end) {
- GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX_V(exec_ctx);
- grpc_error* err = on_hdr(
- exec_ctx, p,
- grpc_mdelem_from_slices(exec_ctx, take_string(exec_ctx, p, &p->key, true),
- take_string(exec_ctx, p, &p->value, false)),
- 0);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- return parse_begin(exec_ctx, p, cur, end);
+ GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX_V();
+ grpc_error* err =
+ on_hdr(p,
+ grpc_mdelem_from_slices(take_string(p, &p->key, true),
+ take_string(p, &p->value, false)),
+ 0);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ return parse_begin(p, cur, end);
}
/* parse a literal header that is never indexed; index < 15 */
-static grpc_error* parse_lithdr_nvridx(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_lithdr_nvridx(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
parse_value_string_with_indexed_key, finish_lithdr_nvridx};
p->dynamic_table_update_allowed = 0;
p->next_state = and_then;
p->index = (*cur) & 0xf;
- return parse_string_prefix(exec_ctx, p, cur + 1, end);
+ return parse_string_prefix(p, cur + 1, end);
}
/* parse a literal header that is never indexed; index >= 15 */
-static grpc_error* parse_lithdr_nvridx_x(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_lithdr_nvridx_x(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
@@ -1027,12 +975,11 @@ static grpc_error* parse_lithdr_nvridx_x(grpc_exec_ctx* exec_ctx,
p->next_state = and_then;
p->index = 0xf;
p->parsing.value = &p->index;
- return parse_value0(exec_ctx, p, cur + 1, end);
+ return parse_value0(p, cur + 1, end);
}
/* parse a literal header that is never indexed; index == 0 */
-static grpc_error* parse_lithdr_nvridx_v(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_lithdr_nvridx_v(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
@@ -1040,47 +987,44 @@ static grpc_error* parse_lithdr_nvridx_v(grpc_exec_ctx* exec_ctx,
parse_value_string_with_literal_key, finish_lithdr_nvridx_v};
p->dynamic_table_update_allowed = 0;
p->next_state = and_then;
- return parse_string_prefix(exec_ctx, p, cur + 1, end);
+ return parse_string_prefix(p, cur + 1, end);
}
/* finish parsing a max table size change */
-static grpc_error* finish_max_tbl_size(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* finish_max_tbl_size(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end) {
if (GRPC_TRACER_ON(grpc_http_trace)) {
gpr_log(GPR_INFO, "MAX TABLE SIZE: %d", p->index);
}
grpc_error* err =
- grpc_chttp2_hptbl_set_current_table_size(exec_ctx, &p->table, p->index);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- return parse_begin(exec_ctx, p, cur, end);
+ grpc_chttp2_hptbl_set_current_table_size(&p->table, p->index);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ return parse_begin(p, cur, end);
}
/* parse a max table size change, max size < 15 */
-static grpc_error* parse_max_tbl_size(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_max_tbl_size(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end) {
if (p->dynamic_table_update_allowed == 0) {
return parse_error(
- exec_ctx, p, cur, end,
+ p, cur, end,
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"More than two max table size changes in a single frame"));
}
p->dynamic_table_update_allowed--;
p->index = (*cur) & 0x1f;
- return finish_max_tbl_size(exec_ctx, p, cur + 1, end);
+ return finish_max_tbl_size(p, cur + 1, end);
}
/* parse a max table size change, max size >= 15 */
-static grpc_error* parse_max_tbl_size_x(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_max_tbl_size_x(grpc_chttp2_hpack_parser* p,
const uint8_t* cur,
const uint8_t* end) {
static const grpc_chttp2_hpack_parser_state and_then[] = {
finish_max_tbl_size};
if (p->dynamic_table_update_allowed == 0) {
return parse_error(
- exec_ctx, p, cur, end,
+ p, cur, end,
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"More than two max table size changes in a single frame"));
}
@@ -1088,12 +1032,11 @@ static grpc_error* parse_max_tbl_size_x(grpc_exec_ctx* exec_ctx,
p->next_state = and_then;
p->index = 0x1f;
p->parsing.value = &p->index;
- return parse_value0(exec_ctx, p, cur + 1, end);
+ return parse_value0(p, cur + 1, end);
}
/* a parse error: jam the parse state into parse_error, and return error */
-static grpc_error* parse_error(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+static grpc_error* parse_error(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
const uint8_t* end, grpc_error* err) {
GPR_ASSERT(err != GRPC_ERROR_NONE);
if (p->last_error == GRPC_ERROR_NONE) {
@@ -1103,27 +1046,24 @@ static grpc_error* parse_error(grpc_exec_ctx* exec_ctx,
return err;
}
-static grpc_error* still_parse_error(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* still_parse_error(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end) {
return GRPC_ERROR_REF(p->last_error);
}
-static grpc_error* parse_illegal_op(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_illegal_op(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end) {
GPR_ASSERT(cur != end);
char* msg;
gpr_asprintf(&msg, "Illegal hpack op code %d", *cur);
grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
- return parse_error(exec_ctx, p, cur, end, err);
+ return parse_error(p, cur, end, err);
}
/* parse the 1st byte of a varint into p->parsing.value
no overflow is possible */
-static grpc_error* parse_value0(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+static grpc_error* parse_value0(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
const uint8_t* end) {
if (cur == end) {
p->state = parse_value0;
@@ -1133,16 +1073,15 @@ static grpc_error* parse_value0(grpc_exec_ctx* exec_ctx,
*p->parsing.value += (*cur) & 0x7f;
if ((*cur) & 0x80) {
- return parse_value1(exec_ctx, p, cur + 1, end);
+ return parse_value1(p, cur + 1, end);
} else {
- return parse_next(exec_ctx, p, cur + 1, end);
+ return parse_next(p, cur + 1, end);
}
}
/* parse the 2nd byte of a varint into p->parsing.value
no overflow is possible */
-static grpc_error* parse_value1(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+static grpc_error* parse_value1(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
const uint8_t* end) {
if (cur == end) {
p->state = parse_value1;
@@ -1152,16 +1091,15 @@ static grpc_error* parse_value1(grpc_exec_ctx* exec_ctx,
*p->parsing.value += (((uint32_t)*cur) & 0x7f) << 7;
if ((*cur) & 0x80) {
- return parse_value2(exec_ctx, p, cur + 1, end);
+ return parse_value2(p, cur + 1, end);
} else {
- return parse_next(exec_ctx, p, cur + 1, end);
+ return parse_next(p, cur + 1, end);
}
}
/* parse the 3rd byte of a varint into p->parsing.value
no overflow is possible */
-static grpc_error* parse_value2(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+static grpc_error* parse_value2(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
const uint8_t* end) {
if (cur == end) {
p->state = parse_value2;
@@ -1171,16 +1109,15 @@ static grpc_error* parse_value2(grpc_exec_ctx* exec_ctx,
*p->parsing.value += (((uint32_t)*cur) & 0x7f) << 14;
if ((*cur) & 0x80) {
- return parse_value3(exec_ctx, p, cur + 1, end);
+ return parse_value3(p, cur + 1, end);
} else {
- return parse_next(exec_ctx, p, cur + 1, end);
+ return parse_next(p, cur + 1, end);
}
}
/* parse the 4th byte of a varint into p->parsing.value
no overflow is possible */
-static grpc_error* parse_value3(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+static grpc_error* parse_value3(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
const uint8_t* end) {
if (cur == end) {
p->state = parse_value3;
@@ -1190,16 +1127,15 @@ static grpc_error* parse_value3(grpc_exec_ctx* exec_ctx,
*p->parsing.value += (((uint32_t)*cur) & 0x7f) << 21;
if ((*cur) & 0x80) {
- return parse_value4(exec_ctx, p, cur + 1, end);
+ return parse_value4(p, cur + 1, end);
} else {
- return parse_next(exec_ctx, p, cur + 1, end);
+ return parse_next(p, cur + 1, end);
}
}
/* parse the 5th byte of a varint into p->parsing.value
depending on the byte, we may overflow, and care must be taken */
-static grpc_error* parse_value4(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+static grpc_error* parse_value4(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
const uint8_t* end) {
uint8_t c;
uint32_t cur_value;
@@ -1225,9 +1161,9 @@ static grpc_error* parse_value4(grpc_exec_ctx* exec_ctx,
*p->parsing.value = cur_value + add_value;
if ((*cur) & 0x80) {
- return parse_value5up(exec_ctx, p, cur + 1, end);
+ return parse_value5up(p, cur + 1, end);
} else {
- return parse_next(exec_ctx, p, cur + 1, end);
+ return parse_next(p, cur + 1, end);
}
error:
@@ -1237,14 +1173,13 @@ error:
*p->parsing.value, *cur);
grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
- return parse_error(exec_ctx, p, cur, end, err);
+ return parse_error(p, cur, end, err);
}
/* parse any trailing bytes in a varint: it's possible to append an arbitrary
number of 0x80's and not affect the value - a zero will terminate - and
anything else will overflow */
-static grpc_error* parse_value5up(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_value5up(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end) {
while (cur != end && *cur == 0x80) {
++cur;
@@ -1256,7 +1191,7 @@ static grpc_error* parse_value5up(grpc_exec_ctx* exec_ctx,
}
if (*cur == 0) {
- return parse_next(exec_ctx, p, cur + 1, end);
+ return parse_next(p, cur + 1, end);
}
char* msg;
@@ -1266,12 +1201,11 @@ static grpc_error* parse_value5up(grpc_exec_ctx* exec_ctx,
*p->parsing.value, *cur);
grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
- return parse_error(exec_ctx, p, cur, end, err);
+ return parse_error(p, cur, end, err);
}
/* parse a string prefix */
-static grpc_error* parse_string_prefix(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_string_prefix(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end) {
if (cur == end) {
p->state = parse_string_prefix;
@@ -1282,9 +1216,9 @@ static grpc_error* parse_string_prefix(grpc_exec_ctx* exec_ctx,
p->huff = (*cur) >> 7;
if (p->strlen == 0x7f) {
p->parsing.value = &p->strlen;
- return parse_value0(exec_ctx, p, cur + 1, end);
+ return parse_value0(p, cur + 1, end);
} else {
- return parse_next(exec_ctx, p, cur + 1, end);
+ return parse_next(p, cur + 1, end);
}
}
@@ -1303,8 +1237,7 @@ static void append_bytes(grpc_chttp2_hpack_parser_string* str,
str->data.copied.length += (uint32_t)length;
}
-static grpc_error* append_string(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* append_string(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end) {
grpc_chttp2_hpack_parser_string* str = p->parsing.str;
uint32_t bits;
@@ -1322,11 +1255,11 @@ static grpc_error* append_string(grpc_exec_ctx* exec_ctx,
/* 'true-binary' case */
++cur;
p->binary = NOT_BINARY;
- GRPC_STATS_INC_HPACK_RECV_BINARY(exec_ctx);
+ GRPC_STATS_INC_HPACK_RECV_BINARY();
append_bytes(str, cur, (size_t)(end - cur));
return GRPC_ERROR_NONE;
}
- GRPC_STATS_INC_HPACK_RECV_BINARY_BASE64(exec_ctx);
+ GRPC_STATS_INC_HPACK_RECV_BINARY_BASE64();
/* fallthrough */
b64_byte0:
case B64_BYTE0:
@@ -1338,7 +1271,7 @@ static grpc_error* append_string(grpc_exec_ctx* exec_ctx,
++cur;
if (bits == 255)
return parse_error(
- exec_ctx, p, cur, end,
+ p, cur, end,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
else if (bits == 64)
goto b64_byte0;
@@ -1354,7 +1287,7 @@ static grpc_error* append_string(grpc_exec_ctx* exec_ctx,
++cur;
if (bits == 255)
return parse_error(
- exec_ctx, p, cur, end,
+ p, cur, end,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
else if (bits == 64)
goto b64_byte1;
@@ -1370,7 +1303,7 @@ static grpc_error* append_string(grpc_exec_ctx* exec_ctx,
++cur;
if (bits == 255)
return parse_error(
- exec_ctx, p, cur, end,
+ p, cur, end,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
else if (bits == 64)
goto b64_byte2;
@@ -1386,7 +1319,7 @@ static grpc_error* append_string(grpc_exec_ctx* exec_ctx,
++cur;
if (bits == 255)
return parse_error(
- exec_ctx, p, cur, end,
+ p, cur, end,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal base64 character"));
else if (bits == 64)
goto b64_byte3;
@@ -1399,12 +1332,11 @@ static grpc_error* append_string(grpc_exec_ctx* exec_ctx,
goto b64_byte0;
}
GPR_UNREACHABLE_CODE(return parse_error(
- exec_ctx, p, cur, end,
+ p, cur, end,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Should never reach here")));
}
-static grpc_error* finish_str(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+static grpc_error* finish_str(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
const uint8_t* end) {
uint8_t decoded[2];
uint32_t bits;
@@ -1417,7 +1349,7 @@ static grpc_error* finish_str(grpc_exec_ctx* exec_ctx,
case B64_BYTE0:
break;
case B64_BYTE1:
- return parse_error(exec_ctx, p, cur, end,
+ return parse_error(p, cur, end,
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"illegal base64 encoding")); /* illegal encoding */
case B64_BYTE2:
@@ -1428,7 +1360,7 @@ static grpc_error* finish_str(grpc_exec_ctx* exec_ctx,
bits & 0xffff);
grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
- return parse_error(exec_ctx, p, cur, end, err);
+ return parse_error(p, cur, end, err);
}
decoded[0] = (uint8_t)(bits >> 16);
append_bytes(str, decoded, 1);
@@ -1441,7 +1373,7 @@ static grpc_error* finish_str(grpc_exec_ctx* exec_ctx,
bits & 0xff);
grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
- return parse_error(exec_ctx, p, cur, end, err);
+ return parse_error(p, cur, end, err);
}
decoded[0] = (uint8_t)(bits >> 16);
decoded[1] = (uint8_t)(bits >> 8);
@@ -1452,14 +1384,13 @@ static grpc_error* finish_str(grpc_exec_ctx* exec_ctx,
}
/* decode a nibble from a huffman encoded stream */
-static grpc_error* huff_nibble(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p, uint8_t nibble) {
+static grpc_error* huff_nibble(grpc_chttp2_hpack_parser* p, uint8_t nibble) {
int16_t emit = emit_sub_tbl[16 * emit_tbl[p->huff_state] + nibble];
int16_t next = next_sub_tbl[16 * next_tbl[p->huff_state] + nibble];
if (emit != -1) {
if (emit >= 0 && emit < 256) {
uint8_t c = (uint8_t)emit;
- grpc_error* err = append_string(exec_ctx, p, &c, (&c) + 1);
+ grpc_error* err = append_string(p, &c, (&c) + 1);
if (err != GRPC_ERROR_NONE) return err;
} else {
assert(emit == 256);
@@ -1470,45 +1401,42 @@ static grpc_error* huff_nibble(grpc_exec_ctx* exec_ctx,
}
/* decode full bytes from a huffman encoded stream */
-static grpc_error* add_huff_bytes(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* add_huff_bytes(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end) {
for (; cur != end; ++cur) {
- grpc_error* err = huff_nibble(exec_ctx, p, *cur >> 4);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- err = huff_nibble(exec_ctx, p, *cur & 0xf);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
+ grpc_error* err = huff_nibble(p, *cur >> 4);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ err = huff_nibble(p, *cur & 0xf);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
}
return GRPC_ERROR_NONE;
}
/* decode some string bytes based on the current decoding mode
(huffman or not) */
-static grpc_error* add_str_bytes(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* add_str_bytes(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end) {
if (p->huff) {
- return add_huff_bytes(exec_ctx, p, cur, end);
+ return add_huff_bytes(p, cur, end);
} else {
- return append_string(exec_ctx, p, cur, end);
+ return append_string(p, cur, end);
}
}
/* parse a string - tries to do large chunks at a time */
-static grpc_error* parse_string(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p, const uint8_t* cur,
+static grpc_error* parse_string(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
const uint8_t* end) {
size_t remaining = p->strlen - p->strgot;
size_t given = (size_t)(end - cur);
if (remaining <= given) {
- grpc_error* err = add_str_bytes(exec_ctx, p, cur, cur + remaining);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- err = finish_str(exec_ctx, p, cur + remaining, end);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- return parse_next(exec_ctx, p, cur + remaining, end);
+ grpc_error* err = add_str_bytes(p, cur, cur + remaining);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ err = finish_str(p, cur + remaining, end);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ return parse_next(p, cur + remaining, end);
} else {
- grpc_error* err = add_str_bytes(exec_ctx, p, cur, cur + given);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
+ grpc_error* err = add_str_bytes(p, cur, cur + given);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
GPR_ASSERT(given <= UINT32_MAX - p->strgot);
p->strgot += (uint32_t)given;
p->state = parse_string;
@@ -1517,20 +1445,19 @@ static grpc_error* parse_string(grpc_exec_ctx* exec_ctx,
}
/* begin parsing a string - performs setup, calls parse_string */
-static grpc_error* begin_parse_string(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* begin_parse_string(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end,
uint8_t binary,
grpc_chttp2_hpack_parser_string* str) {
if (!p->huff && binary == NOT_BINARY && (end - cur) >= (intptr_t)p->strlen &&
p->current_slice_refcount != nullptr) {
- GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED(exec_ctx);
+ GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED();
str->copied = false;
str->data.referenced.refcount = p->current_slice_refcount;
str->data.referenced.data.refcounted.bytes = (uint8_t*)cur;
str->data.referenced.data.refcounted.length = p->strlen;
grpc_slice_ref_internal(str->data.referenced);
- return parse_next(exec_ctx, p, cur + p->strlen, end);
+ return parse_next(p, cur + p->strlen, end);
}
p->strgot = 0;
str->copied = true;
@@ -1541,9 +1468,9 @@ static grpc_error* begin_parse_string(grpc_exec_ctx* exec_ctx,
switch (p->binary) {
case NOT_BINARY:
if (p->huff) {
- GRPC_STATS_INC_HPACK_RECV_HUFFMAN(exec_ctx);
+ GRPC_STATS_INC_HPACK_RECV_HUFFMAN();
} else {
- GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED(exec_ctx);
+ GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED();
}
break;
case BINARY_BEGIN:
@@ -1552,14 +1479,13 @@ static grpc_error* begin_parse_string(grpc_exec_ctx* exec_ctx,
default:
abort();
}
- return parse_string(exec_ctx, p, cur, end);
+ return parse_string(p, cur, end);
}
/* parse the key string */
-static grpc_error* parse_key_string(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_key_string(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end) {
- return begin_parse_string(exec_ctx, p, cur, end, NOT_BINARY, &p->key);
+ return begin_parse_string(p, cur, end, NOT_BINARY, &p->key);
}
/* check if a key represents a binary header or not */
@@ -1586,33 +1512,29 @@ static grpc_error* is_binary_indexed_header(grpc_chttp2_hpack_parser* p,
}
/* parse the value string */
-static grpc_error* parse_value_string(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+static grpc_error* parse_value_string(grpc_chttp2_hpack_parser* p,
const uint8_t* cur, const uint8_t* end,
bool is_binary) {
- return begin_parse_string(exec_ctx, p, cur, end,
- is_binary ? BINARY_BEGIN : NOT_BINARY, &p->value);
+ return begin_parse_string(p, cur, end, is_binary ? BINARY_BEGIN : NOT_BINARY,
+ &p->value);
}
static grpc_error* parse_value_string_with_indexed_key(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_parser* p, const uint8_t* cur,
- const uint8_t* end) {
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end) {
bool is_binary = false;
grpc_error* err = is_binary_indexed_header(p, &is_binary);
- if (err != GRPC_ERROR_NONE) return parse_error(exec_ctx, p, cur, end, err);
- return parse_value_string(exec_ctx, p, cur, end, is_binary);
+ if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
+ return parse_value_string(p, cur, end, is_binary);
}
static grpc_error* parse_value_string_with_literal_key(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_parser* p, const uint8_t* cur,
- const uint8_t* end) {
- return parse_value_string(exec_ctx, p, cur, end, is_binary_literal_header(p));
+ grpc_chttp2_hpack_parser* p, const uint8_t* cur, const uint8_t* end) {
+ return parse_value_string(p, cur, end, is_binary_literal_header(p));
}
/* PUBLIC INTERFACE */
-void grpc_chttp2_hpack_parser_init(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p) {
+void grpc_chttp2_hpack_parser_init(grpc_chttp2_hpack_parser* p) {
p->on_header = nullptr;
p->on_header_user_data = nullptr;
p->state = parse_begin;
@@ -1626,7 +1548,7 @@ void grpc_chttp2_hpack_parser_init(grpc_exec_ctx* exec_ctx,
p->value.data.copied.length = 0;
p->dynamic_table_update_allowed = 2;
p->last_error = GRPC_ERROR_NONE;
- grpc_chttp2_hptbl_init(exec_ctx, &p->table);
+ grpc_chttp2_hptbl_init(&p->table);
}
void grpc_chttp2_hpack_parser_set_has_priority(grpc_chttp2_hpack_parser* p) {
@@ -1634,18 +1556,16 @@ void grpc_chttp2_hpack_parser_set_has_priority(grpc_chttp2_hpack_parser* p) {
p->state = parse_stream_dep0;
}
-void grpc_chttp2_hpack_parser_destroy(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p) {
- grpc_chttp2_hptbl_destroy(exec_ctx, &p->table);
+void grpc_chttp2_hpack_parser_destroy(grpc_chttp2_hpack_parser* p) {
+ grpc_chttp2_hptbl_destroy(&p->table);
GRPC_ERROR_UNREF(p->last_error);
- grpc_slice_unref_internal(exec_ctx, p->key.data.referenced);
- grpc_slice_unref_internal(exec_ctx, p->value.data.referenced);
+ grpc_slice_unref_internal(p->key.data.referenced);
+ grpc_slice_unref_internal(p->value.data.referenced);
gpr_free(p->key.data.copied.str);
gpr_free(p->value.data.copied.str);
}
-grpc_error* grpc_chttp2_hpack_parser_parse(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+grpc_error* grpc_chttp2_hpack_parser_parse(grpc_chttp2_hpack_parser* p,
grpc_slice slice) {
/* max number of bytes to parse at a time... limits call stack depth on
* compilers without TCO */
@@ -1656,37 +1576,33 @@ grpc_error* grpc_chttp2_hpack_parser_parse(grpc_exec_ctx* exec_ctx,
grpc_error* error = GRPC_ERROR_NONE;
while (start != end && error == GRPC_ERROR_NONE) {
uint8_t* target = start + GPR_MIN(MAX_PARSE_LENGTH, end - start);
- error = p->state(exec_ctx, p, start, target);
+ error = p->state(p, start, target);
start = target;
}
p->current_slice_refcount = nullptr;
return error;
}
-typedef void (*maybe_complete_func_type)(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+typedef void (*maybe_complete_func_type)(grpc_chttp2_transport* t,
grpc_chttp2_stream* s);
static const maybe_complete_func_type maybe_complete_funcs[] = {
grpc_chttp2_maybe_complete_recv_initial_metadata,
grpc_chttp2_maybe_complete_recv_trailing_metadata};
-static void force_client_rst_stream(grpc_exec_ctx* exec_ctx, void* sp,
- grpc_error* error) {
+static void force_client_rst_stream(void* sp, grpc_error* error) {
grpc_chttp2_stream* s = (grpc_chttp2_stream*)sp;
grpc_chttp2_transport* t = s->t;
if (!s->write_closed) {
grpc_slice_buffer_add(
&t->qbuf, grpc_chttp2_rst_stream_create(s->id, GRPC_HTTP2_NO_ERROR,
&s->stats.outgoing));
- grpc_chttp2_initiate_write(exec_ctx, t,
- GRPC_CHTTP2_INITIATE_WRITE_FORCE_RST_STREAM);
- grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, true, GRPC_ERROR_NONE);
+ grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_FORCE_RST_STREAM);
+ grpc_chttp2_mark_stream_closed(t, s, true, true, GRPC_ERROR_NONE);
}
- GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "final_rst");
+ GRPC_CHTTP2_STREAM_UNREF(s, "final_rst");
}
-static void parse_stream_compression_md(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+static void parse_stream_compression_md(grpc_chttp2_transport* t,
grpc_chttp2_stream* s,
grpc_metadata_batch* initial_metadata) {
if (initial_metadata->idx.named.content_encoding == nullptr ||
@@ -1698,8 +1614,7 @@ static void parse_stream_compression_md(grpc_exec_ctx* exec_ctx,
}
}
-grpc_error* grpc_chttp2_header_parser_parse(grpc_exec_ctx* exec_ctx,
- void* hpack_parser,
+grpc_error* grpc_chttp2_header_parser_parse(void* hpack_parser,
grpc_chttp2_transport* t,
grpc_chttp2_stream* s,
grpc_slice slice, int is_last) {
@@ -1708,7 +1623,7 @@ grpc_error* grpc_chttp2_header_parser_parse(grpc_exec_ctx* exec_ctx,
if (s != nullptr) {
s->stats.incoming.header_bytes += GRPC_SLICE_LENGTH(slice);
}
- grpc_error* error = grpc_chttp2_hpack_parser_parse(exec_ctx, parser, slice);
+ grpc_error* error = grpc_chttp2_hpack_parser_parse(parser, slice);
if (error != GRPC_ERROR_NONE) {
GPR_TIMER_END("grpc_chttp2_hpack_parser_parse", 0);
return error;
@@ -1731,12 +1646,11 @@ grpc_error* grpc_chttp2_header_parser_parse(grpc_exec_ctx* exec_ctx,
/* Process stream compression md element if it exists */
if (s->header_frames_received ==
0) { /* Only acts on initial metadata */
- parse_stream_compression_md(exec_ctx, t, s,
- &s->metadata_buffer[0].batch);
+ parse_stream_compression_md(t, s, &s->metadata_buffer[0].batch);
}
s->published_metadata[s->header_frames_received] =
GRPC_METADATA_PUBLISHED_FROM_WIRE;
- maybe_complete_funcs[s->header_frames_received](exec_ctx, t, s);
+ maybe_complete_funcs[s->header_frames_received](t, s);
s->header_frames_received++;
}
if (parser->is_eof) {
@@ -1747,13 +1661,11 @@ grpc_error* grpc_chttp2_header_parser_parse(grpc_exec_ctx* exec_ctx,
and can avoid the extra write */
GRPC_CHTTP2_STREAM_REF(s, "final_rst");
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_CREATE(force_client_rst_stream, s,
grpc_combiner_finally_scheduler(t->combiner)),
GRPC_ERROR_NONE);
}
- grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, false,
- GRPC_ERROR_NONE);
+ grpc_chttp2_mark_stream_closed(t, s, true, false, GRPC_ERROR_NONE);
}
}
parser->on_header = nullptr;
diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.h b/src/core/ext/transport/chttp2/transport/hpack_parser.h
index 838c482e4a..a57012a131 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_parser.h
+++ b/src/core/ext/transport/chttp2/transport/hpack_parser.h
@@ -34,8 +34,7 @@ extern "C" {
typedef struct grpc_chttp2_hpack_parser grpc_chttp2_hpack_parser;
typedef grpc_error* (*grpc_chttp2_hpack_parser_state)(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_hpack_parser* p, const uint8_t* beg,
- const uint8_t* end);
+ grpc_chttp2_hpack_parser* p, const uint8_t* beg, const uint8_t* end);
typedef struct {
bool copied;
@@ -51,7 +50,7 @@ typedef struct {
struct grpc_chttp2_hpack_parser {
/* user specified callback for each header output */
- void (*on_header)(grpc_exec_ctx* exec_ctx, void* user_data, grpc_mdelem md);
+ void (*on_header)(void* user_data, grpc_mdelem md);
void* on_header_user_data;
grpc_error* last_error;
@@ -96,21 +95,17 @@ struct grpc_chttp2_hpack_parser {
grpc_chttp2_hptbl table;
};
-void grpc_chttp2_hpack_parser_init(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p);
-void grpc_chttp2_hpack_parser_destroy(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p);
+void grpc_chttp2_hpack_parser_init(grpc_chttp2_hpack_parser* p);
+void grpc_chttp2_hpack_parser_destroy(grpc_chttp2_hpack_parser* p);
void grpc_chttp2_hpack_parser_set_has_priority(grpc_chttp2_hpack_parser* p);
-grpc_error* grpc_chttp2_hpack_parser_parse(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hpack_parser* p,
+grpc_error* grpc_chttp2_hpack_parser_parse(grpc_chttp2_hpack_parser* p,
grpc_slice slice);
/* wraps grpc_chttp2_hpack_parser_parse to provide a frame level parser for
the transport */
-grpc_error* grpc_chttp2_header_parser_parse(grpc_exec_ctx* exec_ctx,
- void* hpack_parser,
+grpc_error* grpc_chttp2_header_parser_parse(void* hpack_parser,
grpc_chttp2_transport* t,
grpc_chttp2_stream* s,
grpc_slice slice, int is_last);
diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.cc b/src/core/ext/transport/chttp2/transport/hpack_table.cc
index 7970d2ae27..ef0adf718f 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_table.cc
+++ b/src/core/ext/transport/chttp2/transport/hpack_table.cc
@@ -165,7 +165,7 @@ static uint32_t entries_for_bytes(uint32_t bytes) {
GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD;
}
-void grpc_chttp2_hptbl_init(grpc_exec_ctx* exec_ctx, grpc_chttp2_hptbl* tbl) {
+void grpc_chttp2_hptbl_init(grpc_chttp2_hptbl* tbl) {
size_t i;
memset(tbl, 0, sizeof(*tbl));
@@ -177,22 +177,19 @@ void grpc_chttp2_hptbl_init(grpc_exec_ctx* exec_ctx, grpc_chttp2_hptbl* tbl) {
memset(tbl->ents, 0, sizeof(*tbl->ents) * tbl->cap_entries);
for (i = 1; i <= GRPC_CHTTP2_LAST_STATIC_ENTRY; i++) {
tbl->static_ents[i - 1] = grpc_mdelem_from_slices(
- exec_ctx,
grpc_slice_intern(grpc_slice_from_static_string(static_table[i].key)),
grpc_slice_intern(
grpc_slice_from_static_string(static_table[i].value)));
}
}
-void grpc_chttp2_hptbl_destroy(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hptbl* tbl) {
+void grpc_chttp2_hptbl_destroy(grpc_chttp2_hptbl* tbl) {
size_t i;
for (i = 0; i < GRPC_CHTTP2_LAST_STATIC_ENTRY; i++) {
- GRPC_MDELEM_UNREF(exec_ctx, tbl->static_ents[i]);
+ GRPC_MDELEM_UNREF(tbl->static_ents[i]);
}
for (i = 0; i < tbl->num_ents; i++) {
- GRPC_MDELEM_UNREF(exec_ctx,
- tbl->ents[(tbl->first_ent + i) % tbl->cap_entries]);
+ GRPC_MDELEM_UNREF(tbl->ents[(tbl->first_ent + i) % tbl->cap_entries]);
}
gpr_free(tbl->ents);
}
@@ -215,7 +212,7 @@ grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl* tbl,
}
/* Evict one element from the table */
-static void evict1(grpc_exec_ctx* exec_ctx, grpc_chttp2_hptbl* tbl) {
+static void evict1(grpc_chttp2_hptbl* tbl) {
grpc_mdelem first_ent = tbl->ents[tbl->first_ent];
size_t elem_bytes = GRPC_SLICE_LENGTH(GRPC_MDKEY(first_ent)) +
GRPC_SLICE_LENGTH(GRPC_MDVALUE(first_ent)) +
@@ -224,7 +221,7 @@ static void evict1(grpc_exec_ctx* exec_ctx, grpc_chttp2_hptbl* tbl) {
tbl->mem_used -= (uint32_t)elem_bytes;
tbl->first_ent = ((tbl->first_ent + 1) % tbl->cap_entries);
tbl->num_ents--;
- GRPC_MDELEM_UNREF(exec_ctx, first_ent);
+ GRPC_MDELEM_UNREF(first_ent);
}
static void rebuild_ents(grpc_chttp2_hptbl* tbl, uint32_t new_cap) {
@@ -240,8 +237,7 @@ static void rebuild_ents(grpc_chttp2_hptbl* tbl, uint32_t new_cap) {
tbl->first_ent = 0;
}
-void grpc_chttp2_hptbl_set_max_bytes(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hptbl* tbl,
+void grpc_chttp2_hptbl_set_max_bytes(grpc_chttp2_hptbl* tbl,
uint32_t max_bytes) {
if (tbl->max_bytes == max_bytes) {
return;
@@ -250,13 +246,12 @@ void grpc_chttp2_hptbl_set_max_bytes(grpc_exec_ctx* exec_ctx,
gpr_log(GPR_DEBUG, "Update hpack parser max size to %d", max_bytes);
}
while (tbl->mem_used > max_bytes) {
- evict1(exec_ctx, tbl);
+ evict1(tbl);
}
tbl->max_bytes = max_bytes;
}
-grpc_error* grpc_chttp2_hptbl_set_current_table_size(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hptbl* tbl,
+grpc_error* grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl* tbl,
uint32_t bytes) {
if (tbl->current_table_bytes == bytes) {
return GRPC_ERROR_NONE;
@@ -274,7 +269,7 @@ grpc_error* grpc_chttp2_hptbl_set_current_table_size(grpc_exec_ctx* exec_ctx,
gpr_log(GPR_DEBUG, "Update hpack parser table size to %d", bytes);
}
while (tbl->mem_used > bytes) {
- evict1(exec_ctx, tbl);
+ evict1(tbl);
}
tbl->current_table_bytes = bytes;
tbl->max_entries = entries_for_bytes(bytes);
@@ -289,8 +284,7 @@ grpc_error* grpc_chttp2_hptbl_set_current_table_size(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-grpc_error* grpc_chttp2_hptbl_add(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hptbl* tbl, grpc_mdelem md) {
+grpc_error* grpc_chttp2_hptbl_add(grpc_chttp2_hptbl* tbl, grpc_mdelem md) {
/* determine how many bytes of buffer this entry represents */
size_t elem_bytes = GRPC_SLICE_LENGTH(GRPC_MDKEY(md)) +
GRPC_SLICE_LENGTH(GRPC_MDVALUE(md)) +
@@ -320,14 +314,14 @@ grpc_error* grpc_chttp2_hptbl_add(grpc_exec_ctx* exec_ctx,
* empty table.
*/
while (tbl->num_ents) {
- evict1(exec_ctx, tbl);
+ evict1(tbl);
}
return GRPC_ERROR_NONE;
}
/* evict entries to ensure no overflow */
while (elem_bytes > (size_t)tbl->current_table_bytes - tbl->mem_used) {
- evict1(exec_ctx, tbl);
+ evict1(tbl);
}
/* copy the finalized entry in */
diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.h b/src/core/ext/transport/chttp2/transport/hpack_table.h
index ddc8888f86..8548942695 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_table.h
+++ b/src/core/ext/transport/chttp2/transport/hpack_table.h
@@ -73,21 +73,18 @@ typedef struct {
} grpc_chttp2_hptbl;
/* initialize a hpack table */
-void grpc_chttp2_hptbl_init(grpc_exec_ctx* exec_ctx, grpc_chttp2_hptbl* tbl);
-void grpc_chttp2_hptbl_destroy(grpc_exec_ctx* exec_ctx, grpc_chttp2_hptbl* tbl);
-void grpc_chttp2_hptbl_set_max_bytes(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hptbl* tbl,
+void grpc_chttp2_hptbl_init(grpc_chttp2_hptbl* tbl);
+void grpc_chttp2_hptbl_destroy(grpc_chttp2_hptbl* tbl);
+void grpc_chttp2_hptbl_set_max_bytes(grpc_chttp2_hptbl* tbl,
uint32_t max_bytes);
-grpc_error* grpc_chttp2_hptbl_set_current_table_size(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hptbl* tbl,
+grpc_error* grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl* tbl,
uint32_t bytes);
/* lookup a table entry based on its hpack index */
grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl* tbl,
uint32_t index);
/* add a table entry to the index */
-grpc_error* grpc_chttp2_hptbl_add(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_hptbl* tbl,
+grpc_error* grpc_chttp2_hptbl_add(grpc_chttp2_hptbl* tbl,
grpc_mdelem md) GRPC_MUST_USE_RESULT;
/* Find a key/value pair in the table... returns the index in the table of the
most similar entry, or 0 if the value was not found */
diff --git a/src/core/ext/transport/chttp2/transport/incoming_metadata.cc b/src/core/ext/transport/chttp2/transport/incoming_metadata.cc
index 4461f8c12c..ef0c9ed230 100644
--- a/src/core/ext/transport/chttp2/transport/incoming_metadata.cc
+++ b/src/core/ext/transport/chttp2/transport/incoming_metadata.cc
@@ -33,33 +33,31 @@ void grpc_chttp2_incoming_metadata_buffer_init(
}
void grpc_chttp2_incoming_metadata_buffer_destroy(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_metadata_buffer* buffer) {
- grpc_metadata_batch_destroy(exec_ctx, &buffer->batch);
+ grpc_chttp2_incoming_metadata_buffer* buffer) {
+ grpc_metadata_batch_destroy(&buffer->batch);
}
grpc_error* grpc_chttp2_incoming_metadata_buffer_add(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_metadata_buffer* buffer,
- grpc_mdelem elem) {
+ grpc_chttp2_incoming_metadata_buffer* buffer, grpc_mdelem elem) {
buffer->size += GRPC_MDELEM_LENGTH(elem);
return grpc_metadata_batch_add_tail(
- exec_ctx, &buffer->batch,
+ &buffer->batch,
(grpc_linked_mdelem*)gpr_arena_alloc(buffer->arena,
sizeof(grpc_linked_mdelem)),
elem);
}
grpc_error* grpc_chttp2_incoming_metadata_buffer_replace_or_add(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_metadata_buffer* buffer,
- grpc_mdelem elem) {
+ grpc_chttp2_incoming_metadata_buffer* buffer, grpc_mdelem elem) {
for (grpc_linked_mdelem* l = buffer->batch.list.head; l != nullptr;
l = l->next) {
if (grpc_slice_eq(GRPC_MDKEY(l->md), GRPC_MDKEY(elem))) {
- GRPC_MDELEM_UNREF(exec_ctx, l->md);
+ GRPC_MDELEM_UNREF(l->md);
l->md = elem;
return GRPC_ERROR_NONE;
}
}
- return grpc_chttp2_incoming_metadata_buffer_add(exec_ctx, buffer, elem);
+ return grpc_chttp2_incoming_metadata_buffer_add(buffer, elem);
}
void grpc_chttp2_incoming_metadata_buffer_set_deadline(
@@ -68,8 +66,7 @@ void grpc_chttp2_incoming_metadata_buffer_set_deadline(
}
void grpc_chttp2_incoming_metadata_buffer_publish(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_metadata_buffer* buffer,
- grpc_metadata_batch* batch) {
+ grpc_chttp2_incoming_metadata_buffer* buffer, grpc_metadata_batch* batch) {
*batch = buffer->batch;
grpc_metadata_batch_init(&buffer->batch);
}
diff --git a/src/core/ext/transport/chttp2/transport/incoming_metadata.h b/src/core/ext/transport/chttp2/transport/incoming_metadata.h
index 7ccb4a0126..4df8ebaa26 100644
--- a/src/core/ext/transport/chttp2/transport/incoming_metadata.h
+++ b/src/core/ext/transport/chttp2/transport/incoming_metadata.h
@@ -35,16 +35,15 @@ typedef struct {
void grpc_chttp2_incoming_metadata_buffer_init(
grpc_chttp2_incoming_metadata_buffer* buffer, gpr_arena* arena);
void grpc_chttp2_incoming_metadata_buffer_destroy(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_metadata_buffer* buffer);
+ grpc_chttp2_incoming_metadata_buffer* buffer);
void grpc_chttp2_incoming_metadata_buffer_publish(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_metadata_buffer* buffer,
- grpc_metadata_batch* batch);
+ grpc_chttp2_incoming_metadata_buffer* buffer, grpc_metadata_batch* batch);
grpc_error* grpc_chttp2_incoming_metadata_buffer_add(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_metadata_buffer* buffer,
+ grpc_chttp2_incoming_metadata_buffer* buffer,
grpc_mdelem elem) GRPC_MUST_USE_RESULT;
grpc_error* grpc_chttp2_incoming_metadata_buffer_replace_or_add(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_metadata_buffer* buffer,
+ grpc_chttp2_incoming_metadata_buffer* buffer,
grpc_mdelem elem) GRPC_MUST_USE_RESULT;
void grpc_chttp2_incoming_metadata_buffer_set_deadline(
grpc_chttp2_incoming_metadata_buffer* buffer, grpc_millis deadline);
diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h
index 60cc280c43..3f27da6d0a 100644
--- a/src/core/ext/transport/chttp2/transport/internal.h
+++ b/src/core/ext/transport/chttp2/transport/internal.h
@@ -284,8 +284,8 @@ struct grpc_chttp2_transport {
struct {
/* accept stream callback */
- void (*accept_stream)(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_transport* transport, const void* server_data);
+ void (*accept_stream)(void* user_data, grpc_transport* transport,
+ const void* server_data);
void* accept_stream_user_data;
/** connectivity tracking */
@@ -373,9 +373,8 @@ struct grpc_chttp2_transport {
/* active parser */
void* parser_data;
grpc_chttp2_stream* incoming_stream;
- grpc_error* (*parser)(grpc_exec_ctx* exec_ctx, void* parser_user_data,
- grpc_chttp2_transport* t, grpc_chttp2_stream* s,
- grpc_slice slice, int is_last);
+ grpc_error* (*parser)(void* parser_user_data, grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, grpc_slice slice, int is_last);
grpc_chttp2_write_cb* write_cb_pool;
@@ -573,8 +572,7 @@ struct grpc_chttp2_stream {
The actual call chain is documented in the implementation of this function.
*/
-void grpc_chttp2_initiate_write(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+void grpc_chttp2_initiate_write(grpc_chttp2_transport* t,
grpc_chttp2_initiate_write_reason reason);
typedef struct {
@@ -587,14 +585,12 @@ typedef struct {
} grpc_chttp2_begin_write_result;
grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t);
-void grpc_chttp2_end_write(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
- grpc_error* error);
+ grpc_chttp2_transport* t);
+void grpc_chttp2_end_write(grpc_chttp2_transport* t, grpc_error* error);
/** Process one slice of incoming data; return 1 if the connection is still
viable after reading, or 0 if the connection should be torn down */
-grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t,
grpc_slice slice);
bool grpc_chttp2_list_add_writable_stream(grpc_chttp2_transport* t,
@@ -642,27 +638,23 @@ bool grpc_chttp2_list_remove_stalled_by_stream(grpc_chttp2_transport* t,
// Takes in a flow control action and performs all the needed operations.
void grpc_chttp2_act_on_flowctl_action(
- grpc_exec_ctx* exec_ctx, const grpc_core::chttp2::FlowControlAction& action,
+ const grpc_core::chttp2::FlowControlAction& action,
grpc_chttp2_transport* t, grpc_chttp2_stream* s);
/********* End of Flow Control ***************/
grpc_chttp2_stream* grpc_chttp2_parsing_lookup_stream(grpc_chttp2_transport* t,
uint32_t id);
-grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_chttp2_transport* t,
uint32_t id);
-void grpc_chttp2_add_incoming_goaway(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t,
uint32_t goaway_error,
grpc_slice goaway_text);
-void grpc_chttp2_parsing_become_skip_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t);
+void grpc_chttp2_parsing_become_skip_parser(grpc_chttp2_transport* t);
-void grpc_chttp2_complete_closure_step(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+void grpc_chttp2_complete_closure_step(grpc_chttp2_transport* t,
grpc_chttp2_stream* s,
grpc_closure** pclosure,
grpc_error* error, const char* desc);
@@ -683,94 +675,80 @@ extern grpc_tracer_flag grpc_flowctl_trace;
else \
stmt
-void grpc_chttp2_fake_status(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
+void grpc_chttp2_fake_status(grpc_chttp2_transport* t,
grpc_chttp2_stream* stream, grpc_error* error);
-void grpc_chttp2_mark_stream_closed(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+void grpc_chttp2_mark_stream_closed(grpc_chttp2_transport* t,
grpc_chttp2_stream* s, int close_reads,
int close_writes, grpc_error* error);
-void grpc_chttp2_start_writing(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t);
+void grpc_chttp2_start_writing(grpc_chttp2_transport* t);
#ifndef NDEBUG
#define GRPC_CHTTP2_STREAM_REF(stream, reason) \
grpc_chttp2_stream_ref(stream, reason)
-#define GRPC_CHTTP2_STREAM_UNREF(exec_ctx, stream, reason) \
- grpc_chttp2_stream_unref(exec_ctx, stream, reason)
+#define GRPC_CHTTP2_STREAM_UNREF(stream, reason) \
+ grpc_chttp2_stream_unref(stream, reason)
void grpc_chttp2_stream_ref(grpc_chttp2_stream* s, const char* reason);
-void grpc_chttp2_stream_unref(grpc_exec_ctx* exec_ctx, grpc_chttp2_stream* s,
- const char* reason);
+void grpc_chttp2_stream_unref(grpc_chttp2_stream* s, const char* reason);
#else
#define GRPC_CHTTP2_STREAM_REF(stream, reason) grpc_chttp2_stream_ref(stream)
-#define GRPC_CHTTP2_STREAM_UNREF(exec_ctx, stream, reason) \
- grpc_chttp2_stream_unref(exec_ctx, stream)
+#define GRPC_CHTTP2_STREAM_UNREF(stream, reason) \
+ grpc_chttp2_stream_unref(stream)
void grpc_chttp2_stream_ref(grpc_chttp2_stream* s);
-void grpc_chttp2_stream_unref(grpc_exec_ctx* exec_ctx, grpc_chttp2_stream* s);
+void grpc_chttp2_stream_unref(grpc_chttp2_stream* s);
#endif
#ifndef NDEBUG
#define GRPC_CHTTP2_REF_TRANSPORT(t, r) \
grpc_chttp2_ref_transport(t, r, __FILE__, __LINE__)
-#define GRPC_CHTTP2_UNREF_TRANSPORT(cl, t, r) \
- grpc_chttp2_unref_transport(cl, t, r, __FILE__, __LINE__)
-void grpc_chttp2_unref_transport(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t, const char* reason,
+#define GRPC_CHTTP2_UNREF_TRANSPORT(t, r) \
+ grpc_chttp2_unref_transport(t, r, __FILE__, __LINE__)
+void grpc_chttp2_unref_transport(grpc_chttp2_transport* t, const char* reason,
const char* file, int line);
void grpc_chttp2_ref_transport(grpc_chttp2_transport* t, const char* reason,
const char* file, int line);
#else
#define GRPC_CHTTP2_REF_TRANSPORT(t, r) grpc_chttp2_ref_transport(t)
-#define GRPC_CHTTP2_UNREF_TRANSPORT(cl, t, r) grpc_chttp2_unref_transport(cl, t)
-void grpc_chttp2_unref_transport(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t);
+#define GRPC_CHTTP2_UNREF_TRANSPORT(t, r) grpc_chttp2_unref_transport(t)
+void grpc_chttp2_unref_transport(grpc_chttp2_transport* t);
void grpc_chttp2_ref_transport(grpc_chttp2_transport* t);
#endif
grpc_chttp2_incoming_byte_stream* grpc_chttp2_incoming_byte_stream_create(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t, grpc_chttp2_stream* s,
- uint32_t frame_size, uint32_t flags);
+ grpc_chttp2_transport* t, grpc_chttp2_stream* s, uint32_t frame_size,
+ uint32_t flags);
grpc_error* grpc_chttp2_incoming_byte_stream_push(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_byte_stream* bs,
- grpc_slice slice, grpc_slice* slice_out);
+ grpc_chttp2_incoming_byte_stream* bs, grpc_slice slice,
+ grpc_slice* slice_out);
grpc_error* grpc_chttp2_incoming_byte_stream_finished(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_byte_stream* bs,
- grpc_error* error, bool reset_on_error);
+ grpc_chttp2_incoming_byte_stream* bs, grpc_error* error,
+ bool reset_on_error);
void grpc_chttp2_incoming_byte_stream_notify(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_byte_stream* bs,
- grpc_error* error);
+ grpc_chttp2_incoming_byte_stream* bs, grpc_error* error);
-void grpc_chttp2_ack_ping(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
- uint64_t id);
+void grpc_chttp2_ack_ping(grpc_chttp2_transport* t, uint64_t id);
/** Add a new ping strike to ping_recv_state.ping_strikes. If
ping_recv_state.ping_strikes > ping_policy.max_ping_strikes, it sends GOAWAY
with error code ENHANCE_YOUR_CALM and additional debug data resembling
"too_many_pings" followed by immediately closing the connection. */
-void grpc_chttp2_add_ping_strike(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t);
+void grpc_chttp2_add_ping_strike(grpc_chttp2_transport* t);
/** add a ref to the stream and add it to the writable list;
ref will be dropped in writing.c */
-void grpc_chttp2_mark_stream_writable(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+void grpc_chttp2_mark_stream_writable(grpc_chttp2_transport* t,
grpc_chttp2_stream* s);
-void grpc_chttp2_cancel_stream(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+void grpc_chttp2_cancel_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
grpc_error* due_to_error);
-void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_chttp2_transport* t,
grpc_chttp2_stream* s);
-void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+void grpc_chttp2_maybe_complete_recv_message(grpc_chttp2_transport* t,
grpc_chttp2_stream* s);
-void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_chttp2_transport* t,
grpc_chttp2_stream* s);
-void grpc_chttp2_fail_pending_writes(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+void grpc_chttp2_fail_pending_writes(grpc_chttp2_transport* t,
grpc_chttp2_stream* s, grpc_error* error);
/** Set the default keepalive configurations, must only be called at
diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc
index 5f07dec8e8..a9d08c34d0 100644
--- a/src/core/ext/transport/chttp2/transport/parsing.cc
+++ b/src/core/ext/transport/chttp2/transport/parsing.cc
@@ -31,33 +31,22 @@
#include "src/core/lib/transport/status_conversion.h"
#include "src/core/lib/transport/timeout_encoding.h"
-static grpc_error* init_frame_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t);
-static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+static grpc_error* init_frame_parser(grpc_chttp2_transport* t);
+static grpc_error* init_header_frame_parser(grpc_chttp2_transport* t,
int is_continuation);
-static grpc_error* init_data_frame_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t);
-static grpc_error* init_rst_stream_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t);
-static grpc_error* init_settings_frame_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t);
-static grpc_error* init_window_update_frame_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t);
-static grpc_error* init_ping_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t);
-static grpc_error* init_goaway_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t);
-static grpc_error* init_skip_frame_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+static grpc_error* init_data_frame_parser(grpc_chttp2_transport* t);
+static grpc_error* init_rst_stream_parser(grpc_chttp2_transport* t);
+static grpc_error* init_settings_frame_parser(grpc_chttp2_transport* t);
+static grpc_error* init_window_update_frame_parser(grpc_chttp2_transport* t);
+static grpc_error* init_ping_parser(grpc_chttp2_transport* t);
+static grpc_error* init_goaway_parser(grpc_chttp2_transport* t);
+static grpc_error* init_skip_frame_parser(grpc_chttp2_transport* t,
int is_header);
-static grpc_error* parse_frame_slice(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t, grpc_slice slice,
+static grpc_error* parse_frame_slice(grpc_chttp2_transport* t, grpc_slice slice,
int is_last);
-grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t,
grpc_slice slice) {
uint8_t* beg = GRPC_SLICE_START_PTR(slice);
uint8_t* end = GRPC_SLICE_END_PTR(slice);
@@ -182,12 +171,12 @@ grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx,
GPR_ASSERT(cur < end);
t->incoming_stream_id |= ((uint32_t)*cur);
t->deframe_state = GRPC_DTS_FRAME;
- err = init_frame_parser(exec_ctx, t);
+ err = init_frame_parser(t);
if (err != GRPC_ERROR_NONE) {
return err;
}
if (t->incoming_frame_size == 0) {
- err = parse_frame_slice(exec_ctx, t, grpc_empty_slice(), 1);
+ err = parse_frame_slice(t, grpc_empty_slice(), 1);
if (err != GRPC_ERROR_NONE) {
return err;
}
@@ -217,7 +206,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx,
GPR_ASSERT(cur < end);
if ((uint32_t)(end - cur) == t->incoming_frame_size) {
err =
- parse_frame_slice(exec_ctx, t,
+ parse_frame_slice(t,
grpc_slice_sub_no_ref(slice, (size_t)(cur - beg),
(size_t)(end - beg)),
1);
@@ -230,7 +219,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx,
} else if ((uint32_t)(end - cur) > t->incoming_frame_size) {
size_t cur_offset = (size_t)(cur - beg);
err = parse_frame_slice(
- exec_ctx, t,
+ t,
grpc_slice_sub_no_ref(slice, cur_offset,
cur_offset + t->incoming_frame_size),
1);
@@ -242,7 +231,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx,
goto dts_fh_0; /* loop */
} else {
err =
- parse_frame_slice(exec_ctx, t,
+ parse_frame_slice(t,
grpc_slice_sub_no_ref(slice, (size_t)(cur - beg),
(size_t)(end - beg)),
0);
@@ -258,8 +247,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx,
GPR_UNREACHABLE_CODE(return nullptr);
}
-static grpc_error* init_frame_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t) {
+static grpc_error* init_frame_parser(grpc_chttp2_transport* t) {
if (t->is_first_frame &&
t->incoming_frame_type != GRPC_CHTTP2_FRAME_SETTINGS) {
char* msg;
@@ -291,46 +279,43 @@ static grpc_error* init_frame_parser(grpc_exec_ctx* exec_ctx,
gpr_free(msg);
return err;
}
- return init_header_frame_parser(exec_ctx, t, 1);
+ return init_header_frame_parser(t, 1);
}
switch (t->incoming_frame_type) {
case GRPC_CHTTP2_FRAME_DATA:
- return init_data_frame_parser(exec_ctx, t);
+ return init_data_frame_parser(t);
case GRPC_CHTTP2_FRAME_HEADER:
- return init_header_frame_parser(exec_ctx, t, 0);
+ return init_header_frame_parser(t, 0);
case GRPC_CHTTP2_FRAME_CONTINUATION:
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Unexpected CONTINUATION frame");
case GRPC_CHTTP2_FRAME_RST_STREAM:
- return init_rst_stream_parser(exec_ctx, t);
+ return init_rst_stream_parser(t);
case GRPC_CHTTP2_FRAME_SETTINGS:
- return init_settings_frame_parser(exec_ctx, t);
+ return init_settings_frame_parser(t);
case GRPC_CHTTP2_FRAME_WINDOW_UPDATE:
- return init_window_update_frame_parser(exec_ctx, t);
+ return init_window_update_frame_parser(t);
case GRPC_CHTTP2_FRAME_PING:
- return init_ping_parser(exec_ctx, t);
+ return init_ping_parser(t);
case GRPC_CHTTP2_FRAME_GOAWAY:
- return init_goaway_parser(exec_ctx, t);
+ return init_goaway_parser(t);
default:
if (GRPC_TRACER_ON(grpc_http_trace)) {
gpr_log(GPR_ERROR, "Unknown frame type %02x", t->incoming_frame_type);
}
- return init_skip_frame_parser(exec_ctx, t, 0);
+ return init_skip_frame_parser(t, 0);
}
}
-static grpc_error* skip_parser(grpc_exec_ctx* exec_ctx, void* parser,
- grpc_chttp2_transport* t, grpc_chttp2_stream* s,
- grpc_slice slice, int is_last) {
+static grpc_error* skip_parser(void* parser, grpc_chttp2_transport* t,
+ grpc_chttp2_stream* s, grpc_slice slice,
+ int is_last) {
return GRPC_ERROR_NONE;
}
-static void skip_header(grpc_exec_ctx* exec_ctx, void* tp, grpc_mdelem md) {
- GRPC_MDELEM_UNREF(exec_ctx, md);
-}
+static void skip_header(void* tp, grpc_mdelem md) { GRPC_MDELEM_UNREF(md); }
-static grpc_error* init_skip_frame_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+static grpc_error* init_skip_frame_parser(grpc_chttp2_transport* t,
int is_header) {
if (is_header) {
uint8_t is_eoh = t->expect_continuation_stream_id != 0;
@@ -346,14 +331,11 @@ static grpc_error* init_skip_frame_parser(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-void grpc_chttp2_parsing_become_skip_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t) {
- init_skip_frame_parser(exec_ctx, t,
- t->parser == grpc_chttp2_header_parser_parse);
+void grpc_chttp2_parsing_become_skip_parser(grpc_chttp2_transport* t) {
+ init_skip_frame_parser(t, t->parser == grpc_chttp2_header_parser_parse);
}
-static grpc_error* init_data_frame_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t) {
+static grpc_error* init_data_frame_parser(grpc_chttp2_transport* t) {
grpc_chttp2_stream* s =
grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id);
grpc_error* err = GRPC_ERROR_NONE;
@@ -365,17 +347,17 @@ static grpc_error* init_data_frame_parser(grpc_exec_ctx* exec_ctx,
err = s->flow_control->RecvData(t->incoming_frame_size);
action = s->flow_control->MakeAction();
}
- grpc_chttp2_act_on_flowctl_action(exec_ctx, action, t, s);
+ grpc_chttp2_act_on_flowctl_action(action, t, s);
if (err != GRPC_ERROR_NONE) {
goto error_handler;
}
if (s == nullptr) {
- return init_skip_frame_parser(exec_ctx, t, 0);
+ return init_skip_frame_parser(t, 0);
}
s->received_bytes += t->incoming_frame_size;
s->stats.incoming.framing_bytes += 9;
if (err == GRPC_ERROR_NONE && s->read_closed) {
- return init_skip_frame_parser(exec_ctx, t, 0);
+ return init_skip_frame_parser(t, 0);
}
if (err == GRPC_ERROR_NONE) {
err = grpc_chttp2_data_parser_begin_frame(
@@ -394,13 +376,13 @@ error_handler:
} else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, nullptr)) {
/* handle stream errors by closing the stream */
if (s != nullptr) {
- grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, false, err);
+ grpc_chttp2_mark_stream_closed(t, s, true, false, err);
}
grpc_slice_buffer_add(
&t->qbuf, grpc_chttp2_rst_stream_create(t->incoming_stream_id,
GRPC_HTTP2_PROTOCOL_ERROR,
&s->stats.outgoing));
- return init_skip_frame_parser(exec_ctx, t, 0);
+ return init_skip_frame_parser(t, 0);
} else {
return err;
}
@@ -408,8 +390,7 @@ error_handler:
static void free_timeout(void* p) { gpr_free(p); }
-static void on_initial_header(grpc_exec_ctx* exec_ctx, void* tp,
- grpc_mdelem md) {
+static void on_initial_header(void* tp, grpc_mdelem md) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
grpc_chttp2_stream* s = t->incoming_stream;
@@ -455,9 +436,9 @@ static void on_initial_header(grpc_exec_ctx* exec_ctx, void* tp,
}
if (timeout != GRPC_MILLIS_INF_FUTURE) {
grpc_chttp2_incoming_metadata_buffer_set_deadline(
- &s->metadata_buffer[0], grpc_exec_ctx_now(exec_ctx) + timeout);
+ &s->metadata_buffer[0], grpc_core::ExecCtx::Get()->Now() + timeout);
}
- GRPC_MDELEM_UNREF(exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
} else {
const size_t new_size = s->metadata_buffer[0].size + GRPC_MDELEM_LENGTH(md);
const size_t metadata_size_limit =
@@ -469,22 +450,22 @@ static void on_initial_header(grpc_exec_ctx* exec_ctx, void* tp,
" vs. %" PRIuPTR ")",
new_size, metadata_size_limit);
grpc_chttp2_cancel_stream(
- exec_ctx, t, s,
+ t, s,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"received initial metadata size exceeds limit"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_RESOURCE_EXHAUSTED));
- grpc_chttp2_parsing_become_skip_parser(exec_ctx, t);
+ grpc_chttp2_parsing_become_skip_parser(t);
s->seen_error = true;
- GRPC_MDELEM_UNREF(exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
} else {
- grpc_error* error = grpc_chttp2_incoming_metadata_buffer_add(
- exec_ctx, &s->metadata_buffer[0], md);
+ grpc_error* error =
+ grpc_chttp2_incoming_metadata_buffer_add(&s->metadata_buffer[0], md);
if (error != GRPC_ERROR_NONE) {
- grpc_chttp2_cancel_stream(exec_ctx, t, s, error);
- grpc_chttp2_parsing_become_skip_parser(exec_ctx, t);
+ grpc_chttp2_cancel_stream(t, s, error);
+ grpc_chttp2_parsing_become_skip_parser(t);
s->seen_error = true;
- GRPC_MDELEM_UNREF(exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
}
}
}
@@ -492,8 +473,7 @@ static void on_initial_header(grpc_exec_ctx* exec_ctx, void* tp,
GPR_TIMER_END("on_initial_header", 0);
}
-static void on_trailing_header(grpc_exec_ctx* exec_ctx, void* tp,
- grpc_mdelem md) {
+static void on_trailing_header(void* tp, grpc_mdelem md) {
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
grpc_chttp2_stream* s = t->incoming_stream;
@@ -527,30 +507,29 @@ static void on_trailing_header(grpc_exec_ctx* exec_ctx, void* tp,
" vs. %" PRIuPTR ")",
new_size, metadata_size_limit);
grpc_chttp2_cancel_stream(
- exec_ctx, t, s,
+ t, s,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"received trailing metadata size exceeds limit"),
GRPC_ERROR_INT_GRPC_STATUS,
GRPC_STATUS_RESOURCE_EXHAUSTED));
- grpc_chttp2_parsing_become_skip_parser(exec_ctx, t);
+ grpc_chttp2_parsing_become_skip_parser(t);
s->seen_error = true;
- GRPC_MDELEM_UNREF(exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
} else {
- grpc_error* error = grpc_chttp2_incoming_metadata_buffer_add(
- exec_ctx, &s->metadata_buffer[1], md);
+ grpc_error* error =
+ grpc_chttp2_incoming_metadata_buffer_add(&s->metadata_buffer[1], md);
if (error != GRPC_ERROR_NONE) {
- grpc_chttp2_cancel_stream(exec_ctx, t, s, error);
- grpc_chttp2_parsing_become_skip_parser(exec_ctx, t);
+ grpc_chttp2_cancel_stream(t, s, error);
+ grpc_chttp2_parsing_become_skip_parser(t);
s->seen_error = true;
- GRPC_MDELEM_UNREF(exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
}
}
GPR_TIMER_END("on_trailing_header", 0);
}
-static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t,
+static grpc_error* init_header_frame_parser(grpc_chttp2_transport* t,
int is_continuation) {
uint8_t is_eoh =
(t->incoming_frame_flags & GRPC_CHTTP2_DATA_FLAG_END_HEADERS) != 0;
@@ -580,7 +559,7 @@ static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx,
GRPC_CHTTP2_IF_TRACING(
gpr_log(GPR_ERROR,
"grpc_chttp2_stream disbanded before CONTINUATION received"));
- return init_skip_frame_parser(exec_ctx, t, 1);
+ return init_skip_frame_parser(t, 1);
}
if (t->is_client) {
if ((t->incoming_stream_id & 1) &&
@@ -590,7 +569,7 @@ static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx,
GRPC_CHTTP2_IF_TRACING(gpr_log(
GPR_ERROR, "ignoring new grpc_chttp2_stream creation on client"));
}
- grpc_error* err = init_skip_frame_parser(exec_ctx, t, 1);
+ grpc_error* err = init_skip_frame_parser(t, 1);
if (t->incoming_frame_flags & GRPC_CHTTP2_FLAG_HAS_PRIORITY) {
grpc_chttp2_hpack_parser_set_has_priority(&t->hpack_parser);
}
@@ -602,13 +581,13 @@ static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx,
"last grpc_chttp2_stream "
"id=%d, new grpc_chttp2_stream id=%d",
t->last_new_stream_id, t->incoming_stream_id));
- return init_skip_frame_parser(exec_ctx, t, 1);
+ return init_skip_frame_parser(t, 1);
} else if ((t->incoming_stream_id & 1) == 0) {
GRPC_CHTTP2_IF_TRACING(gpr_log(
GPR_ERROR,
"ignoring grpc_chttp2_stream with non-client generated index %d",
t->incoming_stream_id));
- return init_skip_frame_parser(exec_ctx, t, 1);
+ return init_skip_frame_parser(t, 1);
} else if (grpc_chttp2_stream_map_size(&t->stream_map) >=
t->settings[GRPC_ACKED_SETTINGS]
[GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS]) {
@@ -616,11 +595,11 @@ 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);
+ grpc_chttp2_parsing_accept_stream(t, t->incoming_stream_id);
if (s == nullptr) {
GRPC_CHTTP2_IF_TRACING(
gpr_log(GPR_ERROR, "grpc_chttp2_stream not accepted"));
- return init_skip_frame_parser(exec_ctx, t, 1);
+ return init_skip_frame_parser(t, 1);
}
} else {
t->incoming_stream = s;
@@ -631,7 +610,7 @@ static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx,
GRPC_CHTTP2_IF_TRACING(gpr_log(
GPR_ERROR, "skipping already closed grpc_chttp2_stream header"));
t->incoming_stream = nullptr;
- return init_skip_frame_parser(exec_ctx, t, 1);
+ return init_skip_frame_parser(t, 1);
}
t->parser = grpc_chttp2_header_parser_parse;
t->parser_data = &t->hpack_parser;
@@ -656,7 +635,7 @@ static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx,
break;
case 2:
gpr_log(GPR_ERROR, "too many header frames received");
- return init_skip_frame_parser(exec_ctx, t, 1);
+ return init_skip_frame_parser(t, 1);
}
t->hpack_parser.on_header_user_data = t;
t->hpack_parser.is_boundary = is_eoh;
@@ -668,8 +647,7 @@ static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error* init_window_update_frame_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t) {
+static grpc_error* init_window_update_frame_parser(grpc_chttp2_transport* t) {
grpc_error* err = grpc_chttp2_window_update_parser_begin_frame(
&t->simple.window_update, t->incoming_frame_size,
t->incoming_frame_flags);
@@ -678,7 +656,7 @@ static grpc_error* init_window_update_frame_parser(grpc_exec_ctx* exec_ctx,
grpc_chttp2_stream* s = t->incoming_stream =
grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id);
if (s == nullptr) {
- return init_skip_frame_parser(exec_ctx, t, 0);
+ return init_skip_frame_parser(t, 0);
}
s->stats.incoming.framing_bytes += 9;
}
@@ -687,8 +665,7 @@ static grpc_error* init_window_update_frame_parser(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error* init_ping_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t) {
+static grpc_error* init_ping_parser(grpc_chttp2_transport* t) {
grpc_error* err = grpc_chttp2_ping_parser_begin_frame(
&t->simple.ping, t->incoming_frame_size, t->incoming_frame_flags);
if (err != GRPC_ERROR_NONE) return err;
@@ -697,15 +674,14 @@ static grpc_error* init_ping_parser(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error* init_rst_stream_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t) {
+static grpc_error* init_rst_stream_parser(grpc_chttp2_transport* t) {
grpc_error* err = grpc_chttp2_rst_stream_parser_begin_frame(
&t->simple.rst_stream, t->incoming_frame_size, t->incoming_frame_flags);
if (err != GRPC_ERROR_NONE) return err;
grpc_chttp2_stream* s = t->incoming_stream =
grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id);
if (!t->incoming_stream) {
- return init_skip_frame_parser(exec_ctx, t, 0);
+ return init_skip_frame_parser(t, 0);
}
s->stats.incoming.framing_bytes += 9;
t->parser = grpc_chttp2_rst_stream_parser_parse;
@@ -713,8 +689,7 @@ static grpc_error* init_rst_stream_parser(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error* init_goaway_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t) {
+static grpc_error* init_goaway_parser(grpc_chttp2_transport* t) {
grpc_error* err = grpc_chttp2_goaway_parser_begin_frame(
&t->goaway_parser, t->incoming_frame_size, t->incoming_frame_flags);
if (err != GRPC_ERROR_NONE) return err;
@@ -723,8 +698,7 @@ static grpc_error* init_goaway_parser(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error* init_settings_frame_parser(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t) {
+static grpc_error* init_settings_frame_parser(grpc_chttp2_transport* t) {
if (t->incoming_stream_id != 0) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Settings frame received for grpc_chttp2_stream");
@@ -740,7 +714,7 @@ static grpc_error* init_settings_frame_parser(grpc_exec_ctx* exec_ctx,
memcpy(t->settings[GRPC_ACKED_SETTINGS], t->settings[GRPC_SENT_SETTINGS],
GRPC_CHTTP2_NUM_SETTINGS * sizeof(uint32_t));
grpc_chttp2_hptbl_set_max_bytes(
- exec_ctx, &t->hpack_parser.table,
+ &t->hpack_parser.table,
t->settings[GRPC_ACKED_SETTINGS]
[GRPC_CHTTP2_SETTINGS_HEADER_TABLE_SIZE]);
t->sent_local_settings = 0;
@@ -750,11 +724,10 @@ static grpc_error* init_settings_frame_parser(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error* parse_frame_slice(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t, grpc_slice slice,
+static grpc_error* parse_frame_slice(grpc_chttp2_transport* t, grpc_slice slice,
int is_last) {
grpc_chttp2_stream* s = t->incoming_stream;
- grpc_error* err = t->parser(exec_ctx, t->parser_data, t, s, slice, is_last);
+ grpc_error* err = t->parser(t->parser_data, t, s, slice, is_last);
if (err == GRPC_ERROR_NONE) {
return err;
} else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, nullptr)) {
@@ -762,7 +735,7 @@ static grpc_error* parse_frame_slice(grpc_exec_ctx* exec_ctx,
const char* msg = grpc_error_string(err);
gpr_log(GPR_ERROR, "%s", msg);
}
- grpc_chttp2_parsing_become_skip_parser(exec_ctx, t);
+ grpc_chttp2_parsing_become_skip_parser(t);
if (s) {
s->forced_close_error = err;
grpc_slice_buffer_add(
diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc
index 61a2598618..77cdd9c71a 100644
--- a/src/core/ext/transport/chttp2/transport/writing.cc
+++ b/src/core/ext/transport/chttp2/transport/writing.cc
@@ -33,17 +33,15 @@ static void add_to_write_list(grpc_chttp2_write_cb** list,
*list = cb;
}
-static void finish_write_cb(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
- grpc_chttp2_stream* s, grpc_chttp2_write_cb* cb,
- grpc_error* error) {
- grpc_chttp2_complete_closure_step(exec_ctx, t, s, &cb->closure, error,
+static void finish_write_cb(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+ grpc_chttp2_write_cb* cb, grpc_error* error) {
+ grpc_chttp2_complete_closure_step(t, s, &cb->closure, error,
"finish_write_cb");
cb->next = t->write_cb_pool;
t->write_cb_pool = cb;
}
-static void maybe_initiate_ping(grpc_exec_ctx* exec_ctx,
- grpc_chttp2_transport* t) {
+static void maybe_initiate_ping(grpc_chttp2_transport* t) {
grpc_chttp2_ping_queue* pq = &t->ping_queue;
if (grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_NEXT])) {
/* no ping needed: wait */
@@ -70,7 +68,7 @@ static void maybe_initiate_ping(grpc_exec_ctx* exec_ctx,
}
return;
}
- grpc_millis now = grpc_exec_ctx_now(exec_ctx);
+ grpc_millis now = grpc_core::ExecCtx::Get()->Now();
grpc_millis next_allowed_ping =
t->ping_state.last_ping_sent_time +
t->ping_policy.min_sent_ping_interval_without_data;
@@ -89,19 +87,19 @@ static void maybe_initiate_ping(grpc_exec_ctx* exec_ctx,
}
if (!t->ping_state.is_delayed_ping_timer_set) {
t->ping_state.is_delayed_ping_timer_set = true;
- grpc_timer_init(exec_ctx, &t->ping_state.delayed_ping_timer,
- next_allowed_ping, &t->retry_initiate_ping_locked);
+ grpc_timer_init(&t->ping_state.delayed_ping_timer, next_allowed_ping,
+ &t->retry_initiate_ping_locked);
}
return;
}
pq->inflight_id = t->ping_ctr;
t->ping_ctr++;
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pq->lists[GRPC_CHTTP2_PCL_INITIATE]);
+ GRPC_CLOSURE_LIST_SCHED(&pq->lists[GRPC_CHTTP2_PCL_INITIATE]);
grpc_closure_list_move(&pq->lists[GRPC_CHTTP2_PCL_NEXT],
&pq->lists[GRPC_CHTTP2_PCL_INFLIGHT]);
grpc_slice_buffer_add(&t->outbuf,
grpc_chttp2_ping_create(false, pq->inflight_id));
- GRPC_STATS_INC_HTTP2_PINGS_SENT(exec_ctx);
+ GRPC_STATS_INC_HTTP2_PINGS_SENT();
t->ping_state.last_ping_sent_time = now;
if (GRPC_TRACER_ON(grpc_http_trace) ||
GRPC_TRACER_ON(grpc_bdp_estimator_trace)) {
@@ -114,10 +112,9 @@ static void maybe_initiate_ping(grpc_exec_ctx* exec_ctx,
(t->ping_state.pings_before_data_required != 0);
}
-static bool update_list(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
- grpc_chttp2_stream* s, int64_t send_bytes,
- grpc_chttp2_write_cb** list, int64_t* ctr,
- grpc_error* error) {
+static bool update_list(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
+ int64_t send_bytes, grpc_chttp2_write_cb** list,
+ int64_t* ctr, grpc_error* error) {
bool sched_any = false;
grpc_chttp2_write_cb* cb = *list;
*list = nullptr;
@@ -126,7 +123,7 @@ static bool update_list(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
grpc_chttp2_write_cb* next = cb->next;
if (cb->call_at_byte <= *ctr) {
sched_any = true;
- finish_write_cb(exec_ctx, t, s, cb, GRPC_ERROR_REF(error));
+ finish_write_cb(t, s, cb, GRPC_ERROR_REF(error));
} else {
add_to_write_list(list, cb);
}
@@ -179,22 +176,22 @@ class StreamWriteContext;
class WriteContext {
public:
- WriteContext(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t) : t_(t) {
- GRPC_STATS_INC_HTTP2_WRITES_BEGUN(exec_ctx);
+ WriteContext(grpc_chttp2_transport* t) : t_(t) {
+ GRPC_STATS_INC_HTTP2_WRITES_BEGUN();
GPR_TIMER_BEGIN("grpc_chttp2_begin_write", 0);
}
// TODO(ctiller): make this the destructor
- void FlushStats(grpc_exec_ctx* exec_ctx) {
+ void FlushStats() {
GRPC_STATS_INC_HTTP2_SEND_INITIAL_METADATA_PER_WRITE(
- exec_ctx, initial_metadata_writes_);
- GRPC_STATS_INC_HTTP2_SEND_MESSAGE_PER_WRITE(exec_ctx, message_writes_);
+ initial_metadata_writes_);
+ GRPC_STATS_INC_HTTP2_SEND_MESSAGE_PER_WRITE(message_writes_);
GRPC_STATS_INC_HTTP2_SEND_TRAILING_METADATA_PER_WRITE(
- exec_ctx, trailing_metadata_writes_);
- GRPC_STATS_INC_HTTP2_SEND_FLOWCTL_PER_WRITE(exec_ctx, flow_control_writes_);
+ trailing_metadata_writes_);
+ GRPC_STATS_INC_HTTP2_SEND_FLOWCTL_PER_WRITE(flow_control_writes_);
}
- void FlushSettings(grpc_exec_ctx* exec_ctx) {
+ void FlushSettings() {
if (t_->dirtied_local_settings && !t_->sent_local_settings) {
grpc_slice_buffer_add(
&t_->outbuf, grpc_chttp2_settings_create(
@@ -204,17 +201,17 @@ class WriteContext {
t_->force_send_settings = false;
t_->dirtied_local_settings = false;
t_->sent_local_settings = true;
- GRPC_STATS_INC_HTTP2_SETTINGS_WRITES(exec_ctx);
+ GRPC_STATS_INC_HTTP2_SETTINGS_WRITES();
}
}
- void FlushQueuedBuffers(grpc_exec_ctx* exec_ctx) {
+ void FlushQueuedBuffers() {
/* simple writes are queued to qbuf, and flushed here */
grpc_slice_buffer_move_into(&t_->qbuf, &t_->outbuf);
GPR_ASSERT(t_->qbuf.count == 0);
}
- void FlushWindowUpdates(grpc_exec_ctx* exec_ctx) {
+ void FlushWindowUpdates() {
uint32_t transport_announce =
t_->flow_control->MaybeSendUpdate(t_->outbuf.count > 0);
if (transport_announce) {
@@ -234,7 +231,7 @@ class WriteContext {
t_->ping_ack_count = 0;
}
- void EnactHpackSettings(grpc_exec_ctx* exec_ctx) {
+ void EnactHpackSettings() {
grpc_chttp2_hpack_compressor_set_max_table_size(
&t_->hpack_compressor,
t_->settings[GRPC_PEER_SETTINGS]
@@ -374,8 +371,8 @@ class DataSendContext {
bool is_last_frame() const { return is_last_frame_; }
- void CallCallbacks(grpc_exec_ctx* exec_ctx) {
- if (update_list(exec_ctx, t_, s_,
+ void CallCallbacks() {
+ if (update_list(t_, s_,
(int64_t)(s_->sending_bytes - sending_bytes_before_),
&s_->on_flow_controlled_cbs,
&s_->flow_controlled_bytes_flowed, GRPC_ERROR_NONE)) {
@@ -403,7 +400,7 @@ class StreamWriteContext {
s->flow_control->announced_window_delta())));
}
- void FlushInitialMetadata(grpc_exec_ctx* exec_ctx) {
+ void FlushInitialMetadata() {
/* send initial metadata if it's available */
if (s_->sent_initial_metadata) return;
if (s_->send_initial_metadata == nullptr) return;
@@ -430,7 +427,7 @@ class StreamWriteContext {
[GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], // max_frame_size
&s_->stats.outgoing // stats
};
- grpc_chttp2_encode_header(exec_ctx, &t_->hpack_compressor, nullptr, 0,
+ grpc_chttp2_encode_header(&t_->hpack_compressor, nullptr, 0,
s_->send_initial_metadata, &hopt, &t_->outbuf);
write_context_->ResetPingRecvClock();
write_context_->IncInitialMetadataWrites();
@@ -440,11 +437,11 @@ class StreamWriteContext {
s_->sent_initial_metadata = true;
write_context_->NoteScheduledResults();
grpc_chttp2_complete_closure_step(
- exec_ctx, t_, s_, &s_->send_initial_metadata_finished, GRPC_ERROR_NONE,
+ t_, s_, &s_->send_initial_metadata_finished, GRPC_ERROR_NONE,
"send_initial_metadata_finished");
}
- void FlushWindowUpdates(grpc_exec_ctx* exec_ctx) {
+ void FlushWindowUpdates() {
/* send any window updates */
const uint32_t stream_announce = s_->flow_control->MaybeSendUpdate();
if (stream_announce == 0) return;
@@ -456,7 +453,7 @@ class StreamWriteContext {
write_context_->IncWindowUpdateWrites();
}
- void FlushData(grpc_exec_ctx* exec_ctx) {
+ void FlushData() {
if (!s_->sent_initial_metadata) return;
if (s_->flow_controlled_buffer.length == 0 &&
@@ -488,9 +485,9 @@ class StreamWriteContext {
}
write_context_->ResetPingRecvClock();
if (data_send_context.is_last_frame()) {
- SentLastFrame(exec_ctx);
+ SentLastFrame();
}
- data_send_context.CallCallbacks(exec_ctx);
+ data_send_context.CallCallbacks();
stream_became_writable_ = true;
if (s_->flow_controlled_buffer.length > 0 ||
s_->compressed_data_buffer.length > 0) {
@@ -500,7 +497,7 @@ class StreamWriteContext {
write_context_->IncMessageWrites();
}
- void FlushTrailingMetadata(grpc_exec_ctx* exec_ctx) {
+ void FlushTrailingMetadata() {
if (!s_->sent_initial_metadata) return;
if (s_->send_trailing_metadata == nullptr) return;
@@ -521,18 +518,18 @@ class StreamWriteContext {
t_->settings[GRPC_PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE],
&s_->stats.outgoing};
- grpc_chttp2_encode_header(exec_ctx, &t_->hpack_compressor,
+ grpc_chttp2_encode_header(&t_->hpack_compressor,
extra_headers_for_trailing_metadata_,
num_extra_headers_for_trailing_metadata_,
s_->send_trailing_metadata, &hopt, &t_->outbuf);
}
write_context_->IncTrailingMetadataWrites();
write_context_->ResetPingRecvClock();
- SentLastFrame(exec_ctx);
+ SentLastFrame();
write_context_->NoteScheduledResults();
grpc_chttp2_complete_closure_step(
- exec_ctx, t_, s_, &s_->send_trailing_metadata_finished, GRPC_ERROR_NONE,
+ t_, s_, &s_->send_trailing_metadata_finished, GRPC_ERROR_NONE,
"send_trailing_metadata_finished");
}
@@ -556,7 +553,7 @@ class StreamWriteContext {
}
}
- void SentLastFrame(grpc_exec_ctx* exec_ctx) {
+ void SentLastFrame() {
s_->send_trailing_metadata = nullptr;
s_->sent_trailing_metadata = true;
@@ -565,7 +562,7 @@ class StreamWriteContext {
&t_->outbuf, grpc_chttp2_rst_stream_create(
s_->id, GRPC_HTTP2_NO_ERROR, &s_->stats.outgoing));
}
- grpc_chttp2_mark_stream_closed(exec_ctx, t_, s_, !t_->is_client, true,
+ grpc_chttp2_mark_stream_closed(t_, s_, !t_->is_client, true,
GRPC_ERROR_NONE);
}
@@ -579,12 +576,12 @@ class StreamWriteContext {
} // namespace
grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
- grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t) {
- WriteContext ctx(exec_ctx, t);
- ctx.FlushSettings(exec_ctx);
+ grpc_chttp2_transport* t) {
+ WriteContext ctx(t);
+ ctx.FlushSettings();
ctx.FlushPingAcks();
- ctx.FlushQueuedBuffers(exec_ctx);
- ctx.EnactHpackSettings(exec_ctx);
+ ctx.FlushQueuedBuffers();
+ ctx.EnactHpackSettings();
if (t->flow_control->remote_window() > 0) {
ctx.UpdateStreamsNoLongerStalled();
@@ -594,47 +591,45 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
(according to available window sizes) and add to the output buffer */
while (grpc_chttp2_stream* s = ctx.NextStream()) {
StreamWriteContext stream_ctx(&ctx, s);
- stream_ctx.FlushInitialMetadata(exec_ctx);
- stream_ctx.FlushWindowUpdates(exec_ctx);
- stream_ctx.FlushData(exec_ctx);
- stream_ctx.FlushTrailingMetadata(exec_ctx);
+ stream_ctx.FlushInitialMetadata();
+ stream_ctx.FlushWindowUpdates();
+ stream_ctx.FlushData();
+ stream_ctx.FlushTrailingMetadata();
if (stream_ctx.stream_became_writable()) {
if (!grpc_chttp2_list_add_writing_stream(t, s)) {
/* already in writing list: drop ref */
- GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "chttp2_writing:already_writing");
+ GRPC_CHTTP2_STREAM_UNREF(s, "chttp2_writing:already_writing");
} else {
/* ref will be dropped at end of write */
}
} else {
- GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "chttp2_writing:no_write");
+ GRPC_CHTTP2_STREAM_UNREF(s, "chttp2_writing:no_write");
}
}
- ctx.FlushWindowUpdates(exec_ctx);
+ ctx.FlushWindowUpdates();
- maybe_initiate_ping(exec_ctx, t);
+ maybe_initiate_ping(t);
GPR_TIMER_END("grpc_chttp2_begin_write", 0);
return ctx.Result();
}
-void grpc_chttp2_end_write(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
- grpc_error* error) {
+void grpc_chttp2_end_write(grpc_chttp2_transport* t, grpc_error* error) {
GPR_TIMER_BEGIN("grpc_chttp2_end_write", 0);
grpc_chttp2_stream* s;
while (grpc_chttp2_list_pop_writing_stream(t, &s)) {
if (s->sending_bytes != 0) {
- update_list(exec_ctx, t, s, (int64_t)s->sending_bytes,
- &s->on_write_finished_cbs, &s->flow_controlled_bytes_written,
- GRPC_ERROR_REF(error));
+ update_list(t, s, (int64_t)s->sending_bytes, &s->on_write_finished_cbs,
+ &s->flow_controlled_bytes_written, GRPC_ERROR_REF(error));
s->sending_bytes = 0;
}
- GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "chttp2_writing:end");
+ GRPC_CHTTP2_STREAM_UNREF(s, "chttp2_writing:end");
}
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &t->outbuf);
+ grpc_slice_buffer_reset_and_unref_internal(&t->outbuf);
GRPC_ERROR_UNREF(error);
GPR_TIMER_END("grpc_chttp2_end_write", 0);
}
diff --git a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc
index d590ba0371..8e1dcc542e 100644
--- a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc
+++ b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc
@@ -49,7 +49,6 @@ GRPCAPI grpc_channel* grpc_cronet_secure_channel_create(
grpc_transport* ct =
grpc_create_cronet_transport(engine, target, args, reserved);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- return grpc_channel_create(&exec_ctx, target, args,
- GRPC_CLIENT_DIRECT_CHANNEL, ct);
+ grpc_core::ExecCtx _local_exec_ctx;
+ return grpc_channel_create(target, args, GRPC_CLIENT_DIRECT_CHANNEL, ct);
}
diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc
index 4d24efe47b..f9f47a4a12 100644
--- a/src/core/ext/transport/cronet/transport/cronet_transport.cc
+++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc
@@ -197,27 +197,23 @@ typedef struct stream_obj stream_obj;
#ifndef NDEBUG
#define GRPC_CRONET_STREAM_REF(stream, reason) \
grpc_cronet_stream_ref((stream), (reason))
-#define GRPC_CRONET_STREAM_UNREF(exec_ctx, stream, reason) \
- grpc_cronet_stream_unref((exec_ctx), (stream), (reason))
+#define GRPC_CRONET_STREAM_UNREF(stream, reason) \
+ grpc_cronet_stream_unref((stream), (reason))
void grpc_cronet_stream_ref(stream_obj* s, const char* reason) {
grpc_stream_ref(s->refcount, reason);
}
-void grpc_cronet_stream_unref(grpc_exec_ctx* exec_ctx, stream_obj* s,
- const char* reason) {
- grpc_stream_unref(exec_ctx, s->refcount, reason);
+void grpc_cronet_stream_unref(stream_obj* s, const char* reason) {
+ grpc_stream_unref(s->refcount, reason);
}
#else
#define GRPC_CRONET_STREAM_REF(stream, reason) grpc_cronet_stream_ref((stream))
-#define GRPC_CRONET_STREAM_UNREF(exec_ctx, stream, reason) \
- grpc_cronet_stream_unref((exec_ctx), (stream))
+#define GRPC_CRONET_STREAM_UNREF(stream, reason) \
+ grpc_cronet_stream_unref((stream))
void grpc_cronet_stream_ref(stream_obj* s) { grpc_stream_ref(s->refcount); }
-void grpc_cronet_stream_unref(grpc_exec_ctx* exec_ctx, stream_obj* s) {
- grpc_stream_unref(exec_ctx, s->refcount);
-}
+void grpc_cronet_stream_unref(stream_obj* s) { grpc_stream_unref(s->refcount); }
#endif
-static enum e_op_result execute_stream_op(grpc_exec_ctx* exec_ctx,
- struct op_and_state* oas);
+static enum e_op_result execute_stream_op(struct op_and_state* oas);
/*
Utility function to translate enum into string for printing
@@ -373,12 +369,12 @@ static void remove_from_storage(struct stream_obj* s,
This can get executed from the Cronet network thread via cronet callback
or on the application supplied thread via the perform_stream_op function.
*/
-static void execute_from_storage(grpc_exec_ctx* exec_ctx, stream_obj* s) {
+static void execute_from_storage(stream_obj* s) {
gpr_mu_lock(&s->mu);
for (struct op_and_state* curr = s->storage.head; curr != nullptr;) {
CRONET_LOG(GPR_DEBUG, "calling op at %p. done = %d", curr, curr->done);
GPR_ASSERT(curr->done == 0);
- enum e_op_result result = execute_stream_op(exec_ctx, curr);
+ enum e_op_result result = execute_stream_op(curr);
CRONET_LOG(GPR_DEBUG, "execute_stream_op[%p] returns %s", curr,
op_result_string(result));
/* if this op is done, then remove it and free memory */
@@ -402,7 +398,7 @@ static void execute_from_storage(grpc_exec_ctx* exec_ctx, stream_obj* s) {
*/
static void on_failed(bidirectional_stream* stream, int net_error) {
CRONET_LOG(GPR_DEBUG, "on_failed(%p, %d)", stream, net_error);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
stream_obj* s = (stream_obj*)stream->annotation;
gpr_mu_lock(&s->mu);
@@ -419,9 +415,8 @@ static void on_failed(bidirectional_stream* stream, int net_error) {
}
null_and_maybe_free_read_buffer(s);
gpr_mu_unlock(&s->mu);
- execute_from_storage(&exec_ctx, s);
- GRPC_CRONET_STREAM_UNREF(&exec_ctx, s, "cronet transport");
- grpc_exec_ctx_finish(&exec_ctx);
+ execute_from_storage(s);
+ GRPC_CRONET_STREAM_UNREF(s, "cronet transport");
}
/*
@@ -429,7 +424,7 @@ static void on_failed(bidirectional_stream* stream, int net_error) {
*/
static void on_canceled(bidirectional_stream* stream) {
CRONET_LOG(GPR_DEBUG, "on_canceled(%p)", stream);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
stream_obj* s = (stream_obj*)stream->annotation;
gpr_mu_lock(&s->mu);
@@ -446,9 +441,8 @@ static void on_canceled(bidirectional_stream* stream) {
}
null_and_maybe_free_read_buffer(s);
gpr_mu_unlock(&s->mu);
- execute_from_storage(&exec_ctx, s);
- GRPC_CRONET_STREAM_UNREF(&exec_ctx, s, "cronet transport");
- grpc_exec_ctx_finish(&exec_ctx);
+ execute_from_storage(s);
+ GRPC_CRONET_STREAM_UNREF(s, "cronet transport");
}
/*
@@ -456,7 +450,7 @@ static void on_canceled(bidirectional_stream* stream) {
*/
static void on_succeeded(bidirectional_stream* stream) {
CRONET_LOG(GPR_DEBUG, "on_succeeded(%p)", stream);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
stream_obj* s = (stream_obj*)stream->annotation;
gpr_mu_lock(&s->mu);
@@ -465,9 +459,8 @@ static void on_succeeded(bidirectional_stream* stream) {
s->cbs = nullptr;
null_and_maybe_free_read_buffer(s);
gpr_mu_unlock(&s->mu);
- execute_from_storage(&exec_ctx, s);
- GRPC_CRONET_STREAM_UNREF(&exec_ctx, s, "cronet transport");
- grpc_exec_ctx_finish(&exec_ctx);
+ execute_from_storage(s);
+ GRPC_CRONET_STREAM_UNREF(s, "cronet transport");
}
/*
@@ -475,7 +468,7 @@ static void on_succeeded(bidirectional_stream* stream) {
*/
static void on_stream_ready(bidirectional_stream* stream) {
CRONET_LOG(GPR_DEBUG, "W: on_stream_ready(%p)", stream);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
stream_obj* s = (stream_obj*)stream->annotation;
grpc_cronet_transport* t = (grpc_cronet_transport*)s->curr_ct;
gpr_mu_lock(&s->mu);
@@ -495,8 +488,7 @@ static void on_stream_ready(bidirectional_stream* stream) {
}
}
gpr_mu_unlock(&s->mu);
- execute_from_storage(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ execute_from_storage(s);
}
/*
@@ -506,7 +498,7 @@ static void on_response_headers_received(
bidirectional_stream* stream,
const bidirectional_stream_header_array* headers,
const char* negotiated_protocol) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
CRONET_LOG(GPR_DEBUG, "R: on_response_headers_received(%p, %p, %s)", stream,
headers, negotiated_protocol);
stream_obj* s = (stream_obj*)stream->annotation;
@@ -528,9 +520,8 @@ static void on_response_headers_received(
for (size_t i = 0; i < headers->count; i++) {
GRPC_LOG_IF_ERROR("on_response_headers_received",
grpc_chttp2_incoming_metadata_buffer_add(
- &exec_ctx, &s->state.rs.initial_metadata,
+ &s->state.rs.initial_metadata,
grpc_mdelem_from_slices(
- &exec_ctx,
grpc_slice_intern(grpc_slice_from_static_string(
headers->headers[i].key)),
grpc_slice_intern(grpc_slice_from_static_string(
@@ -552,15 +543,14 @@ static void on_response_headers_received(
s->state.pending_read_from_cronet = true;
}
gpr_mu_unlock(&s->mu);
- execute_from_storage(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ execute_from_storage(s);
}
/*
Cronet callback
*/
static void on_write_completed(bidirectional_stream* stream, const char* data) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
stream_obj* s = (stream_obj*)stream->annotation;
CRONET_LOG(GPR_DEBUG, "W: on_write_completed(%p, %s)", stream, data);
gpr_mu_lock(&s->mu);
@@ -570,8 +560,7 @@ static void on_write_completed(bidirectional_stream* stream, const char* data) {
}
s->state.state_callback_received[OP_SEND_MESSAGE] = true;
gpr_mu_unlock(&s->mu);
- execute_from_storage(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ execute_from_storage(s);
}
/*
@@ -579,7 +568,7 @@ static void on_write_completed(bidirectional_stream* stream, const char* data) {
*/
static void on_read_completed(bidirectional_stream* stream, char* data,
int count) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
stream_obj* s = (stream_obj*)stream->annotation;
CRONET_LOG(GPR_DEBUG, "R: on_read_completed(%p, %p, %d)", stream, data,
count);
@@ -605,15 +594,14 @@ static void on_read_completed(bidirectional_stream* stream, char* data,
gpr_mu_unlock(&s->mu);
} else {
gpr_mu_unlock(&s->mu);
- execute_from_storage(&exec_ctx, s);
+ execute_from_storage(s);
}
} else {
null_and_maybe_free_read_buffer(s);
s->state.rs.read_stream_closed = true;
gpr_mu_unlock(&s->mu);
- execute_from_storage(&exec_ctx, s);
+ execute_from_storage(s);
}
- grpc_exec_ctx_finish(&exec_ctx);
}
/*
@@ -622,7 +610,7 @@ static void on_read_completed(bidirectional_stream* stream, char* data,
static void on_response_trailers_received(
bidirectional_stream* stream,
const bidirectional_stream_header_array* trailers) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
CRONET_LOG(GPR_DEBUG, "R: on_response_trailers_received(%p,%p)", stream,
trailers);
stream_obj* s = (stream_obj*)stream->annotation;
@@ -638,9 +626,8 @@ static void on_response_trailers_received(
trailers->headers[i].value);
GRPC_LOG_IF_ERROR("on_response_trailers_received",
grpc_chttp2_incoming_metadata_buffer_add(
- &exec_ctx, &s->state.rs.trailing_metadata,
+ &s->state.rs.trailing_metadata,
grpc_mdelem_from_slices(
- &exec_ctx,
grpc_slice_intern(grpc_slice_from_static_string(
trailers->headers[i].key)),
grpc_slice_intern(grpc_slice_from_static_string(
@@ -670,17 +657,15 @@ static void on_response_trailers_received(
gpr_mu_unlock(&s->mu);
} else {
gpr_mu_unlock(&s->mu);
- execute_from_storage(&exec_ctx, s);
+ execute_from_storage(s);
}
- grpc_exec_ctx_finish(&exec_ctx);
}
/*
Utility function that takes the data from s->write_slice_buffer and assembles
into a contiguous byte stream with 5 byte gRPC header prepended.
*/
-static void create_grpc_frame(grpc_exec_ctx* exec_ctx,
- grpc_slice_buffer* write_slice_buffer,
+static void create_grpc_frame(grpc_slice_buffer* write_slice_buffer,
char** pp_write_buffer,
size_t* p_write_buffer_size, uint32_t flags) {
grpc_slice slice = grpc_slice_buffer_take_first(write_slice_buffer);
@@ -700,7 +685,7 @@ static void create_grpc_frame(grpc_exec_ctx* exec_ctx,
*p++ = (uint8_t)(length);
/* append actual data */
memcpy(p, GRPC_SLICE_START_PTR(slice), length);
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
}
/*
@@ -981,8 +966,7 @@ static bool op_can_be_run(grpc_transport_stream_op_batch* curr_op,
/*
TODO (makdharma): Break down this function in smaller chunks for readability.
*/
-static enum e_op_result execute_stream_op(grpc_exec_ctx* exec_ctx,
- struct op_and_state* oas) {
+static enum e_op_result execute_stream_op(struct op_and_state* oas) {
grpc_transport_stream_op_batch* stream_op = &oas->op;
struct stream_obj* s = oas->s;
grpc_cronet_transport* t = (grpc_cronet_transport*)s->curr_ct;
@@ -1040,15 +1024,14 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx* exec_ctx,
grpc_slice slice;
grpc_slice_buffer_init(&write_slice_buffer);
if (1 != grpc_byte_stream_next(
- exec_ctx, stream_op->payload->send_message.send_message,
+ stream_op->payload->send_message.send_message,
stream_op->payload->send_message.send_message->length,
nullptr)) {
/* Should never reach here */
GPR_ASSERT(false);
}
if (GRPC_ERROR_NONE !=
- grpc_byte_stream_pull(exec_ctx,
- stream_op->payload->send_message.send_message,
+ grpc_byte_stream_pull(stream_op->payload->send_message.send_message,
&slice)) {
/* Should never reach here */
GPR_ASSERT(false);
@@ -1061,15 +1044,15 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx* exec_ctx,
}
if (write_slice_buffer.count > 0) {
size_t write_buffer_size;
- create_grpc_frame(exec_ctx, &write_slice_buffer,
- &stream_state->ws.write_buffer, &write_buffer_size,
+ create_grpc_frame(&write_slice_buffer, &stream_state->ws.write_buffer,
+ &write_buffer_size,
stream_op->payload->send_message.send_message->flags);
CRONET_LOG(GPR_DEBUG, "bidirectional_stream_write (%p, %p)", s->cbs,
stream_state->ws.write_buffer);
stream_state->state_callback_received[OP_SEND_MESSAGE] = false;
bidirectional_stream_write(s->cbs, stream_state->ws.write_buffer,
(int)write_buffer_size, false);
- grpc_slice_buffer_destroy_internal(exec_ctx, &write_slice_buffer);
+ grpc_slice_buffer_destroy_internal(&write_slice_buffer);
if (t->use_packet_coalescing) {
if (!stream_op->send_trailing_metadata) {
CRONET_LOG(GPR_DEBUG, "bidirectional_stream_flush (%p)", s->cbs);
@@ -1112,25 +1095,21 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx* exec_ctx,
CRONET_LOG(GPR_DEBUG, "running: %p OP_RECV_INITIAL_METADATA", oas);
if (stream_state->state_op_done[OP_CANCEL_ERROR]) {
GRPC_CLOSURE_SCHED(
- exec_ctx,
stream_op->payload->recv_initial_metadata.recv_initial_metadata_ready,
GRPC_ERROR_NONE);
} else if (stream_state->state_callback_received[OP_FAILED]) {
GRPC_CLOSURE_SCHED(
- exec_ctx,
stream_op->payload->recv_initial_metadata.recv_initial_metadata_ready,
GRPC_ERROR_NONE);
} else if (stream_state->state_op_done[OP_RECV_TRAILING_METADATA]) {
GRPC_CLOSURE_SCHED(
- exec_ctx,
stream_op->payload->recv_initial_metadata.recv_initial_metadata_ready,
GRPC_ERROR_NONE);
} else {
grpc_chttp2_incoming_metadata_buffer_publish(
- exec_ctx, &oas->s->state.rs.initial_metadata,
+ &oas->s->state.rs.initial_metadata,
stream_op->payload->recv_initial_metadata.recv_initial_metadata);
GRPC_CLOSURE_SCHED(
- exec_ctx,
stream_op->payload->recv_initial_metadata.recv_initial_metadata_ready,
GRPC_ERROR_NONE);
}
@@ -1141,16 +1120,14 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx* exec_ctx,
CRONET_LOG(GPR_DEBUG, "running: %p OP_RECV_MESSAGE", oas);
if (stream_state->state_op_done[OP_CANCEL_ERROR]) {
CRONET_LOG(GPR_DEBUG, "Stream is cancelled.");
- GRPC_CLOSURE_SCHED(exec_ctx,
- stream_op->payload->recv_message.recv_message_ready,
+ GRPC_CLOSURE_SCHED(stream_op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE);
stream_state->state_op_done[OP_RECV_MESSAGE] = true;
oas->state.state_op_done[OP_RECV_MESSAGE] = true;
result = ACTION_TAKEN_NO_CALLBACK;
} else if (stream_state->state_callback_received[OP_FAILED]) {
CRONET_LOG(GPR_DEBUG, "Stream failed.");
- GRPC_CLOSURE_SCHED(exec_ctx,
- stream_op->payload->recv_message.recv_message_ready,
+ GRPC_CLOSURE_SCHED(stream_op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE);
stream_state->state_op_done[OP_RECV_MESSAGE] = true;
oas->state.state_op_done[OP_RECV_MESSAGE] = true;
@@ -1158,16 +1135,14 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx* exec_ctx,
} else if (stream_state->rs.read_stream_closed == true) {
/* No more data will be received */
CRONET_LOG(GPR_DEBUG, "read stream closed");
- GRPC_CLOSURE_SCHED(exec_ctx,
- stream_op->payload->recv_message.recv_message_ready,
+ GRPC_CLOSURE_SCHED(stream_op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE);
stream_state->state_op_done[OP_RECV_MESSAGE] = true;
oas->state.state_op_done[OP_RECV_MESSAGE] = true;
result = ACTION_TAKEN_NO_CALLBACK;
} else if (stream_state->flush_read) {
CRONET_LOG(GPR_DEBUG, "flush read");
- GRPC_CLOSURE_SCHED(exec_ctx,
- stream_op->payload->recv_message.recv_message_ready,
+ GRPC_CLOSURE_SCHED(stream_op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE);
stream_state->state_op_done[OP_RECV_MESSAGE] = true;
oas->state.state_op_done[OP_RECV_MESSAGE] = true;
@@ -1200,7 +1175,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx* exec_ctx,
CRONET_LOG(GPR_DEBUG, "read operation complete. Empty response.");
/* Clean up read_slice_buffer in case there is unread data. */
grpc_slice_buffer_destroy_internal(
- exec_ctx, &stream_state->rs.read_slice_buffer);
+ &stream_state->rs.read_slice_buffer);
grpc_slice_buffer_init(&stream_state->rs.read_slice_buffer);
grpc_slice_buffer_stream_init(&stream_state->rs.sbs,
&stream_state->rs.read_slice_buffer, 0);
@@ -1210,7 +1185,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx* exec_ctx,
*((grpc_byte_buffer**)stream_op->payload->recv_message.recv_message) =
(grpc_byte_buffer*)&stream_state->rs.sbs;
GRPC_CLOSURE_SCHED(
- exec_ctx, stream_op->payload->recv_message.recv_message_ready,
+ stream_op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE);
stream_state->state_op_done[OP_RECV_MESSAGE] = true;
oas->state.state_op_done[OP_RECV_MESSAGE] = true;
@@ -1254,8 +1229,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx* exec_ctx,
(size_t)stream_state->rs.length_field);
null_and_maybe_free_read_buffer(s);
/* Clean up read_slice_buffer in case there is unread data. */
- grpc_slice_buffer_destroy_internal(exec_ctx,
- &stream_state->rs.read_slice_buffer);
+ grpc_slice_buffer_destroy_internal(&stream_state->rs.read_slice_buffer);
grpc_slice_buffer_init(&stream_state->rs.read_slice_buffer);
grpc_slice_buffer_add(&stream_state->rs.read_slice_buffer,
read_data_slice);
@@ -1266,8 +1240,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx* exec_ctx,
}
*((grpc_byte_buffer**)stream_op->payload->recv_message.recv_message) =
(grpc_byte_buffer*)&stream_state->rs.sbs;
- GRPC_CLOSURE_SCHED(exec_ctx,
- stream_op->payload->recv_message.recv_message_ready,
+ GRPC_CLOSURE_SCHED(stream_op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE);
stream_state->state_op_done[OP_RECV_MESSAGE] = true;
oas->state.state_op_done[OP_RECV_MESSAGE] = true;
@@ -1290,7 +1263,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx* exec_ctx,
CRONET_LOG(GPR_DEBUG, "running: %p OP_RECV_TRAILING_METADATA", oas);
if (oas->s->state.rs.trailing_metadata_valid) {
grpc_chttp2_incoming_metadata_buffer_publish(
- exec_ctx, &oas->s->state.rs.trailing_metadata,
+ &oas->s->state.rs.trailing_metadata,
stream_op->payload->recv_trailing_metadata.recv_trailing_metadata);
stream_state->rs.trailing_metadata_valid = false;
}
@@ -1315,17 +1288,17 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx* exec_ctx,
op_can_be_run(stream_op, s, &oas->state, OP_ON_COMPLETE)) {
CRONET_LOG(GPR_DEBUG, "running: %p OP_ON_COMPLETE", oas);
if (stream_state->state_op_done[OP_CANCEL_ERROR]) {
- GRPC_CLOSURE_SCHED(exec_ctx, stream_op->on_complete,
+ GRPC_CLOSURE_SCHED(stream_op->on_complete,
GRPC_ERROR_REF(stream_state->cancel_error));
} else if (stream_state->state_callback_received[OP_FAILED]) {
GRPC_CLOSURE_SCHED(
- exec_ctx, stream_op->on_complete,
+ stream_op->on_complete,
make_error_with_desc(GRPC_STATUS_UNAVAILABLE, "Unavailable."));
} else {
/* All actions in this stream_op are complete. Call the on_complete
* callback
*/
- GRPC_CLOSURE_SCHED(exec_ctx, stream_op->on_complete, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(stream_op->on_complete, GRPC_ERROR_NONE);
}
oas->state.state_op_done[OP_ON_COMPLETE] = true;
oas->done = true;
@@ -1350,9 +1323,9 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx* exec_ctx,
Functions used by upper layers to access transport functionality.
*/
-static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
- grpc_stream* gs, grpc_stream_refcount* refcount,
- const void* server_data, gpr_arena* arena) {
+static int init_stream(grpc_transport* gt, grpc_stream* gs,
+ grpc_stream_refcount* refcount, const void* server_data,
+ gpr_arena* arena) {
stream_obj* s = (stream_obj*)gs;
s->refcount = refcount;
@@ -1383,15 +1356,13 @@ static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
return 0;
}
-static void set_pollset_do_nothing(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
- grpc_stream* gs, grpc_pollset* pollset) {}
+static void set_pollset_do_nothing(grpc_transport* gt, grpc_stream* gs,
+ grpc_pollset* pollset) {}
-static void set_pollset_set_do_nothing(grpc_exec_ctx* exec_ctx,
- grpc_transport* gt, grpc_stream* gs,
+static void set_pollset_set_do_nothing(grpc_transport* gt, grpc_stream* gs,
grpc_pollset_set* pollset_set) {}
-static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
- grpc_stream* gs,
+static void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
grpc_transport_stream_op_batch* op) {
CRONET_LOG(GPR_DEBUG, "perform_stream_op");
if (op->send_initial_metadata &&
@@ -1401,42 +1372,36 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
this field is present in metadata */
if (op->recv_initial_metadata) {
GRPC_CLOSURE_SCHED(
- exec_ctx,
op->payload->recv_initial_metadata.recv_initial_metadata_ready,
GRPC_ERROR_CANCELLED);
}
if (op->recv_message) {
- GRPC_CLOSURE_SCHED(exec_ctx, op->payload->recv_message.recv_message_ready,
+ GRPC_CLOSURE_SCHED(op->payload->recv_message.recv_message_ready,
GRPC_ERROR_CANCELLED);
}
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_complete, GRPC_ERROR_CANCELLED);
+ GRPC_CLOSURE_SCHED(op->on_complete, GRPC_ERROR_CANCELLED);
return;
}
stream_obj* s = (stream_obj*)gs;
add_to_storage(s, op);
- execute_from_storage(exec_ctx, s);
+ execute_from_storage(s);
}
-static void destroy_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
- grpc_stream* gs,
+static void destroy_stream(grpc_transport* gt, grpc_stream* gs,
grpc_closure* then_schedule_closure) {
stream_obj* s = (stream_obj*)gs;
null_and_maybe_free_read_buffer(s);
/* Clean up read_slice_buffer in case there is unread data. */
- grpc_slice_buffer_destroy_internal(exec_ctx, &s->state.rs.read_slice_buffer);
+ grpc_slice_buffer_destroy_internal(&s->state.rs.read_slice_buffer);
GRPC_ERROR_UNREF(s->state.cancel_error);
- GRPC_CLOSURE_SCHED(exec_ctx, then_schedule_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(then_schedule_closure, GRPC_ERROR_NONE);
}
-static void destroy_transport(grpc_exec_ctx* exec_ctx, grpc_transport* gt) {}
+static void destroy_transport(grpc_transport* gt) {}
-static grpc_endpoint* get_endpoint(grpc_exec_ctx* exec_ctx,
- grpc_transport* gt) {
- return nullptr;
-}
+static grpc_endpoint* get_endpoint(grpc_transport* gt) { return nullptr; }
-static void perform_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
- grpc_transport_op* op) {}
+static void perform_op(grpc_transport* gt, grpc_transport_op* op) {}
static const grpc_transport_vtable grpc_cronet_vtable = {
sizeof(stream_obj),
diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc
index 7ea08b05bb..4ce870f7c3 100644
--- a/src/core/ext/transport/inproc/inproc_transport.cc
+++ b/src/core/ext/transport/inproc/inproc_transport.cc
@@ -54,8 +54,8 @@ typedef struct inproc_transport {
gpr_refcount refs;
bool is_client;
grpc_connectivity_state_tracker connectivity;
- void (*accept_stream_cb)(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_transport* transport, const void* server_data);
+ void (*accept_stream_cb)(void* user_data, grpc_transport* transport,
+ const void* server_data);
void* accept_stream_data;
bool is_closed;
struct inproc_transport* other_side;
@@ -118,39 +118,36 @@ typedef struct inproc_stream {
} inproc_stream;
static grpc_closure do_nothing_closure;
-static bool cancel_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
- grpc_error* error);
-static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error);
+static bool cancel_stream_locked(inproc_stream* s, grpc_error* error);
+static void op_state_machine(void* arg, grpc_error* error);
static void ref_transport(inproc_transport* t) {
INPROC_LOG(GPR_DEBUG, "ref_transport %p", t);
gpr_ref(&t->refs);
}
-static void really_destroy_transport(grpc_exec_ctx* exec_ctx,
- inproc_transport* t) {
+static void really_destroy_transport(inproc_transport* t) {
INPROC_LOG(GPR_DEBUG, "really_destroy_transport %p", t);
- grpc_connectivity_state_destroy(exec_ctx, &t->connectivity);
+ grpc_connectivity_state_destroy(&t->connectivity);
if (gpr_unref(&t->mu->refs)) {
gpr_free(t->mu);
}
gpr_free(t);
}
-static void unref_transport(grpc_exec_ctx* exec_ctx, inproc_transport* t) {
+static void unref_transport(inproc_transport* t) {
INPROC_LOG(GPR_DEBUG, "unref_transport %p", t);
if (gpr_unref(&t->refs)) {
- really_destroy_transport(exec_ctx, t);
+ really_destroy_transport(t);
}
}
#ifndef NDEBUG
#define STREAM_REF(refs, reason) grpc_stream_ref(refs, reason)
-#define STREAM_UNREF(e, refs, reason) grpc_stream_unref(e, refs, reason)
+#define STREAM_UNREF(refs, reason) grpc_stream_unref(refs, reason)
#else
#define STREAM_REF(refs, reason) grpc_stream_ref(refs)
-#define STREAM_UNREF(e, refs, reason) grpc_stream_unref(e, refs)
+#define STREAM_UNREF(refs, reason) grpc_stream_unref(refs)
#endif
static void ref_stream(inproc_stream* s, const char* reason) {
@@ -158,13 +155,12 @@ static void ref_stream(inproc_stream* s, const char* reason) {
STREAM_REF(s->refs, reason);
}
-static void unref_stream(grpc_exec_ctx* exec_ctx, inproc_stream* s,
- const char* reason) {
+static void unref_stream(inproc_stream* s, const char* reason) {
INPROC_LOG(GPR_DEBUG, "unref_stream %p %s", s, reason);
- STREAM_UNREF(exec_ctx, s->refs, reason);
+ STREAM_UNREF(s->refs, reason);
}
-static void really_destroy_stream(grpc_exec_ctx* exec_ctx, inproc_stream* s) {
+static void really_destroy_stream(inproc_stream* s) {
INPROC_LOG(GPR_DEBUG, "really_destroy_stream %p", s);
GRPC_ERROR_UNREF(s->write_buffer_cancel_error);
@@ -172,13 +168,13 @@ static void really_destroy_stream(grpc_exec_ctx* exec_ctx, inproc_stream* s) {
GRPC_ERROR_UNREF(s->cancel_other_error);
if (s->recv_inited) {
- grpc_slice_buffer_destroy_internal(exec_ctx, &s->recv_message);
+ grpc_slice_buffer_destroy_internal(&s->recv_message);
}
- unref_transport(exec_ctx, s->t);
+ unref_transport(s->t);
if (s->closure_at_destroy) {
- GRPC_CLOSURE_SCHED(exec_ctx, s->closure_at_destroy, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(s->closure_at_destroy, GRPC_ERROR_NONE);
}
}
@@ -195,7 +191,7 @@ static void log_metadata(const grpc_metadata_batch* md_batch, bool is_client,
}
}
-static grpc_error* fill_in_metadata(grpc_exec_ctx* exec_ctx, inproc_stream* s,
+static grpc_error* fill_in_metadata(inproc_stream* s,
const grpc_metadata_batch* metadata,
uint32_t flags, grpc_metadata_batch* out_md,
uint32_t* outflags, bool* markfilled) {
@@ -214,18 +210,18 @@ static grpc_error* fill_in_metadata(grpc_exec_ctx* exec_ctx, inproc_stream* s,
(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(
- exec_ctx, grpc_slice_intern(GRPC_MDKEY(elem->md)),
- grpc_slice_intern(GRPC_MDVALUE(elem->md)));
+ nelem->md =
+ grpc_mdelem_from_slices(grpc_slice_intern(GRPC_MDKEY(elem->md)),
+ grpc_slice_intern(GRPC_MDVALUE(elem->md)));
- error = grpc_metadata_batch_link_tail(exec_ctx, out_md, nelem);
+ error = grpc_metadata_batch_link_tail(out_md, nelem);
}
return error;
}
-static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
- grpc_stream* gs, grpc_stream_refcount* refcount,
- const void* server_data, gpr_arena* arena) {
+static int init_stream(grpc_transport* gt, grpc_stream* gs,
+ grpc_stream_refcount* refcount, const void* server_data,
+ gpr_arena* arena) {
INPROC_LOG(GPR_DEBUG, "init_stream %p %p %p", gt, gs, server_data);
inproc_transport* t = (inproc_transport*)gt;
inproc_stream* s = (inproc_stream*)gs;
@@ -285,8 +281,7 @@ static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
// side to avoid destruction
INPROC_LOG(GPR_DEBUG, "calling accept stream cb %p %p",
st->accept_stream_cb, st->accept_stream_data);
- (*st->accept_stream_cb)(exec_ctx, st->accept_stream_data, &st->base,
- (void*)s);
+ (*st->accept_stream_cb)(st->accept_stream_data, &st->base, (void*)s);
} else {
// This is the server-side and is being called through accept_stream_cb
inproc_stream* cs = (inproc_stream*)server_data;
@@ -301,19 +296,19 @@ static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
// Now transfer from the other side's write_buffer if any to the to_read
// buffer
if (cs->write_buffer_initial_md_filled) {
- fill_in_metadata(exec_ctx, s, &cs->write_buffer_initial_md,
+ fill_in_metadata(s, &cs->write_buffer_initial_md,
cs->write_buffer_initial_md_flags,
&s->to_read_initial_md, &s->to_read_initial_md_flags,
&s->to_read_initial_md_filled);
s->deadline = GPR_MIN(s->deadline, cs->write_buffer_deadline);
- grpc_metadata_batch_clear(exec_ctx, &cs->write_buffer_initial_md);
+ grpc_metadata_batch_clear(&cs->write_buffer_initial_md);
cs->write_buffer_initial_md_filled = false;
}
if (cs->write_buffer_trailing_md_filled) {
- fill_in_metadata(exec_ctx, s, &cs->write_buffer_trailing_md, 0,
+ fill_in_metadata(s, &cs->write_buffer_trailing_md, 0,
&s->to_read_trailing_md, nullptr,
&s->to_read_trailing_md_filled);
- grpc_metadata_batch_clear(exec_ctx, &cs->write_buffer_trailing_md);
+ grpc_metadata_batch_clear(&cs->write_buffer_trailing_md);
cs->write_buffer_trailing_md_filled = false;
}
if (cs->write_buffer_cancel_error != GRPC_ERROR_NONE) {
@@ -326,11 +321,11 @@ static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
return 0; // return value is not important
}
-static void close_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s) {
+static void close_stream_locked(inproc_stream* s) {
if (!s->closed) {
// Release the metadata that we would have written out
- grpc_metadata_batch_destroy(exec_ctx, &s->write_buffer_initial_md);
- grpc_metadata_batch_destroy(exec_ctx, &s->write_buffer_trailing_md);
+ grpc_metadata_batch_destroy(&s->write_buffer_initial_md);
+ grpc_metadata_batch_destroy(&s->write_buffer_trailing_md);
if (s->listed) {
inproc_stream* p = s->stream_list_prev;
@@ -344,22 +339,21 @@ static void close_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s) {
n->stream_list_prev = p;
}
s->listed = false;
- unref_stream(exec_ctx, s, "close_stream:list");
+ unref_stream(s, "close_stream:list");
}
s->closed = true;
- unref_stream(exec_ctx, s, "close_stream:closing");
+ unref_stream(s, "close_stream:closing");
}
}
// This function means that we are done talking/listening to the other side
-static void close_other_side_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
- const char* reason) {
+static void close_other_side_locked(inproc_stream* s, const char* reason) {
if (s->other_side != nullptr) {
// First release the metadata that came from the other side's arena
- grpc_metadata_batch_destroy(exec_ctx, &s->to_read_initial_md);
- grpc_metadata_batch_destroy(exec_ctx, &s->to_read_trailing_md);
+ grpc_metadata_batch_destroy(&s->to_read_initial_md);
+ grpc_metadata_batch_destroy(&s->to_read_trailing_md);
- unref_stream(exec_ctx, s->other_side, reason);
+ unref_stream(s->other_side, reason);
s->other_side_closed = true;
s->other_side = nullptr;
} else if (!s->other_side_closed) {
@@ -371,8 +365,7 @@ static void close_other_side_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
// this stream_op_batch is only one of the pending operations for this
// stream. This is called when one of the pending operations for the stream
// is done and about to be NULLed out
-static void complete_if_batch_end_locked(grpc_exec_ctx* exec_ctx,
- inproc_stream* s, grpc_error* error,
+static void complete_if_batch_end_locked(inproc_stream* s, grpc_error* error,
grpc_transport_stream_op_batch* op,
const char* msg) {
int is_sm = (int)(op == s->send_message_op);
@@ -383,22 +376,20 @@ static void complete_if_batch_end_locked(grpc_exec_ctx* exec_ctx,
if ((is_sm + is_stm + is_rim + is_rm + is_rtm) == 1) {
INPROC_LOG(GPR_DEBUG, "%s %p %p %p", msg, s, op, error);
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_complete, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(op->on_complete, GRPC_ERROR_REF(error));
}
}
-static void maybe_schedule_op_closure_locked(grpc_exec_ctx* exec_ctx,
- inproc_stream* s,
+static void maybe_schedule_op_closure_locked(inproc_stream* s,
grpc_error* error) {
if (s && s->ops_needed && !s->op_closure_scheduled) {
- GRPC_CLOSURE_SCHED(exec_ctx, &s->op_closure, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(&s->op_closure, GRPC_ERROR_REF(error));
s->op_closure_scheduled = true;
s->ops_needed = false;
}
}
-static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
- grpc_error* error) {
+static void fail_helper_locked(inproc_stream* s, grpc_error* error) {
INPROC_LOG(GPR_DEBUG, "op_state_machine %p fail_helper", s);
// If we're failing this side, we need to make sure that
// we also send or have already sent trailing metadata
@@ -415,14 +406,14 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
: &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);
+ fill_in_metadata(s, &fake_md, 0, dest, nullptr, destfilled);
+ grpc_metadata_batch_destroy(&fake_md);
if (other != nullptr) {
if (other->cancel_other_error == GRPC_ERROR_NONE) {
other->cancel_other_error = GRPC_ERROR_REF(error);
}
- maybe_schedule_op_closure_locked(exec_ctx, other, error);
+ maybe_schedule_op_closure_locked(other, error);
} else if (s->write_buffer_cancel_error == GRPC_ERROR_NONE) {
s->write_buffer_cancel_error = GRPC_ERROR_REF(error);
}
@@ -436,24 +427,22 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
grpc_metadata_batch_init(&fake_md);
grpc_linked_mdelem* path_md =
(grpc_linked_mdelem*)gpr_arena_alloc(s->arena, sizeof(*path_md));
- path_md->md =
- grpc_mdelem_from_slices(exec_ctx, g_fake_path_key, g_fake_path_value);
- GPR_ASSERT(grpc_metadata_batch_link_tail(exec_ctx, &fake_md, path_md) ==
+ path_md->md = grpc_mdelem_from_slices(g_fake_path_key, g_fake_path_value);
+ GPR_ASSERT(grpc_metadata_batch_link_tail(&fake_md, path_md) ==
GRPC_ERROR_NONE);
grpc_linked_mdelem* auth_md =
(grpc_linked_mdelem*)gpr_arena_alloc(s->arena, sizeof(*auth_md));
- auth_md->md =
- grpc_mdelem_from_slices(exec_ctx, g_fake_auth_key, g_fake_auth_value);
- GPR_ASSERT(grpc_metadata_batch_link_tail(exec_ctx, &fake_md, auth_md) ==
+ auth_md->md = grpc_mdelem_from_slices(g_fake_auth_key, g_fake_auth_value);
+ GPR_ASSERT(grpc_metadata_batch_link_tail(&fake_md, auth_md) ==
GRPC_ERROR_NONE);
fill_in_metadata(
- exec_ctx, s, &fake_md, 0,
+ s, &fake_md, 0,
s->recv_initial_md_op->payload->recv_initial_metadata
.recv_initial_metadata,
s->recv_initial_md_op->payload->recv_initial_metadata.recv_flags,
nullptr);
- grpc_metadata_batch_destroy(exec_ctx, &fake_md);
+ grpc_metadata_batch_destroy(&fake_md);
err = GRPC_ERROR_NONE;
} else {
err = GRPC_ERROR_REF(error);
@@ -461,14 +450,13 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
INPROC_LOG(GPR_DEBUG,
"fail_helper %p scheduling initial-metadata-ready %p %p", s,
error, err);
- GRPC_CLOSURE_SCHED(exec_ctx,
- s->recv_initial_md_op->payload->recv_initial_metadata
+ GRPC_CLOSURE_SCHED(s->recv_initial_md_op->payload->recv_initial_metadata
.recv_initial_metadata_ready,
err);
// Last use of err so no need to REF and then UNREF it
complete_if_batch_end_locked(
- exec_ctx, s, error, s->recv_initial_md_op,
+ s, error, s->recv_initial_md_op,
"fail_helper scheduling recv-initial-metadata-on-complete");
s->recv_initial_md_op = nullptr;
}
@@ -476,22 +464,22 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
INPROC_LOG(GPR_DEBUG, "fail_helper %p scheduling message-ready %p", s,
error);
GRPC_CLOSURE_SCHED(
- exec_ctx, s->recv_message_op->payload->recv_message.recv_message_ready,
+ s->recv_message_op->payload->recv_message.recv_message_ready,
GRPC_ERROR_REF(error));
complete_if_batch_end_locked(
- exec_ctx, s, error, s->recv_message_op,
+ s, error, s->recv_message_op,
"fail_helper scheduling recv-message-on-complete");
s->recv_message_op = nullptr;
}
if (s->send_message_op) {
complete_if_batch_end_locked(
- exec_ctx, s, error, s->send_message_op,
+ s, error, s->send_message_op,
"fail_helper scheduling send-message-on-complete");
s->send_message_op = nullptr;
}
if (s->send_trailing_md_op) {
complete_if_batch_end_locked(
- exec_ctx, s, error, s->send_trailing_md_op,
+ s, error, s->send_trailing_md_op,
"fail_helper scheduling send-trailng-md-on-complete");
s->send_trailing_md_op = nullptr;
}
@@ -500,23 +488,22 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
"fail_helper %p scheduling trailing-md-on-complete %p", s,
error);
complete_if_batch_end_locked(
- exec_ctx, s, error, s->recv_trailing_md_op,
+ s, error, s->recv_trailing_md_op,
"fail_helper scheduling recv-trailing-metadata-on-complete");
s->recv_trailing_md_op = nullptr;
}
- close_other_side_locked(exec_ctx, s, "fail_helper:other_side");
- close_stream_locked(exec_ctx, s);
+ close_other_side_locked(s, "fail_helper:other_side");
+ close_stream_locked(s);
GRPC_ERROR_UNREF(error);
}
-static void message_transfer_locked(grpc_exec_ctx* exec_ctx,
- inproc_stream* sender,
+static void message_transfer_locked(inproc_stream* sender,
inproc_stream* receiver) {
size_t remaining =
sender->send_message_op->payload->send_message.send_message->length;
if (receiver->recv_inited) {
- grpc_slice_buffer_destroy_internal(exec_ctx, &receiver->recv_message);
+ grpc_slice_buffer_destroy_internal(&receiver->recv_message);
}
grpc_slice_buffer_init(&receiver->recv_message);
receiver->recv_inited = true;
@@ -524,13 +511,13 @@ static void message_transfer_locked(grpc_exec_ctx* exec_ctx,
grpc_slice message_slice;
grpc_closure unused;
GPR_ASSERT(grpc_byte_stream_next(
- exec_ctx, sender->send_message_op->payload->send_message.send_message,
- SIZE_MAX, &unused));
+ sender->send_message_op->payload->send_message.send_message, SIZE_MAX,
+ &unused));
grpc_error* error = grpc_byte_stream_pull(
- exec_ctx, sender->send_message_op->payload->send_message.send_message,
+ sender->send_message_op->payload->send_message.send_message,
&message_slice);
if (error != GRPC_ERROR_NONE) {
- cancel_stream_locked(exec_ctx, sender, GRPC_ERROR_REF(error));
+ cancel_stream_locked(sender, GRPC_ERROR_REF(error));
break;
}
GPR_ASSERT(error == GRPC_ERROR_NONE);
@@ -545,22 +532,20 @@ static void message_transfer_locked(grpc_exec_ctx* exec_ctx,
INPROC_LOG(GPR_DEBUG, "message_transfer_locked %p scheduling message-ready",
receiver);
GRPC_CLOSURE_SCHED(
- exec_ctx,
receiver->recv_message_op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE);
complete_if_batch_end_locked(
- exec_ctx, sender, GRPC_ERROR_NONE, sender->send_message_op,
+ sender, GRPC_ERROR_NONE, sender->send_message_op,
"message_transfer scheduling sender on_complete");
complete_if_batch_end_locked(
- exec_ctx, receiver, GRPC_ERROR_NONE, receiver->recv_message_op,
+ receiver, GRPC_ERROR_NONE, receiver->recv_message_op,
"message_transfer scheduling receiver on_complete");
receiver->recv_message_op = nullptr;
sender->send_message_op = nullptr;
}
-static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void op_state_machine(void* arg, grpc_error* error) {
// This function gets called when we have contents in the unprocessed reads
// Get what we want based on our ops wanted
// Schedule our appropriate closures
@@ -581,26 +566,26 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
inproc_stream* other = s->other_side;
if (s->cancel_self_error != GRPC_ERROR_NONE) {
- fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(s->cancel_self_error));
+ fail_helper_locked(s, GRPC_ERROR_REF(s->cancel_self_error));
goto done;
} else if (s->cancel_other_error != GRPC_ERROR_NONE) {
- fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(s->cancel_other_error));
+ fail_helper_locked(s, GRPC_ERROR_REF(s->cancel_other_error));
goto done;
} else if (error != GRPC_ERROR_NONE) {
- fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(error));
+ fail_helper_locked(s, GRPC_ERROR_REF(error));
goto done;
}
if (s->send_message_op && other) {
if (other->recv_message_op) {
- message_transfer_locked(exec_ctx, s, other);
- maybe_schedule_op_closure_locked(exec_ctx, other, GRPC_ERROR_NONE);
+ message_transfer_locked(s, other);
+ maybe_schedule_op_closure_locked(other, GRPC_ERROR_NONE);
} else if (!s->t->is_client &&
(s->trailing_md_sent || other->recv_trailing_md_op)) {
// A server send will never be matched if the client is waiting
// for trailing metadata already
complete_if_batch_end_locked(
- exec_ctx, s, GRPC_ERROR_NONE, s->send_message_op,
+ s, GRPC_ERROR_NONE, s->send_message_op,
"op_state_machine scheduling send-message-on-complete");
s->send_message_op = nullptr;
}
@@ -622,11 +607,11 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
// The buffer is already in use; that's an error!
INPROC_LOG(GPR_DEBUG, "Extra trailing metadata %p", s);
new_err = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Extra trailing metadata");
- fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err));
+ fail_helper_locked(s, GRPC_ERROR_REF(new_err));
goto done;
} else {
if (!other || !other->closed) {
- fill_in_metadata(exec_ctx, s,
+ fill_in_metadata(s,
s->send_trailing_md_op->payload->send_trailing_metadata
.send_trailing_metadata,
0, dest, nullptr, destfilled);
@@ -635,15 +620,15 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
if (!s->t->is_client && s->trailing_md_recvd && s->recv_trailing_md_op) {
INPROC_LOG(GPR_DEBUG,
"op_state_machine %p scheduling trailing-md-on-complete", s);
- GRPC_CLOSURE_SCHED(exec_ctx, s->recv_trailing_md_op->on_complete,
+ GRPC_CLOSURE_SCHED(s->recv_trailing_md_op->on_complete,
GRPC_ERROR_NONE);
s->recv_trailing_md_op = nullptr;
needs_close = true;
}
}
- maybe_schedule_op_closure_locked(exec_ctx, other, GRPC_ERROR_NONE);
+ maybe_schedule_op_closure_locked(other, GRPC_ERROR_NONE);
complete_if_batch_end_locked(
- exec_ctx, s, GRPC_ERROR_NONE, s->send_trailing_md_op,
+ s, GRPC_ERROR_NONE, s->send_trailing_md_op,
"op_state_machine scheduling send-trailing-metadata-on-complete");
s->send_trailing_md_op = nullptr;
}
@@ -656,31 +641,30 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
"op_state_machine %p scheduling on_complete errors for already "
"recvd initial md %p",
s, new_err);
- fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err));
+ fail_helper_locked(s, GRPC_ERROR_REF(new_err));
goto done;
}
if (s->to_read_initial_md_filled) {
s->initial_md_recvd = true;
new_err = fill_in_metadata(
- exec_ctx, s, &s->to_read_initial_md, s->to_read_initial_md_flags,
+ s, &s->to_read_initial_md, s->to_read_initial_md_flags,
s->recv_initial_md_op->payload->recv_initial_metadata
.recv_initial_metadata,
s->recv_initial_md_op->payload->recv_initial_metadata.recv_flags,
nullptr);
s->recv_initial_md_op->payload->recv_initial_metadata
.recv_initial_metadata->deadline = s->deadline;
- grpc_metadata_batch_clear(exec_ctx, &s->to_read_initial_md);
+ grpc_metadata_batch_clear(&s->to_read_initial_md);
s->to_read_initial_md_filled = false;
INPROC_LOG(GPR_DEBUG,
"op_state_machine %p scheduling initial-metadata-ready %p", s,
new_err);
- GRPC_CLOSURE_SCHED(exec_ctx,
- s->recv_initial_md_op->payload->recv_initial_metadata
+ GRPC_CLOSURE_SCHED(s->recv_initial_md_op->payload->recv_initial_metadata
.recv_initial_metadata_ready,
GRPC_ERROR_REF(new_err));
complete_if_batch_end_locked(
- exec_ctx, s, new_err, s->recv_initial_md_op,
+ s, new_err, s->recv_initial_md_op,
"op_state_machine scheduling recv-initial-metadata-on-complete");
s->recv_initial_md_op = nullptr;
@@ -688,20 +672,20 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
INPROC_LOG(GPR_DEBUG,
"op_state_machine %p scheduling on_complete errors2 %p", s,
new_err);
- fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err));
+ fail_helper_locked(s, GRPC_ERROR_REF(new_err));
goto done;
}
}
}
if (s->recv_message_op) {
if (other && other->send_message_op) {
- message_transfer_locked(exec_ctx, other, s);
- maybe_schedule_op_closure_locked(exec_ctx, other, GRPC_ERROR_NONE);
+ message_transfer_locked(other, s);
+ maybe_schedule_op_closure_locked(other, GRPC_ERROR_NONE);
}
}
if (s->recv_trailing_md_op && s->t->is_client && other &&
other->send_message_op) {
- maybe_schedule_op_closure_locked(exec_ctx, other, GRPC_ERROR_NONE);
+ maybe_schedule_op_closure_locked(other, GRPC_ERROR_NONE);
}
if (s->to_read_trailing_md_filled) {
if (s->trailing_md_recvd) {
@@ -712,7 +696,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
"op_state_machine %p scheduling on_complete errors for already "
"recvd trailing md %p",
s, new_err);
- fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err));
+ fail_helper_locked(s, GRPC_ERROR_REF(new_err));
goto done;
}
if (s->recv_message_op != nullptr) {
@@ -720,11 +704,10 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
// satisfied
INPROC_LOG(GPR_DEBUG, "op_state_machine %p scheduling message-ready", s);
GRPC_CLOSURE_SCHED(
- exec_ctx,
s->recv_message_op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE);
complete_if_batch_end_locked(
- exec_ctx, s, new_err, s->recv_message_op,
+ s, new_err, s->recv_message_op,
"op_state_machine scheduling recv-message-on-complete");
s->recv_message_op = nullptr;
}
@@ -732,7 +715,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
// Nothing further will try to receive from this stream, so finish off
// any outstanding send_message op
complete_if_batch_end_locked(
- exec_ctx, s, new_err, s->send_message_op,
+ s, new_err, s->send_message_op,
"op_state_machine scheduling send-message-on-complete");
s->send_message_op = nullptr;
}
@@ -740,11 +723,11 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
// 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,
+ fill_in_metadata(s, &s->to_read_trailing_md, 0,
s->recv_trailing_md_op->payload
->recv_trailing_metadata.recv_trailing_metadata,
nullptr, nullptr);
- grpc_metadata_batch_clear(exec_ctx, &s->to_read_trailing_md);
+ grpc_metadata_batch_clear(&s->to_read_trailing_md);
s->to_read_trailing_md_filled = false;
// We should schedule the recv_trailing_md_op completion if
@@ -756,7 +739,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
INPROC_LOG(GPR_DEBUG,
"op_state_machine %p scheduling trailing-md-on-complete %p",
s, new_err);
- GRPC_CLOSURE_SCHED(exec_ctx, s->recv_trailing_md_op->on_complete,
+ GRPC_CLOSURE_SCHED(s->recv_trailing_md_op->on_complete,
GRPC_ERROR_REF(new_err));
s->recv_trailing_md_op = nullptr;
needs_close = true;
@@ -777,10 +760,10 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
// recv_message_op
INPROC_LOG(GPR_DEBUG, "op_state_machine %p scheduling message-ready", s);
GRPC_CLOSURE_SCHED(
- exec_ctx, s->recv_message_op->payload->recv_message.recv_message_ready,
+ s->recv_message_op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE);
complete_if_batch_end_locked(
- exec_ctx, s, new_err, s->recv_message_op,
+ s, new_err, s->recv_message_op,
"op_state_machine scheduling recv-message-on-complete");
s->recv_message_op = nullptr;
}
@@ -789,7 +772,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
// Nothing further will try to receive from this stream, so finish off
// any outstanding send_message op
complete_if_batch_end_locked(
- exec_ctx, s, new_err, s->send_message_op,
+ s, new_err, s->send_message_op,
"op_state_machine scheduling send-message-on-complete");
s->send_message_op = nullptr;
}
@@ -805,22 +788,21 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
}
done:
if (needs_close) {
- close_other_side_locked(exec_ctx, s, "op_state_machine");
- close_stream_locked(exec_ctx, s);
+ close_other_side_locked(s, "op_state_machine");
+ close_stream_locked(s);
}
gpr_mu_unlock(mu);
GRPC_ERROR_UNREF(new_err);
}
-static bool cancel_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
- grpc_error* error) {
+static bool cancel_stream_locked(inproc_stream* s, grpc_error* error) {
bool ret = false; // was the cancel accepted
INPROC_LOG(GPR_DEBUG, "cancel_stream %p with %s", s,
grpc_error_string(error));
if (s->cancel_self_error == GRPC_ERROR_NONE) {
ret = true;
s->cancel_self_error = GRPC_ERROR_REF(error);
- maybe_schedule_op_closure_locked(exec_ctx, s, s->cancel_self_error);
+ maybe_schedule_op_closure_locked(s, s->cancel_self_error);
// Send trailing md to the other side indicating cancellation, even if we
// already have
s->trailing_md_sent = true;
@@ -834,15 +816,14 @@ static bool cancel_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
: &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);
+ fill_in_metadata(s, &cancel_md, 0, dest, nullptr, destfilled);
+ grpc_metadata_batch_destroy(&cancel_md);
if (other != nullptr) {
if (other->cancel_other_error == GRPC_ERROR_NONE) {
other->cancel_other_error = GRPC_ERROR_REF(s->cancel_self_error);
}
- maybe_schedule_op_closure_locked(exec_ctx, other,
- other->cancel_other_error);
+ maybe_schedule_op_closure_locked(other, other->cancel_other_error);
} else if (s->write_buffer_cancel_error == GRPC_ERROR_NONE) {
s->write_buffer_cancel_error = GRPC_ERROR_REF(s->cancel_self_error);
}
@@ -852,21 +833,20 @@ static bool cancel_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
// md, now's the chance
if (!s->t->is_client && s->trailing_md_recvd && s->recv_trailing_md_op) {
complete_if_batch_end_locked(
- exec_ctx, s, s->cancel_self_error, s->recv_trailing_md_op,
+ s, s->cancel_self_error, s->recv_trailing_md_op,
"cancel_stream scheduling trailing-md-on-complete");
s->recv_trailing_md_op = nullptr;
}
}
- close_other_side_locked(exec_ctx, s, "cancel_stream:other_side");
- close_stream_locked(exec_ctx, s);
+ close_other_side_locked(s, "cancel_stream:other_side");
+ close_stream_locked(s);
GRPC_ERROR_UNREF(error);
return ret;
}
-static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
- grpc_stream* gs,
+static void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
grpc_transport_stream_op_batch* op) {
INPROC_LOG(GPR_DEBUG, "perform_stream_op %p %p %p", gt, gs, op);
inproc_stream* s = (inproc_stream*)gs;
@@ -892,7 +872,7 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
if (op->cancel_stream) {
// Call cancel_stream_locked without ref'ing the cancel_error because
// this function is responsible to make sure that that field gets unref'ed
- cancel_stream_locked(exec_ctx, s, op->payload->cancel_stream.cancel_error);
+ cancel_stream_locked(s, op->payload->cancel_stream.cancel_error);
// this op can complete without an error
} else if (s->cancel_self_error != GRPC_ERROR_NONE) {
// already self-canceled so still give it an error
@@ -932,8 +912,7 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
} else {
if (!other || !other->closed) {
fill_in_metadata(
- exec_ctx, s,
- op->payload->send_initial_metadata.send_initial_metadata,
+ s, op->payload->send_initial_metadata.send_initial_metadata,
op->payload->send_initial_metadata.send_initial_metadata_flags,
dest, destflags, destfilled);
}
@@ -945,7 +924,7 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
s->initial_md_sent = true;
}
}
- maybe_schedule_op_closure_locked(exec_ctx, other, error);
+ maybe_schedule_op_closure_locked(other, error);
}
}
@@ -985,7 +964,7 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
(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);
+ GRPC_CLOSURE_SCHED(&s->op_closure, GRPC_ERROR_NONE);
s->op_closure_scheduled = true;
}
} else {
@@ -1000,7 +979,6 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
"perform_stream_op error %p scheduling initial-metadata-ready %p",
s, error);
GRPC_CLOSURE_SCHED(
- exec_ctx,
op->payload->recv_initial_metadata.recv_initial_metadata_ready,
GRPC_ERROR_REF(error));
}
@@ -1009,28 +987,26 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
GPR_DEBUG,
"perform_stream_op error %p scheduling recv message-ready %p", s,
error);
- GRPC_CLOSURE_SCHED(exec_ctx,
- op->payload->recv_message.recv_message_ready,
+ GRPC_CLOSURE_SCHED(op->payload->recv_message.recv_message_ready,
GRPC_ERROR_REF(error));
}
}
INPROC_LOG(GPR_DEBUG, "perform_stream_op %p scheduling on_complete %p", s,
error);
- GRPC_CLOSURE_SCHED(exec_ctx, on_complete, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(on_complete, GRPC_ERROR_REF(error));
}
if (needs_close) {
- close_other_side_locked(exec_ctx, s, "perform_stream_op:other_side");
- close_stream_locked(exec_ctx, s);
+ close_other_side_locked(s, "perform_stream_op:other_side");
+ close_stream_locked(s);
}
gpr_mu_unlock(mu);
GRPC_ERROR_UNREF(error);
}
-static void close_transport_locked(grpc_exec_ctx* exec_ctx,
- inproc_transport* t) {
+static void close_transport_locked(inproc_transport* t) {
INPROC_LOG(GPR_DEBUG, "close_transport %p %d", t, t->is_closed);
grpc_connectivity_state_set(
- exec_ctx, &t->connectivity, GRPC_CHANNEL_SHUTDOWN,
+ &t->connectivity, GRPC_CHANNEL_SHUTDOWN,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Closing transport."),
"close transport");
if (!t->is_closed) {
@@ -1039,7 +1015,7 @@ static void close_transport_locked(grpc_exec_ctx* exec_ctx,
while (t->stream_list != nullptr) {
// cancel_stream_locked also adjusts stream list
cancel_stream_locked(
- exec_ctx, t->stream_list,
+ t->stream_list,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport closed"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
@@ -1047,14 +1023,13 @@ static void close_transport_locked(grpc_exec_ctx* exec_ctx,
}
}
-static void perform_transport_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
- grpc_transport_op* op) {
+static void perform_transport_op(grpc_transport* gt, grpc_transport_op* op) {
inproc_transport* t = (inproc_transport*)gt;
INPROC_LOG(GPR_DEBUG, "perform_transport_op %p %p", t, op);
gpr_mu_lock(&t->mu->mu);
if (op->on_connectivity_state_change) {
grpc_connectivity_state_notify_on_state_change(
- exec_ctx, &t->connectivity, op->connectivity_state,
+ &t->connectivity, op->connectivity_state,
op->on_connectivity_state_change);
}
if (op->set_accept_stream) {
@@ -1062,7 +1037,7 @@ static void perform_transport_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
t->accept_stream_data = op->set_accept_stream_user_data;
}
if (op->on_consumed) {
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(op->on_consumed, GRPC_ERROR_NONE);
}
bool do_close = false;
@@ -1076,71 +1051,67 @@ static void perform_transport_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
}
if (do_close) {
- close_transport_locked(exec_ctx, t);
+ close_transport_locked(t);
}
gpr_mu_unlock(&t->mu->mu);
}
-static void destroy_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
- grpc_stream* gs,
+static void destroy_stream(grpc_transport* gt, grpc_stream* gs,
grpc_closure* then_schedule_closure) {
INPROC_LOG(GPR_DEBUG, "destroy_stream %p %p", gs, then_schedule_closure);
inproc_stream* s = (inproc_stream*)gs;
s->closure_at_destroy = then_schedule_closure;
- really_destroy_stream(exec_ctx, s);
+ really_destroy_stream(s);
}
-static void destroy_transport(grpc_exec_ctx* exec_ctx, grpc_transport* gt) {
+static void destroy_transport(grpc_transport* gt) {
inproc_transport* t = (inproc_transport*)gt;
INPROC_LOG(GPR_DEBUG, "destroy_transport %p", t);
gpr_mu_lock(&t->mu->mu);
- close_transport_locked(exec_ctx, t);
+ close_transport_locked(t);
gpr_mu_unlock(&t->mu->mu);
- unref_transport(exec_ctx, t->other_side);
- unref_transport(exec_ctx, t);
+ unref_transport(t->other_side);
+ unref_transport(t);
}
/*******************************************************************************
* INTEGRATION GLUE
*/
-static void set_pollset(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
- grpc_stream* gs, grpc_pollset* pollset) {
+static void set_pollset(grpc_transport* gt, grpc_stream* gs,
+ grpc_pollset* pollset) {
// Nothing to do here
}
-static void set_pollset_set(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
- grpc_stream* gs, grpc_pollset_set* pollset_set) {
+static void set_pollset_set(grpc_transport* gt, grpc_stream* gs,
+ grpc_pollset_set* pollset_set) {
// Nothing to do here
}
-static grpc_endpoint* get_endpoint(grpc_exec_ctx* exec_ctx, grpc_transport* t) {
- return nullptr;
-}
+static grpc_endpoint* get_endpoint(grpc_transport* t) { return nullptr; }
/*******************************************************************************
* GLOBAL INIT AND DESTROY
*/
-static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
+static void do_nothing(void* arg, grpc_error* error) {}
void grpc_inproc_transport_init(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GRPC_CLOSURE_INIT(&do_nothing_closure, do_nothing, nullptr,
grpc_schedule_on_exec_ctx);
g_empty_slice = grpc_slice_from_static_buffer(nullptr, 0);
grpc_slice key_tmp = grpc_slice_from_static_string(":path");
g_fake_path_key = grpc_slice_intern(key_tmp);
- grpc_slice_unref_internal(&exec_ctx, key_tmp);
+ grpc_slice_unref_internal(key_tmp);
g_fake_path_value = grpc_slice_from_static_string("/");
grpc_slice auth_tmp = grpc_slice_from_static_string(":authority");
g_fake_auth_key = grpc_slice_intern(auth_tmp);
- grpc_slice_unref_internal(&exec_ctx, auth_tmp);
+ grpc_slice_unref_internal(auth_tmp);
g_fake_auth_value = grpc_slice_from_static_string("inproc-fail");
- grpc_exec_ctx_finish(&exec_ctx);
}
static const grpc_transport_vtable inproc_vtable = {
@@ -1152,8 +1123,7 @@ static const grpc_transport_vtable inproc_vtable = {
/*******************************************************************************
* Main inproc transport functions
*/
-static void inproc_transports_create(grpc_exec_ctx* exec_ctx,
- grpc_transport** server_transport,
+static void inproc_transports_create(grpc_transport** server_transport,
const grpc_channel_args* server_args,
grpc_transport** client_transport,
const grpc_channel_args* client_args) {
@@ -1190,7 +1160,7 @@ grpc_channel* grpc_inproc_channel_create(grpc_server* server,
GRPC_API_TRACE("grpc_inproc_channel_create(server=%p, args=%p)", 2,
(server, args));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
const grpc_channel_args* server_args = grpc_server_get_channel_args(server);
@@ -1205,30 +1175,26 @@ grpc_channel* grpc_inproc_channel_create(grpc_server* server,
grpc_transport* server_transport;
grpc_transport* client_transport;
- inproc_transports_create(&exec_ctx, &server_transport, server_args,
- &client_transport, client_args);
+ inproc_transports_create(&server_transport, server_args, &client_transport,
+ client_args);
- grpc_server_setup_transport(&exec_ctx, server, server_transport, nullptr,
- server_args);
- grpc_channel* channel =
- grpc_channel_create(&exec_ctx, "inproc", client_args,
- GRPC_CLIENT_DIRECT_CHANNEL, client_transport);
+ grpc_server_setup_transport(server, server_transport, nullptr, server_args);
+ grpc_channel* channel = grpc_channel_create(
+ "inproc", client_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport);
// Free up created channel args
- grpc_channel_args_destroy(&exec_ctx, client_args);
+ grpc_channel_args_destroy(client_args);
// Now finish scheduled operations
- grpc_exec_ctx_finish(&exec_ctx);
return channel;
}
void grpc_inproc_transport_shutdown(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_unref_internal(&exec_ctx, g_empty_slice);
- grpc_slice_unref_internal(&exec_ctx, g_fake_path_key);
- grpc_slice_unref_internal(&exec_ctx, g_fake_path_value);
- grpc_slice_unref_internal(&exec_ctx, g_fake_auth_key);
- grpc_slice_unref_internal(&exec_ctx, g_fake_auth_value);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_slice_unref_internal(g_empty_slice);
+ grpc_slice_unref_internal(g_fake_path_key);
+ grpc_slice_unref_internal(g_fake_path_value);
+ grpc_slice_unref_internal(g_fake_auth_key);
+ grpc_slice_unref_internal(g_fake_auth_value);
}
diff --git a/src/core/lib/backoff/backoff.cc b/src/core/lib/backoff/backoff.cc
index dc754ddd82..da3b9b1b2d 100644
--- a/src/core/lib/backoff/backoff.cc
+++ b/src/core/lib/backoff/backoff.cc
@@ -32,12 +32,11 @@ void grpc_backoff_init(grpc_backoff* backoff, grpc_millis initial_backoff,
backoff->rng_state = (uint32_t)gpr_now(GPR_CLOCK_REALTIME).tv_nsec;
}
-grpc_backoff_result grpc_backoff_begin(grpc_exec_ctx* exec_ctx,
- grpc_backoff* backoff) {
+grpc_backoff_result grpc_backoff_begin(grpc_backoff* backoff) {
backoff->current_backoff = backoff->initial_backoff;
const grpc_millis initial_timeout =
GPR_MAX(backoff->initial_backoff, backoff->min_connect_timeout);
- const grpc_millis now = grpc_exec_ctx_now(exec_ctx);
+ const grpc_millis now = grpc_core::ExecCtx::Get()->Now();
const grpc_backoff_result result = {now + initial_timeout,
now + backoff->current_backoff};
return result;
@@ -57,8 +56,7 @@ static double generate_uniform_random_number_between(uint32_t* rng_state,
return a + generate_uniform_random_number(rng_state) * range;
}
-grpc_backoff_result grpc_backoff_step(grpc_exec_ctx* exec_ctx,
- grpc_backoff* backoff) {
+grpc_backoff_result grpc_backoff_step(grpc_backoff* backoff) {
backoff->current_backoff = (grpc_millis)(GPR_MIN(
backoff->current_backoff * backoff->multiplier, backoff->max_backoff));
const double jitter = generate_uniform_random_number_between(
@@ -69,7 +67,7 @@ grpc_backoff_result grpc_backoff_step(grpc_exec_ctx* exec_ctx,
backoff->min_connect_timeout);
const grpc_millis next_timeout = GPR_MIN(
(grpc_millis)(backoff->current_backoff + jitter), backoff->max_backoff);
- const grpc_millis now = grpc_exec_ctx_now(exec_ctx);
+ const grpc_millis now = grpc_core::ExecCtx::Get()->Now();
const grpc_backoff_result result = {now + current_timeout,
now + next_timeout};
return result;
diff --git a/src/core/lib/backoff/backoff.h b/src/core/lib/backoff/backoff.h
index 1067281403..eb89209373 100644
--- a/src/core/lib/backoff/backoff.h
+++ b/src/core/lib/backoff/backoff.h
@@ -64,13 +64,11 @@ void grpc_backoff_init(grpc_backoff* backoff, grpc_millis initial_backoff,
/// Begin retry loop: returns the deadlines to be used for the current attempt
/// and the subsequent retry, if any.
-grpc_backoff_result grpc_backoff_begin(grpc_exec_ctx* exec_ctx,
- grpc_backoff* backoff);
+grpc_backoff_result grpc_backoff_begin(grpc_backoff* backoff);
/// Step a retry loop: returns the deadlines to be used for the current attempt
/// and the subsequent retry, if any.
-grpc_backoff_result grpc_backoff_step(grpc_exec_ctx* exec_ctx,
- grpc_backoff* backoff);
+grpc_backoff_result grpc_backoff_step(grpc_backoff* backoff);
/// Reset the backoff, so the next grpc_backoff_step will be a
/// grpc_backoff_begin.
diff --git a/src/core/lib/channel/channel_args.cc b/src/core/lib/channel/channel_args.cc
index 735fcbe405..578475b248 100644
--- a/src/core/lib/channel/channel_args.cc
+++ b/src/core/lib/channel/channel_args.cc
@@ -188,7 +188,7 @@ grpc_channel_args* grpc_channel_args_normalize(const grpc_channel_args* a) {
return b;
}
-void grpc_channel_args_destroy(grpc_exec_ctx* exec_ctx, grpc_channel_args* a) {
+void grpc_channel_args_destroy(grpc_channel_args* a) {
size_t i;
if (!a) return;
for (i = 0; i < a->num_args; i++) {
@@ -199,8 +199,7 @@ void grpc_channel_args_destroy(grpc_exec_ctx* exec_ctx, grpc_channel_args* a) {
case GRPC_ARG_INTEGER:
break;
case GRPC_ARG_POINTER:
- a->args[i].value.pointer.vtable->destroy(exec_ctx,
- a->args[i].value.pointer.p);
+ a->args[i].value.pointer.vtable->destroy(a->args[i].value.pointer.p);
break;
}
gpr_free(a->args[i].key);
@@ -299,8 +298,7 @@ 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) {
+ grpc_channel_args** a, grpc_compression_algorithm algorithm, int state) {
int* states_arg = nullptr;
grpc_channel_args* result = *a;
const int states_arg_found =
@@ -333,15 +331,15 @@ grpc_channel_args* grpc_channel_args_compression_algorithm_set_state(
GPR_BITCLEAR((unsigned*)&tmp.value.integer, algorithm);
}
result = grpc_channel_args_copy_and_add(*a, &tmp, 1);
- grpc_channel_args_destroy(exec_ctx, *a);
+ grpc_channel_args_destroy(*a);
*a = result;
}
return result;
}
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) {
+ grpc_channel_args** a, grpc_stream_compression_algorithm algorithm,
+ int state) {
int* states_arg = nullptr;
grpc_channel_args* result = *a;
const int states_arg_found =
@@ -375,7 +373,7 @@ grpc_channel_args* grpc_channel_args_stream_compression_algorithm_set_state(
GPR_BITCLEAR((unsigned*)&tmp.value.integer, algorithm);
}
result = grpc_channel_args_copy_and_add(*a, &tmp, 1);
- grpc_channel_args_destroy(exec_ctx, *a);
+ grpc_channel_args_destroy(*a);
*a = result;
}
return result;
diff --git a/src/core/lib/channel/channel_args.h b/src/core/lib/channel/channel_args.h
index d36761da57..4273af7228 100644
--- a/src/core/lib/channel/channel_args.h
+++ b/src/core/lib/channel/channel_args.h
@@ -57,7 +57,7 @@ grpc_channel_args* grpc_channel_args_union(const grpc_channel_args* a,
const grpc_channel_args* b);
/** Destroy arguments created by \a grpc_channel_args_copy */
-void grpc_channel_args_destroy(grpc_exec_ctx* exec_ctx, grpc_channel_args* a);
+void grpc_channel_args_destroy(grpc_channel_args* a);
/** Returns the compression algorithm set in \a a. */
grpc_compression_algorithm grpc_channel_args_get_compression_algorithm(
@@ -89,8 +89,7 @@ grpc_channel_args* grpc_channel_args_set_stream_compression_algorithm(
* modified to point to the returned instance (which may be different from the
* input value of \a a). */
grpc_channel_args* grpc_channel_args_compression_algorithm_set_state(
- grpc_exec_ctx* exec_ctx, grpc_channel_args** a,
- grpc_compression_algorithm algorithm, int enabled);
+ grpc_channel_args** a, grpc_compression_algorithm algorithm, int enabled);
/** Sets the support for the given stream compression algorithm. By default, all
* stream compression algorithms are enabled. It's an error to disable an
@@ -100,8 +99,8 @@ grpc_channel_args* grpc_channel_args_compression_algorithm_set_state(
* modified to point to the returned instance (which may be different from the
* input value of \a a). */
grpc_channel_args* grpc_channel_args_stream_compression_algorithm_set_state(
- grpc_exec_ctx* exec_ctx, grpc_channel_args** a,
- grpc_stream_compression_algorithm algorithm, int enabled);
+ grpc_channel_args** a, grpc_stream_compression_algorithm algorithm,
+ int enabled);
/** Returns the bitset representing the support state (true for enabled, false
* for disabled) for compression algorithms.
diff --git a/src/core/lib/channel/channel_stack.cc b/src/core/lib/channel/channel_stack.cc
index 6e5080995e..45d6fceb03 100644
--- a/src/core/lib/channel/channel_stack.cc
+++ b/src/core/lib/channel/channel_stack.cc
@@ -88,8 +88,8 @@ grpc_call_element* grpc_call_stack_element(grpc_call_stack* call_stack,
}
grpc_error* grpc_channel_stack_init(
- grpc_exec_ctx* exec_ctx, int initial_refs, grpc_iomgr_cb_func destroy,
- void* destroy_arg, const grpc_channel_filter** filters, size_t filter_count,
+ int initial_refs, grpc_iomgr_cb_func destroy, void* destroy_arg,
+ const grpc_channel_filter** filters, size_t filter_count,
const grpc_channel_args* channel_args, grpc_transport* optional_transport,
const char* name, grpc_channel_stack* stack) {
size_t call_size =
@@ -117,8 +117,7 @@ grpc_error* grpc_channel_stack_init(
args.is_last = i == (filter_count - 1);
elems[i].filter = filters[i];
elems[i].channel_data = user_data;
- grpc_error* error =
- elems[i].filter->init_channel_elem(exec_ctx, &elems[i], &args);
+ grpc_error* error = elems[i].filter->init_channel_elem(&elems[i], &args);
if (error != GRPC_ERROR_NONE) {
if (first_error == GRPC_ERROR_NONE) {
first_error = error;
@@ -138,20 +137,18 @@ grpc_error* grpc_channel_stack_init(
return first_error;
}
-void grpc_channel_stack_destroy(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack* stack) {
+void grpc_channel_stack_destroy(grpc_channel_stack* stack) {
grpc_channel_element* channel_elems = CHANNEL_ELEMS_FROM_STACK(stack);
size_t count = stack->count;
size_t i;
/* destroy per-filter data */
for (i = 0; i < count; i++) {
- channel_elems[i].filter->destroy_channel_elem(exec_ctx, &channel_elems[i]);
+ channel_elems[i].filter->destroy_channel_elem(&channel_elems[i]);
}
}
-grpc_error* grpc_call_stack_init(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack* channel_stack,
+grpc_error* grpc_call_stack_init(grpc_channel_stack* channel_stack,
int initial_refs, grpc_iomgr_cb_func destroy,
void* destroy_arg,
const grpc_call_element_args* elem_args) {
@@ -174,8 +171,8 @@ grpc_error* grpc_call_stack_init(grpc_exec_ctx* exec_ctx,
call_elems[i].filter = channel_elems[i].filter;
call_elems[i].channel_data = channel_elems[i].channel_data;
call_elems[i].call_data = user_data;
- grpc_error* error = call_elems[i].filter->init_call_elem(
- exec_ctx, &call_elems[i], elem_args);
+ grpc_error* error =
+ call_elems[i].filter->init_call_elem(&call_elems[i], elem_args);
if (error != GRPC_ERROR_NONE) {
if (first_error == GRPC_ERROR_NONE) {
first_error = error;
@@ -189,8 +186,7 @@ grpc_error* grpc_call_stack_init(grpc_exec_ctx* exec_ctx,
return first_error;
}
-void grpc_call_stack_set_pollset_or_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_call_stack* call_stack,
+void grpc_call_stack_set_pollset_or_pollset_set(grpc_call_stack* call_stack,
grpc_polling_entity* pollent) {
size_t count = call_stack->count;
grpc_call_element* call_elems;
@@ -203,18 +199,16 @@ void grpc_call_stack_set_pollset_or_pollset_set(grpc_exec_ctx* exec_ctx,
/* init per-filter data */
for (i = 0; i < count; i++) {
- call_elems[i].filter->set_pollset_or_pollset_set(exec_ctx, &call_elems[i],
- pollent);
+ call_elems[i].filter->set_pollset_or_pollset_set(&call_elems[i], pollent);
user_data +=
ROUND_UP_TO_ALIGNMENT_SIZE(call_elems[i].filter->sizeof_call_data);
}
}
void grpc_call_stack_ignore_set_pollset_or_pollset_set(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_polling_entity* pollent) {}
+ grpc_call_element* elem, grpc_polling_entity* pollent) {}
-void grpc_call_stack_destroy(grpc_exec_ctx* exec_ctx, grpc_call_stack* stack,
+void grpc_call_stack_destroy(grpc_call_stack* stack,
const grpc_call_final_info* final_info,
grpc_closure* then_schedule_closure) {
grpc_call_element* elems = CALL_ELEMS_FROM_STACK(stack);
@@ -224,29 +218,27 @@ void grpc_call_stack_destroy(grpc_exec_ctx* exec_ctx, grpc_call_stack* stack,
/* destroy per-filter data */
for (i = 0; i < count; i++) {
elems[i].filter->destroy_call_elem(
- exec_ctx, &elems[i], final_info,
+ &elems[i], final_info,
i == count - 1 ? then_schedule_closure : nullptr);
}
}
-void grpc_call_next_op(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+void grpc_call_next_op(grpc_call_element* elem,
grpc_transport_stream_op_batch* op) {
grpc_call_element* next_elem = elem + 1;
GRPC_CALL_LOG_OP(GPR_INFO, next_elem, op);
- next_elem->filter->start_transport_stream_op_batch(exec_ctx, next_elem, op);
+ next_elem->filter->start_transport_stream_op_batch(next_elem, op);
}
-void grpc_channel_next_get_info(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+void grpc_channel_next_get_info(grpc_channel_element* elem,
const grpc_channel_info* channel_info) {
grpc_channel_element* next_elem = elem + 1;
- next_elem->filter->get_channel_info(exec_ctx, next_elem, channel_info);
+ next_elem->filter->get_channel_info(next_elem, channel_info);
}
-void grpc_channel_next_op(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
- grpc_transport_op* op) {
+void grpc_channel_next_op(grpc_channel_element* elem, grpc_transport_op* op) {
grpc_channel_element* next_elem = elem + 1;
- next_elem->filter->start_transport_op(exec_ctx, next_elem, op);
+ next_elem->filter->start_transport_op(next_elem, op);
}
grpc_channel_stack* grpc_channel_stack_from_top_element(
diff --git a/src/core/lib/channel/channel_stack.h b/src/core/lib/channel/channel_stack.h
index aa993112a0..4496b864dc 100644
--- a/src/core/lib/channel/channel_stack.h
+++ b/src/core/lib/channel/channel_stack.h
@@ -99,14 +99,12 @@ typedef struct {
typedef struct {
/* Called to eg. send/receive data on a call.
See grpc_call_next_op on how to call the next element in the stack */
- void (*start_transport_stream_op_batch)(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+ void (*start_transport_stream_op_batch)(grpc_call_element* elem,
grpc_transport_stream_op_batch* op);
/* Called to handle channel level operations - e.g. new calls, or transport
closure.
See grpc_channel_next_op on how to call the next element in the stack */
- void (*start_transport_op)(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem, grpc_transport_op* op);
+ void (*start_transport_op)(grpc_channel_element* elem, grpc_transport_op* op);
/* sizeof(per call data) */
size_t sizeof_call_data;
@@ -119,11 +117,9 @@ typedef struct {
transport and is on the server. Most filters want to ignore this
argument.
Implementations may assume that elem->call_data is all zeros. */
- grpc_error* (*init_call_elem)(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+ grpc_error* (*init_call_elem)(grpc_call_element* elem,
const grpc_call_element_args* args);
- void (*set_pollset_or_pollset_set)(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+ void (*set_pollset_or_pollset_set)(grpc_call_element* elem,
grpc_polling_entity* pollent);
/* Destroy per call data.
The filter does not need to do any chaining.
@@ -131,7 +127,7 @@ typedef struct {
\a then_schedule_closure that should be passed to GRPC_CLOSURE_SCHED when
destruction is complete. \a final_info contains data about the completed
call, mainly for reporting purposes. */
- void (*destroy_call_elem)(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+ void (*destroy_call_elem)(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* then_schedule_closure);
@@ -144,16 +140,14 @@ typedef struct {
useful for asserting correct configuration by upper layer code.
The filter does not need to do any chaining.
Implementations may assume that elem->call_data is all zeros. */
- grpc_error* (*init_channel_elem)(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+ grpc_error* (*init_channel_elem)(grpc_channel_element* elem,
grpc_channel_element_args* args);
/* Destroy per channel data.
The filter does not need to do any chaining */
- void (*destroy_channel_elem)(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem);
+ void (*destroy_channel_elem)(grpc_channel_element* elem);
/* Implement grpc_channel_get_info() */
- void (*get_channel_info)(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+ void (*get_channel_info)(grpc_channel_element* elem,
const grpc_channel_info* channel_info);
/* The name of this filter */
@@ -211,68 +205,62 @@ size_t grpc_channel_stack_size(const grpc_channel_filter** filters,
size_t filter_count);
/* Initialize a channel stack given some filters */
grpc_error* grpc_channel_stack_init(
- grpc_exec_ctx* exec_ctx, int initial_refs, grpc_iomgr_cb_func destroy,
- void* destroy_arg, const grpc_channel_filter** filters, size_t filter_count,
+ int initial_refs, grpc_iomgr_cb_func destroy, void* destroy_arg,
+ const grpc_channel_filter** filters, size_t filter_count,
const grpc_channel_args* args, grpc_transport* optional_transport,
const char* name, grpc_channel_stack* stack);
/* Destroy a channel stack */
-void grpc_channel_stack_destroy(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack* stack);
+void grpc_channel_stack_destroy(grpc_channel_stack* stack);
/* Initialize a call stack given a channel stack. transport_server_data is
expected to be NULL on a client, or an opaque transport owned pointer on the
server. */
-grpc_error* grpc_call_stack_init(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack* channel_stack,
+grpc_error* grpc_call_stack_init(grpc_channel_stack* channel_stack,
int initial_refs, grpc_iomgr_cb_func destroy,
void* destroy_arg,
const grpc_call_element_args* elem_args);
/* Set a pollset or a pollset_set for a call stack: must occur before the first
* op is started */
-void grpc_call_stack_set_pollset_or_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_call_stack* call_stack,
+void grpc_call_stack_set_pollset_or_pollset_set(grpc_call_stack* call_stack,
grpc_polling_entity* pollent);
#ifndef NDEBUG
#define GRPC_CALL_STACK_REF(call_stack, reason) \
grpc_stream_ref(&(call_stack)->refcount, reason)
-#define GRPC_CALL_STACK_UNREF(exec_ctx, call_stack, reason) \
- grpc_stream_unref(exec_ctx, &(call_stack)->refcount, reason)
+#define GRPC_CALL_STACK_UNREF(call_stack, reason) \
+ grpc_stream_unref(&(call_stack)->refcount, reason)
#define GRPC_CHANNEL_STACK_REF(channel_stack, reason) \
grpc_stream_ref(&(channel_stack)->refcount, reason)
-#define GRPC_CHANNEL_STACK_UNREF(exec_ctx, channel_stack, reason) \
- grpc_stream_unref(exec_ctx, &(channel_stack)->refcount, reason)
+#define GRPC_CHANNEL_STACK_UNREF(channel_stack, reason) \
+ grpc_stream_unref(&(channel_stack)->refcount, reason)
#else
#define GRPC_CALL_STACK_REF(call_stack, reason) \
grpc_stream_ref(&(call_stack)->refcount)
-#define GRPC_CALL_STACK_UNREF(exec_ctx, call_stack, reason) \
- grpc_stream_unref(exec_ctx, &(call_stack)->refcount)
+#define GRPC_CALL_STACK_UNREF(call_stack, reason) \
+ grpc_stream_unref(&(call_stack)->refcount)
#define GRPC_CHANNEL_STACK_REF(channel_stack, reason) \
grpc_stream_ref(&(channel_stack)->refcount)
-#define GRPC_CHANNEL_STACK_UNREF(exec_ctx, channel_stack, reason) \
- grpc_stream_unref(exec_ctx, &(channel_stack)->refcount)
+#define GRPC_CHANNEL_STACK_UNREF(channel_stack, reason) \
+ grpc_stream_unref(&(channel_stack)->refcount)
#endif
/* Destroy a call stack */
-void grpc_call_stack_destroy(grpc_exec_ctx* exec_ctx, grpc_call_stack* stack,
+void grpc_call_stack_destroy(grpc_call_stack* stack,
const grpc_call_final_info* final_info,
grpc_closure* then_schedule_closure);
/* Ignore set pollset{_set} - used by filters if they don't care about pollsets
* at all. Does nothing. */
void grpc_call_stack_ignore_set_pollset_or_pollset_set(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_polling_entity* pollent);
+ grpc_call_element* elem, grpc_polling_entity* pollent);
/* Call the next operation in a call stack */
-void grpc_call_next_op(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+void grpc_call_next_op(grpc_call_element* elem,
grpc_transport_stream_op_batch* op);
/* Call the next operation (depending on call directionality) in a channel
stack */
-void grpc_channel_next_op(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
- grpc_transport_op* op);
+void grpc_channel_next_op(grpc_channel_element* elem, grpc_transport_op* op);
/* Pass through a request to get_channel_info() to the next child element */
-void grpc_channel_next_get_info(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+void grpc_channel_next_get_info(grpc_channel_element* elem,
const grpc_channel_info* channel_info);
/* Given the top element of a channel stack, get the channel stack itself */
diff --git a/src/core/lib/channel/channel_stack_builder.cc b/src/core/lib/channel/channel_stack_builder.cc
index 1e553bfb03..9cef3501bc 100644
--- a/src/core/lib/channel/channel_stack_builder.cc
+++ b/src/core/lib/channel/channel_stack_builder.cc
@@ -150,10 +150,9 @@ void grpc_channel_stack_builder_set_name(grpc_channel_stack_builder* builder,
}
void grpc_channel_stack_builder_set_channel_arguments(
- grpc_exec_ctx* exec_ctx, grpc_channel_stack_builder* builder,
- const grpc_channel_args* args) {
+ grpc_channel_stack_builder* builder, const grpc_channel_args* args) {
if (builder->args != nullptr) {
- grpc_channel_args_destroy(exec_ctx, builder->args);
+ grpc_channel_args_destroy(builder->args);
}
builder->args = grpc_channel_args_copy(args);
}
@@ -241,8 +240,7 @@ bool grpc_channel_stack_builder_add_filter_after(
return true;
}
-void grpc_channel_stack_builder_destroy(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder) {
+void grpc_channel_stack_builder_destroy(grpc_channel_stack_builder* builder) {
filter_node* p = builder->begin.next;
while (p != &builder->end) {
filter_node* next = p->next;
@@ -250,16 +248,15 @@ void grpc_channel_stack_builder_destroy(grpc_exec_ctx* exec_ctx,
p = next;
}
if (builder->args != nullptr) {
- grpc_channel_args_destroy(exec_ctx, builder->args);
+ grpc_channel_args_destroy(builder->args);
}
gpr_free(builder->target);
gpr_free(builder);
}
grpc_error* grpc_channel_stack_builder_finish(
- grpc_exec_ctx* exec_ctx, grpc_channel_stack_builder* builder,
- size_t prefix_bytes, int initial_refs, grpc_iomgr_cb_func destroy,
- void* destroy_arg, void** result) {
+ grpc_channel_stack_builder* builder, size_t prefix_bytes, int initial_refs,
+ grpc_iomgr_cb_func destroy, void* destroy_arg, void** result) {
// count the number of filters
size_t num_filters = 0;
for (filter_node* p = builder->begin.next; p != &builder->end; p = p->next) {
@@ -284,12 +281,12 @@ grpc_error* grpc_channel_stack_builder_finish(
(grpc_channel_stack*)((char*)(*result) + prefix_bytes);
// and initialize it
grpc_error* error = grpc_channel_stack_init(
- exec_ctx, initial_refs, destroy,
- destroy_arg == nullptr ? *result : destroy_arg, filters, num_filters,
- builder->args, builder->transport, builder->name, channel_stack);
+ initial_refs, destroy, destroy_arg == nullptr ? *result : destroy_arg,
+ filters, num_filters, builder->args, builder->transport, builder->name,
+ channel_stack);
if (error != GRPC_ERROR_NONE) {
- grpc_channel_stack_destroy(exec_ctx, channel_stack);
+ grpc_channel_stack_destroy(channel_stack);
gpr_free(*result);
*result = nullptr;
} else {
@@ -305,7 +302,7 @@ grpc_error* grpc_channel_stack_builder_finish(
}
}
- grpc_channel_stack_builder_destroy(exec_ctx, builder);
+ grpc_channel_stack_builder_destroy(builder);
gpr_free((grpc_channel_filter**)filters);
return error;
diff --git a/src/core/lib/channel/channel_stack_builder.h b/src/core/lib/channel/channel_stack_builder.h
index 23134b7d10..f4e4a200d9 100644
--- a/src/core/lib/channel/channel_stack_builder.h
+++ b/src/core/lib/channel/channel_stack_builder.h
@@ -58,8 +58,7 @@ grpc_transport* grpc_channel_stack_builder_get_transport(
/// Set channel arguments: copies args
void grpc_channel_stack_builder_set_channel_arguments(
- grpc_exec_ctx* exec_ctx, grpc_channel_stack_builder* builder,
- const grpc_channel_args* args);
+ grpc_channel_stack_builder* builder, const grpc_channel_args* args);
/// Return a borrowed pointer to the channel arguments
const grpc_channel_args* grpc_channel_stack_builder_get_channel_arguments(
@@ -152,13 +151,11 @@ void grpc_channel_stack_builder_iterator_destroy(
/// \a initial_refs, \a destroy, \a destroy_arg are as per
/// grpc_channel_stack_init
grpc_error* grpc_channel_stack_builder_finish(
- grpc_exec_ctx* exec_ctx, grpc_channel_stack_builder* builder,
- size_t prefix_bytes, int initial_refs, grpc_iomgr_cb_func destroy,
- void* destroy_arg, void** result);
+ grpc_channel_stack_builder* builder, size_t prefix_bytes, int initial_refs,
+ grpc_iomgr_cb_func destroy, void* destroy_arg, void** result);
/// Destroy the builder without creating a channel stack
-void grpc_channel_stack_builder_destroy(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder);
+void grpc_channel_stack_builder_destroy(grpc_channel_stack_builder* builder);
extern grpc_tracer_flag grpc_trace_channel_stack_builder;
diff --git a/src/core/lib/channel/connected_channel.cc b/src/core/lib/channel/connected_channel.cc
index af2f88ab2e..9d07cfff4e 100644
--- a/src/core/lib/channel/connected_channel.cc
+++ b/src/core/lib/channel/connected_channel.cc
@@ -51,17 +51,14 @@ typedef struct connected_channel_call_data {
callback_state recv_message_ready;
} call_data;
-static void run_in_call_combiner(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void run_in_call_combiner(void* arg, grpc_error* error) {
callback_state* state = (callback_state*)arg;
- GRPC_CALL_COMBINER_START(exec_ctx, state->call_combiner,
- state->original_closure, GRPC_ERROR_REF(error),
- state->reason);
+ GRPC_CALL_COMBINER_START(state->call_combiner, state->original_closure,
+ GRPC_ERROR_REF(error), state->reason);
}
-static void run_cancel_in_call_combiner(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
- run_in_call_combiner(exec_ctx, arg, error);
+static void run_cancel_in_call_combiner(void* arg, grpc_error* error) {
+ run_in_call_combiner(arg, error);
gpr_free(arg);
}
@@ -98,8 +95,7 @@ static callback_state* get_state_for_batch(
/* Intercept a call operation and either push it directly up or translate it
into transport stream operations */
static void con_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* batch) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
call_data* calld = (call_data*)elem->call_data;
channel_data* chand = (channel_data*)elem->channel_data;
if (batch->recv_initial_metadata) {
@@ -126,58 +122,52 @@ static void con_start_transport_stream_op_batch(
callback_state* state = get_state_for_batch(calld, batch);
intercept_callback(calld, state, false, "on_complete", &batch->on_complete);
}
- grpc_transport_perform_stream_op(exec_ctx, chand->transport,
- TRANSPORT_STREAM_FROM_CALL_DATA(calld),
- batch);
- GRPC_CALL_COMBINER_STOP(exec_ctx, calld->call_combiner,
- "passed batch to transport");
+ grpc_transport_perform_stream_op(
+ chand->transport, TRANSPORT_STREAM_FROM_CALL_DATA(calld), batch);
+ GRPC_CALL_COMBINER_STOP(calld->call_combiner, "passed batch to transport");
}
-static void con_start_transport_op(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static void con_start_transport_op(grpc_channel_element* elem,
grpc_transport_op* op) {
channel_data* chand = (channel_data*)elem->channel_data;
- grpc_transport_perform_op(exec_ctx, chand->transport, op);
+ grpc_transport_perform_op(chand->transport, op);
}
/* Constructor for call_data */
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
call_data* calld = (call_data*)elem->call_data;
channel_data* chand = (channel_data*)elem->channel_data;
calld->call_combiner = args->call_combiner;
int r = grpc_transport_init_stream(
- exec_ctx, chand->transport, TRANSPORT_STREAM_FROM_CALL_DATA(calld),
+ chand->transport, TRANSPORT_STREAM_FROM_CALL_DATA(calld),
&args->call_stack->refcount, args->server_transport_data, args->arena);
return r == 0 ? GRPC_ERROR_NONE
: GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"transport stream initialization failed");
}
-static void set_pollset_or_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void set_pollset_or_pollset_set(grpc_call_element* elem,
grpc_polling_entity* pollent) {
call_data* calld = (call_data*)elem->call_data;
channel_data* chand = (channel_data*)elem->channel_data;
- grpc_transport_set_pops(exec_ctx, chand->transport,
+ grpc_transport_set_pops(chand->transport,
TRANSPORT_STREAM_FROM_CALL_DATA(calld), pollent);
}
/* Destructor for call_data */
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* then_schedule_closure) {
call_data* calld = (call_data*)elem->call_data;
channel_data* chand = (channel_data*)elem->channel_data;
- grpc_transport_destroy_stream(exec_ctx, chand->transport,
+ grpc_transport_destroy_stream(chand->transport,
TRANSPORT_STREAM_FROM_CALL_DATA(calld),
then_schedule_closure);
}
/* Constructor for channel_data */
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
channel_data* cd = (channel_data*)elem->channel_data;
GPR_ASSERT(args->is_last);
@@ -186,17 +176,15 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
}
/* Destructor for channel_data */
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {
+static void destroy_channel_elem(grpc_channel_element* elem) {
channel_data* cd = (channel_data*)elem->channel_data;
if (cd->transport) {
- grpc_transport_destroy(exec_ctx, cd->transport);
+ grpc_transport_destroy(cd->transport);
}
}
/* No-op. */
-static void con_get_channel_info(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static void con_get_channel_info(grpc_channel_element* elem,
const grpc_channel_info* channel_info) {}
const grpc_channel_filter grpc_connected_filter = {
@@ -230,8 +218,7 @@ static void bind_transport(grpc_channel_stack* channel_stack,
grpc_transport_stream_size((grpc_transport*)t);
}
-bool grpc_add_connected_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+bool grpc_add_connected_filter(grpc_channel_stack_builder* builder,
void* arg_must_be_null) {
GPR_ASSERT(arg_must_be_null == nullptr);
grpc_transport* t = grpc_channel_stack_builder_get_transport(builder);
diff --git a/src/core/lib/channel/connected_channel.h b/src/core/lib/channel/connected_channel.h
index cca19737dc..0f4343ef5d 100644
--- a/src/core/lib/channel/connected_channel.h
+++ b/src/core/lib/channel/connected_channel.h
@@ -27,8 +27,7 @@ extern "C" {
extern const grpc_channel_filter grpc_connected_filter;
-bool grpc_add_connected_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+bool grpc_add_connected_filter(grpc_channel_stack_builder* builder,
void* arg_must_be_null);
/* Debug helper to dig the transport stream out of a call element */
diff --git a/src/core/lib/channel/handshaker.cc b/src/core/lib/channel/handshaker.cc
index aae1b35845..1f2426bc6c 100644
--- a/src/core/lib/channel/handshaker.cc
+++ b/src/core/lib/channel/handshaker.cc
@@ -34,23 +34,20 @@ void grpc_handshaker_init(const grpc_handshaker_vtable* vtable,
handshaker->vtable = vtable;
}
-void grpc_handshaker_destroy(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker) {
- handshaker->vtable->destroy(exec_ctx, handshaker);
+void grpc_handshaker_destroy(grpc_handshaker* handshaker) {
+ handshaker->vtable->destroy(handshaker);
}
-void grpc_handshaker_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker, grpc_error* why) {
- handshaker->vtable->shutdown(exec_ctx, handshaker, why);
+void grpc_handshaker_shutdown(grpc_handshaker* handshaker, grpc_error* why) {
+ handshaker->vtable->shutdown(handshaker, why);
}
-void grpc_handshaker_do_handshake(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker,
+void grpc_handshaker_do_handshake(grpc_handshaker* handshaker,
grpc_tcp_server_acceptor* acceptor,
grpc_closure* on_handshake_done,
grpc_handshaker_args* args) {
- handshaker->vtable->do_handshake(exec_ctx, handshaker, acceptor,
- on_handshake_done, args);
+ handshaker->vtable->do_handshake(handshaker, acceptor, on_handshake_done,
+ args);
}
//
@@ -116,9 +113,9 @@ void grpc_handshake_manager_pending_list_remove(grpc_handshake_manager** head,
}
void grpc_handshake_manager_pending_list_shutdown_all(
- grpc_exec_ctx* exec_ctx, grpc_handshake_manager* head, grpc_error* why) {
+ grpc_handshake_manager* head, grpc_error* why) {
while (head != nullptr) {
- grpc_handshake_manager_shutdown(exec_ctx, head, GRPC_ERROR_REF(why));
+ grpc_handshake_manager_shutdown(head, GRPC_ERROR_REF(why));
head = head->next;
}
GRPC_ERROR_UNREF(why);
@@ -145,11 +142,10 @@ void grpc_handshake_manager_add(grpc_handshake_manager* mgr,
gpr_mu_unlock(&mgr->mu);
}
-static void grpc_handshake_manager_unref(grpc_exec_ctx* exec_ctx,
- grpc_handshake_manager* mgr) {
+static void grpc_handshake_manager_unref(grpc_handshake_manager* mgr) {
if (gpr_unref(&mgr->refs)) {
for (size_t i = 0; i < mgr->count; ++i) {
- grpc_handshaker_destroy(exec_ctx, mgr->handshakers[i]);
+ grpc_handshaker_destroy(mgr->handshakers[i]);
}
gpr_free(mgr->handshakers);
gpr_mu_destroy(&mgr->mu);
@@ -157,19 +153,17 @@ static void grpc_handshake_manager_unref(grpc_exec_ctx* exec_ctx,
}
}
-void grpc_handshake_manager_destroy(grpc_exec_ctx* exec_ctx,
- grpc_handshake_manager* mgr) {
- grpc_handshake_manager_unref(exec_ctx, mgr);
+void grpc_handshake_manager_destroy(grpc_handshake_manager* mgr) {
+ grpc_handshake_manager_unref(mgr);
}
-void grpc_handshake_manager_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_handshake_manager* mgr,
+void grpc_handshake_manager_shutdown(grpc_handshake_manager* mgr,
grpc_error* why) {
gpr_mu_lock(&mgr->mu);
// Shutdown the handshaker that's currently in progress, if any.
if (!mgr->shutdown && mgr->index > 0) {
mgr->shutdown = true;
- grpc_handshaker_shutdown(exec_ctx, mgr->handshakers[mgr->index - 1],
+ grpc_handshaker_shutdown(mgr->handshakers[mgr->index - 1],
GRPC_ERROR_REF(why));
}
gpr_mu_unlock(&mgr->mu);
@@ -179,8 +173,7 @@ void grpc_handshake_manager_shutdown(grpc_exec_ctx* exec_ctx,
// Helper function to call either the next handshaker or the
// on_handshake_done callback.
// Returns true if we've scheduled the on_handshake_done callback.
-static bool call_next_handshaker_locked(grpc_exec_ctx* exec_ctx,
- grpc_handshake_manager* mgr,
+static bool call_next_handshaker_locked(grpc_handshake_manager* mgr,
grpc_error* error) {
GPR_ASSERT(mgr->index <= mgr->count);
// If we got an error or we've been shut down or we're exiting early or
@@ -190,13 +183,12 @@ static bool call_next_handshaker_locked(grpc_exec_ctx* exec_ctx,
mgr->index == mgr->count) {
// Cancel deadline timer, since we're invoking the on_handshake_done
// callback now.
- grpc_timer_cancel(exec_ctx, &mgr->deadline_timer);
- GRPC_CLOSURE_SCHED(exec_ctx, &mgr->on_handshake_done, error);
+ grpc_timer_cancel(&mgr->deadline_timer);
+ GRPC_CLOSURE_SCHED(&mgr->on_handshake_done, error);
mgr->shutdown = true;
} else {
- grpc_handshaker_do_handshake(exec_ctx, mgr->handshakers[mgr->index],
- mgr->acceptor, &mgr->call_next_handshaker,
- &mgr->args);
+ grpc_handshaker_do_handshake(mgr->handshakers[mgr->index], mgr->acceptor,
+ &mgr->call_next_handshaker, &mgr->args);
}
++mgr->index;
return mgr->shutdown;
@@ -204,36 +196,36 @@ static bool call_next_handshaker_locked(grpc_exec_ctx* exec_ctx,
// A function used as the handshaker-done callback when chaining
// handshakers together.
-static void call_next_handshaker(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void call_next_handshaker(void* arg, grpc_error* error) {
grpc_handshake_manager* mgr = (grpc_handshake_manager*)arg;
gpr_mu_lock(&mgr->mu);
- bool done = call_next_handshaker_locked(exec_ctx, mgr, GRPC_ERROR_REF(error));
+ bool done = call_next_handshaker_locked(mgr, GRPC_ERROR_REF(error));
gpr_mu_unlock(&mgr->mu);
// If we're invoked the final callback, we won't be coming back
// to this function, so we can release our reference to the
// handshake manager.
if (done) {
- grpc_handshake_manager_unref(exec_ctx, mgr);
+ grpc_handshake_manager_unref(mgr);
}
}
// Callback invoked when deadline is exceeded.
-static void on_timeout(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void on_timeout(void* arg, grpc_error* error) {
grpc_handshake_manager* mgr = (grpc_handshake_manager*)arg;
if (error == GRPC_ERROR_NONE) { // Timer fired, rather than being cancelled.
grpc_handshake_manager_shutdown(
- exec_ctx, mgr,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshake timed out"));
+ mgr, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshake timed out"));
}
- grpc_handshake_manager_unref(exec_ctx, mgr);
+ grpc_handshake_manager_unref(mgr);
}
-void grpc_handshake_manager_do_handshake(
- grpc_exec_ctx* exec_ctx, grpc_handshake_manager* mgr,
- grpc_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) {
+void grpc_handshake_manager_do_handshake(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) {
gpr_mu_lock(&mgr->mu);
GPR_ASSERT(mgr->index == 0);
GPR_ASSERT(!mgr->shutdown);
@@ -255,12 +247,12 @@ void grpc_handshake_manager_do_handshake(
gpr_ref(&mgr->refs);
GRPC_CLOSURE_INIT(&mgr->on_timeout, on_timeout, mgr,
grpc_schedule_on_exec_ctx);
- grpc_timer_init(exec_ctx, &mgr->deadline_timer, deadline, &mgr->on_timeout);
+ grpc_timer_init(&mgr->deadline_timer, deadline, &mgr->on_timeout);
// Start first handshaker, which also owns a ref.
gpr_ref(&mgr->refs);
- bool done = call_next_handshaker_locked(exec_ctx, mgr, GRPC_ERROR_NONE);
+ bool done = call_next_handshaker_locked(mgr, GRPC_ERROR_NONE);
gpr_mu_unlock(&mgr->mu);
if (done) {
- grpc_handshake_manager_unref(exec_ctx, mgr);
+ grpc_handshake_manager_unref(mgr);
}
}
diff --git a/src/core/lib/channel/handshaker.h b/src/core/lib/channel/handshaker.h
index 8ed38c15ba..a7d3e5700f 100644
--- a/src/core/lib/channel/handshaker.h
+++ b/src/core/lib/channel/handshaker.h
@@ -71,18 +71,17 @@ typedef struct {
typedef struct {
/// Destroys the handshaker.
- void (*destroy)(grpc_exec_ctx* exec_ctx, grpc_handshaker* handshaker);
+ void (*destroy)(grpc_handshaker* handshaker);
/// Shuts down the handshaker (e.g., to clean up when the operation is
/// aborted in the middle).
- void (*shutdown)(grpc_exec_ctx* exec_ctx, grpc_handshaker* handshaker,
- grpc_error* why);
+ void (*shutdown)(grpc_handshaker* handshaker, grpc_error* why);
/// Performs handshaking, modifying \a args as needed (e.g., to
/// replace \a endpoint with a wrapped endpoint).
/// When finished, invokes \a on_handshake_done.
/// \a acceptor will be NULL for client-side handshakers.
- void (*do_handshake)(grpc_exec_ctx* exec_ctx, grpc_handshaker* handshaker,
+ void (*do_handshake)(grpc_handshaker* handshaker,
grpc_tcp_server_acceptor* acceptor,
grpc_closure* on_handshake_done,
grpc_handshaker_args* args);
@@ -98,12 +97,9 @@ struct grpc_handshaker {
void grpc_handshaker_init(const grpc_handshaker_vtable* vtable,
grpc_handshaker* handshaker);
-void grpc_handshaker_destroy(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker);
-void grpc_handshaker_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker, grpc_error* why);
-void grpc_handshaker_do_handshake(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker,
+void grpc_handshaker_destroy(grpc_handshaker* handshaker);
+void grpc_handshaker_shutdown(grpc_handshaker* handshaker, grpc_error* why);
+void grpc_handshaker_do_handshake(grpc_handshaker* handshaker,
grpc_tcp_server_acceptor* acceptor,
grpc_closure* on_handshake_done,
grpc_handshaker_args* args);
@@ -123,15 +119,13 @@ void grpc_handshake_manager_add(grpc_handshake_manager* mgr,
grpc_handshaker* handshaker);
/// Destroys the handshake manager.
-void grpc_handshake_manager_destroy(grpc_exec_ctx* exec_ctx,
- grpc_handshake_manager* mgr);
+void grpc_handshake_manager_destroy(grpc_handshake_manager* mgr);
/// Shuts down the handshake manager (e.g., to clean up when the operation is
/// aborted in the middle).
/// The caller must still call grpc_handshake_manager_destroy() after
/// calling this function.
-void grpc_handshake_manager_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_handshake_manager* mgr,
+void grpc_handshake_manager_shutdown(grpc_handshake_manager* mgr,
grpc_error* why);
/// Invokes handshakers in the order they were added.
@@ -146,11 +140,13 @@ void grpc_handshake_manager_shutdown(grpc_exec_ctx* exec_ctx,
/// GRPC_ERROR_NONE, then handshaking failed and the handshaker has done
/// the necessary clean-up. Otherwise, the callback takes ownership of
/// the arguments.
-void grpc_handshake_manager_do_handshake(
- grpc_exec_ctx* exec_ctx, grpc_handshake_manager* mgr,
- grpc_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);
+void grpc_handshake_manager_do_handshake(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);
/// Add \a mgr to the server side list of all pending handshake managers, the
/// list starts with \a *head.
@@ -166,7 +162,7 @@ void grpc_handshake_manager_pending_list_remove(grpc_handshake_manager** head,
/// Shutdown all pending handshake managers on the server side.
// Not thread-safe. Caller needs to synchronize.
void grpc_handshake_manager_pending_list_shutdown_all(
- grpc_exec_ctx* exec_ctx, grpc_handshake_manager* head, grpc_error* why);
+ grpc_handshake_manager* head, grpc_error* why);
#ifdef __cplusplus
}
diff --git a/src/core/lib/channel/handshaker_factory.cc b/src/core/lib/channel/handshaker_factory.cc
index 015006ade0..2380d98300 100644
--- a/src/core/lib/channel/handshaker_factory.cc
+++ b/src/core/lib/channel/handshaker_factory.cc
@@ -21,19 +21,19 @@
#include <grpc/support/log.h>
void grpc_handshaker_factory_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory* handshaker_factory,
- const grpc_channel_args* args, grpc_handshake_manager* handshake_mgr) {
+ grpc_handshaker_factory* handshaker_factory, const grpc_channel_args* args,
+ grpc_handshake_manager* handshake_mgr) {
if (handshaker_factory != nullptr) {
GPR_ASSERT(handshaker_factory->vtable != nullptr);
- handshaker_factory->vtable->add_handshakers(exec_ctx, handshaker_factory,
- args, handshake_mgr);
+ handshaker_factory->vtable->add_handshakers(handshaker_factory, args,
+ handshake_mgr);
}
}
void grpc_handshaker_factory_destroy(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory* handshaker_factory) {
+ grpc_handshaker_factory* handshaker_factory) {
if (handshaker_factory != nullptr) {
GPR_ASSERT(handshaker_factory->vtable != nullptr);
- handshaker_factory->vtable->destroy(exec_ctx, handshaker_factory);
+ handshaker_factory->vtable->destroy(handshaker_factory);
}
}
diff --git a/src/core/lib/channel/handshaker_factory.h b/src/core/lib/channel/handshaker_factory.h
index 63d9b5af72..aba037ce56 100644
--- a/src/core/lib/channel/handshaker_factory.h
+++ b/src/core/lib/channel/handshaker_factory.h
@@ -33,12 +33,10 @@ extern "C" {
typedef struct grpc_handshaker_factory grpc_handshaker_factory;
typedef struct {
- void (*add_handshakers)(grpc_exec_ctx* exec_ctx,
- grpc_handshaker_factory* handshaker_factory,
+ void (*add_handshakers)(grpc_handshaker_factory* handshaker_factory,
const grpc_channel_args* args,
grpc_handshake_manager* handshake_mgr);
- void (*destroy)(grpc_exec_ctx* exec_ctx,
- grpc_handshaker_factory* handshaker_factory);
+ void (*destroy)(grpc_handshaker_factory* handshaker_factory);
} grpc_handshaker_factory_vtable;
struct grpc_handshaker_factory {
@@ -46,11 +44,11 @@ struct grpc_handshaker_factory {
};
void grpc_handshaker_factory_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory* handshaker_factory,
- const grpc_channel_args* args, grpc_handshake_manager* handshake_mgr);
+ grpc_handshaker_factory* handshaker_factory, const grpc_channel_args* args,
+ grpc_handshake_manager* handshake_mgr);
void grpc_handshaker_factory_destroy(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory* handshaker_factory);
+ grpc_handshaker_factory* handshaker_factory);
#ifdef __cplusplus
}
diff --git a/src/core/lib/channel/handshaker_registry.cc b/src/core/lib/channel/handshaker_registry.cc
index c6bc87d704..098eabf084 100644
--- a/src/core/lib/channel/handshaker_registry.cc
+++ b/src/core/lib/channel/handshaker_registry.cc
@@ -47,18 +47,17 @@ static void grpc_handshaker_factory_list_register(
}
static void grpc_handshaker_factory_list_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory_list* list,
- const grpc_channel_args* args, grpc_handshake_manager* handshake_mgr) {
+ grpc_handshaker_factory_list* list, const grpc_channel_args* args,
+ grpc_handshake_manager* handshake_mgr) {
for (size_t i = 0; i < list->num_factories; ++i) {
- grpc_handshaker_factory_add_handshakers(exec_ctx, list->list[i], args,
- handshake_mgr);
+ grpc_handshaker_factory_add_handshakers(list->list[i], args, handshake_mgr);
}
}
static void grpc_handshaker_factory_list_destroy(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory_list* list) {
+ grpc_handshaker_factory_list* list) {
for (size_t i = 0; i < list->num_factories; ++i) {
- grpc_handshaker_factory_destroy(exec_ctx, list->list[i]);
+ grpc_handshaker_factory_destroy(list->list[i]);
}
gpr_free(list->list);
}
@@ -74,10 +73,9 @@ void grpc_handshaker_factory_registry_init() {
memset(g_handshaker_factory_lists, 0, sizeof(g_handshaker_factory_lists));
}
-void grpc_handshaker_factory_registry_shutdown(grpc_exec_ctx* exec_ctx) {
+void grpc_handshaker_factory_registry_shutdown() {
for (size_t i = 0; i < NUM_HANDSHAKER_TYPES; ++i) {
- grpc_handshaker_factory_list_destroy(exec_ctx,
- &g_handshaker_factory_lists[i]);
+ grpc_handshaker_factory_list_destroy(&g_handshaker_factory_lists[i]);
}
}
@@ -88,11 +86,9 @@ void grpc_handshaker_factory_register(bool at_start,
&g_handshaker_factory_lists[handshaker_type], at_start, factory);
}
-void grpc_handshakers_add(grpc_exec_ctx* exec_ctx,
- grpc_handshaker_type handshaker_type,
+void grpc_handshakers_add(grpc_handshaker_type handshaker_type,
const grpc_channel_args* args,
grpc_handshake_manager* handshake_mgr) {
grpc_handshaker_factory_list_add_handshakers(
- exec_ctx, &g_handshaker_factory_lists[handshaker_type], args,
- handshake_mgr);
+ &g_handshaker_factory_lists[handshaker_type], args, handshake_mgr);
}
diff --git a/src/core/lib/channel/handshaker_registry.h b/src/core/lib/channel/handshaker_registry.h
index ddd280bea8..edcf205fee 100644
--- a/src/core/lib/channel/handshaker_registry.h
+++ b/src/core/lib/channel/handshaker_registry.h
@@ -35,7 +35,7 @@ typedef enum {
} grpc_handshaker_type;
void grpc_handshaker_factory_registry_init();
-void grpc_handshaker_factory_registry_shutdown(grpc_exec_ctx* exec_ctx);
+void grpc_handshaker_factory_registry_shutdown();
/// Registers a new handshaker factory. Takes ownership.
/// If \a at_start is true, the new handshaker will be at the beginning of
@@ -44,8 +44,7 @@ void grpc_handshaker_factory_register(bool at_start,
grpc_handshaker_type handshaker_type,
grpc_handshaker_factory* factory);
-void grpc_handshakers_add(grpc_exec_ctx* exec_ctx,
- grpc_handshaker_type handshaker_type,
+void grpc_handshakers_add(grpc_handshaker_type handshaker_type,
const grpc_channel_args* args,
grpc_handshake_manager* handshake_mgr);
diff --git a/src/core/lib/compression/message_compress.cc b/src/core/lib/compression/message_compress.cc
index c051e28864..aa43a53f2b 100644
--- a/src/core/lib/compression/message_compress.cc
+++ b/src/core/lib/compression/message_compress.cc
@@ -29,8 +29,8 @@
#define OUTPUT_BLOCK_SIZE 1024
-static int zlib_body(grpc_exec_ctx* exec_ctx, z_stream* zs,
- grpc_slice_buffer* input, grpc_slice_buffer* output,
+static int zlib_body(z_stream* zs, grpc_slice_buffer* input,
+ grpc_slice_buffer* output,
int (*flate)(z_stream* zs, int flush)) {
int r;
int flush;
@@ -74,7 +74,7 @@ static int zlib_body(grpc_exec_ctx* exec_ctx, z_stream* zs,
return 1;
error:
- grpc_slice_unref_internal(exec_ctx, outbuf);
+ grpc_slice_unref_internal(outbuf);
return 0;
}
@@ -84,8 +84,8 @@ static void* zalloc_gpr(void* opaque, unsigned int items, unsigned int size) {
static void zfree_gpr(void* opaque, void* address) { gpr_free(address); }
-static int zlib_compress(grpc_exec_ctx* exec_ctx, grpc_slice_buffer* input,
- grpc_slice_buffer* output, int gzip) {
+static int zlib_compress(grpc_slice_buffer* input, grpc_slice_buffer* output,
+ int gzip) {
z_stream zs;
int r;
size_t i;
@@ -97,11 +97,10 @@ static int zlib_compress(grpc_exec_ctx* exec_ctx, grpc_slice_buffer* input,
r = deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 15 | (gzip ? 16 : 0),
8, Z_DEFAULT_STRATEGY);
GPR_ASSERT(r == Z_OK);
- r = zlib_body(exec_ctx, &zs, input, output, deflate) &&
- output->length < input->length;
+ r = zlib_body(&zs, input, output, deflate) && output->length < input->length;
if (!r) {
for (i = count_before; i < output->count; i++) {
- grpc_slice_unref_internal(exec_ctx, output->slices[i]);
+ grpc_slice_unref_internal(output->slices[i]);
}
output->count = count_before;
output->length = length_before;
@@ -110,8 +109,8 @@ static int zlib_compress(grpc_exec_ctx* exec_ctx, grpc_slice_buffer* input,
return r;
}
-static int zlib_decompress(grpc_exec_ctx* exec_ctx, grpc_slice_buffer* input,
- grpc_slice_buffer* output, int gzip) {
+static int zlib_decompress(grpc_slice_buffer* input, grpc_slice_buffer* output,
+ int gzip) {
z_stream zs;
int r;
size_t i;
@@ -122,10 +121,10 @@ static int zlib_decompress(grpc_exec_ctx* exec_ctx, grpc_slice_buffer* input,
zs.zfree = zfree_gpr;
r = inflateInit2(&zs, 15 | (gzip ? 16 : 0));
GPR_ASSERT(r == Z_OK);
- r = zlib_body(exec_ctx, &zs, input, output, inflate);
+ r = zlib_body(&zs, input, output, inflate);
if (!r) {
for (i = count_before; i < output->count; i++) {
- grpc_slice_unref_internal(exec_ctx, output->slices[i]);
+ grpc_slice_unref_internal(output->slices[i]);
}
output->count = count_before;
output->length = length_before;
@@ -142,8 +141,7 @@ static int copy(grpc_slice_buffer* input, grpc_slice_buffer* output) {
return 1;
}
-static int compress_inner(grpc_exec_ctx* exec_ctx,
- grpc_compression_algorithm algorithm,
+static int compress_inner(grpc_compression_algorithm algorithm,
grpc_slice_buffer* input, grpc_slice_buffer* output) {
switch (algorithm) {
case GRPC_COMPRESS_NONE:
@@ -151,9 +149,9 @@ static int compress_inner(grpc_exec_ctx* exec_ctx,
rely on that here */
return 0;
case GRPC_COMPRESS_DEFLATE:
- return zlib_compress(exec_ctx, input, output, 0);
+ return zlib_compress(input, output, 0);
case GRPC_COMPRESS_GZIP:
- return zlib_compress(exec_ctx, input, output, 1);
+ return zlib_compress(input, output, 1);
case GRPC_COMPRESS_ALGORITHMS_COUNT:
break;
}
@@ -161,26 +159,24 @@ static int compress_inner(grpc_exec_ctx* exec_ctx,
return 0;
}
-int grpc_msg_compress(grpc_exec_ctx* exec_ctx,
- grpc_compression_algorithm algorithm,
+int grpc_msg_compress(grpc_compression_algorithm algorithm,
grpc_slice_buffer* input, grpc_slice_buffer* output) {
- if (!compress_inner(exec_ctx, algorithm, input, output)) {
+ if (!compress_inner(algorithm, input, output)) {
copy(input, output);
return 0;
}
return 1;
}
-int grpc_msg_decompress(grpc_exec_ctx* exec_ctx,
- grpc_compression_algorithm algorithm,
+int grpc_msg_decompress(grpc_compression_algorithm algorithm,
grpc_slice_buffer* input, grpc_slice_buffer* output) {
switch (algorithm) {
case GRPC_COMPRESS_NONE:
return copy(input, output);
case GRPC_COMPRESS_DEFLATE:
- return zlib_decompress(exec_ctx, input, output, 0);
+ return zlib_decompress(input, output, 0);
case GRPC_COMPRESS_GZIP:
- return zlib_decompress(exec_ctx, input, output, 1);
+ return zlib_decompress(input, output, 1);
case GRPC_COMPRESS_ALGORITHMS_COUNT:
break;
}
diff --git a/src/core/lib/compression/message_compress.h b/src/core/lib/compression/message_compress.h
index fffe175fd2..9e109127eb 100644
--- a/src/core/lib/compression/message_compress.h
+++ b/src/core/lib/compression/message_compress.h
@@ -29,15 +29,13 @@ extern "C" {
/* compress 'input' to 'output' using 'algorithm'.
On success, appends compressed slices to output and returns 1.
On failure, appends uncompressed slices to output and returns 0. */
-int grpc_msg_compress(grpc_exec_ctx* exec_ctx,
- grpc_compression_algorithm algorithm,
+int grpc_msg_compress(grpc_compression_algorithm algorithm,
grpc_slice_buffer* input, grpc_slice_buffer* output);
/* decompress 'input' to 'output' using 'algorithm'.
On success, appends slices to output and returns 1.
On failure, output is unchanged, and returns 0. */
-int grpc_msg_decompress(grpc_exec_ctx* exec_ctx,
- grpc_compression_algorithm algorithm,
+int grpc_msg_decompress(grpc_compression_algorithm algorithm,
grpc_slice_buffer* input, grpc_slice_buffer* output);
#ifdef __cplusplus
diff --git a/src/core/lib/compression/stream_compression_gzip.cc b/src/core/lib/compression/stream_compression_gzip.cc
index 0c3fdd1269..6c4397759f 100644
--- a/src/core/lib/compression/stream_compression_gzip.cc
+++ b/src/core/lib/compression/stream_compression_gzip.cc
@@ -40,7 +40,7 @@ static bool gzip_flate(grpc_stream_compression_context_gzip* ctx,
/* Full flush is not allowed when inflating. */
GPR_ASSERT(!(ctx->flate == inflate && (flush == Z_FINISH)));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
int r;
bool eoc = false;
size_t original_max_output_size = max_output_size;
@@ -57,8 +57,8 @@ static bool gzip_flate(grpc_stream_compression_context_gzip* ctx,
r = ctx->flate(&ctx->zs, Z_NO_FLUSH);
if (r < 0 && r != Z_BUF_ERROR) {
gpr_log(GPR_ERROR, "zlib error (%d)", r);
- grpc_slice_unref_internal(&exec_ctx, slice_out);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(slice_out);
+
return false;
} else if (r == Z_STREAM_END && ctx->flate == inflate) {
eoc = true;
@@ -69,7 +69,7 @@ static bool gzip_flate(grpc_stream_compression_context_gzip* ctx,
grpc_slice_sub(slice, GRPC_SLICE_LENGTH(slice) - ctx->zs.avail_in,
GRPC_SLICE_LENGTH(slice)));
}
- grpc_slice_unref_internal(&exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
}
if (flush != 0 && ctx->zs.avail_out > 0 && !eoc) {
GPR_ASSERT(in->length == 0);
@@ -88,8 +88,8 @@ static bool gzip_flate(grpc_stream_compression_context_gzip* ctx,
break;
default:
gpr_log(GPR_ERROR, "zlib error (%d)", r);
- grpc_slice_unref_internal(&exec_ctx, slice_out);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(slice_out);
+
return false;
}
} else if (flush == Z_FINISH) {
@@ -104,8 +104,8 @@ static bool gzip_flate(grpc_stream_compression_context_gzip* ctx,
break;
default:
gpr_log(GPR_ERROR, "zlib error (%d)", r);
- grpc_slice_unref_internal(&exec_ctx, slice_out);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(slice_out);
+
return false;
}
}
@@ -117,11 +117,11 @@ static bool gzip_flate(grpc_stream_compression_context_gzip* ctx,
slice_out.data.refcounted.length -= ctx->zs.avail_out;
grpc_slice_buffer_add(out, slice_out);
} else {
- grpc_slice_unref_internal(&exec_ctx, slice_out);
+ grpc_slice_unref_internal(slice_out);
}
max_output_size -= (slice_size - ctx->zs.avail_out);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
if (end_of_context) {
*end_of_context = eoc;
}
diff --git a/src/core/lib/debug/stats.cc b/src/core/lib/debug/stats.cc
index 7d2af71c47..0b39b2b1e7 100644
--- a/src/core/lib/debug/stats.cc
+++ b/src/core/lib/debug/stats.cc
@@ -62,9 +62,9 @@ void grpc_stats_diff(const grpc_stats_data* b, const grpc_stats_data* a,
}
}
-int grpc_stats_histo_find_bucket_slow(grpc_exec_ctx* exec_ctx, int value,
- const int* table, int table_size) {
- GRPC_STATS_INC_HISTOGRAM_SLOW_LOOKUPS(exec_ctx);
+int grpc_stats_histo_find_bucket_slow(int value, const int* table,
+ int table_size) {
+ GRPC_STATS_INC_HISTOGRAM_SLOW_LOOKUPS();
const int* const start = table;
while (table_size > 0) {
int step = table_size / 2;
diff --git a/src/core/lib/debug/stats.h b/src/core/lib/debug/stats.h
index 1c19e72345..6b36f67172 100644
--- a/src/core/lib/debug/stats.h
+++ b/src/core/lib/debug/stats.h
@@ -34,17 +34,15 @@ typedef struct grpc_stats_data {
extern grpc_stats_data* grpc_stats_per_cpu_storage;
-#define GRPC_THREAD_STATS_DATA(exec_ctx) \
- (&grpc_stats_per_cpu_storage[(exec_ctx)->starting_cpu])
+#define GRPC_THREAD_STATS_DATA() \
+ (&grpc_stats_per_cpu_storage[grpc_core::ExecCtx::Get()->starting_cpu()])
-#define GRPC_STATS_INC_COUNTER(exec_ctx, ctr) \
- (gpr_atm_no_barrier_fetch_add( \
- &GRPC_THREAD_STATS_DATA((exec_ctx))->counters[(ctr)], 1))
+#define GRPC_STATS_INC_COUNTER(ctr) \
+ (gpr_atm_no_barrier_fetch_add(&GRPC_THREAD_STATS_DATA()->counters[(ctr)], 1))
-#define GRPC_STATS_INC_HISTOGRAM(exec_ctx, histogram, index) \
- (gpr_atm_no_barrier_fetch_add( \
- &GRPC_THREAD_STATS_DATA((exec_ctx)) \
- ->histograms[histogram##_FIRST_SLOT + (index)], \
+#define GRPC_STATS_INC_HISTOGRAM(histogram, index) \
+ (gpr_atm_no_barrier_fetch_add( \
+ &GRPC_THREAD_STATS_DATA()->histograms[histogram##_FIRST_SLOT + (index)], \
1))
void grpc_stats_init(void);
@@ -54,8 +52,8 @@ void grpc_stats_collect(grpc_stats_data* output);
void grpc_stats_diff(const grpc_stats_data* b, const grpc_stats_data* a,
grpc_stats_data* c);
char* grpc_stats_data_as_json(const grpc_stats_data* data);
-int grpc_stats_histo_find_bucket_slow(grpc_exec_ctx* exec_ctx, int value,
- const int* table, int table_size);
+int grpc_stats_histo_find_bucket_slow(int value, const int* table,
+ int table_size);
double grpc_stats_histo_percentile(const grpc_stats_data* data,
grpc_stats_histograms histogram,
double percentile);
diff --git a/src/core/lib/debug/stats_data.cc b/src/core/lib/debug/stats_data.cc
index 17e15f4cfb..996ed3de9a 100644
--- a/src/core/lib/debug/stats_data.cc
+++ b/src/core/lib/debug/stats_data.cc
@@ -342,11 +342,10 @@ const uint8_t grpc_stats_table_7[102] = {
42, 42, 43, 44, 44, 45, 46, 46, 47, 48, 48, 49, 49, 50, 50, 51, 51};
const int grpc_stats_table_8[9] = {0, 1, 2, 4, 7, 13, 23, 39, 64};
const uint8_t grpc_stats_table_9[9] = {0, 0, 1, 2, 2, 3, 4, 4, 5};
-void grpc_stats_inc_call_initial_size(grpc_exec_ctx* exec_ctx, int value) {
+void grpc_stats_inc_call_initial_size(int value) {
value = GPR_CLAMP(value, 0, 262144);
if (value < 6) {
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE,
- value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE, value);
return;
}
union {
@@ -359,19 +358,17 @@ void grpc_stats_inc_call_initial_size(grpc_exec_ctx* exec_ctx, int value) {
grpc_stats_table_1[((_val.uint - 4618441417868443648ull) >> 49)] + 6;
_bkt.dbl = grpc_stats_table_0[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE,
- bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE, bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_0, 64));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_0, 64));
}
-void grpc_stats_inc_poll_events_returned(grpc_exec_ctx* exec_ctx, int value) {
+void grpc_stats_inc_poll_events_returned(int value) {
value = GPR_CLAMP(value, 0, 1024);
if (value < 29) {
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_POLL_EVENTS_RETURNED, value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_POLL_EVENTS_RETURNED, value);
return;
}
union {
@@ -384,20 +381,17 @@ void grpc_stats_inc_poll_events_returned(grpc_exec_ctx* exec_ctx, int value) {
grpc_stats_table_3[((_val.uint - 4628855992006737920ull) >> 47)] + 29;
_bkt.dbl = grpc_stats_table_2[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_POLL_EVENTS_RETURNED, bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_POLL_EVENTS_RETURNED, bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_POLL_EVENTS_RETURNED,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_2, 128));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_POLL_EVENTS_RETURNED,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_2, 128));
}
-void grpc_stats_inc_tcp_write_size(grpc_exec_ctx* exec_ctx, int value) {
+void grpc_stats_inc_tcp_write_size(int value) {
value = GPR_CLAMP(value, 0, 16777216);
if (value < 5) {
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE,
- value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE, value);
return;
}
union {
@@ -410,19 +404,17 @@ void grpc_stats_inc_tcp_write_size(grpc_exec_ctx* exec_ctx, int value) {
grpc_stats_table_5[((_val.uint - 4617315517961601024ull) >> 50)] + 5;
_bkt.dbl = grpc_stats_table_4[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE,
- bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE, bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_4, 64));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_4, 64));
}
-void grpc_stats_inc_tcp_write_iov_size(grpc_exec_ctx* exec_ctx, int value) {
+void grpc_stats_inc_tcp_write_iov_size(int value) {
value = GPR_CLAMP(value, 0, 1024);
if (value < 13) {
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE, value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE, value);
return;
}
union {
@@ -435,19 +427,17 @@ void grpc_stats_inc_tcp_write_iov_size(grpc_exec_ctx* exec_ctx, int value) {
grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
_bkt.dbl = grpc_stats_table_6[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE, bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE, bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_6, 64));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
}
-void grpc_stats_inc_tcp_read_size(grpc_exec_ctx* exec_ctx, int value) {
+void grpc_stats_inc_tcp_read_size(int value) {
value = GPR_CLAMP(value, 0, 16777216);
if (value < 5) {
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_SIZE,
- value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_SIZE, value);
return;
}
union {
@@ -460,19 +450,17 @@ void grpc_stats_inc_tcp_read_size(grpc_exec_ctx* exec_ctx, int value) {
grpc_stats_table_5[((_val.uint - 4617315517961601024ull) >> 50)] + 5;
_bkt.dbl = grpc_stats_table_4[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_SIZE,
- bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_SIZE, bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_SIZE,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_4, 64));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_TCP_READ_SIZE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_4, 64));
}
-void grpc_stats_inc_tcp_read_offer(grpc_exec_ctx* exec_ctx, int value) {
+void grpc_stats_inc_tcp_read_offer(int value) {
value = GPR_CLAMP(value, 0, 16777216);
if (value < 5) {
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_OFFER,
- value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_OFFER, value);
return;
}
union {
@@ -485,20 +473,18 @@ void grpc_stats_inc_tcp_read_offer(grpc_exec_ctx* exec_ctx, int value) {
grpc_stats_table_5[((_val.uint - 4617315517961601024ull) >> 50)] + 5;
_bkt.dbl = grpc_stats_table_4[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_OFFER,
- bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_OFFER, bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_OFFER,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_4, 64));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_TCP_READ_OFFER,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_4, 64));
}
-void grpc_stats_inc_tcp_read_offer_iov_size(grpc_exec_ctx* exec_ctx,
- int value) {
+void grpc_stats_inc_tcp_read_offer_iov_size(int value) {
value = GPR_CLAMP(value, 0, 1024);
if (value < 13) {
- GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_OFFER_IOV_SIZE, value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_OFFER_IOV_SIZE,
+ value);
return;
}
union {
@@ -511,21 +497,19 @@ void grpc_stats_inc_tcp_read_offer_iov_size(grpc_exec_ctx* exec_ctx,
grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
_bkt.dbl = grpc_stats_table_6[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_OFFER_IOV_SIZE, bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_OFFER_IOV_SIZE,
+ bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_TCP_READ_OFFER_IOV_SIZE,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_6, 64));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_TCP_READ_OFFER_IOV_SIZE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
}
-void grpc_stats_inc_http2_send_message_size(grpc_exec_ctx* exec_ctx,
- int value) {
+void grpc_stats_inc_http2_send_message_size(int value) {
value = GPR_CLAMP(value, 0, 16777216);
if (value < 5) {
- GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_SIZE, value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_SIZE,
+ value);
return;
}
union {
@@ -538,22 +522,19 @@ void grpc_stats_inc_http2_send_message_size(grpc_exec_ctx* exec_ctx,
grpc_stats_table_5[((_val.uint - 4617315517961601024ull) >> 50)] + 5;
_bkt.dbl = grpc_stats_table_4[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_SIZE, bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_SIZE,
+ bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_SIZE,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_4, 64));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_SIZE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_4, 64));
}
-void grpc_stats_inc_http2_send_initial_metadata_per_write(
- grpc_exec_ctx* exec_ctx, int value) {
+void grpc_stats_inc_http2_send_initial_metadata_per_write(int value) {
value = GPR_CLAMP(value, 0, 1024);
if (value < 13) {
GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_INITIAL_METADATA_PER_WRITE,
- value);
+ GRPC_STATS_HISTOGRAM_HTTP2_SEND_INITIAL_METADATA_PER_WRITE, value);
return;
}
union {
@@ -567,21 +548,18 @@ void grpc_stats_inc_http2_send_initial_metadata_per_write(
_bkt.dbl = grpc_stats_table_6[bucket];
bucket -= (_val.uint < _bkt.uint);
GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_INITIAL_METADATA_PER_WRITE,
- bucket);
+ GRPC_STATS_HISTOGRAM_HTTP2_SEND_INITIAL_METADATA_PER_WRITE, bucket);
return;
}
GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_INITIAL_METADATA_PER_WRITE,
- grpc_stats_histo_find_bucket_slow((exec_ctx), value, grpc_stats_table_6,
- 64));
+ GRPC_STATS_HISTOGRAM_HTTP2_SEND_INITIAL_METADATA_PER_WRITE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
}
-void grpc_stats_inc_http2_send_message_per_write(grpc_exec_ctx* exec_ctx,
- int value) {
+void grpc_stats_inc_http2_send_message_per_write(int value) {
value = GPR_CLAMP(value, 0, 1024);
if (value < 13) {
- GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_PER_WRITE, value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_PER_WRITE,
+ value);
return;
}
union {
@@ -594,22 +572,19 @@ void grpc_stats_inc_http2_send_message_per_write(grpc_exec_ctx* exec_ctx,
grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
_bkt.dbl = grpc_stats_table_6[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_PER_WRITE, bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_PER_WRITE,
+ bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_PER_WRITE,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_6, 64));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_PER_WRITE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
}
-void grpc_stats_inc_http2_send_trailing_metadata_per_write(
- grpc_exec_ctx* exec_ctx, int value) {
+void grpc_stats_inc_http2_send_trailing_metadata_per_write(int value) {
value = GPR_CLAMP(value, 0, 1024);
if (value < 13) {
GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE,
- value);
+ GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE, value);
return;
}
union {
@@ -623,21 +598,18 @@ void grpc_stats_inc_http2_send_trailing_metadata_per_write(
_bkt.dbl = grpc_stats_table_6[bucket];
bucket -= (_val.uint < _bkt.uint);
GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE,
- bucket);
+ GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE, bucket);
return;
}
GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE,
- grpc_stats_histo_find_bucket_slow((exec_ctx), value, grpc_stats_table_6,
- 64));
+ GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
}
-void grpc_stats_inc_http2_send_flowctl_per_write(grpc_exec_ctx* exec_ctx,
- int value) {
+void grpc_stats_inc_http2_send_flowctl_per_write(int value) {
value = GPR_CLAMP(value, 0, 1024);
if (value < 13) {
- GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE, value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE,
+ value);
return;
}
union {
@@ -650,20 +622,18 @@ void grpc_stats_inc_http2_send_flowctl_per_write(grpc_exec_ctx* exec_ctx,
grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
_bkt.dbl = grpc_stats_table_6[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM(
- (exec_ctx), GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE, bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE,
+ bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_6, 64));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
}
-void grpc_stats_inc_server_cqs_checked(grpc_exec_ctx* exec_ctx, int value) {
+void grpc_stats_inc_server_cqs_checked(int value) {
value = GPR_CLAMP(value, 0, 64);
if (value < 3) {
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED, value);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED, value);
return;
}
union {
@@ -676,13 +646,12 @@ void grpc_stats_inc_server_cqs_checked(grpc_exec_ctx* exec_ctx, int value) {
grpc_stats_table_9[((_val.uint - 4613937818241073152ull) >> 51)] + 3;
_bkt.dbl = grpc_stats_table_8[bucket];
bucket -= (_val.uint < _bkt.uint);
- GRPC_STATS_INC_HISTOGRAM((exec_ctx),
- GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED, bucket);
+ GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED, bucket);
return;
}
- GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED,
- grpc_stats_histo_find_bucket_slow(
- (exec_ctx), value, grpc_stats_table_8, 8));
+ GRPC_STATS_INC_HISTOGRAM(
+ GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED,
+ grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_8, 8));
}
const int grpc_stats_histo_buckets[13] = {64, 128, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 8};
@@ -694,7 +663,7 @@ const int* const grpc_stats_histo_bucket_boundaries[13] = {
grpc_stats_table_6, grpc_stats_table_4, grpc_stats_table_6,
grpc_stats_table_6, grpc_stats_table_6, grpc_stats_table_6,
grpc_stats_table_8};
-void (*const grpc_stats_inc_histogram[13])(grpc_exec_ctx* exec_ctx, int x) = {
+void (*const grpc_stats_inc_histogram[13])(int x) = {
grpc_stats_inc_call_initial_size,
grpc_stats_inc_poll_events_returned,
grpc_stats_inc_tcp_write_size,
diff --git a/src/core/lib/debug/stats_data.h b/src/core/lib/debug/stats_data.h
index fbfcce83ba..a5debec43e 100644
--- a/src/core/lib/debug/stats_data.h
+++ b/src/core/lib/debug/stats_data.h
@@ -176,331 +176,263 @@ typedef enum {
GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED_BUCKETS = 8,
GRPC_STATS_HISTOGRAM_BUCKETS = 840
} grpc_stats_histogram_constants;
-#define GRPC_STATS_INC_CLIENT_CALLS_CREATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_CLIENT_CALLS_CREATED)
-#define GRPC_STATS_INC_SERVER_CALLS_CREATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SERVER_CALLS_CREATED)
-#define GRPC_STATS_INC_CQS_CREATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_CQS_CREATED)
-#define GRPC_STATS_INC_CLIENT_CHANNELS_CREATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_CLIENT_CHANNELS_CREATED)
-#define GRPC_STATS_INC_CLIENT_SUBCHANNELS_CREATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_CLIENT_SUBCHANNELS_CREATED)
-#define GRPC_STATS_INC_SERVER_CHANNELS_CREATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SERVER_CHANNELS_CREATED)
-#define GRPC_STATS_INC_SYSCALL_POLL(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_POLL)
-#define GRPC_STATS_INC_SYSCALL_WAIT(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_WAIT)
-#define GRPC_STATS_INC_POLLSET_KICK(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_POLLSET_KICK)
-#define GRPC_STATS_INC_POLLSET_KICKED_WITHOUT_POLLER(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_POLLSET_KICKED_WITHOUT_POLLER)
-#define GRPC_STATS_INC_POLLSET_KICKED_AGAIN(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_POLLSET_KICKED_AGAIN)
-#define GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_POLLSET_KICK_WAKEUP_FD)
-#define GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_POLLSET_KICK_WAKEUP_CV)
-#define GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_POLLSET_KICK_OWN_THREAD)
-#define GRPC_STATS_INC_HISTOGRAM_SLOW_LOOKUPS(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HISTOGRAM_SLOW_LOOKUPS)
-#define GRPC_STATS_INC_SYSCALL_WRITE(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_WRITE)
-#define GRPC_STATS_INC_SYSCALL_READ(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_READ)
-#define GRPC_STATS_INC_TCP_BACKUP_POLLERS_CREATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_TCP_BACKUP_POLLERS_CREATED)
-#define GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_TCP_BACKUP_POLLER_POLLS)
-#define GRPC_STATS_INC_HTTP2_OP_BATCHES(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_OP_BATCHES)
-#define GRPC_STATS_INC_HTTP2_OP_CANCEL(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_OP_CANCEL)
-#define GRPC_STATS_INC_HTTP2_OP_SEND_INITIAL_METADATA(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HTTP2_OP_SEND_INITIAL_METADATA)
-#define GRPC_STATS_INC_HTTP2_OP_SEND_MESSAGE(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_OP_SEND_MESSAGE)
-#define GRPC_STATS_INC_HTTP2_OP_SEND_TRAILING_METADATA(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HTTP2_OP_SEND_TRAILING_METADATA)
-#define GRPC_STATS_INC_HTTP2_OP_RECV_INITIAL_METADATA(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HTTP2_OP_RECV_INITIAL_METADATA)
-#define GRPC_STATS_INC_HTTP2_OP_RECV_MESSAGE(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_OP_RECV_MESSAGE)
-#define GRPC_STATS_INC_HTTP2_OP_RECV_TRAILING_METADATA(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HTTP2_OP_RECV_TRAILING_METADATA)
-#define GRPC_STATS_INC_HTTP2_SETTINGS_WRITES(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_SETTINGS_WRITES)
-#define GRPC_STATS_INC_HTTP2_PINGS_SENT(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_PINGS_SENT)
-#define GRPC_STATS_INC_HTTP2_WRITES_BEGUN(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_WRITES_BEGUN)
-#define GRPC_STATS_INC_HTTP2_WRITES_OFFLOADED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_WRITES_OFFLOADED)
-#define GRPC_STATS_INC_HTTP2_WRITES_CONTINUED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_WRITES_CONTINUED)
-#define GRPC_STATS_INC_HTTP2_PARTIAL_WRITES(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_PARTIAL_WRITES)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_INITIAL_WRITE(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_CLIENT_CALLS_CREATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CLIENT_CALLS_CREATED)
+#define GRPC_STATS_INC_SERVER_CALLS_CREATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_SERVER_CALLS_CREATED)
+#define GRPC_STATS_INC_CQS_CREATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CQS_CREATED)
+#define GRPC_STATS_INC_CLIENT_CHANNELS_CREATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CLIENT_CHANNELS_CREATED)
+#define GRPC_STATS_INC_CLIENT_SUBCHANNELS_CREATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CLIENT_SUBCHANNELS_CREATED)
+#define GRPC_STATS_INC_SERVER_CHANNELS_CREATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_SERVER_CHANNELS_CREATED)
+#define GRPC_STATS_INC_SYSCALL_POLL() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_SYSCALL_POLL)
+#define GRPC_STATS_INC_SYSCALL_WAIT() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_SYSCALL_WAIT)
+#define GRPC_STATS_INC_POLLSET_KICK() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_POLLSET_KICK)
+#define GRPC_STATS_INC_POLLSET_KICKED_WITHOUT_POLLER() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_POLLSET_KICKED_WITHOUT_POLLER)
+#define GRPC_STATS_INC_POLLSET_KICKED_AGAIN() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_POLLSET_KICKED_AGAIN)
+#define GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_POLLSET_KICK_WAKEUP_FD)
+#define GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_POLLSET_KICK_WAKEUP_CV)
+#define GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_POLLSET_KICK_OWN_THREAD)
+#define GRPC_STATS_INC_HISTOGRAM_SLOW_LOOKUPS() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HISTOGRAM_SLOW_LOOKUPS)
+#define GRPC_STATS_INC_SYSCALL_WRITE() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_SYSCALL_WRITE)
+#define GRPC_STATS_INC_SYSCALL_READ() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_SYSCALL_READ)
+#define GRPC_STATS_INC_TCP_BACKUP_POLLERS_CREATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_TCP_BACKUP_POLLERS_CREATED)
+#define GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_TCP_BACKUP_POLLER_POLLS)
+#define GRPC_STATS_INC_HTTP2_OP_BATCHES() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_OP_BATCHES)
+#define GRPC_STATS_INC_HTTP2_OP_CANCEL() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_OP_CANCEL)
+#define GRPC_STATS_INC_HTTP2_OP_SEND_INITIAL_METADATA() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_OP_SEND_INITIAL_METADATA)
+#define GRPC_STATS_INC_HTTP2_OP_SEND_MESSAGE() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_OP_SEND_MESSAGE)
+#define GRPC_STATS_INC_HTTP2_OP_SEND_TRAILING_METADATA() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_OP_SEND_TRAILING_METADATA)
+#define GRPC_STATS_INC_HTTP2_OP_RECV_INITIAL_METADATA() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_OP_RECV_INITIAL_METADATA)
+#define GRPC_STATS_INC_HTTP2_OP_RECV_MESSAGE() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_OP_RECV_MESSAGE)
+#define GRPC_STATS_INC_HTTP2_OP_RECV_TRAILING_METADATA() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_OP_RECV_TRAILING_METADATA)
+#define GRPC_STATS_INC_HTTP2_SETTINGS_WRITES() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_SETTINGS_WRITES)
+#define GRPC_STATS_INC_HTTP2_PINGS_SENT() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_PINGS_SENT)
+#define GRPC_STATS_INC_HTTP2_WRITES_BEGUN() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_WRITES_BEGUN)
+#define GRPC_STATS_INC_HTTP2_WRITES_OFFLOADED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_WRITES_OFFLOADED)
+#define GRPC_STATS_INC_HTTP2_WRITES_CONTINUED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_WRITES_CONTINUED)
+#define GRPC_STATS_INC_HTTP2_PARTIAL_WRITES() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_PARTIAL_WRITES)
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_INITIAL_WRITE() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_INITIAL_WRITE)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_START_NEW_STREAM(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_START_NEW_STREAM() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_START_NEW_STREAM)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_MESSAGE(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_SEND_MESSAGE)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_INITIAL_METADATA( \
- exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
- GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_SEND_INITIAL_METADATA)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_TRAILING_METADATA( \
- exec_ctx) \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_MESSAGE() \
+ GRPC_STATS_INC_COUNTER( \
+ GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_SEND_MESSAGE)
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_INITIAL_METADATA() \
GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+ GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_SEND_INITIAL_METADATA)
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_TRAILING_METADATA() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_SEND_TRAILING_METADATA)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_RETRY_SEND_PING(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_RETRY_SEND_PING() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_RETRY_SEND_PING)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_CONTINUE_PINGS(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_CONTINUE_PINGS() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_CONTINUE_PINGS)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_GOAWAY_SENT(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_GOAWAY_SENT)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_RST_STREAM(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_RST_STREAM)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_CLOSE_FROM_API(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_GOAWAY_SENT() \
+ GRPC_STATS_INC_COUNTER( \
+ GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_GOAWAY_SENT)
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_RST_STREAM() \
+ GRPC_STATS_INC_COUNTER( \
+ GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_RST_STREAM)
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_CLOSE_FROM_API() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_CLOSE_FROM_API)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_STREAM_FLOW_CONTROL( \
- exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_STREAM_FLOW_CONTROL() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_STREAM_FLOW_CONTROL)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL( \
- exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_SETTINGS(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_SETTINGS() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_SEND_SETTINGS)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_BDP_ESTIMATOR_PING( \
- exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_BDP_ESTIMATOR_PING() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_BDP_ESTIMATOR_PING)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_SETTING( \
- exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_SETTING() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_SETTING)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_UPDATE( \
- exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_UPDATE() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_UPDATE)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_APPLICATION_PING(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_APPLICATION_PING() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_APPLICATION_PING)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_KEEPALIVE_PING(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_KEEPALIVE_PING() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_KEEPALIVE_PING)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL_UNSTALLED( \
- exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL_UNSTALLED() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL_UNSTALLED)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_PING_RESPONSE(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_PING_RESPONSE() \
+ GRPC_STATS_INC_COUNTER( \
GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_PING_RESPONSE)
-#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FORCE_RST_STREAM(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), \
- GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_FORCE_RST_STREAM)
-#define GRPC_STATS_INC_HTTP2_SPURIOUS_WRITES_BEGUN(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HTTP2_SPURIOUS_WRITES_BEGUN)
-#define GRPC_STATS_INC_HPACK_RECV_INDEXED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HPACK_RECV_INDEXED)
-#define GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_INCIDX)
-#define GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX_V(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_INCIDX_V)
-#define GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_NOTIDX)
-#define GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX_V(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_NOTIDX_V)
-#define GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_NVRIDX)
-#define GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX_V(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_NVRIDX_V)
-#define GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HPACK_RECV_UNCOMPRESSED)
-#define GRPC_STATS_INC_HPACK_RECV_HUFFMAN(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HPACK_RECV_HUFFMAN)
-#define GRPC_STATS_INC_HPACK_RECV_BINARY(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HPACK_RECV_BINARY)
-#define GRPC_STATS_INC_HPACK_RECV_BINARY_BASE64(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_RECV_BINARY_BASE64)
-#define GRPC_STATS_INC_HPACK_SEND_INDEXED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HPACK_SEND_INDEXED)
-#define GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_INCIDX)
-#define GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX_V(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_INCIDX_V)
-#define GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_NOTIDX)
-#define GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX_V(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_NOTIDX_V)
-#define GRPC_STATS_INC_HPACK_SEND_LITHDR_NVRIDX(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_NVRIDX)
-#define GRPC_STATS_INC_HPACK_SEND_LITHDR_NVRIDX_V(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_NVRIDX_V)
-#define GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HPACK_SEND_UNCOMPRESSED)
-#define GRPC_STATS_INC_HPACK_SEND_HUFFMAN(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HPACK_SEND_HUFFMAN)
-#define GRPC_STATS_INC_HPACK_SEND_BINARY(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HPACK_SEND_BINARY)
-#define GRPC_STATS_INC_HPACK_SEND_BINARY_BASE64(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_HPACK_SEND_BINARY_BASE64)
-#define GRPC_STATS_INC_COMBINER_LOCKS_INITIATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_COMBINER_LOCKS_INITIATED)
-#define GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_ITEMS(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_COMBINER_LOCKS_SCHEDULED_ITEMS)
-#define GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_FINAL_ITEMS(exec_ctx) \
+#define GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FORCE_RST_STREAM() \
GRPC_STATS_INC_COUNTER( \
- (exec_ctx), GRPC_STATS_COUNTER_COMBINER_LOCKS_SCHEDULED_FINAL_ITEMS)
-#define GRPC_STATS_INC_COMBINER_LOCKS_OFFLOADED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_COMBINER_LOCKS_OFFLOADED)
-#define GRPC_STATS_INC_CALL_COMBINER_LOCKS_INITIATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_CALL_COMBINER_LOCKS_INITIATED)
-#define GRPC_STATS_INC_CALL_COMBINER_LOCKS_SCHEDULED_ITEMS(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), GRPC_STATS_COUNTER_CALL_COMBINER_LOCKS_SCHEDULED_ITEMS)
-#define GRPC_STATS_INC_CALL_COMBINER_SET_NOTIFY_ON_CANCEL(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), GRPC_STATS_COUNTER_CALL_COMBINER_SET_NOTIFY_ON_CANCEL)
-#define GRPC_STATS_INC_CALL_COMBINER_CANCELLED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_CALL_COMBINER_CANCELLED)
-#define GRPC_STATS_INC_EXECUTOR_SCHEDULED_SHORT_ITEMS(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_EXECUTOR_SCHEDULED_SHORT_ITEMS)
-#define GRPC_STATS_INC_EXECUTOR_SCHEDULED_LONG_ITEMS(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_EXECUTOR_SCHEDULED_LONG_ITEMS)
-#define GRPC_STATS_INC_EXECUTOR_SCHEDULED_TO_SELF(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_EXECUTOR_SCHEDULED_TO_SELF)
-#define GRPC_STATS_INC_EXECUTOR_WAKEUP_INITIATED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_EXECUTOR_WAKEUP_INITIATED)
-#define GRPC_STATS_INC_EXECUTOR_QUEUE_DRAINED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_EXECUTOR_QUEUE_DRAINED)
-#define GRPC_STATS_INC_EXECUTOR_PUSH_RETRIES(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_EXECUTOR_PUSH_RETRIES)
-#define GRPC_STATS_INC_SERVER_REQUESTED_CALLS(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SERVER_REQUESTED_CALLS)
-#define GRPC_STATS_INC_SERVER_SLOWPATH_REQUESTS_QUEUED(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_SERVER_SLOWPATH_REQUESTS_QUEUED)
-#define GRPC_STATS_INC_CQ_EV_QUEUE_TRYLOCK_FAILURES(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_CQ_EV_QUEUE_TRYLOCK_FAILURES)
-#define GRPC_STATS_INC_CQ_EV_QUEUE_TRYLOCK_SUCCESSES(exec_ctx) \
- GRPC_STATS_INC_COUNTER((exec_ctx), \
- GRPC_STATS_COUNTER_CQ_EV_QUEUE_TRYLOCK_SUCCESSES)
-#define GRPC_STATS_INC_CQ_EV_QUEUE_TRANSIENT_POP_FAILURES(exec_ctx) \
- GRPC_STATS_INC_COUNTER( \
- (exec_ctx), GRPC_STATS_COUNTER_CQ_EV_QUEUE_TRANSIENT_POP_FAILURES)
-#define GRPC_STATS_INC_CALL_INITIAL_SIZE(exec_ctx, value) \
- grpc_stats_inc_call_initial_size((exec_ctx), (int)(value))
-void grpc_stats_inc_call_initial_size(grpc_exec_ctx* exec_ctx, int x);
-#define GRPC_STATS_INC_POLL_EVENTS_RETURNED(exec_ctx, value) \
- grpc_stats_inc_poll_events_returned((exec_ctx), (int)(value))
-void grpc_stats_inc_poll_events_returned(grpc_exec_ctx* exec_ctx, int x);
-#define GRPC_STATS_INC_TCP_WRITE_SIZE(exec_ctx, value) \
- grpc_stats_inc_tcp_write_size((exec_ctx), (int)(value))
-void grpc_stats_inc_tcp_write_size(grpc_exec_ctx* exec_ctx, int x);
-#define GRPC_STATS_INC_TCP_WRITE_IOV_SIZE(exec_ctx, value) \
- grpc_stats_inc_tcp_write_iov_size((exec_ctx), (int)(value))
-void grpc_stats_inc_tcp_write_iov_size(grpc_exec_ctx* exec_ctx, int x);
-#define GRPC_STATS_INC_TCP_READ_SIZE(exec_ctx, value) \
- grpc_stats_inc_tcp_read_size((exec_ctx), (int)(value))
-void grpc_stats_inc_tcp_read_size(grpc_exec_ctx* exec_ctx, int x);
-#define GRPC_STATS_INC_TCP_READ_OFFER(exec_ctx, value) \
- grpc_stats_inc_tcp_read_offer((exec_ctx), (int)(value))
-void grpc_stats_inc_tcp_read_offer(grpc_exec_ctx* exec_ctx, int x);
-#define GRPC_STATS_INC_TCP_READ_OFFER_IOV_SIZE(exec_ctx, value) \
- grpc_stats_inc_tcp_read_offer_iov_size((exec_ctx), (int)(value))
-void grpc_stats_inc_tcp_read_offer_iov_size(grpc_exec_ctx* exec_ctx, int x);
-#define GRPC_STATS_INC_HTTP2_SEND_MESSAGE_SIZE(exec_ctx, value) \
- grpc_stats_inc_http2_send_message_size((exec_ctx), (int)(value))
-void grpc_stats_inc_http2_send_message_size(grpc_exec_ctx* exec_ctx, int x);
-#define GRPC_STATS_INC_HTTP2_SEND_INITIAL_METADATA_PER_WRITE(exec_ctx, value) \
- grpc_stats_inc_http2_send_initial_metadata_per_write((exec_ctx), (int)(value))
-void grpc_stats_inc_http2_send_initial_metadata_per_write(
- grpc_exec_ctx* exec_ctx, int x);
-#define GRPC_STATS_INC_HTTP2_SEND_MESSAGE_PER_WRITE(exec_ctx, value) \
- grpc_stats_inc_http2_send_message_per_write((exec_ctx), (int)(value))
-void grpc_stats_inc_http2_send_message_per_write(grpc_exec_ctx* exec_ctx,
- int x);
-#define GRPC_STATS_INC_HTTP2_SEND_TRAILING_METADATA_PER_WRITE(exec_ctx, value) \
- grpc_stats_inc_http2_send_trailing_metadata_per_write((exec_ctx), \
- (int)(value))
-void grpc_stats_inc_http2_send_trailing_metadata_per_write(
- grpc_exec_ctx* exec_ctx, int x);
-#define GRPC_STATS_INC_HTTP2_SEND_FLOWCTL_PER_WRITE(exec_ctx, value) \
- grpc_stats_inc_http2_send_flowctl_per_write((exec_ctx), (int)(value))
-void grpc_stats_inc_http2_send_flowctl_per_write(grpc_exec_ctx* exec_ctx,
- int x);
-#define GRPC_STATS_INC_SERVER_CQS_CHECKED(exec_ctx, value) \
- grpc_stats_inc_server_cqs_checked((exec_ctx), (int)(value))
-void grpc_stats_inc_server_cqs_checked(grpc_exec_ctx* exec_ctx, int x);
+ GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_FORCE_RST_STREAM)
+#define GRPC_STATS_INC_HTTP2_SPURIOUS_WRITES_BEGUN() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_SPURIOUS_WRITES_BEGUN)
+#define GRPC_STATS_INC_HPACK_RECV_INDEXED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_INDEXED)
+#define GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_INCIDX)
+#define GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX_V() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_INCIDX_V)
+#define GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_NOTIDX)
+#define GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX_V() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_NOTIDX_V)
+#define GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_NVRIDX)
+#define GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX_V() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_LITHDR_NVRIDX_V)
+#define GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_UNCOMPRESSED)
+#define GRPC_STATS_INC_HPACK_RECV_HUFFMAN() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_HUFFMAN)
+#define GRPC_STATS_INC_HPACK_RECV_BINARY() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_BINARY)
+#define GRPC_STATS_INC_HPACK_RECV_BINARY_BASE64() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_RECV_BINARY_BASE64)
+#define GRPC_STATS_INC_HPACK_SEND_INDEXED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_INDEXED)
+#define GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_INCIDX)
+#define GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX_V() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_INCIDX_V)
+#define GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_NOTIDX)
+#define GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX_V() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_NOTIDX_V)
+#define GRPC_STATS_INC_HPACK_SEND_LITHDR_NVRIDX() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_NVRIDX)
+#define GRPC_STATS_INC_HPACK_SEND_LITHDR_NVRIDX_V() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_LITHDR_NVRIDX_V)
+#define GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_UNCOMPRESSED)
+#define GRPC_STATS_INC_HPACK_SEND_HUFFMAN() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_HUFFMAN)
+#define GRPC_STATS_INC_HPACK_SEND_BINARY() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_BINARY)
+#define GRPC_STATS_INC_HPACK_SEND_BINARY_BASE64() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HPACK_SEND_BINARY_BASE64)
+#define GRPC_STATS_INC_COMBINER_LOCKS_INITIATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_COMBINER_LOCKS_INITIATED)
+#define GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_ITEMS() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_COMBINER_LOCKS_SCHEDULED_ITEMS)
+#define GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_FINAL_ITEMS() \
+ GRPC_STATS_INC_COUNTER( \
+ GRPC_STATS_COUNTER_COMBINER_LOCKS_SCHEDULED_FINAL_ITEMS)
+#define GRPC_STATS_INC_COMBINER_LOCKS_OFFLOADED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_COMBINER_LOCKS_OFFLOADED)
+#define GRPC_STATS_INC_CALL_COMBINER_LOCKS_INITIATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CALL_COMBINER_LOCKS_INITIATED)
+#define GRPC_STATS_INC_CALL_COMBINER_LOCKS_SCHEDULED_ITEMS() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CALL_COMBINER_LOCKS_SCHEDULED_ITEMS)
+#define GRPC_STATS_INC_CALL_COMBINER_SET_NOTIFY_ON_CANCEL() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CALL_COMBINER_SET_NOTIFY_ON_CANCEL)
+#define GRPC_STATS_INC_CALL_COMBINER_CANCELLED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CALL_COMBINER_CANCELLED)
+#define GRPC_STATS_INC_EXECUTOR_SCHEDULED_SHORT_ITEMS() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_EXECUTOR_SCHEDULED_SHORT_ITEMS)
+#define GRPC_STATS_INC_EXECUTOR_SCHEDULED_LONG_ITEMS() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_EXECUTOR_SCHEDULED_LONG_ITEMS)
+#define GRPC_STATS_INC_EXECUTOR_SCHEDULED_TO_SELF() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_EXECUTOR_SCHEDULED_TO_SELF)
+#define GRPC_STATS_INC_EXECUTOR_WAKEUP_INITIATED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_EXECUTOR_WAKEUP_INITIATED)
+#define GRPC_STATS_INC_EXECUTOR_QUEUE_DRAINED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_EXECUTOR_QUEUE_DRAINED)
+#define GRPC_STATS_INC_EXECUTOR_PUSH_RETRIES() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_EXECUTOR_PUSH_RETRIES)
+#define GRPC_STATS_INC_SERVER_REQUESTED_CALLS() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_SERVER_REQUESTED_CALLS)
+#define GRPC_STATS_INC_SERVER_SLOWPATH_REQUESTS_QUEUED() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_SERVER_SLOWPATH_REQUESTS_QUEUED)
+#define GRPC_STATS_INC_CQ_EV_QUEUE_TRYLOCK_FAILURES() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CQ_EV_QUEUE_TRYLOCK_FAILURES)
+#define GRPC_STATS_INC_CQ_EV_QUEUE_TRYLOCK_SUCCESSES() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CQ_EV_QUEUE_TRYLOCK_SUCCESSES)
+#define GRPC_STATS_INC_CQ_EV_QUEUE_TRANSIENT_POP_FAILURES() \
+ GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CQ_EV_QUEUE_TRANSIENT_POP_FAILURES)
+#define GRPC_STATS_INC_CALL_INITIAL_SIZE(value) \
+ grpc_stats_inc_call_initial_size((int)(value))
+void grpc_stats_inc_call_initial_size(int x);
+#define GRPC_STATS_INC_POLL_EVENTS_RETURNED(value) \
+ grpc_stats_inc_poll_events_returned((int)(value))
+void grpc_stats_inc_poll_events_returned(int x);
+#define GRPC_STATS_INC_TCP_WRITE_SIZE(value) \
+ grpc_stats_inc_tcp_write_size((int)(value))
+void grpc_stats_inc_tcp_write_size(int x);
+#define GRPC_STATS_INC_TCP_WRITE_IOV_SIZE(value) \
+ grpc_stats_inc_tcp_write_iov_size((int)(value))
+void grpc_stats_inc_tcp_write_iov_size(int x);
+#define GRPC_STATS_INC_TCP_READ_SIZE(value) \
+ grpc_stats_inc_tcp_read_size((int)(value))
+void grpc_stats_inc_tcp_read_size(int x);
+#define GRPC_STATS_INC_TCP_READ_OFFER(value) \
+ grpc_stats_inc_tcp_read_offer((int)(value))
+void grpc_stats_inc_tcp_read_offer(int x);
+#define GRPC_STATS_INC_TCP_READ_OFFER_IOV_SIZE(value) \
+ grpc_stats_inc_tcp_read_offer_iov_size((int)(value))
+void grpc_stats_inc_tcp_read_offer_iov_size(int x);
+#define GRPC_STATS_INC_HTTP2_SEND_MESSAGE_SIZE(value) \
+ grpc_stats_inc_http2_send_message_size((int)(value))
+void grpc_stats_inc_http2_send_message_size(int x);
+#define GRPC_STATS_INC_HTTP2_SEND_INITIAL_METADATA_PER_WRITE(value) \
+ grpc_stats_inc_http2_send_initial_metadata_per_write((int)(value))
+void grpc_stats_inc_http2_send_initial_metadata_per_write(int x);
+#define GRPC_STATS_INC_HTTP2_SEND_MESSAGE_PER_WRITE(value) \
+ grpc_stats_inc_http2_send_message_per_write((int)(value))
+void grpc_stats_inc_http2_send_message_per_write(int x);
+#define GRPC_STATS_INC_HTTP2_SEND_TRAILING_METADATA_PER_WRITE(value) \
+ grpc_stats_inc_http2_send_trailing_metadata_per_write((int)(value))
+void grpc_stats_inc_http2_send_trailing_metadata_per_write(int x);
+#define GRPC_STATS_INC_HTTP2_SEND_FLOWCTL_PER_WRITE(value) \
+ grpc_stats_inc_http2_send_flowctl_per_write((int)(value))
+void grpc_stats_inc_http2_send_flowctl_per_write(int x);
+#define GRPC_STATS_INC_SERVER_CQS_CHECKED(value) \
+ grpc_stats_inc_server_cqs_checked((int)(value))
+void grpc_stats_inc_server_cqs_checked(int x);
extern const int grpc_stats_histo_buckets[13];
extern const int grpc_stats_histo_start[13];
extern const int* const grpc_stats_histo_bucket_boundaries[13];
-extern void (*const grpc_stats_inc_histogram[13])(grpc_exec_ctx* exec_ctx,
- int x);
+extern void (*const grpc_stats_inc_histogram[13])(int x);
#ifdef __cplusplus
}
diff --git a/src/core/lib/http/httpcli.cc b/src/core/lib/http/httpcli.cc
index 73b484b06d..ed874c4265 100644
--- a/src/core/lib/http/httpcli.cc
+++ b/src/core/lib/http/httpcli.cc
@@ -63,13 +63,11 @@ typedef struct {
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,
- grpc_millis deadline,
- void (*on_done)(grpc_exec_ctx* exec_ctx,
- void* arg,
+static void plaintext_handshake(void* arg, grpc_endpoint* endpoint,
+ const char* host, grpc_millis deadline,
+ void (*on_done)(void* arg,
grpc_endpoint* endpoint)) {
- on_done(exec_ctx, arg, endpoint);
+ on_done(arg, endpoint);
}
const grpc_httpcli_handshaker grpc_httpcli_plaintext = {"http",
@@ -79,34 +77,31 @@ void grpc_httpcli_context_init(grpc_httpcli_context* context) {
context->pollset_set = grpc_pollset_set_create();
}
-void grpc_httpcli_context_destroy(grpc_exec_ctx* exec_ctx,
- grpc_httpcli_context* context) {
- grpc_pollset_set_destroy(exec_ctx, context->pollset_set);
+void grpc_httpcli_context_destroy(grpc_httpcli_context* context) {
+ grpc_pollset_set_destroy(context->pollset_set);
}
-static void next_address(grpc_exec_ctx* exec_ctx, internal_request* req,
- grpc_error* due_to_error);
+static void next_address(internal_request* req, grpc_error* due_to_error);
-static void finish(grpc_exec_ctx* exec_ctx, internal_request* req,
- grpc_error* error) {
- grpc_polling_entity_del_from_pollset_set(exec_ctx, req->pollent,
+static void finish(internal_request* req, grpc_error* error) {
+ grpc_polling_entity_del_from_pollset_set(req->pollent,
req->context->pollset_set);
- GRPC_CLOSURE_SCHED(exec_ctx, req->on_done, error);
+ GRPC_CLOSURE_SCHED(req->on_done, error);
grpc_http_parser_destroy(&req->parser);
if (req->addresses != nullptr) {
grpc_resolved_addresses_destroy(req->addresses);
}
if (req->ep != nullptr) {
- grpc_endpoint_destroy(exec_ctx, req->ep);
+ grpc_endpoint_destroy(req->ep);
}
- grpc_slice_unref_internal(exec_ctx, req->request_text);
+ grpc_slice_unref_internal(req->request_text);
gpr_free(req->host);
gpr_free(req->ssl_host_override);
grpc_iomgr_unregister_object(&req->iomgr_obj);
- grpc_slice_buffer_destroy_internal(exec_ctx, &req->incoming);
- grpc_slice_buffer_destroy_internal(exec_ctx, &req->outgoing);
+ grpc_slice_buffer_destroy_internal(&req->incoming);
+ grpc_slice_buffer_destroy_internal(&req->outgoing);
GRPC_ERROR_UNREF(req->overall_error);
- grpc_resource_quota_unref_internal(exec_ctx, req->resource_quota);
+ grpc_resource_quota_unref_internal(req->resource_quota);
gpr_free(req);
}
@@ -124,12 +119,11 @@ static void append_error(internal_request* req, grpc_error* error) {
gpr_free(addr_text);
}
-static void do_read(grpc_exec_ctx* exec_ctx, internal_request* req) {
- grpc_endpoint_read(exec_ctx, req->ep, &req->incoming, &req->on_read);
+static void do_read(internal_request* req) {
+ grpc_endpoint_read(req->ep, &req->incoming, &req->on_read);
}
-static void on_read(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_error* error) {
+static void on_read(void* user_data, grpc_error* error) {
internal_request* req = (internal_request*)user_data;
size_t i;
@@ -139,77 +133,70 @@ static void on_read(grpc_exec_ctx* exec_ctx, void* user_data,
grpc_error* err = grpc_http_parser_parse(
&req->parser, req->incoming.slices[i], nullptr);
if (err != GRPC_ERROR_NONE) {
- finish(exec_ctx, req, err);
+ finish(req, err);
return;
}
}
}
if (error == GRPC_ERROR_NONE) {
- do_read(exec_ctx, req);
+ do_read(req);
} else if (!req->have_read_byte) {
- next_address(exec_ctx, req, GRPC_ERROR_REF(error));
+ next_address(req, GRPC_ERROR_REF(error));
} else {
- finish(exec_ctx, req, grpc_http_parser_eof(&req->parser));
+ finish(req, grpc_http_parser_eof(&req->parser));
}
}
-static void on_written(grpc_exec_ctx* exec_ctx, internal_request* req) {
- do_read(exec_ctx, req);
-}
+static void on_written(internal_request* req) { do_read(req); }
-static void done_write(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void done_write(void* arg, grpc_error* error) {
internal_request* req = (internal_request*)arg;
if (error == GRPC_ERROR_NONE) {
- on_written(exec_ctx, req);
+ on_written(req);
} else {
- next_address(exec_ctx, req, GRPC_ERROR_REF(error));
+ next_address(req, GRPC_ERROR_REF(error));
}
}
-static void start_write(grpc_exec_ctx* exec_ctx, internal_request* req) {
+static void start_write(internal_request* req) {
grpc_slice_ref_internal(req->request_text);
grpc_slice_buffer_add(&req->outgoing, req->request_text);
- grpc_endpoint_write(exec_ctx, req->ep, &req->outgoing, &req->done_write);
+ grpc_endpoint_write(req->ep, &req->outgoing, &req->done_write);
}
-static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_endpoint* ep) {
+static void on_handshake_done(void* arg, grpc_endpoint* ep) {
internal_request* req = (internal_request*)arg;
if (!ep) {
- next_address(
- exec_ctx, req,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unexplained handshake failure"));
+ next_address(req, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Unexplained handshake failure"));
return;
}
req->ep = ep;
- start_write(exec_ctx, req);
+ start_write(req);
}
-static void on_connected(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_connected(void* arg, grpc_error* error) {
internal_request* req = (internal_request*)arg;
if (!req->ep) {
- next_address(exec_ctx, req, GRPC_ERROR_REF(error));
+ next_address(req, GRPC_ERROR_REF(error));
return;
}
req->handshaker->handshake(
- exec_ctx, req, req->ep,
- req->ssl_host_override ? req->ssl_host_override : req->host,
+ req, req->ep, req->ssl_host_override ? req->ssl_host_override : req->host,
req->deadline, on_handshake_done);
}
-static void next_address(grpc_exec_ctx* exec_ctx, internal_request* req,
- grpc_error* error) {
+static void next_address(internal_request* req, grpc_error* error) {
grpc_resolved_address* addr;
if (error != GRPC_ERROR_NONE) {
append_error(req, error);
}
if (req->next_address == req->addresses->naddrs) {
- finish(exec_ctx, req,
+ finish(req,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failed HTTP requests to all targets", &req->overall_error, 1));
return;
@@ -221,23 +208,21 @@ static void next_address(grpc_exec_ctx* exec_ctx, internal_request* req,
(char*)GRPC_ARG_RESOURCE_QUOTA, req->resource_quota,
grpc_resource_quota_arg_vtable());
grpc_channel_args args = {1, &arg};
- grpc_tcp_client_connect(exec_ctx, &req->connected, &req->ep,
- req->context->pollset_set, &args, addr,
- req->deadline);
+ grpc_tcp_client_connect(&req->connected, &req->ep, req->context->pollset_set,
+ &args, addr, req->deadline);
}
-static void on_resolved(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void on_resolved(void* arg, grpc_error* error) {
internal_request* req = (internal_request*)arg;
if (error != GRPC_ERROR_NONE) {
- finish(exec_ctx, req, GRPC_ERROR_REF(error));
+ finish(req, GRPC_ERROR_REF(error));
return;
}
req->next_address = 0;
- next_address(exec_ctx, req, GRPC_ERROR_NONE);
+ next_address(req, GRPC_ERROR_NONE);
}
-static void internal_request_begin(grpc_exec_ctx* exec_ctx,
- grpc_httpcli_context* context,
+static void internal_request_begin(grpc_httpcli_context* context,
grpc_polling_entity* pollent,
grpc_resource_quota* resource_quota,
const grpc_httpcli_request* request,
@@ -267,33 +252,31 @@ static void internal_request_begin(grpc_exec_ctx* exec_ctx,
req->ssl_host_override = gpr_strdup(request->ssl_host_override);
GPR_ASSERT(pollent);
- grpc_polling_entity_add_to_pollset_set(exec_ctx, req->pollent,
+ grpc_polling_entity_add_to_pollset_set(req->pollent,
req->context->pollset_set);
grpc_resolve_address(
- exec_ctx, request->host, req->handshaker->default_port,
- req->context->pollset_set,
+ request->host, req->handshaker->default_port, req->context->pollset_set,
GRPC_CLOSURE_CREATE(on_resolved, req, grpc_schedule_on_exec_ctx),
&req->addresses);
}
-void grpc_httpcli_get(grpc_exec_ctx* exec_ctx, grpc_httpcli_context* context,
+void grpc_httpcli_get(grpc_httpcli_context* context,
grpc_polling_entity* pollent,
grpc_resource_quota* resource_quota,
const grpc_httpcli_request* request, grpc_millis deadline,
grpc_closure* on_done, grpc_httpcli_response* response) {
char* name;
- if (g_get_override &&
- g_get_override(exec_ctx, request, deadline, on_done, response)) {
+ if (g_get_override && g_get_override(request, deadline, on_done, response)) {
return;
}
gpr_asprintf(&name, "HTTP:GET:%s:%s", request->host, request->http.path);
- internal_request_begin(exec_ctx, context, pollent, resource_quota, request,
- deadline, on_done, response, name,
+ internal_request_begin(context, pollent, resource_quota, request, deadline,
+ on_done, response, name,
grpc_httpcli_format_get_request(request));
gpr_free(name);
}
-void grpc_httpcli_post(grpc_exec_ctx* exec_ctx, grpc_httpcli_context* context,
+void grpc_httpcli_post(grpc_httpcli_context* context,
grpc_polling_entity* pollent,
grpc_resource_quota* resource_quota,
const grpc_httpcli_request* request,
@@ -301,16 +284,14 @@ void grpc_httpcli_post(grpc_exec_ctx* exec_ctx, grpc_httpcli_context* context,
grpc_millis deadline, grpc_closure* on_done,
grpc_httpcli_response* response) {
char* name;
- if (g_post_override &&
- g_post_override(exec_ctx, request, body_bytes, body_size, deadline,
- on_done, response)) {
+ if (g_post_override && g_post_override(request, body_bytes, body_size,
+ deadline, on_done, response)) {
return;
}
gpr_asprintf(&name, "HTTP:POST:%s:%s", request->host, request->http.path);
internal_request_begin(
- exec_ctx, context, pollent, resource_quota, request, deadline, on_done,
- response, name,
- grpc_httpcli_format_post_request(request, body_bytes, body_size));
+ context, pollent, resource_quota, request, deadline, on_done, response,
+ name, grpc_httpcli_format_post_request(request, body_bytes, body_size));
gpr_free(name);
}
diff --git a/src/core/lib/http/httpcli.h b/src/core/lib/http/httpcli.h
index a3411341ad..d112d16fcc 100644
--- a/src/core/lib/http/httpcli.h
+++ b/src/core/lib/http/httpcli.h
@@ -45,10 +45,9 @@ typedef struct grpc_httpcli_context {
typedef struct {
const char* default_port;
- void (*handshake)(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* endpoint,
- const char* host, grpc_millis deadline,
- void (*on_done)(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_endpoint* endpoint));
+ void (*handshake)(void* arg, grpc_endpoint* endpoint, const char* host,
+ grpc_millis deadline,
+ void (*on_done)(void* arg, grpc_endpoint* endpoint));
} grpc_httpcli_handshaker;
extern const grpc_httpcli_handshaker grpc_httpcli_plaintext;
@@ -72,8 +71,7 @@ typedef struct grpc_httpcli_request {
typedef struct grpc_http_response grpc_httpcli_response;
void grpc_httpcli_context_init(grpc_httpcli_context* context);
-void grpc_httpcli_context_destroy(grpc_exec_ctx* exec_ctx,
- grpc_httpcli_context* context);
+void grpc_httpcli_context_destroy(grpc_httpcli_context* context);
/* Asynchronously perform a HTTP GET.
'context' specifies the http context under which to do the get
@@ -84,7 +82,7 @@ void grpc_httpcli_context_destroy(grpc_exec_ctx* exec_ctx,
destroyed once the call returns
'deadline' contains a deadline for the request (or gpr_inf_future)
'on_response' is a callback to report results to */
-void grpc_httpcli_get(grpc_exec_ctx* exec_ctx, grpc_httpcli_context* context,
+void grpc_httpcli_get(grpc_httpcli_context* context,
grpc_polling_entity* pollent,
grpc_resource_quota* resource_quota,
const grpc_httpcli_request* request, grpc_millis deadline,
@@ -105,7 +103,7 @@ void grpc_httpcli_get(grpc_exec_ctx* exec_ctx, grpc_httpcli_context* context,
lifetime of the request
'on_response' is a callback to report results to
Does not support ?var1=val1&var2=val2 in the path. */
-void grpc_httpcli_post(grpc_exec_ctx* exec_ctx, grpc_httpcli_context* context,
+void grpc_httpcli_post(grpc_httpcli_context* context,
grpc_polling_entity* pollent,
grpc_resource_quota* resource_quota,
const grpc_httpcli_request* request,
@@ -114,15 +112,16 @@ void grpc_httpcli_post(grpc_exec_ctx* exec_ctx, grpc_httpcli_context* context,
grpc_httpcli_response* response);
/* override functions return 1 if they handled the request, 0 otherwise */
-typedef int (*grpc_httpcli_get_override)(grpc_exec_ctx* exec_ctx,
- const grpc_httpcli_request* request,
+typedef int (*grpc_httpcli_get_override)(const grpc_httpcli_request* request,
grpc_millis deadline,
grpc_closure* on_complete,
grpc_httpcli_response* response);
-typedef int (*grpc_httpcli_post_override)(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- const char* body_bytes, size_t body_size, grpc_millis deadline,
- grpc_closure* on_complete, grpc_httpcli_response* response);
+typedef int (*grpc_httpcli_post_override)(const grpc_httpcli_request* request,
+ const char* body_bytes,
+ size_t body_size,
+ grpc_millis deadline,
+ grpc_closure* on_complete,
+ grpc_httpcli_response* response);
void grpc_httpcli_set_override(grpc_httpcli_get_override get,
grpc_httpcli_post_override post);
diff --git a/src/core/lib/http/httpcli_security_connector.cc b/src/core/lib/http/httpcli_security_connector.cc
index d25fba538f..26599bc50a 100644
--- a/src/core/lib/http/httpcli_security_connector.cc
+++ b/src/core/lib/http/httpcli_security_connector.cc
@@ -38,8 +38,7 @@ typedef struct {
char* secure_peer_name;
} grpc_httpcli_ssl_channel_security_connector;
-static void httpcli_ssl_destroy(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc) {
+static void httpcli_ssl_destroy(grpc_security_connector* sc) {
grpc_httpcli_ssl_channel_security_connector* c =
(grpc_httpcli_ssl_channel_security_connector*)sc;
if (c->handshaker_factory != nullptr) {
@@ -50,8 +49,7 @@ static void httpcli_ssl_destroy(grpc_exec_ctx* exec_ctx,
gpr_free(sc);
}
-static void httpcli_ssl_add_handshakers(grpc_exec_ctx* exec_ctx,
- grpc_channel_security_connector* sc,
+static void httpcli_ssl_add_handshakers(grpc_channel_security_connector* sc,
grpc_handshake_manager* handshake_mgr) {
grpc_httpcli_ssl_channel_security_connector* c =
(grpc_httpcli_ssl_channel_security_connector*)sc;
@@ -65,13 +63,11 @@ static void httpcli_ssl_add_handshakers(grpc_exec_ctx* exec_ctx,
}
}
grpc_handshake_manager_add(
- handshake_mgr,
- grpc_security_handshaker_create(
- exec_ctx, tsi_create_adapter_handshaker(handshaker), &sc->base));
+ handshake_mgr, grpc_security_handshaker_create(
+ tsi_create_adapter_handshaker(handshaker), &sc->base));
}
-static void httpcli_ssl_check_peer(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc, tsi_peer peer,
+static void httpcli_ssl_check_peer(grpc_security_connector* sc, tsi_peer peer,
grpc_auth_context** auth_context,
grpc_closure* on_peer_checked) {
grpc_httpcli_ssl_channel_security_connector* c =
@@ -87,7 +83,7 @@ static void httpcli_ssl_check_peer(grpc_exec_ctx* exec_ctx,
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
}
- GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked, error);
+ GRPC_CLOSURE_SCHED(on_peer_checked, error);
tsi_peer_destruct(&peer);
}
@@ -104,8 +100,8 @@ static grpc_security_connector_vtable httpcli_ssl_vtable = {
httpcli_ssl_destroy, httpcli_ssl_check_peer, httpcli_ssl_cmp};
static grpc_security_status httpcli_ssl_channel_security_connector_create(
- grpc_exec_ctx* exec_ctx, const char* pem_root_certs,
- const char* secure_peer_name, grpc_channel_security_connector** sc) {
+ const char* pem_root_certs, const char* secure_peer_name,
+ grpc_channel_security_connector** sc) {
tsi_result result = TSI_OK;
grpc_httpcli_ssl_channel_security_connector* c;
@@ -128,12 +124,12 @@ static grpc_security_status httpcli_ssl_channel_security_connector_create(
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);
+ httpcli_ssl_destroy(&c->base.base);
*sc = nullptr;
return GRPC_SECURITY_ERROR;
}
// We don't actually need a channel credentials object in this case,
- // but we set it to a non-NULL address so that we don't trigger
+ // but we set it to a non-nullptr address so that we don't trigger
// assertions in grpc_channel_security_connector_cmp().
c->base.channel_creds = (grpc_channel_credentials*)1;
c->base.add_handshakers = httpcli_ssl_add_handshakers;
@@ -144,40 +140,37 @@ static grpc_security_status httpcli_ssl_channel_security_connector_create(
/* handshaker */
typedef struct {
- void (*func)(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* endpoint);
+ void (*func)(void* arg, grpc_endpoint* endpoint);
void* arg;
grpc_handshake_manager* handshake_mgr;
} on_done_closure;
-static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_handshake_done(void* arg, grpc_error* error) {
grpc_handshaker_args* args = (grpc_handshaker_args*)arg;
on_done_closure* c = (on_done_closure*)args->user_data;
if (error != GRPC_ERROR_NONE) {
const char* msg = grpc_error_string(error);
gpr_log(GPR_ERROR, "Secure transport setup failed: %s", msg);
- c->func(exec_ctx, c->arg, nullptr);
+ c->func(c->arg, nullptr);
} else {
- grpc_channel_args_destroy(exec_ctx, args->args);
- grpc_slice_buffer_destroy_internal(exec_ctx, args->read_buffer);
+ grpc_channel_args_destroy(args->args);
+ grpc_slice_buffer_destroy_internal(args->read_buffer);
gpr_free(args->read_buffer);
- c->func(exec_ctx, c->arg, args->endpoint);
+ c->func(c->arg, args->endpoint);
}
- grpc_handshake_manager_destroy(exec_ctx, c->handshake_mgr);
+ grpc_handshake_manager_destroy(c->handshake_mgr);
gpr_free(c);
}
-static void ssl_handshake(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_endpoint* tcp, const char* host,
+static void ssl_handshake(void* arg, grpc_endpoint* tcp, const char* host,
grpc_millis deadline,
- void (*on_done)(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_endpoint* endpoint)) {
+ void (*on_done)(void* arg, grpc_endpoint* endpoint)) {
on_done_closure* c = (on_done_closure*)gpr_malloc(sizeof(*c));
const char* pem_root_certs = grpc_get_default_ssl_roots();
if (pem_root_certs == nullptr) {
gpr_log(GPR_ERROR, "Could not get default pem root certs.");
- on_done(exec_ctx, arg, nullptr);
+ on_done(arg, nullptr);
gpr_free(c);
return;
}
@@ -185,15 +178,15 @@ static void ssl_handshake(grpc_exec_ctx* exec_ctx, void* arg,
c->arg = arg;
grpc_channel_security_connector* sc = nullptr;
GPR_ASSERT(httpcli_ssl_channel_security_connector_create(
- exec_ctx, pem_root_certs, host, &sc) == GRPC_SECURITY_OK);
+ pem_root_certs, host, &sc) == GRPC_SECURITY_OK);
grpc_arg channel_arg = grpc_security_connector_to_arg(&sc->base);
grpc_channel_args args = {1, &channel_arg};
c->handshake_mgr = grpc_handshake_manager_create();
- grpc_handshakers_add(exec_ctx, HANDSHAKER_CLIENT, &args, c->handshake_mgr);
+ grpc_handshakers_add(HANDSHAKER_CLIENT, &args, c->handshake_mgr);
grpc_handshake_manager_do_handshake(
- exec_ctx, c->handshake_mgr, tcp, nullptr /* channel_args */, deadline,
+ c->handshake_mgr, tcp, nullptr /* channel_args */, deadline,
nullptr /* acceptor */, on_handshake_done, c /* user_data */);
- GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, &sc->base, "httpcli");
+ GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "httpcli");
}
const grpc_httpcli_handshaker grpc_httpcli_ssl = {"https", ssl_handshake};
diff --git a/src/core/lib/iomgr/block_annotate.h b/src/core/lib/iomgr/block_annotate.h
index fcbfe9eb1a..55bde3eaac 100644
--- a/src/core/lib/iomgr/block_annotate.h
+++ b/src/core/lib/iomgr/block_annotate.h
@@ -19,6 +19,8 @@
#ifndef GRPC_CORE_LIB_IOMGR_BLOCK_ANNOTATE_H
#define GRPC_CORE_LIB_IOMGR_BLOCK_ANNOTATE_H
+#include "src/core/lib/iomgr/exec_ctx.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -39,25 +41,18 @@ void gpr_thd_end_blocking_region();
do { \
gpr_thd_start_blocking_region(); \
} while (0)
-#define GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX \
- do { \
- gpr_thd_end_blocking_region(); \
- } while (0)
-#define GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(ec) \
- do { \
- gpr_thd_end_blocking_region(); \
- grpc_exec_ctx_invalidate_now((ec)); \
+#define GRPC_SCHEDULING_END_BLOCKING_REGION \
+ do { \
+ gpr_thd_end_blocking_region(); \
+ grpc_core::ExecCtx::Get()->InvalidateNow(); \
} while (0)
#else
#define GRPC_SCHEDULING_START_BLOCKING_REGION \
do { \
} while (0)
-#define GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX \
- do { \
- } while (0)
-#define GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(ec) \
- do { \
- grpc_exec_ctx_invalidate_now((ec)); \
+#define GRPC_SCHEDULING_END_BLOCKING_REGION \
+ do { \
+ grpc_core::ExecCtx::Get()->InvalidateNow(); \
} while (0)
#endif
diff --git a/src/core/lib/iomgr/call_combiner.cc b/src/core/lib/iomgr/call_combiner.cc
index 74b077de06..32b4244748 100644
--- a/src/core/lib/iomgr/call_combiner.cc
+++ b/src/core/lib/iomgr/call_combiner.cc
@@ -57,8 +57,7 @@ void grpc_call_combiner_destroy(grpc_call_combiner* call_combiner) {
#define DEBUG_FMT_ARGS
#endif
-void grpc_call_combiner_start(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner,
+void grpc_call_combiner_start(grpc_call_combiner* call_combiner,
grpc_closure* closure,
grpc_error* error DEBUG_ARGS,
const char* reason) {
@@ -76,15 +75,16 @@ void grpc_call_combiner_start(grpc_exec_ctx* exec_ctx,
gpr_log(GPR_DEBUG, " size: %" PRIdPTR " -> %" PRIdPTR, prev_size,
prev_size + 1);
}
- GRPC_STATS_INC_CALL_COMBINER_LOCKS_SCHEDULED_ITEMS(exec_ctx);
+ GRPC_STATS_INC_CALL_COMBINER_LOCKS_SCHEDULED_ITEMS();
if (prev_size == 0) {
- GRPC_STATS_INC_CALL_COMBINER_LOCKS_INITIATED(exec_ctx);
+ GRPC_STATS_INC_CALL_COMBINER_LOCKS_INITIATED();
+
GPR_TIMER_MARK("call_combiner_initiate", 0);
if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
gpr_log(GPR_DEBUG, " EXECUTING IMMEDIATELY");
}
// Queue was empty, so execute this closure immediately.
- GRPC_CLOSURE_SCHED(exec_ctx, closure, error);
+ GRPC_CLOSURE_SCHED(closure, error);
} else {
if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
gpr_log(GPR_INFO, " QUEUING");
@@ -96,8 +96,7 @@ void grpc_call_combiner_start(grpc_exec_ctx* exec_ctx,
GPR_TIMER_END("call_combiner_start", 0);
}
-void grpc_call_combiner_stop(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner DEBUG_ARGS,
+void grpc_call_combiner_stop(grpc_call_combiner* call_combiner DEBUG_ARGS,
const char* reason) {
GPR_TIMER_BEGIN("call_combiner_stop", 0);
if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
@@ -132,7 +131,7 @@ void grpc_call_combiner_stop(grpc_exec_ctx* exec_ctx,
gpr_log(GPR_DEBUG, " EXECUTING FROM QUEUE: closure=%p error=%s",
closure, grpc_error_string(closure->error_data.error));
}
- GRPC_CLOSURE_SCHED(exec_ctx, closure, closure->error_data.error);
+ GRPC_CLOSURE_SCHED(closure, closure->error_data.error);
break;
}
} else if (GRPC_TRACER_ON(grpc_call_combiner_trace)) {
@@ -141,10 +140,9 @@ void grpc_call_combiner_stop(grpc_exec_ctx* exec_ctx,
GPR_TIMER_END("call_combiner_stop", 0);
}
-void grpc_call_combiner_set_notify_on_cancel(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner,
+void grpc_call_combiner_set_notify_on_cancel(grpc_call_combiner* call_combiner,
grpc_closure* closure) {
- GRPC_STATS_INC_CALL_COMBINER_SET_NOTIFY_ON_CANCEL(exec_ctx);
+ GRPC_STATS_INC_CALL_COMBINER_SET_NOTIFY_ON_CANCEL();
while (true) {
// Decode original state.
gpr_atm original_state = gpr_atm_acq_load(&call_combiner->cancel_state);
@@ -158,7 +156,7 @@ void grpc_call_combiner_set_notify_on_cancel(grpc_exec_ctx* exec_ctx,
"for pre-existing cancellation",
call_combiner, closure);
}
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_REF(original_error));
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_REF(original_error));
break;
} else {
if (gpr_atm_full_cas(&call_combiner->cancel_state, original_state,
@@ -177,7 +175,7 @@ void grpc_call_combiner_set_notify_on_cancel(grpc_exec_ctx* exec_ctx,
"call_combiner=%p: scheduling old cancel callback=%p",
call_combiner, closure);
}
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
}
break;
}
@@ -186,10 +184,9 @@ void grpc_call_combiner_set_notify_on_cancel(grpc_exec_ctx* exec_ctx,
}
}
-void grpc_call_combiner_cancel(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner,
+void grpc_call_combiner_cancel(grpc_call_combiner* call_combiner,
grpc_error* error) {
- GRPC_STATS_INC_CALL_COMBINER_CANCELLED(exec_ctx);
+ GRPC_STATS_INC_CALL_COMBINER_CANCELLED();
while (true) {
gpr_atm original_state = gpr_atm_acq_load(&call_combiner->cancel_state);
grpc_error* original_error = decode_cancel_state_error(original_state);
@@ -206,7 +203,7 @@ void grpc_call_combiner_cancel(grpc_exec_ctx* exec_ctx,
"call_combiner=%p: scheduling notify_on_cancel callback=%p",
call_combiner, notify_on_cancel);
}
- GRPC_CLOSURE_SCHED(exec_ctx, notify_on_cancel, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(notify_on_cancel, GRPC_ERROR_REF(error));
}
break;
}
diff --git a/src/core/lib/iomgr/call_combiner.h b/src/core/lib/iomgr/call_combiner.h
index 527f84fce0..364f77a167 100644
--- a/src/core/lib/iomgr/call_combiner.h
+++ b/src/core/lib/iomgr/call_combiner.h
@@ -57,37 +57,29 @@ void grpc_call_combiner_init(grpc_call_combiner* call_combiner);
void grpc_call_combiner_destroy(grpc_call_combiner* call_combiner);
#ifndef NDEBUG
-#define GRPC_CALL_COMBINER_START(exec_ctx, call_combiner, closure, error, \
- reason) \
- grpc_call_combiner_start((exec_ctx), (call_combiner), (closure), (error), \
- __FILE__, __LINE__, (reason))
-#define GRPC_CALL_COMBINER_STOP(exec_ctx, call_combiner, reason) \
- grpc_call_combiner_stop((exec_ctx), (call_combiner), __FILE__, __LINE__, \
- (reason))
+#define GRPC_CALL_COMBINER_START(call_combiner, closure, error, reason) \
+ grpc_call_combiner_start((call_combiner), (closure), (error), __FILE__, \
+ __LINE__, (reason))
+#define GRPC_CALL_COMBINER_STOP(call_combiner, reason) \
+ grpc_call_combiner_stop((call_combiner), __FILE__, __LINE__, (reason))
/// Starts processing \a closure on \a call_combiner.
-void grpc_call_combiner_start(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner,
+void grpc_call_combiner_start(grpc_call_combiner* call_combiner,
grpc_closure* closure, grpc_error* error,
const char* file, int line, const char* reason);
/// Yields the call combiner to the next closure in the queue, if any.
-void grpc_call_combiner_stop(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner,
+void grpc_call_combiner_stop(grpc_call_combiner* call_combiner,
const char* file, int line, const char* reason);
#else
-#define GRPC_CALL_COMBINER_START(exec_ctx, call_combiner, closure, error, \
- reason) \
- grpc_call_combiner_start((exec_ctx), (call_combiner), (closure), (error), \
- (reason))
-#define GRPC_CALL_COMBINER_STOP(exec_ctx, call_combiner, reason) \
- grpc_call_combiner_stop((exec_ctx), (call_combiner), (reason))
+#define GRPC_CALL_COMBINER_START(call_combiner, closure, error, reason) \
+ grpc_call_combiner_start((call_combiner), (closure), (error), (reason))
+#define GRPC_CALL_COMBINER_STOP(call_combiner, reason) \
+ grpc_call_combiner_stop((call_combiner), (reason))
/// Starts processing \a closure on \a call_combiner.
-void grpc_call_combiner_start(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner,
+void grpc_call_combiner_start(grpc_call_combiner* call_combiner,
grpc_closure* closure, grpc_error* error,
const char* reason);
/// Yields the call combiner to the next closure in the queue, if any.
-void grpc_call_combiner_stop(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner,
+void grpc_call_combiner_stop(grpc_call_combiner* call_combiner,
const char* reason);
#endif
@@ -113,13 +105,11 @@ void grpc_call_combiner_stop(grpc_exec_ctx* exec_ctx,
/// cancellation; this effectively unregisters the previously set closure.
/// However, most filters will not need to explicitly unregister their
/// callbacks, as this is done automatically when the call is destroyed.
-void grpc_call_combiner_set_notify_on_cancel(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner,
+void grpc_call_combiner_set_notify_on_cancel(grpc_call_combiner* call_combiner,
grpc_closure* closure);
/// Indicates that the call has been cancelled.
-void grpc_call_combiner_cancel(grpc_exec_ctx* exec_ctx,
- grpc_call_combiner* call_combiner,
+void grpc_call_combiner_cancel(grpc_call_combiner* call_combiner,
grpc_error* error);
#ifdef __cplusplus
diff --git a/src/core/lib/iomgr/closure.cc b/src/core/lib/iomgr/closure.cc
index 09257d258c..32766110cc 100644
--- a/src/core/lib/iomgr/closure.cc
+++ b/src/core/lib/iomgr/closure.cc
@@ -107,13 +107,12 @@ typedef struct {
grpc_closure wrapper;
} wrapped_closure;
-static void closure_wrapper(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void closure_wrapper(void* arg, grpc_error* error) {
wrapped_closure* wc = (wrapped_closure*)arg;
grpc_iomgr_cb_func cb = wc->cb;
void* cb_arg = wc->cb_arg;
gpr_free(wc);
- cb(exec_ctx, cb_arg, error);
+ cb(cb_arg, error);
}
#ifndef NDEBUG
@@ -136,11 +135,10 @@ grpc_closure* grpc_closure_create(grpc_iomgr_cb_func cb, void* cb_arg,
}
#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,
+void grpc_closure_run(const char* file, int line, grpc_closure* c,
grpc_error* error) {
+#else
+void grpc_closure_run(grpc_closure* c, grpc_error* error) {
#endif
GPR_TIMER_BEGIN("grpc_closure_run", 0);
if (c != nullptr) {
@@ -150,7 +148,7 @@ void grpc_closure_run(grpc_exec_ctx* exec_ctx, grpc_closure* c,
c->run = true;
#endif
assert(c->cb);
- c->scheduler->vtable->run(exec_ctx, c, error);
+ c->scheduler->vtable->run(c, error);
} else {
GRPC_ERROR_UNREF(error);
}
@@ -158,11 +156,10 @@ void grpc_closure_run(grpc_exec_ctx* exec_ctx, grpc_closure* c,
}
#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,
+void grpc_closure_sched(const char* file, int line, grpc_closure* c,
grpc_error* error) {
+#else
+void grpc_closure_sched(grpc_closure* c, grpc_error* error) {
#endif
GPR_TIMER_BEGIN("grpc_closure_sched", 0);
if (c != nullptr) {
@@ -181,7 +178,7 @@ void grpc_closure_sched(grpc_exec_ctx* exec_ctx, grpc_closure* c,
c->run = false;
#endif
assert(c->cb);
- c->scheduler->vtable->sched(exec_ctx, c, error);
+ c->scheduler->vtable->sched(c, error);
} else {
GRPC_ERROR_UNREF(error);
}
@@ -190,9 +187,9 @@ void grpc_closure_sched(grpc_exec_ctx* exec_ctx, grpc_closure* c,
#ifndef NDEBUG
void grpc_closure_list_sched(const char* file, int line,
- grpc_exec_ctx* exec_ctx, grpc_closure_list* list) {
+ grpc_closure_list* list) {
#else
-void grpc_closure_list_sched(grpc_exec_ctx* exec_ctx, grpc_closure_list* list) {
+void grpc_closure_list_sched(grpc_closure_list* list) {
#endif
grpc_closure* c = list->head;
while (c != nullptr) {
@@ -212,7 +209,7 @@ void grpc_closure_list_sched(grpc_exec_ctx* exec_ctx, grpc_closure_list* list) {
c->run = false;
#endif
assert(c->cb);
- c->scheduler->vtable->sched(exec_ctx, c, c->error_data.error);
+ c->scheduler->vtable->sched(c, c->error_data.error);
c = next;
}
list->head = list->tail = nullptr;
diff --git a/src/core/lib/iomgr/closure.h b/src/core/lib/iomgr/closure.h
index 8b1188e2db..63843ad76d 100644
--- a/src/core/lib/iomgr/closure.h
+++ b/src/core/lib/iomgr/closure.h
@@ -49,18 +49,15 @@ typedef struct grpc_closure_list {
* describing what went wrong.
* Error contract: it is not the cb's job to unref this error;
* the closure scheduler will do that after the cb returns */
-typedef void (*grpc_iomgr_cb_func)(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error);
+typedef void (*grpc_iomgr_cb_func)(void* arg, grpc_error* error);
typedef struct grpc_closure_scheduler grpc_closure_scheduler;
typedef struct grpc_closure_scheduler_vtable {
/* NOTE: for all these functions, closure->scheduler == the scheduler that was
used to find this vtable */
- void (*run)(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
- grpc_error* error);
- void (*sched)(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
- grpc_error* error);
+ void (*run)(grpc_closure* closure, grpc_error* error);
+ void (*sched)(grpc_closure* closure, grpc_error* error);
const char* name;
} grpc_closure_scheduler_vtable;
@@ -162,43 +159,37 @@ bool grpc_closure_list_empty(grpc_closure_list list);
* 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,
+void grpc_closure_run(const char* file, int line, grpc_closure* closure,
grpc_error* error);
-#define GRPC_CLOSURE_RUN(exec_ctx, closure, error) \
- grpc_closure_run(exec_ctx, closure, error)
+#define GRPC_CLOSURE_RUN(closure, error) \
+ grpc_closure_run(__FILE__, __LINE__, closure, error)
+#else
+void grpc_closure_run(grpc_closure* closure, grpc_error* error);
+#define GRPC_CLOSURE_RUN(closure, error) grpc_closure_run(closure, error)
#endif
/** Schedule a closure to be run. Does not need to be run from a safe point. */
#ifndef NDEBUG
-void grpc_closure_sched(const char* file, int line, grpc_exec_ctx* exec_ctx,
- grpc_closure* closure, grpc_error* error);
-#define GRPC_CLOSURE_SCHED(exec_ctx, closure, error) \
- grpc_closure_sched(__FILE__, __LINE__, exec_ctx, closure, error)
-#else
-void grpc_closure_sched(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
+void grpc_closure_sched(const char* file, int line, grpc_closure* closure,
grpc_error* error);
-#define GRPC_CLOSURE_SCHED(exec_ctx, closure, error) \
- grpc_closure_sched(exec_ctx, closure, error)
+#define GRPC_CLOSURE_SCHED(closure, error) \
+ grpc_closure_sched(__FILE__, __LINE__, closure, error)
+#else
+void grpc_closure_sched(grpc_closure* closure, grpc_error* error);
+#define GRPC_CLOSURE_SCHED(closure, error) grpc_closure_sched(closure, error)
#endif
/** 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)
+#define GRPC_CLOSURE_LIST_SCHED(closure_list) \
+ grpc_closure_list_sched(__FILE__, __LINE__, 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)
+void grpc_closure_list_sched(grpc_closure_list* closure_list);
+#define GRPC_CLOSURE_LIST_SCHED(closure_list) \
+ grpc_closure_list_sched(closure_list)
#endif
#ifdef __cplusplus
diff --git a/src/core/lib/iomgr/combiner.cc b/src/core/lib/iomgr/combiner.cc
index b28ca3464c..d2b7cf4b10 100644
--- a/src/core/lib/iomgr/combiner.cc
+++ b/src/core/lib/iomgr/combiner.cc
@@ -62,17 +62,15 @@ struct grpc_combiner {
gpr_refcount refs;
};
-static void combiner_exec(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
- grpc_error* error);
-static void combiner_finally_exec(grpc_exec_ctx* exec_ctx,
- grpc_closure* closure, grpc_error* error);
+static void combiner_exec(grpc_closure* closure, grpc_error* error);
+static void combiner_finally_exec(grpc_closure* closure, grpc_error* error);
static const grpc_closure_scheduler_vtable scheduler = {
combiner_exec, combiner_exec, "combiner:immediately"};
static const grpc_closure_scheduler_vtable finally_scheduler = {
combiner_finally_exec, combiner_finally_exec, "combiner:finally"};
-static void offload(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error);
+static void offload(void* arg, grpc_error* error);
grpc_combiner* grpc_combiner_create(void) {
grpc_combiner* lock = (grpc_combiner*)gpr_zalloc(sizeof(*lock));
@@ -88,19 +86,19 @@ grpc_combiner* grpc_combiner_create(void) {
return lock;
}
-static void really_destroy(grpc_exec_ctx* exec_ctx, grpc_combiner* lock) {
+static void really_destroy(grpc_combiner* lock) {
GRPC_COMBINER_TRACE(gpr_log(GPR_DEBUG, "C:%p really_destroy", lock));
GPR_ASSERT(gpr_atm_no_barrier_load(&lock->state) == 0);
gpr_mpscq_destroy(&lock->queue);
gpr_free(lock);
}
-static void start_destroy(grpc_exec_ctx* exec_ctx, grpc_combiner* lock) {
+static void start_destroy(grpc_combiner* lock) {
gpr_atm old_state = gpr_atm_full_fetch_add(&lock->state, -STATE_UNORPHANED);
GRPC_COMBINER_TRACE(gpr_log(
GPR_DEBUG, "C:%p really_destroy old_state=%" PRIdPTR, lock, old_state));
if (old_state == 1) {
- really_destroy(exec_ctx, lock);
+ really_destroy(lock);
}
}
@@ -116,11 +114,10 @@ static void start_destroy(grpc_exec_ctx* exec_ctx, grpc_combiner* lock) {
#define GRPC_COMBINER_DEBUG_SPAM(op, delta)
#endif
-void grpc_combiner_unref(grpc_exec_ctx* exec_ctx,
- grpc_combiner* lock GRPC_COMBINER_DEBUG_ARGS) {
+void grpc_combiner_unref(grpc_combiner* lock GRPC_COMBINER_DEBUG_ARGS) {
GRPC_COMBINER_DEBUG_SPAM("UNREF", -1);
if (gpr_unref(&lock->refs)) {
- start_destroy(exec_ctx, lock);
+ start_destroy(lock);
}
}
@@ -130,23 +127,25 @@ grpc_combiner* grpc_combiner_ref(grpc_combiner* lock GRPC_COMBINER_DEBUG_ARGS) {
return lock;
}
-static void push_last_on_exec_ctx(grpc_exec_ctx* exec_ctx,
- grpc_combiner* lock) {
+static void push_last_on_exec_ctx(grpc_combiner* lock) {
lock->next_combiner_on_this_exec_ctx = nullptr;
- if (exec_ctx->active_combiner == nullptr) {
- exec_ctx->active_combiner = exec_ctx->last_combiner = lock;
+ if (grpc_core::ExecCtx::Get()->combiner_data()->active_combiner == nullptr) {
+ grpc_core::ExecCtx::Get()->combiner_data()->active_combiner =
+ grpc_core::ExecCtx::Get()->combiner_data()->last_combiner = lock;
} else {
- exec_ctx->last_combiner->next_combiner_on_this_exec_ctx = lock;
- exec_ctx->last_combiner = lock;
+ grpc_core::ExecCtx::Get()
+ ->combiner_data()
+ ->last_combiner->next_combiner_on_this_exec_ctx = lock;
+ grpc_core::ExecCtx::Get()->combiner_data()->last_combiner = lock;
}
}
-static void push_first_on_exec_ctx(grpc_exec_ctx* exec_ctx,
- grpc_combiner* lock) {
- lock->next_combiner_on_this_exec_ctx = exec_ctx->active_combiner;
- exec_ctx->active_combiner = lock;
+static void push_first_on_exec_ctx(grpc_combiner* lock) {
+ lock->next_combiner_on_this_exec_ctx =
+ grpc_core::ExecCtx::Get()->combiner_data()->active_combiner;
+ grpc_core::ExecCtx::Get()->combiner_data()->active_combiner = lock;
if (lock->next_combiner_on_this_exec_ctx == nullptr) {
- exec_ctx->last_combiner = lock;
+ grpc_core::ExecCtx::Get()->combiner_data()->last_combiner = lock;
}
}
@@ -154,9 +153,8 @@ static void push_first_on_exec_ctx(grpc_exec_ctx* exec_ctx,
((grpc_combiner*)(((char*)((closure)->scheduler)) - \
offsetof(grpc_combiner, scheduler_name)))
-static void combiner_exec(grpc_exec_ctx* exec_ctx, grpc_closure* cl,
- grpc_error* error) {
- GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_ITEMS(exec_ctx);
+static void combiner_exec(grpc_closure* cl, grpc_error* error) {
+ GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_ITEMS();
GPR_TIMER_BEGIN("combiner.execute", 0);
grpc_combiner* lock = COMBINER_FROM_CLOSURE_SCHEDULER(cl, scheduler);
gpr_atm last = gpr_atm_full_fetch_add(&lock->state, STATE_ELEM_COUNT_LOW_BIT);
@@ -164,19 +162,19 @@ static void combiner_exec(grpc_exec_ctx* exec_ctx, grpc_closure* cl,
"C:%p grpc_combiner_execute c=%p last=%" PRIdPTR,
lock, cl, last));
if (last == 1) {
- GRPC_STATS_INC_COMBINER_LOCKS_INITIATED(exec_ctx);
+ GRPC_STATS_INC_COMBINER_LOCKS_INITIATED();
GPR_TIMER_MARK("combiner.initiated", 0);
gpr_atm_no_barrier_store(&lock->initiating_exec_ctx_or_null,
- (gpr_atm)exec_ctx);
+ (gpr_atm)grpc_core::ExecCtx::Get());
// first element on this list: add it to the list of combiner locks
// executing within this exec_ctx
- push_last_on_exec_ctx(exec_ctx, lock);
+ push_last_on_exec_ctx(lock);
} else {
// there may be a race with setting here: if that happens, we may delay
// offload for one or two actions, and that's fine
gpr_atm initiator =
gpr_atm_no_barrier_load(&lock->initiating_exec_ctx_or_null);
- if (initiator != 0 && initiator != (gpr_atm)exec_ctx) {
+ if (initiator != 0 && initiator != (gpr_atm)grpc_core::ExecCtx::Get()) {
gpr_atm_no_barrier_store(&lock->initiating_exec_ctx_or_null, 0);
}
}
@@ -187,29 +185,32 @@ static void combiner_exec(grpc_exec_ctx* exec_ctx, grpc_closure* cl,
GPR_TIMER_END("combiner.execute", 0);
}
-static void move_next(grpc_exec_ctx* exec_ctx) {
- exec_ctx->active_combiner =
- exec_ctx->active_combiner->next_combiner_on_this_exec_ctx;
- if (exec_ctx->active_combiner == nullptr) {
- exec_ctx->last_combiner = nullptr;
+static void move_next() {
+ grpc_core::ExecCtx::Get()->combiner_data()->active_combiner =
+ grpc_core::ExecCtx::Get()
+ ->combiner_data()
+ ->active_combiner->next_combiner_on_this_exec_ctx;
+ if (grpc_core::ExecCtx::Get()->combiner_data()->active_combiner == nullptr) {
+ grpc_core::ExecCtx::Get()->combiner_data()->last_combiner = nullptr;
}
}
-static void offload(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void offload(void* arg, grpc_error* error) {
grpc_combiner* lock = (grpc_combiner*)arg;
- push_last_on_exec_ctx(exec_ctx, lock);
+ push_last_on_exec_ctx(lock);
}
-static void queue_offload(grpc_exec_ctx* exec_ctx, grpc_combiner* lock) {
- GRPC_STATS_INC_COMBINER_LOCKS_OFFLOADED(exec_ctx);
- move_next(exec_ctx);
+static void queue_offload(grpc_combiner* lock) {
+ GRPC_STATS_INC_COMBINER_LOCKS_OFFLOADED();
+ move_next();
GRPC_COMBINER_TRACE(gpr_log(GPR_DEBUG, "C:%p queue_offload", lock));
- GRPC_CLOSURE_SCHED(exec_ctx, &lock->offload, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&lock->offload, GRPC_ERROR_NONE);
}
-bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx* exec_ctx) {
+bool grpc_combiner_continue_exec_ctx() {
GPR_TIMER_BEGIN("combiner.continue_exec_ctx", 0);
- grpc_combiner* lock = exec_ctx->active_combiner;
+ grpc_combiner* lock =
+ grpc_core::ExecCtx::Get()->combiner_data()->active_combiner;
if (lock == nullptr) {
GPR_TIMER_END("combiner.continue_exec_ctx", 0);
return false;
@@ -224,15 +225,15 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx* exec_ctx) {
"exec_ctx_ready_to_finish=%d "
"time_to_execute_final_list=%d",
lock, contended,
- grpc_exec_ctx_ready_to_finish(exec_ctx),
+ grpc_core::ExecCtx::Get()->IsReadyToFinish(),
lock->time_to_execute_final_list));
- if (contended && grpc_exec_ctx_ready_to_finish(exec_ctx) &&
+ if (contended && grpc_core::ExecCtx::Get()->IsReadyToFinish() &&
grpc_executor_is_threaded()) {
GPR_TIMER_MARK("offload_from_finished_exec_ctx", 0);
// this execution context wants to move on: schedule remaining work to be
// picked up on the executor
- queue_offload(exec_ctx, lock);
+ queue_offload(lock);
GPR_TIMER_END("combiner.continue_exec_ctx", 0);
return true;
}
@@ -248,7 +249,7 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx* exec_ctx) {
// queue is in an inconsistent state: use this as a cue that we should
// go off and do something else for a while (and come back later)
GPR_TIMER_MARK("delay_busy", 0);
- queue_offload(exec_ctx, lock);
+ queue_offload(lock);
GPR_TIMER_END("combiner.continue_exec_ctx", 0);
return true;
}
@@ -258,7 +259,7 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx* exec_ctx) {
#ifndef NDEBUG
cl->scheduled = false;
#endif
- cl->cb(exec_ctx, cl->cb_arg, cl_err);
+ cl->cb(cl->cb_arg, cl_err);
GRPC_ERROR_UNREF(cl_err);
GPR_TIMER_END("combiner.exec1", 0);
} else {
@@ -275,7 +276,7 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx* exec_ctx) {
#ifndef NDEBUG
c->scheduled = false;
#endif
- c->cb(exec_ctx, c->cb_arg, error);
+ c->cb(c->cb_arg, error);
GRPC_ERROR_UNREF(error);
c = next;
GPR_TIMER_END("combiner.exec_1final", 0);
@@ -283,7 +284,7 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx* exec_ctx) {
}
GPR_TIMER_MARK("unref", 0);
- move_next(exec_ctx);
+ move_next();
lock->time_to_execute_final_list = false;
gpr_atm old_state =
gpr_atm_full_fetch_add(&lock->state, -STATE_ELEM_COUNT_LOW_BIT);
@@ -312,7 +313,7 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx* exec_ctx) {
return true;
case OLD_STATE_WAS(true, 1):
// and one count, one orphaned --> unlocked and orphaned
- really_destroy(exec_ctx, lock);
+ really_destroy(lock);
GPR_TIMER_END("combiner.continue_exec_ctx", 0);
return true;
case OLD_STATE_WAS(false, 0):
@@ -322,27 +323,24 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx* exec_ctx) {
GPR_TIMER_END("combiner.continue_exec_ctx", 0);
GPR_UNREACHABLE_CODE(return true);
}
- push_first_on_exec_ctx(exec_ctx, lock);
+ push_first_on_exec_ctx(lock);
GPR_TIMER_END("combiner.continue_exec_ctx", 0);
return true;
}
-static void enqueue_finally(grpc_exec_ctx* exec_ctx, void* closure,
- grpc_error* error);
+static void enqueue_finally(void* closure, grpc_error* error);
-static void combiner_finally_exec(grpc_exec_ctx* exec_ctx,
- grpc_closure* closure, grpc_error* error) {
- GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_FINAL_ITEMS(exec_ctx);
+static void combiner_finally_exec(grpc_closure* closure, grpc_error* error) {
+ GRPC_STATS_INC_COMBINER_LOCKS_SCHEDULED_FINAL_ITEMS();
grpc_combiner* lock =
COMBINER_FROM_CLOSURE_SCHEDULER(closure, finally_scheduler);
- GRPC_COMBINER_TRACE(gpr_log(GPR_DEBUG,
- "C:%p grpc_combiner_execute_finally c=%p; ac=%p",
- lock, closure, exec_ctx->active_combiner));
+ GRPC_COMBINER_TRACE(gpr_log(
+ GPR_DEBUG, "C:%p grpc_combiner_execute_finally c=%p; ac=%p", lock,
+ closure, grpc_core::ExecCtx::Get()->combiner_data()->active_combiner));
GPR_TIMER_BEGIN("combiner.execute_finally", 0);
- if (exec_ctx->active_combiner != lock) {
+ if (grpc_core::ExecCtx::Get()->combiner_data()->active_combiner != lock) {
GPR_TIMER_MARK("slowpath", 0);
- GRPC_CLOSURE_SCHED(exec_ctx,
- GRPC_CLOSURE_CREATE(enqueue_finally, closure,
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(enqueue_finally, closure,
grpc_combiner_scheduler(lock)),
error);
GPR_TIMER_END("combiner.execute_finally", 0);
@@ -356,10 +354,8 @@ static void combiner_finally_exec(grpc_exec_ctx* exec_ctx,
GPR_TIMER_END("combiner.execute_finally", 0);
}
-static void enqueue_finally(grpc_exec_ctx* exec_ctx, void* closure,
- grpc_error* error) {
- combiner_finally_exec(exec_ctx, (grpc_closure*)closure,
- GRPC_ERROR_REF(error));
+static void enqueue_finally(void* closure, grpc_error* error) {
+ combiner_finally_exec((grpc_closure*)closure, GRPC_ERROR_REF(error));
}
grpc_closure_scheduler* grpc_combiner_scheduler(grpc_combiner* combiner) {
diff --git a/src/core/lib/iomgr/combiner.h b/src/core/lib/iomgr/combiner.h
index f8a8b9df62..bb450db2fc 100644
--- a/src/core/lib/iomgr/combiner.h
+++ b/src/core/lib/iomgr/combiner.h
@@ -44,26 +44,24 @@ grpc_combiner* grpc_combiner_create(void);
, const char *file, int line, const char *reason
#define GRPC_COMBINER_REF(combiner, reason) \
grpc_combiner_ref((combiner), __FILE__, __LINE__, (reason))
-#define GRPC_COMBINER_UNREF(exec_ctx, combiner, reason) \
- grpc_combiner_unref((exec_ctx), (combiner), __FILE__, __LINE__, (reason))
+#define GRPC_COMBINER_UNREF(combiner, reason) \
+ grpc_combiner_unref((combiner), __FILE__, __LINE__, (reason))
#else
#define GRPC_COMBINER_DEBUG_ARGS
#define GRPC_COMBINER_REF(combiner, reason) grpc_combiner_ref((combiner))
-#define GRPC_COMBINER_UNREF(exec_ctx, combiner, reason) \
- grpc_combiner_unref((exec_ctx), (combiner))
+#define GRPC_COMBINER_UNREF(combiner, reason) grpc_combiner_unref((combiner))
#endif
// Ref/unref the lock, for when we're sharing the lock ownership
// Prefer to use the macros above
grpc_combiner* grpc_combiner_ref(grpc_combiner* lock GRPC_COMBINER_DEBUG_ARGS);
-void grpc_combiner_unref(grpc_exec_ctx* exec_ctx,
- grpc_combiner* lock GRPC_COMBINER_DEBUG_ARGS);
+void grpc_combiner_unref(grpc_combiner* lock GRPC_COMBINER_DEBUG_ARGS);
// Fetch a scheduler to schedule closures against
grpc_closure_scheduler* grpc_combiner_scheduler(grpc_combiner* lock);
// Scheduler to execute \a action within the lock just prior to unlocking.
grpc_closure_scheduler* grpc_combiner_finally_scheduler(grpc_combiner* lock);
-bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx* exec_ctx);
+bool grpc_combiner_continue_exec_ctx();
extern grpc_tracer_flag grpc_combiner_trace;
diff --git a/src/core/lib/iomgr/endpoint.cc b/src/core/lib/iomgr/endpoint.cc
index 5eab1d3158..9d4b102822 100644
--- a/src/core/lib/iomgr/endpoint.cc
+++ b/src/core/lib/iomgr/endpoint.cc
@@ -18,41 +18,35 @@
#include "src/core/lib/iomgr/endpoint.h"
-void grpc_endpoint_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
- ep->vtable->read(exec_ctx, ep, slices, cb);
+void grpc_endpoint_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
+ ep->vtable->read(ep, slices, cb);
}
-void grpc_endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
- ep->vtable->write(exec_ctx, ep, slices, cb);
+void grpc_endpoint_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
+ ep->vtable->write(ep, slices, cb);
}
-void grpc_endpoint_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset* pollset) {
- ep->vtable->add_to_pollset(exec_ctx, ep, pollset);
+void grpc_endpoint_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {
+ ep->vtable->add_to_pollset(ep, pollset);
}
-void grpc_endpoint_add_to_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* ep,
+void grpc_endpoint_add_to_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset_set) {
- ep->vtable->add_to_pollset_set(exec_ctx, ep, pollset_set);
+ ep->vtable->add_to_pollset_set(ep, pollset_set);
}
-void grpc_endpoint_delete_from_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* ep,
+void grpc_endpoint_delete_from_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset_set) {
- ep->vtable->delete_from_pollset_set(exec_ctx, ep, pollset_set);
+ ep->vtable->delete_from_pollset_set(ep, pollset_set);
}
-void grpc_endpoint_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_error* why) {
- ep->vtable->shutdown(exec_ctx, ep, why);
+void grpc_endpoint_shutdown(grpc_endpoint* ep, grpc_error* why) {
+ ep->vtable->shutdown(ep, why);
}
-void grpc_endpoint_destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) {
- ep->vtable->destroy(exec_ctx, ep);
-}
+void grpc_endpoint_destroy(grpc_endpoint* ep) { ep->vtable->destroy(ep); }
char* grpc_endpoint_get_peer(grpc_endpoint* ep) {
return ep->vtable->get_peer(ep);
diff --git a/src/core/lib/iomgr/endpoint.h b/src/core/lib/iomgr/endpoint.h
index 1b0a9e725e..10397fd98f 100644
--- a/src/core/lib/iomgr/endpoint.h
+++ b/src/core/lib/iomgr/endpoint.h
@@ -37,18 +37,13 @@ typedef struct grpc_endpoint grpc_endpoint;
typedef struct grpc_endpoint_vtable grpc_endpoint_vtable;
struct grpc_endpoint_vtable {
- void (*read)(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb);
- void (*write)(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb);
- void (*add_to_pollset)(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset* pollset);
- void (*add_to_pollset_set)(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset_set* pollset);
- void (*delete_from_pollset_set)(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset_set* pollset);
- void (*shutdown)(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, grpc_error* why);
- void (*destroy)(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep);
+ void (*read)(grpc_endpoint* ep, grpc_slice_buffer* slices, grpc_closure* cb);
+ void (*write)(grpc_endpoint* ep, grpc_slice_buffer* slices, grpc_closure* cb);
+ void (*add_to_pollset)(grpc_endpoint* ep, grpc_pollset* pollset);
+ void (*add_to_pollset_set)(grpc_endpoint* ep, grpc_pollset_set* pollset);
+ void (*delete_from_pollset_set)(grpc_endpoint* ep, grpc_pollset_set* pollset);
+ void (*shutdown)(grpc_endpoint* ep, grpc_error* why);
+ void (*destroy)(grpc_endpoint* ep);
grpc_resource_user* (*get_resource_user)(grpc_endpoint* ep);
char* (*get_peer)(grpc_endpoint* ep);
int (*get_fd)(grpc_endpoint* ep);
@@ -59,8 +54,8 @@ struct grpc_endpoint_vtable {
indicates the endpoint is closed.
Valid slices may be placed into \a slices even when the callback is
invoked with error != GRPC_ERROR_NONE. */
-void grpc_endpoint_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb);
+void grpc_endpoint_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb);
char* grpc_endpoint_get_peer(grpc_endpoint* ep);
@@ -78,26 +73,22 @@ int grpc_endpoint_get_fd(grpc_endpoint* ep);
No guarantee is made to the content of slices after a write EXCEPT that
it is a valid slice buffer.
*/
-void grpc_endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb);
+void grpc_endpoint_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb);
/* Causes any pending and future read/write callbacks to run immediately with
success==0 */
-void grpc_endpoint_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_error* why);
-void grpc_endpoint_destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep);
+void grpc_endpoint_shutdown(grpc_endpoint* ep, grpc_error* why);
+void grpc_endpoint_destroy(grpc_endpoint* ep);
/* Add an endpoint to a pollset or pollset_set, so that when the pollset is
polled, events from this endpoint are considered */
-void grpc_endpoint_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset* pollset);
-void grpc_endpoint_add_to_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* ep,
+void grpc_endpoint_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset);
+void grpc_endpoint_add_to_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset_set);
/* Delete an endpoint from a pollset_set */
-void grpc_endpoint_delete_from_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* ep,
+void grpc_endpoint_delete_from_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset_set);
grpc_resource_user* grpc_endpoint_get_resource_user(grpc_endpoint* endpoint);
diff --git a/src/core/lib/iomgr/endpoint_pair_posix.cc b/src/core/lib/iomgr/endpoint_pair_posix.cc
index f5f59f9917..65db4a9675 100644
--- a/src/core/lib/iomgr/endpoint_pair_posix.cc
+++ b/src/core/lib/iomgr/endpoint_pair_posix.cc
@@ -54,18 +54,17 @@ grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char* name,
char* final_name;
create_sockets(sv);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_asprintf(&final_name, "%s:client", name);
- p.client = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], final_name), args,
+ p.client = grpc_tcp_create(grpc_fd_create(sv[1], final_name), args,
"socketpair-server");
gpr_free(final_name);
gpr_asprintf(&final_name, "%s:server", name);
- p.server = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[0], final_name), args,
+ p.server = grpc_tcp_create(grpc_fd_create(sv[0], final_name), args,
"socketpair-client");
gpr_free(final_name);
- grpc_exec_ctx_finish(&exec_ctx);
return p;
}
diff --git a/src/core/lib/iomgr/endpoint_pair_windows.cc b/src/core/lib/iomgr/endpoint_pair_windows.cc
index afa995a1c7..afd91c9932 100644
--- a/src/core/lib/iomgr/endpoint_pair_windows.cc
+++ b/src/core/lib/iomgr/endpoint_pair_windows.cc
@@ -72,14 +72,12 @@ grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(
SOCKET sv[2];
grpc_endpoint_pair p;
create_sockets(sv);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- p.client = grpc_tcp_create(&exec_ctx,
- grpc_winsocket_create(sv[1], "endpoint:client"),
+ grpc_core::ExecCtx _local_exec_ctx;
+ p.client = grpc_tcp_create(grpc_winsocket_create(sv[1], "endpoint:client"),
channel_args, "endpoint:server");
- p.server = grpc_tcp_create(&exec_ctx,
- grpc_winsocket_create(sv[0], "endpoint:server"),
+ p.server = grpc_tcp_create(grpc_winsocket_create(sv[0], "endpoint:server"),
channel_args, "endpoint:client");
- grpc_exec_ctx_finish(&exec_ctx);
+
return p;
}
diff --git a/src/core/lib/iomgr/error.cc b/src/core/lib/iomgr/error.cc
index 581b903f1a..2364b1a369 100644
--- a/src/core/lib/iomgr/error.cc
+++ b/src/core/lib/iomgr/error.cc
@@ -157,11 +157,7 @@ static void unref_errs(grpc_error* err) {
}
}
-static void unref_slice(grpc_slice slice) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_unref_internal(&exec_ctx, slice);
- grpc_exec_ctx_finish(&exec_ctx);
-}
+static void unref_slice(grpc_slice slice) { grpc_slice_unref_internal(slice); }
static void unref_strs(grpc_error* err) {
for (size_t which = 0; which < GRPC_ERROR_STR_MAX; ++which) {
diff --git a/src/core/lib/iomgr/ev_epoll1_linux.cc b/src/core/lib/iomgr/ev_epoll1_linux.cc
index 918bc6f933..1598657afe 100644
--- a/src/core/lib/iomgr/ev_epoll1_linux.cc
+++ b/src/core/lib/iomgr/ev_epoll1_linux.cc
@@ -268,7 +268,7 @@ static grpc_fd* fd_create(int fd, const char* name) {
new_fd->fd = fd;
new_fd->read_closure.Init();
new_fd->write_closure.Init();
- gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL);
+ gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm) nullptr);
new_fd->freelist_next = nullptr;
@@ -297,31 +297,29 @@ static int fd_wrapped_fd(grpc_fd* fd) { return fd->fd; }
/* if 'releasing_fd' is true, it means that we are going to detach the internal
* fd from grpc_fd structure (i.e which means we should not be calling
* shutdown() syscall on that fd) */
-static void fd_shutdown_internal(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_error* why, bool releasing_fd) {
- if (fd->read_closure->SetShutdown(exec_ctx, GRPC_ERROR_REF(why))) {
+static void fd_shutdown_internal(grpc_fd* fd, grpc_error* why,
+ bool releasing_fd) {
+ if (fd->read_closure->SetShutdown(GRPC_ERROR_REF(why))) {
if (!releasing_fd) {
shutdown(fd->fd, SHUT_RDWR);
}
- fd->write_closure->SetShutdown(exec_ctx, GRPC_ERROR_REF(why));
+ fd->write_closure->SetShutdown(GRPC_ERROR_REF(why));
}
GRPC_ERROR_UNREF(why);
}
/* Might be called multiple times */
-static void fd_shutdown(grpc_exec_ctx* exec_ctx, grpc_fd* fd, grpc_error* why) {
- fd_shutdown_internal(exec_ctx, fd, why, false);
+static void fd_shutdown(grpc_fd* fd, grpc_error* why) {
+ fd_shutdown_internal(fd, why, false);
}
-static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure* on_done, int* release_fd,
+static void fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd,
bool already_closed, const char* reason) {
grpc_error* error = GRPC_ERROR_NONE;
bool is_release_fd = (release_fd != nullptr);
if (!fd->read_closure->IsShutdown()) {
- fd_shutdown_internal(exec_ctx, fd,
- GRPC_ERROR_CREATE_FROM_COPIED_STRING(reason),
+ fd_shutdown_internal(fd, GRPC_ERROR_CREATE_FROM_COPIED_STRING(reason),
is_release_fd);
}
@@ -333,7 +331,7 @@ static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
close(fd->fd);
}
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_REF(error));
grpc_iomgr_unregister_object(&fd->iomgr_object);
fd->read_closure.Destroy();
@@ -345,8 +343,7 @@ static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
gpr_mu_unlock(&fd_freelist_mu);
}
-static grpc_pollset* fd_get_read_notifier_pollset(grpc_exec_ctx* exec_ctx,
- grpc_fd* fd) {
+static grpc_pollset* fd_get_read_notifier_pollset(grpc_fd* fd) {
gpr_atm notifier = gpr_atm_acq_load(&fd->read_notifier_pollset);
return (grpc_pollset*)notifier;
}
@@ -355,26 +352,21 @@ static bool fd_is_shutdown(grpc_fd* fd) {
return fd->read_closure->IsShutdown();
}
-static void fd_notify_on_read(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure* closure) {
- fd->read_closure->NotifyOn(exec_ctx, closure);
+static void fd_notify_on_read(grpc_fd* fd, grpc_closure* closure) {
+ fd->read_closure->NotifyOn(closure);
}
-static void fd_notify_on_write(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure* closure) {
- fd->write_closure->NotifyOn(exec_ctx, closure);
+static void fd_notify_on_write(grpc_fd* fd, grpc_closure* closure) {
+ fd->write_closure->NotifyOn(closure);
}
-static void fd_become_readable(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_pollset* notifier) {
- fd->read_closure->SetReady(exec_ctx);
+static void fd_become_readable(grpc_fd* fd, grpc_pollset* notifier) {
+ fd->read_closure->SetReady();
/* Use release store to match with acquire load in fd_get_read_notifier */
gpr_atm_rel_store(&fd->read_notifier_pollset, (gpr_atm)notifier);
}
-static void fd_become_writable(grpc_exec_ctx* exec_ctx, grpc_fd* fd) {
- fd->write_closure->SetReady(exec_ctx);
-}
+static void fd_become_writable(grpc_fd* fd) { fd->write_closure->SetReady(); }
/*******************************************************************************
* Pollset Definitions
@@ -477,7 +469,7 @@ static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
pollset->next = pollset->prev = nullptr;
}
-static void pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) {
+static void pollset_destroy(grpc_pollset* pollset) {
gpr_mu_lock(&pollset->mu);
if (!pollset->seen_inactive) {
pollset_neighborhood* neighborhood = pollset->neighborhood;
@@ -505,27 +497,26 @@ static void pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) {
gpr_mu_destroy(&pollset->mu);
}
-static grpc_error* pollset_kick_all(grpc_exec_ctx* exec_ctx,
- grpc_pollset* pollset) {
+static grpc_error* pollset_kick_all(grpc_pollset* pollset) {
GPR_TIMER_BEGIN("pollset_kick_all", 0);
grpc_error* error = GRPC_ERROR_NONE;
if (pollset->root_worker != nullptr) {
grpc_pollset_worker* worker = pollset->root_worker;
do {
- GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK();
switch (worker->state) {
case KICKED:
- GRPC_STATS_INC_POLLSET_KICKED_AGAIN(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICKED_AGAIN();
break;
case UNKICKED:
SET_KICK_STATE(worker, KICKED);
if (worker->initialized_cv) {
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV();
gpr_cv_signal(&worker->cv);
}
break;
case DESIGNATED_POLLER:
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD();
SET_KICK_STATE(worker, KICKED);
append_error(&error, grpc_wakeup_fd_wakeup(&global_wakeup_fd),
"pollset_kick_all");
@@ -541,32 +532,29 @@ static grpc_error* pollset_kick_all(grpc_exec_ctx* exec_ctx,
return error;
}
-static void pollset_maybe_finish_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_pollset* pollset) {
+static void pollset_maybe_finish_shutdown(grpc_pollset* pollset) {
if (pollset->shutdown_closure != nullptr && pollset->root_worker == nullptr &&
pollset->begin_refs == 0) {
GPR_TIMER_MARK("pollset_finish_shutdown", 0);
- GRPC_CLOSURE_SCHED(exec_ctx, pollset->shutdown_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(pollset->shutdown_closure, GRPC_ERROR_NONE);
pollset->shutdown_closure = nullptr;
}
}
-static void pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- grpc_closure* closure) {
+static void pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
GPR_TIMER_BEGIN("pollset_shutdown", 0);
GPR_ASSERT(pollset->shutdown_closure == nullptr);
GPR_ASSERT(!pollset->shutting_down);
pollset->shutdown_closure = closure;
pollset->shutting_down = true;
- GRPC_LOG_IF_ERROR("pollset_shutdown", pollset_kick_all(exec_ctx, pollset));
- pollset_maybe_finish_shutdown(exec_ctx, pollset);
+ GRPC_LOG_IF_ERROR("pollset_shutdown", pollset_kick_all(pollset));
+ pollset_maybe_finish_shutdown(pollset);
GPR_TIMER_END("pollset_shutdown", 0);
}
-static int poll_deadline_to_millis_timeout(grpc_exec_ctx* exec_ctx,
- grpc_millis millis) {
+static int poll_deadline_to_millis_timeout(grpc_millis millis) {
if (millis == GRPC_MILLIS_INF_FUTURE) return -1;
- grpc_millis delta = millis - grpc_exec_ctx_now(exec_ctx);
+ grpc_millis delta = millis - grpc_core::ExecCtx::Get()->Now();
if (delta > INT_MAX) {
return INT_MAX;
} else if (delta < 0) {
@@ -584,8 +572,7 @@ static int poll_deadline_to_millis_timeout(grpc_exec_ctx* exec_ctx,
NOTE ON SYNCRHONIZATION: Similar to do_epoll_wait(), this function is only
called by g_active_poller thread. So there is no need for synchronization
when accessing fields in g_epoll_set */
-static grpc_error* process_epoll_events(grpc_exec_ctx* exec_ctx,
- grpc_pollset* pollset) {
+static grpc_error* process_epoll_events(grpc_pollset* pollset) {
static const char* err_desc = "process_events";
grpc_error* error = GRPC_ERROR_NONE;
@@ -609,11 +596,11 @@ static grpc_error* process_epoll_events(grpc_exec_ctx* exec_ctx,
bool write_ev = (ev->events & EPOLLOUT) != 0;
if (read_ev || cancel) {
- fd_become_readable(exec_ctx, fd, pollset);
+ fd_become_readable(fd, pollset);
}
if (write_ev || cancel) {
- fd_become_writable(exec_ctx, fd);
+ fd_become_writable(fd);
}
}
}
@@ -629,27 +616,26 @@ static grpc_error* process_epoll_events(grpc_exec_ctx* exec_ctx,
NOTE ON SYNCHRONIZATION: At any point of time, only the g_active_poller
(i.e the designated poller thread) will be calling this function. So there is
no need for any synchronization when accesing fields in g_epoll_set */
-static grpc_error* do_epoll_wait(grpc_exec_ctx* exec_ctx, grpc_pollset* ps,
- grpc_millis deadline) {
+static grpc_error* do_epoll_wait(grpc_pollset* ps, grpc_millis deadline) {
GPR_TIMER_BEGIN("do_epoll_wait", 0);
int r;
- int timeout = poll_deadline_to_millis_timeout(exec_ctx, deadline);
+ int timeout = poll_deadline_to_millis_timeout(deadline);
if (timeout != 0) {
GRPC_SCHEDULING_START_BLOCKING_REGION;
}
do {
- GRPC_STATS_INC_SYSCALL_POLL(exec_ctx);
+ GRPC_STATS_INC_SYSCALL_POLL();
r = epoll_wait(g_epoll_set.epfd, g_epoll_set.events, MAX_EPOLL_EVENTS,
timeout);
} while (r < 0 && errno == EINTR);
if (timeout != 0) {
- GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(exec_ctx);
+ GRPC_SCHEDULING_END_BLOCKING_REGION;
}
if (r < 0) return GRPC_OS_ERROR(errno, "epoll_wait");
- GRPC_STATS_INC_POLL_EVENTS_RETURNED(exec_ctx, r);
+ GRPC_STATS_INC_POLL_EVENTS_RETURNED(r);
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "ps: %p poll got %d events", ps, r);
@@ -662,8 +648,7 @@ static grpc_error* do_epoll_wait(grpc_exec_ctx* exec_ctx, grpc_pollset* ps,
return GRPC_ERROR_NONE;
}
-static bool begin_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- grpc_pollset_worker* worker,
+static bool begin_worker(grpc_pollset* pollset, grpc_pollset_worker* worker,
grpc_pollset_worker** worker_hdl,
grpc_millis deadline) {
GPR_TIMER_BEGIN("begin_worker", 0);
@@ -758,7 +743,7 @@ static bool begin_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
SET_KICK_STATE(worker, KICKED);
}
}
- grpc_exec_ctx_invalidate_now(exec_ctx);
+ grpc_core::ExecCtx::Get()->InvalidateNow();
}
if (GRPC_TRACER_ON(grpc_polling_trace)) {
@@ -789,7 +774,7 @@ static bool begin_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
}
static bool check_neighborhood_for_available_poller(
- grpc_exec_ctx* exec_ctx, pollset_neighborhood* neighborhood) {
+ pollset_neighborhood* neighborhood) {
GPR_TIMER_BEGIN("check_neighborhood_for_available_poller", 0);
bool found_worker = false;
do {
@@ -813,7 +798,7 @@ static bool check_neighborhood_for_available_poller(
SET_KICK_STATE(inspect_worker, DESIGNATED_POLLER);
if (inspect_worker->initialized_cv) {
GPR_TIMER_MARK("signal worker", 0);
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV();
gpr_cv_signal(&inspect_worker->cv);
}
} else {
@@ -853,8 +838,7 @@ static bool check_neighborhood_for_available_poller(
return found_worker;
}
-static void end_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- grpc_pollset_worker* worker,
+static void end_worker(grpc_pollset* pollset, grpc_pollset_worker* worker,
grpc_pollset_worker** worker_hdl) {
GPR_TIMER_BEGIN("end_worker", 0);
if (GRPC_TRACER_ON(grpc_polling_trace)) {
@@ -864,7 +848,7 @@ static void end_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
/* Make sure we appear kicked */
SET_KICK_STATE(worker, KICKED);
grpc_closure_list_move(&worker->schedule_on_end_work,
- &exec_ctx->closure_list);
+ grpc_core::ExecCtx::Get()->closure_list());
if (gpr_atm_no_barrier_load(&g_active_poller) == (gpr_atm)worker) {
if (worker->next != worker && worker->next->state == UNKICKED) {
if (GRPC_TRACER_ON(grpc_polling_trace)) {
@@ -873,11 +857,11 @@ static void end_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
GPR_ASSERT(worker->next->initialized_cv);
gpr_atm_no_barrier_store(&g_active_poller, (gpr_atm)worker->next);
SET_KICK_STATE(worker->next, DESIGNATED_POLLER);
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV();
gpr_cv_signal(&worker->next->cv);
- if (grpc_exec_ctx_has_work(exec_ctx)) {
+ if (grpc_core::ExecCtx::Get()->HasWork()) {
gpr_mu_unlock(&pollset->mu);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->mu);
}
} else {
@@ -892,8 +876,7 @@ static void end_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
&g_neighborhoods[(poller_neighborhood_idx + i) %
g_num_neighborhoods];
if (gpr_mu_trylock(&neighborhood->mu)) {
- found_worker =
- check_neighborhood_for_available_poller(exec_ctx, neighborhood);
+ found_worker = check_neighborhood_for_available_poller(neighborhood);
gpr_mu_unlock(&neighborhood->mu);
scan_state[i] = true;
} else {
@@ -906,16 +889,15 @@ static void end_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
&g_neighborhoods[(poller_neighborhood_idx + i) %
g_num_neighborhoods];
gpr_mu_lock(&neighborhood->mu);
- found_worker =
- check_neighborhood_for_available_poller(exec_ctx, neighborhood);
+ found_worker = check_neighborhood_for_available_poller(neighborhood);
gpr_mu_unlock(&neighborhood->mu);
}
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->mu);
}
- } else if (grpc_exec_ctx_has_work(exec_ctx)) {
+ } else if (grpc_core::ExecCtx::Get()->HasWork()) {
gpr_mu_unlock(&pollset->mu);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->mu);
}
if (worker->initialized_cv) {
@@ -925,7 +907,7 @@ static void end_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
gpr_log(GPR_DEBUG, " .. remove worker");
}
if (EMPTIED == worker_remove(pollset, worker)) {
- pollset_maybe_finish_shutdown(exec_ctx, pollset);
+ pollset_maybe_finish_shutdown(pollset);
}
GPR_ASSERT(gpr_atm_no_barrier_load(&g_active_poller) != (gpr_atm)worker);
GPR_TIMER_END("end_worker", 0);
@@ -935,7 +917,7 @@ static void end_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
The function pollset_work() may temporarily release the lock (pollset->po.mu)
during the course of its execution but it will always re-acquire the lock and
ensure that it is held by the time the function returns */
-static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* ps,
+static grpc_error* pollset_work(grpc_pollset* ps,
grpc_pollset_worker** worker_hdl,
grpc_millis deadline) {
grpc_pollset_worker worker;
@@ -948,7 +930,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* ps,
return GRPC_ERROR_NONE;
}
- if (begin_worker(exec_ctx, ps, &worker, worker_hdl, deadline)) {
+ if (begin_worker(ps, &worker, worker_hdl, deadline)) {
gpr_tls_set(&g_current_thread_pollset, (intptr_t)ps);
gpr_tls_set(&g_current_thread_worker, (intptr_t)&worker);
GPR_ASSERT(!ps->shutting_down);
@@ -966,14 +948,14 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* ps,
process_epoll_events() returns very quickly: It just queues the work on
exec_ctx but does not execute it (the actual exectution or more
- accurately grpc_exec_ctx_flush() happens in end_worker() AFTER selecting
- a designated poller). So we are not waiting long periods without a
- designated poller */
+ accurately grpc_core::ExecCtx::Get()->Flush() happens in end_worker()
+ AFTER selecting a designated poller). So we are not waiting long periods
+ without a designated poller */
if (gpr_atm_acq_load(&g_epoll_set.cursor) ==
gpr_atm_acq_load(&g_epoll_set.num_events)) {
- append_error(&error, do_epoll_wait(exec_ctx, ps, deadline), err_desc);
+ append_error(&error, do_epoll_wait(ps, deadline), err_desc);
}
- append_error(&error, process_epoll_events(exec_ctx, ps), err_desc);
+ append_error(&error, process_epoll_events(ps), err_desc);
gpr_mu_lock(&ps->mu); /* lock */
@@ -981,17 +963,17 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* ps,
} else {
gpr_tls_set(&g_current_thread_pollset, (intptr_t)ps);
}
- end_worker(exec_ctx, ps, &worker, worker_hdl);
+ end_worker(ps, &worker, worker_hdl);
gpr_tls_set(&g_current_thread_pollset, 0);
GPR_TIMER_END("pollset_work", 0);
return error;
}
-static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
+static grpc_error* pollset_kick(grpc_pollset* pollset,
grpc_pollset_worker* specific_worker) {
GPR_TIMER_BEGIN("pollset_kick", 0);
- GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK();
grpc_error* ret_err = GRPC_ERROR_NONE;
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_strvec log;
@@ -1024,7 +1006,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
if (gpr_tls_get(&g_current_thread_pollset) != (intptr_t)pollset) {
grpc_pollset_worker* root_worker = pollset->root_worker;
if (root_worker == nullptr) {
- GRPC_STATS_INC_POLLSET_KICKED_WITHOUT_POLLER(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICKED_WITHOUT_POLLER();
pollset->kicked_without_poller = true;
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_ERROR, " .. kicked_without_poller");
@@ -1033,14 +1015,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);
+ GRPC_STATS_INC_POLLSET_KICKED_AGAIN();
if (GRPC_TRACER_ON(grpc_polling_trace)) {
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);
+ GRPC_STATS_INC_POLLSET_KICKED_AGAIN();
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_ERROR, " .. already kicked %p", next_worker);
}
@@ -1051,7 +1033,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
// there is no next worker
root_worker == (grpc_pollset_worker*)gpr_atm_no_barrier_load(
&g_active_poller)) {
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD();
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_ERROR, " .. kicked %p", root_worker);
}
@@ -1059,7 +1041,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
ret_err = grpc_wakeup_fd_wakeup(&global_wakeup_fd);
goto done;
} else if (next_worker->state == UNKICKED) {
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV();
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_ERROR, " .. kicked %p", next_worker);
}
@@ -1077,12 +1059,12 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
}
SET_KICK_STATE(root_worker, KICKED);
if (root_worker->initialized_cv) {
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV();
gpr_cv_signal(&root_worker->cv);
}
goto done;
} else {
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD();
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_ERROR, " .. non-root poller %p (root=%p)", next_worker,
root_worker);
@@ -1092,13 +1074,13 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
goto done;
}
} else {
- GRPC_STATS_INC_POLLSET_KICKED_AGAIN(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICKED_AGAIN();
GPR_ASSERT(next_worker->state == KICKED);
SET_KICK_STATE(next_worker, KICKED);
goto done;
}
} else {
- GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD();
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_ERROR, " .. kicked while waking up");
}
@@ -1115,7 +1097,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
goto done;
} else if (gpr_tls_get(&g_current_thread_worker) ==
(intptr_t)specific_worker) {
- GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD();
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_ERROR, " .. mark %p kicked", specific_worker);
}
@@ -1123,7 +1105,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
goto done;
} else if (specific_worker ==
(grpc_pollset_worker*)gpr_atm_no_barrier_load(&g_active_poller)) {
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD();
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_ERROR, " .. kick active poller");
}
@@ -1131,7 +1113,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
ret_err = grpc_wakeup_fd_wakeup(&global_wakeup_fd);
goto done;
} else if (specific_worker->initialized_cv) {
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV();
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_ERROR, " .. kick waiting worker");
}
@@ -1139,7 +1121,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
gpr_cv_signal(&specific_worker->cv);
goto done;
} else {
- GRPC_STATS_INC_POLLSET_KICKED_AGAIN(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICKED_AGAIN();
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_ERROR, " .. kick non-waiting worker");
}
@@ -1151,8 +1133,7 @@ done:
return ret_err;
}
-static void pollset_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- grpc_fd* fd) {}
+static void pollset_add_fd(grpc_pollset* pollset, grpc_fd* fd) {}
/*******************************************************************************
* Pollset-set Definitions
@@ -1162,27 +1143,20 @@ static grpc_pollset_set* pollset_set_create(void) {
return (grpc_pollset_set*)((intptr_t)0xdeafbeef);
}
-static void pollset_set_destroy(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pss) {}
+static void pollset_set_destroy(grpc_pollset_set* pss) {}
-static void pollset_set_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss,
- grpc_fd* fd) {}
+static void pollset_set_add_fd(grpc_pollset_set* pss, grpc_fd* fd) {}
-static void pollset_set_del_fd(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss,
- grpc_fd* fd) {}
+static void pollset_set_del_fd(grpc_pollset_set* pss, grpc_fd* fd) {}
-static void pollset_set_add_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pss, grpc_pollset* ps) {}
+static void pollset_set_add_pollset(grpc_pollset_set* pss, grpc_pollset* ps) {}
-static void pollset_set_del_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pss, grpc_pollset* ps) {}
+static void pollset_set_del_pollset(grpc_pollset_set* pss, grpc_pollset* ps) {}
-static void pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+static void pollset_set_add_pollset_set(grpc_pollset_set* bag,
grpc_pollset_set* item) {}
-static void pollset_set_del_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+static void pollset_set_del_pollset_set(grpc_pollset_set* bag,
grpc_pollset_set* item) {}
/*******************************************************************************
@@ -1258,7 +1232,7 @@ const grpc_event_engine_vtable* grpc_init_epoll1_linux(bool explicit_request) {
const grpc_event_engine_vtable* grpc_init_epoll1_linux(bool explicit_request) {
gpr_log(GPR_ERROR,
"Skipping epoll1 becuase GRPC_LINUX_EPOLL is not defined.");
- return NULL;
+ return nullptr;
}
#endif /* defined(GRPC_POSIX_SOCKET) */
#endif /* !defined(GRPC_LINUX_EPOLL) */
diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc
index bfd2ac4326..d83fe8f80a 100644
--- a/src/core/lib/iomgr/ev_epollex_linux.cc
+++ b/src/core/lib/iomgr/ev_epollex_linux.cc
@@ -259,8 +259,7 @@ static gpr_mu fd_freelist_mu;
#ifndef NDEBUG
#define REF_BY(fd, n, reason) ref_by(fd, n, reason, __FILE__, __LINE__)
-#define UNREF_BY(ec, fd, n, reason) \
- unref_by(ec, fd, n, reason, __FILE__, __LINE__)
+#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)) {
@@ -271,13 +270,13 @@ static void ref_by(grpc_fd* fd, int n, const char* reason, const char* file,
}
#else
#define REF_BY(fd, n, reason) ref_by(fd, n)
-#define UNREF_BY(ec, fd, n, reason) unref_by(ec, fd, n)
+#define UNREF_BY(fd, n, reason) unref_by(fd, n)
static void ref_by(grpc_fd* fd, int n) {
#endif
GPR_ASSERT(gpr_atm_no_barrier_fetch_add(&fd->refst, n) > 0);
}
-static void fd_destroy(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void fd_destroy(void* arg, grpc_error* error) {
grpc_fd* fd = (grpc_fd*)arg;
/* Add the fd to the freelist */
grpc_iomgr_unregister_object(&fd->iomgr_object);
@@ -295,8 +294,8 @@ 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) {
+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)) {
gpr_log(GPR_DEBUG,
"FD %d %p unref %d %" PRIdPTR " -> %" PRIdPTR " [%s; %s:%d]",
@@ -304,12 +303,11 @@ static void unref_by(grpc_exec_ctx* exec_ctx, grpc_fd* fd, int n,
gpr_atm_no_barrier_load(&fd->refst) - n, reason, file, line);
}
#else
-static void unref_by(grpc_exec_ctx* exec_ctx, grpc_fd* fd, int n) {
+static void unref_by(grpc_fd* fd, int n) {
#endif
gpr_atm old = gpr_atm_full_fetch_add(&fd->refst, -n);
if (old == n) {
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_CREATE(fd_destroy, fd, grpc_schedule_on_exec_ctx),
GRPC_ERROR_NONE);
} else {
@@ -351,7 +349,7 @@ static grpc_fd* fd_create(int fd, const char* name) {
new_fd->fd = fd;
new_fd->read_closure.Init();
new_fd->write_closure.Init();
- gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL);
+ gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm) nullptr);
new_fd->freelist_next = nullptr;
new_fd->on_done_closure = nullptr;
@@ -373,8 +371,7 @@ static int fd_wrapped_fd(grpc_fd* fd) {
return (gpr_atm_acq_load(&fd->refst) & 1) ? ret_fd : -1;
}
-static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure* on_done, int* release_fd,
+static void fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd,
bool already_closed, const char* reason) {
bool is_fd_closed = already_closed;
@@ -399,15 +396,14 @@ static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
to be alive (and not added to freelist) until the end of this function */
REF_BY(fd, 1, reason);
- GRPC_CLOSURE_SCHED(exec_ctx, fd->on_done_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(fd->on_done_closure, GRPC_ERROR_NONE);
gpr_mu_unlock(&fd->orphan_mu);
- UNREF_BY(exec_ctx, fd, 2, reason); /* Drop the reference */
+ UNREF_BY(fd, 2, reason); /* Drop the reference */
}
-static grpc_pollset* fd_get_read_notifier_pollset(grpc_exec_ctx* exec_ctx,
- grpc_fd* fd) {
+static grpc_pollset* fd_get_read_notifier_pollset(grpc_fd* fd) {
gpr_atm notifier = gpr_atm_acq_load(&fd->read_notifier_pollset);
return (grpc_pollset*)notifier;
}
@@ -417,22 +413,20 @@ static bool fd_is_shutdown(grpc_fd* fd) {
}
/* Might be called multiple times */
-static void fd_shutdown(grpc_exec_ctx* exec_ctx, grpc_fd* fd, grpc_error* why) {
- if (fd->read_closure->SetShutdown(exec_ctx, GRPC_ERROR_REF(why))) {
+static void fd_shutdown(grpc_fd* fd, grpc_error* why) {
+ if (fd->read_closure->SetShutdown(GRPC_ERROR_REF(why))) {
shutdown(fd->fd, SHUT_RDWR);
- fd->write_closure->SetShutdown(exec_ctx, GRPC_ERROR_REF(why));
+ fd->write_closure->SetShutdown(GRPC_ERROR_REF(why));
}
GRPC_ERROR_UNREF(why);
}
-static void fd_notify_on_read(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure* closure) {
- fd->read_closure->NotifyOn(exec_ctx, closure);
+static void fd_notify_on_read(grpc_fd* fd, grpc_closure* closure) {
+ fd->read_closure->NotifyOn(closure);
}
-static void fd_notify_on_write(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure* closure) {
- fd->write_closure->NotifyOn(exec_ctx, closure);
+static void fd_notify_on_write(grpc_fd* fd, grpc_closure* closure) {
+ fd->write_closure->NotifyOn(closure);
}
/*******************************************************************************
@@ -556,8 +550,7 @@ 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) {
+static void pollset_maybe_finish_shutdown(grpc_pollset* pollset) {
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG,
"PS:%p (pollable:%p) maybe_finish_shutdown sc=%p (target:!NULL) "
@@ -567,7 +560,7 @@ static void pollset_maybe_finish_shutdown(grpc_exec_ctx* exec_ctx,
}
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);
+ GRPC_CLOSURE_SCHED(pollset->shutdown_closure, GRPC_ERROR_NONE);
pollset->shutdown_closure = nullptr;
}
}
@@ -575,8 +568,7 @@ static void pollset_maybe_finish_shutdown(grpc_exec_ctx* exec_ctx,
/* pollset->mu must be held before calling this function,
* pollset->active_pollable->mu & specific_worker->pollable_obj->mu must not be
* held */
-static grpc_error* kick_one_worker(grpc_exec_ctx* exec_ctx,
- grpc_pollset_worker* specific_worker) {
+static grpc_error* kick_one_worker(grpc_pollset_worker* specific_worker) {
pollable* p = specific_worker->pollable_obj;
grpc_core::mu_guard lock(&p->mu);
GPR_ASSERT(specific_worker != nullptr);
@@ -584,19 +576,19 @@ static grpc_error* kick_one_worker(grpc_exec_ctx* exec_ctx,
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "PS:%p kicked_specific_but_already_kicked", p);
}
- GRPC_STATS_INC_POLLSET_KICKED_AGAIN(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICKED_AGAIN();
return GRPC_ERROR_NONE;
}
if (gpr_tls_get(&g_current_thread_worker) == (intptr_t)specific_worker) {
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "PS:%p kicked_specific_but_awake", p);
}
- GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD();
specific_worker->kicked = true;
return GRPC_ERROR_NONE;
}
if (specific_worker == p->root_worker) {
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD();
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "PS:%p kicked_specific_via_wakeup_fd", p);
}
@@ -605,7 +597,7 @@ static grpc_error* kick_one_worker(grpc_exec_ctx* exec_ctx,
return error;
}
if (specific_worker->initialized_cv) {
- GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_WAKEUP_CV();
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "PS:%p kicked_specific_via_cv", p);
}
@@ -618,9 +610,9 @@ static grpc_error* kick_one_worker(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
+static grpc_error* pollset_kick(grpc_pollset* pollset,
grpc_pollset_worker* specific_worker) {
- GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK();
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG,
"PS:%p kick %p tls_pollset=%p tls_worker=%p pollset.root_worker=%p",
@@ -634,7 +626,7 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "PS:%p kicked_any_without_poller", pollset);
}
- GRPC_STATS_INC_POLLSET_KICKED_WITHOUT_POLLER(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICKED_WITHOUT_POLLER();
pollset->kicked_without_poller = true;
return GRPC_ERROR_NONE;
} else {
@@ -654,29 +646,28 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
// so we take our chances and choose the SECOND worker enqueued against
// the pollset as a worker that's likely to be in cv_wait
return kick_one_worker(
- exec_ctx, pollset->root_worker->links[PWLINK_POLLSET].next);
+ pollset->root_worker->links[PWLINK_POLLSET].next);
}
} else {
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "PS:%p kicked_any_but_awake", pollset);
}
- GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK_OWN_THREAD();
return GRPC_ERROR_NONE;
}
} else {
- return kick_one_worker(exec_ctx, specific_worker);
+ return kick_one_worker(specific_worker);
}
}
-static grpc_error* pollset_kick_all(grpc_exec_ctx* exec_ctx,
- grpc_pollset* pollset) {
+static grpc_error* pollset_kick_all(grpc_pollset* pollset) {
grpc_error* error = GRPC_ERROR_NONE;
const char* err_desc = "pollset_kick_all";
grpc_pollset_worker* w = pollset->root_worker;
if (w != nullptr) {
do {
- GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
- append_error(&error, kick_one_worker(exec_ctx, w), err_desc);
+ GRPC_STATS_INC_POLLSET_KICK();
+ append_error(&error, kick_one_worker(w), err_desc);
w = w->links[PWLINK_POLLSET].next;
} while (w != pollset->root_worker);
}
@@ -689,10 +680,9 @@ static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
*mu = &pollset->mu;
}
-static int poll_deadline_to_millis_timeout(grpc_exec_ctx* exec_ctx,
- grpc_millis millis) {
+static int poll_deadline_to_millis_timeout(grpc_millis millis) {
if (millis == GRPC_MILLIS_INF_FUTURE) return -1;
- grpc_millis delta = millis - grpc_exec_ctx_now(exec_ctx);
+ grpc_millis delta = millis - grpc_core::ExecCtx::Get()->Now();
if (delta > INT_MAX)
return INT_MAX;
else if (delta < 0)
@@ -701,9 +691,8 @@ static int poll_deadline_to_millis_timeout(grpc_exec_ctx* exec_ctx,
return (int)delta;
}
-static void fd_become_readable(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_pollset* notifier) {
- fd->read_closure->SetReady(exec_ctx);
+static void fd_become_readable(grpc_fd* fd, grpc_pollset* notifier) {
+ fd->read_closure->SetReady();
/* Note, it is possible that fd_become_readable might be called twice with
different 'notifier's when an fd becomes readable and it is in two epoll
@@ -714,9 +703,7 @@ static void fd_become_readable(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
gpr_atm_rel_store(&fd->read_notifier_pollset, (gpr_atm)notifier);
}
-static void fd_become_writable(grpc_exec_ctx* exec_ctx, grpc_fd* fd) {
- fd->write_closure->SetReady(exec_ctx);
-}
+static void fd_become_writable(grpc_fd* fd) { fd->write_closure->SetReady(); }
static grpc_error* fd_get_or_become_pollable(grpc_fd* fd, pollable** p) {
gpr_mu_lock(&fd->pollable_mu);
@@ -745,16 +732,14 @@ 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) {
+static void pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
GPR_ASSERT(pollset->shutdown_closure == nullptr);
pollset->shutdown_closure = closure;
- GRPC_LOG_IF_ERROR("pollset_shutdown", pollset_kick_all(exec_ctx, pollset));
- pollset_maybe_finish_shutdown(exec_ctx, pollset);
+ GRPC_LOG_IF_ERROR("pollset_shutdown", pollset_kick_all(pollset));
+ pollset_maybe_finish_shutdown(pollset);
}
-static grpc_error* pollable_process_events(grpc_exec_ctx* exec_ctx,
- grpc_pollset* pollset,
+static grpc_error* pollable_process_events(grpc_pollset* pollset,
pollable* pollable_obj, bool drain) {
static const char* err_desc = "pollset_process_events";
grpc_error* error = GRPC_ERROR_NONE;
@@ -784,10 +769,10 @@ static grpc_error* pollable_process_events(grpc_exec_ctx* exec_ctx,
pollset, fd, cancel, read_ev, write_ev);
}
if (read_ev || cancel) {
- fd_become_readable(exec_ctx, fd, pollset);
+ fd_become_readable(fd, pollset);
}
if (write_ev || cancel) {
- fd_become_writable(exec_ctx, fd);
+ fd_become_writable(fd);
}
}
}
@@ -796,14 +781,13 @@ 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) {
+static void pollset_destroy(grpc_pollset* pollset) {
POLLABLE_UNREF(pollset->active_pollable, "pollset");
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);
+static grpc_error* pollable_epoll(pollable* p, grpc_millis deadline) {
+ int timeout = poll_deadline_to_millis_timeout(deadline);
if (GRPC_TRACER_ON(grpc_polling_trace)) {
char* desc = pollable_desc(p);
@@ -816,11 +800,11 @@ static grpc_error* pollable_epoll(grpc_exec_ctx* exec_ctx, pollable* p,
}
int r;
do {
- GRPC_STATS_INC_SYSCALL_POLL(exec_ctx);
+ GRPC_STATS_INC_SYSCALL_POLL();
r = epoll_wait(p->epfd, p->events, MAX_EPOLL_EVENTS, timeout);
} while (r < 0 && errno == EINTR);
if (timeout != 0) {
- GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(exec_ctx);
+ GRPC_SCHEDULING_END_BLOCKING_REGION;
}
if (r < 0) return GRPC_OS_ERROR(errno, "epoll_wait");
@@ -875,8 +859,7 @@ static worker_remove_result worker_remove(grpc_pollset_worker** root_worker,
}
/* Return true if this thread should poll */
-static bool begin_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- grpc_pollset_worker* worker,
+static bool begin_worker(grpc_pollset* pollset, grpc_pollset_worker* worker,
grpc_pollset_worker** worker_hdl,
grpc_millis deadline) {
bool do_poll = (pollset->shutdown_closure == nullptr);
@@ -897,7 +880,7 @@ static bool begin_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
worker->pollable_obj->root_worker != worker) {
gpr_log(GPR_DEBUG, "PS:%p wait %p w=%p for %dms", pollset,
worker->pollable_obj, worker,
- poll_deadline_to_millis_timeout(exec_ctx, deadline));
+ poll_deadline_to_millis_timeout(deadline));
}
while (do_poll && worker->pollable_obj->root_worker != worker) {
if (gpr_cv_wait(&worker->cv, &worker->pollable_obj->mu,
@@ -919,7 +902,7 @@ static bool begin_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
worker->pollable_obj, worker);
}
}
- grpc_exec_ctx_invalidate_now(exec_ctx);
+ grpc_core::ExecCtx::Get()->InvalidateNow();
} else {
gpr_mu_unlock(&pollset->mu);
}
@@ -928,8 +911,7 @@ static bool begin_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
return do_poll;
}
-static void end_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- grpc_pollset_worker* worker,
+static void end_worker(grpc_pollset* pollset, grpc_pollset_worker* worker,
grpc_pollset_worker** worker_hdl) {
gpr_mu_lock(&pollset->mu);
gpr_mu_lock(&worker->pollable_obj->mu);
@@ -945,7 +927,7 @@ static void end_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
case WRR_EMPTIED:
if (pollset->active_pollable != worker->pollable_obj) {
// pollable no longer being polled: flush events
- pollable_process_events(exec_ctx, pollset, worker->pollable_obj, true);
+ pollable_process_events(pollset, worker->pollable_obj, true);
}
break;
case WRR_REMOVED:
@@ -955,7 +937,7 @@ static void end_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
POLLABLE_UNREF(worker->pollable_obj, "pollset_worker");
if (worker_remove(&pollset->root_worker, worker, PWLINK_POLLSET) ==
WRR_EMPTIED) {
- pollset_maybe_finish_shutdown(exec_ctx, pollset);
+ pollset_maybe_finish_shutdown(pollset);
}
if (worker->initialized_cv) {
gpr_cv_destroy(&worker->cv);
@@ -970,7 +952,7 @@ static long gettid(void) { return syscall(__NR_gettid); }
The function pollset_work() may temporarily release the lock (pollset->po.mu)
during the course of its execution but it will always re-acquire the lock and
ensure that it is held by the time the function returns */
-static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
+static grpc_error* pollset_work(grpc_pollset* pollset,
grpc_pollset_worker** worker_hdl,
grpc_millis deadline) {
#ifdef GRPC_EPOLLEX_CREATE_WORKERS_ON_HEAP
@@ -988,7 +970,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
gpr_log(GPR_DEBUG,
"PS:%p work hdl=%p worker=%p now=%" PRIdPTR " deadline=%" PRIdPTR
" kwp=%d pollable=%p",
- pollset, worker_hdl, WORKER_PTR, grpc_exec_ctx_now(exec_ctx),
+ pollset, worker_hdl, WORKER_PTR, grpc_core::ExecCtx::Get()->Now(),
deadline, pollset->kicked_without_poller, pollset->active_pollable);
}
static const char* err_desc = "pollset_work";
@@ -996,25 +978,23 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
if (pollset->kicked_without_poller) {
pollset->kicked_without_poller = false;
} else {
- if (begin_worker(exec_ctx, pollset, WORKER_PTR, worker_hdl, deadline)) {
+ if (begin_worker(pollset, WORKER_PTR, worker_hdl, deadline)) {
gpr_tls_set(&g_current_thread_pollset, (intptr_t)pollset);
gpr_tls_set(&g_current_thread_worker, (intptr_t)WORKER_PTR);
if (WORKER_PTR->pollable_obj->event_cursor ==
WORKER_PTR->pollable_obj->event_count) {
- append_error(
- &error,
- pollable_epoll(exec_ctx, WORKER_PTR->pollable_obj, deadline),
- err_desc);
+ append_error(&error, pollable_epoll(WORKER_PTR->pollable_obj, deadline),
+ err_desc);
}
- append_error(&error,
- pollable_process_events(exec_ctx, pollset,
- WORKER_PTR->pollable_obj, false),
- err_desc);
- grpc_exec_ctx_flush(exec_ctx);
+ append_error(
+ &error,
+ pollable_process_events(pollset, WORKER_PTR->pollable_obj, false),
+ err_desc);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_tls_set(&g_current_thread_pollset, 0);
gpr_tls_set(&g_current_thread_worker, 0);
}
- end_worker(exec_ctx, pollset, WORKER_PTR, worker_hdl);
+ end_worker(pollset, WORKER_PTR, worker_hdl);
}
#ifdef GRPC_EPOLLEX_CREATE_WORKERS_ON_HEAP
gpr_free(worker);
@@ -1024,7 +1004,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
}
static grpc_error* pollset_transition_pollable_from_empty_to_fd_locked(
- grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, grpc_fd* fd) {
+ 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)) {
@@ -1032,7 +1012,7 @@ static grpc_error* pollset_transition_pollable_from_empty_to_fd_locked(
"PS:%p add fd %p (%d); transition pollable from empty to fd",
pollset, fd, fd->fd);
}
- append_error(&error, pollset_kick_all(exec_ctx, pollset), err_desc);
+ append_error(&error, pollset_kick_all(pollset), err_desc);
POLLABLE_UNREF(pollset->active_pollable, "pollset");
append_error(&error, fd_get_or_become_pollable(fd, &pollset->active_pollable),
err_desc);
@@ -1040,7 +1020,7 @@ static grpc_error* pollset_transition_pollable_from_empty_to_fd_locked(
}
static grpc_error* pollset_transition_pollable_from_fd_to_multi_locked(
- grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, grpc_fd* and_add_fd) {
+ 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)) {
@@ -1050,7 +1030,7 @@ static grpc_error* pollset_transition_pollable_from_fd_to_multi_locked(
pollset, and_add_fd, and_add_fd ? and_add_fd->fd : -1,
pollset->active_pollable->owner_fd);
}
- append_error(&error, pollset_kick_all(exec_ctx, pollset), err_desc);
+ append_error(&error, pollset_kick_all(pollset), err_desc);
grpc_fd* initial_fd = pollset->active_pollable->owner_fd;
POLLABLE_UNREF(pollset->active_pollable, "pollset");
pollset->active_pollable = nullptr;
@@ -1068,27 +1048,25 @@ static grpc_error* pollset_transition_pollable_from_fd_to_multi_locked(
}
/* expects pollsets locked, flag whether fd is locked or not */
-static grpc_error* pollset_add_fd_locked(grpc_exec_ctx* exec_ctx,
- grpc_pollset* pollset, grpc_fd* fd) {
+static grpc_error* pollset_add_fd_locked(grpc_pollset* pollset, grpc_fd* fd) {
grpc_error* error = GRPC_ERROR_NONE;
pollable* po_at_start =
POLLABLE_REF(pollset->active_pollable, "pollset_add_fd");
switch (pollset->active_pollable->type) {
case PO_EMPTY:
/* empty pollable --> single fd pollable */
- error = pollset_transition_pollable_from_empty_to_fd_locked(exec_ctx,
- pollset, fd);
+ error = pollset_transition_pollable_from_empty_to_fd_locked(pollset, fd);
break;
case PO_FD:
gpr_mu_lock(&po_at_start->owner_fd->orphan_mu);
if ((gpr_atm_no_barrier_load(&pollset->active_pollable->owner_fd->refst) &
1) == 0) {
- error = pollset_transition_pollable_from_empty_to_fd_locked(
- exec_ctx, pollset, fd);
+ error =
+ pollset_transition_pollable_from_empty_to_fd_locked(pollset, fd);
} else {
/* fd --> multipoller */
- error = pollset_transition_pollable_from_fd_to_multi_locked(
- exec_ctx, pollset, fd);
+ error =
+ pollset_transition_pollable_from_fd_to_multi_locked(pollset, fd);
}
gpr_mu_unlock(&po_at_start->owner_fd->orphan_mu);
break;
@@ -1105,8 +1083,7 @@ static grpc_error* pollset_add_fd_locked(grpc_exec_ctx* exec_ctx,
return error;
}
-static grpc_error* pollset_as_multipollable_locked(grpc_exec_ctx* exec_ctx,
- grpc_pollset* pollset,
+static grpc_error* pollset_as_multipollable_locked(grpc_pollset* pollset,
pollable** pollable_obj) {
grpc_error* error = GRPC_ERROR_NONE;
pollable* po_at_start =
@@ -1123,8 +1100,8 @@ static grpc_error* pollset_as_multipollable_locked(grpc_exec_ctx* exec_ctx,
POLLABLE_UNREF(pollset->active_pollable, "pollset");
error = pollable_create(PO_MULTI, &pollset->active_pollable);
} else {
- error = pollset_transition_pollable_from_fd_to_multi_locked(
- exec_ctx, pollset, nullptr);
+ error = pollset_transition_pollable_from_fd_to_multi_locked(pollset,
+ nullptr);
}
gpr_mu_unlock(&po_at_start->owner_fd->orphan_mu);
break;
@@ -1142,10 +1119,9 @@ static grpc_error* pollset_as_multipollable_locked(grpc_exec_ctx* exec_ctx,
return error;
}
-static void pollset_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- grpc_fd* fd) {
+static void pollset_add_fd(grpc_pollset* pollset, grpc_fd* fd) {
gpr_mu_lock(&pollset->mu);
- grpc_error* error = pollset_add_fd_locked(exec_ctx, pollset, fd);
+ grpc_error* error = pollset_add_fd_locked(pollset, fd);
gpr_mu_unlock(&pollset->mu);
GRPC_LOG_IF_ERROR("pollset_add_fd", error);
}
@@ -1171,28 +1147,27 @@ static grpc_pollset_set* pollset_set_create(void) {
return pss;
}
-static void pollset_set_unref(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss) {
+static void pollset_set_unref(grpc_pollset_set* pss) {
if (pss == nullptr) return;
if (!gpr_unref(&pss->refs)) return;
- pollset_set_unref(exec_ctx, pss->parent);
+ pollset_set_unref(pss->parent);
gpr_mu_destroy(&pss->mu);
for (size_t i = 0; i < pss->pollset_count; i++) {
gpr_mu_lock(&pss->pollsets[i]->mu);
if (0 == --pss->pollsets[i]->containing_pollset_set_count) {
- pollset_maybe_finish_shutdown(exec_ctx, pss->pollsets[i]);
+ pollset_maybe_finish_shutdown(pss->pollsets[i]);
}
gpr_mu_unlock(&pss->pollsets[i]->mu);
}
for (size_t i = 0; i < pss->fd_count; i++) {
- UNREF_BY(exec_ctx, pss->fds[i], 2, "pollset_set");
+ UNREF_BY(pss->fds[i], 2, "pollset_set");
}
gpr_free(pss->pollsets);
gpr_free(pss->fds);
gpr_free(pss);
}
-static void pollset_set_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss,
- grpc_fd* fd) {
+static void pollset_set_add_fd(grpc_pollset_set* pss, grpc_fd* fd) {
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "PSS:%p: add fd %p (%d)", pss, fd, fd->fd);
}
@@ -1215,8 +1190,7 @@ static void pollset_set_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss,
GRPC_LOG_IF_ERROR(err_desc, error);
}
-static void pollset_set_del_fd(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss,
- grpc_fd* fd) {
+static void pollset_set_del_fd(grpc_pollset_set* pss, grpc_fd* fd) {
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "PSS:%p: del fd %p", pss, fd);
}
@@ -1224,7 +1198,7 @@ static void pollset_set_del_fd(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss,
size_t i;
for (i = 0; i < pss->fd_count; i++) {
if (pss->fds[i] == fd) {
- UNREF_BY(exec_ctx, fd, 2, "pollset_set");
+ UNREF_BY(fd, 2, "pollset_set");
break;
}
}
@@ -1236,8 +1210,7 @@ static void pollset_set_del_fd(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss,
gpr_mu_unlock(&pss->mu);
}
-static void pollset_set_del_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pss, grpc_pollset* ps) {
+static void pollset_set_del_pollset(grpc_pollset_set* pss, grpc_pollset* ps) {
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "PSS:%p: del pollset %p", pss, ps);
}
@@ -1256,15 +1229,15 @@ static void pollset_set_del_pollset(grpc_exec_ctx* exec_ctx,
gpr_mu_unlock(&pss->mu);
gpr_mu_lock(&ps->mu);
if (0 == --ps->containing_pollset_set_count) {
- pollset_maybe_finish_shutdown(exec_ctx, ps);
+ pollset_maybe_finish_shutdown(ps);
}
gpr_mu_unlock(&ps->mu);
}
// add all fds to pollables, and output a new array of unorphaned out_fds
// assumes pollsets are multipollable
-static grpc_error* add_fds_to_pollsets(grpc_exec_ctx* exec_ctx, grpc_fd** fds,
- size_t fd_count, grpc_pollset** pollsets,
+static grpc_error* add_fds_to_pollsets(grpc_fd** fds, size_t fd_count,
+ grpc_pollset** pollsets,
size_t pollset_count,
const char* err_desc, grpc_fd** out_fds,
size_t* out_fd_count) {
@@ -1273,7 +1246,7 @@ static grpc_error* add_fds_to_pollsets(grpc_exec_ctx* exec_ctx, grpc_fd** fds,
gpr_mu_lock(&fds[i]->orphan_mu);
if ((gpr_atm_no_barrier_load(&fds[i]->refst) & 1) == 0) {
gpr_mu_unlock(&fds[i]->orphan_mu);
- UNREF_BY(exec_ctx, fds[i], 2, "pollset_set");
+ UNREF_BY(fds[i], 2, "pollset_set");
} else {
for (size_t j = 0; j < pollset_count; j++) {
append_error(&error,
@@ -1287,8 +1260,7 @@ static grpc_error* add_fds_to_pollsets(grpc_exec_ctx* exec_ctx, grpc_fd** fds,
return error;
}
-static void pollset_set_add_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pss, grpc_pollset* ps) {
+static void pollset_set_add_pollset(grpc_pollset_set* pss, grpc_pollset* ps) {
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "PSS:%p: add pollset %p", pss, ps);
}
@@ -1296,8 +1268,8 @@ static void pollset_set_add_pollset(grpc_exec_ctx* exec_ctx,
static const char* err_desc = "pollset_set_add_pollset";
pollable* pollable_obj = nullptr;
gpr_mu_lock(&ps->mu);
- if (!GRPC_LOG_IF_ERROR(err_desc, pollset_as_multipollable_locked(
- exec_ctx, ps, &pollable_obj))) {
+ if (!GRPC_LOG_IF_ERROR(err_desc,
+ pollset_as_multipollable_locked(ps, &pollable_obj))) {
GPR_ASSERT(pollable_obj == nullptr);
gpr_mu_unlock(&ps->mu);
return;
@@ -1308,8 +1280,8 @@ static void pollset_set_add_pollset(grpc_exec_ctx* exec_ctx,
size_t initial_fd_count = pss->fd_count;
pss->fd_count = 0;
append_error(&error,
- add_fds_to_pollsets(exec_ctx, pss->fds, initial_fd_count, &ps, 1,
- err_desc, pss->fds, &pss->fd_count),
+ add_fds_to_pollsets(pss->fds, initial_fd_count, &ps, 1, err_desc,
+ pss->fds, &pss->fd_count),
err_desc);
if (pss->pollset_count == pss->pollset_capacity) {
pss->pollset_capacity = GPR_MAX(pss->pollset_capacity * 2, 8);
@@ -1323,8 +1295,7 @@ static void pollset_set_add_pollset(grpc_exec_ctx* exec_ctx,
GRPC_LOG_IF_ERROR(err_desc, error);
}
-static void pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* a,
+static void pollset_set_add_pollset_set(grpc_pollset_set* a,
grpc_pollset_set* b) {
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "PSS: merge (%p, %p)", a, b);
@@ -1373,13 +1344,13 @@ static void pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
a->fd_count = 0;
append_error(
&error,
- add_fds_to_pollsets(exec_ctx, a->fds, initial_a_fd_count, b->pollsets,
+ add_fds_to_pollsets(a->fds, initial_a_fd_count, b->pollsets,
b->pollset_count, "merge_a2b", a->fds, &a->fd_count),
err_desc);
append_error(
&error,
- add_fds_to_pollsets(exec_ctx, b->fds, b->fd_count, a->pollsets,
- a->pollset_count, "merge_b2a", a->fds, &a->fd_count),
+ add_fds_to_pollsets(b->fds, b->fd_count, a->pollsets, a->pollset_count,
+ "merge_b2a", a->fds, &a->fd_count),
err_desc);
if (a->pollset_capacity < a->pollset_count + b->pollset_count) {
a->pollset_capacity =
@@ -1401,8 +1372,7 @@ static void pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
gpr_mu_unlock(&b->mu);
}
-static void pollset_set_del_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+static void pollset_set_del_pollset_set(grpc_pollset_set* bag,
grpc_pollset_set* item) {}
/*******************************************************************************
@@ -1485,7 +1455,7 @@ const grpc_event_engine_vtable* grpc_init_epollex_linux(
bool explicitly_requested) {
gpr_log(GPR_ERROR,
"Skipping epollex becuase GRPC_LINUX_EPOLL is not defined.");
- return NULL;
+ return nullptr;
}
#endif /* defined(GRPC_POSIX_SOCKET) */
diff --git a/src/core/lib/iomgr/ev_epollsig_linux.cc b/src/core/lib/iomgr/ev_epollsig_linux.cc
index 5b4a7ba19c..cbea6e4680 100644
--- a/src/core/lib/iomgr/ev_epollsig_linux.cc
+++ b/src/core/lib/iomgr/ev_epollsig_linux.cc
@@ -165,13 +165,12 @@ static void fd_global_shutdown(void);
#ifndef NDEBUG
#define PI_ADD_REF(p, r) pi_add_ref_dbg((p), (r), __FILE__, __LINE__)
-#define PI_UNREF(exec_ctx, p, r) \
- pi_unref_dbg((exec_ctx), (p), (r), __FILE__, __LINE__)
+#define PI_UNREF(p, r) pi_unref_dbg((p), (r), __FILE__, __LINE__)
#else
#define PI_ADD_REF(p, r) pi_add_ref((p))
-#define PI_UNREF(exec_ctx, p, r) pi_unref((exec_ctx), (p))
+#define PI_UNREF(p, r) pi_unref((p))
#endif
@@ -270,7 +269,7 @@ static grpc_wakeup_fd polling_island_wakeup_fd;
static __thread polling_island* g_current_thread_polling_island;
/* Forward declaration */
-static void polling_island_delete(grpc_exec_ctx* exec_ctx, polling_island* pi);
+static void polling_island_delete(polling_island* pi);
#ifdef GRPC_TSAN
/* Currently TSAN may incorrectly flag data races between epoll_ctl and
@@ -284,7 +283,7 @@ gpr_atm g_epoll_sync;
#endif /* defined(GRPC_TSAN) */
static void pi_add_ref(polling_island* pi);
-static void pi_unref(grpc_exec_ctx* exec_ctx, polling_island* pi);
+static void pi_unref(polling_island* pi);
#ifndef NDEBUG
static void pi_add_ref_dbg(polling_island* pi, const char* reason,
@@ -299,8 +298,8 @@ static void pi_add_ref_dbg(polling_island* pi, const char* reason,
pi_add_ref(pi);
}
-static void pi_unref_dbg(grpc_exec_ctx* exec_ctx, polling_island* pi,
- const char* reason, const char* file, int line) {
+static void pi_unref_dbg(polling_island* pi, const char* reason,
+ const char* file, int line) {
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_atm old_cnt = gpr_atm_acq_load(&pi->ref_count);
gpr_log(GPR_DEBUG,
@@ -308,7 +307,7 @@ static void pi_unref_dbg(grpc_exec_ctx* exec_ctx, polling_island* pi,
" (%s) - (%s, %d)",
pi, old_cnt, (old_cnt - 1), reason, file, line);
}
- pi_unref(exec_ctx, pi);
+ pi_unref(pi);
}
#endif
@@ -316,7 +315,7 @@ static void pi_add_ref(polling_island* pi) {
gpr_atm_no_barrier_fetch_add(&pi->ref_count, 1);
}
-static void pi_unref(grpc_exec_ctx* exec_ctx, polling_island* pi) {
+static void pi_unref(polling_island* pi) {
/* If ref count went to zero, delete the polling island.
Note that this deletion not be done under a lock. Once the ref count goes
to zero, we are guaranteed that no one else holds a reference to the
@@ -327,9 +326,9 @@ 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);
+ polling_island_delete(pi);
if (next != nullptr) {
- PI_UNREF(exec_ctx, next, "pi_delete"); /* Recursive call */
+ PI_UNREF(next, "pi_delete"); /* Recursive call */
}
}
}
@@ -465,8 +464,7 @@ static void polling_island_remove_fd_locked(polling_island* pi, grpc_fd* fd,
}
/* Might return NULL in case of an error */
-static polling_island* polling_island_create(grpc_exec_ctx* exec_ctx,
- grpc_fd* initial_fd,
+static polling_island* polling_island_create(grpc_fd* initial_fd,
grpc_error** error) {
polling_island* pi = nullptr;
const char* err_desc = "polling_island_create";
@@ -482,7 +480,7 @@ static polling_island* polling_island_create(grpc_exec_ctx* exec_ctx,
gpr_atm_rel_store(&pi->ref_count, 0);
gpr_atm_rel_store(&pi->poller_count, 0);
- gpr_atm_rel_store(&pi->merged_to, (gpr_atm)NULL);
+ gpr_atm_rel_store(&pi->merged_to, (gpr_atm) nullptr);
pi->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
@@ -497,13 +495,13 @@ static polling_island* polling_island_create(grpc_exec_ctx* exec_ctx,
done:
if (*error != GRPC_ERROR_NONE) {
- polling_island_delete(exec_ctx, pi);
+ polling_island_delete(pi);
pi = nullptr;
}
return pi;
}
-static void polling_island_delete(grpc_exec_ctx* exec_ctx, polling_island* pi) {
+static void polling_island_delete(polling_island* pi) {
GPR_ASSERT(pi->fd_cnt == 0);
if (pi->epoll_fd >= 0) {
@@ -835,7 +833,7 @@ static grpc_fd* fd_create(int fd, const char* name) {
new_fd->orphaned = false;
new_fd->read_closure.Init();
new_fd->write_closure.Init();
- gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL);
+ gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm) nullptr);
new_fd->freelist_next = nullptr;
new_fd->on_done_closure = nullptr;
@@ -860,8 +858,7 @@ static int fd_wrapped_fd(grpc_fd* fd) {
return ret_fd;
}
-static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure* on_done, int* release_fd,
+static void fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd,
bool already_closed, const char* reason) {
grpc_error* error = GRPC_ERROR_NONE;
polling_island* unref_pi = nullptr;
@@ -900,7 +897,7 @@ static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
fd->orphaned = true;
- GRPC_CLOSURE_SCHED(exec_ctx, fd->on_done_closure, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(fd->on_done_closure, GRPC_ERROR_REF(error));
gpr_mu_unlock(&fd->po.mu);
UNREF_BY(fd, 2, reason); /* Drop the reference */
@@ -909,7 +906,7 @@ static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
The polling island owns a workqueue which owns an fd, and unreffing
inside the lock can cause an eventual lock loop that makes TSAN very
unhappy. */
- PI_UNREF(exec_ctx, unref_pi, "fd_orphan");
+ PI_UNREF(unref_pi, "fd_orphan");
}
if (error != GRPC_ERROR_NONE) {
const char* msg = grpc_error_string(error);
@@ -918,8 +915,7 @@ static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
GRPC_ERROR_UNREF(error);
}
-static grpc_pollset* fd_get_read_notifier_pollset(grpc_exec_ctx* exec_ctx,
- grpc_fd* fd) {
+static grpc_pollset* fd_get_read_notifier_pollset(grpc_fd* fd) {
gpr_atm notifier = gpr_atm_acq_load(&fd->read_notifier_pollset);
return (grpc_pollset*)notifier;
}
@@ -929,22 +925,20 @@ static bool fd_is_shutdown(grpc_fd* fd) {
}
/* Might be called multiple times */
-static void fd_shutdown(grpc_exec_ctx* exec_ctx, grpc_fd* fd, grpc_error* why) {
- if (fd->read_closure->SetShutdown(exec_ctx, GRPC_ERROR_REF(why))) {
+static void fd_shutdown(grpc_fd* fd, grpc_error* why) {
+ if (fd->read_closure->SetShutdown(GRPC_ERROR_REF(why))) {
shutdown(fd->fd, SHUT_RDWR);
- fd->write_closure->SetShutdown(exec_ctx, GRPC_ERROR_REF(why));
+ fd->write_closure->SetShutdown(GRPC_ERROR_REF(why));
}
GRPC_ERROR_UNREF(why);
}
-static void fd_notify_on_read(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure* closure) {
- fd->read_closure->NotifyOn(exec_ctx, closure);
+static void fd_notify_on_read(grpc_fd* fd, grpc_closure* closure) {
+ fd->read_closure->NotifyOn(closure);
}
-static void fd_notify_on_write(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure* closure) {
- fd->write_closure->NotifyOn(exec_ctx, closure);
+static void fd_notify_on_write(grpc_fd* fd, grpc_closure* closure) {
+ fd->write_closure->NotifyOn(closure);
}
/*******************************************************************************
@@ -1026,11 +1020,11 @@ static void push_front_worker(grpc_pollset* p, grpc_pollset_worker* worker) {
}
/* p->mu must be held before calling this function */
-static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* p,
+static grpc_error* pollset_kick(grpc_pollset* p,
grpc_pollset_worker* specific_worker) {
GPR_TIMER_BEGIN("pollset_kick", 0);
grpc_error* error = GRPC_ERROR_NONE;
- GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK();
const char* err_desc = "Kick Failure";
grpc_pollset_worker* worker = specific_worker;
if (worker != nullptr) {
@@ -1094,10 +1088,9 @@ static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
pollset->shutdown_done = nullptr;
}
-static int poll_deadline_to_millis_timeout(grpc_exec_ctx* exec_ctx,
- grpc_millis millis) {
+static int poll_deadline_to_millis_timeout(grpc_millis millis) {
if (millis == GRPC_MILLIS_INF_FUTURE) return -1;
- grpc_millis delta = millis - grpc_exec_ctx_now(exec_ctx);
+ grpc_millis delta = millis - grpc_core::ExecCtx::Get()->Now();
if (delta > INT_MAX)
return INT_MAX;
else if (delta < 0)
@@ -1106,9 +1099,8 @@ static int poll_deadline_to_millis_timeout(grpc_exec_ctx* exec_ctx,
return (int)delta;
}
-static void fd_become_readable(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_pollset* notifier) {
- fd->read_closure->SetReady(exec_ctx);
+static void fd_become_readable(grpc_fd* fd, grpc_pollset* notifier) {
+ fd->read_closure->SetReady();
/* Note, it is possible that fd_become_readable might be called twice with
different 'notifier's when an fd becomes readable and it is in two epoll
@@ -1119,39 +1111,34 @@ static void fd_become_readable(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
gpr_atm_rel_store(&fd->read_notifier_pollset, (gpr_atm)notifier);
}
-static void fd_become_writable(grpc_exec_ctx* exec_ctx, grpc_fd* fd) {
- fd->write_closure->SetReady(exec_ctx);
-}
+static void fd_become_writable(grpc_fd* fd) { fd->write_closure->SetReady(); }
-static void pollset_release_polling_island(grpc_exec_ctx* exec_ctx,
- grpc_pollset* ps,
+static void pollset_release_polling_island(grpc_pollset* ps,
const char* reason) {
if (ps->po.pi != nullptr) {
- PI_UNREF(exec_ctx, ps->po.pi, reason);
+ PI_UNREF(ps->po.pi, reason);
}
ps->po.pi = nullptr;
}
-static void finish_shutdown_locked(grpc_exec_ctx* exec_ctx,
- grpc_pollset* pollset) {
+static void finish_shutdown_locked(grpc_pollset* pollset) {
/* The pollset cannot have any workers if we are at this stage */
GPR_ASSERT(!pollset_has_workers(pollset));
pollset->finish_shutdown_called = true;
/* Release the ref and set pollset->po.pi to NULL */
- pollset_release_polling_island(exec_ctx, pollset, "ps_shutdown");
- GRPC_CLOSURE_SCHED(exec_ctx, pollset->shutdown_done, GRPC_ERROR_NONE);
+ pollset_release_polling_island(pollset, "ps_shutdown");
+ GRPC_CLOSURE_SCHED(pollset->shutdown_done, GRPC_ERROR_NONE);
}
/* pollset->po.mu lock must be held by the caller before calling this */
-static void pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- grpc_closure* closure) {
+static void pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
GPR_TIMER_BEGIN("pollset_shutdown", 0);
GPR_ASSERT(!pollset->shutting_down);
pollset->shutting_down = true;
pollset->shutdown_done = closure;
- pollset_kick(exec_ctx, pollset, GRPC_POLLSET_KICK_BROADCAST);
+ pollset_kick(pollset, GRPC_POLLSET_KICK_BROADCAST);
/* If the pollset has any workers, we cannot call finish_shutdown_locked()
because it would release the underlying polling island. In such a case, we
@@ -1159,7 +1146,7 @@ static void pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
if (!pollset_has_workers(pollset)) {
GPR_ASSERT(!pollset->finish_shutdown_called);
GPR_TIMER_MARK("pollset_shutdown.finish_shutdown_locked", 0);
- finish_shutdown_locked(exec_ctx, pollset);
+ finish_shutdown_locked(pollset);
}
GPR_TIMER_END("pollset_shutdown", 0);
}
@@ -1167,15 +1154,14 @@ static void pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
/* pollset_shutdown is guaranteed to be called before pollset_destroy. So other
* than destroying the mutexes, there is nothing special that needs to be done
* here */
-static void pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) {
+static void pollset_destroy(grpc_pollset* pollset) {
GPR_ASSERT(!pollset_has_workers(pollset));
gpr_mu_destroy(&pollset->po.mu);
}
#define GRPC_EPOLL_MAX_EVENTS 100
/* Note: sig_mask contains the signal mask to use *during* epoll_wait() */
-static void pollset_work_and_unlock(grpc_exec_ctx* exec_ctx,
- grpc_pollset* pollset,
+static void pollset_work_and_unlock(grpc_pollset* pollset,
grpc_pollset_worker* worker, int timeout_ms,
sigset_t* sig_mask, grpc_error** error) {
struct epoll_event ep_ev[GRPC_EPOLL_MAX_EVENTS];
@@ -1197,7 +1183,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx* exec_ctx,
this function (i.e pollset_work_and_unlock()) is called */
if (pollset->po.pi == nullptr) {
- pollset->po.pi = polling_island_create(exec_ctx, nullptr, error);
+ pollset->po.pi = polling_island_create(nullptr, error);
if (pollset->po.pi == nullptr) {
GPR_TIMER_END("pollset_work_and_unlock", 0);
return; /* Fatal error. We cannot continue */
@@ -1217,7 +1203,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx* exec_ctx,
/* Always do PI_ADD_REF before PI_UNREF because PI_UNREF may cause the
polling island to be deleted */
PI_ADD_REF(pi, "ps");
- PI_UNREF(exec_ctx, pollset->po.pi, "ps");
+ PI_UNREF(pollset->po.pi, "ps");
pollset->po.pi = pi;
}
@@ -1231,10 +1217,10 @@ static void pollset_work_and_unlock(grpc_exec_ctx* exec_ctx,
g_current_thread_polling_island = pi;
GRPC_SCHEDULING_START_BLOCKING_REGION;
- GRPC_STATS_INC_SYSCALL_POLL(exec_ctx);
+ GRPC_STATS_INC_SYSCALL_POLL();
ep_rv =
epoll_pwait(epoll_fd, ep_ev, GRPC_EPOLL_MAX_EVENTS, timeout_ms, sig_mask);
- GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(exec_ctx);
+ GRPC_SCHEDULING_END_BLOCKING_REGION;
if (ep_rv < 0) {
if (errno != EINTR) {
gpr_asprintf(&err_msg,
@@ -1272,10 +1258,10 @@ static void pollset_work_and_unlock(grpc_exec_ctx* exec_ctx,
int read_ev = ep_ev[i].events & (EPOLLIN | EPOLLPRI);
int write_ev = ep_ev[i].events & EPOLLOUT;
if (read_ev || cancel) {
- fd_become_readable(exec_ctx, fd, pollset);
+ fd_become_readable(fd, pollset);
}
if (write_ev || cancel) {
- fd_become_writable(exec_ctx, fd);
+ fd_become_writable(fd);
}
}
}
@@ -1290,7 +1276,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx* exec_ctx,
that we got before releasing the polling island lock). This is because
pollset->po.pi pointer might get udpated in other parts of the
code when there is an island merge while we are doing epoll_wait() above */
- PI_UNREF(exec_ctx, pi, "ps_work");
+ PI_UNREF(pi, "ps_work");
GPR_TIMER_END("pollset_work_and_unlock", 0);
}
@@ -1299,12 +1285,12 @@ static void pollset_work_and_unlock(grpc_exec_ctx* exec_ctx,
The function pollset_work() may temporarily release the lock (pollset->po.mu)
during the course of its execution but it will always re-acquire the lock and
ensure that it is held by the time the function returns */
-static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
+static grpc_error* pollset_work(grpc_pollset* pollset,
grpc_pollset_worker** worker_hdl,
grpc_millis deadline) {
GPR_TIMER_BEGIN("pollset_work", 0);
grpc_error* error = GRPC_ERROR_NONE;
- int timeout_ms = poll_deadline_to_millis_timeout(exec_ctx, deadline);
+ int timeout_ms = poll_deadline_to_millis_timeout(deadline);
sigset_t new_mask;
@@ -1362,9 +1348,9 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
push_front_worker(pollset, &worker); /* Add worker to pollset */
- pollset_work_and_unlock(exec_ctx, pollset, &worker, timeout_ms,
- &g_orig_sigmask, &error);
- grpc_exec_ctx_flush(exec_ctx);
+ pollset_work_and_unlock(pollset, &worker, timeout_ms, &g_orig_sigmask,
+ &error);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->po.mu);
@@ -1384,10 +1370,10 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
if (pollset->shutting_down && !pollset_has_workers(pollset) &&
!pollset->finish_shutdown_called) {
GPR_TIMER_MARK("pollset_work.finish_shutdown_locked", 0);
- finish_shutdown_locked(exec_ctx, pollset);
+ finish_shutdown_locked(pollset);
gpr_mu_unlock(&pollset->po.mu);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->po.mu);
}
@@ -1402,9 +1388,8 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
return error;
}
-static void add_poll_object(grpc_exec_ctx* exec_ctx, poll_obj* bag,
- poll_obj_type bag_type, poll_obj* item,
- poll_obj_type item_type) {
+static void add_poll_object(poll_obj* bag, poll_obj_type bag_type,
+ poll_obj* item, poll_obj_type item_type) {
GPR_TIMER_BEGIN("add_poll_object", 0);
#ifndef NDEBUG
@@ -1454,7 +1439,7 @@ retry:
keeping TSAN happy outweigh any performance advantage we might have
by keeping the lock held. */
gpr_mu_unlock(&item->mu);
- pi_new = polling_island_create(exec_ctx, FD_FROM_PO(item), &error);
+ pi_new = polling_island_create(FD_FROM_PO(item), &error);
gpr_mu_lock(&item->mu);
/* Need to reverify any assumptions made between the initial lock and
@@ -1473,11 +1458,11 @@ retry:
/* Ref and unref so that the polling island gets deleted during unref
*/
PI_ADD_REF(pi_new, "dance_of_destruction");
- PI_UNREF(exec_ctx, pi_new, "dance_of_destruction");
+ PI_UNREF(pi_new, "dance_of_destruction");
goto retry;
}
} else {
- pi_new = polling_island_create(exec_ctx, nullptr, &error);
+ pi_new = polling_island_create(nullptr, &error);
}
GRPC_POLLING_TRACE(
@@ -1531,7 +1516,7 @@ retry:
if (item->pi != pi_new) {
PI_ADD_REF(pi_new, poll_obj_string(item_type));
if (item->pi != nullptr) {
- PI_UNREF(exec_ctx, item->pi, poll_obj_string(item_type));
+ PI_UNREF(item->pi, poll_obj_string(item_type));
}
item->pi = pi_new;
}
@@ -1539,7 +1524,7 @@ retry:
if (bag->pi != pi_new) {
PI_ADD_REF(pi_new, poll_obj_string(bag_type));
if (bag->pi != nullptr) {
- PI_UNREF(exec_ctx, bag->pi, poll_obj_string(bag_type));
+ PI_UNREF(bag->pi, poll_obj_string(bag_type));
}
bag->pi = pi_new;
}
@@ -1551,10 +1536,8 @@ retry:
GPR_TIMER_END("add_poll_object", 0);
}
-static void pollset_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- grpc_fd* fd) {
- add_poll_object(exec_ctx, &pollset->po, POLL_OBJ_POLLSET, &fd->po,
- POLL_OBJ_FD);
+static void pollset_add_fd(grpc_pollset* pollset, grpc_fd* fd) {
+ add_poll_object(&pollset->po, POLL_OBJ_POLLSET, &fd->po, POLL_OBJ_FD);
}
/*******************************************************************************
@@ -1571,48 +1554,39 @@ static grpc_pollset_set* pollset_set_create(void) {
return pss;
}
-static void pollset_set_destroy(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pss) {
+static void pollset_set_destroy(grpc_pollset_set* pss) {
gpr_mu_destroy(&pss->po.mu);
if (pss->po.pi != nullptr) {
- PI_UNREF(exec_ctx, pss->po.pi, "pss_destroy");
+ PI_UNREF(pss->po.pi, "pss_destroy");
}
gpr_free(pss);
}
-static void pollset_set_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss,
- grpc_fd* fd) {
- add_poll_object(exec_ctx, &pss->po, POLL_OBJ_POLLSET_SET, &fd->po,
- POLL_OBJ_FD);
+static void pollset_set_add_fd(grpc_pollset_set* pss, grpc_fd* fd) {
+ add_poll_object(&pss->po, POLL_OBJ_POLLSET_SET, &fd->po, POLL_OBJ_FD);
}
-static void pollset_set_del_fd(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss,
- grpc_fd* fd) {
+static void pollset_set_del_fd(grpc_pollset_set* pss, grpc_fd* fd) {
/* Nothing to do */
}
-static void pollset_set_add_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pss, grpc_pollset* ps) {
- add_poll_object(exec_ctx, &pss->po, POLL_OBJ_POLLSET_SET, &ps->po,
- POLL_OBJ_POLLSET);
+static void pollset_set_add_pollset(grpc_pollset_set* pss, grpc_pollset* ps) {
+ add_poll_object(&pss->po, POLL_OBJ_POLLSET_SET, &ps->po, POLL_OBJ_POLLSET);
}
-static void pollset_set_del_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pss, grpc_pollset* ps) {
+static void pollset_set_del_pollset(grpc_pollset_set* pss, grpc_pollset* ps) {
/* Nothing to do */
}
-static void pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+static void pollset_set_add_pollset_set(grpc_pollset_set* bag,
grpc_pollset_set* item) {
- add_poll_object(exec_ctx, &bag->po, POLL_OBJ_POLLSET_SET, &item->po,
+ add_poll_object(&bag->po, POLL_OBJ_POLLSET_SET, &item->po,
POLL_OBJ_POLLSET_SET);
}
-static void pollset_set_del_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+static void pollset_set_del_pollset_set(grpc_pollset_set* bag,
grpc_pollset_set* item) {
/* Nothing to do */
}
@@ -1758,7 +1732,7 @@ const grpc_event_engine_vtable* grpc_init_epollsig_linux(
bool explicit_request) {
gpr_log(GPR_ERROR,
"Skipping epollsig becuase GRPC_LINUX_EPOLL is not defined.");
- return NULL;
+ return nullptr;
}
#endif /* defined(GRPC_POSIX_SOCKET) */
diff --git a/src/core/lib/iomgr/ev_poll_posix.cc b/src/core/lib/iomgr/ev_poll_posix.cc
index f8b9629462..09ebe894fa 100644
--- a/src/core/lib/iomgr/ev_poll_posix.cc
+++ b/src/core/lib/iomgr/ev_poll_posix.cc
@@ -128,8 +128,7 @@ static uint32_t fd_begin_poll(grpc_fd* fd, grpc_pollset* pollset,
MUST NOT be called with a pollset lock taken
if got_read or got_write are 1, also does the become_{readable,writable} as
appropriate. */
-static void fd_end_poll(grpc_exec_ctx* exec_ctx, grpc_fd_watcher* rec,
- int got_read, int got_write,
+static void fd_end_poll(grpc_fd_watcher* rec, int got_read, int got_write,
grpc_pollset* read_notifier_pollset);
/* Return 1 if this fd is orphaned, 0 otherwise */
@@ -186,11 +185,9 @@ struct grpc_pollset {
};
/* Add an fd to a pollset */
-static void pollset_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- struct grpc_fd* fd);
+static void pollset_add_fd(grpc_pollset* pollset, struct grpc_fd* fd);
-static void pollset_set_add_fd(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set, grpc_fd* fd);
+static void pollset_set_add_fd(grpc_pollset_set* pollset_set, grpc_fd* fd);
/* Convert a timespec to milliseconds:
- very small or negative poll times are clamped to zero to do a
@@ -199,8 +196,7 @@ static void pollset_set_add_fd(grpc_exec_ctx* exec_ctx,
- longer than a millisecond polls are rounded up to the next nearest
millisecond to avoid spinning
- infinite timeouts are converted to -1 */
-static int poll_deadline_to_millis_timeout(grpc_exec_ctx* exec_ctx,
- grpc_millis deadline);
+static int poll_deadline_to_millis_timeout(grpc_millis deadline);
/* Allow kick to wakeup the currently polling worker */
#define GRPC_POLLSET_CAN_KICK_SELF 1
@@ -208,7 +204,7 @@ static int poll_deadline_to_millis_timeout(grpc_exec_ctx* exec_ctx,
#define GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP 2
/* As per pollset_kick, with an extended set of flags (defined above)
-- mostly for fd_posix's use. */
-static grpc_error* pollset_kick_ext(grpc_exec_ctx* exec_ctx, grpc_pollset* p,
+static grpc_error* pollset_kick_ext(grpc_pollset* p,
grpc_pollset_worker* specific_worker,
uint32_t flags) GRPC_MUST_USE_RESULT;
@@ -353,8 +349,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) {
+static grpc_pollset* fd_get_read_notifier_pollset(grpc_fd* fd) {
grpc_pollset* notifier = nullptr;
gpr_mu_lock(&fd->mu);
@@ -364,39 +359,36 @@ static grpc_pollset* fd_get_read_notifier_pollset(grpc_exec_ctx* exec_ctx,
return notifier;
}
-static grpc_error* pollset_kick_locked(grpc_exec_ctx* exec_ctx,
- grpc_fd_watcher* watcher) {
+static grpc_error* pollset_kick_locked(grpc_fd_watcher* watcher) {
gpr_mu_lock(&watcher->pollset->mu);
GPR_ASSERT(watcher->worker);
- grpc_error* err =
- pollset_kick_ext(exec_ctx, watcher->pollset, watcher->worker,
- GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP);
+ grpc_error* err = pollset_kick_ext(watcher->pollset, watcher->worker,
+ GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP);
gpr_mu_unlock(&watcher->pollset->mu);
return err;
}
-static void maybe_wake_one_watcher_locked(grpc_exec_ctx* exec_ctx,
- grpc_fd* fd) {
+static void maybe_wake_one_watcher_locked(grpc_fd* fd) {
if (fd->inactive_watcher_root.next != &fd->inactive_watcher_root) {
- pollset_kick_locked(exec_ctx, fd->inactive_watcher_root.next);
+ pollset_kick_locked(fd->inactive_watcher_root.next);
} else if (fd->read_watcher) {
- pollset_kick_locked(exec_ctx, fd->read_watcher);
+ pollset_kick_locked(fd->read_watcher);
} else if (fd->write_watcher) {
- pollset_kick_locked(exec_ctx, fd->write_watcher);
+ pollset_kick_locked(fd->write_watcher);
}
}
-static void wake_all_watchers_locked(grpc_exec_ctx* exec_ctx, grpc_fd* fd) {
+static void wake_all_watchers_locked(grpc_fd* fd) {
grpc_fd_watcher* watcher;
for (watcher = fd->inactive_watcher_root.next;
watcher != &fd->inactive_watcher_root; watcher = watcher->next) {
- pollset_kick_locked(exec_ctx, watcher);
+ pollset_kick_locked(watcher);
}
if (fd->read_watcher) {
- pollset_kick_locked(exec_ctx, fd->read_watcher);
+ pollset_kick_locked(fd->read_watcher);
}
if (fd->write_watcher && fd->write_watcher != fd->read_watcher) {
- pollset_kick_locked(exec_ctx, fd->write_watcher);
+ pollset_kick_locked(fd->write_watcher);
}
}
@@ -405,12 +397,12 @@ static int has_watchers(grpc_fd* fd) {
fd->inactive_watcher_root.next != &fd->inactive_watcher_root;
}
-static void close_fd_locked(grpc_exec_ctx* exec_ctx, grpc_fd* fd) {
+static void close_fd_locked(grpc_fd* fd) {
fd->closed = 1;
if (!fd->released) {
close(fd->fd);
}
- GRPC_CLOSURE_SCHED(exec_ctx, fd->on_done_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(fd->on_done_closure, GRPC_ERROR_NONE);
}
static int fd_wrapped_fd(grpc_fd* fd) {
@@ -421,8 +413,7 @@ static int fd_wrapped_fd(grpc_fd* fd) {
}
}
-static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure* on_done, int* release_fd,
+static void fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd,
bool already_closed, const char* reason) {
fd->on_done_closure = on_done;
fd->released = release_fd != nullptr;
@@ -435,9 +426,9 @@ static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
gpr_mu_lock(&fd->mu);
REF_BY(fd, 1, reason); /* remove active status, but keep referenced */
if (!has_watchers(fd)) {
- close_fd_locked(exec_ctx, fd);
+ close_fd_locked(fd);
} else {
- wake_all_watchers_locked(exec_ctx, fd);
+ wake_all_watchers_locked(fd);
}
gpr_mu_unlock(&fd->mu);
UNREF_BY(fd, 2, reason); /* drop the reference */
@@ -469,10 +460,10 @@ static grpc_error* fd_shutdown_error(grpc_fd* fd) {
}
}
-static void notify_on_locked(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure** st, grpc_closure* closure) {
+static void notify_on_locked(grpc_fd* fd, grpc_closure** st,
+ grpc_closure* closure) {
if (fd->shutdown) {
- GRPC_CLOSURE_SCHED(exec_ctx, closure,
+ GRPC_CLOSURE_SCHED(closure,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("FD shutdown"));
} else if (*st == CLOSURE_NOT_READY) {
/* not ready ==> switch to a waiting state by setting the closure */
@@ -480,8 +471,8 @@ static void notify_on_locked(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
} else if (*st == CLOSURE_READY) {
/* already ready ==> queue the closure to run immediately */
*st = CLOSURE_NOT_READY;
- GRPC_CLOSURE_SCHED(exec_ctx, closure, fd_shutdown_error(fd));
- maybe_wake_one_watcher_locked(exec_ctx, fd);
+ GRPC_CLOSURE_SCHED(closure, fd_shutdown_error(fd));
+ maybe_wake_one_watcher_locked(fd);
} else {
/* upcallptr was set to a different closure. This is an error! */
gpr_log(GPR_ERROR,
@@ -492,8 +483,7 @@ static void notify_on_locked(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
}
/* returns 1 if state becomes not ready */
-static int set_ready_locked(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure** st) {
+static int set_ready_locked(grpc_fd* fd, grpc_closure** st) {
if (*st == CLOSURE_READY) {
/* duplicate ready ==> ignore */
return 0;
@@ -503,18 +493,18 @@ static int set_ready_locked(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
return 0;
} else {
/* waiting ==> queue closure */
- GRPC_CLOSURE_SCHED(exec_ctx, *st, fd_shutdown_error(fd));
+ GRPC_CLOSURE_SCHED(*st, fd_shutdown_error(fd));
*st = CLOSURE_NOT_READY;
return 1;
}
}
static void set_read_notifier_pollset_locked(
- grpc_exec_ctx* exec_ctx, grpc_fd* fd, grpc_pollset* read_notifier_pollset) {
+ grpc_fd* fd, grpc_pollset* read_notifier_pollset) {
fd->read_notifier_pollset = read_notifier_pollset;
}
-static void fd_shutdown(grpc_exec_ctx* exec_ctx, grpc_fd* fd, grpc_error* why) {
+static void fd_shutdown(grpc_fd* fd, grpc_error* why) {
gpr_mu_lock(&fd->mu);
/* only shutdown once */
if (!fd->shutdown) {
@@ -522,8 +512,8 @@ static void fd_shutdown(grpc_exec_ctx* exec_ctx, grpc_fd* fd, grpc_error* why) {
fd->shutdown_error = why;
/* signal read/write closed to OS so that future operations fail */
shutdown(fd->fd, SHUT_RDWR);
- set_ready_locked(exec_ctx, fd, &fd->read_closure);
- set_ready_locked(exec_ctx, fd, &fd->write_closure);
+ set_ready_locked(fd, &fd->read_closure);
+ set_ready_locked(fd, &fd->write_closure);
} else {
GRPC_ERROR_UNREF(why);
}
@@ -537,17 +527,15 @@ static bool fd_is_shutdown(grpc_fd* fd) {
return r;
}
-static void fd_notify_on_read(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure* closure) {
+static void fd_notify_on_read(grpc_fd* fd, grpc_closure* closure) {
gpr_mu_lock(&fd->mu);
- notify_on_locked(exec_ctx, fd, &fd->read_closure, closure);
+ notify_on_locked(fd, &fd->read_closure, closure);
gpr_mu_unlock(&fd->mu);
}
-static void fd_notify_on_write(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure* closure) {
+static void fd_notify_on_write(grpc_fd* fd, grpc_closure* closure) {
gpr_mu_lock(&fd->mu);
- notify_on_locked(exec_ctx, fd, &fd->write_closure, closure);
+ notify_on_locked(fd, &fd->write_closure, closure);
gpr_mu_unlock(&fd->mu);
}
@@ -602,8 +590,7 @@ static uint32_t fd_begin_poll(grpc_fd* fd, grpc_pollset* pollset,
return mask;
}
-static void fd_end_poll(grpc_exec_ctx* exec_ctx, grpc_fd_watcher* watcher,
- int got_read, int got_write,
+static void fd_end_poll(grpc_fd_watcher* watcher, int got_read, int got_write,
grpc_pollset* read_notifier_pollset) {
int was_polling = 0;
int kick = 0;
@@ -637,23 +624,23 @@ static void fd_end_poll(grpc_exec_ctx* exec_ctx, grpc_fd_watcher* watcher,
watcher->prev->next = watcher->next;
}
if (got_read) {
- if (set_ready_locked(exec_ctx, fd, &fd->read_closure)) {
+ if (set_ready_locked(fd, &fd->read_closure)) {
kick = 1;
}
if (read_notifier_pollset != nullptr) {
- set_read_notifier_pollset_locked(exec_ctx, fd, read_notifier_pollset);
+ set_read_notifier_pollset_locked(fd, read_notifier_pollset);
}
}
if (got_write) {
- if (set_ready_locked(exec_ctx, fd, &fd->write_closure)) {
+ if (set_ready_locked(fd, &fd->write_closure)) {
kick = 1;
}
}
if (kick) {
- maybe_wake_one_watcher_locked(exec_ctx, fd);
+ maybe_wake_one_watcher_locked(fd);
}
if (fd_is_orphaned(fd) && !has_watchers(fd) && !fd->closed) {
- close_fd_locked(exec_ctx, fd);
+ close_fd_locked(fd);
}
gpr_mu_unlock(&fd->mu);
@@ -714,12 +701,12 @@ static void kick_append_error(grpc_error** composite, grpc_error* error) {
*composite = grpc_error_add_child(*composite, error);
}
-static grpc_error* pollset_kick_ext(grpc_exec_ctx* exec_ctx, grpc_pollset* p,
+static grpc_error* pollset_kick_ext(grpc_pollset* p,
grpc_pollset_worker* specific_worker,
uint32_t flags) {
GPR_TIMER_BEGIN("pollset_kick_ext", 0);
grpc_error* error = GRPC_ERROR_NONE;
- GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
+ GRPC_STATS_INC_POLLSET_KICK();
/* pollset->mu already held */
if (specific_worker != nullptr) {
@@ -785,9 +772,9 @@ static grpc_error* pollset_kick_ext(grpc_exec_ctx* exec_ctx, grpc_pollset* p,
return error;
}
-static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* p,
+static grpc_error* pollset_kick(grpc_pollset* p,
grpc_pollset_worker* specific_worker) {
- return pollset_kick_ext(exec_ctx, p, specific_worker, 0);
+ return pollset_kick_ext(p, specific_worker, 0);
}
/* global state management */
@@ -821,7 +808,7 @@ static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
pollset->pollset_set_count = 0;
}
-static void pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) {
+static void pollset_destroy(grpc_pollset* pollset) {
GPR_ASSERT(!pollset_has_workers(pollset));
GPR_ASSERT(pollset->idle_jobs.head == pollset->idle_jobs.tail);
while (pollset->local_wakeup_cache) {
@@ -834,8 +821,7 @@ static void pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) {
gpr_mu_destroy(&pollset->mu);
}
-static void pollset_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- grpc_fd* fd) {
+static void pollset_add_fd(grpc_pollset* pollset, grpc_fd* fd) {
gpr_mu_lock(&pollset->mu);
size_t i;
/* TODO(ctiller): this is O(num_fds^2); maybe switch to a hash set here */
@@ -850,19 +836,19 @@ 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, nullptr);
+ pollset_kick(pollset, nullptr);
exit:
gpr_mu_unlock(&pollset->mu);
}
-static void finish_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) {
+static void finish_shutdown(grpc_pollset* pollset) {
GPR_ASSERT(grpc_closure_list_empty(pollset->idle_jobs));
size_t i;
for (i = 0; i < pollset->fd_count; i++) {
GRPC_FD_UNREF(pollset->fds[i], "multipoller");
}
pollset->fd_count = 0;
- GRPC_CLOSURE_SCHED(exec_ctx, pollset->shutdown_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(pollset->shutdown_done, GRPC_ERROR_NONE);
}
static void work_combine_error(grpc_error** composite, grpc_error* error) {
@@ -873,7 +859,7 @@ static void work_combine_error(grpc_error** composite, grpc_error* error) {
*composite = grpc_error_add_child(*composite, error);
}
-static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
+static grpc_error* pollset_work(grpc_pollset* pollset,
grpc_pollset_worker** worker_hdl,
grpc_millis deadline) {
grpc_pollset_worker worker;
@@ -912,7 +898,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
if (!pollset_has_workers(pollset) &&
!grpc_closure_list_empty(pollset->idle_jobs)) {
GPR_TIMER_MARK("pollset_work.idle_jobs", 0);
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pollset->idle_jobs);
+ GRPC_CLOSURE_LIST_SCHED(&pollset->idle_jobs);
goto done;
}
/* If we're shutting down then we don't execute any extended work */
@@ -944,7 +930,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
grpc_fd_watcher* watchers;
struct pollfd* pfds;
- timeout = poll_deadline_to_millis_timeout(exec_ctx, deadline);
+ timeout = poll_deadline_to_millis_timeout(deadline);
if (pollset->fd_count + 2 <= inline_elements) {
pfds = pollfd_space;
@@ -988,9 +974,9 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
/* TODO(vpai): Consider first doing a 0 timeout poll here to avoid
even going into the blocking annotation if possible */
GRPC_SCHEDULING_START_BLOCKING_REGION;
- GRPC_STATS_INC_SYSCALL_POLL(exec_ctx);
+ GRPC_STATS_INC_SYSCALL_POLL();
r = grpc_poll_function(pfds, pfd_count, timeout);
- GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(exec_ctx);
+ GRPC_SCHEDULING_END_BLOCKING_REGION;
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "%p poll=%d", pollset, r);
@@ -1003,16 +989,16 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
for (i = 1; i < pfd_count; i++) {
if (watchers[i].fd == nullptr) {
- fd_end_poll(exec_ctx, &watchers[i], 0, 0, nullptr);
+ fd_end_poll(&watchers[i], 0, 0, nullptr);
} else {
// Wake up all the file descriptors, if we have an invalid one
// we can identify it on the next pollset_work()
- fd_end_poll(exec_ctx, &watchers[i], 1, 1, pollset);
+ fd_end_poll(&watchers[i], 1, 1, pollset);
}
}
} else if (r == 0) {
for (i = 1; i < pfd_count; i++) {
- fd_end_poll(exec_ctx, &watchers[i], 0, 0, nullptr);
+ fd_end_poll(&watchers[i], 0, 0, nullptr);
}
} else {
if (pfds[0].revents & POLLIN_CHECK) {
@@ -1024,14 +1010,14 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
}
for (i = 1; i < pfd_count; i++) {
if (watchers[i].fd == nullptr) {
- fd_end_poll(exec_ctx, &watchers[i], 0, 0, nullptr);
+ fd_end_poll(&watchers[i], 0, 0, nullptr);
} else {
if (GRPC_TRACER_ON(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "%p got_event: %d r:%d w:%d [%d]", pollset,
pfds[i].fd, (pfds[i].revents & POLLIN_CHECK) != 0,
(pfds[i].revents & POLLOUT_CHECK) != 0, pfds[i].revents);
}
- fd_end_poll(exec_ctx, &watchers[i], pfds[i].revents & POLLIN_CHECK,
+ fd_end_poll(&watchers[i], pfds[i].revents & POLLIN_CHECK,
pfds[i].revents & POLLOUT_CHECK, pollset);
}
}
@@ -1054,7 +1040,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
worker list, which means nobody could ask us to re-evaluate polling). */
done:
if (!locked) {
- queued_work |= grpc_exec_ctx_flush(exec_ctx);
+ queued_work |= grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->mu);
locked = 1;
}
@@ -1083,21 +1069,21 @@ 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, nullptr);
+ pollset_kick(pollset, nullptr);
} else if (!pollset->called_shutdown && !pollset_has_observers(pollset)) {
pollset->called_shutdown = 1;
gpr_mu_unlock(&pollset->mu);
- finish_shutdown(exec_ctx, pollset);
- grpc_exec_ctx_flush(exec_ctx);
+ finish_shutdown(pollset);
+ grpc_core::ExecCtx::Get()->Flush();
/* Continuing to access pollset here is safe -- it is the caller's
* responsibility to not destroy when it has outstanding calls to
* pollset_work.
* TODO(dklempner): Can we refactor the shutdown logic to avoid this? */
gpr_mu_lock(&pollset->mu);
} else if (!grpc_closure_list_empty(pollset->idle_jobs)) {
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pollset->idle_jobs);
+ GRPC_CLOSURE_LIST_SCHED(&pollset->idle_jobs);
gpr_mu_unlock(&pollset->mu);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&pollset->mu);
}
}
@@ -1107,26 +1093,24 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
return error;
}
-static void pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- grpc_closure* closure) {
+static void pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
GPR_ASSERT(!pollset->shutting_down);
pollset->shutting_down = 1;
pollset->shutdown_done = closure;
- pollset_kick(exec_ctx, pollset, GRPC_POLLSET_KICK_BROADCAST);
+ pollset_kick(pollset, GRPC_POLLSET_KICK_BROADCAST);
if (!pollset_has_workers(pollset)) {
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pollset->idle_jobs);
+ GRPC_CLOSURE_LIST_SCHED(&pollset->idle_jobs);
}
if (!pollset->called_shutdown && !pollset_has_observers(pollset)) {
pollset->called_shutdown = 1;
- finish_shutdown(exec_ctx, pollset);
+ finish_shutdown(pollset);
}
}
-static int poll_deadline_to_millis_timeout(grpc_exec_ctx* exec_ctx,
- grpc_millis deadline) {
+static int poll_deadline_to_millis_timeout(grpc_millis deadline) {
if (deadline == GRPC_MILLIS_INF_FUTURE) return -1;
if (deadline == 0) return 0;
- grpc_millis n = deadline - grpc_exec_ctx_now(exec_ctx);
+ grpc_millis n = deadline - grpc_core::ExecCtx::Get()->Now();
if (n < 0) return 0;
if (n > INT_MAX) return -1;
return (int)n;
@@ -1143,8 +1127,7 @@ static grpc_pollset_set* pollset_set_create(void) {
return pollset_set;
}
-static void pollset_set_destroy(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set) {
+static void pollset_set_destroy(grpc_pollset_set* pollset_set) {
size_t i;
gpr_mu_destroy(&pollset_set->mu);
for (i = 0; i < pollset_set->fd_count; i++) {
@@ -1159,7 +1142,7 @@ static void pollset_set_destroy(grpc_exec_ctx* exec_ctx,
!pollset_has_observers(pollset)) {
pollset->called_shutdown = 1;
gpr_mu_unlock(&pollset->mu);
- finish_shutdown(exec_ctx, pollset);
+ finish_shutdown(pollset);
} else {
gpr_mu_unlock(&pollset->mu);
}
@@ -1170,8 +1153,7 @@ static void pollset_set_destroy(grpc_exec_ctx* exec_ctx,
gpr_free(pollset_set);
}
-static void pollset_set_add_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set,
+static void pollset_set_add_pollset(grpc_pollset_set* pollset_set,
grpc_pollset* pollset) {
size_t i, j;
gpr_mu_lock(&pollset->mu);
@@ -1190,7 +1172,7 @@ static void pollset_set_add_pollset(grpc_exec_ctx* exec_ctx,
if (fd_is_orphaned(pollset_set->fds[i])) {
GRPC_FD_UNREF(pollset_set->fds[i], "pollset_set");
} else {
- pollset_add_fd(exec_ctx, pollset, pollset_set->fds[i]);
+ pollset_add_fd(pollset, pollset_set->fds[i]);
pollset_set->fds[j++] = pollset_set->fds[i];
}
}
@@ -1198,8 +1180,7 @@ static void pollset_set_add_pollset(grpc_exec_ctx* exec_ctx,
gpr_mu_unlock(&pollset_set->mu);
}
-static void pollset_set_del_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set,
+static void pollset_set_del_pollset(grpc_pollset_set* pollset_set,
grpc_pollset* pollset) {
size_t i;
gpr_mu_lock(&pollset_set->mu);
@@ -1219,14 +1200,13 @@ static void pollset_set_del_pollset(grpc_exec_ctx* exec_ctx,
!pollset_has_observers(pollset)) {
pollset->called_shutdown = 1;
gpr_mu_unlock(&pollset->mu);
- finish_shutdown(exec_ctx, pollset);
+ finish_shutdown(pollset);
} else {
gpr_mu_unlock(&pollset->mu);
}
}
-static void pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+static void pollset_set_add_pollset_set(grpc_pollset_set* bag,
grpc_pollset_set* item) {
size_t i, j;
gpr_mu_lock(&bag->mu);
@@ -1241,7 +1221,7 @@ static void pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
if (fd_is_orphaned(bag->fds[i])) {
GRPC_FD_UNREF(bag->fds[i], "pollset_set");
} else {
- pollset_set_add_fd(exec_ctx, item, bag->fds[i]);
+ pollset_set_add_fd(item, bag->fds[i]);
bag->fds[j++] = bag->fds[i];
}
}
@@ -1249,8 +1229,7 @@ static void pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
gpr_mu_unlock(&bag->mu);
}
-static void pollset_set_del_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+static void pollset_set_del_pollset_set(grpc_pollset_set* bag,
grpc_pollset_set* item) {
size_t i;
gpr_mu_lock(&bag->mu);
@@ -1265,8 +1244,7 @@ static void pollset_set_del_pollset_set(grpc_exec_ctx* exec_ctx,
gpr_mu_unlock(&bag->mu);
}
-static void pollset_set_add_fd(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set, grpc_fd* fd) {
+static void pollset_set_add_fd(grpc_pollset_set* pollset_set, grpc_fd* fd) {
size_t i;
gpr_mu_lock(&pollset_set->mu);
if (pollset_set->fd_count == pollset_set->fd_capacity) {
@@ -1277,16 +1255,15 @@ static void pollset_set_add_fd(grpc_exec_ctx* exec_ctx,
GRPC_FD_REF(fd, "pollset_set");
pollset_set->fds[pollset_set->fd_count++] = fd;
for (i = 0; i < pollset_set->pollset_count; i++) {
- pollset_add_fd(exec_ctx, pollset_set->pollsets[i], fd);
+ pollset_add_fd(pollset_set->pollsets[i], fd);
}
for (i = 0; i < pollset_set->pollset_set_count; i++) {
- pollset_set_add_fd(exec_ctx, pollset_set->pollset_sets[i], fd);
+ pollset_set_add_fd(pollset_set->pollset_sets[i], fd);
}
gpr_mu_unlock(&pollset_set->mu);
}
-static void pollset_set_del_fd(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set, grpc_fd* fd) {
+static void pollset_set_del_fd(grpc_pollset_set* pollset_set, grpc_fd* fd) {
size_t i;
gpr_mu_lock(&pollset_set->mu);
for (i = 0; i < pollset_set->fd_count; i++) {
@@ -1299,7 +1276,7 @@ static void pollset_set_del_fd(grpc_exec_ctx* exec_ctx,
}
}
for (i = 0; i < pollset_set->pollset_set_count; i++) {
- pollset_set_del_fd(exec_ctx, pollset_set->pollset_sets[i], fd);
+ pollset_set_del_fd(pollset_set->pollset_sets[i], fd);
}
gpr_mu_unlock(&pollset_set->mu);
}
diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc
index 076d2e6bab..985469942f 100644
--- a/src/core/lib/iomgr/ev_posix.cc
+++ b/src/core/lib/iomgr/ev_posix.cc
@@ -193,28 +193,25 @@ int grpc_fd_wrapped_fd(grpc_fd* fd) {
return g_event_engine->fd_wrapped_fd(fd);
}
-void grpc_fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd, grpc_closure* on_done,
- int* release_fd, bool already_closed, const char* reason) {
- g_event_engine->fd_orphan(exec_ctx, fd, on_done, release_fd, already_closed,
- reason);
+void grpc_fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd,
+ bool already_closed, const char* reason) {
+ g_event_engine->fd_orphan(fd, on_done, release_fd, already_closed, reason);
}
-void grpc_fd_shutdown(grpc_exec_ctx* exec_ctx, grpc_fd* fd, grpc_error* why) {
- g_event_engine->fd_shutdown(exec_ctx, fd, why);
+void grpc_fd_shutdown(grpc_fd* fd, grpc_error* why) {
+ g_event_engine->fd_shutdown(fd, why);
}
bool grpc_fd_is_shutdown(grpc_fd* fd) {
return g_event_engine->fd_is_shutdown(fd);
}
-void grpc_fd_notify_on_read(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure* closure) {
- g_event_engine->fd_notify_on_read(exec_ctx, fd, closure);
+void grpc_fd_notify_on_read(grpc_fd* fd, grpc_closure* closure) {
+ g_event_engine->fd_notify_on_read(fd, closure);
}
-void grpc_fd_notify_on_write(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure* closure) {
- g_event_engine->fd_notify_on_write(exec_ctx, fd, closure);
+void grpc_fd_notify_on_write(grpc_fd* fd, grpc_closure* closure) {
+ g_event_engine->fd_notify_on_write(fd, closure);
}
size_t grpc_pollset_size(void) { return g_event_engine->pollset_size; }
@@ -223,72 +220,63 @@ void grpc_pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
g_event_engine->pollset_init(pollset, mu);
}
-void grpc_pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- grpc_closure* closure) {
- g_event_engine->pollset_shutdown(exec_ctx, pollset, closure);
+void grpc_pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
+ g_event_engine->pollset_shutdown(pollset, closure);
}
-void grpc_pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) {
- g_event_engine->pollset_destroy(exec_ctx, pollset);
+void grpc_pollset_destroy(grpc_pollset* pollset) {
+ g_event_engine->pollset_destroy(pollset);
}
-grpc_error* grpc_pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
+grpc_error* grpc_pollset_work(grpc_pollset* pollset,
grpc_pollset_worker** worker,
grpc_millis deadline) {
- return g_event_engine->pollset_work(exec_ctx, pollset, worker, deadline);
+ return g_event_engine->pollset_work(pollset, worker, deadline);
}
-grpc_error* grpc_pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
+grpc_error* grpc_pollset_kick(grpc_pollset* pollset,
grpc_pollset_worker* specific_worker) {
- return g_event_engine->pollset_kick(exec_ctx, pollset, specific_worker);
+ return g_event_engine->pollset_kick(pollset, specific_worker);
}
-void grpc_pollset_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- struct grpc_fd* fd) {
- g_event_engine->pollset_add_fd(exec_ctx, pollset, fd);
+void grpc_pollset_add_fd(grpc_pollset* pollset, struct grpc_fd* fd) {
+ g_event_engine->pollset_add_fd(pollset, fd);
}
grpc_pollset_set* grpc_pollset_set_create(void) {
return g_event_engine->pollset_set_create();
}
-void grpc_pollset_set_destroy(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set) {
- g_event_engine->pollset_set_destroy(exec_ctx, pollset_set);
+void grpc_pollset_set_destroy(grpc_pollset_set* pollset_set) {
+ g_event_engine->pollset_set_destroy(pollset_set);
}
-void grpc_pollset_set_add_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set,
+void grpc_pollset_set_add_pollset(grpc_pollset_set* pollset_set,
grpc_pollset* pollset) {
- g_event_engine->pollset_set_add_pollset(exec_ctx, pollset_set, pollset);
+ g_event_engine->pollset_set_add_pollset(pollset_set, pollset);
}
-void grpc_pollset_set_del_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set,
+void grpc_pollset_set_del_pollset(grpc_pollset_set* pollset_set,
grpc_pollset* pollset) {
- g_event_engine->pollset_set_del_pollset(exec_ctx, pollset_set, pollset);
+ g_event_engine->pollset_set_del_pollset(pollset_set, pollset);
}
-void grpc_pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+void grpc_pollset_set_add_pollset_set(grpc_pollset_set* bag,
grpc_pollset_set* item) {
- g_event_engine->pollset_set_add_pollset_set(exec_ctx, bag, item);
+ g_event_engine->pollset_set_add_pollset_set(bag, item);
}
-void grpc_pollset_set_del_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+void grpc_pollset_set_del_pollset_set(grpc_pollset_set* bag,
grpc_pollset_set* item) {
- g_event_engine->pollset_set_del_pollset_set(exec_ctx, bag, item);
+ g_event_engine->pollset_set_del_pollset_set(bag, item);
}
-void grpc_pollset_set_add_fd(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set, grpc_fd* fd) {
- g_event_engine->pollset_set_add_fd(exec_ctx, pollset_set, fd);
+void grpc_pollset_set_add_fd(grpc_pollset_set* pollset_set, grpc_fd* fd) {
+ g_event_engine->pollset_set_add_fd(pollset_set, fd);
}
-void grpc_pollset_set_del_fd(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set, grpc_fd* fd) {
- g_event_engine->pollset_set_del_fd(exec_ctx, pollset_set, fd);
+void grpc_pollset_set_del_fd(grpc_pollset_set* pollset_set, grpc_fd* fd) {
+ g_event_engine->pollset_set_del_fd(pollset_set, fd);
}
#endif // GRPC_POSIX_SOCKET
diff --git a/src/core/lib/iomgr/ev_posix.h b/src/core/lib/iomgr/ev_posix.h
index d719b8f3c9..93d8618d4d 100644
--- a/src/core/lib/iomgr/ev_posix.h
+++ b/src/core/lib/iomgr/ev_posix.h
@@ -40,48 +40,36 @@ typedef struct grpc_event_engine_vtable {
grpc_fd* (*fd_create)(int fd, const char* name);
int (*fd_wrapped_fd)(grpc_fd* fd);
- void (*fd_orphan)(grpc_exec_ctx* exec_ctx, grpc_fd* fd, grpc_closure* on_done,
- int* release_fd, bool already_closed, const char* reason);
- void (*fd_shutdown)(grpc_exec_ctx* exec_ctx, grpc_fd* fd, grpc_error* why);
- void (*fd_notify_on_read)(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure* closure);
- void (*fd_notify_on_write)(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure* closure);
+ void (*fd_orphan)(grpc_fd* fd, grpc_closure* on_done, int* release_fd,
+ bool already_closed, const char* reason);
+ void (*fd_shutdown)(grpc_fd* fd, grpc_error* why);
+ void (*fd_notify_on_read)(grpc_fd* fd, grpc_closure* closure);
+ void (*fd_notify_on_write)(grpc_fd* fd, grpc_closure* closure);
bool (*fd_is_shutdown)(grpc_fd* fd);
- grpc_pollset* (*fd_get_read_notifier_pollset)(grpc_exec_ctx* exec_ctx,
- grpc_fd* fd);
+ grpc_pollset* (*fd_get_read_notifier_pollset)(grpc_fd* fd);
void (*pollset_init)(grpc_pollset* pollset, gpr_mu** mu);
- void (*pollset_shutdown)(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- grpc_closure* closure);
- void (*pollset_destroy)(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset);
- grpc_error* (*pollset_work)(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
+ void (*pollset_shutdown)(grpc_pollset* pollset, grpc_closure* closure);
+ void (*pollset_destroy)(grpc_pollset* pollset);
+ grpc_error* (*pollset_work)(grpc_pollset* pollset,
grpc_pollset_worker** worker,
grpc_millis deadline);
- grpc_error* (*pollset_kick)(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
+ grpc_error* (*pollset_kick)(grpc_pollset* pollset,
grpc_pollset_worker* specific_worker);
- void (*pollset_add_fd)(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- struct grpc_fd* fd);
+ void (*pollset_add_fd)(grpc_pollset* pollset, struct grpc_fd* fd);
grpc_pollset_set* (*pollset_set_create)(void);
- void (*pollset_set_destroy)(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set);
- void (*pollset_set_add_pollset)(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set,
+ void (*pollset_set_destroy)(grpc_pollset_set* pollset_set);
+ void (*pollset_set_add_pollset)(grpc_pollset_set* pollset_set,
grpc_pollset* pollset);
- void (*pollset_set_del_pollset)(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set,
+ void (*pollset_set_del_pollset)(grpc_pollset_set* pollset_set,
grpc_pollset* pollset);
- void (*pollset_set_add_pollset_set)(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+ void (*pollset_set_add_pollset_set)(grpc_pollset_set* bag,
grpc_pollset_set* item);
- void (*pollset_set_del_pollset_set)(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+ void (*pollset_set_del_pollset_set)(grpc_pollset_set* bag,
grpc_pollset_set* item);
- void (*pollset_set_add_fd)(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set, grpc_fd* fd);
- void (*pollset_set_del_fd)(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set, grpc_fd* fd);
+ void (*pollset_set_add_fd)(grpc_pollset_set* pollset_set, grpc_fd* fd);
+ void (*pollset_set_del_fd)(grpc_pollset_set* pollset_set, grpc_fd* fd);
void (*shutdown_engine)(void);
} grpc_event_engine_vtable;
@@ -107,14 +95,14 @@ int grpc_fd_wrapped_fd(grpc_fd* fd);
Requires: *fd initialized; no outstanding notify_on_read or
notify_on_write.
MUST NOT be called with a pollset lock taken */
-void grpc_fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd, grpc_closure* on_done,
- int* release_fd, bool already_closed, const char* reason);
+void grpc_fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd,
+ bool already_closed, const char* reason);
/* Has grpc_fd_shutdown been called on an fd? */
bool grpc_fd_is_shutdown(grpc_fd* fd);
/* Cause any current and future callbacks to fail. */
-void grpc_fd_shutdown(grpc_exec_ctx* exec_ctx, grpc_fd* fd, grpc_error* why);
+void grpc_fd_shutdown(grpc_fd* fd, grpc_error* why);
/* Register read interest, causing read_cb to be called once when fd becomes
readable, on deadline specified by deadline, or on shutdown triggered by
@@ -129,29 +117,23 @@ void grpc_fd_shutdown(grpc_exec_ctx* exec_ctx, grpc_fd* fd, grpc_error* why);
underlying platform. This means that users must drain fd in read_cb before
calling notify_on_read again. Users are also expected to handle spurious
events, i.e read_cb is called while nothing can be readable from fd */
-void grpc_fd_notify_on_read(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure* closure);
+void grpc_fd_notify_on_read(grpc_fd* fd, grpc_closure* closure);
/* Exactly the same semantics as above, except based on writable events. */
-void grpc_fd_notify_on_write(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- grpc_closure* closure);
+void grpc_fd_notify_on_write(grpc_fd* fd, grpc_closure* closure);
/* Return the read notifier pollset from the fd */
-grpc_pollset* grpc_fd_get_read_notifier_pollset(grpc_exec_ctx* exec_ctx,
- grpc_fd* fd);
+grpc_pollset* grpc_fd_get_read_notifier_pollset(grpc_fd* fd);
/* pollset_posix functions */
/* Add an fd to a pollset */
-void grpc_pollset_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- struct grpc_fd* fd);
+void grpc_pollset_add_fd(grpc_pollset* pollset, struct grpc_fd* fd);
/* pollset_set_posix functions */
-void grpc_pollset_set_add_fd(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set, grpc_fd* fd);
-void grpc_pollset_set_del_fd(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set, grpc_fd* fd);
+void grpc_pollset_set_add_fd(grpc_pollset_set* pollset_set, grpc_fd* fd);
+void grpc_pollset_set_del_fd(grpc_pollset_set* pollset_set, grpc_fd* fd);
/* override to allow tests to hook poll() usage */
typedef int (*grpc_poll_function_type)(struct pollfd*, nfds_t, int);
diff --git a/src/core/lib/iomgr/exec_ctx.cc b/src/core/lib/iomgr/exec_ctx.cc
index 27c769a7ed..8a4b489ebb 100644
--- a/src/core/lib/iomgr/exec_ctx.cc
+++ b/src/core/lib/iomgr/exec_ctx.cc
@@ -28,39 +28,7 @@
#define GRPC_START_TIME_UPDATE_INTERVAL 10000
extern "C" grpc_tracer_flag grpc_timer_check_trace;
-bool grpc_exec_ctx_ready_to_finish(grpc_exec_ctx* exec_ctx) {
- if ((exec_ctx->flags & GRPC_EXEC_CTX_FLAG_IS_FINISHED) == 0) {
- if (exec_ctx->check_ready_to_finish(exec_ctx,
- exec_ctx->check_ready_to_finish_arg)) {
- exec_ctx->flags |= GRPC_EXEC_CTX_FLAG_IS_FINISHED;
- return true;
- }
- return false;
- } else {
- return true;
- }
-}
-
-bool grpc_never_ready_to_finish(grpc_exec_ctx* exec_ctx, void* arg_ignored) {
- return false;
-}
-
-bool grpc_always_ready_to_finish(grpc_exec_ctx* exec_ctx, void* arg_ignored) {
- return true;
-}
-
-bool grpc_exec_ctx_has_work(grpc_exec_ctx* exec_ctx) {
- return exec_ctx->active_combiner != nullptr ||
- !grpc_closure_list_empty(exec_ctx->closure_list);
-}
-
-void grpc_exec_ctx_finish(grpc_exec_ctx* exec_ctx) {
- exec_ctx->flags |= GRPC_EXEC_CTX_FLAG_IS_FINISHED;
- grpc_exec_ctx_flush(exec_ctx);
-}
-
-static void exec_ctx_run(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
- grpc_error* error) {
+static void exec_ctx_run(grpc_closure* closure, grpc_error* error) {
#ifndef NDEBUG
closure->scheduled = false;
if (GRPC_TRACER_ON(grpc_trace_closure)) {
@@ -70,7 +38,7 @@ static void exec_ctx_run(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
closure->line_initiated);
}
#endif
- closure->cb(exec_ctx, closure->cb_arg, error);
+ closure->cb(closure->cb_arg, error);
#ifndef NDEBUG
if (GRPC_TRACER_ON(grpc_trace_closure)) {
gpr_log(GPR_DEBUG, "closure %p finished", closure);
@@ -79,32 +47,9 @@ static void exec_ctx_run(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
GRPC_ERROR_UNREF(error);
}
-bool grpc_exec_ctx_flush(grpc_exec_ctx* exec_ctx) {
- bool did_something = 0;
- GPR_TIMER_BEGIN("grpc_exec_ctx_flush", 0);
- for (;;) {
- if (!grpc_closure_list_empty(exec_ctx->closure_list)) {
- grpc_closure* c = exec_ctx->closure_list.head;
- exec_ctx->closure_list.head = exec_ctx->closure_list.tail = nullptr;
- while (c != nullptr) {
- grpc_closure* next = c->next_data.next;
- grpc_error* error = c->error_data.error;
- did_something = true;
- exec_ctx_run(exec_ctx, c, error);
- c = next;
- }
- } else if (!grpc_combiner_continue_exec_ctx(exec_ctx)) {
- break;
- }
- }
- GPR_ASSERT(exec_ctx->active_combiner == nullptr);
- GPR_TIMER_END("grpc_exec_ctx_flush", 0);
- return did_something;
-}
-
-static void exec_ctx_sched(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
- grpc_error* error) {
- grpc_closure_list_append(&exec_ctx->closure_list, closure, error);
+static void exec_ctx_sched(grpc_closure* closure, grpc_error* error) {
+ grpc_closure_list_append(grpc_core::ExecCtx::Get()->closure_list(), closure,
+ error);
}
/* This time pair is not entirely thread-safe as store/load of tv_sec and
@@ -136,16 +81,6 @@ static void time_atm_pair_store(time_atm_pair* dst, const gpr_timespec src) {
gpr_atm_no_barrier_store(&dst->tv_nsec, src.tv_nsec);
}
-void grpc_exec_ctx_global_init(void) {
- for (int i = 0; i < GPR_TIMESPAN; i++) {
- time_atm_pair_store(&g_start_time[i], gpr_now((gpr_clock_type)i));
- }
- // allows uniform treatment in conversion functions
- time_atm_pair_store(&g_start_time[GPR_TIMESPAN], gpr_time_0(GPR_TIMESPAN));
-}
-
-void grpc_exec_ctx_global_shutdown(void) {}
-
static gpr_atm timespec_to_atm_round_down(gpr_timespec ts) {
gpr_timespec start_time =
timespec_from_time_atm_pair(&g_start_time[ts.clock_type], ts.clock_type);
@@ -169,18 +104,6 @@ static gpr_atm timespec_to_atm_round_up(gpr_timespec ts) {
return (gpr_atm)x;
}
-grpc_millis grpc_exec_ctx_now(grpc_exec_ctx* exec_ctx) {
- if (!exec_ctx->now_is_valid) {
- exec_ctx->now = timespec_to_atm_round_down(gpr_now(GPR_CLOCK_MONOTONIC));
- exec_ctx->now_is_valid = true;
- }
- return exec_ctx->now;
-}
-
-void grpc_exec_ctx_invalidate_now(grpc_exec_ctx* exec_ctx) {
- exec_ctx->now_is_valid = false;
-}
-
gpr_timespec grpc_millis_to_timespec(grpc_millis millis,
gpr_clock_type clock_type) {
// special-case infinities as grpc_millis can be 32bit on some platforms
@@ -208,8 +131,8 @@ grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec ts) {
return timespec_to_atm_round_up(ts);
}
-void grpc_exec_ctx_maybe_update_start_time(grpc_exec_ctx* exec_ctx) {
- grpc_millis now = grpc_exec_ctx_now(exec_ctx);
+void grpc_exec_ctx_maybe_update_start_time() {
+ grpc_millis now = grpc_core::ExecCtx::Get()->Now();
grpc_millis last_start_time_update =
gpr_atm_no_barrier_load(&g_last_start_time_update);
@@ -236,3 +159,49 @@ static const grpc_closure_scheduler_vtable exec_ctx_scheduler_vtable = {
exec_ctx_run, exec_ctx_sched, "exec_ctx"};
static grpc_closure_scheduler exec_ctx_scheduler = {&exec_ctx_scheduler_vtable};
grpc_closure_scheduler* grpc_schedule_on_exec_ctx = &exec_ctx_scheduler;
+
+namespace grpc_core {
+thread_local ExecCtx* ExecCtx::exec_ctx_ = nullptr;
+
+bool ExecCtx::Flush() {
+ bool did_something = 0;
+ GPR_TIMER_BEGIN("grpc_exec_ctx_flush", 0);
+ for (;;) {
+ if (!grpc_closure_list_empty(closure_list_)) {
+ grpc_closure* c = closure_list_.head;
+ closure_list_.head = closure_list_.tail = nullptr;
+ while (c != nullptr) {
+ grpc_closure* next = c->next_data.next;
+ grpc_error* error = c->error_data.error;
+ did_something = true;
+ exec_ctx_run(c, error);
+ c = next;
+ }
+ } else if (!grpc_combiner_continue_exec_ctx()) {
+ break;
+ }
+ }
+ GPR_ASSERT(combiner_data_.active_combiner == nullptr);
+ GPR_TIMER_END("grpc_exec_ctx_flush", 0);
+ return did_something;
+}
+
+void ExecCtx::GlobalInit(void) {
+ for (int i = 0; i < GPR_TIMESPAN; i++) {
+ time_atm_pair_store(&g_start_time[i], gpr_now((gpr_clock_type)i));
+ }
+ // allows uniform treatment in conversion functions
+ time_atm_pair_store(&g_start_time[GPR_TIMESPAN], gpr_time_0(GPR_TIMESPAN));
+}
+
+void ExecCtx::GlobalShutdown(void) {}
+
+grpc_millis ExecCtx::Now() {
+ if (!now_is_valid_) {
+ now_ = timespec_to_atm_round_down(gpr_now(GPR_CLOCK_MONOTONIC));
+ now_is_valid_ = true;
+ }
+ return now_;
+}
+
+} // namespace grpc_core
diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h
index 6035e08361..0f2ee8d4fa 100644
--- a/src/core/lib/iomgr/exec_ctx.h
+++ b/src/core/lib/iomgr/exec_ctx.h
@@ -21,6 +21,7 @@
#include <grpc/support/atm.h>
#include <grpc/support/cpu.h>
+#include <grpc/support/log.h>
#include "src/core/lib/iomgr/closure.h"
@@ -45,6 +46,7 @@ typedef struct grpc_combiner grpc_combiner;
should be given to not delete said call/channel from this exec_ctx */
#define GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP 2
+namespace grpc_core {
/** Execution context.
* A bag of data that collects information along a callstack.
* Generally created at public API entry points, and passed down as
@@ -65,66 +67,132 @@ typedef struct grpc_combiner grpc_combiner;
* - Instances are always passed as the first argument to a function that
* takes it, and always as a pointer (grpc_exec_ctx is never copied).
*/
-struct grpc_exec_ctx {
- grpc_closure_list closure_list;
- /** currently active combiner: updated only via combiner.c */
- grpc_combiner* active_combiner;
- /** last active combiner in the active combiner list */
- grpc_combiner* last_combiner;
- uintptr_t flags;
- unsigned starting_cpu;
- void* check_ready_to_finish_arg;
- bool (*check_ready_to_finish)(grpc_exec_ctx* exec_ctx, void* arg);
-
- bool now_is_valid;
- grpc_millis now;
-};
+class ExecCtx {
+ public:
+ /** Default Constructor */
+ ExecCtx() : flags_(GRPC_EXEC_CTX_FLAG_IS_FINISHED) { exec_ctx_ = this; }
+
+ /** Parameterised Constructor */
+ ExecCtx(uintptr_t fl) : flags_(fl) { exec_ctx_ = this; }
+
+ /** Destructor */
+ ~ExecCtx() {
+ GPR_ASSERT(exec_ctx_ == this);
+ flags_ |= GRPC_EXEC_CTX_FLAG_IS_FINISHED;
+ Flush();
+ exec_ctx_ = last_exec_ctx_;
+ }
+
+ /** Disallow copy and assignment operators */
+ ExecCtx(const ExecCtx&) = delete;
+ ExecCtx& operator=(const ExecCtx&) = delete;
+
+ /** Return starting_cpu */
+ unsigned starting_cpu() const { return starting_cpu_; }
+
+ struct CombinerData {
+ /* currently active combiner: updated only via combiner.c */
+ grpc_combiner* active_combiner;
+ /* last active combiner in the active combiner list */
+ grpc_combiner* last_combiner;
+ };
+
+ /** Only to be used by grpc-combiner code */
+ CombinerData* combiner_data() { return &combiner_data_; }
+
+ /** Return pointer to grpc_closure_list */
+ grpc_closure_list* closure_list() { return &closure_list_; }
+
+ /** Return flags */
+ uintptr_t flags() { return flags_; }
+
+ /** Checks if there is work to be done */
+ bool HasWork() {
+ return combiner_data_.active_combiner != NULL ||
+ !grpc_closure_list_empty(closure_list_);
+ }
+
+ /** Flush any work that has been enqueued onto this grpc_exec_ctx.
+ * Caller must guarantee that no interfering locks are held.
+ * Returns true if work was performed, false otherwise. */
+ bool Flush();
+
+ /** Returns true if we'd like to leave this execution context as soon as
+possible: useful for deciding whether to do something more or not depending
+on outside context */
+ bool IsReadyToFinish() {
+ if ((flags_ & GRPC_EXEC_CTX_FLAG_IS_FINISHED) == 0) {
+ if (CheckReadyToFinish()) {
+ flags_ |= GRPC_EXEC_CTX_FLAG_IS_FINISHED;
+ return true;
+ }
+ return false;
+ } else {
+ return true;
+ }
+ }
-/* initializer for grpc_exec_ctx:
- prefer to use GRPC_EXEC_CTX_INIT whenever possible */
-#define GRPC_EXEC_CTX_INITIALIZER(flags, finish_check, finish_check_arg) \
- { \
- GRPC_CLOSURE_LIST_INIT, NULL, NULL, flags, gpr_cpu_current_cpu(), \
- finish_check_arg, finish_check, false, 0 \
+ /** Returns the stored current time relative to start if valid,
+ * otherwise refreshes the stored time, sets it valid and returns the new
+ * value */
+ grpc_millis Now();
+
+ /** Invalidates the stored time value. A new time value will be set on calling
+ * Now() */
+ void InvalidateNow() { now_is_valid_ = false; }
+
+ /** To be used only by shutdown code in iomgr */
+ void SetNowIomgrShutdown() {
+ now_ = GRPC_MILLIS_INF_FUTURE;
+ now_is_valid_ = true;
+ }
+
+ /** To be used only for testing.
+ * Sets the now value
+ */
+ void TestOnlySetNow(grpc_millis new_val) {
+ now_ = new_val;
+ now_is_valid_ = true;
}
-/* initialize an execution context at the top level of an API call into grpc
- (this is safe to use elsewhere, though possibly not as efficient) */
-#define GRPC_EXEC_CTX_INIT \
- GRPC_EXEC_CTX_INITIALIZER(GRPC_EXEC_CTX_FLAG_IS_FINISHED, NULL, NULL)
+ /** Finish any pending work for a grpc_exec_ctx. Must be called before
+ * the instance is destroyed, or work may be lost. */
+ void Finish();
+
+ /** Global initialization for ExecCtx. Called by iomgr */
+ static void GlobalInit(void);
+
+ /** Global shutdown for ExecCtx. Called by iomgr */
+ static void GlobalShutdown(void);
+
+ /** Gets pointer to current exec_ctx */
+ static ExecCtx* Get() { return exec_ctx_; }
+
+ protected:
+ /** Check if ready to finish */
+ virtual bool CheckReadyToFinish() { return false; }
+
+ private:
+ grpc_closure_list closure_list_ = GRPC_CLOSURE_LIST_INIT;
+ CombinerData combiner_data_ = {nullptr, nullptr};
+ uintptr_t flags_;
+ unsigned starting_cpu_ = gpr_cpu_current_cpu();
+
+ bool now_is_valid_ = false;
+ grpc_millis now_ = 0;
+
+ static thread_local ExecCtx* exec_ctx_;
+ ExecCtx* last_exec_ctx_ = exec_ctx_;
+};
+} // namespace grpc_core
extern grpc_closure_scheduler* grpc_schedule_on_exec_ctx;
-bool grpc_exec_ctx_has_work(grpc_exec_ctx* exec_ctx);
-
-/** Flush any work that has been enqueued onto this grpc_exec_ctx.
- * Caller must guarantee that no interfering locks are held.
- * Returns true if work was performed, false otherwise. */
-bool grpc_exec_ctx_flush(grpc_exec_ctx* exec_ctx);
-/** Finish any pending work for a grpc_exec_ctx. Must be called before
- * the instance is destroyed, or work may be lost. */
-void grpc_exec_ctx_finish(grpc_exec_ctx* exec_ctx);
-/** Returns true if we'd like to leave this execution context as soon as
- possible: useful for deciding whether to do something more or not depending
- on outside context */
-bool grpc_exec_ctx_ready_to_finish(grpc_exec_ctx* exec_ctx);
-/** A finish check that is never ready to finish */
-bool grpc_never_ready_to_finish(grpc_exec_ctx* exec_ctx, void* arg_ignored);
-/** A finish check that is always ready to finish */
-bool grpc_always_ready_to_finish(grpc_exec_ctx* exec_ctx, void* arg_ignored);
-
-void grpc_exec_ctx_global_init(void);
-
-void grpc_exec_ctx_global_init(void);
-void grpc_exec_ctx_global_shutdown(void);
-
-grpc_millis grpc_exec_ctx_now(grpc_exec_ctx* exec_ctx);
-void grpc_exec_ctx_invalidate_now(grpc_exec_ctx* exec_ctx);
gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_clock_type clock);
grpc_millis grpc_timespec_to_millis_round_down(gpr_timespec timespec);
grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec timespec);
-void grpc_exec_ctx_maybe_update_start_time(grpc_exec_ctx* exec_ctx);
+void grpc_exec_ctx_maybe_update_start_time();
#ifdef __cplusplus
}
diff --git a/src/core/lib/iomgr/executor.cc b/src/core/lib/iomgr/executor.cc
index 6097d66024..12f336cb37 100644
--- a/src/core/lib/iomgr/executor.cc
+++ b/src/core/lib/iomgr/executor.cc
@@ -56,7 +56,7 @@ static grpc_tracer_flag executor_trace =
static void executor_thread(void* arg);
-static size_t run_closures(grpc_exec_ctx* exec_ctx, grpc_closure_list list) {
+static size_t run_closures(grpc_closure_list list) {
size_t n = 0;
grpc_closure* c = list.head;
@@ -74,11 +74,11 @@ static size_t run_closures(grpc_exec_ctx* exec_ctx, grpc_closure_list list) {
#ifndef NDEBUG
c->scheduled = false;
#endif
- c->cb(exec_ctx, c->cb_arg, error);
+ c->cb(c->cb_arg, error);
GRPC_ERROR_UNREF(error);
c = next;
n++;
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
}
return n;
@@ -88,7 +88,7 @@ bool grpc_executor_is_threaded() {
return gpr_atm_no_barrier_load(&g_cur_threads) > 0;
}
-void grpc_executor_set_threading(grpc_exec_ctx* exec_ctx, bool threading) {
+void grpc_executor_set_threading(bool threading) {
gpr_atm cur_threads = gpr_atm_no_barrier_load(&g_cur_threads);
if (threading) {
if (cur_threads > 0) return;
@@ -126,29 +126,26 @@ void grpc_executor_set_threading(grpc_exec_ctx* exec_ctx, bool threading) {
for (size_t i = 0; i < g_max_threads; i++) {
gpr_mu_destroy(&g_thread_state[i].mu);
gpr_cv_destroy(&g_thread_state[i].cv);
- run_closures(exec_ctx, g_thread_state[i].elems);
+ run_closures(g_thread_state[i].elems);
}
gpr_free(g_thread_state);
gpr_tls_destroy(&g_this_thread_state);
}
}
-void grpc_executor_init(grpc_exec_ctx* exec_ctx) {
+void grpc_executor_init() {
grpc_register_tracer(&executor_trace);
gpr_atm_no_barrier_store(&g_cur_threads, 0);
- grpc_executor_set_threading(exec_ctx, true);
+ grpc_executor_set_threading(true);
}
-void grpc_executor_shutdown(grpc_exec_ctx* exec_ctx) {
- grpc_executor_set_threading(exec_ctx, false);
-}
+void grpc_executor_shutdown() { grpc_executor_set_threading(false); }
static void executor_thread(void* arg) {
thread_state* ts = (thread_state*)arg;
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, nullptr);
+ grpc_core::ExecCtx _local_exec_ctx(0);
size_t subtract_depth = 0;
for (;;) {
@@ -170,7 +167,7 @@ static void executor_thread(void* arg) {
gpr_mu_unlock(&ts->mu);
break;
}
- GRPC_STATS_INC_EXECUTOR_QUEUE_DRAINED(&exec_ctx);
+ GRPC_STATS_INC_EXECUTOR_QUEUE_DRAINED();
grpc_closure_list exec = ts->elems;
ts->elems = GRPC_CLOSURE_LIST_INIT;
gpr_mu_unlock(&ts->mu);
@@ -178,19 +175,18 @@ static void executor_thread(void* arg) {
gpr_log(GPR_DEBUG, "EXECUTOR[%d]: execute", (int)(ts - g_thread_state));
}
- grpc_exec_ctx_invalidate_now(&exec_ctx);
- subtract_depth = run_closures(&exec_ctx, exec);
+ grpc_core::ExecCtx::Get()->InvalidateNow();
+ subtract_depth = run_closures(exec);
}
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void executor_push(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
- grpc_error* error, bool is_short) {
+static void executor_push(grpc_closure* closure, grpc_error* error,
+ bool is_short) {
bool retry_push;
if (is_short) {
- GRPC_STATS_INC_EXECUTOR_SCHEDULED_SHORT_ITEMS(exec_ctx);
+ GRPC_STATS_INC_EXECUTOR_SCHEDULED_SHORT_ITEMS();
} else {
- GRPC_STATS_INC_EXECUTOR_SCHEDULED_LONG_ITEMS(exec_ctx);
+ GRPC_STATS_INC_EXECUTOR_SCHEDULED_LONG_ITEMS();
}
do {
retry_push = false;
@@ -204,14 +200,16 @@ static void executor_push(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
gpr_log(GPR_DEBUG, "EXECUTOR: schedule %p inline", closure);
#endif
}
- grpc_closure_list_append(&exec_ctx->closure_list, closure, error);
+ grpc_closure_list_append(grpc_core::ExecCtx::Get()->closure_list(),
+ closure, error);
return;
}
thread_state* ts = (thread_state*)gpr_tls_get(&g_this_thread_state);
if (ts == nullptr) {
- ts = &g_thread_state[GPR_HASH_POINTER(exec_ctx, cur_thread_count)];
+ ts = &g_thread_state[GPR_HASH_POINTER(grpc_core::ExecCtx::Get(),
+ cur_thread_count)];
} else {
- GRPC_STATS_INC_EXECUTOR_SCHEDULED_TO_SELF(exec_ctx);
+ GRPC_STATS_INC_EXECUTOR_SCHEDULED_TO_SELF();
}
thread_state* orig_ts = ts;
@@ -247,7 +245,7 @@ static void executor_push(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
continue;
}
if (grpc_closure_list_empty(ts->elems)) {
- GRPC_STATS_INC_EXECUTOR_WAKEUP_INITIATED(exec_ctx);
+ GRPC_STATS_INC_EXECUTOR_WAKEUP_INITIATED();
gpr_cv_signal(&ts->cv);
}
grpc_closure_list_append(&ts->elems, closure, error);
@@ -271,19 +269,17 @@ static void executor_push(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
gpr_spinlock_unlock(&g_adding_thread_lock);
}
if (retry_push) {
- GRPC_STATS_INC_EXECUTOR_PUSH_RETRIES(exec_ctx);
+ GRPC_STATS_INC_EXECUTOR_PUSH_RETRIES();
}
} while (retry_push);
}
-static void executor_push_short(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
- grpc_error* error) {
- executor_push(exec_ctx, closure, error, true);
+static void executor_push_short(grpc_closure* closure, grpc_error* error) {
+ executor_push(closure, error, true);
}
-static void executor_push_long(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
- grpc_error* error) {
- executor_push(exec_ctx, closure, error, false);
+static void executor_push_long(grpc_closure* closure, grpc_error* error) {
+ executor_push(closure, error, false);
}
static const grpc_closure_scheduler_vtable executor_vtable_short = {
diff --git a/src/core/lib/iomgr/executor.h b/src/core/lib/iomgr/executor.h
index 8418ace06e..4f21f853f0 100644
--- a/src/core/lib/iomgr/executor.h
+++ b/src/core/lib/iomgr/executor.h
@@ -35,19 +35,19 @@ typedef enum {
* This mechanism is meant to outsource work (grpc_closure instances) to a
* thread, for those cases where blocking isn't an option but there isn't a
* non-blocking solution available. */
-void grpc_executor_init(grpc_exec_ctx* exec_ctx);
+void grpc_executor_init();
grpc_closure_scheduler* grpc_executor_scheduler(grpc_executor_job_length);
/** Shutdown the executor, running all pending work as part of the call */
-void grpc_executor_shutdown(grpc_exec_ctx* exec_ctx);
+void grpc_executor_shutdown();
/** Is the executor multi-threaded? */
bool grpc_executor_is_threaded();
/* enable/disable threading - must be called after grpc_executor_init and before
grpc_executor_shutdown */
-void grpc_executor_set_threading(grpc_exec_ctx* exec_ctx, bool enable);
+void grpc_executor_set_threading(bool enable);
#ifdef __cplusplus
}
diff --git a/src/core/lib/iomgr/iocp_windows.cc b/src/core/lib/iomgr/iocp_windows.cc
index 6bbe5669c7..f5c6297438 100644
--- a/src/core/lib/iomgr/iocp_windows.cc
+++ b/src/core/lib/iomgr/iocp_windows.cc
@@ -42,20 +42,18 @@ static gpr_atm g_custom_events = 0;
static HANDLE g_iocp;
-static DWORD deadline_to_millis_timeout(grpc_exec_ctx* exec_ctx,
- grpc_millis deadline) {
+static DWORD deadline_to_millis_timeout(grpc_millis deadline) {
if (deadline == GRPC_MILLIS_INF_FUTURE) {
return INFINITE;
}
- grpc_millis now = grpc_exec_ctx_now(exec_ctx);
+ grpc_millis now = grpc_core::ExecCtx::Get()->Now();
if (deadline < now) return 0;
grpc_millis timeout = deadline - now;
if (timeout > std::numeric_limits<DWORD>::max()) return INFINITE;
return static_cast<DWORD>(deadline - now);
}
-grpc_iocp_work_status grpc_iocp_work(grpc_exec_ctx* exec_ctx,
- grpc_millis deadline) {
+grpc_iocp_work_status grpc_iocp_work(grpc_millis deadline) {
BOOL success;
DWORD bytes = 0;
DWORD flags = 0;
@@ -63,11 +61,11 @@ grpc_iocp_work_status grpc_iocp_work(grpc_exec_ctx* exec_ctx,
LPOVERLAPPED overlapped;
grpc_winsocket* socket;
grpc_winsocket_callback_info* info;
- GRPC_STATS_INC_SYSCALL_POLL(exec_ctx);
+ GRPC_STATS_INC_SYSCALL_POLL();
success =
GetQueuedCompletionStatus(g_iocp, &bytes, &completion_key, &overlapped,
- deadline_to_millis_timeout(exec_ctx, deadline));
- grpc_exec_ctx_invalidate_now(exec_ctx);
+ deadline_to_millis_timeout(deadline));
+ grpc_core::ExecCtx::Get()->InvalidateNow();
if (success == 0 && overlapped == NULL) {
return GRPC_IOCP_WORK_TIMEOUT;
}
@@ -95,7 +93,7 @@ grpc_iocp_work_status grpc_iocp_work(grpc_exec_ctx* exec_ctx,
info->bytes_transfered = bytes;
info->wsa_error = success ? 0 : WSAGetLastError();
GPR_ASSERT(overlapped == &info->overlapped);
- grpc_socket_become_ready(exec_ctx, socket, info);
+ grpc_socket_become_ready(socket, info);
return GRPC_IOCP_WORK_WORK;
}
@@ -115,22 +113,22 @@ void grpc_iocp_kick(void) {
}
void grpc_iocp_flush(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_iocp_work_status work_status;
do {
- work_status = grpc_iocp_work(&exec_ctx, GRPC_MILLIS_INF_PAST);
+ work_status = grpc_iocp_work(GRPC_MILLIS_INF_PAST);
} while (work_status == GRPC_IOCP_WORK_KICK ||
- grpc_exec_ctx_flush(&exec_ctx));
+ grpc_core::ExecCtx::Get()->Flush());
}
void grpc_iocp_shutdown(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (gpr_atm_acq_load(&g_custom_events)) {
- grpc_iocp_work(&exec_ctx, GRPC_MILLIS_INF_FUTURE);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_iocp_work(GRPC_MILLIS_INF_FUTURE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
GPR_ASSERT(CloseHandle(g_iocp));
}
diff --git a/src/core/lib/iomgr/iocp_windows.h b/src/core/lib/iomgr/iocp_windows.h
index d112c50538..4e6f6ed106 100644
--- a/src/core/lib/iomgr/iocp_windows.h
+++ b/src/core/lib/iomgr/iocp_windows.h
@@ -37,8 +37,7 @@ typedef enum {
GRPC_IOCP_WORK_KICK
} grpc_iocp_work_status;
-grpc_iocp_work_status grpc_iocp_work(grpc_exec_ctx* exec_ctx,
- grpc_millis deadline);
+grpc_iocp_work_status grpc_iocp_work(grpc_millis deadline);
void grpc_iocp_init(void);
void grpc_iocp_kick(void);
void grpc_iocp_flush(void);
diff --git a/src/core/lib/iomgr/iomgr.cc b/src/core/lib/iomgr/iomgr.cc
index e077b35014..f3f080e315 100644
--- a/src/core/lib/iomgr/iomgr.cc
+++ b/src/core/lib/iomgr/iomgr.cc
@@ -45,20 +45,20 @@ static gpr_cv g_rcv;
static int g_shutdown;
static grpc_iomgr_object g_root_object;
-void grpc_iomgr_init(grpc_exec_ctx* exec_ctx) {
+void grpc_iomgr_init() {
g_shutdown = 0;
gpr_mu_init(&g_mu);
gpr_cv_init(&g_rcv);
- grpc_exec_ctx_global_init();
- grpc_executor_init(exec_ctx);
- grpc_timer_list_init(exec_ctx);
+ grpc_core::ExecCtx::GlobalInit();
+ grpc_executor_init();
+ grpc_timer_list_init();
g_root_object.next = g_root_object.prev = &g_root_object;
g_root_object.name = (char*)"root";
grpc_network_status_init();
grpc_iomgr_platform_init();
}
-void grpc_iomgr_start(grpc_exec_ctx* exec_ctx) { grpc_timer_manager_init(); }
+void grpc_iomgr_start() { grpc_timer_manager_init(); }
static size_t count_objects(void) {
grpc_iomgr_object* obj;
@@ -76,14 +76,14 @@ static void dump_objects(const char* kind) {
}
}
-void grpc_iomgr_shutdown(grpc_exec_ctx* exec_ctx) {
+void grpc_iomgr_shutdown() {
gpr_timespec shutdown_deadline = gpr_time_add(
gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(10, GPR_TIMESPAN));
gpr_timespec last_warning_time = gpr_now(GPR_CLOCK_REALTIME);
grpc_timer_manager_shutdown();
grpc_iomgr_platform_flush();
- grpc_executor_shutdown(exec_ctx);
+ grpc_executor_shutdown();
gpr_mu_lock(&g_mu);
g_shutdown = 1;
@@ -98,11 +98,10 @@ void grpc_iomgr_shutdown(grpc_exec_ctx* exec_ctx) {
}
last_warning_time = gpr_now(GPR_CLOCK_REALTIME);
}
- exec_ctx->now_is_valid = true;
- exec_ctx->now = GRPC_MILLIS_INF_FUTURE;
- if (grpc_timer_check(exec_ctx, nullptr) == GRPC_TIMERS_FIRED) {
+ grpc_core::ExecCtx::Get()->SetNowIomgrShutdown();
+ if (grpc_timer_check(nullptr) == GRPC_TIMERS_FIRED) {
gpr_mu_unlock(&g_mu);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
grpc_iomgr_platform_flush();
gpr_mu_lock(&g_mu);
continue;
@@ -136,15 +135,15 @@ void grpc_iomgr_shutdown(grpc_exec_ctx* exec_ctx) {
}
gpr_mu_unlock(&g_mu);
- grpc_timer_list_shutdown(exec_ctx);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_timer_list_shutdown();
+ grpc_core::ExecCtx::Get()->Flush();
/* ensure all threads have left g_mu */
gpr_mu_lock(&g_mu);
gpr_mu_unlock(&g_mu);
grpc_iomgr_platform_shutdown();
- grpc_exec_ctx_global_shutdown();
+ grpc_core::ExecCtx::GlobalShutdown();
grpc_network_status_shutdown();
gpr_mu_destroy(&g_mu);
gpr_cv_destroy(&g_rcv);
diff --git a/src/core/lib/iomgr/iomgr.h b/src/core/lib/iomgr/iomgr.h
index d1549c8c63..ce9f60521c 100644
--- a/src/core/lib/iomgr/iomgr.h
+++ b/src/core/lib/iomgr/iomgr.h
@@ -27,14 +27,14 @@ extern "C" {
#endif
/** Initializes the iomgr. */
-void grpc_iomgr_init(grpc_exec_ctx* exec_ctx);
+void grpc_iomgr_init();
/** Starts any background threads for iomgr. */
-void grpc_iomgr_start(grpc_exec_ctx* exec_ctx);
+void grpc_iomgr_start();
/** Signals the intention to shutdown the iomgr. Expects to be able to flush
* exec_ctx. */
-void grpc_iomgr_shutdown(grpc_exec_ctx* exec_ctx);
+void grpc_iomgr_shutdown();
#ifdef __cplusplus
}
diff --git a/src/core/lib/iomgr/iomgr_uv.cc b/src/core/lib/iomgr/iomgr_uv.cc
index df5d23af3b..5823bb7ec2 100644
--- a/src/core/lib/iomgr/iomgr_uv.cc
+++ b/src/core/lib/iomgr/iomgr_uv.cc
@@ -29,12 +29,11 @@
gpr_thd_id g_init_thread;
void grpc_iomgr_platform_init(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_pollset_global_init();
grpc_register_tracer(&grpc_tcp_trace);
- grpc_executor_set_threading(&exec_ctx, false);
+ grpc_executor_set_threading(false);
g_init_thread = gpr_thd_currentid();
- grpc_exec_ctx_finish(&exec_ctx);
}
void grpc_iomgr_platform_flush(void) {}
void grpc_iomgr_platform_shutdown(void) { grpc_pollset_global_shutdown(); }
diff --git a/src/core/lib/iomgr/load_file.cc b/src/core/lib/iomgr/load_file.cc
index 4a05de1410..03ed98f3ba 100644
--- a/src/core/lib/iomgr/load_file.cc
+++ b/src/core/lib/iomgr/load_file.cc
@@ -73,6 +73,6 @@ end:
GRPC_ERROR_UNREF(error);
error = error_out;
}
- GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX;
+ GRPC_SCHEDULING_END_BLOCKING_REGION;
return error;
}
diff --git a/src/core/lib/iomgr/lockfree_event.cc b/src/core/lib/iomgr/lockfree_event.cc
index 40e2ed6219..288e597c29 100644
--- a/src/core/lib/iomgr/lockfree_event.cc
+++ b/src/core/lib/iomgr/lockfree_event.cc
@@ -83,7 +83,7 @@ LockfreeEvent::~LockfreeEvent() {
kShutdownBit /* shutdown, no error */));
}
-void LockfreeEvent::NotifyOn(grpc_exec_ctx* exec_ctx, grpc_closure* closure) {
+void LockfreeEvent::NotifyOn(grpc_closure* closure) {
while (true) {
gpr_atm curr = gpr_atm_no_barrier_load(&state_);
if (GRPC_TRACER_ON(grpc_polling_trace)) {
@@ -116,7 +116,7 @@ void LockfreeEvent::NotifyOn(grpc_exec_ctx* exec_ctx, grpc_closure* closure) {
closure when transitioning out of CLOSURE_NO_READY state (i.e there
is no other code that needs to 'happen-after' this) */
if (gpr_atm_no_barrier_cas(&state_, kClosureReady, kClosureNotReady)) {
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
return; /* Successful. Return */
}
@@ -129,7 +129,7 @@ void LockfreeEvent::NotifyOn(grpc_exec_ctx* exec_ctx, grpc_closure* closure) {
schedule the closure with the shutdown error */
if ((curr & kShutdownBit) > 0) {
grpc_error* shutdown_err = (grpc_error*)(curr & ~kShutdownBit);
- GRPC_CLOSURE_SCHED(exec_ctx, closure,
+ GRPC_CLOSURE_SCHED(closure,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"FD Shutdown", &shutdown_err, 1));
return;
@@ -147,8 +147,7 @@ void LockfreeEvent::NotifyOn(grpc_exec_ctx* exec_ctx, grpc_closure* closure) {
GPR_UNREACHABLE_CODE(return );
}
-bool LockfreeEvent::SetShutdown(grpc_exec_ctx* exec_ctx,
- grpc_error* shutdown_err) {
+bool LockfreeEvent::SetShutdown(grpc_error* shutdown_err) {
gpr_atm new_state = (gpr_atm)shutdown_err | kShutdownBit;
while (true) {
@@ -182,7 +181,7 @@ bool LockfreeEvent::SetShutdown(grpc_exec_ctx* exec_ctx,
happens-after on that edge), and a release to pair with anything
loading the shutdown state. */
if (gpr_atm_full_cas(&state_, curr, new_state)) {
- GRPC_CLOSURE_SCHED(exec_ctx, (grpc_closure*)curr,
+ GRPC_CLOSURE_SCHED((grpc_closure*)curr,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"FD Shutdown", &shutdown_err, 1));
return true;
@@ -198,7 +197,7 @@ bool LockfreeEvent::SetShutdown(grpc_exec_ctx* exec_ctx,
GPR_UNREACHABLE_CODE(return false);
}
-void LockfreeEvent::SetReady(grpc_exec_ctx* exec_ctx) {
+void LockfreeEvent::SetReady() {
while (true) {
gpr_atm curr = gpr_atm_no_barrier_load(&state_);
@@ -232,7 +231,7 @@ void LockfreeEvent::SetReady(grpc_exec_ctx* exec_ctx) {
spurious set_ready; release pairs with this or the acquire in
notify_on (or set_shutdown) */
else if (gpr_atm_full_cas(&state_, curr, kClosureNotReady)) {
- GRPC_CLOSURE_SCHED(exec_ctx, (grpc_closure*)curr, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED((grpc_closure*)curr, GRPC_ERROR_NONE);
return;
}
/* else the state changed again (only possible by either a racing
diff --git a/src/core/lib/iomgr/lockfree_event.h b/src/core/lib/iomgr/lockfree_event.h
index c667dcd3bc..70fa1ac89d 100644
--- a/src/core/lib/iomgr/lockfree_event.h
+++ b/src/core/lib/iomgr/lockfree_event.h
@@ -39,9 +39,9 @@ class LockfreeEvent {
return (gpr_atm_no_barrier_load(&state_) & kShutdownBit) != 0;
}
- void NotifyOn(grpc_exec_ctx* exec_ctx, grpc_closure* closure);
- bool SetShutdown(grpc_exec_ctx* exec_ctx, grpc_error* error);
- void SetReady(grpc_exec_ctx* exec_ctx);
+ void NotifyOn(grpc_closure* closure);
+ bool SetShutdown(grpc_error* error);
+ void SetReady();
private:
enum State { kClosureNotReady = 0, kClosureReady = 2, kShutdownBit = 1 };
diff --git a/src/core/lib/iomgr/polling_entity.cc b/src/core/lib/iomgr/polling_entity.cc
index 0ee4ea1255..126f6f45d6 100644
--- a/src/core/lib/iomgr/polling_entity.cc
+++ b/src/core/lib/iomgr/polling_entity.cc
@@ -56,32 +56,28 @@ bool grpc_polling_entity_is_empty(const grpc_polling_entity* pollent) {
return pollent->tag == GRPC_POLLS_NONE;
}
-void grpc_polling_entity_add_to_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_polling_entity* pollent,
+void grpc_polling_entity_add_to_pollset_set(grpc_polling_entity* pollent,
grpc_pollset_set* pss_dst) {
if (pollent->tag == GRPC_POLLS_POLLSET) {
GPR_ASSERT(pollent->pollent.pollset != nullptr);
- grpc_pollset_set_add_pollset(exec_ctx, pss_dst, pollent->pollent.pollset);
+ grpc_pollset_set_add_pollset(pss_dst, pollent->pollent.pollset);
} else if (pollent->tag == GRPC_POLLS_POLLSET_SET) {
GPR_ASSERT(pollent->pollent.pollset_set != nullptr);
- grpc_pollset_set_add_pollset_set(exec_ctx, pss_dst,
- pollent->pollent.pollset_set);
+ grpc_pollset_set_add_pollset_set(pss_dst, pollent->pollent.pollset_set);
} else {
gpr_log(GPR_ERROR, "Invalid grpc_polling_entity tag '%d'", pollent->tag);
abort();
}
}
-void grpc_polling_entity_del_from_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_polling_entity* pollent,
+void grpc_polling_entity_del_from_pollset_set(grpc_polling_entity* pollent,
grpc_pollset_set* pss_dst) {
if (pollent->tag == GRPC_POLLS_POLLSET) {
GPR_ASSERT(pollent->pollent.pollset != nullptr);
- grpc_pollset_set_del_pollset(exec_ctx, pss_dst, pollent->pollent.pollset);
+ grpc_pollset_set_del_pollset(pss_dst, pollent->pollent.pollset);
} else if (pollent->tag == GRPC_POLLS_POLLSET_SET) {
GPR_ASSERT(pollent->pollent.pollset_set != nullptr);
- grpc_pollset_set_del_pollset_set(exec_ctx, pss_dst,
- pollent->pollent.pollset_set);
+ grpc_pollset_set_del_pollset_set(pss_dst, pollent->pollent.pollset_set);
} else {
gpr_log(GPR_ERROR, "Invalid grpc_polling_entity tag '%d'", pollent->tag);
abort();
diff --git a/src/core/lib/iomgr/polling_entity.h b/src/core/lib/iomgr/polling_entity.h
index 867e085153..6861acfb6d 100644
--- a/src/core/lib/iomgr/polling_entity.h
+++ b/src/core/lib/iomgr/polling_entity.h
@@ -59,14 +59,12 @@ bool grpc_polling_entity_is_empty(const grpc_polling_entity* pollent);
/** Add the pollset or pollset_set in \a pollent to the destination pollset_set
* \a * pss_dst */
-void grpc_polling_entity_add_to_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_polling_entity* pollent,
+void grpc_polling_entity_add_to_pollset_set(grpc_polling_entity* pollent,
grpc_pollset_set* pss_dst);
/** Delete the pollset or pollset_set in \a pollent from the destination
* pollset_set \a * pss_dst */
-void grpc_polling_entity_del_from_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_polling_entity* pollent,
+void grpc_polling_entity_del_from_pollset_set(grpc_polling_entity* pollent,
grpc_pollset_set* pss_dst);
#ifdef __cplusplus
}
diff --git a/src/core/lib/iomgr/pollset.h b/src/core/lib/iomgr/pollset.h
index c99b930e8e..0645c7d919 100644
--- a/src/core/lib/iomgr/pollset.h
+++ b/src/core/lib/iomgr/pollset.h
@@ -48,9 +48,8 @@ size_t grpc_pollset_size(void);
void grpc_pollset_init(grpc_pollset* pollset, gpr_mu** mu);
/* Begin shutting down the pollset, and call closure when done.
* pollset's mutex must be held */
-void grpc_pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- grpc_closure* closure);
-void grpc_pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset);
+void grpc_pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure);
+void grpc_pollset_destroy(grpc_pollset* pollset);
/* Do some work on a pollset.
May involve invoking asynchronous callbacks, or actually polling file
@@ -74,13 +73,13 @@ void grpc_pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset);
May call grpc_closure_list_run on grpc_closure_list, without holding the
pollset
lock */
-grpc_error* grpc_pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
+grpc_error* grpc_pollset_work(grpc_pollset* pollset,
grpc_pollset_worker** worker,
grpc_millis deadline) GRPC_MUST_USE_RESULT;
/* Break one polling thread out of polling work for this pollset.
If specific_worker is non-NULL, then kick that worker. */
-grpc_error* grpc_pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
+grpc_error* grpc_pollset_kick(grpc_pollset* pollset,
grpc_pollset_worker* specific_worker)
GRPC_MUST_USE_RESULT;
diff --git a/src/core/lib/iomgr/pollset_set.h b/src/core/lib/iomgr/pollset_set.h
index 0167a50a56..4aa1a5977e 100644
--- a/src/core/lib/iomgr/pollset_set.h
+++ b/src/core/lib/iomgr/pollset_set.h
@@ -33,19 +33,14 @@ extern "C" {
typedef struct grpc_pollset_set grpc_pollset_set;
grpc_pollset_set* grpc_pollset_set_create(void);
-void grpc_pollset_set_destroy(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set);
-void grpc_pollset_set_add_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set,
+void grpc_pollset_set_destroy(grpc_pollset_set* pollset_set);
+void grpc_pollset_set_add_pollset(grpc_pollset_set* pollset_set,
grpc_pollset* pollset);
-void grpc_pollset_set_del_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set,
+void grpc_pollset_set_del_pollset(grpc_pollset_set* pollset_set,
grpc_pollset* pollset);
-void grpc_pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+void grpc_pollset_set_add_pollset_set(grpc_pollset_set* bag,
grpc_pollset_set* item);
-void grpc_pollset_set_del_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+void grpc_pollset_set_del_pollset_set(grpc_pollset_set* bag,
grpc_pollset_set* item);
#ifdef __cplusplus
diff --git a/src/core/lib/iomgr/pollset_set_uv.cc b/src/core/lib/iomgr/pollset_set_uv.cc
index 90186edbb7..ac5dade8a5 100644
--- a/src/core/lib/iomgr/pollset_set_uv.cc
+++ b/src/core/lib/iomgr/pollset_set_uv.cc
@@ -26,23 +26,18 @@ grpc_pollset_set* grpc_pollset_set_create(void) {
return (grpc_pollset_set*)((intptr_t)0xdeafbeef);
}
-void grpc_pollset_set_destroy(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set) {}
+void grpc_pollset_set_destroy(grpc_pollset_set* pollset_set) {}
-void grpc_pollset_set_add_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set,
+void grpc_pollset_set_add_pollset(grpc_pollset_set* pollset_set,
grpc_pollset* pollset) {}
-void grpc_pollset_set_del_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set,
+void grpc_pollset_set_del_pollset(grpc_pollset_set* pollset_set,
grpc_pollset* pollset) {}
-void grpc_pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+void grpc_pollset_set_add_pollset_set(grpc_pollset_set* bag,
grpc_pollset_set* item) {}
-void grpc_pollset_set_del_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+void grpc_pollset_set_del_pollset_set(grpc_pollset_set* bag,
grpc_pollset_set* item) {}
#endif /* GRPC_UV */
diff --git a/src/core/lib/iomgr/pollset_set_windows.cc b/src/core/lib/iomgr/pollset_set_windows.cc
index 2105a47ad4..85edc9dee1 100644
--- a/src/core/lib/iomgr/pollset_set_windows.cc
+++ b/src/core/lib/iomgr/pollset_set_windows.cc
@@ -27,23 +27,18 @@ grpc_pollset_set* grpc_pollset_set_create(void) {
return (grpc_pollset_set*)((intptr_t)0xdeafbeef);
}
-void grpc_pollset_set_destroy(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set) {}
+void grpc_pollset_set_destroy(grpc_pollset_set* pollset_set) {}
-void grpc_pollset_set_add_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set,
+void grpc_pollset_set_add_pollset(grpc_pollset_set* pollset_set,
grpc_pollset* pollset) {}
-void grpc_pollset_set_del_pollset(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* pollset_set,
+void grpc_pollset_set_del_pollset(grpc_pollset_set* pollset_set,
grpc_pollset* pollset) {}
-void grpc_pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+void grpc_pollset_set_add_pollset_set(grpc_pollset_set* bag,
grpc_pollset_set* item) {}
-void grpc_pollset_set_del_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_pollset_set* bag,
+void grpc_pollset_set_del_pollset_set(grpc_pollset_set* bag,
grpc_pollset_set* item) {}
#endif /* GRPC_WINSOCK_SOCKET */
diff --git a/src/core/lib/iomgr/pollset_uv.cc b/src/core/lib/iomgr/pollset_uv.cc
index 1d54942c1d..89d28a0f9d 100644
--- a/src/core/lib/iomgr/pollset_uv.cc
+++ b/src/core/lib/iomgr/pollset_uv.cc
@@ -91,8 +91,7 @@ void grpc_pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
pollset->shutting_down = 0;
}
-void grpc_pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- grpc_closure* closure) {
+void grpc_pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
GPR_ASSERT(!pollset->shutting_down);
GRPC_UV_ASSERT_SAME_THREAD();
pollset->shutting_down = 1;
@@ -103,10 +102,10 @@ void grpc_pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
// kick the loop once
uv_timer_start(dummy_uv_handle, dummy_timer_cb, 0, 0);
}
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
}
-void grpc_pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) {
+void grpc_pollset_destroy(grpc_pollset* pollset) {
GRPC_UV_ASSERT_SAME_THREAD();
uv_close((uv_handle_t*)pollset->timer, timer_close_cb);
// timer.data is a boolean indicating that the timer has finished closing
@@ -118,14 +117,14 @@ void grpc_pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) {
}
}
-grpc_error* grpc_pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
+grpc_error* grpc_pollset_work(grpc_pollset* pollset,
grpc_pollset_worker** worker_hdl,
grpc_millis deadline) {
uint64_t timeout;
GRPC_UV_ASSERT_SAME_THREAD();
gpr_mu_unlock(&grpc_polling_mu);
if (grpc_pollset_work_run_loop) {
- grpc_millis now = grpc_exec_ctx_now(exec_ctx);
+ grpc_millis now = grpc_core::ExecCtx::Get()->Now();
if (deadline >= now) {
timeout = deadline - now;
} else {
@@ -144,13 +143,13 @@ grpc_error* grpc_pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
}
}
if (!grpc_closure_list_empty(exec_ctx->closure_list)) {
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
}
gpr_mu_lock(&grpc_polling_mu);
return GRPC_ERROR_NONE;
}
-grpc_error* grpc_pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
+grpc_error* grpc_pollset_kick(grpc_pollset* pollset,
grpc_pollset_worker* specific_worker) {
GRPC_UV_ASSERT_SAME_THREAD();
uv_timer_start(dummy_uv_handle, dummy_timer_cb, 0, 0);
diff --git a/src/core/lib/iomgr/pollset_windows.cc b/src/core/lib/iomgr/pollset_windows.cc
index 5998b3f5bc..81e1d009ca 100644
--- a/src/core/lib/iomgr/pollset_windows.cc
+++ b/src/core/lib/iomgr/pollset_windows.cc
@@ -95,20 +95,19 @@ void grpc_pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
&pollset->root_worker;
}
-void grpc_pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- grpc_closure* closure) {
+void grpc_pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
pollset->shutting_down = 1;
- grpc_pollset_kick(exec_ctx, pollset, GRPC_POLLSET_KICK_BROADCAST);
+ grpc_pollset_kick(pollset, GRPC_POLLSET_KICK_BROADCAST);
if (!pollset->is_iocp_worker) {
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
} else {
pollset->on_shutdown = closure;
}
}
-void grpc_pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) {}
+void grpc_pollset_destroy(grpc_pollset* pollset) {}
-grpc_error* grpc_pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
+grpc_error* grpc_pollset_work(grpc_pollset* pollset,
grpc_pollset_worker** worker_hdl,
grpc_millis deadline) {
grpc_pollset_worker worker;
@@ -129,8 +128,8 @@ grpc_error* grpc_pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
pollset->is_iocp_worker = 1;
g_active_poller = &worker;
gpr_mu_unlock(&grpc_polling_mu);
- grpc_iocp_work(exec_ctx, deadline);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_iocp_work(deadline);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&grpc_polling_mu);
pollset->is_iocp_worker = 0;
g_active_poller = NULL;
@@ -148,7 +147,7 @@ grpc_error* grpc_pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
}
if (pollset->shutting_down && pollset->on_shutdown != NULL) {
- GRPC_CLOSURE_SCHED(exec_ctx, pollset->on_shutdown, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(pollset->on_shutdown, GRPC_ERROR_NONE);
pollset->on_shutdown = NULL;
}
goto done;
@@ -161,10 +160,10 @@ grpc_error* grpc_pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
while (!worker.kicked) {
if (gpr_cv_wait(&worker.cv, &grpc_polling_mu,
grpc_millis_to_timespec(deadline, GPR_CLOCK_REALTIME))) {
- grpc_exec_ctx_invalidate_now(exec_ctx);
+ grpc_core::ExecCtx::Get()->InvalidateNow();
break;
}
- grpc_exec_ctx_invalidate_now(exec_ctx);
+ grpc_core::ExecCtx::Get()->InvalidateNow();
}
} else {
pollset->kicked_without_pollers = 0;
@@ -172,7 +171,7 @@ grpc_error* grpc_pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
done:
if (!grpc_closure_list_empty(exec_ctx->closure_list)) {
gpr_mu_unlock(&grpc_polling_mu);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&grpc_polling_mu);
}
if (added_worker) {
@@ -184,7 +183,7 @@ done:
return GRPC_ERROR_NONE;
}
-grpc_error* grpc_pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* p,
+grpc_error* grpc_pollset_kick(grpc_pollset* p,
grpc_pollset_worker* specific_worker) {
if (specific_worker != NULL) {
if (specific_worker == GRPC_POLLSET_KICK_BROADCAST) {
@@ -212,7 +211,7 @@ grpc_error* grpc_pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* p,
specific_worker =
pop_front_worker(&p->root_worker, GRPC_POLLSET_WORKER_LINK_POLLSET);
if (specific_worker != NULL) {
- grpc_pollset_kick(exec_ctx, p, specific_worker);
+ grpc_pollset_kick(p, specific_worker);
} else if (p->is_iocp_worker) {
grpc_iocp_kick();
} else {
diff --git a/src/core/lib/iomgr/resolve_address.h b/src/core/lib/iomgr/resolve_address.h
index 847e10f177..f62f92b0bf 100644
--- a/src/core/lib/iomgr/resolve_address.h
+++ b/src/core/lib/iomgr/resolve_address.h
@@ -42,8 +42,7 @@ typedef struct {
/* Asynchronously resolve addr. Use default_port if a port isn't designated
in addr, otherwise use the port in addr. */
/* TODO(ctiller): add a timeout here */
-extern void (*grpc_resolve_address)(grpc_exec_ctx* exec_ctx, const char* addr,
- const char* default_port,
+extern void (*grpc_resolve_address)(const char* addr, const char* default_port,
grpc_pollset_set* interested_parties,
grpc_closure* on_done,
grpc_resolved_addresses** addresses);
diff --git a/src/core/lib/iomgr/resolve_address_posix.cc b/src/core/lib/iomgr/resolve_address_posix.cc
index fb5fa9d422..6c9534a291 100644
--- a/src/core/lib/iomgr/resolve_address_posix.cc
+++ b/src/core/lib/iomgr/resolve_address_posix.cc
@@ -81,7 +81,7 @@ static grpc_error* blocking_resolve_address_impl(
GRPC_SCHEDULING_START_BLOCKING_REGION;
s = getaddrinfo(host, port, &hints, &result);
- GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX;
+ GRPC_SCHEDULING_END_BLOCKING_REGION;
if (s != 0) {
/* Retry if well-known service name is recognized */
@@ -90,7 +90,7 @@ static grpc_error* blocking_resolve_address_impl(
if (strcmp(port, svc[i][0]) == 0) {
GRPC_SCHEDULING_START_BLOCKING_REGION;
s = getaddrinfo(host, svc[i][1], &hints, &result);
- GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX;
+ GRPC_SCHEDULING_END_BLOCKING_REGION;
break;
}
}
@@ -152,12 +152,10 @@ typedef struct {
/* Callback to be passed to grpc_executor to asynch-ify
* grpc_blocking_resolve_address */
-static void do_request_thread(grpc_exec_ctx* exec_ctx, void* rp,
- grpc_error* error) {
+static void do_request_thread(void* rp, grpc_error* error) {
request* r = (request*)rp;
- GRPC_CLOSURE_SCHED(
- exec_ctx, r->on_done,
- grpc_blocking_resolve_address(r->name, r->default_port, r->addrs_out));
+ GRPC_CLOSURE_SCHED(r->on_done, grpc_blocking_resolve_address(
+ r->name, r->default_port, r->addrs_out));
gpr_free(r->name);
gpr_free(r->default_port);
gpr_free(r);
@@ -170,8 +168,7 @@ void grpc_resolved_addresses_destroy(grpc_resolved_addresses* addrs) {
gpr_free(addrs);
}
-static void resolve_address_impl(grpc_exec_ctx* exec_ctx, const char* name,
- const char* default_port,
+static void resolve_address_impl(const char* name, const char* default_port,
grpc_pollset_set* interested_parties,
grpc_closure* on_done,
grpc_resolved_addresses** addrs) {
@@ -182,11 +179,11 @@ static void resolve_address_impl(grpc_exec_ctx* exec_ctx, const char* name,
r->default_port = gpr_strdup(default_port);
r->on_done = on_done;
r->addrs_out = addrs;
- GRPC_CLOSURE_SCHED(exec_ctx, &r->request_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&r->request_closure, GRPC_ERROR_NONE);
}
void (*grpc_resolve_address)(
- grpc_exec_ctx* exec_ctx, const char* name, const char* default_port,
+ const char* name, const char* default_port,
grpc_pollset_set* interested_parties, grpc_closure* on_done,
grpc_resolved_addresses** addrs) = resolve_address_impl;
diff --git a/src/core/lib/iomgr/resolve_address_uv.cc b/src/core/lib/iomgr/resolve_address_uv.cc
index 6d09fd1d02..54adf9b9f6 100644
--- a/src/core/lib/iomgr/resolve_address_uv.cc
+++ b/src/core/lib/iomgr/resolve_address_uv.cc
@@ -114,7 +114,7 @@ static grpc_error* handle_addrinfo_result(int status, struct addrinfo* result,
static void getaddrinfo_callback(uv_getaddrinfo_t* req, int status,
struct addrinfo* res) {
request* r = (request*)req->data;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_error* error;
int retry_status;
char* port = r->port;
@@ -130,8 +130,8 @@ static void getaddrinfo_callback(uv_getaddrinfo_t* req, int status,
/* Either no retry was attempted, or the retry failed. Either way, the
original error probably has more interesting information */
error = handle_addrinfo_result(status, res, r->addresses);
- GRPC_CLOSURE_SCHED(&exec_ctx, r->on_done, error);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_CLOSURE_SCHED(r->on_done, error);
+
gpr_free(r->hints);
gpr_free(r->host);
gpr_free(r->port);
@@ -224,8 +224,7 @@ void grpc_resolved_addresses_destroy(grpc_resolved_addresses* addrs) {
gpr_free(addrs);
}
-static void resolve_address_impl(grpc_exec_ctx* exec_ctx, const char* name,
- const char* default_port,
+static void resolve_address_impl(const char* name, const char* default_port,
grpc_pollset_set* interested_parties,
grpc_closure* on_done,
grpc_resolved_addresses** addrs) {
@@ -239,7 +238,7 @@ static void resolve_address_impl(grpc_exec_ctx* exec_ctx, const char* name,
GRPC_UV_ASSERT_SAME_THREAD();
err = try_split_host_port(name, default_port, &host, &port);
if (err != GRPC_ERROR_NONE) {
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, err);
+ GRPC_CLOSURE_SCHED(on_done, err);
gpr_free(host);
gpr_free(port);
return;
@@ -268,7 +267,7 @@ static void resolve_address_impl(grpc_exec_ctx* exec_ctx, const char* name,
err = GRPC_ERROR_CREATE_FROM_STATIC_STRING("getaddrinfo failed");
err = grpc_error_set_str(err, GRPC_ERROR_STR_OS_ERROR,
grpc_slice_from_static_string(uv_strerror(s)));
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, err);
+ GRPC_CLOSURE_SCHED(on_done, err);
gpr_free(r);
gpr_free(req);
gpr_free(hints);
@@ -278,7 +277,7 @@ static void resolve_address_impl(grpc_exec_ctx* exec_ctx, const char* name,
}
void (*grpc_resolve_address)(
- grpc_exec_ctx* exec_ctx, const char* name, const char* default_port,
+ const char* name, const char* default_port,
grpc_pollset_set* interested_parties, grpc_closure* on_done,
grpc_resolved_addresses** addrs) = resolve_address_impl;
diff --git a/src/core/lib/iomgr/resolve_address_windows.cc b/src/core/lib/iomgr/resolve_address_windows.cc
index d9fc17a9f4..4e2bc7b5ca 100644
--- a/src/core/lib/iomgr/resolve_address_windows.cc
+++ b/src/core/lib/iomgr/resolve_address_windows.cc
@@ -87,7 +87,7 @@ static grpc_error* blocking_resolve_address_impl(
GRPC_SCHEDULING_START_BLOCKING_REGION;
s = getaddrinfo(host, port, &hints, &result);
- GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX;
+ GRPC_SCHEDULING_END_BLOCKING_REGION;
if (s != 0) {
error = GRPC_WSA_ERROR(WSAGetLastError(), "getaddrinfo");
goto done;
@@ -132,8 +132,7 @@ grpc_error* (*grpc_blocking_resolve_address)(
/* Callback to be passed to grpc_executor to asynch-ify
* grpc_blocking_resolve_address */
-static void do_request_thread(grpc_exec_ctx* exec_ctx, void* rp,
- grpc_error* error) {
+static void do_request_thread(void* rp, grpc_error* error) {
request* r = (request*)rp;
if (error == GRPC_ERROR_NONE) {
error =
@@ -141,7 +140,7 @@ static void do_request_thread(grpc_exec_ctx* exec_ctx, void* rp,
} else {
GRPC_ERROR_REF(error);
}
- GRPC_CLOSURE_SCHED(exec_ctx, r->on_done, error);
+ GRPC_CLOSURE_SCHED(r->on_done, error);
gpr_free(r->name);
gpr_free(r->default_port);
gpr_free(r);
@@ -154,8 +153,7 @@ void grpc_resolved_addresses_destroy(grpc_resolved_addresses* addrs) {
gpr_free(addrs);
}
-static void resolve_address_impl(grpc_exec_ctx* exec_ctx, const char* name,
- const char* default_port,
+static void resolve_address_impl(const char* name, const char* default_port,
grpc_pollset_set* interested_parties,
grpc_closure* on_done,
grpc_resolved_addresses** addresses) {
@@ -166,11 +164,11 @@ static void resolve_address_impl(grpc_exec_ctx* exec_ctx, const char* name,
r->default_port = gpr_strdup(default_port);
r->on_done = on_done;
r->addresses = addresses;
- GRPC_CLOSURE_SCHED(exec_ctx, &r->request_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&r->request_closure, GRPC_ERROR_NONE);
}
void (*grpc_resolve_address)(
- grpc_exec_ctx* exec_ctx, const char* name, const char* default_port,
+ const char* name, const char* default_port,
grpc_pollset_set* interested_parties, grpc_closure* on_done,
grpc_resolved_addresses** addresses) = resolve_address_impl;
diff --git a/src/core/lib/iomgr/resource_quota.cc b/src/core/lib/iomgr/resource_quota.cc
index 9a44fa203c..819d997ce9 100644
--- a/src/core/lib/iomgr/resource_quota.cc
+++ b/src/core/lib/iomgr/resource_quota.cc
@@ -155,8 +155,7 @@ struct grpc_resource_quota {
char* name;
};
-static void ru_unref_by(grpc_exec_ctx* exec_ctx,
- grpc_resource_user* resource_user, gpr_atm amount);
+static void ru_unref_by(grpc_resource_user* resource_user, gpr_atm amount);
/*******************************************************************************
* list management
@@ -240,35 +239,31 @@ static void rulist_remove(grpc_resource_user* resource_user, grpc_rulist list) {
* resource quota state machine
*/
-static bool rq_alloc(grpc_exec_ctx* exec_ctx,
- grpc_resource_quota* resource_quota);
+static bool rq_alloc(grpc_resource_quota* resource_quota);
static bool rq_reclaim_from_per_user_free_pool(
- grpc_exec_ctx* exec_ctx, grpc_resource_quota* resource_quota);
-static bool rq_reclaim(grpc_exec_ctx* exec_ctx,
- grpc_resource_quota* resource_quota, bool destructive);
+ grpc_resource_quota* resource_quota);
+static bool rq_reclaim(grpc_resource_quota* resource_quota, bool destructive);
-static void rq_step(grpc_exec_ctx* exec_ctx, void* rq, grpc_error* error) {
+static void rq_step(void* rq, grpc_error* error) {
grpc_resource_quota* resource_quota = (grpc_resource_quota*)rq;
resource_quota->step_scheduled = false;
do {
- if (rq_alloc(exec_ctx, resource_quota)) goto done;
- } while (rq_reclaim_from_per_user_free_pool(exec_ctx, resource_quota));
+ if (rq_alloc(resource_quota)) goto done;
+ } while (rq_reclaim_from_per_user_free_pool(resource_quota));
- if (!rq_reclaim(exec_ctx, resource_quota, false)) {
- rq_reclaim(exec_ctx, resource_quota, true);
+ if (!rq_reclaim(resource_quota, false)) {
+ rq_reclaim(resource_quota, true);
}
done:
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
}
-static void rq_step_sched(grpc_exec_ctx* exec_ctx,
- grpc_resource_quota* resource_quota) {
+static void rq_step_sched(grpc_resource_quota* resource_quota) {
if (resource_quota->step_scheduled) return;
resource_quota->step_scheduled = true;
grpc_resource_quota_ref_internal(resource_quota);
- GRPC_CLOSURE_SCHED(exec_ctx, &resource_quota->rq_step_closure,
- GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&resource_quota->rq_step_closure, GRPC_ERROR_NONE);
}
/* update the atomically available resource estimate - use no barriers since
@@ -287,8 +282,7 @@ static void rq_update_estimate(grpc_resource_quota* resource_quota) {
}
/* returns true if all allocations are completed */
-static bool rq_alloc(grpc_exec_ctx* exec_ctx,
- grpc_resource_quota* resource_quota) {
+static bool rq_alloc(grpc_resource_quota* resource_quota) {
grpc_resource_user* resource_user;
while ((resource_user = rulist_pop_head(resource_quota,
GRPC_RULIST_AWAITING_ALLOCATION))) {
@@ -308,9 +302,9 @@ static bool rq_alloc(grpc_exec_ctx* exec_ctx,
int64_t aborted_allocations = resource_user->outstanding_allocations;
resource_user->outstanding_allocations = 0;
resource_user->free_pool += aborted_allocations;
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &resource_user->on_allocated);
+ GRPC_CLOSURE_LIST_SCHED(&resource_user->on_allocated);
gpr_mu_unlock(&resource_user->mu);
- ru_unref_by(exec_ctx, resource_user, (gpr_atm)aborted_allocations);
+ ru_unref_by(resource_user, (gpr_atm)aborted_allocations);
continue;
}
if (resource_user->free_pool < 0 &&
@@ -334,7 +328,7 @@ static bool rq_alloc(grpc_exec_ctx* exec_ctx,
if (resource_user->free_pool >= 0) {
resource_user->allocating = false;
resource_user->outstanding_allocations = 0;
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &resource_user->on_allocated);
+ GRPC_CLOSURE_LIST_SCHED(&resource_user->on_allocated);
gpr_mu_unlock(&resource_user->mu);
} else {
rulist_add_head(resource_user, GRPC_RULIST_AWAITING_ALLOCATION);
@@ -347,7 +341,7 @@ static bool rq_alloc(grpc_exec_ctx* exec_ctx,
/* returns true if any memory could be reclaimed from buffers */
static bool rq_reclaim_from_per_user_free_pool(
- grpc_exec_ctx* exec_ctx, grpc_resource_quota* resource_quota) {
+ grpc_resource_quota* resource_quota) {
grpc_resource_user* resource_user;
while ((resource_user = rulist_pop_head(resource_quota,
GRPC_RULIST_NON_EMPTY_FREE_POOL))) {
@@ -374,8 +368,7 @@ static bool rq_reclaim_from_per_user_free_pool(
}
/* returns true if reclamation is proceeding */
-static bool rq_reclaim(grpc_exec_ctx* exec_ctx,
- grpc_resource_quota* resource_quota, bool destructive) {
+static bool rq_reclaim(grpc_resource_quota* resource_quota, bool destructive) {
if (resource_quota->reclaiming) return true;
grpc_rulist list = destructive ? GRPC_RULIST_RECLAIMER_DESTRUCTIVE
: GRPC_RULIST_RECLAIMER_BENIGN;
@@ -393,7 +386,7 @@ static bool rq_reclaim(grpc_exec_ctx* exec_ctx,
resource_quota->debug_only_last_reclaimer_resource_user = resource_user;
resource_quota->debug_only_last_initiated_reclaimer = c;
resource_user->reclaimers[destructive] = nullptr;
- GRPC_CLOSURE_RUN(exec_ctx, c, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_RUN(c, GRPC_ERROR_NONE);
return true;
}
@@ -413,10 +406,10 @@ static void ru_slice_ref(void* p) {
gpr_ref(&rc->refs);
}
-static void ru_slice_unref(grpc_exec_ctx* exec_ctx, void* p) {
+static void ru_slice_unref(void* p) {
ru_slice_refcount* rc = (ru_slice_refcount*)p;
if (gpr_unref(&rc->refs)) {
- grpc_resource_user_free(exec_ctx, rc->resource_user, rc->size);
+ grpc_resource_user_free(rc->resource_user, rc->size);
gpr_free(rc);
}
}
@@ -446,61 +439,57 @@ static grpc_slice ru_slice_create(grpc_resource_user* resource_user,
* the combiner
*/
-static void ru_allocate(grpc_exec_ctx* exec_ctx, void* ru, grpc_error* error) {
+static void ru_allocate(void* ru, grpc_error* error) {
grpc_resource_user* resource_user = (grpc_resource_user*)ru;
if (rulist_empty(resource_user->resource_quota,
GRPC_RULIST_AWAITING_ALLOCATION)) {
- rq_step_sched(exec_ctx, resource_user->resource_quota);
+ rq_step_sched(resource_user->resource_quota);
}
rulist_add_tail(resource_user, GRPC_RULIST_AWAITING_ALLOCATION);
}
-static void ru_add_to_free_pool(grpc_exec_ctx* exec_ctx, void* ru,
- grpc_error* error) {
+static void ru_add_to_free_pool(void* ru, grpc_error* error) {
grpc_resource_user* resource_user = (grpc_resource_user*)ru;
if (!rulist_empty(resource_user->resource_quota,
GRPC_RULIST_AWAITING_ALLOCATION) &&
rulist_empty(resource_user->resource_quota,
GRPC_RULIST_NON_EMPTY_FREE_POOL)) {
- rq_step_sched(exec_ctx, resource_user->resource_quota);
+ rq_step_sched(resource_user->resource_quota);
}
rulist_add_tail(resource_user, GRPC_RULIST_NON_EMPTY_FREE_POOL);
}
-static bool ru_post_reclaimer(grpc_exec_ctx* exec_ctx,
- grpc_resource_user* resource_user,
+static bool ru_post_reclaimer(grpc_resource_user* resource_user,
bool destructive) {
grpc_closure* closure = resource_user->new_reclaimers[destructive];
GPR_ASSERT(closure != nullptr);
resource_user->new_reclaimers[destructive] = nullptr;
GPR_ASSERT(resource_user->reclaimers[destructive] == nullptr);
if (gpr_atm_acq_load(&resource_user->shutdown) > 0) {
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_CANCELLED);
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_CANCELLED);
return false;
}
resource_user->reclaimers[destructive] = closure;
return true;
}
-static void ru_post_benign_reclaimer(grpc_exec_ctx* exec_ctx, void* ru,
- grpc_error* error) {
+static void ru_post_benign_reclaimer(void* ru, grpc_error* error) {
grpc_resource_user* resource_user = (grpc_resource_user*)ru;
- if (!ru_post_reclaimer(exec_ctx, resource_user, false)) return;
+ if (!ru_post_reclaimer(resource_user, false)) return;
if (!rulist_empty(resource_user->resource_quota,
GRPC_RULIST_AWAITING_ALLOCATION) &&
rulist_empty(resource_user->resource_quota,
GRPC_RULIST_NON_EMPTY_FREE_POOL) &&
rulist_empty(resource_user->resource_quota,
GRPC_RULIST_RECLAIMER_BENIGN)) {
- rq_step_sched(exec_ctx, resource_user->resource_quota);
+ rq_step_sched(resource_user->resource_quota);
}
rulist_add_tail(resource_user, GRPC_RULIST_RECLAIMER_BENIGN);
}
-static void ru_post_destructive_reclaimer(grpc_exec_ctx* exec_ctx, void* ru,
- grpc_error* error) {
+static void ru_post_destructive_reclaimer(void* ru, grpc_error* error) {
grpc_resource_user* resource_user = (grpc_resource_user*)ru;
- if (!ru_post_reclaimer(exec_ctx, resource_user, true)) return;
+ if (!ru_post_reclaimer(resource_user, true)) return;
if (!rulist_empty(resource_user->resource_quota,
GRPC_RULIST_AWAITING_ALLOCATION) &&
rulist_empty(resource_user->resource_quota,
@@ -509,51 +498,46 @@ static void ru_post_destructive_reclaimer(grpc_exec_ctx* exec_ctx, void* ru,
GRPC_RULIST_RECLAIMER_BENIGN) &&
rulist_empty(resource_user->resource_quota,
GRPC_RULIST_RECLAIMER_DESTRUCTIVE)) {
- rq_step_sched(exec_ctx, resource_user->resource_quota);
+ rq_step_sched(resource_user->resource_quota);
}
rulist_add_tail(resource_user, GRPC_RULIST_RECLAIMER_DESTRUCTIVE);
}
-static void ru_shutdown(grpc_exec_ctx* exec_ctx, void* ru, grpc_error* error) {
+static void ru_shutdown(void* ru, grpc_error* error) {
if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
gpr_log(GPR_DEBUG, "RU shutdown %p", ru);
}
grpc_resource_user* resource_user = (grpc_resource_user*)ru;
- GRPC_CLOSURE_SCHED(exec_ctx, resource_user->reclaimers[0],
- GRPC_ERROR_CANCELLED);
- GRPC_CLOSURE_SCHED(exec_ctx, resource_user->reclaimers[1],
- GRPC_ERROR_CANCELLED);
+ GRPC_CLOSURE_SCHED(resource_user->reclaimers[0], GRPC_ERROR_CANCELLED);
+ GRPC_CLOSURE_SCHED(resource_user->reclaimers[1], GRPC_ERROR_CANCELLED);
resource_user->reclaimers[0] = nullptr;
resource_user->reclaimers[1] = nullptr;
rulist_remove(resource_user, GRPC_RULIST_RECLAIMER_BENIGN);
rulist_remove(resource_user, GRPC_RULIST_RECLAIMER_DESTRUCTIVE);
if (resource_user->allocating) {
- rq_step_sched(exec_ctx, resource_user->resource_quota);
+ rq_step_sched(resource_user->resource_quota);
}
}
-static void ru_destroy(grpc_exec_ctx* exec_ctx, void* ru, grpc_error* error) {
+static void ru_destroy(void* ru, grpc_error* error) {
grpc_resource_user* resource_user = (grpc_resource_user*)ru;
GPR_ASSERT(gpr_atm_no_barrier_load(&resource_user->refs) == 0);
for (int i = 0; i < GRPC_RULIST_COUNT; i++) {
rulist_remove(resource_user, (grpc_rulist)i);
}
- GRPC_CLOSURE_SCHED(exec_ctx, resource_user->reclaimers[0],
- GRPC_ERROR_CANCELLED);
- GRPC_CLOSURE_SCHED(exec_ctx, resource_user->reclaimers[1],
- GRPC_ERROR_CANCELLED);
+ GRPC_CLOSURE_SCHED(resource_user->reclaimers[0], GRPC_ERROR_CANCELLED);
+ GRPC_CLOSURE_SCHED(resource_user->reclaimers[1], GRPC_ERROR_CANCELLED);
if (resource_user->free_pool != 0) {
resource_user->resource_quota->free_pool += resource_user->free_pool;
- rq_step_sched(exec_ctx, resource_user->resource_quota);
+ rq_step_sched(resource_user->resource_quota);
}
- grpc_resource_quota_unref_internal(exec_ctx, resource_user->resource_quota);
+ grpc_resource_quota_unref_internal(resource_user->resource_quota);
gpr_mu_destroy(&resource_user->mu);
gpr_free(resource_user->name);
gpr_free(resource_user);
}
-static void ru_allocated_slices(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void ru_allocated_slices(void* arg, grpc_error* error) {
grpc_resource_user_slice_allocator* slice_allocator =
(grpc_resource_user_slice_allocator*)arg;
if (error == GRPC_ERROR_NONE) {
@@ -563,7 +547,7 @@ static void ru_allocated_slices(grpc_exec_ctx* exec_ctx, void* arg,
slice_allocator->length));
}
}
- GRPC_CLOSURE_RUN(exec_ctx, &slice_allocator->on_done, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_RUN(&slice_allocator->on_done, GRPC_ERROR_REF(error));
}
/*******************************************************************************
@@ -577,23 +561,22 @@ typedef struct {
grpc_closure closure;
} rq_resize_args;
-static void rq_resize(grpc_exec_ctx* exec_ctx, void* args, grpc_error* error) {
+static void rq_resize(void* args, grpc_error* error) {
rq_resize_args* a = (rq_resize_args*)args;
int64_t delta = a->size - a->resource_quota->size;
a->resource_quota->size += delta;
a->resource_quota->free_pool += delta;
rq_update_estimate(a->resource_quota);
- rq_step_sched(exec_ctx, a->resource_quota);
- grpc_resource_quota_unref_internal(exec_ctx, a->resource_quota);
+ rq_step_sched(a->resource_quota);
+ grpc_resource_quota_unref_internal(a->resource_quota);
gpr_free(a);
}
-static void rq_reclamation_done(grpc_exec_ctx* exec_ctx, void* rq,
- grpc_error* error) {
+static void rq_reclamation_done(void* rq, grpc_error* error) {
grpc_resource_quota* resource_quota = (grpc_resource_quota*)rq;
resource_quota->reclaiming = false;
- rq_step_sched(exec_ctx, resource_quota);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ rq_step_sched(resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
}
/*******************************************************************************
@@ -629,10 +612,9 @@ grpc_resource_quota* grpc_resource_quota_create(const char* name) {
return resource_quota;
}
-void grpc_resource_quota_unref_internal(grpc_exec_ctx* exec_ctx,
- grpc_resource_quota* resource_quota) {
+void grpc_resource_quota_unref_internal(grpc_resource_quota* resource_quota) {
if (gpr_unref(&resource_quota->refs)) {
- GRPC_COMBINER_UNREF(exec_ctx, resource_quota->combiner, "resource_quota");
+ GRPC_COMBINER_UNREF(resource_quota->combiner, "resource_quota");
gpr_free(resource_quota->name);
gpr_free(resource_quota);
}
@@ -640,9 +622,8 @@ void grpc_resource_quota_unref_internal(grpc_exec_ctx* exec_ctx,
/* Public API */
void grpc_resource_quota_unref(grpc_resource_quota* resource_quota) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_quota_unref_internal(resource_quota);
}
grpc_resource_quota* grpc_resource_quota_ref_internal(
@@ -666,15 +647,14 @@ double grpc_resource_quota_get_memory_pressure(
/* Public API */
void grpc_resource_quota_resize(grpc_resource_quota* resource_quota,
size_t size) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
rq_resize_args* a = (rq_resize_args*)gpr_malloc(sizeof(*a));
a->resource_quota = grpc_resource_quota_ref_internal(resource_quota);
a->size = (int64_t)size;
gpr_atm_no_barrier_store(&resource_quota->last_size,
(gpr_atm)GPR_MIN((size_t)GPR_ATM_MAX, size));
GRPC_CLOSURE_INIT(&a->closure, rq_resize, a, grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_SCHED(&exec_ctx, &a->closure, GRPC_ERROR_NONE);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&a->closure, GRPC_ERROR_NONE);
}
size_t grpc_resource_quota_peek_size(grpc_resource_quota* resource_quota) {
@@ -705,8 +685,8 @@ static void* rq_copy(void* rq) {
return rq;
}
-static void rq_destroy(grpc_exec_ctx* exec_ctx, void* rq) {
- grpc_resource_quota_unref_internal(exec_ctx, (grpc_resource_quota*)rq);
+static void rq_destroy(void* rq) {
+ grpc_resource_quota_unref_internal((grpc_resource_quota*)rq);
}
static int rq_cmp(void* a, void* b) { return GPR_ICMP(a, b); }
@@ -774,14 +754,12 @@ static void ru_ref_by(grpc_resource_user* resource_user, gpr_atm amount) {
GPR_ASSERT(gpr_atm_no_barrier_fetch_add(&resource_user->refs, amount) != 0);
}
-static void ru_unref_by(grpc_exec_ctx* exec_ctx,
- grpc_resource_user* resource_user, gpr_atm amount) {
+static void ru_unref_by(grpc_resource_user* resource_user, gpr_atm amount) {
GPR_ASSERT(amount > 0);
gpr_atm old = gpr_atm_full_fetch_add(&resource_user->refs, -amount);
GPR_ASSERT(old >= amount);
if (old == amount) {
- GRPC_CLOSURE_SCHED(exec_ctx, &resource_user->destroy_closure,
- GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&resource_user->destroy_closure, GRPC_ERROR_NONE);
}
}
@@ -789,16 +767,13 @@ void grpc_resource_user_ref(grpc_resource_user* resource_user) {
ru_ref_by(resource_user, 1);
}
-void grpc_resource_user_unref(grpc_exec_ctx* exec_ctx,
- grpc_resource_user* resource_user) {
- ru_unref_by(exec_ctx, resource_user, 1);
+void grpc_resource_user_unref(grpc_resource_user* resource_user) {
+ ru_unref_by(resource_user, 1);
}
-void grpc_resource_user_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_resource_user* resource_user) {
+void grpc_resource_user_shutdown(grpc_resource_user* resource_user) {
if (gpr_atm_full_fetch_add(&resource_user->shutdown, 1) == 0) {
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_CREATE(
ru_shutdown, resource_user,
grpc_combiner_scheduler(resource_user->resource_quota->combiner)),
@@ -806,8 +781,7 @@ void grpc_resource_user_shutdown(grpc_exec_ctx* exec_ctx,
}
}
-void grpc_resource_user_alloc(grpc_exec_ctx* exec_ctx,
- grpc_resource_user* resource_user, size_t size,
+void grpc_resource_user_alloc(grpc_resource_user* resource_user, size_t size,
grpc_closure* optional_on_done) {
gpr_mu_lock(&resource_user->mu);
ru_ref_by(resource_user, (gpr_atm)size);
@@ -823,18 +797,16 @@ void grpc_resource_user_alloc(grpc_exec_ctx* exec_ctx,
GRPC_ERROR_NONE);
if (!resource_user->allocating) {
resource_user->allocating = true;
- GRPC_CLOSURE_SCHED(exec_ctx, &resource_user->allocate_closure,
- GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&resource_user->allocate_closure, GRPC_ERROR_NONE);
}
} else {
resource_user->outstanding_allocations -= (int64_t)size;
- GRPC_CLOSURE_SCHED(exec_ctx, optional_on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(optional_on_done, GRPC_ERROR_NONE);
}
gpr_mu_unlock(&resource_user->mu);
}
-void grpc_resource_user_free(grpc_exec_ctx* exec_ctx,
- grpc_resource_user* resource_user, size_t size) {
+void grpc_resource_user_free(grpc_resource_user* resource_user, size_t size) {
gpr_mu_lock(&resource_user->mu);
bool was_zero_or_negative = resource_user->free_pool <= 0;
resource_user->free_pool += (int64_t)size;
@@ -847,32 +819,29 @@ void grpc_resource_user_free(grpc_exec_ctx* exec_ctx,
if (is_bigger_than_zero && was_zero_or_negative &&
!resource_user->added_to_free_pool) {
resource_user->added_to_free_pool = true;
- GRPC_CLOSURE_SCHED(exec_ctx, &resource_user->add_to_free_pool_closure,
+ GRPC_CLOSURE_SCHED(&resource_user->add_to_free_pool_closure,
GRPC_ERROR_NONE);
}
gpr_mu_unlock(&resource_user->mu);
- ru_unref_by(exec_ctx, resource_user, (gpr_atm)size);
+ ru_unref_by(resource_user, (gpr_atm)size);
}
-void grpc_resource_user_post_reclaimer(grpc_exec_ctx* exec_ctx,
- grpc_resource_user* resource_user,
+void grpc_resource_user_post_reclaimer(grpc_resource_user* resource_user,
bool destructive,
grpc_closure* closure) {
GPR_ASSERT(resource_user->new_reclaimers[destructive] == nullptr);
resource_user->new_reclaimers[destructive] = closure;
- GRPC_CLOSURE_SCHED(exec_ctx,
- &resource_user->post_reclaimer_closure[destructive],
+ GRPC_CLOSURE_SCHED(&resource_user->post_reclaimer_closure[destructive],
GRPC_ERROR_NONE);
}
-void grpc_resource_user_finish_reclamation(grpc_exec_ctx* exec_ctx,
- grpc_resource_user* resource_user) {
+void grpc_resource_user_finish_reclamation(grpc_resource_user* resource_user) {
if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
gpr_log(GPR_DEBUG, "RQ %s %s: reclamation complete",
resource_user->resource_quota->name, resource_user->name);
}
GRPC_CLOSURE_SCHED(
- exec_ctx, &resource_user->resource_quota->rq_reclamation_done_closure,
+ &resource_user->resource_quota->rq_reclamation_done_closure,
GRPC_ERROR_NONE);
}
@@ -887,19 +856,17 @@ void grpc_resource_user_slice_allocator_init(
}
void grpc_resource_user_alloc_slices(
- grpc_exec_ctx* exec_ctx,
grpc_resource_user_slice_allocator* slice_allocator, size_t length,
size_t count, grpc_slice_buffer* dest) {
slice_allocator->length = length;
slice_allocator->count = count;
slice_allocator->dest = dest;
- grpc_resource_user_alloc(exec_ctx, slice_allocator->resource_user,
- count * length, &slice_allocator->on_allocated);
+ grpc_resource_user_alloc(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,
+grpc_slice grpc_resource_user_slice_malloc(grpc_resource_user* resource_user,
size_t size) {
- grpc_resource_user_alloc(exec_ctx, resource_user, size, nullptr);
+ grpc_resource_user_alloc(resource_user, size, nullptr);
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..b5ccdc76ca 100644
--- a/src/core/lib/iomgr/resource_quota.h
+++ b/src/core/lib/iomgr/resource_quota.h
@@ -69,8 +69,7 @@ extern grpc_tracer_flag grpc_resource_quota_trace;
grpc_resource_quota* grpc_resource_quota_ref_internal(
grpc_resource_quota* resource_quota);
-void grpc_resource_quota_unref_internal(grpc_exec_ctx* exec_ctx,
- grpc_resource_quota* resource_quota);
+void grpc_resource_quota_unref_internal(grpc_resource_quota* resource_quota);
grpc_resource_quota* grpc_resource_quota_from_channel_args(
const grpc_channel_args* channel_args);
@@ -93,32 +92,26 @@ grpc_resource_quota* grpc_resource_user_quota(
grpc_resource_user* resource_user);
void grpc_resource_user_ref(grpc_resource_user* resource_user);
-void grpc_resource_user_unref(grpc_exec_ctx* exec_ctx,
- grpc_resource_user* resource_user);
-void grpc_resource_user_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_resource_user* resource_user);
+void grpc_resource_user_unref(grpc_resource_user* resource_user);
+void grpc_resource_user_shutdown(grpc_resource_user* resource_user);
/* Allocate from the resource user (and its quota).
If optional_on_done is NULL, then allocate immediately. This may push the
quota over-limit, at which point reclamation will kick in.
If optional_on_done is non-NULL, it will be scheduled when the allocation has
been granted by the quota. */
-void grpc_resource_user_alloc(grpc_exec_ctx* exec_ctx,
- grpc_resource_user* resource_user, size_t size,
+void grpc_resource_user_alloc(grpc_resource_user* resource_user, size_t size,
grpc_closure* optional_on_done);
/* Release memory back to the quota */
-void grpc_resource_user_free(grpc_exec_ctx* exec_ctx,
- grpc_resource_user* resource_user, size_t size);
+void grpc_resource_user_free(grpc_resource_user* resource_user, size_t size);
/* Post a memory reclaimer to the resource user. Only one benign and one
destructive reclaimer can be posted at once. When executed, the reclaimer
MUST call grpc_resource_user_finish_reclamation before it completes, to
return control to the resource quota. */
-void grpc_resource_user_post_reclaimer(grpc_exec_ctx* exec_ctx,
- grpc_resource_user* resource_user,
+void grpc_resource_user_post_reclaimer(grpc_resource_user* resource_user,
bool destructive, grpc_closure* closure);
/* Finish a reclamation step */
-void grpc_resource_user_finish_reclamation(grpc_exec_ctx* exec_ctx,
- grpc_resource_user* resource_user);
+void grpc_resource_user_finish_reclamation(grpc_resource_user* resource_user);
/* Helper to allocate slices from a resource user */
typedef struct grpc_resource_user_slice_allocator {
@@ -145,13 +138,11 @@ void grpc_resource_user_slice_allocator_init(
/* Allocate \a count slices of length \a length into \a dest. Only one request
can be outstanding at a time. */
void grpc_resource_user_alloc_slices(
- grpc_exec_ctx* exec_ctx,
grpc_resource_user_slice_allocator* slice_allocator, size_t length,
size_t count, grpc_slice_buffer* dest);
/* Allocate one slice of length \a size synchronously. */
-grpc_slice grpc_resource_user_slice_malloc(grpc_exec_ctx* exec_ctx,
- grpc_resource_user* resource_user,
+grpc_slice grpc_resource_user_slice_malloc(grpc_resource_user* resource_user,
size_t size);
#ifdef __cplusplus
diff --git a/src/core/lib/iomgr/socket_factory_posix.cc b/src/core/lib/iomgr/socket_factory_posix.cc
index 40bfecd4c2..bc7d0b12f3 100644
--- a/src/core/lib/iomgr/socket_factory_posix.cc
+++ b/src/core/lib/iomgr/socket_factory_posix.cc
@@ -72,7 +72,7 @@ static void* socket_factory_arg_copy(void* p) {
return grpc_socket_factory_ref((grpc_socket_factory*)p);
}
-static void socket_factory_arg_destroy(grpc_exec_ctx* exec_ctx, void* p) {
+static void socket_factory_arg_destroy(void* p) {
grpc_socket_factory_unref((grpc_socket_factory*)p);
}
diff --git a/src/core/lib/iomgr/socket_mutator.cc b/src/core/lib/iomgr/socket_mutator.cc
index ff6c0c70d8..9d30e46b6b 100644
--- a/src/core/lib/iomgr/socket_mutator.cc
+++ b/src/core/lib/iomgr/socket_mutator.cc
@@ -63,7 +63,7 @@ static void* socket_mutator_arg_copy(void* p) {
return grpc_socket_mutator_ref((grpc_socket_mutator*)p);
}
-static void socket_mutator_arg_destroy(grpc_exec_ctx* exec_ctx, void* p) {
+static void socket_mutator_arg_destroy(void* p) {
grpc_socket_mutator_unref((grpc_socket_mutator*)p);
}
diff --git a/src/core/lib/iomgr/socket_windows.cc b/src/core/lib/iomgr/socket_windows.cc
index aee80f4b4c..9bb6a75dd8 100644
--- a/src/core/lib/iomgr/socket_windows.cc
+++ b/src/core/lib/iomgr/socket_windows.cc
@@ -109,37 +109,34 @@ void grpc_winsocket_destroy(grpc_winsocket* winsocket) {
-) The IOCP already completed in the background, and we need to call
the callback now.
-) The IOCP hasn't completed yet, and we're queuing it for later. */
-static void socket_notify_on_iocp(grpc_exec_ctx* exec_ctx,
- grpc_winsocket* socket, grpc_closure* closure,
+static void socket_notify_on_iocp(grpc_winsocket* socket, grpc_closure* closure,
grpc_winsocket_callback_info* info) {
GPR_ASSERT(info->closure == NULL);
gpr_mu_lock(&socket->state_mu);
if (info->has_pending_iocp) {
info->has_pending_iocp = 0;
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
} else {
info->closure = closure;
}
gpr_mu_unlock(&socket->state_mu);
}
-void grpc_socket_notify_on_write(grpc_exec_ctx* exec_ctx,
- grpc_winsocket* socket,
+void grpc_socket_notify_on_write(grpc_winsocket* socket,
grpc_closure* closure) {
- socket_notify_on_iocp(exec_ctx, socket, closure, &socket->write_info);
+ socket_notify_on_iocp(socket, closure, &socket->write_info);
}
-void grpc_socket_notify_on_read(grpc_exec_ctx* exec_ctx, grpc_winsocket* socket,
- grpc_closure* closure) {
- socket_notify_on_iocp(exec_ctx, socket, closure, &socket->read_info);
+void grpc_socket_notify_on_read(grpc_winsocket* socket, grpc_closure* closure) {
+ socket_notify_on_iocp(socket, closure, &socket->read_info);
}
-void grpc_socket_become_ready(grpc_exec_ctx* exec_ctx, grpc_winsocket* socket,
+void grpc_socket_become_ready(grpc_winsocket* socket,
grpc_winsocket_callback_info* info) {
GPR_ASSERT(!info->has_pending_iocp);
gpr_mu_lock(&socket->state_mu);
if (info->closure) {
- GRPC_CLOSURE_SCHED(exec_ctx, info->closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(info->closure, GRPC_ERROR_NONE);
info->closure = NULL;
} else {
info->has_pending_iocp = 1;
diff --git a/src/core/lib/iomgr/socket_windows.h b/src/core/lib/iomgr/socket_windows.h
index c3ad99d82f..4a1c624916 100644
--- a/src/core/lib/iomgr/socket_windows.h
+++ b/src/core/lib/iomgr/socket_windows.h
@@ -102,16 +102,13 @@ void grpc_winsocket_shutdown(grpc_winsocket* socket);
/* Destroy a socket. Should only be called if there's no pending operation. */
void grpc_winsocket_destroy(grpc_winsocket* socket);
-void grpc_socket_notify_on_write(grpc_exec_ctx* exec_ctx,
- grpc_winsocket* winsocket,
+void grpc_socket_notify_on_write(grpc_winsocket* winsocket,
grpc_closure* closure);
-void grpc_socket_notify_on_read(grpc_exec_ctx* exec_ctx,
- grpc_winsocket* winsocket,
+void grpc_socket_notify_on_read(grpc_winsocket* winsocket,
grpc_closure* closure);
-void grpc_socket_become_ready(grpc_exec_ctx* exec_ctx,
- grpc_winsocket* winsocket,
+void grpc_socket_become_ready(grpc_winsocket* winsocket,
grpc_winsocket_callback_info* ci);
#ifdef __cplusplus
diff --git a/src/core/lib/iomgr/tcp_client.h b/src/core/lib/iomgr/tcp_client.h
index c18d8a9316..04b91790eb 100644
--- a/src/core/lib/iomgr/tcp_client.h
+++ b/src/core/lib/iomgr/tcp_client.h
@@ -34,8 +34,7 @@ extern "C" {
NULL on failure).
interested_parties points to a set of pollsets that would be interested
in this connection being established (in order to continue their work) */
-void grpc_tcp_client_connect(grpc_exec_ctx* exec_ctx, grpc_closure* on_connect,
- grpc_endpoint** endpoint,
+void grpc_tcp_client_connect(grpc_closure* on_connect, grpc_endpoint** endpoint,
grpc_pollset_set* interested_parties,
const grpc_channel_args* channel_args,
const grpc_resolved_address* addr,
diff --git a/src/core/lib/iomgr/tcp_client_posix.cc b/src/core/lib/iomgr/tcp_client_posix.cc
index cb0f627c94..6e0fbf2a3c 100644
--- a/src/core/lib/iomgr/tcp_client_posix.cc
+++ b/src/core/lib/iomgr/tcp_client_posix.cc
@@ -96,7 +96,7 @@ done:
return err;
}
-static void tc_on_alarm(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
+static void tc_on_alarm(void* acp, grpc_error* error) {
int done;
async_connect* ac = (async_connect*)acp;
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
@@ -107,26 +107,24 @@ static void tc_on_alarm(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
gpr_mu_lock(&ac->mu);
if (ac->fd != nullptr) {
grpc_fd_shutdown(
- exec_ctx, ac->fd,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("connect() timed out"));
+ ac->fd, GRPC_ERROR_CREATE_FROM_STATIC_STRING("connect() timed out"));
}
done = (--ac->refs == 0);
gpr_mu_unlock(&ac->mu);
if (done) {
gpr_mu_destroy(&ac->mu);
gpr_free(ac->addr_str);
- grpc_channel_args_destroy(exec_ctx, ac->channel_args);
+ grpc_channel_args_destroy(ac->channel_args);
gpr_free(ac);
}
}
grpc_endpoint* grpc_tcp_client_create_from_fd(
- grpc_exec_ctx* exec_ctx, grpc_fd* fd, const grpc_channel_args* channel_args,
- const char* addr_str) {
- return grpc_tcp_create(exec_ctx, fd, channel_args, addr_str);
+ grpc_fd* fd, const grpc_channel_args* channel_args, const char* addr_str) {
+ return grpc_tcp_create(fd, channel_args, addr_str);
}
-static void on_writable(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
+static void on_writable(void* acp, grpc_error* error) {
async_connect* ac = (async_connect*)acp;
int so_error = 0;
socklen_t so_error_size;
@@ -150,7 +148,7 @@ static void on_writable(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
ac->fd = nullptr;
gpr_mu_unlock(&ac->mu);
- grpc_timer_cancel(exec_ctx, &ac->alarm);
+ grpc_timer_cancel(&ac->alarm);
gpr_mu_lock(&ac->mu);
if (error != GRPC_ERROR_NONE) {
@@ -172,9 +170,8 @@ static void on_writable(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
switch (so_error) {
case 0:
- grpc_pollset_set_del_fd(exec_ctx, ac->interested_parties, fd);
- *ep = grpc_tcp_client_create_from_fd(exec_ctx, fd, ac->channel_args,
- ac->addr_str);
+ grpc_pollset_set_del_fd(ac->interested_parties, fd);
+ *ep = grpc_tcp_client_create_from_fd(fd, ac->channel_args, ac->addr_str);
fd = nullptr;
break;
case ENOBUFS:
@@ -194,7 +191,7 @@ static void on_writable(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
don't do that! */
gpr_log(GPR_ERROR, "kernel out of buffers");
gpr_mu_unlock(&ac->mu);
- grpc_fd_notify_on_write(exec_ctx, fd, &ac->write_closure);
+ grpc_fd_notify_on_write(fd, &ac->write_closure);
return;
case ECONNREFUSED:
/* This error shouldn't happen for anything other than connect(). */
@@ -209,8 +206,8 @@ static void on_writable(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
finish:
if (fd != nullptr) {
- grpc_pollset_set_del_fd(exec_ctx, ac->interested_parties, fd);
- grpc_fd_orphan(exec_ctx, fd, nullptr, nullptr, false /* already_closed */,
+ grpc_pollset_set_del_fd(ac->interested_parties, fd);
+ grpc_fd_orphan(fd, nullptr, nullptr, false /* already_closed */,
"tcp_client_orphan");
fd = nullptr;
}
@@ -233,14 +230,13 @@ finish:
if (done) {
gpr_mu_destroy(&ac->mu);
gpr_free(ac->addr_str);
- grpc_channel_args_destroy(exec_ctx, ac->channel_args);
+ grpc_channel_args_destroy(ac->channel_args);
gpr_free(ac);
}
- GRPC_CLOSURE_SCHED(exec_ctx, closure, error);
+ GRPC_CLOSURE_SCHED(closure, error);
}
-static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx,
- grpc_closure* closure, grpc_endpoint** ep,
+static void tcp_client_connect_impl(grpc_closure* closure, grpc_endpoint** ep,
grpc_pollset_set* interested_parties,
const grpc_channel_args* channel_args,
const grpc_resolved_address* addr,
@@ -265,7 +261,7 @@ static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx,
error = grpc_create_dualstack_socket(addr, SOCK_STREAM, 0, &dsmode, &fd);
if (error != GRPC_ERROR_NONE) {
- GRPC_CLOSURE_SCHED(exec_ctx, closure, error);
+ GRPC_CLOSURE_SCHED(closure, error);
return;
}
if (dsmode == GRPC_DSMODE_IPV4) {
@@ -274,7 +270,7 @@ static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx,
addr = &addr4_copy;
}
if ((error = prepare_socket(addr, fd, channel_args)) != GRPC_ERROR_NONE) {
- GRPC_CLOSURE_SCHED(exec_ctx, closure, error);
+ GRPC_CLOSURE_SCHED(closure, error);
return;
}
@@ -289,20 +285,19 @@ static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx,
fdobj = grpc_fd_create(fd, name);
if (err >= 0) {
- *ep =
- grpc_tcp_client_create_from_fd(exec_ctx, fdobj, channel_args, addr_str);
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
+ *ep = grpc_tcp_client_create_from_fd(fdobj, channel_args, addr_str);
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
goto done;
}
if (errno != EWOULDBLOCK && errno != EINPROGRESS) {
- 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"));
+ grpc_fd_orphan(fdobj, nullptr, nullptr, false /* already_closed */,
+ "tcp_client_connect_error");
+ GRPC_CLOSURE_SCHED(closure, GRPC_OS_ERROR(errno, "connect"));
goto done;
}
- grpc_pollset_set_add_fd(exec_ctx, interested_parties, fdobj);
+ grpc_pollset_set_add_fd(interested_parties, fdobj);
ac = (async_connect*)gpr_malloc(sizeof(async_connect));
ac->closure = closure;
@@ -324,8 +319,8 @@ static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx,
gpr_mu_lock(&ac->mu);
GRPC_CLOSURE_INIT(&ac->on_alarm, tc_on_alarm, ac, grpc_schedule_on_exec_ctx);
- grpc_timer_init(exec_ctx, &ac->alarm, deadline, &ac->on_alarm);
- grpc_fd_notify_on_write(exec_ctx, ac->fd, &ac->write_closure);
+ grpc_timer_init(&ac->alarm, deadline, &ac->on_alarm);
+ grpc_fd_notify_on_write(ac->fd, &ac->write_closure);
gpr_mu_unlock(&ac->mu);
done:
@@ -336,20 +331,19 @@ 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_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,
+void grpc_tcp_client_connect(grpc_closure* closure, grpc_endpoint** ep,
grpc_pollset_set* interested_parties,
const grpc_channel_args* channel_args,
const grpc_resolved_address* addr,
grpc_millis deadline) {
- grpc_tcp_client_connect_impl(exec_ctx, closure, ep, interested_parties,
- channel_args, addr, deadline);
+ grpc_tcp_client_connect_impl(closure, ep, interested_parties, channel_args,
+ addr, deadline);
}
#endif
diff --git a/src/core/lib/iomgr/tcp_client_posix.h b/src/core/lib/iomgr/tcp_client_posix.h
index 13d917891e..ae5dc30566 100644
--- a/src/core/lib/iomgr/tcp_client_posix.h
+++ b/src/core/lib/iomgr/tcp_client_posix.h
@@ -28,8 +28,7 @@ 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);
+ grpc_fd* fd, const grpc_channel_args* channel_args, const char* addr_str);
#ifdef __cplusplus
}
diff --git a/src/core/lib/iomgr/tcp_client_uv.cc b/src/core/lib/iomgr/tcp_client_uv.cc
index 15345c8091..0bf3a043df 100644
--- a/src/core/lib/iomgr/tcp_client_uv.cc
+++ b/src/core/lib/iomgr/tcp_client_uv.cc
@@ -46,17 +46,15 @@ typedef struct grpc_uv_tcp_connect {
grpc_resource_quota* resource_quota;
} grpc_uv_tcp_connect;
-static void uv_tcp_connect_cleanup(grpc_exec_ctx* exec_ctx,
- grpc_uv_tcp_connect* connect) {
- grpc_resource_quota_unref_internal(exec_ctx, connect->resource_quota);
+static void uv_tcp_connect_cleanup(grpc_uv_tcp_connect* connect) {
+ grpc_resource_quota_unref_internal(connect->resource_quota);
gpr_free(connect->addr_name);
gpr_free(connect);
}
static void tcp_close_callback(uv_handle_t* handle) { gpr_free(handle); }
-static void uv_tc_on_alarm(grpc_exec_ctx* exec_ctx, void* acp,
- grpc_error* error) {
+static void uv_tc_on_alarm(void* acp, grpc_error* error) {
int done;
grpc_uv_tcp_connect* connect = (grpc_uv_tcp_connect*)acp;
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
@@ -72,17 +70,17 @@ static void uv_tc_on_alarm(grpc_exec_ctx* exec_ctx, void* acp,
}
done = (--connect->refs == 0);
if (done) {
- uv_tcp_connect_cleanup(exec_ctx, connect);
+ uv_tcp_connect_cleanup(connect);
}
}
static void uv_tc_on_connect(uv_connect_t* req, int status) {
grpc_uv_tcp_connect* connect = (grpc_uv_tcp_connect*)req->data;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_error* error = GRPC_ERROR_NONE;
int done;
grpc_closure* closure = connect->closure;
- grpc_timer_cancel(&exec_ctx, &connect->alarm);
+ grpc_timer_cancel(&connect->alarm);
if (status == 0) {
*connect->endpoint = grpc_tcp_create(
connect->tcp_handle, connect->resource_quota, connect->addr_name);
@@ -107,15 +105,13 @@ static void uv_tc_on_connect(uv_connect_t* req, int status) {
}
done = (--connect->refs == 0);
if (done) {
- grpc_exec_ctx_flush(&exec_ctx);
- uv_tcp_connect_cleanup(&exec_ctx, connect);
+ grpc_core::ExecCtx::Get()->Flush();
+ uv_tcp_connect_cleanup(connect);
}
- GRPC_CLOSURE_SCHED(&exec_ctx, closure, error);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_CLOSURE_SCHED(closure, error);
}
-static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx,
- grpc_closure* closure, grpc_endpoint** ep,
+static void tcp_client_connect_impl(grpc_closure* closure, grpc_endpoint** ep,
grpc_pollset_set* interested_parties,
const grpc_channel_args* channel_args,
const grpc_resolved_address* resolved_addr,
@@ -130,7 +126,7 @@ static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx,
if (channel_args != NULL) {
for (size_t i = 0; i < channel_args->num_args; i++) {
if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) {
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
resource_quota = grpc_resource_quota_ref_internal(
(grpc_resource_quota*)channel_args->args[i].value.pointer.p);
}
@@ -157,26 +153,25 @@ static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx,
(const struct sockaddr*)resolved_addr->addr, uv_tc_on_connect);
GRPC_CLOSURE_INIT(&connect->on_alarm, uv_tc_on_alarm, connect,
grpc_schedule_on_exec_ctx);
- grpc_timer_init(exec_ctx, &connect->alarm, deadline, &connect->on_alarm);
+ grpc_timer_init(&connect->alarm, deadline, &connect->on_alarm);
}
// 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_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,
+void grpc_tcp_client_connect(grpc_closure* closure, grpc_endpoint** ep,
grpc_pollset_set* interested_parties,
const grpc_channel_args* channel_args,
const grpc_resolved_address* addr,
grpc_millis deadline) {
- grpc_tcp_client_connect_impl(exec_ctx, closure, ep, interested_parties,
- channel_args, addr, deadline);
+ grpc_tcp_client_connect_impl(closure, ep, interested_parties, channel_args,
+ addr, deadline);
}
#endif /* GRPC_UV */
diff --git a/src/core/lib/iomgr/tcp_client_windows.cc b/src/core/lib/iomgr/tcp_client_windows.cc
index 103e6b78de..d67addd11c 100644
--- a/src/core/lib/iomgr/tcp_client_windows.cc
+++ b/src/core/lib/iomgr/tcp_client_windows.cc
@@ -52,13 +52,12 @@ typedef struct {
grpc_channel_args* channel_args;
} async_connect;
-static void async_connect_unlock_and_cleanup(grpc_exec_ctx* exec_ctx,
- async_connect* ac,
+static void async_connect_unlock_and_cleanup(async_connect* ac,
grpc_winsocket* socket) {
int done = (--ac->refs == 0);
gpr_mu_unlock(&ac->mu);
if (done) {
- grpc_channel_args_destroy(exec_ctx, ac->channel_args);
+ grpc_channel_args_destroy(ac->channel_args);
gpr_mu_destroy(&ac->mu);
gpr_free(ac->addr_name);
gpr_free(ac);
@@ -66,7 +65,7 @@ static void async_connect_unlock_and_cleanup(grpc_exec_ctx* exec_ctx,
if (socket != NULL) grpc_winsocket_destroy(socket);
}
-static void on_alarm(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
+static void on_alarm(void* acp, grpc_error* error) {
async_connect* ac = (async_connect*)acp;
gpr_mu_lock(&ac->mu);
grpc_winsocket* socket = ac->socket;
@@ -74,10 +73,10 @@ static void on_alarm(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
if (socket != NULL) {
grpc_winsocket_shutdown(socket);
}
- async_connect_unlock_and_cleanup(exec_ctx, ac, socket);
+ async_connect_unlock_and_cleanup(ac, socket);
}
-static void on_connect(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
+static void on_connect(void* acp, grpc_error* error) {
async_connect* ac = (async_connect*)acp;
grpc_endpoint** ep = ac->endpoint;
GPR_ASSERT(*ep == NULL);
@@ -90,7 +89,7 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
ac->socket = NULL;
gpr_mu_unlock(&ac->mu);
- grpc_timer_cancel(exec_ctx, &ac->alarm);
+ grpc_timer_cancel(&ac->alarm);
gpr_mu_lock(&ac->mu);
@@ -105,8 +104,7 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
if (!wsa_success) {
error = GRPC_WSA_ERROR(WSAGetLastError(), "ConnectEx");
} else {
- *ep =
- grpc_tcp_create(exec_ctx, socket, ac->channel_args, ac->addr_name);
+ *ep = grpc_tcp_create(socket, ac->channel_args, ac->addr_name);
socket = NULL;
}
} else {
@@ -114,18 +112,20 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
}
}
- async_connect_unlock_and_cleanup(exec_ctx, ac, socket);
+ async_connect_unlock_and_cleanup(ac, socket);
/* If the connection was aborted, the callback was already called when
the deadline was met. */
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
+ GRPC_CLOSURE_SCHED(on_done, error);
}
/* Tries to issue one async connection, then schedules both an IOCP
notification request for the connection, and one timeout alert. */
-static void tcp_client_connect_impl(
- grpc_exec_ctx* exec_ctx, grpc_closure* on_done, grpc_endpoint** endpoint,
- grpc_pollset_set* interested_parties, const grpc_channel_args* channel_args,
- const grpc_resolved_address* addr, grpc_millis deadline) {
+static void tcp_client_connect_impl(grpc_closure* on_done,
+ grpc_endpoint** endpoint,
+ grpc_pollset_set* interested_parties,
+ const grpc_channel_args* channel_args,
+ const grpc_resolved_address* addr,
+ grpc_millis deadline) {
SOCKET sock = INVALID_SOCKET;
BOOL success;
int status;
@@ -205,8 +205,8 @@ static void tcp_client_connect_impl(
GRPC_CLOSURE_INIT(&ac->on_connect, on_connect, ac, grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&ac->on_alarm, on_alarm, ac, grpc_schedule_on_exec_ctx);
- grpc_timer_init(exec_ctx, &ac->alarm, deadline, &ac->on_alarm);
- grpc_socket_notify_on_write(exec_ctx, socket, &ac->on_connect);
+ grpc_timer_init(&ac->alarm, deadline, &ac->on_alarm);
+ grpc_socket_notify_on_write(socket, &ac->on_connect);
return;
failure:
@@ -222,26 +222,25 @@ failure:
} else if (sock != INVALID_SOCKET) {
closesocket(sock);
}
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, final_error);
+ GRPC_CLOSURE_SCHED(on_done, final_error);
}
// overridden by api_fuzzer.c
extern "C" {
void (*grpc_tcp_client_connect_impl)(
- grpc_exec_ctx* exec_ctx, grpc_closure* closure, grpc_endpoint** ep,
+ 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,
+void grpc_tcp_client_connect(grpc_closure* closure, grpc_endpoint** ep,
grpc_pollset_set* interested_parties,
const grpc_channel_args* channel_args,
const grpc_resolved_address* addr,
grpc_millis deadline) {
- grpc_tcp_client_connect_impl(exec_ctx, closure, ep, interested_parties,
- channel_args, addr, deadline);
+ grpc_tcp_client_connect_impl(closure, ep, interested_parties, channel_args,
+ addr, deadline);
}
#endif /* GRPC_WINSOCK_SOCKET */
diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc
index cb90933e31..c1305bef8e 100644
--- a/src/core/lib/iomgr/tcp_posix.cc
+++ b/src/core/lib/iomgr/tcp_posix.cc
@@ -110,36 +110,31 @@ typedef struct backup_poller {
static gpr_atm g_uncovered_notifications_pending;
static gpr_atm g_backup_poller; /* backup_poller* */
-static void tcp_handle_read(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
- grpc_error* error);
-static void tcp_handle_write(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
- grpc_error* error);
-static void tcp_drop_uncovered_then_handle_write(grpc_exec_ctx* exec_ctx,
- void* arg /* grpc_tcp */,
+static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error* error);
+static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error);
+static void tcp_drop_uncovered_then_handle_write(void* arg /* grpc_tcp */,
grpc_error* error);
-static void done_poller(grpc_exec_ctx* exec_ctx, void* bp,
- grpc_error* error_ignored) {
+static void done_poller(void* bp, grpc_error* error_ignored) {
backup_poller* p = (backup_poller*)bp;
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p destroy", p);
}
- grpc_pollset_destroy(exec_ctx, BACKUP_POLLER_POLLSET(p));
+ grpc_pollset_destroy(BACKUP_POLLER_POLLSET(p));
gpr_free(p);
}
-static void run_poller(grpc_exec_ctx* exec_ctx, void* bp,
- grpc_error* error_ignored) {
+static void run_poller(void* bp, grpc_error* error_ignored) {
backup_poller* p = (backup_poller*)bp;
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p run", p);
}
gpr_mu_lock(p->pollset_mu);
- grpc_millis deadline = grpc_exec_ctx_now(exec_ctx) + 13 * GPR_MS_PER_SEC;
- GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS(exec_ctx);
+ grpc_millis deadline = grpc_core::ExecCtx::Get()->Now() + 13 * GPR_MS_PER_SEC;
+ GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS();
GRPC_LOG_IF_ERROR(
"backup_poller:pollset_work",
- grpc_pollset_work(exec_ctx, BACKUP_POLLER_POLLSET(p), nullptr, deadline));
+ grpc_pollset_work(BACKUP_POLLER_POLLSET(p), nullptr, deadline));
gpr_mu_unlock(p->pollset_mu);
/* last "uncovered" notification is the ref that keeps us polling, if we get
* there try a cas to release it */
@@ -154,18 +149,18 @@ static void run_poller(grpc_exec_ctx* exec_ctx, void* bp,
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p shutdown", p);
}
- grpc_pollset_shutdown(exec_ctx, BACKUP_POLLER_POLLSET(p),
+ grpc_pollset_shutdown(BACKUP_POLLER_POLLSET(p),
GRPC_CLOSURE_INIT(&p->run_poller, done_poller, p,
grpc_schedule_on_exec_ctx));
} else {
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p reschedule", p);
}
- GRPC_CLOSURE_SCHED(exec_ctx, &p->run_poller, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&p->run_poller, GRPC_ERROR_NONE);
}
}
-static void drop_uncovered(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
+static void drop_uncovered(grpc_tcp* tcp) {
backup_poller* p = (backup_poller*)gpr_atm_acq_load(&g_backup_poller);
gpr_atm old_count =
gpr_atm_no_barrier_fetch_add(&g_uncovered_notifications_pending, -1);
@@ -176,7 +171,7 @@ static void drop_uncovered(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
GPR_ASSERT(old_count != 1);
}
-static void cover_self(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
+static void cover_self(grpc_tcp* tcp) {
backup_poller* p;
gpr_atm old_count =
gpr_atm_no_barrier_fetch_add(&g_uncovered_notifications_pending, 2);
@@ -185,7 +180,7 @@ static void cover_self(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
2 + (int)old_count);
}
if (old_count == 0) {
- GRPC_STATS_INC_TCP_BACKUP_POLLERS_CREATED(exec_ctx);
+ GRPC_STATS_INC_TCP_BACKUP_POLLERS_CREATED();
p = (backup_poller*)gpr_zalloc(sizeof(*p) + grpc_pollset_size());
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p create", p);
@@ -193,7 +188,6 @@ static void cover_self(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
grpc_pollset_init(BACKUP_POLLER_POLLSET(p), &p->pollset_mu);
gpr_atm_rel_store(&g_backup_poller, (gpr_atm)p);
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_INIT(&p->run_poller, run_poller, p,
grpc_executor_scheduler(GRPC_EXECUTOR_LONG)),
GRPC_ERROR_NONE);
@@ -206,39 +200,38 @@ static void cover_self(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p add %p", p, tcp);
}
- grpc_pollset_add_fd(exec_ctx, BACKUP_POLLER_POLLSET(p), tcp->em_fd);
+ grpc_pollset_add_fd(BACKUP_POLLER_POLLSET(p), tcp->em_fd);
if (old_count != 0) {
- drop_uncovered(exec_ctx, tcp);
+ drop_uncovered(tcp);
}
}
-static void notify_on_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
+static void notify_on_read(grpc_tcp* tcp) {
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
gpr_log(GPR_DEBUG, "TCP:%p notify_on_read", tcp);
}
GRPC_CLOSURE_INIT(&tcp->read_done_closure, tcp_handle_read, tcp,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_read(exec_ctx, tcp->em_fd, &tcp->read_done_closure);
+ grpc_fd_notify_on_read(tcp->em_fd, &tcp->read_done_closure);
}
-static void notify_on_write(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
+static void notify_on_write(grpc_tcp* tcp) {
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
gpr_log(GPR_DEBUG, "TCP:%p notify_on_write", tcp);
}
- cover_self(exec_ctx, tcp);
+ cover_self(tcp);
GRPC_CLOSURE_INIT(&tcp->write_done_closure,
tcp_drop_uncovered_then_handle_write, tcp,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_write(exec_ctx, tcp->em_fd, &tcp->write_done_closure);
+ grpc_fd_notify_on_write(tcp->em_fd, &tcp->write_done_closure);
}
-static void tcp_drop_uncovered_then_handle_write(grpc_exec_ctx* exec_ctx,
- void* arg, grpc_error* error) {
+static void tcp_drop_uncovered_then_handle_write(void* arg, grpc_error* error) {
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
gpr_log(GPR_DEBUG, "TCP:%p got_write: %s", arg, grpc_error_string(error));
}
- drop_uncovered(exec_ctx, (grpc_tcp*)arg);
- tcp_handle_write(exec_ctx, arg, error);
+ drop_uncovered((grpc_tcp*)arg);
+ tcp_handle_write(arg, error);
}
static void add_to_estimate(grpc_tcp* tcp, size_t bytes) {
@@ -284,33 +277,29 @@ static grpc_error* tcp_annotate_error(grpc_error* src_error, grpc_tcp* tcp) {
grpc_slice_from_copied_string(tcp->peer_string));
}
-static void tcp_handle_read(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
- grpc_error* error);
-static void tcp_handle_write(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
- grpc_error* error);
+static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error* error);
+static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error);
-static void tcp_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_error* why) {
+static void tcp_shutdown(grpc_endpoint* ep, grpc_error* why) {
grpc_tcp* tcp = (grpc_tcp*)ep;
- grpc_fd_shutdown(exec_ctx, tcp->em_fd, why);
- grpc_resource_user_shutdown(exec_ctx, tcp->resource_user);
+ grpc_fd_shutdown(tcp->em_fd, why);
+ grpc_resource_user_shutdown(tcp->resource_user);
}
-static void tcp_free(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
- grpc_fd_orphan(exec_ctx, tcp->em_fd, tcp->release_fd_cb, tcp->release_fd,
+static void tcp_free(grpc_tcp* tcp) {
+ grpc_fd_orphan(tcp->em_fd, tcp->release_fd_cb, tcp->release_fd,
false /* already_closed */, "tcp_unref_orphan");
- grpc_slice_buffer_destroy_internal(exec_ctx, &tcp->last_read_buffer);
- grpc_resource_user_unref(exec_ctx, tcp->resource_user);
+ grpc_slice_buffer_destroy_internal(&tcp->last_read_buffer);
+ grpc_resource_user_unref(tcp->resource_user);
gpr_free(tcp->peer_string);
gpr_free(tcp);
}
#ifndef NDEBUG
-#define TCP_UNREF(cl, tcp, reason) \
- tcp_unref((cl), (tcp), (reason), __FILE__, __LINE__)
+#define TCP_UNREF(tcp, reason) tcp_unref((tcp), (reason), __FILE__, __LINE__)
#define TCP_REF(tcp, reason) tcp_ref((tcp), (reason), __FILE__, __LINE__)
-static void tcp_unref(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
- const char* reason, const char* file, int line) {
+static void tcp_unref(grpc_tcp* tcp, const char* reason, const char* file,
+ int line) {
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
gpr_atm val = gpr_atm_no_barrier_load(&tcp->refcount.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
@@ -318,7 +307,7 @@ static void tcp_unref(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
val - 1);
}
if (gpr_unref(&tcp->refcount)) {
- tcp_free(exec_ctx, tcp);
+ tcp_free(tcp);
}
}
@@ -333,26 +322,25 @@ static void tcp_ref(grpc_tcp* tcp, const char* reason, const char* file,
gpr_ref(&tcp->refcount);
}
#else
-#define TCP_UNREF(cl, tcp, reason) tcp_unref((cl), (tcp))
+#define TCP_UNREF(tcp, reason) tcp_unref((tcp))
#define TCP_REF(tcp, reason) tcp_ref((tcp))
-static void tcp_unref(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
+static void tcp_unref(grpc_tcp* tcp) {
if (gpr_unref(&tcp->refcount)) {
- tcp_free(exec_ctx, tcp);
+ tcp_free(tcp);
}
}
static void tcp_ref(grpc_tcp* tcp) { gpr_ref(&tcp->refcount); }
#endif
-static void tcp_destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) {
+static void tcp_destroy(grpc_endpoint* ep) {
grpc_network_status_unregister_endpoint(ep);
grpc_tcp* tcp = (grpc_tcp*)ep;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &tcp->last_read_buffer);
- TCP_UNREF(exec_ctx, tcp, "destroy");
+ grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
+ TCP_UNREF(tcp, "destroy");
}
-static void call_read_cb(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
- grpc_error* error) {
+static void call_read_cb(grpc_tcp* tcp, grpc_error* error) {
grpc_closure* cb = tcp->read_cb;
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
@@ -371,11 +359,11 @@ static void call_read_cb(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
tcp->read_cb = nullptr;
tcp->incoming_buffer = nullptr;
- GRPC_CLOSURE_RUN(exec_ctx, cb, error);
+ GRPC_CLOSURE_RUN(cb, error);
}
#define MAX_READ_IOVEC 4
-static void tcp_do_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
+static void tcp_do_read(grpc_tcp* tcp) {
struct msghdr msg;
struct iovec iov[MAX_READ_IOVEC];
ssize_t read_bytes;
@@ -398,12 +386,12 @@ static void tcp_do_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
msg.msg_controllen = 0;
msg.msg_flags = 0;
- GRPC_STATS_INC_TCP_READ_OFFER(exec_ctx, tcp->incoming_buffer->length);
- GRPC_STATS_INC_TCP_READ_OFFER_IOV_SIZE(exec_ctx, tcp->incoming_buffer->count);
+ GRPC_STATS_INC_TCP_READ_OFFER(tcp->incoming_buffer->length);
+ GRPC_STATS_INC_TCP_READ_OFFER_IOV_SIZE(tcp->incoming_buffer->count);
GPR_TIMER_BEGIN("recvmsg", 0);
do {
- GRPC_STATS_INC_SYSCALL_READ(exec_ctx);
+ GRPC_STATS_INC_SYSCALL_READ();
read_bytes = recvmsg(tcp->fd, &msg, 0);
} while (read_bytes < 0 && errno == EINTR);
GPR_TIMER_END("recvmsg", read_bytes >= 0);
@@ -414,24 +402,22 @@ static void tcp_do_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
if (errno == EAGAIN) {
finish_estimate(tcp);
/* We've consumed the edge, request a new one */
- notify_on_read(exec_ctx, tcp);
+ notify_on_read(tcp);
} else {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
- tcp->incoming_buffer);
- call_read_cb(exec_ctx, tcp,
+ grpc_slice_buffer_reset_and_unref_internal(tcp->incoming_buffer);
+ call_read_cb(tcp,
tcp_annotate_error(GRPC_OS_ERROR(errno, "recvmsg"), tcp));
- TCP_UNREF(exec_ctx, tcp, "read");
+ TCP_UNREF(tcp, "read");
}
} else if (read_bytes == 0) {
/* 0 read size ==> end of stream */
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, tcp->incoming_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(tcp->incoming_buffer);
call_read_cb(
- exec_ctx, tcp,
- tcp_annotate_error(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Socket closed"), tcp));
- TCP_UNREF(exec_ctx, tcp, "read");
+ tcp, tcp_annotate_error(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Socket closed"), tcp));
+ TCP_UNREF(tcp, "read");
} else {
- GRPC_STATS_INC_TCP_READ_SIZE(exec_ctx, read_bytes);
+ GRPC_STATS_INC_TCP_READ_SIZE(read_bytes);
add_to_estimate(tcp, (size_t)read_bytes);
GPR_ASSERT((size_t)read_bytes <= tcp->incoming_buffer->length);
if ((size_t)read_bytes < tcp->incoming_buffer->length) {
@@ -441,50 +427,47 @@ static void tcp_do_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
&tcp->last_read_buffer);
}
GPR_ASSERT((size_t)read_bytes == tcp->incoming_buffer->length);
- call_read_cb(exec_ctx, tcp, GRPC_ERROR_NONE);
- TCP_UNREF(exec_ctx, tcp, "read");
+ call_read_cb(tcp, GRPC_ERROR_NONE);
+ TCP_UNREF(tcp, "read");
}
GPR_TIMER_END("tcp_continue_read", 0);
}
-static void tcp_read_allocation_done(grpc_exec_ctx* exec_ctx, void* tcpp,
- grpc_error* error) {
+static void tcp_read_allocation_done(void* tcpp, grpc_error* error) {
grpc_tcp* tcp = (grpc_tcp*)tcpp;
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
gpr_log(GPR_DEBUG, "TCP:%p read_allocation_done: %s", tcp,
grpc_error_string(error));
}
if (error != GRPC_ERROR_NONE) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, tcp->incoming_buffer);
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
- &tcp->last_read_buffer);
- call_read_cb(exec_ctx, tcp, GRPC_ERROR_REF(error));
- TCP_UNREF(exec_ctx, tcp, "read");
+ grpc_slice_buffer_reset_and_unref_internal(tcp->incoming_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
+ call_read_cb(tcp, GRPC_ERROR_REF(error));
+ TCP_UNREF(tcp, "read");
} else {
- tcp_do_read(exec_ctx, tcp);
+ tcp_do_read(tcp);
}
}
-static void tcp_continue_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
+static void tcp_continue_read(grpc_tcp* tcp) {
size_t target_read_size = get_target_read_size(tcp);
if (tcp->incoming_buffer->length < target_read_size &&
tcp->incoming_buffer->count < MAX_READ_IOVEC) {
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
gpr_log(GPR_DEBUG, "TCP:%p alloc_slices", tcp);
}
- grpc_resource_user_alloc_slices(exec_ctx, &tcp->slice_allocator,
- target_read_size, 1, tcp->incoming_buffer);
+ grpc_resource_user_alloc_slices(&tcp->slice_allocator, target_read_size, 1,
+ tcp->incoming_buffer);
} else {
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
gpr_log(GPR_DEBUG, "TCP:%p do_read", tcp);
}
- tcp_do_read(exec_ctx, tcp);
+ tcp_do_read(tcp);
}
}
-static void tcp_handle_read(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
- grpc_error* error) {
+static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error* error) {
grpc_tcp* tcp = (grpc_tcp*)arg;
GPR_ASSERT(!tcp->finished_edge);
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
@@ -492,37 +475,35 @@ static void tcp_handle_read(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
}
if (error != GRPC_ERROR_NONE) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, tcp->incoming_buffer);
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
- &tcp->last_read_buffer);
- call_read_cb(exec_ctx, tcp, GRPC_ERROR_REF(error));
- TCP_UNREF(exec_ctx, tcp, "read");
+ grpc_slice_buffer_reset_and_unref_internal(tcp->incoming_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
+ call_read_cb(tcp, GRPC_ERROR_REF(error));
+ TCP_UNREF(tcp, "read");
} else {
- tcp_continue_read(exec_ctx, tcp);
+ tcp_continue_read(tcp);
}
}
-static void tcp_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* incoming_buffer, grpc_closure* cb) {
+static void tcp_read(grpc_endpoint* ep, grpc_slice_buffer* incoming_buffer,
+ grpc_closure* cb) {
grpc_tcp* tcp = (grpc_tcp*)ep;
GPR_ASSERT(tcp->read_cb == nullptr);
tcp->read_cb = cb;
tcp->incoming_buffer = incoming_buffer;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, incoming_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(incoming_buffer);
grpc_slice_buffer_swap(incoming_buffer, &tcp->last_read_buffer);
TCP_REF(tcp, "read");
if (tcp->finished_edge) {
tcp->finished_edge = false;
- notify_on_read(exec_ctx, tcp);
+ notify_on_read(tcp);
} else {
- GRPC_CLOSURE_SCHED(exec_ctx, &tcp->read_done_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&tcp->read_done_closure, GRPC_ERROR_NONE);
}
}
/* returns true if done, false if pending; if returning true, *error is set */
#define MAX_WRITE_IOVEC 1000
-static bool tcp_flush(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
- grpc_error** error) {
+static bool tcp_flush(grpc_tcp* tcp, grpc_error** error) {
struct msghdr msg;
struct iovec iov[MAX_WRITE_IOVEC];
msg_iovlen_type iov_size;
@@ -561,13 +542,13 @@ static bool tcp_flush(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
msg.msg_controllen = 0;
msg.msg_flags = 0;
- GRPC_STATS_INC_TCP_WRITE_SIZE(exec_ctx, sending_length);
- GRPC_STATS_INC_TCP_WRITE_IOV_SIZE(exec_ctx, iov_size);
+ GRPC_STATS_INC_TCP_WRITE_SIZE(sending_length);
+ GRPC_STATS_INC_TCP_WRITE_IOV_SIZE(iov_size);
GPR_TIMER_BEGIN("sendmsg", 1);
do {
/* TODO(klempner): Cork if this is a partial write */
- GRPC_STATS_INC_SYSCALL_WRITE(exec_ctx);
+ GRPC_STATS_INC_SYSCALL_WRITE();
sent_length = sendmsg(tcp->fd, &msg, SENDMSG_FLAGS);
} while (sent_length < 0 && errno == EINTR);
GPR_TIMER_END("sendmsg", 0);
@@ -611,24 +592,23 @@ static bool tcp_flush(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
};
}
-static void tcp_handle_write(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
- grpc_error* error) {
+static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) {
grpc_tcp* tcp = (grpc_tcp*)arg;
grpc_closure* cb;
if (error != GRPC_ERROR_NONE) {
cb = tcp->write_cb;
tcp->write_cb = nullptr;
- cb->cb(exec_ctx, cb->cb_arg, error);
- TCP_UNREF(exec_ctx, tcp, "write");
+ cb->cb(cb->cb_arg, error);
+ TCP_UNREF(tcp, "write");
return;
}
- if (!tcp_flush(exec_ctx, tcp, &error)) {
+ if (!tcp_flush(tcp, &error)) {
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
gpr_log(GPR_DEBUG, "write: delayed");
}
- notify_on_write(exec_ctx, tcp);
+ notify_on_write(tcp);
} else {
cb = tcp->write_cb;
tcp->write_cb = nullptr;
@@ -637,13 +617,13 @@ static void tcp_handle_write(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
gpr_log(GPR_DEBUG, "write: %s", str);
}
- GRPC_CLOSURE_RUN(exec_ctx, cb, error);
- TCP_UNREF(exec_ctx, tcp, "write");
+ GRPC_CLOSURE_RUN(cb, error);
+ TCP_UNREF(tcp, "write");
}
}
-static void tcp_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* buf, grpc_closure* cb) {
+static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf,
+ grpc_closure* cb) {
grpc_tcp* tcp = (grpc_tcp*)ep;
grpc_error* error = GRPC_ERROR_NONE;
@@ -664,52 +644,49 @@ static void tcp_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
if (buf->length == 0) {
GPR_TIMER_END("tcp_write", 0);
GRPC_CLOSURE_SCHED(
- exec_ctx, cb,
- grpc_fd_is_shutdown(tcp->em_fd)
- ? tcp_annotate_error(GRPC_ERROR_CREATE_FROM_STATIC_STRING("EOF"),
- tcp)
- : GRPC_ERROR_NONE);
+ cb, grpc_fd_is_shutdown(tcp->em_fd)
+ ? tcp_annotate_error(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("EOF"), tcp)
+ : GRPC_ERROR_NONE);
return;
}
tcp->outgoing_buffer = buf;
tcp->outgoing_slice_idx = 0;
tcp->outgoing_byte_idx = 0;
- if (!tcp_flush(exec_ctx, tcp, &error)) {
+ if (!tcp_flush(tcp, &error)) {
TCP_REF(tcp, "write");
tcp->write_cb = cb;
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
gpr_log(GPR_DEBUG, "write: delayed");
}
- notify_on_write(exec_ctx, tcp);
+ notify_on_write(tcp);
} else {
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
const char* str = grpc_error_string(error);
gpr_log(GPR_DEBUG, "write: %s", str);
}
- GRPC_CLOSURE_SCHED(exec_ctx, cb, error);
+ GRPC_CLOSURE_SCHED(cb, error);
}
GPR_TIMER_END("tcp_write", 0);
}
-static void tcp_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset* pollset) {
+static void tcp_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {
grpc_tcp* tcp = (grpc_tcp*)ep;
- grpc_pollset_add_fd(exec_ctx, pollset, tcp->em_fd);
+ grpc_pollset_add_fd(pollset, tcp->em_fd);
}
-static void tcp_add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
+static void tcp_add_to_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset_set) {
grpc_tcp* tcp = (grpc_tcp*)ep;
- grpc_pollset_set_add_fd(exec_ctx, pollset_set, tcp->em_fd);
+ grpc_pollset_set_add_fd(pollset_set, tcp->em_fd);
}
-static void tcp_delete_from_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* ep,
+static void tcp_delete_from_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset_set) {
grpc_tcp* tcp = (grpc_tcp*)ep;
- grpc_pollset_set_del_fd(exec_ctx, pollset_set, tcp->em_fd);
+ grpc_pollset_set_del_fd(pollset_set, tcp->em_fd);
}
static char* tcp_get_peer(grpc_endpoint* ep) {
@@ -740,7 +717,7 @@ static const grpc_endpoint_vtable vtable = {tcp_read,
#define MAX_CHUNK_SIZE 32 * 1024 * 1024
-grpc_endpoint* grpc_tcp_create(grpc_exec_ctx* exec_ctx, grpc_fd* em_fd,
+grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd,
const grpc_channel_args* channel_args,
const char* peer_string) {
int tcp_read_chunk_size = GRPC_TCP_DEFAULT_READ_SLICE_SIZE;
@@ -769,7 +746,7 @@ grpc_endpoint* grpc_tcp_create(grpc_exec_ctx* exec_ctx, grpc_fd* em_fd,
grpc_channel_arg_get_integer(&channel_args->args[i], options);
} else if (0 ==
strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) {
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
resource_quota = grpc_resource_quota_ref_internal(
(grpc_resource_quota*)channel_args->args[i].value.pointer.p);
}
@@ -806,7 +783,7 @@ grpc_endpoint* grpc_tcp_create(grpc_exec_ctx* exec_ctx, grpc_fd* em_fd,
&tcp->slice_allocator, tcp->resource_user, tcp_read_allocation_done, tcp);
/* Tell network status tracker about new endpoint */
grpc_network_status_register_endpoint(&tcp->base);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
return &tcp->base;
}
@@ -817,15 +794,15 @@ int grpc_tcp_fd(grpc_endpoint* ep) {
return grpc_fd_wrapped_fd(tcp->em_fd);
}
-void grpc_tcp_destroy_and_release_fd(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- int* fd, grpc_closure* done) {
+void grpc_tcp_destroy_and_release_fd(grpc_endpoint* ep, int* fd,
+ grpc_closure* done) {
grpc_network_status_unregister_endpoint(ep);
grpc_tcp* tcp = (grpc_tcp*)ep;
GPR_ASSERT(ep->vtable == &vtable);
tcp->release_fd = fd;
tcp->release_fd_cb = done;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &tcp->last_read_buffer);
- TCP_UNREF(exec_ctx, tcp, "destroy");
+ grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
+ TCP_UNREF(tcp, "destroy");
}
#endif
diff --git a/src/core/lib/iomgr/tcp_posix.h b/src/core/lib/iomgr/tcp_posix.h
index ff1060b0ff..a6320306fd 100644
--- a/src/core/lib/iomgr/tcp_posix.h
+++ b/src/core/lib/iomgr/tcp_posix.h
@@ -41,8 +41,7 @@ extern grpc_tracer_flag grpc_tcp_trace;
/* Create a tcp endpoint given a file desciptor and a read slice size.
Takes ownership of fd. */
-grpc_endpoint* grpc_tcp_create(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
- const grpc_channel_args* args,
+grpc_endpoint* grpc_tcp_create(grpc_fd* fd, const grpc_channel_args* args,
const char* peer_string);
/* Return the tcp endpoint's fd, or -1 if this is not available. Does not
@@ -54,8 +53,8 @@ int grpc_tcp_fd(grpc_endpoint* ep);
/* Destroy the tcp endpoint without closing its fd. *fd will be set and done
* will be called when the endpoint is destroyed.
* Requires: ep must be a tcp endpoint and fd must not be NULL. */
-void grpc_tcp_destroy_and_release_fd(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- int* fd, grpc_closure* done);
+void grpc_tcp_destroy_and_release_fd(grpc_endpoint* ep, int* fd,
+ grpc_closure* done);
#ifdef __cplusplus
}
diff --git a/src/core/lib/iomgr/tcp_server.h b/src/core/lib/iomgr/tcp_server.h
index ef983199b8..4d2bd8dc2a 100644
--- a/src/core/lib/iomgr/tcp_server.h
+++ b/src/core/lib/iomgr/tcp_server.h
@@ -43,22 +43,20 @@ typedef struct grpc_tcp_server_acceptor {
/* Called for newly connected TCP connections.
Takes ownership of acceptor. */
-typedef void (*grpc_tcp_server_cb)(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_endpoint* ep,
+typedef void (*grpc_tcp_server_cb)(void* arg, grpc_endpoint* ep,
grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor);
/* Create a server, initially not bound to any ports. The caller owns one ref.
If shutdown_complete is not NULL, it will be used by
grpc_tcp_server_unref() when the ref count reaches zero. */
-grpc_error* grpc_tcp_server_create(grpc_exec_ctx* exec_ctx,
- grpc_closure* shutdown_complete,
+grpc_error* grpc_tcp_server_create(grpc_closure* shutdown_complete,
const grpc_channel_args* args,
grpc_tcp_server** server);
/* Start listening to bound ports */
-void grpc_tcp_server_start(grpc_exec_ctx* exec_ctx, grpc_tcp_server* server,
- grpc_pollset** pollsets, size_t pollset_count,
+void grpc_tcp_server_start(grpc_tcp_server* server, grpc_pollset** pollsets,
+ size_t pollset_count,
grpc_tcp_server_cb on_accept_cb, void* cb_arg);
/* Add a port to the server, returning the newly allocated port on success, or
@@ -96,11 +94,10 @@ void grpc_tcp_server_shutdown_starting_add(grpc_tcp_server* s,
/* If the refcount drops to zero, enqueue calls on exec_ctx to
shutdown_listeners and delete s. */
-void grpc_tcp_server_unref(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s);
+void grpc_tcp_server_unref(grpc_tcp_server* s);
/* Shutdown the fds of listeners. */
-void grpc_tcp_server_shutdown_listeners(grpc_exec_ctx* exec_ctx,
- grpc_tcp_server* s);
+void grpc_tcp_server_shutdown_listeners(grpc_tcp_server* s);
#ifdef __cplusplus
}
diff --git a/src/core/lib/iomgr/tcp_server_posix.cc b/src/core/lib/iomgr/tcp_server_posix.cc
index f84fa9751d..475e9fef79 100644
--- a/src/core/lib/iomgr/tcp_server_posix.cc
+++ b/src/core/lib/iomgr/tcp_server_posix.cc
@@ -68,8 +68,7 @@ static void init(void) {
#endif
}
-grpc_error* grpc_tcp_server_create(grpc_exec_ctx* exec_ctx,
- grpc_closure* shutdown_complete,
+grpc_error* grpc_tcp_server_create(grpc_closure* shutdown_complete,
const grpc_channel_args* args,
grpc_tcp_server** server) {
gpr_once_init(&check_init, init);
@@ -116,12 +115,12 @@ grpc_error* grpc_tcp_server_create(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-static void finish_shutdown(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s) {
+static void finish_shutdown(grpc_tcp_server* s) {
gpr_mu_lock(&s->mu);
GPR_ASSERT(s->shutdown);
gpr_mu_unlock(&s->mu);
if (s->shutdown_complete != nullptr) {
- GRPC_CLOSURE_SCHED(exec_ctx, s->shutdown_complete, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(s->shutdown_complete, GRPC_ERROR_NONE);
}
gpr_mu_destroy(&s->mu);
@@ -131,19 +130,18 @@ static void finish_shutdown(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s) {
s->head = sp->next;
gpr_free(sp);
}
- grpc_channel_args_destroy(exec_ctx, s->channel_args);
+ grpc_channel_args_destroy(s->channel_args);
gpr_free(s);
}
-static void destroyed_port(grpc_exec_ctx* exec_ctx, void* server,
- grpc_error* error) {
+static void destroyed_port(void* server, grpc_error* error) {
grpc_tcp_server* s = (grpc_tcp_server*)server;
gpr_mu_lock(&s->mu);
s->destroyed_ports++;
if (s->destroyed_ports == s->nports) {
gpr_mu_unlock(&s->mu);
- finish_shutdown(exec_ctx, s);
+ finish_shutdown(s);
} else {
GPR_ASSERT(s->destroyed_ports < s->nports);
gpr_mu_unlock(&s->mu);
@@ -153,7 +151,7 @@ static void destroyed_port(grpc_exec_ctx* exec_ctx, void* server,
/* called when all listening endpoints have been shutdown, so no further
events will be received on them - at this point it's safe to destroy
things */
-static void deactivated_all_ports(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s) {
+static void deactivated_all_ports(grpc_tcp_server* s) {
/* delete ALL the things */
gpr_mu_lock(&s->mu);
@@ -165,17 +163,17 @@ 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, nullptr,
+ grpc_fd_orphan(sp->emfd, &sp->destroyed_closure, nullptr,
false /* already_closed */, "tcp_listener_shutdown");
}
gpr_mu_unlock(&s->mu);
} else {
gpr_mu_unlock(&s->mu);
- finish_shutdown(exec_ctx, s);
+ finish_shutdown(s);
}
}
-static void tcp_server_destroy(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s) {
+static void tcp_server_destroy(grpc_tcp_server* s) {
gpr_mu_lock(&s->mu);
GPR_ASSERT(!s->shutdown);
@@ -186,18 +184,17 @@ static void tcp_server_destroy(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s) {
grpc_tcp_listener* sp;
for (sp = s->head; sp; sp = sp->next) {
grpc_fd_shutdown(
- exec_ctx, sp->emfd,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server destroyed"));
+ sp->emfd, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server destroyed"));
}
gpr_mu_unlock(&s->mu);
} else {
gpr_mu_unlock(&s->mu);
- deactivated_all_ports(exec_ctx, s);
+ deactivated_all_ports(s);
}
}
/* event manager callback when reads are ready */
-static void on_read(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* err) {
+static void on_read(void* arg, grpc_error* err) {
grpc_tcp_listener* sp = (grpc_tcp_listener*)arg;
grpc_pollset* read_notifier_pollset;
if (err != GRPC_ERROR_NONE) {
@@ -223,7 +220,7 @@ static void on_read(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* err) {
case EINTR:
continue;
case EAGAIN:
- grpc_fd_notify_on_read(exec_ctx, sp->emfd, &sp->read_closure);
+ grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
return;
default:
gpr_mu_lock(&sp->server->mu);
@@ -249,7 +246,7 @@ static void on_read(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* err) {
grpc_fd* fdobj = grpc_fd_create(fd, name);
- grpc_pollset_add_fd(exec_ctx, read_notifier_pollset, fdobj);
+ grpc_pollset_add_fd(read_notifier_pollset, fdobj);
// Create acceptor.
grpc_tcp_server_acceptor* acceptor =
@@ -259,8 +256,8 @@ static void on_read(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* err) {
acceptor->fd_index = sp->fd_index;
sp->server->on_accept_cb(
- exec_ctx, sp->server->on_accept_cb_arg,
- grpc_tcp_create(exec_ctx, fdobj, sp->server->channel_args, addr_str),
+ sp->server->on_accept_cb_arg,
+ grpc_tcp_create(fdobj, sp->server->channel_args, addr_str),
read_notifier_pollset, acceptor);
gpr_free(name);
@@ -273,7 +270,7 @@ error:
gpr_mu_lock(&sp->server->mu);
if (0 == --sp->server->active_ports && sp->server->shutdown) {
gpr_mu_unlock(&sp->server->mu);
- deactivated_all_ports(exec_ctx, sp->server);
+ deactivated_all_ports(sp->server);
} else {
gpr_mu_unlock(&sp->server->mu);
}
@@ -483,8 +480,8 @@ int grpc_tcp_server_port_fd(grpc_tcp_server* s, unsigned port_index,
return -1;
}
-void grpc_tcp_server_start(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s,
- grpc_pollset** pollsets, size_t pollset_count,
+void grpc_tcp_server_start(grpc_tcp_server* s, grpc_pollset** pollsets,
+ size_t pollset_count,
grpc_tcp_server_cb on_accept_cb,
void* on_accept_cb_arg) {
size_t i;
@@ -504,20 +501,20 @@ void grpc_tcp_server_start(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s,
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"clone_port", clone_port(sp, (unsigned)(pollset_count - 1))));
for (i = 0; i < pollset_count; i++) {
- grpc_pollset_add_fd(exec_ctx, pollsets[i], sp->emfd);
+ grpc_pollset_add_fd(pollsets[i], sp->emfd);
GRPC_CLOSURE_INIT(&sp->read_closure, on_read, sp,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_read(exec_ctx, sp->emfd, &sp->read_closure);
+ grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
s->active_ports++;
sp = sp->next;
}
} else {
for (i = 0; i < pollset_count; i++) {
- grpc_pollset_add_fd(exec_ctx, pollsets[i], sp->emfd);
+ grpc_pollset_add_fd(pollsets[i], sp->emfd);
}
GRPC_CLOSURE_INIT(&sp->read_closure, on_read, sp,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_read(exec_ctx, sp->emfd, &sp->read_closure);
+ grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
s->active_ports++;
sp = sp->next;
}
@@ -538,25 +535,24 @@ void grpc_tcp_server_shutdown_starting_add(grpc_tcp_server* s,
gpr_mu_unlock(&s->mu);
}
-void grpc_tcp_server_unref(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s) {
+void grpc_tcp_server_unref(grpc_tcp_server* s) {
if (gpr_unref(&s->refs)) {
- grpc_tcp_server_shutdown_listeners(exec_ctx, s);
+ grpc_tcp_server_shutdown_listeners(s);
gpr_mu_lock(&s->mu);
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &s->shutdown_starting);
+ GRPC_CLOSURE_LIST_SCHED(&s->shutdown_starting);
gpr_mu_unlock(&s->mu);
- tcp_server_destroy(exec_ctx, s);
+ tcp_server_destroy(s);
}
}
-void grpc_tcp_server_shutdown_listeners(grpc_exec_ctx* exec_ctx,
- grpc_tcp_server* s) {
+void grpc_tcp_server_shutdown_listeners(grpc_tcp_server* s) {
gpr_mu_lock(&s->mu);
s->shutdown_listeners = true;
/* shutdown all fd's */
if (s->active_ports) {
grpc_tcp_listener* sp;
for (sp = s->head; sp; sp = sp->next) {
- grpc_fd_shutdown(exec_ctx, sp->emfd,
+ grpc_fd_shutdown(sp->emfd,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server shutdown"));
}
}
diff --git a/src/core/lib/iomgr/tcp_server_uv.cc b/src/core/lib/iomgr/tcp_server_uv.cc
index 0eed4d428f..daa7afe95f 100644
--- a/src/core/lib/iomgr/tcp_server_uv.cc
+++ b/src/core/lib/iomgr/tcp_server_uv.cc
@@ -73,8 +73,7 @@ struct grpc_tcp_server {
grpc_resource_quota* resource_quota;
};
-grpc_error* grpc_tcp_server_create(grpc_exec_ctx* exec_ctx,
- grpc_closure* shutdown_complete,
+grpc_error* grpc_tcp_server_create(grpc_closure* shutdown_complete,
const grpc_channel_args* args,
grpc_tcp_server** server) {
grpc_tcp_server* s = (grpc_tcp_server*)gpr_malloc(sizeof(grpc_tcp_server));
@@ -82,11 +81,11 @@ grpc_error* grpc_tcp_server_create(grpc_exec_ctx* exec_ctx,
for (size_t i = 0; i < (args == NULL ? 0 : args->num_args); i++) {
if (0 == strcmp(GRPC_ARG_RESOURCE_QUOTA, args->args[i].key)) {
if (args->args[i].type == GRPC_ARG_POINTER) {
- grpc_resource_quota_unref_internal(exec_ctx, s->resource_quota);
+ grpc_resource_quota_unref_internal(s->resource_quota);
s->resource_quota = grpc_resource_quota_ref_internal(
(grpc_resource_quota*)args->args[i].value.pointer.p);
} else {
- grpc_resource_quota_unref_internal(exec_ctx, s->resource_quota);
+ grpc_resource_quota_unref_internal(s->resource_quota);
gpr_free(s);
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
GRPC_ARG_RESOURCE_QUOTA " must be a pointer to a buffer pool");
@@ -119,10 +118,10 @@ void grpc_tcp_server_shutdown_starting_add(grpc_tcp_server* s,
GRPC_ERROR_NONE);
}
-static void finish_shutdown(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s) {
+static void finish_shutdown(grpc_tcp_server* s) {
GPR_ASSERT(s->shutdown);
if (s->shutdown_complete != NULL) {
- GRPC_CLOSURE_SCHED(exec_ctx, s->shutdown_complete, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(s->shutdown_complete, GRPC_ERROR_NONE);
}
while (s->head) {
@@ -132,18 +131,17 @@ static void finish_shutdown(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s) {
gpr_free(sp->handle);
gpr_free(sp);
}
- grpc_resource_quota_unref_internal(exec_ctx, s->resource_quota);
+ grpc_resource_quota_unref_internal(s->resource_quota);
gpr_free(s);
}
static void handle_close_callback(uv_handle_t* handle) {
grpc_tcp_listener* sp = (grpc_tcp_listener*)handle->data;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
sp->server->open_ports--;
if (sp->server->open_ports == 0 && sp->server->shutdown) {
- finish_shutdown(&exec_ctx, sp->server);
+ finish_shutdown(sp->server);
}
- grpc_exec_ctx_finish(&exec_ctx);
}
static void close_listener(grpc_tcp_listener* sp) {
@@ -153,7 +151,7 @@ static void close_listener(grpc_tcp_listener* sp) {
}
}
-static void tcp_server_destroy(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s) {
+static void tcp_server_destroy(grpc_tcp_server* s) {
int immediately_done = 0;
grpc_tcp_listener* sp;
@@ -168,28 +166,22 @@ static void tcp_server_destroy(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s) {
}
if (immediately_done) {
- finish_shutdown(exec_ctx, s);
+ finish_shutdown(s);
}
}
-void grpc_tcp_server_unref(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s) {
+void grpc_tcp_server_unref(grpc_tcp_server* s) {
GRPC_UV_ASSERT_SAME_THREAD();
if (gpr_unref(&s->refs)) {
/* Complete shutdown_starting work before destroying. */
- grpc_exec_ctx local_exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CLOSURE_LIST_SCHED(&local_exec_ctx, &s->shutdown_starting);
- if (exec_ctx == NULL) {
- grpc_exec_ctx_flush(&local_exec_ctx);
- tcp_server_destroy(&local_exec_ctx, s);
- grpc_exec_ctx_finish(&local_exec_ctx);
- } else {
- grpc_exec_ctx_finish(&local_exec_ctx);
- tcp_server_destroy(exec_ctx, s);
- }
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_CLOSURE_LIST_SCHED(&s->shutdown_starting);
+ grpc_core::ExecCtx::Get()->Flush();
+ tcp_server_destroy(s);
}
}
-static void finish_accept(grpc_exec_ctx* exec_ctx, grpc_tcp_listener* sp) {
+static void finish_accept(grpc_tcp_listener* sp) {
grpc_tcp_server_acceptor* acceptor =
(grpc_tcp_server_acceptor*)gpr_malloc(sizeof(*acceptor));
uv_tcp_t* client = NULL;
@@ -225,14 +217,13 @@ static void finish_accept(grpc_exec_ctx* exec_ctx, grpc_tcp_listener* sp) {
acceptor->from_server = sp->server;
acceptor->port_index = sp->port_index;
acceptor->fd_index = 0;
- sp->server->on_accept_cb(exec_ctx, sp->server->on_accept_cb_arg, ep, NULL,
- acceptor);
+ sp->server->on_accept_cb(sp->server->on_accept_cb_arg, ep, NULL, acceptor);
gpr_free(peer_name_string);
}
static void on_connect(uv_stream_t* server, int status) {
grpc_tcp_listener* sp = (grpc_tcp_listener*)server->data;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
if (status < 0) {
switch (status) {
@@ -253,11 +244,10 @@ static void on_connect(uv_stream_t* server, int status) {
// Create acceptor.
if (sp->server->on_accept_cb) {
- finish_accept(&exec_ctx, sp);
+ finish_accept(sp);
} else {
sp->has_pending_connection = true;
}
- grpc_exec_ctx_finish(&exec_ctx);
}
static grpc_error* add_socket_to_server(grpc_tcp_server* s, uv_tcp_t* handle,
@@ -428,8 +418,8 @@ grpc_error* grpc_tcp_server_add_port(grpc_tcp_server* s,
return error;
}
-void grpc_tcp_server_start(grpc_exec_ctx* exec_ctx, grpc_tcp_server* server,
- grpc_pollset** pollsets, size_t pollset_count,
+void grpc_tcp_server_start(grpc_tcp_server* server, grpc_pollset** pollsets,
+ size_t pollset_count,
grpc_tcp_server_cb on_accept_cb, void* cb_arg) {
grpc_tcp_listener* sp;
(void)pollsets;
@@ -444,13 +434,12 @@ void grpc_tcp_server_start(grpc_exec_ctx* exec_ctx, grpc_tcp_server* server,
server->on_accept_cb_arg = cb_arg;
for (sp = server->head; sp; sp = sp->next) {
if (sp->has_pending_connection) {
- finish_accept(exec_ctx, sp);
+ finish_accept(sp);
sp->has_pending_connection = false;
}
}
}
-void grpc_tcp_server_shutdown_listeners(grpc_exec_ctx* exec_ctx,
- grpc_tcp_server* s) {}
+void grpc_tcp_server_shutdown_listeners(grpc_tcp_server* s) {}
#endif /* GRPC_UV */
diff --git a/src/core/lib/iomgr/tcp_server_windows.cc b/src/core/lib/iomgr/tcp_server_windows.cc
index f538194895..8a30dfde43 100644
--- a/src/core/lib/iomgr/tcp_server_windows.cc
+++ b/src/core/lib/iomgr/tcp_server_windows.cc
@@ -94,8 +94,7 @@ struct grpc_tcp_server {
/* Public function. Allocates the proper data structures to hold a
grpc_tcp_server. */
-grpc_error* grpc_tcp_server_create(grpc_exec_ctx* exec_ctx,
- grpc_closure* shutdown_complete,
+grpc_error* grpc_tcp_server_create(grpc_closure* shutdown_complete,
const grpc_channel_args* args,
grpc_tcp_server** server) {
grpc_tcp_server* s = (grpc_tcp_server*)gpr_malloc(sizeof(grpc_tcp_server));
@@ -114,8 +113,7 @@ grpc_error* grpc_tcp_server_create(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-static void destroy_server(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void destroy_server(void* arg, grpc_error* error) {
grpc_tcp_server* s = (grpc_tcp_server*)arg;
/* Now that the accepts have been aborted, we can destroy the sockets.
@@ -128,18 +126,16 @@ static void destroy_server(grpc_exec_ctx* exec_ctx, void* arg,
grpc_winsocket_destroy(sp->socket);
gpr_free(sp);
}
- grpc_channel_args_destroy(exec_ctx, s->channel_args);
+ grpc_channel_args_destroy(s->channel_args);
gpr_free(s);
}
-static void finish_shutdown_locked(grpc_exec_ctx* exec_ctx,
- grpc_tcp_server* s) {
+static void finish_shutdown_locked(grpc_tcp_server* s) {
if (s->shutdown_complete != NULL) {
- GRPC_CLOSURE_SCHED(exec_ctx, s->shutdown_complete, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(s->shutdown_complete, GRPC_ERROR_NONE);
}
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_CREATE(destroy_server, s, grpc_schedule_on_exec_ctx),
GRPC_ERROR_NONE);
}
@@ -157,14 +153,14 @@ void grpc_tcp_server_shutdown_starting_add(grpc_tcp_server* s,
gpr_mu_unlock(&s->mu);
}
-static void tcp_server_destroy(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s) {
+static void tcp_server_destroy(grpc_tcp_server* s) {
grpc_tcp_listener* sp;
gpr_mu_lock(&s->mu);
/* First, shutdown all fd's. This will queue abortion calls for all
of the pending accepts due to the normal operation mechanism. */
if (s->active_ports == 0) {
- finish_shutdown_locked(exec_ctx, s);
+ finish_shutdown_locked(s);
} else {
for (sp = s->head; sp; sp = sp->next) {
sp->shutting_down = 1;
@@ -174,13 +170,13 @@ static void tcp_server_destroy(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s) {
gpr_mu_unlock(&s->mu);
}
-void grpc_tcp_server_unref(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s) {
+void grpc_tcp_server_unref(grpc_tcp_server* s) {
if (gpr_unref(&s->refs)) {
- grpc_tcp_server_shutdown_listeners(exec_ctx, s);
+ grpc_tcp_server_shutdown_listeners(s);
gpr_mu_lock(&s->mu);
- GRPC_CLOSURE_LIST_SCHED(exec_ctx, &s->shutdown_starting);
+ GRPC_CLOSURE_LIST_SCHED(&s->shutdown_starting);
gpr_mu_unlock(&s->mu);
- tcp_server_destroy(exec_ctx, s);
+ tcp_server_destroy(s);
}
}
@@ -234,19 +230,17 @@ failure:
return error;
}
-static void decrement_active_ports_and_notify_locked(grpc_exec_ctx* exec_ctx,
- grpc_tcp_listener* sp) {
+static void decrement_active_ports_and_notify_locked(grpc_tcp_listener* sp) {
sp->shutting_down = 0;
GPR_ASSERT(sp->server->active_ports > 0);
if (0 == --sp->server->active_ports) {
- finish_shutdown_locked(exec_ctx, sp->server);
+ finish_shutdown_locked(sp->server);
}
}
/* In order to do an async accept, we need to create a socket first which
will be the one assigned to the new incoming connection. */
-static grpc_error* start_accept_locked(grpc_exec_ctx* exec_ctx,
- grpc_tcp_listener* port) {
+static grpc_error* start_accept_locked(grpc_tcp_listener* port) {
SOCKET sock = INVALID_SOCKET;
BOOL success;
DWORD addrlen = sizeof(struct sockaddr_in6) + 16;
@@ -285,7 +279,7 @@ static grpc_error* start_accept_locked(grpc_exec_ctx* exec_ctx,
/* We're ready to do the accept. Calling grpc_socket_notify_on_read may
immediately process an accept that happened in the meantime. */
port->new_socket = sock;
- grpc_socket_notify_on_read(exec_ctx, port->socket, &port->on_accept);
+ grpc_socket_notify_on_read(port->socket, &port->on_accept);
port->outstanding_calls++;
return error;
@@ -296,7 +290,7 @@ failure:
}
/* Event manager callback when reads are ready. */
-static void on_accept(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void on_accept(void* arg, grpc_error* error) {
grpc_tcp_listener* sp = (grpc_tcp_listener*)arg;
SOCKET sock = sp->new_socket;
grpc_winsocket_callback_info* info = &sp->socket->read_info;
@@ -357,7 +351,7 @@ static void on_accept(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
gpr_free(utf8_message);
}
gpr_asprintf(&fd_name, "tcp_server:%s", peer_name_string);
- ep = grpc_tcp_create(exec_ctx, grpc_winsocket_create(sock, fd_name),
+ ep = grpc_tcp_create(grpc_winsocket_create(sock, fd_name),
sp->server->channel_args, peer_name_string);
gpr_free(fd_name);
gpr_free(peer_name_string);
@@ -375,17 +369,15 @@ static void on_accept(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
acceptor->from_server = sp->server;
acceptor->port_index = sp->port_index;
acceptor->fd_index = 0;
- sp->server->on_accept_cb(exec_ctx, sp->server->on_accept_cb_arg, ep, NULL,
- acceptor);
+ sp->server->on_accept_cb(sp->server->on_accept_cb_arg, ep, NULL, acceptor);
}
/* As we were notified from the IOCP of one and exactly one accept,
the former socked we created has now either been destroy or assigned
to the new connection. We need to create a new one for the next
connection. */
- GPR_ASSERT(
- GRPC_LOG_IF_ERROR("start_accept", start_accept_locked(exec_ctx, sp)));
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("start_accept", start_accept_locked(sp)));
if (0 == --sp->outstanding_calls) {
- decrement_active_ports_and_notify_locked(exec_ctx, sp);
+ decrement_active_ports_and_notify_locked(sp);
}
gpr_mu_unlock(&sp->server->mu);
}
@@ -522,8 +514,8 @@ done:
return error;
}
-void grpc_tcp_server_start(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s,
- grpc_pollset** pollset, size_t pollset_count,
+void grpc_tcp_server_start(grpc_tcp_server* s, grpc_pollset** pollset,
+ size_t pollset_count,
grpc_tcp_server_cb on_accept_cb,
void* on_accept_cb_arg) {
grpc_tcp_listener* sp;
@@ -534,14 +526,12 @@ void grpc_tcp_server_start(grpc_exec_ctx* exec_ctx, grpc_tcp_server* s,
s->on_accept_cb = on_accept_cb;
s->on_accept_cb_arg = on_accept_cb_arg;
for (sp = s->head; sp; sp = sp->next) {
- GPR_ASSERT(
- GRPC_LOG_IF_ERROR("start_accept", start_accept_locked(exec_ctx, sp)));
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("start_accept", start_accept_locked(sp)));
s->active_ports++;
}
gpr_mu_unlock(&s->mu);
}
-void grpc_tcp_server_shutdown_listeners(grpc_exec_ctx* exec_ctx,
- grpc_tcp_server* s) {}
+void grpc_tcp_server_shutdown_listeners(grpc_tcp_server* s) {}
#endif /* GRPC_WINSOCK_SOCKET */
diff --git a/src/core/lib/iomgr/tcp_uv.cc b/src/core/lib/iomgr/tcp_uv.cc
index ac9ca4ea11..742ab9a754 100644
--- a/src/core/lib/iomgr/tcp_uv.cc
+++ b/src/core/lib/iomgr/tcp_uv.cc
@@ -65,20 +65,19 @@ typedef struct {
grpc_pollset* pollset;
} grpc_tcp;
-static void tcp_free(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
- grpc_slice_unref_internal(exec_ctx, tcp->read_slice);
- grpc_resource_user_unref(exec_ctx, tcp->resource_user);
+static void tcp_free(grpc_tcp* tcp) {
+ grpc_slice_unref_internal(tcp->read_slice);
+ grpc_resource_user_unref(tcp->resource_user);
gpr_free(tcp->handle);
gpr_free(tcp->peer_string);
gpr_free(tcp);
}
#ifndef NDEBUG
-#define TCP_UNREF(exec_ctx, tcp, reason) \
- tcp_unref((exec_ctx), (tcp), (reason), __FILE__, __LINE__)
+#define TCP_UNREF(tcp, reason) tcp_unref((tcp), (reason), __FILE__, __LINE__)
#define TCP_REF(tcp, reason) tcp_ref((tcp), (reason), __FILE__, __LINE__)
-static void tcp_unref(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
- const char* reason, const char* file, int line) {
+static void tcp_unref(grpc_tcp* tcp, const char* reason, const char* file,
+ int line) {
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
gpr_atm val = gpr_atm_no_barrier_load(&tcp->refcount.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
@@ -86,7 +85,7 @@ static void tcp_unref(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
val - 1);
}
if (gpr_unref(&tcp->refcount)) {
- tcp_free(exec_ctx, tcp);
+ tcp_free(tcp);
}
}
@@ -101,11 +100,11 @@ static void tcp_ref(grpc_tcp* tcp, const char* reason, const char* file,
gpr_ref(&tcp->refcount);
}
#else
-#define TCP_UNREF(exec_ctx, tcp, reason) tcp_unref((exec_ctx), (tcp))
+#define TCP_UNREF(tcp, reason) tcp_unref((tcp))
#define TCP_REF(tcp, reason) tcp_ref((tcp))
-static void tcp_unref(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
+static void tcp_unref(grpc_tcp* tcp) {
if (gpr_unref(&tcp->refcount)) {
- tcp_free(exec_ctx, tcp);
+ tcp_free(tcp);
}
}
@@ -113,40 +112,37 @@ static void tcp_ref(grpc_tcp* tcp) { gpr_ref(&tcp->refcount); }
#endif
static void uv_close_callback(uv_handle_t* handle) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_tcp* tcp = (grpc_tcp*)handle->data;
- TCP_UNREF(&exec_ctx, tcp, "destroy");
- grpc_exec_ctx_finish(&exec_ctx);
+ TCP_UNREF(tcp, "destroy");
}
-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,
+static grpc_slice alloc_read_slice(grpc_resource_user* resource_user) {
+ return grpc_resource_user_slice_malloc(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_core::ExecCtx _local_exec_ctx;
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);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void read_callback(uv_stream_t* stream, ssize_t nread,
const uv_buf_t* buf) {
grpc_slice sub;
grpc_error* error;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_tcp* tcp = (grpc_tcp*)stream->data;
grpc_closure* cb = tcp->read_cb;
if (nread == 0) {
// Nothing happened. Wait for the next callback
return;
}
- TCP_UNREF(&exec_ctx, tcp, "read");
+ TCP_UNREF(tcp, "read");
tcp->read_cb = NULL;
// TODO(murgatroid99): figure out what the return value here means
uv_read_stop(stream);
@@ -156,7 +152,7 @@ static void read_callback(uv_stream_t* stream, ssize_t nread,
// 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);
+ tcp->read_slice = alloc_read_slice(tcp->resource_user);
error = GRPC_ERROR_NONE;
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
size_t i;
@@ -175,12 +171,11 @@ static void read_callback(uv_stream_t* stream, ssize_t nread,
// nread < 0: Error
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("TCP Read failed");
}
- GRPC_CLOSURE_SCHED(&exec_ctx, cb, error);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_CLOSURE_SCHED(cb, error);
}
-static void uv_endpoint_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* read_slices, grpc_closure* cb) {
+static void uv_endpoint_read(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;
@@ -188,7 +183,7 @@ static void uv_endpoint_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
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);
+ grpc_slice_buffer_reset_and_unref_internal(read_slices);
TCP_REF(tcp, "read");
// TODO(murgatroid99): figure out what the return value here means
status =
@@ -198,7 +193,7 @@ static void uv_endpoint_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
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);
+ GRPC_CLOSURE_SCHED(cb, error);
}
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
const char* str = grpc_error_string(error);
@@ -209,10 +204,10 @@ static void uv_endpoint_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
static void write_callback(uv_write_t* req, int status) {
grpc_tcp* tcp = (grpc_tcp*)req->data;
grpc_error* error;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_closure* cb = tcp->write_cb;
tcp->write_cb = NULL;
- TCP_UNREF(&exec_ctx, tcp, "write");
+ TCP_UNREF(tcp, "write");
if (status == 0) {
error = GRPC_ERROR_NONE;
} else {
@@ -223,13 +218,12 @@ static void write_callback(uv_write_t* req, int status) {
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,
+ grpc_resource_user_free(tcp->resource_user,
sizeof(uv_buf_t) * tcp->write_slices->count);
- GRPC_CLOSURE_SCHED(&exec_ctx, cb, error);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_CLOSURE_SCHED(cb, error);
}
-static void uv_endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
+static void uv_endpoint_write(grpc_endpoint* ep,
grpc_slice_buffer* write_slices,
grpc_closure* cb) {
grpc_tcp* tcp = (grpc_tcp*)ep;
@@ -252,9 +246,8 @@ static void uv_endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
}
if (tcp->shutting_down) {
- GRPC_CLOSURE_SCHED(
- exec_ctx, cb,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("TCP socket is shutting down"));
+ GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "TCP socket is shutting down"));
return;
}
@@ -264,15 +257,15 @@ static void uv_endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
if (tcp->write_slices->count == 0) {
// No slices means we don't have to do anything,
// and libuv doesn't like empty writes
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_NONE);
return;
}
tcp->write_cb = cb;
buffer_count = (unsigned int)tcp->write_slices->count;
buffers = (uv_buf_t*)gpr_malloc(sizeof(uv_buf_t) * buffer_count);
- grpc_resource_user_alloc(exec_ctx, tcp->resource_user,
- sizeof(uv_buf_t) * buffer_count, NULL);
+ grpc_resource_user_alloc(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);
@@ -287,8 +280,7 @@ static void uv_endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
write_callback);
}
-static void uv_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset* pollset) {
+static void uv_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {
// No-op. We're ignoring pollsets currently
(void)exec_ctx;
(void)ep;
@@ -297,7 +289,7 @@ static void uv_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
tcp->pollset = pollset;
}
-static void uv_add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
+static void uv_add_to_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset) {
// No-op. We're ignoring pollsets currently
(void)exec_ctx;
@@ -305,8 +297,7 @@ static void uv_add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
(void)pollset;
}
-static void uv_delete_from_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* ep,
+static void uv_delete_from_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset) {
// No-op. We're ignoring pollsets currently
(void)exec_ctx;
@@ -316,8 +307,7 @@ static void uv_delete_from_pollset_set(grpc_exec_ctx* exec_ctx,
static void shutdown_callback(uv_shutdown_t* req, int status) {}
-static void uv_endpoint_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_error* why) {
+static void uv_endpoint_shutdown(grpc_endpoint* ep, grpc_error* why) {
grpc_tcp* tcp = (grpc_tcp*)ep;
if (!tcp->shutting_down) {
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
@@ -327,12 +317,12 @@ static void uv_endpoint_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
tcp->shutting_down = true;
uv_shutdown_t* req = &tcp->shutdown_req;
uv_shutdown(req, (uv_stream_t*)tcp->handle, shutdown_callback);
- grpc_resource_user_shutdown(exec_ctx, tcp->resource_user);
+ grpc_resource_user_shutdown(tcp->resource_user);
}
GRPC_ERROR_UNREF(why);
}
-static void uv_destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) {
+static void uv_destroy(grpc_endpoint* ep) {
grpc_network_status_unregister_endpoint(ep);
grpc_tcp* tcp = (grpc_tcp*)ep;
uv_close((uv_handle_t*)tcp->handle, uv_close_callback);
@@ -365,7 +355,7 @@ grpc_endpoint* grpc_tcp_create(uv_tcp_t* handle,
grpc_resource_quota* resource_quota,
char* peer_string) {
grpc_tcp* tcp = (grpc_tcp*)gpr_malloc(sizeof(grpc_tcp));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
gpr_log(GPR_DEBUG, "Creating TCP endpoint %p", tcp);
@@ -382,7 +372,7 @@ grpc_endpoint* grpc_tcp_create(uv_tcp_t* handle,
tcp->peer_string = gpr_strdup(peer_string);
tcp->shutting_down = false;
tcp->resource_user = grpc_resource_user_create(resource_quota, peer_string);
- tcp->read_slice = alloc_read_slice(&exec_ctx, tcp->resource_user);
+ tcp->read_slice = alloc_read_slice(tcp->resource_user);
/* Tell network status tracking code about the new endpoint */
grpc_network_status_register_endpoint(&tcp->base);
@@ -390,7 +380,6 @@ grpc_endpoint* grpc_tcp_create(uv_tcp_t* handle,
uv_unref((uv_handle_t*)handle);
#endif
- grpc_exec_ctx_finish(&exec_ctx);
return &tcp->base;
}
diff --git a/src/core/lib/iomgr/tcp_windows.cc b/src/core/lib/iomgr/tcp_windows.cc
index 04922b4037..ab9a8a5c1e 100644
--- a/src/core/lib/iomgr/tcp_windows.cc
+++ b/src/core/lib/iomgr/tcp_windows.cc
@@ -109,21 +109,20 @@ typedef struct grpc_tcp {
char* peer_string;
} grpc_tcp;
-static void tcp_free(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
+static void tcp_free(grpc_tcp* tcp) {
grpc_winsocket_destroy(tcp->socket);
gpr_mu_destroy(&tcp->mu);
gpr_free(tcp->peer_string);
- grpc_resource_user_unref(exec_ctx, tcp->resource_user);
+ grpc_resource_user_unref(tcp->resource_user);
if (tcp->shutting_down) GRPC_ERROR_UNREF(tcp->shutdown_error);
gpr_free(tcp);
}
#ifndef NDEBUG
-#define TCP_UNREF(exec_ctx, tcp, reason) \
- tcp_unref((exec_ctx), (tcp), (reason), __FILE__, __LINE__)
+#define TCP_UNREF(tcp, reason) tcp_unref((tcp), (reason), __FILE__, __LINE__)
#define TCP_REF(tcp, reason) tcp_ref((tcp), (reason), __FILE__, __LINE__)
-static void tcp_unref(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
- const char* reason, const char* file, int line) {
+static void tcp_unref(grpc_tcp* tcp, const char* reason, const char* file,
+ int line) {
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
gpr_atm val = gpr_atm_no_barrier_load(&tcp->refcount.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
@@ -131,7 +130,7 @@ static void tcp_unref(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
val - 1);
}
if (gpr_unref(&tcp->refcount)) {
- tcp_free(exec_ctx, tcp);
+ tcp_free(tcp);
}
}
@@ -146,11 +145,11 @@ static void tcp_ref(grpc_tcp* tcp, const char* reason, const char* file,
gpr_ref(&tcp->refcount);
}
#else
-#define TCP_UNREF(exec_ctx, tcp, reason) tcp_unref((exec_ctx), (tcp))
+#define TCP_UNREF(tcp, reason) tcp_unref((tcp))
#define TCP_REF(tcp, reason) tcp_ref((tcp))
-static void tcp_unref(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
+static void tcp_unref(grpc_tcp* tcp) {
if (gpr_unref(&tcp->refcount)) {
- tcp_free(exec_ctx, tcp);
+ tcp_free(tcp);
}
}
@@ -158,7 +157,7 @@ static void tcp_ref(grpc_tcp* tcp) { gpr_ref(&tcp->refcount); }
#endif
/* Asynchronous callback from the IOCP, or the background thread. */
-static void on_read(grpc_exec_ctx* exec_ctx, void* tcpp, grpc_error* error) {
+static void on_read(void* tcpp, grpc_error* error) {
grpc_tcp* tcp = (grpc_tcp*)tcpp;
grpc_closure* cb = tcp->read_cb;
grpc_winsocket* socket = tcp->socket;
@@ -172,13 +171,13 @@ static void on_read(grpc_exec_ctx* exec_ctx, void* tcpp, grpc_error* error) {
char* utf8_message = gpr_format_message(info->wsa_error);
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(utf8_message);
gpr_free(utf8_message);
- grpc_slice_unref_internal(exec_ctx, tcp->read_slice);
+ grpc_slice_unref_internal(tcp->read_slice);
} else {
if (info->bytes_transfered != 0 && !tcp->shutting_down) {
sub = grpc_slice_sub_no_ref(tcp->read_slice, 0, info->bytes_transfered);
grpc_slice_buffer_add(tcp->read_slices, sub);
} else {
- grpc_slice_unref_internal(exec_ctx, tcp->read_slice);
+ grpc_slice_unref_internal(tcp->read_slice);
error = tcp->shutting_down
? GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"TCP stream shutting down", &tcp->shutdown_error, 1)
@@ -188,12 +187,12 @@ static void on_read(grpc_exec_ctx* exec_ctx, void* tcpp, grpc_error* error) {
}
tcp->read_cb = NULL;
- TCP_UNREF(exec_ctx, tcp, "read");
- GRPC_CLOSURE_SCHED(exec_ctx, cb, error);
+ TCP_UNREF(tcp, "read");
+ GRPC_CLOSURE_SCHED(cb, error);
}
-static void win_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* read_slices, grpc_closure* cb) {
+static void win_read(grpc_endpoint* ep, grpc_slice_buffer* read_slices,
+ grpc_closure* cb) {
grpc_tcp* tcp = (grpc_tcp*)ep;
grpc_winsocket* handle = tcp->socket;
grpc_winsocket_callback_info* info = &handle->read_info;
@@ -204,15 +203,14 @@ static void win_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
if (tcp->shutting_down) {
GRPC_CLOSURE_SCHED(
- exec_ctx, cb,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "TCP socket is shutting down", &tcp->shutdown_error, 1));
+ cb, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "TCP socket is shutting down", &tcp->shutdown_error, 1));
return;
}
tcp->read_cb = cb;
tcp->read_slices = read_slices;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, read_slices);
+ grpc_slice_buffer_reset_and_unref_internal(read_slices);
tcp->read_slice = GRPC_SLICE_MALLOC(8192);
@@ -230,7 +228,7 @@ static void win_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
/* Did we get data immediately ? Yay. */
if (info->wsa_error != WSAEWOULDBLOCK) {
info->bytes_transfered = bytes_read;
- GRPC_CLOSURE_SCHED(exec_ctx, &tcp->on_read, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&tcp->on_read, GRPC_ERROR_NONE);
return;
}
@@ -243,17 +241,17 @@ static void win_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
int wsa_error = WSAGetLastError();
if (wsa_error != WSA_IO_PENDING) {
info->wsa_error = wsa_error;
- GRPC_CLOSURE_SCHED(exec_ctx, &tcp->on_read,
+ GRPC_CLOSURE_SCHED(&tcp->on_read,
GRPC_WSA_ERROR(info->wsa_error, "WSARecv"));
return;
}
}
- grpc_socket_notify_on_read(exec_ctx, tcp->socket, &tcp->on_read);
+ grpc_socket_notify_on_read(tcp->socket, &tcp->on_read);
}
/* Asynchronous callback from the IOCP, or the background thread. */
-static void on_write(grpc_exec_ctx* exec_ctx, void* tcpp, grpc_error* error) {
+static void on_write(void* tcpp, grpc_error* error) {
grpc_tcp* tcp = (grpc_tcp*)tcpp;
grpc_winsocket* handle = tcp->socket;
grpc_winsocket_callback_info* info = &handle->write_info;
@@ -274,13 +272,13 @@ static void on_write(grpc_exec_ctx* exec_ctx, void* tcpp, grpc_error* error) {
}
}
- TCP_UNREF(exec_ctx, tcp, "write");
- GRPC_CLOSURE_SCHED(exec_ctx, cb, error);
+ TCP_UNREF(tcp, "write");
+ GRPC_CLOSURE_SCHED(cb, error);
}
/* Initiates a write. */
-static void win_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
+static void win_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
grpc_tcp* tcp = (grpc_tcp*)ep;
grpc_winsocket* socket = tcp->socket;
grpc_winsocket_callback_info* info = &socket->write_info;
@@ -294,9 +292,8 @@ static void win_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
if (tcp->shutting_down) {
GRPC_CLOSURE_SCHED(
- exec_ctx, cb,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "TCP socket is shutting down", &tcp->shutdown_error, 1));
+ cb, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "TCP socket is shutting down", &tcp->shutdown_error, 1));
return;
}
@@ -327,7 +324,7 @@ static void win_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
grpc_error* error = status == 0
? GRPC_ERROR_NONE
: GRPC_WSA_ERROR(info->wsa_error, "WSASend");
- GRPC_CLOSURE_SCHED(exec_ctx, cb, error);
+ GRPC_CLOSURE_SCHED(cb, error);
if (allocated) gpr_free(allocated);
return;
}
@@ -344,35 +341,32 @@ static void win_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
if (status != 0) {
int wsa_error = WSAGetLastError();
if (wsa_error != WSA_IO_PENDING) {
- TCP_UNREF(exec_ctx, tcp, "write");
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_WSA_ERROR(wsa_error, "WSASend"));
+ TCP_UNREF(tcp, "write");
+ GRPC_CLOSURE_SCHED(cb, GRPC_WSA_ERROR(wsa_error, "WSASend"));
return;
}
}
/* As all is now setup, we can now ask for the IOCP notification. It may
trigger the callback immediately however, but no matter. */
- grpc_socket_notify_on_write(exec_ctx, socket, &tcp->on_write);
+ grpc_socket_notify_on_write(socket, &tcp->on_write);
}
-static void win_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset* ps) {
+static void win_add_to_pollset(grpc_endpoint* ep, grpc_pollset* ps) {
grpc_tcp* tcp;
(void)ps;
tcp = (grpc_tcp*)ep;
grpc_iocp_add_socket(tcp->socket);
}
-static void win_add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset_set* pss) {
+static void win_add_to_pollset_set(grpc_endpoint* ep, grpc_pollset_set* pss) {
grpc_tcp* tcp;
(void)pss;
tcp = (grpc_tcp*)ep;
grpc_iocp_add_socket(tcp->socket);
}
-static void win_delete_from_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* ep,
+static void win_delete_from_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pss) {}
/* Initiates a shutdown of the TCP endpoint. This will queue abort callbacks
@@ -381,8 +375,7 @@ static void win_delete_from_pollset_set(grpc_exec_ctx* exec_ctx,
we're not going to protect against these. However the IO Completion Port
callback will happen from another thread, so we need to protect against
concurrent access of the data structure in that regard. */
-static void win_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_error* why) {
+static void win_shutdown(grpc_endpoint* ep, grpc_error* why) {
grpc_tcp* tcp = (grpc_tcp*)ep;
gpr_mu_lock(&tcp->mu);
/* At that point, what may happen is that we're already inside the IOCP
@@ -395,13 +388,13 @@ static void win_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
}
grpc_winsocket_shutdown(tcp->socket);
gpr_mu_unlock(&tcp->mu);
- grpc_resource_user_shutdown(exec_ctx, tcp->resource_user);
+ grpc_resource_user_shutdown(tcp->resource_user);
}
-static void win_destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) {
+static void win_destroy(grpc_endpoint* ep) {
grpc_network_status_unregister_endpoint(ep);
grpc_tcp* tcp = (grpc_tcp*)ep;
- TCP_UNREF(exec_ctx, tcp, "destroy");
+ TCP_UNREF(tcp, "destroy");
}
static char* win_get_peer(grpc_endpoint* ep) {
@@ -427,14 +420,14 @@ static grpc_endpoint_vtable vtable = {win_read,
win_get_peer,
win_get_fd};
-grpc_endpoint* grpc_tcp_create(grpc_exec_ctx* exec_ctx, grpc_winsocket* socket,
+grpc_endpoint* grpc_tcp_create(grpc_winsocket* socket,
grpc_channel_args* channel_args,
const char* peer_string) {
grpc_resource_quota* resource_quota = grpc_resource_quota_create(NULL);
if (channel_args != NULL) {
for (size_t i = 0; i < channel_args->num_args; i++) {
if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) {
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
resource_quota = grpc_resource_quota_ref_internal(
(grpc_resource_quota*)channel_args->args[i].value.pointer.p);
}
@@ -452,7 +445,7 @@ grpc_endpoint* grpc_tcp_create(grpc_exec_ctx* exec_ctx, grpc_winsocket* socket,
tcp->resource_user = grpc_resource_user_create(resource_quota, peer_string);
/* Tell network status tracking code about the new endpoint */
grpc_network_status_register_endpoint(&tcp->base);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
return &tcp->base;
}
diff --git a/src/core/lib/iomgr/tcp_windows.h b/src/core/lib/iomgr/tcp_windows.h
index 9c7ccdf132..693037cab7 100644
--- a/src/core/lib/iomgr/tcp_windows.h
+++ b/src/core/lib/iomgr/tcp_windows.h
@@ -42,7 +42,7 @@ extern "C" {
/* Create a tcp endpoint given a winsock handle.
* Takes ownership of the handle.
*/
-grpc_endpoint* grpc_tcp_create(grpc_exec_ctx* exec_ctx, grpc_winsocket* socket,
+grpc_endpoint* grpc_tcp_create(grpc_winsocket* socket,
grpc_channel_args* channel_args,
const char* peer_string);
diff --git a/src/core/lib/iomgr/timer.h b/src/core/lib/iomgr/timer.h
index cd8334eceb..a74292eaf9 100644
--- a/src/core/lib/iomgr/timer.h
+++ b/src/core/lib/iomgr/timer.h
@@ -44,8 +44,8 @@ typedef struct grpc_timer grpc_timer;
application code should check the error to determine how it was invoked. The
application callback is also responsible for maintaining information about
when to free up any user-level state. */
-void grpc_timer_init(grpc_exec_ctx* exec_ctx, grpc_timer* timer,
- grpc_millis deadline, grpc_closure* closure);
+void grpc_timer_init(grpc_timer* timer, grpc_millis deadline,
+ grpc_closure* closure);
/* Initialize *timer without setting it. This can later be passed through
the regular init or cancel */
@@ -77,7 +77,7 @@ void grpc_timer_init_unset(grpc_timer* timer);
matches this aim.
Requires: cancel() must happen after init() on a given timer */
-void grpc_timer_cancel(grpc_exec_ctx* exec_ctx, grpc_timer* timer);
+void grpc_timer_cancel(grpc_timer* timer);
/* iomgr internal api for dealing with timers */
@@ -94,10 +94,9 @@ typedef enum {
*next is never guaranteed to be updated on any given execution; however,
with high probability at least one thread in the system will see an update
at any time slice. */
-grpc_timer_check_result grpc_timer_check(grpc_exec_ctx* exec_ctx,
- grpc_millis* next);
-void grpc_timer_list_init(grpc_exec_ctx* exec_ctx);
-void grpc_timer_list_shutdown(grpc_exec_ctx* exec_ctx);
+grpc_timer_check_result grpc_timer_check(grpc_millis* next);
+void grpc_timer_list_init();
+void grpc_timer_list_shutdown();
/* Consume a kick issued by grpc_kick_poller */
void grpc_timer_consume_kick(void);
diff --git a/src/core/lib/iomgr/timer_generic.cc b/src/core/lib/iomgr/timer_generic.cc
index a4bfbcb342..861a85577b 100644
--- a/src/core/lib/iomgr/timer_generic.cc
+++ b/src/core/lib/iomgr/timer_generic.cc
@@ -228,8 +228,7 @@ static gpr_atm saturating_add(gpr_atm a, gpr_atm b) {
return a + b;
}
-static grpc_timer_check_result run_some_expired_timers(grpc_exec_ctx* exec_ctx,
- gpr_atm now,
+static grpc_timer_check_result run_some_expired_timers(gpr_atm now,
gpr_atm* next,
grpc_error* error);
@@ -239,7 +238,7 @@ static gpr_atm compute_min_deadline(timer_shard* shard) {
: grpc_timer_heap_top(&shard->heap)->deadline;
}
-void grpc_timer_list_init(grpc_exec_ctx* exec_ctx) {
+void grpc_timer_list_init() {
uint32_t i;
g_num_shards = GPR_MIN(1, 2 * gpr_cpu_num_cores());
@@ -250,7 +249,7 @@ void grpc_timer_list_init(grpc_exec_ctx* exec_ctx) {
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);
+ g_shared_mutables.min_timer = grpc_core::ExecCtx::Get()->Now();
gpr_tls_init(&g_last_seen_min_timer);
gpr_tls_set(&g_last_seen_min_timer, 0);
grpc_register_tracer(&grpc_timer_trace);
@@ -272,10 +271,10 @@ void grpc_timer_list_init(grpc_exec_ctx* exec_ctx) {
INIT_TIMER_HASH_TABLE();
}
-void grpc_timer_list_shutdown(grpc_exec_ctx* exec_ctx) {
+void grpc_timer_list_shutdown() {
size_t i;
run_some_expired_timers(
- exec_ctx, GPR_ATM_MAX, nullptr,
+ GPR_ATM_MAX, nullptr,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Timer list shutdown"));
for (i = 0; i < g_num_shards; i++) {
timer_shard* shard = &g_shards[i];
@@ -328,8 +327,8 @@ static void note_deadline_change(timer_shard* shard) {
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) {
+void grpc_timer_init(grpc_timer* timer, grpc_millis deadline,
+ grpc_closure* closure) {
int is_first_timer = 0;
timer_shard* shard = &g_shards[GPR_HASH_POINTER(timer, g_num_shards)];
timer->closure = closure;
@@ -342,12 +341,12 @@ void grpc_timer_init(grpc_exec_ctx* exec_ctx, grpc_timer* timer,
if (GRPC_TRACER_ON(grpc_timer_trace)) {
gpr_log(GPR_DEBUG,
"TIMER %p: SET %" PRIdPTR " now %" PRIdPTR " call %p[%p]", timer,
- deadline, grpc_exec_ctx_now(exec_ctx), closure, closure->cb);
+ deadline, grpc_core::ExecCtx::Get()->Now(), closure, closure->cb);
}
if (!g_shared_mutables.initialized) {
timer->pending = false;
- GRPC_CLOSURE_SCHED(exec_ctx, timer->closure,
+ GRPC_CLOSURE_SCHED(timer->closure,
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Attempt to create timer before initialization"));
return;
@@ -355,10 +354,10 @@ void grpc_timer_init(grpc_exec_ctx* exec_ctx, grpc_timer* timer,
gpr_mu_lock(&shard->mu);
timer->pending = true;
- grpc_millis now = grpc_exec_ctx_now(exec_ctx);
+ grpc_millis now = grpc_core::ExecCtx::Get()->Now();
if (deadline <= now) {
timer->pending = false;
- GRPC_CLOSURE_SCHED(exec_ctx, timer->closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(timer->closure, GRPC_ERROR_NONE);
gpr_mu_unlock(&shard->mu);
/* early out */
return;
@@ -419,7 +418,7 @@ void grpc_timer_consume_kick(void) {
gpr_tls_set(&g_last_seen_min_timer, 0);
}
-void grpc_timer_cancel(grpc_exec_ctx* exec_ctx, grpc_timer* timer) {
+void grpc_timer_cancel(grpc_timer* timer) {
if (!g_shared_mutables.initialized) {
/* must have already been cancelled, also the shard mutex is invalid */
return;
@@ -435,7 +434,7 @@ void grpc_timer_cancel(grpc_exec_ctx* exec_ctx, grpc_timer* timer) {
if (timer->pending) {
REMOVE_FROM_HASH_TABLE(timer);
- GRPC_CLOSURE_SCHED(exec_ctx, timer->closure, GRPC_ERROR_CANCELLED);
+ GRPC_CLOSURE_SCHED(timer->closure, GRPC_ERROR_CANCELLED);
timer->pending = false;
if (timer->heap_index == INVALID_HEAP_INDEX) {
list_remove(timer);
@@ -521,15 +520,14 @@ static grpc_timer* pop_one(timer_shard* shard, gpr_atm now) {
}
/* REQUIRES: shard->mu unlocked */
-static size_t pop_timers(grpc_exec_ctx* exec_ctx, timer_shard* shard,
- gpr_atm now, gpr_atm* new_min_deadline,
- grpc_error* error) {
+static size_t pop_timers(timer_shard* shard, gpr_atm now,
+ gpr_atm* new_min_deadline, grpc_error* error) {
size_t n = 0;
grpc_timer* timer;
gpr_mu_lock(&shard->mu);
while ((timer = pop_one(shard, now))) {
REMOVE_FROM_HASH_TABLE(timer);
- GRPC_CLOSURE_SCHED(exec_ctx, timer->closure, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(timer->closure, GRPC_ERROR_REF(error));
n++;
}
*new_min_deadline = compute_min_deadline(shard);
@@ -541,8 +539,7 @@ static size_t pop_timers(grpc_exec_ctx* exec_ctx, timer_shard* shard,
return n;
}
-static grpc_timer_check_result run_some_expired_timers(grpc_exec_ctx* exec_ctx,
- gpr_atm now,
+static grpc_timer_check_result run_some_expired_timers(gpr_atm now,
gpr_atm* next,
grpc_error* error) {
grpc_timer_check_result result = GRPC_TIMERS_NOT_CHECKED;
@@ -571,8 +568,7 @@ static grpc_timer_check_result run_some_expired_timers(grpc_exec_ctx* exec_ctx,
/* For efficiency, we pop as many available timers as we can from the
shard. This may violate perfect timer deadline ordering, but that
shouldn't be a big deal because we don't make ordering guarantees. */
- if (pop_timers(exec_ctx, g_shard_queue[0], now, &new_min_deadline,
- error) > 0) {
+ if (pop_timers(g_shard_queue[0], now, &new_min_deadline, error) > 0) {
result = GRPC_TIMERS_FIRED;
}
@@ -609,10 +605,9 @@ static grpc_timer_check_result run_some_expired_timers(grpc_exec_ctx* exec_ctx,
return result;
}
-grpc_timer_check_result grpc_timer_check(grpc_exec_ctx* exec_ctx,
- grpc_millis* next) {
+grpc_timer_check_result grpc_timer_check(grpc_millis* next) {
// prelude
- grpc_millis now = grpc_exec_ctx_now(exec_ctx);
+ grpc_millis now = grpc_core::ExecCtx::Get()->Now();
/* fetch from a thread-local first: this avoids contention on a globally
mutable cacheline in the common case */
@@ -651,7 +646,7 @@ grpc_timer_check_result grpc_timer_check(grpc_exec_ctx* exec_ctx,
}
// actual code
grpc_timer_check_result r =
- run_some_expired_timers(exec_ctx, now, next, shutdown_error);
+ run_some_expired_timers(now, next, shutdown_error);
// tracing
if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
char* next_str;
diff --git a/src/core/lib/iomgr/timer_manager.cc b/src/core/lib/iomgr/timer_manager.cc
index acc40b6c9e..dfa381a1f1 100644
--- a/src/core/lib/iomgr/timer_manager.cc
+++ b/src/core/lib/iomgr/timer_manager.cc
@@ -98,13 +98,12 @@ static void start_timer_thread_and_unlock(void) {
}
void grpc_timer_manager_tick() {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_millis next = GRPC_MILLIS_INF_FUTURE;
- grpc_timer_check(&exec_ctx, &next);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_timer_check(&next);
}
-static void run_some_timers(grpc_exec_ctx* exec_ctx) {
+static void run_some_timers() {
// if there's something to execute...
gpr_mu_lock(&g_mu);
// remove a waiter from the pool, and start another thread if necessary
@@ -126,7 +125,7 @@ static void run_some_timers(grpc_exec_ctx* exec_ctx) {
if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
gpr_log(GPR_DEBUG, "flush exec_ctx");
}
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&g_mu);
// garbage collect any threads hanging out that are dead
gc_completed_threads();
@@ -138,7 +137,7 @@ static void run_some_timers(grpc_exec_ctx* exec_ctx) {
// wait until 'next' (or forever if there is already a timed waiter in the pool)
// returns true if the thread should continue executing (false if it should
// shutdown)
-static bool wait_until(grpc_exec_ctx* exec_ctx, grpc_millis next) {
+static bool wait_until(grpc_millis next) {
gpr_mu_lock(&g_mu);
// if we're not threaded anymore, leave
if (!g_threaded) {
@@ -179,7 +178,7 @@ static bool wait_until(grpc_exec_ctx* exec_ctx, grpc_millis next) {
g_timed_waiter_deadline = next;
if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
- grpc_millis wait_time = next - grpc_exec_ctx_now(exec_ctx);
+ grpc_millis wait_time = next - grpc_core::ExecCtx::Get()->Now();
gpr_log(GPR_DEBUG, "sleep for a %" PRIdPTR " milliseconds",
wait_time);
}
@@ -221,19 +220,18 @@ static bool wait_until(grpc_exec_ctx* exec_ctx, grpc_millis next) {
return true;
}
-static void timer_main_loop(grpc_exec_ctx* exec_ctx) {
+static void timer_main_loop() {
for (;;) {
grpc_millis next = GRPC_MILLIS_INF_FUTURE;
- grpc_exec_ctx_invalidate_now(exec_ctx);
-
+ grpc_core::ExecCtx::Get()->InvalidateNow();
/* Calibrate g_start_time in exec_ctx.cc with a regular interval in case the
* system clock has changed */
- grpc_exec_ctx_maybe_update_start_time(exec_ctx);
+ grpc_exec_ctx_maybe_update_start_time();
// check timer state, updates next to the next time to run a check
- switch (grpc_timer_check(exec_ctx, &next)) {
+ switch (grpc_timer_check(&next)) {
case GRPC_TIMERS_FIRED:
- run_some_timers(exec_ctx);
+ run_some_timers();
break;
case GRPC_TIMERS_NOT_CHECKED:
/* This case only happens under contention, meaning more than one timer
@@ -251,7 +249,7 @@ static void timer_main_loop(grpc_exec_ctx* exec_ctx) {
next = GRPC_MILLIS_INF_FUTURE;
/* fall through */
case GRPC_TIMERS_CHECKED_AND_EMPTY:
- if (!wait_until(exec_ctx, next)) {
+ if (!wait_until(next)) {
return;
}
break;
@@ -279,10 +277,9 @@ static void timer_thread_cleanup(completed_thread* ct) {
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, nullptr);
- timer_main_loop(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx(0);
+ timer_main_loop();
+
timer_thread_cleanup((completed_thread*)completed_thread_ptr);
}
diff --git a/src/core/lib/iomgr/timer_uv.cc b/src/core/lib/iomgr/timer_uv.cc
index df40e54ae6..1432eba51e 100644
--- a/src/core/lib/iomgr/timer_uv.cc
+++ b/src/core/lib/iomgr/timer_uv.cc
@@ -45,28 +45,27 @@ static void stop_uv_timer(uv_timer_t* handle) {
void run_expired_timer(uv_timer_t* handle) {
grpc_timer* timer = (grpc_timer*)handle->data;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GRPC_UV_ASSERT_SAME_THREAD();
GPR_ASSERT(timer->pending);
timer->pending = 0;
- GRPC_CLOSURE_SCHED(&exec_ctx, timer->closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(timer->closure, GRPC_ERROR_NONE);
stop_uv_timer(handle);
- grpc_exec_ctx_finish(&exec_ctx);
}
-void grpc_timer_init(grpc_exec_ctx* exec_ctx, grpc_timer* timer,
- grpc_millis deadline, grpc_closure* closure) {
+void grpc_timer_init(grpc_timer* timer, grpc_millis deadline,
+ grpc_closure* closure) {
uint64_t timeout;
uv_timer_t* uv_timer;
GRPC_UV_ASSERT_SAME_THREAD();
timer->closure = closure;
- if (deadline <= grpc_exec_ctx_now(exec_ctx)) {
+ if (deadline <= grpc_core::ExecCtx::Get()->Now()) {
timer->pending = 0;
- GRPC_CLOSURE_SCHED(exec_ctx, timer->closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(timer->closure, GRPC_ERROR_NONE);
return;
}
timer->pending = 1;
- timeout = (uint64_t)(deadline - grpc_exec_ctx_now(exec_ctx));
+ timeout = (uint64_t)(deadline - grpc_core::ExecCtx::Get()->Now());
uv_timer = (uv_timer_t*)gpr_malloc(sizeof(uv_timer_t));
uv_timer_init(uv_default_loop(), uv_timer);
uv_timer->data = timer;
@@ -80,22 +79,21 @@ void grpc_timer_init(grpc_exec_ctx* exec_ctx, grpc_timer* timer,
void grpc_timer_init_unset(grpc_timer* timer) { timer->pending = 0; }
-void grpc_timer_cancel(grpc_exec_ctx* exec_ctx, grpc_timer* timer) {
+void grpc_timer_cancel(grpc_timer* timer) {
GRPC_UV_ASSERT_SAME_THREAD();
if (timer->pending) {
timer->pending = 0;
- GRPC_CLOSURE_SCHED(exec_ctx, timer->closure, GRPC_ERROR_CANCELLED);
+ GRPC_CLOSURE_SCHED(timer->closure, GRPC_ERROR_CANCELLED);
stop_uv_timer((uv_timer_t*)timer->uv_timer);
}
}
-grpc_timer_check_result grpc_timer_check(grpc_exec_ctx* exec_ctx,
- grpc_millis* next) {
+grpc_timer_check_result grpc_timer_check(grpc_millis* next) {
return GRPC_TIMERS_NOT_CHECKED;
}
-void grpc_timer_list_init(grpc_exec_ctx* exec_ctx) {}
-void grpc_timer_list_shutdown(grpc_exec_ctx* exec_ctx) {}
+void grpc_timer_list_init() {}
+void grpc_timer_list_shutdown() {}
void grpc_timer_consume_kick(void) {}
diff --git a/src/core/lib/iomgr/udp_server.cc b/src/core/lib/iomgr/udp_server.cc
index 68ab9355ca..d4de04a894 100644
--- a/src/core/lib/iomgr/udp_server.cc
+++ b/src/core/lib/iomgr/udp_server.cc
@@ -141,22 +141,21 @@ grpc_udp_server* grpc_udp_server_create(const grpc_channel_args* args) {
return s;
}
-static void shutdown_fd(grpc_exec_ctx* exec_ctx, void* args,
- grpc_error* error) {
+static void shutdown_fd(void* args, grpc_error* error) {
struct shutdown_fd_args* shutdown_args = (struct shutdown_fd_args*)args;
gpr_mu_lock(shutdown_args->server_mu);
- grpc_fd_shutdown(exec_ctx, shutdown_args->fd, GRPC_ERROR_REF(error));
+ grpc_fd_shutdown(shutdown_args->fd, GRPC_ERROR_REF(error));
gpr_mu_unlock(shutdown_args->server_mu);
gpr_free(shutdown_args);
}
-static void dummy_cb(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void dummy_cb(void* arg, grpc_error* error) {
// No-op.
}
-static void finish_shutdown(grpc_exec_ctx* exec_ctx, grpc_udp_server* s) {
+static void finish_shutdown(grpc_udp_server* s) {
if (s->shutdown_complete != nullptr) {
- GRPC_CLOSURE_SCHED(exec_ctx, s->shutdown_complete, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(s->shutdown_complete, GRPC_ERROR_NONE);
}
gpr_mu_destroy(&s->mu);
@@ -174,14 +173,13 @@ static void finish_shutdown(grpc_exec_ctx* exec_ctx, grpc_udp_server* s) {
gpr_free(s);
}
-static void destroyed_port(grpc_exec_ctx* exec_ctx, void* server,
- grpc_error* error) {
+static void destroyed_port(void* server, grpc_error* error) {
grpc_udp_server* s = (grpc_udp_server*)server;
gpr_mu_lock(&s->mu);
s->destroyed_ports++;
if (s->destroyed_ports == s->nports) {
gpr_mu_unlock(&s->mu);
- finish_shutdown(exec_ctx, s);
+ finish_shutdown(s);
} else {
gpr_mu_unlock(&s->mu);
}
@@ -190,7 +188,7 @@ static void destroyed_port(grpc_exec_ctx* exec_ctx, void* server,
/* called when all listening endpoints have been shutdown, so no further
events will be received on them - at this point it's safe to destroy
things */
-static void deactivated_all_ports(grpc_exec_ctx* exec_ctx, grpc_udp_server* s) {
+static void deactivated_all_ports(grpc_udp_server* s) {
/* delete ALL the things */
gpr_mu_lock(&s->mu);
@@ -210,21 +208,19 @@ static void deactivated_all_ports(grpc_exec_ctx* exec_ctx, grpc_udp_server* s) {
GRPC_CLOSURE_INIT(&sp->orphan_fd_closure, dummy_cb, sp->emfd,
grpc_schedule_on_exec_ctx);
GPR_ASSERT(sp->orphan_cb);
- sp->orphan_cb(exec_ctx, sp->emfd, &sp->orphan_fd_closure,
- sp->server->user_data);
+ sp->orphan_cb(sp->emfd, &sp->orphan_fd_closure, sp->server->user_data);
}
- grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, nullptr,
+ grpc_fd_orphan(sp->emfd, &sp->destroyed_closure, nullptr,
false /* already_closed */, "udp_listener_shutdown");
}
gpr_mu_unlock(&s->mu);
} else {
gpr_mu_unlock(&s->mu);
- finish_shutdown(exec_ctx, s);
+ finish_shutdown(s);
}
}
-void grpc_udp_server_destroy(grpc_exec_ctx* exec_ctx, grpc_udp_server* s,
- grpc_closure* on_done) {
+void grpc_udp_server_destroy(grpc_udp_server* s, grpc_closure* on_done) {
grpc_udp_listener* sp;
gpr_mu_lock(&s->mu);
@@ -243,14 +239,13 @@ void grpc_udp_server_destroy(grpc_exec_ctx* exec_ctx, grpc_udp_server* s,
args->server_mu = &s->mu;
GRPC_CLOSURE_INIT(&sp->orphan_fd_closure, shutdown_fd, args,
grpc_schedule_on_exec_ctx);
- sp->orphan_cb(exec_ctx, sp->emfd, &sp->orphan_fd_closure,
- sp->server->user_data);
+ sp->orphan_cb(sp->emfd, &sp->orphan_fd_closure, sp->server->user_data);
sp->orphan_notified = true;
}
gpr_mu_unlock(&s->mu);
} else {
gpr_mu_unlock(&s->mu);
- deactivated_all_ports(exec_ctx, s);
+ deactivated_all_ports(s);
}
}
@@ -330,14 +325,14 @@ error:
}
/* event manager callback when reads are ready */
-static void on_read(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void on_read(void* arg, grpc_error* error) {
grpc_udp_listener* sp = (grpc_udp_listener*)arg;
gpr_mu_lock(&sp->server->mu);
if (error != GRPC_ERROR_NONE) {
if (0 == --sp->server->active_ports && sp->server->shutdown) {
gpr_mu_unlock(&sp->server->mu);
- deactivated_all_ports(exec_ctx, sp->server);
+ deactivated_all_ports(sp->server);
} else {
gpr_mu_unlock(&sp->server->mu);
}
@@ -346,21 +341,21 @@ static void on_read(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
/* Tell the registered callback that data is available to read. */
GPR_ASSERT(sp->read_cb);
- sp->read_cb(exec_ctx, sp->emfd, sp->server->user_data);
+ sp->read_cb(sp->emfd, sp->server->user_data);
/* Re-arm the notification event so we get another chance to read. */
- grpc_fd_notify_on_read(exec_ctx, sp->emfd, &sp->read_closure);
+ grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
gpr_mu_unlock(&sp->server->mu);
}
-static void on_write(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void on_write(void* arg, grpc_error* error) {
grpc_udp_listener* sp = (grpc_udp_listener*)arg;
gpr_mu_lock(&(sp->server->mu));
if (error != GRPC_ERROR_NONE) {
if (0 == --sp->server->active_ports && sp->server->shutdown) {
gpr_mu_unlock(&sp->server->mu);
- deactivated_all_ports(exec_ctx, sp->server);
+ deactivated_all_ports(sp->server);
} else {
gpr_mu_unlock(&sp->server->mu);
}
@@ -369,10 +364,10 @@ static void on_write(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
/* 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);
+ sp->write_cb(sp->emfd, sp->server->user_data);
/* 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_fd_notify_on_write(sp->emfd, &sp->write_closure);
gpr_mu_unlock(&sp->server->mu);
}
@@ -512,9 +507,8 @@ int grpc_udp_server_get_fd(grpc_udp_server* s, unsigned port_index) {
return sp->fd;
}
-void grpc_udp_server_start(grpc_exec_ctx* exec_ctx, grpc_udp_server* s,
- grpc_pollset** pollsets, size_t pollset_count,
- void* user_data) {
+void grpc_udp_server_start(grpc_udp_server* s, grpc_pollset** pollsets,
+ size_t pollset_count, void* user_data) {
size_t i;
gpr_mu_lock(&s->mu);
grpc_udp_listener* sp;
@@ -525,15 +519,15 @@ void grpc_udp_server_start(grpc_exec_ctx* exec_ctx, grpc_udp_server* s,
sp = s->head;
while (sp != nullptr) {
for (i = 0; i < pollset_count; i++) {
- grpc_pollset_add_fd(exec_ctx, pollsets[i], sp->emfd);
+ grpc_pollset_add_fd(pollsets[i], sp->emfd);
}
GRPC_CLOSURE_INIT(&sp->read_closure, on_read, sp,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_read(exec_ctx, sp->emfd, &sp->read_closure);
+ grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
GRPC_CLOSURE_INIT(&sp->write_closure, on_write, sp,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_write(exec_ctx, sp->emfd, &sp->write_closure);
+ grpc_fd_notify_on_write(sp->emfd, &sp->write_closure);
/* Registered for both read and write callbacks: increment active_ports
* twice to account for this, and delay free-ing of memory until both
diff --git a/src/core/lib/iomgr/udp_server.h b/src/core/lib/iomgr/udp_server.h
index bca0f049fb..ff68474430 100644
--- a/src/core/lib/iomgr/udp_server.h
+++ b/src/core/lib/iomgr/udp_server.h
@@ -35,16 +35,13 @@ struct grpc_server;
typedef struct grpc_udp_server grpc_udp_server;
/* Called when data is available to read from the socket. */
-typedef void (*grpc_udp_server_read_cb)(grpc_exec_ctx* exec_ctx, grpc_fd* emfd,
- void* user_data);
+typedef void (*grpc_udp_server_read_cb)(grpc_fd* emfd, void* user_data);
/* Called when the socket is writeable. */
-typedef void (*grpc_udp_server_write_cb)(grpc_exec_ctx* exec_ctx, grpc_fd* emfd,
- void* user_data);
+typedef void (*grpc_udp_server_write_cb)(grpc_fd* emfd, void* user_data);
/* Called when the grpc_fd is about to be orphaned (and the FD closed). */
-typedef void (*grpc_udp_server_orphan_cb)(grpc_exec_ctx* exec_ctx,
- grpc_fd* emfd,
+typedef void (*grpc_udp_server_orphan_cb)(grpc_fd* emfd,
grpc_closure* shutdown_fd_callback,
void* user_data);
@@ -52,9 +49,8 @@ typedef void (*grpc_udp_server_orphan_cb)(grpc_exec_ctx* exec_ctx,
grpc_udp_server* grpc_udp_server_create(const grpc_channel_args* args);
/* Start listening to bound ports. user_data is passed to callbacks. */
-void grpc_udp_server_start(grpc_exec_ctx* exec_ctx, grpc_udp_server* udp_server,
- grpc_pollset** pollsets, size_t pollset_count,
- void* user_data);
+void grpc_udp_server_start(grpc_udp_server* udp_server, grpc_pollset** pollsets,
+ size_t pollset_count, void* user_data);
int grpc_udp_server_get_fd(grpc_udp_server* s, unsigned port_index);
@@ -74,8 +70,7 @@ int grpc_udp_server_add_port(grpc_udp_server* s,
grpc_udp_server_write_cb write_cb,
grpc_udp_server_orphan_cb orphan_cb);
-void grpc_udp_server_destroy(grpc_exec_ctx* exec_ctx, grpc_udp_server* server,
- grpc_closure* on_done);
+void grpc_udp_server_destroy(grpc_udp_server* server, grpc_closure* on_done);
#ifdef __cplusplus
}
diff --git a/src/core/lib/security/context/security_context.cc b/src/core/lib/security/context/security_context.cc
index 36362d95bb..7d9b4fbcb2 100644
--- a/src/core/lib/security/context/security_context.cc
+++ b/src/core/lib/security/context/security_context.cc
@@ -38,7 +38,7 @@ grpc_tracer_flag grpc_trace_auth_context_refcount =
grpc_call_error grpc_call_set_credentials(grpc_call* call,
grpc_call_credentials* creds) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_client_security_context* ctx = nullptr;
GRPC_API_TRACE("grpc_call_set_credentials(call=%p, creds=%p)", 2,
(call, creds));
@@ -54,10 +54,10 @@ grpc_call_error grpc_call_set_credentials(grpc_call* call,
grpc_call_context_set(call, GRPC_CONTEXT_SECURITY, ctx,
grpc_client_security_context_destroy);
} else {
- grpc_call_credentials_unref(&exec_ctx, ctx->creds);
+ grpc_call_credentials_unref(ctx->creds);
ctx->creds = grpc_call_credentials_ref(creds);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
return GRPC_CALL_OK;
}
@@ -87,15 +87,14 @@ grpc_client_security_context* grpc_client_security_context_create(void) {
}
void grpc_client_security_context_destroy(void* ctx) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_client_security_context* c = (grpc_client_security_context*)ctx;
- grpc_call_credentials_unref(&exec_ctx, c->creds);
+ grpc_call_credentials_unref(c->creds);
GRPC_AUTH_CONTEXT_UNREF(c->auth_context, "client_security_context");
if (c->extension.instance != nullptr && c->extension.destroy != nullptr) {
c->extension.destroy(c->extension.instance);
}
gpr_free(ctx);
- grpc_exec_ctx_finish(&exec_ctx);
}
/* --- grpc_server_security_context --- */
@@ -143,7 +142,7 @@ grpc_auth_context* grpc_auth_context_ref(grpc_auth_context* ctx,
}
#else
grpc_auth_context* grpc_auth_context_ref(grpc_auth_context* ctx) {
- if (ctx == NULL) return NULL;
+ if (ctx == nullptr) return nullptr;
#endif
gpr_ref(&ctx->refcount);
return ctx;
@@ -161,7 +160,7 @@ void grpc_auth_context_unref(grpc_auth_context* ctx, const char* file, int line,
}
#else
void grpc_auth_context_unref(grpc_auth_context* ctx) {
- if (ctx == NULL) return;
+ if (ctx == nullptr) return;
#endif
if (gpr_unref(&ctx->refcount)) {
size_t i;
@@ -305,7 +304,7 @@ void grpc_auth_property_reset(grpc_auth_property* property) {
memset(property, 0, sizeof(grpc_auth_property));
}
-static void auth_context_pointer_arg_destroy(grpc_exec_ctx* exec_ctx, void* p) {
+static void auth_context_pointer_arg_destroy(void* p) {
GRPC_AUTH_CONTEXT_UNREF((grpc_auth_context*)p, "auth_context_pointer_arg");
}
diff --git a/src/core/lib/security/credentials/composite/composite_credentials.cc b/src/core/lib/security/credentials/composite/composite_credentials.cc
index 93dd721240..e4c1604795 100644
--- a/src/core/lib/security/credentials/composite/composite_credentials.cc
+++ b/src/core/lib/security/credentials/composite/composite_credentials.cc
@@ -39,17 +39,15 @@ typedef struct {
grpc_closure internal_on_request_metadata;
} grpc_composite_call_credentials_metadata_context;
-static void composite_call_destruct(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds) {
+static void composite_call_destruct(grpc_call_credentials* creds) {
grpc_composite_call_credentials* c = (grpc_composite_call_credentials*)creds;
for (size_t i = 0; i < c->inner.num_creds; i++) {
- grpc_call_credentials_unref(exec_ctx, c->inner.creds_array[i]);
+ grpc_call_credentials_unref(c->inner.creds_array[i]);
}
gpr_free(c->inner.creds_array);
}
-static void composite_call_metadata_cb(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void composite_call_metadata_cb(void* arg, grpc_error* error) {
grpc_composite_call_credentials_metadata_context* ctx =
(grpc_composite_call_credentials_metadata_context*)arg;
if (error == GRPC_ERROR_NONE) {
@@ -58,23 +56,23 @@ static void composite_call_metadata_cb(grpc_exec_ctx* exec_ctx, void* arg,
grpc_call_credentials* inner_creds =
ctx->composite_creds->inner.creds_array[ctx->creds_index++];
if (grpc_call_credentials_get_request_metadata(
- exec_ctx, inner_creds, ctx->pollent, ctx->auth_md_context,
- ctx->md_array, &ctx->internal_on_request_metadata, &error)) {
+ inner_creds, ctx->pollent, ctx->auth_md_context, ctx->md_array,
+ &ctx->internal_on_request_metadata, &error)) {
// Synchronous response, so call ourselves recursively.
- composite_call_metadata_cb(exec_ctx, arg, error);
+ composite_call_metadata_cb(arg, error);
GRPC_ERROR_UNREF(error);
}
return;
}
// We're done!
}
- GRPC_CLOSURE_SCHED(exec_ctx, ctx->on_request_metadata, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(ctx->on_request_metadata, GRPC_ERROR_REF(error));
gpr_free(ctx);
}
static bool composite_call_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_polling_entity* pollent, grpc_auth_metadata_context auth_md_context,
+ grpc_call_credentials* creds, grpc_polling_entity* pollent,
+ grpc_auth_metadata_context auth_md_context,
grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata,
grpc_error** error) {
grpc_composite_call_credentials* c = (grpc_composite_call_credentials*)creds;
@@ -93,8 +91,8 @@ static bool composite_call_get_request_metadata(
grpc_call_credentials* inner_creds =
ctx->composite_creds->inner.creds_array[ctx->creds_index++];
if (grpc_call_credentials_get_request_metadata(
- exec_ctx, inner_creds, ctx->pollent, ctx->auth_md_context,
- ctx->md_array, &ctx->internal_on_request_metadata, error)) {
+ inner_creds, ctx->pollent, ctx->auth_md_context, ctx->md_array,
+ &ctx->internal_on_request_metadata, error)) {
if (*error != GRPC_ERROR_NONE) break;
} else {
synchronous = false; // Async return.
@@ -106,12 +104,12 @@ static bool composite_call_get_request_metadata(
}
static void composite_call_cancel_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_credentials_mdelem_array* md_array, grpc_error* error) {
+ grpc_call_credentials* creds, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
grpc_composite_call_credentials* c = (grpc_composite_call_credentials*)creds;
for (size_t i = 0; i < c->inner.num_creds; ++i) {
grpc_call_credentials_cancel_get_request_metadata(
- exec_ctx, c->inner.creds_array[i], md_array, GRPC_ERROR_REF(error));
+ c->inner.creds_array[i], md_array, GRPC_ERROR_REF(error));
}
GRPC_ERROR_UNREF(error);
}
@@ -200,19 +198,17 @@ grpc_call_credentials* grpc_credentials_contains_type(
/* -- Composite channel credentials. -- */
-static void composite_channel_destruct(grpc_exec_ctx* exec_ctx,
- grpc_channel_credentials* creds) {
+static void composite_channel_destruct(grpc_channel_credentials* creds) {
grpc_composite_channel_credentials* c =
(grpc_composite_channel_credentials*)creds;
- grpc_channel_credentials_unref(exec_ctx, c->inner_creds);
- grpc_call_credentials_unref(exec_ctx, c->call_creds);
+ grpc_channel_credentials_unref(c->inner_creds);
+ grpc_call_credentials_unref(c->call_creds);
}
static grpc_security_status composite_channel_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* creds,
- grpc_call_credentials* call_creds, const char* target,
- const grpc_channel_args* args, grpc_channel_security_connector** sc,
- grpc_channel_args** new_args) {
+ grpc_channel_credentials* creds, grpc_call_credentials* call_creds,
+ const char* target, const grpc_channel_args* args,
+ grpc_channel_security_connector** sc, grpc_channel_args** new_args) {
grpc_composite_channel_credentials* c =
(grpc_composite_channel_credentials*)creds;
grpc_security_status status = GRPC_SECURITY_ERROR;
@@ -227,12 +223,11 @@ static grpc_security_status composite_channel_create_security_connector(
grpc_composite_call_credentials_create(c->call_creds, call_creds,
nullptr);
status = c->inner_creds->vtable->create_security_connector(
- exec_ctx, c->inner_creds, composite_call_creds, target, args, sc,
- new_args);
- grpc_call_credentials_unref(exec_ctx, composite_call_creds);
+ c->inner_creds, composite_call_creds, target, args, sc, new_args);
+ grpc_call_credentials_unref(composite_call_creds);
} else {
status = c->inner_creds->vtable->create_security_connector(
- exec_ctx, c->inner_creds, c->call_creds, target, args, sc, new_args);
+ c->inner_creds, c->call_creds, target, args, sc, new_args);
}
return status;
}
diff --git a/src/core/lib/security/credentials/credentials.cc b/src/core/lib/security/credentials/credentials.cc
index 90576e69b9..d8a98fa3f0 100644
--- a/src/core/lib/security/credentials/credentials.cc
+++ b/src/core/lib/security/credentials/credentials.cc
@@ -47,8 +47,8 @@ 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) {
- grpc_call_credentials_unref(exec_ctx, r->creds);
+ grpc_credentials_metadata_request* r) {
+ grpc_call_credentials_unref(r->creds);
grpc_http_response_destroy(&r->response);
gpr_free(r);
}
@@ -60,12 +60,11 @@ grpc_channel_credentials* grpc_channel_credentials_ref(
return creds;
}
-void grpc_channel_credentials_unref(grpc_exec_ctx* exec_ctx,
- grpc_channel_credentials* creds) {
+void grpc_channel_credentials_unref(grpc_channel_credentials* creds) {
if (creds == nullptr) return;
if (gpr_unref(&creds->refcount)) {
if (creds->vtable->destruct != nullptr) {
- creds->vtable->destruct(exec_ctx, creds);
+ creds->vtable->destruct(creds);
}
gpr_free(creds);
}
@@ -73,9 +72,8 @@ void grpc_channel_credentials_unref(grpc_exec_ctx* exec_ctx,
void grpc_channel_credentials_release(grpc_channel_credentials* creds) {
GRPC_API_TRACE("grpc_channel_credentials_release(creds=%p)", 1, (creds));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_credentials_unref(creds);
}
grpc_call_credentials* grpc_call_credentials_ref(grpc_call_credentials* creds) {
@@ -84,12 +82,11 @@ grpc_call_credentials* grpc_call_credentials_ref(grpc_call_credentials* creds) {
return creds;
}
-void grpc_call_credentials_unref(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds) {
+void grpc_call_credentials_unref(grpc_call_credentials* creds) {
if (creds == nullptr) return;
if (gpr_unref(&creds->refcount)) {
if (creds->vtable->destruct != nullptr) {
- creds->vtable->destruct(exec_ctx, creds);
+ creds->vtable->destruct(creds);
}
gpr_free(creds);
}
@@ -97,44 +94,42 @@ void grpc_call_credentials_unref(grpc_exec_ctx* exec_ctx,
void grpc_call_credentials_release(grpc_call_credentials* creds) {
GRPC_API_TRACE("grpc_call_credentials_release(creds=%p)", 1, (creds));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_call_credentials_unref(creds);
}
bool grpc_call_credentials_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_polling_entity* pollent, grpc_auth_metadata_context context,
- grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata,
- grpc_error** error) {
+ grpc_call_credentials* creds, grpc_polling_entity* pollent,
+ grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array,
+ grpc_closure* on_request_metadata, grpc_error** error) {
if (creds == nullptr || creds->vtable->get_request_metadata == nullptr) {
return true;
}
- return creds->vtable->get_request_metadata(
- exec_ctx, creds, pollent, context, md_array, on_request_metadata, error);
+ return creds->vtable->get_request_metadata(creds, pollent, context, md_array,
+ on_request_metadata, error);
}
void grpc_call_credentials_cancel_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_credentials_mdelem_array* md_array, grpc_error* error) {
+ grpc_call_credentials* creds, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
if (creds == nullptr ||
creds->vtable->cancel_get_request_metadata == nullptr) {
return;
}
- creds->vtable->cancel_get_request_metadata(exec_ctx, creds, md_array, error);
+ creds->vtable->cancel_get_request_metadata(creds, md_array, error);
}
grpc_security_status grpc_channel_credentials_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* channel_creds,
- const char* target, const grpc_channel_args* args,
- grpc_channel_security_connector** sc, grpc_channel_args** new_args) {
+ grpc_channel_credentials* channel_creds, const char* target,
+ const grpc_channel_args* args, grpc_channel_security_connector** sc,
+ grpc_channel_args** new_args) {
*new_args = nullptr;
if (channel_creds == nullptr) {
return GRPC_SECURITY_ERROR;
}
GPR_ASSERT(channel_creds->vtable->create_security_connector != nullptr);
return channel_creds->vtable->create_security_connector(
- exec_ctx, channel_creds, nullptr, target, args, sc, new_args);
+ channel_creds, nullptr, target, args, sc, new_args);
}
grpc_channel_credentials*
@@ -149,8 +144,8 @@ grpc_channel_credentials_duplicate_without_call_credentials(
}
}
-static void credentials_pointer_arg_destroy(grpc_exec_ctx* exec_ctx, void* p) {
- grpc_channel_credentials_unref(exec_ctx, (grpc_channel_credentials*)p);
+static void credentials_pointer_arg_destroy(void* p) {
+ grpc_channel_credentials_unref((grpc_channel_credentials*)p);
}
static void* credentials_pointer_arg_copy(void* p) {
@@ -200,12 +195,11 @@ grpc_server_credentials* grpc_server_credentials_ref(
return creds;
}
-void grpc_server_credentials_unref(grpc_exec_ctx* exec_ctx,
- grpc_server_credentials* creds) {
+void grpc_server_credentials_unref(grpc_server_credentials* creds) {
if (creds == nullptr) return;
if (gpr_unref(&creds->refcount)) {
if (creds->vtable->destruct != nullptr) {
- creds->vtable->destruct(exec_ctx, creds);
+ creds->vtable->destruct(creds);
}
if (creds->processor.destroy != nullptr &&
creds->processor.state != nullptr) {
@@ -217,19 +211,17 @@ void grpc_server_credentials_unref(grpc_exec_ctx* exec_ctx,
void grpc_server_credentials_release(grpc_server_credentials* creds) {
GRPC_API_TRACE("grpc_server_credentials_release(creds=%p)", 1, (creds));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_server_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_server_credentials_unref(creds);
}
grpc_security_status grpc_server_credentials_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_server_credentials* creds,
- grpc_server_security_connector** sc) {
+ grpc_server_credentials* creds, grpc_server_security_connector** sc) {
if (creds == nullptr || creds->vtable->create_security_connector == nullptr) {
gpr_log(GPR_ERROR, "Server credentials cannot create security context.");
return GRPC_SECURITY_ERROR;
}
- return creds->vtable->create_security_connector(exec_ctx, creds, sc);
+ return creds->vtable->create_security_connector(creds, sc);
}
void grpc_server_credentials_set_auth_metadata_processor(
@@ -247,9 +239,8 @@ void grpc_server_credentials_set_auth_metadata_processor(
creds->processor = processor;
}
-static void server_credentials_pointer_arg_destroy(grpc_exec_ctx* exec_ctx,
- void* p) {
- grpc_server_credentials_unref(exec_ctx, (grpc_server_credentials*)p);
+static void server_credentials_pointer_arg_destroy(void* p) {
+ grpc_server_credentials_unref((grpc_server_credentials*)p);
}
static void* server_credentials_pointer_arg_copy(void* p) {
diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h
index c65b9660ea..7d3368857e 100644
--- a/src/core/lib/security/credentials/credentials.h
+++ b/src/core/lib/security/credentials/credentials.h
@@ -92,13 +92,12 @@ void grpc_override_well_known_credentials_path_getter(
#define GRPC_ARG_CHANNEL_CREDENTIALS "grpc.channel_credentials"
typedef struct {
- void (*destruct)(grpc_exec_ctx* exec_ctx, grpc_channel_credentials* c);
+ void (*destruct)(grpc_channel_credentials* c);
grpc_security_status (*create_security_connector)(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* c,
- grpc_call_credentials* call_creds, const char* target,
- const grpc_channel_args* args, grpc_channel_security_connector** sc,
- grpc_channel_args** new_args);
+ grpc_channel_credentials* c, grpc_call_credentials* call_creds,
+ const char* target, const grpc_channel_args* args,
+ grpc_channel_security_connector** sc, grpc_channel_args** new_args);
grpc_channel_credentials* (*duplicate_without_call_credentials)(
grpc_channel_credentials* c);
@@ -112,17 +111,16 @@ struct grpc_channel_credentials {
grpc_channel_credentials* grpc_channel_credentials_ref(
grpc_channel_credentials* creds);
-void grpc_channel_credentials_unref(grpc_exec_ctx* exec_ctx,
- grpc_channel_credentials* creds);
+void grpc_channel_credentials_unref(grpc_channel_credentials* creds);
/* Creates a security connector for the channel. May also create new channel
args for the channel to be used in place of the passed in const args if
returned non NULL. In that case the caller is responsible for destroying
new_args after channel creation. */
grpc_security_status grpc_channel_credentials_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* creds,
- const char* target, const grpc_channel_args* args,
- grpc_channel_security_connector** sc, grpc_channel_args** new_args);
+ grpc_channel_credentials* creds, const char* target,
+ const grpc_channel_args* args, grpc_channel_security_connector** sc,
+ grpc_channel_args** new_args);
/* Creates a version of the channel credentials without any attached call
credentials. This can be used in order to open a channel to a non-trusted
@@ -157,22 +155,19 @@ void grpc_credentials_mdelem_array_add(grpc_credentials_mdelem_array* list,
void grpc_credentials_mdelem_array_append(grpc_credentials_mdelem_array* dst,
grpc_credentials_mdelem_array* src);
-void grpc_credentials_mdelem_array_destroy(grpc_exec_ctx* exec_ctx,
- grpc_credentials_mdelem_array* list);
+void grpc_credentials_mdelem_array_destroy(grpc_credentials_mdelem_array* list);
/* --- grpc_call_credentials. --- */
typedef struct {
- void (*destruct)(grpc_exec_ctx* exec_ctx, grpc_call_credentials* c);
- bool (*get_request_metadata)(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* c,
+ void (*destruct)(grpc_call_credentials* c);
+ bool (*get_request_metadata)(grpc_call_credentials* c,
grpc_polling_entity* pollent,
grpc_auth_metadata_context context,
grpc_credentials_mdelem_array* md_array,
grpc_closure* on_request_metadata,
grpc_error** error);
- void (*cancel_get_request_metadata)(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* c,
+ void (*cancel_get_request_metadata)(grpc_call_credentials* c,
grpc_credentials_mdelem_array* md_array,
grpc_error* error);
} grpc_call_credentials_vtable;
@@ -184,39 +179,35 @@ struct grpc_call_credentials {
};
grpc_call_credentials* grpc_call_credentials_ref(grpc_call_credentials* creds);
-void grpc_call_credentials_unref(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds);
+void grpc_call_credentials_unref(grpc_call_credentials* creds);
/// Returns true if completed synchronously, in which case \a error will
/// be set to indicate the result. Otherwise, \a on_request_metadata will
/// be invoked asynchronously when complete. \a md_array will be populated
/// with the resulting metadata once complete.
bool grpc_call_credentials_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_polling_entity* pollent, grpc_auth_metadata_context context,
- grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata,
- grpc_error** error);
+ grpc_call_credentials* creds, grpc_polling_entity* pollent,
+ grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array,
+ grpc_closure* on_request_metadata, grpc_error** error);
/// Cancels a pending asynchronous operation started by
/// grpc_call_credentials_get_request_metadata() with the corresponding
/// value of \a md_array.
void grpc_call_credentials_cancel_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* c,
- grpc_credentials_mdelem_array* md_array, grpc_error* error);
+ grpc_call_credentials* c, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error);
/* Metadata-only credentials with the specified key and value where
asynchronicity can be simulated for testing. */
grpc_call_credentials* grpc_md_only_test_credentials_create(
- grpc_exec_ctx* exec_ctx, const char* md_key, const char* md_value,
- bool is_async);
+ const char* md_key, const char* md_value, bool is_async);
/* --- grpc_server_credentials. --- */
typedef struct {
- void (*destruct)(grpc_exec_ctx* exec_ctx, grpc_server_credentials* c);
+ void (*destruct)(grpc_server_credentials* c);
grpc_security_status (*create_security_connector)(
- grpc_exec_ctx* exec_ctx, grpc_server_credentials* c,
- grpc_server_security_connector** sc);
+ grpc_server_credentials* c, grpc_server_security_connector** sc);
} grpc_server_credentials_vtable;
struct grpc_server_credentials {
@@ -227,14 +218,12 @@ struct grpc_server_credentials {
};
grpc_security_status grpc_server_credentials_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_server_credentials* creds,
- grpc_server_security_connector** sc);
+ grpc_server_credentials* creds, grpc_server_security_connector** sc);
grpc_server_credentials* grpc_server_credentials_ref(
grpc_server_credentials* creds);
-void grpc_server_credentials_unref(grpc_exec_ctx* exec_ctx,
- grpc_server_credentials* creds);
+void grpc_server_credentials_unref(grpc_server_credentials* creds);
#define GRPC_SERVER_CREDENTIALS_ARG "grpc.server_credentials"
@@ -254,7 +243,7 @@ grpc_credentials_metadata_request* grpc_credentials_metadata_request_create(
grpc_call_credentials* creds);
void grpc_credentials_metadata_request_destroy(
- grpc_exec_ctx* exec_ctx, grpc_credentials_metadata_request* r);
+ grpc_credentials_metadata_request* r);
#ifdef __cplusplus
}
diff --git a/src/core/lib/security/credentials/credentials_metadata.cc b/src/core/lib/security/credentials/credentials_metadata.cc
index a3623fa1d6..9ceaf21139 100644
--- a/src/core/lib/security/credentials/credentials_metadata.cc
+++ b/src/core/lib/security/credentials/credentials_metadata.cc
@@ -52,9 +52,9 @@ void grpc_credentials_mdelem_array_append(grpc_credentials_mdelem_array* dst,
}
void grpc_credentials_mdelem_array_destroy(
- grpc_exec_ctx* exec_ctx, grpc_credentials_mdelem_array* list) {
+ grpc_credentials_mdelem_array* list) {
for (size_t i = 0; i < list->size; ++i) {
- GRPC_MDELEM_UNREF(exec_ctx, list->md[i]);
+ GRPC_MDELEM_UNREF(list->md[i]);
}
gpr_free(list->md);
}
diff --git a/src/core/lib/security/credentials/fake/fake_credentials.cc b/src/core/lib/security/credentials/fake/fake_credentials.cc
index a535a317ee..99b1214951 100644
--- a/src/core/lib/security/credentials/fake/fake_credentials.cc
+++ b/src/core/lib/security/credentials/fake/fake_credentials.cc
@@ -34,10 +34,9 @@
"grpc.fake_security.expected_targets"
static grpc_security_status fake_transport_security_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* c,
- grpc_call_credentials* call_creds, const char* target,
- const grpc_channel_args* args, grpc_channel_security_connector** sc,
- grpc_channel_args** new_args) {
+ grpc_channel_credentials* c, grpc_call_credentials* call_creds,
+ const char* target, const grpc_channel_args* args,
+ grpc_channel_security_connector** sc, grpc_channel_args** new_args) {
*sc =
grpc_fake_channel_security_connector_create(c, call_creds, target, args);
return GRPC_SECURITY_OK;
@@ -45,8 +44,7 @@ static grpc_security_status fake_transport_security_create_security_connector(
static grpc_security_status
fake_transport_security_server_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_server_credentials* c,
- grpc_server_security_connector** sc) {
+ grpc_server_credentials* c, grpc_server_security_connector** sc) {
*sc = grpc_fake_server_security_connector_create(c);
return GRPC_SECURITY_OK;
}
@@ -98,29 +96,27 @@ const char* grpc_fake_transport_get_expected_targets(
/* -- Metadata-only test credentials. -- */
-static void md_only_test_destruct(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds) {
+static void md_only_test_destruct(grpc_call_credentials* creds) {
grpc_md_only_test_credentials* c = (grpc_md_only_test_credentials*)creds;
- GRPC_MDELEM_UNREF(exec_ctx, c->md);
+ GRPC_MDELEM_UNREF(c->md);
}
static bool md_only_test_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_polling_entity* pollent, grpc_auth_metadata_context context,
- grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata,
- grpc_error** error) {
+ grpc_call_credentials* creds, grpc_polling_entity* pollent,
+ grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array,
+ grpc_closure* on_request_metadata, grpc_error** error) {
grpc_md_only_test_credentials* c = (grpc_md_only_test_credentials*)creds;
grpc_credentials_mdelem_array_add(md_array, c->md);
if (c->is_async) {
- GRPC_CLOSURE_SCHED(exec_ctx, on_request_metadata, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_request_metadata, GRPC_ERROR_NONE);
return false;
}
return true;
}
static void md_only_test_cancel_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* c,
- grpc_credentials_mdelem_array* md_array, grpc_error* error) {
+ grpc_call_credentials* c, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
GRPC_ERROR_UNREF(error);
}
@@ -129,16 +125,14 @@ static grpc_call_credentials_vtable md_only_test_vtable = {
md_only_test_cancel_get_request_metadata};
grpc_call_credentials* grpc_md_only_test_credentials_create(
- grpc_exec_ctx* exec_ctx, const char* md_key, const char* md_value,
- bool is_async) {
+ const char* md_key, const char* md_value, bool is_async) {
grpc_md_only_test_credentials* c = (grpc_md_only_test_credentials*)gpr_zalloc(
sizeof(grpc_md_only_test_credentials));
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_OAUTH2;
c->base.vtable = &md_only_test_vtable;
gpr_ref_init(&c->base.refcount, 1);
- c->md =
- grpc_mdelem_from_slices(exec_ctx, grpc_slice_from_copied_string(md_key),
- grpc_slice_from_copied_string(md_value));
+ c->md = grpc_mdelem_from_slices(grpc_slice_from_copied_string(md_key),
+ grpc_slice_from_copied_string(md_value));
c->is_async = is_async;
return &c->base;
}
diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.cc b/src/core/lib/security/credentials/google_default/google_default_credentials.cc
index f586c7b604..072dffe035 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
@@ -58,8 +58,7 @@ typedef struct {
grpc_http_response response;
} compute_engine_detector;
-static void on_compute_engine_detection_http_response(grpc_exec_ctx* exec_ctx,
- void* user_data,
+static void on_compute_engine_detection_http_response(void* user_data,
grpc_error* error) {
compute_engine_detector* detector = (compute_engine_detector*)user_data;
if (error == GRPC_ERROR_NONE && detector->response.status == 200 &&
@@ -80,16 +79,16 @@ static void on_compute_engine_detection_http_response(grpc_exec_ctx* exec_ctx,
detector->is_done = 1;
GRPC_LOG_IF_ERROR(
"Pollset kick",
- grpc_pollset_kick(
- exec_ctx, grpc_polling_entity_pollset(&detector->pollent), nullptr));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&detector->pollent),
+ nullptr));
gpr_mu_unlock(g_polling_mu);
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, grpc_error* e) {
- grpc_pollset_destroy(exec_ctx, (grpc_pollset*)p);
+static void destroy_pollset(void* p, grpc_error* e) {
+ grpc_pollset_destroy((grpc_pollset*)p);
}
-static int is_stack_running_on_compute_engine(grpc_exec_ctx* exec_ctx) {
+static int is_stack_running_on_compute_engine() {
compute_engine_detector detector;
grpc_httpcli_request request;
grpc_httpcli_context context;
@@ -115,14 +114,14 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx* exec_ctx) {
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("google_default_credentials");
grpc_httpcli_get(
- exec_ctx, &context, &detector.pollent, resource_quota, &request,
- grpc_exec_ctx_now(exec_ctx) + max_detection_delay,
+ &context, &detector.pollent, resource_quota, &request,
+ grpc_core::ExecCtx::Get()->Now() + max_detection_delay,
GRPC_CLOSURE_CREATE(on_compute_engine_detection_http_response, &detector,
grpc_schedule_on_exec_ctx),
&detector.response);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
/* Block until we get the response. This is not ideal but this should only be
called once for the lifetime of the process by the default credentials. */
@@ -131,8 +130,7 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx* exec_ctx) {
grpc_pollset_worker* worker = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(exec_ctx,
- grpc_polling_entity_pollset(&detector.pollent),
+ grpc_pollset_work(grpc_polling_entity_pollset(&detector.pollent),
&worker, GRPC_MILLIS_INF_FUTURE))) {
detector.is_done = 1;
detector.success = 0;
@@ -140,15 +138,14 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx* exec_ctx) {
}
gpr_mu_unlock(g_polling_mu);
- grpc_httpcli_context_destroy(exec_ctx, &context);
+ grpc_httpcli_context_destroy(&context);
GRPC_CLOSURE_INIT(&destroy_closure, destroy_pollset,
grpc_polling_entity_pollset(&detector.pollent),
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(exec_ctx,
- grpc_polling_entity_pollset(&detector.pollent),
+ grpc_pollset_shutdown(grpc_polling_entity_pollset(&detector.pollent),
&destroy_closure);
g_polling_mu = nullptr;
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(grpc_polling_entity_pollset(&detector.pollent));
grpc_http_response_destroy(&detector.response);
@@ -158,7 +155,7 @@ 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) {
+ char* creds_path, grpc_call_credentials** creds) {
grpc_json* json = nullptr;
grpc_auth_json_key key;
grpc_auth_refresh_token token;
@@ -187,7 +184,7 @@ static grpc_error* create_default_creds_from_path(
if (grpc_auth_json_key_is_valid(&key)) {
result =
grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
- exec_ctx, key, grpc_max_auth_token_lifetime());
+ key, grpc_max_auth_token_lifetime());
if (result == nullptr) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"grpc_service_account_jwt_access_credentials_create_from_auth_json_"
@@ -212,7 +209,7 @@ static grpc_error* create_default_creds_from_path(
end:
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);
+ grpc_slice_unref_internal(creds_data);
if (json != nullptr) grpc_json_destroy(json);
*creds = result;
return error;
@@ -224,7 +221,7 @@ grpc_channel_credentials* grpc_google_default_credentials_create(void) {
grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Failed to create Google credentials");
grpc_error* err;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GRPC_API_TRACE("grpc_google_default_credentials_create(void)", 0, ());
@@ -239,22 +236,20 @@ grpc_channel_credentials* grpc_google_default_credentials_create(void) {
/* First, try the environment variable. */
err = create_default_creds_from_path(
- &exec_ctx, gpr_getenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR), &call_creds);
+ gpr_getenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR), &call_creds);
if (err == GRPC_ERROR_NONE) goto end;
error = grpc_error_add_child(error, err);
/* Then the well-known file. */
err = create_default_creds_from_path(
- &exec_ctx, grpc_get_well_known_google_credentials_file_path(),
- &call_creds);
+ grpc_get_well_known_google_credentials_file_path(), &call_creds);
if (err == GRPC_ERROR_NONE) goto end;
error = grpc_error_add_child(error, err);
/* At last try to see if we're on compute engine (do the detection only once
since it requires a network test). */
if (!compute_engine_detection_done) {
- int need_compute_engine_creds =
- is_stack_running_on_compute_engine(&exec_ctx);
+ int need_compute_engine_creds = is_stack_running_on_compute_engine();
compute_engine_detection_done = 1;
if (need_compute_engine_creds) {
call_creds = grpc_google_compute_engine_credentials_create(nullptr);
@@ -278,8 +273,8 @@ end:
grpc_composite_channel_credentials_create(ssl_creds, call_creds,
nullptr));
GPR_ASSERT(default_credentials != nullptr);
- grpc_channel_credentials_unref(&exec_ctx, ssl_creds);
- grpc_call_credentials_unref(&exec_ctx, call_creds);
+ grpc_channel_credentials_unref(ssl_creds);
+ grpc_call_credentials_unref(call_creds);
result = default_credentials;
} else {
gpr_log(GPR_ERROR, "Could not create google default credentials.");
@@ -291,21 +286,20 @@ end:
} else {
GRPC_ERROR_UNREF(error);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
return result;
}
void grpc_flush_cached_google_default_credentials(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_once_init(&g_once, init_default_credentials);
gpr_mu_lock(&g_state_mu);
if (default_credentials != nullptr) {
- grpc_channel_credentials_unref(&exec_ctx, default_credentials);
+ grpc_channel_credentials_unref(default_credentials);
default_credentials = nullptr;
}
compute_engine_detection_done = 0;
gpr_mu_unlock(&g_state_mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
/* -- Well known credentials path. -- */
diff --git a/src/core/lib/security/credentials/iam/iam_credentials.cc b/src/core/lib/security/credentials/iam/iam_credentials.cc
index 1741bf3068..3b01137ed9 100644
--- a/src/core/lib/security/credentials/iam/iam_credentials.cc
+++ b/src/core/lib/security/credentials/iam/iam_credentials.cc
@@ -27,14 +27,12 @@
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
-static void iam_destruct(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds) {
+static void iam_destruct(grpc_call_credentials* creds) {
grpc_google_iam_credentials* c = (grpc_google_iam_credentials*)creds;
- grpc_credentials_mdelem_array_destroy(exec_ctx, &c->md_array);
+ grpc_credentials_mdelem_array_destroy(&c->md_array);
}
-static bool iam_get_request_metadata(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds,
+static bool iam_get_request_metadata(grpc_call_credentials* creds,
grpc_polling_entity* pollent,
grpc_auth_metadata_context context,
grpc_credentials_mdelem_array* md_array,
@@ -46,8 +44,8 @@ static bool iam_get_request_metadata(grpc_exec_ctx* exec_ctx,
}
static void iam_cancel_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* c,
- grpc_credentials_mdelem_array* md_array, grpc_error* error) {
+ grpc_call_credentials* c, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
GRPC_ERROR_UNREF(error);
}
@@ -56,7 +54,7 @@ static grpc_call_credentials_vtable iam_vtable = {
grpc_call_credentials* grpc_google_iam_credentials_create(
const char* token, const char* authority_selector, void* reserved) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GRPC_API_TRACE(
"grpc_iam_credentials_create(token=%s, authority_selector=%s, "
"reserved=%p)",
@@ -70,17 +68,15 @@ grpc_call_credentials* grpc_google_iam_credentials_create(
c->base.vtable = &iam_vtable;
gpr_ref_init(&c->base.refcount, 1);
grpc_mdelem md = grpc_mdelem_from_slices(
- &exec_ctx,
grpc_slice_from_static_string(GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY),
grpc_slice_from_copied_string(token));
grpc_credentials_mdelem_array_add(&c->md_array, md);
- GRPC_MDELEM_UNREF(&exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
md = grpc_mdelem_from_slices(
- &exec_ctx,
grpc_slice_from_static_string(GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY),
grpc_slice_from_copied_string(authority_selector));
grpc_credentials_mdelem_array_add(&c->md_array, md);
- GRPC_MDELEM_UNREF(&exec_ctx, md);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(md);
+
return &c->base;
}
diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.cc b/src/core/lib/security/credentials/jwt/jwt_credentials.cc
index d666e6b658..df26b4e2c0 100644
--- a/src/core/lib/security/credentials/jwt/jwt_credentials.cc
+++ b/src/core/lib/security/credentials/jwt/jwt_credentials.cc
@@ -30,9 +30,8 @@
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
-static void jwt_reset_cache(grpc_exec_ctx* exec_ctx,
- grpc_service_account_jwt_access_credentials* c) {
- GRPC_MDELEM_UNREF(exec_ctx, c->cached.jwt_md);
+static void jwt_reset_cache(grpc_service_account_jwt_access_credentials* c) {
+ GRPC_MDELEM_UNREF(c->cached.jwt_md);
c->cached.jwt_md = GRPC_MDNULL;
if (c->cached.service_url != nullptr) {
gpr_free(c->cached.service_url);
@@ -41,17 +40,15 @@ static void jwt_reset_cache(grpc_exec_ctx* exec_ctx,
c->cached.jwt_expiration = gpr_inf_past(GPR_CLOCK_REALTIME);
}
-static void jwt_destruct(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds) {
+static void jwt_destruct(grpc_call_credentials* creds) {
grpc_service_account_jwt_access_credentials* c =
(grpc_service_account_jwt_access_credentials*)creds;
grpc_auth_json_key_destruct(&c->key);
- jwt_reset_cache(exec_ctx, c);
+ jwt_reset_cache(c);
gpr_mu_destroy(&c->cache_mu);
}
-static bool jwt_get_request_metadata(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds,
+static bool jwt_get_request_metadata(grpc_call_credentials* creds,
grpc_polling_entity* pollent,
grpc_auth_metadata_context context,
grpc_credentials_mdelem_array* md_array,
@@ -81,7 +78,7 @@ static bool jwt_get_request_metadata(grpc_exec_ctx* exec_ctx,
char* jwt = nullptr;
/* Generate a new jwt. */
gpr_mu_lock(&c->cache_mu);
- jwt_reset_cache(exec_ctx, c);
+ jwt_reset_cache(c);
jwt = grpc_jwt_encode_and_sign(&c->key, context.service_url,
c->jwt_lifetime, nullptr);
if (jwt != nullptr) {
@@ -92,7 +89,6 @@ static bool jwt_get_request_metadata(grpc_exec_ctx* exec_ctx,
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), c->jwt_lifetime);
c->cached.service_url = gpr_strdup(context.service_url);
c->cached.jwt_md = grpc_mdelem_from_slices(
- exec_ctx,
grpc_slice_from_static_string(GRPC_AUTHORIZATION_METADATA_KEY),
grpc_slice_from_copied_string(md_value));
gpr_free(md_value);
@@ -103,7 +99,7 @@ static bool jwt_get_request_metadata(grpc_exec_ctx* exec_ctx,
if (!GRPC_MDISNULL(jwt_md)) {
grpc_credentials_mdelem_array_add(md_array, jwt_md);
- GRPC_MDELEM_UNREF(exec_ctx, jwt_md);
+ GRPC_MDELEM_UNREF(jwt_md);
} else {
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Could not generate JWT.");
}
@@ -111,8 +107,8 @@ static bool jwt_get_request_metadata(grpc_exec_ctx* exec_ctx,
}
static void jwt_cancel_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* c,
- grpc_credentials_mdelem_array* md_array, grpc_error* error) {
+ grpc_call_credentials* c, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
GRPC_ERROR_UNREF(error);
}
@@ -121,8 +117,7 @@ static grpc_call_credentials_vtable jwt_vtable = {
grpc_call_credentials*
grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
- grpc_exec_ctx* exec_ctx, grpc_auth_json_key key,
- gpr_timespec token_lifetime) {
+ grpc_auth_json_key key, gpr_timespec token_lifetime) {
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");
@@ -143,7 +138,7 @@ grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
}
c->jwt_lifetime = token_lifetime;
gpr_mu_init(&c->cache_mu);
- jwt_reset_cache(exec_ctx, c);
+ jwt_reset_cache(c);
return &c->base;
}
@@ -186,11 +181,10 @@ grpc_call_credentials* grpc_service_account_jwt_access_credentials_create(
gpr_free(clean_json);
}
GPR_ASSERT(reserved == nullptr);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_call_credentials* creds =
grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
- &exec_ctx, grpc_auth_json_key_create_from_string(json_key),
- token_lifetime);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_auth_json_key_create_from_string(json_key), token_lifetime);
+
return creds;
}
diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.h b/src/core/lib/security/credentials/jwt/jwt_credentials.h
index d554613eed..4e7b756b20 100644
--- a/src/core/lib/security/credentials/jwt/jwt_credentials.h
+++ b/src/core/lib/security/credentials/jwt/jwt_credentials.h
@@ -46,8 +46,7 @@ typedef struct {
// Takes ownership of the key.
grpc_call_credentials*
grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
- grpc_exec_ctx* exec_ctx, grpc_auth_json_key key,
- gpr_timespec token_lifetime);
+ grpc_auth_json_key key, gpr_timespec token_lifetime);
#ifdef __cplusplus
}
diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.cc b/src/core/lib/security/credentials/jwt/jwt_verifier.cc
index 3709b83c4e..dc67a20e6f 100644
--- a/src/core/lib/security/credentials/jwt/jwt_verifier.cc
+++ b/src/core/lib/security/credentials/jwt/jwt_verifier.cc
@@ -74,12 +74,11 @@ static const EVP_MD* evp_md_from_alg(const char* alg) {
}
}
-static grpc_json* parse_json_part_from_jwt(grpc_exec_ctx* exec_ctx,
- const char* str, size_t len,
+static grpc_json* parse_json_part_from_jwt(const char* str, size_t len,
grpc_slice* buffer) {
grpc_json* json;
- *buffer = grpc_base64_decode_with_len(exec_ctx, str, len, 1);
+ *buffer = grpc_base64_decode_with_len(str, len, 1);
if (GRPC_SLICE_IS_EMPTY(*buffer)) {
gpr_log(GPR_ERROR, "Invalid base64.");
return nullptr;
@@ -87,7 +86,7 @@ static grpc_json* parse_json_part_from_jwt(grpc_exec_ctx* exec_ctx,
json = grpc_json_parse_string_with_len((char*)GRPC_SLICE_START_PTR(*buffer),
GRPC_SLICE_LENGTH(*buffer));
if (json == nullptr) {
- grpc_slice_unref_internal(exec_ctx, *buffer);
+ grpc_slice_unref_internal(*buffer);
gpr_log(GPR_ERROR, "JSON parsing error.");
}
return json;
@@ -123,14 +122,13 @@ typedef struct {
grpc_slice buffer;
} jose_header;
-static void jose_header_destroy(grpc_exec_ctx* exec_ctx, jose_header* h) {
- grpc_slice_unref_internal(exec_ctx, h->buffer);
+static void jose_header_destroy(jose_header* h) {
+ grpc_slice_unref_internal(h->buffer);
gpr_free(h);
}
/* Takes ownership of json and buffer. */
-static jose_header* jose_header_from_json(grpc_exec_ctx* exec_ctx,
- grpc_json* json, grpc_slice buffer) {
+static jose_header* jose_header_from_json(grpc_json* json, grpc_slice buffer) {
grpc_json* cur;
jose_header* h = (jose_header*)gpr_zalloc(sizeof(jose_header));
h->buffer = buffer;
@@ -164,7 +162,7 @@ static jose_header* jose_header_from_json(grpc_exec_ctx* exec_ctx,
error:
grpc_json_destroy(json);
- jose_header_destroy(exec_ctx, h);
+ jose_header_destroy(h);
return nullptr;
}
@@ -184,9 +182,9 @@ struct grpc_jwt_claims {
grpc_slice buffer;
};
-void grpc_jwt_claims_destroy(grpc_exec_ctx* exec_ctx, grpc_jwt_claims* claims) {
+void grpc_jwt_claims_destroy(grpc_jwt_claims* claims) {
grpc_json_destroy(claims->json);
- grpc_slice_unref_internal(exec_ctx, claims->buffer);
+ grpc_slice_unref_internal(claims->buffer);
gpr_free(claims);
}
@@ -231,8 +229,7 @@ gpr_timespec grpc_jwt_claims_not_before(const grpc_jwt_claims* claims) {
}
/* Takes ownership of json and buffer even in case of failure. */
-grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_exec_ctx* exec_ctx,
- grpc_json* json, grpc_slice buffer) {
+grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_json* json, grpc_slice buffer) {
grpc_json* cur;
grpc_jwt_claims* claims =
(grpc_jwt_claims*)gpr_malloc(sizeof(grpc_jwt_claims));
@@ -274,7 +271,7 @@ grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_exec_ctx* exec_ctx,
return claims;
error:
- grpc_jwt_claims_destroy(exec_ctx, claims);
+ grpc_jwt_claims_destroy(claims);
return nullptr;
}
@@ -350,7 +347,7 @@ static verifier_cb_ctx* verifier_cb_ctx_create(
grpc_jwt_claims* claims, const char* audience, grpc_slice signature,
const char* signed_jwt, size_t signed_jwt_len, void* user_data,
grpc_jwt_verification_done_cb cb) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
verifier_cb_ctx* ctx = (verifier_cb_ctx*)gpr_zalloc(sizeof(verifier_cb_ctx));
ctx->verifier = verifier;
ctx->pollent = grpc_polling_entity_create_from_pollset(pollset);
@@ -361,16 +358,16 @@ static verifier_cb_ctx* verifier_cb_ctx_create(
ctx->signed_data = grpc_slice_from_copied_buffer(signed_jwt, signed_jwt_len);
ctx->user_data = user_data;
ctx->user_cb = cb;
- grpc_exec_ctx_finish(&exec_ctx);
+
return ctx;
}
-void verifier_cb_ctx_destroy(grpc_exec_ctx* exec_ctx, verifier_cb_ctx* ctx) {
+void verifier_cb_ctx_destroy(verifier_cb_ctx* ctx) {
if (ctx->audience != nullptr) gpr_free(ctx->audience);
- if (ctx->claims != nullptr) grpc_jwt_claims_destroy(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);
+ if (ctx->claims != nullptr) grpc_jwt_claims_destroy(ctx->claims);
+ grpc_slice_unref_internal(ctx->signature);
+ grpc_slice_unref_internal(ctx->signed_data);
+ jose_header_destroy(ctx->header);
for (size_t i = 0; i < HTTP_RESPONSE_COUNT; i++) {
grpc_http_response_destroy(&ctx->responses[i]);
}
@@ -450,19 +447,19 @@ end:
return result;
}
-static BIGNUM* bignum_from_base64(grpc_exec_ctx* exec_ctx, const char* b64) {
+static BIGNUM* bignum_from_base64(const char* b64) {
BIGNUM* result = nullptr;
grpc_slice bin;
if (b64 == nullptr) return nullptr;
- bin = grpc_base64_decode(exec_ctx, b64, 1);
+ bin = grpc_base64_decode(b64, 1);
if (GRPC_SLICE_IS_EMPTY(bin)) {
gpr_log(GPR_ERROR, "Invalid base64 for big num.");
return nullptr;
}
result = BN_bin2bn(GRPC_SLICE_START_PTR(bin),
TSI_SIZE_AS_SIZE(GRPC_SLICE_LENGTH(bin)), nullptr);
- grpc_slice_unref_internal(exec_ctx, bin);
+ grpc_slice_unref_internal(bin);
return result;
}
@@ -495,8 +492,7 @@ static int RSA_set0_key(RSA* r, BIGNUM* n, BIGNUM* e, BIGNUM* d) {
}
#endif // OPENSSL_VERSION_NUMBER < 0x10100000L
-static EVP_PKEY* pkey_from_jwk(grpc_exec_ctx* exec_ctx, const grpc_json* json,
- const char* kty) {
+static EVP_PKEY* pkey_from_jwk(const grpc_json* json, const char* kty) {
const grpc_json* key_prop;
RSA* rsa = nullptr;
EVP_PKEY* result = nullptr;
@@ -515,12 +511,10 @@ static EVP_PKEY* pkey_from_jwk(grpc_exec_ctx* exec_ctx, const grpc_json* json,
}
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"));
+ tmp_n = bignum_from_base64(validate_string_field(key_prop, "n"));
if (tmp_n == nullptr) goto end;
} else if (strcmp(key_prop->key, "e") == 0) {
- tmp_e =
- bignum_from_base64(exec_ctx, validate_string_field(key_prop, "e"));
+ tmp_e = bignum_from_base64(validate_string_field(key_prop, "e"));
if (tmp_e == nullptr) goto end;
}
}
@@ -545,8 +539,7 @@ end:
return result;
}
-static EVP_PKEY* find_verification_key(grpc_exec_ctx* exec_ctx,
- const grpc_json* json,
+static EVP_PKEY* find_verification_key(const grpc_json* json,
const char* header_alg,
const char* header_kid) {
const grpc_json* jkey;
@@ -591,7 +584,7 @@ static EVP_PKEY* find_verification_key(grpc_exec_ctx* exec_ctx,
}
if (alg != nullptr && kid != nullptr && kty != nullptr &&
strcmp(kid, header_kid) == 0 && strcmp(alg, header_alg) == 0) {
- return pkey_from_jwk(exec_ctx, jkey, kty);
+ return pkey_from_jwk(jkey, kty);
}
}
gpr_log(GPR_ERROR,
@@ -632,8 +625,7 @@ end:
return result;
}
-static void on_keys_retrieved(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_error* error) {
+static void on_keys_retrieved(void* user_data, grpc_error* error) {
verifier_cb_ctx* ctx = (verifier_cb_ctx*)user_data;
grpc_json* json = json_from_http(&ctx->responses[HTTP_RESPONSE_KEYS]);
EVP_PKEY* verification_key = nullptr;
@@ -645,7 +637,7 @@ static void on_keys_retrieved(grpc_exec_ctx* exec_ctx, void* user_data,
goto end;
}
verification_key =
- find_verification_key(exec_ctx, json, ctx->header->alg, ctx->header->kid);
+ find_verification_key(json, ctx->header->alg, ctx->header->kid);
if (verification_key == nullptr) {
gpr_log(GPR_ERROR, "Could not find verification key with kid %s.",
ctx->header->kid);
@@ -669,12 +661,11 @@ static void on_keys_retrieved(grpc_exec_ctx* exec_ctx, void* user_data,
end:
if (json != nullptr) grpc_json_destroy(json);
EVP_PKEY_free(verification_key);
- ctx->user_cb(exec_ctx, ctx->user_data, status, claims);
- verifier_cb_ctx_destroy(exec_ctx, ctx);
+ ctx->user_cb(ctx->user_data, status, claims);
+ verifier_cb_ctx_destroy(ctx);
}
-static void on_openid_config_retrieved(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_error* error) {
+static void on_openid_config_retrieved(void* user_data, grpc_error* error) {
const grpc_json* cur;
verifier_cb_ctx* ctx = (verifier_cb_ctx*)user_data;
const grpc_http_response* response = &ctx->responses[HTTP_RESPONSE_OPENID];
@@ -711,20 +702,19 @@ static void on_openid_config_retrieved(grpc_exec_ctx* exec_ctx, void* user_data,
extreme memory pressure. */
resource_quota = grpc_resource_quota_create("jwt_verifier");
grpc_httpcli_get(
- exec_ctx, &ctx->verifier->http_ctx, &ctx->pollent, resource_quota, &req,
- grpc_exec_ctx_now(exec_ctx) + grpc_jwt_verifier_max_delay,
+ &ctx->verifier->http_ctx, &ctx->pollent, resource_quota, &req,
+ grpc_core::ExecCtx::Get()->Now() + grpc_jwt_verifier_max_delay,
GRPC_CLOSURE_CREATE(on_keys_retrieved, ctx, grpc_schedule_on_exec_ctx),
&ctx->responses[HTTP_RESPONSE_KEYS]);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
grpc_json_destroy(json);
gpr_free(req.host);
return;
error:
if (json != nullptr) grpc_json_destroy(json);
- ctx->user_cb(exec_ctx, ctx->user_data, GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR,
- nullptr);
- verifier_cb_ctx_destroy(exec_ctx, ctx);
+ ctx->user_cb(ctx->user_data, GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR, nullptr);
+ verifier_cb_ctx_destroy(ctx);
}
static email_key_mapping* verifier_get_mapping(grpc_jwt_verifier* v,
@@ -772,8 +762,7 @@ const char* grpc_jwt_issuer_email_domain(const char* issuer) {
}
/* Takes ownership of ctx. */
-static void retrieve_key_and_verify(grpc_exec_ctx* exec_ctx,
- verifier_cb_ctx* ctx) {
+static void retrieve_key_and_verify(verifier_cb_ctx* ctx) {
const char* email_domain;
grpc_closure* http_cb;
char* path_prefix = nullptr;
@@ -840,23 +829,21 @@ static void retrieve_key_and_verify(grpc_exec_ctx* exec_ctx,
channel. This would allow us to cancel an authentication query when under
extreme memory pressure. */
resource_quota = grpc_resource_quota_create("jwt_verifier");
- grpc_httpcli_get(exec_ctx, &ctx->verifier->http_ctx, &ctx->pollent,
- resource_quota, &req,
- grpc_exec_ctx_now(exec_ctx) + grpc_jwt_verifier_max_delay,
- http_cb, &ctx->responses[rsp_idx]);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_httpcli_get(
+ &ctx->verifier->http_ctx, &ctx->pollent, resource_quota, &req,
+ grpc_core::ExecCtx::Get()->Now() + grpc_jwt_verifier_max_delay, http_cb,
+ &ctx->responses[rsp_idx]);
+ grpc_resource_quota_unref_internal(resource_quota);
gpr_free(req.host);
gpr_free(req.http.path);
return;
error:
- ctx->user_cb(exec_ctx, ctx->user_data, GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR,
- nullptr);
- verifier_cb_ctx_destroy(exec_ctx, ctx);
+ ctx->user_cb(ctx->user_data, GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR, nullptr);
+ verifier_cb_ctx_destroy(ctx);
}
-void grpc_jwt_verifier_verify(grpc_exec_ctx* exec_ctx,
- grpc_jwt_verifier* verifier,
+void grpc_jwt_verifier_verify(grpc_jwt_verifier* verifier,
grpc_pollset* pollset, const char* jwt,
const char* audience,
grpc_jwt_verification_done_cb cb,
@@ -875,35 +862,32 @@ void grpc_jwt_verifier_verify(grpc_exec_ctx* exec_ctx,
cb != nullptr);
dot = strchr(cur, '.');
if (dot == nullptr) goto error;
- json = parse_json_part_from_jwt(exec_ctx, cur, (size_t)(dot - cur),
- &header_buffer);
+ json = parse_json_part_from_jwt(cur, (size_t)(dot - cur), &header_buffer);
if (json == nullptr) goto error;
- header = jose_header_from_json(exec_ctx, json, header_buffer);
+ header = jose_header_from_json(json, header_buffer);
if (header == nullptr) goto error;
cur = dot + 1;
dot = strchr(cur, '.');
if (dot == nullptr) goto error;
- json = parse_json_part_from_jwt(exec_ctx, cur, (size_t)(dot - cur),
- &claims_buffer);
+ json = parse_json_part_from_jwt(cur, (size_t)(dot - cur), &claims_buffer);
if (json == nullptr) goto error;
- claims = grpc_jwt_claims_from_json(exec_ctx, json, claims_buffer);
+ claims = grpc_jwt_claims_from_json(json, claims_buffer);
if (claims == nullptr) goto error;
signed_jwt_len = (size_t)(dot - jwt);
cur = dot + 1;
- signature = grpc_base64_decode(exec_ctx, cur, 1);
+ signature = grpc_base64_decode(cur, 1);
if (GRPC_SLICE_IS_EMPTY(signature)) goto error;
retrieve_key_and_verify(
- exec_ctx,
verifier_cb_ctx_create(verifier, pollset, header, claims, audience,
signature, jwt, signed_jwt_len, user_data, cb));
return;
error:
- if (header != 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);
+ if (header != nullptr) jose_header_destroy(header);
+ if (claims != nullptr) grpc_jwt_claims_destroy(claims);
+ cb(user_data, GRPC_JWT_VERIFIER_BAD_FORMAT, nullptr);
}
grpc_jwt_verifier* grpc_jwt_verifier_create(
@@ -930,10 +914,10 @@ grpc_jwt_verifier* grpc_jwt_verifier_create(
return v;
}
-void grpc_jwt_verifier_destroy(grpc_exec_ctx* exec_ctx, grpc_jwt_verifier* v) {
+void grpc_jwt_verifier_destroy(grpc_jwt_verifier* v) {
size_t i;
if (v == nullptr) return;
- grpc_httpcli_context_destroy(exec_ctx, &v->http_ctx);
+ grpc_httpcli_context_destroy(&v->http_ctx);
if (v->mappings != nullptr) {
for (i = 0; i < v->num_mappings; i++) {
gpr_free(v->mappings[i].email_domain);
diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.h b/src/core/lib/security/credentials/jwt/jwt_verifier.h
index 8083cf9beb..545be71923 100644
--- a/src/core/lib/security/credentials/jwt/jwt_verifier.h
+++ b/src/core/lib/security/credentials/jwt/jwt_verifier.h
@@ -55,7 +55,7 @@ const char* grpc_jwt_verifier_status_to_string(grpc_jwt_verifier_status status);
typedef struct grpc_jwt_claims grpc_jwt_claims;
-void grpc_jwt_claims_destroy(grpc_exec_ctx* exec_ctx, grpc_jwt_claims* claims);
+void grpc_jwt_claims_destroy(grpc_jwt_claims* claims);
/* Returns the whole JSON tree of the claims. */
const grpc_json* grpc_jwt_claims_json(const grpc_jwt_claims* claims);
@@ -98,21 +98,18 @@ grpc_jwt_verifier* grpc_jwt_verifier_create(
size_t num_mappings);
/*The verifier must not be destroyed if there are still outstanding callbacks.*/
-void grpc_jwt_verifier_destroy(grpc_exec_ctx* exec_ctx,
- grpc_jwt_verifier* verifier);
+void grpc_jwt_verifier_destroy(grpc_jwt_verifier* verifier);
/* User provided callback that will be called when the verification of the JWT
is done (maybe in another thread).
It is the responsibility of the callee to call grpc_jwt_claims_destroy on
the claims. */
-typedef void (*grpc_jwt_verification_done_cb)(grpc_exec_ctx* exec_ctx,
- void* user_data,
+typedef void (*grpc_jwt_verification_done_cb)(void* user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims);
/* Verifies for the JWT for the given expected audience. */
-void grpc_jwt_verifier_verify(grpc_exec_ctx* exec_ctx,
- grpc_jwt_verifier* verifier,
+void grpc_jwt_verifier_verify(grpc_jwt_verifier* verifier,
grpc_pollset* pollset, const char* jwt,
const char* audience,
grpc_jwt_verification_done_cb cb,
@@ -120,8 +117,7 @@ void grpc_jwt_verifier_verify(grpc_exec_ctx* exec_ctx,
/* --- TESTING ONLY exposed functions. --- */
-grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_exec_ctx* exec_ctx,
- grpc_json* json, grpc_slice buffer);
+grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_json* json, grpc_slice buffer);
grpc_jwt_verifier_status grpc_jwt_claims_check(const grpc_jwt_claims* claims,
const char* audience);
const char* grpc_jwt_issuer_email_domain(const char* issuer);
diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
index 943d23f21e..f95df0f021 100644
--- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
+++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
@@ -103,21 +103,19 @@ void grpc_auth_refresh_token_destruct(grpc_auth_refresh_token* refresh_token) {
// Oauth2 Token Fetcher credentials.
//
-static void oauth2_token_fetcher_destruct(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds) {
+static void oauth2_token_fetcher_destruct(grpc_call_credentials* creds) {
grpc_oauth2_token_fetcher_credentials* c =
(grpc_oauth2_token_fetcher_credentials*)creds;
- GRPC_MDELEM_UNREF(exec_ctx, c->access_token_md);
+ GRPC_MDELEM_UNREF(c->access_token_md);
gpr_mu_destroy(&c->mu);
- grpc_pollset_set_destroy(exec_ctx,
- grpc_polling_entity_pollset_set(&c->pollent));
- grpc_httpcli_context_destroy(exec_ctx, &c->httpcli_context);
+ grpc_pollset_set_destroy(grpc_polling_entity_pollset_set(&c->pollent));
+ grpc_httpcli_context_destroy(&c->httpcli_context);
}
grpc_credentials_status
grpc_oauth2_token_fetcher_credentials_parse_server_response(
- grpc_exec_ctx* exec_ctx, const grpc_http_response* response,
- grpc_mdelem* token_md, grpc_millis* token_lifetime) {
+ const grpc_http_response* response, grpc_mdelem* token_md,
+ grpc_millis* token_lifetime) {
char* null_terminated_body = nullptr;
char* new_access_token = nullptr;
grpc_credentials_status status = GRPC_CREDENTIALS_OK;
@@ -184,9 +182,8 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response(
gpr_asprintf(&new_access_token, "%s %s", token_type->value,
access_token->value);
*token_lifetime = strtol(expires_in->value, nullptr, 10) * GPR_MS_PER_SEC;
- if (!GRPC_MDISNULL(*token_md)) GRPC_MDELEM_UNREF(exec_ctx, *token_md);
+ if (!GRPC_MDISNULL(*token_md)) GRPC_MDELEM_UNREF(*token_md);
*token_md = grpc_mdelem_from_slices(
- exec_ctx,
grpc_slice_from_static_string(GRPC_AUTHORIZATION_METADATA_KEY),
grpc_slice_from_copied_string(new_access_token));
status = GRPC_CREDENTIALS_OK;
@@ -194,7 +191,7 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response(
end:
if (status != GRPC_CREDENTIALS_OK && !GRPC_MDISNULL(*token_md)) {
- GRPC_MDELEM_UNREF(exec_ctx, *token_md);
+ GRPC_MDELEM_UNREF(*token_md);
*token_md = GRPC_MDNULL;
}
if (null_terminated_body != nullptr) gpr_free(null_terminated_body);
@@ -203,8 +200,7 @@ end:
return status;
}
-static void on_oauth2_token_fetcher_http_response(grpc_exec_ctx* exec_ctx,
- void* user_data,
+static void on_oauth2_token_fetcher_http_response(void* user_data,
grpc_error* error) {
GRPC_LOG_IF_ERROR("oauth_fetch", GRPC_ERROR_REF(error));
grpc_credentials_metadata_request* r =
@@ -215,13 +211,13 @@ static void on_oauth2_token_fetcher_http_response(grpc_exec_ctx* exec_ctx,
grpc_millis token_lifetime;
grpc_credentials_status status =
grpc_oauth2_token_fetcher_credentials_parse_server_response(
- exec_ctx, &r->response, &access_token_md, &token_lifetime);
+ &r->response, &access_token_md, &token_lifetime);
// Update cache and grab list of pending requests.
gpr_mu_lock(&c->mu);
c->token_fetch_pending = false;
c->access_token_md = GRPC_MDELEM_REF(access_token_md);
c->token_expiration = status == GRPC_CREDENTIALS_OK
- ? grpc_exec_ctx_now(exec_ctx) + token_lifetime
+ ? grpc_core::ExecCtx::Get()->Now() + token_lifetime
: 0;
grpc_oauth2_pending_get_request_metadata* pending_request =
c->pending_requests;
@@ -236,24 +232,22 @@ static void on_oauth2_token_fetcher_http_response(grpc_exec_ctx* exec_ctx,
error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Error occured when fetching oauth2 token.", &error, 1);
}
- GRPC_CLOSURE_SCHED(exec_ctx, pending_request->on_request_metadata, error);
+ GRPC_CLOSURE_SCHED(pending_request->on_request_metadata, error);
grpc_polling_entity_del_from_pollset_set(
- exec_ctx, pending_request->pollent,
- grpc_polling_entity_pollset_set(&c->pollent));
+ pending_request->pollent, grpc_polling_entity_pollset_set(&c->pollent));
grpc_oauth2_pending_get_request_metadata* prev = pending_request;
pending_request = pending_request->next;
gpr_free(prev);
}
- GRPC_MDELEM_UNREF(exec_ctx, access_token_md);
- grpc_call_credentials_unref(exec_ctx, r->creds);
- grpc_credentials_metadata_request_destroy(exec_ctx, r);
+ GRPC_MDELEM_UNREF(access_token_md);
+ grpc_call_credentials_unref(r->creds);
+ grpc_credentials_metadata_request_destroy(r);
}
static bool oauth2_token_fetcher_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_polling_entity* pollent, grpc_auth_metadata_context context,
- grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata,
- grpc_error** error) {
+ grpc_call_credentials* creds, grpc_polling_entity* pollent,
+ grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array,
+ grpc_closure* on_request_metadata, grpc_error** error) {
grpc_oauth2_token_fetcher_credentials* c =
(grpc_oauth2_token_fetcher_credentials*)creds;
// Check if we can use the cached token.
@@ -262,13 +256,14 @@ static bool oauth2_token_fetcher_get_request_metadata(
grpc_mdelem cached_access_token_md = GRPC_MDNULL;
gpr_mu_lock(&c->mu);
if (!GRPC_MDISNULL(c->access_token_md) &&
- (c->token_expiration - grpc_exec_ctx_now(exec_ctx) > refresh_threshold)) {
+ (c->token_expiration - grpc_core::ExecCtx::Get()->Now() >
+ refresh_threshold)) {
cached_access_token_md = GRPC_MDELEM_REF(c->access_token_md);
}
if (!GRPC_MDISNULL(cached_access_token_md)) {
gpr_mu_unlock(&c->mu);
grpc_credentials_mdelem_array_add(md_array, cached_access_token_md);
- GRPC_MDELEM_UNREF(exec_ctx, cached_access_token_md);
+ GRPC_MDELEM_UNREF(cached_access_token_md);
return true;
}
// Couldn't get the token from the cache.
@@ -280,7 +275,7 @@ static bool oauth2_token_fetcher_get_request_metadata(
pending_request->on_request_metadata = on_request_metadata;
pending_request->pollent = pollent;
grpc_polling_entity_add_to_pollset_set(
- exec_ctx, pollent, grpc_polling_entity_pollset_set(&c->pollent));
+ pollent, grpc_polling_entity_pollset_set(&c->pollent));
pending_request->next = c->pending_requests;
c->pending_requests = pending_request;
bool start_fetch = false;
@@ -291,17 +286,17 @@ static bool oauth2_token_fetcher_get_request_metadata(
gpr_mu_unlock(&c->mu);
if (start_fetch) {
grpc_call_credentials_ref(creds);
- c->fetch_func(exec_ctx, grpc_credentials_metadata_request_create(creds),
+ c->fetch_func(grpc_credentials_metadata_request_create(creds),
&c->httpcli_context, &c->pollent,
on_oauth2_token_fetcher_http_response,
- grpc_exec_ctx_now(exec_ctx) + refresh_threshold);
+ grpc_core::ExecCtx::Get()->Now() + refresh_threshold);
}
return false;
}
static void oauth2_token_fetcher_cancel_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_credentials_mdelem_array* md_array, grpc_error* error) {
+ grpc_call_credentials* creds, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
grpc_oauth2_token_fetcher_credentials* c =
(grpc_oauth2_token_fetcher_credentials*)creds;
gpr_mu_lock(&c->mu);
@@ -317,7 +312,7 @@ static void oauth2_token_fetcher_cancel_get_request_metadata(
c->pending_requests = pending_request->next;
}
// Invoke the callback immediately with an error.
- GRPC_CLOSURE_SCHED(exec_ctx, pending_request->on_request_metadata,
+ GRPC_CLOSURE_SCHED(pending_request->on_request_metadata,
GRPC_ERROR_REF(error));
gpr_free(pending_request);
break;
@@ -351,7 +346,7 @@ static grpc_call_credentials_vtable compute_engine_vtable = {
oauth2_token_fetcher_cancel_get_request_metadata};
static void compute_engine_fetch_oauth2(
- grpc_exec_ctx* exec_ctx, grpc_credentials_metadata_request* metadata_req,
+ grpc_credentials_metadata_request* metadata_req,
grpc_httpcli_context* httpcli_context, grpc_polling_entity* pollent,
grpc_iomgr_cb_func response_cb, grpc_millis deadline) {
grpc_http_header header = {(char*)"Metadata-Flavor", (char*)"Google"};
@@ -367,10 +362,10 @@ static void compute_engine_fetch_oauth2(
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("oauth2_credentials");
grpc_httpcli_get(
- exec_ctx, httpcli_context, pollent, resource_quota, &request, deadline,
+ httpcli_context, pollent, resource_quota, &request, deadline,
GRPC_CLOSURE_CREATE(response_cb, metadata_req, grpc_schedule_on_exec_ctx),
&metadata_req->response);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
}
grpc_call_credentials* grpc_google_compute_engine_credentials_create(
@@ -390,12 +385,11 @@ grpc_call_credentials* grpc_google_compute_engine_credentials_create(
// Google Refresh Token credentials.
//
-static void refresh_token_destruct(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds) {
+static void refresh_token_destruct(grpc_call_credentials* creds) {
grpc_google_refresh_token_credentials* c =
(grpc_google_refresh_token_credentials*)creds;
grpc_auth_refresh_token_destruct(&c->refresh_token);
- oauth2_token_fetcher_destruct(exec_ctx, &c->base.base);
+ oauth2_token_fetcher_destruct(&c->base.base);
}
static grpc_call_credentials_vtable refresh_token_vtable = {
@@ -403,7 +397,7 @@ static grpc_call_credentials_vtable refresh_token_vtable = {
oauth2_token_fetcher_cancel_get_request_metadata};
static void refresh_token_fetch_oauth2(
- grpc_exec_ctx* exec_ctx, grpc_credentials_metadata_request* metadata_req,
+ grpc_credentials_metadata_request* metadata_req,
grpc_httpcli_context* httpcli_context, grpc_polling_entity* pollent,
grpc_iomgr_cb_func response_cb, grpc_millis deadline) {
grpc_google_refresh_token_credentials* c =
@@ -427,11 +421,11 @@ static void refresh_token_fetch_oauth2(
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("oauth2_credentials_refresh");
grpc_httpcli_post(
- exec_ctx, httpcli_context, pollent, resource_quota, &request, body,
- strlen(body), deadline,
+ httpcli_context, pollent, resource_quota, &request, body, strlen(body),
+ deadline,
GRPC_CLOSURE_CREATE(response_cb, metadata_req, grpc_schedule_on_exec_ctx),
&metadata_req->response);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
gpr_free(body);
}
@@ -483,25 +477,23 @@ grpc_call_credentials* grpc_google_refresh_token_credentials_create(
// Oauth2 Access Token credentials.
//
-static void access_token_destruct(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds) {
+static void access_token_destruct(grpc_call_credentials* creds) {
grpc_access_token_credentials* c = (grpc_access_token_credentials*)creds;
- GRPC_MDELEM_UNREF(exec_ctx, c->access_token_md);
+ GRPC_MDELEM_UNREF(c->access_token_md);
}
static bool access_token_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_polling_entity* pollent, grpc_auth_metadata_context context,
- grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata,
- grpc_error** error) {
+ grpc_call_credentials* creds, grpc_polling_entity* pollent,
+ grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array,
+ grpc_closure* on_request_metadata, grpc_error** error) {
grpc_access_token_credentials* c = (grpc_access_token_credentials*)creds;
grpc_credentials_mdelem_array_add(md_array, c->access_token_md);
return true;
}
static void access_token_cancel_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* c,
- grpc_credentials_mdelem_array* md_array, grpc_error* error) {
+ grpc_call_credentials* c, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
GRPC_ERROR_UNREF(error);
}
@@ -523,11 +515,11 @@ grpc_call_credentials* grpc_access_token_credentials_create(
gpr_ref_init(&c->base.refcount, 1);
char* token_md_value;
gpr_asprintf(&token_md_value, "Bearer %s", access_token);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
c->access_token_md = grpc_mdelem_from_slices(
- &exec_ctx, grpc_slice_from_static_string(GRPC_AUTHORIZATION_METADATA_KEY),
+ grpc_slice_from_static_string(GRPC_AUTHORIZATION_METADATA_KEY),
grpc_slice_from_copied_string(token_md_value));
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_free(token_md_value);
return &c->base;
}
diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h
index 32d3ff760d..0f897d9f86 100644
--- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h
+++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h
@@ -56,8 +56,7 @@ void grpc_auth_refresh_token_destruct(grpc_auth_refresh_token* refresh_token);
// This object is a base for credentials that need to acquire an oauth2 token
// from an http service.
-typedef void (*grpc_fetch_oauth2_func)(grpc_exec_ctx* exec_ctx,
- grpc_credentials_metadata_request* req,
+typedef void (*grpc_fetch_oauth2_func)(grpc_credentials_metadata_request* req,
grpc_httpcli_context* http_context,
grpc_polling_entity* pollent,
grpc_iomgr_cb_func cb,
@@ -103,8 +102,8 @@ grpc_refresh_token_credentials_create_from_auth_refresh_token(
// Exposed for testing only.
grpc_credentials_status
grpc_oauth2_token_fetcher_credentials_parse_server_response(
- grpc_exec_ctx* exec_ctx, const struct grpc_http_response* response,
- grpc_mdelem* token_md, grpc_millis* token_lifetime);
+ const struct grpc_http_response* response, grpc_mdelem* token_md,
+ grpc_millis* token_lifetime);
#ifdef __cplusplus
}
diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/src/core/lib/security/credentials/plugin/plugin_credentials.cc
index b83a1b426a..27a762d9a3 100644
--- a/src/core/lib/security/credentials/plugin/plugin_credentials.cc
+++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc
@@ -34,8 +34,7 @@
grpc_tracer_flag grpc_plugin_credentials_trace =
GRPC_TRACER_INITIALIZER(false, "plugin_credentials");
-static void plugin_destruct(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds) {
+static void plugin_destruct(grpc_call_credentials* creds) {
grpc_plugin_credentials* c = (grpc_plugin_credentials*)creds;
gpr_mu_destroy(&c->mu);
if (c->plugin.state != nullptr && c->plugin.destroy != nullptr) {
@@ -62,18 +61,17 @@ static void pending_request_remove_locked(
// When this returns, r->cancelled indicates whether the request was
// cancelled before completion.
static void pending_request_complete(
- grpc_exec_ctx* exec_ctx, grpc_plugin_credentials_pending_request* r) {
+ grpc_plugin_credentials_pending_request* r) {
gpr_mu_lock(&r->creds->mu);
if (!r->cancelled) pending_request_remove_locked(r->creds, r);
gpr_mu_unlock(&r->creds->mu);
// Ref to credentials not needed anymore.
- grpc_call_credentials_unref(exec_ctx, &r->creds->base);
+ grpc_call_credentials_unref(&r->creds->base);
}
static grpc_error* process_plugin_result(
- grpc_exec_ctx* exec_ctx, grpc_plugin_credentials_pending_request* r,
- const grpc_metadata* md, size_t num_md, grpc_status_code status,
- const char* error_details) {
+ grpc_plugin_credentials_pending_request* r, const grpc_metadata* md,
+ size_t num_md, grpc_status_code status, const char* error_details) {
grpc_error* error = GRPC_ERROR_NONE;
if (status != GRPC_STATUS_OK) {
char* msg;
@@ -101,11 +99,11 @@ static grpc_error* process_plugin_result(
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal metadata");
} else {
for (size_t i = 0; i < num_md; ++i) {
- grpc_mdelem mdelem = grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_ref_internal(md[i].key),
- grpc_slice_ref_internal(md[i].value));
+ grpc_mdelem mdelem =
+ grpc_mdelem_from_slices(grpc_slice_ref_internal(md[i].key),
+ grpc_slice_ref_internal(md[i].value));
grpc_credentials_mdelem_array_add(r->md_array, mdelem);
- GRPC_MDELEM_UNREF(exec_ctx, mdelem);
+ GRPC_MDELEM_UNREF(mdelem);
}
}
}
@@ -118,9 +116,8 @@ static void plugin_md_request_metadata_ready(void* request,
grpc_status_code status,
const char* error_details) {
/* called from application code */
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INITIALIZER(
- GRPC_EXEC_CTX_FLAG_IS_FINISHED | GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP,
- nullptr, nullptr);
+ grpc_core::ExecCtx _local_exec_ctx(GRPC_EXEC_CTX_FLAG_IS_FINISHED |
+ GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP);
grpc_plugin_credentials_pending_request* r =
(grpc_plugin_credentials_pending_request*)request;
if (GRPC_TRACER_ON(grpc_plugin_credentials_trace)) {
@@ -130,12 +127,12 @@ static void plugin_md_request_metadata_ready(void* request,
r->creds, r);
}
// Remove request from pending list if not previously cancelled.
- pending_request_complete(&exec_ctx, r);
+ pending_request_complete(r);
// If it has not been cancelled, process it.
if (!r->cancelled) {
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);
+ process_plugin_result(r, md, num_md, status, error_details);
+ GRPC_CLOSURE_SCHED(r->on_request_metadata, error);
} else if (GRPC_TRACER_ON(grpc_plugin_credentials_trace)) {
gpr_log(GPR_INFO,
"plugin_credentials[%p]: request %p: plugin was previously "
@@ -143,11 +140,9 @@ static void plugin_md_request_metadata_ready(void* request,
r->creds, r);
}
gpr_free(r);
- grpc_exec_ctx_finish(&exec_ctx);
}
-static bool plugin_get_request_metadata(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds,
+static bool plugin_get_request_metadata(grpc_call_credentials* creds,
grpc_polling_entity* pollent,
grpc_auth_metadata_context context,
grpc_credentials_mdelem_array* md_array,
@@ -195,7 +190,7 @@ static bool plugin_get_request_metadata(grpc_exec_ctx* exec_ctx,
}
// Returned synchronously.
// Remove request from pending list if not previously cancelled.
- pending_request_complete(exec_ctx, pending_request);
+ pending_request_complete(pending_request);
// If the request was cancelled, the error will have been returned
// asynchronously by plugin_cancel_get_request_metadata(), so return
// false. Otherwise, process the result.
@@ -214,13 +209,13 @@ static bool plugin_get_request_metadata(grpc_exec_ctx* exec_ctx,
"synchronously",
c, pending_request);
}
- *error = process_plugin_result(exec_ctx, pending_request, creds_md,
- num_creds_md, status, error_details);
+ *error = process_plugin_result(pending_request, creds_md, num_creds_md,
+ status, error_details);
}
// Clean up.
for (size_t i = 0; i < num_creds_md; ++i) {
- grpc_slice_unref_internal(exec_ctx, creds_md[i].key);
- grpc_slice_unref_internal(exec_ctx, creds_md[i].value);
+ grpc_slice_unref_internal(creds_md[i].key);
+ grpc_slice_unref_internal(creds_md[i].value);
}
gpr_free((void*)error_details);
gpr_free(pending_request);
@@ -229,8 +224,8 @@ static bool plugin_get_request_metadata(grpc_exec_ctx* exec_ctx,
}
static void plugin_cancel_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_credentials_mdelem_array* md_array, grpc_error* error) {
+ grpc_call_credentials* creds, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
grpc_plugin_credentials* c = (grpc_plugin_credentials*)creds;
gpr_mu_lock(&c->mu);
for (grpc_plugin_credentials_pending_request* pending_request =
@@ -242,7 +237,7 @@ static void plugin_cancel_get_request_metadata(
pending_request);
}
pending_request->cancelled = true;
- GRPC_CLOSURE_SCHED(exec_ctx, pending_request->on_request_metadata,
+ GRPC_CLOSURE_SCHED(pending_request->on_request_metadata,
GRPC_ERROR_REF(error));
pending_request_remove_locked(c, pending_request);
break;
diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.cc b/src/core/lib/security/credentials/ssl/ssl_credentials.cc
index 39dd38cf88..d8546441c9 100644
--- a/src/core/lib/security/credentials/ssl/ssl_credentials.cc
+++ b/src/core/lib/security/credentials/ssl/ssl_credentials.cc
@@ -41,18 +41,16 @@ void grpc_tsi_ssl_pem_key_cert_pairs_destroy(tsi_ssl_pem_key_cert_pair* kp,
gpr_free(kp);
}
-static void ssl_destruct(grpc_exec_ctx* exec_ctx,
- grpc_channel_credentials* creds) {
+static void ssl_destruct(grpc_channel_credentials* creds) {
grpc_ssl_credentials* c = (grpc_ssl_credentials*)creds;
gpr_free(c->config.pem_root_certs);
grpc_tsi_ssl_pem_key_cert_pairs_destroy(c->config.pem_key_cert_pair, 1);
}
static grpc_security_status ssl_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* creds,
- grpc_call_credentials* call_creds, const char* target,
- const grpc_channel_args* args, grpc_channel_security_connector** sc,
- grpc_channel_args** new_args) {
+ grpc_channel_credentials* creds, grpc_call_credentials* call_creds,
+ const char* target, const grpc_channel_args* args,
+ grpc_channel_security_connector** sc, grpc_channel_args** new_args) {
grpc_ssl_credentials* c = (grpc_ssl_credentials*)creds;
grpc_security_status status = GRPC_SECURITY_OK;
const char* overridden_target_name = nullptr;
@@ -65,8 +63,7 @@ static grpc_security_status ssl_create_security_connector(
}
}
status = grpc_ssl_channel_security_connector_create(
- exec_ctx, creds, call_creds, &c->config, target, overridden_target_name,
- sc);
+ creds, call_creds, &c->config, target, overridden_target_name, sc);
if (status != GRPC_SECURITY_OK) {
return status;
}
@@ -125,8 +122,7 @@ struct grpc_ssl_server_credentials_options {
grpc_ssl_server_certificate_config_fetcher* certificate_config_fetcher;
};
-static void ssl_server_destruct(grpc_exec_ctx* exec_ctx,
- grpc_server_credentials* creds) {
+static void ssl_server_destruct(grpc_server_credentials* creds) {
grpc_ssl_server_credentials* c = (grpc_ssl_server_credentials*)creds;
grpc_tsi_ssl_pem_key_cert_pairs_destroy(c->config.pem_key_cert_pairs,
c->config.num_key_cert_pairs);
@@ -134,9 +130,8 @@ static void ssl_server_destruct(grpc_exec_ctx* exec_ctx,
}
static grpc_security_status ssl_server_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_server_credentials* creds,
- grpc_server_security_connector** sc) {
- return grpc_ssl_server_security_connector_create(exec_ctx, creds, sc);
+ grpc_server_credentials* creds, grpc_server_security_connector** sc) {
+ return grpc_ssl_server_security_connector_create(creds, sc);
}
static grpc_server_credentials_vtable ssl_server_vtable = {
diff --git a/src/core/lib/security/transport/client_auth_filter.cc b/src/core/lib/security/transport/client_auth_filter.cc
index 326f4d7773..cd3c2e3f19 100644
--- a/src/core/lib/security/transport/client_auth_filter.cc
+++ b/src/core/lib/security/transport/client_auth_filter.cc
@@ -90,8 +90,7 @@ static void add_error(grpc_error** combined, grpc_error* error) {
*combined = grpc_error_add_child(*combined, error);
}
-static void on_credentials_metadata(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* input_error) {
+static void on_credentials_metadata(void* arg, grpc_error* input_error) {
grpc_transport_stream_op_batch* batch = (grpc_transport_stream_op_batch*)arg;
grpc_call_element* elem =
(grpc_call_element*)batch->handler_private.extra_arg;
@@ -105,16 +104,16 @@ static void on_credentials_metadata(grpc_exec_ctx* exec_ctx, void* arg,
batch->payload->send_initial_metadata.send_initial_metadata;
for (size_t i = 0; i < calld->md_array.size; ++i) {
add_error(&error, grpc_metadata_batch_add_tail(
- exec_ctx, mdb, &calld->md_links[i],
+ mdb, &calld->md_links[i],
GRPC_MDELEM_REF(calld->md_array.md[i])));
}
}
if (error == GRPC_ERROR_NONE) {
- grpc_call_next_op(exec_ctx, elem, batch);
+ grpc_call_next_op(elem, batch);
} else {
error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS,
GRPC_STATUS_UNAUTHENTICATED);
- grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, batch, error,
+ grpc_transport_stream_op_batch_finish_with_failure(batch, error,
calld->call_combiner);
}
}
@@ -156,20 +155,17 @@ void grpc_auth_metadata_context_build(
gpr_free(host_and_port);
}
-static void cancel_get_request_metadata(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void cancel_get_request_metadata(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
call_data* calld = (call_data*)elem->call_data;
if (error != GRPC_ERROR_NONE) {
grpc_call_credentials_cancel_get_request_metadata(
- exec_ctx, calld->creds, &calld->md_array, GRPC_ERROR_REF(error));
+ calld->creds, &calld->md_array, GRPC_ERROR_REF(error));
}
- GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call,
- "cancel_get_request_metadata");
+ GRPC_CALL_STACK_UNREF(calld->owning_call, "cancel_get_request_metadata");
}
-static void send_security_metadata(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void send_security_metadata(grpc_call_element* elem,
grpc_transport_stream_op_batch* batch) {
call_data* calld = (call_data*)elem->call_data;
channel_data* chand = (channel_data*)elem->channel_data;
@@ -183,7 +179,7 @@ static void send_security_metadata(grpc_exec_ctx* exec_ctx,
if (channel_call_creds == nullptr && !call_creds_has_md) {
/* Skip sending metadata altogether. */
- grpc_call_next_op(exec_ctx, elem, batch);
+ grpc_call_next_op(elem, batch);
return;
}
@@ -192,7 +188,7 @@ static void send_security_metadata(grpc_exec_ctx* exec_ctx,
ctx->creds, nullptr);
if (calld->creds == nullptr) {
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, batch,
+ batch,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Incompatible credentials set on channel and call."),
@@ -215,30 +211,29 @@ static void send_security_metadata(grpc_exec_ctx* exec_ctx,
batch, grpc_schedule_on_exec_ctx);
grpc_error* error = GRPC_ERROR_NONE;
if (grpc_call_credentials_get_request_metadata(
- exec_ctx, calld->creds, calld->pollent, calld->auth_md_context,
+ calld->creds, calld->pollent, calld->auth_md_context,
&calld->md_array, &calld->async_result_closure, &error)) {
// Synchronous return; invoke on_credentials_metadata() directly.
- on_credentials_metadata(exec_ctx, batch, error);
+ on_credentials_metadata(batch, error);
GRPC_ERROR_UNREF(error);
} else {
// Async return; register cancellation closure with call combiner.
GRPC_CALL_STACK_REF(calld->owning_call, "cancel_get_request_metadata");
grpc_call_combiner_set_notify_on_cancel(
- exec_ctx, calld->call_combiner,
+ calld->call_combiner,
GRPC_CLOSURE_INIT(&calld->get_request_metadata_cancel_closure,
cancel_get_request_metadata, elem,
grpc_schedule_on_exec_ctx));
}
}
-static void on_host_checked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_host_checked(void* arg, grpc_error* error) {
grpc_transport_stream_op_batch* batch = (grpc_transport_stream_op_batch*)arg;
grpc_call_element* elem =
(grpc_call_element*)batch->handler_private.extra_arg;
call_data* calld = (call_data*)elem->call_data;
if (error == GRPC_ERROR_NONE) {
- send_security_metadata(exec_ctx, elem, batch);
+ send_security_metadata(elem, batch);
} else {
char* error_msg;
char* host = grpc_slice_to_c_string(calld->host);
@@ -246,7 +241,7 @@ static void on_host_checked(grpc_exec_ctx* exec_ctx, void* arg,
host);
gpr_free(host);
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, batch,
+ batch,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg),
GRPC_ERROR_INT_GRPC_STATUS,
GRPC_STATUS_UNAUTHENTICATED),
@@ -255,22 +250,20 @@ static void on_host_checked(grpc_exec_ctx* exec_ctx, void* arg,
}
}
-static void cancel_check_call_host(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void cancel_check_call_host(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
call_data* calld = (call_data*)elem->call_data;
channel_data* chand = (channel_data*)elem->channel_data;
if (error != GRPC_ERROR_NONE) {
grpc_channel_security_connector_cancel_check_call_host(
- exec_ctx, chand->security_connector, &calld->async_result_closure,
+ chand->security_connector, &calld->async_result_closure,
GRPC_ERROR_REF(error));
}
- GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "cancel_check_call_host");
+ GRPC_CALL_STACK_UNREF(calld->owning_call, "cancel_check_call_host");
}
static void auth_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* batch) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
GPR_TIMER_BEGIN("auth_start_transport_stream_op_batch", 0);
/* grab pointers to our data from the call element */
@@ -303,13 +296,13 @@ static void auth_start_transport_stream_op_batch(
*/
if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_AUTHORITY)) {
if (calld->have_host) {
- grpc_slice_unref_internal(exec_ctx, calld->host);
+ grpc_slice_unref_internal(calld->host);
}
calld->host = grpc_slice_ref_internal(GRPC_MDVALUE(md));
calld->have_host = true;
} else if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_PATH)) {
if (calld->have_method) {
- grpc_slice_unref_internal(exec_ctx, calld->method);
+ grpc_slice_unref_internal(calld->method);
}
calld->method = grpc_slice_ref_internal(GRPC_MDVALUE(md));
calld->have_method = true;
@@ -322,16 +315,16 @@ static void auth_start_transport_stream_op_batch(
char* call_host = grpc_slice_to_c_string(calld->host);
grpc_error* error = GRPC_ERROR_NONE;
if (grpc_channel_security_connector_check_call_host(
- exec_ctx, chand->security_connector, call_host,
- chand->auth_context, &calld->async_result_closure, &error)) {
+ chand->security_connector, call_host, chand->auth_context,
+ &calld->async_result_closure, &error)) {
// Synchronous return; invoke on_host_checked() directly.
- on_host_checked(exec_ctx, batch, error);
+ on_host_checked(batch, error);
GRPC_ERROR_UNREF(error);
} else {
// Async return; register cancellation closure with call combiner.
GRPC_CALL_STACK_REF(calld->owning_call, "cancel_check_call_host");
grpc_call_combiner_set_notify_on_cancel(
- exec_ctx, calld->call_combiner,
+ calld->call_combiner,
GRPC_CLOSURE_INIT(&calld->check_call_host_cancel_closure,
cancel_check_call_host, elem,
grpc_schedule_on_exec_ctx));
@@ -343,13 +336,12 @@ static void auth_start_transport_stream_op_batch(
}
/* pass control down the stack */
- grpc_call_next_op(exec_ctx, elem, batch);
+ grpc_call_next_op(elem, batch);
GPR_TIMER_END("auth_start_transport_stream_op_batch", 0);
}
/* Constructor for call_data */
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
call_data* calld = (call_data*)elem->call_data;
calld->owning_call = args->call_stack;
@@ -357,32 +349,30 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-static void set_pollset_or_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void set_pollset_or_pollset_set(grpc_call_element* elem,
grpc_polling_entity* pollent) {
call_data* calld = (call_data*)elem->call_data;
calld->pollent = pollent;
}
/* Destructor for call_data */
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
call_data* calld = (call_data*)elem->call_data;
- grpc_credentials_mdelem_array_destroy(exec_ctx, &calld->md_array);
- grpc_call_credentials_unref(exec_ctx, calld->creds);
+ grpc_credentials_mdelem_array_destroy(&calld->md_array);
+ grpc_call_credentials_unref(calld->creds);
if (calld->have_host) {
- grpc_slice_unref_internal(exec_ctx, calld->host);
+ grpc_slice_unref_internal(calld->host);
}
if (calld->have_method) {
- grpc_slice_unref_internal(exec_ctx, calld->method);
+ grpc_slice_unref_internal(calld->method);
}
grpc_auth_metadata_context_reset(&calld->auth_md_context);
}
/* Constructor for channel_data */
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
grpc_security_connector* sc =
grpc_security_connector_find_in_args(args->channel_args);
@@ -415,13 +405,12 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
}
/* Destructor for channel data */
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {
+static void destroy_channel_elem(grpc_channel_element* elem) {
/* grab pointers to our data from the channel element */
channel_data* chand = (channel_data*)elem->channel_data;
grpc_channel_security_connector* sc = chand->security_connector;
if (sc != nullptr) {
- GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, &sc->base, "client_auth_filter");
+ GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "client_auth_filter");
}
GRPC_AUTH_CONTEXT_UNREF(chand->auth_context, "client_auth_filter");
}
diff --git a/src/core/lib/security/transport/lb_targets_info.cc b/src/core/lib/security/transport/lb_targets_info.cc
index c07be35840..183b1ebf35 100644
--- a/src/core/lib/security/transport/lb_targets_info.cc
+++ b/src/core/lib/security/transport/lb_targets_info.cc
@@ -28,8 +28,8 @@
static void* targets_info_copy(void* p) {
return grpc_slice_hash_table_ref((grpc_slice_hash_table*)p);
}
-static void targets_info_destroy(grpc_exec_ctx* exec_ctx, void* p) {
- grpc_slice_hash_table_unref(exec_ctx, (grpc_slice_hash_table*)p);
+static void targets_info_destroy(void* p) {
+ grpc_slice_hash_table_unref((grpc_slice_hash_table*)p);
}
static int targets_info_cmp(void* a, void* b) {
return grpc_slice_hash_table_cmp((const grpc_slice_hash_table*)a,
diff --git a/src/core/lib/security/transport/secure_endpoint.cc b/src/core/lib/security/transport/secure_endpoint.cc
index 3ba987a105..4ea40e7fa1 100644
--- a/src/core/lib/security/transport/secure_endpoint.cc
+++ b/src/core/lib/security/transport/secure_endpoint.cc
@@ -64,28 +64,27 @@ typedef struct {
grpc_tracer_flag grpc_trace_secure_endpoint =
GRPC_TRACER_INITIALIZER(false, "secure_endpoint");
-static void destroy(grpc_exec_ctx* exec_ctx, secure_endpoint* secure_ep) {
+static void destroy(secure_endpoint* secure_ep) {
secure_endpoint* ep = secure_ep;
- grpc_endpoint_destroy(exec_ctx, ep->wrapped_ep);
+ grpc_endpoint_destroy(ep->wrapped_ep);
tsi_frame_protector_destroy(ep->protector);
- tsi_zero_copy_grpc_protector_destroy(exec_ctx, ep->zero_copy_protector);
- grpc_slice_buffer_destroy_internal(exec_ctx, &ep->leftover_bytes);
- grpc_slice_unref_internal(exec_ctx, ep->read_staging_buffer);
- grpc_slice_unref_internal(exec_ctx, ep->write_staging_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &ep->output_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &ep->source_buffer);
+ tsi_zero_copy_grpc_protector_destroy(ep->zero_copy_protector);
+ grpc_slice_buffer_destroy_internal(&ep->leftover_bytes);
+ grpc_slice_unref_internal(ep->read_staging_buffer);
+ grpc_slice_unref_internal(ep->write_staging_buffer);
+ grpc_slice_buffer_destroy_internal(&ep->output_buffer);
+ grpc_slice_buffer_destroy_internal(&ep->source_buffer);
gpr_mu_destroy(&ep->protector_mu);
gpr_free(ep);
}
#ifndef NDEBUG
-#define SECURE_ENDPOINT_UNREF(exec_ctx, ep, reason) \
- secure_endpoint_unref((exec_ctx), (ep), (reason), __FILE__, __LINE__)
+#define SECURE_ENDPOINT_UNREF(ep, reason) \
+ secure_endpoint_unref((ep), (reason), __FILE__, __LINE__)
#define SECURE_ENDPOINT_REF(ep, reason) \
secure_endpoint_ref((ep), (reason), __FILE__, __LINE__)
-static void secure_endpoint_unref(grpc_exec_ctx* exec_ctx, secure_endpoint* ep,
- const char* reason, const char* file,
- int line) {
+static void secure_endpoint_unref(secure_endpoint* ep, const char* reason,
+ const char* file, int line) {
if (GRPC_TRACER_ON(grpc_trace_secure_endpoint)) {
gpr_atm val = gpr_atm_no_barrier_load(&ep->ref.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
@@ -93,7 +92,7 @@ static void secure_endpoint_unref(grpc_exec_ctx* exec_ctx, secure_endpoint* ep,
val - 1);
}
if (gpr_unref(&ep->ref)) {
- destroy(exec_ctx, ep);
+ destroy(ep);
}
}
@@ -108,13 +107,11 @@ static void secure_endpoint_ref(secure_endpoint* ep, const char* reason,
gpr_ref(&ep->ref);
}
#else
-#define SECURE_ENDPOINT_UNREF(exec_ctx, ep, reason) \
- secure_endpoint_unref((exec_ctx), (ep))
+#define SECURE_ENDPOINT_UNREF(ep, reason) secure_endpoint_unref((ep))
#define SECURE_ENDPOINT_REF(ep, reason) secure_endpoint_ref((ep))
-static void secure_endpoint_unref(grpc_exec_ctx* exec_ctx,
- secure_endpoint* ep) {
+static void secure_endpoint_unref(secure_endpoint* ep) {
if (gpr_unref(&ep->ref)) {
- destroy(exec_ctx, ep);
+ destroy(ep);
}
}
@@ -129,8 +126,7 @@ static void flush_read_staging_buffer(secure_endpoint* ep, uint8_t** cur,
*end = GRPC_SLICE_END_PTR(ep->read_staging_buffer);
}
-static void call_read_cb(grpc_exec_ctx* exec_ctx, secure_endpoint* ep,
- grpc_error* error) {
+static void call_read_cb(secure_endpoint* ep, grpc_error* error) {
if (GRPC_TRACER_ON(grpc_trace_secure_endpoint)) {
size_t i;
for (i = 0; i < ep->read_buffer->count; i++) {
@@ -141,12 +137,11 @@ static void call_read_cb(grpc_exec_ctx* exec_ctx, secure_endpoint* ep,
}
}
ep->read_buffer = nullptr;
- GRPC_CLOSURE_SCHED(exec_ctx, ep->read_cb, error);
- SECURE_ENDPOINT_UNREF(exec_ctx, ep, "read");
+ GRPC_CLOSURE_SCHED(ep->read_cb, error);
+ SECURE_ENDPOINT_UNREF(ep, "read");
}
-static void on_read(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_error* error) {
+static void on_read(void* user_data, grpc_error* error) {
unsigned i;
uint8_t keep_looping = 0;
tsi_result result = TSI_OK;
@@ -155,17 +150,16 @@ static void on_read(grpc_exec_ctx* exec_ctx, void* user_data,
uint8_t* end = GRPC_SLICE_END_PTR(ep->read_staging_buffer);
if (error != GRPC_ERROR_NONE) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, ep->read_buffer);
- call_read_cb(exec_ctx, ep,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Secure read failed", &error, 1));
+ grpc_slice_buffer_reset_and_unref_internal(ep->read_buffer);
+ call_read_cb(ep, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Secure read failed", &error, 1));
return;
}
if (ep->zero_copy_protector != nullptr) {
// Use zero-copy grpc protector to unprotect.
result = tsi_zero_copy_grpc_protector_unprotect(
- exec_ctx, ep->zero_copy_protector, &ep->source_buffer, ep->read_buffer);
+ ep->zero_copy_protector, &ep->source_buffer, ep->read_buffer);
} else {
// Use frame protector to unprotect.
/* TODO(yangg) check error, maybe bail out early */
@@ -218,37 +212,35 @@ static void on_read(grpc_exec_ctx* exec_ctx, void* user_data,
/* TODO(yangg) experiment with moving this block after read_cb to see if it
helps latency */
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &ep->source_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(&ep->source_buffer);
if (result != TSI_OK) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, ep->read_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(ep->read_buffer);
call_read_cb(
- exec_ctx, ep,
- grpc_set_tsi_error_result(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unwrap failed"), result));
+ ep, grpc_set_tsi_error_result(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unwrap failed"), result));
return;
}
- call_read_cb(exec_ctx, ep, GRPC_ERROR_NONE);
+ call_read_cb(ep, GRPC_ERROR_NONE);
}
-static void endpoint_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* secure_ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
+static void endpoint_read(grpc_endpoint* secure_ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
secure_endpoint* ep = (secure_endpoint*)secure_ep;
ep->read_cb = cb;
ep->read_buffer = slices;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, ep->read_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(ep->read_buffer);
SECURE_ENDPOINT_REF(ep, "read");
if (ep->leftover_bytes.count) {
grpc_slice_buffer_swap(&ep->leftover_bytes, &ep->source_buffer);
GPR_ASSERT(ep->leftover_bytes.count == 0);
- on_read(exec_ctx, ep, GRPC_ERROR_NONE);
+ on_read(ep, GRPC_ERROR_NONE);
return;
}
- grpc_endpoint_read(exec_ctx, ep->wrapped_ep, &ep->source_buffer,
- &ep->on_read);
+ grpc_endpoint_read(ep->wrapped_ep, &ep->source_buffer, &ep->on_read);
}
static void flush_write_staging_buffer(secure_endpoint* ep, uint8_t** cur,
@@ -259,8 +251,8 @@ static void flush_write_staging_buffer(secure_endpoint* ep, uint8_t** cur,
*end = GRPC_SLICE_END_PTR(ep->write_staging_buffer);
}
-static void endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* secure_ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
+static void endpoint_write(grpc_endpoint* secure_ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
GPR_TIMER_BEGIN("secure_endpoint.endpoint_write", 0);
unsigned i;
@@ -269,7 +261,7 @@ static void endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* secure_ep,
uint8_t* cur = GRPC_SLICE_START_PTR(ep->write_staging_buffer);
uint8_t* end = GRPC_SLICE_END_PTR(ep->write_staging_buffer);
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &ep->output_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(&ep->output_buffer);
if (GRPC_TRACER_ON(grpc_trace_secure_endpoint)) {
for (i = 0; i < slices->count; i++) {
@@ -282,8 +274,8 @@ static void endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* secure_ep,
if (ep->zero_copy_protector != nullptr) {
// Use zero-copy grpc protector to protect.
- result = tsi_zero_copy_grpc_protector_protect(
- exec_ctx, ep->zero_copy_protector, slices, &ep->output_buffer);
+ result = tsi_zero_copy_grpc_protector_protect(ep->zero_copy_protector,
+ slices, &ep->output_buffer);
} else {
// Use frame protector to protect.
for (i = 0; i < slices->count; i++) {
@@ -341,50 +333,44 @@ static void endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* secure_ep,
if (result != TSI_OK) {
/* TODO(yangg) do different things according to the error type? */
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &ep->output_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(&ep->output_buffer);
GRPC_CLOSURE_SCHED(
- exec_ctx, cb,
- grpc_set_tsi_error_result(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Wrap failed"), result));
+ cb, grpc_set_tsi_error_result(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Wrap failed"), result));
GPR_TIMER_END("secure_endpoint.endpoint_write", 0);
return;
}
- grpc_endpoint_write(exec_ctx, ep->wrapped_ep, &ep->output_buffer, cb);
+ grpc_endpoint_write(ep->wrapped_ep, &ep->output_buffer, cb);
GPR_TIMER_END("secure_endpoint.endpoint_write", 0);
}
-static void endpoint_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* secure_ep,
- grpc_error* why) {
+static void endpoint_shutdown(grpc_endpoint* secure_ep, grpc_error* why) {
secure_endpoint* ep = (secure_endpoint*)secure_ep;
- grpc_endpoint_shutdown(exec_ctx, ep->wrapped_ep, why);
+ grpc_endpoint_shutdown(ep->wrapped_ep, why);
}
-static void endpoint_destroy(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* secure_ep) {
+static void endpoint_destroy(grpc_endpoint* secure_ep) {
secure_endpoint* ep = (secure_endpoint*)secure_ep;
- SECURE_ENDPOINT_UNREF(exec_ctx, ep, "destroy");
+ SECURE_ENDPOINT_UNREF(ep, "destroy");
}
-static void endpoint_add_to_pollset(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* secure_ep,
+static void endpoint_add_to_pollset(grpc_endpoint* secure_ep,
grpc_pollset* pollset) {
secure_endpoint* ep = (secure_endpoint*)secure_ep;
- grpc_endpoint_add_to_pollset(exec_ctx, ep->wrapped_ep, pollset);
+ grpc_endpoint_add_to_pollset(ep->wrapped_ep, pollset);
}
-static void endpoint_add_to_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* secure_ep,
+static void endpoint_add_to_pollset_set(grpc_endpoint* secure_ep,
grpc_pollset_set* pollset_set) {
secure_endpoint* ep = (secure_endpoint*)secure_ep;
- grpc_endpoint_add_to_pollset_set(exec_ctx, ep->wrapped_ep, pollset_set);
+ grpc_endpoint_add_to_pollset_set(ep->wrapped_ep, pollset_set);
}
-static void endpoint_delete_from_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* secure_ep,
+static void endpoint_delete_from_pollset_set(grpc_endpoint* secure_ep,
grpc_pollset_set* pollset_set) {
secure_endpoint* ep = (secure_endpoint*)secure_ep;
- grpc_endpoint_delete_from_pollset_set(exec_ctx, ep->wrapped_ep, pollset_set);
+ grpc_endpoint_delete_from_pollset_set(ep->wrapped_ep, pollset_set);
}
static char* endpoint_get_peer(grpc_endpoint* secure_ep) {
diff --git a/src/core/lib/security/transport/security_connector.cc b/src/core/lib/security/transport/security_connector.cc
index b996cc8cdb..0c99268578 100644
--- a/src/core/lib/security/transport/security_connector.cc
+++ b/src/core/lib/security/transport/security_connector.cc
@@ -107,33 +107,32 @@ const tsi_peer_property* tsi_peer_get_property_by_name(const tsi_peer* peer,
}
void grpc_channel_security_connector_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* connector,
+ grpc_channel_security_connector* connector,
grpc_handshake_manager* handshake_mgr) {
if (connector != nullptr) {
- connector->add_handshakers(exec_ctx, connector, handshake_mgr);
+ connector->add_handshakers(connector, handshake_mgr);
}
}
void grpc_server_security_connector_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_server_security_connector* connector,
+ grpc_server_security_connector* connector,
grpc_handshake_manager* handshake_mgr) {
if (connector != nullptr) {
- connector->add_handshakers(exec_ctx, connector, handshake_mgr);
+ connector->add_handshakers(connector, handshake_mgr);
}
}
-void grpc_security_connector_check_peer(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc,
+void grpc_security_connector_check_peer(grpc_security_connector* sc,
tsi_peer peer,
grpc_auth_context** auth_context,
grpc_closure* on_peer_checked) {
if (sc == nullptr) {
- GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked,
+ GRPC_CLOSURE_SCHED(on_peer_checked,
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"cannot check peer -- no security connector"));
tsi_peer_destruct(&peer);
} else {
- sc->vtable->check_peer(exec_ctx, sc, peer, auth_context, on_peer_checked);
+ sc->vtable->check_peer(sc, peer, auth_context, on_peer_checked);
}
}
@@ -171,26 +170,26 @@ int grpc_server_security_connector_cmp(grpc_server_security_connector* sc1,
}
bool grpc_channel_security_connector_check_call_host(
- grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* sc,
- const char* host, grpc_auth_context* auth_context,
- grpc_closure* on_call_host_checked, grpc_error** error) {
+ grpc_channel_security_connector* sc, const char* host,
+ grpc_auth_context* auth_context, grpc_closure* on_call_host_checked,
+ grpc_error** error) {
if (sc == nullptr || sc->check_call_host == nullptr) {
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"cannot check call host -- no security connector");
return true;
}
- return sc->check_call_host(exec_ctx, sc, host, auth_context,
- on_call_host_checked, error);
+ return sc->check_call_host(sc, host, auth_context, on_call_host_checked,
+ error);
}
void grpc_channel_security_connector_cancel_check_call_host(
- grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* sc,
- grpc_closure* on_call_host_checked, grpc_error* error) {
+ grpc_channel_security_connector* sc, grpc_closure* on_call_host_checked,
+ grpc_error* error) {
if (sc == nullptr || sc->cancel_check_call_host == nullptr) {
GRPC_ERROR_UNREF(error);
return;
}
- sc->cancel_check_call_host(exec_ctx, sc, on_call_host_checked, error);
+ sc->cancel_check_call_host(sc, on_call_host_checked, error);
}
#ifndef NDEBUG
@@ -207,15 +206,14 @@ grpc_security_connector* grpc_security_connector_ref(
#else
grpc_security_connector* grpc_security_connector_ref(
grpc_security_connector* sc) {
- if (sc == NULL) return NULL;
+ if (sc == nullptr) return nullptr;
#endif
gpr_ref(&sc->refcount);
return sc;
}
#ifndef NDEBUG
-void grpc_security_connector_unref(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc,
+void grpc_security_connector_unref(grpc_security_connector* sc,
const char* file, int line,
const char* reason) {
if (sc == nullptr) return;
@@ -226,15 +224,14 @@ void grpc_security_connector_unref(grpc_exec_ctx* exec_ctx,
val, val - 1, reason);
}
#else
-void grpc_security_connector_unref(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc) {
- if (sc == NULL) return;
+void grpc_security_connector_unref(grpc_security_connector* sc) {
+ if (sc == nullptr) return;
#endif
- if (gpr_unref(&sc->refcount)) sc->vtable->destroy(exec_ctx, sc);
+ if (gpr_unref(&sc->refcount)) sc->vtable->destroy(sc);
}
-static void connector_arg_destroy(grpc_exec_ctx* exec_ctx, void* p) {
- GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, (grpc_security_connector*)p,
+static void connector_arg_destroy(void* p) {
+ GRPC_SECURITY_CONNECTOR_UNREF((grpc_security_connector*)p,
"connector_arg_destroy");
}
@@ -311,20 +308,16 @@ typedef struct {
bool is_lb_channel;
} grpc_fake_channel_security_connector;
-static void fake_channel_destroy(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc) {
+static void fake_channel_destroy(grpc_security_connector* sc) {
grpc_fake_channel_security_connector* c =
(grpc_fake_channel_security_connector*)sc;
- grpc_call_credentials_unref(exec_ctx, c->base.request_metadata_creds);
+ grpc_call_credentials_unref(c->base.request_metadata_creds);
gpr_free(c->target);
gpr_free(c->expected_targets);
gpr_free(c);
}
-static void fake_server_destroy(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc) {
- gpr_free(sc);
-}
+static void fake_server_destroy(grpc_security_connector* sc) { gpr_free(sc); }
static bool fake_check_target(const char* target_type, const char* target,
const char* set_str) {
@@ -388,8 +381,7 @@ done:
if (!success) abort();
}
-static void fake_check_peer(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc, tsi_peer peer,
+static void fake_check_peer(grpc_security_connector* sc, tsi_peer peer,
grpc_auth_context** auth_context,
grpc_closure* on_peer_checked) {
const char* prop_name;
@@ -421,25 +413,23 @@ static void fake_check_peer(grpc_exec_ctx* exec_ctx,
*auth_context, GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME,
GRPC_FAKE_TRANSPORT_SECURITY_TYPE);
end:
- GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked, error);
+ GRPC_CLOSURE_SCHED(on_peer_checked, error);
tsi_peer_destruct(&peer);
}
-static void fake_channel_check_peer(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc, tsi_peer peer,
+static void fake_channel_check_peer(grpc_security_connector* sc, tsi_peer peer,
grpc_auth_context** auth_context,
grpc_closure* on_peer_checked) {
- fake_check_peer(exec_ctx, sc, peer, auth_context, on_peer_checked);
+ fake_check_peer(sc, peer, auth_context, on_peer_checked);
grpc_fake_channel_security_connector* c =
(grpc_fake_channel_security_connector*)sc;
fake_secure_name_check(c->target, c->expected_targets, c->is_lb_channel);
}
-static void fake_server_check_peer(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc, tsi_peer peer,
+static void fake_server_check_peer(grpc_security_connector* sc, tsi_peer peer,
grpc_auth_context** auth_context,
grpc_closure* on_peer_checked) {
- fake_check_peer(exec_ctx, sc, peer, auth_context, on_peer_checked);
+ fake_check_peer(sc, peer, auth_context, on_peer_checked);
}
static int fake_channel_cmp(grpc_security_connector* sc1,
@@ -468,8 +458,7 @@ static int fake_server_cmp(grpc_security_connector* sc1,
(grpc_server_security_connector*)sc2);
}
-static bool fake_channel_check_call_host(grpc_exec_ctx* exec_ctx,
- grpc_channel_security_connector* sc,
+static bool fake_channel_check_call_host(grpc_channel_security_connector* sc,
const char* host,
grpc_auth_context* auth_context,
grpc_closure* on_call_host_checked,
@@ -478,29 +467,26 @@ static bool fake_channel_check_call_host(grpc_exec_ctx* exec_ctx,
}
static void fake_channel_cancel_check_call_host(
- grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* sc,
- grpc_closure* on_call_host_checked, grpc_error* error) {
+ grpc_channel_security_connector* sc, grpc_closure* on_call_host_checked,
+ grpc_error* error) {
GRPC_ERROR_UNREF(error);
}
static void fake_channel_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* sc,
+ grpc_channel_security_connector* sc,
grpc_handshake_manager* handshake_mgr) {
grpc_handshake_manager_add(
handshake_mgr,
grpc_security_handshaker_create(
- exec_ctx, tsi_create_fake_handshaker(true /* is_client */),
- &sc->base));
+ tsi_create_fake_handshaker(true /* is_client */), &sc->base));
}
-static void fake_server_add_handshakers(grpc_exec_ctx* exec_ctx,
- grpc_server_security_connector* sc,
+static void fake_server_add_handshakers(grpc_server_security_connector* sc,
grpc_handshake_manager* handshake_mgr) {
grpc_handshake_manager_add(
handshake_mgr,
grpc_security_handshaker_create(
- exec_ctx, tsi_create_fake_handshaker(false /* is_client */),
- &sc->base));
+ tsi_create_fake_handshaker(false /* is_client */), &sc->base));
}
static grpc_security_connector_vtable fake_channel_vtable = {
@@ -567,12 +553,11 @@ static bool server_connector_has_cert_config_fetcher(
return server_creds->certificate_config_fetcher.cb != nullptr;
}
-static void ssl_channel_destroy(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc) {
+static void ssl_channel_destroy(grpc_security_connector* sc) {
grpc_ssl_channel_security_connector* c =
(grpc_ssl_channel_security_connector*)sc;
- grpc_channel_credentials_unref(exec_ctx, c->base.channel_creds);
- grpc_call_credentials_unref(exec_ctx, c->base.request_metadata_creds);
+ grpc_channel_credentials_unref(c->base.channel_creds);
+ grpc_call_credentials_unref(c->base.request_metadata_creds);
tsi_ssl_client_handshaker_factory_unref(c->client_handshaker_factory);
c->client_handshaker_factory = nullptr;
if (c->target_name != nullptr) gpr_free(c->target_name);
@@ -580,18 +565,16 @@ static void ssl_channel_destroy(grpc_exec_ctx* exec_ctx,
gpr_free(sc);
}
-static void ssl_server_destroy(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc) {
+static void ssl_server_destroy(grpc_security_connector* sc) {
grpc_ssl_server_security_connector* c =
(grpc_ssl_server_security_connector*)sc;
- grpc_server_credentials_unref(exec_ctx, c->base.server_creds);
+ grpc_server_credentials_unref(c->base.server_creds);
tsi_ssl_server_handshaker_factory_unref(c->server_handshaker_factory);
c->server_handshaker_factory = nullptr;
gpr_free(sc);
}
-static void ssl_channel_add_handshakers(grpc_exec_ctx* exec_ctx,
- grpc_channel_security_connector* sc,
+static void ssl_channel_add_handshakers(grpc_channel_security_connector* sc,
grpc_handshake_manager* handshake_mgr) {
grpc_ssl_channel_security_connector* c =
(grpc_ssl_channel_security_connector*)sc;
@@ -609,9 +592,8 @@ static void ssl_channel_add_handshakers(grpc_exec_ctx* exec_ctx,
}
// Create handshakers.
grpc_handshake_manager_add(
- handshake_mgr,
- grpc_security_handshaker_create(
- exec_ctx, tsi_create_adapter_handshaker(tsi_hs), &sc->base));
+ handshake_mgr, grpc_security_handshaker_create(
+ tsi_create_adapter_handshaker(tsi_hs), &sc->base));
}
static const char** fill_alpn_protocol_strings(size_t* num_alpn_protocols) {
@@ -703,8 +685,7 @@ static bool try_fetch_ssl_server_credentials(
return status;
}
-static void ssl_server_add_handshakers(grpc_exec_ctx* exec_ctx,
- grpc_server_security_connector* sc,
+static void ssl_server_add_handshakers(grpc_server_security_connector* sc,
grpc_handshake_manager* handshake_mgr) {
grpc_ssl_server_security_connector* c =
(grpc_ssl_server_security_connector*)sc;
@@ -720,9 +701,8 @@ static void ssl_server_add_handshakers(grpc_exec_ctx* exec_ctx,
}
// Create handshakers.
grpc_handshake_manager_add(
- handshake_mgr,
- grpc_security_handshaker_create(
- exec_ctx, tsi_create_adapter_handshaker(tsi_hs), &sc->base));
+ handshake_mgr, grpc_security_handshaker_create(
+ tsi_create_adapter_handshaker(tsi_hs), &sc->base));
}
static int ssl_host_matches_name(const tsi_peer* peer, const char* peer_name) {
@@ -806,8 +786,7 @@ static grpc_error* ssl_check_peer(grpc_security_connector* sc,
return GRPC_ERROR_NONE;
}
-static void ssl_channel_check_peer(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc, tsi_peer peer,
+static void ssl_channel_check_peer(grpc_security_connector* sc, tsi_peer peer,
grpc_auth_context** auth_context,
grpc_closure* on_peer_checked) {
grpc_ssl_channel_security_connector* c =
@@ -817,17 +796,16 @@ static void ssl_channel_check_peer(grpc_exec_ctx* exec_ctx,
? c->overridden_target_name
: c->target_name,
&peer, auth_context);
- GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked, error);
+ GRPC_CLOSURE_SCHED(on_peer_checked, error);
tsi_peer_destruct(&peer);
}
-static void ssl_server_check_peer(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc, tsi_peer peer,
+static void ssl_server_check_peer(grpc_security_connector* sc, tsi_peer peer,
grpc_auth_context** auth_context,
grpc_closure* on_peer_checked) {
grpc_error* error = ssl_check_peer(sc, nullptr, &peer, auth_context);
tsi_peer_destruct(&peer);
- GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked, error);
+ GRPC_CLOSURE_SCHED(on_peer_checked, error);
}
static int ssl_channel_cmp(grpc_security_connector* sc1,
@@ -897,8 +875,7 @@ void tsi_shallow_peer_destruct(tsi_peer* peer) {
if (peer->properties != nullptr) gpr_free(peer->properties);
}
-static bool ssl_channel_check_call_host(grpc_exec_ctx* exec_ctx,
- grpc_channel_security_connector* sc,
+static bool ssl_channel_check_call_host(grpc_channel_security_connector* sc,
const char* host,
grpc_auth_context* auth_context,
grpc_closure* on_call_host_checked,
@@ -924,8 +901,8 @@ static bool ssl_channel_check_call_host(grpc_exec_ctx* exec_ctx,
}
static void ssl_channel_cancel_check_call_host(
- grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* sc,
- grpc_closure* on_call_host_checked, grpc_error* error) {
+ grpc_channel_security_connector* sc, grpc_closure* on_call_host_checked,
+ grpc_error* error) {
GRPC_ERROR_UNREF(error);
}
@@ -992,7 +969,7 @@ const char* grpc_get_default_ssl_roots(void) {
}
grpc_security_status grpc_ssl_channel_security_connector_create(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* channel_creds,
+ grpc_channel_credentials* channel_creds,
grpc_call_credentials* request_metadata_creds,
const grpc_ssl_config* config, const char* target_name,
const char* overridden_target_name, grpc_channel_security_connector** sc) {
@@ -1047,7 +1024,7 @@ grpc_security_status grpc_ssl_channel_security_connector_create(
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);
+ ssl_channel_destroy(&c->base.base);
*sc = nullptr;
goto error;
}
@@ -1075,8 +1052,7 @@ grpc_ssl_server_security_connector_initialize(
}
grpc_security_status grpc_ssl_server_security_connector_create(
- grpc_exec_ctx* exec_ctx, grpc_server_credentials* gsc,
- grpc_server_security_connector** sc) {
+ grpc_server_credentials* gsc, grpc_server_security_connector** sc) {
tsi_result result = TSI_OK;
grpc_ssl_server_credentials* server_credentials =
(grpc_ssl_server_credentials*)gsc;
@@ -1116,7 +1092,7 @@ grpc_security_status grpc_ssl_server_security_connector_create(
if (retval == GRPC_SECURITY_OK) {
*sc = &c->base;
} else {
- if (c != nullptr) ssl_server_destroy(exec_ctx, &c->base.base);
+ if (c != nullptr) ssl_server_destroy(&c->base.base);
if (sc != nullptr) *sc = nullptr;
}
return retval;
diff --git a/src/core/lib/security/transport/security_connector.h b/src/core/lib/security/transport/security_connector.h
index 79fdbc1a66..bb66cae422 100644
--- a/src/core/lib/security/transport/security_connector.h
+++ b/src/core/lib/security/transport/security_connector.h
@@ -56,9 +56,9 @@ typedef struct grpc_security_connector grpc_security_connector;
#define GRPC_ARG_SECURITY_CONNECTOR "grpc.security_connector"
typedef struct {
- void (*destroy)(grpc_exec_ctx* exec_ctx, grpc_security_connector* sc);
- void (*check_peer)(grpc_exec_ctx* exec_ctx, grpc_security_connector* sc,
- tsi_peer peer, grpc_auth_context** auth_context,
+ void (*destroy)(grpc_security_connector* sc);
+ void (*check_peer)(grpc_security_connector* sc, tsi_peer peer,
+ grpc_auth_context** auth_context,
grpc_closure* on_peer_checked);
int (*cmp)(grpc_security_connector* sc, grpc_security_connector* other);
} grpc_security_connector_vtable;
@@ -73,29 +73,25 @@ struct grpc_security_connector {
#ifndef NDEBUG
#define GRPC_SECURITY_CONNECTOR_REF(p, r) \
grpc_security_connector_ref((p), __FILE__, __LINE__, (r))
-#define GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, p, r) \
- grpc_security_connector_unref((exec_ctx), (p), __FILE__, __LINE__, (r))
+#define GRPC_SECURITY_CONNECTOR_UNREF(p, r) \
+ grpc_security_connector_unref((p), __FILE__, __LINE__, (r))
grpc_security_connector* grpc_security_connector_ref(
grpc_security_connector* policy, const char* file, int line,
const char* reason);
-void grpc_security_connector_unref(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* policy,
+void grpc_security_connector_unref(grpc_security_connector* policy,
const char* file, int line,
const char* reason);
#else
#define GRPC_SECURITY_CONNECTOR_REF(p, r) grpc_security_connector_ref((p))
-#define GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, p, r) \
- grpc_security_connector_unref((exec_ctx), (p))
+#define GRPC_SECURITY_CONNECTOR_UNREF(p, r) grpc_security_connector_unref((p))
grpc_security_connector* grpc_security_connector_ref(
grpc_security_connector* policy);
-void grpc_security_connector_unref(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* policy);
+void grpc_security_connector_unref(grpc_security_connector* policy);
#endif
/* Check the peer. Callee takes ownership of the peer object.
When done, sets *auth_context and invokes on_peer_checked. */
-void grpc_security_connector_check_peer(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc,
+void grpc_security_connector_check_peer(grpc_security_connector* sc,
tsi_peer peer,
grpc_auth_context** auth_context,
grpc_closure* on_peer_checked);
@@ -125,17 +121,14 @@ struct grpc_channel_security_connector {
grpc_security_connector base;
grpc_channel_credentials* channel_creds;
grpc_call_credentials* request_metadata_creds;
- bool (*check_call_host)(grpc_exec_ctx* exec_ctx,
- grpc_channel_security_connector* sc, const char* host,
+ bool (*check_call_host)(grpc_channel_security_connector* sc, const char* host,
grpc_auth_context* auth_context,
grpc_closure* on_call_host_checked,
grpc_error** error);
- void (*cancel_check_call_host)(grpc_exec_ctx* exec_ctx,
- grpc_channel_security_connector* sc,
+ void (*cancel_check_call_host)(grpc_channel_security_connector* sc,
grpc_closure* on_call_host_checked,
grpc_error* error);
- void (*add_handshakers)(grpc_exec_ctx* exec_ctx,
- grpc_channel_security_connector* sc,
+ void (*add_handshakers)(grpc_channel_security_connector* sc,
grpc_handshake_manager* handshake_mgr);
};
@@ -148,20 +141,20 @@ int grpc_channel_security_connector_cmp(grpc_channel_security_connector* sc1,
/// be set to indicate the result. Otherwise, \a on_call_host_checked
/// will be invoked when complete.
bool grpc_channel_security_connector_check_call_host(
- grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* sc,
- const char* host, grpc_auth_context* auth_context,
- grpc_closure* on_call_host_checked, grpc_error** error);
+ grpc_channel_security_connector* sc, const char* host,
+ grpc_auth_context* auth_context, grpc_closure* on_call_host_checked,
+ grpc_error** error);
/// Cancels a pending asychronous call to
/// grpc_channel_security_connector_check_call_host() with
/// \a on_call_host_checked as its callback.
void grpc_channel_security_connector_cancel_check_call_host(
- grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* sc,
- grpc_closure* on_call_host_checked, grpc_error* error);
+ grpc_channel_security_connector* sc, grpc_closure* on_call_host_checked,
+ grpc_error* error);
/* Registers handshakers with \a handshake_mgr. */
void grpc_channel_security_connector_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* connector,
+ grpc_channel_security_connector* connector,
grpc_handshake_manager* handshake_mgr);
/* --- server_security_connector object. ---
@@ -174,8 +167,7 @@ typedef struct grpc_server_security_connector grpc_server_security_connector;
struct grpc_server_security_connector {
grpc_security_connector base;
grpc_server_credentials* server_creds;
- void (*add_handshakers)(grpc_exec_ctx* exec_ctx,
- grpc_server_security_connector* sc,
+ void (*add_handshakers)(grpc_server_security_connector* sc,
grpc_handshake_manager* handshake_mgr);
};
@@ -184,8 +176,7 @@ int grpc_server_security_connector_cmp(grpc_server_security_connector* sc1,
grpc_server_security_connector* sc2);
void grpc_server_security_connector_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_server_security_connector* sc,
- grpc_handshake_manager* handshake_mgr);
+ grpc_server_security_connector* sc, grpc_handshake_manager* handshake_mgr);
/* --- Creation security connectors. --- */
@@ -222,7 +213,7 @@ typedef struct {
specific error code otherwise.
*/
grpc_security_status grpc_ssl_channel_security_connector_create(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* channel_creds,
+ grpc_channel_credentials* channel_creds,
grpc_call_credentials* request_metadata_creds,
const grpc_ssl_config* config, const char* target_name,
const char* overridden_target_name, grpc_channel_security_connector** sc);
@@ -248,7 +239,7 @@ typedef struct {
specific error code otherwise.
*/
grpc_security_status grpc_ssl_server_security_connector_create(
- grpc_exec_ctx* exec_ctx, grpc_server_credentials* server_credentials,
+ grpc_server_credentials* server_credentials,
grpc_server_security_connector** sc);
/* Util. */
diff --git a/src/core/lib/security/transport/security_handshaker.cc b/src/core/lib/security/transport/security_handshaker.cc
index 7067b70cb6..25a1e59ace 100644
--- a/src/core/lib/security/transport/security_handshaker.cc
+++ b/src/core/lib/security/transport/security_handshaker.cc
@@ -65,8 +65,7 @@ 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) {
+static size_t move_read_buffer_into_handshake_buffer(security_handshaker* h) {
size_t bytes_in_read_buffer = h->args->read_buffer->length;
if (h->handshake_buffer_size < bytes_in_read_buffer) {
h->handshake_buffer =
@@ -79,48 +78,45 @@ static size_t move_read_buffer_into_handshake_buffer(grpc_exec_ctx* exec_ctx,
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);
+ grpc_slice_unref_internal(next_slice);
}
return bytes_in_read_buffer;
}
-static void security_handshaker_unref(grpc_exec_ctx* exec_ctx,
- security_handshaker* h) {
+static void security_handshaker_unref(security_handshaker* h) {
if (gpr_unref(&h->refs)) {
gpr_mu_destroy(&h->mu);
tsi_handshaker_destroy(h->handshaker);
tsi_handshaker_result_destroy(h->handshaker_result);
if (h->endpoint_to_destroy != nullptr) {
- grpc_endpoint_destroy(exec_ctx, h->endpoint_to_destroy);
+ grpc_endpoint_destroy(h->endpoint_to_destroy);
}
if (h->read_buffer_to_destroy != nullptr) {
- grpc_slice_buffer_destroy_internal(exec_ctx, h->read_buffer_to_destroy);
+ grpc_slice_buffer_destroy_internal(h->read_buffer_to_destroy);
gpr_free(h->read_buffer_to_destroy);
}
gpr_free(h->handshake_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &h->outgoing);
+ grpc_slice_buffer_destroy_internal(&h->outgoing);
GRPC_AUTH_CONTEXT_UNREF(h->auth_context, "handshake");
- GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, h->connector, "handshake");
+ GRPC_SECURITY_CONNECTOR_UNREF(h->connector, "handshake");
gpr_free(h);
}
}
// Set args fields to NULL, saving the endpoint and read buffer for
// later destruction.
-static void cleanup_args_for_failure_locked(grpc_exec_ctx* exec_ctx,
- security_handshaker* h) {
+static void cleanup_args_for_failure_locked(security_handshaker* h) {
h->endpoint_to_destroy = h->args->endpoint;
h->args->endpoint = nullptr;
h->read_buffer_to_destroy = h->args->read_buffer;
h->args->read_buffer = nullptr;
- grpc_channel_args_destroy(exec_ctx, h->args->args);
+ grpc_channel_args_destroy(h->args->args);
h->args->args = nullptr;
}
// If the handshake failed or we're shutting down, clean up and invoke the
// callback with the error.
-static void security_handshake_failed_locked(grpc_exec_ctx* exec_ctx,
- security_handshaker* h,
+static void security_handshake_failed_locked(security_handshaker* h,
grpc_error* error) {
if (error == GRPC_ERROR_NONE) {
// If we were shut down after the handshake succeeded but before an
@@ -135,34 +131,33 @@ static void security_handshake_failed_locked(grpc_exec_ctx* exec_ctx,
// before destroying them, even if we know that there are no
// pending read/write callbacks. This should be fixed, at which
// point this can be removed.
- grpc_endpoint_shutdown(exec_ctx, h->args->endpoint, GRPC_ERROR_REF(error));
+ grpc_endpoint_shutdown(h->args->endpoint, GRPC_ERROR_REF(error));
// Not shutting down, so the write failed. Clean up before
// invoking the callback.
- cleanup_args_for_failure_locked(exec_ctx, h);
+ cleanup_args_for_failure_locked(h);
// Set shutdown to true so that subsequent calls to
// security_handshaker_shutdown() do nothing.
h->shutdown = true;
}
// Invoke callback.
- GRPC_CLOSURE_SCHED(exec_ctx, h->on_handshake_done, error);
+ GRPC_CLOSURE_SCHED(h->on_handshake_done, error);
}
-static void on_peer_checked_inner(grpc_exec_ctx* exec_ctx,
- security_handshaker* h, grpc_error* error) {
+static void on_peer_checked_inner(security_handshaker* h, grpc_error* error) {
if (error != GRPC_ERROR_NONE || h->shutdown) {
- security_handshake_failed_locked(exec_ctx, h, GRPC_ERROR_REF(error));
+ security_handshake_failed_locked(h, GRPC_ERROR_REF(error));
return;
}
// Create zero-copy frame protector, if implemented.
tsi_zero_copy_grpc_protector* zero_copy_protector = nullptr;
tsi_result result = tsi_handshaker_result_create_zero_copy_grpc_protector(
- exec_ctx, h->handshaker_result, nullptr, &zero_copy_protector);
+ h->handshaker_result, nullptr, &zero_copy_protector);
if (result != TSI_OK && result != TSI_UNIMPLEMENTED) {
error = grpc_set_tsi_error_result(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Zero-copy frame protector creation failed"),
result);
- security_handshake_failed_locked(exec_ctx, h, error);
+ security_handshake_failed_locked(h, error);
return;
}
// Create frame protector if zero-copy frame protector is NULL.
@@ -174,7 +169,7 @@ static void on_peer_checked_inner(grpc_exec_ctx* exec_ctx,
error = grpc_set_tsi_error_result(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Frame protector creation failed"),
result);
- security_handshake_failed_locked(exec_ctx, h, error);
+ security_handshake_failed_locked(h, error);
return;
}
}
@@ -189,7 +184,7 @@ static void on_peer_checked_inner(grpc_exec_ctx* exec_ctx,
grpc_slice_from_copied_buffer((char*)unused_bytes, unused_bytes_size);
h->args->endpoint = grpc_secure_endpoint_create(
protector, zero_copy_protector, h->args->endpoint, &slice, 1);
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
} else {
h->args->endpoint = grpc_secure_endpoint_create(
protector, zero_copy_protector, h->args->endpoint, nullptr, 0);
@@ -201,25 +196,23 @@ static void on_peer_checked_inner(grpc_exec_ctx* exec_ctx,
grpc_channel_args* tmp_args = h->args->args;
h->args->args =
grpc_channel_args_copy_and_add(tmp_args, &auth_context_arg, 1);
- grpc_channel_args_destroy(exec_ctx, tmp_args);
+ grpc_channel_args_destroy(tmp_args);
// Invoke callback.
- GRPC_CLOSURE_SCHED(exec_ctx, h->on_handshake_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(h->on_handshake_done, GRPC_ERROR_NONE);
// Set shutdown to true so that subsequent calls to
// security_handshaker_shutdown() do nothing.
h->shutdown = true;
}
-static void on_peer_checked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_peer_checked(void* arg, grpc_error* error) {
security_handshaker* h = (security_handshaker*)arg;
gpr_mu_lock(&h->mu);
- on_peer_checked_inner(exec_ctx, h, error);
+ on_peer_checked_inner(h, error);
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
}
-static grpc_error* check_peer_locked(grpc_exec_ctx* exec_ctx,
- security_handshaker* h) {
+static grpc_error* check_peer_locked(security_handshaker* h) {
tsi_peer peer;
tsi_result result =
tsi_handshaker_result_extract_peer(h->handshaker_result, &peer);
@@ -227,20 +220,20 @@ static grpc_error* check_peer_locked(grpc_exec_ctx* exec_ctx,
return grpc_set_tsi_error_result(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Peer extraction failed"), result);
}
- grpc_security_connector_check_peer(exec_ctx, h->connector, peer,
- &h->auth_context, &h->on_peer_checked);
+ grpc_security_connector_check_peer(h->connector, peer, &h->auth_context,
+ &h->on_peer_checked);
return GRPC_ERROR_NONE;
}
static grpc_error* on_handshake_next_done_locked(
- grpc_exec_ctx* exec_ctx, security_handshaker* h, tsi_result result,
+ security_handshaker* h, tsi_result result,
const unsigned char* bytes_to_send, size_t bytes_to_send_size,
tsi_handshaker_result* handshaker_result) {
grpc_error* error = GRPC_ERROR_NONE;
// Read more if we need to.
if (result == TSI_INCOMPLETE_DATA) {
GPR_ASSERT(bytes_to_send_size == 0);
- grpc_endpoint_read(exec_ctx, h->args->endpoint, h->args->read_buffer,
+ grpc_endpoint_read(h->args->endpoint, h->args->read_buffer,
&h->on_handshake_data_received_from_peer);
return error;
}
@@ -257,17 +250,17 @@ static grpc_error* on_handshake_next_done_locked(
// Send data to peer, if needed.
grpc_slice to_send = grpc_slice_from_copied_buffer(
(const char*)bytes_to_send, bytes_to_send_size);
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &h->outgoing);
+ grpc_slice_buffer_reset_and_unref_internal(&h->outgoing);
grpc_slice_buffer_add(&h->outgoing, to_send);
- grpc_endpoint_write(exec_ctx, h->args->endpoint, &h->outgoing,
+ grpc_endpoint_write(h->args->endpoint, &h->outgoing,
&h->on_handshake_data_sent_to_peer);
} else if (handshaker_result == nullptr) {
// There is nothing to send, but need to read from peer.
- grpc_endpoint_read(exec_ctx, h->args->endpoint, h->args->read_buffer,
+ grpc_endpoint_read(h->args->endpoint, h->args->read_buffer,
&h->on_handshake_data_received_from_peer);
} else {
// Handshake has finished, check peer and so on.
- error = check_peer_locked(exec_ctx, h);
+ error = check_peer_locked(h);
}
return error;
}
@@ -278,24 +271,22 @@ static void on_handshake_next_done_grpc_wrapper(
security_handshaker* h = (security_handshaker*)user_data;
// This callback will be invoked by TSI in a non-grpc thread, so it's
// safe to create our own exec_ctx here.
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_mu_lock(&h->mu);
- grpc_error* error =
- on_handshake_next_done_locked(&exec_ctx, h, result, bytes_to_send,
- bytes_to_send_size, handshaker_result);
+ grpc_error* error = on_handshake_next_done_locked(
+ h, result, bytes_to_send, bytes_to_send_size, handshaker_result);
if (error != GRPC_ERROR_NONE) {
- security_handshake_failed_locked(&exec_ctx, h, error);
+ security_handshake_failed_locked(h, error);
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(&exec_ctx, h);
+ security_handshaker_unref(h);
} else {
gpr_mu_unlock(&h->mu);
}
- grpc_exec_ctx_finish(&exec_ctx);
}
static grpc_error* do_handshaker_next_locked(
- grpc_exec_ctx* exec_ctx, security_handshaker* h,
- const unsigned char* bytes_received, size_t bytes_received_size) {
+ security_handshaker* h, const unsigned char* bytes_received,
+ size_t bytes_received_size) {
// Invoke TSI handshaker.
const unsigned char* bytes_to_send = nullptr;
size_t bytes_to_send_size = 0;
@@ -311,62 +302,57 @@ static grpc_error* do_handshaker_next_locked(
}
// Handshaker returned synchronously. Invoke callback directly in
// this thread with our existing exec_ctx.
- return on_handshake_next_done_locked(exec_ctx, h, result, bytes_to_send,
+ return on_handshake_next_done_locked(h, result, bytes_to_send,
bytes_to_send_size, handshaker_result);
}
-static void on_handshake_data_received_from_peer(grpc_exec_ctx* exec_ctx,
- void* arg, grpc_error* error) {
+static void on_handshake_data_received_from_peer(void* arg, grpc_error* error) {
security_handshaker* h = (security_handshaker*)arg;
gpr_mu_lock(&h->mu);
if (error != GRPC_ERROR_NONE || h->shutdown) {
security_handshake_failed_locked(
- exec_ctx, h,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Handshake read failed", &error, 1));
+ h, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Handshake read failed", &error, 1));
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
return;
}
// Copy all slices received.
- size_t bytes_received_size =
- move_read_buffer_into_handshake_buffer(exec_ctx, h);
+ size_t bytes_received_size = move_read_buffer_into_handshake_buffer(h);
// Call TSI handshaker.
- error = do_handshaker_next_locked(exec_ctx, h, h->handshake_buffer,
- bytes_received_size);
+ error =
+ do_handshaker_next_locked(h, h->handshake_buffer, bytes_received_size);
if (error != GRPC_ERROR_NONE) {
- security_handshake_failed_locked(exec_ctx, h, error);
+ security_handshake_failed_locked(h, error);
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
} else {
gpr_mu_unlock(&h->mu);
}
}
-static void on_handshake_data_sent_to_peer(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_handshake_data_sent_to_peer(void* arg, grpc_error* error) {
security_handshaker* h = (security_handshaker*)arg;
gpr_mu_lock(&h->mu);
if (error != GRPC_ERROR_NONE || h->shutdown) {
security_handshake_failed_locked(
- exec_ctx, h,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Handshake write failed", &error, 1));
+ h, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Handshake write failed", &error, 1));
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
return;
}
// We may be done.
if (h->handshaker_result == nullptr) {
- grpc_endpoint_read(exec_ctx, h->args->endpoint, h->args->read_buffer,
+ grpc_endpoint_read(h->args->endpoint, h->args->read_buffer,
&h->on_handshake_data_received_from_peer);
} else {
- error = check_peer_locked(exec_ctx, h);
+ error = check_peer_locked(h);
if (error != GRPC_ERROR_NONE) {
- security_handshake_failed_locked(exec_ctx, h, error);
+ security_handshake_failed_locked(h, error);
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
return;
}
}
@@ -377,28 +363,25 @@ static void on_handshake_data_sent_to_peer(grpc_exec_ctx* exec_ctx, void* arg,
// public handshaker API
//
-static void security_handshaker_destroy(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker) {
+static void security_handshaker_destroy(grpc_handshaker* handshaker) {
security_handshaker* h = (security_handshaker*)handshaker;
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
}
-static void security_handshaker_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker,
+static void security_handshaker_shutdown(grpc_handshaker* handshaker,
grpc_error* why) {
security_handshaker* h = (security_handshaker*)handshaker;
gpr_mu_lock(&h->mu);
if (!h->shutdown) {
h->shutdown = true;
- grpc_endpoint_shutdown(exec_ctx, h->args->endpoint, GRPC_ERROR_REF(why));
- cleanup_args_for_failure_locked(exec_ctx, h);
+ grpc_endpoint_shutdown(h->args->endpoint, GRPC_ERROR_REF(why));
+ cleanup_args_for_failure_locked(h);
}
gpr_mu_unlock(&h->mu);
GRPC_ERROR_UNREF(why);
}
-static void security_handshaker_do_handshake(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker,
+static void security_handshaker_do_handshake(grpc_handshaker* handshaker,
grpc_tcp_server_acceptor* acceptor,
grpc_closure* on_handshake_done,
grpc_handshaker_args* args) {
@@ -407,14 +390,13 @@ 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);
- 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);
+ size_t bytes_received_size = move_read_buffer_into_handshake_buffer(h);
+ grpc_error* error =
+ do_handshaker_next_locked(h, h->handshake_buffer, bytes_received_size);
if (error != GRPC_ERROR_NONE) {
- security_handshake_failed_locked(exec_ctx, h, error);
+ security_handshake_failed_locked(h, error);
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
return;
}
gpr_mu_unlock(&h->mu);
@@ -425,8 +407,7 @@ static const grpc_handshaker_vtable security_handshaker_vtable = {
security_handshaker_do_handshake};
static grpc_handshaker* security_handshaker_create(
- grpc_exec_ctx* exec_ctx, tsi_handshaker* handshaker,
- grpc_security_connector* connector) {
+ tsi_handshaker* handshaker, grpc_security_connector* connector) {
security_handshaker* h =
(security_handshaker*)gpr_zalloc(sizeof(security_handshaker));
grpc_handshaker_init(&security_handshaker_vtable, &h->base);
@@ -452,23 +433,20 @@ static grpc_handshaker* security_handshaker_create(
// fail_handshaker
//
-static void fail_handshaker_destroy(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker) {
+static void fail_handshaker_destroy(grpc_handshaker* handshaker) {
gpr_free(handshaker);
}
-static void fail_handshaker_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker,
+static void fail_handshaker_shutdown(grpc_handshaker* handshaker,
grpc_error* why) {
GRPC_ERROR_UNREF(why);
}
-static void fail_handshaker_do_handshake(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker,
+static void fail_handshaker_do_handshake(grpc_handshaker* handshaker,
grpc_tcp_server_acceptor* acceptor,
grpc_closure* on_handshake_done,
grpc_handshaker_args* args) {
- GRPC_CLOSURE_SCHED(exec_ctx, on_handshake_done,
+ GRPC_CLOSURE_SCHED(on_handshake_done,
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Failed to create security handshaker"));
}
@@ -488,27 +466,27 @@ static grpc_handshaker* fail_handshaker_create() {
//
static void client_handshaker_factory_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory* handshaker_factory,
- const grpc_channel_args* args, grpc_handshake_manager* handshake_mgr) {
+ grpc_handshaker_factory* handshaker_factory, const grpc_channel_args* args,
+ grpc_handshake_manager* handshake_mgr) {
grpc_channel_security_connector* security_connector =
(grpc_channel_security_connector*)grpc_security_connector_find_in_args(
args);
- grpc_channel_security_connector_add_handshakers(exec_ctx, security_connector,
+ grpc_channel_security_connector_add_handshakers(security_connector,
handshake_mgr);
}
static void server_handshaker_factory_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory* hf,
- const grpc_channel_args* args, grpc_handshake_manager* handshake_mgr) {
+ grpc_handshaker_factory* hf, const grpc_channel_args* args,
+ grpc_handshake_manager* handshake_mgr) {
grpc_server_security_connector* security_connector =
(grpc_server_security_connector*)grpc_security_connector_find_in_args(
args);
- grpc_server_security_connector_add_handshakers(exec_ctx, security_connector,
+ grpc_server_security_connector_add_handshakers(security_connector,
handshake_mgr);
}
static void handshaker_factory_destroy(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory* handshaker_factory) {}
+ grpc_handshaker_factory* handshaker_factory) {}
static const grpc_handshaker_factory_vtable client_handshaker_factory_vtable = {
client_handshaker_factory_add_handshakers, handshaker_factory_destroy};
@@ -527,14 +505,13 @@ static grpc_handshaker_factory server_handshaker_factory = {
//
grpc_handshaker* grpc_security_handshaker_create(
- grpc_exec_ctx* exec_ctx, tsi_handshaker* handshaker,
- grpc_security_connector* connector) {
+ tsi_handshaker* handshaker, grpc_security_connector* connector) {
// If no TSI handshaker was created, return a handshaker that always fails.
// Otherwise, return a real security handshaker.
if (handshaker == nullptr) {
return fail_handshaker_create();
} else {
- return security_handshaker_create(exec_ctx, handshaker, connector);
+ return security_handshaker_create(handshaker, connector);
}
}
diff --git a/src/core/lib/security/transport/security_handshaker.h b/src/core/lib/security/transport/security_handshaker.h
index 174f70f0dd..b4c704c05f 100644
--- a/src/core/lib/security/transport/security_handshaker.h
+++ b/src/core/lib/security/transport/security_handshaker.h
@@ -29,8 +29,7 @@ extern "C" {
/// Creates a security handshaker using \a handshaker.
grpc_handshaker* grpc_security_handshaker_create(
- grpc_exec_ctx* exec_ctx, tsi_handshaker* handshaker,
- grpc_security_connector* connector);
+ tsi_handshaker* handshaker, grpc_security_connector* connector);
/// Registers security handshaker factories.
void grpc_security_register_handshaker_factories();
diff --git a/src/core/lib/security/transport/server_auth_filter.cc b/src/core/lib/security/transport/server_auth_filter.cc
index 9cf368acd0..3566ddf64e 100644
--- a/src/core/lib/security/transport/server_auth_filter.cc
+++ b/src/core/lib/security/transport/server_auth_filter.cc
@@ -73,8 +73,7 @@ static grpc_metadata_array metadata_batch_to_md_array(
return result;
}
-static grpc_filtered_mdelem remove_consumed_md(grpc_exec_ctx* exec_ctx,
- void* user_data,
+static grpc_filtered_mdelem remove_consumed_md(void* user_data,
grpc_mdelem md) {
grpc_call_element* elem = (grpc_call_element*)user_data;
call_data* calld = (call_data*)elem->call_data;
@@ -88,8 +87,7 @@ static grpc_filtered_mdelem remove_consumed_md(grpc_exec_ctx* exec_ctx,
return GRPC_FILTERED_MDELEM(md);
}
-static void on_md_processing_done_inner(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void on_md_processing_done_inner(grpc_call_element* elem,
const grpc_metadata* consumed_md,
size_t num_consumed_md,
const grpc_metadata* response_md,
@@ -107,11 +105,10 @@ static void on_md_processing_done_inner(grpc_exec_ctx* exec_ctx,
calld->consumed_md = consumed_md;
calld->num_consumed_md = num_consumed_md;
error = grpc_metadata_batch_filter(
- exec_ctx, batch->payload->recv_initial_metadata.recv_initial_metadata,
+ batch->payload->recv_initial_metadata.recv_initial_metadata,
remove_consumed_md, elem, "Response metadata filtering error");
}
- GRPC_CLOSURE_SCHED(exec_ctx, calld->original_recv_initial_metadata_ready,
- error);
+ GRPC_CLOSURE_SCHED(calld->original_recv_initial_metadata_ready, error);
}
// Called from application code.
@@ -121,7 +118,7 @@ static void on_md_processing_done(
grpc_status_code status, const char* error_details) {
grpc_call_element* elem = (grpc_call_element*)user_data;
call_data* calld = (call_data*)elem->call_data;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
// If the call was not cancelled while we were in flight, process the result.
if (gpr_atm_full_cas(&calld->state, (gpr_atm)STATE_INIT,
(gpr_atm)STATE_DONE)) {
@@ -134,34 +131,32 @@ static void on_md_processing_done(
GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_details),
GRPC_ERROR_INT_GRPC_STATUS, status);
}
- on_md_processing_done_inner(&exec_ctx, elem, consumed_md, num_consumed_md,
- response_md, num_response_md, error);
+ on_md_processing_done_inner(elem, consumed_md, num_consumed_md, response_md,
+ num_response_md, error);
}
// Clean up.
for (size_t i = 0; i < calld->md.count; i++) {
- grpc_slice_unref_internal(&exec_ctx, calld->md.metadata[i].key);
- grpc_slice_unref_internal(&exec_ctx, calld->md.metadata[i].value);
+ grpc_slice_unref_internal(calld->md.metadata[i].key);
+ grpc_slice_unref_internal(calld->md.metadata[i].value);
}
grpc_metadata_array_destroy(&calld->md);
- GRPC_CALL_STACK_UNREF(&exec_ctx, calld->owning_call, "server_auth_metadata");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_CALL_STACK_UNREF(calld->owning_call, "server_auth_metadata");
}
-static void cancel_call(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void cancel_call(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
call_data* calld = (call_data*)elem->call_data;
// If the result was not already processed, invoke the callback now.
if (error != GRPC_ERROR_NONE &&
gpr_atm_full_cas(&calld->state, (gpr_atm)STATE_INIT,
(gpr_atm)STATE_CANCELLED)) {
- on_md_processing_done_inner(exec_ctx, elem, nullptr, 0, nullptr, 0,
+ on_md_processing_done_inner(elem, nullptr, 0, nullptr, 0,
GRPC_ERROR_REF(error));
}
- GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "cancel_call");
+ GRPC_CALL_STACK_UNREF(calld->owning_call, "cancel_call");
}
-static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void recv_initial_metadata_ready(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
channel_data* chand = (channel_data*)elem->channel_data;
call_data* calld = (call_data*)elem->call_data;
@@ -173,7 +168,7 @@ static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx, void* arg,
GRPC_CALL_STACK_REF(calld->owning_call, "cancel_call");
GRPC_CLOSURE_INIT(&calld->cancel_closure, cancel_call, elem,
grpc_schedule_on_exec_ctx);
- grpc_call_combiner_set_notify_on_cancel(exec_ctx, calld->call_combiner,
+ grpc_call_combiner_set_notify_on_cancel(calld->call_combiner,
&calld->cancel_closure);
GRPC_CALL_STACK_REF(calld->owning_call, "server_auth_metadata");
calld->md = metadata_batch_to_md_array(
@@ -184,13 +179,12 @@ static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx, void* arg,
return;
}
}
- GRPC_CLOSURE_RUN(exec_ctx, calld->original_recv_initial_metadata_ready,
+ GRPC_CLOSURE_RUN(calld->original_recv_initial_metadata_ready,
GRPC_ERROR_REF(error));
}
static void auth_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* batch) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
call_data* calld = (call_data*)elem->call_data;
if (batch->recv_initial_metadata) {
// Inject our callback.
@@ -200,12 +194,11 @@ static void auth_start_transport_stream_op_batch(
batch->payload->recv_initial_metadata.recv_initial_metadata_ready =
&calld->recv_initial_metadata_ready;
}
- grpc_call_next_op(exec_ctx, elem, batch);
+ grpc_call_next_op(elem, batch);
}
/* Constructor for call_data */
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
call_data* calld = (call_data*)elem->call_data;
channel_data* chand = (channel_data*)elem->channel_data;
@@ -231,13 +224,12 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
}
/* Destructor for call_data */
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {}
/* Constructor for channel_data */
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
GPR_ASSERT(!args->is_last);
channel_data* chand = (channel_data*)elem->channel_data;
@@ -253,11 +245,10 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
}
/* Destructor for channel data */
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {
+static void destroy_channel_elem(grpc_channel_element* elem) {
channel_data* chand = (channel_data*)elem->channel_data;
GRPC_AUTH_CONTEXT_UNREF(chand->auth_context, "server_auth_filter");
- grpc_server_credentials_unref(exec_ctx, chand->creds);
+ grpc_server_credentials_unref(chand->creds);
}
const grpc_channel_filter grpc_server_auth_filter = {
diff --git a/src/core/lib/slice/b64.cc b/src/core/lib/slice/b64.cc
index fe7a86ef84..f36b13ef1b 100644
--- a/src/core/lib/slice/b64.cc
+++ b/src/core/lib/slice/b64.cc
@@ -122,9 +122,8 @@ void grpc_base64_encode_core(char* result, const void* vdata, size_t data_size,
result[current - result] = '\0';
}
-grpc_slice grpc_base64_decode(grpc_exec_ctx* exec_ctx, const char* b64,
- int url_safe) {
- return grpc_base64_decode_with_len(exec_ctx, b64, strlen(b64), url_safe);
+grpc_slice grpc_base64_decode(const char* b64, int url_safe) {
+ return grpc_base64_decode_with_len(b64, strlen(b64), url_safe);
}
static void decode_one_char(const unsigned char* codes, unsigned char* result,
@@ -185,8 +184,8 @@ static int decode_group(const unsigned char* codes, size_t num_codes,
return 1;
}
-grpc_slice grpc_base64_decode_with_len(grpc_exec_ctx* exec_ctx, const char* b64,
- size_t b64_len, int url_safe) {
+grpc_slice grpc_base64_decode_with_len(const char* b64, size_t b64_len,
+ int url_safe) {
grpc_slice result = GRPC_SLICE_MALLOC(b64_len);
unsigned char* current = GRPC_SLICE_START_PTR(result);
size_t result_size = 0;
@@ -231,6 +230,6 @@ grpc_slice grpc_base64_decode_with_len(grpc_exec_ctx* exec_ctx, const char* b64,
return result;
fail:
- grpc_slice_unref_internal(exec_ctx, result);
+ grpc_slice_unref_internal(result);
return grpc_empty_slice();
}
diff --git a/src/core/lib/slice/b64.h b/src/core/lib/slice/b64.h
index 467f5d848a..39dede770e 100644
--- a/src/core/lib/slice/b64.h
+++ b/src/core/lib/slice/b64.h
@@ -44,12 +44,11 @@ void grpc_base64_encode_core(char* result, const void* vdata, size_t data_size,
/* Decodes data according to the base64 specification. Returns an empty
slice in case of failure. */
-grpc_slice grpc_base64_decode(grpc_exec_ctx* exec_ctx, const char* b64,
- int url_safe);
+grpc_slice grpc_base64_decode(const char* b64, int url_safe);
/* Same as above except that the length is provided by the caller. */
-grpc_slice grpc_base64_decode_with_len(grpc_exec_ctx* exec_ctx, const char* b64,
- size_t b64_len, int url_safe);
+grpc_slice grpc_base64_decode_with_len(const char* b64, size_t b64_len,
+ int url_safe);
#ifdef __cplusplus
}
diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc
index bbaf87ba23..7ac6204716 100644
--- a/src/core/lib/slice/slice.cc
+++ b/src/core/lib/slice/slice.cc
@@ -54,9 +54,9 @@ grpc_slice grpc_slice_ref_internal(grpc_slice slice) {
return slice;
}
-void grpc_slice_unref_internal(grpc_exec_ctx* exec_ctx, grpc_slice slice) {
+void grpc_slice_unref_internal(grpc_slice slice) {
if (slice.refcount) {
- slice.refcount->vtable->unref(exec_ctx, slice.refcount);
+ slice.refcount->vtable->unref(slice.refcount);
}
}
@@ -67,15 +67,14 @@ grpc_slice grpc_slice_ref(grpc_slice slice) {
/* Public API */
void grpc_slice_unref(grpc_slice slice) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_unref_internal(&exec_ctx, slice);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_slice_unref_internal(slice);
}
/* grpc_slice_from_static_string support structure - a refcount that does
nothing */
static void noop_ref(void* unused) {}
-static void noop_unref(grpc_exec_ctx* exec_ctx, void* unused) {}
+static void noop_unref(void* unused) {}
static const grpc_slice_refcount_vtable noop_refcount_vtable = {
noop_ref, noop_unref, grpc_slice_default_eq_impl,
@@ -109,7 +108,7 @@ static void new_slice_ref(void* p) {
gpr_ref(&r->refs);
}
-static void new_slice_unref(grpc_exec_ctx* exec_ctx, void* p) {
+static void new_slice_unref(void* p) {
new_slice_refcount* r = (new_slice_refcount*)p;
if (gpr_unref(&r->refs)) {
r->user_destroy(r->user_data);
@@ -159,7 +158,7 @@ static void new_with_len_ref(void* p) {
gpr_ref(&r->refs);
}
-static void new_with_len_unref(grpc_exec_ctx* exec_ctx, void* p) {
+static void new_with_len_unref(void* p) {
new_with_len_slice_refcount* r = (new_with_len_slice_refcount*)p;
if (gpr_unref(&r->refs)) {
r->user_destroy(r->user_data, r->user_length);
@@ -210,7 +209,7 @@ static void malloc_ref(void* p) {
gpr_ref(&r->refs);
}
-static void malloc_unref(grpc_exec_ctx* exec_ctx, void* p) {
+static void malloc_unref(void* p) {
malloc_refcount* r = (malloc_refcount*)p;
if (gpr_unref(&r->refs)) {
gpr_free(r);
diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc
index 5db54dad91..dbe8d48343 100644
--- a/src/core/lib/slice/slice_buffer.cc
+++ b/src/core/lib/slice/slice_buffer.cc
@@ -65,18 +65,16 @@ void grpc_slice_buffer_init(grpc_slice_buffer* sb) {
sb->base_slices = sb->slices = sb->inlined;
}
-void grpc_slice_buffer_destroy_internal(grpc_exec_ctx* exec_ctx,
- grpc_slice_buffer* sb) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, sb);
+void grpc_slice_buffer_destroy_internal(grpc_slice_buffer* sb) {
+ grpc_slice_buffer_reset_and_unref_internal(sb);
if (sb->base_slices != sb->inlined) {
gpr_free(sb->base_slices);
}
}
void grpc_slice_buffer_destroy(grpc_slice_buffer* sb) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_buffer_destroy_internal(&exec_ctx, sb);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_slice_buffer_destroy_internal(sb);
}
uint8_t* grpc_slice_buffer_tiny_add(grpc_slice_buffer* sb, size_t n) {
@@ -163,11 +161,10 @@ void grpc_slice_buffer_pop(grpc_slice_buffer* sb) {
}
}
-void grpc_slice_buffer_reset_and_unref_internal(grpc_exec_ctx* exec_ctx,
- grpc_slice_buffer* sb) {
+void grpc_slice_buffer_reset_and_unref_internal(grpc_slice_buffer* sb) {
size_t i;
for (i = 0; i < sb->count; i++) {
- grpc_slice_unref_internal(exec_ctx, sb->slices[i]);
+ grpc_slice_unref_internal(sb->slices[i]);
}
sb->count = 0;
@@ -175,9 +172,8 @@ void grpc_slice_buffer_reset_and_unref_internal(grpc_exec_ctx* exec_ctx,
}
void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer* sb) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_buffer_reset_and_unref_internal(&exec_ctx, sb);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_slice_buffer_reset_and_unref_internal(sb);
}
void grpc_slice_buffer_swap(grpc_slice_buffer* a, grpc_slice_buffer* b) {
@@ -289,8 +285,7 @@ void grpc_slice_buffer_move_first_no_ref(grpc_slice_buffer* src, size_t n,
slice_buffer_move_first_maybe_ref(src, n, dst, false);
}
-void grpc_slice_buffer_move_first_into_buffer(grpc_exec_ctx* exec_ctx,
- grpc_slice_buffer* src, size_t n,
+void grpc_slice_buffer_move_first_into_buffer(grpc_slice_buffer* src, size_t n,
void* dst) {
char* dstp = (char*)dst;
GPR_ASSERT(src->length >= n);
@@ -305,13 +300,13 @@ void grpc_slice_buffer_move_first_into_buffer(grpc_exec_ctx* exec_ctx,
n = 0;
} else if (slice_len == n) {
memcpy(dstp, GRPC_SLICE_START_PTR(slice), n);
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
n = 0;
} else {
memcpy(dstp, GRPC_SLICE_START_PTR(slice), slice_len);
dstp += slice_len;
n -= slice_len;
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
}
}
}
diff --git a/src/core/lib/slice/slice_hash_table.cc b/src/core/lib/slice/slice_hash_table.cc
index 8f8e5a6b34..89340eff84 100644
--- a/src/core/lib/slice/slice_hash_table.cc
+++ b/src/core/lib/slice/slice_hash_table.cc
@@ -27,7 +27,7 @@
struct grpc_slice_hash_table {
gpr_refcount refs;
- void (*destroy_value)(grpc_exec_ctx* exec_ctx, void* value);
+ void (*destroy_value)(void* value);
int (*value_cmp)(void* a, void* b);
size_t size;
size_t max_num_probes;
@@ -58,8 +58,7 @@ static void grpc_slice_hash_table_add(grpc_slice_hash_table* table,
grpc_slice_hash_table* grpc_slice_hash_table_create(
size_t num_entries, grpc_slice_hash_table_entry* entries,
- void (*destroy_value)(grpc_exec_ctx* exec_ctx, void* value),
- int (*value_cmp)(void* a, void* b)) {
+ void (*destroy_value)(void* value), int (*value_cmp)(void* a, void* b)) {
grpc_slice_hash_table* table =
(grpc_slice_hash_table*)gpr_zalloc(sizeof(*table));
gpr_ref_init(&table->refs, 1);
@@ -81,14 +80,13 @@ grpc_slice_hash_table* grpc_slice_hash_table_ref(grpc_slice_hash_table* table) {
return table;
}
-void grpc_slice_hash_table_unref(grpc_exec_ctx* exec_ctx,
- grpc_slice_hash_table* table) {
+void grpc_slice_hash_table_unref(grpc_slice_hash_table* table) {
if (table != nullptr && gpr_unref(&table->refs)) {
for (size_t i = 0; i < table->size; ++i) {
grpc_slice_hash_table_entry* entry = &table->entries[i];
if (!is_empty(entry)) {
- grpc_slice_unref_internal(exec_ctx, entry->key);
- table->destroy_value(exec_ctx, entry->value);
+ grpc_slice_unref_internal(entry->key);
+ table->destroy_value(entry->value);
}
}
gpr_free(table->entries);
diff --git a/src/core/lib/slice/slice_hash_table.h b/src/core/lib/slice/slice_hash_table.h
index f86f25ea7c..6d212a0d32 100644
--- a/src/core/lib/slice/slice_hash_table.h
+++ b/src/core/lib/slice/slice_hash_table.h
@@ -50,12 +50,10 @@ typedef struct grpc_slice_hash_table_entry {
will be used. */
grpc_slice_hash_table* grpc_slice_hash_table_create(
size_t num_entries, grpc_slice_hash_table_entry* entries,
- void (*destroy_value)(grpc_exec_ctx* exec_ctx, void* value),
- int (*value_cmp)(void* a, void* b));
+ void (*destroy_value)(void* value), int (*value_cmp)(void* a, void* b));
grpc_slice_hash_table* grpc_slice_hash_table_ref(grpc_slice_hash_table* table);
-void grpc_slice_hash_table_unref(grpc_exec_ctx* exec_ctx,
- grpc_slice_hash_table* table);
+void grpc_slice_hash_table_unref(grpc_slice_hash_table* table);
/** Returns the value from \a table associated with \a key.
Returns NULL if \a key is not found. */
diff --git a/src/core/lib/slice/slice_intern.cc b/src/core/lib/slice/slice_intern.cc
index e8949135c0..c578c6d9de 100644
--- a/src/core/lib/slice/slice_intern.cc
+++ b/src/core/lib/slice/slice_intern.cc
@@ -90,7 +90,7 @@ static void interned_slice_destroy(interned_slice_refcount* s) {
gpr_mu_unlock(&shard->mu);
}
-static void interned_slice_unref(grpc_exec_ctx* exec_ctx, void* p) {
+static void interned_slice_unref(void* p) {
interned_slice_refcount* s = (interned_slice_refcount*)p;
if (1 == gpr_atm_full_fetch_add(&s->refcnt, -1)) {
interned_slice_destroy(s);
@@ -101,9 +101,8 @@ static void interned_slice_sub_ref(void* p) {
interned_slice_ref(((char*)p) - offsetof(interned_slice_refcount, sub));
}
-static void interned_slice_sub_unref(grpc_exec_ctx* exec_ctx, void* p) {
- interned_slice_unref(exec_ctx,
- ((char*)p) - offsetof(interned_slice_refcount, sub));
+static void interned_slice_sub_unref(void* p) {
+ interned_slice_unref(((char*)p) - offsetof(interned_slice_refcount, sub));
}
static uint32_t interned_slice_hash(grpc_slice slice) {
diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h
index 2439fc0826..be66b8ab00 100644
--- a/src/core/lib/slice/slice_internal.h
+++ b/src/core/lib/slice/slice_internal.h
@@ -29,11 +29,9 @@ 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_destroy_internal(grpc_exec_ctx* exec_ctx,
- grpc_slice_buffer* sb);
+void grpc_slice_unref_internal(grpc_slice slice);
+void grpc_slice_buffer_reset_and_unref_internal(grpc_slice_buffer* sb);
+void grpc_slice_buffer_destroy_internal(grpc_slice_buffer* sb);
/* Check if a slice is interned */
bool grpc_slice_is_interned(grpc_slice slice);
diff --git a/src/core/lib/surface/alarm.cc b/src/core/lib/surface/alarm.cc
index d8b1f18065..00d609b80d 100644
--- a/src/core/lib/surface/alarm.cc
+++ b/src/core/lib/surface/alarm.cc
@@ -47,11 +47,11 @@ 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;
+ grpc_core::ExecCtx _local_exec_ctx;
if (alarm->cq != nullptr) {
- GRPC_CQ_INTERNAL_UNREF(&exec_ctx, alarm->cq, "alarm");
+ GRPC_CQ_INTERNAL_UNREF(alarm->cq, "alarm");
}
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_free(alarm);
}
}
@@ -82,20 +82,19 @@ static void alarm_unref_dbg(grpc_alarm* alarm, const char* reason,
}
#endif
-static void alarm_end_completion(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_cq_completion* c) {
+static void alarm_end_completion(void* arg, grpc_cq_completion* c) {
grpc_alarm* alarm = (grpc_alarm*)arg;
GRPC_ALARM_UNREF(alarm, "dequeue-end-op");
}
-static void alarm_cb(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void alarm_cb(void* arg, grpc_error* error) {
grpc_alarm* alarm = (grpc_alarm*)arg;
/* We are queuing an op on completion queue. This means, the alarm's structure
cannot be destroyed until the op is dequeued. Adding an extra ref
here and unref'ing when the op is dequeued will achieve this */
GRPC_ALARM_REF(alarm, "queue-end-op");
- grpc_cq_end_op(exec_ctx, alarm->cq, alarm->tag, error, alarm_end_completion,
+ grpc_cq_end_op(alarm->cq, alarm->tag, error, alarm_end_completion,
(void*)alarm, &alarm->completion);
}
@@ -118,22 +117,20 @@ grpc_alarm* grpc_alarm_create(void* reserved) {
void grpc_alarm_set(grpc_alarm* alarm, grpc_completion_queue* cq,
gpr_timespec deadline, void* tag, void* reserved) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GRPC_CQ_INTERNAL_REF(cq, "alarm");
alarm->cq = cq;
alarm->tag = tag;
GPR_ASSERT(grpc_cq_begin_op(cq, tag));
- grpc_timer_init(&exec_ctx, &alarm->alarm,
- grpc_timespec_to_millis_round_up(deadline), &alarm->on_alarm);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_timer_init(&alarm->alarm, grpc_timespec_to_millis_round_up(deadline),
+ &alarm->on_alarm);
}
void grpc_alarm_cancel(grpc_alarm* alarm, void* reserved) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_timer_cancel(&exec_ctx, &alarm->alarm);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_timer_cancel(&alarm->alarm);
}
void grpc_alarm_destroy(grpc_alarm* alarm, void* reserved) {
diff --git a/src/core/lib/surface/byte_buffer.cc b/src/core/lib/surface/byte_buffer.cc
index 9e0636b4ce..b706f5ba9b 100644
--- a/src/core/lib/surface/byte_buffer.cc
+++ b/src/core/lib/surface/byte_buffer.cc
@@ -71,14 +71,13 @@ grpc_byte_buffer* grpc_byte_buffer_copy(grpc_byte_buffer* bb) {
void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) {
if (!bb) return;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
switch (bb->type) {
case GRPC_BB_RAW:
- grpc_slice_buffer_destroy_internal(&exec_ctx, &bb->data.raw.slice_buffer);
+ grpc_slice_buffer_destroy_internal(&bb->data.raw.slice_buffer);
break;
}
gpr_free(bb);
- grpc_exec_ctx_finish(&exec_ctx);
}
size_t grpc_byte_buffer_length(grpc_byte_buffer* bb) {
diff --git a/src/core/lib/surface/byte_buffer_reader.cc b/src/core/lib/surface/byte_buffer_reader.cc
index 001227a2aa..c5f8df3dda 100644
--- a/src/core/lib/surface/byte_buffer_reader.cc
+++ b/src/core/lib/surface/byte_buffer_reader.cc
@@ -42,15 +42,14 @@ static int is_compressed(grpc_byte_buffer* buffer) {
int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader,
grpc_byte_buffer* buffer) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_slice_buffer decompressed_slices_buffer;
reader->buffer_in = buffer;
switch (reader->buffer_in->type) {
case GRPC_BB_RAW:
grpc_slice_buffer_init(&decompressed_slices_buffer);
if (is_compressed(reader->buffer_in)) {
- if (grpc_msg_decompress(&exec_ctx,
- reader->buffer_in->data.raw.compression,
+ if (grpc_msg_decompress(reader->buffer_in->data.raw.compression,
&reader->buffer_in->data.raw.slice_buffer,
&decompressed_slices_buffer) == 0) {
gpr_log(GPR_ERROR,
@@ -64,15 +63,14 @@ int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader,
grpc_raw_byte_buffer_create(decompressed_slices_buffer.slices,
decompressed_slices_buffer.count);
}
- grpc_slice_buffer_destroy_internal(&exec_ctx,
- &decompressed_slices_buffer);
+ grpc_slice_buffer_destroy_internal(&decompressed_slices_buffer);
} else { /* not compressed, use the input buffer as output */
reader->buffer_out = reader->buffer_in;
}
reader->current.index = 0;
break;
}
- grpc_exec_ctx_finish(&exec_ctx);
+
return 1;
}
@@ -112,14 +110,14 @@ grpc_slice grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader* reader) {
grpc_slice out_slice = GRPC_SLICE_MALLOC(input_size);
uint8_t* const outbuf = GRPC_SLICE_START_PTR(out_slice); /* just an alias */
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (grpc_byte_buffer_reader_next(reader, &in_slice) != 0) {
const size_t slice_length = GRPC_SLICE_LENGTH(in_slice);
memcpy(&(outbuf[bytes_read]), GRPC_SLICE_START_PTR(in_slice), slice_length);
bytes_read += slice_length;
- grpc_slice_unref_internal(&exec_ctx, in_slice);
+ grpc_slice_unref_internal(in_slice);
GPR_ASSERT(bytes_read <= input_size);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
return out_slice;
}
diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc
index 3a06b0c4cf..1caa717195 100644
--- a/src/core/lib/surface/call.cc
+++ b/src/core/lib/surface/call.cc
@@ -271,29 +271,26 @@ grpc_tracer_flag grpc_compression_trace =
#define CALL_FROM_TOP_ELEM(top_elem) \
CALL_FROM_CALL_STACK(grpc_call_stack_from_top_element(top_elem))
-static void execute_batch(grpc_exec_ctx* exec_ctx, grpc_call* call,
- grpc_transport_stream_op_batch* op,
+static void execute_batch(grpc_call* call, grpc_transport_stream_op_batch* op,
grpc_closure* start_batch_closure);
-static void cancel_with_status(grpc_exec_ctx* exec_ctx, grpc_call* c,
- status_source source, grpc_status_code status,
+static void cancel_with_status(grpc_call* c, status_source source,
+ grpc_status_code status,
const char* description);
-static void cancel_with_error(grpc_exec_ctx* exec_ctx, grpc_call* c,
- status_source source, grpc_error* error);
-static void destroy_call(grpc_exec_ctx* exec_ctx, void* call_stack,
- grpc_error* error);
-static void receiving_slice_ready(grpc_exec_ctx* exec_ctx, void* bctlp,
- grpc_error* error);
-static void get_final_status(grpc_exec_ctx* exec_ctx, grpc_call* call,
+static void cancel_with_error(grpc_call* c, status_source source,
+ grpc_error* error);
+static void destroy_call(void* call_stack, grpc_error* error);
+static void receiving_slice_ready(void* bctlp, grpc_error* error);
+static void get_final_status(grpc_call* call,
void (*set_value)(grpc_status_code code,
void* user_data),
void* set_value_user_data, grpc_slice* details);
static void set_status_value_directly(grpc_status_code status, void* dest);
-static void set_status_from_error(grpc_exec_ctx* exec_ctx, grpc_call* call,
- status_source source, grpc_error* error);
-static void process_data_after_md(grpc_exec_ctx* exec_ctx, batch_control* bctl);
-static void post_batch_completion(grpc_exec_ctx* exec_ctx, batch_control* bctl);
-static void add_batch_error(grpc_exec_ctx* exec_ctx, batch_control* bctl,
- grpc_error* error, bool has_cancelled);
+static void set_status_from_error(grpc_call* call, status_source source,
+ grpc_error* error);
+static void process_data_after_md(batch_control* bctl);
+static void post_batch_completion(batch_control* bctl);
+static void add_batch_error(batch_control* bctl, grpc_error* error,
+ bool has_cancelled);
static void add_init_error(grpc_error** composite, grpc_error* new_err) {
if (new_err == GRPC_ERROR_NONE) return;
@@ -311,7 +308,8 @@ static parent_call* get_or_create_parent_call(grpc_call* call) {
if (p == nullptr) {
p = (parent_call*)gpr_arena_alloc(call->arena, sizeof(*p));
gpr_mu_init(&p->child_list_mu);
- if (!gpr_atm_rel_cas(&call->parent_call_atm, (gpr_atm)NULL, (gpr_atm)p)) {
+ if (!gpr_atm_rel_cas(&call->parent_call_atm, (gpr_atm) nullptr,
+ (gpr_atm)p)) {
gpr_mu_destroy(&p->child_list_mu);
p = (parent_call*)gpr_atm_acq_load(&call->parent_call_atm);
}
@@ -323,8 +321,7 @@ static parent_call* get_parent_call(grpc_call* call) {
return (parent_call*)gpr_atm_acq_load(&call->parent_call_atm);
}
-grpc_error* grpc_call_create(grpc_exec_ctx* exec_ctx,
- const grpc_call_create_args* args,
+grpc_error* grpc_call_create(const grpc_call_create_args* args,
grpc_call** out_call) {
size_t i, j;
grpc_error* error = GRPC_ERROR_NONE;
@@ -333,7 +330,7 @@ grpc_error* grpc_call_create(grpc_exec_ctx* exec_ctx,
grpc_call* call;
GPR_TIMER_BEGIN("grpc_call_create", 0);
size_t initial_size = grpc_channel_get_call_size_estimate(args->channel);
- GRPC_STATS_INC_CALL_INITIAL_SIZE(exec_ctx, initial_size);
+ GRPC_STATS_INC_CALL_INITIAL_SIZE(initial_size);
gpr_arena* arena = gpr_arena_create(initial_size);
call = (grpc_call*)gpr_arena_alloc(
arena, sizeof(grpc_call) + channel_stack->call_stack_size);
@@ -348,9 +345,9 @@ grpc_error* grpc_call_create(grpc_exec_ctx* exec_ctx,
GPR_BITSET(&call->encodings_accepted_by_peer, GRPC_COMPRESS_NONE);
call->is_client = args->server_transport_data == nullptr;
if (call->is_client) {
- GRPC_STATS_INC_CLIENT_CALLS_CREATED(exec_ctx);
+ GRPC_STATS_INC_CLIENT_CALLS_CREATED();
} else {
- GRPC_STATS_INC_SERVER_CALLS_CREATED(exec_ctx);
+ GRPC_STATS_INC_SERVER_CALLS_CREATED();
}
call->stream_op_payload.context = call->context;
grpc_slice path = grpc_empty_slice();
@@ -445,15 +442,13 @@ grpc_error* grpc_call_create(grpc_exec_ctx* exec_ctx,
send_deadline,
call->arena,
&call->call_combiner};
- add_init_error(&error, grpc_call_stack_init(exec_ctx, channel_stack, 1,
- destroy_call, call, &call_args));
+ add_init_error(&error, grpc_call_stack_init(channel_stack, 1, destroy_call,
+ call, &call_args));
if (error != GRPC_ERROR_NONE) {
- cancel_with_error(exec_ctx, call, STATUS_FROM_SURFACE,
- GRPC_ERROR_REF(error));
+ cancel_with_error(call, STATUS_FROM_SURFACE, GRPC_ERROR_REF(error));
}
if (immediately_cancel) {
- cancel_with_error(exec_ctx, call, STATUS_FROM_API_OVERRIDE,
- GRPC_ERROR_CANCELLED);
+ cancel_with_error(call, STATUS_FROM_API_OVERRIDE, GRPC_ERROR_CANCELLED);
}
if (args->cq != nullptr) {
GPR_ASSERT(
@@ -468,17 +463,17 @@ grpc_error* grpc_call_create(grpc_exec_ctx* exec_ctx,
args->pollset_set_alternative);
}
if (!grpc_polling_entity_is_empty(&call->pollent)) {
- grpc_call_stack_set_pollset_or_pollset_set(
- exec_ctx, CALL_STACK_FROM_CALL(call), &call->pollent);
+ grpc_call_stack_set_pollset_or_pollset_set(CALL_STACK_FROM_CALL(call),
+ &call->pollent);
}
- grpc_slice_unref_internal(exec_ctx, path);
+ grpc_slice_unref_internal(path);
GPR_TIMER_END("grpc_call_create", 0);
return error;
}
-void grpc_call_set_completion_queue(grpc_exec_ctx* exec_ctx, grpc_call* call,
+void grpc_call_set_completion_queue(grpc_call* call,
grpc_completion_queue* cq) {
GPR_ASSERT(cq);
@@ -489,8 +484,8 @@ void grpc_call_set_completion_queue(grpc_exec_ctx* exec_ctx, grpc_call* call,
call->cq = cq;
GRPC_CQ_INTERNAL_REF(cq, "bind");
call->pollent = grpc_polling_entity_create_from_pollset(grpc_cq_pollset(cq));
- grpc_call_stack_set_pollset_or_pollset_set(
- exec_ctx, CALL_STACK_FROM_CALL(call), &call->pollent);
+ grpc_call_stack_set_pollset_or_pollset_set(CALL_STACK_FROM_CALL(call),
+ &call->pollent);
}
#ifndef NDEBUG
@@ -503,40 +498,38 @@ void grpc_call_set_completion_queue(grpc_exec_ctx* exec_ctx, grpc_call* call,
void grpc_call_internal_ref(grpc_call* c REF_ARG) {
GRPC_CALL_STACK_REF(CALL_STACK_FROM_CALL(c), REF_REASON);
}
-void grpc_call_internal_unref(grpc_exec_ctx* exec_ctx, grpc_call* c REF_ARG) {
- GRPC_CALL_STACK_UNREF(exec_ctx, CALL_STACK_FROM_CALL(c), REF_REASON);
+void grpc_call_internal_unref(grpc_call* c REF_ARG) {
+ GRPC_CALL_STACK_UNREF(CALL_STACK_FROM_CALL(c), REF_REASON);
}
-static void release_call(grpc_exec_ctx* exec_ctx, void* call,
- grpc_error* error) {
+static void release_call(void* call, grpc_error* error) {
grpc_call* c = (grpc_call*)call;
grpc_channel* channel = c->channel;
grpc_call_combiner_destroy(&c->call_combiner);
gpr_free((char*)c->peer_string);
grpc_channel_update_call_size_estimate(channel, gpr_arena_destroy(c->arena));
- GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, channel, "call");
+ GRPC_CHANNEL_INTERNAL_UNREF(channel, "call");
}
static void set_status_value_directly(grpc_status_code status, void* dest);
-static void destroy_call(grpc_exec_ctx* exec_ctx, void* call,
- grpc_error* error) {
+static void destroy_call(void* call, grpc_error* error) {
size_t i;
int ii;
grpc_call* c = (grpc_call*)call;
GPR_TIMER_BEGIN("destroy_call", 0);
for (i = 0; i < 2; i++) {
grpc_metadata_batch_destroy(
- exec_ctx, &c->metadata_batch[1 /* is_receiving */][i /* is_initial */]);
+ &c->metadata_batch[1 /* is_receiving */][i /* is_initial */]);
}
if (c->receiving_stream != nullptr) {
- grpc_byte_stream_destroy(exec_ctx, c->receiving_stream);
+ grpc_byte_stream_destroy(c->receiving_stream);
}
parent_call* pc = get_parent_call(c);
if (pc != nullptr) {
gpr_mu_destroy(&pc->child_list_mu);
}
for (ii = 0; ii < c->send_extra_metadata_count; ii++) {
- GRPC_MDELEM_UNREF(exec_ctx, c->send_extra_metadata[ii].md);
+ GRPC_MDELEM_UNREF(c->send_extra_metadata[ii].md);
}
for (i = 0; i < GRPC_CONTEXT_COUNT; i++) {
if (c->context[i].destroy) {
@@ -544,11 +537,11 @@ static void destroy_call(grpc_exec_ctx* exec_ctx, void* call,
}
}
if (c->cq) {
- GRPC_CQ_INTERNAL_UNREF(exec_ctx, c->cq, "bind");
+ GRPC_CQ_INTERNAL_UNREF(c->cq, "bind");
}
- get_final_status(exec_ctx, c, set_status_value_directly,
- &c->final_info.final_status, nullptr);
+ get_final_status(c, set_status_value_directly, &c->final_info.final_status,
+ nullptr);
c->final_info.stats.latency =
gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), c->start_time);
@@ -557,7 +550,7 @@ static void destroy_call(grpc_exec_ctx* exec_ctx, void* call,
unpack_received_status(gpr_atm_acq_load(&c->status[i])).error);
}
- grpc_call_stack_destroy(exec_ctx, CALL_STACK_FROM_CALL(c), &c->final_info,
+ grpc_call_stack_destroy(CALL_STACK_FROM_CALL(c), &c->final_info,
GRPC_CLOSURE_INIT(&c->release_call, release_call, c,
grpc_schedule_on_exec_ctx));
GPR_TIMER_END("destroy_call", 0);
@@ -569,7 +562,7 @@ void grpc_call_unref(grpc_call* c) {
if (!gpr_unref(&c->ext_ref)) return;
child_call* cc = c->child;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GPR_TIMER_BEGIN("grpc_call_unref", 0);
GRPC_API_TRACE("grpc_call_unref(c=%p)", 1, (c));
@@ -586,7 +579,7 @@ void grpc_call_unref(grpc_call* c) {
cc->sibling_prev->child->sibling_next = cc->sibling_next;
cc->sibling_next->child->sibling_prev = cc->sibling_prev;
gpr_mu_unlock(&pc->child_list_mu);
- GRPC_CALL_INTERNAL_UNREF(&exec_ctx, cc->parent, "child");
+ GRPC_CALL_INTERNAL_UNREF(cc->parent, "child");
}
GPR_ASSERT(!c->destroy_called);
@@ -594,53 +587,49 @@ void grpc_call_unref(grpc_call* c) {
bool cancel = gpr_atm_acq_load(&c->any_ops_sent_atm) != 0 &&
gpr_atm_acq_load(&c->received_final_op_atm) == 0;
if (cancel) {
- cancel_with_error(&exec_ctx, c, STATUS_FROM_API_OVERRIDE,
- GRPC_ERROR_CANCELLED);
+ cancel_with_error(c, STATUS_FROM_API_OVERRIDE, GRPC_ERROR_CANCELLED);
} else {
// Unset the call combiner cancellation closure. This has the
// effect of scheduling the previously set cancellation closure, if
// any, so that it can release any internal references it may be
// holding to the call stack.
- grpc_call_combiner_set_notify_on_cancel(&exec_ctx, &c->call_combiner,
- nullptr);
+ grpc_call_combiner_set_notify_on_cancel(&c->call_combiner, nullptr);
}
- GRPC_CALL_INTERNAL_UNREF(&exec_ctx, c, "destroy");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_CALL_INTERNAL_UNREF(c, "destroy");
+
GPR_TIMER_END("grpc_call_unref", 0);
}
grpc_call_error grpc_call_cancel(grpc_call* call, void* reserved) {
GRPC_API_TRACE("grpc_call_cancel(call=%p, reserved=%p)", 2, (call, reserved));
GPR_ASSERT(!reserved);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- cancel_with_error(&exec_ctx, call, STATUS_FROM_API_OVERRIDE,
- GRPC_ERROR_CANCELLED);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ cancel_with_error(call, STATUS_FROM_API_OVERRIDE, GRPC_ERROR_CANCELLED);
+
return GRPC_CALL_OK;
}
// This is called via the call combiner to start sending a batch down
// the filter stack.
-static void execute_batch_in_call_combiner(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* ignored) {
+static void execute_batch_in_call_combiner(void* arg, grpc_error* ignored) {
grpc_transport_stream_op_batch* batch = (grpc_transport_stream_op_batch*)arg;
grpc_call* call = (grpc_call*)batch->handler_private.extra_arg;
GPR_TIMER_BEGIN("execute_batch", 0);
grpc_call_element* elem = CALL_ELEM_FROM_CALL(call, 0);
GRPC_CALL_LOG_OP(GPR_INFO, elem, batch);
- elem->filter->start_transport_stream_op_batch(exec_ctx, elem, batch);
+ elem->filter->start_transport_stream_op_batch(elem, batch);
GPR_TIMER_END("execute_batch", 0);
}
// start_batch_closure points to a caller-allocated closure to be used
// for entering the call combiner.
-static void execute_batch(grpc_exec_ctx* exec_ctx, grpc_call* call,
+static void execute_batch(grpc_call* call,
grpc_transport_stream_op_batch* batch,
grpc_closure* start_batch_closure) {
batch->handler_private.extra_arg = call;
GRPC_CLOSURE_INIT(start_batch_closure, execute_batch_in_call_combiner, batch,
grpc_schedule_on_exec_ctx);
- GRPC_CALL_COMBINER_START(exec_ctx, &call->call_combiner, start_batch_closure,
+ GRPC_CALL_COMBINER_START(&call->call_combiner, start_batch_closure,
GRPC_ERROR_NONE, "executing batch");
}
@@ -664,15 +653,14 @@ grpc_call_error grpc_call_cancel_with_status(grpc_call* c,
grpc_status_code status,
const char* description,
void* reserved) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GRPC_API_TRACE(
"grpc_call_cancel_with_status("
"c=%p, status=%d, description=%s, reserved=%p)",
4, (c, (int)status, description, reserved));
GPR_ASSERT(reserved == nullptr);
- cancel_with_status(&exec_ctx, c, STATUS_FROM_API_OVERRIDE, status,
- description);
- grpc_exec_ctx_finish(&exec_ctx);
+ cancel_with_status(c, STATUS_FROM_API_OVERRIDE, status, description);
+
return GRPC_CALL_OK;
}
@@ -684,24 +672,23 @@ typedef struct {
// The on_complete callback used when sending a cancel_stream batch down
// the filter stack. Yields the call combiner when the batch is done.
-static void done_termination(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void done_termination(void* arg, grpc_error* error) {
cancel_state* state = (cancel_state*)arg;
- GRPC_CALL_COMBINER_STOP(exec_ctx, &state->call->call_combiner,
+ GRPC_CALL_COMBINER_STOP(&state->call->call_combiner,
"on_complete for cancel_stream op");
- GRPC_CALL_INTERNAL_UNREF(exec_ctx, state->call, "termination");
+ GRPC_CALL_INTERNAL_UNREF(state->call, "termination");
gpr_free(state);
}
-static void cancel_with_error(grpc_exec_ctx* exec_ctx, grpc_call* c,
- status_source source, grpc_error* error) {
+static void cancel_with_error(grpc_call* c, status_source source,
+ grpc_error* error) {
GRPC_CALL_INTERNAL_REF(c, "termination");
// Inform the call combiner of the cancellation, so that it can cancel
// any in-flight asynchronous actions that may be holding the call
// combiner. This ensures that the cancel_stream batch can be sent
// down the filter stack in a timely manner.
- grpc_call_combiner_cancel(exec_ctx, &c->call_combiner, GRPC_ERROR_REF(error));
- set_status_from_error(exec_ctx, c, source, GRPC_ERROR_REF(error));
+ grpc_call_combiner_cancel(&c->call_combiner, GRPC_ERROR_REF(error));
+ set_status_from_error(c, source, GRPC_ERROR_REF(error));
cancel_state* state = (cancel_state*)gpr_malloc(sizeof(*state));
state->call = c;
GRPC_CLOSURE_INIT(&state->finish_batch, done_termination, state,
@@ -710,7 +697,7 @@ static void cancel_with_error(grpc_exec_ctx* exec_ctx, grpc_call* c,
grpc_make_transport_stream_op(&state->finish_batch);
op->cancel_stream = true;
op->payload->cancel_stream.cancel_error = error;
- execute_batch(exec_ctx, c, op, &state->start_batch);
+ execute_batch(c, op, &state->start_batch);
}
static grpc_error* error_from_status(grpc_status_code status,
@@ -724,27 +711,23 @@ static grpc_error* error_from_status(grpc_status_code status,
GRPC_ERROR_INT_GRPC_STATUS, status);
}
-static void cancel_with_status(grpc_exec_ctx* exec_ctx, grpc_call* c,
- status_source source, grpc_status_code status,
+static void cancel_with_status(grpc_call* c, status_source source,
+ grpc_status_code status,
const char* description) {
- cancel_with_error(exec_ctx, c, source,
- error_from_status(status, description));
+ cancel_with_error(c, source, error_from_status(status, description));
}
/*******************************************************************************
* 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_call* call, grpc_error* error, bool allow_ok_status,
+ void (*set_value)(grpc_status_code code, void* user_data),
+ void* set_value_user_data, grpc_slice* details) {
grpc_status_code code;
grpc_slice slice = grpc_empty_slice();
- grpc_error_get_status(exec_ctx, error, call->send_deadline, &code, &slice,
- nullptr);
+ grpc_error_get_status(error, call->send_deadline, &code, &slice, nullptr);
if (code == GRPC_STATUS_OK && !allow_ok_status) {
return false;
}
@@ -756,7 +739,7 @@ static bool get_final_status_from(grpc_exec_ctx* exec_ctx, grpc_call* call,
return true;
}
-static void get_final_status(grpc_exec_ctx* exec_ctx, grpc_call* call,
+static void get_final_status(grpc_call* call,
void (*set_value)(grpc_status_code code,
void* user_data),
void* set_value_user_data, grpc_slice* details) {
@@ -781,9 +764,8 @@ static void get_final_status(grpc_exec_ctx* exec_ctx, grpc_call* call,
for (i = 0; i < STATUS_SOURCE_COUNT; i++) {
if (status[i].is_set &&
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)) {
+ if (get_final_status_from(call, status[i].error, allow_ok_status != 0,
+ set_value, set_value_user_data, details)) {
return;
}
}
@@ -791,9 +773,8 @@ static void get_final_status(grpc_exec_ctx* exec_ctx, grpc_call* call,
/* If no clearly defined status exists, search for 'anything' */
for (i = 0; i < STATUS_SOURCE_COUNT; i++) {
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)) {
+ if (get_final_status_from(call, status[i].error, allow_ok_status != 0,
+ set_value, set_value_user_data, details)) {
return;
}
}
@@ -807,8 +788,8 @@ static void get_final_status(grpc_exec_ctx* exec_ctx, grpc_call* call,
}
}
-static void set_status_from_error(grpc_exec_ctx* exec_ctx, grpc_call* call,
- status_source source, grpc_error* error) {
+static void set_status_from_error(grpc_call* call, status_source source,
+ grpc_error* error) {
if (!gpr_atm_rel_cas(&call->status[source],
pack_received_status({false, GRPC_ERROR_NONE}),
pack_received_status({true, error}))) {
@@ -860,8 +841,7 @@ uint32_t grpc_call_test_only_get_message_flags(grpc_call* call) {
static void destroy_encodings_accepted_by_peer(void* p) { return; }
-static void set_encodings_accepted_by_peer(grpc_exec_ctx* exec_ctx,
- grpc_call* call, grpc_mdelem mdel) {
+static void set_encodings_accepted_by_peer(grpc_call* call, grpc_mdelem mdel) {
size_t i;
grpc_compression_algorithm algorithm;
grpc_slice_buffer accept_encoding_parts;
@@ -899,15 +879,14 @@ static void set_encodings_accepted_by_peer(grpc_exec_ctx* exec_ctx,
}
}
- grpc_slice_buffer_destroy_internal(exec_ctx, &accept_encoding_parts);
+ grpc_slice_buffer_destroy_internal(&accept_encoding_parts);
grpc_mdelem_set_user_data(
mdel, destroy_encodings_accepted_by_peer,
(void*)(((uintptr_t)call->encodings_accepted_by_peer) + 1));
}
-static void set_stream_encodings_accepted_by_peer(grpc_exec_ctx* exec_ctx,
- grpc_call* call,
+static void set_stream_encodings_accepted_by_peer(grpc_call* call,
grpc_mdelem mdel) {
size_t i;
grpc_stream_compression_algorithm algorithm;
@@ -945,7 +924,7 @@ static void set_stream_encodings_accepted_by_peer(grpc_exec_ctx* exec_ctx,
}
}
- grpc_slice_buffer_destroy_internal(exec_ctx, &accept_encoding_parts);
+ grpc_slice_buffer_destroy_internal(&accept_encoding_parts);
grpc_mdelem_set_user_data(
mdel, destroy_encodings_accepted_by_peer,
@@ -983,10 +962,12 @@ static grpc_metadata* get_md_elem(grpc_metadata* metadata,
return res;
}
-static int prepare_application_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call* call, int count,
- grpc_metadata* metadata, int is_trailing, int prepend_extra_metadata,
- grpc_metadata* additional_metadata, int additional_metadata_count) {
+static int prepare_application_metadata(grpc_call* call, int count,
+ grpc_metadata* metadata,
+ int is_trailing,
+ int prepend_extra_metadata,
+ grpc_metadata* additional_metadata,
+ int additional_metadata_count) {
int total_count = count + additional_metadata_count;
int i;
grpc_metadata_batch* batch =
@@ -1005,14 +986,14 @@ static int prepare_application_metadata(
grpc_validate_header_nonbin_value_is_legal(md->value))) {
break;
}
- l->md = grpc_mdelem_from_grpc_metadata(exec_ctx, (grpc_metadata*)md);
+ l->md = grpc_mdelem_from_grpc_metadata((grpc_metadata*)md);
}
if (i != total_count) {
for (int j = 0; j < i; j++) {
const grpc_metadata* md =
get_md_elem(metadata, additional_metadata, j, count);
grpc_linked_mdelem* l = linked_from_md(md);
- GRPC_MDELEM_UNREF(exec_ctx, l->md);
+ GRPC_MDELEM_UNREF(l->md);
}
return 0;
}
@@ -1023,16 +1004,16 @@ static int prepare_application_metadata(
for (i = 0; i < call->send_extra_metadata_count; i++) {
GRPC_LOG_IF_ERROR("prepare_application_metadata",
grpc_metadata_batch_link_tail(
- exec_ctx, batch, &call->send_extra_metadata[i]));
+ batch, &call->send_extra_metadata[i]));
}
}
}
for (i = 0; i < total_count; i++) {
grpc_metadata* md = get_md_elem(metadata, additional_metadata, i, count);
grpc_linked_mdelem* l = linked_from_md(md);
- grpc_error* error = grpc_metadata_batch_link_tail(exec_ctx, batch, l);
+ grpc_error* error = grpc_metadata_batch_link_tail(batch, l);
if (error != GRPC_ERROR_NONE) {
- GRPC_MDELEM_UNREF(exec_ctx, l->md);
+ GRPC_MDELEM_UNREF(l->md);
}
GRPC_LOG_IF_ERROR("prepare_application_metadata", error);
}
@@ -1119,46 +1100,43 @@ static void publish_app_metadata(grpc_call* call, grpc_metadata_batch* b,
GPR_TIMER_END("publish_app_metadata", 0);
}
-static void recv_initial_filter(grpc_exec_ctx* exec_ctx, grpc_call* call,
- grpc_metadata_batch* b) {
+static void recv_initial_filter(grpc_call* call, grpc_metadata_batch* b) {
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.");
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_encoding);
+ grpc_metadata_batch_remove(b, b->idx.named.grpc_encoding);
}
GPR_TIMER_BEGIN("incoming_stream_compression_algorithm", 0);
set_incoming_stream_compression_algorithm(
call, decode_stream_compression(b->idx.named.content_encoding->md));
GPR_TIMER_END("incoming_stream_compression_algorithm", 0);
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.content_encoding);
+ grpc_metadata_batch_remove(b, b->idx.named.content_encoding);
} 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);
+ grpc_metadata_batch_remove(b, b->idx.named.grpc_encoding);
}
if (b->idx.named.grpc_accept_encoding != nullptr) {
GPR_TIMER_BEGIN("encodings_accepted_by_peer", 0);
- set_encodings_accepted_by_peer(exec_ctx, call,
- b->idx.named.grpc_accept_encoding->md);
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_accept_encoding);
+ set_encodings_accepted_by_peer(call, b->idx.named.grpc_accept_encoding->md);
+ grpc_metadata_batch_remove(b, b->idx.named.grpc_accept_encoding);
GPR_TIMER_END("encodings_accepted_by_peer", 0);
}
if (b->idx.named.accept_encoding != nullptr) {
GPR_TIMER_BEGIN("stream_encodings_accepted_by_peer", 0);
- set_stream_encodings_accepted_by_peer(exec_ctx, call,
+ set_stream_encodings_accepted_by_peer(call,
b->idx.named.accept_encoding->md);
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.accept_encoding);
+ grpc_metadata_batch_remove(b, b->idx.named.accept_encoding);
GPR_TIMER_END("stream_encodings_accepted_by_peer", 0);
}
publish_app_metadata(call, b, false);
}
-static void recv_trailing_filter(grpc_exec_ctx* exec_ctx, void* args,
- grpc_metadata_batch* b) {
+static void recv_trailing_filter(void* args, grpc_metadata_batch* b) {
grpc_call* call = (grpc_call*)args;
if (b->idx.named.grpc_status != nullptr) {
uint32_t status_code = decode_status(b->idx.named.grpc_status->md);
@@ -1173,13 +1151,13 @@ static void recv_trailing_filter(grpc_exec_ctx* exec_ctx, void* args,
error = grpc_error_set_str(
error, GRPC_ERROR_STR_GRPC_MESSAGE,
grpc_slice_ref_internal(GRPC_MDVALUE(b->idx.named.grpc_message->md)));
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_message);
+ grpc_metadata_batch_remove(b, b->idx.named.grpc_message);
} else if (error != GRPC_ERROR_NONE) {
error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE,
grpc_empty_slice());
}
- set_status_from_error(exec_ctx, call, STATUS_FROM_WIRE, error);
- grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_status);
+ set_status_from_error(call, STATUS_FROM_WIRE, error);
+ grpc_metadata_batch_remove(b, b->idx.named.grpc_status);
}
publish_app_metadata(call, b, true);
}
@@ -1256,12 +1234,12 @@ static batch_control* allocate_batch_control(grpc_call* call,
return bctl;
}
-static void finish_batch_completion(grpc_exec_ctx* exec_ctx, void* user_data,
+static void finish_batch_completion(void* user_data,
grpc_cq_completion* storage) {
batch_control* bctl = (batch_control*)user_data;
grpc_call* call = bctl->call;
bctl->call = nullptr;
- GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, "completion");
+ GRPC_CALL_INTERNAL_UNREF(call, "completion");
}
static grpc_error* consolidate_batch_errors(batch_control* bctl) {
@@ -1285,15 +1263,13 @@ static grpc_error* consolidate_batch_errors(batch_control* bctl) {
}
}
-static void post_batch_completion(grpc_exec_ctx* exec_ctx,
- batch_control* bctl) {
+static void post_batch_completion(batch_control* bctl) {
grpc_call* next_child_call;
grpc_call* call = bctl->call;
grpc_error* error = consolidate_batch_errors(bctl);
if (bctl->op.send_initial_metadata) {
grpc_metadata_batch_destroy(
- exec_ctx,
&call->metadata_batch[0 /* is_receiving */][0 /* is_trailing */]);
}
if (bctl->op.send_message) {
@@ -1301,13 +1277,12 @@ static void post_batch_completion(grpc_exec_ctx* exec_ctx,
}
if (bctl->op.send_trailing_metadata) {
grpc_metadata_batch_destroy(
- exec_ctx,
&call->metadata_batch[0 /* is_receiving */][1 /* is_trailing */]);
}
if (bctl->op.recv_trailing_metadata) {
grpc_metadata_batch* md =
&call->metadata_batch[1 /* is_receiving */][1 /* is_trailing */];
- recv_trailing_filter(exec_ctx, call, md);
+ recv_trailing_filter(call, md);
/* propagate cancellation to any interested children */
gpr_atm_rel_store(&call->received_final_op_atm, 1);
@@ -1321,9 +1296,9 @@ static void post_batch_completion(grpc_exec_ctx* exec_ctx,
next_child_call = child->child->sibling_next;
if (child->cancellation_is_inherited) {
GRPC_CALL_INTERNAL_REF(child, "propagate_cancel");
- cancel_with_error(exec_ctx, child, STATUS_FROM_API_OVERRIDE,
+ cancel_with_error(child, STATUS_FROM_API_OVERRIDE,
GRPC_ERROR_CANCELLED);
- GRPC_CALL_INTERNAL_UNREF(exec_ctx, child, "propagate_cancel");
+ GRPC_CALL_INTERNAL_UNREF(child, "propagate_cancel");
}
child = next_child_call;
} while (child != pc->first_child);
@@ -1332,11 +1307,11 @@ static void post_batch_completion(grpc_exec_ctx* exec_ctx,
}
if (call->is_client) {
- get_final_status(exec_ctx, call, set_status_value_directly,
+ get_final_status(call, set_status_value_directly,
call->final_op.client.status,
call->final_op.client.status_details);
} else {
- get_final_status(exec_ctx, call, set_cancelled_value,
+ get_final_status(call, set_cancelled_value,
call->final_op.server.cancelled, nullptr);
}
@@ -1352,25 +1327,24 @@ static void post_batch_completion(grpc_exec_ctx* exec_ctx,
if (bctl->completion_data.notify_tag.is_closure) {
/* unrefs bctl->error */
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");
+ GRPC_CLOSURE_RUN((grpc_closure*)bctl->completion_data.notify_tag.tag,
+ error);
+ GRPC_CALL_INTERNAL_UNREF(call, "completion");
} else {
/* unrefs bctl->error */
- grpc_cq_end_op(
- exec_ctx, bctl->call->cq, bctl->completion_data.notify_tag.tag, error,
- finish_batch_completion, bctl, &bctl->completion_data.cq_completion);
+ grpc_cq_end_op(bctl->call->cq, bctl->completion_data.notify_tag.tag, error,
+ finish_batch_completion, bctl,
+ &bctl->completion_data.cq_completion);
}
}
-static void finish_batch_step(grpc_exec_ctx* exec_ctx, batch_control* bctl) {
+static void finish_batch_step(batch_control* bctl) {
if (gpr_unref(&bctl->steps_to_complete)) {
- post_batch_completion(exec_ctx, bctl);
+ post_batch_completion(bctl);
}
}
-static void continue_receiving_slices(grpc_exec_ctx* exec_ctx,
- batch_control* bctl) {
+static void continue_receiving_slices(batch_control* bctl) {
grpc_error* error;
grpc_call* call = bctl->call;
for (;;) {
@@ -1378,25 +1352,25 @@ static void continue_receiving_slices(grpc_exec_ctx* exec_ctx,
(*call->receiving_buffer)->data.raw.slice_buffer.length;
if (remaining == 0) {
call->receiving_message = 0;
- grpc_byte_stream_destroy(exec_ctx, call->receiving_stream);
+ grpc_byte_stream_destroy(call->receiving_stream);
call->receiving_stream = nullptr;
- finish_batch_step(exec_ctx, bctl);
+ finish_batch_step(bctl);
return;
}
- if (grpc_byte_stream_next(exec_ctx, call->receiving_stream, remaining,
+ if (grpc_byte_stream_next(call->receiving_stream, remaining,
&call->receiving_slice_ready)) {
- error = grpc_byte_stream_pull(exec_ctx, call->receiving_stream,
- &call->receiving_slice);
+ error =
+ grpc_byte_stream_pull(call->receiving_stream, &call->receiving_slice);
if (error == GRPC_ERROR_NONE) {
grpc_slice_buffer_add(&(*call->receiving_buffer)->data.raw.slice_buffer,
call->receiving_slice);
} else {
- grpc_byte_stream_destroy(exec_ctx, call->receiving_stream);
+ grpc_byte_stream_destroy(call->receiving_stream);
call->receiving_stream = nullptr;
grpc_byte_buffer_destroy(*call->receiving_buffer);
*call->receiving_buffer = nullptr;
call->receiving_message = 0;
- finish_batch_step(exec_ctx, bctl);
+ finish_batch_step(bctl);
return;
}
} else {
@@ -1405,8 +1379,7 @@ static void continue_receiving_slices(grpc_exec_ctx* exec_ctx,
}
}
-static void receiving_slice_ready(grpc_exec_ctx* exec_ctx, void* bctlp,
- grpc_error* error) {
+static void receiving_slice_ready(void* bctlp, grpc_error* error) {
batch_control* bctl = (batch_control*)bctlp;
grpc_call* call = bctl->call;
grpc_byte_stream* bs = call->receiving_stream;
@@ -1414,11 +1387,11 @@ static void receiving_slice_ready(grpc_exec_ctx* exec_ctx, void* bctlp,
if (error == GRPC_ERROR_NONE) {
grpc_slice slice;
- error = grpc_byte_stream_pull(exec_ctx, bs, &slice);
+ error = grpc_byte_stream_pull(bs, &slice);
if (error == GRPC_ERROR_NONE) {
grpc_slice_buffer_add(&(*call->receiving_buffer)->data.raw.slice_buffer,
slice);
- continue_receiving_slices(exec_ctx, bctl);
+ continue_receiving_slices(bctl);
} else {
/* Error returned by grpc_byte_stream_pull needs to be released manually
*/
@@ -1430,25 +1403,24 @@ static void receiving_slice_ready(grpc_exec_ctx* exec_ctx, void* bctlp,
if (GRPC_TRACER_ON(grpc_trace_operation_failures)) {
GRPC_LOG_IF_ERROR("receiving_slice_ready", GRPC_ERROR_REF(error));
}
- grpc_byte_stream_destroy(exec_ctx, call->receiving_stream);
+ grpc_byte_stream_destroy(call->receiving_stream);
call->receiving_stream = nullptr;
grpc_byte_buffer_destroy(*call->receiving_buffer);
*call->receiving_buffer = nullptr;
call->receiving_message = 0;
- finish_batch_step(exec_ctx, bctl);
+ finish_batch_step(bctl);
if (release_error) {
GRPC_ERROR_UNREF(error);
}
}
}
-static void process_data_after_md(grpc_exec_ctx* exec_ctx,
- batch_control* bctl) {
+static void process_data_after_md(batch_control* bctl) {
grpc_call* call = bctl->call;
if (call->receiving_stream == nullptr) {
*call->receiving_buffer = nullptr;
call->receiving_message = 0;
- finish_batch_step(exec_ctx, bctl);
+ finish_batch_step(bctl);
} else {
call->test_only_last_message_flags = call->receiving_stream->flags;
if ((call->receiving_stream->flags & GRPC_WRITE_INTERNAL_COMPRESS) &&
@@ -1460,46 +1432,42 @@ static void process_data_after_md(grpc_exec_ctx* exec_ctx,
}
GRPC_CLOSURE_INIT(&call->receiving_slice_ready, receiving_slice_ready, bctl,
grpc_schedule_on_exec_ctx);
- continue_receiving_slices(exec_ctx, bctl);
+ continue_receiving_slices(bctl);
}
}
-static void receiving_stream_ready(grpc_exec_ctx* exec_ctx, void* bctlp,
- grpc_error* error) {
+static void receiving_stream_ready(void* bctlp, grpc_error* error) {
batch_control* bctl = (batch_control*)bctlp;
grpc_call* call = bctl->call;
if (error != GRPC_ERROR_NONE) {
if (call->receiving_stream != nullptr) {
- grpc_byte_stream_destroy(exec_ctx, call->receiving_stream);
+ grpc_byte_stream_destroy(call->receiving_stream);
call->receiving_stream = nullptr;
}
- add_batch_error(exec_ctx, bctl, GRPC_ERROR_REF(error), true);
- cancel_with_error(exec_ctx, call, STATUS_FROM_SURFACE,
- GRPC_ERROR_REF(error));
+ add_batch_error(bctl, GRPC_ERROR_REF(error), true);
+ cancel_with_error(call, STATUS_FROM_SURFACE, GRPC_ERROR_REF(error));
}
/* If recv_state is RECV_NONE, we will save the batch_control
* object with rel_cas, and will not use it after the cas. Its corresponding
* acq_load is in receiving_initial_metadata_ready() */
if (error != GRPC_ERROR_NONE || call->receiving_stream == nullptr ||
!gpr_atm_rel_cas(&call->recv_state, RECV_NONE, (gpr_atm)bctlp)) {
- process_data_after_md(exec_ctx, bctl);
+ process_data_after_md(bctl);
}
}
// The recv_message_ready callback used when sending a batch containing
// a recv_message op down the filter stack. Yields the call combiner
// before processing the received message.
-static void receiving_stream_ready_in_call_combiner(grpc_exec_ctx* exec_ctx,
- void* bctlp,
+static void receiving_stream_ready_in_call_combiner(void* bctlp,
grpc_error* error) {
batch_control* bctl = (batch_control*)bctlp;
grpc_call* call = bctl->call;
- GRPC_CALL_COMBINER_STOP(exec_ctx, &call->call_combiner, "recv_message_ready");
- receiving_stream_ready(exec_ctx, bctlp, error);
+ GRPC_CALL_COMBINER_STOP(&call->call_combiner, "recv_message_ready");
+ receiving_stream_ready(bctlp, error);
}
-static void validate_filtered_metadata(grpc_exec_ctx* exec_ctx,
- batch_control* bctl) {
+static void validate_filtered_metadata(batch_control* bctl) {
grpc_call* call = bctl->call;
/* validate compression algorithms */
if (call->incoming_stream_compression_algorithm !=
@@ -1513,8 +1481,8 @@ static void validate_filtered_metadata(grpc_exec_ctx* exec_ctx,
gpr_asprintf(&error_msg,
"Invalid stream compression algorithm value '%d'.", algo);
gpr_log(GPR_ERROR, "%s", error_msg);
- cancel_with_status(exec_ctx, call, STATUS_FROM_SURFACE,
- GRPC_STATUS_UNIMPLEMENTED, error_msg);
+ cancel_with_status(call, STATUS_FROM_SURFACE, GRPC_STATUS_UNIMPLEMENTED,
+ error_msg);
} else if (grpc_compression_options_is_stream_compression_algorithm_enabled(
&compression_options, algo) == 0) {
/* check if algorithm is supported by current channel config */
@@ -1523,8 +1491,8 @@ static void validate_filtered_metadata(grpc_exec_ctx* exec_ctx,
gpr_asprintf(&error_msg, "Stream compression algorithm '%s' is disabled.",
algo_name);
gpr_log(GPR_ERROR, "%s", error_msg);
- cancel_with_status(exec_ctx, call, STATUS_FROM_SURFACE,
- GRPC_STATUS_UNIMPLEMENTED, error_msg);
+ cancel_with_status(call, STATUS_FROM_SURFACE, GRPC_STATUS_UNIMPLEMENTED,
+ error_msg);
}
gpr_free(error_msg);
@@ -1554,8 +1522,8 @@ static void validate_filtered_metadata(grpc_exec_ctx* exec_ctx,
gpr_asprintf(&error_msg, "Invalid compression algorithm value '%d'.",
algo);
gpr_log(GPR_ERROR, "%s", error_msg);
- cancel_with_status(exec_ctx, call, STATUS_FROM_SURFACE,
- GRPC_STATUS_UNIMPLEMENTED, error_msg);
+ cancel_with_status(call, STATUS_FROM_SURFACE, GRPC_STATUS_UNIMPLEMENTED,
+ error_msg);
} else if (grpc_compression_options_is_algorithm_enabled(
&compression_options, algo) == 0) {
/* check if algorithm is supported by current channel config */
@@ -1564,8 +1532,8 @@ static void validate_filtered_metadata(grpc_exec_ctx* exec_ctx,
gpr_asprintf(&error_msg, "Compression algorithm '%s' is disabled.",
algo_name);
gpr_log(GPR_ERROR, "%s", error_msg);
- cancel_with_status(exec_ctx, call, STATUS_FROM_SURFACE,
- GRPC_STATUS_UNIMPLEMENTED, error_msg);
+ cancel_with_status(call, STATUS_FROM_SURFACE, GRPC_STATUS_UNIMPLEMENTED,
+ error_msg);
} else {
call->incoming_compression_algorithm = algo;
}
@@ -1588,34 +1556,31 @@ static void validate_filtered_metadata(grpc_exec_ctx* exec_ctx,
}
}
-static void add_batch_error(grpc_exec_ctx* exec_ctx, batch_control* bctl,
- grpc_error* error, bool has_cancelled) {
+static void add_batch_error(batch_control* bctl, grpc_error* error,
+ bool has_cancelled) {
if (error == GRPC_ERROR_NONE) return;
int idx = (int)gpr_atm_full_fetch_add(&bctl->num_errors, 1);
if (idx == 0 && !has_cancelled) {
- cancel_with_error(exec_ctx, bctl->call, STATUS_FROM_CORE,
- GRPC_ERROR_REF(error));
+ cancel_with_error(bctl->call, STATUS_FROM_CORE, GRPC_ERROR_REF(error));
}
bctl->errors[idx] = error;
}
-static void receiving_initial_metadata_ready(grpc_exec_ctx* exec_ctx,
- void* bctlp, grpc_error* error) {
+static void receiving_initial_metadata_ready(void* bctlp, grpc_error* error) {
batch_control* bctl = (batch_control*)bctlp;
grpc_call* call = bctl->call;
- GRPC_CALL_COMBINER_STOP(exec_ctx, &call->call_combiner,
- "recv_initial_metadata_ready");
+ GRPC_CALL_COMBINER_STOP(&call->call_combiner, "recv_initial_metadata_ready");
- add_batch_error(exec_ctx, bctl, GRPC_ERROR_REF(error), false);
+ add_batch_error(bctl, GRPC_ERROR_REF(error), false);
if (error == GRPC_ERROR_NONE) {
grpc_metadata_batch* md =
&call->metadata_batch[1 /* is_receiving */][0 /* is_trailing */];
- recv_initial_filter(exec_ctx, call, md);
+ recv_initial_filter(call, md);
/* TODO(ctiller): this could be moved into recv_initial_filter now */
GPR_TIMER_BEGIN("validate_filtered_metadata", 0);
- validate_filtered_metadata(exec_ctx, bctl);
+ validate_filtered_metadata(bctl);
GPR_TIMER_END("validate_filtered_metadata", 0);
if (md->deadline != GRPC_MILLIS_INF_FUTURE && !call->is_client) {
@@ -1648,28 +1613,25 @@ static void receiving_initial_metadata_ready(grpc_exec_ctx* exec_ctx,
}
}
if (saved_rsr_closure != nullptr) {
- GRPC_CLOSURE_RUN(exec_ctx, saved_rsr_closure, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_RUN(saved_rsr_closure, GRPC_ERROR_REF(error));
}
- finish_batch_step(exec_ctx, bctl);
+ finish_batch_step(bctl);
}
-static void finish_batch(grpc_exec_ctx* exec_ctx, void* bctlp,
- grpc_error* error) {
+static void finish_batch(void* bctlp, grpc_error* error) {
batch_control* bctl = (batch_control*)bctlp;
grpc_call* call = bctl->call;
- GRPC_CALL_COMBINER_STOP(exec_ctx, &call->call_combiner, "on_complete");
- add_batch_error(exec_ctx, bctl, GRPC_ERROR_REF(error), false);
- finish_batch_step(exec_ctx, bctl);
+ GRPC_CALL_COMBINER_STOP(&call->call_combiner, "on_complete");
+ add_batch_error(bctl, GRPC_ERROR_REF(error), false);
+ finish_batch_step(bctl);
}
-static void free_no_op_completion(grpc_exec_ctx* exec_ctx, void* p,
- grpc_cq_completion* completion) {
+static void free_no_op_completion(void* p, grpc_cq_completion* completion) {
gpr_free(completion);
}
-static grpc_call_error call_start_batch(grpc_exec_ctx* exec_ctx,
- grpc_call* call, const grpc_op* ops,
+static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
size_t nops, void* notify_tag,
int is_notify_tag_closure) {
size_t i;
@@ -1687,11 +1649,10 @@ static grpc_call_error call_start_batch(grpc_exec_ctx* exec_ctx,
if (!is_notify_tag_closure) {
GPR_ASSERT(grpc_cq_begin_op(call->cq, notify_tag));
grpc_cq_end_op(
- exec_ctx, call->cq, notify_tag, GRPC_ERROR_NONE,
- free_no_op_completion, nullptr,
+ call->cq, notify_tag, GRPC_ERROR_NONE, free_no_op_completion, nullptr,
(grpc_cq_completion*)gpr_malloc(sizeof(grpc_cq_completion)));
} else {
- GRPC_CLOSURE_SCHED(exec_ctx, (grpc_closure*)notify_tag, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED((grpc_closure*)notify_tag, GRPC_ERROR_NONE);
}
error = GRPC_CALL_OK;
goto done;
@@ -1791,7 +1752,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx* exec_ctx,
stream_op->send_initial_metadata = true;
call->sent_initial_metadata = true;
if (!prepare_application_metadata(
- exec_ctx, call, (int)op->data.send_initial_metadata.count,
+ call, (int)op->data.send_initial_metadata.count,
op->data.send_initial_metadata.metadata, 0, call->is_client,
&call->compression_md, (int)additional_metadata_count)) {
error = GRPC_CALL_ERROR_INVALID_METADATA;
@@ -1885,7 +1846,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx* exec_ctx,
GPR_ASSERT(call->send_extra_metadata_count == 0);
call->send_extra_metadata_count = 1;
call->send_extra_metadata[0].md = grpc_channel_get_reffed_status_elem(
- exec_ctx, call->channel, op->data.send_status_from_server.status);
+ call->channel, op->data.send_status_from_server.status);
{
grpc_error* override_error = GRPC_ERROR_NONE;
if (op->data.send_status_from_server.status != GRPC_STATUS_OK) {
@@ -1894,7 +1855,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx* exec_ctx,
}
if (op->data.send_status_from_server.status_details != nullptr) {
call->send_extra_metadata[1].md = grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_GRPC_MESSAGE,
+ GRPC_MDSTR_GRPC_MESSAGE,
grpc_slice_ref_internal(
*op->data.send_status_from_server.status_details));
call->send_extra_metadata_count++;
@@ -1905,16 +1866,15 @@ static grpc_call_error call_start_batch(grpc_exec_ctx* exec_ctx,
grpc_slice_from_copied_string(msg));
gpr_free(msg);
}
- set_status_from_error(exec_ctx, call, STATUS_FROM_API_OVERRIDE,
- override_error);
+ set_status_from_error(call, STATUS_FROM_API_OVERRIDE, override_error);
}
if (!prepare_application_metadata(
- exec_ctx, call,
+ call,
(int)op->data.send_status_from_server.trailing_metadata_count,
op->data.send_status_from_server.trailing_metadata, 1, 1,
nullptr, 0)) {
for (int n = 0; n < call->send_extra_metadata_count; n++) {
- GRPC_MDELEM_UNREF(exec_ctx, call->send_extra_metadata[n].md);
+ GRPC_MDELEM_UNREF(call->send_extra_metadata[n].md);
}
call->send_extra_metadata_count = 0;
error = GRPC_CALL_ERROR_INVALID_METADATA;
@@ -2041,7 +2001,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx* exec_ctx,
stream_op->on_complete = &bctl->finish_batch;
gpr_atm_rel_store(&call->any_ops_sent_atm, 1);
- execute_batch(exec_ctx, call, stream_op, &bctl->start_batch);
+ execute_batch(call, stream_op, &bctl->start_batch);
done:
GPR_TIMER_END("grpc_call_start_batch", 0);
@@ -2051,15 +2011,15 @@ done_with_error:
/* reverse any mutations that occured */
if (stream_op->send_initial_metadata) {
call->sent_initial_metadata = false;
- grpc_metadata_batch_clear(exec_ctx, &call->metadata_batch[0][0]);
+ grpc_metadata_batch_clear(&call->metadata_batch[0][0]);
}
if (stream_op->send_message) {
call->sending_message = false;
- grpc_byte_stream_destroy(exec_ctx, &call->sending_stream.base);
+ grpc_byte_stream_destroy(&call->sending_stream.base);
}
if (stream_op->send_trailing_metadata) {
call->sent_final_op = false;
- grpc_metadata_batch_clear(exec_ctx, &call->metadata_batch[0][1]);
+ grpc_metadata_batch_clear(&call->metadata_batch[0][1]);
}
if (stream_op->recv_initial_metadata) {
call->received_initial_metadata = false;
@@ -2075,7 +2035,7 @@ done_with_error:
grpc_call_error grpc_call_start_batch(grpc_call* call, const grpc_op* ops,
size_t nops, void* tag, void* reserved) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_call_error err;
GRPC_API_TRACE(
@@ -2086,19 +2046,17 @@ grpc_call_error grpc_call_start_batch(grpc_call* call, const grpc_op* ops,
if (reserved != nullptr) {
err = GRPC_CALL_ERROR;
} else {
- err = call_start_batch(&exec_ctx, call, ops, nops, tag, 0);
+ err = call_start_batch(call, ops, nops, tag, 0);
}
- grpc_exec_ctx_finish(&exec_ctx);
return err;
}
-grpc_call_error grpc_call_start_batch_and_execute(grpc_exec_ctx* exec_ctx,
- grpc_call* call,
+grpc_call_error grpc_call_start_batch_and_execute(grpc_call* call,
const grpc_op* ops,
size_t nops,
grpc_closure* closure) {
- return call_start_batch(exec_ctx, call, ops, nops, closure, 1);
+ return call_start_batch(call, ops, nops, closure, 1);
}
void grpc_call_context_set(grpc_call* call, grpc_context_index elem,
diff --git a/src/core/lib/surface/call.h b/src/core/lib/surface/call.h
index d4e596f84b..61cc6520da 100644
--- a/src/core/lib/surface/call.h
+++ b/src/core/lib/surface/call.h
@@ -30,8 +30,7 @@ extern "C" {
#include <grpc/grpc.h>
#include <grpc/impl/codegen/compression_types.h>
-typedef void (*grpc_ioreq_completion_func)(grpc_exec_ctx* exec_ctx,
- grpc_call* call, int success,
+typedef void (*grpc_ioreq_completion_func)(grpc_call* call, int success,
void* user_data);
typedef struct grpc_call_create_args {
@@ -55,33 +54,28 @@ typedef struct grpc_call_create_args {
/* Create a new call based on \a args.
Regardless of success or failure, always returns a valid new call into *call
*/
-grpc_error* grpc_call_create(grpc_exec_ctx* exec_ctx,
- const grpc_call_create_args* args,
+grpc_error* grpc_call_create(const grpc_call_create_args* args,
grpc_call** call);
-void grpc_call_set_completion_queue(grpc_exec_ctx* exec_ctx, grpc_call* call,
- grpc_completion_queue* cq);
+void grpc_call_set_completion_queue(grpc_call* call, grpc_completion_queue* cq);
#ifndef NDEBUG
void grpc_call_internal_ref(grpc_call* call, const char* reason);
-void grpc_call_internal_unref(grpc_exec_ctx* exec_ctx, grpc_call* call,
- const char* reason);
+void grpc_call_internal_unref(grpc_call* call, const char* reason);
#define GRPC_CALL_INTERNAL_REF(call, reason) \
grpc_call_internal_ref(call, reason)
-#define GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, reason) \
- grpc_call_internal_unref(exec_ctx, call, reason)
+#define GRPC_CALL_INTERNAL_UNREF(call, reason) \
+ grpc_call_internal_unref(call, reason)
#else
void grpc_call_internal_ref(grpc_call* call);
-void grpc_call_internal_unref(grpc_exec_ctx* exec_ctx, grpc_call* call);
+void grpc_call_internal_unref(grpc_call* call);
#define GRPC_CALL_INTERNAL_REF(call, reason) grpc_call_internal_ref(call)
-#define GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, reason) \
- grpc_call_internal_unref(exec_ctx, call)
+#define GRPC_CALL_INTERNAL_UNREF(call, reason) grpc_call_internal_unref(call)
#endif
grpc_call_stack* grpc_call_get_call_stack(grpc_call* call);
-grpc_call_error grpc_call_start_batch_and_execute(grpc_exec_ctx* exec_ctx,
- grpc_call* call,
+grpc_call_error grpc_call_start_batch_and_execute(grpc_call* call,
const grpc_op* ops,
size_t nops,
grpc_closure* closure);
diff --git a/src/core/lib/surface/call_details.cc b/src/core/lib/surface/call_details.cc
index ea9208c7e3..7d81ba9e22 100644
--- a/src/core/lib/surface/call_details.cc
+++ b/src/core/lib/surface/call_details.cc
@@ -34,8 +34,7 @@ void grpc_call_details_init(grpc_call_details* cd) {
void grpc_call_details_destroy(grpc_call_details* cd) {
GRPC_API_TRACE("grpc_call_details_destroy(cd=%p)", 1, (cd));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_unref_internal(&exec_ctx, cd->method);
- grpc_slice_unref_internal(&exec_ctx, cd->host);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_slice_unref_internal(cd->method);
+ grpc_slice_unref_internal(cd->host);
}
diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc
index 1be734cdb7..b44096fc32 100644
--- a/src/core/lib/surface/channel.cc
+++ b/src/core/lib/surface/channel.cc
@@ -69,23 +69,22 @@ struct grpc_channel {
#define CHANNEL_FROM_TOP_ELEM(top_elem) \
CHANNEL_FROM_CHANNEL_STACK(grpc_channel_stack_from_top_element(top_elem))
-static void destroy_channel(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error);
+static void destroy_channel(void* arg, grpc_error* error);
grpc_channel* grpc_channel_create_with_builder(
- grpc_exec_ctx* exec_ctx, grpc_channel_stack_builder* builder,
+ grpc_channel_stack_builder* builder,
grpc_channel_stack_type channel_stack_type) {
char* target = gpr_strdup(grpc_channel_stack_builder_get_target(builder));
grpc_channel_args* args = grpc_channel_args_copy(
grpc_channel_stack_builder_get_channel_arguments(builder));
grpc_channel* channel;
if (channel_stack_type == GRPC_SERVER_CHANNEL) {
- GRPC_STATS_INC_SERVER_CHANNELS_CREATED(exec_ctx);
+ GRPC_STATS_INC_SERVER_CHANNELS_CREATED();
} else {
- GRPC_STATS_INC_CLIENT_CHANNELS_CREATED(exec_ctx);
+ GRPC_STATS_INC_CLIENT_CHANNELS_CREATED();
}
grpc_error* error = grpc_channel_stack_builder_finish(
- exec_ctx, builder, sizeof(grpc_channel), 1, destroy_channel, nullptr,
+ builder, sizeof(grpc_channel), 1, destroy_channel, nullptr,
(void**)&channel);
if (error != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "channel stack builder failed: %s",
@@ -114,10 +113,10 @@ grpc_channel* grpc_channel_create_with_builder(
} else {
if (!GRPC_MDISNULL(channel->default_authority)) {
/* setting this takes precedence over anything else */
- GRPC_MDELEM_UNREF(exec_ctx, channel->default_authority);
+ GRPC_MDELEM_UNREF(channel->default_authority);
}
channel->default_authority = grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_AUTHORITY,
+ GRPC_MDSTR_AUTHORITY,
grpc_slice_intern(
grpc_slice_from_static_string(args->args[i].value.string)));
}
@@ -134,7 +133,7 @@ grpc_channel* grpc_channel_create_with_builder(
GRPC_SSL_TARGET_NAME_OVERRIDE_ARG);
} else {
channel->default_authority = grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_AUTHORITY,
+ GRPC_MDSTR_AUTHORITY,
grpc_slice_intern(
grpc_slice_from_static_string(args->args[i].value.string)));
}
@@ -191,25 +190,23 @@ grpc_channel* grpc_channel_create_with_builder(
}
done:
- grpc_channel_args_destroy(exec_ctx, args);
+ grpc_channel_args_destroy(args);
return channel;
}
-grpc_channel* grpc_channel_create(grpc_exec_ctx* exec_ctx, const char* target,
+grpc_channel* grpc_channel_create(const char* target,
const grpc_channel_args* input_args,
grpc_channel_stack_type channel_stack_type,
grpc_transport* optional_transport) {
grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create();
- grpc_channel_stack_builder_set_channel_arguments(exec_ctx, builder,
- input_args);
+ grpc_channel_stack_builder_set_channel_arguments(builder, input_args);
grpc_channel_stack_builder_set_target(builder, target);
grpc_channel_stack_builder_set_transport(builder, optional_transport);
- if (!grpc_channel_init_create_stack(exec_ctx, builder, channel_stack_type)) {
- grpc_channel_stack_builder_destroy(exec_ctx, builder);
+ if (!grpc_channel_init_create_stack(builder, channel_stack_type)) {
+ grpc_channel_stack_builder_destroy(builder);
return nullptr;
}
- return grpc_channel_create_with_builder(exec_ctx, builder,
- channel_stack_type);
+ return grpc_channel_create_with_builder(builder, channel_stack_type);
}
size_t grpc_channel_get_call_size_estimate(grpc_channel* channel) {
@@ -251,18 +248,17 @@ char* grpc_channel_get_target(grpc_channel* channel) {
void grpc_channel_get_info(grpc_channel* channel,
const grpc_channel_info* channel_info) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_channel_element* elem =
grpc_channel_stack_element(CHANNEL_STACK_FROM_CHANNEL(channel), 0);
- elem->filter->get_channel_info(&exec_ctx, elem, channel_info);
- grpc_exec_ctx_finish(&exec_ctx);
+ elem->filter->get_channel_info(elem, channel_info);
}
static grpc_call* grpc_channel_create_call_internal(
- grpc_exec_ctx* exec_ctx, grpc_channel* channel, grpc_call* parent_call,
- uint32_t propagation_mask, grpc_completion_queue* cq,
- grpc_pollset_set* pollset_set_alternative, grpc_mdelem path_mdelem,
- grpc_mdelem authority_mdelem, grpc_millis deadline) {
+ grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask,
+ grpc_completion_queue* cq, grpc_pollset_set* pollset_set_alternative,
+ grpc_mdelem path_mdelem, grpc_mdelem authority_mdelem,
+ grpc_millis deadline) {
grpc_mdelem send_metadata[2];
size_t num_metadata = 0;
@@ -289,7 +285,7 @@ static grpc_call* grpc_channel_create_call_internal(
args.send_deadline = deadline;
grpc_call* call;
- GRPC_LOG_IF_ERROR("call_create", grpc_call_create(exec_ctx, &args, &call));
+ GRPC_LOG_IF_ERROR("call_create", grpc_call_create(&args, &call));
return call;
}
@@ -300,29 +296,27 @@ grpc_call* grpc_channel_create_call(grpc_channel* channel,
grpc_slice method, const grpc_slice* host,
gpr_timespec deadline, void* reserved) {
GPR_ASSERT(!reserved);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_call* call = grpc_channel_create_call_internal(
- &exec_ctx, channel, parent_call, propagation_mask, cq, nullptr,
- grpc_mdelem_from_slices(&exec_ctx, GRPC_MDSTR_PATH,
- grpc_slice_ref_internal(method)),
- host != nullptr ? grpc_mdelem_from_slices(&exec_ctx, GRPC_MDSTR_AUTHORITY,
+ channel, parent_call, propagation_mask, cq, nullptr,
+ grpc_mdelem_from_slices(GRPC_MDSTR_PATH, grpc_slice_ref_internal(method)),
+ host != nullptr ? grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY,
grpc_slice_ref_internal(*host))
: GRPC_MDNULL,
grpc_timespec_to_millis_round_up(deadline));
- grpc_exec_ctx_finish(&exec_ctx);
+
return call;
}
grpc_call* grpc_channel_create_pollset_set_call(
- grpc_exec_ctx* exec_ctx, grpc_channel* channel, grpc_call* parent_call,
- uint32_t propagation_mask, grpc_pollset_set* pollset_set, grpc_slice method,
- const grpc_slice* host, grpc_millis deadline, void* reserved) {
+ grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask,
+ grpc_pollset_set* pollset_set, grpc_slice method, const grpc_slice* host,
+ grpc_millis deadline, void* reserved) {
GPR_ASSERT(!reserved);
return grpc_channel_create_call_internal(
- exec_ctx, channel, parent_call, propagation_mask, nullptr, pollset_set,
- grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_PATH,
- grpc_slice_ref_internal(method)),
- host != nullptr ? grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_AUTHORITY,
+ channel, parent_call, propagation_mask, nullptr, pollset_set,
+ grpc_mdelem_from_slices(GRPC_MDSTR_PATH, grpc_slice_ref_internal(method)),
+ host != nullptr ? grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY,
grpc_slice_ref_internal(*host))
: GRPC_MDNULL,
deadline);
@@ -335,21 +329,21 @@ void* grpc_channel_register_call(grpc_channel* channel, const char* method,
"grpc_channel_register_call(channel=%p, method=%s, host=%s, reserved=%p)",
4, (channel, method, host, reserved));
GPR_ASSERT(!reserved);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
rc->path = grpc_mdelem_from_slices(
- &exec_ctx, GRPC_MDSTR_PATH,
+ GRPC_MDSTR_PATH,
grpc_slice_intern(grpc_slice_from_static_string(method)));
rc->authority =
host ? grpc_mdelem_from_slices(
- &exec_ctx, GRPC_MDSTR_AUTHORITY,
+ GRPC_MDSTR_AUTHORITY,
grpc_slice_intern(grpc_slice_from_static_string(host)))
: GRPC_MDNULL;
gpr_mu_lock(&channel->registered_call_mu);
rc->next = channel->registered_calls;
channel->registered_calls = rc;
gpr_mu_unlock(&channel->registered_call_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
return rc;
}
@@ -370,12 +364,12 @@ grpc_call* grpc_channel_create_registered_call(
registered_call_handle, deadline.tv_sec, deadline.tv_nsec,
(int)deadline.clock_type, reserved));
GPR_ASSERT(!reserved);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_call* call = grpc_channel_create_call_internal(
- &exec_ctx, channel, parent_call, propagation_mask, completion_queue,
- nullptr, GRPC_MDELEM_REF(rc->path), GRPC_MDELEM_REF(rc->authority),
+ 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;
}
@@ -390,23 +384,21 @@ void grpc_channel_internal_ref(grpc_channel* c REF_ARG) {
GRPC_CHANNEL_STACK_REF(CHANNEL_STACK_FROM_CHANNEL(c), REF_REASON);
}
-void grpc_channel_internal_unref(grpc_exec_ctx* exec_ctx,
- grpc_channel* c REF_ARG) {
- GRPC_CHANNEL_STACK_UNREF(exec_ctx, CHANNEL_STACK_FROM_CHANNEL(c), REF_REASON);
+void grpc_channel_internal_unref(grpc_channel* c REF_ARG) {
+ GRPC_CHANNEL_STACK_UNREF(CHANNEL_STACK_FROM_CHANNEL(c), REF_REASON);
}
-static void destroy_channel(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void destroy_channel(void* arg, grpc_error* error) {
grpc_channel* channel = (grpc_channel*)arg;
- grpc_channel_stack_destroy(exec_ctx, CHANNEL_STACK_FROM_CHANNEL(channel));
+ grpc_channel_stack_destroy(CHANNEL_STACK_FROM_CHANNEL(channel));
while (channel->registered_calls) {
registered_call* rc = channel->registered_calls;
channel->registered_calls = rc->next;
- GRPC_MDELEM_UNREF(exec_ctx, rc->path);
- GRPC_MDELEM_UNREF(exec_ctx, rc->authority);
+ GRPC_MDELEM_UNREF(rc->path);
+ GRPC_MDELEM_UNREF(rc->authority);
gpr_free(rc);
}
- GRPC_MDELEM_UNREF(exec_ctx, channel->default_authority);
+ GRPC_MDELEM_UNREF(channel->default_authority);
gpr_mu_destroy(&channel->registered_call_mu);
gpr_free(channel->target);
gpr_free(channel);
@@ -415,16 +407,14 @@ 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(nullptr);
grpc_channel_element* elem;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GRPC_API_TRACE("grpc_channel_destroy(channel=%p)", 1, (channel));
op->disconnect_with_error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Destroyed");
elem = grpc_channel_stack_element(CHANNEL_STACK_FROM_CHANNEL(channel), 0);
- elem->filter->start_transport_op(&exec_ctx, elem, op);
-
- GRPC_CHANNEL_INTERNAL_UNREF(&exec_ctx, channel, "channel");
+ elem->filter->start_transport_op(elem, op);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_CHANNEL_INTERNAL_UNREF(channel, "channel");
}
grpc_channel_stack* grpc_channel_get_channel_stack(grpc_channel* channel) {
@@ -436,8 +426,7 @@ grpc_compression_options grpc_channel_compression_options(
return channel->compression_options;
}
-grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel* channel, int i) {
+grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_channel* channel, int i) {
char tmp[GPR_LTOA_MIN_BUFSIZE];
switch (i) {
case 0:
@@ -448,6 +437,6 @@ grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_exec_ctx* exec_ctx,
return GRPC_MDELEM_GRPC_STATUS_2;
}
gpr_ltoa(i, tmp);
- return grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_GRPC_STATUS,
+ return grpc_mdelem_from_slices(GRPC_MDSTR_GRPC_STATUS,
grpc_slice_from_copied_string(tmp));
}
diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h
index 063e685f6b..6499486896 100644
--- a/src/core/lib/surface/channel.h
+++ b/src/core/lib/surface/channel.h
@@ -27,13 +27,13 @@
extern "C" {
#endif
-grpc_channel* grpc_channel_create(grpc_exec_ctx* exec_ctx, const char* target,
+grpc_channel* grpc_channel_create(const char* target,
const grpc_channel_args* args,
grpc_channel_stack_type channel_stack_type,
grpc_transport* optional_transport);
grpc_channel* grpc_channel_create_with_builder(
- grpc_exec_ctx* exec_ctx, grpc_channel_stack_builder* builder,
+ grpc_channel_stack_builder* builder,
grpc_channel_stack_type channel_stack_type);
/** Create a call given a grpc_channel, in order to call \a method.
@@ -45,9 +45,9 @@ grpc_channel* grpc_channel_create_with_builder(
properties from the server call to this new client call, depending on the
value of \a propagation_mask (see propagation_bits.h for possible values) */
grpc_call* grpc_channel_create_pollset_set_call(
- grpc_exec_ctx* exec_ctx, grpc_channel* channel, grpc_call* parent_call,
- uint32_t propagation_mask, grpc_pollset_set* pollset_set, grpc_slice method,
- const grpc_slice* host, grpc_millis deadline, void* reserved);
+ grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask,
+ grpc_pollset_set* pollset_set, grpc_slice method, const grpc_slice* host,
+ grpc_millis deadline, void* reserved);
/** Get a (borrowed) pointer to this channels underlying channel stack */
grpc_channel_stack* grpc_channel_get_channel_stack(grpc_channel* channel);
@@ -56,8 +56,7 @@ grpc_channel_stack* grpc_channel_get_channel_stack(grpc_channel* channel);
status_code.
The returned elem is owned by the caller. */
-grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel* channel,
+grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_channel* channel,
int status_code);
size_t grpc_channel_get_call_size_estimate(grpc_channel* channel);
@@ -65,20 +64,18 @@ void grpc_channel_update_call_size_estimate(grpc_channel* channel, size_t size);
#ifndef NDEBUG
void grpc_channel_internal_ref(grpc_channel* channel, const char* reason);
-void grpc_channel_internal_unref(grpc_exec_ctx* exec_ctx, grpc_channel* channel,
- const char* reason);
+void grpc_channel_internal_unref(grpc_channel* channel, const char* reason);
#define GRPC_CHANNEL_INTERNAL_REF(channel, reason) \
grpc_channel_internal_ref(channel, reason)
-#define GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, channel, reason) \
- grpc_channel_internal_unref(exec_ctx, channel, reason)
+#define GRPC_CHANNEL_INTERNAL_UNREF(channel, reason) \
+ grpc_channel_internal_unref(channel, reason)
#else
void grpc_channel_internal_ref(grpc_channel* channel);
-void grpc_channel_internal_unref(grpc_exec_ctx* exec_ctx,
- grpc_channel* channel);
+void grpc_channel_internal_unref(grpc_channel* channel);
#define GRPC_CHANNEL_INTERNAL_REF(channel, reason) \
grpc_channel_internal_ref(channel)
-#define GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, channel, reason) \
- grpc_channel_internal_unref(exec_ctx, channel)
+#define GRPC_CHANNEL_INTERNAL_UNREF(channel, reason) \
+ grpc_channel_internal_unref(channel)
#endif
/** Return the channel's compression options. */
diff --git a/src/core/lib/surface/channel_init.cc b/src/core/lib/surface/channel_init.cc
index b563537f35..95cbbbd037 100644
--- a/src/core/lib/surface/channel_init.cc
+++ b/src/core/lib/surface/channel_init.cc
@@ -89,8 +89,7 @@ void grpc_channel_init_shutdown(void) {
}
}
-bool grpc_channel_init_create_stack(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+bool grpc_channel_init_create_stack(grpc_channel_stack_builder* builder,
grpc_channel_stack_type type) {
GPR_ASSERT(g_finalized);
@@ -99,7 +98,7 @@ bool grpc_channel_init_create_stack(grpc_exec_ctx* exec_ctx,
for (size_t i = 0; i < g_slots[type].num_slots; i++) {
const stage_slot* slot = &g_slots[type].slots[i];
- if (!slot->fn(exec_ctx, builder, slot->arg)) {
+ if (!slot->fn(builder, slot->arg)) {
return false;
}
}
diff --git a/src/core/lib/surface/channel_init.h b/src/core/lib/surface/channel_init.h
index 9932781081..b4bee7c673 100644
--- a/src/core/lib/surface/channel_init.h
+++ b/src/core/lib/surface/channel_init.h
@@ -36,8 +36,7 @@ extern "C" {
/// One stage of mutation: call functions against \a builder to influence the
/// finally constructed channel stack
-typedef bool (*grpc_channel_init_stage)(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+typedef bool (*grpc_channel_init_stage)(grpc_channel_stack_builder* builder,
void* arg);
/// Global initialization of the system
@@ -70,8 +69,7 @@ void grpc_channel_init_shutdown(void);
/// \a optional_transport is either NULL or a constructed transport object
/// Returns a pointer to the base of the memory allocated (the actual channel
/// stack object will be prefix_bytes past that pointer)
-bool grpc_channel_init_create_stack(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+bool grpc_channel_init_create_stack(grpc_channel_stack_builder* builder,
grpc_channel_stack_type type);
#ifdef __cplusplus
diff --git a/src/core/lib/surface/channel_ping.cc b/src/core/lib/surface/channel_ping.cc
index e8f47f01cf..c44307df8d 100644
--- a/src/core/lib/surface/channel_ping.cc
+++ b/src/core/lib/surface/channel_ping.cc
@@ -33,15 +33,14 @@ typedef struct {
grpc_cq_completion completion_storage;
} ping_result;
-static void ping_destroy(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_cq_completion* storage) {
+static void ping_destroy(void* arg, grpc_cq_completion* storage) {
gpr_free(arg);
}
-static void ping_done(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void ping_done(void* arg, grpc_error* error) {
ping_result* pr = (ping_result*)arg;
- grpc_cq_end_op(exec_ctx, pr->cq, pr->tag, GRPC_ERROR_REF(error), ping_destroy,
- pr, &pr->completion_storage);
+ grpc_cq_end_op(pr->cq, pr->tag, GRPC_ERROR_REF(error), ping_destroy, pr,
+ &pr->completion_storage);
}
void grpc_channel_ping(grpc_channel* channel, grpc_completion_queue* cq,
@@ -52,7 +51,7 @@ void grpc_channel_ping(grpc_channel* channel, grpc_completion_queue* cq,
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;
+ grpc_core::ExecCtx _local_exec_ctx;
GPR_ASSERT(reserved == nullptr);
pr->tag = tag;
pr->cq = cq;
@@ -60,6 +59,5 @@ void grpc_channel_ping(grpc_channel* channel, grpc_completion_queue* cq,
op->send_ping = &pr->closure;
op->bind_pollset = grpc_cq_pollset(cq);
GPR_ASSERT(grpc_cq_begin_op(cq, tag));
- top_elem->filter->start_transport_op(&exec_ctx, top_elem, op);
- grpc_exec_ctx_finish(&exec_ctx);
+ top_elem->filter->start_transport_op(top_elem, op);
}
diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc
index a171f90666..c84f35c508 100644
--- a/src/core/lib/surface/completion_queue.cc
+++ b/src/core/lib/surface/completion_queue.cc
@@ -67,13 +67,12 @@ typedef struct {
bool can_listen;
size_t (*size)(void);
void (*init)(grpc_pollset* pollset, gpr_mu** mu);
- grpc_error* (*kick)(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
+ grpc_error* (*kick)(grpc_pollset* pollset,
grpc_pollset_worker* specific_worker);
- grpc_error* (*work)(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- grpc_pollset_worker** worker, grpc_millis deadline);
- void (*shutdown)(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- grpc_closure* closure);
- void (*destroy)(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset);
+ grpc_error* (*work)(grpc_pollset* pollset, grpc_pollset_worker** worker,
+ grpc_millis deadline);
+ void (*shutdown)(grpc_pollset* pollset, grpc_closure* closure);
+ void (*destroy)(grpc_pollset* pollset);
} cq_poller_vtable;
typedef struct non_polling_worker {
@@ -99,14 +98,12 @@ static void non_polling_poller_init(grpc_pollset* pollset, gpr_mu** mu) {
*mu = &npp->mu;
}
-static void non_polling_poller_destroy(grpc_exec_ctx* exec_ctx,
- grpc_pollset* pollset) {
+static void non_polling_poller_destroy(grpc_pollset* pollset) {
non_polling_poller* npp = (non_polling_poller*)pollset;
gpr_mu_destroy(&npp->mu);
}
-static grpc_error* non_polling_poller_work(grpc_exec_ctx* exec_ctx,
- grpc_pollset* pollset,
+static grpc_error* non_polling_poller_work(grpc_pollset* pollset,
grpc_pollset_worker** worker,
grpc_millis deadline) {
non_polling_poller* npp = (non_polling_poller*)pollset;
@@ -127,12 +124,12 @@ static grpc_error* non_polling_poller_work(grpc_exec_ctx* exec_ctx,
while (!npp->shutdown && !w.kicked &&
!gpr_cv_wait(&w.cv, &npp->mu, deadline_ts))
;
- grpc_exec_ctx_invalidate_now(exec_ctx);
+ grpc_core::ExecCtx::Get()->InvalidateNow();
if (&w == npp->root) {
npp->root = w.next;
if (&w == npp->root) {
if (npp->shutdown) {
- GRPC_CLOSURE_SCHED(exec_ctx, npp->shutdown, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(npp->shutdown, GRPC_ERROR_NONE);
}
npp->root = nullptr;
}
@@ -145,8 +142,7 @@ static grpc_error* non_polling_poller_work(grpc_exec_ctx* exec_ctx,
}
static grpc_error* non_polling_poller_kick(
- grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
- grpc_pollset_worker* specific_worker) {
+ grpc_pollset* pollset, grpc_pollset_worker* specific_worker) {
non_polling_poller* p = (non_polling_poller*)pollset;
if (specific_worker == nullptr)
specific_worker = (grpc_pollset_worker*)p->root;
@@ -160,14 +156,13 @@ static grpc_error* non_polling_poller_kick(
return GRPC_ERROR_NONE;
}
-static void non_polling_poller_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_pollset* pollset,
+static void non_polling_poller_shutdown(grpc_pollset* pollset,
grpc_closure* closure) {
non_polling_poller* p = (non_polling_poller*)pollset;
GPR_ASSERT(closure != nullptr);
p->shutdown = closure;
if (p->root == nullptr) {
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
} else {
non_polling_worker* w = p->root;
do {
@@ -194,13 +189,11 @@ typedef struct cq_vtable {
grpc_cq_completion_type cq_completion_type;
size_t data_size;
void (*init)(void* data);
- void (*shutdown)(grpc_exec_ctx* exec_ctx, grpc_completion_queue* cq);
+ void (*shutdown)(grpc_completion_queue* cq);
void (*destroy)(void* data);
bool (*begin_op)(grpc_completion_queue* cq, void* tag);
- void (*end_op)(grpc_exec_ctx* exec_ctx, grpc_completion_queue* cq, void* tag,
- grpc_error* error,
- void (*done)(grpc_exec_ctx* exec_ctx, void* done_arg,
- grpc_cq_completion* storage),
+ void (*end_op)(grpc_completion_queue* cq, void* tag, grpc_error* error,
+ void (*done)(void* done_arg, grpc_cq_completion* storage),
void* done_arg, grpc_cq_completion* storage);
grpc_event (*next)(grpc_completion_queue* cq, gpr_timespec deadline,
void* reserved);
@@ -285,31 +278,23 @@ struct grpc_completion_queue {
};
/* Forward declarations */
-static void cq_finish_shutdown_next(grpc_exec_ctx* exec_ctx,
- grpc_completion_queue* cq);
-static void cq_finish_shutdown_pluck(grpc_exec_ctx* exec_ctx,
- grpc_completion_queue* cq);
-static void cq_shutdown_next(grpc_exec_ctx* exec_ctx,
- grpc_completion_queue* cq);
-static void cq_shutdown_pluck(grpc_exec_ctx* exec_ctx,
- grpc_completion_queue* cq);
+static void cq_finish_shutdown_next(grpc_completion_queue* cq);
+static void cq_finish_shutdown_pluck(grpc_completion_queue* cq);
+static void cq_shutdown_next(grpc_completion_queue* cq);
+static void cq_shutdown_pluck(grpc_completion_queue* cq);
static bool cq_begin_op_for_next(grpc_completion_queue* cq, void* tag);
static bool cq_begin_op_for_pluck(grpc_completion_queue* cq, void* tag);
-static void cq_end_op_for_next(grpc_exec_ctx* exec_ctx,
- grpc_completion_queue* cq, void* tag,
+static void cq_end_op_for_next(grpc_completion_queue* cq, void* tag,
grpc_error* error,
- void (*done)(grpc_exec_ctx* exec_ctx,
- void* done_arg,
+ void (*done)(void* done_arg,
grpc_cq_completion* storage),
void* done_arg, grpc_cq_completion* storage);
-static void cq_end_op_for_pluck(grpc_exec_ctx* exec_ctx,
- grpc_completion_queue* cq, void* tag,
+static void cq_end_op_for_pluck(grpc_completion_queue* cq, void* tag,
grpc_error* error,
- void (*done)(grpc_exec_ctx* exec_ctx,
- void* done_arg,
+ void (*done)(void* done_arg,
grpc_cq_completion* storage),
void* done_arg, grpc_cq_completion* storage);
@@ -354,8 +339,7 @@ grpc_tracer_flag grpc_cq_event_timeout_trace =
gpr_free(_ev); \
}
-static void on_pollset_shutdown_done(grpc_exec_ctx* exec_ctx, void* cq,
- grpc_error* error);
+static void on_pollset_shutdown_done(void* cq, grpc_error* error);
void grpc_cq_global_init() {
gpr_tls_init(&g_cached_event);
@@ -377,19 +361,18 @@ int grpc_completion_queue_thread_local_cache_flush(grpc_completion_queue* cq,
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;
+ grpc_core::ExecCtx _local_exec_ctx;
*ok = (storage->next & (uintptr_t)(1)) == 1;
- storage->done(&exec_ctx, storage->done_arg, storage);
+ storage->done(storage->done_arg, storage);
ret = 1;
cq_next_data* cqd = (cq_next_data*)DATA_FROM_CQ(cq);
if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
GRPC_CQ_INTERNAL_REF(cq, "shutting_down");
gpr_mu_lock(cq->mu);
- cq_finish_shutdown_next(&exec_ctx, cq);
+ cq_finish_shutdown_next(cq);
gpr_mu_unlock(cq->mu);
- GRPC_CQ_INTERNAL_UNREF(&exec_ctx, cq, "shutting_down");
+ GRPC_CQ_INTERNAL_UNREF(cq, "shutting_down");
}
- grpc_exec_ctx_finish(&exec_ctx);
}
gpr_tls_set(&g_cached_event, (intptr_t)0);
gpr_tls_set(&g_cached_cq, (intptr_t)0);
@@ -414,24 +397,22 @@ 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 = nullptr;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
if (gpr_spinlock_trylock(&q->queue_lock)) {
- GRPC_STATS_INC_CQ_EV_QUEUE_TRYLOCK_SUCCESSES(&exec_ctx);
+ GRPC_STATS_INC_CQ_EV_QUEUE_TRYLOCK_SUCCESSES();
bool is_empty = false;
c = (grpc_cq_completion*)gpr_mpscq_pop_and_check_end(&q->queue, &is_empty);
gpr_spinlock_unlock(&q->queue_lock);
if (c == nullptr && !is_empty) {
- GRPC_STATS_INC_CQ_EV_QUEUE_TRANSIENT_POP_FAILURES(&exec_ctx);
+ GRPC_STATS_INC_CQ_EV_QUEUE_TRANSIENT_POP_FAILURES();
}
} else {
- GRPC_STATS_INC_CQ_EV_QUEUE_TRYLOCK_FAILURES(&exec_ctx);
+ GRPC_STATS_INC_CQ_EV_QUEUE_TRYLOCK_FAILURES();
}
- grpc_exec_ctx_finish(&exec_ctx);
-
if (c) {
gpr_atm_no_barrier_fetch_add(&q->num_queue_items, -1);
}
@@ -461,9 +442,8 @@ grpc_completion_queue* grpc_completion_queue_create_internal(
const cq_poller_vtable* poller_vtable =
&g_poller_vtable_by_poller_type[polling_type];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_STATS_INC_CQS_CREATED(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_STATS_INC_CQS_CREATED();
cq = (grpc_completion_queue*)gpr_zalloc(sizeof(grpc_completion_queue) +
vtable->data_size +
@@ -545,15 +525,14 @@ void grpc_cq_internal_ref(grpc_completion_queue* cq) {
gpr_ref(&cq->owning_refs);
}
-static void on_pollset_shutdown_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_pollset_shutdown_done(void* arg, grpc_error* error) {
grpc_completion_queue* cq = (grpc_completion_queue*)arg;
- GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "pollset_destroy");
+ GRPC_CQ_INTERNAL_UNREF(cq, "pollset_destroy");
}
#ifndef NDEBUG
-void grpc_cq_internal_unref(grpc_exec_ctx* exec_ctx, grpc_completion_queue* cq,
- const char* reason, const char* file, int line) {
+void grpc_cq_internal_unref(grpc_completion_queue* cq, const char* reason,
+ const char* file, int line) {
if (GRPC_TRACER_ON(grpc_trace_cq_refcount)) {
gpr_atm val = gpr_atm_no_barrier_load(&cq->owning_refs.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
@@ -561,12 +540,11 @@ void grpc_cq_internal_unref(grpc_exec_ctx* exec_ctx, grpc_completion_queue* cq,
reason);
}
#else
-void grpc_cq_internal_unref(grpc_exec_ctx* exec_ctx,
- grpc_completion_queue* cq) {
+void grpc_cq_internal_unref(grpc_completion_queue* cq) {
#endif
if (gpr_unref(&cq->owning_refs)) {
cq->vtable->destroy(DATA_FROM_CQ(cq));
- cq->poller_vtable->destroy(exec_ctx, POLLSET_FROM_CQ(cq));
+ cq->poller_vtable->destroy(POLLSET_FROM_CQ(cq));
#ifndef NDEBUG
gpr_free(cq->outstanding_tags);
#endif
@@ -647,11 +625,9 @@ bool grpc_cq_begin_op(grpc_completion_queue* cq, void* tag) {
/* Queue a GRPC_OP_COMPLETED operation to a completion queue (with a
* completion
* type of GRPC_CQ_NEXT) */
-static void cq_end_op_for_next(grpc_exec_ctx* exec_ctx,
- grpc_completion_queue* cq, void* tag,
+static void cq_end_op_for_next(grpc_completion_queue* cq, void* tag,
grpc_error* error,
- void (*done)(grpc_exec_ctx* exec_ctx,
- void* done_arg,
+ void (*done)(void* done_arg,
grpc_cq_completion* storage),
void* done_arg, grpc_cq_completion* storage) {
GPR_TIMER_BEGIN("cq_end_op_for_next", 0);
@@ -661,9 +637,9 @@ static void cq_end_op_for_next(grpc_exec_ctx* exec_ctx,
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, "
+ "cq_end_op_for_next(cq=%p, tag=%p, error=%s, "
"done=%p, done_arg=%p, storage=%p)",
- 7, (exec_ctx, cq, tag, errmsg, done, done_arg, storage));
+ 6, (cq, tag, errmsg, done, done_arg, storage));
if (GRPC_TRACER_ON(grpc_trace_operation_failures) &&
error != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg);
@@ -699,7 +675,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), nullptr);
+ cq->poller_vtable->kick(POLLSET_FROM_CQ(cq), nullptr);
gpr_mu_unlock(cq->mu);
if (kick_error != GRPC_ERROR_NONE) {
@@ -711,17 +687,17 @@ static void cq_end_op_for_next(grpc_exec_ctx* exec_ctx,
if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
GRPC_CQ_INTERNAL_REF(cq, "shutting_down");
gpr_mu_lock(cq->mu);
- cq_finish_shutdown_next(exec_ctx, cq);
+ cq_finish_shutdown_next(cq);
gpr_mu_unlock(cq->mu);
- GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down");
+ GRPC_CQ_INTERNAL_UNREF(cq, "shutting_down");
}
} else {
GRPC_CQ_INTERNAL_REF(cq, "shutting_down");
gpr_atm_rel_store(&cqd->pending_events, 0);
gpr_mu_lock(cq->mu);
- cq_finish_shutdown_next(exec_ctx, cq);
+ cq_finish_shutdown_next(cq);
gpr_mu_unlock(cq->mu);
- GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down");
+ GRPC_CQ_INTERNAL_UNREF(cq, "shutting_down");
}
}
@@ -733,11 +709,9 @@ static void cq_end_op_for_next(grpc_exec_ctx* exec_ctx,
/* Queue a GRPC_OP_COMPLETED operation to a completion queue (with a
* completion
* type of GRPC_CQ_PLUCK) */
-static void cq_end_op_for_pluck(grpc_exec_ctx* exec_ctx,
- grpc_completion_queue* cq, void* tag,
+static void cq_end_op_for_pluck(grpc_completion_queue* cq, void* tag,
grpc_error* error,
- void (*done)(grpc_exec_ctx* exec_ctx,
- void* done_arg,
+ void (*done)(void* done_arg,
grpc_cq_completion* storage),
void* done_arg, grpc_cq_completion* storage) {
cq_pluck_data* cqd = (cq_pluck_data*)DATA_FROM_CQ(cq);
@@ -750,9 +724,9 @@ static void cq_end_op_for_pluck(grpc_exec_ctx* exec_ctx,
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, "
+ "cq_end_op_for_pluck(cq=%p, tag=%p, error=%s, "
"done=%p, done_arg=%p, storage=%p)",
- 7, (exec_ctx, cq, tag, errmsg, done, done_arg, storage));
+ 6, (cq, tag, errmsg, done, done_arg, storage));
if (GRPC_TRACER_ON(grpc_trace_operation_failures) &&
error != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg);
@@ -774,7 +748,7 @@ static void cq_end_op_for_pluck(grpc_exec_ctx* exec_ctx,
cqd->completed_tail = storage;
if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
- cq_finish_shutdown_pluck(exec_ctx, cq);
+ cq_finish_shutdown_pluck(cq);
gpr_mu_unlock(cq->mu);
} else {
grpc_pollset_worker* pluck_worker = nullptr;
@@ -786,7 +760,7 @@ static void cq_end_op_for_pluck(grpc_exec_ctx* exec_ctx,
}
grpc_error* kick_error =
- cq->poller_vtable->kick(exec_ctx, POLLSET_FROM_CQ(cq), pluck_worker);
+ cq->poller_vtable->kick(POLLSET_FROM_CQ(cq), pluck_worker);
gpr_mu_unlock(cq->mu);
@@ -803,12 +777,10 @@ static void cq_end_op_for_pluck(grpc_exec_ctx* exec_ctx,
GRPC_ERROR_UNREF(error);
}
-void grpc_cq_end_op(grpc_exec_ctx* exec_ctx, grpc_completion_queue* cq,
- void* tag, grpc_error* error,
- void (*done)(grpc_exec_ctx* exec_ctx, void* done_arg,
- grpc_cq_completion* storage),
+void grpc_cq_end_op(grpc_completion_queue* cq, void* tag, grpc_error* error,
+ void (*done)(void* done_arg, grpc_cq_completion* storage),
void* done_arg, grpc_cq_completion* storage) {
- cq->vtable->end_op(exec_ctx, cq, tag, error, done, done_arg, storage);
+ cq->vtable->end_op(cq, tag, error, done, done_arg, storage);
}
typedef struct {
@@ -820,31 +792,40 @@ typedef struct {
bool first_loop;
} cq_is_finished_arg;
-static bool cq_is_next_finished(grpc_exec_ctx* exec_ctx, void* arg) {
- cq_is_finished_arg* a = (cq_is_finished_arg*)arg;
- grpc_completion_queue* cq = a->cq;
- cq_next_data* cqd = (cq_next_data*)DATA_FROM_CQ(cq);
- GPR_ASSERT(a->stolen_completion == nullptr);
+class ExecCtxNext : public grpc_core::ExecCtx {
+ public:
+ ExecCtxNext(void* arg) : ExecCtx(0), check_ready_to_finish_arg_(arg) {}
- gpr_atm current_last_seen_things_queued_ever =
- gpr_atm_no_barrier_load(&cqd->things_queued_ever);
+ bool CheckReadyToFinish() override {
+ cq_is_finished_arg* a = (cq_is_finished_arg*)check_ready_to_finish_arg_;
+ grpc_completion_queue* cq = a->cq;
+ cq_next_data* cqd = (cq_next_data*)DATA_FROM_CQ(cq);
+ GPR_ASSERT(a->stolen_completion == nullptr);
- if (current_last_seen_things_queued_ever != a->last_seen_things_queued_ever) {
- a->last_seen_things_queued_ever =
+ gpr_atm current_last_seen_things_queued_ever =
gpr_atm_no_barrier_load(&cqd->things_queued_ever);
- /* Pop a cq_completion from the queue. Returns NULL if the queue is empty
- * might return NULL in some cases even if the queue is not empty; but
- * that
- * is ok and doesn't affect correctness. Might effect the tail latencies a
- * bit) */
- a->stolen_completion = cq_event_queue_pop(&cqd->queue);
- if (a->stolen_completion != nullptr) {
- return true;
+ if (current_last_seen_things_queued_ever !=
+ a->last_seen_things_queued_ever) {
+ a->last_seen_things_queued_ever =
+ gpr_atm_no_barrier_load(&cqd->things_queued_ever);
+
+ /* Pop a cq_completion from the queue. Returns NULL if the queue is empty
+ * might return NULL in some cases even if the queue is not empty; but
+ * that
+ * is ok and doesn't affect correctness. Might effect the tail latencies a
+ * bit) */
+ a->stolen_completion = cq_event_queue_pop(&cqd->queue);
+ if (a->stolen_completion != nullptr) {
+ return true;
+ }
}
+ return !a->first_loop && a->deadline < grpc_core::ExecCtx::Get()->Now();
}
- return !a->first_loop && a->deadline < grpc_exec_ctx_now(exec_ctx);
-}
+
+ private:
+ void* check_ready_to_finish_arg_;
+};
#ifndef NDEBUG
static void dump_pending_tags(grpc_completion_queue* cq) {
@@ -899,8 +880,7 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
nullptr,
nullptr,
true};
- grpc_exec_ctx exec_ctx =
- GRPC_EXEC_CTX_INITIALIZER(0, cq_is_next_finished, &is_finished_arg);
+ ExecCtxNext _local_exec_ctx(&is_finished_arg);
for (;;) {
grpc_millis iteration_deadline = deadline_millis;
@@ -910,7 +890,7 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
ret.type = GRPC_OP_COMPLETE;
ret.success = c->next & 1u;
ret.tag = c->tag;
- c->done(&exec_ctx, c->done_arg, c);
+ c->done(c->done_arg, c);
break;
}
@@ -920,7 +900,7 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
ret.type = GRPC_OP_COMPLETE;
ret.success = c->next & 1u;
ret.tag = c->tag;
- c->done(&exec_ctx, c->done_arg, c);
+ c->done(c->done_arg, c);
break;
} else {
/* If c == NULL it means either the queue is empty OR in an transient
@@ -951,7 +931,7 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
}
if (!is_finished_arg.first_loop &&
- grpc_exec_ctx_now(&exec_ctx) >= deadline_millis) {
+ grpc_core::ExecCtx::Get()->Now() >= deadline_millis) {
memset(&ret, 0, sizeof(ret));
ret.type = GRPC_QUEUE_TIMEOUT;
dump_pending_tags(cq);
@@ -961,8 +941,8 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
/* The main polling work happens in grpc_pollset_work */
gpr_mu_lock(cq->mu);
cq->num_polls++;
- grpc_error* err = cq->poller_vtable->work(&exec_ctx, POLLSET_FROM_CQ(cq),
- nullptr, iteration_deadline);
+ grpc_error* err = cq->poller_vtable->work(POLLSET_FROM_CQ(cq), nullptr,
+ iteration_deadline);
gpr_mu_unlock(cq->mu);
if (err != GRPC_ERROR_NONE) {
@@ -981,13 +961,13 @@ 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), nullptr);
+ cq->poller_vtable->kick(POLLSET_FROM_CQ(cq), nullptr);
gpr_mu_unlock(cq->mu);
}
GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, &ret);
- GRPC_CQ_INTERNAL_UNREF(&exec_ctx, cq, "next");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_CQ_INTERNAL_UNREF(cq, "next");
+
GPR_ASSERT(is_finished_arg.stolen_completion == nullptr);
GPR_TIMER_END("grpc_completion_queue_next", 0);
@@ -1001,19 +981,16 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
- Must be called only once in completion queue's lifetime
- grpc_completion_queue_shutdown() MUST have been called before calling
this function */
-static void cq_finish_shutdown_next(grpc_exec_ctx* exec_ctx,
- grpc_completion_queue* cq) {
+static void cq_finish_shutdown_next(grpc_completion_queue* cq) {
cq_next_data* cqd = (cq_next_data*)DATA_FROM_CQ(cq);
GPR_ASSERT(cqd->shutdown_called);
GPR_ASSERT(gpr_atm_no_barrier_load(&cqd->pending_events) == 0);
- cq->poller_vtable->shutdown(exec_ctx, POLLSET_FROM_CQ(cq),
- &cq->pollset_shutdown_done);
+ cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done);
}
-static void cq_shutdown_next(grpc_exec_ctx* exec_ctx,
- grpc_completion_queue* cq) {
+static void cq_shutdown_next(grpc_completion_queue* cq) {
cq_next_data* cqd = (cq_next_data*)DATA_FROM_CQ(cq);
/* Need an extra ref for cq here because:
@@ -1026,7 +1003,7 @@ static void cq_shutdown_next(grpc_exec_ctx* exec_ctx,
gpr_mu_lock(cq->mu);
if (cqd->shutdown_called) {
gpr_mu_unlock(cq->mu);
- GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down");
+ GRPC_CQ_INTERNAL_UNREF(cq, "shutting_down");
return;
}
cqd->shutdown_called = true;
@@ -1034,10 +1011,10 @@ static void cq_shutdown_next(grpc_exec_ctx* exec_ctx,
* cq_begin_op_for_next and and cq_end_op_for_next functions which read/write
* on this counter without necessarily holding a lock on cq */
if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
- cq_finish_shutdown_next(exec_ctx, cq);
+ cq_finish_shutdown_next(cq);
}
gpr_mu_unlock(cq->mu);
- GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down");
+ GRPC_CQ_INTERNAL_UNREF(cq, "shutting_down");
}
grpc_event grpc_completion_queue_next(grpc_completion_queue* cq,
@@ -1070,37 +1047,46 @@ static void del_plucker(grpc_completion_queue* cq, void* tag,
GPR_UNREACHABLE_CODE(return );
}
-static bool cq_is_pluck_finished(grpc_exec_ctx* exec_ctx, void* arg) {
- cq_is_finished_arg* a = (cq_is_finished_arg*)arg;
- grpc_completion_queue* cq = a->cq;
- cq_pluck_data* cqd = (cq_pluck_data*)DATA_FROM_CQ(cq);
+class ExecCtxPluck : public grpc_core::ExecCtx {
+ public:
+ ExecCtxPluck(void* arg) : ExecCtx(0), check_ready_to_finish_arg_(arg) {}
- GPR_ASSERT(a->stolen_completion == nullptr);
- gpr_atm current_last_seen_things_queued_ever =
- gpr_atm_no_barrier_load(&cqd->things_queued_ever);
- if (current_last_seen_things_queued_ever != a->last_seen_things_queued_ever) {
- gpr_mu_lock(cq->mu);
- a->last_seen_things_queued_ever =
+ bool CheckReadyToFinish() override {
+ cq_is_finished_arg* a = (cq_is_finished_arg*)check_ready_to_finish_arg_;
+ grpc_completion_queue* cq = a->cq;
+ cq_pluck_data* cqd = (cq_pluck_data*)DATA_FROM_CQ(cq);
+
+ GPR_ASSERT(a->stolen_completion == nullptr);
+ gpr_atm current_last_seen_things_queued_ever =
gpr_atm_no_barrier_load(&cqd->things_queued_ever);
- grpc_cq_completion* c;
- grpc_cq_completion* prev = &cqd->completed_head;
- while ((c = (grpc_cq_completion*)(prev->next & ~(uintptr_t)1)) !=
- &cqd->completed_head) {
- if (c->tag == a->tag) {
- prev->next = (prev->next & (uintptr_t)1) | (c->next & ~(uintptr_t)1);
- if (c == cqd->completed_tail) {
- cqd->completed_tail = prev;
+ if (current_last_seen_things_queued_ever !=
+ a->last_seen_things_queued_ever) {
+ gpr_mu_lock(cq->mu);
+ a->last_seen_things_queued_ever =
+ gpr_atm_no_barrier_load(&cqd->things_queued_ever);
+ grpc_cq_completion* c;
+ grpc_cq_completion* prev = &cqd->completed_head;
+ while ((c = (grpc_cq_completion*)(prev->next & ~(uintptr_t)1)) !=
+ &cqd->completed_head) {
+ if (c->tag == a->tag) {
+ prev->next = (prev->next & (uintptr_t)1) | (c->next & ~(uintptr_t)1);
+ if (c == cqd->completed_tail) {
+ cqd->completed_tail = prev;
+ }
+ gpr_mu_unlock(cq->mu);
+ a->stolen_completion = c;
+ return true;
}
- gpr_mu_unlock(cq->mu);
- a->stolen_completion = c;
- return true;
+ prev = c;
}
- prev = c;
+ gpr_mu_unlock(cq->mu);
}
- gpr_mu_unlock(cq->mu);
+ return !a->first_loop && a->deadline < grpc_core::ExecCtx::Get()->Now();
}
- return !a->first_loop && a->deadline < grpc_exec_ctx_now(exec_ctx);
-}
+
+ private:
+ void* check_ready_to_finish_arg_;
+};
static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
gpr_timespec deadline, void* reserved) {
@@ -1137,8 +1123,7 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
nullptr,
tag,
true};
- grpc_exec_ctx exec_ctx =
- GRPC_EXEC_CTX_INITIALIZER(0, cq_is_pluck_finished, &is_finished_arg);
+ ExecCtxPluck _local_exec_ctx(&is_finished_arg);
for (;;) {
if (is_finished_arg.stolen_completion != nullptr) {
gpr_mu_unlock(cq->mu);
@@ -1147,7 +1132,7 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
ret.type = GRPC_OP_COMPLETE;
ret.success = c->next & 1u;
ret.tag = c->tag;
- c->done(&exec_ctx, c->done_arg, c);
+ c->done(c->done_arg, c);
break;
}
prev = &cqd->completed_head;
@@ -1162,7 +1147,7 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
ret.type = GRPC_OP_COMPLETE;
ret.success = c->next & 1u;
ret.tag = c->tag;
- c->done(&exec_ctx, c->done_arg, c);
+ c->done(c->done_arg, c);
goto done;
}
prev = c;
@@ -1186,7 +1171,7 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
break;
}
if (!is_finished_arg.first_loop &&
- grpc_exec_ctx_now(&exec_ctx) >= deadline_millis) {
+ grpc_core::ExecCtx::Get()->Now() >= deadline_millis) {
del_plucker(cq, tag, &worker);
gpr_mu_unlock(cq->mu);
memset(&ret, 0, sizeof(ret));
@@ -1195,8 +1180,8 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
break;
}
cq->num_polls++;
- grpc_error* err = cq->poller_vtable->work(&exec_ctx, POLLSET_FROM_CQ(cq),
- &worker, deadline_millis);
+ grpc_error* err =
+ cq->poller_vtable->work(POLLSET_FROM_CQ(cq), &worker, deadline_millis);
if (err != GRPC_ERROR_NONE) {
del_plucker(cq, tag, &worker);
gpr_mu_unlock(cq->mu);
@@ -1214,8 +1199,8 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
}
done:
GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, &ret);
- GRPC_CQ_INTERNAL_UNREF(&exec_ctx, cq, "pluck");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_CQ_INTERNAL_UNREF(cq, "pluck");
+
GPR_ASSERT(is_finished_arg.stolen_completion == nullptr);
GPR_TIMER_END("grpc_completion_queue_pluck", 0);
@@ -1228,22 +1213,19 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue* cq, void* tag,
return cq->vtable->pluck(cq, tag, deadline, reserved);
}
-static void cq_finish_shutdown_pluck(grpc_exec_ctx* exec_ctx,
- grpc_completion_queue* cq) {
+static void cq_finish_shutdown_pluck(grpc_completion_queue* cq) {
cq_pluck_data* cqd = (cq_pluck_data*)DATA_FROM_CQ(cq);
GPR_ASSERT(cqd->shutdown_called);
GPR_ASSERT(!gpr_atm_no_barrier_load(&cqd->shutdown));
gpr_atm_no_barrier_store(&cqd->shutdown, 1);
- cq->poller_vtable->shutdown(exec_ctx, POLLSET_FROM_CQ(cq),
- &cq->pollset_shutdown_done);
+ cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done);
}
/* NOTE: This function is almost exactly identical to cq_shutdown_next() but
* merging them is a bit tricky and probably not worth it */
-static void cq_shutdown_pluck(grpc_exec_ctx* exec_ctx,
- grpc_completion_queue* cq) {
+static void cq_shutdown_pluck(grpc_completion_queue* cq) {
cq_pluck_data* cqd = (cq_pluck_data*)DATA_FROM_CQ(cq);
/* Need an extra ref for cq here because:
@@ -1256,25 +1238,25 @@ static void cq_shutdown_pluck(grpc_exec_ctx* exec_ctx,
gpr_mu_lock(cq->mu);
if (cqd->shutdown_called) {
gpr_mu_unlock(cq->mu);
- GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down (pluck cq)");
+ GRPC_CQ_INTERNAL_UNREF(cq, "shutting_down (pluck cq)");
return;
}
cqd->shutdown_called = true;
if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
- cq_finish_shutdown_pluck(exec_ctx, cq);
+ cq_finish_shutdown_pluck(cq);
}
gpr_mu_unlock(cq->mu);
- GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down (pluck cq)");
+ GRPC_CQ_INTERNAL_UNREF(cq, "shutting_down (pluck cq)");
}
/* Shutdown simply drops a ref that we reserved at creation time; if we drop
to zero here, then enter shutdown mode and wake up any waiters */
void grpc_completion_queue_shutdown(grpc_completion_queue* cq) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GPR_TIMER_BEGIN("grpc_completion_queue_shutdown", 0);
GRPC_API_TRACE("grpc_completion_queue_shutdown(cq=%p)", 1, (cq));
- cq->vtable->shutdown(&exec_ctx, cq);
- grpc_exec_ctx_finish(&exec_ctx);
+ cq->vtable->shutdown(cq);
+
GPR_TIMER_END("grpc_completion_queue_shutdown", 0);
}
@@ -1283,9 +1265,9 @@ void grpc_completion_queue_destroy(grpc_completion_queue* cq) {
GPR_TIMER_BEGIN("grpc_completion_queue_destroy", 0);
grpc_completion_queue_shutdown(cq);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CQ_INTERNAL_UNREF(&exec_ctx, cq, "destroy");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_CQ_INTERNAL_UNREF(cq, "destroy");
+
GPR_TIMER_END("grpc_completion_queue_destroy", 0);
}
diff --git a/src/core/lib/surface/completion_queue.h b/src/core/lib/surface/completion_queue.h
index 0ed9875f58..5ddafd9eb5 100644
--- a/src/core/lib/surface/completion_queue.h
+++ b/src/core/lib/surface/completion_queue.h
@@ -47,8 +47,7 @@ typedef struct grpc_cq_completion {
void* tag;
/** done callback - called when this queue element is no longer
needed by the completion queue */
- void (*done)(grpc_exec_ctx* exec_ctx, void* done_arg,
- struct grpc_cq_completion* c);
+ void (*done)(void* done_arg, struct grpc_cq_completion* c);
void* done_arg;
/** next pointer; low bit is used to indicate success or not */
uintptr_t next;
@@ -57,17 +56,17 @@ typedef struct grpc_cq_completion {
#ifndef NDEBUG
void grpc_cq_internal_ref(grpc_completion_queue* cc, const char* reason,
const char* file, int line);
-void grpc_cq_internal_unref(grpc_exec_ctx* exec_ctx, grpc_completion_queue* cc,
- const char* reason, const char* file, int line);
+void grpc_cq_internal_unref(grpc_completion_queue* cc, const char* reason,
+ const char* file, int line);
#define GRPC_CQ_INTERNAL_REF(cc, reason) \
grpc_cq_internal_ref(cc, reason, __FILE__, __LINE__)
-#define GRPC_CQ_INTERNAL_UNREF(ec, cc, reason) \
- grpc_cq_internal_unref(ec, cc, reason, __FILE__, __LINE__)
+#define GRPC_CQ_INTERNAL_UNREF(cc, reason) \
+ grpc_cq_internal_unref(cc, reason, __FILE__, __LINE__)
#else
void grpc_cq_internal_ref(grpc_completion_queue* cc);
-void grpc_cq_internal_unref(grpc_exec_ctx* exec_ctx, grpc_completion_queue* cc);
+void grpc_cq_internal_unref(grpc_completion_queue* cc);
#define GRPC_CQ_INTERNAL_REF(cc, reason) grpc_cq_internal_ref(cc)
-#define GRPC_CQ_INTERNAL_UNREF(ec, cc, reason) grpc_cq_internal_unref(ec, cc)
+#define GRPC_CQ_INTERNAL_UNREF(cc, reason) grpc_cq_internal_unref(cc)
#endif
/* Initializes global variables used by completion queues */
@@ -81,10 +80,8 @@ bool grpc_cq_begin_op(grpc_completion_queue* cc, void* tag);
/* Queue a GRPC_OP_COMPLETED operation; tag must correspond to the tag passed to
grpc_cq_begin_op */
-void grpc_cq_end_op(grpc_exec_ctx* exec_ctx, grpc_completion_queue* cc,
- void* tag, grpc_error* error,
- void (*done)(grpc_exec_ctx* exec_ctx, void* done_arg,
- grpc_cq_completion* storage),
+void grpc_cq_end_op(grpc_completion_queue* cc, void* tag, grpc_error* error,
+ void (*done)(void* done_arg, grpc_cq_completion* storage),
void* done_arg, grpc_cq_completion* storage);
grpc_pollset* grpc_cq_pollset(grpc_completion_queue* cc);
diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc
index 673e13ce6e..b64e862b40 100644
--- a/src/core/lib/surface/init.cc
+++ b/src/core/lib/surface/init.cc
@@ -68,14 +68,12 @@ static void do_basic_init(void) {
g_initializations = 0;
}
-static bool append_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder, void* arg) {
+static bool append_filter(grpc_channel_stack_builder* builder, void* arg) {
return grpc_channel_stack_builder_append_filter(
builder, (const grpc_channel_filter*)arg, nullptr, nullptr);
}
-static bool prepend_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder, void* arg) {
+static bool prepend_filter(grpc_channel_stack_builder* builder, void* arg) {
return grpc_channel_stack_builder_prepend_filter(
builder, (const grpc_channel_filter*)arg, nullptr, nullptr);
}
@@ -118,7 +116,7 @@ void grpc_init(void) {
int i;
gpr_once_init(&g_basic_init, do_basic_init);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_mu_lock(&g_init_mu);
if (++g_initializations == 1) {
gpr_time_init();
@@ -151,7 +149,7 @@ void grpc_init(void) {
grpc_register_tracer(&grpc_trace_metadata);
#endif
grpc_security_pre_init();
- grpc_iomgr_init(&exec_ctx);
+ grpc_iomgr_init();
gpr_timers_global_init();
grpc_handshaker_factory_registry_init();
grpc_security_init();
@@ -167,37 +165,35 @@ void grpc_init(void) {
grpc_tracer_init("GRPC_TRACE");
/* no more changes to channel init pipelines */
grpc_channel_init_finalize();
- grpc_iomgr_start(&exec_ctx);
+ grpc_iomgr_start();
}
gpr_mu_unlock(&g_init_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
GRPC_API_TRACE("grpc_init(void)", 0, ());
}
void grpc_shutdown(void) {
int i;
GRPC_API_TRACE("grpc_shutdown(void)", 0, ());
- grpc_exec_ctx exec_ctx =
- GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, nullptr);
+ grpc_core::ExecCtx _local_exec_ctx(0);
gpr_mu_lock(&g_init_mu);
if (--g_initializations == 0) {
- grpc_executor_shutdown(&exec_ctx);
+ grpc_executor_shutdown();
grpc_timer_manager_set_threading(false); // shutdown timer_manager thread
for (i = g_number_of_plugins; i >= 0; i--) {
if (g_all_of_the_plugins[i].destroy != nullptr) {
g_all_of_the_plugins[i].destroy();
}
}
- grpc_iomgr_shutdown(&exec_ctx);
+ grpc_iomgr_shutdown();
gpr_timers_global_destroy();
grpc_tracer_shutdown();
- grpc_mdctx_global_shutdown(&exec_ctx);
- grpc_handshaker_factory_registry_shutdown(&exec_ctx);
+ grpc_mdctx_global_shutdown();
+ grpc_handshaker_factory_registry_shutdown();
grpc_slice_intern_shutdown();
grpc_stats_shutdown();
}
gpr_mu_unlock(&g_init_mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
int grpc_is_initialized(void) {
diff --git a/src/core/lib/surface/init_secure.cc b/src/core/lib/surface/init_secure.cc
index deb9a8e9e5..c8935c767d 100644
--- a/src/core/lib/surface/init_secure.cc
+++ b/src/core/lib/surface/init_secure.cc
@@ -47,7 +47,7 @@ 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) {
+ grpc_channel_stack_builder* builder, void* arg) {
const grpc_channel_args* args =
grpc_channel_stack_builder_get_channel_arguments(builder);
if (args) {
@@ -62,7 +62,7 @@ static bool maybe_prepend_client_auth_filter(
}
static bool maybe_prepend_server_auth_filter(
- grpc_exec_ctx* exec_ctx, grpc_channel_stack_builder* builder, void* arg) {
+ grpc_channel_stack_builder* builder, void* arg) {
const grpc_channel_args* args =
grpc_channel_stack_builder_get_channel_arguments(builder);
if (args) {
diff --git a/src/core/lib/surface/lame_client.cc b/src/core/lib/surface/lame_client.cc
index 7114a9f545..67188b46fc 100644
--- a/src/core/lib/surface/lame_client.cc
+++ b/src/core/lib/surface/lame_client.cc
@@ -51,8 +51,7 @@ struct ChannelData {
const char* error_message;
};
-static void fill_metadata(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_metadata_batch* mdb) {
+static void fill_metadata(grpc_call_element* elem, grpc_metadata_batch* mdb) {
CallData* calld = reinterpret_cast<CallData*>(elem->call_data);
bool expected = false;
if (!calld->filled_metadata.compare_exchange_strong(
@@ -64,9 +63,9 @@ static void fill_metadata(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
char tmp[GPR_LTOA_MIN_BUFSIZE];
gpr_ltoa(chand->error_code, tmp);
calld->status.md = grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_GRPC_STATUS, grpc_slice_from_copied_string(tmp));
+ GRPC_MDSTR_GRPC_STATUS, grpc_slice_from_copied_string(tmp));
calld->details.md = grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_GRPC_MESSAGE,
+ GRPC_MDSTR_GRPC_MESSAGE,
grpc_slice_from_copied_string(chand->error_message));
calld->status.prev = calld->details.next = nullptr;
calld->status.next = &calld->details;
@@ -78,69 +77,61 @@ static void fill_metadata(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
}
static void lame_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* op) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
CallData* calld = reinterpret_cast<CallData*>(elem->call_data);
if (op->recv_initial_metadata) {
- fill_metadata(exec_ctx, elem,
+ fill_metadata(elem,
op->payload->recv_initial_metadata.recv_initial_metadata);
} else if (op->recv_trailing_metadata) {
- fill_metadata(exec_ctx, elem,
+ fill_metadata(elem,
op->payload->recv_trailing_metadata.recv_trailing_metadata);
}
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, op, GRPC_ERROR_CREATE_FROM_STATIC_STRING("lame client channel"),
+ op, GRPC_ERROR_CREATE_FROM_STATIC_STRING("lame client channel"),
calld->call_combiner);
}
-static void lame_get_channel_info(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static void lame_get_channel_info(grpc_channel_element* elem,
const grpc_channel_info* channel_info) {}
-static void lame_start_transport_op(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static void lame_start_transport_op(grpc_channel_element* elem,
grpc_transport_op* op) {
if (op->on_connectivity_state_change) {
GPR_ASSERT(*op->connectivity_state != GRPC_CHANNEL_SHUTDOWN);
*op->connectivity_state = GRPC_CHANNEL_SHUTDOWN;
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_connectivity_state_change,
- GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(op->on_connectivity_state_change, GRPC_ERROR_NONE);
}
if (op->send_ping != nullptr) {
- GRPC_CLOSURE_SCHED(
- exec_ctx, op->send_ping,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("lame client channel"));
+ GRPC_CLOSURE_SCHED(op->send_ping, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "lame client channel"));
}
GRPC_ERROR_UNREF(op->disconnect_with_error);
if (op->on_consumed != nullptr) {
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(op->on_consumed, GRPC_ERROR_NONE);
}
}
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
CallData* calld = reinterpret_cast<CallData*>(elem->call_data);
calld->call_combiner = args->call_combiner;
return GRPC_ERROR_NONE;
}
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* then_schedule_closure) {
- GRPC_CLOSURE_SCHED(exec_ctx, then_schedule_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(then_schedule_closure, GRPC_ERROR_NONE);
}
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
GPR_ASSERT(args->is_first);
GPR_ASSERT(args->is_last);
return GRPC_ERROR_NONE;
}
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
} // namespace
@@ -165,10 +156,10 @@ extern "C" const grpc_channel_filter grpc_lame_filter = {
grpc_channel* grpc_lame_client_channel_create(const char* target,
grpc_status_code error_code,
const char* error_message) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_channel_element* elem;
- grpc_channel* channel = grpc_channel_create(
- &exec_ctx, target, nullptr, GRPC_CLIENT_LAME_CHANNEL, nullptr);
+ grpc_channel* channel =
+ grpc_channel_create(target, nullptr, GRPC_CLIENT_LAME_CHANNEL, nullptr);
elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
GRPC_API_TRACE(
"grpc_lame_client_channel_create(target=%s, error_code=%d, "
@@ -178,6 +169,6 @@ grpc_channel* grpc_lame_client_channel_create(const char* target,
auto chand = reinterpret_cast<grpc_core::ChannelData*>(elem->channel_data);
chand->error_code = error_code;
chand->error_message = error_message;
- grpc_exec_ctx_finish(&exec_ctx);
+
return channel;
}
diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc
index b816439770..49f453569c 100644
--- a/src/core/lib/surface/server.cc
+++ b/src/core/lib/surface/server.cc
@@ -46,10 +46,9 @@
typedef struct listener {
void* arg;
- void (*start)(grpc_exec_ctx* exec_ctx, grpc_server* server, void* arg,
- grpc_pollset** pollsets, size_t pollset_count);
- void (*destroy)(grpc_exec_ctx* exec_ctx, grpc_server* server, void* arg,
- grpc_closure* closure);
+ void (*start)(grpc_server* server, void* arg, grpc_pollset** pollsets,
+ size_t pollset_count);
+ void (*destroy)(grpc_server* server, void* arg, grpc_closure* closure);
struct listener* next;
grpc_closure destroy_done;
} listener;
@@ -225,13 +224,12 @@ struct grpc_server {
#define SERVER_FROM_CALL_ELEM(elem) \
(((channel_data*)(elem)->channel_data)->server)
-static void publish_new_rpc(grpc_exec_ctx* exec_ctx, void* calld,
- grpc_error* error);
-static void fail_call(grpc_exec_ctx* exec_ctx, grpc_server* server,
- size_t cq_idx, requested_call* rc, grpc_error* error);
+static void publish_new_rpc(void* calld, grpc_error* error);
+static void fail_call(grpc_server* server, size_t cq_idx, requested_call* rc,
+ grpc_error* error);
/* Before calling maybe_finish_shutdown, we must hold mu_global and not
hold mu_call */
-static void maybe_finish_shutdown(grpc_exec_ctx* exec_ctx, grpc_server* server);
+static void maybe_finish_shutdown(grpc_server* server);
/*
* channel broadcaster
@@ -259,15 +257,14 @@ struct shutdown_cleanup_args {
grpc_slice slice;
};
-static void shutdown_cleanup(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void shutdown_cleanup(void* arg, grpc_error* error) {
struct shutdown_cleanup_args* a = (struct shutdown_cleanup_args*)arg;
- grpc_slice_unref_internal(exec_ctx, a->slice);
+ grpc_slice_unref_internal(a->slice);
gpr_free(a);
}
-static void send_shutdown(grpc_exec_ctx* exec_ctx, grpc_channel* channel,
- bool send_goaway, grpc_error* send_disconnect) {
+static void send_shutdown(grpc_channel* channel, bool send_goaway,
+ grpc_error* send_disconnect) {
struct shutdown_cleanup_args* sc =
(struct shutdown_cleanup_args*)gpr_malloc(sizeof(*sc));
GRPC_CLOSURE_INIT(&sc->closure, shutdown_cleanup, sc,
@@ -285,19 +282,18 @@ static void send_shutdown(grpc_exec_ctx* exec_ctx, grpc_channel* channel,
op->disconnect_with_error = send_disconnect;
elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
- elem->filter->start_transport_op(exec_ctx, elem, op);
+ elem->filter->start_transport_op(elem, op);
}
-static void channel_broadcaster_shutdown(grpc_exec_ctx* exec_ctx,
- channel_broadcaster* cb,
+static void channel_broadcaster_shutdown(channel_broadcaster* cb,
bool send_goaway,
grpc_error* force_disconnect) {
size_t i;
for (i = 0; i < cb->num_channels; i++) {
- send_shutdown(exec_ctx, cb->channels[i], send_goaway,
+ send_shutdown(cb->channels[i], send_goaway,
GRPC_ERROR_REF(force_disconnect));
- GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, cb->channels[i], "broadcast");
+ GRPC_CHANNEL_INTERNAL_UNREF(cb->channels[i], "broadcast");
}
gpr_free(cb->channels);
GRPC_ERROR_UNREF(force_disconnect);
@@ -325,13 +321,11 @@ static void request_matcher_destroy(request_matcher* rm) {
gpr_free(rm->requests_per_cq);
}
-static void kill_zombie(grpc_exec_ctx* exec_ctx, void* elem,
- grpc_error* error) {
+static void kill_zombie(void* elem, grpc_error* error) {
grpc_call_unref(grpc_call_from_top_element((grpc_call_element*)elem));
}
-static void request_matcher_zombify_all_pending_calls(grpc_exec_ctx* exec_ctx,
- request_matcher* rm) {
+static void request_matcher_zombify_all_pending_calls(request_matcher* rm) {
while (rm->pending_head) {
call_data* calld = rm->pending_head;
rm->pending_head = calld->pending_next;
@@ -340,12 +334,11 @@ static void request_matcher_zombify_all_pending_calls(grpc_exec_ctx* exec_ctx,
&calld->kill_zombie_closure, kill_zombie,
grpc_call_stack_element(grpc_call_get_call_stack(calld->call), 0),
grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_SCHED(exec_ctx, &calld->kill_zombie_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&calld->kill_zombie_closure, GRPC_ERROR_NONE);
}
}
-static void request_matcher_kill_requests(grpc_exec_ctx* exec_ctx,
- grpc_server* server,
+static void request_matcher_kill_requests(grpc_server* server,
request_matcher* rm,
grpc_error* error) {
requested_call* rc;
@@ -358,7 +351,7 @@ static void request_matcher_kill_requests(grpc_exec_ctx* exec_ctx,
NULL returned here truly means that the queue is empty */
while ((rc = (requested_call*)gpr_mpscq_pop(
&rm->requests_per_cq[i].queue)) != nullptr) {
- fail_call(exec_ctx, server, i, rc, GRPC_ERROR_REF(error));
+ fail_call(server, i, rc, GRPC_ERROR_REF(error));
}
}
GRPC_ERROR_UNREF(error);
@@ -372,10 +365,10 @@ static void server_ref(grpc_server* server) {
gpr_ref(&server->internal_refcount);
}
-static void server_delete(grpc_exec_ctx* exec_ctx, grpc_server* server) {
+static void server_delete(grpc_server* server) {
registered_method* rm;
size_t i;
- grpc_channel_args_destroy(exec_ctx, server->channel_args);
+ grpc_channel_args_destroy(server->channel_args);
gpr_mu_destroy(&server->mu_global);
gpr_mu_destroy(&server->mu_call);
gpr_cv_destroy(&server->starting_cv);
@@ -392,7 +385,7 @@ static void server_delete(grpc_exec_ctx* exec_ctx, grpc_server* server) {
request_matcher_destroy(&server->unregistered_request_matcher);
}
for (i = 0; i < server->cq_count; i++) {
- GRPC_CQ_INTERNAL_UNREF(exec_ctx, server->cqs[i], "server");
+ GRPC_CQ_INTERNAL_UNREF(server->cqs[i], "server");
}
gpr_free(server->cqs);
gpr_free(server->pollsets);
@@ -400,9 +393,9 @@ static void server_delete(grpc_exec_ctx* exec_ctx, grpc_server* server) {
gpr_free(server);
}
-static void server_unref(grpc_exec_ctx* exec_ctx, grpc_server* server) {
+static void server_unref(grpc_server* server) {
if (gpr_unref(&server->internal_refcount)) {
- server_delete(exec_ctx, server);
+ server_delete(server);
}
}
@@ -416,21 +409,19 @@ static void orphan_channel(channel_data* chand) {
chand->next = chand->prev = chand;
}
-static void finish_destroy_channel(grpc_exec_ctx* exec_ctx, void* cd,
- grpc_error* error) {
+static void finish_destroy_channel(void* cd, grpc_error* error) {
channel_data* chand = (channel_data*)cd;
grpc_server* server = chand->server;
- GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, chand->channel, "server");
- server_unref(exec_ctx, server);
+ GRPC_CHANNEL_INTERNAL_UNREF(chand->channel, "server");
+ server_unref(server);
}
-static void destroy_channel(grpc_exec_ctx* exec_ctx, channel_data* chand,
- grpc_error* error) {
+static void destroy_channel(channel_data* chand, grpc_error* error) {
if (is_channel_orphaned(chand)) return;
GPR_ASSERT(chand->server != nullptr);
orphan_channel(chand);
server_ref(chand->server);
- maybe_finish_shutdown(exec_ctx, chand->server);
+ maybe_finish_shutdown(chand->server);
GRPC_CLOSURE_INIT(&chand->finish_destroy_channel_closure,
finish_destroy_channel, chand, grpc_schedule_on_exec_ctx);
@@ -443,20 +434,18 @@ static void destroy_channel(grpc_exec_ctx* exec_ctx, channel_data* chand,
grpc_transport_op* op =
grpc_make_transport_op(&chand->finish_destroy_channel_closure);
op->set_accept_stream = true;
- grpc_channel_next_op(exec_ctx,
- grpc_channel_stack_element(
+ grpc_channel_next_op(grpc_channel_stack_element(
grpc_channel_get_channel_stack(chand->channel), 0),
op);
}
-static void done_request_event(grpc_exec_ctx* exec_ctx, void* req,
- grpc_cq_completion* c) {
+static void done_request_event(void* req, grpc_cq_completion* c) {
gpr_free(req);
}
-static void publish_call(grpc_exec_ctx* exec_ctx, grpc_server* server,
- call_data* calld, size_t cq_idx, requested_call* rc) {
- grpc_call_set_completion_queue(exec_ctx, calld->call, rc->cq_bound_to_call);
+static void publish_call(grpc_server* server, call_data* calld, size_t cq_idx,
+ requested_call* rc) {
+ grpc_call_set_completion_queue(calld->call, rc->cq_bound_to_call);
grpc_call* call = calld->call;
*rc->call = call;
calld->cq_new = server->cqs[cq_idx];
@@ -483,12 +472,11 @@ static void publish_call(grpc_exec_ctx* exec_ctx, grpc_server* server,
GPR_UNREACHABLE_CODE(return );
}
- grpc_cq_end_op(exec_ctx, calld->cq_new, rc->tag, GRPC_ERROR_NONE,
- done_request_event, rc, &rc->completion);
+ grpc_cq_end_op(calld->cq_new, rc->tag, GRPC_ERROR_NONE, done_request_event,
+ rc, &rc->completion);
}
-static void publish_new_rpc(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void publish_new_rpc(void* arg, grpc_error* error) {
grpc_call_element* call_elem = (grpc_call_element*)arg;
call_data* calld = (call_data*)call_elem->call_data;
channel_data* chand = (channel_data*)call_elem->channel_data;
@@ -501,8 +489,7 @@ static void publish_new_rpc(grpc_exec_ctx* exec_ctx, void* arg,
&calld->kill_zombie_closure, kill_zombie,
grpc_call_stack_element(grpc_call_get_call_stack(calld->call), 0),
grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_SCHED(exec_ctx, &calld->kill_zombie_closure,
- GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(&calld->kill_zombie_closure, GRPC_ERROR_REF(error));
return;
}
@@ -513,15 +500,15 @@ static void publish_new_rpc(grpc_exec_ctx* exec_ctx, void* arg,
if (rc == nullptr) {
continue;
} else {
- GRPC_STATS_INC_SERVER_CQS_CHECKED(exec_ctx, i);
+ GRPC_STATS_INC_SERVER_CQS_CHECKED(i);
gpr_atm_no_barrier_store(&calld->state, ACTIVATED);
- publish_call(exec_ctx, server, calld, cq_idx, rc);
+ publish_call(server, calld, cq_idx, rc);
return; /* early out */
}
}
/* no cq to take the request found: queue it on the slow list */
- GRPC_STATS_INC_SERVER_SLOWPATH_REQUESTS_QUEUED(exec_ctx);
+ GRPC_STATS_INC_SERVER_SLOWPATH_REQUESTS_QUEUED();
gpr_mu_lock(&server->mu_call);
// We need to ensure that all the queues are empty. We do this under
@@ -536,9 +523,9 @@ static void publish_new_rpc(grpc_exec_ctx* exec_ctx, void* arg,
continue;
} else {
gpr_mu_unlock(&server->mu_call);
- GRPC_STATS_INC_SERVER_CQS_CHECKED(exec_ctx, i + server->cq_count);
+ GRPC_STATS_INC_SERVER_CQS_CHECKED(i + server->cq_count);
gpr_atm_no_barrier_store(&calld->state, ACTIVATED);
- publish_call(exec_ctx, server, calld, cq_idx, rc);
+ publish_call(server, calld, cq_idx, rc);
return; /* early out */
}
}
@@ -555,8 +542,7 @@ static void publish_new_rpc(grpc_exec_ctx* exec_ctx, void* arg,
}
static void finish_start_new_rpc(
- grpc_exec_ctx* exec_ctx, grpc_server* server, grpc_call_element* elem,
- request_matcher* rm,
+ grpc_server* server, grpc_call_element* elem, request_matcher* rm,
grpc_server_register_method_payload_handling payload_handling) {
call_data* calld = (call_data*)elem->call_data;
@@ -564,7 +550,7 @@ static void finish_start_new_rpc(
gpr_atm_no_barrier_store(&calld->state, ZOMBIED);
GRPC_CLOSURE_INIT(&calld->kill_zombie_closure, kill_zombie, elem,
grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_SCHED(exec_ctx, &calld->kill_zombie_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&calld->kill_zombie_closure, GRPC_ERROR_NONE);
return;
}
@@ -572,7 +558,7 @@ static void finish_start_new_rpc(
switch (payload_handling) {
case GRPC_SRM_PAYLOAD_NONE:
- publish_new_rpc(exec_ctx, elem, GRPC_ERROR_NONE);
+ publish_new_rpc(elem, GRPC_ERROR_NONE);
break;
case GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER: {
grpc_op op;
@@ -581,14 +567,13 @@ static void finish_start_new_rpc(
op.data.recv_message.recv_message = &calld->payload;
GRPC_CLOSURE_INIT(&calld->publish, publish_new_rpc, elem,
grpc_schedule_on_exec_ctx);
- grpc_call_start_batch_and_execute(exec_ctx, calld->call, &op, 1,
- &calld->publish);
+ grpc_call_start_batch_and_execute(calld->call, &op, 1, &calld->publish);
break;
}
}
}
-static void start_new_rpc(grpc_exec_ctx* exec_ctx, grpc_call_element* elem) {
+static void start_new_rpc(grpc_call_element* elem) {
channel_data* chand = (channel_data*)elem->channel_data;
call_data* calld = (call_data*)elem->call_data;
grpc_server* server = chand->server;
@@ -613,8 +598,7 @@ static void start_new_rpc(grpc_exec_ctx* exec_ctx, grpc_call_element* elem) {
GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST)) {
continue;
}
- finish_start_new_rpc(exec_ctx, server, elem,
- &rm->server_registered_method->matcher,
+ finish_start_new_rpc(server, elem, &rm->server_registered_method->matcher,
rm->server_registered_method->payload_handling);
return;
}
@@ -631,14 +615,12 @@ static void start_new_rpc(grpc_exec_ctx* exec_ctx, grpc_call_element* elem) {
GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST)) {
continue;
}
- finish_start_new_rpc(exec_ctx, server, elem,
- &rm->server_registered_method->matcher,
+ finish_start_new_rpc(server, elem, &rm->server_registered_method->matcher,
rm->server_registered_method->payload_handling);
return;
}
}
- finish_start_new_rpc(exec_ctx, server, elem,
- &server->unregistered_request_matcher,
+ finish_start_new_rpc(server, elem, &server->unregistered_request_matcher,
GRPC_SRM_PAYLOAD_NONE);
}
@@ -651,9 +633,8 @@ static int num_listeners(grpc_server* server) {
return n;
}
-static void done_shutdown_event(grpc_exec_ctx* exec_ctx, void* server,
- grpc_cq_completion* completion) {
- server_unref(exec_ctx, (grpc_server*)server);
+static void done_shutdown_event(void* server, grpc_cq_completion* completion) {
+ server_unref((grpc_server*)server);
}
static int num_channels(grpc_server* server) {
@@ -666,34 +647,30 @@ static int num_channels(grpc_server* server) {
return n;
}
-static void kill_pending_work_locked(grpc_exec_ctx* exec_ctx,
- grpc_server* server, grpc_error* error) {
+static void kill_pending_work_locked(grpc_server* server, grpc_error* error) {
if (server->started) {
- request_matcher_kill_requests(exec_ctx, server,
- &server->unregistered_request_matcher,
+ request_matcher_kill_requests(server, &server->unregistered_request_matcher,
GRPC_ERROR_REF(error));
request_matcher_zombify_all_pending_calls(
- exec_ctx, &server->unregistered_request_matcher);
+ &server->unregistered_request_matcher);
for (registered_method* rm = server->registered_methods; rm;
rm = rm->next) {
- request_matcher_kill_requests(exec_ctx, server, &rm->matcher,
+ request_matcher_kill_requests(server, &rm->matcher,
GRPC_ERROR_REF(error));
- request_matcher_zombify_all_pending_calls(exec_ctx, &rm->matcher);
+ request_matcher_zombify_all_pending_calls(&rm->matcher);
}
}
GRPC_ERROR_UNREF(error);
}
-static void maybe_finish_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_server* server) {
+static void maybe_finish_shutdown(grpc_server* server) {
size_t i;
if (!gpr_atm_acq_load(&server->shutdown_flag) || server->shutdown_published) {
return;
}
kill_pending_work_locked(
- exec_ctx, server,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
+ server, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
if (server->root_channel_data.next != &server->root_channel_data ||
server->listeners_destroyed < num_listeners(server)) {
@@ -713,15 +690,13 @@ static void maybe_finish_shutdown(grpc_exec_ctx* exec_ctx,
server->shutdown_published = 1;
for (i = 0; i < server->num_shutdown_tags; i++) {
server_ref(server);
- grpc_cq_end_op(exec_ctx, server->shutdown_tags[i].cq,
- server->shutdown_tags[i].tag, GRPC_ERROR_NONE,
- done_shutdown_event, server,
+ grpc_cq_end_op(server->shutdown_tags[i].cq, server->shutdown_tags[i].tag,
+ GRPC_ERROR_NONE, done_shutdown_event, server,
&server->shutdown_tags[i].completion);
}
}
-static void server_on_recv_initial_metadata(grpc_exec_ctx* exec_ctx, void* ptr,
- grpc_error* error) {
+static void server_on_recv_initial_metadata(void* ptr, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)ptr;
call_data* calld = (call_data*)elem->call_data;
grpc_millis op_deadline;
@@ -735,10 +710,10 @@ static void server_on_recv_initial_metadata(grpc_exec_ctx* exec_ctx, void* ptr,
GRPC_MDVALUE(calld->recv_initial_metadata->idx.named.authority->md));
calld->path_set = true;
calld->host_set = true;
- grpc_metadata_batch_remove(exec_ctx, calld->recv_initial_metadata,
+ grpc_metadata_batch_remove(calld->recv_initial_metadata,
calld->recv_initial_metadata->idx.named.path);
grpc_metadata_batch_remove(
- exec_ctx, calld->recv_initial_metadata,
+ calld->recv_initial_metadata,
calld->recv_initial_metadata->idx.named.authority);
} else {
GRPC_ERROR_REF(error);
@@ -756,7 +731,7 @@ static void server_on_recv_initial_metadata(grpc_exec_ctx* exec_ctx, void* ptr,
GRPC_ERROR_UNREF(src_error);
}
- GRPC_CLOSURE_RUN(exec_ctx, calld->on_done_recv_initial_metadata, error);
+ GRPC_CLOSURE_RUN(calld->on_done_recv_initial_metadata, error);
}
static void server_mutate_op(grpc_call_element* elem,
@@ -777,24 +752,21 @@ static void server_mutate_op(grpc_call_element* elem,
}
static void server_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* op) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
server_mutate_op(elem, op);
- grpc_call_next_op(exec_ctx, elem, op);
+ grpc_call_next_op(elem, op);
}
-static void got_initial_metadata(grpc_exec_ctx* exec_ctx, void* ptr,
- grpc_error* error) {
+static void got_initial_metadata(void* ptr, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)ptr;
call_data* calld = (call_data*)elem->call_data;
if (error == GRPC_ERROR_NONE) {
- start_new_rpc(exec_ctx, elem);
+ start_new_rpc(elem);
} else {
if (gpr_atm_full_cas(&calld->state, NOT_STARTED, ZOMBIED)) {
GRPC_CLOSURE_INIT(&calld->kill_zombie_closure, kill_zombie, elem,
grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_SCHED(exec_ctx, &calld->kill_zombie_closure,
- GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&calld->kill_zombie_closure, GRPC_ERROR_NONE);
} else if (gpr_atm_full_cas(&calld->state, PENDING, ZOMBIED)) {
/* zombied call will be destroyed when it's removed from the pending
queue... later */
@@ -802,8 +774,7 @@ static void got_initial_metadata(grpc_exec_ctx* exec_ctx, void* ptr,
}
}
-static void accept_stream(grpc_exec_ctx* exec_ctx, void* cd,
- grpc_transport* transport,
+static void accept_stream(void* cd, grpc_transport* transport,
const void* transport_server_data) {
channel_data* chand = (channel_data*)cd;
/* create a call */
@@ -813,11 +784,11 @@ static void accept_stream(grpc_exec_ctx* exec_ctx, void* cd,
args.server_transport_data = transport_server_data;
args.send_deadline = GRPC_MILLIS_INF_FUTURE;
grpc_call* call;
- grpc_error* error = grpc_call_create(exec_ctx, &args, &call);
+ grpc_error* error = grpc_call_create(&args, &call);
grpc_call_element* elem =
grpc_call_stack_element(grpc_call_get_call_stack(call), 0);
if (error != GRPC_ERROR_NONE) {
- got_initial_metadata(exec_ctx, elem, error);
+ got_initial_metadata(elem, error);
GRPC_ERROR_UNREF(error);
return;
}
@@ -829,32 +800,28 @@ static void accept_stream(grpc_exec_ctx* exec_ctx, void* cd,
&calld->initial_metadata;
GRPC_CLOSURE_INIT(&calld->got_initial_metadata, got_initial_metadata, elem,
grpc_schedule_on_exec_ctx);
- grpc_call_start_batch_and_execute(exec_ctx, call, &op, 1,
- &calld->got_initial_metadata);
+ grpc_call_start_batch_and_execute(call, &op, 1, &calld->got_initial_metadata);
}
-static void channel_connectivity_changed(grpc_exec_ctx* exec_ctx, void* cd,
- grpc_error* error) {
+static void channel_connectivity_changed(void* cd, grpc_error* error) {
channel_data* chand = (channel_data*)cd;
grpc_server* server = chand->server;
if (chand->connectivity_state != GRPC_CHANNEL_SHUTDOWN) {
grpc_transport_op* op = grpc_make_transport_op(nullptr);
op->on_connectivity_state_change = &chand->channel_connectivity_changed,
op->connectivity_state = &chand->connectivity_state;
- grpc_channel_next_op(exec_ctx,
- grpc_channel_stack_element(
+ grpc_channel_next_op(grpc_channel_stack_element(
grpc_channel_get_channel_stack(chand->channel), 0),
op);
} else {
gpr_mu_lock(&server->mu_global);
- destroy_channel(exec_ctx, chand, GRPC_ERROR_REF(error));
+ destroy_channel(chand, GRPC_ERROR_REF(error));
gpr_mu_unlock(&server->mu_global);
- GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, chand->channel, "connectivity");
+ GRPC_CHANNEL_INTERNAL_UNREF(chand->channel, "connectivity");
}
}
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
call_data* calld = (call_data*)elem->call_data;
channel_data* chand = (channel_data*)elem->channel_data;
@@ -870,7 +837,7 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
channel_data* chand = (channel_data*)elem->channel_data;
@@ -879,19 +846,18 @@ static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
GPR_ASSERT(calld->state != PENDING);
if (calld->host_set) {
- grpc_slice_unref_internal(exec_ctx, calld->host);
+ grpc_slice_unref_internal(calld->host);
}
if (calld->path_set) {
- grpc_slice_unref_internal(exec_ctx, calld->path);
+ grpc_slice_unref_internal(calld->path);
}
grpc_metadata_array_destroy(&calld->initial_metadata);
grpc_byte_buffer_destroy(calld->payload);
- server_unref(exec_ctx, chand->server);
+ server_unref(chand->server);
}
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
channel_data* chand = (channel_data*)elem->channel_data;
GPR_ASSERT(args->is_first);
@@ -907,15 +873,14 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {
+static void destroy_channel_elem(grpc_channel_element* elem) {
size_t i;
channel_data* chand = (channel_data*)elem->channel_data;
if (chand->registered_methods) {
for (i = 0; i < chand->registered_method_slots; i++) {
- grpc_slice_unref_internal(exec_ctx, chand->registered_methods[i].method);
+ grpc_slice_unref_internal(chand->registered_methods[i].method);
if (chand->registered_methods[i].has_host) {
- grpc_slice_unref_internal(exec_ctx, chand->registered_methods[i].host);
+ grpc_slice_unref_internal(chand->registered_methods[i].host);
}
}
gpr_free(chand->registered_methods);
@@ -925,9 +890,9 @@ static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
chand->next->prev = chand->prev;
chand->prev->next = chand->next;
chand->next = chand->prev = chand;
- maybe_finish_shutdown(exec_ctx, chand->server);
+ maybe_finish_shutdown(chand->server);
gpr_mu_unlock(&chand->server->mu_global);
- server_unref(exec_ctx, chand->server);
+ server_unref(chand->server);
}
}
@@ -1041,11 +1006,10 @@ void* grpc_server_register_method(
return m;
}
-static void start_listeners(grpc_exec_ctx* exec_ctx, void* s,
- grpc_error* error) {
+static void start_listeners(void* s, grpc_error* error) {
grpc_server* server = (grpc_server*)s;
for (listener* l = server->listeners; l; l = l->next) {
- l->start(exec_ctx, server, l->arg, server->pollsets, server->pollset_count);
+ l->start(server, l->arg, server->pollsets, server->pollset_count);
}
gpr_mu_lock(&server->mu_global);
@@ -1053,12 +1017,12 @@ static void start_listeners(grpc_exec_ctx* exec_ctx, void* s,
gpr_cv_signal(&server->starting_cv);
gpr_mu_unlock(&server->mu_global);
- server_unref(exec_ctx, server);
+ server_unref(server);
}
void grpc_server_start(grpc_server* server) {
size_t i;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GRPC_API_TRACE("grpc_server_start(server=%p)", 1, (server));
@@ -1080,12 +1044,9 @@ void grpc_server_start(grpc_server* server) {
server_ref(server);
server->starting = true;
GRPC_CLOSURE_SCHED(
- &exec_ctx,
GRPC_CLOSURE_CREATE(start_listeners, server,
grpc_executor_scheduler(GRPC_EXECUTOR_SHORT)),
GRPC_ERROR_NONE);
-
- grpc_exec_ctx_finish(&exec_ctx);
}
void grpc_server_get_pollsets(grpc_server* server, grpc_pollset*** pollsets,
@@ -1094,8 +1055,7 @@ void grpc_server_get_pollsets(grpc_server* server, grpc_pollset*** pollsets,
*pollsets = server->pollsets;
}
-void grpc_server_setup_transport(grpc_exec_ctx* exec_ctx, grpc_server* s,
- grpc_transport* transport,
+void grpc_server_setup_transport(grpc_server* s, grpc_transport* transport,
grpc_pollset* accepting_pollset,
const grpc_channel_args* args) {
size_t num_registered_methods;
@@ -1110,8 +1070,7 @@ void grpc_server_setup_transport(grpc_exec_ctx* exec_ctx, grpc_server* s,
uint32_t max_probes = 0;
grpc_transport_op* op = nullptr;
- channel = grpc_channel_create(exec_ctx, nullptr, args, GRPC_SERVER_CHANNEL,
- transport);
+ channel = grpc_channel_create(nullptr, args, GRPC_SERVER_CHANNEL, transport);
chand = (channel_data*)grpc_channel_stack_element(
grpc_channel_get_channel_stack(channel), 0)
->channel_data;
@@ -1188,21 +1147,19 @@ void grpc_server_setup_transport(grpc_exec_ctx* exec_ctx, grpc_server* s,
op->disconnect_with_error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server shutdown");
}
- grpc_transport_perform_op(exec_ctx, transport, op);
+ grpc_transport_perform_op(transport, op);
}
-void done_published_shutdown(grpc_exec_ctx* exec_ctx, void* done_arg,
- grpc_cq_completion* storage) {
+void done_published_shutdown(void* done_arg, grpc_cq_completion* storage) {
(void)done_arg;
gpr_free(storage);
}
-static void listener_destroy_done(grpc_exec_ctx* exec_ctx, void* s,
- grpc_error* error) {
+static void listener_destroy_done(void* s, grpc_error* error) {
grpc_server* server = (grpc_server*)s;
gpr_mu_lock(&server->mu_global);
server->listeners_destroyed++;
- maybe_finish_shutdown(exec_ctx, server);
+ maybe_finish_shutdown(server);
gpr_mu_unlock(&server->mu_global);
}
@@ -1211,7 +1168,7 @@ void grpc_server_shutdown_and_notify(grpc_server* server,
listener* l;
shutdown_tag* sdt;
channel_broadcaster broadcaster;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GRPC_API_TRACE("grpc_server_shutdown_and_notify(server=%p, cq=%p, tag=%p)", 3,
(server, cq, tag));
@@ -1226,11 +1183,10 @@ void grpc_server_shutdown_and_notify(grpc_server* server,
/* stay locked, and gather up some stuff to do */
GPR_ASSERT(grpc_cq_begin_op(cq, tag));
if (server->shutdown_published) {
- grpc_cq_end_op(&exec_ctx, cq, tag, GRPC_ERROR_NONE, done_published_shutdown,
- nullptr,
+ grpc_cq_end_op(cq, tag, GRPC_ERROR_NONE, done_published_shutdown, nullptr,
(grpc_cq_completion*)gpr_malloc(sizeof(grpc_cq_completion)));
gpr_mu_unlock(&server->mu_global);
- goto done;
+ return;
}
server->shutdown_tags = (shutdown_tag*)gpr_realloc(
server->shutdown_tags,
@@ -1240,7 +1196,7 @@ void grpc_server_shutdown_and_notify(grpc_server* server,
sdt->cq = cq;
if (gpr_atm_acq_load(&server->shutdown_flag)) {
gpr_mu_unlock(&server->mu_global);
- goto done;
+ return;
}
server->last_shutdown_message_time = gpr_now(GPR_CLOCK_REALTIME);
@@ -1252,30 +1208,26 @@ void grpc_server_shutdown_and_notify(grpc_server* server,
/* collect all unregistered then registered calls */
gpr_mu_lock(&server->mu_call);
kill_pending_work_locked(
- &exec_ctx, server,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
+ server, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
gpr_mu_unlock(&server->mu_call);
- maybe_finish_shutdown(&exec_ctx, server);
+ maybe_finish_shutdown(server);
gpr_mu_unlock(&server->mu_global);
/* Shutdown listeners */
for (l = server->listeners; l; l = l->next) {
GRPC_CLOSURE_INIT(&l->destroy_done, listener_destroy_done, server,
grpc_schedule_on_exec_ctx);
- l->destroy(&exec_ctx, server, l->arg, &l->destroy_done);
+ l->destroy(server, l->arg, &l->destroy_done);
}
- channel_broadcaster_shutdown(&exec_ctx, &broadcaster, true /* send_goaway */,
+ channel_broadcaster_shutdown(&broadcaster, true /* send_goaway */,
GRPC_ERROR_NONE);
-
-done:
- grpc_exec_ctx_finish(&exec_ctx);
}
void grpc_server_cancel_all_calls(grpc_server* server) {
channel_broadcaster broadcaster;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GRPC_API_TRACE("grpc_server_cancel_all_calls(server=%p)", 1, (server));
@@ -1284,14 +1236,13 @@ void grpc_server_cancel_all_calls(grpc_server* server) {
gpr_mu_unlock(&server->mu_global);
channel_broadcaster_shutdown(
- &exec_ctx, &broadcaster, false /* send_goaway */,
+ &broadcaster, false /* send_goaway */,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Cancelling all calls"));
- grpc_exec_ctx_finish(&exec_ctx);
}
void grpc_server_destroy(grpc_server* server) {
listener* l;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GRPC_API_TRACE("grpc_server_destroy(server=%p)", 1, (server));
@@ -1307,16 +1258,15 @@ void grpc_server_destroy(grpc_server* server) {
gpr_mu_unlock(&server->mu_global);
- server_unref(&exec_ctx, server);
- grpc_exec_ctx_finish(&exec_ctx);
+ server_unref(server);
}
-void grpc_server_add_listener(
- grpc_exec_ctx* exec_ctx, grpc_server* server, void* arg,
- void (*start)(grpc_exec_ctx* exec_ctx, grpc_server* server, void* arg,
- grpc_pollset** pollsets, size_t pollset_count),
- void (*destroy)(grpc_exec_ctx* exec_ctx, grpc_server* server, void* arg,
- grpc_closure* on_done)) {
+void grpc_server_add_listener(grpc_server* server, void* arg,
+ void (*start)(grpc_server* server, void* arg,
+ grpc_pollset** pollsets,
+ size_t pollset_count),
+ void (*destroy)(grpc_server* server, void* arg,
+ grpc_closure* on_done)) {
listener* l = (listener*)gpr_malloc(sizeof(listener));
l->arg = arg;
l->start = start;
@@ -1325,13 +1275,12 @@ void grpc_server_add_listener(
server->listeners = l;
}
-static grpc_call_error queue_call_request(grpc_exec_ctx* exec_ctx,
- grpc_server* server, size_t cq_idx,
+static grpc_call_error queue_call_request(grpc_server* server, size_t cq_idx,
requested_call* rc) {
call_data* calld = nullptr;
request_matcher* rm = nullptr;
if (gpr_atm_acq_load(&server->shutdown_flag)) {
- fail_call(exec_ctx, server, cq_idx, rc,
+ fail_call(server, cq_idx, rc,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
return GRPC_CALL_OK;
}
@@ -1358,10 +1307,9 @@ static grpc_call_error queue_call_request(grpc_exec_ctx* exec_ctx,
&calld->kill_zombie_closure, kill_zombie,
grpc_call_stack_element(grpc_call_get_call_stack(calld->call), 0),
grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_SCHED(exec_ctx, &calld->kill_zombie_closure,
- GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&calld->kill_zombie_closure, GRPC_ERROR_NONE);
} else {
- publish_call(exec_ctx, server, calld, cq_idx, rc);
+ publish_call(server, calld, cq_idx, rc);
}
gpr_mu_lock(&server->mu_call);
}
@@ -1376,9 +1324,9 @@ grpc_call_error grpc_server_request_call(
grpc_completion_queue* cq_bound_to_call,
grpc_completion_queue* cq_for_notification, void* tag) {
grpc_call_error error;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
requested_call* rc = (requested_call*)gpr_malloc(sizeof(*rc));
- GRPC_STATS_INC_SERVER_REQUESTED_CALLS(&exec_ctx);
+ GRPC_STATS_INC_SERVER_REQUESTED_CALLS();
GRPC_API_TRACE(
"grpc_server_request_call("
"server=%p, call=%p, details=%p, initial_metadata=%p, "
@@ -1411,9 +1359,9 @@ grpc_call_error grpc_server_request_call(
rc->call = call;
rc->data.batch.details = details;
rc->initial_metadata = initial_metadata;
- error = queue_call_request(&exec_ctx, server, cq_idx, rc);
+ error = queue_call_request(server, cq_idx, rc);
done:
- grpc_exec_ctx_finish(&exec_ctx);
+
return error;
}
@@ -1423,10 +1371,10 @@ grpc_call_error grpc_server_request_registered_call(
grpc_completion_queue* cq_bound_to_call,
grpc_completion_queue* cq_for_notification, void* tag) {
grpc_call_error error;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
requested_call* rc = (requested_call*)gpr_malloc(sizeof(*rc));
registered_method* rm = (registered_method*)rmp;
- GRPC_STATS_INC_SERVER_REQUESTED_CALLS(&exec_ctx);
+ GRPC_STATS_INC_SERVER_REQUESTED_CALLS();
GRPC_API_TRACE(
"grpc_server_request_registered_call("
"server=%p, rmp=%p, call=%p, deadline=%p, initial_metadata=%p, "
@@ -1468,20 +1416,20 @@ grpc_call_error grpc_server_request_registered_call(
rc->data.registered.deadline = deadline;
rc->initial_metadata = initial_metadata;
rc->data.registered.optional_payload = optional_payload;
- error = queue_call_request(&exec_ctx, server, cq_idx, rc);
+ error = queue_call_request(server, cq_idx, rc);
done:
- grpc_exec_ctx_finish(&exec_ctx);
+
return error;
}
-static void fail_call(grpc_exec_ctx* exec_ctx, grpc_server* server,
- size_t cq_idx, requested_call* rc, grpc_error* error) {
+static void fail_call(grpc_server* server, size_t cq_idx, requested_call* rc,
+ grpc_error* error) {
*rc->call = nullptr;
rc->initial_metadata->count = 0;
GPR_ASSERT(error != GRPC_ERROR_NONE);
- grpc_cq_end_op(exec_ctx, server->cqs[cq_idx], rc->tag, error,
- done_request_event, rc, &rc->completion);
+ grpc_cq_end_op(server->cqs[cq_idx], rc->tag, error, done_request_event, rc,
+ &rc->completion);
}
const grpc_channel_args* grpc_server_get_channel_args(grpc_server* server) {
diff --git a/src/core/lib/surface/server.h b/src/core/lib/surface/server.h
index e3c43f957d..dfd777e8a5 100644
--- a/src/core/lib/surface/server.h
+++ b/src/core/lib/surface/server.h
@@ -35,17 +35,16 @@ extern grpc_tracer_flag grpc_server_channel_trace;
/* Add a listener to the server: when the server starts, it will call start,
and when it shuts down, it will call destroy */
-void grpc_server_add_listener(
- grpc_exec_ctx* exec_ctx, grpc_server* server, void* listener,
- void (*start)(grpc_exec_ctx* exec_ctx, grpc_server* server, void* arg,
- grpc_pollset** pollsets, size_t npollsets),
- void (*destroy)(grpc_exec_ctx* exec_ctx, grpc_server* server, void* arg,
- grpc_closure* on_done));
+void grpc_server_add_listener(grpc_server* server, void* listener,
+ void (*start)(grpc_server* server, void* arg,
+ grpc_pollset** pollsets,
+ size_t npollsets),
+ void (*destroy)(grpc_server* server, void* arg,
+ grpc_closure* on_done));
/* Setup a transport - creates a channel stack, binds the transport to the
server */
-void grpc_server_setup_transport(grpc_exec_ctx* exec_ctx, grpc_server* server,
- grpc_transport* transport,
+void grpc_server_setup_transport(grpc_server* server, grpc_transport* transport,
grpc_pollset* accepting_pollset,
const grpc_channel_args* args);
diff --git a/src/core/lib/transport/bdp_estimator.cc b/src/core/lib/transport/bdp_estimator.cc
index e09ae8e6a6..d2b6e5db25 100644
--- a/src/core/lib/transport/bdp_estimator.cc
+++ b/src/core/lib/transport/bdp_estimator.cc
@@ -38,7 +38,7 @@ BdpEstimator::BdpEstimator(const char* name)
bw_est_(0),
name_(name) {}
-grpc_millis BdpEstimator::CompletePing(grpc_exec_ctx* exec_ctx) {
+grpc_millis BdpEstimator::CompletePing() {
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
gpr_timespec dt_ts = gpr_time_sub(now, ping_start_time_);
double dt = (double)dt_ts.tv_sec + 1e-9 * (double)dt_ts.tv_nsec;
@@ -79,7 +79,7 @@ grpc_millis BdpEstimator::CompletePing(grpc_exec_ctx* exec_ctx) {
}
ping_state_ = PingState::UNSCHEDULED;
accumulator_ = 0;
- return grpc_exec_ctx_now(exec_ctx) + inter_ping_delay_;
+ return grpc_core::ExecCtx::Get()->Now() + inter_ping_delay_;
}
} // namespace grpc_core
diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h
index f7b94a81d3..431d4b845c 100644
--- a/src/core/lib/transport/bdp_estimator.h
+++ b/src/core/lib/transport/bdp_estimator.h
@@ -73,7 +73,7 @@ class BdpEstimator {
}
// Completes a previously started ping, returns when to schedule the next one
- grpc_millis CompletePing(grpc_exec_ctx* exec_ctx);
+ grpc_millis CompletePing();
private:
enum class PingState { UNSCHEDULED, SCHEDULED, STARTED };
diff --git a/src/core/lib/transport/byte_stream.cc b/src/core/lib/transport/byte_stream.cc
index b8720250e7..8dcb1e0bdb 100644
--- a/src/core/lib/transport/byte_stream.cc
+++ b/src/core/lib/transport/byte_stream.cc
@@ -25,34 +25,28 @@
#include "src/core/lib/slice/slice_internal.h"
-bool grpc_byte_stream_next(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream, size_t max_size_hint,
+bool grpc_byte_stream_next(grpc_byte_stream* byte_stream, size_t max_size_hint,
grpc_closure* on_complete) {
- return byte_stream->vtable->next(exec_ctx, byte_stream, max_size_hint,
- on_complete);
+ return byte_stream->vtable->next(byte_stream, max_size_hint, on_complete);
}
-grpc_error* grpc_byte_stream_pull(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream,
+grpc_error* grpc_byte_stream_pull(grpc_byte_stream* byte_stream,
grpc_slice* slice) {
- return byte_stream->vtable->pull(exec_ctx, byte_stream, slice);
+ return byte_stream->vtable->pull(byte_stream, slice);
}
-void grpc_byte_stream_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream,
+void grpc_byte_stream_shutdown(grpc_byte_stream* byte_stream,
grpc_error* error) {
- byte_stream->vtable->shutdown(exec_ctx, byte_stream, error);
+ byte_stream->vtable->shutdown(byte_stream, error);
}
-void grpc_byte_stream_destroy(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream) {
- byte_stream->vtable->destroy(exec_ctx, byte_stream);
+void grpc_byte_stream_destroy(grpc_byte_stream* byte_stream) {
+ byte_stream->vtable->destroy(byte_stream);
}
// grpc_slice_buffer_stream
-static bool slice_buffer_stream_next(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream,
+static bool slice_buffer_stream_next(grpc_byte_stream* byte_stream,
size_t max_size_hint,
grpc_closure* on_complete) {
grpc_slice_buffer_stream* stream = (grpc_slice_buffer_stream*)byte_stream;
@@ -60,8 +54,7 @@ static bool slice_buffer_stream_next(grpc_exec_ctx* exec_ctx,
return true;
}
-static grpc_error* slice_buffer_stream_pull(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream,
+static grpc_error* slice_buffer_stream_pull(grpc_byte_stream* byte_stream,
grpc_slice* slice) {
grpc_slice_buffer_stream* stream = (grpc_slice_buffer_stream*)byte_stream;
if (stream->shutdown_error != GRPC_ERROR_NONE) {
@@ -74,18 +67,16 @@ static grpc_error* slice_buffer_stream_pull(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-static void slice_buffer_stream_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream,
+static void slice_buffer_stream_shutdown(grpc_byte_stream* byte_stream,
grpc_error* error) {
grpc_slice_buffer_stream* stream = (grpc_slice_buffer_stream*)byte_stream;
GRPC_ERROR_UNREF(stream->shutdown_error);
stream->shutdown_error = error;
}
-static void slice_buffer_stream_destroy(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream) {
+static void slice_buffer_stream_destroy(grpc_byte_stream* byte_stream) {
grpc_slice_buffer_stream* stream = (grpc_slice_buffer_stream*)byte_stream;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, stream->backing_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(stream->backing_buffer);
GRPC_ERROR_UNREF(stream->shutdown_error);
}
@@ -113,25 +104,22 @@ void grpc_byte_stream_cache_init(grpc_byte_stream_cache* cache,
grpc_slice_buffer_init(&cache->cache_buffer);
}
-void grpc_byte_stream_cache_destroy(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream_cache* cache) {
- grpc_byte_stream_destroy(exec_ctx, cache->underlying_stream);
- grpc_slice_buffer_destroy_internal(exec_ctx, &cache->cache_buffer);
+void grpc_byte_stream_cache_destroy(grpc_byte_stream_cache* cache) {
+ grpc_byte_stream_destroy(cache->underlying_stream);
+ grpc_slice_buffer_destroy_internal(&cache->cache_buffer);
}
-static bool caching_byte_stream_next(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream,
+static bool caching_byte_stream_next(grpc_byte_stream* byte_stream,
size_t max_size_hint,
grpc_closure* on_complete) {
grpc_caching_byte_stream* stream = (grpc_caching_byte_stream*)byte_stream;
if (stream->shutdown_error != GRPC_ERROR_NONE) return true;
if (stream->cursor < stream->cache->cache_buffer.count) return true;
- return grpc_byte_stream_next(exec_ctx, stream->cache->underlying_stream,
- max_size_hint, on_complete);
+ return grpc_byte_stream_next(stream->cache->underlying_stream, max_size_hint,
+ on_complete);
}
-static grpc_error* caching_byte_stream_pull(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream,
+static grpc_error* caching_byte_stream_pull(grpc_byte_stream* byte_stream,
grpc_slice* slice) {
grpc_caching_byte_stream* stream = (grpc_caching_byte_stream*)byte_stream;
if (stream->shutdown_error != GRPC_ERROR_NONE) {
@@ -144,7 +132,7 @@ static grpc_error* caching_byte_stream_pull(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
grpc_error* error =
- grpc_byte_stream_pull(exec_ctx, stream->cache->underlying_stream, slice);
+ grpc_byte_stream_pull(stream->cache->underlying_stream, slice);
if (error == GRPC_ERROR_NONE) {
++stream->cursor;
grpc_slice_buffer_add(&stream->cache->cache_buffer,
@@ -153,17 +141,15 @@ static grpc_error* caching_byte_stream_pull(grpc_exec_ctx* exec_ctx,
return error;
}
-static void caching_byte_stream_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream,
+static void caching_byte_stream_shutdown(grpc_byte_stream* byte_stream,
grpc_error* error) {
grpc_caching_byte_stream* stream = (grpc_caching_byte_stream*)byte_stream;
GRPC_ERROR_UNREF(stream->shutdown_error);
stream->shutdown_error = GRPC_ERROR_REF(error);
- grpc_byte_stream_shutdown(exec_ctx, stream->cache->underlying_stream, error);
+ grpc_byte_stream_shutdown(stream->cache->underlying_stream, error);
}
-static void caching_byte_stream_destroy(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream) {
+static void caching_byte_stream_destroy(grpc_byte_stream* byte_stream) {
grpc_caching_byte_stream* stream = (grpc_caching_byte_stream*)byte_stream;
GRPC_ERROR_UNREF(stream->shutdown_error);
}
diff --git a/src/core/lib/transport/byte_stream.h b/src/core/lib/transport/byte_stream.h
index 54ad4b9796..cec8c91624 100644
--- a/src/core/lib/transport/byte_stream.h
+++ b/src/core/lib/transport/byte_stream.h
@@ -35,13 +35,11 @@ extern "C" {
typedef struct grpc_byte_stream grpc_byte_stream;
typedef struct {
- bool (*next)(grpc_exec_ctx* exec_ctx, grpc_byte_stream* byte_stream,
- size_t max_size_hint, grpc_closure* on_complete);
- grpc_error* (*pull)(grpc_exec_ctx* exec_ctx, grpc_byte_stream* byte_stream,
- grpc_slice* slice);
- void (*shutdown)(grpc_exec_ctx* exec_ctx, grpc_byte_stream* byte_stream,
- grpc_error* error);
- void (*destroy)(grpc_exec_ctx* exec_ctx, grpc_byte_stream* byte_stream);
+ bool (*next)(grpc_byte_stream* byte_stream, size_t max_size_hint,
+ grpc_closure* on_complete);
+ grpc_error* (*pull)(grpc_byte_stream* byte_stream, grpc_slice* slice);
+ void (*shutdown)(grpc_byte_stream* byte_stream, grpc_error* error);
+ void (*destroy)(grpc_byte_stream* byte_stream);
} grpc_byte_stream_vtable;
struct grpc_byte_stream {
@@ -56,8 +54,7 @@ struct grpc_byte_stream {
//
// max_size_hint can be set as a hint as to the maximum number
// of bytes that would be acceptable to read.
-bool grpc_byte_stream_next(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream, size_t max_size_hint,
+bool grpc_byte_stream_next(grpc_byte_stream* byte_stream, size_t max_size_hint,
grpc_closure* on_complete);
// Returns the next slice in the byte stream when it is ready (indicated by
@@ -65,8 +62,7 @@ bool grpc_byte_stream_next(grpc_exec_ctx* exec_ctx,
// grpc_byte_stream_next is called).
//
// Once a slice is returned into *slice, it is owned by the caller.
-grpc_error* grpc_byte_stream_pull(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream,
+grpc_error* grpc_byte_stream_pull(grpc_byte_stream* byte_stream,
grpc_slice* slice);
// Shuts down the byte stream.
@@ -76,12 +72,10 @@ grpc_error* grpc_byte_stream_pull(grpc_exec_ctx* exec_ctx,
//
// The next call to grpc_byte_stream_pull() (if any) will return the error
// passed to grpc_byte_stream_shutdown().
-void grpc_byte_stream_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream,
+void grpc_byte_stream_shutdown(grpc_byte_stream* byte_stream,
grpc_error* error);
-void grpc_byte_stream_destroy(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream* byte_stream);
+void grpc_byte_stream_destroy(grpc_byte_stream* byte_stream);
// grpc_slice_buffer_stream
//
@@ -123,8 +117,7 @@ void grpc_byte_stream_cache_init(grpc_byte_stream_cache* cache,
grpc_byte_stream* underlying_stream);
// Must not be called while still in use by a grpc_caching_byte_stream.
-void grpc_byte_stream_cache_destroy(grpc_exec_ctx* exec_ctx,
- grpc_byte_stream_cache* cache);
+void grpc_byte_stream_cache_destroy(grpc_byte_stream_cache* cache);
typedef struct {
grpc_byte_stream base;
diff --git a/src/core/lib/transport/connectivity_state.cc b/src/core/lib/transport/connectivity_state.cc
index 55f4236d57..51ee20d7b0 100644
--- a/src/core/lib/transport/connectivity_state.cc
+++ b/src/core/lib/transport/connectivity_state.cc
@@ -52,8 +52,7 @@ void grpc_connectivity_state_init(grpc_connectivity_state_tracker* tracker,
tracker->name = gpr_strdup(name);
}
-void grpc_connectivity_state_destroy(grpc_exec_ctx* exec_ctx,
- grpc_connectivity_state_tracker* tracker) {
+void grpc_connectivity_state_destroy(grpc_connectivity_state_tracker* tracker) {
grpc_error* error;
grpc_connectivity_state_watcher* w;
while ((w = tracker->watchers)) {
@@ -66,7 +65,7 @@ void grpc_connectivity_state_destroy(grpc_exec_ctx* exec_ctx,
error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Shutdown connectivity owner");
}
- GRPC_CLOSURE_SCHED(exec_ctx, w->notify, error);
+ GRPC_CLOSURE_SCHED(w->notify, error);
gpr_free(w);
}
GRPC_ERROR_UNREF(tracker->current_error);
@@ -106,8 +105,8 @@ bool grpc_connectivity_state_has_watchers(
}
bool grpc_connectivity_state_notify_on_state_change(
- grpc_exec_ctx* exec_ctx, grpc_connectivity_state_tracker* tracker,
- grpc_connectivity_state* current, grpc_closure* notify) {
+ grpc_connectivity_state_tracker* tracker, grpc_connectivity_state* current,
+ grpc_closure* notify) {
grpc_connectivity_state cur =
(grpc_connectivity_state)gpr_atm_no_barrier_load(
&tracker->current_state_atm);
@@ -124,7 +123,7 @@ bool grpc_connectivity_state_notify_on_state_change(
if (current == nullptr) {
grpc_connectivity_state_watcher* w = tracker->watchers;
if (w != nullptr && w->notify == notify) {
- GRPC_CLOSURE_SCHED(exec_ctx, notify, GRPC_ERROR_CANCELLED);
+ GRPC_CLOSURE_SCHED(notify, GRPC_ERROR_CANCELLED);
tracker->watchers = w->next;
gpr_free(w);
return false;
@@ -132,7 +131,7 @@ bool grpc_connectivity_state_notify_on_state_change(
while (w != nullptr) {
grpc_connectivity_state_watcher* rm_candidate = w->next;
if (rm_candidate != nullptr && rm_candidate->notify == notify) {
- GRPC_CLOSURE_SCHED(exec_ctx, notify, GRPC_ERROR_CANCELLED);
+ GRPC_CLOSURE_SCHED(notify, GRPC_ERROR_CANCELLED);
w->next = w->next->next;
gpr_free(rm_candidate);
return false;
@@ -143,8 +142,7 @@ bool grpc_connectivity_state_notify_on_state_change(
} else {
if (cur != *current) {
*current = cur;
- GRPC_CLOSURE_SCHED(exec_ctx, notify,
- GRPC_ERROR_REF(tracker->current_error));
+ GRPC_CLOSURE_SCHED(notify, GRPC_ERROR_REF(tracker->current_error));
} else {
grpc_connectivity_state_watcher* w =
(grpc_connectivity_state_watcher*)gpr_malloc(sizeof(*w));
@@ -157,8 +155,7 @@ bool grpc_connectivity_state_notify_on_state_change(
}
}
-void grpc_connectivity_state_set(grpc_exec_ctx* exec_ctx,
- grpc_connectivity_state_tracker* tracker,
+void grpc_connectivity_state_set(grpc_connectivity_state_tracker* tracker,
grpc_connectivity_state state,
grpc_error* error, const char* reason) {
grpc_connectivity_state cur =
@@ -196,8 +193,7 @@ void grpc_connectivity_state_set(grpc_exec_ctx* exec_ctx,
gpr_log(GPR_DEBUG, "NOTIFY: %p %s: %p", tracker, tracker->name,
w->notify);
}
- GRPC_CLOSURE_SCHED(exec_ctx, w->notify,
- GRPC_ERROR_REF(tracker->current_error));
+ GRPC_CLOSURE_SCHED(w->notify, GRPC_ERROR_REF(tracker->current_error));
gpr_free(w);
}
}
diff --git a/src/core/lib/transport/connectivity_state.h b/src/core/lib/transport/connectivity_state.h
index 792e27c43d..83ce99e6d6 100644
--- a/src/core/lib/transport/connectivity_state.h
+++ b/src/core/lib/transport/connectivity_state.h
@@ -55,13 +55,11 @@ const char* grpc_connectivity_state_name(grpc_connectivity_state state);
void grpc_connectivity_state_init(grpc_connectivity_state_tracker* tracker,
grpc_connectivity_state init_state,
const char* name);
-void grpc_connectivity_state_destroy(grpc_exec_ctx* exec_ctx,
- grpc_connectivity_state_tracker* tracker);
+void grpc_connectivity_state_destroy(grpc_connectivity_state_tracker* tracker);
/** Set connectivity state; not thread safe; access must be serialized with an
* external lock */
-void grpc_connectivity_state_set(grpc_exec_ctx* exec_ctx,
- grpc_connectivity_state_tracker* tracker,
+void grpc_connectivity_state_set(grpc_connectivity_state_tracker* tracker,
grpc_connectivity_state state,
grpc_error* associated_error,
const char* reason);
@@ -85,8 +83,8 @@ grpc_connectivity_state grpc_connectivity_state_get(
case).
Access must be serialized with an external lock. */
bool grpc_connectivity_state_notify_on_state_change(
- grpc_exec_ctx* exec_ctx, grpc_connectivity_state_tracker* tracker,
- grpc_connectivity_state* current, grpc_closure* notify);
+ grpc_connectivity_state_tracker* tracker, grpc_connectivity_state* current,
+ grpc_closure* notify);
#ifdef __cplusplus
}
diff --git a/src/core/lib/transport/error_utils.cc b/src/core/lib/transport/error_utils.cc
index 19510b4c8d..2db87b5d29 100644
--- a/src/core/lib/transport/error_utils.cc
+++ b/src/core/lib/transport/error_utils.cc
@@ -39,9 +39,8 @@ static grpc_error* recursively_find_error_with_field(grpc_error* error,
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,
+void grpc_error_get_status(grpc_error* error, grpc_millis deadline,
+ grpc_status_code* code, grpc_slice* slice,
grpc_http2_error_code* http_error) {
// Start with the parent error and recurse through the tree of children
// until we find the first one that has a status code.
@@ -64,8 +63,8 @@ void grpc_error_get_status(grpc_exec_ctx* exec_ctx, grpc_error* error,
status = (grpc_status_code)integer;
} else if (grpc_error_get_int(found_error, GRPC_ERROR_INT_HTTP2_ERROR,
&integer)) {
- status = grpc_http2_error_to_grpc_status(
- exec_ctx, (grpc_http2_error_code)integer, deadline);
+ status = grpc_http2_error_to_grpc_status((grpc_http2_error_code)integer,
+ deadline);
}
if (code != nullptr) *code = status;
diff --git a/src/core/lib/transport/error_utils.h b/src/core/lib/transport/error_utils.h
index 690e42058a..73ca7cf3ab 100644
--- a/src/core/lib/transport/error_utils.h
+++ b/src/core/lib/transport/error_utils.h
@@ -33,9 +33,8 @@ extern "C" {
/// 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
/// NULL.
-void grpc_error_get_status(grpc_exec_ctx* exec_ctx, grpc_error* error,
- grpc_millis deadline, grpc_status_code* code,
- grpc_slice* slice,
+void grpc_error_get_status(grpc_error* error, grpc_millis deadline,
+ grpc_status_code* code, grpc_slice* slice,
grpc_http2_error_code* http_status);
/// A utility function to check whether there is a clear status code that
diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc
index a16f0508f0..7596afa59b 100644
--- a/src/core/lib/transport/metadata.cc
+++ b/src/core/lib/transport/metadata.cc
@@ -108,7 +108,7 @@ typedef struct mdtab_shard {
static mdtab_shard g_shards[SHARD_COUNT];
-static void gc_mdtab(grpc_exec_ctx* exec_ctx, mdtab_shard* shard);
+static void gc_mdtab(mdtab_shard* shard);
void grpc_mdctx_global_init(void) {
/* initialize shards */
@@ -123,11 +123,11 @@ void grpc_mdctx_global_init(void) {
}
}
-void grpc_mdctx_global_shutdown(grpc_exec_ctx* exec_ctx) {
+void grpc_mdctx_global_shutdown() {
for (size_t i = 0; i < SHARD_COUNT; i++) {
mdtab_shard* shard = &g_shards[i];
gpr_mu_destroy(&shard->mu);
- gc_mdtab(exec_ctx, shard);
+ gc_mdtab(shard);
/* TODO(ctiller): GPR_ASSERT(shard->count == 0); */
if (shard->count != 0) {
gpr_log(GPR_DEBUG, "WARNING: %" PRIuPTR " metadata elements were leaked",
@@ -165,7 +165,7 @@ static void ref_md_locked(mdtab_shard* shard,
}
}
-static void gc_mdtab(grpc_exec_ctx* exec_ctx, mdtab_shard* shard) {
+static void gc_mdtab(mdtab_shard* shard) {
size_t i;
interned_metadata** prev_next;
interned_metadata *md, *next;
@@ -178,8 +178,8 @@ static void gc_mdtab(grpc_exec_ctx* exec_ctx, mdtab_shard* shard) {
void* user_data = (void*)gpr_atm_no_barrier_load(&md->user_data);
next = md->bucket_next;
if (gpr_atm_acq_load(&md->refcnt) == 0) {
- grpc_slice_unref_internal(exec_ctx, md->key);
- grpc_slice_unref_internal(exec_ctx, md->value);
+ grpc_slice_unref_internal(md->key);
+ grpc_slice_unref_internal(md->value);
if (md->user_data) {
((destroy_user_data_func)gpr_atm_no_barrier_load(
&md->destroy_user_data))(user_data);
@@ -228,17 +228,17 @@ static void grow_mdtab(mdtab_shard* shard) {
GPR_TIMER_END("grow_mdtab", 0);
}
-static void rehash_mdtab(grpc_exec_ctx* exec_ctx, mdtab_shard* shard) {
+static void rehash_mdtab(mdtab_shard* shard) {
if (gpr_atm_no_barrier_load(&shard->free_estimate) >
(gpr_atm)(shard->capacity / 4)) {
- gc_mdtab(exec_ctx, shard);
+ gc_mdtab(shard);
} else {
grow_mdtab(shard);
}
}
grpc_mdelem grpc_mdelem_create(
- grpc_exec_ctx* exec_ctx, grpc_slice key, grpc_slice value,
+ grpc_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 != nullptr) {
@@ -318,7 +318,7 @@ grpc_mdelem grpc_mdelem_create(
shard->count++;
if (shard->count > shard->capacity * 2) {
- rehash_mdtab(exec_ctx, shard);
+ rehash_mdtab(shard);
}
gpr_mu_unlock(&shard->mu);
@@ -328,22 +328,20 @@ grpc_mdelem grpc_mdelem_create(
return GRPC_MAKE_MDELEM(md, GRPC_MDELEM_STORAGE_INTERNED);
}
-grpc_mdelem grpc_mdelem_from_slices(grpc_exec_ctx* exec_ctx, grpc_slice key,
- grpc_slice value) {
- grpc_mdelem out = grpc_mdelem_create(exec_ctx, key, value, nullptr);
- grpc_slice_unref_internal(exec_ctx, key);
- grpc_slice_unref_internal(exec_ctx, value);
+grpc_mdelem grpc_mdelem_from_slices(grpc_slice key, grpc_slice value) {
+ grpc_mdelem out = grpc_mdelem_create(key, value, nullptr);
+ grpc_slice_unref_internal(key);
+ grpc_slice_unref_internal(value);
return out;
}
-grpc_mdelem grpc_mdelem_from_grpc_metadata(grpc_exec_ctx* exec_ctx,
- grpc_metadata* metadata) {
+grpc_mdelem grpc_mdelem_from_grpc_metadata(grpc_metadata* metadata) {
bool changed = false;
grpc_slice key_slice =
grpc_slice_maybe_static_intern(metadata->key, &changed);
grpc_slice value_slice =
grpc_slice_maybe_static_intern(metadata->value, &changed);
- return grpc_mdelem_create(exec_ctx, key_slice, value_slice,
+ return grpc_mdelem_create(key_slice, value_slice,
changed ? nullptr : (grpc_mdelem_data*)metadata);
}
@@ -417,7 +415,7 @@ grpc_mdelem grpc_mdelem_ref(grpc_mdelem gmd DEBUG_ARGS) {
return gmd;
}
-void grpc_mdelem_unref(grpc_exec_ctx* exec_ctx, grpc_mdelem gmd DEBUG_ARGS) {
+void grpc_mdelem_unref(grpc_mdelem gmd DEBUG_ARGS) {
switch (GRPC_MDELEM_STORAGE(gmd)) {
case GRPC_MDELEM_STORAGE_EXTERNAL:
case GRPC_MDELEM_STORAGE_STATIC:
@@ -465,8 +463,8 @@ void grpc_mdelem_unref(grpc_exec_ctx* exec_ctx, grpc_mdelem gmd DEBUG_ARGS) {
const gpr_atm prev_refcount = gpr_atm_full_fetch_add(&md->refcnt, -1);
GPR_ASSERT(prev_refcount >= 1);
if (1 == prev_refcount) {
- grpc_slice_unref_internal(exec_ctx, md->key);
- grpc_slice_unref_internal(exec_ctx, md->value);
+ grpc_slice_unref_internal(md->key);
+ grpc_slice_unref_internal(md->value);
gpr_free(md);
}
break;
diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h
index 7e7e7b4c14..552eabf9b7 100644
--- a/src/core/lib/transport/metadata.h
+++ b/src/core/lib/transport/metadata.h
@@ -113,20 +113,18 @@ struct grpc_mdelem {
(uintptr_t)GRPC_MDELEM_STORAGE_INTERNED_BIT))
/* Unrefs the slices. */
-grpc_mdelem grpc_mdelem_from_slices(grpc_exec_ctx* exec_ctx, grpc_slice key,
- grpc_slice value);
+grpc_mdelem grpc_mdelem_from_slices(grpc_slice key, grpc_slice value);
/* Cheaply convert a grpc_metadata to a grpc_mdelem; may use the grpc_metadata
object as backing storage (so lifetimes should align) */
-grpc_mdelem grpc_mdelem_from_grpc_metadata(grpc_exec_ctx* exec_ctx,
- grpc_metadata* metadata);
+grpc_mdelem grpc_mdelem_from_grpc_metadata(grpc_metadata* metadata);
/* Does not unref the slices; if a new non-interned mdelem is needed, allocates
one if compatible_external_backing_store is NULL, or uses
compatible_external_backing_store if it is non-NULL (in which case it's the
users responsibility to ensure that it outlives usage) */
grpc_mdelem grpc_mdelem_create(
- grpc_exec_ctx* exec_ctx, grpc_slice key, grpc_slice value,
+ grpc_slice key, grpc_slice value,
grpc_mdelem_data* compatible_external_backing_store);
bool grpc_mdelem_eq(grpc_mdelem a, grpc_mdelem b);
@@ -142,16 +140,14 @@ void* grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void*),
#ifndef NDEBUG
#define GRPC_MDELEM_REF(s) grpc_mdelem_ref((s), __FILE__, __LINE__)
-#define GRPC_MDELEM_UNREF(exec_ctx, s) \
- grpc_mdelem_unref((exec_ctx), (s), __FILE__, __LINE__)
+#define GRPC_MDELEM_UNREF(s) grpc_mdelem_unref((s), __FILE__, __LINE__)
grpc_mdelem grpc_mdelem_ref(grpc_mdelem md, const char* file, int line);
-void grpc_mdelem_unref(grpc_exec_ctx* exec_ctx, grpc_mdelem md,
- const char* file, int line);
+void grpc_mdelem_unref(grpc_mdelem md, const char* file, int line);
#else
#define GRPC_MDELEM_REF(s) grpc_mdelem_ref((s))
-#define GRPC_MDELEM_UNREF(exec_ctx, s) grpc_mdelem_unref((exec_ctx), (s))
+#define GRPC_MDELEM_UNREF(s) grpc_mdelem_unref((s))
grpc_mdelem grpc_mdelem_ref(grpc_mdelem md);
-void grpc_mdelem_unref(grpc_exec_ctx* exec_ctx, grpc_mdelem md);
+void grpc_mdelem_unref(grpc_mdelem md);
#endif
#define GRPC_MDKEY(md) (GRPC_MDELEM_DATA(md)->key)
@@ -168,7 +164,7 @@ void grpc_mdelem_unref(grpc_exec_ctx* exec_ctx, grpc_mdelem md);
#define GRPC_MDSTR_KV_HASH(k_hash, v_hash) (GPR_ROTL((k_hash), 2) ^ (v_hash))
void grpc_mdctx_global_init(void);
-void grpc_mdctx_global_shutdown(grpc_exec_ctx* exec_ctx);
+void grpc_mdctx_global_shutdown();
#ifdef __cplusplus
}
diff --git a/src/core/lib/transport/metadata_batch.cc b/src/core/lib/transport/metadata_batch.cc
index 5817765aa3..9c95339ba0 100644
--- a/src/core/lib/transport/metadata_batch.cc
+++ b/src/core/lib/transport/metadata_batch.cc
@@ -51,8 +51,7 @@ static void assert_valid_list(grpc_mdelem_list* list) {
#endif /* NDEBUG */
}
-static void assert_valid_callouts(grpc_exec_ctx* exec_ctx,
- grpc_metadata_batch* batch) {
+static void assert_valid_callouts(grpc_metadata_batch* batch) {
#ifndef NDEBUG
for (grpc_linked_mdelem* l = batch->list.head; l != nullptr; l = l->next) {
grpc_slice key_interned = grpc_slice_intern(GRPC_MDKEY(l->md));
@@ -61,7 +60,7 @@ static void assert_valid_callouts(grpc_exec_ctx* exec_ctx,
if (callout_idx != GRPC_BATCH_CALLOUTS_COUNT) {
GPR_ASSERT(batch->idx.array[callout_idx] == l);
}
- grpc_slice_unref_internal(exec_ctx, key_interned);
+ grpc_slice_unref_internal(key_interned);
}
#endif
}
@@ -77,11 +76,10 @@ void grpc_metadata_batch_init(grpc_metadata_batch* batch) {
batch->deadline = GRPC_MILLIS_INF_FUTURE;
}
-void grpc_metadata_batch_destroy(grpc_exec_ctx* exec_ctx,
- grpc_metadata_batch* batch) {
+void grpc_metadata_batch_destroy(grpc_metadata_batch* batch) {
grpc_linked_mdelem* l;
for (l = batch->list.head; l; l = l->next) {
- GRPC_MDELEM_UNREF(exec_ctx, l->md);
+ GRPC_MDELEM_UNREF(l->md);
}
}
@@ -126,13 +124,12 @@ static void maybe_unlink_callout(grpc_metadata_batch* batch,
batch->idx.array[idx] = nullptr;
}
-grpc_error* grpc_metadata_batch_add_head(grpc_exec_ctx* exec_ctx,
- grpc_metadata_batch* batch,
+grpc_error* grpc_metadata_batch_add_head(grpc_metadata_batch* batch,
grpc_linked_mdelem* storage,
grpc_mdelem elem_to_add) {
GPR_ASSERT(!GRPC_MDISNULL(elem_to_add));
storage->md = elem_to_add;
- return grpc_metadata_batch_link_head(exec_ctx, batch, storage);
+ return grpc_metadata_batch_link_head(batch, storage);
}
static void link_head(grpc_mdelem_list* list, grpc_linked_mdelem* storage) {
@@ -150,27 +147,25 @@ static void link_head(grpc_mdelem_list* list, grpc_linked_mdelem* storage) {
assert_valid_list(list);
}
-grpc_error* grpc_metadata_batch_link_head(grpc_exec_ctx* exec_ctx,
- grpc_metadata_batch* batch,
+grpc_error* grpc_metadata_batch_link_head(grpc_metadata_batch* batch,
grpc_linked_mdelem* storage) {
- assert_valid_callouts(exec_ctx, batch);
+ assert_valid_callouts(batch);
grpc_error* err = maybe_link_callout(batch, storage);
if (err != GRPC_ERROR_NONE) {
- assert_valid_callouts(exec_ctx, batch);
+ assert_valid_callouts(batch);
return err;
}
link_head(&batch->list, storage);
- assert_valid_callouts(exec_ctx, batch);
+ assert_valid_callouts(batch);
return GRPC_ERROR_NONE;
}
-grpc_error* grpc_metadata_batch_add_tail(grpc_exec_ctx* exec_ctx,
- grpc_metadata_batch* batch,
+grpc_error* grpc_metadata_batch_add_tail(grpc_metadata_batch* batch,
grpc_linked_mdelem* storage,
grpc_mdelem elem_to_add) {
GPR_ASSERT(!GRPC_MDISNULL(elem_to_add));
storage->md = elem_to_add;
- return grpc_metadata_batch_link_tail(exec_ctx, batch, storage);
+ return grpc_metadata_batch_link_tail(batch, storage);
}
static void link_tail(grpc_mdelem_list* list, grpc_linked_mdelem* storage) {
@@ -189,17 +184,16 @@ static void link_tail(grpc_mdelem_list* list, grpc_linked_mdelem* storage) {
assert_valid_list(list);
}
-grpc_error* grpc_metadata_batch_link_tail(grpc_exec_ctx* exec_ctx,
- grpc_metadata_batch* batch,
+grpc_error* grpc_metadata_batch_link_tail(grpc_metadata_batch* batch,
grpc_linked_mdelem* storage) {
- assert_valid_callouts(exec_ctx, batch);
+ assert_valid_callouts(batch);
grpc_error* err = maybe_link_callout(batch, storage);
if (err != GRPC_ERROR_NONE) {
- assert_valid_callouts(exec_ctx, batch);
+ assert_valid_callouts(batch);
return err;
}
link_tail(&batch->list, storage);
- assert_valid_callouts(exec_ctx, batch);
+ assert_valid_callouts(batch);
return GRPC_ERROR_NONE;
}
@@ -220,31 +214,28 @@ static void unlink_storage(grpc_mdelem_list* list,
assert_valid_list(list);
}
-void grpc_metadata_batch_remove(grpc_exec_ctx* exec_ctx,
- grpc_metadata_batch* batch,
+void grpc_metadata_batch_remove(grpc_metadata_batch* batch,
grpc_linked_mdelem* storage) {
- assert_valid_callouts(exec_ctx, batch);
+ assert_valid_callouts(batch);
maybe_unlink_callout(batch, storage);
unlink_storage(&batch->list, storage);
- GRPC_MDELEM_UNREF(exec_ctx, storage->md);
- assert_valid_callouts(exec_ctx, batch);
+ GRPC_MDELEM_UNREF(storage->md);
+ assert_valid_callouts(batch);
}
-void grpc_metadata_batch_set_value(grpc_exec_ctx* exec_ctx,
- grpc_linked_mdelem* storage,
+void grpc_metadata_batch_set_value(grpc_linked_mdelem* storage,
grpc_slice value) {
grpc_mdelem old_mdelem = storage->md;
grpc_mdelem new_mdelem = grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_ref_internal(GRPC_MDKEY(old_mdelem)), value);
+ grpc_slice_ref_internal(GRPC_MDKEY(old_mdelem)), value);
storage->md = new_mdelem;
- GRPC_MDELEM_UNREF(exec_ctx, old_mdelem);
+ GRPC_MDELEM_UNREF(old_mdelem);
}
-grpc_error* grpc_metadata_batch_substitute(grpc_exec_ctx* exec_ctx,
- grpc_metadata_batch* batch,
+grpc_error* grpc_metadata_batch_substitute(grpc_metadata_batch* batch,
grpc_linked_mdelem* storage,
grpc_mdelem new_mdelem) {
- assert_valid_callouts(exec_ctx, batch);
+ assert_valid_callouts(batch);
grpc_error* error = GRPC_ERROR_NONE;
grpc_mdelem old_mdelem = storage->md;
if (!grpc_slice_eq(GRPC_MDKEY(new_mdelem), GRPC_MDKEY(old_mdelem))) {
@@ -253,19 +244,18 @@ grpc_error* grpc_metadata_batch_substitute(grpc_exec_ctx* exec_ctx,
error = maybe_link_callout(batch, storage);
if (error != GRPC_ERROR_NONE) {
unlink_storage(&batch->list, storage);
- GRPC_MDELEM_UNREF(exec_ctx, storage->md);
+ GRPC_MDELEM_UNREF(storage->md);
}
} else {
storage->md = new_mdelem;
}
- GRPC_MDELEM_UNREF(exec_ctx, old_mdelem);
- assert_valid_callouts(exec_ctx, batch);
+ GRPC_MDELEM_UNREF(old_mdelem);
+ assert_valid_callouts(batch);
return error;
}
-void grpc_metadata_batch_clear(grpc_exec_ctx* exec_ctx,
- grpc_metadata_batch* batch) {
- grpc_metadata_batch_destroy(exec_ctx, batch);
+void grpc_metadata_batch_clear(grpc_metadata_batch* batch) {
+ grpc_metadata_batch_destroy(batch);
grpc_metadata_batch_init(batch);
}
@@ -292,8 +282,7 @@ static void add_error(grpc_error** composite, grpc_error* error,
*composite = grpc_error_add_child(*composite, error);
}
-grpc_error* grpc_metadata_batch_filter(grpc_exec_ctx* exec_ctx,
- grpc_metadata_batch* batch,
+grpc_error* grpc_metadata_batch_filter(grpc_metadata_batch* batch,
grpc_metadata_batch_filter_func func,
void* user_data,
const char* composite_error_string) {
@@ -301,12 +290,12 @@ grpc_error* grpc_metadata_batch_filter(grpc_exec_ctx* exec_ctx,
grpc_error* error = GRPC_ERROR_NONE;
while (l) {
grpc_linked_mdelem* next = l->next;
- grpc_filtered_mdelem new_mdelem = func(exec_ctx, user_data, l->md);
+ grpc_filtered_mdelem new_mdelem = func(user_data, l->md);
add_error(&error, new_mdelem.error, composite_error_string);
if (GRPC_MDISNULL(new_mdelem.md)) {
- grpc_metadata_batch_remove(exec_ctx, batch, l);
+ grpc_metadata_batch_remove(batch, l);
} else if (new_mdelem.md.payload != l->md.payload) {
- grpc_metadata_batch_substitute(exec_ctx, batch, l, new_mdelem.md);
+ grpc_metadata_batch_substitute(batch, l, new_mdelem.md);
}
l = next;
}
diff --git a/src/core/lib/transport/metadata_batch.h b/src/core/lib/transport/metadata_batch.h
index 7d17393249..e367f61cfd 100644
--- a/src/core/lib/transport/metadata_batch.h
+++ b/src/core/lib/transport/metadata_batch.h
@@ -57,28 +57,23 @@ typedef struct grpc_metadata_batch {
} grpc_metadata_batch;
void grpc_metadata_batch_init(grpc_metadata_batch* batch);
-void grpc_metadata_batch_destroy(grpc_exec_ctx* exec_ctx,
- grpc_metadata_batch* batch);
-void grpc_metadata_batch_clear(grpc_exec_ctx* exec_ctx,
- grpc_metadata_batch* batch);
+void grpc_metadata_batch_destroy(grpc_metadata_batch* batch);
+void grpc_metadata_batch_clear(grpc_metadata_batch* batch);
bool grpc_metadata_batch_is_empty(grpc_metadata_batch* batch);
/* Returns the transport size of the batch. */
size_t grpc_metadata_batch_size(grpc_metadata_batch* batch);
/** Remove \a storage from the batch, unreffing the mdelem contained */
-void grpc_metadata_batch_remove(grpc_exec_ctx* exec_ctx,
- grpc_metadata_batch* batch,
+void grpc_metadata_batch_remove(grpc_metadata_batch* batch,
grpc_linked_mdelem* storage);
/** Substitute a new mdelem for an old value */
-grpc_error* grpc_metadata_batch_substitute(grpc_exec_ctx* exec_ctx,
- grpc_metadata_batch* batch,
+grpc_error* grpc_metadata_batch_substitute(grpc_metadata_batch* batch,
grpc_linked_mdelem* storage,
grpc_mdelem new_value);
-void grpc_metadata_batch_set_value(grpc_exec_ctx* exec_ctx,
- grpc_linked_mdelem* storage,
+void grpc_metadata_batch_set_value(grpc_linked_mdelem* storage,
grpc_slice value);
/** Add \a storage to the beginning of \a batch. storage->md is
@@ -86,17 +81,17 @@ void grpc_metadata_batch_set_value(grpc_exec_ctx* exec_ctx,
\a storage is owned by the caller and must survive for the
lifetime of batch. This usually means it should be around
for the lifetime of the call. */
-grpc_error* grpc_metadata_batch_link_head(
- grpc_exec_ctx* exec_ctx, grpc_metadata_batch* batch,
- grpc_linked_mdelem* storage) GRPC_MUST_USE_RESULT;
+grpc_error* grpc_metadata_batch_link_head(grpc_metadata_batch* batch,
+ grpc_linked_mdelem* storage)
+ GRPC_MUST_USE_RESULT;
/** Add \a storage to the end of \a batch. storage->md is
assumed to be valid.
\a storage is owned by the caller and must survive for the
lifetime of batch. This usually means it should be around
for the lifetime of the call. */
-grpc_error* grpc_metadata_batch_link_tail(
- grpc_exec_ctx* exec_ctx, grpc_metadata_batch* batch,
- grpc_linked_mdelem* storage) GRPC_MUST_USE_RESULT;
+grpc_error* grpc_metadata_batch_link_tail(grpc_metadata_batch* batch,
+ grpc_linked_mdelem* storage)
+ GRPC_MUST_USE_RESULT;
/** Add \a elem_to_add as the first element in \a batch, using
\a storage as backing storage for the linked list element.
@@ -105,8 +100,8 @@ grpc_error* grpc_metadata_batch_link_tail(
for the lifetime of the call.
Takes ownership of \a elem_to_add */
grpc_error* grpc_metadata_batch_add_head(
- grpc_exec_ctx* exec_ctx, grpc_metadata_batch* batch,
- grpc_linked_mdelem* storage, grpc_mdelem elem_to_add) GRPC_MUST_USE_RESULT;
+ grpc_metadata_batch* batch, grpc_linked_mdelem* storage,
+ grpc_mdelem elem_to_add) GRPC_MUST_USE_RESULT;
/** Add \a elem_to_add as the last element in \a batch, using
\a storage as backing storage for the linked list element.
\a storage is owned by the caller and must survive for the
@@ -114,8 +109,8 @@ grpc_error* grpc_metadata_batch_add_head(
for the lifetime of the call.
Takes ownership of \a elem_to_add */
grpc_error* grpc_metadata_batch_add_tail(
- grpc_exec_ctx* exec_ctx, grpc_metadata_batch* batch,
- grpc_linked_mdelem* storage, grpc_mdelem elem_to_add) GRPC_MUST_USE_RESULT;
+ grpc_metadata_batch* batch, grpc_linked_mdelem* storage,
+ grpc_mdelem elem_to_add) GRPC_MUST_USE_RESULT;
grpc_error* grpc_attach_md_to_error(grpc_error* src, grpc_mdelem md);
@@ -132,11 +127,10 @@ typedef struct {
{ GRPC_ERROR_NONE, GRPC_MDNULL }
typedef grpc_filtered_mdelem (*grpc_metadata_batch_filter_func)(
- grpc_exec_ctx* exec_ctx, void* user_data, grpc_mdelem elem);
+ void* user_data, grpc_mdelem elem);
grpc_error* grpc_metadata_batch_filter(
- grpc_exec_ctx* exec_ctx, grpc_metadata_batch* batch,
- grpc_metadata_batch_filter_func func, void* user_data,
- const char* composite_error_string) GRPC_MUST_USE_RESULT;
+ grpc_metadata_batch* batch, grpc_metadata_batch_filter_func func,
+ void* user_data, const char* composite_error_string) GRPC_MUST_USE_RESULT;
#ifndef NDEBUG
void grpc_metadata_batch_assert_ok(grpc_metadata_batch* comd);
diff --git a/src/core/lib/transport/service_config.cc b/src/core/lib/transport/service_config.cc
index adcec8c444..cbafc33840 100644
--- a/src/core/lib/transport/service_config.cc
+++ b/src/core/lib/transport/service_config.cc
@@ -152,10 +152,8 @@ static char* parse_json_method_name(grpc_json* json) {
// each name found, incrementing \a idx for each entry added.
// Returns false on error.
static bool parse_json_method_config(
- grpc_exec_ctx* exec_ctx, grpc_json* json,
- void* (*create_value)(const grpc_json* method_config_json),
- void* (*ref_value)(void* value),
- void (*unref_value)(grpc_exec_ctx* exec_ctx, void* value),
+ grpc_json* json, void* (*create_value)(const grpc_json* method_config_json),
+ void* (*ref_value)(void* value), void (*unref_value)(void* value),
grpc_slice_hash_table_entry* entries, size_t* idx) {
// Construct value.
void* method_config = create_value(json);
@@ -184,16 +182,15 @@ static bool parse_json_method_config(
}
success = true;
done:
- unref_value(exec_ctx, method_config);
+ unref_value(method_config);
gpr_strvec_destroy(&paths);
return success;
}
grpc_slice_hash_table* grpc_service_config_create_method_config_table(
- grpc_exec_ctx* exec_ctx, const grpc_service_config* service_config,
+ const grpc_service_config* service_config,
void* (*create_value)(const grpc_json* method_config_json),
- void* (*ref_value)(void* value),
- void (*unref_value)(grpc_exec_ctx* exec_ctx, void* value)) {
+ void* (*ref_value)(void* value), void (*unref_value)(void* value)) {
const grpc_json* json = service_config->json_tree;
// Traverse parsed JSON tree.
if (json->type != GRPC_JSON_OBJECT || json->key != nullptr) return nullptr;
@@ -217,11 +214,11 @@ grpc_slice_hash_table* grpc_service_config_create_method_config_table(
size_t idx = 0;
for (grpc_json* method = field->child; method != nullptr;
method = method->next) {
- if (!parse_json_method_config(exec_ctx, method, create_value, ref_value,
+ if (!parse_json_method_config(method, create_value, ref_value,
unref_value, entries, &idx)) {
for (size_t i = 0; i < idx; ++i) {
- grpc_slice_unref_internal(exec_ctx, entries[i].key);
- unref_value(exec_ctx, entries[i].value);
+ grpc_slice_unref_internal(entries[i].key);
+ unref_value(entries[i].value);
}
gpr_free(entries);
return nullptr;
@@ -240,8 +237,7 @@ grpc_slice_hash_table* grpc_service_config_create_method_config_table(
return method_config_table;
}
-void* grpc_method_config_table_get(grpc_exec_ctx* exec_ctx,
- const grpc_slice_hash_table* table,
+void* grpc_method_config_table_get(const grpc_slice_hash_table* table,
grpc_slice path) {
void* value = grpc_slice_hash_table_get(table, path);
// If we didn't find a match for the path, try looking for a wildcard
@@ -257,7 +253,7 @@ void* grpc_method_config_table_get(grpc_exec_ctx* exec_ctx,
grpc_slice wildcard_path = grpc_slice_from_copied_string(buf);
gpr_free(buf);
value = grpc_slice_hash_table_get(table, wildcard_path);
- grpc_slice_unref_internal(exec_ctx, wildcard_path);
+ grpc_slice_unref_internal(wildcard_path);
gpr_free(path_str);
}
return value;
diff --git a/src/core/lib/transport/service_config.h b/src/core/lib/transport/service_config.h
index 405d0f5b41..2b70e884e8 100644
--- a/src/core/lib/transport/service_config.h
+++ b/src/core/lib/transport/service_config.h
@@ -49,10 +49,9 @@ const char* grpc_service_config_get_lb_policy_name(
/// \a ref_value() and \a unref_value() are used to ref and unref values.
/// Returns NULL on error.
grpc_slice_hash_table* grpc_service_config_create_method_config_table(
- grpc_exec_ctx* exec_ctx, const grpc_service_config* service_config,
+ const grpc_service_config* service_config,
void* (*create_value)(const grpc_json* method_config_json),
- void* (*ref_value)(void* value),
- void (*unref_value)(grpc_exec_ctx* exec_ctx, void* value));
+ void* (*ref_value)(void* value), void (*unref_value)(void* value));
/// A helper function for looking up values in the table returned by
/// \a grpc_service_config_create_method_config_table().
@@ -60,8 +59,7 @@ grpc_slice_hash_table* grpc_service_config_create_method_config_table(
/// the form "/service/method".
/// Returns NULL if the method has no config.
/// Caller does NOT own a reference to the result.
-void* grpc_method_config_table_get(grpc_exec_ctx* exec_ctx,
- const grpc_slice_hash_table* table,
+void* grpc_method_config_table_get(const grpc_slice_hash_table* table,
grpc_slice path);
#ifdef __cplusplus
diff --git a/src/core/lib/transport/static_metadata.cc b/src/core/lib/transport/static_metadata.cc
index 844724cbeb..2213b30f56 100644
--- a/src/core/lib/transport/static_metadata.cc
+++ b/src/core/lib/transport/static_metadata.cc
@@ -104,7 +104,7 @@ static uint8_t g_bytes[] = {
101, 44, 103, 122, 105, 112};
static void static_ref(void* unused) {}
-static void static_unref(grpc_exec_ctx* exec_ctx, void* unused) {}
+static void static_unref(void* unused) {}
static const grpc_slice_refcount_vtable static_sub_vtable = {
static_ref, static_unref, grpc_slice_default_eq_impl,
grpc_slice_default_hash_impl};
diff --git a/src/core/lib/transport/status_conversion.cc b/src/core/lib/transport/status_conversion.cc
index a0a5f1ba4b..46cba4292b 100644
--- a/src/core/lib/transport/status_conversion.cc
+++ b/src/core/lib/transport/status_conversion.cc
@@ -37,8 +37,7 @@ 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,
- grpc_http2_error_code error,
+grpc_status_code grpc_http2_error_to_grpc_status(grpc_http2_error_code error,
grpc_millis deadline) {
switch (error) {
case GRPC_HTTP2_NO_ERROR:
@@ -47,7 +46,7 @@ grpc_status_code grpc_http2_error_to_grpc_status(grpc_exec_ctx* exec_ctx,
case GRPC_HTTP2_CANCEL:
/* http2 cancel translates to STATUS_CANCELLED iff deadline hasn't been
* exceeded */
- return grpc_exec_ctx_now(exec_ctx) > deadline
+ return grpc_core::ExecCtx::Get()->Now() > deadline
? GRPC_STATUS_DEADLINE_EXCEEDED
: GRPC_STATUS_CANCELLED;
case GRPC_HTTP2_ENHANCE_YOUR_CALM:
diff --git a/src/core/lib/transport/status_conversion.h b/src/core/lib/transport/status_conversion.h
index b6fcebd4fa..c89a3e992f 100644
--- a/src/core/lib/transport/status_conversion.h
+++ b/src/core/lib/transport/status_conversion.h
@@ -29,8 +29,7 @@ extern "C" {
/* 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,
- grpc_http2_error_code error,
+grpc_status_code grpc_http2_error_to_grpc_status(grpc_http2_error_code error,
grpc_millis deadline);
/* Conversion of HTTP status codes (:status) to grpc status codes */
diff --git a/src/core/lib/transport/transport.cc b/src/core/lib/transport/transport.cc
index b39e6ebc30..d867123d6f 100644
--- a/src/core/lib/transport/transport.cc
+++ b/src/core/lib/transport/transport.cc
@@ -51,8 +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) {
+void grpc_stream_unref(grpc_stream_refcount* refcount, const char* reason) {
if (GRPC_TRACER_ON(grpc_trace_stream_refcount)) {
gpr_atm val = gpr_atm_no_barrier_load(&refcount->refs.count);
gpr_log(GPR_DEBUG, "%s %p:%p UNREF %" PRIdPTR "->%" PRIdPTR " %s",
@@ -60,11 +59,11 @@ void grpc_stream_unref(grpc_exec_ctx* exec_ctx, grpc_stream_refcount* refcount,
val - 1, reason);
}
#else
-void grpc_stream_unref(grpc_exec_ctx* exec_ctx,
- grpc_stream_refcount* refcount) {
+void grpc_stream_unref(grpc_stream_refcount* refcount) {
#endif
if (gpr_unref(&refcount->refs)) {
- if (exec_ctx->flags & GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP) {
+ if (grpc_core::ExecCtx::Get()->flags() &
+ GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP) {
/* Ick.
The thread we're running on MAY be owned (indirectly) by a call-stack.
If that's the case, destroying the call-stack MAY try to destroy the
@@ -75,7 +74,7 @@ void grpc_stream_unref(grpc_exec_ctx* exec_ctx,
refcount->destroy.scheduler =
grpc_executor_scheduler(GRPC_EXECUTOR_SHORT);
}
- GRPC_CLOSURE_SCHED(exec_ctx, &refcount->destroy, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&refcount->destroy, GRPC_ERROR_NONE);
}
}
@@ -91,11 +90,11 @@ static void slice_stream_ref(void* p) {
#endif
}
-static void slice_stream_unref(grpc_exec_ctx* exec_ctx, void* p) {
+static void slice_stream_unref(void* p) {
#ifndef NDEBUG
- grpc_stream_unref(exec_ctx, STREAM_REF_FROM_SLICE_REF(p), "slice");
+ grpc_stream_unref(STREAM_REF_FROM_SLICE_REF(p), "slice");
#else
- grpc_stream_unref(exec_ctx, STREAM_REF_FROM_SLICE_REF(p));
+ grpc_stream_unref(STREAM_REF_FROM_SLICE_REF(p));
#endif
}
@@ -153,59 +152,50 @@ size_t grpc_transport_stream_size(grpc_transport* transport) {
return transport->vtable->sizeof_stream;
}
-void grpc_transport_destroy(grpc_exec_ctx* exec_ctx,
- grpc_transport* transport) {
- transport->vtable->destroy(exec_ctx, transport);
+void grpc_transport_destroy(grpc_transport* transport) {
+ transport->vtable->destroy(transport);
}
-int grpc_transport_init_stream(grpc_exec_ctx* exec_ctx,
- grpc_transport* transport, grpc_stream* stream,
+int grpc_transport_init_stream(grpc_transport* transport, grpc_stream* stream,
grpc_stream_refcount* refcount,
const void* server_data, gpr_arena* arena) {
- return transport->vtable->init_stream(exec_ctx, transport, stream, refcount,
+ return transport->vtable->init_stream(transport, stream, refcount,
server_data, arena);
}
-void grpc_transport_perform_stream_op(grpc_exec_ctx* exec_ctx,
- grpc_transport* transport,
+void grpc_transport_perform_stream_op(grpc_transport* transport,
grpc_stream* stream,
grpc_transport_stream_op_batch* op) {
- transport->vtable->perform_stream_op(exec_ctx, transport, stream, op);
+ transport->vtable->perform_stream_op(transport, stream, op);
}
-void grpc_transport_perform_op(grpc_exec_ctx* exec_ctx,
- grpc_transport* transport,
+void grpc_transport_perform_op(grpc_transport* transport,
grpc_transport_op* op) {
- transport->vtable->perform_op(exec_ctx, transport, op);
+ transport->vtable->perform_op(transport, op);
}
-void grpc_transport_set_pops(grpc_exec_ctx* exec_ctx, grpc_transport* transport,
- grpc_stream* stream,
+void grpc_transport_set_pops(grpc_transport* transport, grpc_stream* stream,
grpc_polling_entity* pollent) {
grpc_pollset* pollset;
grpc_pollset_set* pollset_set;
if ((pollset = grpc_polling_entity_pollset(pollent)) != nullptr) {
- transport->vtable->set_pollset(exec_ctx, transport, stream, pollset);
+ transport->vtable->set_pollset(transport, stream, pollset);
} else if ((pollset_set = grpc_polling_entity_pollset_set(pollent)) !=
nullptr) {
- transport->vtable->set_pollset_set(exec_ctx, transport, stream,
- pollset_set);
+ transport->vtable->set_pollset_set(transport, stream, pollset_set);
} else {
abort();
}
}
-void grpc_transport_destroy_stream(grpc_exec_ctx* exec_ctx,
- grpc_transport* transport,
+void grpc_transport_destroy_stream(grpc_transport* transport,
grpc_stream* stream,
grpc_closure* then_schedule_closure) {
- transport->vtable->destroy_stream(exec_ctx, transport, stream,
- then_schedule_closure);
+ transport->vtable->destroy_stream(transport, stream, then_schedule_closure);
}
-grpc_endpoint* grpc_transport_get_endpoint(grpc_exec_ctx* exec_ctx,
- grpc_transport* transport) {
- return transport->vtable->get_endpoint(exec_ctx, transport);
+grpc_endpoint* grpc_transport_get_endpoint(grpc_transport* transport) {
+ return transport->vtable->get_endpoint(transport);
}
// This comment should be sung to the tune of
@@ -216,25 +206,23 @@ grpc_endpoint* grpc_transport_get_endpoint(grpc_exec_ctx* exec_ctx,
// though it lives in lib, it handles transport stream ops sure
// it's grpc_transport_stream_op_batch_finish_with_failure
void grpc_transport_stream_op_batch_finish_with_failure(
- grpc_exec_ctx* exec_ctx, grpc_transport_stream_op_batch* batch,
- grpc_error* error, grpc_call_combiner* call_combiner) {
+ grpc_transport_stream_op_batch* batch, grpc_error* error,
+ grpc_call_combiner* call_combiner) {
if (batch->send_message) {
- grpc_byte_stream_destroy(exec_ctx,
- batch->payload->send_message.send_message);
+ grpc_byte_stream_destroy(batch->payload->send_message.send_message);
}
if (batch->recv_message) {
- GRPC_CALL_COMBINER_START(exec_ctx, call_combiner,
- batch->payload->recv_message.recv_message_ready,
- GRPC_ERROR_REF(error),
- "failing recv_message_ready");
+ GRPC_CALL_COMBINER_START(
+ call_combiner, batch->payload->recv_message.recv_message_ready,
+ GRPC_ERROR_REF(error), "failing recv_message_ready");
}
if (batch->recv_initial_metadata) {
GRPC_CALL_COMBINER_START(
- exec_ctx, call_combiner,
+ call_combiner,
batch->payload->recv_initial_metadata.recv_initial_metadata_ready,
GRPC_ERROR_REF(error), "failing recv_initial_metadata_ready");
}
- GRPC_CLOSURE_SCHED(exec_ctx, batch->on_complete, error);
+ GRPC_CLOSURE_SCHED(batch->on_complete, error);
if (batch->cancel_stream) {
GRPC_ERROR_UNREF(batch->payload->cancel_stream.cancel_error);
}
@@ -246,10 +234,9 @@ typedef struct {
grpc_transport_op op;
} made_transport_op;
-static void destroy_made_transport_op(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void destroy_made_transport_op(void* arg, grpc_error* error) {
made_transport_op* op = (made_transport_op*)arg;
- GRPC_CLOSURE_SCHED(exec_ctx, op->inner_on_complete, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(op->inner_on_complete, GRPC_ERROR_REF(error));
gpr_free(op);
}
@@ -270,12 +257,11 @@ typedef struct {
grpc_transport_stream_op_batch_payload payload;
} made_transport_stream_op;
-static void destroy_made_transport_stream_op(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void destroy_made_transport_stream_op(void* arg, grpc_error* error) {
made_transport_stream_op* op = (made_transport_stream_op*)arg;
grpc_closure* c = op->inner_on_complete;
gpr_free(op);
- GRPC_CLOSURE_RUN(exec_ctx, c, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_RUN(c, GRPC_ERROR_REF(error));
}
grpc_transport_stream_op_batch* grpc_make_transport_stream_op(
diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h
index 973018e5a5..a6692ba1c2 100644
--- a/src/core/lib/transport/transport.h
+++ b/src/core/lib/transport/transport.h
@@ -61,15 +61,14 @@ void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs,
grpc_iomgr_cb_func cb, void* cb_arg,
const char* object_type);
void grpc_stream_ref(grpc_stream_refcount* refcount, const char* reason);
-void grpc_stream_unref(grpc_exec_ctx* exec_ctx, grpc_stream_refcount* refcount,
- const char* reason);
+void grpc_stream_unref(grpc_stream_refcount* refcount, const char* reason);
#define GRPC_STREAM_REF_INIT(rc, ir, cb, cb_arg, objtype) \
grpc_stream_ref_init(rc, ir, cb, cb_arg, objtype)
#else
void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs,
grpc_iomgr_cb_func cb, void* cb_arg);
void grpc_stream_ref(grpc_stream_refcount* refcount);
-void grpc_stream_unref(grpc_exec_ctx* exec_ctx, grpc_stream_refcount* refcount);
+void grpc_stream_unref(grpc_stream_refcount* refcount);
#define GRPC_STREAM_REF_INIT(rc, ir, cb, cb_arg, objtype) \
grpc_stream_ref_init(rc, ir, cb, cb_arg)
#endif
@@ -243,8 +242,7 @@ typedef struct grpc_transport_op {
If true, the callback is set to set_accept_stream_fn, with its
user_data argument set to set_accept_stream_user_data */
bool set_accept_stream;
- void (*set_accept_stream_fn)(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_transport* transport,
+ void (*set_accept_stream_fn)(void* user_data, grpc_transport* transport,
const void* server_data);
void* set_accept_stream_user_data;
/** add this transport to a pollset */
@@ -275,13 +273,12 @@ size_t grpc_transport_stream_size(grpc_transport* transport);
stream - a pointer to uninitialized memory to initialize
server_data - either NULL for a client initiated stream, or a pointer
supplied from the accept_stream callback function */
-int grpc_transport_init_stream(grpc_exec_ctx* exec_ctx,
- grpc_transport* transport, grpc_stream* stream,
+int grpc_transport_init_stream(grpc_transport* transport, grpc_stream* stream,
grpc_stream_refcount* refcount,
const void* server_data, gpr_arena* arena);
-void grpc_transport_set_pops(grpc_exec_ctx* exec_ctx, grpc_transport* transport,
- grpc_stream* stream, grpc_polling_entity* pollent);
+void grpc_transport_set_pops(grpc_transport* transport, grpc_stream* stream,
+ grpc_polling_entity* pollent);
/* Destroy transport data for a stream.
@@ -293,14 +290,13 @@ void grpc_transport_set_pops(grpc_exec_ctx* exec_ctx, grpc_transport* transport,
transport - the transport on which to create this stream
stream - the grpc_stream to destroy (memory is still owned by the
caller, but any child memory must be cleaned up) */
-void grpc_transport_destroy_stream(grpc_exec_ctx* exec_ctx,
- grpc_transport* transport,
+void grpc_transport_destroy_stream(grpc_transport* transport,
grpc_stream* stream,
grpc_closure* then_schedule_closure);
void grpc_transport_stream_op_batch_finish_with_failure(
- grpc_exec_ctx* exec_ctx, grpc_transport_stream_op_batch* op,
- grpc_error* error, grpc_call_combiner* call_combiner);
+ grpc_transport_stream_op_batch* op, grpc_error* error,
+ grpc_call_combiner* call_combiner);
char* grpc_transport_stream_op_batch_string(grpc_transport_stream_op_batch* op);
char* grpc_transport_op_string(grpc_transport_op* op);
@@ -315,13 +311,11 @@ char* grpc_transport_op_string(grpc_transport_op* op);
non-NULL and previously initialized by the same transport.
op - a grpc_transport_stream_op_batch specifying the op to perform
*/
-void grpc_transport_perform_stream_op(grpc_exec_ctx* exec_ctx,
- grpc_transport* transport,
+void grpc_transport_perform_stream_op(grpc_transport* transport,
grpc_stream* stream,
grpc_transport_stream_op_batch* op);
-void grpc_transport_perform_op(grpc_exec_ctx* exec_ctx,
- grpc_transport* transport,
+void grpc_transport_perform_op(grpc_transport* transport,
grpc_transport_op* op);
/* Send a ping on a transport
@@ -337,11 +331,10 @@ void grpc_transport_goaway(grpc_transport* transport, grpc_status_code status,
void grpc_transport_close(grpc_transport* transport);
/* Destroy the transport */
-void grpc_transport_destroy(grpc_exec_ctx* exec_ctx, grpc_transport* transport);
+void grpc_transport_destroy(grpc_transport* transport);
/* Get the endpoint used by \a transport */
-grpc_endpoint* grpc_transport_get_endpoint(grpc_exec_ctx* exec_ctx,
- grpc_transport* transport);
+grpc_endpoint* grpc_transport_get_endpoint(grpc_transport* transport);
/* Allocate a grpc_transport_op, and preconfigure the on_consumed closure to
\a on_consumed and then delete the returned transport op */
diff --git a/src/core/lib/transport/transport_impl.h b/src/core/lib/transport/transport_impl.h
index 22ad599e2e..8edcb5d310 100644
--- a/src/core/lib/transport/transport_impl.h
+++ b/src/core/lib/transport/transport_impl.h
@@ -34,37 +34,34 @@ typedef struct grpc_transport_vtable {
const char* name;
/* implementation of grpc_transport_init_stream */
- int (*init_stream)(grpc_exec_ctx* exec_ctx, grpc_transport* self,
- grpc_stream* stream, grpc_stream_refcount* refcount,
- const void* server_data, gpr_arena* arena);
+ int (*init_stream)(grpc_transport* self, grpc_stream* stream,
+ grpc_stream_refcount* refcount, const void* server_data,
+ gpr_arena* arena);
/* implementation of grpc_transport_set_pollset */
- void (*set_pollset)(grpc_exec_ctx* exec_ctx, grpc_transport* self,
- grpc_stream* stream, grpc_pollset* pollset);
+ void (*set_pollset)(grpc_transport* self, grpc_stream* stream,
+ grpc_pollset* pollset);
/* implementation of grpc_transport_set_pollset */
- void (*set_pollset_set)(grpc_exec_ctx* exec_ctx, grpc_transport* self,
- grpc_stream* stream, grpc_pollset_set* pollset_set);
+ void (*set_pollset_set)(grpc_transport* self, grpc_stream* stream,
+ grpc_pollset_set* pollset_set);
/* implementation of grpc_transport_perform_stream_op */
- void (*perform_stream_op)(grpc_exec_ctx* exec_ctx, grpc_transport* self,
- grpc_stream* stream,
+ void (*perform_stream_op)(grpc_transport* self, grpc_stream* stream,
grpc_transport_stream_op_batch* op);
/* implementation of grpc_transport_perform_op */
- void (*perform_op)(grpc_exec_ctx* exec_ctx, grpc_transport* self,
- grpc_transport_op* op);
+ void (*perform_op)(grpc_transport* self, grpc_transport_op* op);
/* implementation of grpc_transport_destroy_stream */
- void (*destroy_stream)(grpc_exec_ctx* exec_ctx, grpc_transport* self,
- grpc_stream* stream,
+ void (*destroy_stream)(grpc_transport* self, grpc_stream* stream,
grpc_closure* then_schedule_closure);
/* implementation of grpc_transport_destroy */
- void (*destroy)(grpc_exec_ctx* exec_ctx, grpc_transport* self);
+ void (*destroy)(grpc_transport* self);
/* implementation of grpc_transport_get_endpoint */
- grpc_endpoint* (*get_endpoint)(grpc_exec_ctx* exec_ctx, grpc_transport* self);
+ grpc_endpoint* (*get_endpoint)(grpc_transport* self);
} grpc_transport_vtable;
/* an instance of a grpc transport */
diff --git a/src/core/tsi/fake_transport_security.cc b/src/core/tsi/fake_transport_security.cc
index e508d9b24a..4ea24c8ad2 100644
--- a/src/core/tsi/fake_transport_security.cc
+++ b/src/core/tsi/fake_transport_security.cc
@@ -399,8 +399,7 @@ static const tsi_frame_protector_vtable frame_protector_vtable = {
/* --- tsi_zero_copy_grpc_protector methods implementation. ---*/
static tsi_result fake_zero_copy_grpc_protector_protect(
- grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self,
- grpc_slice_buffer* unprotected_slices,
+ tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* unprotected_slices,
grpc_slice_buffer* protected_slices) {
if (self == nullptr || unprotected_slices == nullptr ||
protected_slices == nullptr) {
@@ -424,8 +423,7 @@ static tsi_result fake_zero_copy_grpc_protector_protect(
}
static tsi_result fake_zero_copy_grpc_protector_unprotect(
- grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self,
- grpc_slice_buffer* protected_slices,
+ tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* protected_slices,
grpc_slice_buffer* unprotected_slices) {
if (self == nullptr || unprotected_slices == nullptr ||
protected_slices == nullptr) {
@@ -454,18 +452,18 @@ static tsi_result fake_zero_copy_grpc_protector_unprotect(
impl->parsed_frame_size - TSI_FAKE_FRAME_HEADER_SIZE,
unprotected_slices);
impl->parsed_frame_size = 0;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &impl->header_sb);
+ grpc_slice_buffer_reset_and_unref_internal(&impl->header_sb);
}
return TSI_OK;
}
static void fake_zero_copy_grpc_protector_destroy(
- grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self) {
+ tsi_zero_copy_grpc_protector* self) {
if (self == nullptr) return;
tsi_fake_zero_copy_grpc_protector* impl =
(tsi_fake_zero_copy_grpc_protector*)self;
- grpc_slice_buffer_destroy_internal(exec_ctx, &impl->header_sb);
- grpc_slice_buffer_destroy_internal(exec_ctx, &impl->protected_sb);
+ grpc_slice_buffer_destroy_internal(&impl->header_sb);
+ grpc_slice_buffer_destroy_internal(&impl->protected_sb);
gpr_free(impl);
}
@@ -497,8 +495,7 @@ static tsi_result fake_handshaker_result_extract_peer(
}
static tsi_result fake_handshaker_result_create_zero_copy_grpc_protector(
- void* exec_ctx, const tsi_handshaker_result* self,
- size_t* max_output_protected_frame_size,
+ const tsi_handshaker_result* self, size_t* max_output_protected_frame_size,
tsi_zero_copy_grpc_protector** protector) {
*protector =
tsi_create_fake_zero_copy_grpc_protector(max_output_protected_frame_size);
diff --git a/src/core/tsi/transport_security.h b/src/core/tsi/transport_security.h
index d639f857fe..c64b1ca51a 100644
--- a/src/core/tsi/transport_security.h
+++ b/src/core/tsi/transport_security.h
@@ -94,7 +94,7 @@ struct tsi_handshaker {
typedef struct {
tsi_result (*extract_peer)(const tsi_handshaker_result* self, tsi_peer* peer);
tsi_result (*create_zero_copy_grpc_protector)(
- void* exec_ctx, const tsi_handshaker_result* self,
+ const tsi_handshaker_result* self,
size_t* max_output_protected_frame_size,
tsi_zero_copy_grpc_protector** protector);
tsi_result (*create_frame_protector)(const tsi_handshaker_result* self,
diff --git a/src/core/tsi/transport_security_grpc.cc b/src/core/tsi/transport_security_grpc.cc
index 875d367218..76f7ae782f 100644
--- a/src/core/tsi/transport_security_grpc.cc
+++ b/src/core/tsi/transport_security_grpc.cc
@@ -20,18 +20,16 @@
/* This method creates a tsi_zero_copy_grpc_protector object. */
tsi_result tsi_handshaker_result_create_zero_copy_grpc_protector(
- grpc_exec_ctx* exec_ctx, const tsi_handshaker_result* self,
- size_t* max_output_protected_frame_size,
+ const tsi_handshaker_result* self, size_t* max_output_protected_frame_size,
tsi_zero_copy_grpc_protector** protector) {
- if (exec_ctx == nullptr || self == nullptr || self->vtable == nullptr ||
- protector == nullptr) {
+ if (self == nullptr || self->vtable == nullptr || protector == nullptr) {
return TSI_INVALID_ARGUMENT;
}
if (self->vtable->create_zero_copy_grpc_protector == nullptr) {
return TSI_UNIMPLEMENTED;
}
return self->vtable->create_zero_copy_grpc_protector(
- exec_ctx, self, max_output_protected_frame_size, protector);
+ self, max_output_protected_frame_size, protector);
}
/* --- tsi_zero_copy_grpc_protector common implementation. ---
@@ -39,33 +37,28 @@ tsi_result tsi_handshaker_result_create_zero_copy_grpc_protector(
Calls specific implementation after state/input validation. */
tsi_result tsi_zero_copy_grpc_protector_protect(
- grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self,
- grpc_slice_buffer* unprotected_slices,
+ tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* unprotected_slices,
grpc_slice_buffer* protected_slices) {
- if (exec_ctx == nullptr || self == nullptr || self->vtable == nullptr ||
+ if (self == nullptr || self->vtable == nullptr ||
unprotected_slices == nullptr || protected_slices == nullptr) {
return TSI_INVALID_ARGUMENT;
}
if (self->vtable->protect == nullptr) return TSI_UNIMPLEMENTED;
- return self->vtable->protect(exec_ctx, self, unprotected_slices,
- protected_slices);
+ return self->vtable->protect(self, unprotected_slices, protected_slices);
}
tsi_result tsi_zero_copy_grpc_protector_unprotect(
- grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self,
- grpc_slice_buffer* protected_slices,
+ tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* protected_slices,
grpc_slice_buffer* unprotected_slices) {
- if (exec_ctx == nullptr || self == nullptr || self->vtable == nullptr ||
+ if (self == nullptr || self->vtable == nullptr ||
protected_slices == nullptr || unprotected_slices == nullptr) {
return TSI_INVALID_ARGUMENT;
}
if (self->vtable->unprotect == nullptr) return TSI_UNIMPLEMENTED;
- return self->vtable->unprotect(exec_ctx, self, protected_slices,
- unprotected_slices);
+ return self->vtable->unprotect(self, protected_slices, unprotected_slices);
}
-void tsi_zero_copy_grpc_protector_destroy(grpc_exec_ctx* exec_ctx,
- tsi_zero_copy_grpc_protector* self) {
+void tsi_zero_copy_grpc_protector_destroy(tsi_zero_copy_grpc_protector* self) {
if (self == nullptr) return;
- self->vtable->destroy(exec_ctx, self);
+ self->vtable->destroy(self);
}
diff --git a/src/core/tsi/transport_security_grpc.h b/src/core/tsi/transport_security_grpc.h
index 1c54693ec9..c9d30e9c46 100644
--- a/src/core/tsi/transport_security_grpc.h
+++ b/src/core/tsi/transport_security_grpc.h
@@ -30,8 +30,7 @@ extern "C" {
assuming there is no fatal error.
The caller is responsible for destroying the protector. */
tsi_result tsi_handshaker_result_create_zero_copy_grpc_protector(
- grpc_exec_ctx* exec_ctx, const tsi_handshaker_result* self,
- size_t* max_output_protected_frame_size,
+ const tsi_handshaker_result* self, size_t* max_output_protected_frame_size,
tsi_zero_copy_grpc_protector** protector);
/* -- tsi_zero_copy_grpc_protector object -- */
@@ -43,8 +42,8 @@ tsi_result tsi_handshaker_result_create_zero_copy_grpc_protector(
- This method returns TSI_OK in case of success or a specific error code in
case of failure. */
tsi_result tsi_zero_copy_grpc_protector_protect(
- grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self,
- grpc_slice_buffer* unprotected_slices, grpc_slice_buffer* protected_slices);
+ tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* unprotected_slices,
+ grpc_slice_buffer* protected_slices);
/* Outputs unprotected bytes.
- protected_slices is the bytes of protected frames.
@@ -53,24 +52,21 @@ tsi_result tsi_zero_copy_grpc_protector_protect(
there is not enough data to output in which case unprotected_slices has 0
bytes. */
tsi_result tsi_zero_copy_grpc_protector_unprotect(
- grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self,
- grpc_slice_buffer* protected_slices, grpc_slice_buffer* unprotected_slices);
+ tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* protected_slices,
+ grpc_slice_buffer* unprotected_slices);
/* Destroys the tsi_zero_copy_grpc_protector object. */
-void tsi_zero_copy_grpc_protector_destroy(grpc_exec_ctx* exec_ctx,
- tsi_zero_copy_grpc_protector* self);
+void tsi_zero_copy_grpc_protector_destroy(tsi_zero_copy_grpc_protector* self);
/* Base for tsi_zero_copy_grpc_protector implementations. */
typedef struct {
- tsi_result (*protect)(grpc_exec_ctx* exec_ctx,
- tsi_zero_copy_grpc_protector* self,
+ tsi_result (*protect)(tsi_zero_copy_grpc_protector* self,
grpc_slice_buffer* unprotected_slices,
grpc_slice_buffer* protected_slices);
- tsi_result (*unprotect)(grpc_exec_ctx* exec_ctx,
- tsi_zero_copy_grpc_protector* self,
+ tsi_result (*unprotect)(tsi_zero_copy_grpc_protector* self,
grpc_slice_buffer* protected_slices,
grpc_slice_buffer* unprotected_slices);
- void (*destroy)(grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self);
+ void (*destroy)(tsi_zero_copy_grpc_protector* self);
} tsi_zero_copy_grpc_protector_vtable;
struct tsi_zero_copy_grpc_protector {
diff --git a/src/cpp/common/channel_arguments.cc b/src/cpp/common/channel_arguments.cc
index f89f5f1f03..82d687c530 100644
--- a/src/cpp/common/channel_arguments.cc
+++ b/src/cpp/common/channel_arguments.cc
@@ -67,13 +67,12 @@ ChannelArguments::ChannelArguments(const ChannelArguments& other)
}
ChannelArguments::~ChannelArguments() {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
for (auto it = args_.begin(); it != args_.end(); ++it) {
if (it->type == GRPC_ARG_POINTER) {
- it->value.pointer.vtable->destroy(&exec_ctx, it->value.pointer.p);
+ it->value.pointer.vtable->destroy(it->value.pointer.p);
}
}
- grpc_exec_ctx_finish(&exec_ctx);
}
void ChannelArguments::Swap(ChannelArguments& other) {
@@ -96,17 +95,17 @@ void ChannelArguments::SetSocketMutator(grpc_socket_mutator* mutator) {
}
grpc_arg mutator_arg = grpc_socket_mutator_to_arg(mutator);
bool replaced = false;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
for (auto it = args_.begin(); it != args_.end(); ++it) {
if (it->type == mutator_arg.type &&
grpc::string(it->key) == grpc::string(mutator_arg.key)) {
GPR_ASSERT(!replaced);
- it->value.pointer.vtable->destroy(&exec_ctx, it->value.pointer.p);
+ it->value.pointer.vtable->destroy(it->value.pointer.p);
it->value.pointer = mutator_arg.value.pointer;
replaced = true;
}
}
- grpc_exec_ctx_finish(&exec_ctx);
+
if (!replaced) {
args_.push_back(mutator_arg);
}
diff --git a/src/cpp/common/channel_filter.cc b/src/cpp/common/channel_filter.cc
index d1cfd2b48a..c23761211c 100644
--- a/src/cpp/common/channel_filter.cc
+++ b/src/cpp/common/channel_filter.cc
@@ -29,43 +29,39 @@ namespace grpc {
// MetadataBatch
-grpc_linked_mdelem* MetadataBatch::AddMetadata(grpc_exec_ctx* exec_ctx,
- const string& key,
+grpc_linked_mdelem* MetadataBatch::AddMetadata(const string& key,
const string& value) {
grpc_linked_mdelem* storage = new grpc_linked_mdelem;
memset(storage, 0, sizeof(grpc_linked_mdelem));
- storage->md = grpc_mdelem_from_slices(exec_ctx, SliceFromCopiedString(key),
+ storage->md = grpc_mdelem_from_slices(SliceFromCopiedString(key),
SliceFromCopiedString(value));
GRPC_LOG_IF_ERROR("MetadataBatch::AddMetadata",
- grpc_metadata_batch_link_head(exec_ctx, batch_, storage));
+ grpc_metadata_batch_link_head(batch_, storage));
return storage;
}
// ChannelData
-void ChannelData::StartTransportOp(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+void ChannelData::StartTransportOp(grpc_channel_element* elem,
TransportOp* op) {
- grpc_channel_next_op(exec_ctx, elem, op->op());
+ grpc_channel_next_op(elem, op->op());
}
-void ChannelData::GetInfo(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+void ChannelData::GetInfo(grpc_channel_element* elem,
const grpc_channel_info* channel_info) {
- grpc_channel_next_get_info(exec_ctx, elem, channel_info);
+ grpc_channel_next_get_info(elem, channel_info);
}
// CallData
-void CallData::StartTransportStreamOpBatch(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+void CallData::StartTransportStreamOpBatch(grpc_call_element* elem,
TransportStreamOpBatch* op) {
- grpc_call_next_op(exec_ctx, elem, op->op());
+ grpc_call_next_op(elem, op->op());
}
-void CallData::SetPollsetOrPollsetSet(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+void CallData::SetPollsetOrPollsetSet(grpc_call_element* elem,
grpc_polling_entity* pollent) {
- grpc_call_stack_ignore_set_pollset_or_pollset_set(exec_ctx, elem, pollent);
+ grpc_call_stack_ignore_set_pollset_or_pollset_set(elem, pollent);
}
// internal code used by RegisterChannelFilter()
@@ -77,8 +73,7 @@ std::vector<FilterRecord>* channel_filters;
namespace {
-bool MaybeAddFilter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder, void* arg) {
+bool MaybeAddFilter(grpc_channel_stack_builder* builder, void* arg) {
const FilterRecord& filter = *(FilterRecord*)arg;
if (filter.include_filter) {
const grpc_channel_args* args =
diff --git a/src/cpp/common/channel_filter.h b/src/cpp/common/channel_filter.h
index 4fb81ecb1e..158a673e31 100644
--- a/src/cpp/common/channel_filter.h
+++ b/src/cpp/common/channel_filter.h
@@ -56,8 +56,7 @@ class MetadataBatch {
/// Adds metadata and returns the newly allocated storage.
/// The caller takes ownership of the result, which must exist for the
/// lifetime of the gRPC call.
- grpc_linked_mdelem* AddMetadata(grpc_exec_ctx* exec_ctx, const string& key,
- const string& value);
+ grpc_linked_mdelem* AddMetadata(const string& key, const string& value);
class const_iterator : public std::iterator<std::bidirectional_iterator_tag,
const grpc_mdelem> {
@@ -224,18 +223,17 @@ class ChannelData {
// TODO(roth): Come up with a more C++-like API for the channel element.
/// Initializes the channel data.
- virtual grpc_error* Init(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+ virtual grpc_error* Init(grpc_channel_element* elem,
grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
// Called before destruction.
- virtual void Destroy(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem) {}
+ virtual void Destroy(grpc_channel_element* elem) {}
- virtual void StartTransportOp(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem, TransportOp* op);
+ virtual void StartTransportOp(grpc_channel_element* elem, TransportOp* op);
- virtual void GetInfo(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+ virtual void GetInfo(grpc_channel_element* elem,
const grpc_channel_info* channel_info);
};
@@ -248,24 +246,22 @@ class CallData {
// TODO(roth): Come up with a more C++-like API for the call element.
/// Initializes the call data.
- virtual grpc_error* Init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+ virtual grpc_error* Init(grpc_call_element* elem,
const grpc_call_element_args* args) {
return GRPC_ERROR_NONE;
}
// Called before destruction.
- virtual void Destroy(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+ virtual void Destroy(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* then_call_closure) {}
/// Starts a new stream operation.
- virtual void StartTransportStreamOpBatch(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+ virtual void StartTransportStreamOpBatch(grpc_call_element* elem,
TransportStreamOpBatch* op);
/// Sets a pollset or pollset set.
- virtual void SetPollsetOrPollsetSet(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+ virtual void SetPollsetOrPollsetSet(grpc_call_element* elem,
grpc_polling_entity* pollent);
};
@@ -279,71 +275,63 @@ class ChannelFilter final {
public:
static const size_t channel_data_size = sizeof(ChannelDataType);
- static grpc_error* InitChannelElement(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+ static grpc_error* InitChannelElement(grpc_channel_element* elem,
grpc_channel_element_args* args) {
// Construct the object in the already-allocated memory.
ChannelDataType* channel_data = new (elem->channel_data) ChannelDataType();
- return channel_data->Init(exec_ctx, elem, args);
+ return channel_data->Init(elem, args);
}
- static void DestroyChannelElement(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {
+ static void DestroyChannelElement(grpc_channel_element* elem) {
ChannelDataType* channel_data =
reinterpret_cast<ChannelDataType*>(elem->channel_data);
- channel_data->Destroy(exec_ctx, elem);
+ channel_data->Destroy(elem);
channel_data->~ChannelDataType();
}
- static void StartTransportOp(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+ static void StartTransportOp(grpc_channel_element* elem,
grpc_transport_op* op) {
ChannelDataType* channel_data =
reinterpret_cast<ChannelDataType*>(elem->channel_data);
TransportOp op_wrapper(op);
- channel_data->StartTransportOp(exec_ctx, elem, &op_wrapper);
+ channel_data->StartTransportOp(elem, &op_wrapper);
}
- static void GetChannelInfo(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+ static void GetChannelInfo(grpc_channel_element* elem,
const grpc_channel_info* channel_info) {
ChannelDataType* channel_data =
reinterpret_cast<ChannelDataType*>(elem->channel_data);
- channel_data->GetInfo(exec_ctx, elem, channel_info);
+ channel_data->GetInfo(elem, channel_info);
}
static const size_t call_data_size = sizeof(CallDataType);
- static grpc_error* InitCallElement(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+ static grpc_error* InitCallElement(grpc_call_element* elem,
const grpc_call_element_args* args) {
// Construct the object in the already-allocated memory.
CallDataType* call_data = new (elem->call_data) CallDataType();
- return call_data->Init(exec_ctx, elem, args);
+ return call_data->Init(elem, args);
}
- static void DestroyCallElement(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+ static void DestroyCallElement(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* then_call_closure) {
CallDataType* call_data = reinterpret_cast<CallDataType*>(elem->call_data);
- call_data->Destroy(exec_ctx, elem, final_info, then_call_closure);
+ call_data->Destroy(elem, final_info, then_call_closure);
call_data->~CallDataType();
}
- static void StartTransportStreamOpBatch(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+ static void StartTransportStreamOpBatch(grpc_call_element* elem,
grpc_transport_stream_op_batch* op) {
CallDataType* call_data = reinterpret_cast<CallDataType*>(elem->call_data);
TransportStreamOpBatch op_wrapper(op);
- call_data->StartTransportStreamOpBatch(exec_ctx, elem, &op_wrapper);
+ call_data->StartTransportStreamOpBatch(elem, &op_wrapper);
}
- static void SetPollsetOrPollsetSet(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+ static void SetPollsetOrPollsetSet(grpc_call_element* elem,
grpc_polling_entity* pollent) {
CallDataType* call_data = reinterpret_cast<CallDataType*>(elem->call_data);
- call_data->SetPollsetOrPollsetSet(exec_ctx, elem, pollent);
+ call_data->SetPollsetOrPollsetSet(elem, pollent);
}
};
diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h
index ae1e1a0b30..3a4c30d385 100644
--- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h
+++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h
@@ -559,7 +559,7 @@ extern grpc_slice_buffer_move_first_type grpc_slice_buffer_move_first_import;
typedef void(*grpc_slice_buffer_move_first_no_ref_type)(grpc_slice_buffer* src, size_t n, grpc_slice_buffer* dst);
extern grpc_slice_buffer_move_first_no_ref_type grpc_slice_buffer_move_first_no_ref_import;
#define grpc_slice_buffer_move_first_no_ref grpc_slice_buffer_move_first_no_ref_import
-typedef void(*grpc_slice_buffer_move_first_into_buffer_type)(grpc_exec_ctx* exec_ctx, grpc_slice_buffer* src, size_t n, void* dst);
+typedef void(*grpc_slice_buffer_move_first_into_buffer_type)(grpc_slice_buffer* src, size_t n, void* dst);
extern grpc_slice_buffer_move_first_into_buffer_type grpc_slice_buffer_move_first_into_buffer_import;
#define grpc_slice_buffer_move_first_into_buffer grpc_slice_buffer_move_first_into_buffer_import
typedef grpc_slice(*grpc_slice_buffer_take_first_type)(grpc_slice_buffer* src);
diff --git a/test/core/backoff/backoff_test.cc b/test/core/backoff/backoff_test.cc
index ef2de8d638..76a9f39c35 100644
--- a/test/core/backoff/backoff_test.cc
+++ b/test/core/backoff/backoff_test.cc
@@ -32,23 +32,24 @@ static void test_constant_backoff(void) {
const grpc_millis max_backoff = 1000;
grpc_backoff_init(&backoff, initial_backoff, multiplier, jitter,
min_connect_timeout, max_backoff);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_backoff_result next_deadlines = grpc_backoff_begin(&exec_ctx, &backoff);
- GPR_ASSERT(next_deadlines.current_deadline - grpc_exec_ctx_now(&exec_ctx) ==
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_backoff_result next_deadlines = grpc_backoff_begin(&backoff);
+ GPR_ASSERT(next_deadlines.current_deadline -
+ grpc_core::ExecCtx::Get()->Now() ==
initial_backoff);
GPR_ASSERT(next_deadlines.next_attempt_start_time -
- grpc_exec_ctx_now(&exec_ctx) ==
+ grpc_core::ExecCtx::Get()->Now() ==
initial_backoff);
for (int i = 0; i < 10000; i++) {
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
- GPR_ASSERT(next_deadlines.current_deadline - grpc_exec_ctx_now(&exec_ctx) ==
+ next_deadlines = grpc_backoff_step(&backoff);
+ GPR_ASSERT(next_deadlines.current_deadline -
+ grpc_core::ExecCtx::Get()->Now() ==
initial_backoff);
GPR_ASSERT(next_deadlines.next_attempt_start_time -
- grpc_exec_ctx_now(&exec_ctx) ==
+ grpc_core::ExecCtx::Get()->Now() ==
initial_backoff);
- exec_ctx.now = next_deadlines.current_deadline;
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
}
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_min_connect(void) {
@@ -60,17 +61,16 @@ static void test_min_connect(void) {
const grpc_millis max_backoff = 1000;
grpc_backoff_init(&backoff, initial_backoff, multiplier, jitter,
min_connect_timeout, max_backoff);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_backoff_result next = grpc_backoff_begin(&exec_ctx, &backoff);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_backoff_result next = grpc_backoff_begin(&backoff);
// Because the min_connect_timeout > initial_backoff, current_deadline is used
// as the deadline for the current attempt.
- GPR_ASSERT(next.current_deadline - grpc_exec_ctx_now(&exec_ctx) ==
+ GPR_ASSERT(next.current_deadline - grpc_core::ExecCtx::Get()->Now() ==
min_connect_timeout);
// ... while, if the current attempt fails, the next one will happen after
// initial_backoff.
- GPR_ASSERT(next.next_attempt_start_time - grpc_exec_ctx_now(&exec_ctx) ==
+ GPR_ASSERT(next.next_attempt_start_time - grpc_core::ExecCtx::Get()->Now() ==
initial_backoff);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_no_jitter_backoff(void) {
@@ -84,49 +84,47 @@ static void test_no_jitter_backoff(void) {
min_connect_timeout, max_backoff);
// x_1 = 2
// x_n = 2**i + x_{i-1} ( = 2**(n+1) - 2 )
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- exec_ctx.now = 0;
- exec_ctx.now_is_valid = true;
- grpc_backoff_result next_deadlines = grpc_backoff_begin(&exec_ctx, &backoff);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(0);
+ grpc_backoff_result next_deadlines = grpc_backoff_begin(&backoff);
GPR_ASSERT(next_deadlines.current_deadline ==
next_deadlines.next_attempt_start_time);
GPR_ASSERT(next_deadlines.current_deadline == 2);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 6);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 14);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 30);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 62);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 126);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 254);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 510);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 1022);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
// Hit the maximum timeout. From this point onwards, retries will increase
// only by max timeout.
GPR_ASSERT(next_deadlines.current_deadline == 1535);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 2048);
- exec_ctx.now = next_deadlines.current_deadline;
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
+ next_deadlines = grpc_backoff_step(&backoff);
GPR_ASSERT(next_deadlines.current_deadline == 2561);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_jitter_backoff(void) {
@@ -142,12 +140,13 @@ static void test_jitter_backoff(void) {
backoff.rng_state = 0; // force consistent PRNG
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_backoff_result next_deadlines = grpc_backoff_begin(&exec_ctx, &backoff);
- GPR_ASSERT(next_deadlines.current_deadline - grpc_exec_ctx_now(&exec_ctx) ==
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_backoff_result next_deadlines = grpc_backoff_begin(&backoff);
+ GPR_ASSERT(next_deadlines.current_deadline -
+ grpc_core::ExecCtx::Get()->Now() ==
initial_backoff);
GPR_ASSERT(next_deadlines.next_attempt_start_time -
- grpc_exec_ctx_now(&exec_ctx) ==
+ grpc_core::ExecCtx::Get()->Now() ==
initial_backoff);
grpc_millis expected_next_lower_bound =
@@ -156,11 +155,11 @@ static void test_jitter_backoff(void) {
(grpc_millis)((double)current_backoff * (1 + jitter));
for (int i = 0; i < 10000; i++) {
- next_deadlines = grpc_backoff_step(&exec_ctx, &backoff);
+ next_deadlines = grpc_backoff_step(&backoff);
// next-now must be within (jitter*100)% of the current backoff (which
// increases by * multiplier up to max_backoff).
const grpc_millis timeout_millis =
- next_deadlines.current_deadline - grpc_exec_ctx_now(&exec_ctx);
+ next_deadlines.current_deadline - grpc_core::ExecCtx::Get()->Now();
GPR_ASSERT(timeout_millis >= expected_next_lower_bound);
GPR_ASSERT(timeout_millis <= expected_next_upper_bound);
current_backoff = GPR_MIN(
@@ -169,9 +168,8 @@ static void test_jitter_backoff(void) {
(grpc_millis)((double)current_backoff * (1 - jitter));
expected_next_upper_bound =
(grpc_millis)((double)current_backoff * (1 + jitter));
- exec_ctx.now = next_deadlines.current_deadline;
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(next_deadlines.current_deadline);
}
- grpc_exec_ctx_finish(&exec_ctx);
}
int main(int argc, char** argv) {
diff --git a/test/core/bad_client/bad_client.cc b/test/core/bad_client/bad_client.cc
index c19b7bdf40..313c43f9b3 100644
--- a/test/core/bad_client/bad_client.cc
+++ b/test/core/bad_client/bad_client.cc
@@ -50,20 +50,19 @@ static void thd_func(void* arg) {
gpr_event_set(&a->done_thd, (void*)1);
}
-static void done_write(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void done_write(void* arg, grpc_error* error) {
thd_args* a = (thd_args*)arg;
gpr_event_set(&a->done_write, (void*)1);
}
static void server_setup_transport(void* ts, grpc_transport* transport) {
thd_args* a = (thd_args*)ts;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_server_setup_transport(&exec_ctx, a->server, transport, nullptr,
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_server_setup_transport(a->server, transport, nullptr,
grpc_server_get_channel_args(a->server));
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void read_done(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void read_done(void* arg, grpc_error* error) {
gpr_event* read_done = (gpr_event*)arg;
gpr_event_set(read_done, (void*)1);
}
@@ -81,7 +80,7 @@ void grpc_run_bad_client_test(
grpc_slice_from_copied_buffer(client_payload, client_payload_length);
grpc_slice_buffer outgoing;
grpc_closure done_write_closure;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_completion_queue* shutdown_cq;
if (client_payload_length < 4 * 1024) {
@@ -115,14 +114,13 @@ void grpc_run_bad_client_test(
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, nullptr, sfd.server, 0);
+ transport = grpc_create_chttp2_transport(nullptr, sfd.server, 0);
server_setup_transport(&a, transport);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
/* Bind everything into the same pollset */
- grpc_endpoint_add_to_pollset(&exec_ctx, sfd.client, grpc_cq_pollset(a.cq));
- grpc_endpoint_add_to_pollset(&exec_ctx, sfd.server, grpc_cq_pollset(a.cq));
+ grpc_endpoint_add_to_pollset(sfd.client, grpc_cq_pollset(a.cq));
+ grpc_endpoint_add_to_pollset(sfd.server, grpc_cq_pollset(a.cq));
/* Check a ground truth */
GPR_ASSERT(grpc_server_has_open_connections(a.server));
@@ -136,8 +134,7 @@ void grpc_run_bad_client_test(
grpc_schedule_on_exec_ctx);
/* Write data */
- grpc_endpoint_write(&exec_ctx, sfd.client, &outgoing, &done_write_closure);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_endpoint_write(sfd.client, &outgoing, &done_write_closure);
/* Await completion, unless the request is large and write may not finish
* before the peer shuts down. */
@@ -148,10 +145,9 @@ void grpc_run_bad_client_test(
if (flags & GRPC_BAD_CLIENT_DISCONNECT) {
grpc_endpoint_shutdown(
- &exec_ctx, sfd.client,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Disconnect"));
- grpc_endpoint_destroy(&exec_ctx, sfd.client);
- grpc_exec_ctx_finish(&exec_ctx);
+ sfd.client, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Disconnect"));
+ grpc_endpoint_destroy(sfd.client);
+
sfd.client = nullptr;
}
@@ -170,9 +166,8 @@ void grpc_run_bad_client_test(
grpc_closure read_done_closure;
GRPC_CLOSURE_INIT(&read_done_closure, read_done, &read_done_event,
grpc_schedule_on_exec_ctx);
- grpc_endpoint_read(&exec_ctx, sfd.client, &incoming,
- &read_done_closure);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_endpoint_read(sfd.client, &incoming, &read_done_closure);
+
do {
GPR_ASSERT(gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0);
GPR_ASSERT(
@@ -185,14 +180,12 @@ void grpc_run_bad_client_test(
"client validator failed; trying additional read "
"in case we didn't get all the data");
}
- grpc_slice_buffer_destroy_internal(&exec_ctx, &incoming);
+ grpc_slice_buffer_destroy_internal(&incoming);
}
// Shutdown.
grpc_endpoint_shutdown(
- &exec_ctx, sfd.client,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
- grpc_endpoint_destroy(&exec_ctx, sfd.client);
- grpc_exec_ctx_finish(&exec_ctx);
+ sfd.client, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
+ grpc_endpoint_destroy(sfd.client);
}
GPR_ASSERT(
@@ -206,8 +199,7 @@ void grpc_run_bad_client_test(
grpc_completion_queue_destroy(shutdown_cq);
grpc_server_destroy(a.server);
grpc_completion_queue_destroy(a.cq);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &outgoing);
+ grpc_slice_buffer_destroy_internal(&outgoing);
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
}
diff --git a/test/core/channel/channel_args_test.cc b/test/core/channel/channel_args_test.cc
index e8b3334185..99a6566a1c 100644
--- a/test/core/channel/channel_args_test.cc
+++ b/test/core/channel/channel_args_test.cc
@@ -26,7 +26,7 @@
#include "test/core/util/test_config.h"
static void test_create(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_arg arg_int;
grpc_arg arg_string;
@@ -55,12 +55,11 @@ static void test_create(void) {
GPR_ASSERT(strcmp(ch_args->args[1].value.string, arg_string.value.string) ==
0);
- grpc_channel_args_destroy(&exec_ctx, ch_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(ch_args);
}
static void test_set_compression_algorithm(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_channel_args* ch_args;
ch_args =
@@ -70,12 +69,11 @@ static void test_set_compression_algorithm(void) {
GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM) == 0);
GPR_ASSERT(ch_args->args[0].type == GRPC_ARG_INTEGER);
- grpc_channel_args_destroy(&exec_ctx, ch_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(ch_args);
}
static void test_compression_algorithm_states(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_channel_args *ch_args, *ch_args_wo_gzip, *ch_args_wo_gzip_deflate;
unsigned states_bitset;
size_t i;
@@ -91,10 +89,10 @@ static void test_compression_algorithm_states(void) {
/* disable gzip and deflate */
ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state(
- &exec_ctx, &ch_args, GRPC_COMPRESS_GZIP, 0);
+ &ch_args, GRPC_COMPRESS_GZIP, 0);
GPR_ASSERT(ch_args == ch_args_wo_gzip);
ch_args_wo_gzip_deflate = grpc_channel_args_compression_algorithm_set_state(
- &exec_ctx, &ch_args_wo_gzip, GRPC_COMPRESS_DEFLATE, 0);
+ &ch_args_wo_gzip, GRPC_COMPRESS_DEFLATE, 0);
GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate);
states_bitset = (unsigned)grpc_channel_args_compression_algorithm_get_states(
@@ -109,7 +107,7 @@ static void test_compression_algorithm_states(void) {
/* re-enabled gzip only */
ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state(
- &exec_ctx, &ch_args_wo_gzip_deflate, GRPC_COMPRESS_GZIP, 1);
+ &ch_args_wo_gzip_deflate, GRPC_COMPRESS_GZIP, 1);
GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate);
states_bitset = (unsigned)grpc_channel_args_compression_algorithm_get_states(
@@ -122,8 +120,7 @@ static void test_compression_algorithm_states(void) {
}
}
- grpc_channel_args_destroy(&exec_ctx, ch_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(ch_args);
}
static void test_set_socket_mutator(void) {
@@ -137,9 +134,8 @@ static void test_set_socket_mutator(void) {
GPR_ASSERT(ch_args->args[0].type == GRPC_ARG_POINTER);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, ch_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(ch_args);
}
}
diff --git a/test/core/channel/channel_stack_builder_test.cc b/test/core/channel/channel_stack_builder_test.cc
index a67f0efafe..ef6db81b0b 100644
--- a/test/core/channel/channel_stack_builder_test.cc
+++ b/test/core/channel/channel_stack_builder_test.cc
@@ -29,34 +29,30 @@
#include "src/core/lib/surface/channel_init.h"
#include "test/core/util/test_config.h"
-static grpc_error* channel_init_func(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* channel_init_func(grpc_channel_element* elem,
grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
-static grpc_error* call_init_func(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* call_init_func(grpc_call_element* elem,
const grpc_call_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void channel_destroy_func(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void channel_destroy_func(grpc_channel_element* elem) {}
-static void call_destroy_func(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void call_destroy_func(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {}
-static void call_func(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void call_func(grpc_call_element* elem,
grpc_transport_stream_op_batch* op) {}
-static void channel_func(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
- grpc_transport_op* op) {
+static void channel_func(grpc_channel_element* elem, grpc_transport_op* op) {
if (op->disconnect_with_error != GRPC_ERROR_NONE) {
GRPC_ERROR_UNREF(op->disconnect_with_error);
}
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(op->on_consumed, GRPC_ERROR_NONE);
}
bool g_replacement_fn_called = false;
@@ -106,8 +102,7 @@ const grpc_channel_filter original_filter = {
grpc_channel_next_get_info,
"filter_name"};
-static bool add_replacement_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+static bool add_replacement_filter(grpc_channel_stack_builder* builder,
void* arg) {
const grpc_channel_filter* filter =
static_cast<const grpc_channel_filter*>(arg);
@@ -118,8 +113,7 @@ static bool add_replacement_filter(grpc_exec_ctx* exec_ctx,
builder, filter, set_arg_once_fn, &g_replacement_fn_called);
}
-static bool add_original_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+static bool add_original_filter(grpc_channel_stack_builder* builder,
void* arg) {
return grpc_channel_stack_builder_prepend_filter(
builder, (const grpc_channel_filter*)arg, set_arg_once_fn,
diff --git a/test/core/channel/channel_stack_test.cc b/test/core/channel/channel_stack_test.cc
index 988ea9bac9..93ddd0fee5 100644
--- a/test/core/channel/channel_stack_test.cc
+++ b/test/core/channel/channel_stack_test.cc
@@ -27,8 +27,7 @@
#include "src/core/lib/slice/slice_internal.h"
#include "test/core/util/test_config.h"
-static grpc_error* channel_init_func(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* channel_init_func(grpc_channel_element* elem,
grpc_channel_element_args* args) {
GPR_ASSERT(args->channel_args->num_args == 1);
GPR_ASSERT(args->channel_args->args[0].type == GRPC_ARG_INTEGER);
@@ -40,42 +39,37 @@ static grpc_error* channel_init_func(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-static grpc_error* call_init_func(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* call_init_func(grpc_call_element* elem,
const grpc_call_element_args* args) {
++*(int*)(elem->channel_data);
*(int*)(elem->call_data) = 0;
return GRPC_ERROR_NONE;
}
-static void channel_destroy_func(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void channel_destroy_func(grpc_channel_element* elem) {}
-static void call_destroy_func(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void call_destroy_func(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
++*(int*)(elem->channel_data);
}
-static void call_func(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void call_func(grpc_call_element* elem,
grpc_transport_stream_op_batch* op) {
++*(int*)(elem->call_data);
}
-static void channel_func(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
- grpc_transport_op* op) {
+static void channel_func(grpc_channel_element* elem, grpc_transport_op* op) {
++*(int*)(elem->channel_data);
}
-static void free_channel(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
- grpc_channel_stack_destroy(exec_ctx, static_cast<grpc_channel_stack*>(arg));
+static void free_channel(void* arg, grpc_error* error) {
+ grpc_channel_stack_destroy(static_cast<grpc_channel_stack*>(arg));
gpr_free(arg);
}
-static void free_call(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
- grpc_call_stack_destroy(exec_ctx, static_cast<grpc_call_stack*>(arg), nullptr,
- nullptr);
+static void free_call(void* arg, grpc_error* error) {
+ grpc_call_stack_destroy(static_cast<grpc_call_stack*>(arg), nullptr, nullptr);
gpr_free(arg);
}
@@ -101,7 +95,7 @@ static void test_create_channel_stack(void) {
grpc_channel_args chan_args;
int* channel_data;
int* call_data;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_slice path = grpc_slice_from_static_string("/service/method");
arg.type = GRPC_ARG_INTEGER;
@@ -113,8 +107,8 @@ 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, nullptr, "test", channel_stack);
+ grpc_channel_stack_init(1, free_channel, channel_stack, &filters, 1,
+ &chan_args, nullptr, "test", channel_stack);
GPR_ASSERT(channel_stack->count == 1);
channel_elem = grpc_channel_stack_element(channel_stack, 0);
channel_data = (int*)channel_elem->channel_data;
@@ -132,8 +126,8 @@ static void test_create_channel_stack(void) {
nullptr, /* arena */
nullptr /* call_combiner */
};
- grpc_error* error = grpc_call_stack_init(&exec_ctx, channel_stack, 1,
- free_call, call_stack, &args);
+ grpc_error* error =
+ grpc_call_stack_init(channel_stack, 1, free_call, call_stack, &args);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(call_stack->count == 1);
call_elem = grpc_call_stack_element(call_stack, 0);
@@ -143,14 +137,13 @@ static void test_create_channel_stack(void) {
GPR_ASSERT(*call_data == 0);
GPR_ASSERT(*channel_data == 1);
- GRPC_CALL_STACK_UNREF(&exec_ctx, call_stack, "done");
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CALL_STACK_UNREF(call_stack, "done");
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(*channel_data == 2);
- GRPC_CHANNEL_STACK_UNREF(&exec_ctx, channel_stack, "done");
+ GRPC_CHANNEL_STACK_UNREF(channel_stack, "done");
- grpc_slice_unref_internal(&exec_ctx, path);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(path);
}
int main(int argc, char** argv) {
diff --git a/test/core/channel/minimal_stack_is_minimal_test.cc b/test/core/channel/minimal_stack_is_minimal_test.cc
index e0cffa39a8..2373bc6329 100644
--- a/test/core/channel/minimal_stack_is_minimal_test.cc
+++ b/test/core/channel/minimal_stack_is_minimal_test.cc
@@ -125,12 +125,10 @@ static int check_stack(const char* file, int line, const char* transport_name,
grpc_channel_stack_builder_set_transport(builder, &fake_transport);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_stack_builder_set_channel_arguments(&exec_ctx, builder,
- channel_args);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_stack_builder_set_channel_arguments(builder, channel_args);
GPR_ASSERT(grpc_channel_init_create_stack(
- &exec_ctx, builder, (grpc_channel_stack_type)channel_stack_type));
- grpc_exec_ctx_finish(&exec_ctx);
+ builder, (grpc_channel_stack_type)channel_stack_type));
}
// build up our expectation list
@@ -212,10 +210,9 @@ static int check_stack(const char* file, int line, const char* transport_name,
gpr_free(expect);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_stack_builder_destroy(&exec_ctx, builder);
- grpc_channel_args_destroy(&exec_ctx, channel_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_stack_builder_destroy(builder);
+ grpc_channel_args_destroy(channel_args);
}
return result;
diff --git a/test/core/client_channel/lb_policies_test.cc b/test/core/client_channel/lb_policies_test.cc
index 5f8d3b84cc..590f934657 100644
--- a/test/core/client_channel/lb_policies_test.cc
+++ b/test/core/client_channel/lb_policies_test.cc
@@ -651,9 +651,8 @@ static void test_get_channel_info() {
grpc_channel_args* args = grpc_channel_args_copy_and_add(nullptr, &arg, 1);
channel = grpc_insecure_channel_create("ipv4:127.0.0.1:1234", args, nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(args);
}
// Ensures that resolver returns.
grpc_channel_check_connectivity_state(channel, true /* try_to_connect */);
@@ -959,7 +958,7 @@ static void verify_rebirth_round_robin(const servers_fixture* f,
}
int main(int argc, char** argv) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
test_spec* spec;
size_t i;
const size_t NUM_ITERS = 10;
@@ -969,9 +968,9 @@ int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_tracer_set_enabled("round_robin", 1);
- GPR_ASSERT(grpc_lb_policy_create(&exec_ctx, "this-lb-policy-does-not-exist",
- nullptr) == nullptr);
- GPR_ASSERT(grpc_lb_policy_create(&exec_ctx, nullptr, nullptr) == nullptr);
+ GPR_ASSERT(grpc_lb_policy_create("this-lb-policy-does-not-exist", nullptr) ==
+ nullptr);
+ GPR_ASSERT(grpc_lb_policy_create(nullptr, nullptr) == nullptr);
spec = test_spec_create(NUM_ITERS, NUM_SERVERS);
/* everything is fine, all servers stay up the whole time and life's peachy
@@ -1025,7 +1024,6 @@ int main(int argc, char** argv) {
test_ping();
test_get_channel_info();
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
return 0;
}
diff --git a/test/core/client_channel/parse_address_test.cc b/test/core/client_channel/parse_address_test.cc
index 94f76da920..f64b092743 100644
--- a/test/core/client_channel/parse_address_test.cc
+++ b/test/core/client_channel/parse_address_test.cc
@@ -33,8 +33,8 @@
#ifdef GRPC_HAVE_UNIX_SOCKET
static void test_grpc_parse_unix(const char* uri_text, const char* pathname) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
grpc_resolved_address addr;
GPR_ASSERT(1 == grpc_parse_unix(uri, &addr));
@@ -43,7 +43,6 @@ static void test_grpc_parse_unix(const char* uri_text, const char* pathname) {
GPR_ASSERT(0 == strcmp(addr_un->sun_path, pathname));
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish(&exec_ctx);
}
#else /* GRPC_HAVE_UNIX_SOCKET */
@@ -54,8 +53,8 @@ static void test_grpc_parse_unix(const char* uri_text, const char* pathname) {}
static void test_grpc_parse_ipv4(const char* uri_text, const char* host,
unsigned short port) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
grpc_resolved_address addr;
char ntop_buf[INET_ADDRSTRLEN];
@@ -68,13 +67,12 @@ static void test_grpc_parse_ipv4(const char* uri_text, const char* host,
GPR_ASSERT(ntohs(addr_in->sin_port) == port);
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_grpc_parse_ipv6(const char* uri_text, const char* host,
unsigned short port, uint32_t scope_id) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
grpc_resolved_address addr;
char ntop_buf[INET6_ADDRSTRLEN];
@@ -88,7 +86,6 @@ static void test_grpc_parse_ipv6(const char* uri_text, const char* host,
GPR_ASSERT(addr_in6->sin6_scope_id == scope_id);
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish(&exec_ctx);
}
int main(int argc, char** argv) {
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 dcf315eba5..08ce148efe 100644
--- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
+++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
@@ -35,8 +35,7 @@ static gpr_mu g_mu;
static bool g_fail_resolution = true;
static grpc_combiner* g_combiner;
-static void my_resolve_address(grpc_exec_ctx* exec_ctx, const char* addr,
- const char* default_port,
+static void my_resolve_address(const char* addr, const char* default_port,
grpc_pollset_set* interested_parties,
grpc_closure* on_done,
grpc_resolved_addresses** addrs) {
@@ -55,13 +54,13 @@ static void my_resolve_address(grpc_exec_ctx* exec_ctx, const char* addr,
gpr_malloc(sizeof(*(*addrs)->addrs)));
(*addrs)->addrs[0].len = 123;
}
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
+ GRPC_CLOSURE_SCHED(on_done, error);
}
static grpc_ares_request* my_dns_lookup_ares(
- grpc_exec_ctx* exec_ctx, const char* dns_server, const char* addr,
- const char* default_port, grpc_pollset_set* interested_parties,
- grpc_closure* on_done, grpc_lb_addresses** lb_addrs, bool check_grpclb,
+ const char* dns_server, const char* addr, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** lb_addrs, bool check_grpclb,
char** service_config_json) {
gpr_mu_lock(&g_mu);
GPR_ASSERT(0 == strcmp("test", addr));
@@ -76,27 +75,26 @@ static grpc_ares_request* my_dns_lookup_ares(
grpc_lb_addresses_set_address(*lb_addrs, 0, nullptr, 0, false, nullptr,
nullptr);
}
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
+ GRPC_CLOSURE_SCHED(on_done, error);
return nullptr;
}
-static grpc_resolver* create_resolver(grpc_exec_ctx* exec_ctx,
- const char* name) {
+static grpc_resolver* create_resolver(const char* name) {
grpc_resolver_factory* factory = grpc_resolver_factory_lookup("dns");
- grpc_uri* uri = grpc_uri_parse(exec_ctx, name, 0);
+ grpc_uri* uri = grpc_uri_parse(name, 0);
GPR_ASSERT(uri);
grpc_resolver_args args;
memset(&args, 0, sizeof(args));
args.uri = uri;
args.combiner = g_combiner;
grpc_resolver* resolver =
- grpc_resolver_factory_create_resolver(exec_ctx, factory, &args);
+ grpc_resolver_factory_create_resolver(factory, &args);
grpc_resolver_factory_unref(factory);
grpc_uri_destroy(uri);
return resolver;
}
-static void on_done(grpc_exec_ctx* exec_ctx, void* ev, grpc_error* error) {
+static void on_done(void* ev, grpc_error* error) {
gpr_event_set((gpr_event*)ev, (void*)1);
}
@@ -107,9 +105,8 @@ static bool wait_loop(int deadline_seconds, gpr_event* ev) {
if (gpr_event_wait(ev, grpc_timeout_seconds_to_deadline(1))) return true;
deadline_seconds--;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_timer_check(&exec_ctx, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_timer_check(nullptr);
}
return false;
}
@@ -120,16 +117,14 @@ typedef struct next_args {
grpc_closure* on_complete;
} next_args;
-static void call_resolver_next_now_lock_taken(grpc_exec_ctx* exec_ctx,
- void* arg,
+static void call_resolver_next_now_lock_taken(void* arg,
grpc_error* error_unused) {
next_args* a = static_cast<next_args*>(arg);
- grpc_resolver_next_locked(exec_ctx, a->resolver, a->result, a->on_complete);
+ grpc_resolver_next_locked(a->resolver, a->result, a->on_complete);
gpr_free(a);
}
-static void call_resolver_next_after_locking(grpc_exec_ctx* exec_ctx,
- grpc_resolver* resolver,
+static void call_resolver_next_after_locking(grpc_resolver* resolver,
grpc_channel_args** result,
grpc_closure* on_complete) {
next_args* a = static_cast<next_args*>(gpr_malloc(sizeof(*a)));
@@ -137,7 +132,6 @@ static void call_resolver_next_after_locking(grpc_exec_ctx* exec_ctx,
a->result = result;
a->on_complete = on_complete;
GRPC_CLOSURE_SCHED(
- exec_ctx,
GRPC_CLOSURE_CREATE(call_resolver_next_now_lock_taken, a,
grpc_combiner_scheduler(resolver->combiner)),
GRPC_ERROR_NONE);
@@ -153,30 +147,29 @@ int main(int argc, char** argv) {
grpc_dns_lookup_ares = my_dns_lookup_ares;
grpc_channel_args* result = (grpc_channel_args*)1;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resolver* resolver = create_resolver(&exec_ctx, "dns:test");
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resolver* resolver = create_resolver("dns:test");
gpr_event ev1;
gpr_event_init(&ev1);
call_resolver_next_after_locking(
- &exec_ctx, resolver, &result,
+ resolver, &result,
GRPC_CLOSURE_CREATE(on_done, &ev1, grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(wait_loop(5, &ev1));
GPR_ASSERT(result == nullptr);
gpr_event ev2;
gpr_event_init(&ev2);
call_resolver_next_after_locking(
- &exec_ctx, resolver, &result,
+ resolver, &result,
GRPC_CLOSURE_CREATE(on_done, &ev2, grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(wait_loop(30, &ev2));
GPR_ASSERT(result != nullptr);
- grpc_channel_args_destroy(&exec_ctx, result);
- GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test");
- GRPC_COMBINER_UNREF(&exec_ctx, g_combiner, "test");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(result);
+ GRPC_RESOLVER_UNREF(resolver, "test");
+ GRPC_COMBINER_UNREF(g_combiner, "test");
grpc_shutdown();
gpr_mu_destroy(&g_mu);
diff --git a/test/core/client_channel/resolvers/dns_resolver_test.cc b/test/core/client_channel/resolvers/dns_resolver_test.cc
index 4c040caeb9..63d1287521 100644
--- a/test/core/client_channel/resolvers/dns_resolver_test.cc
+++ b/test/core/client_channel/resolvers/dns_resolver_test.cc
@@ -28,8 +28,8 @@
static grpc_combiner* g_combiner;
static void test_succeeds(grpc_resolver_factory* factory, const char* string) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, string, 0);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(string, 0);
grpc_resolver_args args;
grpc_resolver* resolver;
gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string,
@@ -38,16 +38,15 @@ static void test_succeeds(grpc_resolver_factory* factory, const char* string) {
memset(&args, 0, sizeof(args));
args.uri = uri;
args.combiner = g_combiner;
- resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
+ resolver = grpc_resolver_factory_create_resolver(factory, &args);
GPR_ASSERT(resolver != nullptr);
- GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test_succeeds");
+ GRPC_RESOLVER_UNREF(resolver, "test_succeeds");
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_fails(grpc_resolver_factory* factory, const char* string) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, string, 0);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(string, 0);
grpc_resolver_args args;
grpc_resolver* resolver;
gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string,
@@ -56,10 +55,9 @@ static void test_fails(grpc_resolver_factory* factory, const char* string) {
memset(&args, 0, sizeof(args));
args.uri = uri;
args.combiner = g_combiner;
- resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
+ resolver = grpc_resolver_factory_create_resolver(factory, &args);
GPR_ASSERT(resolver == nullptr);
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish(&exec_ctx);
}
int main(int argc, char** argv) {
@@ -82,9 +80,8 @@ int main(int argc, char** argv) {
grpc_resolver_factory_unref(dns);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_COMBINER_UNREF(&exec_ctx, g_combiner, "test");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_COMBINER_UNREF(g_combiner, "test");
}
grpc_shutdown();
diff --git a/test/core/client_channel/resolvers/fake_resolver_test.cc b/test/core/client_channel/resolvers/fake_resolver_test.cc
index d5538e9621..ecfe43f9b7 100644
--- a/test/core/client_channel/resolvers/fake_resolver_test.cc
+++ b/test/core/client_channel/resolvers/fake_resolver_test.cc
@@ -33,7 +33,7 @@
#include "test/core/util/test_config.h"
static grpc_resolver* build_fake_resolver(
- grpc_exec_ctx* exec_ctx, grpc_combiner* combiner,
+ grpc_combiner* combiner,
grpc_fake_resolver_response_generator* response_generator) {
grpc_resolver_factory* factory = grpc_resolver_factory_lookup("fake");
grpc_arg generator_arg =
@@ -44,7 +44,7 @@ static grpc_resolver* build_fake_resolver(
args.args = &channel_args;
args.combiner = combiner;
grpc_resolver* resolver =
- grpc_resolver_factory_create_resolver(exec_ctx, factory, &args);
+ grpc_resolver_factory_create_resolver(factory, &args);
grpc_resolver_factory_unref(factory);
return resolver;
}
@@ -55,7 +55,7 @@ typedef struct on_resolution_arg {
gpr_event ev;
} on_resolution_arg;
-void on_resolution_cb(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+void on_resolution_cb(void* arg, grpc_error* error) {
on_resolution_arg* res = static_cast<on_resolution_arg*>(arg);
// We only check the addresses channel arg because that's the only one
// explicitly set by the test via
@@ -66,24 +66,23 @@ void on_resolution_cb(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
grpc_lb_addresses_find_channel_arg(res->expected_resolver_result);
GPR_ASSERT(
grpc_lb_addresses_cmp(actual_lb_addresses, expected_lb_addresses) == 0);
- grpc_channel_args_destroy(exec_ctx, res->resolver_result);
- grpc_channel_args_destroy(exec_ctx, res->expected_resolver_result);
+ grpc_channel_args_destroy(res->resolver_result);
+ grpc_channel_args_destroy(res->expected_resolver_result);
gpr_event_set(&res->ev, (void*)1);
}
static void test_fake_resolver() {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_combiner* combiner = grpc_combiner_create();
// Create resolver.
grpc_fake_resolver_response_generator* response_generator =
grpc_fake_resolver_response_generator_create();
- grpc_resolver* resolver =
- build_fake_resolver(&exec_ctx, combiner, response_generator);
+ grpc_resolver* resolver = build_fake_resolver(combiner, response_generator);
GPR_ASSERT(resolver != nullptr);
// Setup expectations.
- grpc_uri* uris[] = {grpc_uri_parse(&exec_ctx, "ipv4:10.2.1.1:1234", true),
- grpc_uri_parse(&exec_ctx, "ipv4:127.0.0.1:4321", true)};
+ grpc_uri* uris[] = {grpc_uri_parse("ipv4:10.2.1.1:1234", true),
+ grpc_uri_parse("ipv4:127.0.0.1:4321", true)};
const char* balancer_names[] = {"name1", "name2"};
const bool is_balancer[] = {true, false};
grpc_lb_addresses* addresses = grpc_lb_addresses_create(3, nullptr);
@@ -96,7 +95,7 @@ static void test_fake_resolver() {
grpc_lb_addresses_create_channel_arg(addresses);
grpc_channel_args* results =
grpc_channel_args_copy_and_add(nullptr, &addresses_arg, 1);
- grpc_lb_addresses_destroy(&exec_ctx, addresses);
+ grpc_lb_addresses_destroy(addresses);
on_resolution_arg on_res_arg;
memset(&on_res_arg, 0, sizeof(on_res_arg));
on_res_arg.expected_resolver_result = results;
@@ -106,17 +105,16 @@ static void test_fake_resolver() {
// Set resolver results and trigger first resolution. on_resolution_cb
// performs the checks.
- grpc_fake_resolver_response_generator_set_response(
- &exec_ctx, response_generator, results);
- grpc_resolver_next_locked(&exec_ctx, resolver, &on_res_arg.resolver_result,
+ grpc_fake_resolver_response_generator_set_response(response_generator,
+ results);
+ grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
on_resolution);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
// Setup update.
- grpc_uri* uris_update[] = {
- grpc_uri_parse(&exec_ctx, "ipv4:192.168.1.0:31416", true)};
+ grpc_uri* uris_update[] = {grpc_uri_parse("ipv4:192.168.1.0:31416", true)};
const char* balancer_names_update[] = {"name3"};
const bool is_balancer_update[] = {false};
grpc_lb_addresses* addresses_update = grpc_lb_addresses_create(1, nullptr);
@@ -131,7 +129,7 @@ static void test_fake_resolver() {
grpc_lb_addresses_create_channel_arg(addresses_update);
grpc_channel_args* results_update =
grpc_channel_args_copy_and_add(nullptr, &addresses_update_arg, 1);
- grpc_lb_addresses_destroy(&exec_ctx, addresses_update);
+ grpc_lb_addresses_destroy(addresses_update);
// Setup expectations for the update.
on_resolution_arg on_res_arg_update;
@@ -142,27 +140,27 @@ static void test_fake_resolver() {
grpc_combiner_scheduler(combiner));
// Set updated resolver results and trigger a second resolution.
- grpc_fake_resolver_response_generator_set_response(
- &exec_ctx, response_generator, results_update);
- grpc_resolver_next_locked(&exec_ctx, resolver,
- &on_res_arg_update.resolver_result, on_resolution);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_fake_resolver_response_generator_set_response(response_generator,
+ results_update);
+ grpc_resolver_next_locked(resolver, &on_res_arg_update.resolver_result,
+ on_resolution);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&on_res_arg_update.ev,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
// Requesting a new resolution without re-senting the response shouldn't
// trigger the resolution callback.
memset(&on_res_arg, 0, sizeof(on_res_arg));
- grpc_resolver_next_locked(&exec_ctx, resolver, &on_res_arg.resolver_result,
+ grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
on_resolution);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&on_res_arg.ev,
grpc_timeout_milliseconds_to_deadline(100)) ==
nullptr);
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "test_fake_resolver");
- GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test_fake_resolver");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner, "test_fake_resolver");
+ GRPC_RESOLVER_UNREF(resolver, "test_fake_resolver");
+
grpc_fake_resolver_response_generator_unref(response_generator);
}
diff --git a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc
index dfa2d12b5e..f3711c151e 100644
--- a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc
+++ b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc
@@ -35,14 +35,14 @@ typedef struct on_resolution_arg {
grpc_channel_args* resolver_result;
} on_resolution_arg;
-void on_resolution_cb(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+void on_resolution_cb(void* arg, grpc_error* error) {
on_resolution_arg* res = static_cast<on_resolution_arg*>(arg);
- grpc_channel_args_destroy(exec_ctx, res->resolver_result);
+ grpc_channel_args_destroy(res->resolver_result);
}
static void test_succeeds(grpc_resolver_factory* factory, const char* string) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, string, 0);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(string, 0);
grpc_resolver_args args;
grpc_resolver* resolver;
gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string,
@@ -51,7 +51,7 @@ static void test_succeeds(grpc_resolver_factory* factory, const char* string) {
memset(&args, 0, sizeof(args));
args.uri = uri;
args.combiner = g_combiner;
- resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
+ resolver = grpc_resolver_factory_create_resolver(factory, &args);
GPR_ASSERT(resolver != nullptr);
on_resolution_arg on_res_arg;
@@ -60,16 +60,16 @@ static void test_succeeds(grpc_resolver_factory* factory, const char* string) {
grpc_closure* on_resolution = GRPC_CLOSURE_CREATE(
on_resolution_cb, &on_res_arg, grpc_schedule_on_exec_ctx);
- grpc_resolver_next_locked(&exec_ctx, resolver, &on_res_arg.resolver_result,
+ grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result,
on_resolution);
- GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test_succeeds");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_RESOLVER_UNREF(resolver, "test_succeeds");
+
grpc_uri_destroy(uri);
}
static void test_fails(grpc_resolver_factory* factory, const char* string) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, string, 0);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(string, 0);
grpc_resolver_args args;
grpc_resolver* resolver;
gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string,
@@ -78,10 +78,9 @@ static void test_fails(grpc_resolver_factory* factory, const char* string) {
memset(&args, 0, sizeof(args));
args.uri = uri;
args.combiner = g_combiner;
- resolver = grpc_resolver_factory_create_resolver(&exec_ctx, factory, &args);
+ resolver = grpc_resolver_factory_create_resolver(factory, &args);
GPR_ASSERT(resolver == nullptr);
grpc_uri_destroy(uri);
- grpc_exec_ctx_finish(&exec_ctx);
}
int main(int argc, char** argv) {
@@ -112,9 +111,8 @@ int main(int argc, char** argv) {
grpc_resolver_factory_unref(ipv6);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_COMBINER_UNREF(&exec_ctx, g_combiner, "test");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_COMBINER_UNREF(g_combiner, "test");
}
grpc_shutdown();
diff --git a/test/core/client_channel/uri_fuzzer_test.cc b/test/core/client_channel/uri_fuzzer_test.cc
index ba31793ff3..484676e472 100644
--- a/test/core/client_channel/uri_fuzzer_test.cc
+++ b/test/core/client_channel/uri_fuzzer_test.cc
@@ -33,12 +33,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
memcpy(s, data, size);
s[size] = 0;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_uri* x;
- if ((x = grpc_uri_parse(&exec_ctx, s, 1))) {
+ if ((x = grpc_uri_parse(s, 1))) {
grpc_uri_destroy(x);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_free(s);
return 0;
}
diff --git a/test/core/client_channel/uri_parser_test.cc b/test/core/client_channel/uri_parser_test.cc
index 30183f9f57..1694f2363d 100644
--- a/test/core/client_channel/uri_parser_test.cc
+++ b/test/core/client_channel/uri_parser_test.cc
@@ -28,29 +28,28 @@
static void test_succeeds(const char* uri_text, const char* scheme,
const char* authority, const char* path,
const char* query, const char* fragment) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp(scheme, uri->scheme));
GPR_ASSERT(0 == strcmp(authority, uri->authority));
GPR_ASSERT(0 == strcmp(path, uri->path));
GPR_ASSERT(0 == strcmp(query, uri->query));
GPR_ASSERT(0 == strcmp(fragment, uri->fragment));
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_uri_destroy(uri);
}
static void test_fails(const char* uri_text) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(nullptr == grpc_uri_parse(&exec_ctx, uri_text, 0));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GPR_ASSERT(nullptr == grpc_uri_parse(uri_text, 0));
}
static void test_query_parts() {
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
const char* uri_text = "http://foo/path?a&b=B&c=&#frag";
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp("http", uri->scheme));
@@ -77,14 +76,14 @@ static void test_query_parts() {
GPR_ASSERT(nullptr == grpc_uri_get_query_arg(uri, ""));
GPR_ASSERT(0 == strcmp("frag", uri->fragment));
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_uri_destroy(uri);
}
{
/* test the current behavior of multiple query part values */
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
const char* uri_text = "http://auth/path?foo=bar=baz&foobar==";
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp("http", uri->scheme));
@@ -96,14 +95,13 @@ static void test_query_parts() {
GPR_ASSERT(0 == strcmp("bar", grpc_uri_get_query_arg(uri, "foo")));
GPR_ASSERT(0 == strcmp("", grpc_uri_get_query_arg(uri, "foobar")));
- grpc_exec_ctx_finish(&exec_ctx);
grpc_uri_destroy(uri);
}
{
/* empty query */
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
const char* uri_text = "http://foo/path";
- grpc_uri* uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp("http", uri->scheme));
@@ -114,7 +112,7 @@ static void test_query_parts() {
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 2f1d8bc8eb..b0613c4b7d 100644
--- a/test/core/compression/algorithm_test.cc
+++ b/test/core/compression/algorithm_test.cc
@@ -39,7 +39,7 @@ static void test_algorithm_mesh(void) {
grpc_compression_algorithm parsed;
grpc_slice mdstr;
grpc_mdelem mdelem;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GPR_ASSERT(
grpc_compression_algorithm_name((grpc_compression_algorithm)i, &name));
GPR_ASSERT(grpc_compression_algorithm_parse(
@@ -51,9 +51,8 @@ static void test_algorithm_mesh(void) {
mdelem = grpc_compression_encoding_mdelem(parsed);
GPR_ASSERT(grpc_slice_eq(GRPC_MDVALUE(mdelem), mdstr));
GPR_ASSERT(grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_GRPC_ENCODING));
- grpc_slice_unref_internal(&exec_ctx, mdstr);
- GRPC_MDELEM_UNREF(&exec_ctx, mdelem);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(mdstr);
+ GRPC_MDELEM_UNREF(mdelem);
}
/* test failure */
@@ -62,7 +61,7 @@ static void test_algorithm_mesh(void) {
}
static void test_algorithm_failure(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_slice mdstr;
gpr_log(GPR_DEBUG, "test_algorithm_failure");
@@ -83,8 +82,7 @@ static void test_algorithm_failure(void) {
grpc_compression_algorithm_slice(static_cast<grpc_compression_algorithm>(
static_cast<int>(GRPC_COMPRESS_ALGORITHMS_COUNT) + 1)),
grpc_empty_slice()));
- grpc_slice_unref_internal(&exec_ctx, mdstr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(mdstr);
}
int main(int argc, char** argv) {
diff --git a/test/core/compression/message_compress_test.cc b/test/core/compression/message_compress_test.cc
index 676415ba9d..0145b4f402 100644
--- a/test/core/compression/message_compress_test.cc
+++ b/test/core/compression/message_compress_test.cc
@@ -70,10 +70,8 @@ static void assert_passthrough(grpc_slice value,
grpc_split_slices_to_buffer(uncompressed_split_mode, &value, 1, &input);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- was_compressed =
- grpc_msg_compress(&exec_ctx, algorithm, &input, &compressed_raw);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ was_compressed = grpc_msg_compress(algorithm, &input, &compressed_raw);
}
GPR_ASSERT(input.count > 0);
@@ -92,11 +90,9 @@ static void assert_passthrough(grpc_slice value,
grpc_split_slice_buffer(compressed_split_mode, &compressed_raw, &compressed);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GPR_ASSERT(grpc_msg_decompress(
- &exec_ctx, was_compressed ? algorithm : GRPC_COMPRESS_NONE, &compressed,
- &output));
- grpc_exec_ctx_finish(&exec_ctx);
+ was_compressed ? algorithm : GRPC_COMPRESS_NONE, &compressed, &output));
}
final = grpc_slice_merge(output.slices, output.count);
@@ -156,11 +152,11 @@ static void test_tiny_data_compress(void) {
for (int i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
if (i == GRPC_COMPRESS_NONE) continue;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(0 == grpc_msg_compress(
- &exec_ctx, static_cast<grpc_compression_algorithm>(i),
- &input, &output));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GPR_ASSERT(0 ==
+ grpc_msg_compress(static_cast<grpc_compression_algorithm>(i),
+ &input, &output));
+
GPR_ASSERT(1 == output.count);
}
@@ -180,9 +176,9 @@ static void test_bad_decompression_data_crc(void) {
grpc_slice_buffer_init(&output);
grpc_slice_buffer_add(&input, create_test_value(ONE_MB_A));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
/* compress it */
- grpc_msg_compress(&exec_ctx, GRPC_COMPRESS_GZIP, &input, &corrupted);
+ grpc_msg_compress(GRPC_COMPRESS_GZIP, &input, &corrupted);
/* corrupt the output by smashing the CRC */
GPR_ASSERT(corrupted.count > 1);
GPR_ASSERT(GRPC_SLICE_LENGTH(corrupted.slices[1]) > 8);
@@ -190,9 +186,7 @@ static void test_bad_decompression_data_crc(void) {
memcpy(GRPC_SLICE_START_PTR(corrupted.slices[1]) + idx, &bad, 4);
/* try (and fail) to decompress the corrupted compresed buffer */
- GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_COMPRESS_GZIP, &corrupted,
- &output));
- grpc_exec_ctx_finish(&exec_ctx);
+ GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_GZIP, &corrupted, &output));
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&corrupted);
@@ -211,10 +205,8 @@ static void test_bad_decompression_data_trailing_garbage(void) {
"\x78\xda\x63\x60\x60\x60\x00\x00\x00\x04\x00\x01\x99", 13));
/* try (and fail) to decompress the invalid compresed buffer */
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_COMPRESS_DEFLATE, &input,
- &output));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_DEFLATE, &input, &output));
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -230,10 +222,8 @@ static void test_bad_decompression_data_stream(void) {
grpc_slice_from_copied_buffer("\x78\xda\xff\xff", 4));
/* try (and fail) to decompress the invalid compresed buffer */
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(0 == grpc_msg_decompress(&exec_ctx, GRPC_COMPRESS_DEFLATE, &input,
- &output));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_DEFLATE, &input, &output));
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -249,17 +239,15 @@ static void test_bad_compression_algorithm(void) {
grpc_slice_buffer_add(
&input, grpc_slice_from_copied_string("Never gonna give you up"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- was_compressed = grpc_msg_compress(&exec_ctx, GRPC_COMPRESS_ALGORITHMS_COUNT,
- &input, &output);
+ grpc_core::ExecCtx _local_exec_ctx;
+ was_compressed =
+ grpc_msg_compress(GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output);
GPR_ASSERT(0 == was_compressed);
- was_compressed = grpc_msg_compress(&exec_ctx,
- static_cast<grpc_compression_algorithm>(
+ was_compressed = grpc_msg_compress(static_cast<grpc_compression_algorithm>(
GRPC_COMPRESS_ALGORITHMS_COUNT + 123),
&input, &output);
GPR_ASSERT(0 == was_compressed);
- grpc_exec_ctx_finish(&exec_ctx);
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
@@ -275,18 +263,16 @@ static void test_bad_decompression_algorithm(void) {
grpc_slice_buffer_add(&input,
grpc_slice_from_copied_string(
"I'm not really compressed but it doesn't matter"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- was_decompressed = grpc_msg_decompress(
- &exec_ctx, GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output);
+ grpc_core::ExecCtx _local_exec_ctx;
+ was_decompressed =
+ grpc_msg_decompress(GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output);
GPR_ASSERT(0 == was_decompressed);
was_decompressed =
- grpc_msg_decompress(&exec_ctx,
- static_cast<grpc_compression_algorithm>(
+ grpc_msg_decompress(static_cast<grpc_compression_algorithm>(
GRPC_COMPRESS_ALGORITHMS_COUNT + 123),
&input, &output);
GPR_ASSERT(0 == was_decompressed);
- grpc_exec_ctx_finish(&exec_ctx);
grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&output);
diff --git a/test/core/debug/stats_test.cc b/test/core/debug/stats_test.cc
index 5fae61f8f6..1623e7c8a4 100644
--- a/test/core/debug/stats_test.cc
+++ b/test/core/debug/stats_test.cc
@@ -49,9 +49,8 @@ TEST(StatsTest, IncCounters) {
for (int i = 0; i < GRPC_STATS_COUNTER_COUNT; i++) {
Snapshot snapshot;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_STATS_INC_COUNTER(&exec_ctx, (grpc_stats_counters)i);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_STATS_INC_COUNTER((grpc_stats_counters)i);
EXPECT_EQ(snapshot.delta().counters[i], 1);
}
@@ -60,9 +59,8 @@ TEST(StatsTest, IncCounters) {
TEST(StatsTest, IncSpecificCounter) {
Snapshot snapshot;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_STATS_INC_SYSCALL_POLL(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_STATS_INC_SYSCALL_POLL();
EXPECT_EQ(snapshot.delta().counters[GRPC_STATS_COUNTER_SYSCALL_POLL], 1);
}
@@ -94,9 +92,8 @@ TEST_P(HistogramTest, IncHistogram) {
for (auto j : test_values) {
Snapshot snapshot;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_stats_inc_histogram[kHistogram](&exec_ctx, j);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_stats_inc_histogram[kHistogram](j);
auto delta = snapshot.delta();
diff --git a/test/core/end2end/bad_server_response_test.cc b/test/core/end2end/bad_server_response_test.cc
index b0c6ae926e..576d39b319 100644
--- a/test/core/end2end/bad_server_response_test.cc
+++ b/test/core/end2end/bad_server_response_test.cc
@@ -91,22 +91,22 @@ static grpc_closure on_write;
static void* tag(intptr_t t) { return (void*)t; }
-static void done_write(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void done_write(void* arg, grpc_error* error) {
GPR_ASSERT(error == GRPC_ERROR_NONE);
gpr_atm_rel_store(&state.done_atm, 1);
}
-static void handle_write(grpc_exec_ctx* exec_ctx) {
+static void handle_write() {
grpc_slice slice = grpc_slice_from_copied_buffer(
state.response_payload, state.response_payload_length);
grpc_slice_buffer_reset_and_unref(&state.outgoing_buffer);
grpc_slice_buffer_add(&state.outgoing_buffer, slice);
- grpc_endpoint_write(exec_ctx, state.tcp, &state.outgoing_buffer, &on_write);
+ grpc_endpoint_write(state.tcp, &state.outgoing_buffer, &on_write);
}
-static void handle_read(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void handle_read(void* arg, grpc_error* error) {
GPR_ASSERT(error == GRPC_ERROR_NONE);
state.incoming_data_length += state.temp_incoming_buffer.length;
@@ -123,14 +123,13 @@ static void handle_read(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
SERVER_INCOMING_DATA_LENGTH_LOWER_THRESHOLD);
if (state.incoming_data_length >=
SERVER_INCOMING_DATA_LENGTH_LOWER_THRESHOLD) {
- handle_write(exec_ctx);
+ handle_write();
} else {
- grpc_endpoint_read(exec_ctx, state.tcp, &state.temp_incoming_buffer,
- &on_read);
+ grpc_endpoint_read(state.tcp, &state.temp_incoming_buffer, &on_read);
}
}
-static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
+static void on_connect(void* arg, grpc_endpoint* tcp,
grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) {
gpr_free(acceptor);
@@ -141,8 +140,8 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
grpc_slice_buffer_init(&state.outgoing_buffer);
state.tcp = tcp;
state.incoming_data_length = 0;
- grpc_endpoint_add_to_pollset(exec_ctx, tcp, server->pollset);
- grpc_endpoint_read(exec_ctx, tcp, &state.temp_incoming_buffer, &on_read);
+ grpc_endpoint_add_to_pollset(tcp, server->pollset);
+ grpc_endpoint_read(tcp, &state.temp_incoming_buffer, &on_read);
}
static gpr_timespec n_sec_deadline(int seconds) {
@@ -217,10 +216,10 @@ static void start_rpc(int target_port, grpc_status_code expected_status,
cq_verifier_destroy(cqv);
}
-static void cleanup_rpc(grpc_exec_ctx* exec_ctx) {
+static void cleanup_rpc() {
grpc_event ev;
- grpc_slice_buffer_destroy_internal(exec_ctx, &state.temp_incoming_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &state.outgoing_buffer);
+ grpc_slice_buffer_destroy_internal(&state.temp_incoming_buffer);
+ grpc_slice_buffer_destroy_internal(&state.outgoing_buffer);
grpc_call_unref(state.call);
grpc_completion_queue_shutdown(state.cq);
do {
@@ -270,7 +269,7 @@ static void run_test(const char* response_payload,
grpc_status_code expected_status,
const char* expected_detail) {
test_tcp_server test_server;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_event ev;
grpc_init();
@@ -287,11 +286,11 @@ static void run_test(const char* response_payload,
gpr_event_wait(&ev, gpr_inf_future(GPR_CLOCK_REALTIME));
/* clean up */
- grpc_endpoint_shutdown(&exec_ctx, state.tcp,
+ grpc_endpoint_shutdown(state.tcp,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
- grpc_endpoint_destroy(&exec_ctx, state.tcp);
- cleanup_rpc(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_endpoint_destroy(state.tcp);
+ cleanup_rpc();
+
test_tcp_server_destroy(&test_server);
grpc_shutdown();
diff --git a/test/core/end2end/connection_refused_test.cc b/test/core/end2end/connection_refused_test.cc
index f3f2dda91d..9904c1384c 100644
--- a/test/core/end2end/connection_refused_test.cc
+++ b/test/core/end2end/connection_refused_test.cc
@@ -133,9 +133,8 @@ static void run_test(bool wait_for_ready, bool use_service_config) {
grpc_metadata_array_destroy(&trailing_metadata_recv);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- if (args != nullptr) grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ if (args != nullptr) grpc_channel_args_destroy(args);
}
grpc_shutdown();
diff --git a/test/core/end2end/fixtures/h2_census.cc b/test/core/end2end/fixtures/h2_census.cc
index fed8ead5c8..60aafc3b94 100644
--- a/test/core/end2end/fixtures/h2_census.cc
+++ b/test/core/end2end/fixtures/h2_census.cc
@@ -75,9 +75,8 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f,
grpc_insecure_channel_create(ffd->localaddr, client_args, nullptr);
GPR_ASSERT(f->client);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(client_args);
}
}
@@ -92,9 +91,8 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
server_args = grpc_channel_args_copy_and_add(server_args, &arg, 1);
f->server = grpc_server_create(server_args, nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(server_args);
}
grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
diff --git a/test/core/end2end/fixtures/h2_compress.cc b/test/core/end2end/fixtures/h2_compress.cc
index ea8990fd0a..040c041f38 100644
--- a/test/core/end2end/fixtures/h2_compress.cc
+++ b/test/core/end2end/fixtures/h2_compress.cc
@@ -66,9 +66,8 @@ void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture* f,
fullstack_compression_fixture_data* ffd =
static_cast<fullstack_compression_fixture_data*>(f->fixture_data);
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);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(ffd->client_args_compression);
}
ffd->client_args_compression = grpc_channel_args_set_compression_algorithm(
client_args, GRPC_COMPRESS_GZIP);
@@ -81,9 +80,8 @@ void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture* f,
fullstack_compression_fixture_data* ffd =
static_cast<fullstack_compression_fixture_data*>(f->fixture_data);
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);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(ffd->server_args_compression);
}
ffd->server_args_compression = grpc_channel_args_set_compression_algorithm(
server_args, GRPC_COMPRESS_GZIP);
@@ -97,14 +95,13 @@ void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture* f,
}
void chttp2_tear_down_fullstack_compression(grpc_end2end_test_fixture* f) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
fullstack_compression_fixture_data* ffd =
static_cast<fullstack_compression_fixture_data*>(f->fixture_data);
- grpc_channel_args_destroy(&exec_ctx, ffd->client_args_compression);
- grpc_channel_args_destroy(&exec_ctx, ffd->server_args_compression);
+ grpc_channel_args_destroy(ffd->client_args_compression);
+ grpc_channel_args_destroy(ffd->server_args_compression);
gpr_free(ffd->localaddr);
gpr_free(ffd);
- grpc_exec_ctx_finish(&exec_ctx);
}
/* All test configurations */
diff --git a/test/core/end2end/fixtures/h2_fd.cc b/test/core/end2end/fixtures/h2_fd.cc
index 97f4b71bf0..85f5061ee8 100644
--- a/test/core/end2end/fixtures/h2_fd.cc
+++ b/test/core/end2end/fixtures/h2_fd.cc
@@ -68,20 +68,18 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f,
grpc_channel_args* client_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
sp_fixture_data* sfd = static_cast<sp_fixture_data*>(f->fixture_data);
GPR_ASSERT(!f->client);
f->client = grpc_insecure_channel_create_from_fd(
"fixture_client", sfd->fd_pair[0], client_args);
GPR_ASSERT(f->client);
-
- grpc_exec_ctx_finish(&exec_ctx);
}
static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
grpc_channel_args* server_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
sp_fixture_data* sfd = static_cast<sp_fixture_data*>(f->fixture_data);
GPR_ASSERT(!f->server);
f->server = grpc_server_create(server_args, nullptr);
@@ -90,8 +88,6 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
grpc_server_start(f->server);
grpc_server_add_insecure_channel_from_fd(f->server, nullptr, sfd->fd_pair[1]);
-
- grpc_exec_ctx_finish(&exec_ctx);
}
static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture* f) {
diff --git a/test/core/end2end/fixtures/h2_full+workarounds.cc b/test/core/end2end/fixtures/h2_full+workarounds.cc
index 71a497d796..2f9a9d4c4b 100644
--- a/test/core/end2end/fixtures/h2_full+workarounds.cc
+++ b/test/core/end2end/fixtures/h2_full+workarounds.cc
@@ -72,7 +72,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f,
void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
grpc_channel_args* server_args) {
int i;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
fullstack_fixture_data* ffd =
static_cast<fullstack_fixture_data*>(f->fixture_data);
grpc_arg args[GRPC_MAX_WORKAROUND_ID];
@@ -90,8 +90,7 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f,
grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
- grpc_channel_args_destroy(&exec_ctx, server_args_new);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(server_args_new);
}
void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) {
diff --git a/test/core/end2end/fixtures/h2_load_reporting.cc b/test/core/end2end/fixtures/h2_load_reporting.cc
index 7486b6af78..61853740ab 100644
--- a/test/core/end2end/fixtures/h2_load_reporting.cc
+++ b/test/core/end2end/fixtures/h2_load_reporting.cc
@@ -78,9 +78,8 @@ void chttp2_init_server_load_reporting(grpc_end2end_test_fixture* f,
server_args = grpc_channel_args_copy_and_add(server_args, &arg, 1);
f->server = grpc_server_create(server_args, nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(server_args);
}
grpc_server_register_completion_queue(f->server, f->cq, nullptr);
GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
diff --git a/test/core/end2end/fixtures/h2_oauth2.cc b/test/core/end2end/fixtures/h2_oauth2.cc
index 1642cb0db9..40ca2a77fb 100644
--- a/test/core/end2end/fixtures/h2_oauth2.cc
+++ b/test/core/end2end/fixtures/h2_oauth2.cc
@@ -143,11 +143,11 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) {
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_core::ExecCtx _local_exec_ctx;
grpc_channel_credentials* ssl_creds =
grpc_ssl_credentials_create(test_root_cert, nullptr, nullptr);
grpc_call_credentials* oauth2_creds = grpc_md_only_test_credentials_create(
- &exec_ctx, "authorization", oauth2_md, true /* is_async */);
+ "authorization", oauth2_md, true /* is_async */);
grpc_channel_credentials* ssl_oauth2_creds =
grpc_composite_channel_credentials_create(ssl_creds, oauth2_creds,
nullptr);
@@ -158,10 +158,9 @@ static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack(
grpc_channel_args* new_client_args =
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1);
chttp2_init_client_secure_fullstack(f, new_client_args, ssl_oauth2_creds);
- grpc_channel_args_destroy(&exec_ctx, new_client_args);
+ grpc_channel_args_destroy(new_client_args);
grpc_channel_credentials_release(ssl_creds);
grpc_call_credentials_release(oauth2_creds);
- grpc_exec_ctx_finish(&exec_ctx);
}
static int fail_server_auth_check(grpc_channel_args* server_args) {
diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.cc b/test/core/end2end/fixtures/h2_sockpair+trace.cc
index fe4ab74843..b8b18e2a95 100644
--- a/test/core/end2end/fixtures/h2_sockpair+trace.cc
+++ b/test/core/end2end/fixtures/h2_sockpair+trace.cc
@@ -50,12 +50,11 @@
static void server_setup_transport(void* ts, grpc_transport* transport) {
grpc_end2end_test_fixture* f = static_cast<grpc_end2end_test_fixture*>(ts);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
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, nullptr,
+ grpc_endpoint_add_to_pollset(sfd->server, grpc_cq_pollset(f->cq));
+ grpc_server_setup_transport(f->server, transport, nullptr,
grpc_server_get_channel_args(f->server));
- grpc_exec_ctx_finish(&exec_ctx);
}
typedef struct {
@@ -63,13 +62,11 @@ typedef struct {
grpc_channel_args* client_args;
} sp_client_setup;
-static void client_setup_transport(grpc_exec_ctx* exec_ctx, void* ts,
- grpc_transport* transport) {
+static void client_setup_transport(void* ts, grpc_transport* transport) {
sp_client_setup* cs = static_cast<sp_client_setup*>(ts);
- cs->f->client =
- grpc_channel_create(exec_ctx, "socketpair-target", cs->client_args,
- GRPC_CLIENT_DIRECT_CHANNEL, transport);
+ cs->f->client = grpc_channel_create("socketpair-target", cs->client_args,
+ GRPC_CLIENT_DIRECT_CHANNEL, transport);
}
static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
@@ -90,34 +87,30 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f,
grpc_channel_args* client_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
grpc_transport* transport;
sp_client_setup cs;
cs.client_args = client_args;
cs.f = f;
- transport =
- grpc_create_chttp2_transport(&exec_ctx, client_args, sfd->client, 1);
- client_setup_transport(&exec_ctx, &cs, transport);
+ transport = grpc_create_chttp2_transport(client_args, sfd->client, 1);
+ client_setup_transport(&cs, transport);
GPR_ASSERT(f->client);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
}
static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
grpc_channel_args* server_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
grpc_transport* transport;
GPR_ASSERT(!f->server);
f->server = grpc_server_create(server_args, nullptr);
grpc_server_register_completion_queue(f->server, f->cq, nullptr);
grpc_server_start(f->server);
- transport =
- grpc_create_chttp2_transport(&exec_ctx, server_args, sfd->server, 0);
+ transport = grpc_create_chttp2_transport(server_args, sfd->server, 0);
server_setup_transport(f, transport);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
}
static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture* f) {
@@ -133,7 +126,7 @@ static grpc_end2end_test_config configs[] = {
int main(int argc, char** argv) {
size_t i;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
/* force tracing on, with a value to force many
code paths in trace.c to be taken */
@@ -147,7 +140,6 @@ int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_end2end_tests_pre_init();
grpc_init();
- grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(0 == grpc_tracer_set_enabled("also-doesnt-exist", 0));
GPR_ASSERT(1 == grpc_tracer_set_enabled("http", 1));
diff --git a/test/core/end2end/fixtures/h2_sockpair.cc b/test/core/end2end/fixtures/h2_sockpair.cc
index 59a3a6db31..304d0dd1fa 100644
--- a/test/core/end2end/fixtures/h2_sockpair.cc
+++ b/test/core/end2end/fixtures/h2_sockpair.cc
@@ -44,12 +44,11 @@
static void server_setup_transport(void* ts, grpc_transport* transport) {
grpc_end2end_test_fixture* f = static_cast<grpc_end2end_test_fixture*>(ts);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
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, nullptr,
+ grpc_endpoint_add_to_pollset(sfd->server, grpc_cq_pollset(f->cq));
+ grpc_server_setup_transport(f->server, transport, nullptr,
grpc_server_get_channel_args(f->server));
- grpc_exec_ctx_finish(&exec_ctx);
}
typedef struct {
@@ -57,13 +56,11 @@ typedef struct {
grpc_channel_args* client_args;
} sp_client_setup;
-static void client_setup_transport(grpc_exec_ctx* exec_ctx, void* ts,
- grpc_transport* transport) {
+static void client_setup_transport(void* ts, grpc_transport* transport) {
sp_client_setup* cs = static_cast<sp_client_setup*>(ts);
- cs->f->client =
- grpc_channel_create(exec_ctx, "socketpair-target", cs->client_args,
- GRPC_CLIENT_DIRECT_CHANNEL, transport);
+ cs->f->client = grpc_channel_create("socketpair-target", cs->client_args,
+ GRPC_CLIENT_DIRECT_CHANNEL, transport);
}
static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
@@ -84,34 +81,30 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f,
grpc_channel_args* client_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
grpc_transport* transport;
sp_client_setup cs;
cs.client_args = client_args;
cs.f = f;
- transport =
- grpc_create_chttp2_transport(&exec_ctx, client_args, sfd->client, 1);
- client_setup_transport(&exec_ctx, &cs, transport);
+ transport = grpc_create_chttp2_transport(client_args, sfd->client, 1);
+ client_setup_transport(&cs, transport);
GPR_ASSERT(f->client);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
}
static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
grpc_channel_args* server_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
grpc_transport* transport;
GPR_ASSERT(!f->server);
f->server = grpc_server_create(server_args, nullptr);
grpc_server_register_completion_queue(f->server, f->cq, nullptr);
grpc_server_start(f->server);
- transport =
- grpc_create_chttp2_transport(&exec_ctx, server_args, sfd->server, 0);
+ transport = grpc_create_chttp2_transport(server_args, sfd->server, 0);
server_setup_transport(f, transport);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
}
static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture* f) {
diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.cc b/test/core/end2end/fixtures/h2_sockpair_1byte.cc
index d935efbbac..0b5ae3abe4 100644
--- a/test/core/end2end/fixtures/h2_sockpair_1byte.cc
+++ b/test/core/end2end/fixtures/h2_sockpair_1byte.cc
@@ -44,12 +44,11 @@
static void server_setup_transport(void* ts, grpc_transport* transport) {
grpc_end2end_test_fixture* f = static_cast<grpc_end2end_test_fixture*>(ts);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
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, nullptr,
+ grpc_endpoint_add_to_pollset(sfd->server, grpc_cq_pollset(f->cq));
+ grpc_server_setup_transport(f->server, transport, nullptr,
grpc_server_get_channel_args(f->server));
- grpc_exec_ctx_finish(&exec_ctx);
}
typedef struct {
@@ -57,13 +56,11 @@ typedef struct {
grpc_channel_args* client_args;
} sp_client_setup;
-static void client_setup_transport(grpc_exec_ctx* exec_ctx, void* ts,
- grpc_transport* transport) {
+static void client_setup_transport(void* ts, grpc_transport* transport) {
sp_client_setup* cs = static_cast<sp_client_setup*>(ts);
- cs->f->client =
- grpc_channel_create(exec_ctx, "socketpair-target", cs->client_args,
- GRPC_CLIENT_DIRECT_CHANNEL, transport);
+ cs->f->client = grpc_channel_create("socketpair-target", cs->client_args,
+ GRPC_CLIENT_DIRECT_CHANNEL, transport);
}
static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
@@ -95,34 +92,30 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair(
static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f,
grpc_channel_args* client_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
grpc_transport* transport;
sp_client_setup cs;
cs.client_args = client_args;
cs.f = f;
- transport =
- grpc_create_chttp2_transport(&exec_ctx, client_args, sfd->client, 1);
- client_setup_transport(&exec_ctx, &cs, transport);
+ transport = grpc_create_chttp2_transport(client_args, sfd->client, 1);
+ client_setup_transport(&cs, transport);
GPR_ASSERT(f->client);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
}
static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f,
grpc_channel_args* server_args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_endpoint_pair* sfd = static_cast<grpc_endpoint_pair*>(f->fixture_data);
grpc_transport* transport;
GPR_ASSERT(!f->server);
f->server = grpc_server_create(server_args, nullptr);
grpc_server_register_completion_queue(f->server, f->cq, nullptr);
grpc_server_start(f->server);
- transport =
- grpc_create_chttp2_transport(&exec_ctx, server_args, sfd->server, 0);
+ transport = grpc_create_chttp2_transport(server_args, sfd->server, 0);
server_setup_transport(f, transport);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
}
static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture* f) {
diff --git a/test/core/end2end/fixtures/h2_ssl.cc b/test/core/end2end/fixtures/h2_ssl.cc
index 3d7e2e327e..4d6fed14e0 100644
--- a/test/core/end2end/fixtures/h2_ssl.cc
+++ b/test/core/end2end/fixtures/h2_ssl.cc
@@ -110,9 +110,8 @@ static void chttp2_init_client_simple_ssl_secure_fullstack(
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1);
chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, new_client_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(new_client_args);
}
}
diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.cc b/test/core/end2end/fixtures/h2_ssl_proxy.cc
index f8d5a699e4..aee1388a56 100644
--- a/test/core/end2end/fixtures/h2_ssl_proxy.cc
+++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc
@@ -66,9 +66,8 @@ static grpc_channel* create_proxy_client(const char* target,
grpc_secure_channel_create(ssl_creds, target, new_client_args, nullptr);
grpc_channel_credentials_release(ssl_creds);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, new_client_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(new_client_args);
}
return channel;
}
@@ -148,9 +147,8 @@ static void chttp2_init_client_simple_ssl_secure_fullstack(
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1);
chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, new_client_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(new_client_args);
}
}
diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc
index 0bdd15c57d..5ac783611d 100644
--- a/test/core/end2end/fixtures/http_proxy_fixture.cc
+++ b/test/core/end2end/fixtures/http_proxy_fixture.cc
@@ -102,24 +102,21 @@ static void proxy_connection_ref(proxy_connection* conn, const char* reason) {
}
// Helper function to destroy the proxy connection.
-static void proxy_connection_unref(grpc_exec_ctx* exec_ctx,
- proxy_connection* conn, const char* reason) {
+static void proxy_connection_unref(proxy_connection* conn, const char* reason) {
if (gpr_unref(&conn->refcount)) {
gpr_log(GPR_DEBUG, "endpoints: %p %p", conn->client_endpoint,
conn->server_endpoint);
- grpc_endpoint_destroy(exec_ctx, conn->client_endpoint);
+ grpc_endpoint_destroy(conn->client_endpoint);
if (conn->server_endpoint != nullptr) {
- grpc_endpoint_destroy(exec_ctx, conn->server_endpoint);
+ grpc_endpoint_destroy(conn->server_endpoint);
}
- grpc_pollset_set_destroy(exec_ctx, conn->pollset_set);
- grpc_slice_buffer_destroy_internal(exec_ctx, &conn->client_read_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx,
- &conn->client_deferred_write_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &conn->client_write_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &conn->server_read_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx,
- &conn->server_deferred_write_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &conn->server_write_buffer);
+ grpc_pollset_set_destroy(conn->pollset_set);
+ grpc_slice_buffer_destroy_internal(&conn->client_read_buffer);
+ grpc_slice_buffer_destroy_internal(&conn->client_deferred_write_buffer);
+ grpc_slice_buffer_destroy_internal(&conn->client_write_buffer);
+ grpc_slice_buffer_destroy_internal(&conn->server_read_buffer);
+ grpc_slice_buffer_destroy_internal(&conn->server_deferred_write_buffer);
+ grpc_slice_buffer_destroy_internal(&conn->server_write_buffer);
grpc_http_parser_destroy(&conn->http_parser);
grpc_http_request_destroy(&conn->http_request);
gpr_unref(&conn->proxy->users);
@@ -129,27 +126,23 @@ static void proxy_connection_unref(grpc_exec_ctx* exec_ctx,
// 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,
+static void proxy_connection_failed(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));
+ grpc_endpoint_shutdown(conn->client_endpoint, GRPC_ERROR_REF(error));
if (conn->server_endpoint != nullptr) {
- grpc_endpoint_shutdown(exec_ctx, conn->server_endpoint,
- GRPC_ERROR_REF(error));
+ grpc_endpoint_shutdown(conn->server_endpoint, GRPC_ERROR_REF(error));
}
- proxy_connection_unref(exec_ctx, conn, "conn_failed");
+ proxy_connection_unref(conn, "conn_failed");
}
// Callback for writing proxy data to the client.
-static void on_client_write_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_client_write_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
+ proxy_connection_failed(conn, true /* is_client */,
"HTTP proxy client write", error);
return;
}
@@ -160,21 +153,19 @@ static void on_client_write_done(grpc_exec_ctx* exec_ctx, void* arg,
if (conn->client_deferred_write_buffer.length > 0) {
grpc_slice_buffer_move_into(&conn->client_deferred_write_buffer,
&conn->client_write_buffer);
- grpc_endpoint_write(exec_ctx, conn->client_endpoint,
- &conn->client_write_buffer,
+ grpc_endpoint_write(conn->client_endpoint, &conn->client_write_buffer,
&conn->on_client_write_done);
} else {
// No more writes. Unref the connection.
- proxy_connection_unref(exec_ctx, conn, "write_done");
+ proxy_connection_unref(conn, "write_done");
}
}
// Callback for writing proxy data to the backend server.
-static void on_server_write_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_server_write_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, false /* is_client */,
+ proxy_connection_failed(conn, false /* is_client */,
"HTTP proxy server write", error);
return;
}
@@ -185,22 +176,20 @@ static void on_server_write_done(grpc_exec_ctx* exec_ctx, void* arg,
if (conn->server_deferred_write_buffer.length > 0) {
grpc_slice_buffer_move_into(&conn->server_deferred_write_buffer,
&conn->server_write_buffer);
- grpc_endpoint_write(exec_ctx, conn->server_endpoint,
- &conn->server_write_buffer,
+ grpc_endpoint_write(conn->server_endpoint, &conn->server_write_buffer,
&conn->on_server_write_done);
} else {
// No more writes. Unref the connection.
- proxy_connection_unref(exec_ctx, conn, "server_write");
+ proxy_connection_unref(conn, "server_write");
}
}
// Callback for reading data from the client, which will be proxied to
// the backend server.
-static void on_client_read_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_client_read_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
+ proxy_connection_failed(conn, true /* is_client */,
"HTTP proxy client read", error);
return;
}
@@ -217,22 +206,20 @@ static void on_client_read_done(grpc_exec_ctx* exec_ctx, void* arg,
grpc_slice_buffer_move_into(&conn->client_read_buffer,
&conn->server_write_buffer);
proxy_connection_ref(conn, "client_read");
- grpc_endpoint_write(exec_ctx, conn->server_endpoint,
- &conn->server_write_buffer,
+ grpc_endpoint_write(conn->server_endpoint, &conn->server_write_buffer,
&conn->on_server_write_done);
}
// Read more data.
- grpc_endpoint_read(exec_ctx, conn->client_endpoint, &conn->client_read_buffer,
+ grpc_endpoint_read(conn->client_endpoint, &conn->client_read_buffer,
&conn->on_client_read_done);
}
// Callback for reading data from the backend server, which will be
// proxied to the client.
-static void on_server_read_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_server_read_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, false /* is_client */,
+ proxy_connection_failed(conn, false /* is_client */,
"HTTP proxy server read", error);
return;
}
@@ -249,21 +236,19 @@ static void on_server_read_done(grpc_exec_ctx* exec_ctx, void* arg,
grpc_slice_buffer_move_into(&conn->server_read_buffer,
&conn->client_write_buffer);
proxy_connection_ref(conn, "server_read");
- grpc_endpoint_write(exec_ctx, conn->client_endpoint,
- &conn->client_write_buffer,
+ grpc_endpoint_write(conn->client_endpoint, &conn->client_write_buffer,
&conn->on_client_write_done);
}
// Read more data.
- grpc_endpoint_read(exec_ctx, conn->server_endpoint, &conn->server_read_buffer,
+ grpc_endpoint_read(conn->server_endpoint, &conn->server_read_buffer,
&conn->on_server_read_done);
}
// Callback to write the HTTP response for the CONNECT request.
-static void on_write_response_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_write_response_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
+ proxy_connection_failed(conn, true /* is_client */,
"HTTP proxy write response", error);
return;
}
@@ -274,17 +259,16 @@ static void on_write_response_done(grpc_exec_ctx* exec_ctx, void* arg,
// for the other one.
proxy_connection_ref(conn, "client_read");
proxy_connection_ref(conn, "server_read");
- proxy_connection_unref(exec_ctx, conn, "write_response");
- grpc_endpoint_read(exec_ctx, conn->client_endpoint, &conn->client_read_buffer,
+ proxy_connection_unref(conn, "write_response");
+ grpc_endpoint_read(conn->client_endpoint, &conn->client_read_buffer,
&conn->on_client_read_done);
- grpc_endpoint_read(exec_ctx, conn->server_endpoint, &conn->server_read_buffer,
+ grpc_endpoint_read(conn->server_endpoint, &conn->server_read_buffer,
&conn->on_server_read_done);
}
// Callback to connect to the backend server specified by the HTTP
// CONNECT request.
-static void on_server_connect_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_server_connect_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) {
// TODO(roth): Technically, in this case, we should handle the error
@@ -292,7 +276,7 @@ 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 */,
+ proxy_connection_failed(conn, true /* is_client */,
"HTTP proxy server connect", error);
return;
}
@@ -302,8 +286,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);
- grpc_endpoint_write(exec_ctx, conn->client_endpoint,
- &conn->client_write_buffer,
+ grpc_endpoint_write(conn->client_endpoint, &conn->client_write_buffer,
&conn->on_write_response_done);
}
@@ -312,8 +295,7 @@ static void on_server_connect_done(grpc_exec_ctx* exec_ctx, void* arg,
* Basic <base64_encoded_expected_cred>
* Returns true if it matches, false otherwise
*/
-static bool proxy_auth_header_matches(grpc_exec_ctx* exec_ctx,
- char* proxy_auth_header_val,
+static bool proxy_auth_header_matches(char* proxy_auth_header_val,
char* expected_cred) {
GPR_ASSERT(proxy_auth_header_val != nullptr);
GPR_ASSERT(expected_cred != nullptr);
@@ -321,11 +303,10 @@ static bool proxy_auth_header_matches(grpc_exec_ctx* exec_ctx,
return false;
}
proxy_auth_header_val += 6;
- grpc_slice decoded_slice =
- grpc_base64_decode(exec_ctx, proxy_auth_header_val, 0);
+ grpc_slice decoded_slice = grpc_base64_decode(proxy_auth_header_val, 0);
const bool header_matches =
grpc_slice_str_cmp(decoded_slice, expected_cred) == 0;
- grpc_slice_unref_internal(exec_ctx, decoded_slice);
+ grpc_slice_unref_internal(decoded_slice);
return header_matches;
}
@@ -335,13 +316,12 @@ static bool proxy_auth_header_matches(grpc_exec_ctx* exec_ctx,
// the client indicating that the request failed. However, for the purposes
// of this test code, it's fine to pretend this is a client-side error,
// which will cause the client connection to be dropped.
-static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_read_request_done(void* arg, grpc_error* error) {
proxy_connection* conn = (proxy_connection*)arg;
gpr_log(GPR_DEBUG, "on_read_request_done: %p %s", conn,
grpc_error_string(error));
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
+ proxy_connection_failed(conn, true /* is_client */,
"HTTP proxy read request", error);
return;
}
@@ -351,7 +331,7 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
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 */,
+ proxy_connection_failed(conn, true /* is_client */,
"HTTP proxy request parse", error);
GRPC_ERROR_UNREF(error);
return;
@@ -361,8 +341,8 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
grpc_slice_buffer_reset_and_unref(&conn->client_read_buffer);
// If we're not done reading the request, read more data.
if (conn->http_parser.state != GRPC_HTTP_BODY) {
- grpc_endpoint_read(exec_ctx, conn->client_endpoint,
- &conn->client_read_buffer, &conn->on_read_request_done);
+ grpc_endpoint_read(conn->client_endpoint, &conn->client_read_buffer,
+ &conn->on_read_request_done);
return;
}
// Make sure we got a CONNECT request.
@@ -372,7 +352,7 @@ 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 */,
+ proxy_connection_failed(conn, true /* is_client */,
"HTTP proxy read request", error);
GRPC_ERROR_UNREF(error);
return;
@@ -385,15 +365,14 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
for (size_t i = 0; i < conn->http_request.hdr_count; i++) {
if (strcmp(conn->http_request.hdrs[i].key, "Proxy-Authorization") == 0) {
client_authenticated = proxy_auth_header_matches(
- exec_ctx, conn->http_request.hdrs[i].value,
- proxy_auth_arg->value.string);
+ conn->http_request.hdrs[i].value, proxy_auth_arg->value.string);
break;
}
}
if (!client_authenticated) {
const char* msg = "HTTP Connect could not verify authentication";
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(msg);
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
+ proxy_connection_failed(conn, true /* is_client */,
"HTTP proxy read request", error);
GRPC_ERROR_UNREF(error);
return;
@@ -404,8 +383,8 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
error = grpc_blocking_resolve_address(conn->http_request.path, "80",
&resolved_addresses);
if (error != GRPC_ERROR_NONE) {
- proxy_connection_failed(exec_ctx, conn, true /* is_client */,
- "HTTP proxy DNS lookup", error);
+ proxy_connection_failed(conn, true /* is_client */, "HTTP proxy DNS lookup",
+ error);
GRPC_ERROR_UNREF(error);
return;
}
@@ -413,15 +392,15 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
// Connect to requested address.
// The connection callback inherits our reference to conn.
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, nullptr,
+ grpc_core::ExecCtx::Get()->Now() + 10 * GPR_MS_PER_SEC;
+ grpc_tcp_client_connect(&conn->on_server_connect_done, &conn->server_endpoint,
+ conn->pollset_set, nullptr,
&resolved_addresses->addrs[0], deadline);
grpc_resolved_addresses_destroy(resolved_addresses);
}
-static void on_accept(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_endpoint* endpoint, grpc_pollset* accepting_pollset,
+static void on_accept(void* arg, grpc_endpoint* endpoint,
+ grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) {
gpr_free(acceptor);
grpc_end2end_http_proxy* proxy = (grpc_end2end_http_proxy*)arg;
@@ -432,8 +411,8 @@ static void on_accept(grpc_exec_ctx* exec_ctx, void* arg,
conn->proxy = proxy;
gpr_ref_init(&conn->refcount, 1);
conn->pollset_set = grpc_pollset_set_create();
- grpc_pollset_set_add_pollset(exec_ctx, conn->pollset_set, proxy->pollset);
- grpc_endpoint_add_to_pollset_set(exec_ctx, endpoint, conn->pollset_set);
+ grpc_pollset_set_add_pollset(conn->pollset_set, proxy->pollset);
+ grpc_endpoint_add_to_pollset_set(endpoint, conn->pollset_set);
GRPC_CLOSURE_INIT(&conn->on_read_request_done, on_read_request_done, conn,
grpc_combiner_scheduler(conn->proxy->combiner));
GRPC_CLOSURE_INIT(&conn->on_server_connect_done, on_server_connect_done, conn,
@@ -456,7 +435,7 @@ static void on_accept(grpc_exec_ctx* exec_ctx, void* arg,
grpc_slice_buffer_init(&conn->server_write_buffer);
grpc_http_parser_init(&conn->http_parser, GRPC_HTTP_REQUEST,
&conn->http_request);
- grpc_endpoint_read(exec_ctx, conn->client_endpoint, &conn->client_read_buffer,
+ grpc_endpoint_read(conn->client_endpoint, &conn->client_read_buffer,
&conn->on_read_request_done);
}
@@ -466,24 +445,23 @@ static void on_accept(grpc_exec_ctx* exec_ctx, void* arg,
static void thread_main(void* arg) {
grpc_end2end_http_proxy* proxy = (grpc_end2end_http_proxy*)arg;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
do {
gpr_ref(&proxy->users);
grpc_pollset_worker* worker = nullptr;
gpr_mu_lock(proxy->mu);
GRPC_LOG_IF_ERROR(
"grpc_pollset_work",
- grpc_pollset_work(&exec_ctx, proxy->pollset, &worker,
- grpc_exec_ctx_now(&exec_ctx) + GPR_MS_PER_SEC));
+ grpc_pollset_work(proxy->pollset, &worker,
+ grpc_core::ExecCtx::Get()->Now() + GPR_MS_PER_SEC));
gpr_mu_unlock(proxy->mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
} while (!gpr_unref(&proxy->users));
- grpc_exec_ctx_finish(&exec_ctx);
}
grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
grpc_channel_args* args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_end2end_http_proxy* proxy =
(grpc_end2end_http_proxy*)gpr_malloc(sizeof(*proxy));
memset(proxy, 0, sizeof(*proxy));
@@ -495,8 +473,8 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
gpr_log(GPR_INFO, "Proxy address: %s", proxy->proxy_name);
// Create TCP server.
proxy->channel_args = grpc_channel_args_copy(args);
- grpc_error* error = grpc_tcp_server_create(
- &exec_ctx, nullptr, proxy->channel_args, &proxy->server);
+ grpc_error* error =
+ grpc_tcp_server_create(nullptr, proxy->channel_args, &proxy->server);
GPR_ASSERT(error == GRPC_ERROR_NONE);
// Bind to port.
grpc_resolved_address resolved_addr;
@@ -511,9 +489,8 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
// Start server.
proxy->pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
grpc_pollset_init(proxy->pollset, &proxy->mu);
- grpc_tcp_server_start(&exec_ctx, proxy->server, &proxy->pollset, 1, on_accept,
- proxy);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_start(proxy->server, &proxy->pollset, 1, on_accept, proxy);
+
// Start proxy thread.
gpr_thd_options opt = gpr_thd_options_default();
gpr_thd_options_set_joinable(&opt);
@@ -521,27 +498,25 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
return proxy;
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void destroy_pollset(void* arg, grpc_error* error) {
grpc_pollset* pollset = (grpc_pollset*)arg;
- grpc_pollset_destroy(exec_ctx, pollset);
+ grpc_pollset_destroy(pollset);
gpr_free(pollset);
}
void grpc_end2end_http_proxy_destroy(grpc_end2end_http_proxy* proxy) {
gpr_unref(&proxy->users); // Signal proxy thread to shutdown.
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_thd_join(proxy->thd);
- grpc_tcp_server_shutdown_listeners(&exec_ctx, proxy->server);
- grpc_tcp_server_unref(&exec_ctx, proxy->server);
+ grpc_tcp_server_shutdown_listeners(proxy->server);
+ grpc_tcp_server_unref(proxy->server);
gpr_free(proxy->proxy_name);
- grpc_channel_args_destroy(&exec_ctx, proxy->channel_args);
- grpc_pollset_shutdown(&exec_ctx, proxy->pollset,
+ grpc_channel_args_destroy(proxy->channel_args);
+ grpc_pollset_shutdown(proxy->pollset,
GRPC_CLOSURE_CREATE(destroy_pollset, proxy->pollset,
grpc_schedule_on_exec_ctx));
- GRPC_COMBINER_UNREF(&exec_ctx, proxy->combiner, "test");
+ GRPC_COMBINER_UNREF(proxy->combiner, "test");
gpr_free(proxy);
- grpc_exec_ctx_finish(&exec_ctx);
}
const char* grpc_end2end_http_proxy_get_proxy_name(
diff --git a/test/core/end2end/fuzzers/api_fuzzer.cc b/test/core/end2end/fuzzers/api_fuzzer.cc
index b8ec12586e..ce916bd341 100644
--- a/test/core/end2end/fuzzers/api_fuzzer.cc
+++ b/test/core/end2end/fuzzers/api_fuzzer.cc
@@ -376,8 +376,7 @@ typedef struct addr_req {
grpc_lb_addresses** lb_addrs;
} addr_req;
-static void finish_resolve(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void finish_resolve(void* arg, grpc_error* error) {
addr_req* r = static_cast<addr_req*>(arg);
if (error == GRPC_ERROR_NONE && 0 == strcmp(r->addr, "server")) {
@@ -395,9 +394,9 @@ static void finish_resolve(grpc_exec_ctx* exec_ctx, void* arg,
nullptr);
*r->lb_addrs = lb_addrs;
}
- GRPC_CLOSURE_SCHED(exec_ctx, r->on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(r->on_done, GRPC_ERROR_NONE);
} else {
- GRPC_CLOSURE_SCHED(exec_ctx, r->on_done,
+ GRPC_CLOSURE_SCHED(r->on_done,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Resolution failed", &error, 1));
}
@@ -406,8 +405,7 @@ static void finish_resolve(grpc_exec_ctx* exec_ctx, void* arg,
gpr_free(r);
}
-void my_resolve_address(grpc_exec_ctx* exec_ctx, const char* addr,
- const char* default_port,
+void my_resolve_address(const char* addr, const char* default_port,
grpc_pollset_set* interested_parties,
grpc_closure* on_done,
grpc_resolved_addresses** addresses) {
@@ -417,22 +415,24 @@ void my_resolve_address(grpc_exec_ctx* exec_ctx, const char* addr,
r->addrs = addresses;
r->lb_addrs = nullptr;
grpc_timer_init(
- exec_ctx, &r->timer, GPR_MS_PER_SEC + grpc_exec_ctx_now(exec_ctx),
+ &r->timer, GPR_MS_PER_SEC + grpc_core::ExecCtx::Get()->Now(),
GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx));
}
-grpc_ares_request* my_dns_lookup_ares(
- grpc_exec_ctx* exec_ctx, const char* dns_server, const char* addr,
- const char* default_port, grpc_pollset_set* interested_parties,
- grpc_closure* on_done, grpc_lb_addresses** lb_addrs, bool check_grpclb,
- char** service_config_json) {
+grpc_ares_request* my_dns_lookup_ares(const char* dns_server, const char* addr,
+ const char* default_port,
+ grpc_pollset_set* interested_parties,
+ grpc_closure* on_done,
+ grpc_lb_addresses** lb_addrs,
+ bool check_grpclb,
+ char** service_config_json) {
addr_req* r = static_cast<addr_req*>(gpr_malloc(sizeof(*r)));
r->addr = gpr_strdup(addr);
r->on_done = on_done;
r->addrs = nullptr;
r->lb_addrs = lb_addrs;
grpc_timer_init(
- exec_ctx, &r->timer, GPR_MS_PER_SEC + grpc_exec_ctx_now(exec_ctx),
+ &r->timer, GPR_MS_PER_SEC + grpc_core::ExecCtx::Get()->Now(),
GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx));
return nullptr;
}
@@ -442,12 +442,12 @@ grpc_ares_request* my_dns_lookup_ares(
// defined in tcp_client_posix.c
extern "C" void (*grpc_tcp_client_connect_impl)(
- grpc_exec_ctx* exec_ctx, grpc_closure* closure, grpc_endpoint** ep,
+ grpc_closure* closure, grpc_endpoint** ep,
grpc_pollset_set* interested_parties, const grpc_channel_args* channel_args,
const grpc_resolved_address* addr, grpc_millis deadline);
-static void sched_connect(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
- grpc_endpoint** ep, gpr_timespec deadline);
+static void sched_connect(grpc_closure* closure, grpc_endpoint** ep,
+ gpr_timespec deadline);
typedef struct {
grpc_timer timer;
@@ -456,11 +456,11 @@ typedef struct {
gpr_timespec deadline;
} future_connect;
-static void do_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void do_connect(void* arg, grpc_error* error) {
future_connect* fc = static_cast<future_connect*>(arg);
if (error != GRPC_ERROR_NONE) {
*fc->ep = nullptr;
- GRPC_CLOSURE_SCHED(exec_ctx, fc->closure, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(fc->closure, GRPC_ERROR_REF(error));
} else if (g_server != nullptr) {
grpc_endpoint* client;
grpc_endpoint* server;
@@ -468,25 +468,23 @@ static void do_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
*fc->ep = client;
grpc_transport* transport =
- grpc_create_chttp2_transport(exec_ctx, nullptr, server, 0);
- grpc_server_setup_transport(exec_ctx, g_server, transport, nullptr,
- nullptr);
- grpc_chttp2_transport_start_reading(exec_ctx, transport, nullptr);
+ grpc_create_chttp2_transport(nullptr, server, 0);
+ grpc_server_setup_transport(g_server, transport, nullptr, nullptr);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
- GRPC_CLOSURE_SCHED(exec_ctx, fc->closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(fc->closure, GRPC_ERROR_NONE);
} else {
- sched_connect(exec_ctx, fc->closure, fc->ep, fc->deadline);
+ sched_connect(fc->closure, fc->ep, fc->deadline);
}
gpr_free(fc);
}
-static void sched_connect(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
- grpc_endpoint** ep, gpr_timespec deadline) {
+static void sched_connect(grpc_closure* closure, grpc_endpoint** ep,
+ gpr_timespec deadline) {
if (gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) < 0) {
*ep = nullptr;
- GRPC_CLOSURE_SCHED(
- exec_ctx, closure,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connect deadline exceeded"));
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Connect deadline exceeded"));
return;
}
@@ -495,17 +493,16 @@ static void sched_connect(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
fc->ep = ep;
fc->deadline = deadline;
grpc_timer_init(
- exec_ctx, &fc->timer, GPR_MS_PER_SEC + grpc_exec_ctx_now(exec_ctx),
+ &fc->timer, GPR_MS_PER_SEC + grpc_core::ExecCtx::Get()->Now(),
GRPC_CLOSURE_CREATE(do_connect, fc, grpc_schedule_on_exec_ctx));
}
-static void my_tcp_client_connect(grpc_exec_ctx* exec_ctx,
- grpc_closure* closure, grpc_endpoint** ep,
+static void my_tcp_client_connect(grpc_closure* closure, grpc_endpoint** ep,
grpc_pollset_set* interested_parties,
const grpc_channel_args* channel_args,
const grpc_resolved_address* addr,
grpc_millis deadline) {
- sched_connect(exec_ctx, closure, ep,
+ sched_connect(closure, ep,
grpc_millis_to_timespec(deadline, GPR_CLOCK_MONOTONIC));
}
@@ -751,9 +748,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_init();
grpc_timer_manager_set_threading(false);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_executor_set_threading(&exec_ctx, false);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_executor_set_threading(false);
}
grpc_resolve_address = my_resolve_address;
grpc_dns_lookup_ares = my_dns_lookup_ares;
@@ -846,9 +842,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
g_channel = grpc_insecure_channel_create(target_uri, args, nullptr);
GPR_ASSERT(g_channel != nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(args);
}
gpr_free(target_uri);
gpr_free(target);
@@ -874,9 +869,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
g_server = grpc_server_create(args, nullptr);
GPR_ASSERT(g_server != nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(args);
}
grpc_server_register_completion_queue(g_server, cq, nullptr);
grpc_server_start(g_server);
@@ -1205,9 +1199,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_secure_channel_create(creds, target_uri, args, nullptr);
GPR_ASSERT(g_channel != nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(args);
}
gpr_free(target_uri);
gpr_free(target);
diff --git a/test/core/end2end/fuzzers/client_fuzzer.cc b/test/core/end2end/fuzzers/client_fuzzer.cc
index ebc8c2780d..1298dd4e4f 100644
--- a/test/core/end2end/fuzzers/client_fuzzer.cc
+++ b/test/core/end2end/fuzzers/client_fuzzer.cc
@@ -43,22 +43,22 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (squelch) gpr_set_log_function(dont_log);
if (leak_check) grpc_memory_counters_init();
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_executor_set_threading(&exec_ctx, false);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_executor_set_threading(false);
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("client_fuzzer");
grpc_endpoint* mock_endpoint =
grpc_mock_endpoint_create(discard_write, resource_quota);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
grpc_transport* transport =
- grpc_create_chttp2_transport(&exec_ctx, nullptr, mock_endpoint, 1);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
+ grpc_create_chttp2_transport(nullptr, mock_endpoint, 1);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
grpc_channel* channel = grpc_channel_create(
- &exec_ctx, "test-target", nullptr, GRPC_CLIENT_DIRECT_CHANNEL, transport);
+ "test-target", nullptr, GRPC_CLIENT_DIRECT_CHANNEL, transport);
grpc_slice host = grpc_slice_from_static_string("localhost");
grpc_call* call = grpc_channel_create_call(
channel, nullptr, 0, cq, grpc_slice_from_static_string("/foo"), &host,
@@ -107,12 +107,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
GPR_ASSERT(GRPC_CALL_OK == error);
grpc_mock_endpoint_put_read(
- &exec_ctx, mock_endpoint,
- grpc_slice_from_copied_buffer((const char*)data, size));
+ mock_endpoint, grpc_slice_from_copied_buffer((const char*)data, size));
grpc_event ev;
while (1) {
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
nullptr);
switch (ev.type) {
diff --git a/test/core/end2end/fuzzers/server_fuzzer.cc b/test/core/end2end/fuzzers/server_fuzzer.cc
index fb6477b579..2cb6c984c5 100644
--- a/test/core/end2end/fuzzers/server_fuzzer.cc
+++ b/test/core/end2end/fuzzers/server_fuzzer.cc
@@ -41,17 +41,16 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (squelch) gpr_set_log_function(dont_log);
if (leak_check) grpc_memory_counters_init();
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_executor_set_threading(&exec_ctx, false);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_executor_set_threading(false);
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("server_fuzzer");
grpc_endpoint* mock_endpoint =
grpc_mock_endpoint_create(discard_write, resource_quota);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
grpc_mock_endpoint_put_read(
- &exec_ctx, mock_endpoint,
- grpc_slice_from_copied_buffer((const char*)data, size));
+ mock_endpoint, grpc_slice_from_copied_buffer((const char*)data, size));
grpc_server* server = grpc_server_create(nullptr, nullptr);
grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
@@ -61,9 +60,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// grpc_server_register_method(server, "/reg", NULL, 0);
grpc_server_start(server);
grpc_transport* transport =
- grpc_create_chttp2_transport(&exec_ctx, nullptr, mock_endpoint, 0);
- grpc_server_setup_transport(&exec_ctx, server, transport, nullptr, nullptr);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
+ grpc_create_chttp2_transport(nullptr, mock_endpoint, 0);
+ grpc_server_setup_transport(server, transport, nullptr, nullptr);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
grpc_call* call1 = nullptr;
grpc_call_details call_details1;
@@ -79,7 +78,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_event ev;
while (1) {
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
nullptr);
switch (ev.type) {
diff --git a/test/core/end2end/goaway_server_test.cc b/test/core/end2end/goaway_server_test.cc
index 2d0db967c3..94cfbdda7e 100644
--- a/test/core/end2end/goaway_server_test.cc
+++ b/test/core/end2end/goaway_server_test.cc
@@ -39,16 +39,15 @@ static void* tag(intptr_t i) { return (void*)i; }
static gpr_mu g_mu;
static int g_resolve_port = -1;
-static void (*iomgr_resolve_address)(grpc_exec_ctx* exec_ctx, const char* addr,
- const char* default_port,
+static void (*iomgr_resolve_address)(const char* addr, const char* default_port,
grpc_pollset_set* interested_parties,
grpc_closure* on_done,
grpc_resolved_addresses** addresses);
static grpc_ares_request* (*iomgr_dns_lookup_ares)(
- grpc_exec_ctx* exec_ctx, const char* dns_server, const char* addr,
- const char* default_port, grpc_pollset_set* interested_parties,
- grpc_closure* on_done, grpc_lb_addresses** addresses, bool check_grpclb,
+ const char* dns_server, const char* addr, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** addresses, bool check_grpclb,
char** service_config_json);
static void set_resolve_port(int port) {
@@ -57,14 +56,13 @@ static void set_resolve_port(int port) {
gpr_mu_unlock(&g_mu);
}
-static void my_resolve_address(grpc_exec_ctx* exec_ctx, const char* addr,
- const char* default_port,
+static void my_resolve_address(const char* addr, const char* default_port,
grpc_pollset_set* interested_parties,
grpc_closure* on_done,
grpc_resolved_addresses** addrs) {
if (0 != strcmp(addr, "test")) {
- iomgr_resolve_address(exec_ctx, addr, default_port, interested_parties,
- on_done, addrs);
+ iomgr_resolve_address(addr, default_port, interested_parties, on_done,
+ addrs);
return;
}
@@ -86,16 +84,16 @@ static void my_resolve_address(grpc_exec_ctx* exec_ctx, const char* addr,
(*addrs)->addrs[0].len = sizeof(*sa);
gpr_mu_unlock(&g_mu);
}
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
+ GRPC_CLOSURE_SCHED(on_done, error);
}
static grpc_ares_request* my_dns_lookup_ares(
- grpc_exec_ctx* exec_ctx, const char* dns_server, const char* addr,
- const char* default_port, grpc_pollset_set* interested_parties,
- grpc_closure* on_done, grpc_lb_addresses** lb_addrs, bool check_grpclb,
+ const char* dns_server, const char* addr, const char* default_port,
+ grpc_pollset_set* interested_parties, grpc_closure* on_done,
+ grpc_lb_addresses** lb_addrs, bool check_grpclb,
char** service_config_json) {
if (0 != strcmp(addr, "test")) {
- return iomgr_dns_lookup_ares(exec_ctx, dns_server, addr, default_port,
+ return iomgr_dns_lookup_ares(dns_server, addr, default_port,
interested_parties, on_done, lb_addrs,
check_grpclb, service_config_json);
}
@@ -117,7 +115,7 @@ static grpc_ares_request* my_dns_lookup_ares(
gpr_free(sa);
gpr_mu_unlock(&g_mu);
}
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
+ GRPC_CLOSURE_SCHED(on_done, error);
return nullptr;
}
diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc
index 9a98c07158..177731669e 100644
--- a/test/core/end2end/h2_ssl_cert_test.cc
+++ b/test/core/end2end/h2_ssl_cert_test.cc
@@ -181,9 +181,8 @@ typedef enum { NONE, SELF_SIGNED, SIGNED, BAD_CERT_PAIR } certtype;
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); \
chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds); \
{ \
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; \
- grpc_channel_args_destroy(&exec_ctx, new_client_args); \
- grpc_exec_ctx_finish(&exec_ctx); \
+ grpc_core::ExecCtx _local_exec_ctx; \
+ grpc_channel_args_destroy(new_client_args); \
} \
}
diff --git a/test/core/end2end/tests/cancel_after_accept.cc b/test/core/end2end/tests/cancel_after_accept.cc
index 83439d71d2..5ce45b4c61 100644
--- a/test/core/end2end/tests/cancel_after_accept.cc
+++ b/test/core/end2end/tests/cancel_after_accept.cc
@@ -245,9 +245,8 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
grpc_call_unref(s);
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);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(args);
}
cq_verifier_destroy(cqv);
diff --git a/test/core/end2end/tests/cancel_after_round_trip.cc b/test/core/end2end/tests/cancel_after_round_trip.cc
index ddcec67de5..9bd92b06e3 100644
--- a/test/core/end2end/tests/cancel_after_round_trip.cc
+++ b/test/core/end2end/tests/cancel_after_round_trip.cc
@@ -278,9 +278,8 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config,
grpc_call_unref(s);
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);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(args);
}
cq_verifier_destroy(cqv);
diff --git a/test/core/end2end/tests/compressed_payload.cc b/test/core/end2end/tests/compressed_payload.cc
index a8ea0ff2e0..93a06c9dfc 100644
--- a/test/core/end2end/tests/compressed_payload.cc
+++ b/test/core/end2end/tests/compressed_payload.cc
@@ -129,10 +129,9 @@ static void request_for_disabled_algorithm(
server_args =
grpc_channel_args_set_compression_algorithm(nullptr, GRPC_COMPRESS_NONE);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
server_args = grpc_channel_args_compression_algorithm_set_state(
- &exec_ctx, &server_args, algorithm_to_disable, false);
- grpc_exec_ctx_finish(&exec_ctx);
+ &server_args, algorithm_to_disable, false);
}
f = begin_test(config, test_name, client_args, server_args);
@@ -257,10 +256,9 @@ static void request_for_disabled_algorithm(
grpc_byte_buffer_destroy(request_payload_recv);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
end_test(&f);
@@ -539,10 +537,9 @@ static void request_with_payload_template(
cq_verifier_destroy(cqv);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
end_test(&f);
diff --git a/test/core/end2end/tests/filter_call_init_fails.cc b/test/core/end2end/tests/filter_call_init_fails.cc
index 6eed68a2f9..8f46f0bb91 100644
--- a/test/core/end2end/tests/filter_call_init_fails.cc
+++ b/test/core/end2end/tests/filter_call_init_fails.cc
@@ -399,26 +399,23 @@ static void test_client_subchannel_filter(grpc_end2end_test_config config) {
* Test filter - always fails to initialize a call
*/
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
return grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("access denied"),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_PERMISSION_DENIED);
}
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {}
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
static const grpc_channel_filter test_filter = {
grpc_call_next_op,
@@ -437,8 +434,7 @@ static const grpc_channel_filter test_filter = {
* Registration
*/
-static bool maybe_add_server_channel_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+static bool maybe_add_server_channel_filter(grpc_channel_stack_builder* builder,
void* arg) {
if (g_enable_server_channel_filter) {
// Want to add the filter as close to the end as possible, to make
@@ -457,8 +453,7 @@ static bool maybe_add_server_channel_filter(grpc_exec_ctx* exec_ctx,
}
}
-static bool maybe_add_client_channel_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder,
+static bool maybe_add_client_channel_filter(grpc_channel_stack_builder* builder,
void* arg) {
if (g_enable_client_channel_filter) {
// Want to add the filter as close to the end as possible, to make
@@ -478,7 +473,7 @@ static bool maybe_add_client_channel_filter(grpc_exec_ctx* exec_ctx,
}
static bool maybe_add_client_subchannel_filter(
- grpc_exec_ctx* exec_ctx, grpc_channel_stack_builder* builder, void* arg) {
+ grpc_channel_stack_builder* builder, void* arg) {
if (g_enable_client_subchannel_filter) {
// Want to add the filter as close to the end as possible, to make
// sure that all of the filters work well together. However, we
diff --git a/test/core/end2end/tests/filter_causes_close.cc b/test/core/end2end/tests/filter_causes_close.cc
index 793f590686..ec8f9dbe00 100644
--- a/test/core/end2end/tests/filter_causes_close.cc
+++ b/test/core/end2end/tests/filter_causes_close.cc
@@ -197,12 +197,11 @@ typedef struct {
uint8_t unused;
} channel_data;
-static void recv_im_ready(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void recv_im_ready(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
call_data* calld = (call_data*)elem->call_data;
GRPC_CLOSURE_RUN(
- exec_ctx, calld->recv_im_ready,
+ calld->recv_im_ready,
grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failure that's not preventable.", &error, 1),
GRPC_ERROR_INT_GRPC_STATUS,
@@ -210,8 +209,7 @@ static void recv_im_ready(grpc_exec_ctx* exec_ctx, void* arg,
}
static void start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* op) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
call_data* calld = (call_data*)elem->call_data;
if (op->recv_initial_metadata) {
calld->recv_im_ready =
@@ -219,27 +217,24 @@ static void start_transport_stream_op_batch(
op->payload->recv_initial_metadata.recv_initial_metadata_ready =
GRPC_CLOSURE_CREATE(recv_im_ready, elem, grpc_schedule_on_exec_ctx);
}
- grpc_call_next_op(exec_ctx, elem, op);
+ grpc_call_next_op(elem, op);
}
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {}
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
static const grpc_channel_filter test_filter = {
start_transport_stream_op_batch,
@@ -258,8 +253,7 @@ static const grpc_channel_filter test_filter = {
* Registration
*/
-static bool maybe_add_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder, void* arg) {
+static bool maybe_add_filter(grpc_channel_stack_builder* builder, void* arg) {
if (g_enable_filter) {
return grpc_channel_stack_builder_prepend_filter(builder, &test_filter,
nullptr, nullptr);
diff --git a/test/core/end2end/tests/filter_latency.cc b/test/core/end2end/tests/filter_latency.cc
index c4d96ebfe2..845cbc01cf 100644
--- a/test/core/end2end/tests/filter_latency.cc
+++ b/test/core/end2end/tests/filter_latency.cc
@@ -247,14 +247,12 @@ static void test_request(grpc_end2end_test_config config) {
* Test latency filter
*/
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void client_destroy_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void client_destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
gpr_mu_lock(&g_mu);
@@ -262,8 +260,7 @@ static void client_destroy_call_elem(grpc_exec_ctx* exec_ctx,
gpr_mu_unlock(&g_mu);
}
-static void server_destroy_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void server_destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
gpr_mu_lock(&g_mu);
@@ -271,14 +268,12 @@ static void server_destroy_call_elem(grpc_exec_ctx* exec_ctx,
gpr_mu_unlock(&g_mu);
}
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {}
+static void destroy_channel_elem(grpc_channel_element* elem) {}
static const grpc_channel_filter test_client_filter = {
grpc_call_next_op,
@@ -310,8 +305,7 @@ static const grpc_channel_filter test_server_filter = {
* Registration
*/
-static bool maybe_add_filter(grpc_exec_ctx* exec_ctx,
- grpc_channel_stack_builder* builder, void* arg) {
+static bool maybe_add_filter(grpc_channel_stack_builder* builder, void* arg) {
grpc_channel_filter* filter = (grpc_channel_filter*)arg;
if (g_enable_filter) {
// Want to add the filter as close to the end as possible, to make
diff --git a/test/core/end2end/tests/load_reporting_hook.cc b/test/core/end2end/tests/load_reporting_hook.cc
index faabec34cb..13e3af7ac5 100644
--- a/test/core/end2end/tests/load_reporting_hook.cc
+++ b/test/core/end2end/tests/load_reporting_hook.cc
@@ -300,9 +300,8 @@ static void test_load_reporting_hook(grpc_end2end_test_config config) {
&trailing_lr_metadata);
end_test(&f);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, lr_server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(lr_server_args);
}
config.tear_down_data(&f);
}
diff --git a/test/core/end2end/tests/max_message_length.cc b/test/core/end2end/tests/max_message_length.cc
index f1ac27fa7c..06243be75b 100644
--- a/test/core/end2end/tests/max_message_length.cc
+++ b/test/core/end2end/tests/max_message_length.cc
@@ -173,12 +173,9 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
f = begin_test(config, "test_max_request_message_length", client_args,
server_args);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- if (client_args != 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);
+ grpc_core::ExecCtx _local_exec_ctx;
+ if (client_args != nullptr) grpc_channel_args_destroy(client_args);
+ if (server_args != nullptr) grpc_channel_args_destroy(server_args);
}
cqv = cq_verifier_create(f.cq);
@@ -366,12 +363,9 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
f = begin_test(config, "test_max_response_message_length", client_args,
server_args);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- if (client_args != 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);
+ grpc_core::ExecCtx _local_exec_ctx;
+ if (client_args != nullptr) grpc_channel_args_destroy(client_args);
+ if (server_args != nullptr) grpc_channel_args_destroy(server_args);
}
cqv = cq_verifier_create(f.cq);
diff --git a/test/core/end2end/tests/stream_compression_compressed_payload.cc b/test/core/end2end/tests/stream_compression_compressed_payload.cc
index d73346468a..4f09df25db 100644
--- a/test/core/end2end/tests/stream_compression_compressed_payload.cc
+++ b/test/core/end2end/tests/stream_compression_compressed_payload.cc
@@ -129,10 +129,9 @@ static void request_for_disabled_algorithm(
server_args = grpc_channel_args_set_stream_compression_algorithm(
nullptr, GRPC_STREAM_COMPRESS_NONE);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
server_args = grpc_channel_args_stream_compression_algorithm_set_state(
- &exec_ctx, &server_args, algorithm_to_disable, false);
- grpc_exec_ctx_finish(&exec_ctx);
+ &server_args, algorithm_to_disable, false);
}
f = begin_test(config, test_name, client_args, server_args);
@@ -258,10 +257,9 @@ static void request_for_disabled_algorithm(
grpc_byte_buffer_destroy(request_payload_recv);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
end_test(&f);
@@ -547,10 +545,9 @@ static void request_with_payload_template(
cq_verifier_destroy(cqv);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
end_test(&f);
diff --git a/test/core/end2end/tests/stream_compression_payload.cc b/test/core/end2end/tests/stream_compression_payload.cc
index 924961ea55..6a8c9cdcb2 100644
--- a/test/core/end2end/tests/stream_compression_payload.cc
+++ b/test/core/end2end/tests/stream_compression_payload.cc
@@ -277,10 +277,9 @@ static void test_invoke_request_response_with_payload(
end_test(&f);
config.tear_down_data(&f);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
}
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 d3b526f04e..3e1a532af5 100644
--- a/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc
+++ b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc
@@ -275,10 +275,9 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
end_test(&f);
config.tear_down_data(&f);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
}
diff --git a/test/core/end2end/tests/workaround_cronet_compression.cc b/test/core/end2end/tests/workaround_cronet_compression.cc
index bc4d5079d8..8c5c9e834f 100644
--- a/test/core/end2end/tests/workaround_cronet_compression.cc
+++ b/test/core/end2end/tests/workaround_cronet_compression.cc
@@ -142,15 +142,14 @@ static void request_with_payload_template(
nullptr, default_server_channel_compression_algorithm);
if (user_agent_override) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_channel_args* client_args_old = client_args;
grpc_arg arg;
arg.key = const_cast<char*>(GRPC_ARG_PRIMARY_USER_AGENT_STRING);
arg.type = GRPC_ARG_STRING;
arg.value.string = user_agent_override;
client_args = grpc_channel_args_copy_and_add(client_args_old, &arg, 1);
- grpc_channel_args_destroy(&exec_ctx, client_args_old);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_args_destroy(client_args_old);
}
f = begin_test(config, test_name, client_args, server_args);
@@ -351,10 +350,9 @@ static void request_with_payload_template(
cq_verifier_destroy(cqv);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, client_args);
- grpc_channel_args_destroy(&exec_ctx, server_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(client_args);
+ grpc_channel_args_destroy(server_args);
}
end_test(&f);
diff --git a/test/core/handshake/readahead_handshaker_server_ssl.cc b/test/core/handshake/readahead_handshaker_server_ssl.cc
index 2810082837..f271200b7b 100644
--- a/test/core/handshake/readahead_handshaker_server_ssl.cc
+++ b/test/core/handshake/readahead_handshaker_server_ssl.cc
@@ -49,41 +49,41 @@
* 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,
+static void readahead_handshaker_destroy(
grpc_handshaker* handshaker) {
gpr_free(handshaker);
}
-static void readahead_handshaker_shutdown(grpc_exec_ctx* ctx,
+static void readahead_handshaker_shutdown(
grpc_handshaker* handshaker,
grpc_error* error) {}
static void readahead_handshaker_do_handshake(
- grpc_exec_ctx* ctx, grpc_handshaker* handshaker,
+ 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);
+ grpc_endpoint_read(args->endpoint, args->read_buffer, on_handshake_done);
}
const grpc_handshaker_vtable readahead_handshaker_vtable = {
readahead_handshaker_destroy, readahead_handshaker_shutdown,
readahead_handshaker_do_handshake};
-static grpc_handshaker* readahead_handshaker_create(grpc_exec_ctx* ctx) {
+static grpc_handshaker* readahead_handshaker_create() {
grpc_handshaker* h = (grpc_handshaker*)gpr_zalloc(sizeof(grpc_handshaker));
grpc_handshaker_init(&readahead_handshaker_vtable, h);
return h;
}
static void readahead_handshaker_factory_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory* hf,
+ 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));
+ readahead_handshaker_create());
}
static void readahead_handshaker_factory_destroy(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory* handshaker_factory) {}
+ grpc_handshaker_factory* handshaker_factory) {}
static const grpc_handshaker_factory_vtable
readahead_handshaker_factory_vtable = {
diff --git a/test/core/http/httpcli_test.cc b/test/core/http/httpcli_test.cc
index 81e9374819..d354ad3570 100644
--- a/test/core/http/httpcli_test.cc
+++ b/test/core/http/httpcli_test.cc
@@ -40,7 +40,7 @@ static grpc_millis n_seconds_time(int seconds) {
grpc_timeout_seconds_to_deadline(seconds));
}
-static void on_finish(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void on_finish(void* arg, grpc_error* error) {
const char* expect =
"<html><head><title>Hello world!</title></head>"
"<body><p>This is a test</p></body></html>";
@@ -53,15 +53,14 @@ static void on_finish(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
g_done = 1;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&g_pops),
- nullptr)));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&g_pops), nullptr)));
gpr_mu_unlock(g_mu);
}
static void test_get(int port) {
grpc_httpcli_request req;
char* host;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
g_done = 0;
gpr_log(GPR_INFO, "test_get");
@@ -78,19 +77,18 @@ static void test_get(int port) {
memset(&response, 0, sizeof(response));
grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_get");
grpc_httpcli_get(
- &exec_ctx, &g_context, &g_pops, resource_quota, &req, n_seconds_time(15),
+ &g_context, &g_pops, resource_quota, &req, n_seconds_time(15),
GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx),
&response);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
- &worker, n_seconds_time(1))));
+ "pollset_work", grpc_pollset_work(grpc_polling_entity_pollset(&g_pops),
+ &worker, n_seconds_time(1))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -101,7 +99,7 @@ static void test_get(int port) {
static void test_post(int port) {
grpc_httpcli_request req;
char* host;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
g_done = 0;
gpr_log(GPR_INFO, "test_post");
@@ -118,20 +116,18 @@ static void test_post(int port) {
memset(&response, 0, sizeof(response));
grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_post");
grpc_httpcli_post(
- &exec_ctx, &g_context, &g_pops, resource_quota, &req, "hello", 5,
- n_seconds_time(15),
+ &g_context, &g_pops, resource_quota, &req, "hello", 5, n_seconds_time(15),
GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx),
&response);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
- &worker, n_seconds_time(1))));
+ "pollset_work", grpc_pollset_work(grpc_polling_entity_pollset(&g_pops),
+ &worker, n_seconds_time(1))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -139,14 +135,14 @@ static void test_post(int port) {
grpc_http_response_destroy(&response);
}
-static void destroy_pops(grpc_exec_ctx* exec_ctx, void* p, grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, grpc_polling_entity_pollset(
- static_cast<grpc_polling_entity*>(p)));
+static void destroy_pops(void* p, grpc_error* error) {
+ grpc_pollset_destroy(
+ grpc_polling_entity_pollset(static_cast<grpc_polling_entity*>(p)));
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_subprocess* server;
char* me = argv[0];
char* lslash = strrchr(me, '/');
@@ -196,12 +192,11 @@ int main(int argc, char** argv) {
test_get(port);
test_post(port);
- grpc_httpcli_context_destroy(&exec_ctx, &g_context);
+ grpc_httpcli_context_destroy(&g_context);
GRPC_CLOSURE_INIT(&destroyed, destroy_pops, &g_pops,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
- &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(grpc_polling_entity_pollset(&g_pops), &destroyed);
+
grpc_shutdown();
gpr_free(grpc_polling_entity_pollset(&g_pops));
diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc
index da8405c049..76bbd2d366 100644
--- a/test/core/http/httpscli_test.cc
+++ b/test/core/http/httpscli_test.cc
@@ -40,7 +40,7 @@ static grpc_millis n_seconds_time(int seconds) {
grpc_timeout_seconds_to_deadline(seconds));
}
-static void on_finish(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void on_finish(void* arg, grpc_error* error) {
const char* expect =
"<html><head><title>Hello world!</title></head>"
"<body><p>This is a test</p></body></html>";
@@ -53,15 +53,14 @@ static void on_finish(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
g_done = 1;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&g_pops),
- nullptr)));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&g_pops), nullptr)));
gpr_mu_unlock(g_mu);
}
static void test_get(int port) {
grpc_httpcli_request req;
char* host;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
g_done = 0;
gpr_log(GPR_INFO, "test_get");
@@ -79,19 +78,18 @@ static void test_get(int port) {
memset(&response, 0, sizeof(response));
grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_get");
grpc_httpcli_get(
- &exec_ctx, &g_context, &g_pops, resource_quota, &req, n_seconds_time(15),
+ &g_context, &g_pops, resource_quota, &req, n_seconds_time(15),
GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx),
&response);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
- &worker, n_seconds_time(1))));
+ "pollset_work", grpc_pollset_work(grpc_polling_entity_pollset(&g_pops),
+ &worker, n_seconds_time(1))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -102,7 +100,7 @@ static void test_get(int port) {
static void test_post(int port) {
grpc_httpcli_request req;
char* host;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
g_done = 0;
gpr_log(GPR_INFO, "test_post");
@@ -120,20 +118,18 @@ static void test_post(int port) {
memset(&response, 0, sizeof(response));
grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_post");
grpc_httpcli_post(
- &exec_ctx, &g_context, &g_pops, resource_quota, &req, "hello", 5,
- n_seconds_time(15),
+ &g_context, &g_pops, resource_quota, &req, "hello", 5, n_seconds_time(15),
GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx),
&response);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
- &worker, n_seconds_time(1))));
+ "pollset_work", grpc_pollset_work(grpc_polling_entity_pollset(&g_pops),
+ &worker, n_seconds_time(1))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -141,14 +137,14 @@ static void test_post(int port) {
grpc_http_response_destroy(&response);
}
-static void destroy_pops(grpc_exec_ctx* exec_ctx, void* p, grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, grpc_polling_entity_pollset(
- static_cast<grpc_polling_entity*>(p)));
+static void destroy_pops(void* p, grpc_error* error) {
+ grpc_pollset_destroy(
+ grpc_polling_entity_pollset(static_cast<grpc_polling_entity*>(p)));
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_subprocess* server;
char* me = argv[0];
char* lslash = strrchr(me, '/');
@@ -199,12 +195,11 @@ int main(int argc, char** argv) {
test_get(port);
test_post(port);
- grpc_httpcli_context_destroy(&exec_ctx, &g_context);
+ grpc_httpcli_context_destroy(&g_context);
GRPC_CLOSURE_INIT(&destroyed, destroy_pops, &g_pops,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
- &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(grpc_polling_entity_pollset(&g_pops), &destroyed);
+
grpc_shutdown();
gpr_free(grpc_polling_entity_pollset(&g_pops));
diff --git a/test/core/iomgr/combiner_test.cc b/test/core/iomgr/combiner_test.cc
index 146a6bd553..faa5c3dcbc 100644
--- a/test/core/iomgr/combiner_test.cc
+++ b/test/core/iomgr/combiner_test.cc
@@ -28,13 +28,11 @@
static void test_no_op(void) {
gpr_log(GPR_DEBUG, "test_no_op");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_COMBINER_UNREF(&exec_ctx, grpc_combiner_create(), "test_no_op");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_COMBINER_UNREF(grpc_combiner_create(), "test_no_op");
}
-static void set_event_to_true(grpc_exec_ctx* exec_ctx, void* value,
- grpc_error* error) {
+static void set_event_to_true(void* value, grpc_error* error) {
gpr_event_set(static_cast<gpr_event*>(value), (void*)1);
}
@@ -44,16 +42,14 @@ static void test_execute_one(void) {
grpc_combiner* lock = grpc_combiner_create();
gpr_event done;
gpr_event_init(&done);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CLOSURE_SCHED(&exec_ctx,
- GRPC_CLOSURE_CREATE(set_event_to_true, &done,
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(set_event_to_true, &done,
grpc_combiner_scheduler(lock)),
GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&done, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
- GRPC_COMBINER_UNREF(&exec_ctx, lock, "test_execute_one");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(lock, "test_execute_one");
}
typedef struct {
@@ -67,7 +63,7 @@ typedef struct {
size_t value;
} ex_args;
-static void check_one(grpc_exec_ctx* exec_ctx, void* a, grpc_error* error) {
+static void check_one(void* a, grpc_error* error) {
ex_args* args = static_cast<ex_args*>(a);
GPR_ASSERT(*args->ctr == args->value - 1);
*args->ctr = args->value;
@@ -76,28 +72,25 @@ static void check_one(grpc_exec_ctx* exec_ctx, void* a, grpc_error* error) {
static void execute_many_loop(void* a) {
thd_args* args = static_cast<thd_args*>(a);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
size_t n = 1;
for (size_t i = 0; i < 10; i++) {
for (size_t j = 0; j < 10000; j++) {
ex_args* c = static_cast<ex_args*>(gpr_malloc(sizeof(*c)));
c->ctr = &args->ctr;
c->value = n++;
- GRPC_CLOSURE_SCHED(&exec_ctx,
- GRPC_CLOSURE_CREATE(
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(
check_one, c, grpc_combiner_scheduler(args->lock)),
GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
}
// sleep for a little bit, to test a combiner draining and another thread
// picking it up
gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(100));
}
- GRPC_CLOSURE_SCHED(&exec_ctx,
- GRPC_CLOSURE_CREATE(set_event_to_true, &args->done,
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(set_event_to_true, &args->done,
grpc_combiner_scheduler(args->lock)),
GRPC_ERROR_NONE);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_execute_many(void) {
@@ -119,20 +112,18 @@ static void test_execute_many(void) {
gpr_inf_future(GPR_CLOCK_REALTIME)) != nullptr);
gpr_thd_join(thds[i]);
}
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_COMBINER_UNREF(&exec_ctx, lock, "test_execute_many");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_COMBINER_UNREF(lock, "test_execute_many");
}
static gpr_event got_in_finally;
-static void in_finally(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void in_finally(void* arg, grpc_error* error) {
gpr_event_set(&got_in_finally, (void*)1);
}
-static void add_finally(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
- GRPC_CLOSURE_SCHED(exec_ctx,
- GRPC_CLOSURE_CREATE(in_finally, arg,
+static void add_finally(void* arg, grpc_error* error) {
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(in_finally, arg,
grpc_combiner_finally_scheduler(
static_cast<grpc_combiner*>(arg))),
GRPC_ERROR_NONE);
@@ -142,17 +133,15 @@ static void test_execute_finally(void) {
gpr_log(GPR_DEBUG, "test_execute_finally");
grpc_combiner* lock = grpc_combiner_create();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_event_init(&got_in_finally);
GRPC_CLOSURE_SCHED(
- &exec_ctx,
GRPC_CLOSURE_CREATE(add_finally, lock, grpc_combiner_scheduler(lock)),
GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(gpr_event_wait(&got_in_finally,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
- GRPC_COMBINER_UNREF(&exec_ctx, lock, "test_execute_finally");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(lock, "test_execute_finally");
}
int main(int argc, char** argv) {
diff --git a/test/core/iomgr/endpoint_pair_test.cc b/test/core/iomgr/endpoint_pair_test.cc
index 30a0cb5924..658971b9fb 100644
--- a/test/core/iomgr/endpoint_pair_test.cc
+++ b/test/core/iomgr/endpoint_pair_test.cc
@@ -32,7 +32,7 @@ static void clean_up(void) {}
static grpc_endpoint_test_fixture create_fixture_endpoint_pair(
size_t slice_size) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_endpoint_test_fixture f;
grpc_arg a[1];
a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE);
@@ -43,9 +43,8 @@ static grpc_endpoint_test_fixture create_fixture_endpoint_pair(
f.client_ep = p.client;
f.server_ep = p.server;
- grpc_endpoint_add_to_pollset(&exec_ctx, f.client_ep, g_pollset);
- grpc_endpoint_add_to_pollset(&exec_ctx, f.server_ep, g_pollset);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_endpoint_add_to_pollset(f.client_ep, g_pollset);
+ grpc_endpoint_add_to_pollset(f.server_ep, g_pollset);
return f;
}
@@ -54,14 +53,13 @@ static grpc_endpoint_test_config configs[] = {
{"tcp/tcp_socketpair", create_fixture_endpoint_pair, clean_up},
};
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p));
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_test_init(argc, argv);
grpc_init();
g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
@@ -69,8 +67,8 @@ int main(int argc, char** argv) {
grpc_endpoint_tests(configs[0], g_pollset, g_mu);
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+
grpc_shutdown();
gpr_free(g_pollset);
diff --git a/test/core/iomgr/endpoint_tests.cc b/test/core/iomgr/endpoint_tests.cc
index 026e34105d..c011ab96d9 100644
--- a/test/core/iomgr/endpoint_tests.cc
+++ b/test/core/iomgr/endpoint_tests.cc
@@ -115,8 +115,7 @@ struct read_and_write_test_state {
grpc_closure done_write;
};
-static void read_and_write_test_read_handler(grpc_exec_ctx* exec_ctx,
- void* data, grpc_error* error) {
+static void read_and_write_test_read_handler(void* data, grpc_error* error) {
struct read_and_write_test_state* state =
(struct read_and_write_test_state*)data;
@@ -126,17 +125,14 @@ static void read_and_write_test_read_handler(grpc_exec_ctx* exec_ctx,
gpr_log(GPR_INFO, "Read handler done");
gpr_mu_lock(g_mu);
state->read_done = 1 + (error == GRPC_ERROR_NONE);
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, nullptr));
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr));
gpr_mu_unlock(g_mu);
} else if (error == GRPC_ERROR_NONE) {
- grpc_endpoint_read(exec_ctx, state->read_ep, &state->incoming,
- &state->done_read);
+ grpc_endpoint_read(state->read_ep, &state->incoming, &state->done_read);
}
}
-static void read_and_write_test_write_handler(grpc_exec_ctx* exec_ctx,
- void* data, grpc_error* error) {
+static void read_and_write_test_write_handler(void* data, grpc_error* error) {
struct read_and_write_test_state* state =
(struct read_and_write_test_state*)data;
grpc_slice* slices = nullptr;
@@ -153,7 +149,7 @@ static void read_and_write_test_write_handler(grpc_exec_ctx* exec_ctx,
&state->current_write_data);
grpc_slice_buffer_reset_and_unref(&state->outgoing);
grpc_slice_buffer_addn(&state->outgoing, slices, nslices);
- grpc_endpoint_write(exec_ctx, state->write_ep, &state->outgoing,
+ grpc_endpoint_write(state->write_ep, &state->outgoing,
&state->done_write);
gpr_free(slices);
return;
@@ -163,8 +159,7 @@ static void read_and_write_test_write_handler(grpc_exec_ctx* exec_ctx,
gpr_log(GPR_INFO, "Write handler done");
gpr_mu_lock(g_mu);
state->write_done = 1 + (error == GRPC_ERROR_NONE);
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, nullptr));
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr));
gpr_mu_unlock(g_mu);
}
@@ -178,7 +173,7 @@ static void read_and_write_test(grpc_endpoint_test_config config,
struct read_and_write_test_state state;
grpc_endpoint_test_fixture f =
begin_test(config, "read_and_write_test", slice_size);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_millis deadline =
grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20));
gpr_log(GPR_DEBUG,
@@ -217,66 +212,57 @@ static void read_and_write_test(grpc_endpoint_test_config config,
for the first iteration as for later iterations. It does the right thing
even when bytes_written is unsigned. */
state.bytes_written -= state.current_write_size;
- read_and_write_test_write_handler(&exec_ctx, &state, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ read_and_write_test_write_handler(&state, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
- grpc_endpoint_read(&exec_ctx, state.read_ep, &state.incoming,
- &state.done_read);
+ grpc_endpoint_read(state.read_ep, &state.incoming, &state.done_read);
if (shutdown) {
gpr_log(GPR_DEBUG, "shutdown read");
grpc_endpoint_shutdown(
- &exec_ctx, state.read_ep,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
+ state.read_ep, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
gpr_log(GPR_DEBUG, "shutdown write");
grpc_endpoint_shutdown(
- &exec_ctx, state.write_ep,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
+ state.write_ep, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
}
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
while (!state.read_done || !state.write_done) {
grpc_pollset_worker* worker = nullptr;
- GPR_ASSERT(grpc_exec_ctx_now(&exec_ctx) < deadline);
+ GPR_ASSERT(grpc_core::ExecCtx::Get()->Now() < deadline);
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
end_test(config);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &state.outgoing);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &state.incoming);
- grpc_endpoint_destroy(&exec_ctx, state.read_ep);
- grpc_endpoint_destroy(&exec_ctx, state.write_ep);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_buffer_destroy_internal(&state.outgoing);
+ grpc_slice_buffer_destroy_internal(&state.incoming);
+ grpc_endpoint_destroy(state.read_ep);
+ grpc_endpoint_destroy(state.write_ep);
}
-static void inc_on_failure(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void inc_on_failure(void* arg, grpc_error* error) {
gpr_mu_lock(g_mu);
*(int*)arg += (error != GRPC_ERROR_NONE);
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(GRPC_LOG_IF_ERROR("kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
-static void wait_for_fail_count(grpc_exec_ctx* exec_ctx, int* fail_count,
- int want_fail_count) {
- grpc_exec_ctx_flush(exec_ctx);
+static void wait_for_fail_count(int* fail_count, int want_fail_count) {
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
grpc_millis deadline =
grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10));
- while (grpc_exec_ctx_now(exec_ctx) < deadline &&
+ while (grpc_core::ExecCtx::Get()->Now() < deadline &&
*fail_count < want_fail_count) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(exec_ctx, g_pollset, &worker, deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
GPR_ASSERT(*fail_count == want_fail_count);
@@ -291,33 +277,32 @@ static void multiple_shutdown_test(grpc_endpoint_test_config config) {
grpc_slice_buffer slice_buffer;
grpc_slice_buffer_init(&slice_buffer);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_endpoint_add_to_pollset(&exec_ctx, f.client_ep, g_pollset);
- grpc_endpoint_read(&exec_ctx, f.client_ep, &slice_buffer,
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_endpoint_add_to_pollset(f.client_ep, g_pollset);
+ grpc_endpoint_read(f.client_ep, &slice_buffer,
GRPC_CLOSURE_CREATE(inc_on_failure, &fail_count,
grpc_schedule_on_exec_ctx));
- wait_for_fail_count(&exec_ctx, &fail_count, 0);
- grpc_endpoint_shutdown(&exec_ctx, f.client_ep,
+ wait_for_fail_count(&fail_count, 0);
+ grpc_endpoint_shutdown(f.client_ep,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
- wait_for_fail_count(&exec_ctx, &fail_count, 1);
- grpc_endpoint_read(&exec_ctx, f.client_ep, &slice_buffer,
+ wait_for_fail_count(&fail_count, 1);
+ grpc_endpoint_read(f.client_ep, &slice_buffer,
GRPC_CLOSURE_CREATE(inc_on_failure, &fail_count,
grpc_schedule_on_exec_ctx));
- wait_for_fail_count(&exec_ctx, &fail_count, 2);
+ wait_for_fail_count(&fail_count, 2);
grpc_slice_buffer_add(&slice_buffer, grpc_slice_from_copied_string("a"));
- grpc_endpoint_write(&exec_ctx, f.client_ep, &slice_buffer,
+ grpc_endpoint_write(f.client_ep, &slice_buffer,
GRPC_CLOSURE_CREATE(inc_on_failure, &fail_count,
grpc_schedule_on_exec_ctx));
- wait_for_fail_count(&exec_ctx, &fail_count, 3);
- grpc_endpoint_shutdown(&exec_ctx, f.client_ep,
+ wait_for_fail_count(&fail_count, 3);
+ grpc_endpoint_shutdown(f.client_ep,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown"));
- wait_for_fail_count(&exec_ctx, &fail_count, 3);
+ wait_for_fail_count(&fail_count, 3);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &slice_buffer);
+ grpc_slice_buffer_destroy_internal(&slice_buffer);
- grpc_endpoint_destroy(&exec_ctx, f.client_ep);
- grpc_endpoint_destroy(&exec_ctx, f.server_ep);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_endpoint_destroy(f.client_ep);
+ grpc_endpoint_destroy(f.server_ep);
}
void grpc_endpoint_tests(grpc_endpoint_test_config config,
diff --git a/test/core/iomgr/ev_epollsig_linux_test.cc b/test/core/iomgr/ev_epollsig_linux_test.cc
index ac8b2f43d1..ae77834401 100644
--- a/test/core/iomgr/ev_epollsig_linux_test.cc
+++ b/test/core/iomgr/ev_epollsig_linux_test.cc
@@ -70,19 +70,18 @@ static void test_fd_init(test_fd* tfds, int* fds, int num_fds) {
}
}
-static void test_fd_cleanup(grpc_exec_ctx* exec_ctx, test_fd* tfds,
- int num_fds) {
+static void test_fd_cleanup(test_fd* tfds, int num_fds) {
int release_fd;
int i;
for (i = 0; i < num_fds; i++) {
- grpc_fd_shutdown(exec_ctx, tfds[i].fd,
+ grpc_fd_shutdown(tfds[i].fd,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_fd_cleanup"));
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
- grpc_fd_orphan(exec_ctx, tfds[i].fd, nullptr, &release_fd,
- false /* already_closed */, "test_fd_cleanup");
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_fd_orphan(tfds[i].fd, nullptr, &release_fd, false /* already_closed */,
+ "test_fd_cleanup");
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(release_fd == tfds[i].inner_fd);
close(tfds[i].inner_fd);
@@ -98,22 +97,20 @@ static void test_pollset_init(test_pollset* pollsets, int num_pollsets) {
}
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, (grpc_pollset*)p);
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy((grpc_pollset*)p);
}
-static void test_pollset_cleanup(grpc_exec_ctx* exec_ctx,
- test_pollset* pollsets, int num_pollsets) {
+static void test_pollset_cleanup(test_pollset* pollsets, int num_pollsets) {
grpc_closure destroyed;
int i;
for (i = 0; i < num_pollsets; i++) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, pollsets[i].pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(exec_ctx, pollsets[i].pollset, &destroyed);
+ grpc_pollset_shutdown(pollsets[i].pollset, &destroyed);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(pollsets[i].pollset);
}
}
@@ -133,7 +130,7 @@ static void test_pollset_cleanup(grpc_exec_ctx* exec_ctx,
#define NUM_POLLSETS 4
static void test_add_fd_to_pollset() {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
test_fd tfds[NUM_FDS];
int fds[NUM_FDS];
test_pollset pollsets[NUM_POLLSETS];
@@ -170,33 +167,33 @@ static void test_add_fd_to_pollset() {
/* == Step 1 == */
for (i = 0; i <= 2; i++) {
- grpc_pollset_add_fd(&exec_ctx, pollsets[0].pollset, tfds[i].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(pollsets[0].pollset, tfds[i].fd);
+ grpc_core::ExecCtx::Get()->Flush();
}
for (i = 3; i <= 4; i++) {
- grpc_pollset_add_fd(&exec_ctx, pollsets[1].pollset, tfds[i].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(pollsets[1].pollset, tfds[i].fd);
+ grpc_core::ExecCtx::Get()->Flush();
}
for (i = 5; i <= 7; i++) {
- grpc_pollset_add_fd(&exec_ctx, pollsets[2].pollset, tfds[i].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(pollsets[2].pollset, tfds[i].fd);
+ grpc_core::ExecCtx::Get()->Flush();
}
/* == Step 2 == */
for (i = 0; i <= 1; i++) {
- grpc_pollset_add_fd(&exec_ctx, pollsets[3].pollset, tfds[i].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(pollsets[3].pollset, tfds[i].fd);
+ grpc_core::ExecCtx::Get()->Flush();
}
/* == Step 3 == */
- grpc_pollset_add_fd(&exec_ctx, pollsets[1].pollset, tfds[0].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(pollsets[1].pollset, tfds[0].fd);
+ grpc_core::ExecCtx::Get()->Flush();
/* == Step 4 == */
- grpc_pollset_add_fd(&exec_ctx, pollsets[2].pollset, tfds[3].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(pollsets[2].pollset, tfds[3].fd);
+ grpc_core::ExecCtx::Get()->Flush();
/* All polling islands are merged at this point */
@@ -213,9 +210,8 @@ static void test_add_fd_to_pollset() {
expected_pi, grpc_pollset_get_polling_island(pollsets[i].pollset)));
}
- test_fd_cleanup(&exec_ctx, tfds, NUM_FDS);
- test_pollset_cleanup(&exec_ctx, pollsets, NUM_POLLSETS);
- grpc_exec_ctx_finish(&exec_ctx);
+ test_fd_cleanup(tfds, NUM_FDS);
+ test_pollset_cleanup(pollsets, NUM_POLLSETS);
}
#undef NUM_FDS
@@ -235,26 +231,24 @@ static __thread int thread_wakeups = 0;
static void test_threading_loop(void* arg) {
threading_shared* shared = static_cast<threading_shared*>(arg);
while (thread_wakeups < 1000000) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_pollset_worker* worker;
gpr_mu_lock(shared->mu);
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work", grpc_pollset_work(&exec_ctx, shared->pollset, &worker,
- GRPC_MILLIS_INF_FUTURE)));
+ "pollset_work",
+ grpc_pollset_work(shared->pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(shared->mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
}
-static void test_threading_wakeup(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void test_threading_wakeup(void* arg, grpc_error* error) {
threading_shared* shared = static_cast<threading_shared*>(arg);
++shared->wakeups;
++thread_wakeups;
if (error == GRPC_ERROR_NONE) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"consume_wakeup", grpc_wakeup_fd_consume_wakeup(shared->wakeup_fd)));
- grpc_fd_notify_on_read(exec_ctx, shared->wakeup_desc, &shared->on_wakeup);
+ grpc_fd_notify_on_read(shared->wakeup_desc, &shared->on_wakeup);
GPR_ASSERT(GRPC_LOG_IF_ERROR("wakeup_next",
grpc_wakeup_fd_wakeup(shared->wakeup_fd)));
}
@@ -277,13 +271,12 @@ static void test_threading(void) {
shared.wakeup_desc = grpc_fd_create(fd.read_fd, "wakeup");
shared.wakeups = 0;
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_pollset_add_fd(&exec_ctx, shared.pollset, shared.wakeup_desc);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_pollset_add_fd(shared.pollset, shared.wakeup_desc);
grpc_fd_notify_on_read(
- &exec_ctx, shared.wakeup_desc,
+ shared.wakeup_desc,
GRPC_CLOSURE_INIT(&shared.on_wakeup, test_threading_wakeup, &shared,
grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_finish(&exec_ctx);
}
GPR_ASSERT(GRPC_LOG_IF_ERROR("wakeup_first",
grpc_wakeup_fd_wakeup(shared.wakeup_fd)));
@@ -293,14 +286,13 @@ static void test_threading(void) {
fd.read_fd = 0;
grpc_wakeup_fd_destroy(&fd);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_fd_shutdown(&exec_ctx, shared.wakeup_desc, GRPC_ERROR_CANCELLED);
- grpc_fd_orphan(&exec_ctx, shared.wakeup_desc, nullptr, nullptr,
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_fd_shutdown(shared.wakeup_desc, GRPC_ERROR_CANCELLED);
+ grpc_fd_orphan(shared.wakeup_desc, nullptr, nullptr,
false /* already_closed */, "done");
- grpc_pollset_shutdown(&exec_ctx, shared.pollset,
+ grpc_pollset_shutdown(shared.pollset,
GRPC_CLOSURE_CREATE(destroy_pollset, shared.pollset,
grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_finish(&exec_ctx);
}
gpr_free(shared.pollset);
}
@@ -309,7 +301,7 @@ int main(int argc, char** argv) {
const char* poll_strategy = nullptr;
grpc_test_init(argc, argv);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
poll_strategy = grpc_get_poll_strategy_name();
if (poll_strategy != nullptr && strcmp(poll_strategy, "epollsig") == 0) {
@@ -322,7 +314,6 @@ int main(int argc, char** argv) {
poll_strategy);
}
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/fd_conservation_posix_test.cc b/test/core/iomgr/fd_conservation_posix_test.cc
index f46430c611..11e664d8ff 100644
--- a/test/core/iomgr/fd_conservation_posix_test.cc
+++ b/test/core/iomgr/fd_conservation_posix_test.cc
@@ -31,7 +31,7 @@ int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
/* set max # of file descriptors to a low value, and
verify we can create and destroy many more than this number
@@ -42,15 +42,14 @@ 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", nullptr);
- grpc_endpoint_destroy(&exec_ctx, p.client);
- grpc_endpoint_destroy(&exec_ctx, p.server);
- grpc_exec_ctx_flush(&exec_ctx);
+ p = grpc_iomgr_create_endpoint_pair("test", NULL);
+ grpc_endpoint_destroy(p.client);
+ grpc_endpoint_destroy(p.server);
+ grpc_core::ExecCtx::Get()->Flush();
}
grpc_resource_quota_unref(resource_quota);
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/fd_posix_test.cc b/test/core/iomgr/fd_posix_test.cc
index a03d841ecd..3a9d801169 100644
--- a/test/core/iomgr/fd_posix_test.cc
+++ b/test/core/iomgr/fd_posix_test.cc
@@ -111,20 +111,19 @@ typedef struct {
/* Called when an upload session can be safely shutdown.
Close session FD and start to shutdown listen FD. */
-static void session_shutdown_cb(grpc_exec_ctx* exec_ctx, void* arg, /*session */
+static void session_shutdown_cb(void* arg, /*session */
bool success) {
session* se = static_cast<session*>(arg);
server* sv = se->sv;
- grpc_fd_orphan(exec_ctx, se->em_fd, nullptr, nullptr,
- false /* already_closed */, "a");
+ grpc_fd_orphan(se->em_fd, nullptr, nullptr, false /* already_closed */, "a");
gpr_free(se);
/* Start to shutdown listen fd. */
- grpc_fd_shutdown(exec_ctx, sv->em_fd,
+ grpc_fd_shutdown(sv->em_fd,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("session_shutdown_cb"));
}
/* Called when data become readable in a session. */
-static void session_read_cb(grpc_exec_ctx* exec_ctx, void* arg, /*session */
+static void session_read_cb(void* arg, /*session */
grpc_error* error) {
session* se = static_cast<session*>(arg);
int fd = grpc_fd_wrapped_fd(se->em_fd);
@@ -133,7 +132,7 @@ static void session_read_cb(grpc_exec_ctx* exec_ctx, void* arg, /*session */
ssize_t read_total = 0;
if (error != GRPC_ERROR_NONE) {
- session_shutdown_cb(exec_ctx, arg, 1);
+ session_shutdown_cb(arg, 1);
return;
}
@@ -148,7 +147,7 @@ static void session_read_cb(grpc_exec_ctx* exec_ctx, void* arg, /*session */
It is possible to read nothing due to spurious edge event or data has
been drained, In such a case, read() returns -1 and set errno to EAGAIN. */
if (read_once == 0) {
- session_shutdown_cb(exec_ctx, arg, 1);
+ session_shutdown_cb(arg, 1);
} else if (read_once == -1) {
if (errno == EAGAIN) {
/* An edge triggered event is cached in the kernel until next poll.
@@ -159,7 +158,7 @@ static void session_read_cb(grpc_exec_ctx* exec_ctx, void* arg, /*session */
TODO(chenw): in multi-threaded version, callback and polling can be
run in different threads. polling may catch a persist read edge event
before notify_on_read is called. */
- grpc_fd_notify_on_read(exec_ctx, se->em_fd, &se->session_read_closure);
+ grpc_fd_notify_on_read(se->em_fd, &se->session_read_closure);
} else {
gpr_log(GPR_ERROR, "Unhandled read error %s", strerror(errno));
abort();
@@ -169,22 +168,20 @@ static void session_read_cb(grpc_exec_ctx* exec_ctx, void* arg, /*session */
/* Called when the listen FD can be safely shutdown.
Close listen FD and signal that server can be shutdown. */
-static void listen_shutdown_cb(grpc_exec_ctx* exec_ctx, void* arg /*server */,
- int success) {
+static void listen_shutdown_cb(void* arg /*server */, int success) {
server* sv = static_cast<server*>(arg);
- grpc_fd_orphan(exec_ctx, sv->em_fd, nullptr, nullptr,
- false /* already_closed */, "b");
+ grpc_fd_orphan(sv->em_fd, nullptr, nullptr, false /* already_closed */, "b");
gpr_mu_lock(g_mu);
sv->done = 1;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
/* Called when a new TCP connection request arrives in the listening port. */
-static void listen_cb(grpc_exec_ctx* exec_ctx, void* arg, /*=sv_arg*/
+static void listen_cb(void* arg, /*=sv_arg*/
grpc_error* error) {
server* sv = static_cast<server*>(arg);
int fd;
@@ -195,7 +192,7 @@ static void listen_cb(grpc_exec_ctx* exec_ctx, void* arg, /*=sv_arg*/
grpc_fd* listen_em_fd = sv->em_fd;
if (error != GRPC_ERROR_NONE) {
- listen_shutdown_cb(exec_ctx, arg, 1);
+ listen_shutdown_cb(arg, 1);
return;
}
@@ -207,12 +204,12 @@ static void listen_cb(grpc_exec_ctx* exec_ctx, void* arg, /*=sv_arg*/
se = static_cast<session*>(gpr_malloc(sizeof(*se)));
se->sv = sv;
se->em_fd = grpc_fd_create(fd, "listener");
- grpc_pollset_add_fd(exec_ctx, g_pollset, se->em_fd);
+ grpc_pollset_add_fd(g_pollset, se->em_fd);
GRPC_CLOSURE_INIT(&se->session_read_closure, session_read_cb, se,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_read(exec_ctx, se->em_fd, &se->session_read_closure);
+ grpc_fd_notify_on_read(se->em_fd, &se->session_read_closure);
- grpc_fd_notify_on_read(exec_ctx, listen_em_fd, &sv->listen_closure);
+ grpc_fd_notify_on_read(listen_em_fd, &sv->listen_closure);
}
/* Max number of connections pending to be accepted by listen(). */
@@ -222,7 +219,7 @@ static void listen_cb(grpc_exec_ctx* exec_ctx, void* arg, /*=sv_arg*/
listen_cb() is registered to be interested in reading from listen_fd.
When connection request arrives, listen_cb() is called to accept the
connection request. */
-static int server_start(grpc_exec_ctx* exec_ctx, server* sv) {
+static int server_start(server* sv) {
int port = 0;
int fd;
struct sockaddr_in sin;
@@ -236,11 +233,11 @@ static int server_start(grpc_exec_ctx* exec_ctx, server* sv) {
GPR_ASSERT(listen(fd, MAX_NUM_FD) == 0);
sv->em_fd = grpc_fd_create(fd, "server");
- grpc_pollset_add_fd(exec_ctx, g_pollset, sv->em_fd);
+ grpc_pollset_add_fd(g_pollset, sv->em_fd);
/* Register to be interested in reading from listen_fd. */
GRPC_CLOSURE_INIT(&sv->listen_closure, listen_cb, sv,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_read(exec_ctx, sv->em_fd, &sv->listen_closure);
+ grpc_fd_notify_on_read(sv->em_fd, &sv->listen_closure);
return port;
}
@@ -249,13 +246,13 @@ static int server_start(grpc_exec_ctx* exec_ctx, server* sv) {
static void server_wait_and_shutdown(server* sv) {
gpr_mu_lock(g_mu);
while (!sv->done) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
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)));
+ "pollset_work",
+ grpc_pollset_work(g_pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -289,18 +286,16 @@ static void client_init(client* cl) {
}
/* Called when a client upload session is ready to shutdown. */
-static void client_session_shutdown_cb(grpc_exec_ctx* exec_ctx,
- void* arg /*client */, int success) {
+static void client_session_shutdown_cb(void* arg /*client */, int success) {
client* cl = static_cast<client*>(arg);
- grpc_fd_orphan(exec_ctx, cl->em_fd, nullptr, nullptr,
- false /* already_closed */, "c");
+ grpc_fd_orphan(cl->em_fd, nullptr, nullptr, false /* already_closed */, "c");
cl->done = 1;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
}
/* Write as much as possible, then register notify_on_write. */
-static void client_session_write(grpc_exec_ctx* exec_ctx, void* arg, /*client */
+static void client_session_write(void* arg, /*client */
grpc_error* error) {
client* cl = static_cast<client*>(arg);
int fd = grpc_fd_wrapped_fd(cl->em_fd);
@@ -308,7 +303,7 @@ static void client_session_write(grpc_exec_ctx* exec_ctx, void* arg, /*client */
if (error != GRPC_ERROR_NONE) {
gpr_mu_lock(g_mu);
- client_session_shutdown_cb(exec_ctx, arg, 1);
+ client_session_shutdown_cb(arg, 1);
gpr_mu_unlock(g_mu);
return;
}
@@ -323,10 +318,10 @@ static void client_session_write(grpc_exec_ctx* exec_ctx, void* arg, /*client */
if (cl->client_write_cnt < CLIENT_TOTAL_WRITE_CNT) {
GRPC_CLOSURE_INIT(&cl->write_closure, client_session_write, cl,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_write(exec_ctx, cl->em_fd, &cl->write_closure);
+ grpc_fd_notify_on_write(cl->em_fd, &cl->write_closure);
cl->client_write_cnt++;
} else {
- client_session_shutdown_cb(exec_ctx, arg, 1);
+ client_session_shutdown_cb(arg, 1);
}
gpr_mu_unlock(g_mu);
} else {
@@ -336,7 +331,7 @@ static void client_session_write(grpc_exec_ctx* exec_ctx, void* arg, /*client */
}
/* Start a client to send a stream of bytes. */
-static void client_start(grpc_exec_ctx* exec_ctx, client* cl, int port) {
+static void client_start(client* cl, int port) {
int fd;
struct sockaddr_in sin;
create_test_socket(port, &fd, &sin);
@@ -357,9 +352,9 @@ static void client_start(grpc_exec_ctx* exec_ctx, client* cl, int port) {
}
cl->em_fd = grpc_fd_create(fd, "client");
- grpc_pollset_add_fd(exec_ctx, g_pollset, cl->em_fd);
+ grpc_pollset_add_fd(g_pollset, cl->em_fd);
- client_session_write(exec_ctx, cl, GRPC_ERROR_NONE);
+ client_session_write(cl, GRPC_ERROR_NONE);
}
/* Wait for the signal to shutdown a client. */
@@ -367,12 +362,12 @@ static void client_wait_and_shutdown(client* cl) {
gpr_mu_lock(g_mu);
while (!cl->done) {
grpc_pollset_worker* worker = nullptr;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- GRPC_MILLIS_INF_FUTURE)));
+ "pollset_work",
+ grpc_pollset_work(g_pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
@@ -385,13 +380,13 @@ static void test_grpc_fd(void) {
server sv;
client cl;
int port;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
server_init(&sv);
- port = server_start(&exec_ctx, &sv);
+ port = server_start(&sv);
client_init(&cl);
- client_start(&exec_ctx, &cl, port);
- grpc_exec_ctx_finish(&exec_ctx);
+ client_start(&cl, port);
+
client_wait_and_shutdown(&cl);
server_wait_and_shutdown(&sv);
GPR_ASSERT(sv.read_bytes_total == cl.write_bytes_total);
@@ -406,27 +401,25 @@ void init_change_data(fd_change_data* fdc) { fdc->cb_that_ran = nullptr; }
void destroy_change_data(fd_change_data* fdc) {}
-static void first_read_callback(grpc_exec_ctx* exec_ctx,
- void* arg /* fd_change_data */,
+static void first_read_callback(void* arg /* fd_change_data */,
grpc_error* error) {
fd_change_data* fdc = static_cast<fd_change_data*>(arg);
gpr_mu_lock(g_mu);
fdc->cb_that_ran = first_read_callback;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
-static void second_read_callback(grpc_exec_ctx* exec_ctx,
- void* arg /* fd_change_data */,
+static void second_read_callback(void* arg /* fd_change_data */,
grpc_error* error) {
fd_change_data* fdc = static_cast<fd_change_data*>(arg);
gpr_mu_lock(g_mu);
fdc->cb_that_ran = second_read_callback;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
@@ -443,7 +436,7 @@ static void test_grpc_fd_change(void) {
ssize_t result;
grpc_closure first_closure;
grpc_closure second_closure;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GRPC_CLOSURE_INIT(&first_closure, first_read_callback, &a,
grpc_schedule_on_exec_ctx);
@@ -460,10 +453,10 @@ static void test_grpc_fd_change(void) {
GPR_ASSERT(fcntl(sv[1], F_SETFL, flags | O_NONBLOCK) == 0);
em_fd = grpc_fd_create(sv[0], "test_grpc_fd_change");
- grpc_pollset_add_fd(&exec_ctx, g_pollset, em_fd);
+ grpc_pollset_add_fd(g_pollset, em_fd);
/* Register the first callback, then make its FD readable */
- grpc_fd_notify_on_read(&exec_ctx, em_fd, &first_closure);
+ grpc_fd_notify_on_read(em_fd, &first_closure);
data = 0;
result = write(sv[1], &data, 1);
GPR_ASSERT(result == 1);
@@ -473,10 +466,10 @@ static void test_grpc_fd_change(void) {
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)));
+ "pollset_work",
+ grpc_pollset_work(g_pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
GPR_ASSERT(a.cb_that_ran == first_read_callback);
@@ -488,7 +481,7 @@ static void test_grpc_fd_change(void) {
/* Now register a second callback with distinct change data, and do the same
thing again. */
- grpc_fd_notify_on_read(&exec_ctx, em_fd, &second_closure);
+ grpc_fd_notify_on_read(em_fd, &second_closure);
data = 0;
result = write(sv[1], &data, 1);
GPR_ASSERT(result == 1);
@@ -497,32 +490,30 @@ static void test_grpc_fd_change(void) {
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)));
+ "pollset_work",
+ grpc_pollset_work(g_pollset, &worker, GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
/* Except now we verify that second_read_callback ran instead */
GPR_ASSERT(b.cb_that_ran == second_read_callback);
gpr_mu_unlock(g_mu);
- grpc_fd_orphan(&exec_ctx, em_fd, nullptr, nullptr, false /* already_closed */,
- "d");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_fd_orphan(em_fd, nullptr, nullptr, false /* already_closed */, "d");
+
destroy_change_data(&a);
destroy_change_data(&b);
close(sv[1]);
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p));
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_test_init(argc, argv);
grpc_init();
g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
@@ -531,10 +522,10 @@ int main(int argc, char** argv) {
test_grpc_fd_change();
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(g_pollset);
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/pollset_set_test.cc b/test/core/iomgr/pollset_set_test.cc
index 719eab91fe..502b40f2cf 100644
--- a/test/core/iomgr/pollset_set_test.cc
+++ b/test/core/iomgr/pollset_set_test.cc
@@ -47,11 +47,10 @@ void init_test_pollset_sets(test_pollset_set* pollset_sets, const int num_pss) {
}
}
-void cleanup_test_pollset_sets(grpc_exec_ctx* exec_ctx,
- test_pollset_set* pollset_sets,
+void cleanup_test_pollset_sets(test_pollset_set* pollset_sets,
const int num_pss) {
for (int i = 0; i < num_pss; i++) {
- grpc_pollset_set_destroy(exec_ctx, pollset_sets[i].pss);
+ grpc_pollset_set_destroy(pollset_sets[i].pss);
pollset_sets[i].pss = nullptr;
}
}
@@ -73,21 +72,19 @@ static void init_test_pollsets(test_pollset* pollsets, const int num_pollsets) {
}
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p));
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
-static void cleanup_test_pollsets(grpc_exec_ctx* exec_ctx,
- test_pollset* pollsets,
+static void cleanup_test_pollsets(test_pollset* pollsets,
const int num_pollsets) {
grpc_closure destroyed;
for (int i = 0; i < num_pollsets; i++) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, pollsets[i].ps,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(exec_ctx, pollsets[i].ps, &destroyed);
+ grpc_pollset_shutdown(pollsets[i].ps, &destroyed);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(pollsets[i].ps);
pollsets[i].ps = nullptr;
}
@@ -105,45 +102,43 @@ typedef struct test_fd {
grpc_closure on_readable; /* Closure to call when this fd is readable */
} test_fd;
-void on_readable(grpc_exec_ctx* exec_ctx, void* tfd, grpc_error* error) {
+void on_readable(void* tfd, grpc_error* error) {
((test_fd*)tfd)->is_on_readable_called = true;
}
-static void reset_test_fd(grpc_exec_ctx* exec_ctx, test_fd* tfd) {
+static void reset_test_fd(test_fd* tfd) {
tfd->is_on_readable_called = false;
GRPC_CLOSURE_INIT(&tfd->on_readable, on_readable, tfd,
grpc_schedule_on_exec_ctx);
- grpc_fd_notify_on_read(exec_ctx, tfd->fd, &tfd->on_readable);
+ grpc_fd_notify_on_read(tfd->fd, &tfd->on_readable);
}
-static void init_test_fds(grpc_exec_ctx* exec_ctx, test_fd* tfds,
- const int num_fds) {
+static void init_test_fds(test_fd* tfds, const int num_fds) {
for (int i = 0; i < num_fds; i++) {
GPR_ASSERT(GRPC_ERROR_NONE == grpc_wakeup_fd_init(&tfds[i].wakeup_fd));
tfds[i].fd = grpc_fd_create(GRPC_WAKEUP_FD_GET_READ_FD(&tfds[i].wakeup_fd),
"test_fd");
- reset_test_fd(exec_ctx, &tfds[i]);
+ reset_test_fd(&tfds[i]);
}
}
-static void cleanup_test_fds(grpc_exec_ctx* exec_ctx, test_fd* tfds,
- const int num_fds) {
+static void cleanup_test_fds(test_fd* tfds, const int num_fds) {
int release_fd;
for (int i = 0; i < num_fds; i++) {
- grpc_fd_shutdown(exec_ctx, tfds[i].fd,
+ grpc_fd_shutdown(tfds[i].fd,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("fd cleanup"));
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
/* grpc_fd_orphan frees the memory allocated for grpc_fd. Normally it also
* calls close() on the underlying fd. In our case, we are using
* grpc_wakeup_fd and we would like to destroy it ourselves (by calling
* grpc_wakeup_fd_destroy). To prevent grpc_fd from calling close() on the
* underlying fd, call it with a non-NULL 'release_fd' parameter */
- grpc_fd_orphan(exec_ctx, tfds[i].fd, nullptr, &release_fd,
- false /* already_closed */, "test_fd_cleanup");
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_fd_orphan(tfds[i].fd, nullptr, &release_fd, false /* already_closed */,
+ "test_fd_cleanup");
+ grpc_core::ExecCtx::Get()->Flush();
grpc_wakeup_fd_destroy(&tfds[i].wakeup_fd);
}
@@ -155,8 +150,7 @@ static void make_test_fds_readable(test_fd* tfds, const int num_fds) {
}
}
-static void verify_readable_and_reset(grpc_exec_ctx* exec_ctx, test_fd* tfds,
- const int num_fds) {
+static void verify_readable_and_reset(test_fd* tfds, const int num_fds) {
for (int i = 0; i < num_fds; i++) {
/* Verify that the on_readable callback was called */
GPR_ASSERT(tfds[i].is_on_readable_called);
@@ -164,7 +158,7 @@ static void verify_readable_and_reset(grpc_exec_ctx* exec_ctx, test_fd* tfds,
/* Reset the tfd[i] structure */
GPR_ASSERT(GRPC_ERROR_NONE ==
grpc_wakeup_fd_consume_wakeup(&tfds[i].wakeup_fd));
- reset_test_fd(exec_ctx, &tfds[i]);
+ reset_test_fd(&tfds[i]);
}
}
@@ -205,7 +199,7 @@ static void pollset_set_test_basic() {
* |
* +---> FD9 (Added after PS2 is added to PSS0)
*/
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_pollset_worker* worker;
grpc_millis deadline;
@@ -216,34 +210,33 @@ static void pollset_set_test_basic() {
const int num_ps = GPR_ARRAY_SIZE(pollsets);
const int num_pss = GPR_ARRAY_SIZE(pollset_sets);
- init_test_fds(&exec_ctx, tfds, num_fds);
+ init_test_fds(tfds, num_fds);
init_test_pollsets(pollsets, num_ps);
init_test_pollset_sets(pollset_sets, num_pss);
/* Construct the pollset_set/pollset/fd tree (see diagram above) */
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd);
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd);
+ grpc_pollset_set_add_fd(pollset_sets[0].pss, tfds[0].fd);
+ grpc_pollset_set_add_fd(pollset_sets[1].pss, tfds[1].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[0].ps, tfds[2].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[3].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[2].ps, tfds[4].fd);
+ grpc_pollset_add_fd(pollsets[0].ps, tfds[2].fd);
+ grpc_pollset_add_fd(pollsets[1].ps, tfds[3].fd);
+ grpc_pollset_add_fd(pollsets[2].ps, tfds[4].fd);
- grpc_pollset_set_add_pollset_set(&exec_ctx, pollset_sets[0].pss,
- pollset_sets[1].pss);
+ grpc_pollset_set_add_pollset_set(pollset_sets[0].pss, pollset_sets[1].pss);
- grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[1].pss, pollsets[0].ps);
- grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[1].ps);
- grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[2].ps);
+ grpc_pollset_set_add_pollset(pollset_sets[1].pss, pollsets[0].ps);
+ grpc_pollset_set_add_pollset(pollset_sets[0].pss, pollsets[1].ps);
+ grpc_pollset_set_add_pollset(pollset_sets[0].pss, pollsets[2].ps);
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[0].pss, tfds[5].fd);
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[6].fd);
+ grpc_pollset_set_add_fd(pollset_sets[0].pss, tfds[5].fd);
+ grpc_pollset_set_add_fd(pollset_sets[1].pss, tfds[6].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[0].ps, tfds[7].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[8].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[2].ps, tfds[9].fd);
+ grpc_pollset_add_fd(pollsets[0].ps, tfds[7].fd);
+ grpc_pollset_add_fd(pollsets[1].ps, tfds[8].fd);
+ grpc_pollset_add_fd(pollsets[2].ps, tfds[9].fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
/* Test that if any FD in the above structure is readable, it is observable by
* doing grpc_pollset_work on any pollset
@@ -263,34 +256,32 @@ static void pollset_set_test_basic() {
deadline = grpc_timespec_to_millis_round_up(
grpc_timeout_milliseconds_to_deadline(2));
GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_pollset_work(&exec_ctx, pollsets[i].ps, &worker, deadline));
+ grpc_pollset_work(pollsets[i].ps, &worker, deadline));
gpr_mu_unlock(pollsets[i].mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
- verify_readable_and_reset(&exec_ctx, tfds, num_fds);
- grpc_exec_ctx_flush(&exec_ctx);
+ verify_readable_and_reset(tfds, num_fds);
+ grpc_core::ExecCtx::Get()->Flush();
}
/* Test tear down */
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd);
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[0].pss, tfds[5].fd);
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd);
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[6].fd);
- grpc_exec_ctx_flush(&exec_ctx);
-
- grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[1].pss, pollsets[0].ps);
- grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[1].ps);
- grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[0].pss, pollsets[2].ps);
-
- grpc_pollset_set_del_pollset_set(&exec_ctx, pollset_sets[0].pss,
- pollset_sets[1].pss);
- grpc_exec_ctx_flush(&exec_ctx);
-
- cleanup_test_fds(&exec_ctx, tfds, num_fds);
- cleanup_test_pollsets(&exec_ctx, pollsets, num_ps);
- cleanup_test_pollset_sets(&exec_ctx, pollset_sets, num_pss);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_set_del_fd(pollset_sets[0].pss, tfds[0].fd);
+ grpc_pollset_set_del_fd(pollset_sets[0].pss, tfds[5].fd);
+ grpc_pollset_set_del_fd(pollset_sets[1].pss, tfds[1].fd);
+ grpc_pollset_set_del_fd(pollset_sets[1].pss, tfds[6].fd);
+ grpc_core::ExecCtx::Get()->Flush();
+
+ grpc_pollset_set_del_pollset(pollset_sets[1].pss, pollsets[0].ps);
+ grpc_pollset_set_del_pollset(pollset_sets[0].pss, pollsets[1].ps);
+ grpc_pollset_set_del_pollset(pollset_sets[0].pss, pollsets[2].ps);
+
+ grpc_pollset_set_del_pollset_set(pollset_sets[0].pss, pollset_sets[1].pss);
+ grpc_core::ExecCtx::Get()->Flush();
+
+ cleanup_test_fds(tfds, num_fds);
+ cleanup_test_pollsets(pollsets, num_ps);
+ cleanup_test_pollset_sets(pollset_sets, num_pss);
}
/* Same FD added multiple times to the pollset_set tree */
@@ -310,7 +301,7 @@ void pollset_set_test_dup_fds() {
* | +--> FD2
* +---> FD1
*/
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_pollset_worker* worker;
grpc_millis deadline;
@@ -321,21 +312,20 @@ void pollset_set_test_dup_fds() {
const int num_ps = 1;
const int num_pss = GPR_ARRAY_SIZE(pollset_sets);
- init_test_fds(&exec_ctx, tfds, num_fds);
+ init_test_fds(tfds, num_fds);
init_test_pollsets(&pollset, num_ps);
init_test_pollset_sets(pollset_sets, num_pss);
/* Construct the structure */
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd);
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[0].fd);
- grpc_pollset_set_add_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd);
+ grpc_pollset_set_add_fd(pollset_sets[0].pss, tfds[0].fd);
+ grpc_pollset_set_add_fd(pollset_sets[1].pss, tfds[0].fd);
+ grpc_pollset_set_add_fd(pollset_sets[1].pss, tfds[1].fd);
- grpc_pollset_add_fd(&exec_ctx, pollset.ps, tfds[1].fd);
- grpc_pollset_add_fd(&exec_ctx, pollset.ps, tfds[2].fd);
+ grpc_pollset_add_fd(pollset.ps, tfds[1].fd);
+ grpc_pollset_add_fd(pollset.ps, tfds[2].fd);
- grpc_pollset_set_add_pollset(&exec_ctx, pollset_sets[1].pss, pollset.ps);
- grpc_pollset_set_add_pollset_set(&exec_ctx, pollset_sets[0].pss,
- pollset_sets[1].pss);
+ grpc_pollset_set_add_pollset(pollset_sets[1].pss, pollset.ps);
+ grpc_pollset_set_add_pollset_set(pollset_sets[0].pss, pollset_sets[1].pss);
/* Test. Make all FDs readable and make sure that can be observed by doing a
* grpc_pollset_work on the pollset 'PS' */
@@ -345,27 +335,25 @@ void pollset_set_test_dup_fds() {
deadline = grpc_timespec_to_millis_round_up(
grpc_timeout_milliseconds_to_deadline(2));
GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_pollset_work(&exec_ctx, pollset.ps, &worker, deadline));
+ grpc_pollset_work(pollset.ps, &worker, deadline));
gpr_mu_unlock(pollset.mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
- verify_readable_and_reset(&exec_ctx, tfds, num_fds);
- grpc_exec_ctx_flush(&exec_ctx);
+ verify_readable_and_reset(tfds, num_fds);
+ grpc_core::ExecCtx::Get()->Flush();
/* Tear down */
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[0].pss, tfds[0].fd);
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[0].fd);
- grpc_pollset_set_del_fd(&exec_ctx, pollset_sets[1].pss, tfds[1].fd);
-
- grpc_pollset_set_del_pollset(&exec_ctx, pollset_sets[1].pss, pollset.ps);
- grpc_pollset_set_del_pollset_set(&exec_ctx, pollset_sets[0].pss,
- pollset_sets[1].pss);
- grpc_exec_ctx_flush(&exec_ctx);
-
- cleanup_test_fds(&exec_ctx, tfds, num_fds);
- cleanup_test_pollsets(&exec_ctx, &pollset, num_ps);
- cleanup_test_pollset_sets(&exec_ctx, pollset_sets, num_pss);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_set_del_fd(pollset_sets[0].pss, tfds[0].fd);
+ grpc_pollset_set_del_fd(pollset_sets[1].pss, tfds[0].fd);
+ grpc_pollset_set_del_fd(pollset_sets[1].pss, tfds[1].fd);
+
+ grpc_pollset_set_del_pollset(pollset_sets[1].pss, pollset.ps);
+ grpc_pollset_set_del_pollset_set(pollset_sets[0].pss, pollset_sets[1].pss);
+ grpc_core::ExecCtx::Get()->Flush();
+
+ cleanup_test_fds(tfds, num_fds);
+ cleanup_test_pollsets(&pollset, num_ps);
+ cleanup_test_pollset_sets(pollset_sets, num_pss);
}
/* Pollset_set with an empty pollset */
@@ -383,7 +371,7 @@ void pollset_set_test_empty_pollset() {
* |
* +---> FD2
*/
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_pollset_worker* worker;
grpc_millis deadline;
@@ -394,17 +382,17 @@ void pollset_set_test_empty_pollset() {
const int num_ps = GPR_ARRAY_SIZE(pollsets);
const int num_pss = 1;
- init_test_fds(&exec_ctx, tfds, num_fds);
+ init_test_fds(tfds, num_fds);
init_test_pollsets(pollsets, num_ps);
init_test_pollset_sets(&pollset_set, num_pss);
/* Construct the structure */
- grpc_pollset_set_add_fd(&exec_ctx, pollset_set.pss, tfds[0].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[1].fd);
- grpc_pollset_add_fd(&exec_ctx, pollsets[1].ps, tfds[2].fd);
+ grpc_pollset_set_add_fd(pollset_set.pss, tfds[0].fd);
+ grpc_pollset_add_fd(pollsets[1].ps, tfds[1].fd);
+ grpc_pollset_add_fd(pollsets[1].ps, tfds[2].fd);
- grpc_pollset_set_add_pollset(&exec_ctx, pollset_set.pss, pollsets[0].ps);
- grpc_pollset_set_add_pollset(&exec_ctx, pollset_set.pss, pollsets[1].ps);
+ grpc_pollset_set_add_pollset(pollset_set.pss, pollsets[0].ps);
+ grpc_pollset_set_add_pollset(pollset_set.pss, pollsets[1].ps);
/* Test. Make all FDs readable and make sure that can be observed by doing
* grpc_pollset_work on the empty pollset 'PS0' */
@@ -414,27 +402,26 @@ void pollset_set_test_empty_pollset() {
deadline = grpc_timespec_to_millis_round_up(
grpc_timeout_milliseconds_to_deadline(2));
GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_pollset_work(&exec_ctx, pollsets[0].ps, &worker, deadline));
+ grpc_pollset_work(pollsets[0].ps, &worker, deadline));
gpr_mu_unlock(pollsets[0].mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
- verify_readable_and_reset(&exec_ctx, tfds, num_fds);
- grpc_exec_ctx_flush(&exec_ctx);
+ verify_readable_and_reset(tfds, num_fds);
+ grpc_core::ExecCtx::Get()->Flush();
/* Tear down */
- grpc_pollset_set_del_fd(&exec_ctx, pollset_set.pss, tfds[0].fd);
- grpc_pollset_set_del_pollset(&exec_ctx, pollset_set.pss, pollsets[0].ps);
- grpc_pollset_set_del_pollset(&exec_ctx, pollset_set.pss, pollsets[1].ps);
- grpc_exec_ctx_flush(&exec_ctx);
-
- cleanup_test_fds(&exec_ctx, tfds, num_fds);
- cleanup_test_pollsets(&exec_ctx, pollsets, num_ps);
- cleanup_test_pollset_sets(&exec_ctx, &pollset_set, num_pss);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_set_del_fd(pollset_set.pss, tfds[0].fd);
+ grpc_pollset_set_del_pollset(pollset_set.pss, pollsets[0].ps);
+ grpc_pollset_set_del_pollset(pollset_set.pss, pollsets[1].ps);
+ grpc_core::ExecCtx::Get()->Flush();
+
+ cleanup_test_fds(tfds, num_fds);
+ cleanup_test_pollsets(pollsets, num_ps);
+ cleanup_test_pollset_sets(&pollset_set, num_pss);
}
int main(int argc, char** argv) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_test_init(argc, argv);
grpc_init();
const char* poll_strategy = grpc_get_poll_strategy_name();
@@ -452,7 +439,6 @@ int main(int argc, char** argv) {
poll_strategy);
}
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/resolve_address_posix_test.cc b/test/core/iomgr/resolve_address_posix_test.cc
index 1a5eb9ace1..6fb6f72a00 100644
--- a/test/core/iomgr/resolve_address_posix_test.cc
+++ b/test/core/iomgr/resolve_address_posix_test.cc
@@ -46,29 +46,29 @@ typedef struct args_struct {
grpc_pollset_set* pollset_set;
} args_struct;
-static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
+static void do_nothing(void* arg, grpc_error* error) {}
-void args_init(grpc_exec_ctx* exec_ctx, args_struct* args) {
+void args_init(args_struct* args) {
gpr_event_init(&args->ev);
args->pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(args->pollset, &args->mu);
args->pollset_set = grpc_pollset_set_create();
- grpc_pollset_set_add_pollset(exec_ctx, args->pollset_set, args->pollset);
+ grpc_pollset_set_add_pollset(args->pollset_set, args->pollset);
args->addrs = nullptr;
}
-void args_finish(grpc_exec_ctx* exec_ctx, args_struct* args) {
+void args_finish(args_struct* args) {
GPR_ASSERT(gpr_event_wait(&args->ev, test_deadline()));
grpc_resolved_addresses_destroy(args->addrs);
- grpc_pollset_set_del_pollset(exec_ctx, args->pollset_set, args->pollset);
- grpc_pollset_set_destroy(exec_ctx, args->pollset_set);
+ grpc_pollset_set_del_pollset(args->pollset_set, args->pollset);
+ grpc_pollset_set_destroy(args->pollset_set);
grpc_closure do_nothing_cb;
GRPC_CLOSURE_INIT(&do_nothing_cb, do_nothing, nullptr,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(exec_ctx, args->pollset, &do_nothing_cb);
+ grpc_pollset_shutdown(args->pollset, &do_nothing_cb);
// exec_ctx needs to be flushed before calling grpc_pollset_destroy()
- grpc_exec_ctx_flush(exec_ctx);
- grpc_pollset_destroy(exec_ctx, args->pollset);
+ grpc_core::ExecCtx::Get()->Flush();
+ grpc_pollset_destroy(args->pollset);
gpr_free(args->pollset);
}
@@ -79,26 +79,24 @@ static grpc_millis n_sec_deadline(int seconds) {
static void actually_poll(void* argsp) {
args_struct* args = static_cast<args_struct*>(argsp);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_millis deadline = n_sec_deadline(10);
while (true) {
bool done = gpr_atm_acq_load(&args->done_atm) != 0;
if (done) {
break;
}
- grpc_millis time_left = deadline - grpc_exec_ctx_now(&exec_ctx);
+ grpc_millis time_left = deadline - grpc_core::ExecCtx::Get()->Now();
gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left);
GPR_ASSERT(time_left >= 0);
grpc_pollset_worker* worker = nullptr;
gpr_mu_lock(args->mu);
- GRPC_LOG_IF_ERROR("pollset_work",
- grpc_pollset_work(&exec_ctx, args->pollset, &worker,
- n_sec_deadline(1)));
+ GRPC_LOG_IF_ERROR("pollset_work", grpc_pollset_work(args->pollset, &worker,
+ n_sec_deadline(1)));
gpr_mu_unlock(args->mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
}
gpr_event_set(&args->ev, (void*)1);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void poll_pollset_until_request_done(args_struct* args) {
@@ -107,8 +105,7 @@ static void poll_pollset_until_request_done(args_struct* args) {
gpr_thd_new(&id, actually_poll, args, nullptr);
}
-static void must_succeed(grpc_exec_ctx* exec_ctx, void* argsp,
- grpc_error* err) {
+static void must_succeed(void* argsp, grpc_error* err) {
args_struct* args = static_cast<args_struct*>(argsp);
GPR_ASSERT(err == GRPC_ERROR_NONE);
GPR_ASSERT(args->addrs != nullptr);
@@ -116,29 +113,28 @@ static void must_succeed(grpc_exec_ctx* exec_ctx, void* argsp,
gpr_atm_rel_store(&args->done_atm, 1);
}
-static void must_fail(grpc_exec_ctx* exec_ctx, void* argsp, grpc_error* err) {
+static void must_fail(void* argsp, grpc_error* err) {
args_struct* args = static_cast<args_struct*>(argsp);
GPR_ASSERT(err != GRPC_ERROR_NONE);
gpr_atm_rel_store(&args->done_atm, 1);
}
static void test_unix_socket(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
poll_pollset_until_request_done(&args);
grpc_resolve_address(
- &exec_ctx, "unix:/path/name", nullptr, args.pollset_set,
+ "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);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
static void test_unix_socket_path_name_too_long(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
const char prefix[] = "unix:/path/name";
size_t path_name_length =
GPR_ARRAY_SIZE(((struct sockaddr_un*)nullptr)->sun_path) + 6;
@@ -150,22 +146,21 @@ static void test_unix_socket_path_name_too_long(void) {
poll_pollset_until_request_done(&args);
grpc_resolve_address(
- &exec_ctx, path_name, nullptr, args.pollset_set,
+ path_name, nullptr, args.pollset_set,
GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
gpr_free(path_name);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
test_unix_socket();
test_unix_socket_path_name_too_long();
- grpc_executor_shutdown(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_executor_shutdown();
+
grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/resolve_address_test.cc b/test/core/iomgr/resolve_address_test.cc
index 1c5aa38a95..e44d660dad 100644
--- a/test/core/iomgr/resolve_address_test.cc
+++ b/test/core/iomgr/resolve_address_test.cc
@@ -39,32 +39,32 @@ typedef struct args_struct {
grpc_pollset_set* pollset_set;
} args_struct;
-static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
+static void do_nothing(void* arg, grpc_error* error) {}
-void args_init(grpc_exec_ctx* exec_ctx, args_struct* args) {
+void args_init(args_struct* args) {
gpr_event_init(&args->ev);
args->pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(args->pollset, &args->mu);
args->pollset_set = grpc_pollset_set_create();
- grpc_pollset_set_add_pollset(exec_ctx, args->pollset_set, args->pollset);
+ grpc_pollset_set_add_pollset(args->pollset_set, args->pollset);
args->addrs = nullptr;
gpr_atm_rel_store(&args->done_atm, 0);
}
-void args_finish(grpc_exec_ctx* exec_ctx, args_struct* args) {
+void args_finish(args_struct* args) {
GPR_ASSERT(gpr_event_wait(&args->ev, test_deadline()));
grpc_resolved_addresses_destroy(args->addrs);
- grpc_pollset_set_del_pollset(exec_ctx, args->pollset_set, args->pollset);
- grpc_pollset_set_destroy(exec_ctx, args->pollset_set);
+ grpc_pollset_set_del_pollset(args->pollset_set, args->pollset);
+ grpc_pollset_set_destroy(args->pollset_set);
grpc_closure do_nothing_cb;
GRPC_CLOSURE_INIT(&do_nothing_cb, do_nothing, nullptr,
grpc_schedule_on_exec_ctx);
gpr_mu_lock(args->mu);
- grpc_pollset_shutdown(exec_ctx, args->pollset, &do_nothing_cb);
+ grpc_pollset_shutdown(args->pollset, &do_nothing_cb);
gpr_mu_unlock(args->mu);
// exec_ctx needs to be flushed before calling grpc_pollset_destroy()
- grpc_exec_ctx_flush(exec_ctx);
- grpc_pollset_destroy(exec_ctx, args->pollset);
+ grpc_core::ExecCtx::Get()->Flush();
+ grpc_pollset_destroy(args->pollset);
gpr_free(args->pollset);
}
@@ -74,119 +74,109 @@ static grpc_millis n_sec_deadline(int seconds) {
}
static void poll_pollset_until_request_done(args_struct* args) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_millis deadline = n_sec_deadline(10);
while (true) {
bool done = gpr_atm_acq_load(&args->done_atm) != 0;
if (done) {
break;
}
- grpc_millis time_left = deadline - grpc_exec_ctx_now(&exec_ctx);
+ grpc_millis time_left = deadline - grpc_core::ExecCtx::Get()->Now();
gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left);
GPR_ASSERT(time_left >= 0);
grpc_pollset_worker* worker = nullptr;
gpr_mu_lock(args->mu);
- GRPC_LOG_IF_ERROR("pollset_work",
- grpc_pollset_work(&exec_ctx, args->pollset, &worker,
- n_sec_deadline(1)));
+ GRPC_LOG_IF_ERROR("pollset_work", grpc_pollset_work(args->pollset, &worker,
+ n_sec_deadline(1)));
gpr_mu_unlock(args->mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
}
gpr_event_set(&args->ev, (void*)1);
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void must_succeed(grpc_exec_ctx* exec_ctx, void* argsp,
- grpc_error* err) {
+static void must_succeed(void* argsp, grpc_error* err) {
args_struct* args = static_cast<args_struct*>(argsp);
GPR_ASSERT(err == GRPC_ERROR_NONE);
GPR_ASSERT(args->addrs != nullptr);
GPR_ASSERT(args->addrs->naddrs > 0);
gpr_atm_rel_store(&args->done_atm, 1);
gpr_mu_lock(args->mu);
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, args->pollset, nullptr));
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, nullptr));
gpr_mu_unlock(args->mu);
}
-static void must_fail(grpc_exec_ctx* exec_ctx, void* argsp, grpc_error* err) {
+static void must_fail(void* argsp, grpc_error* err) {
args_struct* args = static_cast<args_struct*>(argsp);
GPR_ASSERT(err != GRPC_ERROR_NONE);
gpr_atm_rel_store(&args->done_atm, 1);
gpr_mu_lock(args->mu);
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, args->pollset, nullptr));
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, nullptr));
gpr_mu_unlock(args->mu);
}
static void test_localhost(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
grpc_resolve_address(
- &exec_ctx, "localhost:1", nullptr, args.pollset_set,
+ "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);
+ grpc_core::ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
static void test_default_port(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
grpc_resolve_address(
- &exec_ctx, "localhost", "1", args.pollset_set,
+ "localhost", "1", args.pollset_set,
GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
static void test_non_numeric_default_port(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
grpc_resolve_address(
- &exec_ctx, "localhost", "https", args.pollset_set,
+ "localhost", "https", args.pollset_set,
GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
static void test_missing_default_port(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
grpc_resolve_address(
- &exec_ctx, "localhost", nullptr, args.pollset_set,
+ "localhost", nullptr, args.pollset_set,
GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
static void test_ipv6_with_port(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
grpc_resolve_address(
- &exec_ctx, "[2001:db8::1]:1", nullptr, args.pollset_set,
+ "[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);
+ grpc_core::ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
static void test_ipv6_without_port(void) {
@@ -197,17 +187,16 @@ static void test_ipv6_without_port(void) {
};
unsigned i;
for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
grpc_resolve_address(
- &exec_ctx, kCases[i], "80", args.pollset_set,
+ kCases[i], "80", args.pollset_set,
GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
}
@@ -218,17 +207,16 @@ static void test_invalid_ip_addresses(void) {
};
unsigned i;
for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
grpc_resolve_address(
- &exec_ctx, kCases[i], nullptr, args.pollset_set,
+ 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);
+ grpc_core::ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
}
@@ -238,24 +226,23 @@ static void test_unparseable_hostports(void) {
};
unsigned i;
for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
args_struct args;
- args_init(&exec_ctx, &args);
+ args_init(&args);
grpc_resolve_address(
- &exec_ctx, kCases[i], "1", args.pollset_set,
+ kCases[i], "1", args.pollset_set,
GRPC_CLOSURE_CREATE(must_fail, &args, grpc_schedule_on_exec_ctx),
&args.addrs);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
poll_pollset_until_request_done(&args);
- args_finish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ args_finish(&args);
}
}
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
test_localhost();
test_default_port();
test_non_numeric_default_port();
@@ -264,8 +251,8 @@ int main(int argc, char** argv) {
test_ipv6_without_port();
test_invalid_ip_addresses();
test_unparseable_hostports();
- grpc_executor_shutdown(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_executor_shutdown();
+
grpc_shutdown();
return 0;
}
diff --git a/test/core/iomgr/resource_quota_test.cc b/test/core/iomgr/resource_quota_test.cc
index 6851702e67..b44e8ce1be 100644
--- a/test/core/iomgr/resource_quota_test.cc
+++ b/test/core/iomgr/resource_quota_test.cc
@@ -27,7 +27,7 @@
gpr_mu g_mu;
gpr_cv g_cv;
-static void inc_int_cb(grpc_exec_ctx* exec_ctx, void* a, grpc_error* error) {
+static void inc_int_cb(void* a, grpc_error* error) {
gpr_mu_lock(&g_mu);
++*(int*)a;
gpr_cv_signal(&g_cv);
@@ -43,7 +43,7 @@ static void assert_counter_becomes(int* ctr, int value) {
gpr_mu_unlock(&g_mu);
}
-static void set_event_cb(grpc_exec_ctx* exec_ctx, void* a, grpc_error* error) {
+static void set_event_cb(void* a, grpc_error* error) {
gpr_event_set((gpr_event*)a, (void*)1);
}
grpc_closure* set_event(gpr_event* ev) {
@@ -56,13 +56,12 @@ typedef struct {
grpc_closure* then;
} reclaimer_args;
-static void reclaimer_cb(grpc_exec_ctx* exec_ctx, void* args,
- grpc_error* error) {
+static void reclaimer_cb(void* args, grpc_error* error) {
GPR_ASSERT(error == GRPC_ERROR_NONE);
reclaimer_args* a = static_cast<reclaimer_args*>(args);
- grpc_resource_user_free(exec_ctx, a->resource_user, a->size);
- grpc_resource_user_finish_reclamation(exec_ctx, a->resource_user);
- GRPC_CLOSURE_RUN(exec_ctx, a->then, GRPC_ERROR_NONE);
+ grpc_resource_user_free(a->resource_user, a->size);
+ grpc_resource_user_finish_reclamation(a->resource_user);
+ GRPC_CLOSURE_RUN(a->then, GRPC_ERROR_NONE);
gpr_free(a);
}
@@ -75,10 +74,9 @@ grpc_closure* make_reclaimer(grpc_resource_user* resource_user, size_t size,
return GRPC_CLOSURE_CREATE(reclaimer_cb, a, grpc_schedule_on_exec_ctx);
}
-static void unused_reclaimer_cb(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void unused_reclaimer_cb(void* arg, grpc_error* error) {
GPR_ASSERT(error == GRPC_ERROR_CANCELLED);
- GRPC_CLOSURE_RUN(exec_ctx, static_cast<grpc_closure*>(arg), GRPC_ERROR_NONE);
+ GRPC_CLOSURE_RUN(static_cast<grpc_closure*>(arg), GRPC_ERROR_NONE);
}
grpc_closure* make_unused_reclaimer(grpc_closure* then) {
return GRPC_CLOSURE_CREATE(unused_reclaimer_cb, then,
@@ -86,9 +84,8 @@ grpc_closure* make_unused_reclaimer(grpc_closure* then) {
}
static void destroy_user(grpc_resource_user* usr) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_unref(&exec_ctx, usr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_unref(usr);
}
static void test_no_op(void) {
@@ -120,14 +117,12 @@ static void test_instant_alloc_then_free(void) {
grpc_resource_quota_resize(q, 1024 * 1024);
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, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, NULL);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -140,10 +135,9 @@ static void test_instant_alloc_free_pair(void) {
grpc_resource_quota_resize(q, 1024 * 1024);
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, nullptr);
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, NULL);
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -158,16 +152,15 @@ static void test_simple_async_alloc(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -182,9 +175,9 @@ static void test_async_alloc_blocked_by_size(void) {
gpr_event ev;
gpr_event_init(&ev);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(
&ev, grpc_timeout_milliseconds_to_deadline(100)) == nullptr);
}
@@ -193,9 +186,8 @@ static void test_async_alloc_blocked_by_size(void) {
nullptr);
;
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -210,32 +202,30 @@ static void test_scavenge(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr1, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr1, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr1, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr1, 1024);
}
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr2, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr2, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr2, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr2, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr1);
@@ -251,33 +241,32 @@ static void test_scavenge_blocked(void) {
gpr_event ev;
{
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr1, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr1, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
;
}
{
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr2, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr2, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(
&ev, grpc_timeout_milliseconds_to_deadline(100)) == nullptr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr1, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr1, 1024);
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr2, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr2, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr1);
@@ -293,9 +282,9 @@ static void test_blocked_until_scheduled_reclaim(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
;
@@ -303,18 +292,16 @@ static void test_blocked_until_scheduled_reclaim(void) {
gpr_event reclaim_done;
gpr_event_init(&reclaim_done);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, false,
- make_reclaimer(usr, 1024, set_event(&reclaim_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, false, make_reclaimer(usr, 1024, set_event(&reclaim_done)));
}
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&reclaim_done,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
@@ -322,9 +309,8 @@ static void test_blocked_until_scheduled_reclaim(void) {
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -340,9 +326,9 @@ static void test_blocked_until_scheduled_reclaim_and_scavenge(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr1, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr1, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
;
@@ -350,18 +336,16 @@ static void test_blocked_until_scheduled_reclaim_and_scavenge(void) {
gpr_event reclaim_done;
gpr_event_init(&reclaim_done);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr1, false,
- make_reclaimer(usr1, 1024, set_event(&reclaim_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr1, false, make_reclaimer(usr1, 1024, set_event(&reclaim_done)));
}
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr2, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr2, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&reclaim_done,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
@@ -369,9 +353,8 @@ static void test_blocked_until_scheduled_reclaim_and_scavenge(void) {
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr2, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr2, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr1);
@@ -387,9 +370,9 @@ static void test_blocked_until_scheduled_destructive_reclaim(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
;
@@ -397,18 +380,16 @@ static void test_blocked_until_scheduled_destructive_reclaim(void) {
gpr_event reclaim_done;
gpr_event_init(&reclaim_done);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, true,
- make_reclaimer(usr, 1024, set_event(&reclaim_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, true, make_reclaimer(usr, 1024, set_event(&reclaim_done)));
}
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&reclaim_done,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
@@ -416,9 +397,8 @@ static void test_blocked_until_scheduled_destructive_reclaim(void) {
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -435,13 +415,12 @@ static void test_unused_reclaim_is_cancelled(void) {
gpr_event destructive_done;
gpr_event_init(&destructive_done);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, false, make_unused_reclaimer(set_event(&benign_done)));
+ usr, false, make_unused_reclaimer(set_event(&benign_done)));
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, true,
- make_unused_reclaimer(set_event(&destructive_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, true, make_unused_reclaimer(set_event(&destructive_done)));
+
GPR_ASSERT(gpr_event_wait(&benign_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
nullptr);
@@ -470,22 +449,20 @@ static void test_benign_reclaim_is_preferred(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, false,
- make_reclaimer(usr, 1024, set_event(&benign_done)));
+ usr, false, make_reclaimer(usr, 1024, set_event(&benign_done)));
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, true,
- make_unused_reclaimer(set_event(&destructive_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, true, make_unused_reclaimer(set_event(&destructive_done)));
+
GPR_ASSERT(gpr_event_wait(&benign_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
nullptr);
@@ -496,9 +473,9 @@ static void test_benign_reclaim_is_preferred(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&benign_done,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&destructive_done,
@@ -508,9 +485,8 @@ static void test_benign_reclaim_is_preferred(void) {
nullptr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -533,22 +509,20 @@ static void test_multiple_reclaims_can_be_triggered(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&ev, grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, false,
- make_reclaimer(usr, 512, set_event(&benign_done)));
+ usr, false, make_reclaimer(usr, 512, set_event(&benign_done)));
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, true,
- make_reclaimer(usr, 512, set_event(&destructive_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, true, make_reclaimer(usr, 512, set_event(&destructive_done)));
+
GPR_ASSERT(gpr_event_wait(&benign_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
nullptr);
@@ -559,9 +533,9 @@ static void test_multiple_reclaims_can_be_triggered(void) {
{
gpr_event ev;
gpr_event_init(&ev);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&ev));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&ev));
+
GPR_ASSERT(gpr_event_wait(&benign_done,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
GPR_ASSERT(gpr_event_wait(&destructive_done,
@@ -571,9 +545,8 @@ static void test_multiple_reclaims_can_be_triggered(void) {
;
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
grpc_resource_quota_unref(q);
destroy_user(usr);
@@ -591,20 +564,17 @@ static void test_resource_user_stays_allocated_until_memory_released(void) {
grpc_resource_quota_resize(q, 1024 * 1024);
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, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, NULL);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_quota_unref(q);
- grpc_resource_user_unref(&exec_ctx, usr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_resource_user_unref(usr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
}
@@ -624,11 +594,10 @@ test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released(
gpr_event reclaimer_cancelled;
gpr_event_init(&reclaimer_cancelled);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, false,
- make_unused_reclaimer(set_event(&reclaimer_cancelled)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, false, make_unused_reclaimer(set_event(&reclaimer_cancelled)));
+
GPR_ASSERT(gpr_event_wait(&reclaimer_cancelled,
grpc_timeout_milliseconds_to_deadline(100)) ==
nullptr);
@@ -636,27 +605,27 @@ test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released(
{
gpr_event allocated;
gpr_event_init(&allocated);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&allocated));
- grpc_exec_ctx_finish(&exec_ctx);
- GPR_ASSERT(gpr_event_wait(&allocated, grpc_timeout_seconds_to_deadline(
- 5)) != nullptr);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&allocated));
+
+ GPR_ASSERT(gpr_event_wait(&allocated,
+ grpc_timeout_seconds_to_deadline(5)) != NULL);
GPR_ASSERT(gpr_event_wait(&reclaimer_cancelled,
grpc_timeout_milliseconds_to_deadline(100)) ==
nullptr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_unref(&exec_ctx, usr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_unref(usr);
+
GPR_ASSERT(gpr_event_wait(&reclaimer_cancelled,
grpc_timeout_milliseconds_to_deadline(100)) ==
nullptr);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
+
GPR_ASSERT(gpr_event_wait(&reclaimer_cancelled,
grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
@@ -674,9 +643,9 @@ static void test_reclaimers_can_be_posted_repeatedly(void) {
{
gpr_event allocated;
gpr_event_init(&allocated);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&allocated));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&allocated));
+
GPR_ASSERT(gpr_event_wait(&allocated,
grpc_timeout_seconds_to_deadline(5)) != nullptr);
}
@@ -684,11 +653,10 @@ static void test_reclaimers_can_be_posted_repeatedly(void) {
gpr_event reclaimer_done;
gpr_event_init(&reclaimer_done);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_user_post_reclaimer(
- &exec_ctx, usr, false,
- make_reclaimer(usr, 1024, set_event(&reclaimer_done)));
- grpc_exec_ctx_finish(&exec_ctx);
+ usr, false, make_reclaimer(usr, 1024, set_event(&reclaimer_done)));
+
GPR_ASSERT(gpr_event_wait(&reclaimer_done,
grpc_timeout_milliseconds_to_deadline(100)) ==
nullptr);
@@ -696,20 +664,19 @@ static void test_reclaimers_can_be_posted_repeatedly(void) {
{
gpr_event allocated;
gpr_event_init(&allocated);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc(&exec_ctx, usr, 1024, set_event(&allocated));
- grpc_exec_ctx_finish(&exec_ctx);
- GPR_ASSERT(gpr_event_wait(&allocated, grpc_timeout_seconds_to_deadline(
- 5)) != nullptr);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc(usr, 1024, set_event(&allocated));
+
+ GPR_ASSERT(gpr_event_wait(&allocated,
+ grpc_timeout_seconds_to_deadline(5)) != NULL);
GPR_ASSERT(gpr_event_wait(&reclaimer_done,
grpc_timeout_seconds_to_deadline(5)) !=
nullptr);
}
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_free(&exec_ctx, usr, 1024);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_free(usr, 1024);
}
destroy_user(usr);
grpc_resource_quota_unref(q);
@@ -732,16 +699,15 @@ static void test_one_slice(void) {
{
const int start_allocs = num_allocs;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc_slices(&exec_ctx, &alloc, 1024, 1, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc_slices(&alloc, 1024, 1, &buffer);
+
assert_counter_becomes(&num_allocs, start_allocs + 1);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_slice_buffer_destroy_internal(&buffer);
}
destroy_user(usr);
grpc_resource_quota_unref(q);
@@ -765,23 +731,21 @@ static void test_one_slice_deleted_late(void) {
{
const int start_allocs = num_allocs;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc_slices(&exec_ctx, &alloc, 1024, 1, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc_slices(&alloc, 1024, 1, &buffer);
+
assert_counter_becomes(&num_allocs, start_allocs + 1);
}
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_unref(&exec_ctx, usr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_unref(usr);
}
grpc_resource_quota_unref(q);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_slice_buffer_destroy_internal(&buffer);
}
}
@@ -809,9 +773,9 @@ static void test_negative_rq_free_pool(void) {
{
const int start_allocs = num_allocs;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_alloc_slices(&exec_ctx, &alloc, 1024, 1, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_alloc_slices(&alloc, 1024, 1, &buffer);
+
assert_counter_becomes(&num_allocs, start_allocs + 1);
}
@@ -822,16 +786,14 @@ static void test_negative_rq_free_pool(void) {
GPR_ASSERT(grpc_resource_quota_get_memory_pressure(q) > 1 - eps);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_user_unref(&exec_ctx, usr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resource_user_unref(usr);
}
grpc_resource_quota_unref(q);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_slice_buffer_destroy_internal(&buffer);
}
}
diff --git a/test/core/iomgr/tcp_client_posix_test.cc b/test/core/iomgr/tcp_client_posix_test.cc
index 9fb1a2d770..12295ef180 100644
--- a/test/core/iomgr/tcp_client_posix_test.cc
+++ b/test/core/iomgr/tcp_client_posix_test.cc
@@ -53,26 +53,24 @@ static grpc_millis test_deadline(void) {
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, nullptr)));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
+
gpr_mu_unlock(g_mu);
}
-static void must_succeed(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void must_succeed(void* arg, grpc_error* error) {
GPR_ASSERT(g_connecting != nullptr);
GPR_ASSERT(error == GRPC_ERROR_NONE);
- grpc_endpoint_shutdown(
- exec_ctx, g_connecting,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("must_succeed called"));
- grpc_endpoint_destroy(exec_ctx, g_connecting);
+ grpc_endpoint_shutdown(g_connecting, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "must_succeed called"));
+ grpc_endpoint_destroy(g_connecting);
g_connecting = nullptr;
finish_connection();
}
-static void must_fail(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void must_fail(void* arg, grpc_error* error) {
GPR_ASSERT(g_connecting == nullptr);
GPR_ASSERT(error != GRPC_ERROR_NONE);
finish_connection();
@@ -85,7 +83,7 @@ void test_succeeds(void) {
int r;
int connections_complete_before;
grpc_closure done;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_DEBUG, "test_succeeds");
@@ -108,8 +106,8 @@ void test_succeeds(void) {
GPR_ASSERT(getsockname(svr_fd, (struct sockaddr*)addr,
(socklen_t*)&resolved_addr.len) == 0);
GRPC_CLOSURE_INIT(&done, must_succeed, nullptr, grpc_schedule_on_exec_ctx);
- grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, g_pollset_set,
- nullptr, &resolved_addr, GRPC_MILLIS_INF_FUTURE);
+ grpc_tcp_client_connect(&done, &g_connecting, g_pollset_set, nullptr,
+ &resolved_addr, GRPC_MILLIS_INF_FUTURE);
/* await the connection */
do {
@@ -125,17 +123,15 @@ void test_succeeds(void) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
+ grpc_pollset_work(g_pollset, &worker,
grpc_timespec_to_millis_round_up(
grpc_timeout_seconds_to_deadline(5)))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
-
- grpc_exec_ctx_finish(&exec_ctx);
}
void test_fails(void) {
@@ -143,7 +139,7 @@ void test_fails(void) {
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
int connections_complete_before;
grpc_closure done;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_DEBUG, "test_fails");
@@ -157,8 +153,8 @@ void test_fails(void) {
/* connect to a broken address */
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);
+ grpc_tcp_client_connect(&done, &g_connecting, g_pollset_set, nullptr,
+ &resolved_addr, GRPC_MILLIS_INF_FUTURE);
gpr_mu_lock(g_mu);
@@ -166,7 +162,7 @@ void test_fails(void) {
while (g_connections_complete == connections_complete_before) {
grpc_pollset_worker* worker = nullptr;
grpc_millis polling_deadline = test_deadline();
- switch (grpc_timer_check(&exec_ctx, &polling_deadline)) {
+ switch (grpc_timer_check(&polling_deadline)) {
case GRPC_TIMERS_FIRED:
break;
case GRPC_TIMERS_NOT_CHECKED:
@@ -174,42 +170,40 @@ void test_fails(void) {
/* fall through */
case GRPC_TIMERS_CHECKED_AND_EMPTY:
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- polling_deadline)));
+ "pollset_work",
+ grpc_pollset_work(g_pollset, &worker, polling_deadline)));
break;
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p));
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_test_init(argc, argv);
grpc_init();
g_pollset_set = grpc_pollset_set_create();
g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(g_pollset, &g_mu);
- grpc_pollset_set_add_pollset(&exec_ctx, g_pollset_set, g_pollset);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_set_add_pollset(g_pollset_set, g_pollset);
+
test_succeeds();
gpr_log(GPR_ERROR, "End of first test");
test_fails();
- grpc_pollset_set_destroy(&exec_ctx, g_pollset_set);
+ grpc_pollset_set_destroy(g_pollset_set);
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+
grpc_shutdown();
gpr_free(g_pollset);
return 0;
diff --git a/test/core/iomgr/tcp_client_uv_test.cc b/test/core/iomgr/tcp_client_uv_test.cc
index 101d7bf6b5..344478ea97 100644
--- a/test/core/iomgr/tcp_client_uv_test.cc
+++ b/test/core/iomgr/tcp_client_uv_test.cc
@@ -46,30 +46,28 @@ static grpc_millis test_deadline(void) {
return grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10));
}
-static void finish_connection(grpc_exec_ctx* exec_ctx) {
+static void finish_connection() {
gpr_mu_lock(g_mu);
g_connections_complete++;
- GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, NULL)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, NULL)));
gpr_mu_unlock(g_mu);
}
-static void must_succeed(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void must_succeed(void* arg, grpc_error* error) {
GPR_ASSERT(g_connecting != NULL);
GPR_ASSERT(error == GRPC_ERROR_NONE);
- grpc_endpoint_shutdown(
- exec_ctx, g_connecting,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("must_succeed called"));
- grpc_endpoint_destroy(exec_ctx, g_connecting);
+ grpc_endpoint_shutdown(g_connecting, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "must_succeed called"));
+ grpc_endpoint_destroy(g_connecting);
g_connecting = NULL;
- finish_connection(exec_ctx);
+ finish_connection();
}
-static void must_fail(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void must_fail(void* arg, grpc_error* error) {
GPR_ASSERT(g_connecting == NULL);
GPR_ASSERT(error != GRPC_ERROR_NONE);
- finish_connection(exec_ctx);
+ finish_connection();
}
static void close_cb(uv_handle_t* handle) { gpr_free(handle); }
@@ -89,7 +87,7 @@ void test_succeeds(void) {
uv_tcp_t* svr_handle = static_cast<uv_tcp_t*>(gpr_malloc(sizeof(uv_tcp_t)));
int connections_complete_before;
grpc_closure done;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_DEBUG, "test_succeeds");
@@ -110,8 +108,8 @@ void test_succeeds(void) {
GPR_ASSERT(uv_tcp_getsockname(svr_handle, (struct sockaddr*)addr,
(int*)&resolved_addr.len) == 0);
GRPC_CLOSURE_INIT(&done, must_succeed, NULL, grpc_schedule_on_exec_ctx);
- grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, NULL, NULL,
- &resolved_addr, GRPC_MILLIS_INF_FUTURE);
+ grpc_tcp_client_connect(&done, &g_connecting, NULL, NULL, &resolved_addr,
+ GRPC_MILLIS_INF_FUTURE);
gpr_mu_lock(g_mu);
@@ -119,11 +117,11 @@ void test_succeeds(void) {
grpc_pollset_worker* worker = NULL;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
+ grpc_pollset_work(g_pollset, &worker,
grpc_timespec_to_millis_round_up(
grpc_timeout_seconds_to_deadline(5)))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
@@ -131,8 +129,6 @@ void test_succeeds(void) {
uv_close((uv_handle_t*)svr_handle, close_cb);
gpr_mu_unlock(g_mu);
-
- grpc_exec_ctx_finish(&exec_ctx);
}
void test_fails(void) {
@@ -140,7 +136,7 @@ void test_fails(void) {
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
int connections_complete_before;
grpc_closure done;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_DEBUG, "test_fails");
@@ -154,8 +150,8 @@ void test_fails(void) {
/* connect to a broken address */
GRPC_CLOSURE_INIT(&done, must_fail, NULL, grpc_schedule_on_exec_ctx);
- grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, NULL, NULL,
- &resolved_addr, GRPC_MILLIS_INF_FUTURE);
+ grpc_tcp_client_connect(&done, &g_connecting, NULL, NULL, &resolved_addr,
+ GRPC_MILLIS_INF_FUTURE);
gpr_mu_lock(g_mu);
@@ -164,7 +160,7 @@ void test_fails(void) {
grpc_pollset_worker* worker = NULL;
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
grpc_millis polling_deadline = test_deadline();
- switch (grpc_timer_check(&exec_ctx, &polling_deadline)) {
+ switch (grpc_timer_check(&polling_deadline)) {
case GRPC_TIMERS_FIRED:
break;
case GRPC_TIMERS_NOT_CHECKED:
@@ -172,39 +168,37 @@ void test_fails(void) {
/* fall through */
case GRPC_TIMERS_CHECKED_AND_EMPTY:
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
- polling_deadline)));
+ "pollset_work",
+ grpc_pollset_work(g_pollset, &worker, polling_deadline)));
break;
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p));
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_test_init(argc, argv);
grpc_init();
g_pollset = static_cast<grpc_pollset*>(gpr_malloc(grpc_pollset_size()));
grpc_pollset_init(g_pollset, &g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
test_succeeds();
gpr_log(GPR_ERROR, "End of first test");
test_fails();
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+
grpc_shutdown();
gpr_free(g_pollset);
return 0;
diff --git a/test/core/iomgr/tcp_posix_test.cc b/test/core/iomgr/tcp_posix_test.cc
index 7986dc2b19..4018fe50bd 100644
--- a/test/core/iomgr/tcp_posix_test.cc
+++ b/test/core/iomgr/tcp_posix_test.cc
@@ -131,8 +131,7 @@ static size_t count_slices(grpc_slice* slices, size_t nslices,
return num_bytes;
}
-static void read_cb(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_error* error) {
+static void read_cb(void* user_data, grpc_error* error) {
struct read_socket_state* state = (struct read_socket_state*)user_data;
size_t read_bytes;
int current_data;
@@ -147,11 +146,11 @@ static void read_cb(grpc_exec_ctx* exec_ctx, void* user_data,
gpr_log(GPR_INFO, "Read %" PRIuPTR " bytes of %" PRIuPTR, read_bytes,
state->target_read_bytes);
if (state->read_bytes >= state->target_read_bytes) {
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
} else {
- grpc_endpoint_read(exec_ctx, state->ep, &state->incoming, &state->read_cb);
+ grpc_endpoint_read(state->ep, &state->incoming, &state->read_cb);
gpr_mu_unlock(g_mu);
}
}
@@ -164,7 +163,7 @@ static void read_test(size_t num_bytes, size_t slice_size) {
size_t written_bytes;
grpc_millis deadline =
grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_INFO, "Read test of size %" PRIuPTR ", slice size %" PRIuPTR,
num_bytes, slice_size);
@@ -175,9 +174,8 @@ static void read_test(size_t num_bytes, size_t slice_size) {
a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE);
a[0].type = GRPC_ARG_INTEGER, a[0].value.integer = (int)slice_size;
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
- ep = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], "read_test"), &args,
- "test");
- grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
+ ep = grpc_tcp_create(grpc_fd_create(sv[1], "read_test"), &args, "test");
+ grpc_endpoint_add_to_pollset(ep, g_pollset);
written_bytes = fill_socket_partial(sv[0], num_bytes);
gpr_log(GPR_INFO, "Wrote %" PRIuPTR " bytes", written_bytes);
@@ -188,24 +186,22 @@ static void read_test(size_t num_bytes, size_t slice_size) {
grpc_slice_buffer_init(&state.incoming);
GRPC_CLOSURE_INIT(&state.read_cb, read_cb, &state, grpc_schedule_on_exec_ctx);
- grpc_endpoint_read(&exec_ctx, ep, &state.incoming, &state.read_cb);
+ grpc_endpoint_read(ep, &state.incoming, &state.read_cb);
gpr_mu_lock(g_mu);
while (state.read_bytes < state.target_read_bytes) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
GPR_ASSERT(state.read_bytes == state.target_read_bytes);
gpr_mu_unlock(g_mu);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &state.incoming);
- grpc_endpoint_destroy(&exec_ctx, ep);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_buffer_destroy_internal(&state.incoming);
+ grpc_endpoint_destroy(ep);
}
/* Write to a socket until it fills up, then read from it using the grpc_tcp
@@ -217,7 +213,7 @@ static void large_read_test(size_t slice_size) {
ssize_t written_bytes;
grpc_millis deadline =
grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_INFO, "Start large read test, slice size %" PRIuPTR, slice_size);
@@ -228,9 +224,8 @@ static void large_read_test(size_t slice_size) {
a[0].type = GRPC_ARG_INTEGER;
a[0].value.integer = (int)slice_size;
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
- ep = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], "large_read_test"),
- &args, "test");
- grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
+ ep = grpc_tcp_create(grpc_fd_create(sv[1], "large_read_test"), &args, "test");
+ grpc_endpoint_add_to_pollset(ep, g_pollset);
written_bytes = fill_socket(sv[0]);
gpr_log(GPR_INFO, "Wrote %" PRIuPTR " bytes", written_bytes);
@@ -241,24 +236,22 @@ static void large_read_test(size_t slice_size) {
grpc_slice_buffer_init(&state.incoming);
GRPC_CLOSURE_INIT(&state.read_cb, read_cb, &state, grpc_schedule_on_exec_ctx);
- grpc_endpoint_read(&exec_ctx, ep, &state.incoming, &state.read_cb);
+ grpc_endpoint_read(ep, &state.incoming, &state.read_cb);
gpr_mu_lock(g_mu);
while (state.read_bytes < state.target_read_bytes) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
GPR_ASSERT(state.read_bytes == state.target_read_bytes);
gpr_mu_unlock(g_mu);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &state.incoming);
- grpc_endpoint_destroy(&exec_ctx, ep);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_buffer_destroy_internal(&state.incoming);
+ grpc_endpoint_destroy(ep);
}
struct write_socket_state {
@@ -289,16 +282,15 @@ static grpc_slice* allocate_blocks(size_t num_bytes, size_t slice_size,
return slices;
}
-static void write_done(grpc_exec_ctx* exec_ctx,
- void* user_data /* write_socket_state */,
+static void write_done(void* user_data /* write_socket_state */,
grpc_error* error) {
struct write_socket_state* state = (struct write_socket_state*)user_data;
gpr_log(GPR_INFO, "Write done callback called");
gpr_mu_lock(g_mu);
gpr_log(GPR_INFO, "Signalling write done");
state->write_done = 1;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
@@ -309,7 +301,7 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) {
int flags;
int current = 0;
int i;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
flags = fcntl(fd, F_GETFL, 0);
GPR_ASSERT(fcntl(fd, F_SETFL, flags & ~O_NONBLOCK) == 0);
@@ -319,11 +311,11 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) {
gpr_mu_lock(g_mu);
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker,
+ grpc_pollset_work(g_pollset, &worker,
grpc_timespec_to_millis_round_up(
grpc_timeout_milliseconds_to_deadline(10)))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
do {
bytes_read =
read(fd, buf, bytes_left > read_size ? read_size : bytes_left);
@@ -356,7 +348,7 @@ static void write_test(size_t num_bytes, size_t slice_size) {
grpc_closure write_done_closure;
grpc_millis deadline =
grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_INFO,
"Start write test with %" PRIuPTR " bytes, slice size %" PRIuPTR,
@@ -368,9 +360,8 @@ static void write_test(size_t num_bytes, size_t slice_size) {
a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE);
a[0].type = GRPC_ARG_INTEGER, a[0].value.integer = (int)slice_size;
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
- ep = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], "write_test"), &args,
- "test");
- grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
+ ep = grpc_tcp_create(grpc_fd_create(sv[1], "write_test"), &args, "test");
+ grpc_endpoint_add_to_pollset(ep, g_pollset);
state.ep = ep;
state.write_done = 0;
@@ -382,7 +373,7 @@ static void write_test(size_t num_bytes, size_t slice_size) {
GRPC_CLOSURE_INIT(&write_done_closure, write_done, &state,
grpc_schedule_on_exec_ctx);
- grpc_endpoint_write(&exec_ctx, ep, &outgoing, &write_done_closure);
+ grpc_endpoint_write(ep, &outgoing, &write_done_closure);
drain_socket_blocking(sv[0], num_bytes, num_bytes);
gpr_mu_lock(g_mu);
for (;;) {
@@ -391,25 +382,23 @@ static void write_test(size_t num_bytes, size_t slice_size) {
break;
}
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_mu_unlock(g_mu);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &outgoing);
- grpc_endpoint_destroy(&exec_ctx, ep);
+ grpc_slice_buffer_destroy_internal(&outgoing);
+ grpc_endpoint_destroy(ep);
gpr_free(slices);
- grpc_exec_ctx_finish(&exec_ctx);
}
-void on_fd_released(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* errors) {
+void on_fd_released(void* arg, grpc_error* errors) {
int* done = (int*)arg;
*done = 1;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
}
/* Do a read_test, then release fd and try to read/write again. Verify that
@@ -422,7 +411,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
int fd;
grpc_millis deadline =
grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_closure fd_released_cb;
int fd_released_done = 0;
GRPC_CLOSURE_INIT(&fd_released_cb, &on_fd_released, &fd_released_done,
@@ -439,10 +428,9 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
a[0].type = GRPC_ARG_INTEGER;
a[0].value.integer = (int)slice_size;
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
- ep = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], "read_test"), &args,
- "test");
+ ep = grpc_tcp_create(grpc_fd_create(sv[1], "read_test"), &args, "test");
GPR_ASSERT(grpc_tcp_fd(ep) == sv[1] && sv[1] >= 0);
- grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset);
+ grpc_endpoint_add_to_pollset(ep, g_pollset);
written_bytes = fill_socket_partial(sv[0], num_bytes);
gpr_log(GPR_INFO, "Wrote %" PRIuPTR " bytes", written_bytes);
@@ -453,38 +441,35 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
grpc_slice_buffer_init(&state.incoming);
GRPC_CLOSURE_INIT(&state.read_cb, read_cb, &state, grpc_schedule_on_exec_ctx);
- grpc_endpoint_read(&exec_ctx, ep, &state.incoming, &state.read_cb);
+ grpc_endpoint_read(ep, &state.incoming, &state.read_cb);
gpr_mu_lock(g_mu);
while (state.read_bytes < state.target_read_bytes) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_log(GPR_DEBUG, "wakeup: read=%" PRIdPTR " target=%" PRIdPTR,
state.read_bytes, state.target_read_bytes);
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
GPR_ASSERT(state.read_bytes == state.target_read_bytes);
gpr_mu_unlock(g_mu);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &state.incoming);
- grpc_tcp_destroy_and_release_fd(&exec_ctx, ep, &fd, &fd_released_cb);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_slice_buffer_destroy_internal(&state.incoming);
+ grpc_tcp_destroy_and_release_fd(ep, &fd, &fd_released_cb);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
while (!fd_released_done) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_log(GPR_DEBUG, "wakeup: fd_released_done=%d", fd_released_done);
}
gpr_mu_unlock(g_mu);
GPR_ASSERT(fd_released_done == 1);
GPR_ASSERT(fd == sv[1]);
- grpc_exec_ctx_finish(&exec_ctx);
written_bytes = fill_socket_partial(sv[0], num_bytes);
drain_socket_blocking(fd, written_bytes, written_bytes);
@@ -522,7 +507,7 @@ static grpc_endpoint_test_fixture create_fixture_tcp_socketpair(
size_t slice_size) {
int sv[2];
grpc_endpoint_test_fixture f;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
create_sockets(sv);
grpc_resource_quota* resource_quota =
@@ -532,15 +517,13 @@ static grpc_endpoint_test_fixture create_fixture_tcp_socketpair(
a[0].type = GRPC_ARG_INTEGER;
a[0].value.integer = (int)slice_size;
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
- f.client_ep = grpc_tcp_create(
- &exec_ctx, grpc_fd_create(sv[0], "fixture:client"), &args, "test");
- f.server_ep = grpc_tcp_create(
- &exec_ctx, grpc_fd_create(sv[1], "fixture:server"), &args, "test");
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
- grpc_endpoint_add_to_pollset(&exec_ctx, f.client_ep, g_pollset);
- grpc_endpoint_add_to_pollset(&exec_ctx, f.server_ep, g_pollset);
-
- grpc_exec_ctx_finish(&exec_ctx);
+ f.client_ep =
+ grpc_tcp_create(grpc_fd_create(sv[0], "fixture:client"), &args, "test");
+ f.server_ep =
+ grpc_tcp_create(grpc_fd_create(sv[1], "fixture:server"), &args, "test");
+ grpc_resource_quota_unref_internal(resource_quota);
+ grpc_endpoint_add_to_pollset(f.client_ep, g_pollset);
+ grpc_endpoint_add_to_pollset(f.server_ep, g_pollset);
return f;
}
@@ -549,14 +532,13 @@ static grpc_endpoint_test_config configs[] = {
{"tcp/tcp_socketpair", create_fixture_tcp_socketpair, clean_up},
};
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, (grpc_pollset*)p);
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy((grpc_pollset*)p);
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_test_init(argc, argv);
grpc_init();
g_pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
@@ -565,8 +547,8 @@ int main(int argc, char** argv) {
run_tests();
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+
grpc_shutdown();
gpr_free(g_pollset);
diff --git a/test/core/iomgr/tcp_server_posix_test.cc b/test/core/iomgr/tcp_server_posix_test.cc
index 48d8d425a5..ba9fe92c9c 100644
--- a/test/core/iomgr/tcp_server_posix_test.cc
+++ b/test/core/iomgr/tcp_server_posix_test.cc
@@ -110,8 +110,7 @@ static void on_connect_result_set(on_connect_result* result,
result->server, acceptor->port_index, acceptor->fd_index);
}
-static void server_weak_ref_shutdown(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void server_weak_ref_shutdown(void* arg, grpc_error* error) {
server_weak_ref* weak_ref = static_cast<server_weak_ref*>(arg);
weak_ref->server = nullptr;
}
@@ -145,12 +144,11 @@ static void test_addr_init_str(test_addr* addr) {
}
}
-static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
- grpc_pollset* pollset,
+static void on_connect(void* arg, grpc_endpoint* tcp, grpc_pollset* pollset,
grpc_tcp_server_acceptor* acceptor) {
- grpc_endpoint_shutdown(exec_ctx, tcp,
+ grpc_endpoint_shutdown(tcp,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
- grpc_endpoint_destroy(exec_ctx, tcp);
+ grpc_endpoint_destroy(tcp);
on_connect_result temp_result;
on_connect_result_set(&temp_result, acceptor);
@@ -159,38 +157,33 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
gpr_mu_lock(g_mu);
g_result = temp_result;
g_nconnects++;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
static void test_no_op(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_tcp_server* s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, nullptr, nullptr, &s));
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(nullptr, nullptr, &s));
+ grpc_tcp_server_unref(s);
}
static void test_no_op_with_start(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_tcp_server* s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, nullptr, nullptr, &s));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(nullptr, nullptr, &s));
LOG_TEST("test_no_op_with_start");
- grpc_tcp_server_start(&exec_ctx, s, nullptr, 0, on_connect, nullptr);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_start(s, nullptr, 0, on_connect, nullptr);
+ grpc_tcp_server_unref(s);
}
static void test_no_op_with_port(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
grpc_tcp_server* s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, nullptr, nullptr, &s));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(nullptr, nullptr, &s));
LOG_TEST("test_no_op_with_port");
memset(&resolved_addr, 0, sizeof(resolved_addr));
@@ -201,17 +194,15 @@ static void test_no_op_with_port(void) {
GRPC_ERROR_NONE &&
port > 0);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
}
static void test_no_op_with_port_and_start(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
grpc_tcp_server* s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, nullptr, nullptr, &s));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(nullptr, nullptr, &s));
LOG_TEST("test_no_op_with_port_and_start");
int port = -1;
@@ -222,13 +213,12 @@ static void test_no_op_with_port_and_start(void) {
GRPC_ERROR_NONE &&
port > 0);
- grpc_tcp_server_start(&exec_ctx, s, nullptr, 0, on_connect, nullptr);
+ grpc_tcp_server_start(s, nullptr, 0, on_connect, nullptr);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
}
-static grpc_error* tcp_connect(grpc_exec_ctx* exec_ctx, const test_addr* remote,
+static grpc_error* tcp_connect(const test_addr* remote,
on_connect_result* result) {
grpc_millis deadline =
grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10));
@@ -254,17 +244,17 @@ static grpc_error* tcp_connect(grpc_exec_ctx* exec_ctx, const test_addr* remote,
}
gpr_log(GPR_DEBUG, "wait");
while (g_nconnects == nconnects_before &&
- deadline > grpc_exec_ctx_now(exec_ctx)) {
+ deadline > grpc_core::ExecCtx::Get()->Now()) {
grpc_pollset_worker* worker = nullptr;
grpc_error* err;
- if ((err = grpc_pollset_work(exec_ctx, g_pollset, &worker, deadline)) !=
+ if ((err = grpc_pollset_work(g_pollset, &worker, deadline)) !=
GRPC_ERROR_NONE) {
gpr_mu_unlock(g_mu);
close(clifd);
return err;
}
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_log(GPR_DEBUG, "wait done");
@@ -279,7 +269,7 @@ static grpc_error* tcp_connect(grpc_exec_ctx* exec_ctx, const test_addr* remote,
gpr_mu_unlock(g_mu);
gpr_log(GPR_INFO, "Result (%d, %d) fd %d", result->port_index,
result->fd_index, result->server_fd);
- grpc_tcp_server_unref(exec_ctx, result->server);
+ grpc_tcp_server_unref(result->server);
return GRPC_ERROR_NONE;
}
@@ -292,7 +282,7 @@ static grpc_error* tcp_connect(grpc_exec_ctx* exec_ctx, const test_addr* remote,
static void test_connect(size_t num_connects,
const grpc_channel_args* channel_args,
test_addrs* dst_addrs, bool test_dst_addrs) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
grpc_resolved_address resolved_addr1;
struct sockaddr_storage* const addr =
@@ -307,7 +297,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, nullptr, channel_args, &s));
+ grpc_tcp_server_create(nullptr, channel_args, &s));
unsigned port_num;
server_weak_ref weak_ref;
server_weak_ref_init(&weak_ref);
@@ -352,7 +342,7 @@ 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, nullptr);
+ grpc_tcp_server_start(s, &g_pollset, 1, on_connect, nullptr);
if (dst_addrs != nullptr) {
int ports[] = {svr_port, svr1_port};
@@ -372,7 +362,7 @@ static void test_connect(size_t num_connects,
test_addr_init_str(&dst);
++num_tested;
on_connect_result_init(&result);
- if ((err = tcp_connect(&exec_ctx, &dst, &result)) == GRPC_ERROR_NONE &&
+ if ((err = tcp_connect(&dst, &result)) == GRPC_ERROR_NONE &&
result.server_fd >= 0 && result.server == s) {
continue;
}
@@ -403,8 +393,8 @@ static void test_connect(size_t num_connects,
for (connect_num = 0; connect_num < num_connects; ++connect_num) {
on_connect_result result;
on_connect_result_init(&result);
- GPR_ASSERT(GRPC_LOG_IF_ERROR("tcp_connect",
- tcp_connect(&exec_ctx, &dst, &result)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("tcp_connect", tcp_connect(&dst, &result)));
GPR_ASSERT(result.server_fd == fd);
GPR_ASSERT(result.port_index == port_num);
GPR_ASSERT(result.fd_index == fd_num);
@@ -420,21 +410,19 @@ static void test_connect(size_t num_connects,
GPR_ASSERT(weak_ref.server != nullptr);
GPR_ASSERT(grpc_tcp_server_port_fd(s, 0, 0) >= 0);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
/* Weak ref lost. */
GPR_ASSERT(weak_ref.server == nullptr);
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p));
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_arg chan_args[1];
chan_args[0].type = GRPC_ARG_INTEGER;
chan_args[0].key = const_cast<char*>(GRPC_ARG_EXPAND_WILDCARD_ADDRS);
@@ -497,8 +485,8 @@ int main(int argc, char** argv) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+
grpc_shutdown();
gpr_free(dst_addrs);
gpr_free(g_pollset);
diff --git a/test/core/iomgr/tcp_server_uv_test.cc b/test/core/iomgr/tcp_server_uv_test.cc
index dd047a0498..07b1fb1579 100644
--- a/test/core/iomgr/tcp_server_uv_test.cc
+++ b/test/core/iomgr/tcp_server_uv_test.cc
@@ -74,8 +74,7 @@ static void on_connect_result_set(on_connect_result* result,
result->fd_index = acceptor->fd_index;
}
-static void server_weak_ref_shutdown(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void server_weak_ref_shutdown(void* arg, grpc_error* error) {
server_weak_ref* weak_ref = static_cast<server_weak_ref*>(arg);
weak_ref->server = NULL;
}
@@ -97,12 +96,11 @@ static void server_weak_ref_set(server_weak_ref* weak_ref,
weak_ref->server = server;
}
-static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
- grpc_pollset* pollset,
+static void on_connect(void* arg, grpc_endpoint* tcp, grpc_pollset* pollset,
grpc_tcp_server_acceptor* acceptor) {
- grpc_endpoint_shutdown(exec_ctx, tcp,
+ grpc_endpoint_shutdown(tcp,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
- grpc_endpoint_destroy(exec_ctx, tcp);
+ grpc_endpoint_destroy(tcp);
on_connect_result temp_result;
on_connect_result_set(&temp_result, acceptor);
@@ -111,38 +109,33 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
gpr_mu_lock(g_mu);
g_result = temp_result;
g_nconnects++;
- GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, g_pollset, NULL)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, NULL)));
gpr_mu_unlock(g_mu);
}
static void test_no_op(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_tcp_server* s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
+ grpc_tcp_server_unref(s);
}
static void test_no_op_with_start(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_tcp_server* s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
LOG_TEST("test_no_op_with_start");
- grpc_tcp_server_start(&exec_ctx, s, NULL, 0, on_connect, NULL);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_start(s, NULL, 0, on_connect, NULL);
+ grpc_tcp_server_unref(s);
}
static void test_no_op_with_port(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
grpc_tcp_server* s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
LOG_TEST("test_no_op_with_port");
memset(&resolved_addr, 0, sizeof(resolved_addr));
@@ -153,17 +146,15 @@ static void test_no_op_with_port(void) {
GRPC_ERROR_NONE &&
port > 0);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
}
static void test_no_op_with_port_and_start(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
grpc_tcp_server* s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
LOG_TEST("test_no_op_with_port_and_start");
int port;
@@ -174,10 +165,9 @@ static void test_no_op_with_port_and_start(void) {
GRPC_ERROR_NONE &&
port > 0);
- grpc_tcp_server_start(&exec_ctx, s, NULL, 0, on_connect, NULL);
+ grpc_tcp_server_start(s, NULL, 0, on_connect, NULL);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
}
static void connect_cb(uv_connect_t* req, int status) {
@@ -187,8 +177,8 @@ static void connect_cb(uv_connect_t* req, int status) {
static void close_cb(uv_handle_t* handle) { gpr_free(handle); }
-static void tcp_connect(grpc_exec_ctx* exec_ctx, const struct sockaddr* remote,
- socklen_t remote_len, on_connect_result* result) {
+static void tcp_connect(const struct sockaddr* remote, socklen_t remote_len,
+ on_connect_result* result) {
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10);
uv_tcp_t* client_handle =
static_cast<uv_tcp_t*>(gpr_malloc(sizeof(uv_tcp_t)));
@@ -208,10 +198,10 @@ static void tcp_connect(grpc_exec_ctx* exec_ctx, const struct sockaddr* remote,
grpc_pollset_worker* worker = NULL;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(exec_ctx, g_pollset, &worker,
+ grpc_pollset_work(g_pollset, &worker,
grpc_timespec_to_millis_round_up(deadline))));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_finish(exec_ctx);
+
gpr_mu_lock(g_mu);
}
gpr_log(GPR_DEBUG, "wait done");
@@ -224,7 +214,7 @@ static void tcp_connect(grpc_exec_ctx* exec_ctx, const struct sockaddr* remote,
/* Tests a tcp server with multiple ports. */
static void test_connect(unsigned n) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
grpc_resolved_address resolved_addr1;
struct sockaddr_storage* addr = (struct sockaddr_storage*)resolved_addr.addr;
@@ -233,8 +223,7 @@ static void test_connect(unsigned n) {
int svr_port;
int svr1_port;
grpc_tcp_server* s;
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
unsigned i;
server_weak_ref weak_ref;
server_weak_ref_init(&weak_ref);
@@ -257,48 +246,45 @@ static void test_connect(unsigned n) {
GRPC_ERROR_NONE &&
svr_port == svr1_port);
- grpc_tcp_server_start(&exec_ctx, s, &g_pollset, 1, on_connect, NULL);
+ grpc_tcp_server_start(s, &g_pollset, 1, on_connect, NULL);
GPR_ASSERT(uv_ip6_addr("::", svr_port, (struct sockaddr_in6*)addr1) == 0);
for (i = 0; i < n; i++) {
on_connect_result result;
on_connect_result_init(&result);
- tcp_connect(&exec_ctx, (struct sockaddr*)addr, (socklen_t)resolved_addr.len,
- &result);
+ tcp_connect((struct sockaddr*)addr, (socklen_t)resolved_addr.len, &result);
GPR_ASSERT(result.port_index == 0);
GPR_ASSERT(result.server == s);
if (weak_ref.server == NULL) {
server_weak_ref_set(&weak_ref, result.server);
}
- grpc_tcp_server_unref(&exec_ctx, result.server);
+ grpc_tcp_server_unref(result.server);
on_connect_result_init(&result);
- tcp_connect(&exec_ctx, (struct sockaddr*)addr1,
- (socklen_t)resolved_addr1.len, &result);
+ tcp_connect((struct sockaddr*)addr1, (socklen_t)resolved_addr1.len,
+ &result);
GPR_ASSERT(result.port_index == 1);
GPR_ASSERT(result.server == s);
- grpc_tcp_server_unref(&exec_ctx, result.server);
+ grpc_tcp_server_unref(result.server);
}
/* Weak ref to server valid until final unref. */
GPR_ASSERT(weak_ref.server != NULL);
- grpc_tcp_server_unref(&exec_ctx, s);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
/* Weak ref lost. */
GPR_ASSERT(weak_ref.server == NULL);
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p));
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_test_init(argc, argv);
grpc_init();
g_pollset = static_cast<grpc_pollset*>(gpr_malloc(grpc_pollset_size()));
@@ -313,8 +299,8 @@ int main(int argc, char** argv) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+
grpc_shutdown();
gpr_free(g_pollset);
return 0;
diff --git a/test/core/iomgr/timer_list_test.cc b/test/core/iomgr/timer_list_test.cc
index dc965ef7dc..3041674bd7 100644
--- a/test/core/iomgr/timer_list_test.cc
+++ b/test/core/iomgr/timer_list_test.cc
@@ -36,118 +36,114 @@ extern "C" grpc_tracer_flag grpc_timer_check_trace;
static int cb_called[MAX_CB][2];
-static void cb(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void cb(void* arg, grpc_error* error) {
cb_called[(intptr_t)arg][error == GRPC_ERROR_NONE]++;
}
static void add_test(void) {
int i;
grpc_timer timers[20];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_INFO, "add_test");
- grpc_timer_list_init(&exec_ctx);
+ grpc_timer_list_init();
grpc_timer_trace.value = 1;
grpc_timer_check_trace.value = 1;
memset(cb_called, 0, sizeof(cb_called));
- grpc_millis start = grpc_exec_ctx_now(&exec_ctx);
+ grpc_millis start = grpc_core::ExecCtx::Get()->Now();
/* 10 ms timers. will expire in the current epoch */
for (i = 0; i < 10; i++) {
grpc_timer_init(
- &exec_ctx, &timers[i], start + 10,
+ &timers[i], start + 10,
GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)i, grpc_schedule_on_exec_ctx));
}
/* 1010 ms timers. will expire in the next epoch */
for (i = 10; i < 20; i++) {
grpc_timer_init(
- &exec_ctx, &timers[i], start + 1010,
+ &timers[i], start + 1010,
GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)i, grpc_schedule_on_exec_ctx));
}
/* collect timers. Only the first batch should be ready. */
- exec_ctx.now = start + 500;
- GPR_ASSERT(grpc_timer_check(&exec_ctx, nullptr) == GRPC_TIMERS_FIRED);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(start + 500);
+ GPR_ASSERT(grpc_timer_check(nullptr) == GRPC_TIMERS_FIRED);
+
for (i = 0; i < 20; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 10));
GPR_ASSERT(cb_called[i][0] == 0);
}
- exec_ctx.now = start + 600;
- GPR_ASSERT(grpc_timer_check(&exec_ctx, nullptr) ==
- GRPC_TIMERS_CHECKED_AND_EMPTY);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(start + 600);
+ GPR_ASSERT(grpc_timer_check(nullptr) == GRPC_TIMERS_CHECKED_AND_EMPTY);
+
for (i = 0; i < 30; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 10));
GPR_ASSERT(cb_called[i][0] == 0);
}
/* collect the rest of the timers */
- exec_ctx.now = start + 1500;
- GPR_ASSERT(grpc_timer_check(&exec_ctx, nullptr) == GRPC_TIMERS_FIRED);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(start + 1500);
+ GPR_ASSERT(grpc_timer_check(nullptr) == GRPC_TIMERS_FIRED);
+
for (i = 0; i < 30; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 20));
GPR_ASSERT(cb_called[i][0] == 0);
}
- exec_ctx.now = start + 1600;
- GPR_ASSERT(grpc_timer_check(&exec_ctx, nullptr) ==
- GRPC_TIMERS_CHECKED_AND_EMPTY);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(start + 1600);
+ GPR_ASSERT(grpc_timer_check(nullptr) == GRPC_TIMERS_CHECKED_AND_EMPTY);
for (i = 0; i < 30; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 20));
GPR_ASSERT(cb_called[i][0] == 0);
}
- grpc_timer_list_shutdown(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_timer_list_shutdown();
}
/* Cleaning up a list with pending timers. */
void destruction_test(void) {
grpc_timer timers[5];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_INFO, "destruction_test");
- exec_ctx.now_is_valid = true;
- exec_ctx.now = 0;
- grpc_timer_list_init(&exec_ctx);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(0);
+ grpc_timer_list_init();
grpc_timer_trace.value = 1;
grpc_timer_check_trace.value = 1;
memset(cb_called, 0, sizeof(cb_called));
grpc_timer_init(
- &exec_ctx, &timers[0], 100,
+ &timers[0], 100,
GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)0, grpc_schedule_on_exec_ctx));
grpc_timer_init(
- &exec_ctx, &timers[1], 3,
+ &timers[1], 3,
GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)1, grpc_schedule_on_exec_ctx));
grpc_timer_init(
- &exec_ctx, &timers[2], 100,
+ &timers[2], 100,
GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)2, grpc_schedule_on_exec_ctx));
grpc_timer_init(
- &exec_ctx, &timers[3], 3,
+ &timers[3], 3,
GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)3, grpc_schedule_on_exec_ctx));
grpc_timer_init(
- &exec_ctx, &timers[4], 1,
+ &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, nullptr) == GRPC_TIMERS_FIRED);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->TestOnlySetNow(2);
+ GPR_ASSERT(grpc_timer_check(nullptr) == GRPC_TIMERS_FIRED);
+
GPR_ASSERT(1 == cb_called[4][1]);
- grpc_timer_cancel(&exec_ctx, &timers[0]);
- grpc_timer_cancel(&exec_ctx, &timers[3]);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_timer_cancel(&timers[0]);
+ grpc_timer_cancel(&timers[3]);
+
GPR_ASSERT(1 == cb_called[0][0]);
GPR_ASSERT(1 == cb_called[3][0]);
- grpc_timer_list_shutdown(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_timer_list_shutdown();
+
GPR_ASSERT(1 == cb_called[1][0]);
GPR_ASSERT(1 == cb_called[2][0]);
}
diff --git a/test/core/iomgr/udp_server_test.cc b/test/core/iomgr/udp_server_test.cc
index 803f017106..2c5719f4ae 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 void on_read(grpc_fd* emfd, void* user_data) {
char read_buffer[512];
ssize_t byte_count;
@@ -61,22 +61,22 @@ 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, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
-static void on_write(grpc_exec_ctx* exec_ctx, grpc_fd* emfd, void* user_data) {
+static void on_write(grpc_fd* emfd, void* user_data) {
gpr_mu_lock(g_mu);
g_number_of_writes++;
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_kick", grpc_pollset_kick(exec_ctx, g_pollset, nullptr)));
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
-static void on_fd_orphaned(grpc_exec_ctx* exec_ctx, grpc_fd* emfd,
- grpc_closure* closure, void* user_data) {
+static void on_fd_orphaned(grpc_fd* emfd, grpc_closure* closure,
+ void* user_data) {
gpr_log(GPR_INFO, "gRPC FD about to be orphaned: %d",
grpc_fd_wrapped_fd(emfd));
g_number_of_orphan_calls++;
@@ -127,24 +127,22 @@ 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_core::ExecCtx _local_exec_ctx;
grpc_udp_server* s = grpc_udp_server_create(nullptr);
- grpc_udp_server_destroy(&exec_ctx, s, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_udp_server_destroy(s, nullptr);
}
static void test_no_op_with_start(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_udp_server* s = grpc_udp_server_create(nullptr);
LOG_TEST("test_no_op_with_start");
- grpc_udp_server_start(&exec_ctx, s, nullptr, 0, nullptr);
- grpc_udp_server_destroy(&exec_ctx, s, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_udp_server_start(s, nullptr, 0, nullptr);
+ grpc_udp_server_destroy(s, nullptr);
}
static void test_no_op_with_port(void) {
g_number_of_orphan_calls = 0;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
grpc_udp_server* s = grpc_udp_server_create(nullptr);
@@ -156,8 +154,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, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_udp_server_destroy(s, nullptr);
/* The server had a single FD, which should have been orphaned. */
GPR_ASSERT(g_number_of_orphan_calls == 1);
@@ -165,7 +162,7 @@ static void test_no_op_with_port(void) {
static void test_no_op_with_port_and_socket_factory(void) {
g_number_of_orphan_calls = 0;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
@@ -175,7 +172,7 @@ static void test_no_op_with_port_and_socket_factory(void) {
grpc_channel_args* channel_args =
grpc_channel_args_copy_and_add(nullptr, &socket_factory_arg, 1);
grpc_udp_server* s = grpc_udp_server_create(channel_args);
- grpc_channel_args_destroy(&exec_ctx, channel_args);
+ grpc_channel_args_destroy(channel_args);
LOG_TEST("test_no_op_with_port_and_socket_factory");
@@ -187,8 +184,8 @@ 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, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_udp_server_destroy(s, nullptr);
+
grpc_socket_factory_unref(&socket_factory->base);
/* The server had a single FD, which should have been orphaned. */
@@ -197,7 +194,7 @@ static void test_no_op_with_port_and_socket_factory(void) {
static void test_no_op_with_port_and_start(void) {
g_number_of_orphan_calls = 0;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
grpc_udp_server* s = grpc_udp_server_create(nullptr);
@@ -209,10 +206,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, nullptr, 0, nullptr);
+ grpc_udp_server_start(s, nullptr, 0, nullptr);
- grpc_udp_server_destroy(&exec_ctx, s, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_udp_server_destroy(s, nullptr);
/* The server had a single FD, which is orphaned exactly once in *
* grpc_udp_server_destroy. */
@@ -220,7 +216,7 @@ static void test_no_op_with_port_and_start(void) {
}
static void test_receive(int number_of_clients) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
struct sockaddr_storage* addr = (struct sockaddr_storage*)resolved_addr.addr;
int clifd, svrfd;
@@ -248,7 +244,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, nullptr);
+ grpc_udp_server_start(s, pollsets, 1, nullptr);
gpr_mu_lock(g_mu);
@@ -264,13 +260,12 @@ static void test_receive(int number_of_clients) {
(socklen_t)resolved_addr.len) == 0);
GPR_ASSERT(5 == write(clifd, "hello", 5));
while (g_number_of_reads == number_of_reads_before &&
- deadline > grpc_exec_ctx_now(&exec_ctx)) {
+ deadline > grpc_core::ExecCtx::Get()->Now()) {
grpc_pollset_worker* worker = nullptr;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
+ "pollset_work", grpc_pollset_work(g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(g_mu);
}
GPR_ASSERT(g_number_of_reads == number_of_reads_before + 1);
@@ -280,8 +275,7 @@ static void test_receive(int number_of_clients) {
gpr_mu_unlock(g_mu);
- grpc_udp_server_destroy(&exec_ctx, s, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_udp_server_destroy(s, nullptr);
/* The server had a single FD, which is orphaned exactly once in *
* grpc_udp_server_destroy. */
@@ -291,14 +285,13 @@ static void test_receive(int number_of_clients) {
GPR_ASSERT(g_number_of_writes > 0);
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p));
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_test_init(argc, argv);
grpc_init();
g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
@@ -314,8 +307,8 @@ int main(int argc, char** argv) {
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+
gpr_free(g_pollset);
grpc_shutdown();
return 0;
diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc
index 64d383ad0a..7d0a24a459 100644
--- a/test/core/security/credentials_test.cc
+++ b/test/core/security/credentials_test.cc
@@ -148,41 +148,37 @@ static grpc_httpcli_response http_response(int status, const char* body) {
/* -- Tests. -- */
static void test_empty_md_array(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_credentials_mdelem_array md_array;
memset(&md_array, 0, sizeof(md_array));
GPR_ASSERT(md_array.md == nullptr);
GPR_ASSERT(md_array.size == 0);
- grpc_credentials_mdelem_array_destroy(&exec_ctx, &md_array);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_credentials_mdelem_array_destroy(&md_array);
}
static void test_add_to_empty_md_array(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_credentials_mdelem_array md_array;
memset(&md_array, 0, sizeof(md_array));
const char* key = "hello";
const char* value = "there blah blah blah blah blah blah blah";
- grpc_mdelem md =
- grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_copied_string(key),
- grpc_slice_from_copied_string(value));
+ grpc_mdelem md = grpc_mdelem_from_slices(
+ grpc_slice_from_copied_string(key), grpc_slice_from_copied_string(value));
grpc_credentials_mdelem_array_add(&md_array, md);
GPR_ASSERT(md_array.size == 1);
GPR_ASSERT(grpc_mdelem_eq(md, md_array.md[0]));
- GRPC_MDELEM_UNREF(&exec_ctx, md);
- grpc_credentials_mdelem_array_destroy(&exec_ctx, &md_array);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(md);
+ grpc_credentials_mdelem_array_destroy(&md_array);
}
static void test_add_abunch_to_md_array(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_credentials_mdelem_array md_array;
memset(&md_array, 0, sizeof(md_array));
const char* key = "hello";
const char* value = "there blah blah blah blah blah blah blah";
- grpc_mdelem md =
- grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_copied_string(key),
- grpc_slice_from_copied_string(value));
+ grpc_mdelem md = grpc_mdelem_from_slices(
+ grpc_slice_from_copied_string(key), grpc_slice_from_copied_string(value));
size_t num_entries = 1000;
for (size_t i = 0; i < num_entries; ++i) {
grpc_credentials_mdelem_array_add(&md_array, md);
@@ -190,57 +186,52 @@ static void test_add_abunch_to_md_array(void) {
for (size_t i = 0; i < num_entries; ++i) {
GPR_ASSERT(grpc_mdelem_eq(md_array.md[i], md));
}
- GRPC_MDELEM_UNREF(&exec_ctx, md);
- grpc_credentials_mdelem_array_destroy(&exec_ctx, &md_array);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(md);
+ grpc_credentials_mdelem_array_destroy(&md_array);
}
static void test_oauth2_token_fetcher_creds_parsing_ok(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
grpc_millis token_lifetime;
grpc_httpcli_response response =
http_response(200, valid_oauth2_json_response);
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
- GRPC_CREDENTIALS_OK);
+ &response, &token_md, &token_lifetime) == GRPC_CREDENTIALS_OK);
GPR_ASSERT(token_lifetime == 3599 * GPR_MS_PER_SEC);
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDKEY(token_md), "authorization") == 0);
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDVALUE(token_md),
"Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_") ==
0);
- GRPC_MDELEM_UNREF(&exec_ctx, token_md);
+ GRPC_MDELEM_UNREF(token_md);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_bad_http_status(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
grpc_millis token_lifetime;
grpc_httpcli_response response =
http_response(401, valid_oauth2_json_response);
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
+ &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_empty_http_body(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
grpc_millis token_lifetime;
grpc_httpcli_response response = http_response(200, "");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
+ &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_invalid_json(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
grpc_millis token_lifetime;
grpc_httpcli_response response =
@@ -249,14 +240,13 @@ static void test_oauth2_token_fetcher_creds_parsing_invalid_json(void) {
" \"expires_in\":3599, "
" \"token_type\":\"Bearer\"");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
+ &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_missing_token(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
grpc_millis token_lifetime;
grpc_httpcli_response response = http_response(200,
@@ -264,14 +254,13 @@ static void test_oauth2_token_fetcher_creds_parsing_missing_token(void) {
" \"expires_in\":3599, "
" \"token_type\":\"Bearer\"}");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
+ &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_missing_token_type(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
grpc_millis token_lifetime;
grpc_httpcli_response response =
@@ -280,15 +269,14 @@ static void test_oauth2_token_fetcher_creds_parsing_missing_token_type(void) {
" \"expires_in\":3599, "
"}");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
+ &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_token_fetcher_creds_parsing_missing_token_lifetime(
void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem token_md = GRPC_MDNULL;
grpc_millis token_lifetime;
grpc_httpcli_response response =
@@ -296,10 +284,9 @@ static void test_oauth2_token_fetcher_creds_parsing_missing_token_lifetime(
"{\"access_token\":\"ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_\","
" \"token_type\":\"Bearer\"}");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
- &exec_ctx, &response, &token_md, &token_lifetime) ==
+ &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_ERROR);
grpc_http_response_destroy(&response);
- grpc_exec_ctx_finish(&exec_ctx);
}
typedef struct {
@@ -336,8 +323,7 @@ static void check_metadata(const expected_md* expected,
}
}
-static void check_request_metadata(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void check_request_metadata(void* arg, grpc_error* error) {
request_metadata_state* state = (request_metadata_state*)arg;
gpr_log(GPR_INFO, "expected_error: %s",
grpc_error_string(state->expected_error));
@@ -358,9 +344,8 @@ static void check_request_metadata(grpc_exec_ctx* exec_ctx, void* arg,
state->expected_size, state->md_array.size);
GPR_ASSERT(state->md_array.size == state->expected_size);
check_metadata(state->expected, &state->md_array);
- grpc_credentials_mdelem_array_destroy(exec_ctx, &state->md_array);
- grpc_pollset_set_destroy(exec_ctx,
- grpc_polling_entity_pollset_set(&state->pollent));
+ grpc_credentials_mdelem_array_destroy(&state->md_array);
+ grpc_pollset_set_destroy(grpc_polling_entity_pollset_set(&state->pollent));
gpr_free(state);
}
@@ -379,22 +364,21 @@ static request_metadata_state* make_request_metadata_state(
return state;
}
-static void run_request_metadata_test(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds,
+static void run_request_metadata_test(grpc_call_credentials* creds,
grpc_auth_metadata_context auth_md_ctx,
request_metadata_state* state) {
grpc_error* error = GRPC_ERROR_NONE;
if (grpc_call_credentials_get_request_metadata(
- exec_ctx, creds, &state->pollent, auth_md_ctx, &state->md_array,
+ creds, &state->pollent, auth_md_ctx, &state->md_array,
&state->on_request_metadata, &error)) {
// Synchronous result. Invoke the callback directly.
- check_request_metadata(exec_ctx, state, error);
+ check_request_metadata(state, error);
GRPC_ERROR_UNREF(error);
}
}
static void test_google_iam_creds(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
expected_md emd[] = {{GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY,
test_google_iam_authorization_token},
{GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY,
@@ -406,13 +390,12 @@ static void test_google_iam_creds(void) {
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);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_call_credentials_unref(creds);
}
static void test_access_token_creds(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
expected_md emd[] = {{GRPC_AUTHORIZATION_METADATA_KEY, "Bearer blah"}};
request_metadata_state* state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
@@ -421,16 +404,14 @@ static void test_access_token_creds(void) {
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
nullptr, nullptr};
GPR_ASSERT(strcmp(creds->type, GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_call_credentials_unref(creds);
}
static grpc_security_status check_channel_oauth2_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* c,
- grpc_call_credentials* call_creds, const char* target,
- const grpc_channel_args* args, grpc_channel_security_connector** sc,
- grpc_channel_args** new_args) {
+ grpc_channel_credentials* c, grpc_call_credentials* call_creds,
+ const char* target, const grpc_channel_args* args,
+ grpc_channel_security_connector** sc, grpc_channel_args** new_args) {
GPR_ASSERT(strcmp(c->type, "mock") == 0);
GPR_ASSERT(call_creds != nullptr);
GPR_ASSERT(strcmp(call_creds->type, GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0);
@@ -438,7 +419,7 @@ static grpc_security_status check_channel_oauth2_create_security_connector(
}
static void test_channel_oauth2_composite_creds(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_channel_args* new_args;
grpc_channel_credentials_vtable vtable = {
nullptr, check_channel_oauth2_create_security_connector, nullptr};
@@ -452,14 +433,13 @@ static void test_channel_oauth2_composite_creds(void) {
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, nullptr, nullptr, nullptr,
- &new_args) == GRPC_SECURITY_OK);
+ channel_oauth2_creds, nullptr, nullptr, nullptr, &new_args) ==
+ GRPC_SECURITY_OK);
grpc_channel_credentials_release(channel_oauth2_creds);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_oauth2_google_iam_composite_creds(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
expected_md emd[] = {
{GRPC_AUTHORIZATION_METADATA_KEY, test_oauth2_bearer_token},
{GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY,
@@ -471,15 +451,15 @@ static void test_oauth2_google_iam_composite_creds(void) {
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);
+ "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,
nullptr);
grpc_call_credentials* composite_creds =
grpc_composite_call_credentials_create(oauth2_creds, google_iam_creds,
nullptr);
- grpc_call_credentials_unref(&exec_ctx, oauth2_creds);
- grpc_call_credentials_unref(&exec_ctx, google_iam_creds);
+ grpc_call_credentials_unref(oauth2_creds);
+ grpc_call_credentials_unref(google_iam_creds);
GPR_ASSERT(
strcmp(composite_creds->type, GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) == 0);
const grpc_call_credentials_array* creds_array =
@@ -489,17 +469,15 @@ static void test_oauth2_google_iam_composite_creds(void) {
GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0);
GPR_ASSERT(strcmp(creds_array->creds_array[1]->type,
GRPC_CALL_CREDENTIALS_TYPE_IAM) == 0);
- run_request_metadata_test(&exec_ctx, composite_creds, auth_md_ctx, state);
- grpc_call_credentials_unref(&exec_ctx, composite_creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ run_request_metadata_test(composite_creds, auth_md_ctx, state);
+ grpc_call_credentials_unref(composite_creds);
}
static grpc_security_status
check_channel_oauth2_google_iam_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* c,
- grpc_call_credentials* call_creds, const char* target,
- const grpc_channel_args* args, grpc_channel_security_connector** sc,
- grpc_channel_args** new_args) {
+ grpc_channel_credentials* c, grpc_call_credentials* call_creds,
+ const char* target, const grpc_channel_args* args,
+ grpc_channel_security_connector** sc, grpc_channel_args** new_args) {
const grpc_call_credentials_array* creds_array;
GPR_ASSERT(strcmp(c->type, "mock") == 0);
GPR_ASSERT(call_creds != nullptr);
@@ -514,7 +492,7 @@ check_channel_oauth2_google_iam_create_security_connector(
}
static void test_channel_oauth2_google_iam_composite_creds(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_channel_args* new_args;
grpc_channel_credentials_vtable vtable = {
nullptr, check_channel_oauth2_google_iam_create_security_connector,
@@ -538,11 +516,10 @@ static void test_channel_oauth2_google_iam_composite_creds(void) {
grpc_call_credentials_release(google_iam_creds);
GPR_ASSERT(grpc_channel_credentials_create_security_connector(
- &exec_ctx, channel_oauth2_iam_creds, nullptr, nullptr, nullptr,
+ channel_oauth2_iam_creds, nullptr, nullptr, nullptr,
&new_args) == GRPC_SECURITY_OK);
grpc_channel_credentials_release(channel_oauth2_iam_creds);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void validate_compute_engine_http_request(
@@ -559,35 +536,32 @@ static void validate_compute_engine_http_request(
}
static int compute_engine_httpcli_get_success_override(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- grpc_millis deadline, grpc_closure* on_done,
- grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
validate_compute_engine_http_request(request);
*response = http_response(200, valid_oauth2_json_response);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static int compute_engine_httpcli_get_failure_override(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- grpc_millis deadline, grpc_closure* on_done,
- grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
validate_compute_engine_http_request(request);
*response = http_response(403, "Not Authorized.");
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static int httpcli_post_should_not_be_called(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- const char* body_bytes, size_t body_size, grpc_millis deadline,
- grpc_closure* on_done, grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, const char* body_bytes,
+ size_t body_size, grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
GPR_ASSERT("HTTP POST should not be called" == nullptr);
return 1;
}
-static int httpcli_get_should_not_be_called(grpc_exec_ctx* exec_ctx,
- const grpc_httpcli_request* request,
+static int httpcli_get_should_not_be_called(const grpc_httpcli_request* request,
grpc_millis deadline,
grpc_closure* on_done,
grpc_httpcli_response* response) {
@@ -596,7 +570,7 @@ static int httpcli_get_should_not_be_called(grpc_exec_ctx* exec_ctx,
}
static void test_compute_engine_creds_success(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
expected_md emd[] = {
{"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}};
grpc_call_credentials* creds =
@@ -609,24 +583,23 @@ static void test_compute_engine_creds_success(void) {
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_httpcli_set_override(compute_engine_httpcli_get_success_override,
httpcli_post_should_not_be_called);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
/* Second request: the cached token should be served directly. */
state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
httpcli_post_should_not_be_called);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
- grpc_call_credentials_unref(&exec_ctx, creds);
+ grpc_call_credentials_unref(creds);
grpc_httpcli_set_override(nullptr, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_compute_engine_creds_failure(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
request_metadata_state* state = make_request_metadata_state(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Error occured when fetching oauth2 token."),
@@ -637,10 +610,9 @@ static void test_compute_engine_creds_failure(void) {
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);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_call_credentials_unref(creds);
grpc_httpcli_set_override(nullptr, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void validate_refresh_token_http_request(
@@ -667,27 +639,27 @@ static void validate_refresh_token_http_request(
}
static int refresh_token_httpcli_post_success(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- const char* body, size_t body_size, grpc_millis deadline,
- grpc_closure* on_done, grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, const char* body, size_t body_size,
+ grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
validate_refresh_token_http_request(request, body, body_size);
*response = http_response(200, valid_oauth2_json_response);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static int refresh_token_httpcli_post_failure(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- const char* body, size_t body_size, grpc_millis deadline,
- grpc_closure* on_done, grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, const char* body, size_t body_size,
+ grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
validate_refresh_token_http_request(request, body, body_size);
*response = http_response(403, "Not Authorized.");
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static void test_refresh_token_creds_success(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
expected_md emd[] = {
{"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}};
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
@@ -700,24 +672,23 @@ static void test_refresh_token_creds_success(void) {
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
refresh_token_httpcli_post_success);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
/* Second request: the cached token should be served directly. */
state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
httpcli_post_should_not_be_called);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
- grpc_call_credentials_unref(&exec_ctx, creds);
+ grpc_call_credentials_unref(creds);
grpc_httpcli_set_override(nullptr, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_refresh_token_creds_failure(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
request_metadata_state* state = make_request_metadata_state(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Error occured when fetching oauth2 token."),
@@ -728,10 +699,9 @@ static void test_refresh_token_creds_failure(void) {
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);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_call_credentials_unref(creds);
grpc_httpcli_set_override(nullptr, nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void validate_jwt_encode_and_sign_params(
@@ -821,7 +791,7 @@ 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_core::ExecCtx _local_exec_ctx;
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
nullptr, nullptr};
char* expected_md_value;
@@ -835,16 +805,16 @@ static void test_jwt_creds_success(void) {
request_metadata_state* state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_success);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
/* Second request: the cached token should be served directly. */
state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_jwt_encode_and_sign_set_override(
encode_and_sign_jwt_should_not_be_called);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
/* Third request: Different service url so jwt_encode_and_sign should be
called again (no caching). */
@@ -852,19 +822,18 @@ static void test_jwt_creds_success(void) {
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
auth_md_ctx.service_url = other_test_service_url;
grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_success);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
- grpc_call_credentials_unref(&exec_ctx, creds);
+ grpc_call_credentials_unref(creds);
gpr_free(json_key_string);
gpr_free(expected_md_value);
grpc_jwt_encode_and_sign_set_override(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_core::ExecCtx _local_exec_ctx;
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
nullptr, nullptr};
request_metadata_state* state = make_request_metadata_state(
@@ -875,12 +844,11 @@ static void test_jwt_creds_signing_failure(void) {
json_key_string, grpc_max_auth_token_lifetime(), nullptr);
grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_failure);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
+ run_request_metadata_test(creds, auth_md_ctx, state);
gpr_free(json_key_string);
- grpc_call_credentials_unref(&exec_ctx, creds);
+ grpc_call_credentials_unref(creds);
grpc_jwt_encode_and_sign_set_override(nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void set_google_default_creds_env_var_with_file_contents(
@@ -897,7 +865,7 @@ static void set_google_default_creds_env_var_with_file_contents(
}
static void test_google_default_creds_auth_key(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_service_account_jwt_access_credentials* jwt;
grpc_composite_channel_credentials* creds;
char* json_key = test_json_key_str();
@@ -913,13 +881,12 @@ static void test_google_default_creds_auth_key(void) {
strcmp(jwt->key.client_id,
"777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent.com") ==
0);
- grpc_channel_credentials_unref(&exec_ctx, &creds->base);
+ grpc_channel_credentials_unref(&creds->base);
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */
- grpc_exec_ctx_finish(&exec_ctx);
}
static void test_google_default_creds_refresh_token(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_google_refresh_token_credentials* refresh;
grpc_composite_channel_credentials* creds;
grpc_flush_cached_google_default_credentials();
@@ -931,15 +898,13 @@ static void test_google_default_creds_refresh_token(void) {
refresh = (grpc_google_refresh_token_credentials*)creds->call_creds;
GPR_ASSERT(strcmp(refresh->refresh_token.client_id,
"32555999999.apps.googleusercontent.com") == 0);
- grpc_channel_credentials_unref(&exec_ctx, &creds->base);
+ grpc_channel_credentials_unref(&creds->base);
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */
- grpc_exec_ctx_finish(&exec_ctx);
}
static int default_creds_gce_detection_httpcli_get_success_override(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- grpc_millis deadline, grpc_closure* on_done,
- grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
*response = http_response(200, "");
grpc_http_header* headers =
static_cast<grpc_http_header*>(gpr_malloc(sizeof(*headers) * 1));
@@ -949,14 +914,14 @@ static int default_creds_gce_detection_httpcli_get_success_override(
response->hdrs = headers;
GPR_ASSERT(strcmp(request->http.path, "/") == 0);
GPR_ASSERT(strcmp(request->host, "metadata.google.internal") == 0);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static char* null_well_known_creds_path_getter(void) { return nullptr; }
static void test_google_default_creds_gce(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
expected_md emd[] = {
{"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}};
request_metadata_state* state =
@@ -981,8 +946,8 @@ static void test_google_default_creds_gce(void) {
GPR_ASSERT(creds->call_creds != nullptr);
grpc_httpcli_set_override(compute_engine_httpcli_get_success_override,
httpcli_post_should_not_be_called);
- run_request_metadata_test(&exec_ctx, creds->call_creds, auth_md_ctx, state);
- grpc_exec_ctx_flush(&exec_ctx);
+ run_request_metadata_test(creds->call_creds, auth_md_ctx, state);
+ grpc_core::ExecCtx::Get()->Flush();
/* Check that we get a cached creds if we call
grpc_google_default_credentials_create again.
@@ -994,22 +959,20 @@ static void test_google_default_creds_gce(void) {
GPR_ASSERT(cached_creds == &creds->base);
/* Cleanup. */
- grpc_channel_credentials_unref(&exec_ctx, cached_creds);
- grpc_channel_credentials_unref(&exec_ctx, &creds->base);
+ grpc_channel_credentials_unref(cached_creds);
+ grpc_channel_credentials_unref(&creds->base);
grpc_httpcli_set_override(nullptr, nullptr);
grpc_override_well_known_credentials_path_getter(nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
}
static int default_creds_gce_detection_httpcli_get_failure_override(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- grpc_millis deadline, grpc_closure* on_done,
- grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
/* No magic header. */
GPR_ASSERT(strcmp(request->http.path, "/") == 0);
GPR_ASSERT(strcmp(request->host, "metadata.google.internal") == 0);
*response = http_response(200, "");
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
@@ -1093,7 +1056,7 @@ static void plugin_destroy(void* state) {
static void test_metadata_plugin_success(void) {
plugin_state state = PLUGIN_INITIAL_STATE;
grpc_metadata_credentials_plugin plugin;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
nullptr, nullptr};
request_metadata_state* md_state = make_request_metadata_state(
@@ -1106,17 +1069,17 @@ static void test_metadata_plugin_success(void) {
grpc_call_credentials* creds =
grpc_metadata_credentials_create_from_plugin(plugin, nullptr);
GPR_ASSERT(state == PLUGIN_INITIAL_STATE);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, md_state);
+ run_request_metadata_test(creds, auth_md_ctx, md_state);
GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE);
- grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_call_credentials_unref(creds);
+
GPR_ASSERT(state == PLUGIN_DESTROY_CALLED_STATE);
}
static void test_metadata_plugin_failure(void) {
plugin_state state = PLUGIN_INITIAL_STATE;
grpc_metadata_credentials_plugin plugin;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method,
nullptr, nullptr};
char* expected_error;
@@ -1134,10 +1097,10 @@ static void test_metadata_plugin_failure(void) {
grpc_call_credentials* creds =
grpc_metadata_credentials_create_from_plugin(plugin, nullptr);
GPR_ASSERT(state == PLUGIN_INITIAL_STATE);
- run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, md_state);
+ run_request_metadata_test(creds, auth_md_ctx, md_state);
GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE);
- grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_call_credentials_unref(creds);
+
GPR_ASSERT(state == PLUGIN_DESTROY_CALLED_STATE);
}
@@ -1158,7 +1121,7 @@ static void test_get_well_known_google_credentials_file_path(void) {
}
static void test_channel_creds_duplicate_without_call_creds(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_channel_credentials* channel_creds =
grpc_fake_transport_security_credentials_create();
@@ -1167,23 +1130,21 @@ static void test_channel_creds_duplicate_without_call_creds(void) {
grpc_channel_credentials_duplicate_without_call_credentials(
channel_creds);
GPR_ASSERT(dup == channel_creds);
- grpc_channel_credentials_unref(&exec_ctx, dup);
+ grpc_channel_credentials_unref(dup);
grpc_call_credentials* call_creds =
grpc_access_token_credentials_create("blah", nullptr);
grpc_channel_credentials* composite_creds =
grpc_composite_channel_credentials_create(channel_creds, call_creds,
nullptr);
- grpc_call_credentials_unref(&exec_ctx, call_creds);
+ grpc_call_credentials_unref(call_creds);
dup = grpc_channel_credentials_duplicate_without_call_credentials(
composite_creds);
GPR_ASSERT(dup == channel_creds);
- grpc_channel_credentials_unref(&exec_ctx, dup);
-
- grpc_channel_credentials_unref(&exec_ctx, channel_creds);
- grpc_channel_credentials_unref(&exec_ctx, composite_creds);
+ grpc_channel_credentials_unref(dup);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_credentials_unref(channel_creds);
+ grpc_channel_credentials_unref(composite_creds);
}
typedef struct {
diff --git a/test/core/security/json_token_test.cc b/test/core/security/json_token_test.cc
index 0b6ccd5e37..b717de06d9 100644
--- a/test/core/security/json_token_test.cc
+++ b/test/core/security/json_token_test.cc
@@ -207,7 +207,7 @@ static void test_parse_json_key_failure_no_private_key(void) {
static grpc_json* parse_json_part_from_jwt(const char* str, size_t len,
char** scratchpad) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
char* b64;
char* decoded;
grpc_json* json;
@@ -215,7 +215,7 @@ static grpc_json* parse_json_part_from_jwt(const char* str, size_t len,
b64 = static_cast<char*>(gpr_malloc(len + 1));
strncpy(b64, str, len);
b64[len] = '\0';
- slice = grpc_base64_decode(&exec_ctx, b64, 1);
+ slice = grpc_base64_decode(b64, 1);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(slice));
decoded = static_cast<char*>(gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1));
strncpy(decoded, (const char*)GRPC_SLICE_START_PTR(slice),
@@ -225,7 +225,7 @@ static grpc_json* parse_json_part_from_jwt(const char* str, size_t len,
gpr_free(b64);
*scratchpad = decoded;
grpc_slice_unref(slice);
- grpc_exec_ctx_finish(&exec_ctx);
+
return json;
}
@@ -327,12 +327,12 @@ static void check_jwt_claim(grpc_json* claim, const char* expected_audience,
static void check_jwt_signature(const char* b64_signature, RSA* rsa_key,
const char* signed_data,
size_t signed_data_size) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
EVP_MD_CTX* md_ctx = EVP_MD_CTX_create();
EVP_PKEY* key = EVP_PKEY_new();
- grpc_slice sig = grpc_base64_decode(&exec_ctx, b64_signature, 1);
+ grpc_slice sig = grpc_base64_decode(b64_signature, 1);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(sig));
GPR_ASSERT(GRPC_SLICE_LENGTH(sig) == 128);
@@ -347,11 +347,9 @@ static void check_jwt_signature(const char* b64_signature, RSA* rsa_key,
GPR_ASSERT(EVP_DigestVerifyFinal(md_ctx, GRPC_SLICE_START_PTR(sig),
GRPC_SLICE_LENGTH(sig)) == 1);
- grpc_slice_unref_internal(&exec_ctx, sig);
+ grpc_slice_unref_internal(sig);
if (key != nullptr) EVP_PKEY_free(key);
if (md_ctx != nullptr) EVP_MD_CTX_destroy(md_ctx);
-
- grpc_exec_ctx_finish(&exec_ctx);
}
static char* service_account_creds_jwt_encode_and_sign(
diff --git a/test/core/security/jwt_verifier_test.cc b/test/core/security/jwt_verifier_test.cc
index df0ebe5607..dd798ec1d1 100644
--- a/test/core/security/jwt_verifier_test.cc
+++ b/test/core/security/jwt_verifier_test.cc
@@ -209,8 +209,8 @@ static void test_claims_success(void) {
grpc_json* json = grpc_json_parse_string_with_len(
(char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
GPR_ASSERT(json != nullptr);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
+ grpc_core::ExecCtx _local_exec_ctx;
+ claims = grpc_jwt_claims_from_json(json, s);
GPR_ASSERT(claims != nullptr);
GPR_ASSERT(grpc_jwt_claims_json(claims) == json);
GPR_ASSERT(strcmp(grpc_jwt_claims_audience(claims), "https://foo.com") == 0);
@@ -219,8 +219,7 @@ static void test_claims_success(void) {
GPR_ASSERT(strcmp(grpc_jwt_claims_id(claims), "jwtuniqueid") == 0);
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://foo.com") ==
GRPC_JWT_VERIFIER_OK);
- grpc_jwt_claims_destroy(&exec_ctx, claims);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_claims_destroy(claims);
}
static void test_expired_claims_failure(void) {
@@ -232,8 +231,8 @@ static void test_expired_claims_failure(void) {
gpr_timespec exp_exp = {120, 0, GPR_CLOCK_REALTIME};
gpr_timespec exp_nbf = {60, 0, GPR_CLOCK_REALTIME};
GPR_ASSERT(json != nullptr);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
+ grpc_core::ExecCtx _local_exec_ctx;
+ claims = grpc_jwt_claims_from_json(json, s);
GPR_ASSERT(claims != nullptr);
GPR_ASSERT(grpc_jwt_claims_json(claims) == json);
GPR_ASSERT(strcmp(grpc_jwt_claims_audience(claims), "https://foo.com") == 0);
@@ -246,17 +245,15 @@ static void test_expired_claims_failure(void) {
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://foo.com") ==
GRPC_JWT_VERIFIER_TIME_CONSTRAINT_FAILURE);
- grpc_jwt_claims_destroy(&exec_ctx, claims);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_claims_destroy(claims);
}
static void test_invalid_claims_failure(void) {
grpc_slice s = grpc_slice_from_copied_string(invalid_claims);
grpc_json* json = grpc_json_parse_string_with_len(
(char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(grpc_jwt_claims_from_json(&exec_ctx, json, s) == nullptr);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GPR_ASSERT(grpc_jwt_claims_from_json(json, s) == nullptr);
}
static void test_bad_audience_claims_failure(void) {
@@ -265,13 +262,12 @@ static void test_bad_audience_claims_failure(void) {
grpc_json* json = grpc_json_parse_string_with_len(
(char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
GPR_ASSERT(json != nullptr);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
+ grpc_core::ExecCtx _local_exec_ctx;
+ claims = grpc_jwt_claims_from_json(json, s);
GPR_ASSERT(claims != nullptr);
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://bar.com") ==
GRPC_JWT_VERIFIER_BAD_AUDIENCE);
- grpc_jwt_claims_destroy(&exec_ctx, claims);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_claims_destroy(claims);
}
static void test_bad_subject_claims_failure(void) {
@@ -280,13 +276,12 @@ static void test_bad_subject_claims_failure(void) {
grpc_json* json = grpc_json_parse_string_with_len(
(char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
GPR_ASSERT(json != nullptr);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
+ grpc_core::ExecCtx _local_exec_ctx;
+ claims = grpc_jwt_claims_from_json(json, s);
GPR_ASSERT(claims != nullptr);
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://foo.com") ==
GRPC_JWT_VERIFIER_BAD_SUBJECT);
- grpc_jwt_claims_destroy(&exec_ctx, claims);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_claims_destroy(claims);
}
static char* json_key_str(const char* last_part) {
@@ -323,17 +318,16 @@ static grpc_httpcli_response http_response(int status, char* body) {
}
static int httpcli_post_should_not_be_called(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- const char* body_bytes, size_t body_size, grpc_millis deadline,
- grpc_closure* on_done, grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, const char* body_bytes,
+ size_t body_size, grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
GPR_ASSERT("HTTP POST should not be called" == nullptr);
return 1;
}
static int httpcli_get_google_keys_for_email(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- grpc_millis deadline, grpc_closure* on_done,
- grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
*response = http_response(200, good_google_email_keys());
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
GPR_ASSERT(strcmp(request->host, "www.googleapis.com") == 0);
@@ -341,22 +335,22 @@ static int httpcli_get_google_keys_for_email(
"/robot/v1/metadata/x509/"
"777-abaslkan11hlb6nmim3bpspl31ud@developer."
"gserviceaccount.com") == 0);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
-static void on_verification_success(grpc_exec_ctx* exec_ctx, void* user_data,
+static void on_verification_success(void* user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_OK);
GPR_ASSERT(claims != nullptr);
GPR_ASSERT(user_data == (void*)expected_user_data);
GPR_ASSERT(strcmp(grpc_jwt_claims_audience(claims), expected_audience) == 0);
- grpc_jwt_claims_destroy(exec_ctx, claims);
+ grpc_jwt_claims_destroy(claims);
}
static void test_jwt_verifier_google_email_issuer_success(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
char* jwt = nullptr;
char* key_str = json_key_str(json_key_str_part3_for_google_email_issuer);
@@ -369,28 +363,27 @@ static void test_jwt_verifier_google_email_issuer_success(void) {
nullptr);
grpc_auth_json_key_destruct(&key);
GPR_ASSERT(jwt != nullptr);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
+ grpc_jwt_verifier_verify(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);
+ grpc_jwt_verifier_destroy(verifier);
+
gpr_free(jwt);
grpc_httpcli_set_override(nullptr, nullptr);
}
static int httpcli_get_custom_keys_for_email(
- grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
- grpc_millis deadline, grpc_closure* on_done,
- grpc_httpcli_response* response) {
+ const grpc_httpcli_request* request, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
*response = http_response(200, gpr_strdup(good_jwk_set));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
GPR_ASSERT(strcmp(request->host, "keys.bar.com") == 0);
GPR_ASSERT(strcmp(request->http.path, "/jwk/foo@bar.com") == 0);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static void test_jwt_verifier_custom_email_issuer_success(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(&custom_mapping, 1);
char* jwt = nullptr;
char* key_str = json_key_str(json_key_str_part3_for_custom_email_issuer);
@@ -403,28 +396,26 @@ static void test_jwt_verifier_custom_email_issuer_success(void) {
nullptr);
grpc_auth_json_key_destruct(&key);
GPR_ASSERT(jwt != nullptr);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
+ grpc_jwt_verifier_verify(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);
+ grpc_jwt_verifier_destroy(verifier);
+
gpr_free(jwt);
grpc_httpcli_set_override(nullptr, nullptr);
}
-static int httpcli_get_jwk_set(grpc_exec_ctx* exec_ctx,
- const grpc_httpcli_request* request,
+static int httpcli_get_jwk_set(const grpc_httpcli_request* request,
grpc_millis deadline, grpc_closure* on_done,
grpc_httpcli_response* response) {
*response = http_response(200, gpr_strdup(good_jwk_set));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
GPR_ASSERT(strcmp(request->host, "www.googleapis.com") == 0);
GPR_ASSERT(strcmp(request->http.path, "/oauth2/v3/certs") == 0);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
-static int httpcli_get_openid_config(grpc_exec_ctx* exec_ctx,
- const grpc_httpcli_request* request,
+static int httpcli_get_openid_config(const grpc_httpcli_request* request,
grpc_millis deadline,
grpc_closure* on_done,
grpc_httpcli_response* response) {
@@ -434,12 +425,12 @@ static int httpcli_get_openid_config(grpc_exec_ctx* exec_ctx,
GPR_ASSERT(strcmp(request->http.path, GRPC_OPENID_CONFIG_URL_SUFFIX) == 0);
grpc_httpcli_set_override(httpcli_get_jwk_set,
httpcli_post_should_not_be_called);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static void test_jwt_verifier_url_issuer_success(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
char* jwt = nullptr;
char* key_str = json_key_str(json_key_str_part3_for_url_issuer);
@@ -452,16 +443,15 @@ static void test_jwt_verifier_url_issuer_success(void) {
nullptr);
grpc_auth_json_key_destruct(&key);
GPR_ASSERT(jwt != nullptr);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
+ grpc_jwt_verifier_verify(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);
+ grpc_jwt_verifier_destroy(verifier);
+
gpr_free(jwt);
grpc_httpcli_set_override(nullptr, nullptr);
}
-static void on_verification_key_retrieval_error(grpc_exec_ctx* exec_ctx,
- void* user_data,
+static void on_verification_key_retrieval_error(void* user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR);
@@ -469,18 +459,17 @@ static void on_verification_key_retrieval_error(grpc_exec_ctx* exec_ctx,
GPR_ASSERT(user_data == (void*)expected_user_data);
}
-static int httpcli_get_bad_json(grpc_exec_ctx* exec_ctx,
- const grpc_httpcli_request* request,
+static int httpcli_get_bad_json(const grpc_httpcli_request* request,
grpc_millis deadline, grpc_closure* on_done,
grpc_httpcli_response* response) {
*response = http_response(200, gpr_strdup("{\"bad\": \"stuff\"}"));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_done, GRPC_ERROR_NONE);
return 1;
}
static void test_jwt_verifier_url_issuer_bad_config(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
char* jwt = nullptr;
char* key_str = json_key_str(json_key_str_part3_for_url_issuer);
@@ -493,17 +482,17 @@ static void test_jwt_verifier_url_issuer_bad_config(void) {
nullptr);
grpc_auth_json_key_destruct(&key);
GPR_ASSERT(jwt != nullptr);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
+ grpc_jwt_verifier_verify(verifier, nullptr, jwt, expected_audience,
on_verification_key_retrieval_error,
(void*)expected_user_data);
- grpc_jwt_verifier_destroy(&exec_ctx, verifier);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_verifier_destroy(verifier);
+
gpr_free(jwt);
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_core::ExecCtx _local_exec_ctx;
grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
char* jwt = nullptr;
char* key_str = json_key_str(json_key_str_part3_for_google_email_issuer);
@@ -516,11 +505,11 @@ static void test_jwt_verifier_bad_json_key(void) {
nullptr);
grpc_auth_json_key_destruct(&key);
GPR_ASSERT(jwt != nullptr);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
+ grpc_jwt_verifier_verify(verifier, nullptr, jwt, expected_audience,
on_verification_key_retrieval_error,
(void*)expected_user_data);
- grpc_jwt_verifier_destroy(&exec_ctx, verifier);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_verifier_destroy(verifier);
+
gpr_free(jwt);
grpc_httpcli_set_override(nullptr, nullptr);
}
@@ -532,9 +521,8 @@ static void corrupt_jwt_sig(char* jwt) {
char* last_dot = strrchr(jwt, '.');
GPR_ASSERT(last_dot != nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- sig = grpc_base64_decode(&exec_ctx, last_dot + 1, 1);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ sig = grpc_base64_decode(last_dot + 1, 1);
}
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(sig));
sig_bytes = GRPC_SLICE_START_PTR(sig);
@@ -546,8 +534,7 @@ static void corrupt_jwt_sig(char* jwt) {
grpc_slice_unref(sig);
}
-static void on_verification_bad_signature(grpc_exec_ctx* exec_ctx,
- void* user_data,
+static void on_verification_bad_signature(void* user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_BAD_SIGNATURE);
@@ -556,7 +543,7 @@ static void on_verification_bad_signature(grpc_exec_ctx* exec_ctx,
}
static void test_jwt_verifier_bad_signature(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
char* jwt = nullptr;
char* key_str = json_key_str(json_key_str_part3_for_url_issuer);
@@ -570,17 +557,16 @@ static void test_jwt_verifier_bad_signature(void) {
grpc_auth_json_key_destruct(&key);
corrupt_jwt_sig(jwt);
GPR_ASSERT(jwt != nullptr);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
+ grpc_jwt_verifier_verify(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_jwt_verifier_destroy(verifier);
+
grpc_httpcli_set_override(nullptr, nullptr);
}
-static int httpcli_get_should_not_be_called(grpc_exec_ctx* exec_ctx,
- const grpc_httpcli_request* request,
+static int httpcli_get_should_not_be_called(const grpc_httpcli_request* request,
grpc_millis deadline,
grpc_closure* on_done,
grpc_httpcli_response* response) {
@@ -588,7 +574,7 @@ static int httpcli_get_should_not_be_called(grpc_exec_ctx* exec_ctx,
return 1;
}
-static void on_verification_bad_format(grpc_exec_ctx* exec_ctx, void* user_data,
+static void on_verification_bad_format(void* user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_BAD_FORMAT);
@@ -597,15 +583,15 @@ static void on_verification_bad_format(grpc_exec_ctx* exec_ctx, void* user_data,
}
static void test_jwt_verifier_bad_format(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
httpcli_post_should_not_be_called);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, "bad jwt",
- expected_audience, on_verification_bad_format,
+ grpc_jwt_verifier_verify(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_jwt_verifier_destroy(verifier);
+
grpc_httpcli_set_override(nullptr, nullptr);
}
diff --git a/test/core/security/oauth2_utils.cc b/test/core/security/oauth2_utils.cc
index 602041eecc..7551d7df85 100644
--- a/test/core/security/oauth2_utils.cc
+++ b/test/core/security/oauth2_utils.cc
@@ -39,8 +39,7 @@ typedef struct {
grpc_closure closure;
} oauth2_request;
-static void on_oauth2_response(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_oauth2_response(void* arg, grpc_error* error) {
oauth2_request* request = (oauth2_request*)arg;
char* token = nullptr;
grpc_slice token_slice;
@@ -54,25 +53,23 @@ static void on_oauth2_response(grpc_exec_ctx* exec_ctx, void* arg,
GRPC_SLICE_LENGTH(token_slice));
token[GRPC_SLICE_LENGTH(token_slice)] = '\0';
}
- grpc_credentials_mdelem_array_destroy(exec_ctx, &request->md_array);
+ grpc_credentials_mdelem_array_destroy(&request->md_array);
gpr_mu_lock(request->mu);
request->is_done = true;
request->token = token;
GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&request->pops),
- nullptr));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&request->pops), nullptr));
gpr_mu_unlock(request->mu);
}
-static void do_nothing(grpc_exec_ctx* exec_ctx, void* unused,
- grpc_error* error) {}
+static void do_nothing(void* unused, grpc_error* error) {}
char* grpc_test_fetch_oauth2_token_with_credentials(
grpc_call_credentials* creds) {
oauth2_request request;
memset(&request, 0, sizeof(request));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_closure do_nothing_closure;
grpc_auth_metadata_context null_ctx = {"", "", nullptr, nullptr};
@@ -88,31 +85,30 @@ char* grpc_test_fetch_oauth2_token_with_credentials(
grpc_schedule_on_exec_ctx);
grpc_error* error = GRPC_ERROR_NONE;
- if (grpc_call_credentials_get_request_metadata(
- &exec_ctx, creds, &request.pops, null_ctx, &request.md_array,
- &request.closure, &error)) {
+ if (grpc_call_credentials_get_request_metadata(creds, &request.pops, null_ctx,
+ &request.md_array,
+ &request.closure, &error)) {
// Synchronous result; invoke callback directly.
- on_oauth2_response(&exec_ctx, &request, error);
+ on_oauth2_response(&request, error);
GRPC_ERROR_UNREF(error);
}
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(request.mu);
while (!request.is_done) {
grpc_pollset_worker* worker = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx,
- grpc_polling_entity_pollset(&request.pops),
+ grpc_pollset_work(grpc_polling_entity_pollset(&request.pops),
&worker, GRPC_MILLIS_INF_FUTURE))) {
request.is_done = true;
}
}
gpr_mu_unlock(request.mu);
- grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&request.pops),
+ grpc_pollset_shutdown(grpc_polling_entity_pollset(&request.pops),
&do_nothing_closure);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_free(grpc_polling_entity_pollset(&request.pops));
return request.token;
}
diff --git a/test/core/security/print_google_default_creds_token.cc b/test/core/security/print_google_default_creds_token.cc
index f4acf023bd..7089b9808a 100644
--- a/test/core/security/print_google_default_creds_token.cc
+++ b/test/core/security/print_google_default_creds_token.cc
@@ -41,8 +41,7 @@ typedef struct {
grpc_closure on_request_metadata;
} synchronizer;
-static void on_metadata_response(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_metadata_response(void* arg, grpc_error* error) {
synchronizer* sync = static_cast<synchronizer*>(arg);
if (error != GRPC_ERROR_NONE) {
fprintf(stderr, "Fetching token failed: %s\n", grpc_error_string(error));
@@ -57,14 +56,13 @@ static void on_metadata_response(grpc_exec_ctx* exec_ctx, void* arg,
sync->is_done = true;
GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&sync->pops),
- nullptr));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&sync->pops), nullptr));
gpr_mu_unlock(sync->mu);
}
int main(int argc, char** argv) {
int result = 0;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
synchronizer sync;
grpc_channel_credentials* creds = nullptr;
const char* service_url = "https://test.foo.google.com/Foo";
@@ -97,11 +95,10 @@ int main(int argc, char** argv) {
error = GRPC_ERROR_NONE;
if (grpc_call_credentials_get_request_metadata(
- &exec_ctx, ((grpc_composite_channel_credentials*)creds)->call_creds,
- &sync.pops, context, &sync.md_array, &sync.on_request_metadata,
- &error)) {
+ ((grpc_composite_channel_credentials*)creds)->call_creds, &sync.pops,
+ context, &sync.md_array, &sync.on_request_metadata, &error)) {
// Synchronous response. Invoke callback directly.
- on_metadata_response(&exec_ctx, &sync, error);
+ on_metadata_response(&sync, error);
GRPC_ERROR_UNREF(error);
}
@@ -110,18 +107,15 @@ int main(int argc, char** argv) {
grpc_pollset_worker* worker = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx,
- grpc_polling_entity_pollset(&sync.pops), &worker,
+ grpc_pollset_work(grpc_polling_entity_pollset(&sync.pops), &worker,
GRPC_MILLIS_INF_FUTURE)))
sync.is_done = true;
gpr_mu_unlock(sync.mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(sync.mu);
}
gpr_mu_unlock(sync.mu);
- grpc_exec_ctx_finish(&exec_ctx);
-
grpc_channel_credentials_release(creds);
gpr_free(grpc_polling_entity_pollset(&sync.pops));
diff --git a/test/core/security/secure_endpoint_test.cc b/test/core/security/secure_endpoint_test.cc
index a12af02479..14ca0a8927 100644
--- a/test/core/security/secure_endpoint_test.cc
+++ b/test/core/security/secure_endpoint_test.cc
@@ -38,7 +38,7 @@ static grpc_pollset* g_pollset;
static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
size_t slice_size, grpc_slice* leftover_slices, size_t leftover_nslices,
bool use_zero_copy_protector) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
tsi_frame_protector* fake_read_protector =
tsi_create_fake_frame_protector(nullptr);
tsi_frame_protector* fake_write_protector =
@@ -60,8 +60,8 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
a[0].value.integer = (int)slice_size;
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
tcp = grpc_iomgr_create_endpoint_pair("fixture", &args);
- grpc_endpoint_add_to_pollset(&exec_ctx, tcp.client, g_pollset);
- grpc_endpoint_add_to_pollset(&exec_ctx, tcp.server, g_pollset);
+ grpc_endpoint_add_to_pollset(tcp.client, g_pollset);
+ grpc_endpoint_add_to_pollset(tcp.server, g_pollset);
if (leftover_nslices == 0) {
f.client_ep = grpc_secure_endpoint_create(fake_read_protector,
@@ -117,7 +117,7 @@ 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, nullptr, 0);
- grpc_exec_ctx_finish(&exec_ctx);
+
return f;
}
@@ -165,52 +165,46 @@ static grpc_endpoint_test_config configs[] = {
clean_up},
};
-static void inc_call_ctr(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
- ++*(int*)arg;
-}
+static void inc_call_ctr(void* arg, grpc_error* error) { ++*(int*)arg; }
static void test_leftover(grpc_endpoint_test_config config, size_t slice_size) {
grpc_endpoint_test_fixture f = config.create_fixture(slice_size);
grpc_slice_buffer incoming;
grpc_slice s =
grpc_slice_from_copied_string("hello world 12345678900987654321");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
int n = 0;
grpc_closure done_closure;
gpr_log(GPR_INFO, "Start test left over");
grpc_slice_buffer_init(&incoming);
GRPC_CLOSURE_INIT(&done_closure, inc_call_ctr, &n, grpc_schedule_on_exec_ctx);
- grpc_endpoint_read(&exec_ctx, f.client_ep, &incoming, &done_closure);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_endpoint_read(f.client_ep, &incoming, &done_closure);
+
GPR_ASSERT(n == 1);
GPR_ASSERT(incoming.count == 1);
GPR_ASSERT(grpc_slice_eq(s, incoming.slices[0]));
grpc_endpoint_shutdown(
- &exec_ctx, f.client_ep,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_leftover end"));
+ f.client_ep, GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_leftover end"));
grpc_endpoint_shutdown(
- &exec_ctx, f.server_ep,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_leftover end"));
- grpc_endpoint_destroy(&exec_ctx, f.client_ep);
- grpc_endpoint_destroy(&exec_ctx, f.server_ep);
- grpc_exec_ctx_finish(&exec_ctx);
- grpc_slice_unref_internal(&exec_ctx, s);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &incoming);
+ f.server_ep, GRPC_ERROR_CREATE_FROM_STATIC_STRING("test_leftover end"));
+ grpc_endpoint_destroy(f.client_ep);
+ grpc_endpoint_destroy(f.server_ep);
+
+ grpc_slice_unref_internal(s);
+ grpc_slice_buffer_destroy_internal(&incoming);
clean_up();
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, (grpc_pollset*)p);
+static void destroy_pollset(void* p, grpc_error* error) {
+ grpc_pollset_destroy((grpc_pollset*)p);
}
int main(int argc, char** argv) {
grpc_closure destroyed;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_test_init(argc, argv);
grpc_init();
@@ -222,8 +216,8 @@ int main(int argc, char** argv) {
test_leftover(configs[3], 1);
GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_pollset_shutdown(g_pollset, &destroyed);
+
grpc_shutdown();
gpr_free(g_pollset);
diff --git a/test/core/security/ssl_server_fuzzer.cc b/test/core/security/ssl_server_fuzzer.cc
index bbb2f6013e..df62dc17b8 100644
--- a/test/core/security/ssl_server_fuzzer.cc
+++ b/test/core/security/ssl_server_fuzzer.cc
@@ -40,8 +40,7 @@ struct handshake_state {
bool done_callback_called;
};
-static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_handshake_done(void* arg, grpc_error* error) {
grpc_handshaker_args* args = static_cast<grpc_handshaker_args*>(arg);
struct handshake_state* state =
static_cast<struct handshake_state*>(args->user_data);
@@ -56,17 +55,16 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (squelch) gpr_set_log_function(dont_log);
if (leak_check) grpc_memory_counters_init();
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("ssl_server_fuzzer");
grpc_endpoint* mock_endpoint =
grpc_mock_endpoint_create(discard_write, resource_quota);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
grpc_mock_endpoint_put_read(
- &exec_ctx, mock_endpoint,
- grpc_slice_from_copied_buffer((const char*)data, size));
+ mock_endpoint, grpc_slice_from_copied_buffer((const char*)data, size));
// Load key pair and establish server SSL credentials.
grpc_ssl_pem_key_cert_pair pem_key_cert_pair;
@@ -83,38 +81,37 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// Create security connector
grpc_server_security_connector* sc = nullptr;
grpc_security_status status =
- grpc_server_credentials_create_security_connector(&exec_ctx, creds, &sc);
+ grpc_server_credentials_create_security_connector(creds, &sc);
GPR_ASSERT(status == GRPC_SECURITY_OK);
- grpc_millis deadline = GPR_MS_PER_SEC + grpc_exec_ctx_now(&exec_ctx);
+ grpc_millis deadline = GPR_MS_PER_SEC + grpc_core::ExecCtx::Get()->Now();
struct handshake_state state;
state.done_callback_called = false;
grpc_handshake_manager* handshake_mgr = grpc_handshake_manager_create();
- grpc_server_security_connector_add_handshakers(&exec_ctx, sc, handshake_mgr);
+ grpc_server_security_connector_add_handshakers(sc, handshake_mgr);
grpc_handshake_manager_do_handshake(
- &exec_ctx, handshake_mgr, mock_endpoint, nullptr /* channel_args */,
- deadline, nullptr /* acceptor */, on_handshake_done, &state);
- grpc_exec_ctx_flush(&exec_ctx);
+ handshake_mgr, mock_endpoint, nullptr /* channel_args */, deadline,
+ nullptr /* acceptor */, on_handshake_done, &state);
+ grpc_core::ExecCtx::Get()->Flush();
// If the given string happens to be part of the correct client hello, the
// server will wait for more data. Explicitly fail the server by shutting down
// the endpoint.
if (!state.done_callback_called) {
grpc_endpoint_shutdown(
- &exec_ctx, mock_endpoint,
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Explicit close"));
- grpc_exec_ctx_flush(&exec_ctx);
+ mock_endpoint, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Explicit close"));
+ grpc_core::ExecCtx::Get()->Flush();
}
GPR_ASSERT(state.done_callback_called);
- grpc_handshake_manager_destroy(&exec_ctx, handshake_mgr);
- GRPC_SECURITY_CONNECTOR_UNREF(&exec_ctx, &sc->base, "test");
+ grpc_handshake_manager_destroy(handshake_mgr);
+ GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "test");
grpc_server_credentials_release(creds);
grpc_slice_unref(cert_slice);
grpc_slice_unref(key_slice);
grpc_slice_unref(ca_slice);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
grpc_shutdown();
if (leak_check) {
diff --git a/test/core/security/verify_jwt.cc b/test/core/security/verify_jwt.cc
index 787d58bc37..1bd92bbc97 100644
--- a/test/core/security/verify_jwt.cc
+++ b/test/core/security/verify_jwt.cc
@@ -44,7 +44,7 @@ static void print_usage_and_exit(gpr_cmdline* cl, const char* argv0) {
exit(1);
}
-static void on_jwt_verification_done(grpc_exec_ctx* exec_ctx, void* user_data,
+static void on_jwt_verification_done(void* user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims) {
synchronizer* sync = static_cast<synchronizer*>(user_data);
@@ -57,7 +57,7 @@ static void on_jwt_verification_done(grpc_exec_ctx* exec_ctx, void* user_data,
grpc_json_dump_to_string((grpc_json*)grpc_jwt_claims_json(claims), 2);
printf("Claims: \n\n%s\n", claims_str);
gpr_free(claims_str);
- grpc_jwt_claims_destroy(exec_ctx, claims);
+ grpc_jwt_claims_destroy(claims);
} else {
GPR_ASSERT(claims == nullptr);
fprintf(stderr, "Verification failed with error %s\n",
@@ -66,8 +66,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, nullptr));
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(sync->pollset, nullptr));
gpr_mu_unlock(sync->mu);
}
@@ -77,7 +76,7 @@ int main(int argc, char** argv) {
gpr_cmdline* cl;
const char* jwt = nullptr;
const char* aud = nullptr;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_init();
cl = gpr_cmdline_create("JWT verifier tool");
@@ -96,26 +95,26 @@ int main(int argc, char** argv) {
grpc_pollset_init(sync.pollset, &sync.mu);
sync.is_done = 0;
- grpc_jwt_verifier_verify(&exec_ctx, verifier, sync.pollset, jwt, aud,
+ grpc_jwt_verifier_verify(verifier, sync.pollset, jwt, aud,
on_jwt_verification_done, &sync);
gpr_mu_lock(sync.mu);
while (!sync.is_done) {
grpc_pollset_worker* worker = nullptr;
- if (!GRPC_LOG_IF_ERROR("pollset_work",
- grpc_pollset_work(&exec_ctx, sync.pollset, &worker,
- GRPC_MILLIS_INF_FUTURE)))
+ if (!GRPC_LOG_IF_ERROR(
+ "pollset_work",
+ grpc_pollset_work(sync.pollset, &worker, GRPC_MILLIS_INF_FUTURE)))
sync.is_done = true;
gpr_mu_unlock(sync.mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(sync.mu);
}
gpr_mu_unlock(sync.mu);
gpr_free(sync.pollset);
- grpc_jwt_verifier_destroy(&exec_ctx, verifier);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_jwt_verifier_destroy(verifier);
+
gpr_cmdline_destroy(cl);
grpc_shutdown();
return !sync.success;
diff --git a/test/core/slice/b64_test.cc b/test/core/slice/b64_test.cc
index 479198f9f9..08a5770b2a 100644
--- a/test/core/slice/b64_test.cc
+++ b/test/core/slice/b64_test.cc
@@ -44,14 +44,14 @@ static void test_simple_encode_decode_b64(int url_safe, int multiline) {
const char* hello = "hello";
char* hello_b64 =
grpc_base64_encode(hello, strlen(hello), url_safe, multiline);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice hello_slice = grpc_base64_decode(&exec_ctx, hello_b64, url_safe);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_slice hello_slice = grpc_base64_decode(hello_b64, url_safe);
GPR_ASSERT(GRPC_SLICE_LENGTH(hello_slice) == strlen(hello));
GPR_ASSERT(strncmp((const char*)GRPC_SLICE_START_PTR(hello_slice), hello,
GRPC_SLICE_LENGTH(hello_slice)) == 0);
- grpc_slice_unref_internal(&exec_ctx, hello_slice);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(hello_slice);
+
gpr_free(hello_b64);
}
@@ -64,15 +64,14 @@ static void test_full_range_encode_decode_b64(int url_safe, int multiline) {
/* Try all the different paddings. */
for (i = 0; i < 3; i++) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
b64 = grpc_base64_encode(orig, sizeof(orig) - i, url_safe, multiline);
- orig_decoded = grpc_base64_decode(&exec_ctx, b64, url_safe);
+ orig_decoded = grpc_base64_decode(b64, url_safe);
GPR_ASSERT(GRPC_SLICE_LENGTH(orig_decoded) == (sizeof(orig) - i));
GPR_ASSERT(buffers_are_equal(orig, GRPC_SLICE_START_PTR(orig_decoded),
sizeof(orig) - i));
- grpc_slice_unref_internal(&exec_ctx, orig_decoded);
+ grpc_slice_unref_internal(orig_decoded);
gpr_free(b64);
- grpc_exec_ctx_finish(&exec_ctx);
}
}
@@ -116,19 +115,18 @@ static void test_url_safe_unsafe_mismatch_failure(void) {
int url_safe = 1;
for (i = 0; i < sizeof(orig); i++) orig[i] = (uint8_t)i;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
b64 = grpc_base64_encode(orig, sizeof(orig), url_safe, 0);
- orig_decoded = grpc_base64_decode(&exec_ctx, b64, !url_safe);
+ orig_decoded = grpc_base64_decode(b64, !url_safe);
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded));
gpr_free(b64);
- grpc_slice_unref_internal(&exec_ctx, orig_decoded);
+ grpc_slice_unref_internal(orig_decoded);
b64 = grpc_base64_encode(orig, sizeof(orig), !url_safe, 0);
- orig_decoded = grpc_base64_decode(&exec_ctx, b64, url_safe);
+ orig_decoded = grpc_base64_decode(b64, url_safe);
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded));
gpr_free(b64);
- grpc_slice_unref_internal(&exec_ctx, orig_decoded);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_slice_unref_internal(orig_decoded);
}
static void test_rfc4648_test_vectors(void) {
@@ -166,40 +164,39 @@ static void test_rfc4648_test_vectors(void) {
static void test_unpadded_decode(void) {
grpc_slice decoded;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- decoded = grpc_base64_decode(&exec_ctx, "Zm9vYmFy", 0);
+ grpc_core::ExecCtx _local_exec_ctx;
+ decoded = grpc_base64_decode("Zm9vYmFy", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "foobar") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zm9vYmE", 0);
+ decoded = grpc_base64_decode("Zm9vYmE", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "fooba") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zm9vYg", 0);
+ decoded = grpc_base64_decode("Zm9vYg", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "foob") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zm9v", 0);
+ decoded = grpc_base64_decode("Zm9v", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "foo") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zm8", 0);
+ decoded = grpc_base64_decode("Zm8", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "fo") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "Zg", 0);
+ decoded = grpc_base64_decode("Zg", 0);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "f") == 0);
grpc_slice_unref(decoded);
- decoded = grpc_base64_decode(&exec_ctx, "", 0);
+ decoded = grpc_base64_decode("", 0);
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(decoded));
- grpc_exec_ctx_finish(&exec_ctx);
}
int main(int argc, char** argv) {
diff --git a/test/core/slice/slice_hash_table_test.cc b/test/core/slice/slice_hash_table_test.cc
index 0ee4e8617d..26c2938782 100644
--- a/test/core/slice/slice_hash_table_test.cc
+++ b/test/core/slice/slice_hash_table_test.cc
@@ -59,9 +59,7 @@ static void check_non_existent_value(const char* key_string,
grpc_slice_unref(key);
}
-static void destroy_string(grpc_exec_ctx* exec_ctx, void* value) {
- gpr_free(value);
-}
+static void destroy_string(void* value) { gpr_free(value); }
static grpc_slice_hash_table* create_table_from_entries(
const test_entry* test_entries, size_t num_test_entries,
@@ -121,9 +119,8 @@ static void test_slice_hash_table() {
check_values(test_entries, num_entries, table);
check_non_existent_value("XX", table);
// Clean up.
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_hash_table_unref(&exec_ctx, table);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_slice_hash_table_unref(table);
}
static int value_cmp_fn(void* a, void* b) {
@@ -149,10 +146,9 @@ static void test_slice_hash_table_eq() {
create_table_from_entries(test_entries_b, num_entries_b, value_cmp_fn);
GPR_ASSERT(grpc_slice_hash_table_cmp(table_a, table_b) == 0);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_hash_table_unref(&exec_ctx, table_a);
- grpc_slice_hash_table_unref(&exec_ctx, table_b);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_slice_hash_table_unref(table_a);
+ grpc_slice_hash_table_unref(table_b);
}
static void test_slice_hash_table_not_eq() {
@@ -221,17 +217,16 @@ static void test_slice_hash_table_not_eq() {
create_table_from_entries(test_entries_h, num_entries_h, pointer_cmp_fn);
GPR_ASSERT(grpc_slice_hash_table_cmp(table_g, table_h) != 0);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_hash_table_unref(&exec_ctx, table_a);
- grpc_slice_hash_table_unref(&exec_ctx, table_b_larger);
- grpc_slice_hash_table_unref(&exec_ctx, table_b_smaller);
- grpc_slice_hash_table_unref(&exec_ctx, table_c);
- grpc_slice_hash_table_unref(&exec_ctx, table_d);
- grpc_slice_hash_table_unref(&exec_ctx, table_e);
- grpc_slice_hash_table_unref(&exec_ctx, table_f);
- grpc_slice_hash_table_unref(&exec_ctx, table_g);
- grpc_slice_hash_table_unref(&exec_ctx, table_h);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_slice_hash_table_unref(table_a);
+ grpc_slice_hash_table_unref(table_b_larger);
+ grpc_slice_hash_table_unref(table_b_smaller);
+ grpc_slice_hash_table_unref(table_c);
+ grpc_slice_hash_table_unref(table_d);
+ grpc_slice_hash_table_unref(table_e);
+ grpc_slice_hash_table_unref(table_f);
+ grpc_slice_hash_table_unref(table_g);
+ grpc_slice_hash_table_unref(table_h);
}
int main(int argc, char** argv) {
diff --git a/test/core/surface/byte_buffer_reader_test.cc b/test/core/surface/byte_buffer_reader_test.cc
index e5d2d7c78d..f9ce98da21 100644
--- a/test/core/surface/byte_buffer_reader_test.cc
+++ b/test/core/surface/byte_buffer_reader_test.cc
@@ -132,10 +132,8 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm,
memset(GRPC_SLICE_START_PTR(input_slice), 'a', input_size);
grpc_slice_buffer_add(&sliceb_in, input_slice); /* takes ownership */
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(
- grpc_msg_compress(&exec_ctx, algorithm, &sliceb_in, &sliceb_out));
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GPR_ASSERT(grpc_msg_compress(algorithm, &sliceb_in, &sliceb_out));
}
buffer = grpc_raw_compressed_byte_buffer_create(sliceb_out.slices,
diff --git a/test/core/surface/channel_create_test.cc b/test/core/surface/channel_create_test.cc
index f358b0fc8d..65fac9daa3 100644
--- a/test/core/surface/channel_create_test.cc
+++ b/test/core/surface/channel_create_test.cc
@@ -35,11 +35,10 @@ void test_unknown_scheme_target(void) {
chan = grpc_insecure_channel_create("blah://blah", nullptr, nullptr);
GPR_ASSERT(chan != nullptr);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_channel_element* elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0);
GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client"));
- grpc_exec_ctx_finish(&exec_ctx);
grpc_channel_destroy(chan);
}
diff --git a/test/core/surface/completion_queue_test.cc b/test/core/surface/completion_queue_test.cc
index c6e13d2386..3452f78a3b 100644
--- a/test/core/surface/completion_queue_test.cc
+++ b/test/core/surface/completion_queue_test.cc
@@ -121,8 +121,7 @@ static void test_wait_empty(void) {
}
}
-static void do_nothing_end_completion(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_cq_completion* c) {}
+static void do_nothing_end_completion(void* arg, grpc_cq_completion* c) {}
static void test_cq_end_op(void) {
grpc_event ev;
@@ -131,8 +130,6 @@ static void test_cq_end_op(void) {
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
grpc_completion_queue_attributes attr;
- grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_exec_ctx exec_ctx;
void* tag = create_test_tag();
LOG_TEST("test_cq_end_op");
@@ -140,14 +137,14 @@ static void test_cq_end_op(void) {
attr.version = 1;
attr.cq_completion_type = GRPC_CQ_NEXT;
for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) {
- exec_ctx = init_exec_ctx; // Reset exec_ctx
+ grpc_core::ExecCtx _local_exec_ctx;
attr.cq_polling_type = polling_types[i];
cc = grpc_completion_queue_create(
grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
GPR_ASSERT(grpc_cq_begin_op(cc, tag));
- grpc_cq_end_op(&exec_ctx, cc, tag, GRPC_ERROR_NONE,
- do_nothing_end_completion, nullptr, &completion);
+ grpc_cq_end_op(cc, tag, GRPC_ERROR_NONE, do_nothing_end_completion, nullptr,
+ &completion);
ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME),
nullptr);
@@ -156,7 +153,6 @@ static void test_cq_end_op(void) {
GPR_ASSERT(ev.success);
shutdown_and_destroy(cc);
- grpc_exec_ctx_finish(&exec_ctx);
}
}
@@ -167,8 +163,6 @@ static void test_cq_tls_cache_full(void) {
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
grpc_completion_queue_attributes attr;
- grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_exec_ctx exec_ctx;
void* tag = create_test_tag();
void* res_tag;
int ok;
@@ -178,15 +172,15 @@ static void test_cq_tls_cache_full(void) {
attr.version = 1;
attr.cq_completion_type = GRPC_CQ_NEXT;
for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) {
- exec_ctx = init_exec_ctx; // Reset exec_ctx
+ grpc_core::ExecCtx _local_exec_ctx; // Reset exec_ctx
attr.cq_polling_type = polling_types[i];
cc = grpc_completion_queue_create(
grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
grpc_completion_queue_thread_local_cache_init(cc);
GPR_ASSERT(grpc_cq_begin_op(cc, tag));
- grpc_cq_end_op(&exec_ctx, cc, tag, GRPC_ERROR_NONE,
- do_nothing_end_completion, nullptr, &completion);
+ grpc_cq_end_op(cc, tag, GRPC_ERROR_NONE, do_nothing_end_completion, nullptr,
+ &completion);
ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME),
nullptr);
@@ -202,7 +196,6 @@ static void test_cq_tls_cache_full(void) {
GPR_ASSERT(ev.type == GRPC_QUEUE_TIMEOUT);
shutdown_and_destroy(cc);
- grpc_exec_ctx_finish(&exec_ctx);
}
}
@@ -211,8 +204,6 @@ static void test_cq_tls_cache_empty(void) {
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
grpc_completion_queue_attributes attr;
- grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_exec_ctx exec_ctx;
void* res_tag;
int ok;
@@ -221,7 +212,7 @@ static void test_cq_tls_cache_empty(void) {
attr.version = 1;
attr.cq_completion_type = GRPC_CQ_NEXT;
for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) {
- exec_ctx = init_exec_ctx; // Reset exec_ctx
+ grpc_core::ExecCtx _local_exec_ctx; // Reset exec_ctx
attr.cq_polling_type = polling_types[i];
cc = grpc_completion_queue_create(
grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
@@ -232,7 +223,6 @@ static void test_cq_tls_cache_empty(void) {
GPR_ASSERT(
grpc_completion_queue_thread_local_cache_flush(cc, &res_tag, &ok) == 0);
shutdown_and_destroy(cc);
- grpc_exec_ctx_finish(&exec_ctx);
}
}
@@ -289,8 +279,6 @@ static void test_pluck(void) {
grpc_cq_polling_type polling_types[] = {
GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING};
grpc_completion_queue_attributes attr;
- grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_exec_ctx exec_ctx;
unsigned i, j;
LOG_TEST("test_pluck");
@@ -305,15 +293,15 @@ static void test_pluck(void) {
attr.version = 1;
attr.cq_completion_type = GRPC_CQ_PLUCK;
for (size_t pidx = 0; pidx < GPR_ARRAY_SIZE(polling_types); pidx++) {
- exec_ctx = init_exec_ctx; // reset exec_ctx
+ grpc_core::ExecCtx _local_exec_ctx; // reset exec_ctx
attr.cq_polling_type = polling_types[pidx];
cc = grpc_completion_queue_create(
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, nullptr, &completions[i]);
+ grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, do_nothing_end_completion,
+ nullptr, &completions[i]);
}
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
@@ -324,8 +312,8 @@ static void test_pluck(void) {
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, nullptr, &completions[i]);
+ grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, do_nothing_end_completion,
+ nullptr, &completions[i]);
}
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
@@ -336,7 +324,6 @@ static void test_pluck(void) {
}
shutdown_and_destroy(cc);
- grpc_exec_ctx_finish(&exec_ctx);
}
}
diff --git a/test/core/surface/completion_queue_threading_test.cc b/test/core/surface/completion_queue_threading_test.cc
index af54e00c4a..d923387e23 100644
--- a/test/core/surface/completion_queue_threading_test.cc
+++ b/test/core/surface/completion_queue_threading_test.cc
@@ -59,8 +59,7 @@ static void shutdown_and_destroy(grpc_completion_queue* cc) {
grpc_completion_queue_destroy(cc);
}
-static void do_nothing_end_completion(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_cq_completion* c) {}
+static void do_nothing_end_completion(void* arg, grpc_cq_completion* c) {}
struct thread_state {
grpc_completion_queue* cc;
@@ -81,7 +80,7 @@ static void test_too_many_plucks(void) {
gpr_thd_id thread_ids[GPR_ARRAY_SIZE(tags)];
struct thread_state thread_states[GPR_ARRAY_SIZE(tags)];
gpr_thd_options thread_options = gpr_thd_options_default();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
unsigned i, j;
LOG_TEST("test_too_many_plucks");
@@ -108,8 +107,8 @@ static void test_too_many_plucks(void) {
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, nullptr, &completions[i]);
+ grpc_cq_end_op(cc, tags[i], GRPC_ERROR_NONE, do_nothing_end_completion,
+ nullptr, &completions[i]);
}
for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) {
@@ -117,7 +116,6 @@ static void test_too_many_plucks(void) {
}
shutdown_and_destroy(cc);
- grpc_exec_ctx_finish(&exec_ctx);
}
#define TEST_THREAD_EVENTS 10000
@@ -137,15 +135,14 @@ gpr_timespec ten_seconds_time(void) {
return grpc_timeout_seconds_to_deadline(10);
}
-static void free_completion(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_cq_completion* completion) {
+static void free_completion(void* arg, grpc_cq_completion* completion) {
gpr_free(completion);
}
static void producer_thread(void* arg) {
test_thread_options* opt = static_cast<test_thread_options*>(arg);
int i;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_INFO, "producer %d started", opt->id);
gpr_event_set(&opt->on_started, (void*)(intptr_t)1);
@@ -162,17 +159,15 @@ 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,
+ grpc_cq_end_op(opt->cc, (void*)(intptr_t)1, GRPC_ERROR_NONE,
free_completion, nullptr,
static_cast<grpc_cq_completion*>(
gpr_malloc(sizeof(grpc_cq_completion))));
opt->events_triggered++;
- grpc_exec_ctx_finish(&exec_ctx);
}
gpr_log(GPR_INFO, "producer %d phase 2 done", opt->id);
gpr_event_set(&opt->on_finished, (void*)(intptr_t)1);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void consumer_thread(void* arg) {
diff --git a/test/core/surface/concurrent_connectivity_test.cc b/test/core/surface/concurrent_connectivity_test.cc
index 8fa15ab331..5771e2f240 100644
--- a/test/core/surface/concurrent_connectivity_test.cc
+++ b/test/core/surface/concurrent_connectivity_test.cc
@@ -101,29 +101,28 @@ void server_thread(void* vargs) {
GPR_ASSERT(detag(ev.tag) == 0xd1e);
}
-static void on_connect(grpc_exec_ctx* exec_ctx, void* vargs, grpc_endpoint* tcp,
+static void on_connect(void* vargs, grpc_endpoint* tcp,
grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) {
gpr_free(acceptor);
struct server_thread_args* args = (struct server_thread_args*)vargs;
- grpc_endpoint_shutdown(exec_ctx, tcp,
+ grpc_endpoint_shutdown(tcp,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
- grpc_endpoint_destroy(exec_ctx, tcp);
+ grpc_endpoint_destroy(tcp);
gpr_mu_lock(args->mu);
- GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, args->pollset, nullptr));
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, nullptr));
gpr_mu_unlock(args->mu);
}
void bad_server_thread(void* vargs) {
struct server_thread_args* args = (struct server_thread_args*)vargs;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_resolved_address resolved_addr;
struct sockaddr_storage* addr = (struct sockaddr_storage*)resolved_addr.addr;
int port;
grpc_tcp_server* s;
- grpc_error* error = grpc_tcp_server_create(&exec_ctx, nullptr, nullptr, &s);
+ grpc_error* error = grpc_tcp_server_create(nullptr, nullptr, &s);
GPR_ASSERT(error == GRPC_ERROR_NONE);
memset(&resolved_addr, 0, sizeof(resolved_addr));
addr->ss_family = AF_INET;
@@ -132,35 +131,32 @@ void bad_server_thread(void* vargs) {
GPR_ASSERT(port > 0);
gpr_asprintf(&args->addr, "localhost:%d", port);
- grpc_tcp_server_start(&exec_ctx, s, &args->pollset, 1, on_connect, args);
+ grpc_tcp_server_start(s, &args->pollset, 1, on_connect, args);
gpr_event_set(&args->ready, (void*)1);
gpr_mu_lock(args->mu);
while (gpr_atm_acq_load(&args->stop) == 0) {
- grpc_millis deadline = grpc_exec_ctx_now(&exec_ctx) + 100;
+ grpc_millis deadline = grpc_core::ExecCtx::Get()->Now() + 100;
grpc_pollset_worker* worker = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, args->pollset, &worker, deadline))) {
+ grpc_pollset_work(args->pollset, &worker, deadline))) {
gpr_atm_rel_store(&args->stop, 1);
}
gpr_mu_unlock(args->mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_mu_lock(args->mu);
}
gpr_mu_unlock(args->mu);
- grpc_tcp_server_unref(&exec_ctx, s);
-
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_tcp_server_unref(s);
gpr_free(args->addr);
}
-static void done_pollset_shutdown(grpc_exec_ctx* exec_ctx, void* pollset,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(pollset));
+static void done_pollset_shutdown(void* pollset, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(pollset));
gpr_free(pollset);
}
@@ -228,11 +224,10 @@ int run_concurrent_connectivity_test() {
gpr_atm_rel_store(&args.stop, 1);
gpr_thd_join(server);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_pollset_shutdown(&exec_ctx, args.pollset,
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_pollset_shutdown(args.pollset,
GRPC_CLOSURE_CREATE(done_pollset_shutdown, args.pollset,
grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
return 0;
diff --git a/test/core/surface/lame_client_test.cc b/test/core/surface/lame_client_test.cc
index f3df7f35a7..258ee6a831 100644
--- a/test/core/surface/lame_client_test.cc
+++ b/test/core/surface/lame_client_test.cc
@@ -32,20 +32,19 @@ grpc_closure transport_op_cb;
static void* tag(intptr_t x) { return (void*)x; }
-void verify_connectivity(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+void verify_connectivity(void* arg, grpc_error* error) {
grpc_connectivity_state* state = static_cast<grpc_connectivity_state*>(arg);
GPR_ASSERT(GRPC_CHANNEL_SHUTDOWN == *state);
GPR_ASSERT(error == GRPC_ERROR_NONE);
}
-void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
+void do_nothing(void* arg, grpc_error* error) {}
void test_transport_op(grpc_channel* channel) {
grpc_transport_op* op;
grpc_channel_element* elem;
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GRPC_CLOSURE_INIT(&transport_op_cb, verify_connectivity, &state,
grpc_schedule_on_exec_ctx);
@@ -54,14 +53,12 @@ void test_transport_op(grpc_channel* channel) {
op->on_connectivity_state_change = &transport_op_cb;
op->connectivity_state = &state;
elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
- elem->filter->start_transport_op(&exec_ctx, elem, op);
- grpc_exec_ctx_finish(&exec_ctx);
+ elem->filter->start_transport_op(elem, op);
GRPC_CLOSURE_INIT(&transport_op_cb, do_nothing, nullptr,
grpc_schedule_on_exec_ctx);
op = grpc_make_transport_op(&transport_op_cb);
- elem->filter->start_transport_op(&exec_ctx, elem, op);
- grpc_exec_ctx_finish(&exec_ctx);
+ elem->filter->start_transport_op(elem, op);
}
int main(int argc, char** argv) {
diff --git a/test/core/surface/num_external_connectivity_watchers_test.cc b/test/core/surface/num_external_connectivity_watchers_test.cc
index f78d333673..4052f19f51 100644
--- a/test/core/surface/num_external_connectivity_watchers_test.cc
+++ b/test/core/surface/num_external_connectivity_watchers_test.cc
@@ -178,9 +178,8 @@ static grpc_channel* secure_test_create_channel(const char* addr) {
grpc_channel* channel =
grpc_secure_channel_create(ssl_creds, addr, new_client_args, nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, new_client_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(new_client_args);
}
grpc_channel_credentials_release(ssl_creds);
return channel;
diff --git a/test/core/surface/secure_channel_create_test.cc b/test/core/surface/secure_channel_create_test.cc
index c31c61430c..62c2d92885 100644
--- a/test/core/surface/secure_channel_create_test.cc
+++ b/test/core/surface/secure_channel_create_test.cc
@@ -37,10 +37,9 @@ void test_unknown_scheme_target(void) {
grpc_channel_element* elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0);
GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CHANNEL_INTERNAL_UNREF(&exec_ctx, chan, "test");
- grpc_channel_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_CHANNEL_INTERNAL_UNREF(chan, "test");
+ grpc_channel_credentials_unref(creds);
}
void test_security_connector_already_in_arg(void) {
@@ -56,9 +55,8 @@ void test_security_connector_already_in_arg(void) {
grpc_channel_element* elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0);
GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CHANNEL_INTERNAL_UNREF(&exec_ctx, chan, "test");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_CHANNEL_INTERNAL_UNREF(chan, "test");
}
void test_null_creds(void) {
@@ -67,9 +65,8 @@ void test_null_creds(void) {
grpc_channel_element* elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0);
GPR_ASSERT(0 == strcmp(elem->filter->name, "lame-client"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GRPC_CHANNEL_INTERNAL_UNREF(&exec_ctx, chan, "test");
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ GRPC_CHANNEL_INTERNAL_UNREF(chan, "test");
}
int main(int argc, char** argv) {
diff --git a/test/core/surface/sequential_connectivity_test.cc b/test/core/surface/sequential_connectivity_test.cc
index 015db92cb0..e7ae97908c 100644
--- a/test/core/surface/sequential_connectivity_test.cc
+++ b/test/core/surface/sequential_connectivity_test.cc
@@ -156,9 +156,8 @@ static grpc_channel* secure_test_create_channel(const char* addr) {
grpc_channel* channel =
grpc_secure_channel_create(ssl_creds, addr, new_client_args, nullptr);
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args_destroy(&exec_ctx, new_client_args);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_channel_args_destroy(new_client_args);
}
grpc_channel_credentials_release(ssl_creds);
return channel;
diff --git a/test/core/transport/bdp_estimator_test.cc b/test/core/transport/bdp_estimator_test.cc
index 2a6fa95162..168807adde 100644
--- a/test/core/transport/bdp_estimator_test.cc
+++ b/test/core/transport/bdp_estimator_test.cc
@@ -58,7 +58,7 @@ namespace {
void AddSamples(BdpEstimator* estimator, int64_t* samples, size_t n) {
estimator->AddIncomingBytes(1234567);
inc_time();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
estimator->SchedulePing();
estimator->StartPing();
for (size_t i = 0; i < n; i++) {
@@ -66,9 +66,8 @@ void AddSamples(BdpEstimator* estimator, int64_t* samples, size_t n) {
}
gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_millis(1, GPR_TIMESPAN)));
- grpc_exec_ctx_invalidate_now(&exec_ctx);
- estimator->CompletePing(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->InvalidateNow();
+ estimator->CompletePing();
}
void AddSample(BdpEstimator* estimator, int64_t sample) {
diff --git a/test/core/transport/byte_stream_test.cc b/test/core/transport/byte_stream_test.cc
index 0e34fd7651..593c2ae141 100644
--- a/test/core/transport/byte_stream_test.cc
+++ b/test/core/transport/byte_stream_test.cc
@@ -30,14 +30,13 @@
// grpc_slice_buffer_stream tests
//
-static void not_called_closure(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void not_called_closure(void* arg, grpc_error* error) {
GPR_ASSERT(false);
}
static void test_slice_buffer_stream_basic(void) {
gpr_log(GPR_DEBUG, "test_slice_buffer_stream_basic");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
// Create and populate slice buffer.
grpc_slice_buffer buffer;
grpc_slice_buffer_init(&buffer);
@@ -57,23 +56,21 @@ static void test_slice_buffer_stream_basic(void) {
grpc_schedule_on_exec_ctx);
// Read each slice. Note that next() always returns synchronously.
for (size_t i = 0; i < GPR_ARRAY_SIZE(input); ++i) {
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure));
+ GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure));
grpc_slice output;
- grpc_error* error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output);
+ grpc_error* error = grpc_byte_stream_pull(&stream.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[i], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
}
// Clean up.
- grpc_byte_stream_destroy(&exec_ctx, &stream.base);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_byte_stream_destroy(&stream.base);
+ grpc_slice_buffer_destroy_internal(&buffer);
}
static void test_slice_buffer_stream_shutdown(void) {
gpr_log(GPR_DEBUG, "test_slice_buffer_stream_shutdown");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
// Create and populate slice buffer.
grpc_slice_buffer buffer;
grpc_slice_buffer_init(&buffer);
@@ -92,29 +89,25 @@ static void test_slice_buffer_stream_shutdown(void) {
GRPC_CLOSURE_INIT(&closure, not_called_closure, nullptr,
grpc_schedule_on_exec_ctx);
// Read the first slice.
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure));
+ GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure));
grpc_slice output;
- grpc_error* error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output);
+ grpc_error* error = grpc_byte_stream_pull(&stream.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[0], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
// Now shutdown.
grpc_error* shutdown_error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("shutdown error");
- grpc_byte_stream_shutdown(&exec_ctx, &stream.base,
- GRPC_ERROR_REF(shutdown_error));
+ grpc_byte_stream_shutdown(&stream.base, GRPC_ERROR_REF(shutdown_error));
// After shutdown, the next pull() should return the error.
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure));
- error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output);
+ GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure));
+ error = grpc_byte_stream_pull(&stream.base, &output);
GPR_ASSERT(error == shutdown_error);
GRPC_ERROR_UNREF(error);
GRPC_ERROR_UNREF(shutdown_error);
// Clean up.
- grpc_byte_stream_destroy(&exec_ctx, &stream.base);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_byte_stream_destroy(&stream.base);
+ grpc_slice_buffer_destroy_internal(&buffer);
}
//
@@ -123,7 +116,7 @@ static void test_slice_buffer_stream_shutdown(void) {
static void test_caching_byte_stream_basic(void) {
gpr_log(GPR_DEBUG, "test_caching_byte_stream_basic");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
// Create and populate slice buffer byte stream.
grpc_slice_buffer buffer;
grpc_slice_buffer_init(&buffer);
@@ -147,24 +140,22 @@ static void test_caching_byte_stream_basic(void) {
// Read each slice. Note that next() always returns synchronously,
// because the underlying byte stream always does.
for (size_t i = 0; i < GPR_ARRAY_SIZE(input); ++i) {
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure));
+ GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure));
grpc_slice output;
- grpc_error* error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output);
+ grpc_error* error = grpc_byte_stream_pull(&stream.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[i], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
}
// Clean up.
- grpc_byte_stream_destroy(&exec_ctx, &stream.base);
- grpc_byte_stream_cache_destroy(&exec_ctx, &cache);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_byte_stream_destroy(&stream.base);
+ grpc_byte_stream_cache_destroy(&cache);
+ grpc_slice_buffer_destroy_internal(&buffer);
}
static void test_caching_byte_stream_reset(void) {
gpr_log(GPR_DEBUG, "test_caching_byte_stream_reset");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
// Create and populate slice buffer byte stream.
grpc_slice_buffer buffer;
grpc_slice_buffer_init(&buffer);
@@ -186,34 +177,31 @@ static void test_caching_byte_stream_reset(void) {
GRPC_CLOSURE_INIT(&closure, not_called_closure, nullptr,
grpc_schedule_on_exec_ctx);
// Read one slice.
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure));
+ GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure));
grpc_slice output;
- grpc_error* error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output);
+ grpc_error* error = grpc_byte_stream_pull(&stream.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[0], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
// Reset the caching stream. The reads should start over from the
// first slice.
grpc_caching_byte_stream_reset(&stream);
for (size_t i = 0; i < GPR_ARRAY_SIZE(input); ++i) {
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream.base, ~(size_t)0, &closure));
- error = grpc_byte_stream_pull(&exec_ctx, &stream.base, &output);
+ GPR_ASSERT(grpc_byte_stream_next(&stream.base, ~(size_t)0, &closure));
+ error = grpc_byte_stream_pull(&stream.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[i], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
}
// Clean up.
- grpc_byte_stream_destroy(&exec_ctx, &stream.base);
- grpc_byte_stream_cache_destroy(&exec_ctx, &cache);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_byte_stream_destroy(&stream.base);
+ grpc_byte_stream_cache_destroy(&cache);
+ grpc_slice_buffer_destroy_internal(&buffer);
}
static void test_caching_byte_stream_shared_cache(void) {
gpr_log(GPR_DEBUG, "test_caching_byte_stream_shared_cache");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
// Create and populate slice buffer byte stream.
grpc_slice_buffer buffer;
grpc_slice_buffer_init(&buffer);
@@ -237,35 +225,31 @@ static void test_caching_byte_stream_shared_cache(void) {
GRPC_CLOSURE_INIT(&closure, not_called_closure, nullptr,
grpc_schedule_on_exec_ctx);
// Read one slice from stream1.
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream1.base, ~(size_t)0, &closure));
+ GPR_ASSERT(grpc_byte_stream_next(&stream1.base, ~(size_t)0, &closure));
grpc_slice output;
- grpc_error* error = grpc_byte_stream_pull(&exec_ctx, &stream1.base, &output);
+ grpc_error* error = grpc_byte_stream_pull(&stream1.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[0], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
// Read all slices from stream2.
for (size_t i = 0; i < GPR_ARRAY_SIZE(input); ++i) {
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream2.base, ~(size_t)0, &closure));
- error = grpc_byte_stream_pull(&exec_ctx, &stream2.base, &output);
+ GPR_ASSERT(grpc_byte_stream_next(&stream2.base, ~(size_t)0, &closure));
+ error = grpc_byte_stream_pull(&stream2.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[i], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
}
// Now read the second slice from stream1.
- GPR_ASSERT(
- grpc_byte_stream_next(&exec_ctx, &stream1.base, ~(size_t)0, &closure));
- error = grpc_byte_stream_pull(&exec_ctx, &stream1.base, &output);
+ GPR_ASSERT(grpc_byte_stream_next(&stream1.base, ~(size_t)0, &closure));
+ error = grpc_byte_stream_pull(&stream1.base, &output);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(grpc_slice_eq(input[1], output));
- grpc_slice_unref_internal(&exec_ctx, output);
+ grpc_slice_unref_internal(output);
// Clean up.
- grpc_byte_stream_destroy(&exec_ctx, &stream1.base);
- grpc_byte_stream_destroy(&exec_ctx, &stream2.base);
- grpc_byte_stream_cache_destroy(&exec_ctx, &cache);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &buffer);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_byte_stream_destroy(&stream1.base);
+ grpc_byte_stream_destroy(&stream2.base);
+ grpc_byte_stream_cache_destroy(&cache);
+ grpc_slice_buffer_destroy_internal(&buffer);
}
int main(int argc, char** argv) {
diff --git a/test/core/transport/chttp2/bin_decoder_test.cc b/test/core/transport/chttp2/bin_decoder_test.cc
index a29ec8a13f..897d3008b9 100644
--- a/test/core/transport/chttp2/bin_decoder_test.cc
+++ b/test/core/transport/chttp2/bin_decoder_test.cc
@@ -29,8 +29,8 @@
static int all_ok = 1;
-static void expect_slice_eq(grpc_exec_ctx* exec_ctx, grpc_slice expected,
- grpc_slice slice, const char* debug, int line) {
+static void expect_slice_eq(grpc_slice expected, grpc_slice slice,
+ const char* debug, int line) {
if (!grpc_slice_eq(slice, expected)) {
char* hs = grpc_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
char* he = grpc_dump_slice(expected, GPR_DUMP_HEX | GPR_DUMP_ASCII);
@@ -40,104 +40,94 @@ static void expect_slice_eq(grpc_exec_ctx* exec_ctx, grpc_slice expected,
gpr_free(he);
all_ok = 0;
}
- grpc_slice_unref_internal(exec_ctx, expected);
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(expected);
+ grpc_slice_unref_internal(slice);
}
-static grpc_slice base64_encode(grpc_exec_ctx* exec_ctx, const char* s) {
+static grpc_slice base64_encode(const char* s) {
grpc_slice ss = grpc_slice_from_copied_string(s);
grpc_slice out = grpc_chttp2_base64_encode(ss);
- grpc_slice_unref_internal(exec_ctx, ss);
+ grpc_slice_unref_internal(ss);
return out;
}
-static grpc_slice base64_decode(grpc_exec_ctx* exec_ctx, const char* s) {
+static grpc_slice base64_decode(const char* s) {
grpc_slice ss = grpc_slice_from_copied_string(s);
- grpc_slice out = grpc_chttp2_base64_decode(exec_ctx, ss);
- grpc_slice_unref_internal(exec_ctx, ss);
+ grpc_slice out = grpc_chttp2_base64_decode(ss);
+ grpc_slice_unref_internal(ss);
return out;
}
-static grpc_slice base64_decode_with_length(grpc_exec_ctx* exec_ctx,
- const char* s,
+static grpc_slice base64_decode_with_length(const char* s,
size_t output_length) {
grpc_slice ss = grpc_slice_from_copied_string(s);
- grpc_slice out =
- grpc_chttp2_base64_decode_with_length(exec_ctx, ss, output_length);
- grpc_slice_unref_internal(exec_ctx, ss);
+ grpc_slice out = grpc_chttp2_base64_decode_with_length(ss, output_length);
+ grpc_slice_unref_internal(ss);
return out;
}
-#define EXPECT_SLICE_EQ(exec_ctx, expected, slice) \
- expect_slice_eq( \
- exec_ctx, grpc_slice_from_copied_buffer(expected, sizeof(expected) - 1), \
- slice, #slice, __LINE__);
+#define EXPECT_SLICE_EQ(expected, slice) \
+ expect_slice_eq( \
+ grpc_slice_from_copied_buffer(expected, sizeof(expected) - 1), slice, \
+ #slice, __LINE__);
-#define ENCODE_AND_DECODE(exec_ctx, s) \
- EXPECT_SLICE_EQ(exec_ctx, s, \
- grpc_chttp2_base64_decode_with_length( \
- exec_ctx, base64_encode(exec_ctx, s), strlen(s)));
+#define ENCODE_AND_DECODE(s) \
+ EXPECT_SLICE_EQ( \
+ s, grpc_chttp2_base64_decode_with_length(base64_encode(s), strlen(s)));
int main(int argc, char** argv) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
/* ENCODE_AND_DECODE tests grpc_chttp2_base64_decode_with_length(), which
takes encoded base64 strings without pad chars, but output length is
required. */
/* Base64 test vectors from RFC 4648 */
- ENCODE_AND_DECODE(&exec_ctx, "");
- ENCODE_AND_DECODE(&exec_ctx, "f");
- ENCODE_AND_DECODE(&exec_ctx, "foo");
- ENCODE_AND_DECODE(&exec_ctx, "fo");
- ENCODE_AND_DECODE(&exec_ctx, "foob");
- ENCODE_AND_DECODE(&exec_ctx, "fooba");
- ENCODE_AND_DECODE(&exec_ctx, "foobar");
+ ENCODE_AND_DECODE("");
+ ENCODE_AND_DECODE("f");
+ ENCODE_AND_DECODE("foo");
+ ENCODE_AND_DECODE("fo");
+ ENCODE_AND_DECODE("foob");
+ ENCODE_AND_DECODE("fooba");
+ ENCODE_AND_DECODE("foobar");
- ENCODE_AND_DECODE(&exec_ctx, "\xc0\xc1\xc2\xc3\xc4\xc5");
+ ENCODE_AND_DECODE("\xc0\xc1\xc2\xc3\xc4\xc5");
/* Base64 test vectors from RFC 4648, with pad chars */
/* BASE64("") = "" */
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, ""));
+ EXPECT_SLICE_EQ("", base64_decode(""));
/* BASE64("f") = "Zg==" */
- EXPECT_SLICE_EQ(&exec_ctx, "f", base64_decode(&exec_ctx, "Zg=="));
+ EXPECT_SLICE_EQ("f", base64_decode("Zg=="));
/* BASE64("fo") = "Zm8=" */
- EXPECT_SLICE_EQ(&exec_ctx, "fo", base64_decode(&exec_ctx, "Zm8="));
+ EXPECT_SLICE_EQ("fo", base64_decode("Zm8="));
/* BASE64("foo") = "Zm9v" */
- EXPECT_SLICE_EQ(&exec_ctx, "foo", base64_decode(&exec_ctx, "Zm9v"));
+ EXPECT_SLICE_EQ("foo", base64_decode("Zm9v"));
/* BASE64("foob") = "Zm9vYg==" */
- EXPECT_SLICE_EQ(&exec_ctx, "foob", base64_decode(&exec_ctx, "Zm9vYg=="));
+ EXPECT_SLICE_EQ("foob", base64_decode("Zm9vYg=="));
/* BASE64("fooba") = "Zm9vYmE=" */
- EXPECT_SLICE_EQ(&exec_ctx, "fooba", base64_decode(&exec_ctx, "Zm9vYmE="));
+ EXPECT_SLICE_EQ("fooba", base64_decode("Zm9vYmE="));
/* BASE64("foobar") = "Zm9vYmFy" */
- EXPECT_SLICE_EQ(&exec_ctx, "foobar", base64_decode(&exec_ctx, "Zm9vYmFy"));
+ EXPECT_SLICE_EQ("foobar", base64_decode("Zm9vYmFy"));
- EXPECT_SLICE_EQ(&exec_ctx, "\xc0\xc1\xc2\xc3\xc4\xc5",
- base64_decode(&exec_ctx, "wMHCw8TF"));
+ EXPECT_SLICE_EQ("\xc0\xc1\xc2\xc3\xc4\xc5", base64_decode("wMHCw8TF"));
// Test illegal input length in grpc_chttp2_base64_decode
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "a"));
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "ab"));
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "abc"));
+ EXPECT_SLICE_EQ("", base64_decode("a"));
+ EXPECT_SLICE_EQ("", base64_decode("ab"));
+ EXPECT_SLICE_EQ("", base64_decode("abc"));
// Test illegal charactors in grpc_chttp2_base64_decode
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "Zm:v"));
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode(&exec_ctx, "Zm=v"));
+ EXPECT_SLICE_EQ("", base64_decode("Zm:v"));
+ EXPECT_SLICE_EQ("", base64_decode("Zm=v"));
// Test output_length longer than max possible output length in
// grpc_chttp2_base64_decode_with_length
- EXPECT_SLICE_EQ(&exec_ctx, "", base64_decode_with_length(&exec_ctx, "Zg", 2));
- EXPECT_SLICE_EQ(&exec_ctx, "",
- base64_decode_with_length(&exec_ctx, "Zm8", 3));
- EXPECT_SLICE_EQ(&exec_ctx, "",
- base64_decode_with_length(&exec_ctx, "Zm9v", 4));
+ EXPECT_SLICE_EQ("", base64_decode_with_length("Zg", 2));
+ EXPECT_SLICE_EQ("", base64_decode_with_length("Zm8", 3));
+ EXPECT_SLICE_EQ("", base64_decode_with_length("Zm9v", 4));
// Test illegal charactors in grpc_chttp2_base64_decode_with_length
- EXPECT_SLICE_EQ(&exec_ctx, "",
- base64_decode_with_length(&exec_ctx, "Zm:v", 3));
- EXPECT_SLICE_EQ(&exec_ctx, "",
- base64_decode_with_length(&exec_ctx, "Zm=v", 3));
-
- grpc_exec_ctx_finish(&exec_ctx);
+ EXPECT_SLICE_EQ("", base64_decode_with_length("Zm:v", 3));
+ EXPECT_SLICE_EQ("", base64_decode_with_length("Zm=v", 3));
return all_ok ? 0 : 1;
}
diff --git a/test/core/transport/chttp2/hpack_encoder_test.cc b/test/core/transport/chttp2/hpack_encoder_test.cc
index 2d18b72504..2772aef3c4 100644
--- a/test/core/transport/chttp2/hpack_encoder_test.cc
+++ b/test/core/transport/chttp2/hpack_encoder_test.cc
@@ -51,8 +51,8 @@ typedef struct {
/* verify that the output generated by encoding the stream matches the
hexstring passed in */
-static void verify(grpc_exec_ctx* exec_ctx, const verify_params params,
- const char* expected, size_t nheaders, ...) {
+static void verify(const verify_params params, const char* expected,
+ size_t nheaders, ...) {
grpc_slice_buffer output;
grpc_slice merged;
grpc_slice expect = parse_hexstring(expected);
@@ -77,8 +77,7 @@ static void verify(grpc_exec_ctx* exec_ctx, const verify_params params,
value_slice = grpc_slice_intern(value_slice);
}
e[i].md = grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_intern(grpc_slice_from_static_string(key)),
- value_slice);
+ grpc_slice_intern(grpc_slice_from_static_string(key)), value_slice);
}
e[0].prev = nullptr;
e[nheaders - 1].next = nullptr;
@@ -106,11 +105,10 @@ 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, nullptr, 0, &b, &hopt,
- &output);
+ grpc_chttp2_encode_header(&g_compressor, nullptr, 0, &b, &hopt, &output);
merged = grpc_slice_merge(output.slices, output.count);
- grpc_slice_buffer_destroy_internal(exec_ctx, &output);
- grpc_metadata_batch_destroy(exec_ctx, &b);
+ grpc_slice_buffer_destroy_internal(&output);
+ grpc_metadata_batch_destroy(&b);
if (!grpc_slice_eq(merged, expect)) {
char* expect_str = grpc_dump_slice(expect, GPR_DUMP_HEX | GPR_DUMP_ASCII);
@@ -123,11 +121,11 @@ static void verify(grpc_exec_ctx* exec_ctx, const verify_params params,
g_failure = 1;
}
- grpc_slice_unref_internal(exec_ctx, merged);
- grpc_slice_unref_internal(exec_ctx, expect);
+ grpc_slice_unref_internal(merged);
+ grpc_slice_unref_internal(expect);
}
-static void test_basic_headers(grpc_exec_ctx* exec_ctx) {
+static void test_basic_headers() {
int i;
verify_params params = {
@@ -135,24 +133,22 @@ static void test_basic_headers(grpc_exec_ctx* exec_ctx) {
false,
false,
};
- verify(exec_ctx, params, "000005 0104 deadbeef 40 0161 0161", 1, "a", "a");
- verify(exec_ctx, params, "000001 0104 deadbeef be", 1, "a", "a");
- verify(exec_ctx, params, "000001 0104 deadbeef be", 1, "a", "a");
- verify(exec_ctx, params, "000006 0104 deadbeef be 40 0162 0163", 2, "a", "a",
- "b", "c");
- verify(exec_ctx, params, "000002 0104 deadbeef bf be", 2, "a", "a", "b", "c");
- verify(exec_ctx, params, "000004 0104 deadbeef 7f 00 0164", 1, "a", "d");
+ verify(params, "000005 0104 deadbeef 40 0161 0161", 1, "a", "a");
+ verify(params, "000001 0104 deadbeef be", 1, "a", "a");
+ verify(params, "000001 0104 deadbeef be", 1, "a", "a");
+ verify(params, "000006 0104 deadbeef be 40 0162 0163", 2, "a", "a", "b", "c");
+ verify(params, "000002 0104 deadbeef bf be", 2, "a", "a", "b", "c");
+ verify(params, "000004 0104 deadbeef 7f 00 0164", 1, "a", "d");
/* flush out what's there to make a few values look very popular */
for (i = 0; i < 350; i++) {
- verify(exec_ctx, params, "000003 0104 deadbeef c0 bf be", 3, "a", "a", "b",
- "c", "a", "d");
+ verify(params, "000003 0104 deadbeef c0 bf be", 3, "a", "a", "b", "c", "a",
+ "d");
}
- verify(exec_ctx, params, "000006 0104 deadbeef c0 00 016b 0176", 2, "a", "a",
- "k", "v");
+ verify(params, "000006 0104 deadbeef c0 00 016b 0176", 2, "a", "a", "k", "v");
/* this could be 000004 0104 deadbeef 0f 30 0176 also */
- verify(exec_ctx, params, "000004 0104 deadbeef 0f 2f 0176", 1, "a", "v");
+ verify(params, "000004 0104 deadbeef 0f 2f 0176", 1, "a", "v");
}
static void encode_int_to_str(int i, char* p) {
@@ -163,7 +159,7 @@ static void encode_int_to_str(int i, char* p) {
p[2] = 0;
}
-static void test_decode_table_overflow(grpc_exec_ctx* exec_ctx) {
+static void test_decode_table_overflow() {
int i;
char key[3], value[3];
char* expect;
@@ -192,26 +188,24 @@ static void test_decode_table_overflow(grpc_exec_ctx* exec_ctx) {
}
if (i > 0) {
- verify(exec_ctx, params, expect, 2, "aa", "ba", key, value);
+ verify(params, expect, 2, "aa", "ba", key, value);
} else {
- verify(exec_ctx, params, expect, 1, key, value);
+ verify(params, expect, 1, key, value);
}
gpr_free(expect);
}
/* if the above passes, then we must have just knocked this pair out of the
decoder stack, and so we'll be forced to re-encode it */
- verify(exec_ctx, params, "000007 0104 deadbeef 40 026161 026261", 1, "aa",
- "ba");
+ verify(params, "000007 0104 deadbeef 40 026161 026261", 1, "aa", "ba");
}
-static void verify_table_size_change_match_elem_size(grpc_exec_ctx* exec_ctx,
- const char* key,
+static void verify_table_size_change_match_elem_size(const char* key,
const char* value,
bool use_true_binary) {
grpc_slice_buffer output;
grpc_mdelem elem = grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_intern(grpc_slice_from_static_string(key)),
+ grpc_slice_intern(grpc_slice_from_static_string(key)),
grpc_slice_intern(grpc_slice_from_static_string(value)));
size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem, use_true_binary);
size_t initial_table_size = g_compressor.table_size;
@@ -235,41 +229,38 @@ 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, nullptr, 0, &b, &hopt,
- &output);
- grpc_slice_buffer_destroy_internal(exec_ctx, &output);
- grpc_metadata_batch_destroy(exec_ctx, &b);
+ grpc_chttp2_encode_header(&g_compressor, nullptr, 0, &b, &hopt, &output);
+ grpc_slice_buffer_destroy_internal(&output);
+ grpc_metadata_batch_destroy(&b);
GPR_ASSERT(g_compressor.table_size == elem_size + initial_table_size);
gpr_free(e);
}
-static void test_encode_header_size(grpc_exec_ctx* exec_ctx) {
- verify_table_size_change_match_elem_size(exec_ctx, "hello", "world", false);
- verify_table_size_change_match_elem_size(exec_ctx, "hello-bin", "world",
- false);
- verify_table_size_change_match_elem_size(exec_ctx, "true-binary-bin",
+static void test_encode_header_size() {
+ verify_table_size_change_match_elem_size("hello", "world", false);
+ verify_table_size_change_match_elem_size("hello-bin", "world", false);
+ verify_table_size_change_match_elem_size("true-binary-bin",
"I_am_true_binary_value", true);
}
-static void test_interned_key_indexed(grpc_exec_ctx* exec_ctx) {
+static void test_interned_key_indexed() {
int i;
verify_params params = {false, false, true};
- verify(exec_ctx, params, "000009 0104 deadbeef 40 0161 0162 0f2f 0163", 2,
- "a", "b", "a", "c");
+ verify(params, "000009 0104 deadbeef 40 0161 0162 0f2f 0163", 2, "a", "b",
+ "a", "c");
for (i = 0; i < 10; i++) {
- verify(exec_ctx, params, "000008 0104 deadbeef 0f2f 0162 0f2f 0163", 2, "a",
- "b", "a", "c");
+ verify(params, "000008 0104 deadbeef 0f2f 0162 0f2f 0163", 2, "a", "b", "a",
+ "c");
}
}
-static void run_test(void (*test)(grpc_exec_ctx* exec_ctx), const char* name) {
+static void run_test(void (*test)(), const char* name) {
gpr_log(GPR_INFO, "RUN TEST: %s", name);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_chttp2_hpack_compressor_init(&g_compressor);
- test(&exec_ctx);
- grpc_chttp2_hpack_compressor_destroy(&exec_ctx, &g_compressor);
- grpc_exec_ctx_finish(&exec_ctx);
+ test();
+ grpc_chttp2_hpack_compressor_destroy(&g_compressor);
}
int main(int argc, char** argv) {
diff --git a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc
index 942f25e0b7..0dfd5ecc2d 100644
--- a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc
+++ b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc
@@ -29,9 +29,7 @@
bool squelch = true;
bool leak_check = true;
-static void onhdr(grpc_exec_ctx* exec_ctx, void* ud, grpc_mdelem md) {
- GRPC_MDELEM_UNREF(exec_ctx, md);
-}
+static void onhdr(void* ud, grpc_mdelem md) { GRPC_MDELEM_UNREF(md); }
static void dont_log(gpr_log_func_args* args) {}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
@@ -39,13 +37,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (squelch) gpr_set_log_function(dont_log);
grpc_init();
grpc_chttp2_hpack_parser parser;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_chttp2_hpack_parser_init(&parser);
parser.on_header = onhdr;
GRPC_ERROR_UNREF(grpc_chttp2_hpack_parser_parse(
- &exec_ctx, &parser, grpc_slice_from_static_buffer(data, size)));
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
- grpc_exec_ctx_finish(&exec_ctx);
+ &parser, grpc_slice_from_static_buffer(data, size)));
+ grpc_chttp2_hpack_parser_destroy(&parser);
+
grpc_shutdown();
return 0;
}
diff --git a/test/core/transport/chttp2/hpack_parser_test.cc b/test/core/transport/chttp2/hpack_parser_test.cc
index 82fb20aced..52900c5419 100644
--- a/test/core/transport/chttp2/hpack_parser_test.cc
+++ b/test/core/transport/chttp2/hpack_parser_test.cc
@@ -32,7 +32,7 @@ typedef struct {
va_list args;
} test_checker;
-static void onhdr(grpc_exec_ctx* exec_ctx, void* ud, grpc_mdelem md) {
+static void onhdr(void* ud, grpc_mdelem md) {
const char *ekey, *evalue;
test_checker* chk = static_cast<test_checker*>(ud);
ekey = va_arg(chk->args, char*);
@@ -41,7 +41,7 @@ static void onhdr(grpc_exec_ctx* exec_ctx, void* ud, grpc_mdelem md) {
GPR_ASSERT(evalue);
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDKEY(md), ekey) == 0);
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDVALUE(md), evalue) == 0);
- GRPC_MDELEM_UNREF(exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
}
static void test_vector(grpc_chttp2_hpack_parser* parser,
@@ -62,10 +62,9 @@ static void test_vector(grpc_chttp2_hpack_parser* parser,
grpc_slice_unref(input);
for (i = 0; i < nslices; i++) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- GPR_ASSERT(grpc_chttp2_hpack_parser_parse(&exec_ctx, parser, slices[i]) ==
+ grpc_core::ExecCtx _local_exec_ctx;
+ GPR_ASSERT(grpc_chttp2_hpack_parser_parse(parser, slices[i]) ==
GRPC_ERROR_NONE);
- grpc_exec_ctx_finish(&exec_ctx);
}
for (i = 0; i < nslices; i++) {
@@ -80,9 +79,9 @@ static void test_vector(grpc_chttp2_hpack_parser* parser,
static void test_vectors(grpc_slice_split_mode mode) {
grpc_chttp2_hpack_parser parser;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
- grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_init(&parser);
/* D.2.1 */
test_vector(&parser, mode,
"400a 6375 7374 6f6d 2d6b 6579 0d63 7573"
@@ -98,9 +97,9 @@ static void test_vectors(grpc_slice_split_mode mode) {
"password", "secret", NULL);
/* D.2.4 */
test_vector(&parser, mode, "82", ":method", "GET", NULL);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_destroy(&parser);
- grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_init(&parser);
/* D.3.1 */
test_vector(&parser, mode,
"8286 8441 0f77 7777 2e65 7861 6d70 6c65"
@@ -118,9 +117,9 @@ static void test_vectors(grpc_slice_split_mode mode) {
":method", "GET", ":scheme", "https", ":path", "/index.html",
":authority", "www.example.com", "custom-key", "custom-value",
NULL);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_destroy(&parser);
- grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_init(&parser);
/* D.4.1 */
test_vector(&parser, mode,
"8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4"
@@ -138,11 +137,11 @@ static void test_vectors(grpc_slice_split_mode mode) {
":method", "GET", ":scheme", "https", ":path", "/index.html",
":authority", "www.example.com", "custom-key", "custom-value",
NULL);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_destroy(&parser);
- grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
- grpc_chttp2_hptbl_set_max_bytes(&exec_ctx, &parser.table, 256);
- grpc_chttp2_hptbl_set_current_table_size(&exec_ctx, &parser.table, 256);
+ grpc_chttp2_hpack_parser_init(&parser);
+ grpc_chttp2_hptbl_set_max_bytes(&parser.table, 256);
+ grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256);
/* D.5.1 */
test_vector(&parser, mode,
"4803 3330 3258 0770 7269 7661 7465 611d"
@@ -172,11 +171,11 @@ static void test_vectors(grpc_slice_split_mode mode) {
"https://www.example.com", "content-encoding", "gzip",
"set-cookie",
"foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", NULL);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
+ grpc_chttp2_hpack_parser_destroy(&parser);
- grpc_chttp2_hpack_parser_init(&exec_ctx, &parser);
- grpc_chttp2_hptbl_set_max_bytes(&exec_ctx, &parser.table, 256);
- grpc_chttp2_hptbl_set_current_table_size(&exec_ctx, &parser.table, 256);
+ grpc_chttp2_hpack_parser_init(&parser);
+ grpc_chttp2_hptbl_set_max_bytes(&parser.table, 256);
+ grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256);
/* D.6.1 */
test_vector(&parser, mode,
"4882 6402 5885 aec3 771a 4b61 96d0 7abe"
@@ -203,9 +202,7 @@ static void test_vectors(grpc_slice_split_mode mode) {
"https://www.example.com", "content-encoding", "gzip",
"set-cookie",
"foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", NULL);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &parser);
-
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_hpack_parser_destroy(&parser);
}
int main(int argc, char** argv) {
diff --git a/test/core/transport/chttp2/hpack_table_test.cc b/test/core/transport/chttp2/hpack_table_test.cc
index ff7c2de538..97e1a02621 100644
--- a/test/core/transport/chttp2/hpack_table_test.cc
+++ b/test/core/transport/chttp2/hpack_table_test.cc
@@ -44,10 +44,10 @@ static void assert_index(const grpc_chttp2_hptbl* tbl, uint32_t idx,
}
static void test_static_lookup(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_chttp2_hptbl tbl;
- grpc_chttp2_hptbl_init(&exec_ctx, &tbl);
+ grpc_chttp2_hptbl_init(&tbl);
LOG_TEST("test_static_lookup");
assert_index(&tbl, 1, ":authority", "");
@@ -112,8 +112,7 @@ static void test_static_lookup(void) {
assert_index(&tbl, 60, "via", "");
assert_index(&tbl, 61, "www-authenticate", "");
- grpc_chttp2_hptbl_destroy(&exec_ctx, &tbl);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_hptbl_destroy(&tbl);
}
static void test_many_additions(void) {
@@ -124,18 +123,17 @@ static void test_many_additions(void) {
LOG_TEST("test_many_additions");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_chttp2_hptbl_init(&exec_ctx, &tbl);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_chttp2_hptbl_init(&tbl);
for (i = 0; i < 100000; i++) {
grpc_mdelem elem;
gpr_asprintf(&key, "K:%d", i);
gpr_asprintf(&value, "VALUE:%d", i);
- elem =
- grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_copied_string(key),
- grpc_slice_from_copied_string(value));
- GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(&exec_ctx, elem);
+ elem = grpc_mdelem_from_slices(grpc_slice_from_copied_string(key),
+ grpc_slice_from_copied_string(value));
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(elem);
assert_index(&tbl, 1 + GRPC_CHTTP2_LAST_STATIC_ENTRY, key, value);
gpr_free(key);
gpr_free(value);
@@ -148,25 +146,23 @@ static void test_many_additions(void) {
}
}
- grpc_chttp2_hptbl_destroy(&exec_ctx, &tbl);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_hptbl_destroy(&tbl);
}
static grpc_chttp2_hptbl_find_result find_simple(grpc_chttp2_hptbl* tbl,
const char* key,
const char* value) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_mdelem md =
- grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_copied_string(key),
- grpc_slice_from_copied_string(value));
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_mdelem md = grpc_mdelem_from_slices(
+ grpc_slice_from_copied_string(key), grpc_slice_from_copied_string(value));
grpc_chttp2_hptbl_find_result r = grpc_chttp2_hptbl_find(tbl, md);
- GRPC_MDELEM_UNREF(&exec_ctx, md);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(md);
+
return r;
}
static void test_find(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_chttp2_hptbl tbl;
uint32_t i;
char buffer[32];
@@ -175,21 +171,19 @@ static void test_find(void) {
LOG_TEST("test_find");
- grpc_chttp2_hptbl_init(&exec_ctx, &tbl);
- elem =
- grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_static_string("abc"),
- grpc_slice_from_static_string("xyz"));
- GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(&exec_ctx, elem);
- elem =
- grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_static_string("abc"),
- grpc_slice_from_static_string("123"));
- GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(&exec_ctx, elem);
- elem = grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_static_string("x"),
+ grpc_chttp2_hptbl_init(&tbl);
+ elem = grpc_mdelem_from_slices(grpc_slice_from_static_string("abc"),
+ grpc_slice_from_static_string("xyz"));
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(elem);
+ elem = grpc_mdelem_from_slices(grpc_slice_from_static_string("abc"),
+ grpc_slice_from_static_string("123"));
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(elem);
+ elem = grpc_mdelem_from_slices(grpc_slice_from_static_string("x"),
grpc_slice_from_static_string("1"));
- GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(&exec_ctx, elem);
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(elem);
r = find_simple(&tbl, "abc", "123");
GPR_ASSERT(r.index == 2 + GRPC_CHTTP2_LAST_STATIC_ENTRY);
@@ -238,11 +232,10 @@ static void test_find(void) {
/* overflow the string buffer, check find still works */
for (i = 0; i < 10000; i++) {
int64_ttoa(i, buffer);
- elem = grpc_mdelem_from_slices(&exec_ctx,
- grpc_slice_from_static_string("test"),
+ elem = grpc_mdelem_from_slices(grpc_slice_from_static_string("test"),
grpc_slice_from_copied_string(buffer));
- GPR_ASSERT(grpc_chttp2_hptbl_add(&exec_ctx, &tbl, elem) == GRPC_ERROR_NONE);
- GRPC_MDELEM_UNREF(&exec_ctx, elem);
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem) == GRPC_ERROR_NONE);
+ GRPC_MDELEM_UNREF(elem);
}
r = find_simple(&tbl, "abc", "123");
@@ -270,8 +263,7 @@ static void test_find(void) {
GPR_ASSERT(r.index != 0);
GPR_ASSERT(r.has_value == 0);
- grpc_chttp2_hptbl_destroy(&exec_ctx, &tbl);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_hptbl_destroy(&tbl);
}
int main(int argc, char** argv) {
diff --git a/test/core/transport/connectivity_state_test.cc b/test/core/transport/connectivity_state_test.cc
index 7a22ec848d..06bb093d32 100644
--- a/test/core/transport/connectivity_state_test.cc
+++ b/test/core/transport/connectivity_state_test.cc
@@ -28,14 +28,13 @@
int g_counter;
-static void must_succeed(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void must_succeed(void* arg, grpc_error* error) {
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(arg == THE_ARG);
g_counter++;
}
-static void must_fail(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void must_fail(void* arg, grpc_error* error) {
GPR_ASSERT(error != GRPC_ERROR_NONE);
GPR_ASSERT(arg == THE_ARG);
g_counter++;
@@ -58,7 +57,7 @@ static void test_connectivity_state_name(void) {
static void test_check(void) {
grpc_connectivity_state_tracker tracker;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_error* error;
gpr_log(GPR_DEBUG, "test_check");
grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_IDLE, "xxx");
@@ -66,8 +65,7 @@ static void test_check(void) {
GRPC_CHANNEL_IDLE);
GPR_ASSERT(grpc_connectivity_state_check(&tracker) == GRPC_CHANNEL_IDLE);
GPR_ASSERT(error == GRPC_ERROR_NONE);
- grpc_connectivity_state_destroy(&exec_ctx, &tracker);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_connectivity_state_destroy(&tracker);
}
static void test_subscribe_then_unsubscribe(void) {
@@ -75,23 +73,21 @@ static void test_subscribe_then_unsubscribe(void) {
grpc_closure* closure =
GRPC_CLOSURE_CREATE(must_fail, THE_ARG, grpc_schedule_on_exec_ctx);
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_DEBUG, "test_subscribe_then_unsubscribe");
g_counter = 0;
grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_IDLE, "xxx");
- GPR_ASSERT(grpc_connectivity_state_notify_on_state_change(&exec_ctx, &tracker,
- &state, closure));
- grpc_exec_ctx_flush(&exec_ctx);
+ GPR_ASSERT(grpc_connectivity_state_notify_on_state_change(&tracker, &state,
+ closure));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(state == GRPC_CHANNEL_IDLE);
GPR_ASSERT(g_counter == 0);
- grpc_connectivity_state_notify_on_state_change(&exec_ctx, &tracker, nullptr,
- closure);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_connectivity_state_notify_on_state_change(&tracker, nullptr, closure);
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(state == GRPC_CHANNEL_IDLE);
GPR_ASSERT(g_counter == 1);
- grpc_connectivity_state_destroy(&exec_ctx, &tracker);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_connectivity_state_destroy(&tracker);
}
static void test_subscribe_then_destroy(void) {
@@ -99,17 +95,17 @@ static void test_subscribe_then_destroy(void) {
grpc_closure* closure =
GRPC_CLOSURE_CREATE(must_succeed, THE_ARG, grpc_schedule_on_exec_ctx);
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_DEBUG, "test_subscribe_then_destroy");
g_counter = 0;
grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_IDLE, "xxx");
- GPR_ASSERT(grpc_connectivity_state_notify_on_state_change(&exec_ctx, &tracker,
- &state, closure));
- grpc_exec_ctx_flush(&exec_ctx);
+ GPR_ASSERT(grpc_connectivity_state_notify_on_state_change(&tracker, &state,
+ closure));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(state == GRPC_CHANNEL_IDLE);
GPR_ASSERT(g_counter == 0);
- grpc_connectivity_state_destroy(&exec_ctx, &tracker);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_connectivity_state_destroy(&tracker);
+
GPR_ASSERT(state == GRPC_CHANNEL_SHUTDOWN);
GPR_ASSERT(g_counter == 1);
}
@@ -119,17 +115,17 @@ static void test_subscribe_with_failure_then_destroy(void) {
grpc_closure* closure =
GRPC_CLOSURE_CREATE(must_fail, THE_ARG, grpc_schedule_on_exec_ctx);
grpc_connectivity_state state = GRPC_CHANNEL_SHUTDOWN;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_DEBUG, "test_subscribe_with_failure_then_destroy");
g_counter = 0;
grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_SHUTDOWN, "xxx");
GPR_ASSERT(0 == grpc_connectivity_state_notify_on_state_change(
- &exec_ctx, &tracker, &state, closure));
- grpc_exec_ctx_flush(&exec_ctx);
+ &tracker, &state, closure));
+ grpc_core::ExecCtx::Get()->Flush();
GPR_ASSERT(state == GRPC_CHANNEL_SHUTDOWN);
GPR_ASSERT(g_counter == 0);
- grpc_connectivity_state_destroy(&exec_ctx, &tracker);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_connectivity_state_destroy(&tracker);
+
GPR_ASSERT(state == GRPC_CHANNEL_SHUTDOWN);
GPR_ASSERT(g_counter == 1);
}
diff --git a/test/core/transport/metadata_test.cc b/test/core/transport/metadata_test.cc
index b60a9619fb..e5bdc5901d 100644
--- a/test/core/transport/metadata_test.cc
+++ b/test/core/transport/metadata_test.cc
@@ -60,15 +60,15 @@ static void test_create_metadata(bool intern_keys, bool intern_values) {
intern_keys, intern_values);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
m1 = grpc_mdelem_from_slices(
- &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values));
m2 = grpc_mdelem_from_slices(
- &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values));
m3 = grpc_mdelem_from_slices(
- &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("c"), intern_values));
GPR_ASSERT(grpc_mdelem_eq(m1, m2));
GPR_ASSERT(!grpc_mdelem_eq(m3, m1));
@@ -77,10 +77,10 @@ static void test_create_metadata(bool intern_keys, bool intern_values) {
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDKEY(m1), "a") == 0);
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDVALUE(m1), "b") == 0);
GPR_ASSERT(grpc_slice_str_cmp(GRPC_MDVALUE(m3), "c") == 0);
- GRPC_MDELEM_UNREF(&exec_ctx, m1);
- GRPC_MDELEM_UNREF(&exec_ctx, m2);
- GRPC_MDELEM_UNREF(&exec_ctx, m3);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(m1);
+ GRPC_MDELEM_UNREF(m2);
+ GRPC_MDELEM_UNREF(m3);
+
grpc_shutdown();
}
@@ -95,19 +95,15 @@ static void test_create_many_ephemeral_metadata(bool intern_keys,
intern_keys, intern_values);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
/* add, and immediately delete a bunch of different elements */
for (i = 0; i < MANY; i++) {
gpr_ltoa(i, buffer);
- GRPC_MDELEM_UNREF(
- &exec_ctx,
- grpc_mdelem_from_slices(
- &exec_ctx,
- maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
- maybe_intern(grpc_slice_from_copied_string(buffer),
- intern_values)));
+ GRPC_MDELEM_UNREF(grpc_mdelem_from_slices(
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_copied_string(buffer), intern_values)));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_shutdown();
}
@@ -121,28 +117,28 @@ static void test_create_many_persistant_metadata(void) {
gpr_log(GPR_INFO, "test_create_many_persistant_metadata");
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
/* add phase */
for (i = 0; i < MANY; i++) {
gpr_ltoa(i, buffer);
created[i] = grpc_mdelem_from_slices(
- &exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("a")),
+ grpc_slice_intern(grpc_slice_from_static_string("a")),
grpc_slice_intern(grpc_slice_from_static_string(buffer)));
}
/* verify phase */
for (i = 0; i < MANY; i++) {
gpr_ltoa(i, buffer);
md = grpc_mdelem_from_slices(
- &exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("a")),
+ grpc_slice_intern(grpc_slice_from_static_string("a")),
grpc_slice_intern(grpc_slice_from_static_string(buffer)));
GPR_ASSERT(grpc_mdelem_eq(md, created[i]));
- GRPC_MDELEM_UNREF(&exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
}
/* cleanup phase */
for (i = 0; i < MANY; i++) {
- GRPC_MDELEM_UNREF(&exec_ctx, created[i]);
+ GRPC_MDELEM_UNREF(created[i]);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_shutdown();
gpr_free(created);
@@ -155,31 +151,25 @@ static void test_spin_creating_the_same_thing(bool intern_keys,
intern_keys, intern_values);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem a, b, c;
GRPC_MDELEM_UNREF(
- &exec_ctx,
a = grpc_mdelem_from_slices(
- &exec_ctx,
maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values)));
GRPC_MDELEM_UNREF(
- &exec_ctx,
b = grpc_mdelem_from_slices(
- &exec_ctx,
maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values)));
GRPC_MDELEM_UNREF(
- &exec_ctx,
c = grpc_mdelem_from_slices(
- &exec_ctx,
maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values)));
if (intern_keys && intern_values) {
GPR_ASSERT(a.payload == b.payload);
GPR_ASSERT(a.payload == c.payload);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_shutdown();
}
@@ -188,16 +178,16 @@ static void test_identity_laws(bool intern_keys, bool intern_values) {
intern_keys, intern_values);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem a, b, c;
a = grpc_mdelem_from_slices(
- &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values));
b = grpc_mdelem_from_slices(
- &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values));
c = grpc_mdelem_from_slices(
- &exec_ctx, maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
+ maybe_intern(grpc_slice_from_static_string("a"), intern_keys),
maybe_intern(grpc_slice_from_static_string("b"), intern_values));
GPR_ASSERT(grpc_mdelem_eq(a, a));
GPR_ASSERT(grpc_mdelem_eq(b, b));
@@ -216,10 +206,10 @@ static void test_identity_laws(bool intern_keys, bool intern_values) {
GPR_ASSERT(a.payload != c.payload);
GPR_ASSERT(b.payload != c.payload);
}
- GRPC_MDELEM_UNREF(&exec_ctx, a);
- GRPC_MDELEM_UNREF(&exec_ctx, b);
- GRPC_MDELEM_UNREF(&exec_ctx, c);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(a);
+ GRPC_MDELEM_UNREF(b);
+ GRPC_MDELEM_UNREF(c);
+
grpc_shutdown();
}
@@ -235,7 +225,7 @@ static void test_things_stick_around(void) {
gpr_log(GPR_INFO, "test_things_stick_around");
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
for (i = 0; i < nstrs; i++) {
gpr_asprintf(&buffer, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%" PRIuPTR "x", i);
@@ -246,7 +236,7 @@ static void test_things_stick_around(void) {
for (i = 0; i < nstrs; i++) {
grpc_slice_ref_internal(strs[i]);
- grpc_slice_unref_internal(&exec_ctx, strs[i]);
+ grpc_slice_unref_internal(strs[i]);
}
for (i = 0; i < nstrs; i++) {
@@ -258,18 +248,17 @@ static void test_things_stick_around(void) {
}
for (i = 0; i < nstrs; i++) {
- grpc_slice_unref_internal(&exec_ctx, strs[shuf[i]]);
+ grpc_slice_unref_internal(strs[shuf[i]]);
for (j = i + 1; j < nstrs; j++) {
gpr_asprintf(&buffer, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%" PRIuPTR "x",
shuf[j]);
test = grpc_slice_intern(grpc_slice_from_static_string(buffer));
GPR_ASSERT(grpc_slice_is_equivalent(test, strs[shuf[j]]));
- grpc_slice_unref_internal(&exec_ctx, test);
+ grpc_slice_unref_internal(test);
gpr_free(buffer);
}
}
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
gpr_free(strs);
gpr_free(shuf);
@@ -282,39 +271,38 @@ static void test_user_data_works(void) {
gpr_log(GPR_INFO, "test_user_data_works");
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
ud1 = static_cast<int*>(gpr_malloc(sizeof(int)));
*ud1 = 1;
ud2 = static_cast<int*>(gpr_malloc(sizeof(int)));
*ud2 = 2;
md = grpc_mdelem_from_slices(
- &exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc")),
+ grpc_slice_intern(grpc_slice_from_static_string("abc")),
grpc_slice_intern(grpc_slice_from_static_string("123")));
grpc_mdelem_set_user_data(md, gpr_free, ud1);
grpc_mdelem_set_user_data(md, gpr_free, ud2);
GPR_ASSERT(grpc_mdelem_get_user_data(md, gpr_free) == ud1);
- GRPC_MDELEM_UNREF(&exec_ctx, md);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(md);
+
grpc_shutdown();
}
-static void verify_ascii_header_size(grpc_exec_ctx* exec_ctx, const char* key,
- const char* value, bool intern_key,
- bool intern_value) {
+static void verify_ascii_header_size(const char* key, const char* value,
+ bool intern_key, bool intern_value) {
grpc_mdelem elem = grpc_mdelem_from_slices(
- exec_ctx, maybe_intern(grpc_slice_from_static_string(key), intern_key),
+ maybe_intern(grpc_slice_from_static_string(key), intern_key),
maybe_intern(grpc_slice_from_static_string(value), intern_value));
size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem, false);
size_t expected_size = 32 + strlen(key) + strlen(value);
GPR_ASSERT(expected_size == elem_size);
- GRPC_MDELEM_UNREF(exec_ctx, elem);
+ GRPC_MDELEM_UNREF(elem);
}
-static void verify_binary_header_size(grpc_exec_ctx* exec_ctx, const char* key,
- const uint8_t* value, size_t value_len,
- bool intern_key, bool intern_value) {
+static void verify_binary_header_size(const char* key, const uint8_t* value,
+ size_t value_len, bool intern_key,
+ bool intern_value) {
grpc_mdelem elem = grpc_mdelem_from_slices(
- exec_ctx, maybe_intern(grpc_slice_from_static_string(key), intern_key),
+ maybe_intern(grpc_slice_from_static_string(key), intern_key),
maybe_intern(grpc_slice_from_static_buffer(value, value_len),
intern_value));
GPR_ASSERT(grpc_is_binary_header(GRPC_MDKEY(elem)));
@@ -324,9 +312,9 @@ static void verify_binary_header_size(grpc_exec_ctx* exec_ctx, const char* key,
grpc_slice base64_encoded = grpc_chttp2_base64_encode(value_slice);
size_t expected_size = 32 + strlen(key) + GRPC_SLICE_LENGTH(base64_encoded);
GPR_ASSERT(expected_size == elem_size);
- grpc_slice_unref_internal(exec_ctx, value_slice);
- grpc_slice_unref_internal(exec_ctx, base64_encoded);
- GRPC_MDELEM_UNREF(exec_ctx, elem);
+ grpc_slice_unref_internal(value_slice);
+ grpc_slice_unref_internal(base64_encoded);
+ GRPC_MDELEM_UNREF(elem);
}
#define BUFFER_SIZE 64
@@ -334,27 +322,23 @@ static void test_mdelem_sizes_in_hpack(bool intern_key, bool intern_value) {
gpr_log(GPR_INFO, "test_mdelem_size: intern_key=%d intern_value=%d",
intern_key, intern_value);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
uint8_t binary_value[BUFFER_SIZE] = {0};
for (uint8_t i = 0; i < BUFFER_SIZE; i++) {
binary_value[i] = i;
}
- verify_ascii_header_size(&exec_ctx, "hello", "world", intern_key,
- intern_value);
- verify_ascii_header_size(&exec_ctx, "hello",
- "worldxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", intern_key,
- intern_value);
- verify_ascii_header_size(&exec_ctx, ":scheme", "http", intern_key,
- intern_value);
+ verify_ascii_header_size("hello", "world", intern_key, intern_value);
+ verify_ascii_header_size("hello", "worldxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+ intern_key, intern_value);
+ verify_ascii_header_size(":scheme", "http", intern_key, intern_value);
for (uint8_t i = 0; i < BUFFER_SIZE; i++) {
- verify_binary_header_size(&exec_ctx, "hello-bin", binary_value, i,
- intern_key, intern_value);
+ verify_binary_header_size("hello-bin", binary_value, i, intern_key,
+ intern_value);
}
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
}
@@ -362,13 +346,13 @@ static void test_copied_static_metadata(bool dup_key, bool dup_value) {
gpr_log(GPR_INFO, "test_static_metadata: dup_key=%d dup_value=%d", dup_key,
dup_value);
grpc_init();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
for (size_t i = 0; i < GRPC_STATIC_MDELEM_COUNT; i++) {
grpc_mdelem p = GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[i],
GRPC_MDELEM_STORAGE_STATIC);
grpc_mdelem q =
- grpc_mdelem_from_slices(&exec_ctx, maybe_dup(GRPC_MDKEY(p), dup_key),
+ grpc_mdelem_from_slices(maybe_dup(GRPC_MDKEY(p), dup_key),
maybe_dup(GRPC_MDVALUE(p), dup_value));
GPR_ASSERT(grpc_mdelem_eq(p, q));
if (dup_key || dup_value) {
@@ -376,11 +360,10 @@ static void test_copied_static_metadata(bool dup_key, bool dup_value) {
} else {
GPR_ASSERT(p.payload == q.payload);
}
- GRPC_MDELEM_UNREF(&exec_ctx, p);
- GRPC_MDELEM_UNREF(&exec_ctx, q);
+ GRPC_MDELEM_UNREF(p);
+ GRPC_MDELEM_UNREF(q);
}
- grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown();
}
diff --git a/test/core/transport/status_conversion_test.cc b/test/core/transport/status_conversion_test.cc
index 7af5d12cb7..2a192e04ef 100644
--- a/test/core/transport/status_conversion_test.cc
+++ b/test/core/transport/status_conversion_test.cc
@@ -22,12 +22,11 @@
#define GRPC_STATUS_TO_HTTP2_ERROR(a, b) \
GPR_ASSERT(grpc_status_to_http2_error(a) == (b))
-#define HTTP2_ERROR_TO_GRPC_STATUS(a, deadline, b) \
- do { \
- grpc_exec_ctx my_exec_ctx = GRPC_EXEC_CTX_INIT; \
- GPR_ASSERT(grpc_http2_error_to_grpc_status(&my_exec_ctx, a, deadline) == \
- (b)); \
- grpc_exec_ctx_finish(&my_exec_ctx); \
+#define HTTP2_ERROR_TO_GRPC_STATUS(a, deadline, b) \
+ do { \
+ grpc_core::ExecCtx _local_exec_ctx; \
+ GPR_ASSERT(grpc_http2_error_to_grpc_status(a, deadline) == (b)); \
+ \
} while (0)
#define GRPC_STATUS_TO_HTTP2_STATUS(a, b) \
GPR_ASSERT(grpc_status_to_http2_status(a) == (b))
diff --git a/test/core/transport/stream_owned_slice_test.cc b/test/core/transport/stream_owned_slice_test.cc
index e82df2117d..d25d83c2c6 100644
--- a/test/core/transport/stream_owned_slice_test.cc
+++ b/test/core/transport/stream_owned_slice_test.cc
@@ -22,7 +22,7 @@
#include <grpc/support/log.h>
-static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
+static void do_nothing(void* arg, grpc_error* error) {}
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
diff --git a/test/core/util/mock_endpoint.cc b/test/core/util/mock_endpoint.cc
index d9545efa49..4b35a581b1 100644
--- a/test/core/util/mock_endpoint.cc
+++ b/test/core/util/mock_endpoint.cc
@@ -40,13 +40,13 @@ typedef struct grpc_mock_endpoint {
grpc_resource_user* resource_user;
} grpc_mock_endpoint;
-static void me_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
+static void me_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
gpr_mu_lock(&m->mu);
if (m->read_buffer.count > 0) {
grpc_slice_buffer_swap(&m->read_buffer, slices);
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_NONE);
} else {
m->on_read = cb;
m->on_read_out = slices;
@@ -54,44 +54,41 @@ static void me_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
gpr_mu_unlock(&m->mu);
}
-static void me_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
+static void me_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
for (size_t i = 0; i < slices->count; i++) {
m->on_write(slices->slices[i]);
}
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_NONE);
}
-static void me_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset* pollset) {}
+static void me_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {}
-static void me_add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
+static void me_add_to_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset) {}
-static void me_delete_from_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* ep,
+static void me_delete_from_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset) {}
-static void me_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_error* why) {
+static void me_shutdown(grpc_endpoint* ep, grpc_error* why) {
grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
gpr_mu_lock(&m->mu);
if (m->on_read) {
- GRPC_CLOSURE_SCHED(exec_ctx, m->on_read,
+ GRPC_CLOSURE_SCHED(m->on_read,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Endpoint Shutdown", &why, 1));
m->on_read = nullptr;
}
gpr_mu_unlock(&m->mu);
- grpc_resource_user_shutdown(exec_ctx, m->resource_user);
+ grpc_resource_user_shutdown(m->resource_user);
GRPC_ERROR_UNREF(why);
}
-static void me_destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) {
+static void me_destroy(grpc_endpoint* ep) {
grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
grpc_slice_buffer_destroy(&m->read_buffer);
- grpc_resource_user_unref(exec_ctx, m->resource_user);
+ grpc_resource_user_unref(m->resource_user);
gpr_free(m);
}
@@ -134,13 +131,12 @@ grpc_endpoint* grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice),
return &m->base;
}
-void grpc_mock_endpoint_put_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice slice) {
+void grpc_mock_endpoint_put_read(grpc_endpoint* ep, grpc_slice slice) {
grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
gpr_mu_lock(&m->mu);
if (m->on_read != nullptr) {
grpc_slice_buffer_add(m->on_read_out, slice);
- GRPC_CLOSURE_SCHED(exec_ctx, m->on_read, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(m->on_read, GRPC_ERROR_NONE);
m->on_read = nullptr;
} else {
grpc_slice_buffer_add(&m->read_buffer, slice);
diff --git a/test/core/util/mock_endpoint.h b/test/core/util/mock_endpoint.h
index ccabaf7c3b..6521d3e8e8 100644
--- a/test/core/util/mock_endpoint.h
+++ b/test/core/util/mock_endpoint.h
@@ -23,8 +23,7 @@
grpc_endpoint* grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice),
grpc_resource_quota* resource_quota);
-void grpc_mock_endpoint_put_read(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* mock_endpoint,
+void grpc_mock_endpoint_put_read(grpc_endpoint* mock_endpoint,
grpc_slice slice);
#endif
diff --git a/test/core/util/passthru_endpoint.cc b/test/core/util/passthru_endpoint.cc
index a9efe22b69..5f127cb960 100644
--- a/test/core/util/passthru_endpoint.cc
+++ b/test/core/util/passthru_endpoint.cc
@@ -49,22 +49,22 @@ struct passthru_endpoint {
int halves;
grpc_passthru_endpoint_stats* stats;
grpc_passthru_endpoint_stats
- dummy_stats; // used if constructor stats == NULL
+ dummy_stats; // used if constructor stats == nullptr
bool shutdown;
half client;
half server;
};
-static void me_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
+static void me_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
half* m = (half*)ep;
gpr_mu_lock(&m->parent->mu);
if (m->parent->shutdown) {
GRPC_CLOSURE_SCHED(
- exec_ctx, cb, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already shutdown"));
+ cb, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already shutdown"));
} else if (m->read_buffer.count > 0) {
grpc_slice_buffer_swap(&m->read_buffer, slices);
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_NONE);
} else {
m->on_read = cb;
m->on_read_out = slices;
@@ -77,8 +77,8 @@ static half* other_half(half* h) {
return &h->parent->client;
}
-static void me_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
+static void me_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
half* m = other_half((half*)ep);
gpr_mu_lock(&m->parent->mu);
grpc_error* error = GRPC_ERROR_NONE;
@@ -89,7 +89,7 @@ static void me_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
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);
+ GRPC_CLOSURE_SCHED(m->on_read, GRPC_ERROR_NONE);
m->on_read = nullptr;
} else {
for (size_t i = 0; i < slices->count; i++) {
@@ -98,52 +98,49 @@ static void me_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
}
}
gpr_mu_unlock(&m->parent->mu);
- GRPC_CLOSURE_SCHED(exec_ctx, cb, error);
+ GRPC_CLOSURE_SCHED(cb, error);
}
-static void me_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset* pollset) {}
+static void me_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {}
-static void me_add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
+static void me_add_to_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset) {}
-static void me_delete_from_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* ep,
+static void me_delete_from_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset) {}
-static void me_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_error* why) {
+static void me_shutdown(grpc_endpoint* ep, grpc_error* why) {
half* m = (half*)ep;
gpr_mu_lock(&m->parent->mu);
m->parent->shutdown = true;
if (m->on_read) {
GRPC_CLOSURE_SCHED(
- exec_ctx, m->on_read,
+ m->on_read,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Shutdown", &why, 1));
m->on_read = nullptr;
}
m = other_half(m);
if (m->on_read) {
GRPC_CLOSURE_SCHED(
- exec_ctx, m->on_read,
+ m->on_read,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Shutdown", &why, 1));
m->on_read = nullptr;
}
gpr_mu_unlock(&m->parent->mu);
- grpc_resource_user_shutdown(exec_ctx, m->resource_user);
+ grpc_resource_user_shutdown(m->resource_user);
GRPC_ERROR_UNREF(why);
}
-static void me_destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) {
+static void me_destroy(grpc_endpoint* ep) {
passthru_endpoint* p = ((half*)ep)->parent;
gpr_mu_lock(&p->mu);
if (0 == --p->halves) {
gpr_mu_unlock(&p->mu);
gpr_mu_destroy(&p->mu);
- grpc_slice_buffer_destroy_internal(exec_ctx, &p->client.read_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &p->server.read_buffer);
- grpc_resource_user_unref(exec_ctx, p->client.resource_user);
- grpc_resource_user_unref(exec_ctx, p->server.resource_user);
+ grpc_slice_buffer_destroy_internal(&p->client.read_buffer);
+ grpc_slice_buffer_destroy_internal(&p->server.read_buffer);
+ grpc_resource_user_unref(p->client.resource_user);
+ grpc_resource_user_unref(p->server.resource_user);
gpr_free(p);
} else {
gpr_mu_unlock(&p->mu);
diff --git a/test/core/util/port_server_client.cc b/test/core/util/port_server_client.cc
index edec50b424..7efa951862 100644
--- a/test/core/util/port_server_client.cc
+++ b/test/core/util/port_server_client.cc
@@ -40,22 +40,19 @@ typedef struct freereq {
int done;
} freereq;
-static void destroy_pops_and_shutdown(grpc_exec_ctx* exec_ctx, void* p,
- grpc_error* error) {
+static void destroy_pops_and_shutdown(void* p, grpc_error* error) {
grpc_pollset* pollset = grpc_polling_entity_pollset((grpc_polling_entity*)p);
- grpc_pollset_destroy(exec_ctx, pollset);
+ grpc_pollset_destroy(pollset);
gpr_free(pollset);
}
-static void freed_port_from_server(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void freed_port_from_server(void* arg, grpc_error* error) {
freereq* pr = (freereq*)arg;
gpr_mu_lock(pr->mu);
pr->done = 1;
GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&pr->pops),
- nullptr));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&pr->pops), nullptr));
gpr_mu_unlock(pr->mu);
}
@@ -65,7 +62,7 @@ void grpc_free_port_using_server(int port) {
grpc_httpcli_response rsp;
freereq pr;
char* path;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_closure* shutdown_closure;
grpc_init();
@@ -87,30 +84,30 @@ void grpc_free_port_using_server(int port) {
grpc_httpcli_context_init(&context);
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("port_server_client/free");
- grpc_httpcli_get(&exec_ctx, &context, &pr.pops, resource_quota, &req,
- grpc_exec_ctx_now(&exec_ctx) + 30 * GPR_MS_PER_SEC,
+ grpc_httpcli_get(&context, &pr.pops, resource_quota, &req,
+ grpc_core::ExecCtx::Get()->Now() + 30 * GPR_MS_PER_SEC,
GRPC_CLOSURE_CREATE(freed_port_from_server, &pr,
grpc_schedule_on_exec_ctx),
&rsp);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_resource_quota_unref_internal(resource_quota);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(pr.mu);
while (!pr.done) {
grpc_pollset_worker* worker = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&pr.pops),
- &worker,
- grpc_exec_ctx_now(&exec_ctx) + GPR_MS_PER_SEC))) {
+ grpc_pollset_work(
+ grpc_polling_entity_pollset(&pr.pops), &worker,
+ grpc_core::ExecCtx::Get()->Now() + GPR_MS_PER_SEC))) {
pr.done = 1;
}
}
gpr_mu_unlock(pr.mu);
- grpc_httpcli_context_destroy(&exec_ctx, &context);
- grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&pr.pops),
+ grpc_httpcli_context_destroy(&context);
+ grpc_pollset_shutdown(grpc_polling_entity_pollset(&pr.pops),
shutdown_closure);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_free(path);
grpc_http_response_destroy(&rsp);
@@ -127,8 +124,7 @@ typedef struct portreq {
grpc_httpcli_response response;
} portreq;
-static void got_port_from_server(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void got_port_from_server(void* arg, grpc_error* error) {
size_t i;
int port = 0;
portreq* pr = (portreq*)arg;
@@ -154,8 +150,7 @@ static void got_port_from_server(grpc_exec_ctx* exec_ctx, void* arg,
pr->port = 0;
GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&pr->pops),
- nullptr));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&pr->pops), nullptr));
gpr_mu_unlock(pr->mu);
return;
}
@@ -172,12 +167,12 @@ static void got_port_from_server(grpc_exec_ctx* exec_ctx, void* arg,
memset(&pr->response, 0, sizeof(pr->response));
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("port_server_client/pick_retry");
- grpc_httpcli_get(exec_ctx, pr->ctx, &pr->pops, resource_quota, &req,
- grpc_exec_ctx_now(exec_ctx) + 30 * GPR_MS_PER_SEC,
+ grpc_httpcli_get(pr->ctx, &pr->pops, resource_quota, &req,
+ grpc_core::ExecCtx::Get()->Now() + 30 * GPR_MS_PER_SEC,
GRPC_CLOSURE_CREATE(got_port_from_server, pr,
grpc_schedule_on_exec_ctx),
&pr->response);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
return;
}
GPR_ASSERT(response);
@@ -191,8 +186,7 @@ static void got_port_from_server(grpc_exec_ctx* exec_ctx, void* arg,
pr->port = port;
GRPC_LOG_IF_ERROR(
"pollset_kick",
- grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&pr->pops),
- nullptr));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&pr->pops), nullptr));
gpr_mu_unlock(pr->mu);
}
@@ -200,7 +194,7 @@ int grpc_pick_port_using_server(void) {
grpc_httpcli_context context;
grpc_httpcli_request req;
portreq pr;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_closure* shutdown_closure;
grpc_init();
@@ -223,30 +217,30 @@ int grpc_pick_port_using_server(void) {
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("port_server_client/pick");
grpc_httpcli_get(
- &exec_ctx, &context, &pr.pops, resource_quota, &req,
- grpc_exec_ctx_now(&exec_ctx) + 30 * GPR_MS_PER_SEC,
+ &context, &pr.pops, resource_quota, &req,
+ grpc_core::ExecCtx::Get()->Now() + 30 * GPR_MS_PER_SEC,
GRPC_CLOSURE_CREATE(got_port_from_server, &pr, grpc_schedule_on_exec_ctx),
&pr.response);
- grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_resource_quota_unref_internal(resource_quota);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(pr.mu);
while (pr.port == -1) {
grpc_pollset_worker* worker = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&pr.pops),
- &worker,
- grpc_exec_ctx_now(&exec_ctx) + GPR_MS_PER_SEC))) {
+ grpc_pollset_work(
+ grpc_polling_entity_pollset(&pr.pops), &worker,
+ grpc_core::ExecCtx::Get()->Now() + GPR_MS_PER_SEC))) {
pr.port = 0;
}
}
gpr_mu_unlock(pr.mu);
grpc_http_response_destroy(&pr.response);
- grpc_httpcli_context_destroy(&exec_ctx, &context);
- grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&pr.pops),
+ grpc_httpcli_context_destroy(&context);
+ grpc_pollset_shutdown(grpc_polling_entity_pollset(&pr.pops),
shutdown_closure);
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_shutdown();
return pr.port;
diff --git a/test/core/util/reconnect_server.cc b/test/core/util/reconnect_server.cc
index 4775b074eb..bcafc4e898 100644
--- a/test/core/util/reconnect_server.cc
+++ b/test/core/util/reconnect_server.cc
@@ -55,7 +55,7 @@ static void pretty_print_backoffs(reconnect_server* server) {
}
}
-static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
+static void on_connect(void* arg, grpc_endpoint* tcp,
grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) {
gpr_free(acceptor);
@@ -65,9 +65,9 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp,
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
timestamp_list* new_tail;
peer = grpc_endpoint_get_peer(tcp);
- grpc_endpoint_shutdown(exec_ctx, tcp,
+ grpc_endpoint_shutdown(tcp,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
- grpc_endpoint_destroy(exec_ctx, tcp);
+ grpc_endpoint_destroy(tcp);
if (peer) {
last_colon = strrchr(peer, ':');
if (server->peer == nullptr) {
diff --git a/test/core/util/test_tcp_server.cc b/test/core/util/test_tcp_server.cc
index da34da6fd0..71e6f3af2c 100644
--- a/test/core/util/test_tcp_server.cc
+++ b/test/core/util/test_tcp_server.cc
@@ -33,8 +33,7 @@
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
-static void on_server_destroyed(grpc_exec_ctx* exec_ctx, void* data,
- grpc_error* error) {
+static void on_server_destroyed(void* data, grpc_error* error) {
test_tcp_server* server = static_cast<test_tcp_server*>(data);
server->shutdown = 1;
}
@@ -56,51 +55,46 @@ void test_tcp_server_start(test_tcp_server* server, int port) {
grpc_resolved_address resolved_addr;
struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
int port_added;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
addr->sin_family = AF_INET;
addr->sin_port = htons((uint16_t)port);
memset(&addr->sin_addr, 0, sizeof(addr->sin_addr));
- grpc_error* error = grpc_tcp_server_create(
- &exec_ctx, &server->shutdown_complete, nullptr, &server->tcp_server);
+ grpc_error* error = grpc_tcp_server_create(&server->shutdown_complete,
+ nullptr, &server->tcp_server);
GPR_ASSERT(error == GRPC_ERROR_NONE);
error =
grpc_tcp_server_add_port(server->tcp_server, &resolved_addr, &port_added);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(port_added == port);
- grpc_tcp_server_start(&exec_ctx, server->tcp_server, &server->pollset, 1,
+ grpc_tcp_server_start(server->tcp_server, &server->pollset, 1,
server->on_connect, server->cb_data);
gpr_log(GPR_INFO, "test tcp server listening on 0.0.0.0:%d", port);
-
- grpc_exec_ctx_finish(&exec_ctx);
}
void test_tcp_server_poll(test_tcp_server* server, int seconds) {
grpc_pollset_worker* worker = nullptr;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_millis deadline = grpc_timespec_to_millis_round_up(
grpc_timeout_seconds_to_deadline(seconds));
gpr_mu_lock(server->mu);
- GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(&exec_ctx, server->pollset, &worker, deadline));
+ GRPC_LOG_IF_ERROR("pollset_work",
+ grpc_pollset_work(server->pollset, &worker, deadline));
gpr_mu_unlock(server->mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
-static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
-static void finish_pollset(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(arg));
+static void do_nothing(void* arg, grpc_error* error) {}
+static void finish_pollset(void* arg, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(arg));
}
void test_tcp_server_destroy(test_tcp_server* server) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_timespec shutdown_deadline;
grpc_closure do_nothing_cb;
- grpc_tcp_server_unref(&exec_ctx, server->tcp_server);
+ grpc_tcp_server_unref(server->tcp_server);
GRPC_CLOSURE_INIT(&do_nothing_cb, do_nothing, nullptr,
grpc_schedule_on_exec_ctx);
shutdown_deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
@@ -109,10 +103,10 @@ void test_tcp_server_destroy(test_tcp_server* server) {
gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), shutdown_deadline) < 0) {
test_tcp_server_poll(server, 1);
}
- grpc_pollset_shutdown(&exec_ctx, server->pollset,
+ grpc_pollset_shutdown(server->pollset,
GRPC_CLOSURE_CREATE(finish_pollset, server->pollset,
grpc_schedule_on_exec_ctx));
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_free(server->pollset);
grpc_shutdown();
}
diff --git a/test/core/util/trickle_endpoint.cc b/test/core/util/trickle_endpoint.cc
index 4544fb7f49..f95ed62463 100644
--- a/test/core/util/trickle_endpoint.cc
+++ b/test/core/util/trickle_endpoint.cc
@@ -45,24 +45,23 @@ typedef struct {
grpc_closure* write_cb;
} trickle_endpoint;
-static void te_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
+static void te_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
trickle_endpoint* te = (trickle_endpoint*)ep;
- grpc_endpoint_read(exec_ctx, te->wrapped, slices, cb);
+ grpc_endpoint_read(te->wrapped, slices, cb);
}
-static void maybe_call_write_cb_locked(grpc_exec_ctx* exec_ctx,
- trickle_endpoint* te) {
+static void maybe_call_write_cb_locked(trickle_endpoint* te) {
if (te->write_cb != nullptr &&
(te->error != GRPC_ERROR_NONE ||
te->write_buffer.length <= WRITE_BUFFER_SIZE)) {
- GRPC_CLOSURE_SCHED(exec_ctx, te->write_cb, GRPC_ERROR_REF(te->error));
+ GRPC_CLOSURE_SCHED(te->write_cb, GRPC_ERROR_REF(te->error));
te->write_cb = nullptr;
}
}
-static void te_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
+static void te_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
trickle_endpoint* te = (trickle_endpoint*)ep;
gpr_mu_lock(&te->mu);
GPR_ASSERT(te->write_cb == nullptr);
@@ -74,47 +73,44 @@ static void te_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
grpc_slice_copy(slices->slices[i]));
}
te->write_cb = cb;
- maybe_call_write_cb_locked(exec_ctx, te);
+ maybe_call_write_cb_locked(te);
gpr_mu_unlock(&te->mu);
}
-static void te_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset* pollset) {
+static void te_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {
trickle_endpoint* te = (trickle_endpoint*)ep;
- grpc_endpoint_add_to_pollset(exec_ctx, te->wrapped, pollset);
+ grpc_endpoint_add_to_pollset(te->wrapped, pollset);
}
-static void te_add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
+static void te_add_to_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset_set) {
trickle_endpoint* te = (trickle_endpoint*)ep;
- grpc_endpoint_add_to_pollset_set(exec_ctx, te->wrapped, pollset_set);
+ grpc_endpoint_add_to_pollset_set(te->wrapped, pollset_set);
}
-static void te_delete_from_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* ep,
+static void te_delete_from_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset_set) {
trickle_endpoint* te = (trickle_endpoint*)ep;
- grpc_endpoint_delete_from_pollset_set(exec_ctx, te->wrapped, pollset_set);
+ grpc_endpoint_delete_from_pollset_set(te->wrapped, pollset_set);
}
-static void te_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_error* why) {
+static void te_shutdown(grpc_endpoint* ep, grpc_error* why) {
trickle_endpoint* te = (trickle_endpoint*)ep;
gpr_mu_lock(&te->mu);
if (te->error == GRPC_ERROR_NONE) {
te->error = GRPC_ERROR_REF(why);
}
- maybe_call_write_cb_locked(exec_ctx, te);
+ maybe_call_write_cb_locked(te);
gpr_mu_unlock(&te->mu);
- grpc_endpoint_shutdown(exec_ctx, te->wrapped, why);
+ grpc_endpoint_shutdown(te->wrapped, why);
}
-static void te_destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) {
+static void te_destroy(grpc_endpoint* ep) {
trickle_endpoint* te = (trickle_endpoint*)ep;
- grpc_endpoint_destroy(exec_ctx, te->wrapped);
+ grpc_endpoint_destroy(te->wrapped);
gpr_mu_destroy(&te->mu);
- grpc_slice_buffer_destroy_internal(exec_ctx, &te->write_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &te->writing_buffer);
+ grpc_slice_buffer_destroy_internal(&te->write_buffer);
+ grpc_slice_buffer_destroy_internal(&te->writing_buffer);
GRPC_ERROR_UNREF(te->error);
gpr_free(te);
}
@@ -134,8 +130,7 @@ static int te_get_fd(grpc_endpoint* ep) {
return grpc_endpoint_get_fd(te->wrapped);
}
-static void te_finish_write(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void te_finish_write(void* arg, grpc_error* error) {
trickle_endpoint* te = (trickle_endpoint*)arg;
gpr_mu_lock(&te->mu);
te->writing = false;
@@ -173,8 +168,7 @@ static double ts2dbl(gpr_timespec s) {
return (double)s.tv_sec + 1e-9 * (double)s.tv_nsec;
}
-size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* ep) {
+size_t grpc_trickle_endpoint_trickle(grpc_endpoint* ep) {
trickle_endpoint* te = (trickle_endpoint*)ep;
gpr_mu_lock(&te->mu);
if (!te->writing && te->write_buffer.length > 0) {
@@ -189,9 +183,9 @@ size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx* exec_ctx,
te->writing = true;
te->last_write = now;
grpc_endpoint_write(
- exec_ctx, te->wrapped, &te->writing_buffer,
+ te->wrapped, &te->writing_buffer,
GRPC_CLOSURE_CREATE(te_finish_write, te, grpc_schedule_on_exec_ctx));
- maybe_call_write_cb_locked(exec_ctx, te);
+ maybe_call_write_cb_locked(te);
}
}
size_t backlog = te->write_buffer.length;
diff --git a/test/core/util/trickle_endpoint.h b/test/core/util/trickle_endpoint.h
index 11c113bda8..cd07de905a 100644
--- a/test/core/util/trickle_endpoint.h
+++ b/test/core/util/trickle_endpoint.h
@@ -25,8 +25,7 @@ grpc_endpoint* grpc_trickle_endpoint_create(grpc_endpoint* wrap,
double bytes_per_second);
/* Allow up to \a bytes through the endpoint. Returns the new backlog. */
-size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* endpoint);
+size_t grpc_trickle_endpoint_trickle(grpc_endpoint* endpoint);
size_t grpc_trickle_get_backlog(grpc_endpoint* endpoint);
diff --git a/test/cpp/common/channel_filter_test.cc b/test/cpp/common/channel_filter_test.cc
index 638518107b..7bdd53f9e7 100644
--- a/test/cpp/common/channel_filter_test.cc
+++ b/test/cpp/common/channel_filter_test.cc
@@ -28,7 +28,7 @@ class MyChannelData : public ChannelData {
public:
MyChannelData() {}
- grpc_error* Init(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+ grpc_error* Init(grpc_channel_element* elem,
grpc_channel_element_args* args) override {
(void)args->channel_args; // Make sure field is available.
return GRPC_ERROR_NONE;
@@ -39,7 +39,7 @@ class MyCallData : public CallData {
public:
MyCallData() {}
- grpc_error* Init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+ grpc_error* Init(grpc_call_element* elem,
const grpc_call_element_args* args) override {
(void)args->path; // Make sure field is available.
return GRPC_ERROR_NONE;
diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc
index f8bb12fde1..f2f3cc3425 100644
--- a/test/cpp/end2end/client_lb_end2end_test.cc
+++ b/test/cpp/end2end/client_lb_end2end_test.cc
@@ -112,13 +112,13 @@ class ClientLbEnd2endTest : public ::testing::Test {
}
void SetNextResolution(const std::vector<int>& ports) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_lb_addresses* addresses =
grpc_lb_addresses_create(ports.size(), nullptr);
for (size_t i = 0; i < ports.size(); ++i) {
char* lb_uri_str;
gpr_asprintf(&lb_uri_str, "ipv4:127.0.0.1:%d", ports[i]);
- grpc_uri* lb_uri = grpc_uri_parse(&exec_ctx, lb_uri_str, true);
+ grpc_uri* lb_uri = grpc_uri_parse(lb_uri_str, true);
GPR_ASSERT(lb_uri != nullptr);
grpc_lb_addresses_set_address_from_uri(addresses, i, lb_uri,
false /* is balancer */,
@@ -130,11 +130,10 @@ class ClientLbEnd2endTest : public ::testing::Test {
grpc_lb_addresses_create_channel_arg(addresses);
grpc_channel_args* fake_result =
grpc_channel_args_copy_and_add(nullptr, &fake_addresses, 1);
- grpc_fake_resolver_response_generator_set_response(
- &exec_ctx, response_generator_, fake_result);
- grpc_channel_args_destroy(&exec_ctx, fake_result);
- grpc_lb_addresses_destroy(&exec_ctx, addresses);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_fake_resolver_response_generator_set_response(response_generator_,
+ fake_result);
+ grpc_channel_args_destroy(fake_result);
+ grpc_lb_addresses_destroy(addresses);
}
void ResetStub(const grpc::string& lb_policy_name = "") {
diff --git a/test/cpp/end2end/filter_end2end_test.cc b/test/cpp/end2end/filter_end2end_test.cc
index f260ea0016..c4430379db 100644
--- a/test/cpp/end2end/filter_end2end_test.cc
+++ b/test/cpp/end2end/filter_end2end_test.cc
@@ -100,7 +100,7 @@ int GetCallCounterValue() {
class ChannelDataImpl : public ChannelData {
public:
- grpc_error* Init(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+ grpc_error* Init(grpc_channel_element* elem,
grpc_channel_element_args* args) {
IncrementConnectionCounter();
return GRPC_ERROR_NONE;
@@ -109,13 +109,12 @@ class ChannelDataImpl : public ChannelData {
class CallDataImpl : public CallData {
public:
- void StartTransportStreamOpBatch(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+ void StartTransportStreamOpBatch(grpc_call_element* elem,
TransportStreamOpBatch* op) override {
// Incrementing the counter could be done from Init(), but we want
// to test that the individual methods are actually called correctly.
if (op->recv_initial_metadata() != nullptr) IncrementCallCounter();
- grpc_call_next_op(exec_ctx, elem, op->op());
+ grpc_call_next_op(elem, op->op());
}
};
diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc
index c15ab88da1..c5c53b8b8a 100644
--- a/test/cpp/end2end/grpclb_end2end_test.cc
+++ b/test/cpp/end2end/grpclb_end2end_test.cc
@@ -451,13 +451,13 @@ class GrpclbEnd2endTest : public ::testing::Test {
};
void SetNextResolution(const std::vector<AddressData>& address_data) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_lb_addresses* addresses =
grpc_lb_addresses_create(address_data.size(), nullptr);
for (size_t i = 0; i < address_data.size(); ++i) {
char* lb_uri_str;
gpr_asprintf(&lb_uri_str, "ipv4:127.0.0.1:%d", address_data[i].port);
- grpc_uri* lb_uri = grpc_uri_parse(&exec_ctx, lb_uri_str, true);
+ grpc_uri* lb_uri = grpc_uri_parse(lb_uri_str, true);
GPR_ASSERT(lb_uri != nullptr);
grpc_lb_addresses_set_address_from_uri(
addresses, i, lb_uri, address_data[i].is_balancer,
@@ -467,10 +467,9 @@ class GrpclbEnd2endTest : public ::testing::Test {
}
grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses);
grpc_channel_args fake_result = {1, &fake_addresses};
- grpc_fake_resolver_response_generator_set_response(
- &exec_ctx, response_generator_, &fake_result);
- grpc_lb_addresses_destroy(&exec_ctx, addresses);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_fake_resolver_response_generator_set_response(response_generator_,
+ &fake_result);
+ grpc_lb_addresses_destroy(addresses);
}
const std::vector<int> GetBackendPorts(const size_t start_index = 0) const {
diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc
index ca846c72fd..792c82639c 100644
--- a/test/cpp/grpclb/grpclb_test.cc
+++ b/test/cpp/grpclb/grpclb_test.cc
@@ -562,7 +562,7 @@ static void perform_request(client_fixture* cf) {
#define BALANCERS_NAME "lb.name"
static void setup_client(const server_fixture* lb_server,
const server_fixture* backends, client_fixture* cf) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
char* expected_target_names = nullptr;
const char* backends_name = lb_server->servers_hostport;
@@ -574,7 +574,7 @@ static void setup_client(const server_fixture* lb_server,
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);
+ grpc_uri* lb_uri = grpc_uri_parse(lb_uri_str, true);
GPR_ASSERT(lb_uri != nullptr);
grpc_lb_addresses_set_address_from_uri(addresses, 0, lb_uri, true,
lb_server->balancer_name, nullptr);
@@ -586,7 +586,7 @@ static void setup_client(const server_fixture* lb_server,
grpc_lb_addresses_create_channel_arg(addresses);
grpc_channel_args* fake_result =
grpc_channel_args_copy_and_add(nullptr, &fake_addresses, 1);
- grpc_lb_addresses_destroy(&exec_ctx, addresses);
+ grpc_lb_addresses_destroy(addresses);
const grpc_arg new_args[] = {
grpc_fake_transport_expected_targets_arg(expected_target_names),
@@ -601,13 +601,12 @@ static void setup_client(const server_fixture* lb_server,
grpc_fake_transport_security_credentials_create();
cf->client =
grpc_secure_channel_create(fake_creds, cf->server_uri, args, nullptr);
- grpc_fake_resolver_response_generator_set_response(
- &exec_ctx, response_generator, fake_result);
- grpc_channel_args_destroy(&exec_ctx, fake_result);
- grpc_channel_credentials_unref(&exec_ctx, fake_creds);
- grpc_channel_args_destroy(&exec_ctx, args);
+ grpc_fake_resolver_response_generator_set_response(response_generator,
+ fake_result);
+ grpc_channel_args_destroy(fake_result);
+ grpc_channel_credentials_unref(fake_creds);
+ grpc_channel_args_destroy(args);
grpc_fake_resolver_response_generator_unref(response_generator);
- grpc_exec_ctx_finish(&exec_ctx);
}
static void teardown_client(client_fixture* cf) {
diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc
index a45c577320..b17f79613a 100644
--- a/test/cpp/microbenchmarks/bm_call_create.cc
+++ b/test/cpp/microbenchmarks/bm_call_create.cc
@@ -311,12 +311,9 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State& state) {
}
BENCHMARK(BM_LameChannelCallCreateCoreSeparateBatch);
-static void FilterDestroy(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
- gpr_free(arg);
-}
+static void FilterDestroy(void* arg, grpc_error* error) { gpr_free(arg); }
-static void DoNothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
+static void DoNothing(void* arg, grpc_error* error) {}
class FakeClientChannelFactory : public grpc_client_channel_factory {
public:
@@ -324,15 +321,12 @@ class FakeClientChannelFactory : public grpc_client_channel_factory {
private:
static void NoRef(grpc_client_channel_factory* factory) {}
- static void NoUnref(grpc_exec_ctx* exec_ctx,
- grpc_client_channel_factory* factory) {}
- static grpc_subchannel* CreateSubchannel(grpc_exec_ctx* exec_ctx,
- grpc_client_channel_factory* factory,
+ static void NoUnref(grpc_client_channel_factory* factory) {}
+ static grpc_subchannel* CreateSubchannel(grpc_client_channel_factory* factory,
const grpc_subchannel_args* args) {
return nullptr;
}
- static grpc_channel* CreateClientChannel(grpc_exec_ctx* exec_ctx,
- grpc_client_channel_factory* factory,
+ static grpc_channel* CreateClientChannel(grpc_client_channel_factory* factory,
const char* target,
grpc_client_channel_type type,
const grpc_channel_args* args) {
@@ -366,36 +360,32 @@ struct Fixture {
namespace dummy_filter {
-static void StartTransportStreamOp(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void StartTransportStreamOp(grpc_call_element* elem,
grpc_transport_stream_op_batch* op) {}
-static void StartTransportOp(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static void StartTransportOp(grpc_channel_element* elem,
grpc_transport_op* op) {}
-static grpc_error* InitCallElem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* InitCallElem(grpc_call_element* elem,
const grpc_call_element_args* args) {
return GRPC_ERROR_NONE;
}
-static void SetPollsetOrPollsetSet(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void SetPollsetOrPollsetSet(grpc_call_element* elem,
grpc_polling_entity* pollent) {}
-static void DestroyCallElem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void DestroyCallElem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* then_sched_closure) {}
-grpc_error* InitChannelElem(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+grpc_error* InitChannelElem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
-void DestroyChannelElem(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem) {}
+void DestroyChannelElem(grpc_channel_element* elem) {}
-void GetChannelInfo(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+void GetChannelInfo(grpc_channel_element* elem,
const grpc_channel_info* channel_info) {}
static const grpc_channel_filter dummy_filter = {StartTransportStreamOp,
@@ -422,41 +412,38 @@ size_t sizeof_stream; /* = sizeof(transport stream) */
const char* name;
/* implementation of grpc_transport_init_stream */
-int InitStream(grpc_exec_ctx* exec_ctx, grpc_transport* self,
- grpc_stream* stream, grpc_stream_refcount* refcount,
- const void* server_data, gpr_arena* arena) {
+int InitStream(grpc_transport* self, grpc_stream* stream,
+ grpc_stream_refcount* refcount, const void* server_data,
+ gpr_arena* arena) {
return 0;
}
/* implementation of grpc_transport_set_pollset */
-void SetPollset(grpc_exec_ctx* exec_ctx, grpc_transport* self,
- grpc_stream* stream, grpc_pollset* pollset) {}
+void SetPollset(grpc_transport* self, grpc_stream* stream,
+ grpc_pollset* pollset) {}
/* implementation of grpc_transport_set_pollset */
-void SetPollsetSet(grpc_exec_ctx* exec_ctx, grpc_transport* self,
- grpc_stream* stream, grpc_pollset_set* pollset_set) {}
+void SetPollsetSet(grpc_transport* self, grpc_stream* stream,
+ grpc_pollset_set* pollset_set) {}
/* implementation of grpc_transport_perform_stream_op */
-void PerformStreamOp(grpc_exec_ctx* exec_ctx, grpc_transport* self,
- grpc_stream* stream, grpc_transport_stream_op_batch* op) {
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_complete, GRPC_ERROR_NONE);
+void PerformStreamOp(grpc_transport* self, grpc_stream* stream,
+ grpc_transport_stream_op_batch* op) {
+ GRPC_CLOSURE_SCHED(op->on_complete, GRPC_ERROR_NONE);
}
/* implementation of grpc_transport_perform_op */
-void PerformOp(grpc_exec_ctx* exec_ctx, grpc_transport* self,
- grpc_transport_op* op) {}
+void PerformOp(grpc_transport* self, grpc_transport_op* op) {}
/* implementation of grpc_transport_destroy_stream */
-void DestroyStream(grpc_exec_ctx* exec_ctx, grpc_transport* self,
- grpc_stream* stream, grpc_closure* then_sched_closure) {}
+void DestroyStream(grpc_transport* self, grpc_stream* stream,
+ grpc_closure* then_sched_closure) {}
/* implementation of grpc_transport_destroy */
-void Destroy(grpc_exec_ctx* exec_ctx, grpc_transport* self) {}
+void Destroy(grpc_transport* self) {}
/* implementation of grpc_transport_get_endpoint */
-grpc_endpoint* GetEndpoint(grpc_exec_ctx* exec_ctx, grpc_transport* self) {
- return nullptr;
-}
+grpc_endpoint* GetEndpoint(grpc_transport* self) { return nullptr; }
static const grpc_transport_vtable dummy_transport_vtable = {
0, "dummy_http2", InitStream,
@@ -472,8 +459,8 @@ class NoOp {
public:
class Op {
public:
- Op(grpc_exec_ctx* exec_ctx, NoOp* p, grpc_call_stack* s) {}
- void Finish(grpc_exec_ctx* exec_ctx) {}
+ Op(NoOp* p, grpc_call_stack* s) {}
+ void Finish() {}
};
};
@@ -489,13 +476,11 @@ class SendEmptyMetadata {
class Op {
public:
- Op(grpc_exec_ctx* exec_ctx, SendEmptyMetadata* p, grpc_call_stack* s) {
+ Op(SendEmptyMetadata* p, grpc_call_stack* s) {
grpc_metadata_batch_init(&batch_);
p->op_payload_.send_initial_metadata.send_initial_metadata = &batch_;
}
- void Finish(grpc_exec_ctx* exec_ctx) {
- grpc_metadata_batch_destroy(exec_ctx, &batch_);
- }
+ void Finish() { grpc_metadata_batch_destroy(&batch_); }
private:
grpc_metadata_batch batch_;
@@ -536,20 +521,20 @@ static void BM_IsolatedFilter(benchmark::State& state) {
label << " #has_dummy_filter";
}
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
size_t channel_size = grpc_channel_stack_size(
filters.size() == 0 ? nullptr : &filters[0], filters.size());
grpc_channel_stack* channel_stack =
static_cast<grpc_channel_stack*>(gpr_zalloc(channel_size));
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"channel_stack_init",
- grpc_channel_stack_init(&exec_ctx, 1, FilterDestroy, channel_stack,
- &filters[0], filters.size(), &channel_args,
+ grpc_channel_stack_init(1, FilterDestroy, channel_stack, &filters[0],
+ filters.size(), &channel_args,
fixture.flags & REQUIRES_TRANSPORT
? &dummy_transport::dummy_transport
: nullptr,
"CHANNEL", channel_stack)));
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
grpc_call_stack* call_stack =
static_cast<grpc_call_stack*>(gpr_zalloc(channel_stack->call_stack_size));
grpc_millis deadline = GRPC_MILLIS_INF_FUTURE;
@@ -568,12 +553,12 @@ static void BM_IsolatedFilter(benchmark::State& state) {
call_args.arena = gpr_arena_create(kArenaSize);
while (state.KeepRunning()) {
GPR_TIMER_SCOPE("BenchmarkCycle", 0);
- GRPC_ERROR_UNREF(grpc_call_stack_init(&exec_ctx, channel_stack, 1,
- DoNothing, nullptr, &call_args));
- typename TestOp::Op op(&exec_ctx, &test_op_data, call_stack);
- grpc_call_stack_destroy(&exec_ctx, call_stack, &final_info, nullptr);
- op.Finish(&exec_ctx);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_ERROR_UNREF(
+ grpc_call_stack_init(channel_stack, 1, DoNothing, nullptr, &call_args));
+ typename TestOp::Op op(&test_op_data, call_stack);
+ grpc_call_stack_destroy(call_stack, &final_info, nullptr);
+ op.Finish();
+ grpc_core::ExecCtx::Get()->Flush();
// recreate arena every 64k iterations to avoid oom
if (0 == (state.iterations() & 0xffff)) {
gpr_arena_destroy(call_args.arena);
@@ -581,8 +566,8 @@ static void BM_IsolatedFilter(benchmark::State& state) {
}
}
gpr_arena_destroy(call_args.arena);
- grpc_channel_stack_destroy(&exec_ctx, channel_stack);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_channel_stack_destroy(channel_stack);
+
gpr_free(channel_stack);
gpr_free(call_stack);
@@ -632,59 +617,55 @@ typedef struct {
grpc_call_combiner* call_combiner;
} call_data;
-static void StartTransportStreamOp(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void StartTransportStreamOp(grpc_call_element* elem,
grpc_transport_stream_op_batch* op) {
call_data* calld = static_cast<call_data*>(elem->call_data);
if (op->recv_initial_metadata) {
GRPC_CALL_COMBINER_START(
- exec_ctx, calld->call_combiner,
+ calld->call_combiner,
op->payload->recv_initial_metadata.recv_initial_metadata_ready,
GRPC_ERROR_NONE, "recv_initial_metadata");
}
if (op->recv_message) {
- GRPC_CALL_COMBINER_START(exec_ctx, calld->call_combiner,
+ GRPC_CALL_COMBINER_START(calld->call_combiner,
op->payload->recv_message.recv_message_ready,
GRPC_ERROR_NONE, "recv_message");
}
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_complete, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(op->on_complete, GRPC_ERROR_NONE);
}
-static void StartTransportOp(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static void StartTransportOp(grpc_channel_element* elem,
grpc_transport_op* op) {
if (op->disconnect_with_error != GRPC_ERROR_NONE) {
GRPC_ERROR_UNREF(op->disconnect_with_error);
}
- GRPC_CLOSURE_SCHED(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(op->on_consumed, GRPC_ERROR_NONE);
}
-static grpc_error* InitCallElem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* InitCallElem(grpc_call_element* elem,
const grpc_call_element_args* args) {
call_data* calld = static_cast<call_data*>(elem->call_data);
calld->call_combiner = args->call_combiner;
return GRPC_ERROR_NONE;
}
-static void SetPollsetOrPollsetSet(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void SetPollsetOrPollsetSet(grpc_call_element* elem,
grpc_polling_entity* pollent) {}
-static void DestroyCallElem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void DestroyCallElem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* then_sched_closure) {
- GRPC_CLOSURE_SCHED(exec_ctx, then_sched_closure, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(then_sched_closure, GRPC_ERROR_NONE);
}
-grpc_error* InitChannelElem(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+grpc_error* InitChannelElem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
return GRPC_ERROR_NONE;
}
-void DestroyChannelElem(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem) {}
+void DestroyChannelElem(grpc_channel_element* elem) {}
-void GetChannelInfo(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem,
+void GetChannelInfo(grpc_channel_element* elem,
const grpc_channel_info* channel_info) {}
static const grpc_channel_filter isolated_call_filter = {
@@ -711,10 +692,8 @@ class IsolatedCallFixture : public TrackCounters {
builder, &isolated_call_filter::isolated_call_filter, nullptr,
nullptr));
{
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- channel_ = grpc_channel_create_with_builder(&exec_ctx, builder,
- GRPC_CLIENT_CHANNEL);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ channel_ = grpc_channel_create_with_builder(builder, GRPC_CLIENT_CHANNEL);
}
cq_ = grpc_completion_queue_create_for_next(nullptr);
}
diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
index 3fff8b02d6..6b6b441d93 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
@@ -50,22 +50,22 @@ static grpc_slice MakeSlice(std::vector<uint8_t> bytes) {
static void BM_HpackEncoderInitDestroy(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_chttp2_hpack_compressor c;
while (state.KeepRunning()) {
grpc_chttp2_hpack_compressor_init(&c);
- grpc_chttp2_hpack_compressor_destroy(&exec_ctx, &c);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_chttp2_hpack_compressor_destroy(&c);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_HpackEncoderInitDestroy);
static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_millis saved_now = grpc_exec_ctx_now(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_millis saved_now = grpc_core::ExecCtx::Get()->Now();
grpc_metadata_batch b;
grpc_metadata_batch_init(&b);
@@ -85,14 +85,13 @@ static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) {
(size_t)1024,
&stats,
};
- 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);
+ grpc_chttp2_encode_header(&c, nullptr, 0, &b, &hopt, &outbuf);
+ grpc_slice_buffer_reset_and_unref_internal(&outbuf);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_metadata_batch_destroy(&exec_ctx, &b);
- grpc_chttp2_hpack_compressor_destroy(&exec_ctx, &c);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &outbuf);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_metadata_batch_destroy(&b);
+ grpc_chttp2_hpack_compressor_destroy(&c);
+ grpc_slice_buffer_destroy_internal(&outbuf);
std::ostringstream label;
label << "framing_bytes/iter:"
@@ -109,17 +108,16 @@ BENCHMARK(BM_HpackEncoderEncodeDeadline);
template <class Fixture>
static void BM_HpackEncoderEncodeHeader(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
static bool logged_representative_output = false;
grpc_metadata_batch b;
grpc_metadata_batch_init(&b);
- std::vector<grpc_mdelem> elems = Fixture::GetElems(&exec_ctx);
+ std::vector<grpc_mdelem> elems = Fixture::GetElems();
std::vector<grpc_linked_mdelem> storage(elems.size());
for (size_t i = 0; i < elems.size(); i++) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "addmd",
- grpc_metadata_batch_add_tail(&exec_ctx, &b, &storage[i], elems[i])));
+ "addmd", grpc_metadata_batch_add_tail(&b, &storage[i], elems[i])));
}
grpc_chttp2_hpack_compressor c;
@@ -136,7 +134,7 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State& state) {
(size_t)state.range(1),
&stats,
};
- grpc_chttp2_encode_header(&exec_ctx, &c, nullptr, 0, &b, &hopt, &outbuf);
+ grpc_chttp2_encode_header(&c, nullptr, 0, &b, &hopt, &outbuf);
if (!logged_representative_output && state.iterations() > 3) {
logged_representative_output = true;
for (size_t i = 0; i < outbuf.count; i++) {
@@ -145,13 +143,12 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State& state) {
gpr_free(s);
}
}
- grpc_slice_buffer_reset_and_unref_internal(&exec_ctx, &outbuf);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_slice_buffer_reset_and_unref_internal(&outbuf);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_metadata_batch_destroy(&exec_ctx, &b);
- grpc_chttp2_hpack_compressor_destroy(&exec_ctx, &c);
- grpc_slice_buffer_destroy_internal(&exec_ctx, &outbuf);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_metadata_batch_destroy(&b);
+ grpc_chttp2_hpack_compressor_destroy(&c);
+ grpc_slice_buffer_destroy_internal(&outbuf);
std::ostringstream label;
label << "framing_bytes/iter:"
@@ -169,15 +166,13 @@ namespace hpack_encoder_fixtures {
class EmptyBatch {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
- return {};
- }
+ static std::vector<grpc_mdelem> GetElems() { return {}; }
};
class SingleStaticElem {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE};
}
};
@@ -185,9 +180,9 @@ class SingleStaticElem {
class SingleInternedElem {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc")),
+ grpc_slice_intern(grpc_slice_from_static_string("abc")),
grpc_slice_intern(grpc_slice_from_static_string("def")))};
}
};
@@ -196,10 +191,10 @@ template <int kLength, bool kTrueBinary>
class SingleInternedBinaryElem {
public:
static constexpr bool kEnableTrueBinary = kTrueBinary;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
grpc_slice bytes = MakeBytes();
std::vector<grpc_mdelem> out = {grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc-bin")),
+ grpc_slice_intern(grpc_slice_from_static_string("abc-bin")),
grpc_slice_intern(bytes))};
grpc_slice_unref(bytes);
return out;
@@ -218,9 +213,9 @@ class SingleInternedBinaryElem {
class SingleInternedKeyElem {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc")),
+ grpc_slice_intern(grpc_slice_from_static_string("abc")),
grpc_slice_from_static_string("def"))};
}
};
@@ -228,9 +223,8 @@ class SingleInternedKeyElem {
class SingleNonInternedElem {
public:
static constexpr bool kEnableTrueBinary = false;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
- return {grpc_mdelem_from_slices(exec_ctx,
- grpc_slice_from_static_string("abc"),
+ static std::vector<grpc_mdelem> GetElems() {
+ return {grpc_mdelem_from_slices(grpc_slice_from_static_string("abc"),
grpc_slice_from_static_string("def"))};
}
};
@@ -239,9 +233,9 @@ template <int kLength, bool kTrueBinary>
class SingleNonInternedBinaryElem {
public:
static constexpr bool kEnableTrueBinary = kTrueBinary;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
- return {grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_from_static_string("abc-bin"), MakeBytes())};
+ static std::vector<grpc_mdelem> GetElems() {
+ return {grpc_mdelem_from_slices(grpc_slice_from_static_string("abc-bin"),
+ MakeBytes())};
}
private:
@@ -257,21 +251,21 @@ class SingleNonInternedBinaryElem {
class RepresentativeClientInitialMetadata {
public:
static constexpr bool kEnableTrueBinary = true;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {
GRPC_MDELEM_SCHEME_HTTP,
GRPC_MDELEM_METHOD_POST,
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_PATH,
+ GRPC_MDSTR_PATH,
grpc_slice_intern(grpc_slice_from_static_string("/foo/bar"))),
- grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_AUTHORITY,
+ grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY,
grpc_slice_intern(grpc_slice_from_static_string(
"foo.test.google.fr:1234"))),
GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP,
GRPC_MDELEM_TE_TRAILERS,
GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC,
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_USER_AGENT,
+ GRPC_MDSTR_USER_AGENT,
grpc_slice_intern(grpc_slice_from_static_string(
"grpc-c/3.0.0-dev (linux; chttp2; green)")))};
}
@@ -283,18 +277,18 @@ class RepresentativeClientInitialMetadata {
class MoreRepresentativeClientInitialMetadata {
public:
static constexpr bool kEnableTrueBinary = true;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {
GRPC_MDELEM_SCHEME_HTTP,
GRPC_MDELEM_METHOD_POST,
- grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_PATH,
+ grpc_mdelem_from_slices(GRPC_MDSTR_PATH,
grpc_slice_intern(grpc_slice_from_static_string(
"/grpc.test.FooService/BarMethod"))),
- grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_AUTHORITY,
+ grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY,
grpc_slice_intern(grpc_slice_from_static_string(
"foo.test.google.fr:1234"))),
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_GRPC_TRACE_BIN,
+ GRPC_MDSTR_GRPC_TRACE_BIN,
grpc_slice_from_static_string("\x00\x01\x02\x03\x04\x05\x06\x07\x08"
"\x09\x0a\x0b\x0c\x0d\x0e\x0f"
"\x10\x11\x12\x13\x14\x15\x16\x17\x18"
@@ -303,7 +297,7 @@ class MoreRepresentativeClientInitialMetadata {
"\x29\x2a\x2b\x2c\x2d\x2e\x2f"
"\x30")),
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_GRPC_TAGS_BIN,
+ GRPC_MDSTR_GRPC_TAGS_BIN,
grpc_slice_from_static_string("\x00\x01\x02\x03\x04\x05\x06\x07\x08"
"\x09\x0a\x0b\x0c\x0d\x0e\x0f"
"\x10\x11\x12\x13")),
@@ -311,7 +305,7 @@ class MoreRepresentativeClientInitialMetadata {
GRPC_MDELEM_TE_TRAILERS,
GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC,
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_USER_AGENT,
+ GRPC_MDSTR_USER_AGENT,
grpc_slice_intern(grpc_slice_from_static_string(
"grpc-c/3.0.0-dev (linux; chttp2; green)")))};
}
@@ -320,7 +314,7 @@ class MoreRepresentativeClientInitialMetadata {
class RepresentativeServerInitialMetadata {
public:
static constexpr bool kEnableTrueBinary = true;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {GRPC_MDELEM_STATUS_200,
GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC,
GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP};
@@ -330,7 +324,7 @@ class RepresentativeServerInitialMetadata {
class RepresentativeServerTrailingMetadata {
public:
static constexpr bool kEnableTrueBinary = true;
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {GRPC_MDELEM_GRPC_STATUS_0};
}
};
@@ -431,48 +425,45 @@ BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader,
static void BM_HpackParserInitDestroy(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_chttp2_hpack_parser p;
while (state.KeepRunning()) {
- grpc_chttp2_hpack_parser_init(&exec_ctx, &p);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &p);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_chttp2_hpack_parser_init(&p);
+ grpc_chttp2_hpack_parser_destroy(&p);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_HpackParserInitDestroy);
-static void UnrefHeader(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_mdelem md) {
- GRPC_MDELEM_UNREF(exec_ctx, md);
+static void UnrefHeader(void* user_data, grpc_mdelem md) {
+ GRPC_MDELEM_UNREF(md);
}
-template <class Fixture, void (*OnHeader)(grpc_exec_ctx*, void*, grpc_mdelem)>
+template <class Fixture, void (*OnHeader)(void*, grpc_mdelem)>
static void BM_HpackParserParseHeader(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
std::vector<grpc_slice> init_slices = Fixture::GetInitSlices();
std::vector<grpc_slice> benchmark_slices = Fixture::GetBenchmarkSlices();
grpc_chttp2_hpack_parser p;
- grpc_chttp2_hpack_parser_init(&exec_ctx, &p);
+ grpc_chttp2_hpack_parser_init(&p);
p.on_header = OnHeader;
p.on_header_user_data = nullptr;
for (auto slice : init_slices) {
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_chttp2_hpack_parser_parse(&exec_ctx, &p, slice));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_chttp2_hpack_parser_parse(&p, slice));
}
while (state.KeepRunning()) {
for (auto slice : benchmark_slices) {
- GPR_ASSERT(GRPC_ERROR_NONE ==
- grpc_chttp2_hpack_parser_parse(&exec_ctx, &p, slice));
+ GPR_ASSERT(GRPC_ERROR_NONE == grpc_chttp2_hpack_parser_parse(&p, slice));
}
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
}
for (auto slice : init_slices) grpc_slice_unref(slice);
for (auto slice : benchmark_slices) grpc_slice_unref(slice);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &p);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_chttp2_hpack_parser_destroy(&p);
+
track_counters.Finish(state);
}
@@ -769,8 +760,7 @@ class RepresentativeServerTrailingMetadata {
static void free_timeout(void* p) { gpr_free(p); }
// New implementation.
-static void OnHeaderNew(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_mdelem md) {
+static void OnHeaderNew(void* user_data, grpc_mdelem md) {
if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_TIMEOUT)) {
grpc_millis* cached_timeout =
static_cast<grpc_millis*>(grpc_mdelem_get_user_data(md, free_timeout));
@@ -793,7 +783,7 @@ static void OnHeaderNew(grpc_exec_ctx* exec_ctx, void* user_data,
}
}
benchmark::DoNotOptimize(timeout);
- GRPC_MDELEM_UNREF(exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
} else {
GPR_ASSERT(0);
}
diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc
index b95ee0cc01..044417830f 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc
@@ -58,7 +58,7 @@ class DummyEndpoint : public grpc_endpoint {
ru_ = grpc_resource_user_create(Library::get().rq(), "dummy_endpoint");
}
- void PushInput(grpc_exec_ctx* exec_ctx, grpc_slice slice) {
+ void PushInput(grpc_slice slice) {
if (read_cb_ == nullptr) {
GPR_ASSERT(!have_slice_);
buffered_slice_ = slice;
@@ -66,7 +66,7 @@ class DummyEndpoint : public grpc_endpoint {
return;
}
grpc_slice_buffer_add(slices_, slice);
- GRPC_CLOSURE_SCHED(exec_ctx, read_cb_, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(read_cb_, GRPC_ERROR_NONE);
read_cb_ = nullptr;
}
@@ -77,50 +77,45 @@ class DummyEndpoint : public grpc_endpoint {
bool have_slice_ = false;
grpc_slice buffered_slice_;
- void QueueRead(grpc_exec_ctx* exec_ctx, grpc_slice_buffer* slices,
- grpc_closure* cb) {
+ void QueueRead(grpc_slice_buffer* slices, grpc_closure* cb) {
GPR_ASSERT(read_cb_ == nullptr);
if (have_slice_) {
have_slice_ = false;
grpc_slice_buffer_add(slices, buffered_slice_);
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_NONE);
return;
}
read_cb_ = cb;
slices_ = slices;
}
- static void read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
- static_cast<DummyEndpoint*>(ep)->QueueRead(exec_ctx, slices, cb);
+ static void read(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
+ static_cast<DummyEndpoint*>(ep)->QueueRead(slices, cb);
}
- static void write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
- GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE);
+ static void write(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
+ GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_NONE);
}
static grpc_workqueue* get_workqueue(grpc_endpoint* ep) { return nullptr; }
- static void add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset* pollset) {}
+ static void add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {}
- static void add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_pollset_set* pollset) {}
+ static void add_to_pollset_set(grpc_endpoint* ep, grpc_pollset_set* pollset) {
+ }
- static void delete_from_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* ep,
+ static void delete_from_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset) {}
- static void shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
- grpc_error* why) {
- grpc_resource_user_shutdown(exec_ctx, static_cast<DummyEndpoint*>(ep)->ru_);
- GRPC_CLOSURE_SCHED(exec_ctx, static_cast<DummyEndpoint*>(ep)->read_cb_,
- why);
+ static void shutdown(grpc_endpoint* ep, grpc_error* why) {
+ grpc_resource_user_shutdown(static_cast<DummyEndpoint*>(ep)->ru_);
+ GRPC_CLOSURE_SCHED(static_cast<DummyEndpoint*>(ep)->read_cb_, why);
}
- static void destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) {
- grpc_resource_user_unref(exec_ctx, static_cast<DummyEndpoint*>(ep)->ru_);
+ static void destroy(grpc_endpoint* ep) {
+ grpc_resource_user_unref(static_cast<DummyEndpoint*>(ep)->ru_);
delete static_cast<DummyEndpoint*>(ep);
}
@@ -136,29 +131,24 @@ class Fixture {
Fixture(const grpc::ChannelArguments& args, bool client) {
grpc_channel_args c_args = args.c_channel_args();
ep_ = new DummyEndpoint;
- t_ = grpc_create_chttp2_transport(exec_ctx(), &c_args, ep_, client);
- grpc_chttp2_transport_start_reading(exec_ctx(), t_, nullptr);
+ t_ = grpc_create_chttp2_transport(&c_args, ep_, client);
+ grpc_chttp2_transport_start_reading(t_, nullptr);
FlushExecCtx();
}
- void FlushExecCtx() { grpc_exec_ctx_flush(&exec_ctx_); }
+ void FlushExecCtx() { grpc_core::ExecCtx::Get()->Flush(); }
- ~Fixture() {
- grpc_transport_destroy(&exec_ctx_, t_);
- grpc_exec_ctx_finish(&exec_ctx_);
- }
+ ~Fixture() { grpc_transport_destroy(t_); }
grpc_chttp2_transport* chttp2_transport() {
return reinterpret_cast<grpc_chttp2_transport*>(t_);
}
grpc_transport* transport() { return t_; }
- grpc_exec_ctx* exec_ctx() { return &exec_ctx_; }
- void PushInput(grpc_slice slice) { ep_->PushInput(exec_ctx(), slice); }
+ void PushInput(grpc_slice slice) { ep_->PushInput(slice); }
private:
DummyEndpoint* ep_;
- grpc_exec_ctx exec_ctx_ = GRPC_EXEC_CTX_INIT;
grpc_transport* t_;
};
@@ -175,8 +165,8 @@ std::unique_ptr<Closure> MakeClosure(
GRPC_CLOSURE_INIT(this, Execute, this, sched);
}
F f_;
- static void Execute(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
- static_cast<C*>(arg)->f_(exec_ctx, error);
+ static void Execute(void* arg, grpc_error* error) {
+ static_cast<C*>(arg)->f_(error);
}
};
return std::unique_ptr<Closure>(new C(f, sched));
@@ -188,8 +178,8 @@ grpc_closure* MakeOnceClosure(
struct C : public grpc_closure {
C(const F& f) : f_(f) {}
F f_;
- static void Execute(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
- static_cast<C*>(arg)->f_(exec_ctx, error);
+ static void Execute(void* arg, grpc_error* error) {
+ static_cast<C*>(arg)->f_(error);
delete static_cast<C*>(arg);
}
};
@@ -220,22 +210,22 @@ class Stream {
gpr_arena_destroy(arena_);
arena_ = gpr_arena_create(4096);
}
- grpc_transport_init_stream(f_->exec_ctx(), f_->transport(),
+ grpc_transport_init_stream(f_->transport(),
static_cast<grpc_stream*>(stream_), &refcount_,
nullptr, arena_);
}
- void DestroyThen(grpc_exec_ctx* exec_ctx, grpc_closure* closure) {
+ void DestroyThen(grpc_closure* closure) {
destroy_closure_ = closure;
#ifndef NDEBUG
- grpc_stream_unref(exec_ctx, &refcount_, "DestroyThen");
+ grpc_stream_unref(&refcount_, "DestroyThen");
#else
- grpc_stream_unref(exec_ctx, &refcount_);
+ grpc_stream_unref(&refcount_);
#endif
}
- void Op(grpc_exec_ctx* exec_ctx, grpc_transport_stream_op_batch* op) {
- grpc_transport_perform_stream_op(exec_ctx, f_->transport(),
+ void Op(grpc_transport_stream_op_batch* op) {
+ grpc_transport_perform_stream_op(f_->transport(),
static_cast<grpc_stream*>(stream_), op);
}
@@ -244,10 +234,9 @@ class Stream {
}
private:
- static void FinishDestroy(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+ static void FinishDestroy(void* arg, grpc_error* error) {
auto stream = static_cast<Stream*>(arg);
- grpc_transport_destroy_stream(exec_ctx, stream->f_->transport(),
+ grpc_transport_destroy_stream(stream->f_->transport(),
static_cast<grpc_stream*>(stream->stream_),
stream->destroy_closure_);
gpr_event_set(&stream->done_, (void*)1);
@@ -268,6 +257,7 @@ class Stream {
static void BM_StreamCreateDestroy(benchmark::State& state) {
TrackCounters track_counters;
+ grpc_core::ExecCtx _local_exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
Stream s(&f);
grpc_transport_stream_op_batch op;
@@ -276,14 +266,13 @@ static void BM_StreamCreateDestroy(benchmark::State& state) {
op.cancel_stream = true;
op.payload = &op_payload;
op_payload.cancel_stream.cancel_error = GRPC_ERROR_CANCELLED;
- std::unique_ptr<Closure> next =
- MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) {
- if (!state.KeepRunning()) return;
- s.Init(state);
- s.Op(exec_ctx, &op);
- s.DestroyThen(exec_ctx, next.get());
- });
- GRPC_CLOSURE_RUN(f.exec_ctx(), next.get(), GRPC_ERROR_NONE);
+ std::unique_ptr<Closure> next = MakeClosure([&](grpc_error* error) {
+ if (!state.KeepRunning()) return;
+ s.Init(state);
+ s.Op(&op);
+ s.DestroyThen(next.get());
+ });
+ GRPC_CLOSURE_RUN(next.get(), GRPC_ERROR_NONE);
f.FlushExecCtx();
track_counters.Finish(state);
}
@@ -291,21 +280,21 @@ BENCHMARK(BM_StreamCreateDestroy);
class RepresentativeClientInitialMetadata {
public:
- static std::vector<grpc_mdelem> GetElems(grpc_exec_ctx* exec_ctx) {
+ static std::vector<grpc_mdelem> GetElems() {
return {
GRPC_MDELEM_SCHEME_HTTP,
GRPC_MDELEM_METHOD_POST,
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_PATH,
+ GRPC_MDSTR_PATH,
grpc_slice_intern(grpc_slice_from_static_string("/foo/bar"))),
- grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_AUTHORITY,
+ grpc_mdelem_from_slices(GRPC_MDSTR_AUTHORITY,
grpc_slice_intern(grpc_slice_from_static_string(
"foo.test.google.fr:1234"))),
GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP,
GRPC_MDELEM_TE_TRAILERS,
GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC,
grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_USER_AGENT,
+ GRPC_MDSTR_USER_AGENT,
grpc_slice_intern(grpc_slice_from_static_string(
"grpc-c/3.0.0-dev (linux; chttp2; green)")))};
}
@@ -314,6 +303,7 @@ class RepresentativeClientInitialMetadata {
template <class Metadata>
static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State& state) {
TrackCounters track_counters;
+ grpc_core::ExecCtx _local_exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
Stream s(&f);
grpc_transport_stream_op_batch op;
@@ -330,34 +320,33 @@ static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State& state) {
grpc_metadata_batch b;
grpc_metadata_batch_init(&b);
b.deadline = GRPC_MILLIS_INF_FUTURE;
- std::vector<grpc_mdelem> elems = Metadata::GetElems(f.exec_ctx());
+ std::vector<grpc_mdelem> elems = Metadata::GetElems();
std::vector<grpc_linked_mdelem> storage(elems.size());
for (size_t i = 0; i < elems.size(); i++) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "addmd",
- grpc_metadata_batch_add_tail(f.exec_ctx(), &b, &storage[i], elems[i])));
+ "addmd", grpc_metadata_batch_add_tail(&b, &storage[i], elems[i])));
}
f.FlushExecCtx();
- start = MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) {
+ start = MakeClosure([&](grpc_error* error) {
if (!state.KeepRunning()) return;
s.Init(state);
reset_op();
op.on_complete = done.get();
op.send_initial_metadata = true;
op.payload->send_initial_metadata.send_initial_metadata = &b;
- s.Op(exec_ctx, &op);
+ s.Op(&op);
});
- done = MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) {
+ done = MakeClosure([&](grpc_error* error) {
reset_op();
op.cancel_stream = true;
op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED;
- s.Op(exec_ctx, &op);
- s.DestroyThen(exec_ctx, start.get());
+ s.Op(&op);
+ s.DestroyThen(start.get());
});
- GRPC_CLOSURE_SCHED(f.exec_ctx(), start.get(), GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(start.get(), GRPC_ERROR_NONE);
f.FlushExecCtx();
- grpc_metadata_batch_destroy(f.exec_ctx(), &b);
+ grpc_metadata_batch_destroy(&b);
track_counters.Finish(state);
}
BENCHMARK_TEMPLATE(BM_StreamCreateSendInitialMetadataDestroy,
@@ -365,6 +354,7 @@ BENCHMARK_TEMPLATE(BM_StreamCreateSendInitialMetadataDestroy,
static void BM_TransportEmptyOp(benchmark::State& state) {
TrackCounters track_counters;
+ grpc_core::ExecCtx _local_exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
Stream s(&f);
s.Init(state);
@@ -375,21 +365,19 @@ static void BM_TransportEmptyOp(benchmark::State& state) {
memset(&op, 0, sizeof(op));
op.payload = &op_payload;
};
- std::unique_ptr<Closure> c =
- MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) {
- if (!state.KeepRunning()) return;
- reset_op();
- op.on_complete = c.get();
- s.Op(exec_ctx, &op);
- });
- GRPC_CLOSURE_SCHED(f.exec_ctx(), c.get(), GRPC_ERROR_NONE);
+ std::unique_ptr<Closure> c = MakeClosure([&](grpc_error* error) {
+ if (!state.KeepRunning()) return;
+ reset_op();
+ op.on_complete = c.get();
+ s.Op(&op);
+ });
+ GRPC_CLOSURE_SCHED(c.get(), GRPC_ERROR_NONE);
f.FlushExecCtx();
reset_op();
op.cancel_stream = true;
op_payload.cancel_stream.cancel_error = GRPC_ERROR_CANCELLED;
- s.Op(f.exec_ctx(), &op);
- s.DestroyThen(f.exec_ctx(), MakeOnceClosure([](grpc_exec_ctx* exec_ctx,
- grpc_error* error) {}));
+ s.Op(&op);
+ s.DestroyThen(MakeOnceClosure([](grpc_error* error) {}));
f.FlushExecCtx();
track_counters.Finish(state);
}
@@ -399,6 +387,7 @@ std::vector<std::unique_ptr<gpr_event>> done_events;
static void BM_TransportStreamSend(benchmark::State& state) {
TrackCounters track_counters;
+ grpc_core::ExecCtx _local_exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
auto s = std::unique_ptr<Stream>(new Stream(&f));
s->Init(state);
@@ -420,39 +409,37 @@ static void BM_TransportStreamSend(benchmark::State& state) {
grpc_metadata_batch_init(&b);
b.deadline = GRPC_MILLIS_INF_FUTURE;
std::vector<grpc_mdelem> elems =
- RepresentativeClientInitialMetadata::GetElems(f.exec_ctx());
+ RepresentativeClientInitialMetadata::GetElems();
std::vector<grpc_linked_mdelem> storage(elems.size());
for (size_t i = 0; i < elems.size(); i++) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "addmd",
- grpc_metadata_batch_add_tail(f.exec_ctx(), &b, &storage[i], elems[i])));
+ "addmd", grpc_metadata_batch_add_tail(&b, &storage[i], elems[i])));
}
gpr_event* bm_done = new gpr_event;
gpr_event_init(bm_done);
- std::unique_ptr<Closure> c =
- MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) {
- if (!state.KeepRunning()) {
- gpr_event_set(bm_done, (void*)1);
- return;
- }
- // force outgoing window to be yuge
- s->chttp2_stream()->flow_control->TestOnlyForceHugeWindow();
- f.chttp2_transport()->flow_control->TestOnlyForceHugeWindow();
- grpc_slice_buffer_stream_init(&send_stream, &send_buffer, 0);
- reset_op();
- op.on_complete = c.get();
- op.send_message = true;
- op.payload->send_message.send_message = &send_stream.base;
- s->Op(exec_ctx, &op);
- });
+ std::unique_ptr<Closure> c = MakeClosure([&](grpc_error* error) {
+ if (!state.KeepRunning()) {
+ gpr_event_set(bm_done, (void*)1);
+ return;
+ }
+ // force outgoing window to be yuge
+ s->chttp2_stream()->flow_control->TestOnlyForceHugeWindow();
+ f.chttp2_transport()->flow_control->TestOnlyForceHugeWindow();
+ grpc_slice_buffer_stream_init(&send_stream, &send_buffer, 0);
+ reset_op();
+ op.on_complete = c.get();
+ op.send_message = true;
+ op.payload->send_message.send_message = &send_stream.base;
+ s->Op(&op);
+ });
reset_op();
op.send_initial_metadata = true;
op.payload->send_initial_metadata.send_initial_metadata = &b;
op.on_complete = c.get();
- s->Op(f.exec_ctx(), &op);
+ s->Op(&op);
f.FlushExecCtx();
gpr_event_wait(bm_done, gpr_inf_future(GPR_CLOCK_REALTIME));
@@ -461,13 +448,12 @@ static void BM_TransportStreamSend(benchmark::State& state) {
reset_op();
op.cancel_stream = true;
op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED;
- s->Op(f.exec_ctx(), &op);
- s->DestroyThen(f.exec_ctx(), MakeOnceClosure([](grpc_exec_ctx* exec_ctx,
- grpc_error* error) {}));
+ s->Op(&op);
+ s->DestroyThen(MakeOnceClosure([](grpc_error* error) {}));
f.FlushExecCtx();
s.reset();
track_counters.Finish(state);
- grpc_metadata_batch_destroy(f.exec_ctx(), &b);
+ grpc_metadata_batch_destroy(&b);
grpc_slice_buffer_destroy(&send_buffer);
}
BENCHMARK(BM_TransportStreamSend)->Range(0, 128 * 1024 * 1024);
@@ -531,6 +517,7 @@ static grpc_slice CreateIncomingDataSlice(size_t length, size_t frame_size) {
static void BM_TransportStreamRecv(benchmark::State& state) {
TrackCounters track_counters;
+ grpc_core::ExecCtx _local_exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
Stream s(&f);
s.Init(state);
@@ -551,16 +538,14 @@ static void BM_TransportStreamRecv(benchmark::State& state) {
grpc_metadata_batch_init(&b_recv);
b.deadline = GRPC_MILLIS_INF_FUTURE;
std::vector<grpc_mdelem> elems =
- RepresentativeClientInitialMetadata::GetElems(f.exec_ctx());
+ RepresentativeClientInitialMetadata::GetElems();
std::vector<grpc_linked_mdelem> storage(elems.size());
for (size_t i = 0; i < elems.size(); i++) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "addmd",
- grpc_metadata_batch_add_tail(f.exec_ctx(), &b, &storage[i], elems[i])));
+ "addmd", grpc_metadata_batch_add_tail(&b, &storage[i], elems[i])));
}
- std::unique_ptr<Closure> do_nothing =
- MakeClosure([](grpc_exec_ctx* exec_ctx, grpc_error* error) {});
+ std::unique_ptr<Closure> do_nothing = MakeClosure([](grpc_error* error) {});
uint32_t received;
@@ -569,51 +554,49 @@ static void BM_TransportStreamRecv(benchmark::State& state) {
std::unique_ptr<Closure> drain_continue;
grpc_slice recv_slice;
- std::unique_ptr<Closure> c =
- MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) {
- if (!state.KeepRunning()) return;
- // force outgoing window to be yuge
- s.chttp2_stream()->flow_control->TestOnlyForceHugeWindow();
- f.chttp2_transport()->flow_control->TestOnlyForceHugeWindow();
- received = 0;
- reset_op();
- op.on_complete = do_nothing.get();
- op.recv_message = true;
- op.payload->recv_message.recv_message = &recv_stream;
- op.payload->recv_message.recv_message_ready = drain_start.get();
- s.Op(exec_ctx, &op);
- f.PushInput(grpc_slice_ref(incoming_data));
- });
-
- drain_start = MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) {
+ std::unique_ptr<Closure> c = MakeClosure([&](grpc_error* error) {
+ if (!state.KeepRunning()) return;
+ // force outgoing window to be yuge
+ s.chttp2_stream()->flow_control->TestOnlyForceHugeWindow();
+ f.chttp2_transport()->flow_control->TestOnlyForceHugeWindow();
+ received = 0;
+ reset_op();
+ op.on_complete = do_nothing.get();
+ op.recv_message = true;
+ op.payload->recv_message.recv_message = &recv_stream;
+ op.payload->recv_message.recv_message_ready = drain_start.get();
+ s.Op(&op);
+ f.PushInput(grpc_slice_ref(incoming_data));
+ });
+
+ drain_start = MakeClosure([&](grpc_error* error) {
if (recv_stream == nullptr) {
GPR_ASSERT(!state.KeepRunning());
return;
}
- GRPC_CLOSURE_RUN(exec_ctx, drain.get(), GRPC_ERROR_NONE);
+ GRPC_CLOSURE_RUN(drain.get(), GRPC_ERROR_NONE);
});
- drain = MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) {
+ drain = MakeClosure([&](grpc_error* error) {
do {
if (received == recv_stream->length) {
- grpc_byte_stream_destroy(exec_ctx, recv_stream);
- GRPC_CLOSURE_SCHED(exec_ctx, c.get(), GRPC_ERROR_NONE);
+ grpc_byte_stream_destroy(recv_stream);
+ GRPC_CLOSURE_SCHED(c.get(), GRPC_ERROR_NONE);
return;
}
- } while (grpc_byte_stream_next(exec_ctx, recv_stream,
- recv_stream->length - received,
+ } while (grpc_byte_stream_next(recv_stream, recv_stream->length - received,
drain_continue.get()) &&
GRPC_ERROR_NONE ==
- grpc_byte_stream_pull(exec_ctx, recv_stream, &recv_slice) &&
+ grpc_byte_stream_pull(recv_stream, &recv_slice) &&
(received += GRPC_SLICE_LENGTH(recv_slice),
- grpc_slice_unref_internal(exec_ctx, recv_slice), true));
+ grpc_slice_unref_internal(recv_slice), true));
});
- drain_continue = MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) {
- grpc_byte_stream_pull(exec_ctx, recv_stream, &recv_slice);
+ drain_continue = MakeClosure([&](grpc_error* error) {
+ grpc_byte_stream_pull(recv_stream, &recv_slice);
received += GRPC_SLICE_LENGTH(recv_slice);
- grpc_slice_unref_internal(exec_ctx, recv_slice);
- GRPC_CLOSURE_RUN(exec_ctx, drain.get(), GRPC_ERROR_NONE);
+ grpc_slice_unref_internal(recv_slice);
+ GRPC_CLOSURE_RUN(drain.get(), GRPC_ERROR_NONE);
});
reset_op();
@@ -624,7 +607,7 @@ static void BM_TransportStreamRecv(benchmark::State& state) {
op.payload->recv_initial_metadata.recv_initial_metadata_ready =
do_nothing.get();
op.on_complete = c.get();
- s.Op(f.exec_ctx(), &op);
+ s.Op(&op);
f.PushInput(SLICE_FROM_BUFFER(
"\x00\x00\x00\x04\x00\x00\x00\x00\x00"
// Generated using:
@@ -642,13 +625,12 @@ static void BM_TransportStreamRecv(benchmark::State& state) {
reset_op();
op.cancel_stream = true;
op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED;
- s.Op(f.exec_ctx(), &op);
- s.DestroyThen(f.exec_ctx(), MakeOnceClosure([](grpc_exec_ctx* exec_ctx,
- grpc_error* error) {}));
+ s.Op(&op);
+ s.DestroyThen(MakeOnceClosure([](grpc_error* error) {}));
f.FlushExecCtx();
track_counters.Finish(state);
- grpc_metadata_batch_destroy(f.exec_ctx(), &b);
- grpc_metadata_batch_destroy(f.exec_ctx(), &b_recv);
+ grpc_metadata_batch_destroy(&b);
+ grpc_metadata_batch_destroy(&b_recv);
grpc_slice_unref(incoming_data);
}
BENCHMARK(BM_TransportStreamRecv)->Range(0, 128 * 1024 * 1024);
diff --git a/test/cpp/microbenchmarks/bm_closure.cc b/test/cpp/microbenchmarks/bm_closure.cc
index 2434d4e84e..f28093ae17 100644
--- a/test/cpp/microbenchmarks/bm_closure.cc
+++ b/test/cpp/microbenchmarks/bm_closure.cc
@@ -34,8 +34,7 @@ auto& force_library_initialization = Library::get();
static void BM_NoOpExecCtx(benchmark::State& state) {
TrackCounters track_counters;
while (state.KeepRunning()) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx _local_exec_ctx;
}
track_counters.Finish(state);
}
@@ -43,16 +42,16 @@ BENCHMARK(BM_NoOpExecCtx);
static void BM_WellFlushed(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_WellFlushed);
-static void DoNothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
+static void DoNothing(void* arg, grpc_error* error) {}
static void BM_ClosureInitAgainstExecCtx(benchmark::State& state) {
TrackCounters track_counters;
@@ -69,13 +68,13 @@ static void BM_ClosureInitAgainstCombiner(benchmark::State& state) {
TrackCounters track_counters;
grpc_combiner* combiner = grpc_combiner_create();
grpc_closure c;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
benchmark::DoNotOptimize(GRPC_CLOSURE_INIT(
&c, DoNothing, nullptr, grpc_combiner_scheduler(combiner)));
}
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureInitAgainstCombiner);
@@ -84,41 +83,39 @@ static void BM_ClosureRunOnExecCtx(benchmark::State& state) {
TrackCounters track_counters;
grpc_closure c;
GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_RUN(&exec_ctx, &c, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_RUN(&c, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureRunOnExecCtx);
static void BM_ClosureCreateAndRun(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
GRPC_CLOSURE_RUN(
- &exec_ctx,
GRPC_CLOSURE_CREATE(DoNothing, nullptr, grpc_schedule_on_exec_ctx),
GRPC_ERROR_NONE);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureCreateAndRun);
static void BM_ClosureInitAndRun(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_closure c;
while (state.KeepRunning()) {
GRPC_CLOSURE_RUN(
- &exec_ctx,
GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx),
GRPC_ERROR_NONE);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureInitAndRun);
@@ -127,12 +124,12 @@ static void BM_ClosureSchedOnExecCtx(benchmark::State& state) {
TrackCounters track_counters;
grpc_closure c;
GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSchedOnExecCtx);
@@ -143,13 +140,13 @@ static void BM_ClosureSched2OnExecCtx(benchmark::State& state) {
grpc_closure c2;
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;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c2, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched2OnExecCtx);
@@ -162,14 +159,14 @@ static void BM_ClosureSched3OnExecCtx(benchmark::State& state) {
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;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c2, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c3, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c3, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched3OnExecCtx);
@@ -179,13 +176,13 @@ static void BM_AcquireMutex(benchmark::State& state) {
// for comparison with the combiner stuff below
gpr_mu mu;
gpr_mu_init(&mu);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
gpr_mu_lock(&mu);
- DoNothing(&exec_ctx, nullptr, GRPC_ERROR_NONE);
+ DoNothing(nullptr, GRPC_ERROR_NONE);
gpr_mu_unlock(&mu);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_AcquireMutex);
@@ -195,16 +192,16 @@ static void BM_TryAcquireMutex(benchmark::State& state) {
// for comparison with the combiner stuff below
gpr_mu mu;
gpr_mu_init(&mu);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
if (gpr_mu_trylock(&mu)) {
- DoNothing(&exec_ctx, nullptr, GRPC_ERROR_NONE);
+ DoNothing(nullptr, GRPC_ERROR_NONE);
gpr_mu_unlock(&mu);
} else {
abort();
}
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_TryAcquireMutex);
@@ -213,13 +210,13 @@ static void BM_AcquireSpinlock(benchmark::State& state) {
TrackCounters track_counters;
// for comparison with the combiner stuff below
gpr_spinlock mu = GPR_SPINLOCK_INITIALIZER;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
gpr_spinlock_lock(&mu);
- DoNothing(&exec_ctx, nullptr, GRPC_ERROR_NONE);
+ DoNothing(nullptr, GRPC_ERROR_NONE);
gpr_spinlock_unlock(&mu);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_AcquireSpinlock);
@@ -228,16 +225,16 @@ static void BM_TryAcquireSpinlock(benchmark::State& state) {
TrackCounters track_counters;
// for comparison with the combiner stuff below
gpr_spinlock mu = GPR_SPINLOCK_INITIALIZER;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
if (gpr_spinlock_trylock(&mu)) {
- DoNothing(&exec_ctx, nullptr, GRPC_ERROR_NONE);
+ DoNothing(nullptr, GRPC_ERROR_NONE);
gpr_spinlock_unlock(&mu);
} else {
abort();
}
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_TryAcquireSpinlock);
@@ -247,13 +244,13 @@ static void BM_ClosureSchedOnCombiner(benchmark::State& state) {
grpc_combiner* combiner = grpc_combiner_create();
grpc_closure c;
GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_combiner_scheduler(combiner));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSchedOnCombiner);
@@ -265,14 +262,14 @@ static void BM_ClosureSched2OnCombiner(benchmark::State& state) {
grpc_closure c2;
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;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c2, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched2OnCombiner);
@@ -286,15 +283,15 @@ static void BM_ClosureSched3OnCombiner(benchmark::State& state) {
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;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c2, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c3, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c3, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched3OnCombiner);
@@ -309,15 +306,15 @@ static void BM_ClosureSched2OnTwoCombiners(benchmark::State& state) {
grpc_combiner_scheduler(combiner1));
GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr,
grpc_combiner_scheduler(combiner2));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c2, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- GRPC_COMBINER_UNREF(&exec_ctx, combiner1, "finished");
- GRPC_COMBINER_UNREF(&exec_ctx, combiner2, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner1, "finished");
+ GRPC_COMBINER_UNREF(combiner2, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched2OnTwoCombiners);
@@ -338,17 +335,17 @@ static void BM_ClosureSched4OnTwoCombiners(benchmark::State& state) {
grpc_combiner_scheduler(combiner1));
GRPC_CLOSURE_INIT(&c4, DoNothing, nullptr,
grpc_combiner_scheduler(combiner2));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c2, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c3, GRPC_ERROR_NONE);
- GRPC_CLOSURE_SCHED(&exec_ctx, &c4, GRPC_ERROR_NONE);
- grpc_exec_ctx_flush(&exec_ctx);
+ GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c2, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c3, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&c4, GRPC_ERROR_NONE);
+ grpc_core::ExecCtx::Get()->Flush();
}
- GRPC_COMBINER_UNREF(&exec_ctx, combiner1, "finished");
- GRPC_COMBINER_UNREF(&exec_ctx, combiner2, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_COMBINER_UNREF(combiner1, "finished");
+ GRPC_COMBINER_UNREF(combiner2, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureSched4OnTwoCombiners);
@@ -362,13 +359,11 @@ class Rescheduler {
GRPC_CLOSURE_INIT(&closure_, Step, this, scheduler);
}
- void ScheduleFirst(grpc_exec_ctx* exec_ctx) {
- GRPC_CLOSURE_SCHED(exec_ctx, &closure_, GRPC_ERROR_NONE);
- }
+ void ScheduleFirst() { GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE); }
void ScheduleFirstAgainstDifferentScheduler(
- grpc_exec_ctx* exec_ctx, grpc_closure_scheduler* scheduler) {
- GRPC_CLOSURE_SCHED(exec_ctx, GRPC_CLOSURE_CREATE(Step, this, scheduler),
+ grpc_closure_scheduler* scheduler) {
+ GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(Step, this, scheduler),
GRPC_ERROR_NONE);
}
@@ -376,47 +371,46 @@ class Rescheduler {
benchmark::State& state_;
grpc_closure closure_;
- static void Step(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+ static void Step(void* arg, grpc_error* error) {
Rescheduler* self = static_cast<Rescheduler*>(arg);
if (self->state_.KeepRunning()) {
- GRPC_CLOSURE_SCHED(exec_ctx, &self->closure_, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(&self->closure_, GRPC_ERROR_NONE);
}
}
};
static void BM_ClosureReschedOnExecCtx(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
Rescheduler r(state, grpc_schedule_on_exec_ctx);
- r.ScheduleFirst(&exec_ctx);
- grpc_exec_ctx_finish(&exec_ctx);
+ r.ScheduleFirst();
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureReschedOnExecCtx);
static void BM_ClosureReschedOnCombiner(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_combiner* combiner = grpc_combiner_create();
Rescheduler r(state, grpc_combiner_scheduler(combiner));
- r.ScheduleFirst(&exec_ctx);
- grpc_exec_ctx_flush(&exec_ctx);
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ r.ScheduleFirst();
+ grpc_core::ExecCtx::Get()->Flush();
+ GRPC_COMBINER_UNREF(combiner, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureReschedOnCombiner);
static void BM_ClosureReschedOnCombinerFinally(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_combiner* combiner = grpc_combiner_create();
Rescheduler r(state, grpc_combiner_finally_scheduler(combiner));
- r.ScheduleFirstAgainstDifferentScheduler(&exec_ctx,
- grpc_combiner_scheduler(combiner));
- grpc_exec_ctx_flush(&exec_ctx);
- GRPC_COMBINER_UNREF(&exec_ctx, combiner, "finished");
- grpc_exec_ctx_finish(&exec_ctx);
+ r.ScheduleFirstAgainstDifferentScheduler(grpc_combiner_scheduler(combiner));
+ grpc_core::ExecCtx::Get()->Flush();
+ GRPC_COMBINER_UNREF(combiner, "finished");
+
track_counters.Finish(state);
}
BENCHMARK(BM_ClosureReschedOnCombinerFinally);
diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc
index f0dede7333..16f451d98f 100644
--- a/test/cpp/microbenchmarks/bm_cq.cc
+++ b/test/cpp/microbenchmarks/bm_cq.cc
@@ -66,7 +66,7 @@ static void BM_CreateDestroyCore(benchmark::State& state) {
}
BENCHMARK(BM_CreateDestroyCore);
-static void DoneWithCompletionOnStack(grpc_exec_ctx* exec_ctx, void* arg,
+static void DoneWithCompletionOnStack(void* arg,
grpc_cq_completion* completion) {}
class DummyTag final : public internal::CompletionQueueTag {
@@ -81,11 +81,11 @@ static void BM_Pass1Cpp(benchmark::State& state) {
while (state.KeepRunning()) {
grpc_cq_completion completion;
DummyTag dummy_tag;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
GPR_ASSERT(grpc_cq_begin_op(c_cq, &dummy_tag));
- grpc_cq_end_op(&exec_ctx, c_cq, &dummy_tag, GRPC_ERROR_NONE,
- DoneWithCompletionOnStack, nullptr, &completion);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_cq_end_op(c_cq, &dummy_tag, GRPC_ERROR_NONE, DoneWithCompletionOnStack,
+ nullptr, &completion);
+
void* tag;
bool ok;
cq.Next(&tag, &ok);
@@ -101,11 +101,11 @@ static void BM_Pass1Core(benchmark::State& state) {
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;
+ grpc_core::ExecCtx _local_exec_ctx;
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_cq_end_op(cq, nullptr, GRPC_ERROR_NONE, DoneWithCompletionOnStack,
+ nullptr, &completion);
+
grpc_completion_queue_next(cq, deadline, nullptr);
}
grpc_completion_queue_destroy(cq);
@@ -120,11 +120,11 @@ static void BM_Pluck1Core(benchmark::State& state) {
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;
+ grpc_core::ExecCtx _local_exec_ctx;
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_cq_end_op(cq, nullptr, GRPC_ERROR_NONE, DoneWithCompletionOnStack,
+ nullptr, &completion);
+
grpc_completion_queue_pluck(cq, nullptr, deadline, nullptr);
}
grpc_completion_queue_destroy(cq);
diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
index 7ccebb55ee..874c834931 100644
--- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
+++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
@@ -43,9 +43,8 @@ static grpc_completion_queue* g_cq;
static grpc_event_engine_vtable g_vtable;
static const grpc_event_engine_vtable* g_old_vtable;
-static void pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* ps,
- grpc_closure* closure) {
- GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
+static void pollset_shutdown(grpc_pollset* ps, grpc_closure* closure) {
+ GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
}
static void pollset_init(grpc_pollset* ps, gpr_mu** mu) {
@@ -53,25 +52,20 @@ static void pollset_init(grpc_pollset* ps, gpr_mu** mu) {
*mu = &ps->mu;
}
-static void pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* ps) {
- gpr_mu_destroy(&ps->mu);
-}
+static void pollset_destroy(grpc_pollset* ps) { gpr_mu_destroy(&ps->mu); }
-static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* p,
- grpc_pollset_worker* worker) {
+static grpc_error* pollset_kick(grpc_pollset* p, grpc_pollset_worker* worker) {
return GRPC_ERROR_NONE;
}
/* Callback when the tag is dequeued from the completion queue. Does nothing */
-static void cq_done_cb(grpc_exec_ctx* exec_ctx, void* done_arg,
- grpc_cq_completion* cq_completion) {
+static void cq_done_cb(void* done_arg, grpc_cq_completion* cq_completion) {
gpr_free(cq_completion);
}
/* Queues a completion tag if deadline is > 0.
* Does nothing if deadline is 0 (i.e gpr_time_0(GPR_CLOCK_MONOTONIC)) */
-static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* ps,
- grpc_pollset_worker** worker,
+static grpc_error* pollset_work(grpc_pollset* ps, grpc_pollset_worker** worker,
grpc_millis deadline) {
if (deadline == 0) {
gpr_log(GPR_DEBUG, "no-op");
@@ -80,9 +74,9 @@ 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, nullptr,
+ grpc_cq_end_op(g_cq, g_tag, GRPC_ERROR_NONE, cq_done_cb, nullptr,
(grpc_cq_completion*)gpr_malloc(sizeof(grpc_cq_completion)));
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&ps->mu);
return GRPC_ERROR_NONE;
}
diff --git a/test/cpp/microbenchmarks/bm_error.cc b/test/cpp/microbenchmarks/bm_error.cc
index 02a93e90cc..0ee491a271 100644
--- a/test/cpp/microbenchmarks/bm_error.cc
+++ b/test/cpp/microbenchmarks/bm_error.cc
@@ -246,14 +246,14 @@ template <class Fixture>
static void BM_ErrorGetStatus(benchmark::State& state) {
TrackCounters track_counters;
Fixture fixture;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
grpc_status_code status;
grpc_slice slice;
- grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(),
- &status, &slice, nullptr);
+ grpc_error_get_status(fixture.error(), fixture.deadline(), &status, &slice,
+ nullptr);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
@@ -261,13 +261,13 @@ template <class Fixture>
static void BM_ErrorGetStatusCode(benchmark::State& state) {
TrackCounters track_counters;
Fixture fixture;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
grpc_status_code status;
- grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(),
- &status, nullptr, nullptr);
+ grpc_error_get_status(fixture.error(), fixture.deadline(), &status, nullptr,
+ nullptr);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
@@ -275,13 +275,13 @@ template <class Fixture>
static void BM_ErrorHttpError(benchmark::State& state) {
TrackCounters track_counters;
Fixture fixture;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
grpc_http2_error_code error;
- grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(),
- nullptr, nullptr, &error);
+ grpc_error_get_status(fixture.error(), fixture.deadline(), nullptr, nullptr,
+ &error);
}
- 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 bb974fad50..23ca750307 100644
--- a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
+++ b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
@@ -177,13 +177,13 @@ class TrickledCHTTP2 : public EndpointPairFixture {
}
void Step(bool update_stats) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
inc_time();
size_t client_backlog =
- grpc_trickle_endpoint_trickle(&exec_ctx, endpoint_pair_.client);
+ grpc_trickle_endpoint_trickle(endpoint_pair_.client);
size_t server_backlog =
- grpc_trickle_endpoint_trickle(&exec_ctx, endpoint_pair_.server);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_trickle_endpoint_trickle(endpoint_pair_.server);
+
if (update_stats) {
UpdateStats((grpc_chttp2_transport*)client_transport_, &client_stats_,
client_backlog);
diff --git a/test/cpp/microbenchmarks/bm_metadata.cc b/test/cpp/microbenchmarks/bm_metadata.cc
index 73bce08466..62c9a2e335 100644
--- a/test/cpp/microbenchmarks/bm_metadata.cc
+++ b/test/cpp/microbenchmarks/bm_metadata.cc
@@ -90,11 +90,11 @@ static void BM_MetadataFromNonInternedSlices(benchmark::State& state) {
TrackCounters track_counters;
gpr_slice k = grpc_slice_from_static_string("key");
gpr_slice v = grpc_slice_from_static_string("value");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataFromNonInternedSlices);
@@ -103,11 +103,11 @@ static void BM_MetadataFromInternedSlices(benchmark::State& state) {
TrackCounters track_counters;
gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key"));
gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_slice_unref(k);
grpc_slice_unref(v);
track_counters.Finish(state);
@@ -119,13 +119,13 @@ static void BM_MetadataFromInternedSlicesAlreadyInIndex(
TrackCounters track_counters;
gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key"));
gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value"));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_mdelem seed = grpc_mdelem_create(&exec_ctx, k, v, nullptr);
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_mdelem seed = grpc_mdelem_create(k, v, nullptr);
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr));
}
- GRPC_MDELEM_UNREF(&exec_ctx, seed);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(seed);
+
grpc_slice_unref(k);
grpc_slice_unref(v);
track_counters.Finish(state);
@@ -136,11 +136,11 @@ static void BM_MetadataFromInternedKey(benchmark::State& state) {
TrackCounters track_counters;
gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key"));
gpr_slice v = grpc_slice_from_static_string("value");
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_slice_unref(k);
track_counters.Finish(state);
}
@@ -152,14 +152,12 @@ static void BM_MetadataFromNonInternedSlicesWithBackingStore(
gpr_slice k = grpc_slice_from_static_string("key");
gpr_slice v = grpc_slice_from_static_string("value");
char backing_store[sizeof(grpc_mdelem_data)];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(
- &exec_ctx,
- grpc_mdelem_create(&exec_ctx, k, v,
- reinterpret_cast<grpc_mdelem_data*>(backing_store)));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(
+ k, v, reinterpret_cast<grpc_mdelem_data*>(backing_store)));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataFromNonInternedSlicesWithBackingStore);
@@ -170,14 +168,12 @@ static void BM_MetadataFromInternedSlicesWithBackingStore(
gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key"));
gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value"));
char backing_store[sizeof(grpc_mdelem_data)];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(
- &exec_ctx,
- grpc_mdelem_create(&exec_ctx, k, v,
- reinterpret_cast<grpc_mdelem_data*>(backing_store)));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(
+ k, v, reinterpret_cast<grpc_mdelem_data*>(backing_store)));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_slice_unref(k);
grpc_slice_unref(v);
track_counters.Finish(state);
@@ -190,14 +186,12 @@ static void BM_MetadataFromInternedKeyWithBackingStore(
gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key"));
gpr_slice v = grpc_slice_from_static_string("value");
char backing_store[sizeof(grpc_mdelem_data)];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(
- &exec_ctx,
- grpc_mdelem_create(&exec_ctx, k, v,
- reinterpret_cast<grpc_mdelem_data*>(backing_store)));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(
+ k, v, reinterpret_cast<grpc_mdelem_data*>(backing_store)));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_slice_unref(k);
track_counters.Finish(state);
}
@@ -207,11 +201,11 @@ static void BM_MetadataFromStaticMetadataStrings(benchmark::State& state) {
TrackCounters track_counters;
gpr_slice k = GRPC_MDSTR_STATUS;
gpr_slice v = GRPC_MDSTR_200;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_slice_unref(k);
track_counters.Finish(state);
}
@@ -222,11 +216,11 @@ static void BM_MetadataFromStaticMetadataStringsNotIndexed(
TrackCounters track_counters;
gpr_slice k = GRPC_MDSTR_STATUS;
gpr_slice v = GRPC_MDSTR_GZIP;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr));
+ GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr));
}
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_slice_unref(k);
track_counters.Finish(state);
}
@@ -235,16 +229,15 @@ BENCHMARK(BM_MetadataFromStaticMetadataStringsNotIndexed);
static void BM_MetadataRefUnrefExternal(benchmark::State& state) {
TrackCounters track_counters;
char backing_store[sizeof(grpc_mdelem_data)];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_mdelem el =
- grpc_mdelem_create(&exec_ctx, grpc_slice_from_static_string("a"),
- grpc_slice_from_static_string("b"),
- reinterpret_cast<grpc_mdelem_data*>(backing_store));
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_mdelem el = grpc_mdelem_create(
+ grpc_slice_from_static_string("a"), grpc_slice_from_static_string("b"),
+ reinterpret_cast<grpc_mdelem_data*>(backing_store));
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, GRPC_MDELEM_REF(el));
+ GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el));
}
- GRPC_MDELEM_UNREF(&exec_ctx, el);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(el);
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataRefUnrefExternal);
@@ -252,47 +245,47 @@ BENCHMARK(BM_MetadataRefUnrefExternal);
static void BM_MetadataRefUnrefInterned(benchmark::State& state) {
TrackCounters track_counters;
char backing_store[sizeof(grpc_mdelem_data)];
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key"));
gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value"));
grpc_mdelem el = grpc_mdelem_create(
- &exec_ctx, k, v, reinterpret_cast<grpc_mdelem_data*>(backing_store));
+ k, v, reinterpret_cast<grpc_mdelem_data*>(backing_store));
grpc_slice_unref(k);
grpc_slice_unref(v);
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, GRPC_MDELEM_REF(el));
+ GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el));
}
- GRPC_MDELEM_UNREF(&exec_ctx, el);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(el);
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataRefUnrefInterned);
static void BM_MetadataRefUnrefAllocated(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem el =
- grpc_mdelem_create(&exec_ctx, grpc_slice_from_static_string("a"),
+ grpc_mdelem_create(grpc_slice_from_static_string("a"),
grpc_slice_from_static_string("b"), nullptr);
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, GRPC_MDELEM_REF(el));
+ GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el));
}
- GRPC_MDELEM_UNREF(&exec_ctx, el);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(el);
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataRefUnrefAllocated);
static void BM_MetadataRefUnrefStatic(benchmark::State& state) {
TrackCounters track_counters;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_mdelem el =
- grpc_mdelem_create(&exec_ctx, GRPC_MDSTR_STATUS, GRPC_MDSTR_200, nullptr);
+ grpc_mdelem_create(GRPC_MDSTR_STATUS, GRPC_MDSTR_200, nullptr);
while (state.KeepRunning()) {
- GRPC_MDELEM_UNREF(&exec_ctx, GRPC_MDELEM_REF(el));
+ GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el));
}
- GRPC_MDELEM_UNREF(&exec_ctx, el);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(el);
+
track_counters.Finish(state);
}
BENCHMARK(BM_MetadataRefUnrefStatic);
diff --git a/test/cpp/microbenchmarks/bm_pollset.cc b/test/cpp/microbenchmarks/bm_pollset.cc
index 4da79693f1..ec0bf4e4b9 100644
--- a/test/cpp/microbenchmarks/bm_pollset.cc
+++ b/test/cpp/microbenchmarks/bm_pollset.cc
@@ -41,8 +41,8 @@
auto& force_library_initialization = Library::get();
-static void shutdown_ps(grpc_exec_ctx* exec_ctx, void* ps, grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(ps));
+static void shutdown_ps(void* ps, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(ps));
}
static void BM_CreateDestroyPollset(benchmark::State& state) {
@@ -50,7 +50,7 @@ static void BM_CreateDestroyPollset(benchmark::State& state) {
size_t ps_sz = grpc_pollset_size();
grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_malloc(ps_sz));
gpr_mu* mu;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_closure shutdown_ps_closure;
GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps,
grpc_schedule_on_exec_ctx);
@@ -58,11 +58,11 @@ static void BM_CreateDestroyPollset(benchmark::State& state) {
memset(ps, 0, ps_sz);
grpc_pollset_init(ps, &mu);
gpr_mu_lock(mu);
- grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure);
+ grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_free(ps);
track_counters.Finish(state);
}
@@ -114,17 +114,17 @@ static void BM_PollEmptyPollset(benchmark::State& state) {
grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_zalloc(ps_sz));
gpr_mu* mu;
grpc_pollset_init(ps, &mu);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_mu_lock(mu);
while (state.KeepRunning()) {
- GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, nullptr, 0));
+ GRPC_ERROR_UNREF(grpc_pollset_work(ps, nullptr, 0));
}
grpc_closure shutdown_ps_closure;
GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure);
+ grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_free(ps);
track_counters.Finish(state);
}
@@ -136,24 +136,23 @@ static void BM_PollAddFd(benchmark::State& state) {
grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_zalloc(ps_sz));
gpr_mu* mu;
grpc_pollset_init(ps, &mu);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_wakeup_fd wakeup_fd;
GPR_ASSERT(
GRPC_LOG_IF_ERROR("wakeup_fd_init", grpc_wakeup_fd_init(&wakeup_fd)));
grpc_fd* fd = grpc_fd_create(wakeup_fd.read_fd, "xxx");
while (state.KeepRunning()) {
- grpc_pollset_add_fd(&exec_ctx, ps, fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(ps, fd);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_fd_orphan(&exec_ctx, fd, nullptr, nullptr, false /* already_closed */,
- "xxx");
+ grpc_fd_orphan(fd, nullptr, nullptr, false /* already_closed */, "xxx");
grpc_closure shutdown_ps_closure;
GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps,
grpc_schedule_on_exec_ctx);
gpr_mu_lock(mu);
- grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure);
+ grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_free(ps);
track_counters.Finish(state);
}
@@ -170,7 +169,7 @@ Closure* MakeClosure(F f, grpc_closure_scheduler* scheduler) {
C(F f, grpc_closure_scheduler* scheduler) : f_(f) {
GRPC_CLOSURE_INIT(this, C::cbfn, this, scheduler);
}
- static void cbfn(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+ static void cbfn(void* arg, grpc_error* error) {
C* p = static_cast<C*>(arg);
p->f_();
}
@@ -219,11 +218,11 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) {
grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_zalloc(ps_sz));
gpr_mu* mu;
grpc_pollset_init(ps, &mu);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
grpc_wakeup_fd wakeup_fd;
GRPC_ERROR_UNREF(grpc_wakeup_fd_init(&wakeup_fd));
grpc_fd* wakeup = grpc_fd_create(wakeup_fd.read_fd, "wakeup_read");
- grpc_pollset_add_fd(&exec_ctx, ps, wakeup);
+ grpc_pollset_add_fd(ps, wakeup);
bool done = false;
Closure* continue_closure = MakeClosure(
[&]() {
@@ -233,25 +232,23 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) {
return;
}
GRPC_ERROR_UNREF(grpc_wakeup_fd_wakeup(&wakeup_fd));
- grpc_fd_notify_on_read(&exec_ctx, wakeup, continue_closure);
+ grpc_fd_notify_on_read(wakeup, continue_closure);
},
grpc_schedule_on_exec_ctx);
GRPC_ERROR_UNREF(grpc_wakeup_fd_wakeup(&wakeup_fd));
- grpc_fd_notify_on_read(&exec_ctx, wakeup, continue_closure);
+ grpc_fd_notify_on_read(wakeup, continue_closure);
gpr_mu_lock(mu);
while (!done) {
- GRPC_ERROR_UNREF(
- grpc_pollset_work(&exec_ctx, ps, nullptr, GRPC_MILLIS_INF_FUTURE));
+ GRPC_ERROR_UNREF(grpc_pollset_work(ps, nullptr, GRPC_MILLIS_INF_FUTURE));
}
- grpc_fd_orphan(&exec_ctx, wakeup, nullptr, nullptr,
- false /* already_closed */, "done");
+ grpc_fd_orphan(wakeup, nullptr, nullptr, false /* already_closed */, "done");
wakeup_fd.read_fd = 0;
grpc_closure shutdown_ps_closure;
GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure);
+ grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_finish(&exec_ctx);
+
grpc_wakeup_fd_destroy(&wakeup_fd);
gpr_free(ps);
track_counters.Finish(state);
diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h
index 7f1aa48b56..1520282009 100644
--- a/test/cpp/microbenchmarks/fullstack_fixtures.h
+++ b/test/cpp/microbenchmarks/fullstack_fixtures.h
@@ -166,7 +166,7 @@ class EndpointPairFixture : public BaseFixture {
fixture_configuration.ApplyCommonServerBuilderConfig(&b);
server_ = b.BuildAndStart();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
/* add server endpoint to server_
* */
@@ -174,20 +174,19 @@ class EndpointPairFixture : public BaseFixture {
const grpc_channel_args* server_args =
grpc_server_get_channel_args(server_->c_server());
server_transport_ = grpc_create_chttp2_transport(
- &exec_ctx, server_args, endpoints.server, 0 /* is_client */);
+ server_args, endpoints.server, 0 /* is_client */);
grpc_pollset** pollsets;
size_t num_pollsets = 0;
grpc_server_get_pollsets(server_->c_server(), &pollsets, &num_pollsets);
for (size_t i = 0; i < num_pollsets; i++) {
- grpc_endpoint_add_to_pollset(&exec_ctx, endpoints.server, pollsets[i]);
+ grpc_endpoint_add_to_pollset(endpoints.server, pollsets[i]);
}
- grpc_server_setup_transport(&exec_ctx, server_->c_server(),
- server_transport_, nullptr, server_args);
- grpc_chttp2_transport_start_reading(&exec_ctx, server_transport_,
- nullptr);
+ grpc_server_setup_transport(server_->c_server(), server_transport_,
+ nullptr, server_args);
+ grpc_chttp2_transport_start_reading(server_transport_, nullptr);
}
/* create channel */
@@ -198,18 +197,14 @@ class EndpointPairFixture : public BaseFixture {
grpc_channel_args c_args = args.c_channel_args();
client_transport_ =
- grpc_create_chttp2_transport(&exec_ctx, &c_args, endpoints.client, 1);
+ grpc_create_chttp2_transport(&c_args, endpoints.client, 1);
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_,
- nullptr);
+ grpc_channel* channel = grpc_channel_create(
+ "target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport_);
+ grpc_chttp2_transport_start_reading(client_transport_, nullptr);
channel_ = CreateChannelInternal("", channel);
}
-
- grpc_exec_ctx_finish(&exec_ctx);
}
virtual ~EndpointPairFixture() {
diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc
index 6f1f0c44b9..3bd1df9429 100644
--- a/test/cpp/naming/resolver_component_test.cc
+++ b/test/cpp/naming/resolver_component_test.cc
@@ -149,33 +149,33 @@ struct ArgsStruct {
std::string expected_lb_policy;
};
-void ArgsInit(grpc_exec_ctx* exec_ctx, ArgsStruct* args) {
+void ArgsInit(ArgsStruct* args) {
gpr_event_init(&args->ev);
args->pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
grpc_pollset_init(args->pollset, &args->mu);
args->pollset_set = grpc_pollset_set_create();
- grpc_pollset_set_add_pollset(exec_ctx, args->pollset_set, args->pollset);
+ grpc_pollset_set_add_pollset(args->pollset_set, args->pollset);
args->lock = grpc_combiner_create();
gpr_atm_rel_store(&args->done_atm, 0);
args->channel_args = nullptr;
}
-void DoNothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
+void DoNothing(void* arg, grpc_error* error) {}
-void ArgsFinish(grpc_exec_ctx* exec_ctx, ArgsStruct* args) {
+void ArgsFinish(ArgsStruct* args) {
GPR_ASSERT(gpr_event_wait(&args->ev, TestDeadline()));
- grpc_pollset_set_del_pollset(exec_ctx, args->pollset_set, args->pollset);
- grpc_pollset_set_destroy(exec_ctx, args->pollset_set);
+ grpc_pollset_set_del_pollset(args->pollset_set, args->pollset);
+ grpc_pollset_set_destroy(args->pollset_set);
grpc_closure DoNothing_cb;
GRPC_CLOSURE_INIT(&DoNothing_cb, DoNothing, nullptr,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(exec_ctx, args->pollset, &DoNothing_cb);
+ grpc_pollset_shutdown(args->pollset, &DoNothing_cb);
// exec_ctx needs to be flushed before calling grpc_pollset_destroy()
- grpc_channel_args_destroy(exec_ctx, args->channel_args);
- grpc_exec_ctx_flush(exec_ctx);
- grpc_pollset_destroy(exec_ctx, args->pollset);
+ grpc_channel_args_destroy(args->channel_args);
+ grpc_core::ExecCtx::Get()->Flush();
+ grpc_pollset_destroy(args->pollset);
gpr_free(args->pollset);
- GRPC_COMBINER_UNREF(exec_ctx, args->lock, NULL);
+ GRPC_COMBINER_UNREF(args->lock, nullptr);
}
gpr_timespec NSecondDeadline(int seconds) {
@@ -196,14 +196,13 @@ void PollPollsetUntilRequestDone(ArgsStruct* args) {
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 = nullptr;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
gpr_mu_lock(args->mu);
GRPC_LOG_IF_ERROR("pollset_work",
- grpc_pollset_work(&exec_ctx, args->pollset, &worker,
+ grpc_pollset_work(args->pollset, &worker,
grpc_timespec_to_millis_round_up(
NSecondDeadline(1))));
gpr_mu_unlock(args->mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
gpr_event_set(&args->ev, (void*)1);
}
@@ -235,8 +234,7 @@ void CheckLBPolicyResultLocked(grpc_channel_args* channel_args,
}
}
-void CheckResolverResultLocked(grpc_exec_ctx* exec_ctx, void* argsp,
- grpc_error* err) {
+void CheckResolverResultLocked(void* argsp, grpc_error* err) {
ArgsStruct* args = (ArgsStruct*)argsp;
grpc_channel_args* channel_args = args->channel_args;
const grpc_arg* channel_arg =
@@ -272,15 +270,14 @@ 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, nullptr));
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, nullptr));
gpr_mu_unlock(args->mu);
}
TEST(ResolverComponentTest, TestResolvesRelevantRecords) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
ArgsStruct args;
- ArgsInit(&exec_ctx, &args);
+ ArgsInit(&args);
args.expected_addrs = ParseExpectedAddrs(FLAGS_expected_addrs);
args.expected_service_config_string = FLAGS_expected_chosen_service_config;
args.expected_lb_policy = FLAGS_expected_lb_policy;
@@ -290,19 +287,18 @@ TEST(ResolverComponentTest, TestResolvesRelevantRecords) {
FLAGS_local_dns_server_address.c_str(),
FLAGS_target_name.c_str()));
// create resolver and resolve
- grpc_resolver* resolver = grpc_resolver_create(&exec_ctx, whole_uri, nullptr,
- args.pollset_set, args.lock);
+ grpc_resolver* resolver =
+ grpc_resolver_create(whole_uri, nullptr, args.pollset_set, args.lock);
gpr_free(whole_uri);
grpc_closure on_resolver_result_changed;
GRPC_CLOSURE_INIT(&on_resolver_result_changed, CheckResolverResultLocked,
(void*)&args, grpc_combiner_scheduler(args.lock));
- grpc_resolver_next_locked(&exec_ctx, resolver, &args.channel_args,
+ grpc_resolver_next_locked(resolver, &args.channel_args,
&on_resolver_result_changed);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
PollPollsetUntilRequestDone(&args);
- GRPC_RESOLVER_UNREF(&exec_ctx, resolver, NULL);
- ArgsFinish(&exec_ctx, &args);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_RESOLVER_UNREF(resolver, nullptr);
+ ArgsFinish(&args);
}
} // namespace
diff --git a/test/cpp/performance/writes_per_rpc_test.cc b/test/cpp/performance/writes_per_rpc_test.cc
index 23fff2ea8b..c5d29469b2 100644
--- a/test/cpp/performance/writes_per_rpc_test.cc
+++ b/test/cpp/performance/writes_per_rpc_test.cc
@@ -82,26 +82,26 @@ class EndpointPairFixture {
ApplyCommonServerBuilderConfig(&b);
server_ = b.BuildAndStart();
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx _local_exec_ctx;
/* add server endpoint to server_ */
{
const grpc_channel_args* server_args =
grpc_server_get_channel_args(server_->c_server());
grpc_transport* transport = grpc_create_chttp2_transport(
- &exec_ctx, server_args, endpoints.server, 0 /* is_client */);
+ server_args, endpoints.server, 0 /* is_client */);
grpc_pollset** pollsets;
size_t num_pollsets = 0;
grpc_server_get_pollsets(server_->c_server(), &pollsets, &num_pollsets);
for (size_t i = 0; i < num_pollsets; i++) {
- grpc_endpoint_add_to_pollset(&exec_ctx, endpoints.server, pollsets[i]);
+ grpc_endpoint_add_to_pollset(endpoints.server, pollsets[i]);
}
- grpc_server_setup_transport(&exec_ctx, server_->c_server(), transport,
- nullptr, server_args);
- grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr);
+ grpc_server_setup_transport(server_->c_server(), transport, nullptr,
+ server_args);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
}
/* create channel */
@@ -112,16 +112,14 @@ class EndpointPairFixture {
grpc_channel_args c_args = args.c_channel_args();
grpc_transport* transport =
- grpc_create_chttp2_transport(&exec_ctx, &c_args, endpoints.client, 1);
+ grpc_create_chttp2_transport(&c_args, endpoints.client, 1);
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, nullptr);
+ "target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, transport);
+ grpc_chttp2_transport_start_reading(transport, nullptr);
channel_ = CreateChannelInternal("", channel);
}
-
- grpc_exec_ctx_finish(&exec_ctx);
}
virtual ~EndpointPairFixture() {
diff --git a/tools/codegen/core/gen_stats_data.py b/tools/codegen/core/gen_stats_data.py
index 072a677615..d439d99a8c 100755
--- a/tools/codegen/core/gen_stats_data.py
+++ b/tools/codegen/core/gen_stats_data.py
@@ -150,11 +150,11 @@ def gen_bucket_code(histogram):
code = 'value = GPR_CLAMP(value, 0, %d);\n' % histogram.max
map_table = gen_map_table(code_bounds[first_nontrivial:], shift_data)
if first_nontrivial is None:
- code += ('GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_%s, value);\n'
+ code += ('GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_%s, value);\n'
% histogram.name.upper())
else:
code += 'if (value < %d) {\n' % first_nontrivial
- code += ('GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_%s, value);\n'
+ code += ('GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_%s, value);\n'
% histogram.name.upper())
code += 'return;\n'
code += '}'
@@ -168,11 +168,11 @@ def gen_bucket_code(histogram):
code += 'grpc_stats_table_%d[((_val.uint - %dull) >> %d)] + %d;\n' % (map_table_idx, first_nontrivial_code, shift_data[0], first_nontrivial)
code += '_bkt.dbl = grpc_stats_table_%d[bucket];\n' % bounds_idx
code += 'bucket -= (_val.uint < _bkt.uint);\n'
- code += 'GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_%s, bucket);\n' % histogram.name.upper()
+ code += 'GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_%s, bucket);\n' % histogram.name.upper()
code += 'return;\n'
code += '}\n'
- code += 'GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_%s, '% histogram.name.upper()
- code += 'grpc_stats_histo_find_bucket_slow((exec_ctx), value, grpc_stats_table_%d, %d));\n' % (bounds_idx, histogram.buckets)
+ code += 'GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_%s, '% histogram.name.upper()
+ code += 'grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_%d, %d));\n' % (bounds_idx, histogram.buckets)
return (code, bounds_idx)
# utility: print a big comment block into a set of files
@@ -240,13 +240,13 @@ with open('src/core/lib/debug/stats_data.h', 'w') as H:
print >>H, "} grpc_stats_histogram_constants;"
for ctr in inst_map['Counter']:
- print >>H, ("#define GRPC_STATS_INC_%s(exec_ctx) " +
- "GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_%s)") % (
+ print >>H, ("#define GRPC_STATS_INC_%s() " +
+ "GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_%s)") % (
ctr.name.upper(), ctr.name.upper())
for histogram in inst_map['Histogram']:
- print >>H, "#define GRPC_STATS_INC_%s(exec_ctx, value) grpc_stats_inc_%s((exec_ctx), (int)(value))" % (
+ print >>H, "#define GRPC_STATS_INC_%s(value) grpc_stats_inc_%s( (int)(value))" % (
histogram.name.upper(), histogram.name.lower())
- print >>H, "void grpc_stats_inc_%s(grpc_exec_ctx *exec_ctx, int x);" % histogram.name.lower()
+ print >>H, "void grpc_stats_inc_%s(int x);" % histogram.name.lower()
for i, tbl in enumerate(static_tables):
print >>H, "extern const %s grpc_stats_table_%d[%d];" % (tbl[0], i, len(tbl[1]))
@@ -254,7 +254,7 @@ with open('src/core/lib/debug/stats_data.h', 'w') as H:
print >>H, "extern const int grpc_stats_histo_buckets[%d];" % len(inst_map['Histogram'])
print >>H, "extern const int grpc_stats_histo_start[%d];" % len(inst_map['Histogram'])
print >>H, "extern const int *const grpc_stats_histo_bucket_boundaries[%d];" % len(inst_map['Histogram'])
- print >>H, "extern void (*const grpc_stats_inc_histogram[%d])(grpc_exec_ctx *exec_ctx, int x);" % len(inst_map['Histogram'])
+ print >>H, "extern void (*const grpc_stats_inc_histogram[%d])(int x);" % len(inst_map['Histogram'])
print >>H
print >>H, "#ifdef __cplusplus"
@@ -309,7 +309,7 @@ with open('src/core/lib/debug/stats_data.cc', 'w') as C:
tbl[0], i, len(tbl[1]), ','.join('%s' % x for x in tbl[1]))
for histogram, code in zip(inst_map['Histogram'], histo_code):
- print >>C, ("void grpc_stats_inc_%s(grpc_exec_ctx *exec_ctx, int value) {%s}") % (
+ print >>C, ("void grpc_stats_inc_%s(int value) {%s}") % (
histogram.name.lower(),
code)
@@ -319,7 +319,7 @@ with open('src/core/lib/debug/stats_data.cc', 'w') as C:
len(inst_map['Histogram']), ','.join('%s' % x for x in histo_start))
print >>C, "const int *const grpc_stats_histo_bucket_boundaries[%d] = {%s};" % (
len(inst_map['Histogram']), ','.join('grpc_stats_table_%d' % x for x in histo_bucket_boundaries))
- print >>C, "void (*const grpc_stats_inc_histogram[%d])(grpc_exec_ctx *exec_ctx, int x) = {%s};" % (
+ print >>C, "void (*const grpc_stats_inc_histogram[%d])(int x) = {%s};" % (
len(inst_map['Histogram']), ','.join('grpc_stats_inc_%s' % histogram.name.lower() for histogram in inst_map['Histogram']))
# patch qps_test bigquery schema