grpc 1.25.0 → 1.26.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +782 -291
- data/include/grpc/impl/codegen/grpc_types.h +4 -0
- data/include/grpc/impl/codegen/port_platform.h +7 -0
- data/include/grpc/support/alloc.h +0 -16
- data/src/core/ext/filters/client_channel/backend_metric.cc +2 -2
- data/src/core/ext/filters/client_channel/backup_poller.cc +1 -1
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +2 -2
- data/src/core/ext/filters/client_channel/client_channel.cc +95 -88
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +7 -7
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +4 -2
- data/src/core/ext/filters/client_channel/client_channel_factory.cc +1 -1
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +3 -3
- data/src/core/ext/filters/client_channel/connector.h +40 -45
- data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +10 -10
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +16 -13
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +66 -37
- data/src/core/ext/filters/client_channel/http_proxy.cc +107 -116
- data/src/core/ext/filters/client_channel/http_proxy.h +5 -1
- data/src/core/ext/filters/client_channel/lb_policy.cc +3 -3
- data/src/core/ext/filters/client_channel/lb_policy.h +9 -5
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +10 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +18 -19
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +4 -3
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +4 -4
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +6 -9
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +368 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +157 -77
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +5 -5
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -1
- data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +8 -8
- data/src/core/ext/filters/client_channel/proxy_mapper.h +14 -34
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.cc +46 -79
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +23 -17
- data/src/core/ext/filters/client_channel/resolver.cc +2 -1
- data/src/core/ext/filters/client_channel/resolver.h +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +4 -4
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +13 -10
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +3 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +9 -8
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +17 -16
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +4 -4
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +9 -9
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +5 -3
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver_factory.h +3 -3
- data/src/core/ext/filters/client_channel/resolver_registry.cc +14 -12
- data/src/core/ext/filters/client_channel/resolver_registry.h +6 -4
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +6 -6
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +6 -6
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +5 -5
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +3 -3
- data/src/core/ext/filters/client_channel/service_config.cc +15 -14
- data/src/core/ext/filters/client_channel/service_config.h +14 -19
- data/src/core/ext/filters/client_channel/subchannel.cc +38 -36
- data/src/core/ext/filters/client_channel/subchannel.h +11 -12
- data/src/core/ext/filters/client_channel/subchannel_interface.h +1 -1
- data/src/core/ext/filters/client_channel/xds/xds_api.cc +19 -9
- data/src/core/ext/filters/client_channel/xds/xds_api.h +19 -9
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +3 -3
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +6 -5
- data/src/core/ext/filters/client_channel/xds/xds_client.cc +58 -31
- data/src/core/ext/filters/client_channel/xds/xds_client.h +20 -15
- data/src/core/ext/filters/client_channel/xds/xds_client_stats.cc +5 -3
- data/src/core/ext/filters/client_channel/xds/xds_client_stats.h +18 -15
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +10 -10
- data/src/core/ext/filters/deadline/deadline_filter.cc +15 -13
- data/src/core/ext/filters/http/client/http_client_filter.cc +12 -12
- data/src/core/ext/filters/http/client_authority_filter.cc +3 -3
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +13 -7
- data/src/core/ext/filters/http/server/http_server_filter.cc +14 -13
- data/src/core/ext/filters/max_age/max_age_filter.cc +16 -14
- data/src/core/ext/filters/message_size/message_size_filter.cc +10 -8
- data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +9 -8
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +141 -174
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +31 -1
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +7 -6
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +14 -12
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +8 -5
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +46 -38
- data/src/core/ext/transport/chttp2/transport/context_list.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/flow_control.h +0 -5
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +6 -7
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +4 -3
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +5 -5
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +11 -8
- data/src/core/ext/transport/chttp2/transport/internal.h +3 -3
- data/src/core/ext/transport/chttp2/transport/parsing.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/writing.cc +3 -2
- data/src/core/ext/transport/inproc/inproc_transport.cc +65 -41
- data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c +141 -70
- data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +352 -118
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c +8 -4
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +65 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +16 -2
- data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +36 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +12 -5
- data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +34 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +1 -2
- data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +13 -12
- data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +28 -24
- data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +5 -4
- data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +13 -0
- data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.c +23 -23
- data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +48 -44
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/type/http.upb.c +16 -0
- data/src/core/ext/upb-generated/envoy/type/http.upb.h +36 -0
- data/src/core/ext/upb-generated/envoy/type/percent.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/type/range.upb.c +0 -1
- data/src/core/lib/avl/avl.cc +1 -1
- data/src/core/lib/channel/channel_stack.cc +1 -1
- data/src/core/lib/channel/channel_stack.h +16 -4
- data/src/core/lib/channel/channel_trace.cc +4 -4
- data/src/core/lib/channel/channelz.cc +46 -46
- data/src/core/lib/channel/channelz.h +37 -35
- data/src/core/lib/channel/channelz_registry.cc +2 -2
- data/src/core/lib/channel/channelz_registry.h +1 -1
- data/src/core/lib/channel/connected_channel.cc +3 -2
- data/src/core/lib/channel/handshaker.cc +1 -1
- data/src/core/lib/channel/handshaker_registry.cc +5 -5
- data/src/core/lib/channel/handshaker_registry.h +3 -3
- data/src/core/lib/compression/message_compress.cc +3 -2
- data/src/core/lib/compression/stream_compression_identity.cc +5 -7
- data/src/core/lib/gpr/alloc.cc +4 -29
- data/src/core/lib/gpr/cpu_linux.cc +1 -1
- data/src/core/lib/gprpp/fork.cc +4 -4
- data/src/core/lib/gprpp/global_config_env.cc +7 -7
- data/src/core/lib/gprpp/global_config_env.h +2 -2
- data/src/core/lib/gprpp/host_port.cc +8 -8
- data/src/core/lib/gprpp/host_port.h +3 -3
- data/src/core/lib/gprpp/inlined_vector.h +13 -0
- data/src/core/lib/gprpp/map.h +2 -9
- data/src/core/lib/gprpp/memory.h +12 -98
- data/src/core/lib/gprpp/orphanable.h +3 -3
- data/src/core/lib/gprpp/ref_counted.h +3 -3
- data/src/core/lib/gprpp/ref_counted_ptr.h +1 -1
- data/src/core/lib/gprpp/string_view.h +45 -23
- data/src/core/lib/gprpp/thd.h +1 -1
- data/src/core/lib/gprpp/thd_posix.cc +6 -5
- data/src/core/lib/gprpp/thd_windows.cc +3 -3
- data/src/core/lib/http/httpcli.cc +1 -1
- data/src/core/lib/http/httpcli_security_connector.cc +3 -3
- data/src/core/lib/iomgr/buffer_list.cc +10 -5
- data/src/core/lib/iomgr/call_combiner.cc +7 -6
- data/src/core/lib/iomgr/call_combiner.h +4 -3
- data/src/core/lib/iomgr/cfstream_handle.cc +2 -2
- data/src/core/lib/iomgr/closure.h +33 -135
- data/src/core/lib/iomgr/combiner.cc +10 -17
- data/src/core/lib/iomgr/combiner.h +0 -2
- data/src/core/lib/iomgr/endpoint_cfstream.cc +2 -2
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +1 -1
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +3 -2
- data/src/core/lib/iomgr/ev_epollex_linux.cc +23 -13
- data/src/core/lib/iomgr/ev_poll_posix.cc +30 -17
- data/src/core/lib/iomgr/exec_ctx.cc +52 -5
- data/src/core/lib/iomgr/exec_ctx.h +6 -2
- data/src/core/lib/iomgr/executor.cc +16 -37
- data/src/core/lib/iomgr/executor.h +4 -7
- data/src/core/lib/iomgr/executor/threadpool.cc +4 -4
- data/src/core/lib/iomgr/iomgr_custom.cc +1 -1
- data/src/core/lib/iomgr/lockfree_event.cc +9 -8
- data/src/core/lib/iomgr/logical_thread.cc +103 -0
- data/src/core/lib/iomgr/logical_thread.h +52 -0
- data/src/core/lib/iomgr/pollset_custom.cc +5 -5
- data/src/core/lib/iomgr/pollset_set_custom.cc +9 -9
- data/src/core/lib/iomgr/pollset_windows.cc +16 -2
- data/src/core/lib/iomgr/port.h +3 -0
- data/src/core/lib/iomgr/resolve_address_custom.cc +4 -4
- data/src/core/lib/iomgr/resolve_address_posix.cc +8 -9
- data/src/core/lib/iomgr/resolve_address_windows.cc +4 -6
- data/src/core/lib/iomgr/resource_quota.cc +26 -21
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +11 -0
- data/src/core/lib/iomgr/socket_windows.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_custom.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_posix.cc +5 -4
- data/src/core/lib/iomgr/tcp_client_windows.cc +2 -2
- data/src/core/lib/iomgr/tcp_custom.cc +10 -9
- data/src/core/lib/iomgr/tcp_posix.cc +19 -15
- data/src/core/lib/iomgr/tcp_server_custom.cc +3 -2
- data/src/core/lib/iomgr/tcp_server_posix.cc +5 -4
- data/src/core/lib/iomgr/tcp_server_windows.cc +5 -3
- data/src/core/lib/iomgr/tcp_windows.cc +16 -13
- data/src/core/lib/iomgr/timer_custom.cc +4 -3
- data/src/core/lib/iomgr/timer_generic.cc +11 -9
- data/src/core/lib/iomgr/udp_server.cc +16 -13
- data/src/core/lib/security/credentials/alts/alts_credentials.cc +8 -5
- data/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc +45 -57
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +7 -6
- data/src/core/lib/security/credentials/credentials.cc +8 -8
- data/src/core/lib/security/credentials/credentials.h +5 -5
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +5 -5
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +1 -1
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +4 -4
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +4 -4
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +2 -2
- data/src/core/lib/security/credentials/local/local_credentials.cc +3 -3
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +13 -11
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +6 -5
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +4 -4
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +5 -5
- data/src/core/lib/security/credentials/tls/spiffe_credentials.cc +2 -2
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +28 -22
- data/src/core/lib/security/security_connector/alts/alts_security_connector.h +5 -0
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +10 -10
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +2 -1
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +8 -8
- data/src/core/lib/security/security_connector/security_connector.h +1 -1
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +9 -9
- data/src/core/lib/security/security_connector/ssl_utils.cc +5 -4
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +14 -15
- data/src/core/lib/security/transport/client_auth_filter.cc +4 -3
- data/src/core/lib/security/transport/secure_endpoint.cc +9 -8
- data/src/core/lib/security/transport/security_handshaker.cc +67 -23
- data/src/core/lib/security/transport/server_auth_filter.cc +6 -5
- data/src/core/lib/security/transport/target_authority_table.h +1 -1
- data/src/core/lib/slice/b64.cc +3 -4
- data/src/core/lib/slice/b64.h +1 -2
- data/src/core/lib/slice/slice.cc +8 -13
- data/src/core/lib/surface/call.cc +19 -19
- data/src/core/lib/surface/call.h +6 -7
- data/src/core/lib/surface/call_log_batch.cc +1 -2
- data/src/core/lib/surface/channel.cc +17 -18
- data/src/core/lib/surface/channel.h +4 -19
- data/src/core/lib/surface/channel_ping.cc +1 -1
- data/src/core/lib/surface/completion_queue.cc +21 -22
- data/src/core/lib/surface/completion_queue_factory.cc +1 -1
- data/src/core/lib/surface/init.cc +1 -1
- data/src/core/lib/surface/init_secure.cc +2 -2
- data/src/core/lib/surface/lame_client.cc +10 -12
- data/src/core/lib/surface/server.cc +24 -18
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/byte_stream.cc +2 -2
- data/src/core/lib/transport/byte_stream.h +2 -1
- data/src/core/lib/transport/connectivity_state.cc +4 -4
- data/src/core/lib/transport/connectivity_state.h +2 -2
- data/src/core/lib/transport/metadata.cc +8 -10
- data/src/core/lib/transport/metadata.h +5 -8
- data/src/core/lib/transport/metadata_batch.cc +6 -0
- data/src/core/lib/transport/static_metadata.cc +2 -4
- data/src/core/lib/transport/status_metadata.cc +7 -0
- data/src/core/lib/transport/status_metadata.h +18 -0
- data/src/core/lib/transport/transport.cc +9 -7
- data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +292 -43
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +197 -46
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +4 -2
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +5 -0
- data/src/core/tsi/ssl/session_cache/ssl_session.h +1 -1
- data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +1 -1
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +4 -4
- data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +1 -1
- data/src/core/tsi/ssl_transport_security.cc +2 -1
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +0 -4
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +0 -6
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/upb/upb/decode.c +1 -0
- metadata +40 -38
- data/src/core/ext/filters/client_channel/connector.cc +0 -41
- data/src/core/ext/filters/client_channel/proxy_mapper.cc +0 -48
- data/src/core/lib/gprpp/set.h +0 -33
@@ -69,7 +69,7 @@ using OrphanablePtr = std::unique_ptr<T, Deleter>;
|
|
69
69
|
|
70
70
|
template <typename T, typename... Args>
|
71
71
|
inline OrphanablePtr<T> MakeOrphanable(Args&&... args) {
|
72
|
-
return OrphanablePtr<T>(
|
72
|
+
return OrphanablePtr<T>(new T(std::forward<Args>(args)...));
|
73
73
|
}
|
74
74
|
|
75
75
|
// A type of Orphanable with internal ref-counting.
|
@@ -106,12 +106,12 @@ class InternallyRefCounted : public Orphanable {
|
|
106
106
|
|
107
107
|
void Unref() {
|
108
108
|
if (GPR_UNLIKELY(refs_.Unref())) {
|
109
|
-
|
109
|
+
delete this;
|
110
110
|
}
|
111
111
|
}
|
112
112
|
void Unref(const DebugLocation& location, const char* reason) {
|
113
113
|
if (GPR_UNLIKELY(refs_.Unref(location, reason))) {
|
114
|
-
|
114
|
+
delete this;
|
115
115
|
}
|
116
116
|
}
|
117
117
|
|
@@ -220,7 +220,7 @@ class RefCount {
|
|
220
220
|
|
221
221
|
// A base class for reference-counted objects.
|
222
222
|
// New objects should be created via New() and start with a refcount of 1.
|
223
|
-
// When the refcount reaches 0, the object will be deleted via
|
223
|
+
// When the refcount reaches 0, the object will be deleted via delete .
|
224
224
|
//
|
225
225
|
// This will commonly be used by CRTP (curiously-recurring template pattern)
|
226
226
|
// e.g., class MyClass : public RefCounted<MyClass>
|
@@ -267,12 +267,12 @@ class RefCounted : public Impl {
|
|
267
267
|
// friend of this class.
|
268
268
|
void Unref() {
|
269
269
|
if (GPR_UNLIKELY(refs_.Unref())) {
|
270
|
-
|
270
|
+
delete static_cast<Child*>(this);
|
271
271
|
}
|
272
272
|
}
|
273
273
|
void Unref(const DebugLocation& location, const char* reason) {
|
274
274
|
if (GPR_UNLIKELY(refs_.Unref(location, reason))) {
|
275
|
-
|
275
|
+
delete static_cast<Child*>(this);
|
276
276
|
}
|
277
277
|
}
|
278
278
|
|
@@ -179,7 +179,7 @@ class RefCountedPtr {
|
|
179
179
|
|
180
180
|
template <typename T, typename... Args>
|
181
181
|
inline RefCountedPtr<T> MakeRefCounted(Args&&... args) {
|
182
|
-
return RefCountedPtr<T>(
|
182
|
+
return RefCountedPtr<T>(new T(std::forward<Args>(args)...));
|
183
183
|
}
|
184
184
|
|
185
185
|
} // namespace grpc_core
|
@@ -28,13 +28,24 @@
|
|
28
28
|
#include <cstdint>
|
29
29
|
#include <cstring>
|
30
30
|
#include <limits>
|
31
|
+
#include <string>
|
31
32
|
|
32
33
|
#include "src/core/lib/gpr/string.h"
|
33
34
|
#include "src/core/lib/gpr/useful.h"
|
34
35
|
#include "src/core/lib/gprpp/memory.h"
|
35
36
|
|
37
|
+
#if GRPC_USE_ABSL
|
38
|
+
#include "absl/strings/string_view.h"
|
39
|
+
#endif
|
40
|
+
|
36
41
|
namespace grpc_core {
|
37
42
|
|
43
|
+
#if GRPC_USE_ABSL
|
44
|
+
|
45
|
+
using StringView = absl::string_view;
|
46
|
+
|
47
|
+
#else
|
48
|
+
|
38
49
|
// Provides a light-weight view over a char array or a slice, similar but not
|
39
50
|
// identical to absl::string_view.
|
40
51
|
//
|
@@ -62,10 +73,6 @@ class StringView final {
|
|
62
73
|
constexpr StringView(const char* ptr, size_t size) : ptr_(ptr), size_(size) {}
|
63
74
|
constexpr StringView(const char* ptr)
|
64
75
|
: StringView(ptr, ptr == nullptr ? 0 : strlen(ptr)) {}
|
65
|
-
// Not part of absl::string_view API.
|
66
|
-
StringView(const grpc_slice& slice)
|
67
|
-
: StringView(reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(slice)),
|
68
|
-
GRPC_SLICE_LENGTH(slice)) {}
|
69
76
|
constexpr StringView() : StringView(nullptr, 0) {}
|
70
77
|
|
71
78
|
constexpr const char* data() const { return ptr_; }
|
@@ -105,25 +112,13 @@ class StringView final {
|
|
105
112
|
size_ = 0;
|
106
113
|
}
|
107
114
|
|
108
|
-
//
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
char
|
114
|
-
|
115
|
-
str[size_] = '\0';
|
116
|
-
return grpc_core::UniquePtr<char>(str);
|
117
|
-
}
|
118
|
-
|
119
|
-
// Not part of absl::string_view API.
|
120
|
-
int cmp(StringView other) const {
|
121
|
-
const size_t len = GPR_MIN(size(), other.size());
|
122
|
-
const int ret = strncmp(data(), other.data(), len);
|
123
|
-
if (ret != 0) return ret;
|
124
|
-
if (size() == other.size()) return 0;
|
125
|
-
if (size() < other.size()) return -1;
|
126
|
-
return 1;
|
115
|
+
// Converts to `std::basic_string`.
|
116
|
+
template <typename Allocator>
|
117
|
+
explicit operator std::basic_string<char, std::char_traits<char>, Allocator>()
|
118
|
+
const {
|
119
|
+
if (data() == nullptr) return {};
|
120
|
+
return std::basic_string<char, std::char_traits<char>, Allocator>(data(),
|
121
|
+
size());
|
127
122
|
}
|
128
123
|
|
129
124
|
private:
|
@@ -138,6 +133,33 @@ inline bool operator==(StringView lhs, StringView rhs) {
|
|
138
133
|
|
139
134
|
inline bool operator!=(StringView lhs, StringView rhs) { return !(lhs == rhs); }
|
140
135
|
|
136
|
+
#endif // GRPC_USE_ABSL
|
137
|
+
|
138
|
+
// Converts grpc_slice to StringView.
|
139
|
+
inline StringView StringViewFromSlice(const grpc_slice& slice) {
|
140
|
+
return StringView(reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(slice)),
|
141
|
+
GRPC_SLICE_LENGTH(slice));
|
142
|
+
}
|
143
|
+
|
144
|
+
// Creates a dup of the string viewed by this class.
|
145
|
+
// Return value is null-terminated and never nullptr.
|
146
|
+
inline grpc_core::UniquePtr<char> StringViewToCString(const StringView sv) {
|
147
|
+
char* str = static_cast<char*>(gpr_malloc(sv.size() + 1));
|
148
|
+
if (sv.size() > 0) memcpy(str, sv.data(), sv.size());
|
149
|
+
str[sv.size()] = '\0';
|
150
|
+
return grpc_core::UniquePtr<char>(str);
|
151
|
+
}
|
152
|
+
|
153
|
+
// Compares lhs and rhs.
|
154
|
+
inline int StringViewCmp(const StringView lhs, const StringView rhs) {
|
155
|
+
const size_t len = GPR_MIN(lhs.size(), rhs.size());
|
156
|
+
const int ret = strncmp(lhs.data(), rhs.data(), len);
|
157
|
+
if (ret != 0) return ret;
|
158
|
+
if (lhs.size() == rhs.size()) return 0;
|
159
|
+
if (lhs.size() < rhs.size()) return -1;
|
160
|
+
return 1;
|
161
|
+
}
|
162
|
+
|
141
163
|
} // namespace grpc_core
|
142
164
|
|
143
165
|
#endif /* GRPC_CORE_LIB_GPRPP_STRING_VIEW_H */
|
data/src/core/lib/gprpp/thd.h
CHANGED
@@ -59,8 +59,9 @@ size_t RoundUpToPageSize(size_t size) {
|
|
59
59
|
// Returns the minimum valid stack size that can be passed to
|
60
60
|
// pthread_attr_setstacksize.
|
61
61
|
size_t MinValidStackSize(size_t request_size) {
|
62
|
-
|
63
|
-
|
62
|
+
size_t min_stacksize = sysconf(_SC_THREAD_STACK_MIN);
|
63
|
+
if (request_size < min_stacksize) {
|
64
|
+
request_size = min_stacksize;
|
64
65
|
}
|
65
66
|
|
66
67
|
// On some systems, pthread_attr_setstacksize() can fail if stacksize is
|
@@ -133,7 +134,7 @@ class ThreadInternalsPosix : public internal::ThreadInternalsInterface {
|
|
133
134
|
gpr_mu_unlock(&arg.thread->mu_);
|
134
135
|
|
135
136
|
if (!arg.joinable) {
|
136
|
-
|
137
|
+
delete arg.thread;
|
137
138
|
}
|
138
139
|
|
139
140
|
(*arg.body)(arg.arg);
|
@@ -182,12 +183,12 @@ Thread::Thread(const char* thd_name, void (*thd_body)(void* arg), void* arg,
|
|
182
183
|
bool* success, const Options& options)
|
183
184
|
: options_(options) {
|
184
185
|
bool outcome = false;
|
185
|
-
impl_ =
|
186
|
+
impl_ = new ThreadInternalsPosix(thd_name, thd_body, arg, &outcome, options);
|
186
187
|
if (outcome) {
|
187
188
|
state_ = ALIVE;
|
188
189
|
} else {
|
189
190
|
state_ = FAILED;
|
190
|
-
|
191
|
+
delete impl_;
|
191
192
|
impl_ = nullptr;
|
192
193
|
}
|
193
194
|
|
@@ -121,7 +121,7 @@ class ThreadInternalsWindows
|
|
121
121
|
}
|
122
122
|
gpr_mu_unlock(&g_thd_info->thread->mu_);
|
123
123
|
if (!g_thd_info->joinable) {
|
124
|
-
|
124
|
+
delete g_thd_info->thread;
|
125
125
|
g_thd_info->thread = nullptr;
|
126
126
|
}
|
127
127
|
g_thd_info->body(g_thd_info->arg);
|
@@ -155,12 +155,12 @@ Thread::Thread(const char* thd_name, void (*thd_body)(void* arg), void* arg,
|
|
155
155
|
bool* success, const Options& options)
|
156
156
|
: options_(options) {
|
157
157
|
bool outcome = false;
|
158
|
-
impl_ =
|
158
|
+
impl_ = new ThreadInternalsWindows(thd_body, arg, &outcome, options);
|
159
159
|
if (outcome) {
|
160
160
|
state_ = ALIVE;
|
161
161
|
} else {
|
162
162
|
state_ = FAILED;
|
163
|
-
|
163
|
+
delete impl_;
|
164
164
|
impl_ = nullptr;
|
165
165
|
}
|
166
166
|
|
@@ -88,7 +88,7 @@ static void next_address(internal_request* req, grpc_error* due_to_error);
|
|
88
88
|
static void finish(internal_request* req, grpc_error* error) {
|
89
89
|
grpc_polling_entity_del_from_pollset_set(req->pollent,
|
90
90
|
req->context->pollset_set);
|
91
|
-
|
91
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, req->on_done, error);
|
92
92
|
grpc_http_parser_destroy(&req->parser);
|
93
93
|
if (req->addresses != nullptr) {
|
94
94
|
grpc_resolved_addresses_destroy(req->addresses);
|
@@ -100,7 +100,7 @@ class grpc_httpcli_ssl_channel_security_connector final
|
|
100
100
|
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
|
101
101
|
gpr_free(msg);
|
102
102
|
}
|
103
|
-
|
103
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, on_peer_checked, error);
|
104
104
|
tsi_peer_destruct(&peer);
|
105
105
|
}
|
106
106
|
|
@@ -174,13 +174,13 @@ static void on_handshake_done(void* arg, grpc_error* error) {
|
|
174
174
|
gpr_free(args->read_buffer);
|
175
175
|
c->func(c->arg, args->endpoint);
|
176
176
|
}
|
177
|
-
|
177
|
+
delete c;
|
178
178
|
}
|
179
179
|
|
180
180
|
static void ssl_handshake(void* arg, grpc_endpoint* tcp, const char* host,
|
181
181
|
grpc_millis deadline,
|
182
182
|
void (*on_done)(void* arg, grpc_endpoint* endpoint)) {
|
183
|
-
auto* c =
|
183
|
+
auto* c = new on_done_closure();
|
184
184
|
const char* pem_root_certs =
|
185
185
|
grpc_core::DefaultSslRootStore::GetPemRootCerts();
|
186
186
|
const tsi_ssl_root_certs_store* root_store =
|
@@ -197,7 +197,7 @@ static int get_socket_tcp_info(grpc_core::tcp_info* info, int fd) {
|
|
197
197
|
void TracedBuffer::AddNewEntry(TracedBuffer** head, uint32_t seq_no, int fd,
|
198
198
|
void* arg) {
|
199
199
|
GPR_DEBUG_ASSERT(head != nullptr);
|
200
|
-
TracedBuffer* new_elem =
|
200
|
+
TracedBuffer* new_elem = new TracedBuffer(seq_no, arg);
|
201
201
|
/* Store the current time as the sendmsg time. */
|
202
202
|
new_elem->ts_.sendmsg_time.time = gpr_now(GPR_CLOCK_REALTIME);
|
203
203
|
new_elem->ts_.scheduled_time.time = gpr_inf_past(GPR_CLOCK_REALTIME);
|
@@ -254,7 +254,7 @@ void TracedBuffer::ProcessTimestamp(TracedBuffer** head,
|
|
254
254
|
* restriction on the lifetime. */
|
255
255
|
timestamps_callback(elem->arg_, &(elem->ts_), GRPC_ERROR_NONE);
|
256
256
|
next = elem->next_;
|
257
|
-
|
257
|
+
delete static_cast<TracedBuffer*>(elem);
|
258
258
|
*head = elem = next;
|
259
259
|
break;
|
260
260
|
default:
|
@@ -273,7 +273,7 @@ void TracedBuffer::Shutdown(TracedBuffer** head, void* remaining,
|
|
273
273
|
while (elem != nullptr) {
|
274
274
|
timestamps_callback(elem->arg_, &(elem->ts_), shutdown_err);
|
275
275
|
auto* next = elem->next_;
|
276
|
-
|
276
|
+
delete elem;
|
277
277
|
elem = next;
|
278
278
|
}
|
279
279
|
*head = nullptr;
|
@@ -293,8 +293,13 @@ void grpc_tcp_set_write_timestamps_callback(void (*fn)(void*,
|
|
293
293
|
#else /* GRPC_LINUX_ERRQUEUE */
|
294
294
|
|
295
295
|
namespace grpc_core {
|
296
|
-
void grpc_tcp_set_write_timestamps_callback(
|
297
|
-
|
296
|
+
void grpc_tcp_set_write_timestamps_callback(void (*fn)(void*,
|
297
|
+
grpc_core::Timestamps*,
|
298
|
+
grpc_error* error)) {
|
299
|
+
// Cast value of fn to void to avoid unused parameter warning.
|
300
|
+
// Can't comment out the name because some compilers and formatters don't
|
301
|
+
// like the sequence */* , which would arise from */*fn*/.
|
302
|
+
(void)fn;
|
298
303
|
gpr_log(GPR_DEBUG, "Timestamps callback is not enabled for this platform");
|
299
304
|
}
|
300
305
|
} /* namespace grpc_core */
|
@@ -80,7 +80,8 @@ void CallCombiner::TsanClosure(void* arg, grpc_error* error) {
|
|
80
80
|
} else {
|
81
81
|
lock.reset();
|
82
82
|
}
|
83
|
-
|
83
|
+
grpc_core::Closure::Run(DEBUG_LOCATION, self->original_closure_,
|
84
|
+
GRPC_ERROR_REF(error));
|
84
85
|
if (lock != nullptr) {
|
85
86
|
TSAN_ANNOTATE_RWLOCK_RELEASED(&lock->taken, true);
|
86
87
|
bool prev = true;
|
@@ -92,9 +93,9 @@ void CallCombiner::TsanClosure(void* arg, grpc_error* error) {
|
|
92
93
|
void CallCombiner::ScheduleClosure(grpc_closure* closure, grpc_error* error) {
|
93
94
|
#ifdef GRPC_TSAN_ENABLED
|
94
95
|
original_closure_ = closure;
|
95
|
-
|
96
|
+
ExecCtx::Run(DEBUG_LOCATION, &tsan_closure_, error);
|
96
97
|
#else
|
97
|
-
|
98
|
+
ExecCtx::Run(DEBUG_LOCATION, closure, error);
|
98
99
|
#endif
|
99
100
|
}
|
100
101
|
|
@@ -199,7 +200,7 @@ void CallCombiner::SetNotifyOnCancel(grpc_closure* closure) {
|
|
199
200
|
"for pre-existing cancellation",
|
200
201
|
this, closure);
|
201
202
|
}
|
202
|
-
|
203
|
+
ExecCtx::Run(DEBUG_LOCATION, closure, GRPC_ERROR_REF(original_error));
|
203
204
|
break;
|
204
205
|
} else {
|
205
206
|
if (gpr_atm_full_cas(&cancel_state_, original_state, (gpr_atm)closure)) {
|
@@ -217,7 +218,7 @@ void CallCombiner::SetNotifyOnCancel(grpc_closure* closure) {
|
|
217
218
|
"call_combiner=%p: scheduling old cancel callback=%p", this,
|
218
219
|
closure);
|
219
220
|
}
|
220
|
-
|
221
|
+
ExecCtx::Run(DEBUG_LOCATION, closure, GRPC_ERROR_NONE);
|
221
222
|
}
|
222
223
|
break;
|
223
224
|
}
|
@@ -244,7 +245,7 @@ void CallCombiner::Cancel(grpc_error* error) {
|
|
244
245
|
"call_combiner=%p: scheduling notify_on_cancel callback=%p",
|
245
246
|
this, notify_on_cancel);
|
246
247
|
}
|
247
|
-
|
248
|
+
ExecCtx::Run(DEBUG_LOCATION, notify_on_cancel, GRPC_ERROR_REF(error));
|
248
249
|
}
|
249
250
|
break;
|
250
251
|
}
|
@@ -31,6 +31,7 @@
|
|
31
31
|
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
32
32
|
#include "src/core/lib/iomgr/closure.h"
|
33
33
|
#include "src/core/lib/iomgr/dynamic_annotations.h"
|
34
|
+
#include "src/core/lib/iomgr/exec_ctx.h"
|
34
35
|
|
35
36
|
// A simple, lock-free mechanism for serializing activity related to a
|
36
37
|
// single call. This is similar to a combiner but is more lightweight.
|
@@ -156,8 +157,8 @@ class CallCombinerClosureList {
|
|
156
157
|
//
|
157
158
|
// All but one of the closures in the list will be scheduled via
|
158
159
|
// GRPC_CALL_COMBINER_START(), and the remaining closure will be
|
159
|
-
// scheduled via
|
160
|
-
// yielding the call combiner. If the list is empty, then the call
|
160
|
+
// scheduled via ExecCtx::Run(), which will eventually result
|
161
|
+
// in yielding the call combiner. If the list is empty, then the call
|
161
162
|
// combiner will be yielded immediately.
|
162
163
|
void RunClosures(CallCombiner* call_combiner) {
|
163
164
|
if (closures_.empty()) {
|
@@ -177,7 +178,7 @@ class CallCombinerClosureList {
|
|
177
178
|
grpc_error_string(closures_[0].error), closures_[0].reason);
|
178
179
|
}
|
179
180
|
// This will release the call combiner.
|
180
|
-
|
181
|
+
ExecCtx::Run(DEBUG_LOCATION, closures_[0].closure, closures_[0].error);
|
181
182
|
closures_.clear();
|
182
183
|
}
|
183
184
|
|
@@ -53,7 +53,7 @@ void CFStreamHandle::Release(void* info) {
|
|
53
53
|
|
54
54
|
CFStreamHandle* CFStreamHandle::CreateStreamHandle(
|
55
55
|
CFReadStreamRef read_stream, CFWriteStreamRef write_stream) {
|
56
|
-
return
|
56
|
+
return new CFStreamHandle(read_stream, write_stream);
|
57
57
|
}
|
58
58
|
|
59
59
|
void CFStreamHandle::ReadCallback(CFReadStreamRef stream,
|
@@ -194,7 +194,7 @@ void CFStreamHandle::Unref(const char* file, int line, const char* reason) {
|
|
194
194
|
reason, val, val - 1);
|
195
195
|
}
|
196
196
|
if (gpr_unref(&refcount_)) {
|
197
|
-
|
197
|
+
delete this;
|
198
198
|
}
|
199
199
|
}
|
200
200
|
|
@@ -27,6 +27,7 @@
|
|
27
27
|
#include <grpc/support/alloc.h>
|
28
28
|
#include <grpc/support/log.h>
|
29
29
|
|
30
|
+
#include "src/core/lib/gprpp/debug_location.h"
|
30
31
|
#include "src/core/lib/gprpp/manual_constructor.h"
|
31
32
|
#include "src/core/lib/gprpp/mpscq.h"
|
32
33
|
#include "src/core/lib/iomgr/error.h"
|
@@ -51,21 +52,6 @@ typedef struct grpc_closure_list {
|
|
51
52
|
* the closure scheduler will do that after the cb returns */
|
52
53
|
typedef void (*grpc_iomgr_cb_func)(void* arg, grpc_error* error);
|
53
54
|
|
54
|
-
typedef struct grpc_closure_scheduler grpc_closure_scheduler;
|
55
|
-
|
56
|
-
typedef struct grpc_closure_scheduler_vtable {
|
57
|
-
/* NOTE: for all these functions, closure->scheduler == the scheduler that was
|
58
|
-
used to find this vtable */
|
59
|
-
void (*run)(grpc_closure* closure, grpc_error* error);
|
60
|
-
void (*sched)(grpc_closure* closure, grpc_error* error);
|
61
|
-
const char* name;
|
62
|
-
} grpc_closure_scheduler_vtable;
|
63
|
-
|
64
|
-
/** Abstract type that can schedule closures for execution */
|
65
|
-
struct grpc_closure_scheduler {
|
66
|
-
const grpc_closure_scheduler_vtable* vtable;
|
67
|
-
};
|
68
|
-
|
69
55
|
/** A closure over a grpc_iomgr_cb_func. */
|
70
56
|
struct grpc_closure {
|
71
57
|
/** Once queued, next indicates the next queued closure; before then, scratch
|
@@ -84,10 +70,6 @@ struct grpc_closure {
|
|
84
70
|
/** Arguments to be passed to "cb". */
|
85
71
|
void* cb_arg;
|
86
72
|
|
87
|
-
/** Scheduler to schedule against: nullptr to schedule against current
|
88
|
-
execution context */
|
89
|
-
grpc_closure_scheduler* scheduler;
|
90
|
-
|
91
73
|
/** Once queued, the result of the closure. Before then: scratch space */
|
92
74
|
union {
|
93
75
|
grpc_error* error;
|
@@ -109,16 +91,13 @@ struct grpc_closure {
|
|
109
91
|
#ifndef NDEBUG
|
110
92
|
inline grpc_closure* grpc_closure_init(const char* file, int line,
|
111
93
|
grpc_closure* closure,
|
112
|
-
grpc_iomgr_cb_func cb, void* cb_arg
|
113
|
-
grpc_closure_scheduler* scheduler) {
|
94
|
+
grpc_iomgr_cb_func cb, void* cb_arg) {
|
114
95
|
#else
|
115
96
|
inline grpc_closure* grpc_closure_init(grpc_closure* closure,
|
116
|
-
grpc_iomgr_cb_func cb, void* cb_arg
|
117
|
-
grpc_closure_scheduler* scheduler) {
|
97
|
+
grpc_iomgr_cb_func cb, void* cb_arg) {
|
118
98
|
#endif
|
119
99
|
closure->cb = cb;
|
120
100
|
closure->cb_arg = cb_arg;
|
121
|
-
closure->scheduler = scheduler;
|
122
101
|
closure->error_data.error = GRPC_ERROR_NONE;
|
123
102
|
#ifndef NDEBUG
|
124
103
|
closure->scheduled = false;
|
@@ -134,10 +113,10 @@ inline grpc_closure* grpc_closure_init(grpc_closure* closure,
|
|
134
113
|
/** Initializes \a closure with \a cb and \a cb_arg. Returns \a closure. */
|
135
114
|
#ifndef NDEBUG
|
136
115
|
#define GRPC_CLOSURE_INIT(closure, cb, cb_arg, scheduler) \
|
137
|
-
grpc_closure_init(__FILE__, __LINE__, closure, cb, cb_arg
|
116
|
+
grpc_closure_init(__FILE__, __LINE__, closure, cb, cb_arg)
|
138
117
|
#else
|
139
118
|
#define GRPC_CLOSURE_INIT(closure, cb, cb_arg, scheduler) \
|
140
|
-
grpc_closure_init(closure, cb, cb_arg
|
119
|
+
grpc_closure_init(closure, cb, cb_arg)
|
141
120
|
#endif
|
142
121
|
|
143
122
|
namespace closure_impl {
|
@@ -160,21 +139,19 @@ inline void closure_wrapper(void* arg, grpc_error* error) {
|
|
160
139
|
|
161
140
|
#ifndef NDEBUG
|
162
141
|
inline grpc_closure* grpc_closure_create(const char* file, int line,
|
163
|
-
grpc_iomgr_cb_func cb, void* cb_arg
|
164
|
-
grpc_closure_scheduler* scheduler) {
|
142
|
+
grpc_iomgr_cb_func cb, void* cb_arg) {
|
165
143
|
#else
|
166
|
-
inline grpc_closure* grpc_closure_create(grpc_iomgr_cb_func cb, void* cb_arg
|
167
|
-
grpc_closure_scheduler* scheduler) {
|
144
|
+
inline grpc_closure* grpc_closure_create(grpc_iomgr_cb_func cb, void* cb_arg) {
|
168
145
|
#endif
|
169
146
|
closure_impl::wrapped_closure* wc =
|
170
147
|
static_cast<closure_impl::wrapped_closure*>(gpr_malloc(sizeof(*wc)));
|
171
148
|
wc->cb = cb;
|
172
149
|
wc->cb_arg = cb_arg;
|
173
150
|
#ifndef NDEBUG
|
174
|
-
grpc_closure_init(file, line, &wc->wrapper, closure_impl::closure_wrapper,
|
175
|
-
|
151
|
+
grpc_closure_init(file, line, &wc->wrapper, closure_impl::closure_wrapper,
|
152
|
+
wc);
|
176
153
|
#else
|
177
|
-
grpc_closure_init(&wc->wrapper, closure_impl::closure_wrapper, wc
|
154
|
+
grpc_closure_init(&wc->wrapper, closure_impl::closure_wrapper, wc);
|
178
155
|
#endif
|
179
156
|
return &wc->wrapper;
|
180
157
|
}
|
@@ -182,10 +159,10 @@ inline grpc_closure* grpc_closure_create(grpc_iomgr_cb_func cb, void* cb_arg,
|
|
182
159
|
/* Create a heap allocated closure: try to avoid except for very rare events */
|
183
160
|
#ifndef NDEBUG
|
184
161
|
#define GRPC_CLOSURE_CREATE(cb, cb_arg, scheduler) \
|
185
|
-
grpc_closure_create(__FILE__, __LINE__, cb, cb_arg
|
162
|
+
grpc_closure_create(__FILE__, __LINE__, cb, cb_arg)
|
186
163
|
#else
|
187
164
|
#define GRPC_CLOSURE_CREATE(cb, cb_arg, scheduler) \
|
188
|
-
grpc_closure_create(cb, cb_arg
|
165
|
+
grpc_closure_create(cb, cb_arg)
|
189
166
|
#endif
|
190
167
|
|
191
168
|
#define GRPC_CLOSURE_LIST_INIT \
|
@@ -247,112 +224,33 @@ inline bool grpc_closure_list_empty(grpc_closure_list closure_list) {
|
|
247
224
|
return closure_list.head == nullptr;
|
248
225
|
}
|
249
226
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
c->file_initiated = file;
|
260
|
-
c->line_initiated = line;
|
261
|
-
c->run = true;
|
262
|
-
GPR_ASSERT(c->cb != nullptr);
|
263
|
-
#endif
|
264
|
-
c->scheduler->vtable->run(c, error);
|
265
|
-
} else {
|
266
|
-
GRPC_ERROR_UNREF(error);
|
267
|
-
}
|
268
|
-
}
|
269
|
-
|
270
|
-
/** Run a closure directly. Caller ensures that no locks are being held above.
|
271
|
-
* Note that calling this at the end of a closure callback function itself is
|
272
|
-
* by definition safe. */
|
273
|
-
#ifndef NDEBUG
|
274
|
-
#define GRPC_CLOSURE_RUN(closure, error) \
|
275
|
-
grpc_closure_run(__FILE__, __LINE__, closure, error)
|
276
|
-
#else
|
277
|
-
#define GRPC_CLOSURE_RUN(closure, error) grpc_closure_run(closure, error)
|
278
|
-
#endif
|
279
|
-
|
280
|
-
#ifndef NDEBUG
|
281
|
-
inline void grpc_closure_sched(const char* file, int line, grpc_closure* c,
|
282
|
-
grpc_error* error) {
|
283
|
-
#else
|
284
|
-
inline void grpc_closure_sched(grpc_closure* c, grpc_error* error) {
|
285
|
-
#endif
|
286
|
-
GPR_TIMER_SCOPE("grpc_closure_sched", 0);
|
287
|
-
if (c != nullptr) {
|
288
|
-
#ifndef NDEBUG
|
289
|
-
if (c->scheduled) {
|
290
|
-
gpr_log(GPR_ERROR,
|
291
|
-
"Closure already scheduled. (closure: %p, created: [%s:%d], "
|
292
|
-
"previously scheduled at: [%s: %d], newly scheduled at [%s: %d], "
|
293
|
-
"run?: %s",
|
294
|
-
c, c->file_created, c->line_created, c->file_initiated,
|
295
|
-
c->line_initiated, file, line, c->run ? "true" : "false");
|
296
|
-
abort();
|
227
|
+
namespace grpc_core {
|
228
|
+
class Closure {
|
229
|
+
public:
|
230
|
+
static void Run(const DebugLocation& location, grpc_closure* closure,
|
231
|
+
grpc_error* error) {
|
232
|
+
(void)location;
|
233
|
+
if (closure == nullptr) {
|
234
|
+
GRPC_ERROR_UNREF(error);
|
235
|
+
return;
|
297
236
|
}
|
298
|
-
c->scheduled = true;
|
299
|
-
c->file_initiated = file;
|
300
|
-
c->line_initiated = line;
|
301
|
-
c->run = false;
|
302
|
-
GPR_ASSERT(c->cb != nullptr);
|
303
|
-
#endif
|
304
|
-
c->scheduler->vtable->sched(c, error);
|
305
|
-
} else {
|
306
|
-
GRPC_ERROR_UNREF(error);
|
307
|
-
}
|
308
|
-
}
|
309
|
-
|
310
|
-
/** Schedule a closure to be run. Does not need to be run from a safe point. */
|
311
237
|
#ifndef NDEBUG
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
#ifndef NDEBUG
|
319
|
-
inline void grpc_closure_list_sched(const char* file, int line,
|
320
|
-
grpc_closure_list* list) {
|
321
|
-
#else
|
322
|
-
inline void grpc_closure_list_sched(grpc_closure_list* list) {
|
238
|
+
if (grpc_trace_closure.enabled()) {
|
239
|
+
gpr_log(GPR_DEBUG, "running closure %p: created [%s:%d]: run [%s:%d]",
|
240
|
+
closure, closure->file_created, closure->line_created,
|
241
|
+
location.file(), location.line());
|
242
|
+
}
|
243
|
+
GPR_ASSERT(closure->cb != nullptr);
|
323
244
|
#endif
|
324
|
-
|
325
|
-
while (c != nullptr) {
|
326
|
-
grpc_closure* next = c->next_data.next;
|
245
|
+
closure->cb(closure->cb_arg, error);
|
327
246
|
#ifndef NDEBUG
|
328
|
-
if (
|
329
|
-
gpr_log(
|
330
|
-
"Closure already scheduled. (closure: %p, created: [%s:%d], "
|
331
|
-
"previously scheduled at: [%s: %d] run?: %s",
|
332
|
-
c, c->file_created, c->line_created, c->file_initiated,
|
333
|
-
c->line_initiated, c->run ? "true" : "false");
|
334
|
-
abort();
|
247
|
+
if (grpc_trace_closure.enabled()) {
|
248
|
+
gpr_log(GPR_DEBUG, "closure %p finished", closure);
|
335
249
|
}
|
336
|
-
c->scheduled = true;
|
337
|
-
c->file_initiated = file;
|
338
|
-
c->line_initiated = line;
|
339
|
-
c->run = false;
|
340
|
-
GPR_ASSERT(c->cb != nullptr);
|
341
250
|
#endif
|
342
|
-
|
343
|
-
c = next;
|
251
|
+
GRPC_ERROR_UNREF(error);
|
344
252
|
}
|
345
|
-
|
346
|
-
}
|
347
|
-
|
348
|
-
/** Schedule all closures in a list to be run. Does not need to be run from a
|
349
|
-
* safe point. */
|
350
|
-
#ifndef NDEBUG
|
351
|
-
#define GRPC_CLOSURE_LIST_SCHED(closure_list) \
|
352
|
-
grpc_closure_list_sched(__FILE__, __LINE__, closure_list)
|
353
|
-
#else
|
354
|
-
#define GRPC_CLOSURE_LIST_SCHED(closure_list) \
|
355
|
-
grpc_closure_list_sched(closure_list)
|
356
|
-
#endif
|
253
|
+
};
|
254
|
+
} // namespace grpc_core
|
357
255
|
|
358
256
|
#endif /* GRPC_CORE_LIB_IOMGR_CLOSURE_H */
|