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,12 +22,20 @@
|
|
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_epollsig_linux(bool explicit_request);
|
26
30
|
|
27
31
|
#ifdef GRPC_LINUX_EPOLL
|
28
|
-
void
|
29
|
-
void
|
30
|
-
bool grpc_are_polling_islands_equal(void
|
32
|
+
void* grpc_fd_get_polling_island(grpc_fd* fd);
|
33
|
+
void* grpc_pollset_get_polling_island(grpc_pollset* ps);
|
34
|
+
bool grpc_are_polling_islands_equal(void* p, void* q);
|
31
35
|
#endif /* defined(GRPC_LINUX_EPOLL) */
|
32
36
|
|
37
|
+
#ifdef __cplusplus
|
38
|
+
}
|
39
|
+
#endif
|
40
|
+
|
33
41
|
#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLLSIG_LINUX_H */
|
@@ -24,6 +24,7 @@
|
|
24
24
|
|
25
25
|
#include <assert.h>
|
26
26
|
#include <errno.h>
|
27
|
+
#include <limits.h>
|
27
28
|
#include <poll.h>
|
28
29
|
#include <string.h>
|
29
30
|
#include <sys/socket.h>
|
@@ -37,26 +38,24 @@
|
|
37
38
|
#include <grpc/support/useful.h>
|
38
39
|
|
39
40
|
#include "src/core/lib/debug/stats.h"
|
41
|
+
#include "src/core/lib/iomgr/block_annotate.h"
|
40
42
|
#include "src/core/lib/iomgr/iomgr_internal.h"
|
41
|
-
#include "src/core/lib/iomgr/timer.h"
|
42
43
|
#include "src/core/lib/iomgr/wakeup_fd_cv.h"
|
43
44
|
#include "src/core/lib/iomgr/wakeup_fd_posix.h"
|
44
45
|
#include "src/core/lib/profiling/timers.h"
|
45
|
-
#include "src/core/lib/support/block_annotate.h"
|
46
46
|
#include "src/core/lib/support/murmur_hash.h"
|
47
47
|
|
48
|
-
#define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker
|
48
|
+
#define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker*)1)
|
49
49
|
|
50
50
|
/*******************************************************************************
|
51
51
|
* FD declarations
|
52
52
|
*/
|
53
|
-
|
54
53
|
typedef struct grpc_fd_watcher {
|
55
|
-
struct grpc_fd_watcher
|
56
|
-
struct grpc_fd_watcher
|
57
|
-
grpc_pollset
|
58
|
-
grpc_pollset_worker
|
59
|
-
grpc_fd
|
54
|
+
struct grpc_fd_watcher* next;
|
55
|
+
struct grpc_fd_watcher* prev;
|
56
|
+
grpc_pollset* pollset;
|
57
|
+
grpc_pollset_worker* worker;
|
58
|
+
grpc_fd* fd;
|
60
59
|
} grpc_fd_watcher;
|
61
60
|
|
62
61
|
struct grpc_fd {
|
@@ -72,7 +71,7 @@ struct grpc_fd {
|
|
72
71
|
int shutdown;
|
73
72
|
int closed;
|
74
73
|
int released;
|
75
|
-
grpc_error
|
74
|
+
grpc_error* shutdown_error;
|
76
75
|
|
77
76
|
/* The watcher list.
|
78
77
|
|
@@ -97,18 +96,18 @@ struct grpc_fd {
|
|
97
96
|
the inactive pollers may be kicked out of their poll loops to take
|
98
97
|
that responsibility. */
|
99
98
|
grpc_fd_watcher inactive_watcher_root;
|
100
|
-
grpc_fd_watcher
|
101
|
-
grpc_fd_watcher
|
99
|
+
grpc_fd_watcher* read_watcher;
|
100
|
+
grpc_fd_watcher* write_watcher;
|
102
101
|
|
103
|
-
grpc_closure
|
104
|
-
grpc_closure
|
102
|
+
grpc_closure* read_closure;
|
103
|
+
grpc_closure* write_closure;
|
105
104
|
|
106
|
-
grpc_closure
|
105
|
+
grpc_closure* on_done_closure;
|
107
106
|
|
108
107
|
grpc_iomgr_object iomgr_object;
|
109
108
|
|
110
109
|
/* The pollset that last noticed and notified that the fd is readable */
|
111
|
-
grpc_pollset
|
110
|
+
grpc_pollset* read_notifier_pollset;
|
112
111
|
};
|
113
112
|
|
114
113
|
/* Begin polling on an fd.
|
@@ -122,35 +121,35 @@ struct grpc_fd {
|
|
122
121
|
Polling strategies that do not need to alter their behavior depending on the
|
123
122
|
fd's current interest (such as epoll) do not need to call this function.
|
124
123
|
MUST NOT be called with a pollset lock taken */
|
125
|
-
static uint32_t fd_begin_poll(grpc_fd
|
126
|
-
grpc_pollset_worker
|
127
|
-
uint32_t write_mask, grpc_fd_watcher
|
124
|
+
static uint32_t fd_begin_poll(grpc_fd* fd, grpc_pollset* pollset,
|
125
|
+
grpc_pollset_worker* worker, uint32_t read_mask,
|
126
|
+
uint32_t write_mask, grpc_fd_watcher* rec);
|
128
127
|
/* Complete polling previously started with fd_begin_poll
|
129
128
|
MUST NOT be called with a pollset lock taken
|
130
129
|
if got_read or got_write are 1, also does the become_{readable,writable} as
|
131
130
|
appropriate. */
|
132
|
-
static void fd_end_poll(grpc_exec_ctx
|
131
|
+
static void fd_end_poll(grpc_exec_ctx* exec_ctx, grpc_fd_watcher* rec,
|
133
132
|
int got_read, int got_write,
|
134
|
-
grpc_pollset
|
133
|
+
grpc_pollset* read_notifier_pollset);
|
135
134
|
|
136
135
|
/* Return 1 if this fd is orphaned, 0 otherwise */
|
137
|
-
static bool fd_is_orphaned(grpc_fd
|
136
|
+
static bool fd_is_orphaned(grpc_fd* fd);
|
138
137
|
|
139
138
|
#ifndef NDEBUG
|
140
|
-
static void fd_ref(grpc_fd
|
141
|
-
static void fd_unref(grpc_fd
|
139
|
+
static void fd_ref(grpc_fd* fd, const char* reason, const char* file, int line);
|
140
|
+
static void fd_unref(grpc_fd* fd, const char* reason, const char* file,
|
142
141
|
int line);
|
143
142
|
#define GRPC_FD_REF(fd, reason) fd_ref(fd, reason, __FILE__, __LINE__)
|
144
143
|
#define GRPC_FD_UNREF(fd, reason) fd_unref(fd, reason, __FILE__, __LINE__)
|
145
144
|
#else
|
146
|
-
static void fd_ref(grpc_fd
|
147
|
-
static void fd_unref(grpc_fd
|
145
|
+
static void fd_ref(grpc_fd* fd);
|
146
|
+
static void fd_unref(grpc_fd* fd);
|
148
147
|
#define GRPC_FD_REF(fd, reason) fd_ref(fd)
|
149
148
|
#define GRPC_FD_UNREF(fd, reason) fd_unref(fd)
|
150
149
|
#endif
|
151
150
|
|
152
|
-
#define CLOSURE_NOT_READY ((grpc_closure
|
153
|
-
#define CLOSURE_READY ((grpc_closure
|
151
|
+
#define CLOSURE_NOT_READY ((grpc_closure*)0)
|
152
|
+
#define CLOSURE_READY ((grpc_closure*)1)
|
154
153
|
|
155
154
|
/*******************************************************************************
|
156
155
|
* pollset declarations
|
@@ -158,15 +157,15 @@ static void fd_unref(grpc_fd *fd);
|
|
158
157
|
|
159
158
|
typedef struct grpc_cached_wakeup_fd {
|
160
159
|
grpc_wakeup_fd fd;
|
161
|
-
struct grpc_cached_wakeup_fd
|
160
|
+
struct grpc_cached_wakeup_fd* next;
|
162
161
|
} grpc_cached_wakeup_fd;
|
163
162
|
|
164
163
|
struct grpc_pollset_worker {
|
165
|
-
grpc_cached_wakeup_fd
|
164
|
+
grpc_cached_wakeup_fd* wakeup_fd;
|
166
165
|
int reevaluate_polling_on_wakeup;
|
167
166
|
int kicked_specifically;
|
168
|
-
struct grpc_pollset_worker
|
169
|
-
struct grpc_pollset_worker
|
167
|
+
struct grpc_pollset_worker* next;
|
168
|
+
struct grpc_pollset_worker* prev;
|
170
169
|
};
|
171
170
|
|
172
171
|
struct grpc_pollset {
|
@@ -175,23 +174,23 @@ struct grpc_pollset {
|
|
175
174
|
int shutting_down;
|
176
175
|
int called_shutdown;
|
177
176
|
int kicked_without_pollers;
|
178
|
-
grpc_closure
|
177
|
+
grpc_closure* shutdown_done;
|
179
178
|
grpc_closure_list idle_jobs;
|
180
179
|
int pollset_set_count;
|
181
180
|
/* all polled fds */
|
182
181
|
size_t fd_count;
|
183
182
|
size_t fd_capacity;
|
184
|
-
grpc_fd
|
183
|
+
grpc_fd** fds;
|
185
184
|
/* Local cache of eventfds for workers */
|
186
|
-
grpc_cached_wakeup_fd
|
185
|
+
grpc_cached_wakeup_fd* local_wakeup_cache;
|
187
186
|
};
|
188
187
|
|
189
188
|
/* Add an fd to a pollset */
|
190
|
-
static void pollset_add_fd(grpc_exec_ctx
|
191
|
-
struct grpc_fd
|
189
|
+
static void pollset_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
|
190
|
+
struct grpc_fd* fd);
|
192
191
|
|
193
|
-
static void pollset_set_add_fd(grpc_exec_ctx
|
194
|
-
grpc_pollset_set
|
192
|
+
static void pollset_set_add_fd(grpc_exec_ctx* exec_ctx,
|
193
|
+
grpc_pollset_set* pollset_set, grpc_fd* fd);
|
195
194
|
|
196
195
|
/* Convert a timespec to milliseconds:
|
197
196
|
- very small or negative poll times are clamped to zero to do a
|
@@ -200,8 +199,8 @@ static void pollset_set_add_fd(grpc_exec_ctx *exec_ctx,
|
|
200
199
|
- longer than a millisecond polls are rounded up to the next nearest
|
201
200
|
millisecond to avoid spinning
|
202
201
|
- infinite timeouts are converted to -1 */
|
203
|
-
static int poll_deadline_to_millis_timeout(
|
204
|
-
|
202
|
+
static int poll_deadline_to_millis_timeout(grpc_exec_ctx* exec_ctx,
|
203
|
+
grpc_millis deadline);
|
205
204
|
|
206
205
|
/* Allow kick to wakeup the currently polling worker */
|
207
206
|
#define GRPC_POLLSET_CAN_KICK_SELF 1
|
@@ -209,13 +208,13 @@ static int poll_deadline_to_millis_timeout(gpr_timespec deadline,
|
|
209
208
|
#define GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP 2
|
210
209
|
/* As per pollset_kick, with an extended set of flags (defined above)
|
211
210
|
-- mostly for fd_posix's use. */
|
212
|
-
static grpc_error
|
213
|
-
grpc_pollset_worker
|
211
|
+
static grpc_error* pollset_kick_ext(grpc_exec_ctx* exec_ctx, grpc_pollset* p,
|
212
|
+
grpc_pollset_worker* specific_worker,
|
214
213
|
uint32_t flags) GRPC_MUST_USE_RESULT;
|
215
214
|
|
216
215
|
/* Return 1 if the pollset has active threads in pollset_work (pollset must
|
217
216
|
* be locked) */
|
218
|
-
static bool pollset_has_workers(grpc_pollset
|
217
|
+
static bool pollset_has_workers(grpc_pollset* pollset);
|
219
218
|
|
220
219
|
/*******************************************************************************
|
221
220
|
* pollset_set definitions
|
@@ -226,15 +225,15 @@ struct grpc_pollset_set {
|
|
226
225
|
|
227
226
|
size_t pollset_count;
|
228
227
|
size_t pollset_capacity;
|
229
|
-
grpc_pollset
|
228
|
+
grpc_pollset** pollsets;
|
230
229
|
|
231
230
|
size_t pollset_set_count;
|
232
231
|
size_t pollset_set_capacity;
|
233
|
-
struct grpc_pollset_set
|
232
|
+
struct grpc_pollset_set** pollset_sets;
|
234
233
|
|
235
234
|
size_t fd_count;
|
236
235
|
size_t fd_capacity;
|
237
|
-
grpc_fd
|
236
|
+
grpc_fd** fds;
|
238
237
|
};
|
239
238
|
|
240
239
|
/*******************************************************************************
|
@@ -247,9 +246,9 @@ struct grpc_pollset_set {
|
|
247
246
|
|
248
247
|
typedef struct poll_result {
|
249
248
|
gpr_refcount refcount;
|
250
|
-
cv_node
|
249
|
+
cv_node* watchers;
|
251
250
|
int watchcount;
|
252
|
-
struct pollfd
|
251
|
+
struct pollfd* fds;
|
253
252
|
nfds_t nfds;
|
254
253
|
int retval;
|
255
254
|
int err;
|
@@ -259,11 +258,11 @@ typedef struct poll_result {
|
|
259
258
|
typedef struct poll_args {
|
260
259
|
gpr_cv trigger;
|
261
260
|
int trigger_set;
|
262
|
-
struct pollfd
|
261
|
+
struct pollfd* fds;
|
263
262
|
nfds_t nfds;
|
264
|
-
poll_result
|
265
|
-
struct poll_args
|
266
|
-
struct poll_args
|
263
|
+
poll_result* result;
|
264
|
+
struct poll_args* next;
|
265
|
+
struct poll_args* prev;
|
267
266
|
} poll_args;
|
268
267
|
|
269
268
|
// This is a 2-tiered cache, we mantain a hash table
|
@@ -271,8 +270,8 @@ typedef struct poll_args {
|
|
271
270
|
// of that call. We also maintain a freelist of inactive
|
272
271
|
// poll threads.
|
273
272
|
typedef struct poll_hash_table {
|
274
|
-
poll_args
|
275
|
-
poll_args
|
273
|
+
poll_args* free_pollers;
|
274
|
+
poll_args** active_pollers;
|
276
275
|
unsigned int size;
|
277
276
|
unsigned int count;
|
278
277
|
} poll_hash_table;
|
@@ -287,9 +286,9 @@ cv_fd_table g_cvfds;
|
|
287
286
|
#ifndef NDEBUG
|
288
287
|
#define REF_BY(fd, n, reason) ref_by(fd, n, reason, __FILE__, __LINE__)
|
289
288
|
#define UNREF_BY(fd, n, reason) unref_by(fd, n, reason, __FILE__, __LINE__)
|
290
|
-
static void ref_by(grpc_fd
|
289
|
+
static void ref_by(grpc_fd* fd, int n, const char* reason, const char* file,
|
291
290
|
int line) {
|
292
|
-
if (
|
291
|
+
if (grpc_trace_fd_refcount.enabled()) {
|
293
292
|
gpr_log(GPR_DEBUG,
|
294
293
|
"FD %d %p ref %d %" PRIdPTR " -> %" PRIdPTR " [%s; %s:%d]",
|
295
294
|
fd->fd, fd, n, gpr_atm_no_barrier_load(&fd->refst),
|
@@ -298,22 +297,22 @@ static void ref_by(grpc_fd *fd, int n, const char *reason, const char *file,
|
|
298
297
|
#else
|
299
298
|
#define REF_BY(fd, n, reason) ref_by(fd, n)
|
300
299
|
#define UNREF_BY(fd, n, reason) unref_by(fd, n)
|
301
|
-
static void ref_by(grpc_fd
|
300
|
+
static void ref_by(grpc_fd* fd, int n) {
|
302
301
|
#endif
|
303
302
|
GPR_ASSERT(gpr_atm_no_barrier_fetch_add(&fd->refst, n) > 0);
|
304
303
|
}
|
305
304
|
|
306
305
|
#ifndef NDEBUG
|
307
|
-
static void unref_by(grpc_fd
|
306
|
+
static void unref_by(grpc_fd* fd, int n, const char* reason, const char* file,
|
308
307
|
int line) {
|
309
|
-
if (
|
308
|
+
if (grpc_trace_fd_refcount.enabled()) {
|
310
309
|
gpr_log(GPR_DEBUG,
|
311
310
|
"FD %d %p unref %d %" PRIdPTR " -> %" PRIdPTR " [%s; %s:%d]",
|
312
311
|
fd->fd, fd, n, gpr_atm_no_barrier_load(&fd->refst),
|
313
312
|
gpr_atm_no_barrier_load(&fd->refst) - n, reason, file, line);
|
314
313
|
}
|
315
314
|
#else
|
316
|
-
static void unref_by(grpc_fd
|
315
|
+
static void unref_by(grpc_fd* fd, int n) {
|
317
316
|
#endif
|
318
317
|
gpr_atm old = gpr_atm_full_fetch_add(&fd->refst, -n);
|
319
318
|
if (old == n) {
|
@@ -326,8 +325,8 @@ static void unref_by(grpc_fd *fd, int n) {
|
|
326
325
|
}
|
327
326
|
}
|
328
327
|
|
329
|
-
static grpc_fd
|
330
|
-
grpc_fd
|
328
|
+
static grpc_fd* fd_create(int fd, const char* name) {
|
329
|
+
grpc_fd* r = (grpc_fd*)gpr_malloc(sizeof(*r));
|
331
330
|
gpr_mu_init(&r->mu);
|
332
331
|
gpr_atm_rel_store(&r->refst, 1);
|
333
332
|
r->shutdown = 0;
|
@@ -336,27 +335,27 @@ static grpc_fd *fd_create(int fd, const char *name) {
|
|
336
335
|
r->fd = fd;
|
337
336
|
r->inactive_watcher_root.next = r->inactive_watcher_root.prev =
|
338
337
|
&r->inactive_watcher_root;
|
339
|
-
r->read_watcher = r->write_watcher =
|
340
|
-
r->on_done_closure =
|
338
|
+
r->read_watcher = r->write_watcher = nullptr;
|
339
|
+
r->on_done_closure = nullptr;
|
341
340
|
r->closed = 0;
|
342
341
|
r->released = 0;
|
343
|
-
r->read_notifier_pollset =
|
342
|
+
r->read_notifier_pollset = nullptr;
|
344
343
|
|
345
|
-
char
|
344
|
+
char* name2;
|
346
345
|
gpr_asprintf(&name2, "%s fd=%d", name, fd);
|
347
346
|
grpc_iomgr_register_object(&r->iomgr_object, name2);
|
348
347
|
gpr_free(name2);
|
349
348
|
return r;
|
350
349
|
}
|
351
350
|
|
352
|
-
static bool fd_is_orphaned(grpc_fd
|
351
|
+
static bool fd_is_orphaned(grpc_fd* fd) {
|
353
352
|
return (gpr_atm_acq_load(&fd->refst) & 1) == 0;
|
354
353
|
}
|
355
354
|
|
356
355
|
/* Return the read-notifier pollset */
|
357
|
-
static grpc_pollset
|
358
|
-
grpc_fd
|
359
|
-
grpc_pollset
|
356
|
+
static grpc_pollset* fd_get_read_notifier_pollset(grpc_exec_ctx* exec_ctx,
|
357
|
+
grpc_fd* fd) {
|
358
|
+
grpc_pollset* notifier = nullptr;
|
360
359
|
|
361
360
|
gpr_mu_lock(&fd->mu);
|
362
361
|
notifier = fd->read_notifier_pollset;
|
@@ -365,19 +364,19 @@ static grpc_pollset *fd_get_read_notifier_pollset(grpc_exec_ctx *exec_ctx,
|
|
365
364
|
return notifier;
|
366
365
|
}
|
367
366
|
|
368
|
-
static grpc_error
|
369
|
-
grpc_fd_watcher
|
367
|
+
static grpc_error* pollset_kick_locked(grpc_exec_ctx* exec_ctx,
|
368
|
+
grpc_fd_watcher* watcher) {
|
370
369
|
gpr_mu_lock(&watcher->pollset->mu);
|
371
370
|
GPR_ASSERT(watcher->worker);
|
372
|
-
grpc_error
|
371
|
+
grpc_error* err =
|
373
372
|
pollset_kick_ext(exec_ctx, watcher->pollset, watcher->worker,
|
374
373
|
GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP);
|
375
374
|
gpr_mu_unlock(&watcher->pollset->mu);
|
376
375
|
return err;
|
377
376
|
}
|
378
377
|
|
379
|
-
static void maybe_wake_one_watcher_locked(grpc_exec_ctx
|
380
|
-
grpc_fd
|
378
|
+
static void maybe_wake_one_watcher_locked(grpc_exec_ctx* exec_ctx,
|
379
|
+
grpc_fd* fd) {
|
381
380
|
if (fd->inactive_watcher_root.next != &fd->inactive_watcher_root) {
|
382
381
|
pollset_kick_locked(exec_ctx, fd->inactive_watcher_root.next);
|
383
382
|
} else if (fd->read_watcher) {
|
@@ -387,8 +386,8 @@ static void maybe_wake_one_watcher_locked(grpc_exec_ctx *exec_ctx,
|
|
387
386
|
}
|
388
387
|
}
|
389
388
|
|
390
|
-
static void wake_all_watchers_locked(grpc_exec_ctx
|
391
|
-
grpc_fd_watcher
|
389
|
+
static void wake_all_watchers_locked(grpc_exec_ctx* exec_ctx, grpc_fd* fd) {
|
390
|
+
grpc_fd_watcher* watcher;
|
392
391
|
for (watcher = fd->inactive_watcher_root.next;
|
393
392
|
watcher != &fd->inactive_watcher_root; watcher = watcher->next) {
|
394
393
|
pollset_kick_locked(exec_ctx, watcher);
|
@@ -401,12 +400,12 @@ static void wake_all_watchers_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
|
|
401
400
|
}
|
402
401
|
}
|
403
402
|
|
404
|
-
static int has_watchers(grpc_fd
|
405
|
-
return fd->read_watcher !=
|
403
|
+
static int has_watchers(grpc_fd* fd) {
|
404
|
+
return fd->read_watcher != nullptr || fd->write_watcher != nullptr ||
|
406
405
|
fd->inactive_watcher_root.next != &fd->inactive_watcher_root;
|
407
406
|
}
|
408
407
|
|
409
|
-
static void close_fd_locked(grpc_exec_ctx
|
408
|
+
static void close_fd_locked(grpc_exec_ctx* exec_ctx, grpc_fd* fd) {
|
410
409
|
fd->closed = 1;
|
411
410
|
if (!fd->released) {
|
412
411
|
close(fd->fd);
|
@@ -414,7 +413,7 @@ static void close_fd_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
|
|
414
413
|
GRPC_CLOSURE_SCHED(exec_ctx, fd->on_done_closure, GRPC_ERROR_NONE);
|
415
414
|
}
|
416
415
|
|
417
|
-
static int fd_wrapped_fd(grpc_fd
|
416
|
+
static int fd_wrapped_fd(grpc_fd* fd) {
|
418
417
|
if (fd->released || fd->closed) {
|
419
418
|
return -1;
|
420
419
|
} else {
|
@@ -422,12 +421,12 @@ static int fd_wrapped_fd(grpc_fd *fd) {
|
|
422
421
|
}
|
423
422
|
}
|
424
423
|
|
425
|
-
static void fd_orphan(grpc_exec_ctx
|
426
|
-
grpc_closure
|
427
|
-
bool already_closed, const char
|
424
|
+
static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
|
425
|
+
grpc_closure* on_done, int* release_fd,
|
426
|
+
bool already_closed, const char* reason) {
|
428
427
|
fd->on_done_closure = on_done;
|
429
|
-
fd->released = release_fd !=
|
430
|
-
if (release_fd !=
|
428
|
+
fd->released = release_fd != nullptr;
|
429
|
+
if (release_fd != nullptr) {
|
431
430
|
*release_fd = fd->fd;
|
432
431
|
fd->released = true;
|
433
432
|
} else if (already_closed) {
|
@@ -446,22 +445,22 @@ static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
|
446
445
|
|
447
446
|
/* increment refcount by two to avoid changing the orphan bit */
|
448
447
|
#ifndef NDEBUG
|
449
|
-
static void fd_ref(grpc_fd
|
448
|
+
static void fd_ref(grpc_fd* fd, const char* reason, const char* file,
|
450
449
|
int line) {
|
451
450
|
ref_by(fd, 2, reason, file, line);
|
452
451
|
}
|
453
452
|
|
454
|
-
static void fd_unref(grpc_fd
|
453
|
+
static void fd_unref(grpc_fd* fd, const char* reason, const char* file,
|
455
454
|
int line) {
|
456
455
|
unref_by(fd, 2, reason, file, line);
|
457
456
|
}
|
458
457
|
#else
|
459
|
-
static void fd_ref(grpc_fd
|
458
|
+
static void fd_ref(grpc_fd* fd) { ref_by(fd, 2); }
|
460
459
|
|
461
|
-
static void fd_unref(grpc_fd
|
460
|
+
static void fd_unref(grpc_fd* fd) { unref_by(fd, 2); }
|
462
461
|
#endif
|
463
462
|
|
464
|
-
static grpc_error
|
463
|
+
static grpc_error* fd_shutdown_error(grpc_fd* fd) {
|
465
464
|
if (!fd->shutdown) {
|
466
465
|
return GRPC_ERROR_NONE;
|
467
466
|
} else {
|
@@ -470,8 +469,8 @@ static grpc_error *fd_shutdown_error(grpc_fd *fd) {
|
|
470
469
|
}
|
471
470
|
}
|
472
471
|
|
473
|
-
static void notify_on_locked(grpc_exec_ctx
|
474
|
-
grpc_closure
|
472
|
+
static void notify_on_locked(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
|
473
|
+
grpc_closure** st, grpc_closure* closure) {
|
475
474
|
if (fd->shutdown) {
|
476
475
|
GRPC_CLOSURE_SCHED(exec_ctx, closure,
|
477
476
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("FD shutdown"));
|
@@ -493,8 +492,8 @@ static void notify_on_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
|
493
492
|
}
|
494
493
|
|
495
494
|
/* returns 1 if state becomes not ready */
|
496
|
-
static int set_ready_locked(grpc_exec_ctx
|
497
|
-
grpc_closure
|
495
|
+
static int set_ready_locked(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
|
496
|
+
grpc_closure** st) {
|
498
497
|
if (*st == CLOSURE_READY) {
|
499
498
|
/* duplicate ready ==> ignore */
|
500
499
|
return 0;
|
@@ -511,11 +510,11 @@ static int set_ready_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
|
511
510
|
}
|
512
511
|
|
513
512
|
static void set_read_notifier_pollset_locked(
|
514
|
-
grpc_exec_ctx
|
513
|
+
grpc_exec_ctx* exec_ctx, grpc_fd* fd, grpc_pollset* read_notifier_pollset) {
|
515
514
|
fd->read_notifier_pollset = read_notifier_pollset;
|
516
515
|
}
|
517
516
|
|
518
|
-
static void fd_shutdown(grpc_exec_ctx
|
517
|
+
static void fd_shutdown(grpc_exec_ctx* exec_ctx, grpc_fd* fd, grpc_error* why) {
|
519
518
|
gpr_mu_lock(&fd->mu);
|
520
519
|
/* only shutdown once */
|
521
520
|
if (!fd->shutdown) {
|
@@ -531,32 +530,32 @@ static void fd_shutdown(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_error *why) {
|
|
531
530
|
gpr_mu_unlock(&fd->mu);
|
532
531
|
}
|
533
532
|
|
534
|
-
static bool fd_is_shutdown(grpc_fd
|
533
|
+
static bool fd_is_shutdown(grpc_fd* fd) {
|
535
534
|
gpr_mu_lock(&fd->mu);
|
536
535
|
bool r = fd->shutdown;
|
537
536
|
gpr_mu_unlock(&fd->mu);
|
538
537
|
return r;
|
539
538
|
}
|
540
539
|
|
541
|
-
static void fd_notify_on_read(grpc_exec_ctx
|
542
|
-
grpc_closure
|
540
|
+
static void fd_notify_on_read(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
|
541
|
+
grpc_closure* closure) {
|
543
542
|
gpr_mu_lock(&fd->mu);
|
544
543
|
notify_on_locked(exec_ctx, fd, &fd->read_closure, closure);
|
545
544
|
gpr_mu_unlock(&fd->mu);
|
546
545
|
}
|
547
546
|
|
548
|
-
static void fd_notify_on_write(grpc_exec_ctx
|
549
|
-
grpc_closure
|
547
|
+
static void fd_notify_on_write(grpc_exec_ctx* exec_ctx, grpc_fd* fd,
|
548
|
+
grpc_closure* closure) {
|
550
549
|
gpr_mu_lock(&fd->mu);
|
551
550
|
notify_on_locked(exec_ctx, fd, &fd->write_closure, closure);
|
552
551
|
gpr_mu_unlock(&fd->mu);
|
553
552
|
}
|
554
553
|
|
555
|
-
static uint32_t fd_begin_poll(grpc_fd
|
556
|
-
grpc_pollset_worker
|
557
|
-
uint32_t write_mask, grpc_fd_watcher
|
554
|
+
static uint32_t fd_begin_poll(grpc_fd* fd, grpc_pollset* pollset,
|
555
|
+
grpc_pollset_worker* worker, uint32_t read_mask,
|
556
|
+
uint32_t write_mask, grpc_fd_watcher* watcher) {
|
558
557
|
uint32_t mask = 0;
|
559
|
-
grpc_closure
|
558
|
+
grpc_closure* cur;
|
560
559
|
int requested;
|
561
560
|
/* keep track of pollers that have requested our events, in case they change
|
562
561
|
*/
|
@@ -566,9 +565,9 @@ static uint32_t fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
|
|
566
565
|
|
567
566
|
/* if we are shutdown, then don't add to the watcher set */
|
568
567
|
if (fd->shutdown) {
|
569
|
-
watcher->fd =
|
570
|
-
watcher->pollset =
|
571
|
-
watcher->worker =
|
568
|
+
watcher->fd = nullptr;
|
569
|
+
watcher->pollset = nullptr;
|
570
|
+
watcher->worker = nullptr;
|
572
571
|
gpr_mu_unlock(&fd->mu);
|
573
572
|
GRPC_FD_UNREF(fd, "poll");
|
574
573
|
return 0;
|
@@ -577,7 +576,7 @@ static uint32_t fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
|
|
577
576
|
/* if there is nobody polling for read, but we need to, then start doing so */
|
578
577
|
cur = fd->read_closure;
|
579
578
|
requested = cur != CLOSURE_READY;
|
580
|
-
if (read_mask && fd->read_watcher ==
|
579
|
+
if (read_mask && fd->read_watcher == nullptr && requested) {
|
581
580
|
fd->read_watcher = watcher;
|
582
581
|
mask |= read_mask;
|
583
582
|
}
|
@@ -585,12 +584,12 @@ static uint32_t fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
|
|
585
584
|
*/
|
586
585
|
cur = fd->write_closure;
|
587
586
|
requested = cur != CLOSURE_READY;
|
588
|
-
if (write_mask && fd->write_watcher ==
|
587
|
+
if (write_mask && fd->write_watcher == nullptr && requested) {
|
589
588
|
fd->write_watcher = watcher;
|
590
589
|
mask |= write_mask;
|
591
590
|
}
|
592
591
|
/* if not polling, remember this watcher in case we need someone to later */
|
593
|
-
if (mask == 0 && worker !=
|
592
|
+
if (mask == 0 && worker != nullptr) {
|
594
593
|
watcher->next = &fd->inactive_watcher_root;
|
595
594
|
watcher->prev = watcher->next->prev;
|
596
595
|
watcher->next->prev = watcher->prev->next = watcher;
|
@@ -603,14 +602,14 @@ static uint32_t fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
|
|
603
602
|
return mask;
|
604
603
|
}
|
605
604
|
|
606
|
-
static void fd_end_poll(grpc_exec_ctx
|
605
|
+
static void fd_end_poll(grpc_exec_ctx* exec_ctx, grpc_fd_watcher* watcher,
|
607
606
|
int got_read, int got_write,
|
608
|
-
grpc_pollset
|
607
|
+
grpc_pollset* read_notifier_pollset) {
|
609
608
|
int was_polling = 0;
|
610
609
|
int kick = 0;
|
611
|
-
grpc_fd
|
610
|
+
grpc_fd* fd = watcher->fd;
|
612
611
|
|
613
|
-
if (fd ==
|
612
|
+
if (fd == nullptr) {
|
614
613
|
return;
|
615
614
|
}
|
616
615
|
|
@@ -622,7 +621,7 @@ static void fd_end_poll(grpc_exec_ctx *exec_ctx, grpc_fd_watcher *watcher,
|
|
622
621
|
if (!got_read) {
|
623
622
|
kick = 1;
|
624
623
|
}
|
625
|
-
fd->read_watcher =
|
624
|
+
fd->read_watcher = nullptr;
|
626
625
|
}
|
627
626
|
if (watcher == fd->write_watcher) {
|
628
627
|
/* remove write watcher, kick if we still need a write */
|
@@ -630,9 +629,9 @@ static void fd_end_poll(grpc_exec_ctx *exec_ctx, grpc_fd_watcher *watcher,
|
|
630
629
|
if (!got_write) {
|
631
630
|
kick = 1;
|
632
631
|
}
|
633
|
-
fd->write_watcher =
|
632
|
+
fd->write_watcher = nullptr;
|
634
633
|
}
|
635
|
-
if (!was_polling && watcher->worker !=
|
634
|
+
if (!was_polling && watcher->worker != nullptr) {
|
636
635
|
/* remove from inactive list */
|
637
636
|
watcher->next->prev = watcher->prev;
|
638
637
|
watcher->prev->next = watcher->next;
|
@@ -641,7 +640,7 @@ static void fd_end_poll(grpc_exec_ctx *exec_ctx, grpc_fd_watcher *watcher,
|
|
641
640
|
if (set_ready_locked(exec_ctx, fd, &fd->read_closure)) {
|
642
641
|
kick = 1;
|
643
642
|
}
|
644
|
-
if (read_notifier_pollset !=
|
643
|
+
if (read_notifier_pollset != nullptr) {
|
645
644
|
set_read_notifier_pollset_locked(exec_ctx, fd, read_notifier_pollset);
|
646
645
|
}
|
647
646
|
}
|
@@ -668,46 +667,46 @@ static void fd_end_poll(grpc_exec_ctx *exec_ctx, grpc_fd_watcher *watcher,
|
|
668
667
|
GPR_TLS_DECL(g_current_thread_poller);
|
669
668
|
GPR_TLS_DECL(g_current_thread_worker);
|
670
669
|
|
671
|
-
static void remove_worker(grpc_pollset
|
670
|
+
static void remove_worker(grpc_pollset* p, grpc_pollset_worker* worker) {
|
672
671
|
worker->prev->next = worker->next;
|
673
672
|
worker->next->prev = worker->prev;
|
674
673
|
}
|
675
674
|
|
676
|
-
static bool pollset_has_workers(grpc_pollset
|
675
|
+
static bool pollset_has_workers(grpc_pollset* p) {
|
677
676
|
return p->root_worker.next != &p->root_worker;
|
678
677
|
}
|
679
678
|
|
680
|
-
static bool pollset_in_pollset_sets(grpc_pollset
|
679
|
+
static bool pollset_in_pollset_sets(grpc_pollset* p) {
|
681
680
|
return p->pollset_set_count;
|
682
681
|
}
|
683
682
|
|
684
|
-
static bool pollset_has_observers(grpc_pollset
|
683
|
+
static bool pollset_has_observers(grpc_pollset* p) {
|
685
684
|
return pollset_has_workers(p) || pollset_in_pollset_sets(p);
|
686
685
|
}
|
687
686
|
|
688
|
-
static grpc_pollset_worker
|
687
|
+
static grpc_pollset_worker* pop_front_worker(grpc_pollset* p) {
|
689
688
|
if (pollset_has_workers(p)) {
|
690
|
-
grpc_pollset_worker
|
689
|
+
grpc_pollset_worker* w = p->root_worker.next;
|
691
690
|
remove_worker(p, w);
|
692
691
|
return w;
|
693
692
|
} else {
|
694
|
-
return
|
693
|
+
return nullptr;
|
695
694
|
}
|
696
695
|
}
|
697
696
|
|
698
|
-
static void push_back_worker(grpc_pollset
|
697
|
+
static void push_back_worker(grpc_pollset* p, grpc_pollset_worker* worker) {
|
699
698
|
worker->next = &p->root_worker;
|
700
699
|
worker->prev = worker->next->prev;
|
701
700
|
worker->prev->next = worker->next->prev = worker;
|
702
701
|
}
|
703
702
|
|
704
|
-
static void push_front_worker(grpc_pollset
|
703
|
+
static void push_front_worker(grpc_pollset* p, grpc_pollset_worker* worker) {
|
705
704
|
worker->prev = &p->root_worker;
|
706
705
|
worker->next = worker->prev->next;
|
707
706
|
worker->prev->next = worker->next->prev = worker;
|
708
707
|
}
|
709
708
|
|
710
|
-
static void kick_append_error(grpc_error
|
709
|
+
static void kick_append_error(grpc_error** composite, grpc_error* error) {
|
711
710
|
if (error == GRPC_ERROR_NONE) return;
|
712
711
|
if (*composite == GRPC_ERROR_NONE) {
|
713
712
|
*composite = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Kick Failure");
|
@@ -715,15 +714,15 @@ static void kick_append_error(grpc_error **composite, grpc_error *error) {
|
|
715
714
|
*composite = grpc_error_add_child(*composite, error);
|
716
715
|
}
|
717
716
|
|
718
|
-
static grpc_error
|
719
|
-
grpc_pollset_worker
|
717
|
+
static grpc_error* pollset_kick_ext(grpc_exec_ctx* exec_ctx, grpc_pollset* p,
|
718
|
+
grpc_pollset_worker* specific_worker,
|
720
719
|
uint32_t flags) {
|
721
720
|
GPR_TIMER_BEGIN("pollset_kick_ext", 0);
|
722
|
-
grpc_error
|
721
|
+
grpc_error* error = GRPC_ERROR_NONE;
|
723
722
|
GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
|
724
723
|
|
725
724
|
/* pollset->mu already held */
|
726
|
-
if (specific_worker !=
|
725
|
+
if (specific_worker != nullptr) {
|
727
726
|
if (specific_worker == GRPC_POLLSET_KICK_BROADCAST) {
|
728
727
|
GPR_TIMER_BEGIN("pollset_kick_ext.broadcast", 0);
|
729
728
|
GPR_ASSERT((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) == 0);
|
@@ -757,7 +756,7 @@ static grpc_error *pollset_kick_ext(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
|
|
757
756
|
GPR_ASSERT((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) == 0);
|
758
757
|
GPR_TIMER_MARK("kick_anonymous", 0);
|
759
758
|
specific_worker = pop_front_worker(p);
|
760
|
-
if (specific_worker !=
|
759
|
+
if (specific_worker != nullptr) {
|
761
760
|
if (gpr_tls_get(&g_current_thread_worker) == (intptr_t)specific_worker) {
|
762
761
|
GPR_TIMER_MARK("kick_anonymous_not_self", 0);
|
763
762
|
push_back_worker(p, specific_worker);
|
@@ -766,10 +765,10 @@ static grpc_error *pollset_kick_ext(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
|
|
766
765
|
gpr_tls_get(&g_current_thread_worker) ==
|
767
766
|
(intptr_t)specific_worker) {
|
768
767
|
push_back_worker(p, specific_worker);
|
769
|
-
specific_worker =
|
768
|
+
specific_worker = nullptr;
|
770
769
|
}
|
771
770
|
}
|
772
|
-
if (specific_worker !=
|
771
|
+
if (specific_worker != nullptr) {
|
773
772
|
GPR_TIMER_MARK("finally_kick", 0);
|
774
773
|
push_back_worker(p, specific_worker);
|
775
774
|
kick_append_error(
|
@@ -786,14 +785,14 @@ static grpc_error *pollset_kick_ext(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
|
|
786
785
|
return error;
|
787
786
|
}
|
788
787
|
|
789
|
-
static grpc_error
|
790
|
-
grpc_pollset_worker
|
788
|
+
static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* p,
|
789
|
+
grpc_pollset_worker* specific_worker) {
|
791
790
|
return pollset_kick_ext(exec_ctx, p, specific_worker, 0);
|
792
791
|
}
|
793
792
|
|
794
793
|
/* global state management */
|
795
794
|
|
796
|
-
static grpc_error
|
795
|
+
static grpc_error* pollset_global_init(void) {
|
797
796
|
gpr_tls_init(&g_current_thread_poller);
|
798
797
|
gpr_tls_init(&g_current_thread_worker);
|
799
798
|
return GRPC_ERROR_NONE;
|
@@ -806,27 +805,27 @@ static void pollset_global_shutdown(void) {
|
|
806
805
|
|
807
806
|
/* main interface */
|
808
807
|
|
809
|
-
static void pollset_init(grpc_pollset
|
808
|
+
static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
|
810
809
|
gpr_mu_init(&pollset->mu);
|
811
810
|
*mu = &pollset->mu;
|
812
811
|
pollset->root_worker.next = pollset->root_worker.prev = &pollset->root_worker;
|
813
812
|
pollset->shutting_down = 0;
|
814
813
|
pollset->called_shutdown = 0;
|
815
814
|
pollset->kicked_without_pollers = 0;
|
816
|
-
pollset->idle_jobs.head = pollset->idle_jobs.tail =
|
817
|
-
pollset->local_wakeup_cache =
|
815
|
+
pollset->idle_jobs.head = pollset->idle_jobs.tail = nullptr;
|
816
|
+
pollset->local_wakeup_cache = nullptr;
|
818
817
|
pollset->kicked_without_pollers = 0;
|
819
818
|
pollset->fd_count = 0;
|
820
819
|
pollset->fd_capacity = 0;
|
821
|
-
pollset->fds =
|
820
|
+
pollset->fds = nullptr;
|
822
821
|
pollset->pollset_set_count = 0;
|
823
822
|
}
|
824
823
|
|
825
|
-
static void pollset_destroy(grpc_exec_ctx
|
824
|
+
static void pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) {
|
826
825
|
GPR_ASSERT(!pollset_has_workers(pollset));
|
827
826
|
GPR_ASSERT(pollset->idle_jobs.head == pollset->idle_jobs.tail);
|
828
827
|
while (pollset->local_wakeup_cache) {
|
829
|
-
grpc_cached_wakeup_fd
|
828
|
+
grpc_cached_wakeup_fd* next = pollset->local_wakeup_cache->next;
|
830
829
|
grpc_wakeup_fd_destroy(&pollset->local_wakeup_cache->fd);
|
831
830
|
gpr_free(pollset->local_wakeup_cache);
|
832
831
|
pollset->local_wakeup_cache = next;
|
@@ -835,8 +834,8 @@ static void pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
|
|
835
834
|
gpr_mu_destroy(&pollset->mu);
|
836
835
|
}
|
837
836
|
|
838
|
-
static void pollset_add_fd(grpc_exec_ctx
|
839
|
-
grpc_fd
|
837
|
+
static void pollset_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
|
838
|
+
grpc_fd* fd) {
|
840
839
|
gpr_mu_lock(&pollset->mu);
|
841
840
|
size_t i;
|
842
841
|
/* TODO(ctiller): this is O(num_fds^2); maybe switch to a hash set here */
|
@@ -846,17 +845,17 @@ static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
846
845
|
if (pollset->fd_count == pollset->fd_capacity) {
|
847
846
|
pollset->fd_capacity =
|
848
847
|
GPR_MAX(pollset->fd_capacity + 8, pollset->fd_count * 3 / 2);
|
849
|
-
pollset->fds = (grpc_fd
|
850
|
-
pollset->fds, sizeof(grpc_fd
|
848
|
+
pollset->fds = (grpc_fd**)gpr_realloc(
|
849
|
+
pollset->fds, sizeof(grpc_fd*) * pollset->fd_capacity);
|
851
850
|
}
|
852
851
|
pollset->fds[pollset->fd_count++] = fd;
|
853
852
|
GRPC_FD_REF(fd, "multipoller");
|
854
|
-
pollset_kick(exec_ctx, pollset,
|
853
|
+
pollset_kick(exec_ctx, pollset, nullptr);
|
855
854
|
exit:
|
856
855
|
gpr_mu_unlock(&pollset->mu);
|
857
856
|
}
|
858
857
|
|
859
|
-
static void finish_shutdown(grpc_exec_ctx
|
858
|
+
static void finish_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) {
|
860
859
|
GPR_ASSERT(grpc_closure_list_empty(pollset->idle_jobs));
|
861
860
|
size_t i;
|
862
861
|
for (i = 0; i < pollset->fd_count; i++) {
|
@@ -866,7 +865,7 @@ static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
|
|
866
865
|
GRPC_CLOSURE_SCHED(exec_ctx, pollset->shutdown_done, GRPC_ERROR_NONE);
|
867
866
|
}
|
868
867
|
|
869
|
-
static void work_combine_error(grpc_error
|
868
|
+
static void work_combine_error(grpc_error** composite, grpc_error* error) {
|
870
869
|
if (error == GRPC_ERROR_NONE) return;
|
871
870
|
if (*composite == GRPC_ERROR_NONE) {
|
872
871
|
*composite = GRPC_ERROR_CREATE_FROM_STATIC_STRING("pollset_work");
|
@@ -874,12 +873,12 @@ static void work_combine_error(grpc_error **composite, grpc_error *error) {
|
|
874
873
|
*composite = grpc_error_add_child(*composite, error);
|
875
874
|
}
|
876
875
|
|
877
|
-
static grpc_error
|
878
|
-
grpc_pollset_worker
|
879
|
-
|
876
|
+
static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
|
877
|
+
grpc_pollset_worker** worker_hdl,
|
878
|
+
grpc_millis deadline) {
|
880
879
|
grpc_pollset_worker worker;
|
881
880
|
if (worker_hdl) *worker_hdl = &worker;
|
882
|
-
grpc_error
|
881
|
+
grpc_error* error = GRPC_ERROR_NONE;
|
883
882
|
|
884
883
|
/* Avoid malloc for small number of elements. */
|
885
884
|
enum { inline_elements = 96 };
|
@@ -893,14 +892,14 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
893
892
|
int keep_polling = 0;
|
894
893
|
GPR_TIMER_BEGIN("pollset_work", 0);
|
895
894
|
/* this must happen before we (potentially) drop pollset->mu */
|
896
|
-
worker.next = worker.prev =
|
895
|
+
worker.next = worker.prev = nullptr;
|
897
896
|
worker.reevaluate_polling_on_wakeup = 0;
|
898
|
-
if (pollset->local_wakeup_cache !=
|
897
|
+
if (pollset->local_wakeup_cache != nullptr) {
|
899
898
|
worker.wakeup_fd = pollset->local_wakeup_cache;
|
900
899
|
pollset->local_wakeup_cache = worker.wakeup_fd->next;
|
901
900
|
} else {
|
902
901
|
worker.wakeup_fd =
|
903
|
-
(grpc_cached_wakeup_fd
|
902
|
+
(grpc_cached_wakeup_fd*)gpr_malloc(sizeof(*worker.wakeup_fd));
|
904
903
|
error = grpc_wakeup_fd_init(&worker.wakeup_fd->fd);
|
905
904
|
if (error != GRPC_ERROR_NONE) {
|
906
905
|
GRPC_LOG_IF_ERROR("pollset_work", GRPC_ERROR_REF(error));
|
@@ -942,10 +941,10 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
942
941
|
int r;
|
943
942
|
size_t i, fd_count;
|
944
943
|
nfds_t pfd_count;
|
945
|
-
grpc_fd_watcher
|
946
|
-
struct pollfd
|
944
|
+
grpc_fd_watcher* watchers;
|
945
|
+
struct pollfd* pfds;
|
947
946
|
|
948
|
-
timeout = poll_deadline_to_millis_timeout(
|
947
|
+
timeout = poll_deadline_to_millis_timeout(exec_ctx, deadline);
|
949
948
|
|
950
949
|
if (pollset->fd_count + 2 <= inline_elements) {
|
951
950
|
pfds = pollfd_space;
|
@@ -954,9 +953,9 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
954
953
|
/* Allocate one buffer to hold both pfds and watchers arrays */
|
955
954
|
const size_t pfd_size = sizeof(*pfds) * (pollset->fd_count + 2);
|
956
955
|
const size_t watch_size = sizeof(*watchers) * (pollset->fd_count + 2);
|
957
|
-
void
|
958
|
-
pfds = (struct pollfd
|
959
|
-
watchers = (grpc_fd_watcher
|
956
|
+
void* buf = gpr_malloc(pfd_size + watch_size);
|
957
|
+
pfds = (struct pollfd*)buf;
|
958
|
+
watchers = (grpc_fd_watcher*)(void*)((char*)buf + pfd_size);
|
960
959
|
}
|
961
960
|
|
962
961
|
fd_count = 0;
|
@@ -980,7 +979,7 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
980
979
|
gpr_mu_unlock(&pollset->mu);
|
981
980
|
|
982
981
|
for (i = 1; i < pfd_count; i++) {
|
983
|
-
grpc_fd
|
982
|
+
grpc_fd* fd = watchers[i].fd;
|
984
983
|
pfds[i].events = (short)fd_begin_poll(fd, pollset, &worker, POLLIN,
|
985
984
|
POLLOUT, &watchers[i]);
|
986
985
|
GRPC_FD_UNREF(fd, "multipoller_start");
|
@@ -991,9 +990,9 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
991
990
|
GRPC_SCHEDULING_START_BLOCKING_REGION;
|
992
991
|
GRPC_STATS_INC_SYSCALL_POLL(exec_ctx);
|
993
992
|
r = grpc_poll_function(pfds, pfd_count, timeout);
|
994
|
-
|
993
|
+
GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(exec_ctx);
|
995
994
|
|
996
|
-
if (
|
995
|
+
if (grpc_polling_trace.enabled()) {
|
997
996
|
gpr_log(GPR_DEBUG, "%p poll=%d", pollset, r);
|
998
997
|
}
|
999
998
|
|
@@ -1003,8 +1002,8 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
1003
1002
|
}
|
1004
1003
|
|
1005
1004
|
for (i = 1; i < pfd_count; i++) {
|
1006
|
-
if (watchers[i].fd ==
|
1007
|
-
fd_end_poll(exec_ctx, &watchers[i], 0, 0,
|
1005
|
+
if (watchers[i].fd == nullptr) {
|
1006
|
+
fd_end_poll(exec_ctx, &watchers[i], 0, 0, nullptr);
|
1008
1007
|
} else {
|
1009
1008
|
// Wake up all the file descriptors, if we have an invalid one
|
1010
1009
|
// we can identify it on the next pollset_work()
|
@@ -1013,21 +1012,21 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
1013
1012
|
}
|
1014
1013
|
} else if (r == 0) {
|
1015
1014
|
for (i = 1; i < pfd_count; i++) {
|
1016
|
-
fd_end_poll(exec_ctx, &watchers[i], 0, 0,
|
1015
|
+
fd_end_poll(exec_ctx, &watchers[i], 0, 0, nullptr);
|
1017
1016
|
}
|
1018
1017
|
} else {
|
1019
1018
|
if (pfds[0].revents & POLLIN_CHECK) {
|
1020
|
-
if (
|
1019
|
+
if (grpc_polling_trace.enabled()) {
|
1021
1020
|
gpr_log(GPR_DEBUG, "%p: got_wakeup", pollset);
|
1022
1021
|
}
|
1023
1022
|
work_combine_error(
|
1024
1023
|
&error, grpc_wakeup_fd_consume_wakeup(&worker.wakeup_fd->fd));
|
1025
1024
|
}
|
1026
1025
|
for (i = 1; i < pfd_count; i++) {
|
1027
|
-
if (watchers[i].fd ==
|
1028
|
-
fd_end_poll(exec_ctx, &watchers[i], 0, 0,
|
1026
|
+
if (watchers[i].fd == nullptr) {
|
1027
|
+
fd_end_poll(exec_ctx, &watchers[i], 0, 0, nullptr);
|
1029
1028
|
} else {
|
1030
|
-
if (
|
1029
|
+
if (grpc_polling_trace.enabled()) {
|
1031
1030
|
gpr_log(GPR_DEBUG, "%p got_event: %d r:%d w:%d [%d]", pollset,
|
1032
1031
|
pfds[i].fd, (pfds[i].revents & POLLIN_CHECK) != 0,
|
1033
1032
|
(pfds[i].revents & POLLOUT_CHECK) != 0, pfds[i].revents);
|
@@ -1068,13 +1067,10 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
1068
1067
|
if (queued_work || worker.kicked_specifically) {
|
1069
1068
|
/* If there's queued work on the list, then set the deadline to be
|
1070
1069
|
immediate so we get back out of the polling loop quickly */
|
1071
|
-
deadline =
|
1070
|
+
deadline = 0;
|
1072
1071
|
}
|
1073
1072
|
keep_polling = 1;
|
1074
1073
|
}
|
1075
|
-
if (keep_polling) {
|
1076
|
-
now = gpr_now(now.clock_type);
|
1077
|
-
}
|
1078
1074
|
}
|
1079
1075
|
gpr_tls_set(&g_current_thread_poller, 0);
|
1080
1076
|
if (added_worker) {
|
@@ -1087,7 +1083,7 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
1087
1083
|
/* check shutdown conditions */
|
1088
1084
|
if (pollset->shutting_down) {
|
1089
1085
|
if (pollset_has_workers(pollset)) {
|
1090
|
-
pollset_kick(exec_ctx, pollset,
|
1086
|
+
pollset_kick(exec_ctx, pollset, nullptr);
|
1091
1087
|
} else if (!pollset->called_shutdown && !pollset_has_observers(pollset)) {
|
1092
1088
|
pollset->called_shutdown = 1;
|
1093
1089
|
gpr_mu_unlock(&pollset->mu);
|
@@ -1105,14 +1101,14 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
1105
1101
|
gpr_mu_lock(&pollset->mu);
|
1106
1102
|
}
|
1107
1103
|
}
|
1108
|
-
if (worker_hdl) *worker_hdl =
|
1104
|
+
if (worker_hdl) *worker_hdl = nullptr;
|
1109
1105
|
GPR_TIMER_END("pollset_work", 0);
|
1110
1106
|
GRPC_LOG_IF_ERROR("pollset_work", GRPC_ERROR_REF(error));
|
1111
1107
|
return error;
|
1112
1108
|
}
|
1113
1109
|
|
1114
|
-
static void pollset_shutdown(grpc_exec_ctx
|
1115
|
-
grpc_closure
|
1110
|
+
static void pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset,
|
1111
|
+
grpc_closure* closure) {
|
1116
1112
|
GPR_ASSERT(!pollset->shutting_down);
|
1117
1113
|
pollset->shutting_down = 1;
|
1118
1114
|
pollset->shutdown_done = closure;
|
@@ -1126,43 +1122,36 @@ static void pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
1126
1122
|
}
|
1127
1123
|
}
|
1128
1124
|
|
1129
|
-
static int poll_deadline_to_millis_timeout(
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
max_spin_polling_us,
|
1138
|
-
GPR_TIMESPAN))) <= 0) {
|
1139
|
-
return 0;
|
1140
|
-
}
|
1141
|
-
timeout = gpr_time_sub(deadline, now);
|
1142
|
-
return gpr_time_to_millis(gpr_time_add(
|
1143
|
-
timeout, gpr_time_from_nanos(GPR_NS_PER_MS - 1, GPR_TIMESPAN)));
|
1125
|
+
static int poll_deadline_to_millis_timeout(grpc_exec_ctx* exec_ctx,
|
1126
|
+
grpc_millis deadline) {
|
1127
|
+
if (deadline == GRPC_MILLIS_INF_FUTURE) return -1;
|
1128
|
+
if (deadline == 0) return 0;
|
1129
|
+
grpc_millis n = deadline - grpc_exec_ctx_now(exec_ctx);
|
1130
|
+
if (n < 0) return 0;
|
1131
|
+
if (n > INT_MAX) return -1;
|
1132
|
+
return (int)n;
|
1144
1133
|
}
|
1145
1134
|
|
1146
1135
|
/*******************************************************************************
|
1147
1136
|
* pollset_set_posix.c
|
1148
1137
|
*/
|
1149
1138
|
|
1150
|
-
static grpc_pollset_set
|
1151
|
-
grpc_pollset_set
|
1152
|
-
(grpc_pollset_set
|
1139
|
+
static grpc_pollset_set* pollset_set_create(void) {
|
1140
|
+
grpc_pollset_set* pollset_set =
|
1141
|
+
(grpc_pollset_set*)gpr_zalloc(sizeof(*pollset_set));
|
1153
1142
|
gpr_mu_init(&pollset_set->mu);
|
1154
1143
|
return pollset_set;
|
1155
1144
|
}
|
1156
1145
|
|
1157
|
-
static void pollset_set_destroy(grpc_exec_ctx
|
1158
|
-
grpc_pollset_set
|
1146
|
+
static void pollset_set_destroy(grpc_exec_ctx* exec_ctx,
|
1147
|
+
grpc_pollset_set* pollset_set) {
|
1159
1148
|
size_t i;
|
1160
1149
|
gpr_mu_destroy(&pollset_set->mu);
|
1161
1150
|
for (i = 0; i < pollset_set->fd_count; i++) {
|
1162
1151
|
GRPC_FD_UNREF(pollset_set->fds[i], "pollset_set");
|
1163
1152
|
}
|
1164
1153
|
for (i = 0; i < pollset_set->pollset_count; i++) {
|
1165
|
-
grpc_pollset
|
1154
|
+
grpc_pollset* pollset = pollset_set->pollsets[i];
|
1166
1155
|
gpr_mu_lock(&pollset->mu);
|
1167
1156
|
pollset->pollset_set_count--;
|
1168
1157
|
/* check shutdown */
|
@@ -1181,9 +1170,9 @@ static void pollset_set_destroy(grpc_exec_ctx *exec_ctx,
|
|
1181
1170
|
gpr_free(pollset_set);
|
1182
1171
|
}
|
1183
1172
|
|
1184
|
-
static void pollset_set_add_pollset(grpc_exec_ctx
|
1185
|
-
grpc_pollset_set
|
1186
|
-
grpc_pollset
|
1173
|
+
static void pollset_set_add_pollset(grpc_exec_ctx* exec_ctx,
|
1174
|
+
grpc_pollset_set* pollset_set,
|
1175
|
+
grpc_pollset* pollset) {
|
1187
1176
|
size_t i, j;
|
1188
1177
|
gpr_mu_lock(&pollset->mu);
|
1189
1178
|
pollset->pollset_set_count++;
|
@@ -1192,7 +1181,7 @@ static void pollset_set_add_pollset(grpc_exec_ctx *exec_ctx,
|
|
1192
1181
|
if (pollset_set->pollset_count == pollset_set->pollset_capacity) {
|
1193
1182
|
pollset_set->pollset_capacity =
|
1194
1183
|
GPR_MAX(8, 2 * pollset_set->pollset_capacity);
|
1195
|
-
pollset_set->pollsets = (grpc_pollset
|
1184
|
+
pollset_set->pollsets = (grpc_pollset**)gpr_realloc(
|
1196
1185
|
pollset_set->pollsets,
|
1197
1186
|
pollset_set->pollset_capacity * sizeof(*pollset_set->pollsets));
|
1198
1187
|
}
|
@@ -1209,15 +1198,15 @@ static void pollset_set_add_pollset(grpc_exec_ctx *exec_ctx,
|
|
1209
1198
|
gpr_mu_unlock(&pollset_set->mu);
|
1210
1199
|
}
|
1211
1200
|
|
1212
|
-
static void pollset_set_del_pollset(grpc_exec_ctx
|
1213
|
-
grpc_pollset_set
|
1214
|
-
grpc_pollset
|
1201
|
+
static void pollset_set_del_pollset(grpc_exec_ctx* exec_ctx,
|
1202
|
+
grpc_pollset_set* pollset_set,
|
1203
|
+
grpc_pollset* pollset) {
|
1215
1204
|
size_t i;
|
1216
1205
|
gpr_mu_lock(&pollset_set->mu);
|
1217
1206
|
for (i = 0; i < pollset_set->pollset_count; i++) {
|
1218
1207
|
if (pollset_set->pollsets[i] == pollset) {
|
1219
1208
|
pollset_set->pollset_count--;
|
1220
|
-
GPR_SWAP(grpc_pollset
|
1209
|
+
GPR_SWAP(grpc_pollset*, pollset_set->pollsets[i],
|
1221
1210
|
pollset_set->pollsets[pollset_set->pollset_count]);
|
1222
1211
|
break;
|
1223
1212
|
}
|
@@ -1236,14 +1225,14 @@ static void pollset_set_del_pollset(grpc_exec_ctx *exec_ctx,
|
|
1236
1225
|
}
|
1237
1226
|
}
|
1238
1227
|
|
1239
|
-
static void pollset_set_add_pollset_set(grpc_exec_ctx
|
1240
|
-
grpc_pollset_set
|
1241
|
-
grpc_pollset_set
|
1228
|
+
static void pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx,
|
1229
|
+
grpc_pollset_set* bag,
|
1230
|
+
grpc_pollset_set* item) {
|
1242
1231
|
size_t i, j;
|
1243
1232
|
gpr_mu_lock(&bag->mu);
|
1244
1233
|
if (bag->pollset_set_count == bag->pollset_set_capacity) {
|
1245
1234
|
bag->pollset_set_capacity = GPR_MAX(8, 2 * bag->pollset_set_capacity);
|
1246
|
-
bag->pollset_sets = (grpc_pollset_set
|
1235
|
+
bag->pollset_sets = (grpc_pollset_set**)gpr_realloc(
|
1247
1236
|
bag->pollset_sets,
|
1248
1237
|
bag->pollset_set_capacity * sizeof(*bag->pollset_sets));
|
1249
1238
|
}
|
@@ -1260,15 +1249,15 @@ static void pollset_set_add_pollset_set(grpc_exec_ctx *exec_ctx,
|
|
1260
1249
|
gpr_mu_unlock(&bag->mu);
|
1261
1250
|
}
|
1262
1251
|
|
1263
|
-
static void pollset_set_del_pollset_set(grpc_exec_ctx
|
1264
|
-
grpc_pollset_set
|
1265
|
-
grpc_pollset_set
|
1252
|
+
static void pollset_set_del_pollset_set(grpc_exec_ctx* exec_ctx,
|
1253
|
+
grpc_pollset_set* bag,
|
1254
|
+
grpc_pollset_set* item) {
|
1266
1255
|
size_t i;
|
1267
1256
|
gpr_mu_lock(&bag->mu);
|
1268
1257
|
for (i = 0; i < bag->pollset_set_count; i++) {
|
1269
1258
|
if (bag->pollset_sets[i] == item) {
|
1270
1259
|
bag->pollset_set_count--;
|
1271
|
-
GPR_SWAP(grpc_pollset_set
|
1260
|
+
GPR_SWAP(grpc_pollset_set*, bag->pollset_sets[i],
|
1272
1261
|
bag->pollset_sets[bag->pollset_set_count]);
|
1273
1262
|
break;
|
1274
1263
|
}
|
@@ -1276,13 +1265,13 @@ static void pollset_set_del_pollset_set(grpc_exec_ctx *exec_ctx,
|
|
1276
1265
|
gpr_mu_unlock(&bag->mu);
|
1277
1266
|
}
|
1278
1267
|
|
1279
|
-
static void pollset_set_add_fd(grpc_exec_ctx
|
1280
|
-
grpc_pollset_set
|
1268
|
+
static void pollset_set_add_fd(grpc_exec_ctx* exec_ctx,
|
1269
|
+
grpc_pollset_set* pollset_set, grpc_fd* fd) {
|
1281
1270
|
size_t i;
|
1282
1271
|
gpr_mu_lock(&pollset_set->mu);
|
1283
1272
|
if (pollset_set->fd_count == pollset_set->fd_capacity) {
|
1284
1273
|
pollset_set->fd_capacity = GPR_MAX(8, 2 * pollset_set->fd_capacity);
|
1285
|
-
pollset_set->fds = (grpc_fd
|
1274
|
+
pollset_set->fds = (grpc_fd**)gpr_realloc(
|
1286
1275
|
pollset_set->fds, pollset_set->fd_capacity * sizeof(*pollset_set->fds));
|
1287
1276
|
}
|
1288
1277
|
GRPC_FD_REF(fd, "pollset_set");
|
@@ -1296,14 +1285,14 @@ static void pollset_set_add_fd(grpc_exec_ctx *exec_ctx,
|
|
1296
1285
|
gpr_mu_unlock(&pollset_set->mu);
|
1297
1286
|
}
|
1298
1287
|
|
1299
|
-
static void pollset_set_del_fd(grpc_exec_ctx
|
1300
|
-
grpc_pollset_set
|
1288
|
+
static void pollset_set_del_fd(grpc_exec_ctx* exec_ctx,
|
1289
|
+
grpc_pollset_set* pollset_set, grpc_fd* fd) {
|
1301
1290
|
size_t i;
|
1302
1291
|
gpr_mu_lock(&pollset_set->mu);
|
1303
1292
|
for (i = 0; i < pollset_set->fd_count; i++) {
|
1304
1293
|
if (pollset_set->fds[i] == fd) {
|
1305
1294
|
pollset_set->fd_count--;
|
1306
|
-
GPR_SWAP(grpc_fd
|
1295
|
+
GPR_SWAP(grpc_fd*, pollset_set->fds[i],
|
1307
1296
|
pollset_set->fds[pollset_set->fd_count]);
|
1308
1297
|
GRPC_FD_UNREF(fd, "pollset_set");
|
1309
1298
|
break;
|
@@ -1319,10 +1308,10 @@ static void pollset_set_del_fd(grpc_exec_ctx *exec_ctx,
|
|
1319
1308
|
* Condition Variable polling extensions
|
1320
1309
|
*/
|
1321
1310
|
|
1322
|
-
static void run_poll(void
|
1323
|
-
static void cache_poller_locked(poll_args
|
1311
|
+
static void run_poll(void* args);
|
1312
|
+
static void cache_poller_locked(poll_args* args);
|
1324
1313
|
|
1325
|
-
static void cache_insert_locked(poll_args
|
1314
|
+
static void cache_insert_locked(poll_args* args) {
|
1326
1315
|
uint32_t key = gpr_murmur_hash3(args->fds, args->nfds * sizeof(struct pollfd),
|
1327
1316
|
0xDEADBEEF);
|
1328
1317
|
key = key % poll_cache.size;
|
@@ -1330,18 +1319,18 @@ static void cache_insert_locked(poll_args *args) {
|
|
1330
1319
|
poll_cache.active_pollers[key]->prev = args;
|
1331
1320
|
}
|
1332
1321
|
args->next = poll_cache.active_pollers[key];
|
1333
|
-
args->prev =
|
1322
|
+
args->prev = nullptr;
|
1334
1323
|
poll_cache.active_pollers[key] = args;
|
1335
1324
|
poll_cache.count++;
|
1336
1325
|
}
|
1337
1326
|
|
1338
|
-
static void init_result(poll_args
|
1339
|
-
pargs->result = (poll_result
|
1327
|
+
static void init_result(poll_args* pargs) {
|
1328
|
+
pargs->result = (poll_result*)gpr_malloc(sizeof(poll_result));
|
1340
1329
|
gpr_ref_init(&pargs->result->refcount, 1);
|
1341
|
-
pargs->result->watchers =
|
1330
|
+
pargs->result->watchers = nullptr;
|
1342
1331
|
pargs->result->watchcount = 0;
|
1343
1332
|
pargs->result->fds =
|
1344
|
-
(struct pollfd
|
1333
|
+
(struct pollfd*)gpr_malloc(sizeof(struct pollfd) * pargs->nfds);
|
1345
1334
|
memcpy(pargs->result->fds, pargs->fds, sizeof(struct pollfd) * pargs->nfds);
|
1346
1335
|
pargs->result->nfds = pargs->nfds;
|
1347
1336
|
pargs->result->retval = 0;
|
@@ -1351,11 +1340,11 @@ static void init_result(poll_args *pargs) {
|
|
1351
1340
|
|
1352
1341
|
// Creates a poll_args object for a given arguments to poll().
|
1353
1342
|
// This object may return a poll_args in the cache.
|
1354
|
-
static poll_args
|
1343
|
+
static poll_args* get_poller_locked(struct pollfd* fds, nfds_t count) {
|
1355
1344
|
uint32_t key =
|
1356
1345
|
gpr_murmur_hash3(fds, count * sizeof(struct pollfd), 0xDEADBEEF);
|
1357
1346
|
key = key % poll_cache.size;
|
1358
|
-
poll_args
|
1347
|
+
poll_args* curr = poll_cache.active_pollers[key];
|
1359
1348
|
while (curr) {
|
1360
1349
|
if (curr->nfds == count &&
|
1361
1350
|
memcmp(curr->fds, fds, count * sizeof(struct pollfd)) == 0) {
|
@@ -1366,26 +1355,26 @@ static poll_args *get_poller_locked(struct pollfd *fds, nfds_t count) {
|
|
1366
1355
|
}
|
1367
1356
|
|
1368
1357
|
if (poll_cache.free_pollers) {
|
1369
|
-
poll_args
|
1358
|
+
poll_args* pargs = poll_cache.free_pollers;
|
1370
1359
|
poll_cache.free_pollers = pargs->next;
|
1371
1360
|
if (poll_cache.free_pollers) {
|
1372
|
-
poll_cache.free_pollers->prev =
|
1361
|
+
poll_cache.free_pollers->prev = nullptr;
|
1373
1362
|
}
|
1374
1363
|
pargs->fds = fds;
|
1375
1364
|
pargs->nfds = count;
|
1376
|
-
pargs->next =
|
1377
|
-
pargs->prev =
|
1365
|
+
pargs->next = nullptr;
|
1366
|
+
pargs->prev = nullptr;
|
1378
1367
|
init_result(pargs);
|
1379
1368
|
cache_poller_locked(pargs);
|
1380
1369
|
return pargs;
|
1381
1370
|
}
|
1382
1371
|
|
1383
|
-
poll_args
|
1372
|
+
poll_args* pargs = (poll_args*)gpr_malloc(sizeof(struct poll_args));
|
1384
1373
|
gpr_cv_init(&pargs->trigger);
|
1385
1374
|
pargs->fds = fds;
|
1386
1375
|
pargs->nfds = count;
|
1387
|
-
pargs->next =
|
1388
|
-
pargs->prev =
|
1376
|
+
pargs->next = nullptr;
|
1377
|
+
pargs->prev = nullptr;
|
1389
1378
|
pargs->trigger_set = 0;
|
1390
1379
|
init_result(pargs);
|
1391
1380
|
cache_poller_locked(pargs);
|
@@ -1397,7 +1386,7 @@ static poll_args *get_poller_locked(struct pollfd *fds, nfds_t count) {
|
|
1397
1386
|
return pargs;
|
1398
1387
|
}
|
1399
1388
|
|
1400
|
-
static void cache_delete_locked(poll_args
|
1389
|
+
static void cache_delete_locked(poll_args* args) {
|
1401
1390
|
if (!args->prev) {
|
1402
1391
|
uint32_t key = gpr_murmur_hash3(
|
1403
1392
|
args->fds, args->nfds * sizeof(struct pollfd), 0xDEADBEEF);
|
@@ -1416,25 +1405,25 @@ static void cache_delete_locked(poll_args *args) {
|
|
1416
1405
|
if (poll_cache.free_pollers) {
|
1417
1406
|
poll_cache.free_pollers->prev = args;
|
1418
1407
|
}
|
1419
|
-
args->prev =
|
1408
|
+
args->prev = nullptr;
|
1420
1409
|
args->next = poll_cache.free_pollers;
|
1421
1410
|
gpr_free(args->fds);
|
1422
1411
|
poll_cache.free_pollers = args;
|
1423
1412
|
}
|
1424
1413
|
|
1425
|
-
static void cache_poller_locked(poll_args
|
1414
|
+
static void cache_poller_locked(poll_args* args) {
|
1426
1415
|
if (poll_cache.count + 1 > poll_cache.size / 2) {
|
1427
|
-
poll_args
|
1416
|
+
poll_args** old_active_pollers = poll_cache.active_pollers;
|
1428
1417
|
poll_cache.size = poll_cache.size * 2;
|
1429
1418
|
poll_cache.count = 0;
|
1430
1419
|
poll_cache.active_pollers =
|
1431
|
-
(poll_args
|
1420
|
+
(poll_args**)gpr_malloc(sizeof(void*) * poll_cache.size);
|
1432
1421
|
for (unsigned int i = 0; i < poll_cache.size; i++) {
|
1433
|
-
poll_cache.active_pollers[i] =
|
1422
|
+
poll_cache.active_pollers[i] = nullptr;
|
1434
1423
|
}
|
1435
1424
|
for (unsigned int i = 0; i < poll_cache.size / 2; i++) {
|
1436
|
-
poll_args
|
1437
|
-
poll_args
|
1425
|
+
poll_args* curr = old_active_pollers[i];
|
1426
|
+
poll_args* next = nullptr;
|
1438
1427
|
while (curr) {
|
1439
1428
|
next = curr->next;
|
1440
1429
|
cache_insert_locked(curr);
|
@@ -1447,7 +1436,7 @@ static void cache_poller_locked(poll_args *args) {
|
|
1447
1436
|
cache_insert_locked(args);
|
1448
1437
|
}
|
1449
1438
|
|
1450
|
-
static void cache_destroy_locked(poll_args
|
1439
|
+
static void cache_destroy_locked(poll_args* args) {
|
1451
1440
|
if (args->next) {
|
1452
1441
|
args->next->prev = args->prev;
|
1453
1442
|
}
|
@@ -1461,7 +1450,7 @@ static void cache_destroy_locked(poll_args *args) {
|
|
1461
1450
|
gpr_free(args);
|
1462
1451
|
}
|
1463
1452
|
|
1464
|
-
static void decref_poll_result(poll_result
|
1453
|
+
static void decref_poll_result(poll_result* res) {
|
1465
1454
|
if (gpr_unref(&res->refcount)) {
|
1466
1455
|
GPR_ASSERT(!res->watchers);
|
1467
1456
|
gpr_free(res->fds);
|
@@ -1469,7 +1458,7 @@ static void decref_poll_result(poll_result *res) {
|
|
1469
1458
|
}
|
1470
1459
|
}
|
1471
1460
|
|
1472
|
-
void remove_cvn(cv_node
|
1461
|
+
void remove_cvn(cv_node** head, cv_node* target) {
|
1473
1462
|
if (target->next) {
|
1474
1463
|
target->next->prev = target->prev;
|
1475
1464
|
}
|
@@ -1484,17 +1473,17 @@ void remove_cvn(cv_node **head, cv_node *target) {
|
|
1484
1473
|
gpr_timespec thread_grace;
|
1485
1474
|
|
1486
1475
|
// Poll in a background thread
|
1487
|
-
static void run_poll(void
|
1488
|
-
poll_args
|
1476
|
+
static void run_poll(void* args) {
|
1477
|
+
poll_args* pargs = (poll_args*)args;
|
1489
1478
|
while (1) {
|
1490
|
-
poll_result
|
1479
|
+
poll_result* result = pargs->result;
|
1491
1480
|
int retval = g_cvfds.poll(result->fds, result->nfds, CV_POLL_PERIOD_MS);
|
1492
1481
|
gpr_mu_lock(&g_cvfds.mu);
|
1493
1482
|
if (retval != 0) {
|
1494
1483
|
result->completed = 1;
|
1495
1484
|
result->retval = retval;
|
1496
1485
|
result->err = errno;
|
1497
|
-
cv_node
|
1486
|
+
cv_node* watcher = result->watchers;
|
1498
1487
|
while (watcher) {
|
1499
1488
|
gpr_cv_signal(watcher->cv);
|
1500
1489
|
watcher = watcher->next;
|
@@ -1525,27 +1514,27 @@ static void run_poll(void *args) {
|
|
1525
1514
|
}
|
1526
1515
|
|
1527
1516
|
// This function overrides poll() to handle condition variable wakeup fds
|
1528
|
-
static int cvfd_poll(struct pollfd
|
1517
|
+
static int cvfd_poll(struct pollfd* fds, nfds_t nfds, int timeout) {
|
1529
1518
|
unsigned int i;
|
1530
1519
|
int res, idx;
|
1531
|
-
cv_node
|
1520
|
+
cv_node* pollcv;
|
1532
1521
|
int skip_poll = 0;
|
1533
1522
|
nfds_t nsockfds = 0;
|
1534
|
-
poll_result
|
1523
|
+
poll_result* result = nullptr;
|
1535
1524
|
gpr_mu_lock(&g_cvfds.mu);
|
1536
|
-
pollcv = (cv_node
|
1537
|
-
pollcv->next =
|
1525
|
+
pollcv = (cv_node*)gpr_malloc(sizeof(cv_node));
|
1526
|
+
pollcv->next = nullptr;
|
1538
1527
|
gpr_cv pollcv_cv;
|
1539
1528
|
gpr_cv_init(&pollcv_cv);
|
1540
1529
|
pollcv->cv = &pollcv_cv;
|
1541
|
-
cv_node
|
1530
|
+
cv_node* fd_cvs = (cv_node*)gpr_malloc(nfds * sizeof(cv_node));
|
1542
1531
|
|
1543
1532
|
for (i = 0; i < nfds; i++) {
|
1544
1533
|
fds[i].revents = 0;
|
1545
1534
|
if (fds[i].fd < 0 && (fds[i].events & POLLIN)) {
|
1546
1535
|
idx = GRPC_FD_TO_IDX(fds[i].fd);
|
1547
1536
|
fd_cvs[i].cv = &pollcv_cv;
|
1548
|
-
fd_cvs[i].prev =
|
1537
|
+
fd_cvs[i].prev = nullptr;
|
1549
1538
|
fd_cvs[i].next = g_cvfds.cvfds[idx].cvs;
|
1550
1539
|
if (g_cvfds.cvfds[idx].cvs) {
|
1551
1540
|
g_cvfds.cvfds[idx].cvs->prev = &(fd_cvs[i]);
|
@@ -1570,8 +1559,8 @@ static int cvfd_poll(struct pollfd *fds, nfds_t nfds, int timeout) {
|
|
1570
1559
|
|
1571
1560
|
res = 0;
|
1572
1561
|
if (!skip_poll && nsockfds > 0) {
|
1573
|
-
struct pollfd
|
1574
|
-
(struct pollfd
|
1562
|
+
struct pollfd* pollfds =
|
1563
|
+
(struct pollfd*)gpr_malloc(sizeof(struct pollfd) * nsockfds);
|
1575
1564
|
idx = 0;
|
1576
1565
|
for (i = 0; i < nfds; i++) {
|
1577
1566
|
if (fds[i].fd >= 0) {
|
@@ -1581,10 +1570,10 @@ static int cvfd_poll(struct pollfd *fds, nfds_t nfds, int timeout) {
|
|
1581
1570
|
idx++;
|
1582
1571
|
}
|
1583
1572
|
}
|
1584
|
-
poll_args
|
1573
|
+
poll_args* pargs = get_poller_locked(pollfds, nsockfds);
|
1585
1574
|
result = pargs->result;
|
1586
1575
|
pollcv->next = result->watchers;
|
1587
|
-
pollcv->prev =
|
1576
|
+
pollcv->prev = nullptr;
|
1588
1577
|
if (result->watchers) {
|
1589
1578
|
result->watchers->prev = pollcv;
|
1590
1579
|
}
|
@@ -1634,13 +1623,12 @@ static void global_cv_fd_table_init() {
|
|
1634
1623
|
gpr_cv_init(&g_cvfds.shutdown_cv);
|
1635
1624
|
gpr_ref_init(&g_cvfds.pollcount, 1);
|
1636
1625
|
g_cvfds.size = CV_DEFAULT_TABLE_SIZE;
|
1637
|
-
g_cvfds.cvfds =
|
1638
|
-
|
1639
|
-
g_cvfds.free_fds = NULL;
|
1626
|
+
g_cvfds.cvfds = (fd_node*)gpr_malloc(sizeof(fd_node) * CV_DEFAULT_TABLE_SIZE);
|
1627
|
+
g_cvfds.free_fds = nullptr;
|
1640
1628
|
thread_grace = gpr_time_from_millis(POLLCV_THREAD_GRACE_MS, GPR_TIMESPAN);
|
1641
1629
|
for (int i = 0; i < CV_DEFAULT_TABLE_SIZE; i++) {
|
1642
1630
|
g_cvfds.cvfds[i].is_set = 0;
|
1643
|
-
g_cvfds.cvfds[i].cvs =
|
1631
|
+
g_cvfds.cvfds[i].cvs = nullptr;
|
1644
1632
|
g_cvfds.cvfds[i].next_free = g_cvfds.free_fds;
|
1645
1633
|
g_cvfds.free_fds = &g_cvfds.cvfds[i];
|
1646
1634
|
}
|
@@ -1651,10 +1639,10 @@ static void global_cv_fd_table_init() {
|
|
1651
1639
|
// Initialize the cache
|
1652
1640
|
poll_cache.size = 32;
|
1653
1641
|
poll_cache.count = 0;
|
1654
|
-
poll_cache.free_pollers =
|
1655
|
-
poll_cache.active_pollers = (poll_args
|
1642
|
+
poll_cache.free_pollers = nullptr;
|
1643
|
+
poll_cache.active_pollers = (poll_args**)gpr_malloc(sizeof(void*) * 32);
|
1656
1644
|
for (unsigned int i = 0; i < poll_cache.size; i++) {
|
1657
|
-
poll_cache.active_pollers[i] =
|
1645
|
+
poll_cache.active_pollers[i] = nullptr;
|
1658
1646
|
}
|
1659
1647
|
|
1660
1648
|
gpr_mu_unlock(&g_cvfds.mu);
|
@@ -1722,23 +1710,24 @@ static const grpc_event_engine_vtable vtable = {
|
|
1722
1710
|
shutdown_engine,
|
1723
1711
|
};
|
1724
1712
|
|
1725
|
-
const grpc_event_engine_vtable
|
1713
|
+
const grpc_event_engine_vtable* grpc_init_poll_posix(bool explicit_request) {
|
1726
1714
|
if (!grpc_has_wakeup_fd()) {
|
1727
|
-
|
1715
|
+
gpr_log(GPR_ERROR, "Skipping poll because of no wakeup fd.");
|
1716
|
+
return nullptr;
|
1728
1717
|
}
|
1729
1718
|
if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) {
|
1730
|
-
return
|
1719
|
+
return nullptr;
|
1731
1720
|
}
|
1732
1721
|
return &vtable;
|
1733
1722
|
}
|
1734
1723
|
|
1735
|
-
const grpc_event_engine_vtable
|
1724
|
+
const grpc_event_engine_vtable* grpc_init_poll_cv_posix(bool explicit_request) {
|
1736
1725
|
global_cv_fd_table_init();
|
1737
1726
|
grpc_enable_cv_wakeup_fds(1);
|
1738
1727
|
if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) {
|
1739
1728
|
global_cv_fd_table_shutdown();
|
1740
1729
|
grpc_enable_cv_wakeup_fds(0);
|
1741
|
-
return
|
1730
|
+
return nullptr;
|
1742
1731
|
}
|
1743
1732
|
return &vtable;
|
1744
1733
|
}
|