grpc 1.7.3 → 1.8.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 +2106 -2116
- data/include/grpc/census.h +1 -432
- data/include/grpc/compression.h +9 -9
- data/include/grpc/grpc.h +115 -98
- data/include/grpc/grpc_cronet.h +3 -3
- data/include/grpc/grpc_posix.h +4 -4
- data/include/grpc/grpc_security.h +160 -88
- data/include/grpc/grpc_security_constants.h +7 -0
- data/include/grpc/impl/codegen/atm.h +9 -1
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +13 -4
- data/include/grpc/impl/codegen/atm_gcc_sync.h +6 -5
- data/include/grpc/impl/codegen/atm_windows.h +23 -22
- data/include/grpc/impl/codegen/byte_buffer.h +14 -14
- data/include/grpc/impl/codegen/byte_buffer_reader.h +2 -2
- data/include/grpc/impl/codegen/connectivity_state.h +0 -2
- data/include/grpc/impl/codegen/grpc_types.h +32 -28
- data/include/grpc/impl/codegen/port_platform.h +48 -0
- data/include/grpc/impl/codegen/slice.h +10 -10
- data/include/grpc/impl/codegen/sync_generic.h +9 -3
- data/include/grpc/slice.h +16 -17
- data/include/grpc/slice_buffer.h +22 -22
- data/include/grpc/support/alloc.h +11 -11
- data/include/grpc/support/avl.h +28 -20
- data/include/grpc/support/cmdline.h +13 -13
- data/include/grpc/support/histogram.h +17 -17
- data/include/grpc/support/host_port.h +2 -2
- data/include/grpc/support/log.h +9 -9
- data/include/grpc/support/log_windows.h +1 -1
- data/include/grpc/support/string_util.h +2 -2
- data/include/grpc/support/subprocess.h +5 -5
- data/include/grpc/support/sync.h +43 -27
- data/include/grpc/support/thd.h +6 -6
- data/include/grpc/support/tls_gcc.h +1 -1
- data/include/grpc/support/tls_pthread.h +1 -1
- data/src/core/ext/census/{grpc_context.c → grpc_context.cc} +5 -8
- data/src/core/ext/filters/client_channel/backup_poller.cc +165 -0
- data/src/core/ext/{census/grpc_filter.h → filters/client_channel/backup_poller.h} +12 -7
- data/src/core/ext/filters/client_channel/{channel_connectivity.c → channel_connectivity.cc} +45 -42
- data/src/core/ext/filters/client_channel/{client_channel.c → client_channel.cc} +452 -417
- data/src/core/ext/filters/client_channel/client_channel.h +16 -8
- data/src/core/ext/filters/client_channel/{client_channel_factory.c → client_channel_factory.cc} +0 -0
- data/src/core/ext/filters/client_channel/client_channel_factory.h +29 -21
- data/src/core/ext/filters/client_channel/{client_channel_plugin.c → client_channel_plugin.cc} +15 -19
- data/src/core/ext/filters/client_channel/{connector.c → connector.cc} +0 -0
- data/src/core/ext/filters/client_channel/connector.h +29 -21
- data/src/core/ext/filters/client_channel/{http_connect_handshaker.c → http_connect_handshaker.cc} +10 -10
- data/src/core/ext/filters/client_channel/http_connect_handshaker.h +8 -0
- data/src/core/ext/filters/client_channel/{http_proxy.c → http_proxy.cc} +14 -14
- data/src/core/ext/filters/client_channel/http_proxy.h +8 -0
- data/src/core/ext/filters/client_channel/{lb_policy.c → lb_policy.cc} +47 -48
- data/src/core/ext/filters/client_channel/lb_policy.h +76 -70
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{client_load_reporting_filter.c → client_load_reporting_filter.cc} +28 -29
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +9 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{grpclb.c → grpclb.cc} +554 -563
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +9 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +17 -9
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{grpclb_channel_secure.c → grpclb_channel_secure.cc} +17 -17
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{grpclb_client_stats.c → grpclb_client_stats.cc} +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +9 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{load_balancer_api.c → load_balancer_api.cc} +64 -67
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +20 -21
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +599 -0
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +695 -0
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc +270 -0
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +153 -0
- data/src/core/ext/filters/client_channel/{lb_policy_factory.c → lb_policy_factory.cc} +10 -10
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +48 -40
- data/src/core/ext/filters/client_channel/{lb_policy_registry.c → lb_policy_registry.cc} +9 -9
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +11 -3
- data/src/core/ext/filters/client_channel/{parse_address.c → parse_address.cc} +24 -24
- data/src/core/ext/filters/client_channel/parse_address.h +14 -6
- data/src/core/ext/filters/client_channel/{proxy_mapper.c → proxy_mapper.cc} +0 -0
- data/src/core/ext/filters/client_channel/proxy_mapper.h +8 -0
- data/src/core/ext/filters/client_channel/{proxy_mapper_registry.c → proxy_mapper_registry.cc} +0 -0
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +8 -0
- data/src/core/ext/filters/client_channel/{resolver.c → resolver.cc} +21 -23
- data/src/core/ext/filters/client_channel/resolver.h +33 -27
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/{dns_resolver_ares.c → dns_resolver_ares.cc} +133 -133
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +18 -9
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/{grpc_ares_ev_driver_posix.c → grpc_ares_ev_driver_posix.cc} +58 -56
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/{grpc_ares_wrapper.c → grpc_ares_wrapper.cc} +118 -115
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +23 -15
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +60 -0
- data/src/core/ext/filters/client_channel/resolver/dns/native/{dns_resolver.c → dns_resolver.cc} +100 -94
- data/src/core/ext/filters/client_channel/resolver/fake/{fake_resolver.c → fake_resolver.cc} +14 -14
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +9 -1
- data/src/core/ext/filters/client_channel/resolver/sockaddr/{sockaddr_resolver.c → sockaddr_resolver.cc} +60 -60
- data/src/core/ext/filters/client_channel/{resolver_factory.c → resolver_factory.cc} +2 -2
- data/src/core/ext/filters/client_channel/resolver_factory.h +27 -19
- data/src/core/ext/filters/client_channel/{resolver_registry.c → resolver_registry.cc} +35 -35
- data/src/core/ext/filters/client_channel/resolver_registry.h +18 -10
- data/src/core/ext/filters/client_channel/{retry_throttle.c → retry_throttle.cc} +10 -10
- data/src/core/ext/filters/client_channel/retry_throttle.h +8 -0
- data/src/core/ext/filters/client_channel/{subchannel.c → subchannel.cc} +210 -213
- data/src/core/ext/filters/client_channel/subchannel.h +68 -60
- data/src/core/ext/filters/client_channel/{subchannel_index.c → subchannel_index.cc} +52 -52
- data/src/core/ext/filters/client_channel/subchannel_index.h +22 -14
- data/src/core/ext/filters/client_channel/{uri_parser.c → uri_parser.cc} +29 -27
- data/src/core/ext/filters/client_channel/uri_parser.h +18 -10
- data/src/core/ext/filters/deadline/{deadline_filter.c → deadline_filter.cc} +12 -15
- data/src/core/ext/filters/deadline/deadline_filter.h +11 -2
- data/src/core/ext/filters/http/client/{http_client_filter.c → http_client_filter.cc} +83 -83
- data/src/core/ext/filters/http/client/http_client_filter.h +8 -0
- data/src/core/ext/filters/http/{http_filters_plugin.c → http_filters_plugin.cc} +20 -21
- data/src/core/ext/filters/http/message_compress/{message_compress_filter.c → message_compress_filter.cc} +84 -83
- data/src/core/ext/filters/http/message_compress/message_compress_filter.h +9 -1
- data/src/core/ext/filters/http/server/{http_server_filter.c → http_server_filter.cc} +80 -78
- data/src/core/ext/filters/http/server/http_server_filter.h +8 -0
- data/src/core/ext/filters/load_reporting/{server_load_reporting_filter.c → server_load_reporting_filter.cc} +29 -29
- data/src/core/ext/filters/load_reporting/server_load_reporting_filter.h +9 -1
- data/src/core/ext/filters/load_reporting/{server_load_reporting_plugin.c → server_load_reporting_plugin.cc} +11 -11
- data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h +13 -5
- data/src/core/ext/filters/max_age/{max_age_filter.c → max_age_filter.cc} +46 -56
- data/src/core/ext/filters/max_age/max_age_filter.h +8 -0
- data/src/core/ext/filters/message_size/{message_size_filter.c → message_size_filter.cc} +62 -40
- data/src/core/ext/filters/message_size/message_size_filter.h +8 -0
- data/src/core/ext/filters/workarounds/{workaround_cronet_compression_filter.c → workaround_cronet_compression_filter.cc} +11 -11
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +8 -0
- data/src/core/ext/filters/workarounds/{workaround_utils.c → workaround_utils.cc} +7 -7
- data/src/core/ext/filters/workarounds/workaround_utils.h +9 -1
- data/src/core/ext/transport/chttp2/alpn/{alpn.c → alpn.cc} +3 -3
- data/src/core/ext/transport/chttp2/alpn/alpn.h +10 -2
- data/src/core/ext/transport/chttp2/client/{chttp2_connector.c → chttp2_connector.cc} +49 -45
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +8 -0
- data/src/core/ext/transport/chttp2/client/insecure/{channel_create.c → channel_create.cc} +28 -27
- data/src/core/ext/transport/chttp2/client/insecure/{channel_create_posix.c → channel_create_posix.cc} +14 -13
- data/src/core/ext/transport/chttp2/client/secure/{secure_channel_create.c → secure_channel_create.cc} +68 -66
- data/src/core/ext/transport/chttp2/server/{chttp2_server.c → chttp2_server.cc} +76 -77
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +11 -3
- data/src/core/ext/transport/chttp2/server/insecure/{server_chttp2.c → server_chttp2.cc} +3 -3
- data/src/core/ext/transport/chttp2/server/insecure/{server_chttp2_posix.c → server_chttp2_posix.cc} +13 -12
- data/src/core/ext/transport/chttp2/server/secure/{server_secure_chttp2.c → server_secure_chttp2.cc} +12 -10
- data/src/core/ext/transport/chttp2/transport/{bin_decoder.c → bin_decoder.cc} +7 -7
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +15 -7
- data/src/core/ext/transport/chttp2/transport/{bin_encoder.c → bin_encoder.cc} +11 -11
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +8 -0
- data/src/core/ext/transport/chttp2/transport/{chttp2_plugin.c → chttp2_plugin.cc} +2 -9
- data/src/core/ext/transport/chttp2/transport/{chttp2_transport.c → chttp2_transport.cc} +778 -778
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +14 -10
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +385 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.h +337 -0
- data/src/core/ext/transport/chttp2/transport/frame.h +8 -0
- data/src/core/ext/transport/chttp2/transport/{frame_data.c → frame_data.cc} +34 -34
- data/src/core/ext/transport/chttp2/transport/frame_data.h +25 -17
- data/src/core/ext/transport/chttp2/transport/{frame_goaway.c → frame_goaway.cc} +18 -18
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +18 -10
- data/src/core/ext/transport/chttp2/transport/{frame_ping.c → frame_ping.cc} +18 -19
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +12 -4
- data/src/core/ext/transport/chttp2/transport/{frame_rst_stream.c → frame_rst_stream.cc} +16 -16
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +16 -8
- data/src/core/ext/transport/chttp2/transport/{frame_settings.c → frame_settings.cc} +23 -24
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +17 -9
- data/src/core/ext/transport/chttp2/transport/{frame_window_update.c → frame_window_update.cc} +22 -24
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +14 -6
- data/src/core/ext/transport/chttp2/transport/{hpack_encoder.c → hpack_encoder.cc} +206 -161
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +23 -13
- data/src/core/ext/transport/chttp2/transport/{hpack_parser.c → hpack_parser.cc} +340 -334
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +30 -22
- data/src/core/ext/transport/chttp2/transport/{hpack_table.c → hpack_table.cc} +25 -25
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +19 -11
- data/src/core/ext/transport/chttp2/transport/{http2_settings.c → http2_settings.cc} +1 -1
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +10 -2
- data/src/core/ext/transport/chttp2/transport/{huffsyms.c → huffsyms.cc} +0 -0
- data/src/core/ext/transport/chttp2/transport/huffsyms.h +8 -0
- data/src/core/ext/transport/chttp2/transport/{incoming_metadata.c → incoming_metadata.cc} +14 -13
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +18 -10
- data/src/core/ext/transport/chttp2/transport/internal.h +214 -340
- data/src/core/ext/transport/chttp2/transport/{parsing.c → parsing.cc} +152 -141
- data/src/core/ext/transport/chttp2/transport/{stream_lists.c → stream_lists.cc} +53 -53
- data/src/core/ext/transport/chttp2/transport/{stream_map.c → stream_map.cc} +35 -34
- data/src/core/ext/transport/chttp2/transport/stream_map.h +22 -14
- data/src/core/ext/transport/chttp2/transport/{varint.c → varint.cc} +0 -0
- data/src/core/ext/transport/chttp2/transport/varint.h +8 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +636 -0
- data/src/core/ext/transport/inproc/{inproc_plugin.c → inproc_plugin.cc} +5 -6
- data/src/core/ext/transport/inproc/{inproc_transport.c → inproc_transport.cc} +479 -544
- data/src/core/ext/transport/inproc/inproc_transport.h +4 -4
- data/src/core/lib/backoff/backoff.cc +80 -0
- data/src/core/lib/backoff/backoff.h +83 -0
- data/src/core/lib/channel/{channel_args.c → channel_args.cc} +92 -92
- data/src/core/lib/channel/channel_args.h +45 -37
- data/src/core/lib/channel/{channel_stack.c → channel_stack.cc} +67 -68
- data/src/core/lib/channel/channel_stack.h +76 -75
- data/src/core/lib/channel/{channel_stack_builder.c → channel_stack_builder.cc} +91 -91
- data/src/core/lib/channel/channel_stack_builder.h +45 -45
- data/src/core/lib/channel/{connected_channel.c → connected_channel.cc} +70 -70
- data/src/core/lib/channel/connected_channel.h +12 -4
- data/src/core/lib/channel/context.h +2 -2
- data/src/core/lib/channel/{handshaker.c → handshaker.cc} +7 -9
- data/src/core/lib/channel/handshaker.h +9 -1
- data/src/core/lib/channel/{handshaker_factory.c → handshaker_factory.cc} +7 -7
- data/src/core/lib/channel/handshaker_factory.h +18 -10
- data/src/core/lib/channel/{handshaker_registry.c → handshaker_registry.cc} +0 -0
- data/src/core/lib/channel/handshaker_registry.h +8 -0
- data/src/core/lib/compression/algorithm_metadata.h +8 -0
- data/src/core/lib/compression/{compression.c → compression.cc} +9 -9
- data/src/core/lib/compression/{message_compress.c → message_compress.cc} +0 -0
- data/src/core/lib/compression/message_compress.h +8 -0
- data/src/core/lib/compression/{stream_compression.c → stream_compression.cc} +12 -12
- data/src/core/lib/compression/stream_compression.h +27 -19
- data/src/core/lib/compression/{stream_compression_gzip.c → stream_compression_gzip.cc} +35 -36
- data/src/core/lib/compression/stream_compression_gzip.h +8 -0
- data/src/core/lib/compression/{stream_compression_identity.c → stream_compression_identity.cc} +19 -20
- data/src/core/lib/compression/stream_compression_identity.h +8 -0
- data/src/core/lib/debug/{stats.c → stats.cc} +19 -19
- data/src/core/lib/debug/stats.h +17 -9
- data/src/core/lib/debug/{stats_data.c → stats_data.cc} +45 -22
- data/src/core/lib/debug/stats_data.h +58 -19
- data/src/core/lib/debug/trace.cc +142 -0
- data/src/core/lib/debug/trace.h +74 -14
- data/src/core/lib/http/{format_request.c → format_request.cc} +10 -10
- data/src/core/lib/http/format_request.h +12 -4
- data/src/core/lib/http/{httpcli.c → httpcli.cc} +80 -80
- data/src/core/lib/http/httpcli.h +41 -33
- data/src/core/lib/http/{httpcli_security_connector.c → httpcli_security_connector.cc} +69 -55
- data/src/core/lib/http/{parser.c → parser.cc} +42 -42
- data/src/core/lib/http/parser.h +28 -20
- data/src/core/lib/{support → iomgr}/block_annotate.h +17 -8
- data/src/core/lib/iomgr/{call_combiner.c → call_combiner.cc} +29 -17
- data/src/core/lib/iomgr/call_combiner.h +9 -1
- data/src/core/lib/iomgr/closure.h +220 -62
- data/src/core/lib/iomgr/{combiner.c → combiner.cc} +63 -62
- data/src/core/lib/iomgr/combiner.h +16 -8
- data/src/core/lib/iomgr/{endpoint.c → endpoint.cc} +6 -0
- data/src/core/lib/iomgr/endpoint.h +47 -32
- data/src/core/lib/iomgr/endpoint_pair.h +12 -4
- data/src/core/lib/iomgr/{endpoint_pair_posix.c → endpoint_pair_posix.cc} +3 -3
- data/src/core/lib/iomgr/{endpoint_pair_uv.c → endpoint_pair_uv.cc} +2 -2
- data/src/core/lib/iomgr/{endpoint_pair_windows.c → endpoint_pair_windows.cc} +6 -6
- data/src/core/lib/iomgr/{error.c → error.cc} +125 -124
- data/src/core/lib/iomgr/error.h +32 -27
- data/src/core/lib/iomgr/error_internal.h +11 -2
- data/src/core/lib/iomgr/{ev_epoll1_linux.c → ev_epoll1_linux.cc} +214 -215
- data/src/core/lib/iomgr/ev_epoll1_linux.h +9 -1
- data/src/core/lib/iomgr/ev_epollex_linux.cc +1488 -0
- data/src/core/lib/iomgr/ev_epollex_linux.h +9 -1
- data/src/core/lib/iomgr/{ev_epollsig_linux.c → ev_epollsig_linux.cc} +304 -305
- data/src/core/lib/iomgr/ev_epollsig_linux.h +12 -4
- data/src/core/lib/iomgr/{ev_poll_posix.c → ev_poll_posix.cc} +272 -283
- data/src/core/lib/iomgr/ev_poll_posix.h +10 -2
- data/src/core/lib/iomgr/ev_posix.cc +288 -0
- data/src/core/lib/iomgr/ev_posix.h +75 -67
- data/src/core/lib/iomgr/{ev_windows.c → ev_windows.cc} +2 -2
- data/src/core/lib/iomgr/exec_ctx.cc +177 -0
- data/src/core/lib/iomgr/exec_ctx.h +35 -13
- data/src/core/lib/iomgr/{executor.c → executor.cc} +34 -35
- data/src/core/lib/iomgr/executor.h +12 -4
- data/src/core/lib/iomgr/{fork_posix.c → fork_posix.cc} +0 -0
- data/src/core/lib/iomgr/{fork_windows.c → fork_windows.cc} +0 -0
- data/src/core/lib/iomgr/gethostname.h +9 -1
- data/src/core/lib/iomgr/{gethostname_fallback.c → gethostname_fallback.cc} +2 -1
- data/src/core/lib/iomgr/{gethostname_host_name_max.c → gethostname_host_name_max.cc} +4 -3
- data/src/core/lib/iomgr/{gethostname_sysconf.c → gethostname_sysconf.cc} +3 -2
- data/src/core/lib/iomgr/{iocp_windows.c → iocp_windows.cc} +23 -25
- data/src/core/lib/iomgr/iocp_windows.h +17 -3
- data/src/core/lib/iomgr/{iomgr.c → iomgr.cc} +25 -19
- data/src/core/lib/iomgr/iomgr.h +11 -3
- data/src/core/lib/iomgr/iomgr_internal.h +13 -5
- data/src/core/lib/iomgr/{iomgr_posix.c → iomgr_posix.cc} +0 -1
- data/src/core/lib/iomgr/{iomgr_uv.c → iomgr_uv.cc} +1 -1
- data/src/core/lib/iomgr/iomgr_uv.h +8 -0
- data/src/core/lib/iomgr/{iomgr_windows.c → iomgr_windows.cc} +0 -0
- data/src/core/lib/iomgr/{is_epollexclusive_available.c → is_epollexclusive_available.cc} +1 -1
- data/src/core/lib/iomgr/is_epollexclusive_available.h +8 -0
- data/src/core/lib/iomgr/{load_file.c → load_file.cc} +12 -12
- data/src/core/lib/iomgr/load_file.h +2 -2
- data/src/core/lib/iomgr/{lockfree_event.c → lockfree_event.cc} +76 -68
- data/src/core/lib/iomgr/lockfree_event.h +30 -11
- data/src/core/lib/iomgr/{network_status_tracker.c → network_status_tracker.cc} +3 -2
- data/src/core/lib/iomgr/network_status_tracker.h +2 -2
- data/src/core/lib/iomgr/{polling_entity.c → polling_entity.cc} +18 -18
- data/src/core/lib/iomgr/polling_entity.h +21 -13
- data/src/core/lib/iomgr/pollset.h +17 -11
- data/src/core/lib/iomgr/pollset_set.h +23 -15
- data/src/core/lib/iomgr/{pollset_set_uv.c → pollset_set_uv.cc} +0 -0
- data/src/core/lib/iomgr/{pollset_set_windows.c → pollset_set_windows.cc} +0 -0
- data/src/core/lib/iomgr/{pollset_uv.c → pollset_uv.cc} +31 -29
- data/src/core/lib/iomgr/pollset_uv.h +8 -0
- data/src/core/lib/iomgr/{pollset_windows.c → pollset_windows.cc} +24 -24
- data/src/core/lib/iomgr/pollset_windows.h +17 -4
- data/src/core/lib/iomgr/port.h +10 -0
- data/src/core/lib/iomgr/resolve_address.h +18 -10
- data/src/core/lib/iomgr/{resolve_address_posix.c → resolve_address_posix.cc} +40 -40
- data/src/core/lib/iomgr/{resolve_address_uv.c → resolve_address_uv.cc} +61 -56
- data/src/core/lib/iomgr/{resolve_address_windows.c → resolve_address_windows.cc} +36 -34
- data/src/core/lib/iomgr/{resource_quota.c → resource_quota.cc} +209 -180
- data/src/core/lib/iomgr/resource_quota.h +45 -37
- data/src/core/lib/iomgr/{sockaddr_utils.c → sockaddr_utils.cc} +61 -61
- data/src/core/lib/iomgr/sockaddr_utils.h +23 -15
- data/src/core/lib/iomgr/sockaddr_windows.h +6 -0
- data/src/core/lib/iomgr/{socket_factory_posix.c → socket_factory_posix.cc} +20 -20
- data/src/core/lib/iomgr/socket_factory_posix.h +15 -15
- data/src/core/lib/iomgr/{socket_mutator.c → socket_mutator.cc} +18 -18
- data/src/core/lib/iomgr/socket_mutator.h +11 -11
- data/src/core/lib/iomgr/socket_utils.h +9 -1
- data/src/core/lib/iomgr/{socket_utils_common_posix.c → socket_utils_common_posix.cc} +28 -28
- data/src/core/lib/iomgr/{socket_utils_linux.c → socket_utils_linux.cc} +3 -3
- data/src/core/lib/iomgr/{socket_utils_posix.c → socket_utils_posix.cc} +3 -3
- data/src/core/lib/iomgr/socket_utils_posix.h +26 -18
- data/src/core/lib/iomgr/{socket_utils_uv.c → socket_utils_uv.cc} +1 -1
- data/src/core/lib/iomgr/{socket_utils_windows.c → socket_utils_windows.cc} +2 -2
- data/src/core/lib/iomgr/{socket_windows.c → socket_windows.cc} +18 -18
- data/src/core/lib/iomgr/socket_windows.h +26 -13
- data/src/core/lib/iomgr/tcp_client.h +14 -6
- data/src/core/lib/iomgr/{tcp_client_posix.c → tcp_client_posix.cc} +69 -70
- data/src/core/lib/iomgr/tcp_client_posix.h +11 -3
- data/src/core/lib/iomgr/{tcp_client_uv.c → tcp_client_uv.cc} +47 -48
- data/src/core/lib/iomgr/{tcp_client_windows.c → tcp_client_windows.cc} +46 -44
- data/src/core/lib/iomgr/{tcp_posix.c → tcp_posix.cc} +198 -175
- data/src/core/lib/iomgr/tcp_posix.h +15 -7
- data/src/core/lib/iomgr/tcp_server.h +31 -23
- data/src/core/lib/iomgr/{tcp_server_posix.c → tcp_server_posix.cc} +78 -77
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +27 -19
- data/src/core/lib/iomgr/{tcp_server_utils_posix_common.c → tcp_server_utils_posix_common.cc} +27 -27
- data/src/core/lib/iomgr/{tcp_server_utils_posix_ifaddrs.c → tcp_server_utils_posix_ifaddrs.cc} +25 -25
- data/src/core/lib/iomgr/{tcp_server_utils_posix_noifaddrs.c → tcp_server_utils_posix_noifaddrs.cc} +2 -2
- data/src/core/lib/iomgr/{tcp_server_uv.c → tcp_server_uv.cc} +133 -105
- data/src/core/lib/iomgr/{tcp_server_windows.c → tcp_server_windows.cc} +81 -77
- data/src/core/lib/iomgr/tcp_uv.cc +420 -0
- data/src/core/lib/iomgr/tcp_uv.h +18 -4
- data/src/core/lib/iomgr/{tcp_windows.c → tcp_windows.cc} +90 -79
- data/src/core/lib/iomgr/tcp_windows.h +17 -4
- data/src/core/lib/iomgr/{time_averaged_stats.c → time_averaged_stats.cc} +0 -0
- data/src/core/lib/iomgr/time_averaged_stats.h +8 -0
- data/src/core/lib/iomgr/timer.h +16 -9
- data/src/core/lib/iomgr/{timer_generic.c → timer_generic.cc} +130 -171
- data/src/core/lib/iomgr/timer_generic.h +4 -4
- data/src/core/lib/iomgr/{timer_heap.c → timer_heap.cc} +20 -21
- data/src/core/lib/iomgr/timer_heap.h +16 -8
- data/src/core/lib/iomgr/{timer_manager.c → timer_manager.cc} +54 -52
- data/src/core/lib/iomgr/timer_manager.h +8 -0
- data/src/core/lib/iomgr/{timer_uv.c → timer_uv.cc} +22 -24
- data/src/core/lib/iomgr/timer_uv.h +2 -2
- data/src/core/lib/iomgr/{udp_server.c → udp_server.cc} +75 -75
- data/src/core/lib/iomgr/udp_server.h +25 -17
- data/src/core/lib/iomgr/{unix_sockets_posix.c → unix_sockets_posix.cc} +22 -21
- data/src/core/lib/iomgr/unix_sockets_posix.h +14 -6
- data/src/core/lib/iomgr/{unix_sockets_posix_noop.c → unix_sockets_posix_noop.cc} +5 -5
- data/src/core/lib/iomgr/{wakeup_fd_cv.c → wakeup_fd_cv.cc} +2 -2
- data/src/core/lib/iomgr/wakeup_fd_cv.h +10 -0
- data/src/core/lib/iomgr/{wakeup_fd_eventfd.c → wakeup_fd_eventfd.cc} +0 -0
- data/src/core/lib/iomgr/{wakeup_fd_nospecial.c → wakeup_fd_nospecial.cc} +0 -0
- data/src/core/lib/iomgr/{wakeup_fd_pipe.c → wakeup_fd_pipe.cc} +1 -0
- data/src/core/lib/iomgr/wakeup_fd_pipe.h +9 -1
- data/src/core/lib/iomgr/{wakeup_fd_posix.c → wakeup_fd_posix.cc} +6 -7
- data/src/core/lib/iomgr/wakeup_fd_posix.h +8 -0
- data/src/core/lib/json/{json.c → json.cc} +0 -0
- data/src/core/lib/json/json.h +8 -0
- data/src/core/lib/json/{json_reader.c → json_reader.cc} +18 -18
- data/src/core/lib/json/json_reader.h +26 -18
- data/src/core/lib/json/{json_string.c → json_string.cc} +57 -57
- data/src/core/lib/json/{json_writer.c → json_writer.cc} +20 -20
- data/src/core/lib/json/json_writer.h +23 -15
- data/src/core/lib/profiling/{basic_timers.c → basic_timers.cc} +34 -34
- data/src/core/lib/profiling/{stap_timers.c → stap_timers.cc} +5 -5
- data/src/core/lib/profiling/timers.h +6 -6
- data/src/core/lib/security/context/{security_context.c → security_context.cc} +98 -95
- data/src/core/lib/security/context/security_context.h +27 -29
- data/src/core/lib/security/credentials/composite/{composite_credentials.c → composite_credentials.cc} +79 -73
- data/src/core/lib/security/credentials/composite/composite_credentials.h +17 -9
- data/src/core/lib/security/credentials/{credentials.c → credentials.cc} +97 -92
- data/src/core/lib/security/credentials/credentials.h +83 -75
- data/src/core/lib/security/credentials/{credentials_metadata.c → credentials_metadata.cc} +7 -6
- data/src/core/lib/security/credentials/fake/{fake_credentials.c → fake_credentials.cc} +39 -36
- data/src/core/lib/security/credentials/fake/fake_credentials.h +13 -5
- data/src/core/lib/security/credentials/google_default/{credentials_generic.c → credentials_generic.cc} +5 -5
- data/src/core/lib/security/credentials/google_default/{google_default_credentials.c → google_default_credentials.cc} +55 -55
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +9 -1
- data/src/core/lib/security/credentials/iam/{iam_credentials.c → iam_credentials.cc} +19 -18
- data/src/core/lib/security/credentials/jwt/{json_token.c → json_token.cc} +80 -75
- data/src/core/lib/security/credentials/jwt/json_token.h +23 -15
- data/src/core/lib/security/credentials/jwt/{jwt_credentials.c → jwt_credentials.cc} +45 -41
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +11 -3
- data/src/core/lib/security/credentials/jwt/{jwt_verifier.c → jwt_verifier.cc} +262 -252
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +38 -30
- data/src/core/lib/security/credentials/oauth2/{oauth2_credentials.c → oauth2_credentials.cc} +138 -141
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +30 -22
- data/src/core/lib/security/credentials/plugin/{plugin_credentials.c → plugin_credentials.cc} +52 -53
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +7 -7
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +344 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +27 -0
- data/src/core/lib/security/transport/auth_filters.h +16 -0
- data/src/core/lib/security/transport/{client_auth_filter.c → client_auth_filter.cc} +127 -115
- data/src/core/lib/security/transport/{lb_targets_info.c → lb_targets_info.cc} +16 -13
- data/src/core/lib/security/transport/lb_targets_info.h +11 -3
- data/src/core/lib/security/transport/{secure_endpoint.c → secure_endpoint.cc} +84 -76
- data/src/core/lib/security/transport/secure_endpoint.h +13 -5
- data/src/core/lib/security/transport/security_connector.cc +1121 -0
- data/src/core/lib/security/transport/security_connector.h +97 -79
- data/src/core/lib/security/transport/{security_handshaker.c → security_handshaker.cc} +139 -132
- data/src/core/lib/security/transport/security_handshaker.h +11 -3
- data/src/core/lib/security/transport/{server_auth_filter.c → server_auth_filter.cc} +68 -68
- data/src/core/lib/security/transport/{tsi_error.c → tsi_error.cc} +1 -1
- data/src/core/lib/security/transport/tsi_error.h +9 -1
- data/src/core/lib/security/util/{json_util.c → json_util.cc} +11 -11
- data/src/core/lib/security/util/json_util.h +12 -4
- data/src/core/lib/slice/{b64.c → b64.cc} +15 -15
- data/src/core/lib/slice/b64.h +12 -4
- data/src/core/lib/slice/{percent_encoding.c → percent_encoding.cc} +15 -15
- data/src/core/lib/slice/percent_encoding.h +11 -3
- data/src/core/lib/slice/{slice.c → slice.cc} +64 -64
- data/src/core/lib/slice/{slice_buffer.c → slice_buffer.cc} +38 -38
- data/src/core/lib/slice/{slice_hash_table.c → slice_hash_table.cc} +7 -7
- data/src/core/lib/slice/slice_hash_table.h +19 -11
- data/src/core/lib/slice/{slice_intern.c → slice_intern.cc} +35 -34
- data/src/core/lib/slice/slice_internal.h +17 -6
- data/src/core/lib/slice/{slice_string_helpers.c → slice_string_helpers.cc} +9 -9
- data/src/core/lib/slice/slice_string_helpers.h +3 -3
- data/src/core/lib/support/abstract.h +29 -0
- data/src/core/lib/support/{alloc.c → alloc.cc} +22 -22
- data/src/core/lib/support/{arena.c → arena.cc} +12 -12
- data/src/core/lib/support/arena.h +11 -3
- data/src/core/lib/support/{atm.c → atm.cc} +1 -1
- data/src/core/lib/support/{avl.c → avl.cc} +71 -70
- data/src/core/lib/support/{cmdline.c → cmdline.cc} +62 -62
- data/src/core/lib/support/{cpu_iphone.c → cpu_iphone.cc} +2 -0
- data/src/core/lib/support/{cpu_linux.c → cpu_linux.cc} +10 -0
- data/src/core/lib/support/{cpu_posix.c → cpu_posix.cc} +27 -4
- data/src/core/lib/support/{cpu_windows.c → cpu_windows.cc} +1 -0
- data/src/core/lib/support/env.h +3 -3
- data/src/core/lib/support/{env_linux.c → env_linux.cc} +11 -11
- data/src/core/lib/support/{env_posix.c → env_posix.cc} +4 -4
- data/src/core/lib/support/{env_windows.c → env_windows.cc} +5 -5
- data/src/core/lib/support/{fork.c → fork.cc} +2 -2
- data/src/core/lib/support/{histogram.c → histogram.cc} +25 -26
- data/src/core/lib/support/{host_port.c → host_port.cc} +16 -16
- data/src/core/lib/support/{log.c → log.cc} +8 -8
- data/src/core/lib/support/{log_android.c → log_android.cc} +7 -7
- data/src/core/lib/support/{log_linux.c → log_linux.cc} +8 -8
- data/src/core/lib/support/{log_posix.c → log_posix.cc} +9 -10
- data/src/core/lib/support/{log_windows.c → log_windows.cc} +7 -7
- data/src/core/lib/support/manual_constructor.h +211 -0
- data/src/core/lib/support/memory.h +41 -0
- data/src/core/lib/support/mpscq.cc +114 -0
- data/src/core/lib/support/mpscq.h +45 -7
- data/src/core/lib/support/{murmur_hash.c → murmur_hash.cc} +9 -12
- data/src/core/lib/support/murmur_hash.h +9 -1
- data/src/core/lib/support/spinlock.h +8 -1
- data/src/core/lib/support/{string.c → string.cc} +56 -55
- data/src/core/lib/support/string.h +21 -21
- data/src/core/lib/support/{string_posix.c → string_posix.cc} +5 -4
- data/src/core/lib/support/{string_util_windows.c → string_util_windows.cc} +9 -6
- data/src/core/lib/support/{string_windows.c → string_windows.cc} +3 -2
- data/src/core/lib/support/string_windows.h +8 -0
- data/src/core/lib/support/{subprocess_posix.c → subprocess_posix.cc} +13 -13
- data/src/core/lib/support/{subprocess_windows.c → subprocess_windows.cc} +9 -9
- data/src/core/lib/support/{sync.c → sync.cc} +22 -22
- data/src/core/lib/support/{sync_posix.c → sync_posix.cc} +6 -2
- data/src/core/lib/support/{sync_windows.c → sync_windows.cc} +14 -14
- data/src/core/lib/support/{thd.c → thd.cc} +0 -0
- data/src/core/lib/support/{thd_posix.c → thd_posix.cc} +10 -10
- data/src/core/lib/support/{thd_windows.c → thd_windows.cc} +10 -10
- data/src/core/lib/support/{time.c → time.cc} +0 -0
- data/src/core/lib/support/{time_posix.c → time_posix.cc} +5 -6
- data/src/core/lib/support/{time_precise.c → time_precise.cc} +6 -4
- data/src/core/lib/support/time_precise.h +9 -1
- data/src/core/lib/support/{time_windows.c → time_windows.cc} +2 -3
- data/src/core/lib/support/{tls_pthread.c → tls_pthread.cc} +2 -2
- data/src/core/lib/support/tmpfile.h +1 -1
- data/src/core/lib/support/{tmpfile_msys.c → tmpfile_msys.cc} +2 -2
- data/src/core/lib/support/{tmpfile_posix.c → tmpfile_posix.cc} +7 -7
- data/src/core/lib/support/{tmpfile_windows.c → tmpfile_windows.cc} +2 -2
- data/src/core/lib/support/{wrap_memcpy.c → wrap_memcpy.cc} +4 -2
- data/src/core/lib/surface/{alarm.c → alarm.cc} +32 -31
- data/src/core/lib/surface/alarm_internal.h +10 -2
- data/src/core/lib/surface/{api_trace.c → api_trace.cc} +1 -1
- data/src/core/lib/surface/api_trace.h +2 -2
- data/src/core/lib/surface/{byte_buffer.c → byte_buffer.cc} +13 -13
- data/src/core/lib/surface/{byte_buffer_reader.c → byte_buffer_reader.cc} +9 -9
- data/src/core/lib/surface/{call.c → call.cc} +379 -372
- data/src/core/lib/surface/call.h +37 -38
- data/src/core/lib/surface/{call_details.c → call_details.cc} +0 -0
- data/src/core/lib/surface/{call_log_batch.c → call_log_batch.cc} +13 -11
- data/src/core/lib/surface/call_test_only.h +5 -5
- data/src/core/lib/surface/{channel.c → channel.cc} +94 -95
- data/src/core/lib/surface/channel.h +29 -21
- data/src/core/lib/surface/{channel_init.c → channel_init.cc} +13 -13
- data/src/core/lib/surface/channel_init.h +6 -6
- data/src/core/lib/surface/{channel_ping.c → channel_ping.cc} +12 -12
- data/src/core/lib/surface/{channel_stack_type.c → channel_stack_type.cc} +1 -1
- data/src/core/lib/surface/channel_stack_type.h +9 -1
- data/src/core/lib/surface/{completion_queue.c → completion_queue.cc} +416 -379
- data/src/core/lib/surface/completion_queue.h +29 -29
- data/src/core/lib/surface/{completion_queue_factory.c → completion_queue_factory.cc} +1 -1
- data/src/core/lib/surface/completion_queue_factory.h +8 -0
- data/src/core/lib/surface/{event_string.c → event_string.cc} +9 -9
- data/src/core/lib/surface/event_string.h +9 -1
- data/src/core/lib/surface/{init.c → init.cc} +16 -39
- data/src/core/lib/surface/init.h +8 -0
- data/src/core/lib/surface/{init_secure.c → init_secure.cc} +12 -25
- data/src/core/lib/surface/lame_client.cc +38 -40
- data/src/core/lib/surface/lame_client.h +8 -0
- data/src/core/lib/surface/{metadata_array.c → metadata_array.cc} +0 -0
- data/src/core/lib/surface/{server.c → server.cc} +340 -404
- data/src/core/lib/surface/server.h +22 -14
- data/src/core/lib/surface/{validate_metadata.c → validate_metadata.cc} +10 -9
- data/src/core/lib/surface/validate_metadata.h +10 -2
- data/src/core/lib/surface/{version.c → version.cc} +2 -2
- data/src/core/lib/transport/bdp_estimator.cc +84 -0
- data/src/core/lib/transport/bdp_estimator.h +67 -42
- data/src/core/lib/transport/{byte_stream.c → byte_stream.cc} +51 -51
- data/src/core/lib/transport/byte_stream.h +41 -33
- data/src/core/lib/transport/{connectivity_state.c → connectivity_state.cc} +36 -40
- data/src/core/lib/transport/connectivity_state.h +29 -21
- data/src/core/lib/transport/{error_utils.c → error_utils.cc} +26 -22
- data/src/core/lib/transport/error_utils.h +18 -6
- data/src/core/lib/transport/{metadata.c → metadata.cc} +92 -88
- data/src/core/lib/transport/metadata.h +22 -20
- data/src/core/lib/transport/{metadata_batch.c → metadata_batch.cc} +78 -79
- data/src/core/lib/transport/metadata_batch.h +46 -45
- data/src/core/lib/transport/pid_controller.cc +48 -0
- data/src/core/lib/transport/pid_controller.h +84 -32
- data/src/core/lib/transport/{service_config.c → service_config.cc} +66 -48
- data/src/core/lib/transport/service_config.h +11 -2
- data/src/core/lib/transport/{static_metadata.c → static_metadata.cc} +2 -2
- data/src/core/lib/transport/static_metadata.h +30 -23
- data/src/core/lib/transport/{status_conversion.c → status_conversion.cc} +4 -3
- data/src/core/lib/transport/status_conversion.h +12 -2
- data/src/core/lib/transport/{timeout_encoding.c → timeout_encoding.cc} +28 -61
- data/src/core/lib/transport/timeout_encoding.h +11 -2
- data/src/core/lib/transport/{transport.c → transport.cc} +79 -79
- data/src/core/lib/transport/transport.h +78 -80
- data/src/core/lib/transport/transport_impl.h +27 -19
- data/src/core/lib/transport/{transport_op_string.c → transport_op_string.cc} +32 -30
- data/src/core/plugin_registry/{grpc_plugin_registry.c → grpc_plugin_registry.cc} +34 -38
- data/src/core/tsi/{fake_transport_security.c → fake_transport_security.cc} +141 -132
- data/src/core/tsi/fake_transport_security.h +5 -5
- data/src/core/tsi/{gts_transport_security.c → gts_transport_security.cc} +4 -4
- data/src/core/tsi/gts_transport_security.h +11 -3
- data/src/core/tsi/{ssl_transport_security.c → ssl_transport_security.cc} +309 -300
- data/src/core/tsi/ssl_transport_security.h +25 -25
- data/src/core/tsi/ssl_types.h +8 -0
- data/src/core/tsi/{transport_security.c → transport_security.cc} +94 -87
- data/src/core/tsi/transport_security.h +55 -55
- data/src/core/tsi/{transport_security_adapter.c → transport_security_adapter.cc} +58 -55
- data/src/core/tsi/transport_security_adapter.h +2 -2
- data/src/core/tsi/{transport_security_grpc.c → transport_security_grpc.cc} +21 -21
- data/src/core/tsi/transport_security_grpc.h +19 -19
- data/src/core/tsi/transport_security_interface.h +41 -41
- data/src/ruby/ext/grpc/extconf.rb +4 -2
- data/src/ruby/ext/grpc/rb_byte_buffer.c +5 -5
- data/src/ruby/ext/grpc/rb_byte_buffer.h +2 -2
- data/src/ruby/ext/grpc/rb_call.c +41 -42
- data/src/ruby/ext/grpc/rb_call.h +6 -6
- data/src/ruby/ext/grpc/rb_call_credentials.c +30 -30
- data/src/ruby/ext/grpc/rb_channel.c +87 -87
- data/src/ruby/ext/grpc/rb_channel_credentials.c +23 -23
- data/src/ruby/ext/grpc/rb_completion_queue.c +11 -11
- data/src/ruby/ext/grpc/rb_completion_queue.h +3 -3
- data/src/ruby/ext/grpc/rb_compression_options.c +20 -20
- data/src/ruby/ext/grpc/rb_event_thread.c +14 -14
- data/src/ruby/ext/grpc/rb_event_thread.h +1 -1
- data/src/ruby/ext/grpc/rb_grpc.c +8 -8
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +16 -58
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +242 -306
- data/src/ruby/ext/grpc/rb_server.c +23 -23
- data/src/ruby/ext/grpc/rb_server_credentials.c +13 -13
- data/src/ruby/lib/grpc/generic/rpc_server.rb +25 -12
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/checker.rb +14 -0
- data/src/ruby/spec/pb/health/checker_spec.rb +29 -0
- data/third_party/cares/config_freebsd/ares_config.h +502 -0
- data/third_party/cares/config_openbsd/ares_config.h +502 -0
- metadata +302 -328
- data/src/core/ext/census/aggregation.h +0 -51
- data/src/core/ext/census/base_resources.c +0 -56
- data/src/core/ext/census/base_resources.h +0 -24
- data/src/core/ext/census/census_interface.h +0 -61
- data/src/core/ext/census/census_rpc_stats.h +0 -86
- data/src/core/ext/census/context.c +0 -496
- data/src/core/ext/census/gen/census.pb.c +0 -161
- data/src/core/ext/census/gen/census.pb.h +0 -280
- data/src/core/ext/census/gen/trace_context.pb.c +0 -39
- data/src/core/ext/census/gen/trace_context.pb.h +0 -78
- data/src/core/ext/census/grpc_filter.c +0 -196
- data/src/core/ext/census/grpc_plugin.c +0 -70
- data/src/core/ext/census/initialize.c +0 -51
- data/src/core/ext/census/intrusive_hash_map.c +0 -305
- data/src/core/ext/census/intrusive_hash_map.h +0 -152
- data/src/core/ext/census/intrusive_hash_map_internal.h +0 -48
- data/src/core/ext/census/mlog.c +0 -586
- data/src/core/ext/census/mlog.h +0 -80
- data/src/core/ext/census/operation.c +0 -48
- data/src/core/ext/census/placeholders.c +0 -49
- data/src/core/ext/census/resource.c +0 -303
- data/src/core/ext/census/resource.h +0 -48
- data/src/core/ext/census/rpc_metric_id.h +0 -36
- data/src/core/ext/census/trace_context.c +0 -71
- data/src/core/ext/census/trace_context.h +0 -56
- data/src/core/ext/census/trace_label.h +0 -46
- data/src/core/ext/census/trace_propagation.h +0 -48
- data/src/core/ext/census/trace_status.h +0 -30
- data/src/core/ext/census/trace_string.h +0 -35
- data/src/core/ext/census/tracing.c +0 -55
- data/src/core/ext/census/tracing.h +0 -109
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +0 -714
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +0 -924
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c +0 -60
- data/src/core/ext/transport/chttp2/transport/flow_control.c +0 -502
- data/src/core/ext/transport/chttp2/transport/writing.c +0 -534
- data/src/core/lib/debug/trace.c +0 -146
- data/src/core/lib/iomgr/closure.c +0 -219
- data/src/core/lib/iomgr/ev_epollex_linux.c +0 -1461
- data/src/core/lib/iomgr/ev_posix.c +0 -266
- data/src/core/lib/iomgr/exec_ctx.c +0 -113
- data/src/core/lib/iomgr/tcp_uv.c +0 -381
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +0 -194
- data/src/core/lib/security/transport/security_connector.c +0 -914
- data/src/core/lib/support/backoff.c +0 -72
- data/src/core/lib/support/backoff.h +0 -56
- data/src/core/lib/support/mpscq.c +0 -79
- data/src/core/lib/support/stack_lockfree.c +0 -137
- data/src/core/lib/support/stack_lockfree.h +0 -38
- data/src/core/lib/transport/bdp_estimator.c +0 -110
- data/src/core/lib/transport/pid_controller.c +0 -63
@@ -22,7 +22,15 @@
|
|
22
22
|
#include "src/core/lib/iomgr/ev_posix.h"
|
23
23
|
#include "src/core/lib/iomgr/port.h"
|
24
24
|
|
25
|
-
|
25
|
+
#ifdef __cplusplus
|
26
|
+
extern "C" {
|
27
|
+
#endif
|
28
|
+
|
29
|
+
const grpc_event_engine_vtable* grpc_init_epollex_linux(
|
26
30
|
bool explicitly_requested);
|
27
31
|
|
32
|
+
#ifdef __cplusplus
|
33
|
+
}
|
34
|
+
#endif
|
35
|
+
|
28
36
|
#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLLEX_LINUX_H */
|
@@ -18,6 +18,9 @@
|
|
18
18
|
|
19
19
|
#include "src/core/lib/iomgr/port.h"
|
20
20
|
|
21
|
+
#include <grpc/grpc_posix.h>
|
22
|
+
#include <grpc/support/log.h>
|
23
|
+
|
21
24
|
/* This polling engine is only relevant on linux kernels supporting epoll() */
|
22
25
|
#ifdef GRPC_LINUX_EPOLL
|
23
26
|
|
@@ -25,6 +28,7 @@
|
|
25
28
|
|
26
29
|
#include <assert.h>
|
27
30
|
#include <errno.h>
|
31
|
+
#include <limits.h>
|
28
32
|
#include <poll.h>
|
29
33
|
#include <pthread.h>
|
30
34
|
#include <signal.h>
|
@@ -34,25 +38,25 @@
|
|
34
38
|
#include <unistd.h>
|
35
39
|
|
36
40
|
#include <grpc/support/alloc.h>
|
37
|
-
#include <grpc/support/log.h>
|
38
41
|
#include <grpc/support/string_util.h>
|
39
42
|
#include <grpc/support/tls.h>
|
40
43
|
#include <grpc/support/useful.h>
|
41
44
|
|
42
45
|
#include "src/core/lib/debug/stats.h"
|
46
|
+
#include "src/core/lib/iomgr/block_annotate.h"
|
43
47
|
#include "src/core/lib/iomgr/ev_posix.h"
|
44
48
|
#include "src/core/lib/iomgr/iomgr_internal.h"
|
45
49
|
#include "src/core/lib/iomgr/lockfree_event.h"
|
46
50
|
#include "src/core/lib/iomgr/timer.h"
|
47
51
|
#include "src/core/lib/iomgr/wakeup_fd_posix.h"
|
48
52
|
#include "src/core/lib/profiling/timers.h"
|
49
|
-
#include "src/core/lib/support/
|
53
|
+
#include "src/core/lib/support/manual_constructor.h"
|
50
54
|
|
51
|
-
#define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker
|
55
|
+
#define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker*)1)
|
52
56
|
|
53
|
-
#define GRPC_POLLING_TRACE(...)
|
54
|
-
if (
|
55
|
-
gpr_log(GPR_INFO, __VA_ARGS__);
|
57
|
+
#define GRPC_POLLING_TRACE(...) \
|
58
|
+
if (grpc_polling_trace.enabled()) { \
|
59
|
+
gpr_log(GPR_INFO, __VA_ARGS__); \
|
56
60
|
}
|
57
61
|
|
58
62
|
static int grpc_wakeup_signal = -1;
|
@@ -87,10 +91,10 @@ typedef struct poll_obj {
|
|
87
91
|
poll_obj_type obj_type;
|
88
92
|
#endif
|
89
93
|
gpr_mu mu;
|
90
|
-
struct polling_island
|
94
|
+
struct polling_island* pi;
|
91
95
|
} poll_obj;
|
92
96
|
|
93
|
-
const char
|
97
|
+
const char* poll_obj_string(poll_obj_type po_type) {
|
94
98
|
switch (po_type) {
|
95
99
|
case POLL_OBJ_FD:
|
96
100
|
return "fd";
|
@@ -103,11 +107,11 @@ const char *poll_obj_string(poll_obj_type po_type) {
|
|
103
107
|
GPR_UNREACHABLE_CODE(return "UNKNOWN");
|
104
108
|
}
|
105
109
|
|
106
|
-
/*******************************************************************************
|
107
|
-
|
108
|
-
|
110
|
+
/*******************************************************************************
|
111
|
+
* Fd Declarations
|
112
|
+
*/
|
109
113
|
|
110
|
-
#define FD_FROM_PO(po) ((grpc_fd
|
114
|
+
#define FD_FROM_PO(po) ((grpc_fd*)(po))
|
111
115
|
|
112
116
|
struct grpc_fd {
|
113
117
|
poll_obj po;
|
@@ -124,11 +128,11 @@ struct grpc_fd {
|
|
124
128
|
valid */
|
125
129
|
bool orphaned;
|
126
130
|
|
127
|
-
|
128
|
-
|
131
|
+
grpc_core::ManualConstructor<grpc_core::LockfreeEvent> read_closure;
|
132
|
+
grpc_core::ManualConstructor<grpc_core::LockfreeEvent> write_closure;
|
129
133
|
|
130
|
-
struct grpc_fd
|
131
|
-
grpc_closure
|
134
|
+
struct grpc_fd* freelist_next;
|
135
|
+
grpc_closure* on_done_closure;
|
132
136
|
|
133
137
|
/* The pollset that last noticed that the fd is readable. The actual type
|
134
138
|
* stored in this is (grpc_pollset *) */
|
@@ -139,14 +143,14 @@ struct grpc_fd {
|
|
139
143
|
|
140
144
|
/* Reference counting for fds */
|
141
145
|
#ifndef NDEBUG
|
142
|
-
static void fd_ref(grpc_fd
|
143
|
-
static void fd_unref(grpc_fd
|
146
|
+
static void fd_ref(grpc_fd* fd, const char* reason, const char* file, int line);
|
147
|
+
static void fd_unref(grpc_fd* fd, const char* reason, const char* file,
|
144
148
|
int line);
|
145
149
|
#define GRPC_FD_REF(fd, reason) fd_ref(fd, reason, __FILE__, __LINE__)
|
146
150
|
#define GRPC_FD_UNREF(fd, reason) fd_unref(fd, reason, __FILE__, __LINE__)
|
147
151
|
#else
|
148
|
-
static void fd_ref(grpc_fd
|
149
|
-
static void fd_unref(grpc_fd
|
152
|
+
static void fd_ref(grpc_fd* fd);
|
153
|
+
static void fd_unref(grpc_fd* fd);
|
150
154
|
#define GRPC_FD_REF(fd, reason) fd_ref(fd)
|
151
155
|
#define GRPC_FD_UNREF(fd, reason) fd_unref(fd)
|
152
156
|
#endif
|
@@ -200,7 +204,7 @@ typedef struct polling_island {
|
|
200
204
|
/* The file descriptors in the epoll set */
|
201
205
|
size_t fd_cnt;
|
202
206
|
size_t fd_capacity;
|
203
|
-
grpc_fd
|
207
|
+
grpc_fd** fds;
|
204
208
|
} polling_island;
|
205
209
|
|
206
210
|
/*******************************************************************************
|
@@ -212,8 +216,8 @@ struct grpc_pollset_worker {
|
|
212
216
|
|
213
217
|
/* Used to prevent a worker from getting kicked multiple times */
|
214
218
|
gpr_atm is_kicked;
|
215
|
-
struct grpc_pollset_worker
|
216
|
-
struct grpc_pollset_worker
|
219
|
+
struct grpc_pollset_worker* next;
|
220
|
+
struct grpc_pollset_worker* prev;
|
217
221
|
};
|
218
222
|
|
219
223
|
struct grpc_pollset {
|
@@ -224,7 +228,7 @@ struct grpc_pollset {
|
|
224
228
|
|
225
229
|
bool shutting_down; /* Is the pollset shutting down ? */
|
226
230
|
bool finish_shutdown_called; /* Is the 'finish_shutdown_locked()' called ? */
|
227
|
-
grpc_closure
|
231
|
+
grpc_closure* shutdown_done; /* Called after after shutdown is complete */
|
228
232
|
};
|
229
233
|
|
230
234
|
/*******************************************************************************
|
@@ -238,8 +242,8 @@ struct grpc_pollset_set {
|
|
238
242
|
* Common helpers
|
239
243
|
*/
|
240
244
|
|
241
|
-
static bool append_error(grpc_error
|
242
|
-
const char
|
245
|
+
static bool append_error(grpc_error** composite, grpc_error* error,
|
246
|
+
const char* desc) {
|
243
247
|
if (error == GRPC_ERROR_NONE) return true;
|
244
248
|
if (*composite == GRPC_ERROR_NONE) {
|
245
249
|
*composite = GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc);
|
@@ -263,10 +267,10 @@ static grpc_wakeup_fd polling_island_wakeup_fd;
|
|
263
267
|
|
264
268
|
/* The polling island being polled right now.
|
265
269
|
See comments in workqueue_maybe_wakeup for why this is tracked. */
|
266
|
-
static __thread polling_island
|
270
|
+
static __thread polling_island* g_current_thread_polling_island;
|
267
271
|
|
268
272
|
/* Forward declaration */
|
269
|
-
static void polling_island_delete(grpc_exec_ctx
|
273
|
+
static void polling_island_delete(grpc_exec_ctx* exec_ctx, polling_island* pi);
|
270
274
|
|
271
275
|
#ifdef GRPC_TSAN
|
272
276
|
/* Currently TSAN may incorrectly flag data races between epoll_ctl and
|
@@ -279,38 +283,40 @@ static void polling_island_delete(grpc_exec_ctx *exec_ctx, polling_island *pi);
|
|
279
283
|
gpr_atm g_epoll_sync;
|
280
284
|
#endif /* defined(GRPC_TSAN) */
|
281
285
|
|
282
|
-
static void pi_add_ref(polling_island
|
283
|
-
static void pi_unref(grpc_exec_ctx
|
286
|
+
static void pi_add_ref(polling_island* pi);
|
287
|
+
static void pi_unref(grpc_exec_ctx* exec_ctx, polling_island* pi);
|
284
288
|
|
285
289
|
#ifndef NDEBUG
|
286
|
-
static void pi_add_ref_dbg(polling_island
|
287
|
-
const char
|
288
|
-
if (
|
290
|
+
static void pi_add_ref_dbg(polling_island* pi, const char* reason,
|
291
|
+
const char* file, int line) {
|
292
|
+
if (grpc_polling_trace.enabled()) {
|
289
293
|
gpr_atm old_cnt = gpr_atm_acq_load(&pi->ref_count);
|
290
|
-
gpr_log(GPR_DEBUG,
|
291
|
-
|
294
|
+
gpr_log(GPR_DEBUG,
|
295
|
+
"Add ref pi: %p, old:%" PRIdPTR " -> new:%" PRIdPTR
|
296
|
+
" (%s) - (%s, %d)",
|
292
297
|
pi, old_cnt, old_cnt + 1, reason, file, line);
|
293
298
|
}
|
294
299
|
pi_add_ref(pi);
|
295
300
|
}
|
296
301
|
|
297
|
-
static void pi_unref_dbg(grpc_exec_ctx
|
298
|
-
const char
|
299
|
-
if (
|
302
|
+
static void pi_unref_dbg(grpc_exec_ctx* exec_ctx, polling_island* pi,
|
303
|
+
const char* reason, const char* file, int line) {
|
304
|
+
if (grpc_polling_trace.enabled()) {
|
300
305
|
gpr_atm old_cnt = gpr_atm_acq_load(&pi->ref_count);
|
301
|
-
gpr_log(GPR_DEBUG,
|
302
|
-
|
306
|
+
gpr_log(GPR_DEBUG,
|
307
|
+
"Unref pi: %p, old:%" PRIdPTR " -> new:%" PRIdPTR
|
308
|
+
" (%s) - (%s, %d)",
|
303
309
|
pi, old_cnt, (old_cnt - 1), reason, file, line);
|
304
310
|
}
|
305
311
|
pi_unref(exec_ctx, pi);
|
306
312
|
}
|
307
313
|
#endif
|
308
314
|
|
309
|
-
static void pi_add_ref(polling_island
|
315
|
+
static void pi_add_ref(polling_island* pi) {
|
310
316
|
gpr_atm_no_barrier_fetch_add(&pi->ref_count, 1);
|
311
317
|
}
|
312
318
|
|
313
|
-
static void pi_unref(grpc_exec_ctx
|
319
|
+
static void pi_unref(grpc_exec_ctx* exec_ctx, polling_island* pi) {
|
314
320
|
/* If ref count went to zero, delete the polling island.
|
315
321
|
Note that this deletion not be done under a lock. Once the ref count goes
|
316
322
|
to zero, we are guaranteed that no one else holds a reference to the
|
@@ -320,23 +326,23 @@ static void pi_unref(grpc_exec_ctx *exec_ctx, polling_island *pi) {
|
|
320
326
|
non-empty, we should remove a ref to the merged_to polling island
|
321
327
|
*/
|
322
328
|
if (1 == gpr_atm_full_fetch_add(&pi->ref_count, -1)) {
|
323
|
-
polling_island
|
329
|
+
polling_island* next = (polling_island*)gpr_atm_acq_load(&pi->merged_to);
|
324
330
|
polling_island_delete(exec_ctx, pi);
|
325
|
-
if (next !=
|
331
|
+
if (next != nullptr) {
|
326
332
|
PI_UNREF(exec_ctx, next, "pi_delete"); /* Recursive call */
|
327
333
|
}
|
328
334
|
}
|
329
335
|
}
|
330
336
|
|
331
337
|
/* The caller is expected to hold pi->mu lock before calling this function */
|
332
|
-
static void polling_island_add_fds_locked(polling_island
|
338
|
+
static void polling_island_add_fds_locked(polling_island* pi, grpc_fd** fds,
|
333
339
|
size_t fd_count, bool add_fd_refs,
|
334
|
-
grpc_error
|
340
|
+
grpc_error** error) {
|
335
341
|
int err;
|
336
342
|
size_t i;
|
337
343
|
struct epoll_event ev;
|
338
|
-
char
|
339
|
-
const char
|
344
|
+
char* err_msg;
|
345
|
+
const char* err_desc = "polling_island_add_fds";
|
340
346
|
|
341
347
|
#ifdef GRPC_TSAN
|
342
348
|
/* See the definition of g_epoll_sync for more context */
|
@@ -364,7 +370,7 @@ static void polling_island_add_fds_locked(polling_island *pi, grpc_fd **fds,
|
|
364
370
|
if (pi->fd_cnt == pi->fd_capacity) {
|
365
371
|
pi->fd_capacity = GPR_MAX(pi->fd_capacity + 8, pi->fd_cnt * 3 / 2);
|
366
372
|
pi->fds =
|
367
|
-
(grpc_fd
|
373
|
+
(grpc_fd**)gpr_realloc(pi->fds, sizeof(grpc_fd*) * pi->fd_capacity);
|
368
374
|
}
|
369
375
|
|
370
376
|
pi->fds[pi->fd_cnt++] = fds[i];
|
@@ -375,13 +381,13 @@ static void polling_island_add_fds_locked(polling_island *pi, grpc_fd **fds,
|
|
375
381
|
}
|
376
382
|
|
377
383
|
/* The caller is expected to hold pi->mu before calling this */
|
378
|
-
static void polling_island_add_wakeup_fd_locked(polling_island
|
379
|
-
grpc_wakeup_fd
|
380
|
-
grpc_error
|
384
|
+
static void polling_island_add_wakeup_fd_locked(polling_island* pi,
|
385
|
+
grpc_wakeup_fd* wakeup_fd,
|
386
|
+
grpc_error** error) {
|
381
387
|
struct epoll_event ev;
|
382
388
|
int err;
|
383
|
-
char
|
384
|
-
const char
|
389
|
+
char* err_msg;
|
390
|
+
const char* err_desc = "polling_island_add_wakeup_fd";
|
385
391
|
|
386
392
|
ev.events = (uint32_t)(EPOLLIN | EPOLLET);
|
387
393
|
ev.data.ptr = wakeup_fd;
|
@@ -399,16 +405,16 @@ static void polling_island_add_wakeup_fd_locked(polling_island *pi,
|
|
399
405
|
}
|
400
406
|
|
401
407
|
/* The caller is expected to hold pi->mu lock before calling this function */
|
402
|
-
static void polling_island_remove_all_fds_locked(polling_island
|
408
|
+
static void polling_island_remove_all_fds_locked(polling_island* pi,
|
403
409
|
bool remove_fd_refs,
|
404
|
-
grpc_error
|
410
|
+
grpc_error** error) {
|
405
411
|
int err;
|
406
412
|
size_t i;
|
407
|
-
char
|
408
|
-
const char
|
413
|
+
char* err_msg;
|
414
|
+
const char* err_desc = "polling_island_remove_fds";
|
409
415
|
|
410
416
|
for (i = 0; i < pi->fd_cnt; i++) {
|
411
|
-
err = epoll_ctl(pi->epoll_fd, EPOLL_CTL_DEL, pi->fds[i]->fd,
|
417
|
+
err = epoll_ctl(pi->epoll_fd, EPOLL_CTL_DEL, pi->fds[i]->fd, nullptr);
|
412
418
|
if (err < 0 && errno != ENOENT) {
|
413
419
|
gpr_asprintf(&err_msg,
|
414
420
|
"epoll_ctl (epoll_fd: %d) delete fds[%zu]: %d failed with "
|
@@ -427,18 +433,18 @@ static void polling_island_remove_all_fds_locked(polling_island *pi,
|
|
427
433
|
}
|
428
434
|
|
429
435
|
/* The caller is expected to hold pi->mu lock before calling this function */
|
430
|
-
static void polling_island_remove_fd_locked(polling_island
|
436
|
+
static void polling_island_remove_fd_locked(polling_island* pi, grpc_fd* fd,
|
431
437
|
bool is_fd_closed,
|
432
|
-
grpc_error
|
438
|
+
grpc_error** error) {
|
433
439
|
int err;
|
434
440
|
size_t i;
|
435
|
-
char
|
436
|
-
const char
|
441
|
+
char* err_msg;
|
442
|
+
const char* err_desc = "polling_island_remove_fd";
|
437
443
|
|
438
444
|
/* If fd is already closed, then it would have been automatically been removed
|
439
445
|
from the epoll set */
|
440
446
|
if (!is_fd_closed) {
|
441
|
-
err = epoll_ctl(pi->epoll_fd, EPOLL_CTL_DEL, fd->fd,
|
447
|
+
err = epoll_ctl(pi->epoll_fd, EPOLL_CTL_DEL, fd->fd, nullptr);
|
442
448
|
if (err < 0 && errno != ENOENT) {
|
443
449
|
gpr_asprintf(
|
444
450
|
&err_msg,
|
@@ -459,19 +465,19 @@ static void polling_island_remove_fd_locked(polling_island *pi, grpc_fd *fd,
|
|
459
465
|
}
|
460
466
|
|
461
467
|
/* Might return NULL in case of an error */
|
462
|
-
static polling_island
|
463
|
-
grpc_fd
|
464
|
-
grpc_error
|
465
|
-
polling_island
|
466
|
-
const char
|
468
|
+
static polling_island* polling_island_create(grpc_exec_ctx* exec_ctx,
|
469
|
+
grpc_fd* initial_fd,
|
470
|
+
grpc_error** error) {
|
471
|
+
polling_island* pi = nullptr;
|
472
|
+
const char* err_desc = "polling_island_create";
|
467
473
|
|
468
474
|
*error = GRPC_ERROR_NONE;
|
469
475
|
|
470
|
-
pi = (polling_island
|
476
|
+
pi = (polling_island*)gpr_malloc(sizeof(*pi));
|
471
477
|
gpr_mu_init(&pi->mu);
|
472
478
|
pi->fd_cnt = 0;
|
473
479
|
pi->fd_capacity = 0;
|
474
|
-
pi->fds =
|
480
|
+
pi->fds = nullptr;
|
475
481
|
pi->epoll_fd = -1;
|
476
482
|
|
477
483
|
gpr_atm_rel_store(&pi->ref_count, 0);
|
@@ -485,19 +491,19 @@ static polling_island *polling_island_create(grpc_exec_ctx *exec_ctx,
|
|
485
491
|
goto done;
|
486
492
|
}
|
487
493
|
|
488
|
-
if (initial_fd !=
|
494
|
+
if (initial_fd != nullptr) {
|
489
495
|
polling_island_add_fds_locked(pi, &initial_fd, 1, true, error);
|
490
496
|
}
|
491
497
|
|
492
498
|
done:
|
493
499
|
if (*error != GRPC_ERROR_NONE) {
|
494
500
|
polling_island_delete(exec_ctx, pi);
|
495
|
-
pi =
|
501
|
+
pi = nullptr;
|
496
502
|
}
|
497
503
|
return pi;
|
498
504
|
}
|
499
505
|
|
500
|
-
static void polling_island_delete(grpc_exec_ctx
|
506
|
+
static void polling_island_delete(grpc_exec_ctx* exec_ctx, polling_island* pi) {
|
501
507
|
GPR_ASSERT(pi->fd_cnt == 0);
|
502
508
|
|
503
509
|
if (pi->epoll_fd >= 0) {
|
@@ -511,11 +517,11 @@ static void polling_island_delete(grpc_exec_ctx *exec_ctx, polling_island *pi) {
|
|
511
517
|
/* Attempts to gets the last polling island in the linked list (liked by the
|
512
518
|
* 'merged_to' field). Since this does not lock the polling island, there are no
|
513
519
|
* guarantees that the island returned is the last island */
|
514
|
-
static polling_island
|
515
|
-
polling_island
|
516
|
-
while (next !=
|
520
|
+
static polling_island* polling_island_maybe_get_latest(polling_island* pi) {
|
521
|
+
polling_island* next = (polling_island*)gpr_atm_acq_load(&pi->merged_to);
|
522
|
+
while (next != nullptr) {
|
517
523
|
pi = next;
|
518
|
-
next = (polling_island
|
524
|
+
next = (polling_island*)gpr_atm_acq_load(&pi->merged_to);
|
519
525
|
}
|
520
526
|
|
521
527
|
return pi;
|
@@ -530,19 +536,19 @@ static polling_island *polling_island_maybe_get_latest(polling_island *pi) {
|
|
530
536
|
... critical section ..
|
531
537
|
...
|
532
538
|
gpr_mu_unlock(&pi_latest->mu); // NOTE: use pi_latest->mu. NOT pi->mu */
|
533
|
-
static polling_island
|
534
|
-
polling_island
|
539
|
+
static polling_island* polling_island_lock(polling_island* pi) {
|
540
|
+
polling_island* next = nullptr;
|
535
541
|
|
536
542
|
while (true) {
|
537
|
-
next = (polling_island
|
538
|
-
if (next ==
|
543
|
+
next = (polling_island*)gpr_atm_acq_load(&pi->merged_to);
|
544
|
+
if (next == nullptr) {
|
539
545
|
/* Looks like 'pi' is the last node in the linked list but unless we check
|
540
546
|
this by holding the pi->mu lock, we cannot be sure (i.e without the
|
541
547
|
pi->mu lock, we don't prevent island merges).
|
542
548
|
To be absolutely sure, check once more by holding the pi->mu lock */
|
543
549
|
gpr_mu_lock(&pi->mu);
|
544
|
-
next = (polling_island
|
545
|
-
if (next ==
|
550
|
+
next = (polling_island*)gpr_atm_acq_load(&pi->merged_to);
|
551
|
+
if (next == nullptr) {
|
546
552
|
/* pi is infact the last node and we have the pi->mu lock. we're done */
|
547
553
|
break;
|
548
554
|
}
|
@@ -579,11 +585,11 @@ static polling_island *polling_island_lock(polling_island *pi) {
|
|
579
585
|
// Release locks: Always call polling_island_unlock_pair() to release locks
|
580
586
|
polling_island_unlock_pair(p1, p2);
|
581
587
|
*/
|
582
|
-
static void polling_island_lock_pair(polling_island
|
583
|
-
polling_island
|
584
|
-
polling_island
|
585
|
-
polling_island
|
586
|
-
polling_island
|
588
|
+
static void polling_island_lock_pair(polling_island** p, polling_island** q) {
|
589
|
+
polling_island* pi_1 = *p;
|
590
|
+
polling_island* pi_2 = *q;
|
591
|
+
polling_island* next_1 = nullptr;
|
592
|
+
polling_island* next_2 = nullptr;
|
587
593
|
|
588
594
|
/* The algorithm is simple:
|
589
595
|
- Go to the last polling islands in the linked lists *pi_1 and *pi_2 (and
|
@@ -600,16 +606,16 @@ static void polling_island_lock_pair(polling_island **p, polling_island **q) {
|
|
600
606
|
- If the polling islands are the last islands, we are done. If not,
|
601
607
|
release the locks and continue the process from the first step */
|
602
608
|
while (true) {
|
603
|
-
next_1 = (polling_island
|
604
|
-
while (next_1 !=
|
609
|
+
next_1 = (polling_island*)gpr_atm_acq_load(&pi_1->merged_to);
|
610
|
+
while (next_1 != nullptr) {
|
605
611
|
pi_1 = next_1;
|
606
|
-
next_1 = (polling_island
|
612
|
+
next_1 = (polling_island*)gpr_atm_acq_load(&pi_1->merged_to);
|
607
613
|
}
|
608
614
|
|
609
|
-
next_2 = (polling_island
|
610
|
-
while (next_2 !=
|
615
|
+
next_2 = (polling_island*)gpr_atm_acq_load(&pi_2->merged_to);
|
616
|
+
while (next_2 != nullptr) {
|
611
617
|
pi_2 = next_2;
|
612
|
-
next_2 = (polling_island
|
618
|
+
next_2 = (polling_island*)gpr_atm_acq_load(&pi_2->merged_to);
|
613
619
|
}
|
614
620
|
|
615
621
|
if (pi_1 == pi_2) {
|
@@ -625,9 +631,9 @@ static void polling_island_lock_pair(polling_island **p, polling_island **q) {
|
|
625
631
|
gpr_mu_lock(&pi_1->mu);
|
626
632
|
}
|
627
633
|
|
628
|
-
next_1 = (polling_island
|
629
|
-
next_2 = (polling_island
|
630
|
-
if (next_1 ==
|
634
|
+
next_1 = (polling_island*)gpr_atm_acq_load(&pi_1->merged_to);
|
635
|
+
next_2 = (polling_island*)gpr_atm_acq_load(&pi_2->merged_to);
|
636
|
+
if (next_1 == nullptr && next_2 == nullptr) {
|
631
637
|
break;
|
632
638
|
}
|
633
639
|
|
@@ -639,7 +645,7 @@ static void polling_island_lock_pair(polling_island **p, polling_island **q) {
|
|
639
645
|
*q = pi_2;
|
640
646
|
}
|
641
647
|
|
642
|
-
static void polling_island_unlock_pair(polling_island
|
648
|
+
static void polling_island_unlock_pair(polling_island* p, polling_island* q) {
|
643
649
|
if (p == q) {
|
644
650
|
gpr_mu_unlock(&p->mu);
|
645
651
|
} else {
|
@@ -648,16 +654,16 @@ static void polling_island_unlock_pair(polling_island *p, polling_island *q) {
|
|
648
654
|
}
|
649
655
|
}
|
650
656
|
|
651
|
-
static polling_island
|
652
|
-
polling_island
|
653
|
-
grpc_error
|
657
|
+
static polling_island* polling_island_merge(polling_island* p,
|
658
|
+
polling_island* q,
|
659
|
+
grpc_error** error) {
|
654
660
|
/* Get locks on both the polling islands */
|
655
661
|
polling_island_lock_pair(&p, &q);
|
656
662
|
|
657
663
|
if (p != q) {
|
658
664
|
/* Make sure that p points to the polling island with fewer fds than q */
|
659
665
|
if (p->fd_cnt > q->fd_cnt) {
|
660
|
-
GPR_SWAP(polling_island
|
666
|
+
GPR_SWAP(polling_island*, p, q);
|
661
667
|
}
|
662
668
|
|
663
669
|
/* Merge p with q i.e move all the fds from p (The one with fewer fds) to q
|
@@ -682,8 +688,8 @@ static polling_island *polling_island_merge(polling_island *p,
|
|
682
688
|
return q;
|
683
689
|
}
|
684
690
|
|
685
|
-
static grpc_error
|
686
|
-
grpc_error
|
691
|
+
static grpc_error* polling_island_global_init() {
|
692
|
+
grpc_error* error = GRPC_ERROR_NONE;
|
687
693
|
|
688
694
|
error = grpc_wakeup_fd_init(&polling_island_wakeup_fd);
|
689
695
|
if (error == GRPC_ERROR_NONE) {
|
@@ -719,15 +725,15 @@ static void polling_island_global_shutdown() {
|
|
719
725
|
* alarm 'epoch'). This wakeup_fd gives us something to alert on when such a
|
720
726
|
* case occurs. */
|
721
727
|
|
722
|
-
static grpc_fd
|
728
|
+
static grpc_fd* fd_freelist = nullptr;
|
723
729
|
static gpr_mu fd_freelist_mu;
|
724
730
|
|
725
731
|
#ifndef NDEBUG
|
726
732
|
#define REF_BY(fd, n, reason) ref_by(fd, n, reason, __FILE__, __LINE__)
|
727
733
|
#define UNREF_BY(fd, n, reason) unref_by(fd, n, reason, __FILE__, __LINE__)
|
728
|
-
static void ref_by(grpc_fd
|
734
|
+
static void ref_by(grpc_fd* fd, int n, const char* reason, const char* file,
|
729
735
|
int line) {
|
730
|
-
if (
|
736
|
+
if (grpc_trace_fd_refcount.enabled()) {
|
731
737
|
gpr_log(GPR_DEBUG,
|
732
738
|
"FD %d %p ref %d %" PRIdPTR " -> %" PRIdPTR " [%s; %s:%d]",
|
733
739
|
fd->fd, fd, n, gpr_atm_no_barrier_load(&fd->refst),
|
@@ -736,22 +742,22 @@ static void ref_by(grpc_fd *fd, int n, const char *reason, const char *file,
|
|
736
742
|
#else
|
737
743
|
#define REF_BY(fd, n, reason) ref_by(fd, n)
|
738
744
|
#define UNREF_BY(fd, n, reason) unref_by(fd, n)
|
739
|
-
static void ref_by(grpc_fd
|
745
|
+
static void ref_by(grpc_fd* fd, int n) {
|
740
746
|
#endif
|
741
747
|
GPR_ASSERT(gpr_atm_no_barrier_fetch_add(&fd->refst, n) > 0);
|
742
748
|
}
|
743
749
|
|
744
750
|
#ifndef NDEBUG
|
745
|
-
static void unref_by(grpc_fd
|
751
|
+
static void unref_by(grpc_fd* fd, int n, const char* reason, const char* file,
|
746
752
|
int line) {
|
747
|
-
if (
|
753
|
+
if (grpc_trace_fd_refcount.enabled()) {
|
748
754
|
gpr_log(GPR_DEBUG,
|
749
755
|
"FD %d %p unref %d %" PRIdPTR " -> %" PRIdPTR " [%s; %s:%d]",
|
750
756
|
fd->fd, fd, n, gpr_atm_no_barrier_load(&fd->refst),
|
751
757
|
gpr_atm_no_barrier_load(&fd->refst) - n, reason, file, line);
|
752
758
|
}
|
753
759
|
#else
|
754
|
-
static void unref_by(grpc_fd
|
760
|
+
static void unref_by(grpc_fd* fd, int n) {
|
755
761
|
#endif
|
756
762
|
gpr_atm old = gpr_atm_full_fetch_add(&fd->refst, -n);
|
757
763
|
if (old == n) {
|
@@ -761,8 +767,8 @@ static void unref_by(grpc_fd *fd, int n) {
|
|
761
767
|
fd_freelist = fd;
|
762
768
|
grpc_iomgr_unregister_object(&fd->iomgr_object);
|
763
769
|
|
764
|
-
|
765
|
-
|
770
|
+
fd->read_closure->DestroyEvent();
|
771
|
+
fd->write_closure->DestroyEvent();
|
766
772
|
|
767
773
|
gpr_mu_unlock(&fd_freelist_mu);
|
768
774
|
} else {
|
@@ -772,18 +778,18 @@ static void unref_by(grpc_fd *fd, int n) {
|
|
772
778
|
|
773
779
|
/* Increment refcount by two to avoid changing the orphan bit */
|
774
780
|
#ifndef NDEBUG
|
775
|
-
static void fd_ref(grpc_fd
|
781
|
+
static void fd_ref(grpc_fd* fd, const char* reason, const char* file,
|
776
782
|
int line) {
|
777
783
|
ref_by(fd, 2, reason, file, line);
|
778
784
|
}
|
779
785
|
|
780
|
-
static void fd_unref(grpc_fd
|
786
|
+
static void fd_unref(grpc_fd* fd, const char* reason, const char* file,
|
781
787
|
int line) {
|
782
788
|
unref_by(fd, 2, reason, file, line);
|
783
789
|
}
|
784
790
|
#else
|
785
|
-
static void fd_ref(grpc_fd
|
786
|
-
static void fd_unref(grpc_fd
|
791
|
+
static void fd_ref(grpc_fd* fd) { ref_by(fd, 2); }
|
792
|
+
static void fd_unref(grpc_fd* fd) { unref_by(fd, 2); }
|
787
793
|
#endif
|
788
794
|
|
789
795
|
static void fd_global_init(void) { gpr_mu_init(&fd_freelist_mu); }
|
@@ -791,8 +797,8 @@ static void fd_global_init(void) { gpr_mu_init(&fd_freelist_mu); }
|
|
791
797
|
static void fd_global_shutdown(void) {
|
792
798
|
gpr_mu_lock(&fd_freelist_mu);
|
793
799
|
gpr_mu_unlock(&fd_freelist_mu);
|
794
|
-
while (fd_freelist !=
|
795
|
-
grpc_fd
|
800
|
+
while (fd_freelist != nullptr) {
|
801
|
+
grpc_fd* fd = fd_freelist;
|
796
802
|
fd_freelist = fd_freelist->freelist_next;
|
797
803
|
gpr_mu_destroy(&fd->po.mu);
|
798
804
|
gpr_free(fd);
|
@@ -800,26 +806,28 @@ static void fd_global_shutdown(void) {
|
|
800
806
|
gpr_mu_destroy(&fd_freelist_mu);
|
801
807
|
}
|
802
808
|
|
803
|
-
static grpc_fd
|
804
|
-
grpc_fd
|
809
|
+
static grpc_fd* fd_create(int fd, const char* name) {
|
810
|
+
grpc_fd* new_fd = nullptr;
|
805
811
|
|
806
812
|
gpr_mu_lock(&fd_freelist_mu);
|
807
|
-
if (fd_freelist !=
|
813
|
+
if (fd_freelist != nullptr) {
|
808
814
|
new_fd = fd_freelist;
|
809
815
|
fd_freelist = fd_freelist->freelist_next;
|
810
816
|
}
|
811
817
|
gpr_mu_unlock(&fd_freelist_mu);
|
812
818
|
|
813
|
-
if (new_fd ==
|
814
|
-
new_fd = (grpc_fd
|
819
|
+
if (new_fd == nullptr) {
|
820
|
+
new_fd = (grpc_fd*)gpr_malloc(sizeof(grpc_fd));
|
815
821
|
gpr_mu_init(&new_fd->po.mu);
|
822
|
+
new_fd->read_closure.Init();
|
823
|
+
new_fd->write_closure.Init();
|
816
824
|
}
|
817
825
|
|
818
826
|
/* Note: It is not really needed to get the new_fd->po.mu lock here. If this
|
819
827
|
* is a newly created fd (or an fd we got from the freelist), no one else
|
820
828
|
* would be holding a lock to it anyway. */
|
821
829
|
gpr_mu_lock(&new_fd->po.mu);
|
822
|
-
new_fd->po.pi =
|
830
|
+
new_fd->po.pi = nullptr;
|
823
831
|
#ifndef NDEBUG
|
824
832
|
new_fd->po.obj_type = POLL_OBJ_FD;
|
825
833
|
#endif
|
@@ -827,23 +835,23 @@ static grpc_fd *fd_create(int fd, const char *name) {
|
|
827
835
|
gpr_atm_rel_store(&new_fd->refst, (gpr_atm)1);
|
828
836
|
new_fd->fd = fd;
|
829
837
|
new_fd->orphaned = false;
|
830
|
-
|
831
|
-
|
838
|
+
new_fd->read_closure->InitEvent();
|
839
|
+
new_fd->write_closure->InitEvent();
|
832
840
|
gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL);
|
833
841
|
|
834
|
-
new_fd->freelist_next =
|
835
|
-
new_fd->on_done_closure =
|
842
|
+
new_fd->freelist_next = nullptr;
|
843
|
+
new_fd->on_done_closure = nullptr;
|
836
844
|
|
837
845
|
gpr_mu_unlock(&new_fd->po.mu);
|
838
846
|
|
839
|
-
char
|
847
|
+
char* fd_name;
|
840
848
|
gpr_asprintf(&fd_name, "%s fd=%d", name, fd);
|
841
849
|
grpc_iomgr_register_object(&new_fd->iomgr_object, fd_name);
|
842
850
|
gpr_free(fd_name);
|
843
851
|
return new_fd;
|
844
852
|
}
|
845
853
|
|
846
|
-
static int fd_wrapped_fd(grpc_fd
|
854
|
+
static int fd_wrapped_fd(grpc_fd* fd) {
|
847
855
|
int ret_fd = -1;
|
848
856
|
gpr_mu_lock(&fd->po.mu);
|
849
857
|
if (!fd->orphaned) {
|
@@ -854,11 +862,11 @@ static int fd_wrapped_fd(grpc_fd *fd) {
|
|
854
862
|
return ret_fd;
|
855
863
|
}
|
856
864
|
|
857
|
-
static void fd_orphan(grpc_exec_ctx
|
858
|
-
grpc_closure
|
859
|
-
bool already_closed, const char
|
860
|
-
grpc_error
|
861
|
-
polling_island
|
865
|
+
static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
|
866
|
+
grpc_closure* on_done, int* release_fd,
|
867
|
+
bool already_closed, const char* reason) {
|
868
|
+
grpc_error* error = GRPC_ERROR_NONE;
|
869
|
+
polling_island* unref_pi = nullptr;
|
862
870
|
|
863
871
|
gpr_mu_lock(&fd->po.mu);
|
864
872
|
fd->on_done_closure = on_done;
|
@@ -875,18 +883,18 @@ static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
|
875
883
|
- Unlock the latest polling island
|
876
884
|
- Set fd->po.pi to NULL (but remove the ref on the polling island
|
877
885
|
before doing this.) */
|
878
|
-
if (fd->po.pi !=
|
879
|
-
polling_island
|
886
|
+
if (fd->po.pi != nullptr) {
|
887
|
+
polling_island* pi_latest = polling_island_lock(fd->po.pi);
|
880
888
|
polling_island_remove_fd_locked(pi_latest, fd, already_closed, &error);
|
881
889
|
gpr_mu_unlock(&pi_latest->mu);
|
882
890
|
|
883
891
|
unref_pi = fd->po.pi;
|
884
|
-
fd->po.pi =
|
892
|
+
fd->po.pi = nullptr;
|
885
893
|
}
|
886
894
|
|
887
895
|
/* If release_fd is not NULL, we should be relinquishing control of the file
|
888
896
|
descriptor fd->fd (but we still own the grpc_fd structure). */
|
889
|
-
if (release_fd !=
|
897
|
+
if (release_fd != nullptr) {
|
890
898
|
*release_fd = fd->fd;
|
891
899
|
} else {
|
892
900
|
close(fd->fd);
|
@@ -898,7 +906,7 @@ static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
|
898
906
|
|
899
907
|
gpr_mu_unlock(&fd->po.mu);
|
900
908
|
UNREF_BY(fd, 2, reason); /* Drop the reference */
|
901
|
-
if (unref_pi !=
|
909
|
+
if (unref_pi != nullptr) {
|
902
910
|
/* Unref stale polling island here, outside the fd lock above.
|
903
911
|
The polling island owns a workqueue which owns an fd, and unreffing
|
904
912
|
inside the lock can cause an eventual lock loop that makes TSAN very
|
@@ -906,40 +914,39 @@ static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
|
906
914
|
PI_UNREF(exec_ctx, unref_pi, "fd_orphan");
|
907
915
|
}
|
908
916
|
if (error != GRPC_ERROR_NONE) {
|
909
|
-
const char
|
917
|
+
const char* msg = grpc_error_string(error);
|
910
918
|
gpr_log(GPR_DEBUG, "fd_orphan: %s", msg);
|
911
919
|
}
|
912
920
|
GRPC_ERROR_UNREF(error);
|
913
921
|
}
|
914
922
|
|
915
|
-
static grpc_pollset
|
916
|
-
grpc_fd
|
923
|
+
static grpc_pollset* fd_get_read_notifier_pollset(grpc_exec_ctx* exec_ctx,
|
924
|
+
grpc_fd* fd) {
|
917
925
|
gpr_atm notifier = gpr_atm_acq_load(&fd->read_notifier_pollset);
|
918
|
-
return (grpc_pollset
|
926
|
+
return (grpc_pollset*)notifier;
|
919
927
|
}
|
920
928
|
|
921
|
-
static bool fd_is_shutdown(grpc_fd
|
922
|
-
return
|
929
|
+
static bool fd_is_shutdown(grpc_fd* fd) {
|
930
|
+
return fd->read_closure->IsShutdown();
|
923
931
|
}
|
924
932
|
|
925
933
|
/* Might be called multiple times */
|
926
|
-
static void fd_shutdown(grpc_exec_ctx
|
927
|
-
if (
|
928
|
-
GRPC_ERROR_REF(why))) {
|
934
|
+
static void fd_shutdown(grpc_exec_ctx* exec_ctx, grpc_fd* fd, grpc_error* why) {
|
935
|
+
if (fd->read_closure->SetShutdown(exec_ctx, GRPC_ERROR_REF(why))) {
|
929
936
|
shutdown(fd->fd, SHUT_RDWR);
|
930
|
-
|
937
|
+
fd->write_closure->SetShutdown(exec_ctx, GRPC_ERROR_REF(why));
|
931
938
|
}
|
932
939
|
GRPC_ERROR_UNREF(why);
|
933
940
|
}
|
934
941
|
|
935
|
-
static void fd_notify_on_read(grpc_exec_ctx
|
936
|
-
grpc_closure
|
937
|
-
|
942
|
+
static void fd_notify_on_read(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
|
943
|
+
grpc_closure* closure) {
|
944
|
+
fd->read_closure->NotifyOn(exec_ctx, closure);
|
938
945
|
}
|
939
946
|
|
940
|
-
static void fd_notify_on_write(grpc_exec_ctx
|
941
|
-
grpc_closure
|
942
|
-
|
947
|
+
static void fd_notify_on_write(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
|
948
|
+
grpc_closure* closure) {
|
949
|
+
fd->write_closure->NotifyOn(exec_ctx, closure);
|
943
950
|
}
|
944
951
|
|
945
952
|
/*******************************************************************************
|
@@ -959,7 +966,7 @@ static void sig_handler(int sig_num) {
|
|
959
966
|
static void poller_kick_init() { signal(grpc_wakeup_signal, sig_handler); }
|
960
967
|
|
961
968
|
/* Global state management */
|
962
|
-
static grpc_error
|
969
|
+
static grpc_error* pollset_global_init(void) {
|
963
970
|
gpr_tls_init(&g_current_thread_pollset);
|
964
971
|
gpr_tls_init(&g_current_thread_worker);
|
965
972
|
poller_kick_init();
|
@@ -971,14 +978,14 @@ static void pollset_global_shutdown(void) {
|
|
971
978
|
gpr_tls_destroy(&g_current_thread_worker);
|
972
979
|
}
|
973
980
|
|
974
|
-
static grpc_error
|
975
|
-
grpc_error
|
981
|
+
static grpc_error* pollset_worker_kick(grpc_pollset_worker* worker) {
|
982
|
+
grpc_error* err = GRPC_ERROR_NONE;
|
976
983
|
|
977
984
|
/* Kick the worker only if it was not already kicked */
|
978
985
|
if (gpr_atm_no_barrier_cas(&worker->is_kicked, (gpr_atm)0, (gpr_atm)1)) {
|
979
986
|
GRPC_POLLING_TRACE(
|
980
987
|
"pollset_worker_kick: Kicking worker: %p (thread id: %ld)",
|
981
|
-
(void
|
988
|
+
(void*)worker, (long int)worker->pt_id);
|
982
989
|
int err_num = pthread_kill(worker->pt_id, grpc_wakeup_signal);
|
983
990
|
if (err_num != 0) {
|
984
991
|
err = GRPC_OS_ERROR(err_num, "pthread_kill");
|
@@ -989,46 +996,46 @@ static grpc_error *pollset_worker_kick(grpc_pollset_worker *worker) {
|
|
989
996
|
|
990
997
|
/* Return 1 if the pollset has active threads in pollset_work (pollset must
|
991
998
|
* be locked) */
|
992
|
-
static int pollset_has_workers(grpc_pollset
|
999
|
+
static int pollset_has_workers(grpc_pollset* p) {
|
993
1000
|
return p->root_worker.next != &p->root_worker;
|
994
1001
|
}
|
995
1002
|
|
996
|
-
static void remove_worker(grpc_pollset
|
1003
|
+
static void remove_worker(grpc_pollset* p, grpc_pollset_worker* worker) {
|
997
1004
|
worker->prev->next = worker->next;
|
998
1005
|
worker->next->prev = worker->prev;
|
999
1006
|
}
|
1000
1007
|
|
1001
|
-
static grpc_pollset_worker
|
1008
|
+
static grpc_pollset_worker* pop_front_worker(grpc_pollset* p) {
|
1002
1009
|
if (pollset_has_workers(p)) {
|
1003
|
-
grpc_pollset_worker
|
1010
|
+
grpc_pollset_worker* w = p->root_worker.next;
|
1004
1011
|
remove_worker(p, w);
|
1005
1012
|
return w;
|
1006
1013
|
} else {
|
1007
|
-
return
|
1014
|
+
return nullptr;
|
1008
1015
|
}
|
1009
1016
|
}
|
1010
1017
|
|
1011
|
-
static void push_back_worker(grpc_pollset
|
1018
|
+
static void push_back_worker(grpc_pollset* p, grpc_pollset_worker* worker) {
|
1012
1019
|
worker->next = &p->root_worker;
|
1013
1020
|
worker->prev = worker->next->prev;
|
1014
1021
|
worker->prev->next = worker->next->prev = worker;
|
1015
1022
|
}
|
1016
1023
|
|
1017
|
-
static void push_front_worker(grpc_pollset
|
1024
|
+
static void push_front_worker(grpc_pollset* p, grpc_pollset_worker* worker) {
|
1018
1025
|
worker->prev = &p->root_worker;
|
1019
1026
|
worker->next = worker->prev->next;
|
1020
1027
|
worker->prev->next = worker->next->prev = worker;
|
1021
1028
|
}
|
1022
1029
|
|
1023
1030
|
/* p->mu must be held before calling this function */
|
1024
|
-
static grpc_error
|
1025
|
-
grpc_pollset_worker
|
1031
|
+
static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* p,
|
1032
|
+
grpc_pollset_worker* specific_worker) {
|
1026
1033
|
GPR_TIMER_BEGIN("pollset_kick", 0);
|
1027
|
-
grpc_error
|
1034
|
+
grpc_error* error = GRPC_ERROR_NONE;
|
1028
1035
|
GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
|
1029
|
-
const char
|
1030
|
-
grpc_pollset_worker
|
1031
|
-
if (worker !=
|
1036
|
+
const char* err_desc = "Kick Failure";
|
1037
|
+
grpc_pollset_worker* worker = specific_worker;
|
1038
|
+
if (worker != nullptr) {
|
1032
1039
|
if (worker == GRPC_POLLSET_KICK_BROADCAST) {
|
1033
1040
|
if (pollset_has_workers(p)) {
|
1034
1041
|
GPR_TIMER_BEGIN("pollset_kick.broadcast", 0);
|
@@ -1058,7 +1065,7 @@ static grpc_error *pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
|
|
1058
1065
|
|
1059
1066
|
GPR_TIMER_MARK("kick_anonymous", 0);
|
1060
1067
|
worker = pop_front_worker(p);
|
1061
|
-
if (worker !=
|
1068
|
+
if (worker != nullptr) {
|
1062
1069
|
GPR_TIMER_MARK("finally_kick", 0);
|
1063
1070
|
push_back_worker(p, worker);
|
1064
1071
|
append_error(&error, pollset_worker_kick(worker), err_desc);
|
@@ -1073,10 +1080,10 @@ static grpc_error *pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
|
|
1073
1080
|
return error;
|
1074
1081
|
}
|
1075
1082
|
|
1076
|
-
static void pollset_init(grpc_pollset
|
1083
|
+
static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
|
1077
1084
|
gpr_mu_init(&pollset->po.mu);
|
1078
1085
|
*mu = &pollset->po.mu;
|
1079
|
-
pollset->po.pi =
|
1086
|
+
pollset->po.pi = nullptr;
|
1080
1087
|
#ifndef NDEBUG
|
1081
1088
|
pollset->po.obj_type = POLL_OBJ_POLLSET;
|
1082
1089
|
#endif
|
@@ -1086,38 +1093,24 @@ static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
|
|
1086
1093
|
|
1087
1094
|
pollset->shutting_down = false;
|
1088
1095
|
pollset->finish_shutdown_called = false;
|
1089
|
-
pollset->shutdown_done =
|
1090
|
-
}
|
1091
|
-
|
1092
|
-
/* Convert a timespec to milliseconds:
|
1093
|
-
- Very small or negative poll times are clamped to zero to do a non-blocking
|
1094
|
-
poll (which becomes spin polling)
|
1095
|
-
- Other small values are rounded up to one millisecond
|
1096
|
-
- Longer than a millisecond polls are rounded up to the next nearest
|
1097
|
-
millisecond to avoid spinning
|
1098
|
-
- Infinite timeouts are converted to -1 */
|
1099
|
-
static int poll_deadline_to_millis_timeout(gpr_timespec deadline,
|
1100
|
-
gpr_timespec now) {
|
1101
|
-
gpr_timespec timeout;
|
1102
|
-
static const int64_t max_spin_polling_us = 10;
|
1103
|
-
if (gpr_time_cmp(deadline, gpr_inf_future(deadline.clock_type)) == 0) {
|
1104
|
-
return -1;
|
1105
|
-
}
|
1096
|
+
pollset->shutdown_done = nullptr;
|
1097
|
+
}
|
1106
1098
|
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1099
|
+
static int poll_deadline_to_millis_timeout(grpc_exec_ctx* exec_ctx,
|
1100
|
+
grpc_millis millis) {
|
1101
|
+
if (millis == GRPC_MILLIS_INF_FUTURE) return -1;
|
1102
|
+
grpc_millis delta = millis - grpc_exec_ctx_now(exec_ctx);
|
1103
|
+
if (delta > INT_MAX)
|
1104
|
+
return INT_MAX;
|
1105
|
+
else if (delta < 0)
|
1110
1106
|
return 0;
|
1111
|
-
|
1112
|
-
|
1113
|
-
int millis = gpr_time_to_millis(gpr_time_add(
|
1114
|
-
timeout, gpr_time_from_nanos(GPR_NS_PER_MS - 1, GPR_TIMESPAN)));
|
1115
|
-
return millis >= 1 ? millis : 1;
|
1107
|
+
else
|
1108
|
+
return (int)delta;
|
1116
1109
|
}
|
1117
1110
|
|
1118
|
-
static void fd_become_readable(grpc_exec_ctx
|
1119
|
-
grpc_pollset
|
1120
|
-
|
1111
|
+
static void fd_become_readable(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
|
1112
|
+
grpc_pollset* notifier) {
|
1113
|
+
fd->read_closure->SetReady(exec_ctx);
|
1121
1114
|
|
1122
1115
|
/* Note, it is possible that fd_become_readable might be called twice with
|
1123
1116
|
different 'notifier's when an fd becomes readable and it is in two epoll
|
@@ -1128,21 +1121,21 @@ static void fd_become_readable(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
|
1128
1121
|
gpr_atm_rel_store(&fd->read_notifier_pollset, (gpr_atm)notifier);
|
1129
1122
|
}
|
1130
1123
|
|
1131
|
-
static void fd_become_writable(grpc_exec_ctx
|
1132
|
-
|
1124
|
+
static void fd_become_writable(grpc_exec_ctx* exec_ctx, grpc_fd* fd) {
|
1125
|
+
fd->write_closure->SetReady(exec_ctx);
|
1133
1126
|
}
|
1134
1127
|
|
1135
|
-
static void pollset_release_polling_island(grpc_exec_ctx
|
1136
|
-
grpc_pollset
|
1137
|
-
const char
|
1138
|
-
if (ps->po.pi !=
|
1128
|
+
static void pollset_release_polling_island(grpc_exec_ctx* exec_ctx,
|
1129
|
+
grpc_pollset* ps,
|
1130
|
+
const char* reason) {
|
1131
|
+
if (ps->po.pi != nullptr) {
|
1139
1132
|
PI_UNREF(exec_ctx, ps->po.pi, reason);
|
1140
1133
|
}
|
1141
|
-
ps->po.pi =
|
1134
|
+
ps->po.pi = nullptr;
|
1142
1135
|
}
|
1143
1136
|
|
1144
|
-
static void finish_shutdown_locked(grpc_exec_ctx
|
1145
|
-
grpc_pollset
|
1137
|
+
static void finish_shutdown_locked(grpc_exec_ctx* exec_ctx,
|
1138
|
+
grpc_pollset* pollset) {
|
1146
1139
|
/* The pollset cannot have any workers if we are at this stage */
|
1147
1140
|
GPR_ASSERT(!pollset_has_workers(pollset));
|
1148
1141
|
|
@@ -1154,8 +1147,8 @@ static void finish_shutdown_locked(grpc_exec_ctx *exec_ctx,
|
|
1154
1147
|
}
|
1155
1148
|
|
1156
1149
|
/* pollset->po.mu lock must be held by the caller before calling this */
|
1157
|
-
static void pollset_shutdown(grpc_exec_ctx
|
1158
|
-
grpc_closure
|
1150
|
+
static void pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
|
1151
|
+
grpc_closure* closure) {
|
1159
1152
|
GPR_TIMER_BEGIN("pollset_shutdown", 0);
|
1160
1153
|
GPR_ASSERT(!pollset->shutting_down);
|
1161
1154
|
pollset->shutting_down = true;
|
@@ -1176,23 +1169,23 @@ static void pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
1176
1169
|
/* pollset_shutdown is guaranteed to be called before pollset_destroy. So other
|
1177
1170
|
* than destroying the mutexes, there is nothing special that needs to be done
|
1178
1171
|
* here */
|
1179
|
-
static void pollset_destroy(grpc_exec_ctx
|
1172
|
+
static void pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) {
|
1180
1173
|
GPR_ASSERT(!pollset_has_workers(pollset));
|
1181
1174
|
gpr_mu_destroy(&pollset->po.mu);
|
1182
1175
|
}
|
1183
1176
|
|
1184
1177
|
#define GRPC_EPOLL_MAX_EVENTS 100
|
1185
1178
|
/* Note: sig_mask contains the signal mask to use *during* epoll_wait() */
|
1186
|
-
static void pollset_work_and_unlock(grpc_exec_ctx
|
1187
|
-
grpc_pollset
|
1188
|
-
grpc_pollset_worker
|
1189
|
-
sigset_t
|
1179
|
+
static void pollset_work_and_unlock(grpc_exec_ctx* exec_ctx,
|
1180
|
+
grpc_pollset* pollset,
|
1181
|
+
grpc_pollset_worker* worker, int timeout_ms,
|
1182
|
+
sigset_t* sig_mask, grpc_error** error) {
|
1190
1183
|
struct epoll_event ep_ev[GRPC_EPOLL_MAX_EVENTS];
|
1191
1184
|
int epoll_fd = -1;
|
1192
1185
|
int ep_rv;
|
1193
|
-
polling_island
|
1194
|
-
char
|
1195
|
-
const char
|
1186
|
+
polling_island* pi = nullptr;
|
1187
|
+
char* err_msg;
|
1188
|
+
const char* err_desc = "pollset_work_and_unlock";
|
1196
1189
|
GPR_TIMER_BEGIN("pollset_work_and_unlock", 0);
|
1197
1190
|
|
1198
1191
|
/* We need to get the epoll_fd to wait on. The epoll_fd is in inside the
|
@@ -1205,16 +1198,16 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx,
|
|
1205
1198
|
right-away from epoll_wait() and pick up the latest polling_island the next
|
1206
1199
|
this function (i.e pollset_work_and_unlock()) is called */
|
1207
1200
|
|
1208
|
-
if (pollset->po.pi ==
|
1209
|
-
pollset->po.pi = polling_island_create(exec_ctx,
|
1210
|
-
if (pollset->po.pi ==
|
1201
|
+
if (pollset->po.pi == nullptr) {
|
1202
|
+
pollset->po.pi = polling_island_create(exec_ctx, nullptr, error);
|
1203
|
+
if (pollset->po.pi == nullptr) {
|
1211
1204
|
GPR_TIMER_END("pollset_work_and_unlock", 0);
|
1212
1205
|
return; /* Fatal error. We cannot continue */
|
1213
1206
|
}
|
1214
1207
|
|
1215
1208
|
PI_ADD_REF(pollset->po.pi, "ps");
|
1216
1209
|
GRPC_POLLING_TRACE("pollset_work: pollset: %p created new pi: %p",
|
1217
|
-
(void
|
1210
|
+
(void*)pollset, (void*)pollset->po.pi);
|
1218
1211
|
}
|
1219
1212
|
|
1220
1213
|
pi = polling_island_maybe_get_latest(pollset->po.pi);
|
@@ -1243,7 +1236,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx,
|
|
1243
1236
|
GRPC_STATS_INC_SYSCALL_POLL(exec_ctx);
|
1244
1237
|
ep_rv =
|
1245
1238
|
epoll_pwait(epoll_fd, ep_ev, GRPC_EPOLL_MAX_EVENTS, timeout_ms, sig_mask);
|
1246
|
-
|
1239
|
+
GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(exec_ctx);
|
1247
1240
|
if (ep_rv < 0) {
|
1248
1241
|
if (errno != EINTR) {
|
1249
1242
|
gpr_asprintf(&err_msg,
|
@@ -1254,7 +1247,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx,
|
|
1254
1247
|
/* We were interrupted. Save an interation by doing a zero timeout
|
1255
1248
|
epoll_wait to see if there are any other events of interest */
|
1256
1249
|
GRPC_POLLING_TRACE("pollset_work: pollset: %p, worker: %p received kick",
|
1257
|
-
(void
|
1250
|
+
(void*)pollset, (void*)worker);
|
1258
1251
|
ep_rv = epoll_wait(epoll_fd, ep_ev, GRPC_EPOLL_MAX_EVENTS, 0);
|
1259
1252
|
}
|
1260
1253
|
}
|
@@ -1265,18 +1258,18 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx,
|
|
1265
1258
|
#endif /* defined(GRPC_TSAN) */
|
1266
1259
|
|
1267
1260
|
for (int i = 0; i < ep_rv; ++i) {
|
1268
|
-
void
|
1261
|
+
void* data_ptr = ep_ev[i].data.ptr;
|
1269
1262
|
if (data_ptr == &polling_island_wakeup_fd) {
|
1270
1263
|
GRPC_POLLING_TRACE(
|
1271
1264
|
"pollset_work: pollset: %p, worker: %p polling island (epoll_fd: "
|
1272
1265
|
"%d) got merged",
|
1273
|
-
(void
|
1266
|
+
(void*)pollset, (void*)worker, epoll_fd);
|
1274
1267
|
/* This means that our polling island is merged with a different
|
1275
1268
|
island. We do not have to do anything here since the subsequent call
|
1276
1269
|
to the function pollset_work_and_unlock() will pick up the correct
|
1277
1270
|
epoll_fd */
|
1278
1271
|
} else {
|
1279
|
-
grpc_fd
|
1272
|
+
grpc_fd* fd = (grpc_fd*)data_ptr;
|
1280
1273
|
int cancel = ep_ev[i].events & (EPOLLERR | EPOLLHUP);
|
1281
1274
|
int read_ev = ep_ev[i].events & (EPOLLIN | EPOLLPRI);
|
1282
1275
|
int write_ev = ep_ev[i].events & EPOLLOUT;
|
@@ -1289,10 +1282,10 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx,
|
|
1289
1282
|
}
|
1290
1283
|
}
|
1291
1284
|
|
1292
|
-
g_current_thread_polling_island =
|
1285
|
+
g_current_thread_polling_island = nullptr;
|
1293
1286
|
gpr_atm_no_barrier_fetch_add(&pi->poller_count, -1);
|
1294
1287
|
|
1295
|
-
GPR_ASSERT(pi !=
|
1288
|
+
GPR_ASSERT(pi != nullptr);
|
1296
1289
|
|
1297
1290
|
/* Before leaving, release the extra ref we added to the polling island. It
|
1298
1291
|
is important to use "pi" here (i.e our old copy of pollset->po.pi
|
@@ -1308,17 +1301,17 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx,
|
|
1308
1301
|
The function pollset_work() may temporarily release the lock (pollset->po.mu)
|
1309
1302
|
during the course of its execution but it will always re-acquire the lock and
|
1310
1303
|
ensure that it is held by the time the function returns */
|
1311
|
-
static grpc_error
|
1312
|
-
grpc_pollset_worker
|
1313
|
-
|
1304
|
+
static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
|
1305
|
+
grpc_pollset_worker** worker_hdl,
|
1306
|
+
grpc_millis deadline) {
|
1314
1307
|
GPR_TIMER_BEGIN("pollset_work", 0);
|
1315
|
-
grpc_error
|
1316
|
-
int timeout_ms = poll_deadline_to_millis_timeout(
|
1308
|
+
grpc_error* error = GRPC_ERROR_NONE;
|
1309
|
+
int timeout_ms = poll_deadline_to_millis_timeout(exec_ctx, deadline);
|
1317
1310
|
|
1318
1311
|
sigset_t new_mask;
|
1319
1312
|
|
1320
1313
|
grpc_pollset_worker worker;
|
1321
|
-
worker.next = worker.prev =
|
1314
|
+
worker.next = worker.prev = nullptr;
|
1322
1315
|
worker.pt_id = pthread_self();
|
1323
1316
|
gpr_atm_no_barrier_store(&worker.is_kicked, (gpr_atm)0);
|
1324
1317
|
|
@@ -1400,7 +1393,7 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
1400
1393
|
gpr_mu_lock(&pollset->po.mu);
|
1401
1394
|
}
|
1402
1395
|
|
1403
|
-
if (worker_hdl) *worker_hdl =
|
1396
|
+
if (worker_hdl) *worker_hdl = nullptr;
|
1404
1397
|
|
1405
1398
|
gpr_tls_set(&g_current_thread_pollset, (intptr_t)0);
|
1406
1399
|
gpr_tls_set(&g_current_thread_worker, (intptr_t)0);
|
@@ -1411,8 +1404,8 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
1411
1404
|
return error;
|
1412
1405
|
}
|
1413
1406
|
|
1414
|
-
static void add_poll_object(grpc_exec_ctx
|
1415
|
-
poll_obj_type bag_type, poll_obj
|
1407
|
+
static void add_poll_object(grpc_exec_ctx* exec_ctx, poll_obj* bag,
|
1408
|
+
poll_obj_type bag_type, poll_obj* item,
|
1416
1409
|
poll_obj_type item_type) {
|
1417
1410
|
GPR_TIMER_BEGIN("add_poll_object", 0);
|
1418
1411
|
|
@@ -1421,8 +1414,8 @@ static void add_poll_object(grpc_exec_ctx *exec_ctx, poll_obj *bag,
|
|
1421
1414
|
GPR_ASSERT(bag->obj_type == bag_type);
|
1422
1415
|
#endif
|
1423
1416
|
|
1424
|
-
grpc_error
|
1425
|
-
polling_island
|
1417
|
+
grpc_error* error = GRPC_ERROR_NONE;
|
1418
|
+
polling_island* pi_new = nullptr;
|
1426
1419
|
|
1427
1420
|
gpr_mu_lock(&bag->mu);
|
1428
1421
|
gpr_mu_lock(&item->mu);
|
@@ -1449,7 +1442,7 @@ retry:
|
|
1449
1442
|
|
1450
1443
|
if (item->pi == bag->pi) {
|
1451
1444
|
pi_new = item->pi;
|
1452
|
-
if (pi_new ==
|
1445
|
+
if (pi_new == nullptr) {
|
1453
1446
|
/* GPR_ASSERT(item->pi == bag->pi == NULL) */
|
1454
1447
|
|
1455
1448
|
/* If we are adding an fd to a bag (i.e pollset or pollset_set), then
|
@@ -1469,12 +1462,12 @@ retry:
|
|
1469
1462
|
/* Need to reverify any assumptions made between the initial lock and
|
1470
1463
|
getting to this branch: if they've changed, we need to throw away our
|
1471
1464
|
work and figure things out again. */
|
1472
|
-
if (item->pi !=
|
1465
|
+
if (item->pi != nullptr) {
|
1473
1466
|
GRPC_POLLING_TRACE(
|
1474
1467
|
"add_poll_object: Raced creating new polling island. pi_new: %p "
|
1475
1468
|
"(fd: %d, %s: %p)",
|
1476
|
-
(void
|
1477
|
-
(void
|
1469
|
+
(void*)pi_new, FD_FROM_PO(item)->fd, poll_obj_string(bag_type),
|
1470
|
+
(void*)bag);
|
1478
1471
|
/* No need to lock 'pi_new' here since this is a new polling island
|
1479
1472
|
and no one has a reference to it yet */
|
1480
1473
|
polling_island_remove_all_fds_locked(pi_new, true, &error);
|
@@ -1486,27 +1479,26 @@ retry:
|
|
1486
1479
|
goto retry;
|
1487
1480
|
}
|
1488
1481
|
} else {
|
1489
|
-
pi_new = polling_island_create(exec_ctx,
|
1482
|
+
pi_new = polling_island_create(exec_ctx, nullptr, &error);
|
1490
1483
|
}
|
1491
1484
|
|
1492
1485
|
GRPC_POLLING_TRACE(
|
1493
1486
|
"add_poll_object: Created new polling island. pi_new: %p (%s: %p, "
|
1494
1487
|
"%s: %p)",
|
1495
|
-
(void
|
1496
|
-
poll_obj_string(bag_type), (void
|
1488
|
+
(void*)pi_new, poll_obj_string(item_type), (void*)item,
|
1489
|
+
poll_obj_string(bag_type), (void*)bag);
|
1497
1490
|
} else {
|
1498
1491
|
GRPC_POLLING_TRACE(
|
1499
1492
|
"add_poll_object: Same polling island. pi: %p (%s, %s)",
|
1500
|
-
(void
|
1501
|
-
poll_obj_string(bag_type));
|
1493
|
+
(void*)pi_new, poll_obj_string(item_type), poll_obj_string(bag_type));
|
1502
1494
|
}
|
1503
|
-
} else if (item->pi ==
|
1495
|
+
} else if (item->pi == nullptr) {
|
1504
1496
|
/* GPR_ASSERT(bag->pi != NULL) */
|
1505
1497
|
/* Make pi_new point to latest pi*/
|
1506
1498
|
pi_new = polling_island_lock(bag->pi);
|
1507
1499
|
|
1508
1500
|
if (item_type == POLL_OBJ_FD) {
|
1509
|
-
grpc_fd
|
1501
|
+
grpc_fd* fd = FD_FROM_PO(item);
|
1510
1502
|
polling_island_add_fds_locked(pi_new, &fd, 1, true, &error);
|
1511
1503
|
}
|
1512
1504
|
|
@@ -1514,9 +1506,9 @@ retry:
|
|
1514
1506
|
GRPC_POLLING_TRACE(
|
1515
1507
|
"add_poll_obj: item->pi was NULL. pi_new: %p (item(%s): %p, "
|
1516
1508
|
"bag(%s): %p)",
|
1517
|
-
(void
|
1518
|
-
poll_obj_string(bag_type), (void
|
1519
|
-
} else if (bag->pi ==
|
1509
|
+
(void*)pi_new, poll_obj_string(item_type), (void*)item,
|
1510
|
+
poll_obj_string(bag_type), (void*)bag);
|
1511
|
+
} else if (bag->pi == nullptr) {
|
1520
1512
|
/* GPR_ASSERT(item->pi != NULL) */
|
1521
1513
|
/* Make pi_new to point to latest pi */
|
1522
1514
|
pi_new = polling_island_lock(item->pi);
|
@@ -1524,15 +1516,15 @@ retry:
|
|
1524
1516
|
GRPC_POLLING_TRACE(
|
1525
1517
|
"add_poll_obj: bag->pi was NULL. pi_new: %p (item(%s): %p, "
|
1526
1518
|
"bag(%s): %p)",
|
1527
|
-
(void
|
1528
|
-
poll_obj_string(bag_type), (void
|
1519
|
+
(void*)pi_new, poll_obj_string(item_type), (void*)item,
|
1520
|
+
poll_obj_string(bag_type), (void*)bag);
|
1529
1521
|
} else {
|
1530
1522
|
pi_new = polling_island_merge(item->pi, bag->pi, &error);
|
1531
1523
|
GRPC_POLLING_TRACE(
|
1532
1524
|
"add_poll_obj: polling islands merged. pi_new: %p (item(%s): %p, "
|
1533
1525
|
"bag(%s): %p)",
|
1534
|
-
(void
|
1535
|
-
poll_obj_string(bag_type), (void
|
1526
|
+
(void*)pi_new, poll_obj_string(item_type), (void*)item,
|
1527
|
+
poll_obj_string(bag_type), (void*)bag);
|
1536
1528
|
}
|
1537
1529
|
|
1538
1530
|
/* At this point, pi_new is the polling island that both item->pi and bag->pi
|
@@ -1540,7 +1532,7 @@ retry:
|
|
1540
1532
|
|
1541
1533
|
if (item->pi != pi_new) {
|
1542
1534
|
PI_ADD_REF(pi_new, poll_obj_string(item_type));
|
1543
|
-
if (item->pi !=
|
1535
|
+
if (item->pi != nullptr) {
|
1544
1536
|
PI_UNREF(exec_ctx, item->pi, poll_obj_string(item_type));
|
1545
1537
|
}
|
1546
1538
|
item->pi = pi_new;
|
@@ -1548,7 +1540,7 @@ retry:
|
|
1548
1540
|
|
1549
1541
|
if (bag->pi != pi_new) {
|
1550
1542
|
PI_ADD_REF(pi_new, poll_obj_string(bag_type));
|
1551
|
-
if (bag->pi !=
|
1543
|
+
if (bag->pi != nullptr) {
|
1552
1544
|
PI_UNREF(exec_ctx, bag->pi, poll_obj_string(bag_type));
|
1553
1545
|
}
|
1554
1546
|
bag->pi = pi_new;
|
@@ -1561,8 +1553,8 @@ retry:
|
|
1561
1553
|
GPR_TIMER_END("add_poll_object", 0);
|
1562
1554
|
}
|
1563
1555
|
|
1564
|
-
static void pollset_add_fd(grpc_exec_ctx
|
1565
|
-
grpc_fd
|
1556
|
+
static void pollset_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
|
1557
|
+
grpc_fd* fd) {
|
1566
1558
|
add_poll_object(exec_ctx, &pollset->po, POLL_OBJ_POLLSET, &fd->po,
|
1567
1559
|
POLL_OBJ_FD);
|
1568
1560
|
}
|
@@ -1571,66 +1563,66 @@ static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
1571
1563
|
* Pollset-set Definitions
|
1572
1564
|
*/
|
1573
1565
|
|
1574
|
-
static grpc_pollset_set
|
1575
|
-
grpc_pollset_set
|
1566
|
+
static grpc_pollset_set* pollset_set_create(void) {
|
1567
|
+
grpc_pollset_set* pss = (grpc_pollset_set*)gpr_malloc(sizeof(*pss));
|
1576
1568
|
gpr_mu_init(&pss->po.mu);
|
1577
|
-
pss->po.pi =
|
1569
|
+
pss->po.pi = nullptr;
|
1578
1570
|
#ifndef NDEBUG
|
1579
1571
|
pss->po.obj_type = POLL_OBJ_POLLSET_SET;
|
1580
1572
|
#endif
|
1581
1573
|
return pss;
|
1582
1574
|
}
|
1583
1575
|
|
1584
|
-
static void pollset_set_destroy(grpc_exec_ctx
|
1585
|
-
grpc_pollset_set
|
1576
|
+
static void pollset_set_destroy(grpc_exec_ctx* exec_ctx,
|
1577
|
+
grpc_pollset_set* pss) {
|
1586
1578
|
gpr_mu_destroy(&pss->po.mu);
|
1587
1579
|
|
1588
|
-
if (pss->po.pi !=
|
1580
|
+
if (pss->po.pi != nullptr) {
|
1589
1581
|
PI_UNREF(exec_ctx, pss->po.pi, "pss_destroy");
|
1590
1582
|
}
|
1591
1583
|
|
1592
1584
|
gpr_free(pss);
|
1593
1585
|
}
|
1594
1586
|
|
1595
|
-
static void pollset_set_add_fd(grpc_exec_ctx
|
1596
|
-
grpc_fd
|
1587
|
+
static void pollset_set_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss,
|
1588
|
+
grpc_fd* fd) {
|
1597
1589
|
add_poll_object(exec_ctx, &pss->po, POLL_OBJ_POLLSET_SET, &fd->po,
|
1598
1590
|
POLL_OBJ_FD);
|
1599
1591
|
}
|
1600
1592
|
|
1601
|
-
static void pollset_set_del_fd(grpc_exec_ctx
|
1602
|
-
grpc_fd
|
1593
|
+
static void pollset_set_del_fd(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss,
|
1594
|
+
grpc_fd* fd) {
|
1603
1595
|
/* Nothing to do */
|
1604
1596
|
}
|
1605
1597
|
|
1606
|
-
static void pollset_set_add_pollset(grpc_exec_ctx
|
1607
|
-
grpc_pollset_set
|
1598
|
+
static void pollset_set_add_pollset(grpc_exec_ctx* exec_ctx,
|
1599
|
+
grpc_pollset_set* pss, grpc_pollset* ps) {
|
1608
1600
|
add_poll_object(exec_ctx, &pss->po, POLL_OBJ_POLLSET_SET, &ps->po,
|
1609
1601
|
POLL_OBJ_POLLSET);
|
1610
1602
|
}
|
1611
1603
|
|
1612
|
-
static void pollset_set_del_pollset(grpc_exec_ctx
|
1613
|
-
grpc_pollset_set
|
1604
|
+
static void pollset_set_del_pollset(grpc_exec_ctx* exec_ctx,
|
1605
|
+
grpc_pollset_set* pss, grpc_pollset* ps) {
|
1614
1606
|
/* Nothing to do */
|
1615
1607
|
}
|
1616
1608
|
|
1617
|
-
static void pollset_set_add_pollset_set(grpc_exec_ctx
|
1618
|
-
grpc_pollset_set
|
1619
|
-
grpc_pollset_set
|
1609
|
+
static void pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
|
1610
|
+
grpc_pollset_set* bag,
|
1611
|
+
grpc_pollset_set* item) {
|
1620
1612
|
add_poll_object(exec_ctx, &bag->po, POLL_OBJ_POLLSET_SET, &item->po,
|
1621
1613
|
POLL_OBJ_POLLSET_SET);
|
1622
1614
|
}
|
1623
1615
|
|
1624
|
-
static void pollset_set_del_pollset_set(grpc_exec_ctx
|
1625
|
-
grpc_pollset_set
|
1626
|
-
grpc_pollset_set
|
1616
|
+
static void pollset_set_del_pollset_set(grpc_exec_ctx* exec_ctx,
|
1617
|
+
grpc_pollset_set* bag,
|
1618
|
+
grpc_pollset_set* item) {
|
1627
1619
|
/* Nothing to do */
|
1628
1620
|
}
|
1629
1621
|
|
1630
1622
|
/* Test helper functions
|
1631
1623
|
* */
|
1632
|
-
void
|
1633
|
-
polling_island
|
1624
|
+
void* grpc_fd_get_polling_island(grpc_fd* fd) {
|
1625
|
+
polling_island* pi;
|
1634
1626
|
|
1635
1627
|
gpr_mu_lock(&fd->po.mu);
|
1636
1628
|
pi = fd->po.pi;
|
@@ -1639,8 +1631,8 @@ void *grpc_fd_get_polling_island(grpc_fd *fd) {
|
|
1639
1631
|
return pi;
|
1640
1632
|
}
|
1641
1633
|
|
1642
|
-
void
|
1643
|
-
polling_island
|
1634
|
+
void* grpc_pollset_get_polling_island(grpc_pollset* ps) {
|
1635
|
+
polling_island* pi;
|
1644
1636
|
|
1645
1637
|
gpr_mu_lock(&ps->po.mu);
|
1646
1638
|
pi = ps->po.pi;
|
@@ -1649,9 +1641,9 @@ void *grpc_pollset_get_polling_island(grpc_pollset *ps) {
|
|
1649
1641
|
return pi;
|
1650
1642
|
}
|
1651
1643
|
|
1652
|
-
bool grpc_are_polling_islands_equal(void
|
1653
|
-
polling_island
|
1654
|
-
polling_island
|
1644
|
+
bool grpc_are_polling_islands_equal(void* p, void* q) {
|
1645
|
+
polling_island* p1 = (polling_island*)p;
|
1646
|
+
polling_island* p2 = (polling_island*)q;
|
1655
1647
|
|
1656
1648
|
/* Note: polling_island_lock_pair() may change p1 and p2 to point to the
|
1657
1649
|
latest polling islands in their respective linked lists */
|
@@ -1717,38 +1709,43 @@ static bool is_epoll_available() {
|
|
1717
1709
|
return true;
|
1718
1710
|
}
|
1719
1711
|
|
1720
|
-
const grpc_event_engine_vtable
|
1712
|
+
const grpc_event_engine_vtable* grpc_init_epollsig_linux(
|
1721
1713
|
bool explicit_request) {
|
1722
1714
|
/* If use of signals is disabled, we cannot use epoll engine*/
|
1723
1715
|
if (is_grpc_wakeup_signal_initialized && grpc_wakeup_signal < 0) {
|
1724
|
-
|
1716
|
+
gpr_log(GPR_ERROR, "Skipping epollsig because use of signals is disabled.");
|
1717
|
+
return nullptr;
|
1725
1718
|
}
|
1726
1719
|
|
1727
1720
|
if (!grpc_has_wakeup_fd()) {
|
1728
|
-
|
1721
|
+
gpr_log(GPR_ERROR, "Skipping epollsig because of no wakeup fd.");
|
1722
|
+
return nullptr;
|
1729
1723
|
}
|
1730
1724
|
|
1731
1725
|
if (!is_epoll_available()) {
|
1732
|
-
|
1726
|
+
gpr_log(GPR_ERROR, "Skipping epollsig because epoll is unavailable.");
|
1727
|
+
return nullptr;
|
1733
1728
|
}
|
1734
1729
|
|
1735
1730
|
if (!is_grpc_wakeup_signal_initialized) {
|
1736
1731
|
if (explicit_request) {
|
1737
1732
|
grpc_use_signal(SIGRTMIN + 6);
|
1738
1733
|
} else {
|
1739
|
-
|
1734
|
+
gpr_log(GPR_ERROR,
|
1735
|
+
"Skipping epollsig because uninitialized wakeup signal.");
|
1736
|
+
return nullptr;
|
1740
1737
|
}
|
1741
1738
|
}
|
1742
1739
|
|
1743
1740
|
fd_global_init();
|
1744
1741
|
|
1745
1742
|
if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) {
|
1746
|
-
return
|
1743
|
+
return nullptr;
|
1747
1744
|
}
|
1748
1745
|
|
1749
1746
|
if (!GRPC_LOG_IF_ERROR("polling_island_global_init",
|
1750
1747
|
polling_island_global_init())) {
|
1751
|
-
return
|
1748
|
+
return nullptr;
|
1752
1749
|
}
|
1753
1750
|
|
1754
1751
|
return &vtable;
|
@@ -1756,11 +1753,13 @@ const grpc_event_engine_vtable *grpc_init_epollsig_linux(
|
|
1756
1753
|
|
1757
1754
|
#else /* defined(GRPC_LINUX_EPOLL) */
|
1758
1755
|
#if defined(GRPC_POSIX_SOCKET)
|
1759
|
-
#include "src/core/lib/iomgr/
|
1756
|
+
#include "src/core/lib/iomgr/ev_epollsig_linux.h"
|
1760
1757
|
/* If GRPC_LINUX_EPOLL is not defined, it means epoll is not available. Return
|
1761
1758
|
* NULL */
|
1762
|
-
const grpc_event_engine_vtable
|
1759
|
+
const grpc_event_engine_vtable* grpc_init_epollsig_linux(
|
1763
1760
|
bool explicit_request) {
|
1761
|
+
gpr_log(GPR_ERROR,
|
1762
|
+
"Skipping epollsig becuase GRPC_LINUX_EPOLL is not defined.");
|
1764
1763
|
return NULL;
|
1765
1764
|
}
|
1766
1765
|
#endif /* defined(GRPC_POSIX_SOCKET) */
|