grpc 1.10.0 → 1.11.0.pre2
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 +2098 -501
- data/include/grpc/byte_buffer.h +2 -0
- data/include/grpc/byte_buffer_reader.h +2 -0
- data/include/grpc/census.h +2 -0
- data/include/grpc/fork.h +2 -0
- data/include/grpc/grpc.h +10 -0
- data/include/grpc/grpc_cronet.h +2 -0
- data/include/grpc/grpc_posix.h +2 -1
- data/include/grpc/grpc_security.h +21 -0
- data/include/grpc/grpc_security_constants.h +1 -0
- data/include/grpc/impl/codegen/byte_buffer.h +2 -0
- data/include/grpc/impl/codegen/grpc_types.h +24 -0
- data/include/grpc/impl/codegen/slice.h +1 -1
- data/include/grpc/impl/codegen/sync.h +1 -0
- data/include/grpc/impl/codegen/sync_custom.h +2 -0
- data/include/grpc/impl/codegen/sync_generic.h +2 -0
- data/include/grpc/impl/codegen/sync_posix.h +2 -0
- data/include/grpc/impl/codegen/sync_windows.h +2 -0
- data/include/grpc/slice.h +2 -0
- data/include/grpc/slice_buffer.h +2 -0
- data/include/grpc/status.h +2 -0
- data/include/grpc/support/alloc.h +2 -2
- data/include/grpc/support/atm.h +2 -0
- data/include/grpc/support/atm_gcc_atomic.h +2 -0
- data/include/grpc/support/atm_gcc_sync.h +2 -0
- data/include/grpc/support/atm_windows.h +2 -0
- data/include/grpc/support/log.h +1 -1
- data/include/grpc/support/sync.h +2 -0
- data/include/grpc/support/sync_custom.h +2 -0
- data/include/grpc/support/sync_generic.h +2 -0
- data/include/grpc/support/sync_posix.h +2 -0
- data/include/grpc/support/sync_windows.h +2 -0
- data/include/grpc/support/time.h +2 -0
- data/src/boringssl/err_data.c +444 -438
- data/src/core/ext/census/grpc_context.cc +2 -0
- data/src/core/ext/filters/client_channel/backup_poller.cc +13 -8
- data/src/core/ext/filters/client_channel/backup_poller.h +3 -2
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +2 -0
- data/src/core/ext/filters/client_channel/client_channel.cc +1988 -433
- data/src/core/ext/filters/client_channel/client_channel.h +2 -0
- data/src/core/ext/filters/client_channel/client_channel_factory.cc +2 -0
- data/src/core/ext/filters/client_channel/client_channel_factory.h +2 -0
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +2 -27
- data/src/core/ext/filters/client_channel/connector.cc +2 -0
- data/src/core/ext/filters/client_channel/connector.h +2 -0
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +2 -0
- data/src/core/ext/filters/client_channel/http_proxy.cc +2 -0
- data/src/core/ext/filters/client_channel/lb_policy.cc +2 -0
- data/src/core/ext/filters/client_channel/lb_policy.h +2 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +2 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +2 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +96 -78
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +9 -17
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +70 -62
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +2 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +2 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +2 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +2 -0
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +4 -2
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +4 -2
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc +2 -0
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +2 -0
- data/src/core/ext/filters/client_channel/lb_policy_factory.cc +3 -1
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +2 -1
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +2 -0
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +2 -1
- data/src/core/ext/filters/client_channel/method_params.cc +178 -0
- data/src/core/ext/filters/client_channel/method_params.h +74 -0
- data/src/core/ext/filters/client_channel/parse_address.cc +17 -13
- data/src/core/ext/filters/client_channel/parse_address.h +2 -0
- data/src/core/ext/filters/client_channel/proxy_mapper.cc +2 -0
- data/src/core/ext/filters/client_channel/proxy_mapper.h +2 -0
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.cc +2 -0
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +2 -0
- data/src/core/ext/filters/client_channel/resolver.cc +2 -0
- data/src/core/ext/filters/client_channel/resolver.h +6 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +24 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +2 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +1 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +55 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +8 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +1 -0
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +30 -3
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +7 -0
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +2 -1
- data/src/core/ext/filters/client_channel/resolver_factory.h +2 -0
- data/src/core/ext/filters/client_channel/resolver_registry.cc +2 -0
- data/src/core/ext/filters/client_channel/resolver_registry.h +2 -0
- data/src/core/ext/filters/client_channel/retry_throttle.cc +102 -120
- data/src/core/ext/filters/client_channel/retry_throttle.h +52 -25
- data/src/core/ext/filters/client_channel/subchannel.cc +14 -4
- data/src/core/ext/filters/client_channel/subchannel.h +10 -1
- data/src/core/ext/filters/client_channel/subchannel_index.cc +2 -0
- data/src/core/ext/filters/client_channel/subchannel_index.h +2 -0
- data/src/core/ext/filters/client_channel/uri_parser.cc +2 -1
- data/src/core/ext/filters/client_channel/uri_parser.h +2 -1
- data/src/core/ext/filters/deadline/deadline_filter.cc +2 -1
- data/src/core/ext/filters/deadline/deadline_filter.h +2 -0
- data/src/core/ext/filters/http/client/http_client_filter.cc +27 -25
- data/src/core/ext/filters/http/client/http_client_filter.h +2 -0
- data/src/core/ext/filters/http/client_authority_filter.cc +156 -0
- data/src/core/ext/filters/http/client_authority_filter.h +34 -0
- data/src/core/ext/filters/http/http_filters_plugin.cc +2 -0
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +21 -22
- data/src/core/ext/filters/http/message_compress/message_compress_filter.h +2 -0
- data/src/core/ext/filters/http/server/http_server_filter.cc +11 -8
- data/src/core/ext/filters/http/server/http_server_filter.h +2 -0
- data/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc +2 -0
- data/src/core/ext/filters/load_reporting/server_load_reporting_filter.h +2 -0
- data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h +2 -0
- data/src/core/ext/filters/max_age/max_age_filter.cc +2 -0
- data/src/core/ext/filters/max_age/max_age_filter.h +2 -0
- data/src/core/ext/filters/message_size/message_size_filter.cc +52 -49
- data/src/core/ext/filters/message_size/message_size_filter.h +2 -0
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +5 -1
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +2 -0
- data/src/core/ext/filters/workarounds/workaround_utils.cc +2 -0
- data/src/core/ext/filters/workarounds/workaround_utils.h +2 -0
- data/src/core/ext/transport/chttp2/alpn/alpn.cc +3 -1
- data/src/core/ext/transport/chttp2/alpn/alpn.h +2 -0
- data/src/core/ext/transport/chttp2/client/authority.cc +42 -0
- data/src/core/ext/transport/chttp2/client/authority.h +36 -0
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +2 -0
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +2 -0
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +10 -3
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +2 -2
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +37 -25
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +2 -0
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +3 -1
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +2 -1
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +2 -1
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +3 -1
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +2 -0
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +2 -0
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +152 -182
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +2 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -0
- data/src/core/ext/transport/chttp2/transport/frame.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +15 -19
- data/src/core/ext/transport/chttp2/transport/frame_data.h +7 -5
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +2 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +2 -1
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +2 -1
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +2 -1
- data/src/core/ext/transport/chttp2/transport/http2_settings.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +2 -0
- data/src/core/ext/transport/chttp2/transport/huffsyms.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +3 -2
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +2 -0
- data/src/core/ext/transport/chttp2/transport/internal.h +60 -24
- data/src/core/ext/transport/chttp2/transport/parsing.cc +2 -4
- data/src/core/ext/transport/chttp2/transport/stream_lists.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/stream_map.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/varint.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +10 -6
- data/src/core/ext/transport/inproc/inproc_plugin.cc +2 -0
- data/src/core/ext/transport/inproc/inproc_transport.cc +20 -23
- data/src/core/ext/transport/inproc/inproc_transport.h +2 -0
- data/src/core/lib/avl/avl.cc +2 -0
- data/src/core/lib/avl/avl.h +2 -0
- data/src/core/lib/backoff/backoff.cc +2 -0
- data/src/core/lib/backoff/backoff.h +2 -0
- data/src/core/lib/channel/channel_args.h +2 -0
- data/src/core/lib/channel/channel_stack.cc +3 -1
- data/src/core/lib/channel/channel_stack.h +2 -0
- data/src/core/lib/channel/channel_stack_builder.cc +2 -0
- data/src/core/lib/channel/channel_stack_builder.h +2 -0
- data/src/core/lib/channel/channel_trace.cc +239 -0
- data/src/core/lib/channel/channel_trace.h +133 -0
- data/src/core/lib/channel/channel_trace_registry.cc +80 -0
- data/src/core/lib/channel/channel_trace_registry.h +43 -0
- data/src/core/lib/channel/connected_channel.cc +2 -0
- data/src/core/lib/channel/connected_channel.h +2 -0
- data/src/core/lib/channel/handshaker.cc +2 -0
- data/src/core/lib/channel/handshaker.h +2 -0
- data/src/core/lib/channel/handshaker_factory.cc +2 -0
- data/src/core/lib/channel/handshaker_factory.h +2 -1
- data/src/core/lib/channel/handshaker_registry.cc +2 -0
- data/src/core/lib/channel/handshaker_registry.h +2 -1
- data/src/core/lib/channel/status_util.cc +100 -0
- data/src/core/lib/channel/status_util.h +58 -0
- data/src/core/lib/compression/algorithm_metadata.h +2 -0
- data/src/core/lib/compression/compression.cc +2 -0
- data/src/core/lib/compression/compression_internal.cc +2 -0
- data/src/core/lib/compression/compression_internal.h +2 -0
- data/src/core/lib/compression/message_compress.cc +2 -0
- data/src/core/lib/compression/message_compress.h +2 -0
- data/src/core/lib/compression/stream_compression.cc +2 -0
- data/src/core/lib/compression/stream_compression.h +2 -0
- data/src/core/lib/compression/stream_compression_gzip.cc +2 -0
- data/src/core/lib/compression/stream_compression_gzip.h +2 -0
- data/src/core/lib/compression/stream_compression_identity.cc +2 -1
- data/src/core/lib/compression/stream_compression_identity.h +2 -0
- data/src/core/lib/debug/stats.cc +2 -0
- data/src/core/lib/debug/stats.h +2 -0
- data/src/core/lib/debug/stats_data.cc +3 -1
- data/src/core/lib/debug/stats_data.h +2 -0
- data/src/core/lib/debug/trace.cc +2 -0
- data/src/core/lib/debug/trace.h +2 -1
- data/src/core/lib/gpr/alloc.cc +2 -1
- data/src/core/lib/gpr/arena.cc +47 -0
- data/src/core/lib/gpr/arena.h +2 -0
- data/src/core/lib/gpr/atm.cc +2 -0
- data/src/core/lib/gpr/cpu_linux.cc +5 -1
- data/src/core/lib/gpr/cpu_posix.cc +1 -1
- data/src/core/lib/gpr/env.h +2 -0
- data/src/core/lib/gpr/fork.cc +2 -0
- data/src/core/lib/gpr/host_port.cc +2 -0
- data/src/core/lib/gpr/log.cc +2 -1
- data/src/core/lib/gpr/log_linux.cc +1 -0
- data/src/core/lib/gpr/mpscq.cc +2 -0
- data/src/core/lib/gpr/mpscq.h +2 -0
- data/src/core/lib/gpr/murmur_hash.cc +2 -0
- data/src/core/lib/gpr/spinlock.h +2 -0
- data/src/core/lib/gpr/string.cc +2 -1
- data/src/core/lib/gpr/string.h +2 -2
- data/src/core/lib/gpr/sync.cc +2 -0
- data/src/core/lib/gpr/time.cc +2 -0
- data/src/core/lib/gpr/time_posix.cc +1 -0
- data/src/core/lib/gpr/time_precise.cc +2 -0
- data/src/core/lib/gpr/time_precise.h +2 -0
- data/src/core/lib/gpr/tls_gcc.h +2 -0
- data/src/core/lib/gpr/tls_msvc.h +2 -0
- data/src/core/lib/gpr/tls_pthread.h +2 -0
- data/src/core/lib/gpr/tmpfile.h +2 -0
- data/src/core/lib/gprpp/atomic_with_atm.h +2 -0
- data/src/core/lib/gprpp/atomic_with_std.h +2 -0
- data/src/core/lib/gprpp/inlined_vector.h +2 -0
- data/src/core/lib/gprpp/manual_constructor.h +3 -1
- data/src/core/lib/gprpp/memory.h +5 -3
- data/src/core/lib/gprpp/orphanable.h +3 -0
- data/src/core/lib/gprpp/ref_counted.h +4 -0
- data/src/core/lib/gprpp/ref_counted_ptr.h +3 -0
- data/src/core/lib/gprpp/thd.h +135 -0
- data/src/core/lib/gprpp/thd_posix.cc +209 -0
- data/src/core/lib/gprpp/thd_windows.cc +162 -0
- data/src/core/lib/http/format_request.cc +2 -0
- data/src/core/lib/http/format_request.h +2 -0
- data/src/core/lib/http/httpcli.cc +2 -0
- data/src/core/lib/http/httpcli.h +2 -0
- data/src/core/lib/http/httpcli_security_connector.cc +16 -7
- data/src/core/lib/http/parser.cc +2 -0
- data/src/core/lib/http/parser.h +2 -1
- data/src/core/lib/iomgr/call_combiner.cc +2 -0
- data/src/core/lib/iomgr/call_combiner.h +2 -1
- data/src/core/lib/iomgr/combiner.cc +2 -0
- data/src/core/lib/iomgr/combiner.h +2 -0
- data/src/core/lib/iomgr/endpoint.cc +4 -0
- data/src/core/lib/iomgr/endpoint.h +2 -0
- data/src/core/lib/iomgr/endpoint_pair.h +2 -0
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +2 -0
- data/src/core/lib/iomgr/endpoint_pair_uv.cc +2 -0
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +7 -4
- data/src/core/lib/iomgr/error.h +2 -0
- data/src/core/lib/iomgr/error_internal.h +2 -0
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +2 -0
- data/src/core/lib/iomgr/ev_epoll1_linux.h +2 -0
- data/src/core/lib/iomgr/ev_epollex_linux.cc +4 -18
- data/src/core/lib/iomgr/ev_epollex_linux.h +2 -0
- data/src/core/lib/iomgr/ev_epollsig_linux.cc +2 -0
- data/src/core/lib/iomgr/ev_epollsig_linux.h +2 -0
- data/src/core/lib/iomgr/ev_poll_posix.cc +61 -31
- data/src/core/lib/iomgr/ev_poll_posix.h +2 -0
- data/src/core/lib/iomgr/ev_posix.cc +35 -19
- data/src/core/lib/iomgr/ev_posix.h +2 -0
- data/src/core/lib/iomgr/ev_windows.cc +2 -0
- data/src/core/lib/iomgr/exec_ctx.cc +3 -1
- data/src/core/lib/iomgr/exec_ctx.h +21 -9
- data/src/core/lib/iomgr/executor.cc +13 -11
- data/src/core/lib/iomgr/executor.h +2 -0
- data/src/core/lib/iomgr/fork_posix.cc +4 -2
- data/src/core/lib/iomgr/fork_windows.cc +2 -0
- data/src/core/lib/iomgr/gethostname_fallback.cc +2 -0
- data/src/core/lib/iomgr/gethostname_host_name_max.cc +2 -0
- data/src/core/lib/iomgr/gethostname_sysconf.cc +2 -0
- data/src/core/lib/iomgr/iocp_windows.cc +3 -1
- data/src/core/lib/iomgr/iocp_windows.h +3 -0
- data/src/core/lib/iomgr/iomgr.cc +2 -1
- data/src/core/lib/iomgr/iomgr.h +2 -0
- data/src/core/lib/iomgr/iomgr_custom.cc +63 -0
- data/src/core/lib/iomgr/iomgr_custom.h +47 -0
- data/src/core/lib/iomgr/iomgr_internal.cc +43 -0
- data/src/core/lib/iomgr/iomgr_internal.h +14 -0
- data/src/core/lib/iomgr/iomgr_posix.cc +30 -3
- data/src/core/lib/iomgr/iomgr_posix.h +2 -0
- data/src/core/lib/iomgr/iomgr_uv.cc +17 -20
- data/src/core/lib/iomgr/iomgr_windows.cc +29 -3
- data/src/core/lib/iomgr/is_epollexclusive_available.cc +2 -0
- data/src/core/lib/iomgr/is_epollexclusive_available.h +2 -0
- data/src/core/lib/iomgr/load_file.cc +2 -0
- data/src/core/lib/iomgr/load_file.h +2 -0
- data/src/core/lib/iomgr/lockfree_event.cc +2 -0
- data/src/core/lib/iomgr/lockfree_event.h +14 -1
- data/src/core/lib/iomgr/nameser.h +2 -0
- data/src/core/lib/iomgr/network_status_tracker.cc +3 -1
- data/src/core/lib/iomgr/network_status_tracker.h +2 -0
- data/src/core/lib/iomgr/polling_entity.cc +2 -0
- data/src/core/lib/iomgr/polling_entity.h +2 -0
- data/src/core/lib/iomgr/pollset.cc +56 -0
- data/src/core/lib/iomgr/pollset.h +19 -0
- data/src/core/lib/iomgr/pollset_custom.cc +106 -0
- data/src/core/lib/iomgr/{timer_generic.h → pollset_custom.h} +15 -17
- data/src/core/lib/iomgr/pollset_set.cc +55 -0
- data/src/core/lib/iomgr/pollset_set.h +13 -0
- data/src/core/lib/iomgr/pollset_set_custom.cc +48 -0
- data/src/core/lib/iomgr/{pollset_uv.h → pollset_set_custom.h} +6 -7
- data/src/core/lib/iomgr/pollset_set_windows.cc +17 -10
- data/src/core/lib/iomgr/pollset_set_windows.h +2 -0
- data/src/core/lib/iomgr/pollset_uv.cc +42 -105
- data/src/core/lib/iomgr/pollset_windows.cc +20 -12
- data/src/core/lib/iomgr/pollset_windows.h +2 -0
- data/src/core/lib/iomgr/port.h +10 -19
- data/src/core/lib/iomgr/resolve_address.cc +50 -0
- data/src/core/lib/iomgr/resolve_address.h +39 -10
- data/src/core/lib/iomgr/resolve_address_custom.cc +187 -0
- data/src/core/lib/iomgr/resolve_address_custom.h +43 -0
- data/src/core/lib/iomgr/resolve_address_posix.cc +10 -22
- data/src/core/lib/iomgr/resolve_address_windows.cc +10 -22
- data/src/core/lib/iomgr/resource_quota.cc +2 -0
- data/src/core/lib/iomgr/resource_quota.h +3 -5
- data/src/core/lib/iomgr/sockaddr.h +3 -11
- data/src/core/lib/iomgr/sockaddr_custom.h +54 -0
- data/src/core/lib/iomgr/sockaddr_posix.h +26 -0
- data/src/core/lib/iomgr/sockaddr_utils.cc +91 -71
- data/src/core/lib/iomgr/sockaddr_utils.h +4 -0
- data/src/core/lib/iomgr/sockaddr_windows.h +21 -0
- data/src/core/lib/iomgr/socket_factory_posix.cc +2 -0
- data/src/core/lib/iomgr/socket_factory_posix.h +2 -0
- data/src/core/lib/iomgr/socket_mutator.cc +2 -0
- data/src/core/lib/iomgr/socket_mutator.h +2 -0
- data/src/core/lib/iomgr/socket_utils.h +11 -0
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +15 -6
- data/src/core/lib/iomgr/socket_utils_linux.cc +4 -4
- data/src/core/lib/iomgr/socket_utils_posix.cc +3 -2
- data/src/core/lib/iomgr/socket_utils_posix.h +2 -0
- data/src/core/lib/iomgr/socket_utils_uv.cc +13 -2
- data/src/core/lib/iomgr/socket_utils_windows.cc +10 -0
- data/src/core/lib/iomgr/socket_windows.cc +2 -0
- data/src/core/lib/iomgr/socket_windows.h +2 -1
- data/src/core/lib/iomgr/sys_epoll_wrapper.h +2 -0
- data/src/core/lib/iomgr/tcp_client.cc +36 -0
- data/src/core/lib/iomgr/tcp_client.h +13 -0
- data/src/core/lib/iomgr/tcp_client_custom.cc +151 -0
- data/src/core/lib/iomgr/tcp_client_posix.cc +11 -24
- data/src/core/lib/iomgr/tcp_client_posix.h +2 -0
- data/src/core/lib/iomgr/tcp_client_windows.cc +10 -23
- data/src/core/lib/iomgr/tcp_custom.cc +365 -0
- data/src/core/lib/iomgr/tcp_custom.h +81 -0
- data/src/core/lib/iomgr/tcp_posix.cc +3 -1
- data/src/core/lib/iomgr/tcp_posix.h +2 -0
- data/src/core/lib/iomgr/tcp_server.cc +73 -0
- data/src/core/lib/iomgr/tcp_server.h +24 -0
- data/src/core/lib/iomgr/tcp_server_custom.cc +472 -0
- data/src/core/lib/iomgr/tcp_server_posix.cc +41 -23
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +2 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +7 -7
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +8 -6
- data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc +2 -0
- data/src/core/lib/iomgr/tcp_server_windows.cc +43 -21
- data/src/core/lib/iomgr/tcp_uv.cc +308 -314
- data/src/core/lib/iomgr/tcp_windows.cc +3 -1
- data/src/core/lib/iomgr/tcp_windows.h +2 -0
- data/src/core/lib/iomgr/time_averaged_stats.cc +2 -0
- data/src/core/lib/iomgr/timer.cc +45 -0
- data/src/core/lib/iomgr/timer.h +36 -15
- data/src/core/lib/iomgr/timer_custom.cc +93 -0
- data/src/core/lib/iomgr/timer_custom.h +43 -0
- data/src/core/lib/iomgr/timer_generic.cc +12 -10
- data/src/core/lib/iomgr/timer_heap.cc +2 -4
- data/src/core/lib/iomgr/timer_heap.h +2 -0
- data/src/core/lib/iomgr/timer_manager.cc +12 -20
- data/src/core/lib/iomgr/timer_manager.h +2 -0
- data/src/core/lib/iomgr/timer_uv.cc +15 -49
- data/src/core/lib/iomgr/udp_server.cc +271 -230
- data/src/core/lib/iomgr/udp_server.h +44 -20
- data/src/core/lib/iomgr/unix_sockets_posix.cc +10 -7
- data/src/core/lib/iomgr/unix_sockets_posix.h +2 -0
- data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +2 -0
- data/src/core/lib/iomgr/wakeup_fd_cv.cc +3 -1
- data/src/core/lib/iomgr/wakeup_fd_cv.h +2 -0
- data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +2 -0
- data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +2 -0
- data/src/core/lib/iomgr/wakeup_fd_pipe.cc +2 -0
- data/src/core/lib/iomgr/wakeup_fd_pipe.h +2 -0
- data/src/core/lib/iomgr/wakeup_fd_posix.cc +2 -0
- data/src/core/lib/iomgr/wakeup_fd_posix.h +2 -0
- data/src/core/lib/json/json.cc +38 -0
- data/src/core/lib/json/json.h +22 -1
- data/src/core/lib/json/json_reader.cc +2 -2
- data/src/core/lib/json/json_reader.h +1 -0
- data/src/core/lib/json/json_string.cc +2 -0
- data/src/core/lib/json/json_writer.cc +2 -2
- data/src/core/lib/json/json_writer.h +2 -0
- data/src/core/lib/profiling/basic_timers.cc +11 -9
- data/src/core/lib/profiling/timers.h +6 -3
- data/src/core/lib/security/context/security_context.cc +2 -0
- data/src/core/lib/security/context/security_context.h +2 -0
- data/src/core/lib/security/credentials/alts/alts_credentials.cc +119 -0
- data/src/core/lib/security/credentials/alts/alts_credentials.h +102 -0
- data/src/core/lib/security/credentials/alts/check_gcp_environment.cc +72 -0
- data/src/core/lib/security/credentials/alts/check_gcp_environment.h +57 -0
- data/src/core/lib/security/credentials/alts/check_gcp_environment_linux.cc +67 -0
- data/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc +33 -0
- data/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc +114 -0
- data/src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc +126 -0
- data/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc +46 -0
- data/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h +112 -0
- data/src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc +58 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +2 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.h +2 -0
- data/src/core/lib/security/credentials/credentials.cc +2 -0
- data/src/core/lib/security/credentials/credentials.h +2 -0
- data/src/core/lib/security/credentials/credentials_metadata.cc +2 -0
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +2 -3
- data/src/core/lib/security/credentials/fake/fake_credentials.h +5 -0
- data/src/core/lib/security/credentials/google_default/credentials_generic.cc +2 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +2 -0
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +2 -0
- data/src/core/lib/security/credentials/iam/iam_credentials.h +2 -0
- data/src/core/lib/security/credentials/jwt/json_token.cc +2 -0
- data/src/core/lib/security/credentials/jwt/json_token.h +2 -0
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +2 -0
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +2 -0
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -0
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +2 -0
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +2 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +2 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +11 -2
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +2 -0
- data/src/core/lib/security/security_connector/alts_security_connector.cc +287 -0
- data/src/core/lib/security/security_connector/alts_security_connector.h +69 -0
- data/src/core/lib/security/security_connector/security_connector.cc +174 -74
- data/src/core/lib/security/security_connector/security_connector.h +41 -7
- data/src/core/lib/security/transport/auth_filters.h +2 -0
- data/src/core/lib/security/transport/client_auth_filter.cc +14 -28
- data/src/core/lib/security/transport/secure_endpoint.cc +2 -0
- data/src/core/lib/security/transport/secure_endpoint.h +2 -0
- data/src/core/lib/security/transport/security_handshaker.cc +2 -0
- data/src/core/lib/security/transport/security_handshaker.h +2 -1
- data/src/core/lib/security/transport/server_auth_filter.cc +2 -0
- data/src/core/lib/security/transport/target_authority_table.cc +75 -0
- data/src/core/lib/security/transport/{lb_targets_info.h → target_authority_table.h} +16 -8
- data/src/core/lib/security/transport/tsi_error.cc +2 -0
- data/src/core/lib/security/transport/tsi_error.h +2 -0
- data/src/core/lib/security/util/json_util.cc +2 -0
- data/src/core/lib/security/util/json_util.h +2 -0
- data/src/core/lib/slice/b64.cc +2 -0
- data/src/core/lib/slice/b64.h +2 -0
- data/src/core/lib/slice/percent_encoding.cc +2 -0
- data/src/core/lib/slice/percent_encoding.h +2 -0
- data/src/core/lib/slice/slice.cc +2 -0
- data/src/core/lib/slice/slice_buffer.cc +3 -1
- data/src/core/lib/slice/slice_hash_table.h +178 -45
- data/src/core/lib/slice/slice_intern.cc +2 -0
- data/src/core/lib/slice/slice_internal.h +2 -2
- data/src/core/lib/slice/slice_string_helpers.cc +2 -0
- data/src/core/lib/slice/slice_string_helpers.h +2 -1
- data/src/core/lib/slice/slice_weak_hash_table.h +105 -0
- data/src/core/lib/surface/api_trace.cc +3 -1
- data/src/core/lib/surface/api_trace.h +2 -0
- data/src/core/lib/surface/byte_buffer.cc +3 -0
- data/src/core/lib/surface/byte_buffer_reader.cc +3 -0
- data/src/core/lib/surface/call.cc +46 -80
- data/src/core/lib/surface/call.h +2 -0
- data/src/core/lib/surface/call_details.cc +2 -0
- data/src/core/lib/surface/call_log_batch.cc +2 -0
- data/src/core/lib/surface/call_test_only.h +2 -0
- data/src/core/lib/surface/channel.cc +72 -41
- data/src/core/lib/surface/channel.h +2 -0
- data/src/core/lib/surface/channel_init.cc +2 -0
- data/src/core/lib/surface/channel_init.h +2 -0
- data/src/core/lib/surface/channel_ping.cc +2 -0
- data/src/core/lib/surface/channel_stack_type.cc +3 -2
- data/src/core/lib/surface/channel_stack_type.h +2 -0
- data/src/core/lib/surface/completion_queue.h +2 -0
- data/src/core/lib/surface/completion_queue_factory.cc +3 -1
- data/src/core/lib/surface/completion_queue_factory.h +2 -0
- data/src/core/lib/surface/event_string.cc +2 -0
- data/src/core/lib/surface/event_string.h +2 -0
- data/src/core/lib/surface/init.cc +5 -2
- data/src/core/lib/surface/init_secure.cc +5 -2
- data/src/core/lib/surface/lame_client.cc +7 -5
- data/src/core/lib/surface/lame_client.h +2 -0
- data/src/core/lib/surface/metadata_array.cc +2 -0
- data/src/core/lib/surface/server.cc +2 -0
- data/src/core/lib/surface/server.h +2 -0
- data/src/core/lib/surface/validate_metadata.cc +2 -1
- data/src/core/lib/surface/validate_metadata.h +2 -0
- data/src/core/lib/surface/version.cc +4 -2
- data/src/core/lib/transport/bdp_estimator.cc +2 -0
- data/src/core/lib/transport/byte_stream.cc +94 -116
- data/src/core/lib/transport/byte_stream.h +111 -78
- data/src/core/lib/transport/connectivity_state.cc +2 -0
- data/src/core/lib/transport/connectivity_state.h +3 -1
- data/src/core/lib/transport/error_utils.cc +2 -0
- data/src/core/lib/transport/error_utils.h +2 -0
- data/src/core/lib/transport/metadata.cc +2 -0
- data/src/core/lib/transport/metadata.h +3 -1
- data/src/core/lib/transport/metadata_batch.cc +26 -0
- data/src/core/lib/transport/metadata_batch.h +12 -1
- data/src/core/lib/transport/pid_controller.cc +2 -0
- data/src/core/lib/transport/pid_controller.h +2 -0
- data/src/core/lib/transport/service_config.cc +21 -175
- data/src/core/lib/transport/service_config.h +223 -35
- data/src/core/lib/transport/static_metadata.cc +310 -294
- data/src/core/lib/transport/static_metadata.h +96 -82
- data/src/core/lib/transport/status_conversion.cc +2 -0
- data/src/core/lib/transport/status_conversion.h +3 -0
- data/src/core/lib/transport/status_metadata.cc +54 -0
- data/src/core/lib/{iomgr/timer_uv.h → transport/status_metadata.h} +10 -12
- data/src/core/lib/transport/timeout_encoding.cc +2 -1
- data/src/core/lib/transport/timeout_encoding.h +2 -0
- data/src/core/lib/transport/transport.cc +3 -1
- data/src/core/lib/transport/transport.h +33 -7
- data/src/core/lib/transport/transport_impl.h +2 -0
- data/src/core/lib/transport/transport_op_string.cc +10 -3
- data/src/core/plugin_registry/grpc_plugin_registry.cc +10 -4
- data/src/core/tsi/alts/crypt/aes_gcm.cc +687 -0
- data/src/core/tsi/alts/crypt/gsec.cc +189 -0
- data/src/core/tsi/alts/crypt/gsec.h +454 -0
- data/src/core/tsi/alts/frame_protector/alts_counter.cc +118 -0
- data/src/core/tsi/alts/frame_protector/alts_counter.h +98 -0
- data/src/core/tsi/alts/frame_protector/alts_crypter.cc +66 -0
- data/src/core/tsi/alts/frame_protector/alts_crypter.h +255 -0
- data/src/core/tsi/alts/frame_protector/alts_frame_protector.cc +407 -0
- data/src/core/tsi/alts/frame_protector/alts_frame_protector.h +55 -0
- data/src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.cc +114 -0
- data/src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.h +114 -0
- data/src/core/tsi/alts/frame_protector/alts_seal_privacy_integrity_crypter.cc +105 -0
- data/src/core/tsi/alts/frame_protector/alts_unseal_privacy_integrity_crypter.cc +103 -0
- data/src/core/tsi/alts/frame_protector/frame_handler.cc +218 -0
- data/src/core/tsi/alts/frame_protector/frame_handler.h +236 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +316 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +137 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc +520 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_service_api.h +323 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc +143 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h +149 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_event.cc +73 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_event.h +93 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +483 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +83 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +52 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_utils.cc +58 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_utils.h +52 -0
- data/src/core/tsi/alts/handshaker/altscontext.pb.c +48 -0
- data/src/core/tsi/alts/handshaker/altscontext.pb.h +64 -0
- data/src/core/tsi/alts/handshaker/handshaker.pb.c +123 -0
- data/src/core/tsi/alts/handshaker/handshaker.pb.h +255 -0
- data/src/core/tsi/alts/handshaker/transport_security_common.pb.c +50 -0
- data/src/core/tsi/alts/handshaker/transport_security_common.pb.h +78 -0
- data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +196 -0
- data/src/core/tsi/alts/handshaker/transport_security_common_api.h +163 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc +180 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h +52 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc +144 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.h +49 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol.h +91 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc +174 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h +100 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc +476 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h +199 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +296 -0
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h +52 -0
- data/src/core/tsi/alts_transport_security.cc +3 -1
- data/src/core/tsi/alts_transport_security.h +4 -2
- data/src/core/tsi/fake_transport_security.cc +2 -1
- data/src/core/tsi/fake_transport_security.h +2 -0
- data/src/core/tsi/ssl/session_cache/ssl_session.h +73 -0
- data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +58 -0
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +211 -0
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +93 -0
- data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +76 -0
- data/src/core/tsi/ssl_transport_security.cc +266 -62
- data/src/core/tsi/ssl_transport_security.h +128 -6
- data/src/core/tsi/ssl_types.h +2 -0
- data/src/core/tsi/transport_security.cc +2 -0
- data/src/core/tsi/transport_security.h +2 -0
- data/src/core/tsi/transport_security_adapter.cc +2 -0
- data/src/core/tsi/transport_security_adapter.h +2 -0
- data/src/core/tsi/transport_security_grpc.cc +2 -0
- data/src/core/tsi/transport_security_grpc.h +2 -0
- data/src/core/tsi/transport_security_interface.h +2 -0
- data/src/ruby/ext/grpc/extconf.rb +1 -2
- data/src/ruby/ext/grpc/rb_call.c +1 -13
- data/src/ruby/ext/grpc/rb_channel.c +6 -6
- data/src/ruby/ext/grpc/rb_compression_options.c +1 -1
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +10 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +15 -0
- data/src/ruby/lib/grpc/core/time_consts.rb +1 -1
- data/src/ruby/lib/grpc/generic/bidi_call.rb +19 -8
- data/src/ruby/lib/grpc/generic/client_stub.rb +6 -10
- data/src/ruby/lib/grpc/generic/interceptors.rb +1 -1
- data/src/ruby/lib/grpc/generic/rpc_server.rb +2 -2
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/generic/client_stub_spec.rb +133 -0
- data/src/ruby/spec/pb/package_with_underscore/checker_spec.rb +54 -0
- data/src/ruby/spec/pb/package_with_underscore/data.proto +23 -0
- data/src/ruby/spec/pb/package_with_underscore/service.proto +23 -0
- data/third_party/address_sorting/address_sorting.c +369 -0
- data/third_party/address_sorting/address_sorting_internal.h +70 -0
- data/third_party/address_sorting/address_sorting_posix.c +97 -0
- data/third_party/address_sorting/address_sorting_windows.c +55 -0
- data/third_party/address_sorting/include/address_sorting/address_sorting.h +110 -0
- data/third_party/boringssl/crypto/asn1/a_enum.c +20 -9
- data/third_party/boringssl/crypto/asn1/a_i2d_fp.c +3 -0
- data/third_party/boringssl/crypto/asn1/a_int.c +19 -8
- data/third_party/boringssl/crypto/asn1/a_object.c +0 -128
- data/third_party/boringssl/crypto/asn1/asn1_locl.h +3 -0
- data/third_party/boringssl/crypto/asn1/tasn_fre.c +2 -4
- data/third_party/boringssl/crypto/asn1/tasn_new.c +3 -2
- data/third_party/boringssl/crypto/bn_extra/bn_asn1.c +0 -16
- data/third_party/boringssl/crypto/buf/buf.c +14 -0
- data/third_party/boringssl/crypto/bytestring/cbb.c +93 -0
- data/third_party/boringssl/crypto/conf/conf.c +2 -2
- data/third_party/boringssl/crypto/cpu-intel.c +17 -17
- data/third_party/boringssl/crypto/crypto.c +16 -4
- data/third_party/boringssl/crypto/curve25519/spake25519.c +11 -11
- data/third_party/boringssl/crypto/curve25519/x25519-x86_64.c +1 -1
- data/third_party/boringssl/crypto/dsa/dsa.c +9 -21
- data/third_party/boringssl/crypto/ec_extra/ec_asn1.c +2 -2
- data/third_party/boringssl/crypto/ecdsa_extra/ecdsa_asn1.c +1 -8
- data/third_party/boringssl/crypto/evp/p_rsa_asn1.c +2 -23
- data/third_party/boringssl/crypto/ex_data.c +0 -1
- data/third_party/boringssl/crypto/fipsmodule/bn/add.c +7 -11
- data/third_party/boringssl/crypto/fipsmodule/bn/asm/x86_64-gcc.c +19 -16
- data/third_party/boringssl/crypto/fipsmodule/bn/cmp.c +15 -0
- data/third_party/boringssl/crypto/fipsmodule/bn/div.c +53 -46
- data/third_party/boringssl/crypto/fipsmodule/bn/exponentiation.c +242 -85
- data/third_party/boringssl/crypto/fipsmodule/bn/generic.c +42 -47
- data/third_party/boringssl/crypto/fipsmodule/bn/internal.h +176 -34
- data/third_party/boringssl/crypto/fipsmodule/bn/montgomery.c +118 -65
- data/third_party/boringssl/crypto/fipsmodule/bn/mul.c +94 -61
- data/third_party/boringssl/crypto/fipsmodule/bn/random.c +79 -63
- data/third_party/boringssl/crypto/fipsmodule/bn/shift.c +26 -28
- data/third_party/boringssl/crypto/fipsmodule/cipher/cipher.c +2 -0
- data/third_party/boringssl/crypto/fipsmodule/ec/ec.c +250 -149
- data/third_party/boringssl/crypto/fipsmodule/ec/ec_montgomery.c +0 -27
- data/third_party/boringssl/crypto/fipsmodule/ec/internal.h +54 -20
- data/third_party/boringssl/crypto/fipsmodule/ec/oct.c +3 -3
- data/third_party/boringssl/crypto/fipsmodule/ec/p224-64.c +7 -41
- data/third_party/boringssl/crypto/fipsmodule/ec/p256-64.c +6 -40
- data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.c +17 -122
- data/third_party/boringssl/crypto/fipsmodule/ec/simple.c +3 -64
- data/third_party/boringssl/crypto/fipsmodule/ec/wnaf.c +27 -9
- data/third_party/boringssl/crypto/fipsmodule/ecdsa/ecdsa.c +203 -205
- data/third_party/boringssl/crypto/fipsmodule/modes/cbc.c +14 -15
- data/third_party/boringssl/crypto/fipsmodule/modes/cfb.c +12 -8
- data/third_party/boringssl/crypto/fipsmodule/modes/ctr.c +4 -3
- data/third_party/boringssl/crypto/fipsmodule/modes/gcm.c +25 -36
- data/third_party/boringssl/crypto/fipsmodule/modes/internal.h +10 -0
- data/third_party/boringssl/crypto/fipsmodule/rsa/internal.h +0 -4
- data/third_party/boringssl/crypto/fipsmodule/rsa/rsa.c +2 -0
- data/third_party/boringssl/crypto/fipsmodule/rsa/rsa_impl.c +9 -19
- data/third_party/boringssl/crypto/lhash/lhash.c +19 -0
- data/third_party/boringssl/crypto/obj/obj.c +29 -69
- data/third_party/boringssl/crypto/pem/pem_lib.c +2 -2
- data/third_party/boringssl/crypto/poly1305/poly1305_vec.c +4 -55
- data/third_party/boringssl/crypto/rsa_extra/rsa_asn1.c +3 -22
- data/third_party/boringssl/crypto/x509/by_dir.c +1 -3
- data/third_party/boringssl/crypto/x509/by_file.c +0 -1
- data/third_party/boringssl/crypto/x509/x509_lu.c +0 -1
- data/third_party/boringssl/crypto/x509/x509_obj.c +1 -3
- data/third_party/boringssl/crypto/x509/x509_txt.c +0 -6
- data/third_party/boringssl/crypto/x509/x509_vfy.c +0 -1
- data/third_party/boringssl/crypto/x509/x509_vpm.c +0 -1
- data/third_party/boringssl/crypto/x509/x_algor.c +2 -2
- data/third_party/boringssl/crypto/x509v3/v3_alt.c +3 -4
- data/third_party/boringssl/crypto/x509v3/v3_genn.c +1 -0
- data/third_party/boringssl/crypto/x509v3/v3_info.c +1 -2
- data/third_party/boringssl/crypto/x509v3/v3_lib.c +15 -7
- data/third_party/boringssl/crypto/x509v3/v3_utl.c +41 -2
- data/third_party/boringssl/include/openssl/asn1.h +0 -1
- data/third_party/boringssl/include/openssl/base.h +1 -1
- data/third_party/boringssl/include/openssl/bio.h +5 -2
- data/third_party/boringssl/include/openssl/bn.h +2 -17
- data/third_party/boringssl/include/openssl/buf.h +4 -0
- data/third_party/boringssl/include/openssl/bytestring.h +11 -0
- data/third_party/boringssl/include/openssl/chacha.h +5 -1
- data/third_party/boringssl/include/openssl/cipher.h +10 -0
- data/third_party/boringssl/include/openssl/conf.h +4 -8
- data/third_party/boringssl/include/openssl/dsa.h +2 -18
- data/third_party/boringssl/include/openssl/ec.h +5 -5
- data/third_party/boringssl/include/openssl/ecdsa.h +10 -28
- data/third_party/boringssl/include/openssl/evp.h +0 -4
- data/third_party/boringssl/include/openssl/lhash.h +1 -18
- data/third_party/boringssl/include/openssl/obj.h +1 -0
- data/third_party/boringssl/include/openssl/rsa.h +3 -4
- data/third_party/boringssl/include/openssl/ssl.h +35 -54
- data/third_party/boringssl/include/openssl/ssl3.h +2 -0
- data/third_party/boringssl/include/openssl/stack.h +1 -1
- data/third_party/boringssl/include/openssl/tls1.h +1 -16
- data/third_party/boringssl/include/openssl/x509.h +3 -2
- data/third_party/boringssl/include/openssl/x509_vfy.h +0 -2
- data/third_party/boringssl/include/openssl/x509v3.h +1 -0
- data/third_party/boringssl/ssl/custom_extensions.cc +1 -1
- data/third_party/boringssl/ssl/d1_both.cc +120 -129
- data/third_party/boringssl/ssl/d1_lib.cc +23 -21
- data/third_party/boringssl/ssl/d1_pkt.cc +39 -143
- data/third_party/boringssl/ssl/dtls_method.cc +16 -23
- data/third_party/boringssl/ssl/dtls_record.cc +11 -4
- data/third_party/boringssl/ssl/handshake.cc +109 -40
- data/third_party/boringssl/ssl/handshake_client.cc +104 -96
- data/third_party/boringssl/ssl/handshake_server.cc +62 -72
- data/third_party/boringssl/ssl/internal.h +397 -318
- data/third_party/boringssl/ssl/s3_both.cc +173 -191
- data/third_party/boringssl/ssl/s3_lib.cc +26 -34
- data/third_party/boringssl/ssl/s3_pkt.cc +105 -247
- data/third_party/boringssl/ssl/ssl_asn1.cc +22 -22
- data/third_party/boringssl/ssl/ssl_buffer.cc +98 -108
- data/third_party/boringssl/ssl/ssl_cert.cc +12 -1
- data/third_party/boringssl/ssl/ssl_cipher.cc +23 -28
- data/third_party/boringssl/ssl/ssl_key_share.cc +11 -6
- data/third_party/boringssl/ssl/ssl_lib.cc +190 -113
- data/third_party/boringssl/ssl/ssl_privkey.cc +76 -106
- data/third_party/boringssl/ssl/ssl_session.cc +3 -3
- data/third_party/boringssl/ssl/ssl_stat.cc +3 -3
- data/third_party/boringssl/ssl/ssl_transcript.cc +38 -22
- data/third_party/boringssl/ssl/ssl_versions.cc +64 -31
- data/third_party/boringssl/ssl/t1_enc.cc +137 -154
- data/third_party/boringssl/ssl/t1_lib.cc +463 -478
- data/third_party/boringssl/ssl/tls13_both.cc +57 -58
- data/third_party/boringssl/ssl/tls13_client.cc +256 -121
- data/third_party/boringssl/ssl/tls13_enc.cc +187 -72
- data/third_party/boringssl/ssl/tls13_server.cc +187 -86
- data/third_party/boringssl/ssl/tls_method.cc +20 -30
- data/third_party/boringssl/ssl/tls_record.cc +77 -40
- data/third_party/boringssl/third_party/fiat/curve25519.c +5062 -0
- data/third_party/boringssl/{crypto/curve25519 → third_party/fiat}/internal.h +40 -27
- data/third_party/nanopb/pb.h +1 -1
- metadata +147 -45
- data/src/core/lib/gpr/thd.cc +0 -49
- data/src/core/lib/gpr/thd.h +0 -71
- data/src/core/lib/gpr/thd_posix.cc +0 -154
- data/src/core/lib/gpr/thd_windows.cc +0 -107
- data/src/core/lib/iomgr/iomgr_uv.h +0 -37
- data/src/core/lib/iomgr/pollset_set_uv.cc +0 -43
- data/src/core/lib/iomgr/resolve_address_uv.cc +0 -284
- data/src/core/lib/iomgr/tcp_client_uv.cc +0 -175
- data/src/core/lib/iomgr/tcp_server_uv.cc +0 -471
- data/src/core/lib/iomgr/tcp_uv.h +0 -51
- data/src/core/lib/security/transport/lb_targets_info.cc +0 -59
- data/src/core/lib/slice/slice_hash_table.cc +0 -145
- data/third_party/boringssl/crypto/curve25519/curve25519.c +0 -4938
@@ -16,22 +16,22 @@
|
|
16
16
|
*
|
17
17
|
*/
|
18
18
|
|
19
|
+
#include <grpc/support/port_platform.h>
|
20
|
+
|
19
21
|
#include "src/core/lib/iomgr/port.h"
|
20
22
|
|
21
|
-
#
|
23
|
+
#ifdef GRPC_UV
|
22
24
|
|
23
25
|
#include <grpc/support/alloc.h>
|
24
26
|
#include <grpc/support/log.h>
|
25
27
|
|
26
28
|
#include "src/core/lib/debug/trace.h"
|
27
|
-
#include "src/core/lib/iomgr/
|
29
|
+
#include "src/core/lib/iomgr/iomgr_custom.h"
|
28
30
|
#include "src/core/lib/iomgr/timer.h"
|
31
|
+
#include "src/core/lib/iomgr/timer_custom.h"
|
29
32
|
|
30
33
|
#include <uv.h>
|
31
34
|
|
32
|
-
grpc_core::TraceFlag grpc_timer_trace(false, "timer");
|
33
|
-
grpc_core::TraceFlag grpc_timer_check_trace(false, "timer_check");
|
34
|
-
|
35
35
|
static void timer_close_callback(uv_handle_t* handle) { gpr_free(handle); }
|
36
36
|
|
37
37
|
static void stop_uv_timer(uv_timer_t* handle) {
|
@@ -41,57 +41,23 @@ static void stop_uv_timer(uv_timer_t* handle) {
|
|
41
41
|
}
|
42
42
|
|
43
43
|
void run_expired_timer(uv_timer_t* handle) {
|
44
|
-
|
45
|
-
|
46
|
-
GRPC_UV_ASSERT_SAME_THREAD();
|
47
|
-
GPR_ASSERT(timer->pending);
|
48
|
-
timer->pending = 0;
|
49
|
-
GRPC_CLOSURE_SCHED(timer->closure, GRPC_ERROR_NONE);
|
50
|
-
stop_uv_timer(handle);
|
44
|
+
grpc_custom_timer* timer_wrapper = (grpc_custom_timer*)handle->data;
|
45
|
+
grpc_custom_timer_callback(timer_wrapper, GRPC_ERROR_NONE);
|
51
46
|
}
|
52
47
|
|
53
|
-
void
|
54
|
-
grpc_closure* closure) {
|
55
|
-
uint64_t timeout;
|
48
|
+
static void timer_start(grpc_custom_timer* t) {
|
56
49
|
uv_timer_t* uv_timer;
|
57
|
-
GRPC_UV_ASSERT_SAME_THREAD();
|
58
|
-
timer->closure = closure;
|
59
|
-
if (deadline <= grpc_core::ExecCtx::Get()->Now()) {
|
60
|
-
timer->pending = 0;
|
61
|
-
GRPC_CLOSURE_SCHED(timer->closure, GRPC_ERROR_NONE);
|
62
|
-
return;
|
63
|
-
}
|
64
|
-
timer->pending = 1;
|
65
|
-
timeout = (uint64_t)(deadline - grpc_core::ExecCtx::Get()->Now());
|
66
50
|
uv_timer = (uv_timer_t*)gpr_malloc(sizeof(uv_timer_t));
|
67
51
|
uv_timer_init(uv_default_loop(), uv_timer);
|
68
|
-
uv_timer->data =
|
69
|
-
timer
|
70
|
-
uv_timer_start(uv_timer, run_expired_timer,
|
71
|
-
/* We assume that gRPC timers are only used alongside other active gRPC
|
72
|
-
objects, and that there will therefore always be something else keeping
|
73
|
-
the uv loop alive whenever there is a timer */
|
74
|
-
uv_unref((uv_handle_t*)uv_timer);
|
75
|
-
}
|
76
|
-
|
77
|
-
void grpc_timer_init_unset(grpc_timer* timer) { timer->pending = 0; }
|
78
|
-
|
79
|
-
void grpc_timer_cancel(grpc_timer* timer) {
|
80
|
-
GRPC_UV_ASSERT_SAME_THREAD();
|
81
|
-
if (timer->pending) {
|
82
|
-
timer->pending = 0;
|
83
|
-
GRPC_CLOSURE_SCHED(timer->closure, GRPC_ERROR_CANCELLED);
|
84
|
-
stop_uv_timer((uv_timer_t*)timer->uv_timer);
|
85
|
-
}
|
52
|
+
uv_timer->data = t;
|
53
|
+
t->timer = (void*)uv_timer;
|
54
|
+
uv_timer_start(uv_timer, run_expired_timer, t->timeout_ms, 0);
|
86
55
|
}
|
87
56
|
|
88
|
-
|
89
|
-
|
57
|
+
static void timer_stop(grpc_custom_timer* t) {
|
58
|
+
stop_uv_timer((uv_timer_t*)t->timer);
|
90
59
|
}
|
91
60
|
|
92
|
-
|
93
|
-
void grpc_timer_list_shutdown() {}
|
94
|
-
|
95
|
-
void grpc_timer_consume_kick(void) {}
|
61
|
+
grpc_custom_timer_vtable uv_timer_vtable = {timer_start, timer_stop};
|
96
62
|
|
97
|
-
#endif
|
63
|
+
#endif
|
@@ -25,6 +25,8 @@
|
|
25
25
|
#define SO_RXQ_OVFL 40
|
26
26
|
#endif
|
27
27
|
|
28
|
+
#include <grpc/support/port_platform.h>
|
29
|
+
|
28
30
|
#include "src/core/lib/iomgr/port.h"
|
29
31
|
|
30
32
|
#ifdef GRPC_POSIX_SOCKET
|
@@ -50,6 +52,8 @@
|
|
50
52
|
#include <grpc/support/time.h>
|
51
53
|
#include "src/core/lib/channel/channel_args.h"
|
52
54
|
#include "src/core/lib/gpr/string.h"
|
55
|
+
#include "src/core/lib/gprpp/inlined_vector.h"
|
56
|
+
#include "src/core/lib/gprpp/memory.h"
|
53
57
|
#include "src/core/lib/iomgr/error.h"
|
54
58
|
#include "src/core/lib/iomgr/ev_posix.h"
|
55
59
|
#include "src/core/lib/iomgr/executor.h"
|
@@ -60,41 +64,102 @@
|
|
60
64
|
#include "src/core/lib/iomgr/socket_utils_posix.h"
|
61
65
|
#include "src/core/lib/iomgr/unix_sockets_posix.h"
|
62
66
|
|
63
|
-
/*
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
67
|
+
/* A listener which implements basic features of Listening on a port for
|
68
|
+
* I/O events*/
|
69
|
+
class GrpcUdpListener {
|
70
|
+
public:
|
71
|
+
GrpcUdpListener(grpc_udp_server* server, int fd,
|
72
|
+
const grpc_resolved_address* addr);
|
73
|
+
~GrpcUdpListener();
|
74
|
+
|
75
|
+
/* Called when grpc server starts to listening on the grpc_fd. */
|
76
|
+
void StartListening(grpc_pollset** pollsets, size_t pollset_count,
|
77
|
+
GrpcUdpHandlerFactory* handler_factory);
|
78
|
+
|
79
|
+
/* Called when data is available to read from the socket.
|
80
|
+
* Return true if there is more data to read from fd. */
|
81
|
+
void OnRead(grpc_error* error, void* do_read_arg);
|
82
|
+
|
83
|
+
/* Called when the socket is writeable. The given closure should be scheduled
|
84
|
+
* when the socket becomes blocked next time. */
|
85
|
+
void OnCanWrite(grpc_error* error, void* do_write_arg);
|
86
|
+
|
87
|
+
/* Called when the grpc_fd is about to be orphaned (and the FD closed). */
|
88
|
+
void OnFdAboutToOrphan();
|
89
|
+
|
90
|
+
/* Called to orphan fd of this listener.*/
|
91
|
+
void OrphanFd();
|
92
|
+
|
93
|
+
/* Called when this listener is going to be destroyed. */
|
94
|
+
void OnDestroy();
|
95
|
+
|
96
|
+
int fd() const { return fd_; }
|
97
|
+
|
98
|
+
protected:
|
99
|
+
grpc_fd* emfd() const { return emfd_; }
|
100
|
+
|
101
|
+
gpr_mu* mutex() { return &mutex_; }
|
102
|
+
|
103
|
+
private:
|
104
|
+
/* event manager callback when reads are ready */
|
105
|
+
static void on_read(void* arg, grpc_error* error);
|
106
|
+
static void on_write(void* arg, grpc_error* error);
|
107
|
+
|
108
|
+
static void do_read(void* arg, grpc_error* error);
|
109
|
+
static void do_write(void* arg, grpc_error* error);
|
110
|
+
// Wrapper of grpc_fd_notify_on_write() with a grpc_closure callback
|
111
|
+
// interface.
|
112
|
+
static void fd_notify_on_write_wrapper(void* arg, grpc_error* error);
|
113
|
+
|
114
|
+
static void shutdown_fd(void* args, grpc_error* error);
|
115
|
+
|
116
|
+
int fd_;
|
117
|
+
grpc_fd* emfd_;
|
118
|
+
grpc_udp_server* server_;
|
119
|
+
grpc_resolved_address addr_;
|
120
|
+
grpc_closure read_closure_;
|
121
|
+
grpc_closure write_closure_;
|
72
122
|
// To be called when corresponding QuicGrpcServer closes all active
|
73
123
|
// connections.
|
74
|
-
grpc_closure
|
75
|
-
grpc_closure
|
76
|
-
grpc_udp_server_read_cb read_cb;
|
77
|
-
grpc_udp_server_write_cb write_cb;
|
78
|
-
grpc_udp_server_orphan_cb orphan_cb;
|
79
|
-
grpc_udp_server_start_cb start_cb;
|
124
|
+
grpc_closure orphan_fd_closure_;
|
125
|
+
grpc_closure destroyed_closure_;
|
80
126
|
// To be scheduled on another thread to actually read/write.
|
81
|
-
grpc_closure
|
82
|
-
grpc_closure
|
83
|
-
grpc_closure
|
127
|
+
grpc_closure do_read_closure_;
|
128
|
+
grpc_closure do_write_closure_;
|
129
|
+
grpc_closure notify_on_write_closure_;
|
84
130
|
// True if orphan_cb is trigered.
|
85
|
-
bool
|
131
|
+
bool orphan_notified_;
|
86
132
|
// True if grpc_fd_notify_on_write() is called after on_write() call.
|
87
|
-
bool
|
133
|
+
bool notify_on_write_armed_;
|
88
134
|
// True if fd has been shutdown.
|
89
|
-
bool
|
90
|
-
|
91
|
-
|
135
|
+
bool already_shutdown_;
|
136
|
+
// Object actually handles I/O events. Assigned in StartListening().
|
137
|
+
GrpcUdpHandler* udp_handler_ = nullptr;
|
138
|
+
// To be notified on destruction.
|
139
|
+
GrpcUdpHandlerFactory* handler_factory_ = nullptr;
|
140
|
+
// Required to access above fields.
|
141
|
+
gpr_mu mutex_;
|
92
142
|
};
|
93
143
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
144
|
+
GrpcUdpListener::GrpcUdpListener(grpc_udp_server* server, int fd,
|
145
|
+
const grpc_resolved_address* addr)
|
146
|
+
: fd_(fd),
|
147
|
+
server_(server),
|
148
|
+
orphan_notified_(false),
|
149
|
+
already_shutdown_(false) {
|
150
|
+
char* addr_str;
|
151
|
+
char* name;
|
152
|
+
grpc_sockaddr_to_string(&addr_str, addr, 1);
|
153
|
+
gpr_asprintf(&name, "udp-server-listener:%s", addr_str);
|
154
|
+
gpr_free(addr_str);
|
155
|
+
emfd_ = grpc_fd_create(fd, name);
|
156
|
+
memcpy(&addr_, addr, sizeof(grpc_resolved_address));
|
157
|
+
GPR_ASSERT(emfd_);
|
158
|
+
gpr_free(name);
|
159
|
+
gpr_mu_init(&mutex_);
|
160
|
+
}
|
161
|
+
|
162
|
+
GrpcUdpListener::~GrpcUdpListener() { gpr_mu_destroy(&mutex_); }
|
98
163
|
|
99
164
|
/* the overall server */
|
100
165
|
struct grpc_udp_server {
|
@@ -111,10 +176,11 @@ struct grpc_udp_server {
|
|
111
176
|
/* is this server shutting down? (boolean) */
|
112
177
|
int shutdown;
|
113
178
|
|
114
|
-
/*
|
115
|
-
|
116
|
-
|
117
|
-
|
179
|
+
/* An array of listeners */
|
180
|
+
grpc_core::InlinedVector<GrpcUdpListener, 16> listeners;
|
181
|
+
|
182
|
+
/* factory for use to create udp listeners */
|
183
|
+
GrpcUdpHandlerFactory* handler_factory;
|
118
184
|
|
119
185
|
/* shutdown callback */
|
120
186
|
grpc_closure* shutdown_complete;
|
@@ -139,8 +205,7 @@ static grpc_socket_factory* get_socket_factory(const grpc_channel_args* args) {
|
|
139
205
|
}
|
140
206
|
|
141
207
|
grpc_udp_server* grpc_udp_server_create(const grpc_channel_args* args) {
|
142
|
-
grpc_udp_server* s =
|
143
|
-
static_cast<grpc_udp_server*>(gpr_malloc(sizeof(grpc_udp_server)));
|
208
|
+
grpc_udp_server* s = grpc_core::New<grpc_udp_server>();
|
144
209
|
gpr_mu_init(&s->mu);
|
145
210
|
s->socket_factory = get_socket_factory(args);
|
146
211
|
if (s->socket_factory) {
|
@@ -149,33 +214,27 @@ grpc_udp_server* grpc_udp_server_create(const grpc_channel_args* args) {
|
|
149
214
|
s->active_ports = 0;
|
150
215
|
s->destroyed_ports = 0;
|
151
216
|
s->shutdown = 0;
|
152
|
-
s->head = nullptr;
|
153
|
-
s->tail = nullptr;
|
154
|
-
s->nports = 0;
|
155
|
-
|
156
217
|
return s;
|
157
218
|
}
|
158
219
|
|
159
|
-
static
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
sp->
|
167
|
-
|
220
|
+
// static
|
221
|
+
void GrpcUdpListener::shutdown_fd(void* args, grpc_error* error) {
|
222
|
+
if (args == nullptr) {
|
223
|
+
// No-op if shutdown args are null.
|
224
|
+
return;
|
225
|
+
}
|
226
|
+
auto sp = static_cast<GrpcUdpListener*>(args);
|
227
|
+
gpr_mu_lock(sp->mutex());
|
228
|
+
gpr_log(GPR_DEBUG, "shutdown fd %d", sp->fd_);
|
229
|
+
grpc_fd_shutdown(sp->emfd_, GRPC_ERROR_REF(error));
|
230
|
+
sp->already_shutdown_ = true;
|
231
|
+
if (!sp->notify_on_write_armed_) {
|
168
232
|
// Re-arm write notification to notify listener with error. This is
|
169
233
|
// necessary to decrement active_ports.
|
170
|
-
sp->
|
171
|
-
grpc_fd_notify_on_write(sp->
|
234
|
+
sp->notify_on_write_armed_ = true;
|
235
|
+
grpc_fd_notify_on_write(sp->emfd_, &sp->write_closure_);
|
172
236
|
}
|
173
|
-
gpr_mu_unlock(
|
174
|
-
gpr_free(shutdown_args);
|
175
|
-
}
|
176
|
-
|
177
|
-
static void dummy_cb(void* arg, grpc_error* error) {
|
178
|
-
// No-op.
|
237
|
+
gpr_mu_unlock(sp->mutex());
|
179
238
|
}
|
180
239
|
|
181
240
|
static void finish_shutdown(grpc_udp_server* s) {
|
@@ -186,24 +245,22 @@ static void finish_shutdown(grpc_udp_server* s) {
|
|
186
245
|
gpr_mu_destroy(&s->mu);
|
187
246
|
|
188
247
|
gpr_log(GPR_DEBUG, "Destroy all listeners.");
|
189
|
-
|
190
|
-
|
191
|
-
s->head = sp->next;
|
192
|
-
gpr_free(sp);
|
248
|
+
for (size_t i = 0; i < s->listeners.size(); ++i) {
|
249
|
+
s->listeners[i].OnDestroy();
|
193
250
|
}
|
194
251
|
|
195
252
|
if (s->socket_factory) {
|
196
253
|
grpc_socket_factory_unref(s->socket_factory);
|
197
254
|
}
|
198
255
|
|
199
|
-
|
256
|
+
grpc_core::Delete(s);
|
200
257
|
}
|
201
258
|
|
202
259
|
static void destroyed_port(void* server, grpc_error* error) {
|
203
260
|
grpc_udp_server* s = static_cast<grpc_udp_server*>(server);
|
204
261
|
gpr_mu_lock(&s->mu);
|
205
262
|
s->destroyed_ports++;
|
206
|
-
if (s->destroyed_ports == s->
|
263
|
+
if (s->destroyed_ports == s->listeners.size()) {
|
207
264
|
gpr_mu_unlock(&s->mu);
|
208
265
|
finish_shutdown(s);
|
209
266
|
} else {
|
@@ -220,35 +277,30 @@ static void deactivated_all_ports(grpc_udp_server* s) {
|
|
220
277
|
|
221
278
|
GPR_ASSERT(s->shutdown);
|
222
279
|
|
223
|
-
if (s->
|
224
|
-
grpc_udp_listener* sp;
|
225
|
-
for (sp = s->head; sp; sp = sp->next) {
|
226
|
-
grpc_unlink_if_unix_domain_socket(&sp->addr);
|
227
|
-
|
228
|
-
GRPC_CLOSURE_INIT(&sp->destroyed_closure, destroyed_port, s,
|
229
|
-
grpc_schedule_on_exec_ctx);
|
230
|
-
if (!sp->orphan_notified) {
|
231
|
-
/* Call the orphan_cb to signal that the FD is about to be closed and
|
232
|
-
* should no longer be used. Because at this point, all listening ports
|
233
|
-
* have been shutdown already, no need to shutdown again.*/
|
234
|
-
GRPC_CLOSURE_INIT(&sp->orphan_fd_closure, dummy_cb, sp,
|
235
|
-
grpc_schedule_on_exec_ctx);
|
236
|
-
GPR_ASSERT(sp->orphan_cb);
|
237
|
-
gpr_log(GPR_DEBUG, "Orphan fd %d", sp->fd);
|
238
|
-
sp->orphan_cb(sp->emfd, &sp->orphan_fd_closure, sp->server->user_data);
|
239
|
-
}
|
240
|
-
grpc_fd_orphan(sp->emfd, &sp->destroyed_closure, nullptr,
|
241
|
-
false /* already_closed */, "udp_listener_shutdown");
|
242
|
-
}
|
243
|
-
gpr_mu_unlock(&s->mu);
|
244
|
-
} else {
|
280
|
+
if (s->listeners.size() == 0) {
|
245
281
|
gpr_mu_unlock(&s->mu);
|
246
282
|
finish_shutdown(s);
|
283
|
+
return;
|
284
|
+
}
|
285
|
+
for (size_t i = 0; i < s->listeners.size(); ++i) {
|
286
|
+
s->listeners[i].OrphanFd();
|
247
287
|
}
|
288
|
+
gpr_mu_unlock(&s->mu);
|
289
|
+
}
|
290
|
+
|
291
|
+
void GrpcUdpListener::OrphanFd() {
|
292
|
+
gpr_log(GPR_DEBUG, "Orphan fd %d, emfd %p", fd_, emfd_);
|
293
|
+
grpc_unlink_if_unix_domain_socket(&addr_);
|
294
|
+
|
295
|
+
GRPC_CLOSURE_INIT(&destroyed_closure_, destroyed_port, server_,
|
296
|
+
grpc_schedule_on_exec_ctx);
|
297
|
+
/* Because at this point, all listening sockets have been shutdown already, no
|
298
|
+
* need to call OnFdAboutToOrphan() to notify the handler again. */
|
299
|
+
grpc_fd_orphan(emfd_, &destroyed_closure_, nullptr,
|
300
|
+
false /* already_closed */, "udp_listener_shutdown");
|
248
301
|
}
|
249
302
|
|
250
303
|
void grpc_udp_server_destroy(grpc_udp_server* s, grpc_closure* on_done) {
|
251
|
-
grpc_udp_listener* sp;
|
252
304
|
gpr_mu_lock(&s->mu);
|
253
305
|
|
254
306
|
GPR_ASSERT(!s->shutdown);
|
@@ -259,16 +311,9 @@ void grpc_udp_server_destroy(grpc_udp_server* s, grpc_closure* on_done) {
|
|
259
311
|
gpr_log(GPR_DEBUG, "start to destroy udp_server");
|
260
312
|
/* shutdown all fd's */
|
261
313
|
if (s->active_ports) {
|
262
|
-
for (
|
263
|
-
|
264
|
-
|
265
|
-
static_cast<struct shutdown_fd_args*>(gpr_malloc(sizeof(*args)));
|
266
|
-
args->sp = sp;
|
267
|
-
args->server_mu = &s->mu;
|
268
|
-
GRPC_CLOSURE_INIT(&sp->orphan_fd_closure, shutdown_fd, args,
|
269
|
-
grpc_schedule_on_exec_ctx);
|
270
|
-
sp->orphan_cb(sp->emfd, &sp->orphan_fd_closure, sp->server->user_data);
|
271
|
-
sp->orphan_notified = true;
|
314
|
+
for (size_t i = 0; i < s->listeners.size(); ++i) {
|
315
|
+
GrpcUdpListener* sp = &s->listeners[i];
|
316
|
+
sp->OnFdAboutToOrphan();
|
272
317
|
}
|
273
318
|
gpr_mu_unlock(&s->mu);
|
274
319
|
} else {
|
@@ -277,14 +322,32 @@ void grpc_udp_server_destroy(grpc_udp_server* s, grpc_closure* on_done) {
|
|
277
322
|
}
|
278
323
|
}
|
279
324
|
|
325
|
+
void GrpcUdpListener::OnFdAboutToOrphan() {
|
326
|
+
gpr_mu_lock(&mutex_);
|
327
|
+
grpc_unlink_if_unix_domain_socket(&addr_);
|
328
|
+
|
329
|
+
GRPC_CLOSURE_INIT(&destroyed_closure_, destroyed_port, server_,
|
330
|
+
grpc_schedule_on_exec_ctx);
|
331
|
+
if (!orphan_notified_ && udp_handler_ != nullptr) {
|
332
|
+
/* Singals udp_handler that the FD is about to be closed and
|
333
|
+
* should no longer be used. */
|
334
|
+
GRPC_CLOSURE_INIT(&orphan_fd_closure_, shutdown_fd, this,
|
335
|
+
grpc_schedule_on_exec_ctx);
|
336
|
+
gpr_log(GPR_DEBUG, "fd %d about to be orphaned", fd_);
|
337
|
+
udp_handler_->OnFdAboutToOrphan(&orphan_fd_closure_, server_->user_data);
|
338
|
+
orphan_notified_ = true;
|
339
|
+
}
|
340
|
+
gpr_mu_unlock(&mutex_);
|
341
|
+
}
|
342
|
+
|
280
343
|
static int bind_socket(grpc_socket_factory* socket_factory, int sockfd,
|
281
344
|
const grpc_resolved_address* addr) {
|
282
345
|
return (socket_factory != nullptr)
|
283
346
|
? grpc_socket_factory_bind(socket_factory, sockfd, addr)
|
284
347
|
: bind(sockfd,
|
285
|
-
reinterpret_cast<
|
348
|
+
reinterpret_cast<grpc_sockaddr*>(
|
286
349
|
const_cast<char*>(addr->addr)),
|
287
|
-
|
350
|
+
addr->len);
|
288
351
|
}
|
289
352
|
|
290
353
|
/* Prepare a recently-created socket for listening. */
|
@@ -292,8 +355,8 @@ static int prepare_socket(grpc_socket_factory* socket_factory, int fd,
|
|
292
355
|
const grpc_resolved_address* addr, int rcv_buf_size,
|
293
356
|
int snd_buf_size) {
|
294
357
|
grpc_resolved_address sockname_temp;
|
295
|
-
|
296
|
-
reinterpret_cast<
|
358
|
+
grpc_sockaddr* addr_ptr =
|
359
|
+
reinterpret_cast<grpc_sockaddr*>(const_cast<char*>(addr->addr));
|
297
360
|
|
298
361
|
if (fd < 0) {
|
299
362
|
goto error;
|
@@ -318,7 +381,6 @@ static int prepare_socket(grpc_socket_factory* socket_factory, int fd,
|
|
318
381
|
}
|
319
382
|
}
|
320
383
|
|
321
|
-
GPR_ASSERT(addr->len < ~(socklen_t)0);
|
322
384
|
if (bind_socket(socket_factory, fd, addr) < 0) {
|
323
385
|
char* addr_str;
|
324
386
|
grpc_sockaddr_to_string(&addr_str, addr, 0);
|
@@ -327,10 +389,10 @@ static int prepare_socket(grpc_socket_factory* socket_factory, int fd,
|
|
327
389
|
goto error;
|
328
390
|
}
|
329
391
|
|
330
|
-
sockname_temp.len = sizeof(struct sockaddr_storage);
|
392
|
+
sockname_temp.len = static_cast<socklen_t>(sizeof(struct sockaddr_storage));
|
331
393
|
|
332
|
-
if (getsockname(fd, reinterpret_cast<
|
333
|
-
|
394
|
+
if (getsockname(fd, reinterpret_cast<grpc_sockaddr*>(sockname_temp.addr),
|
395
|
+
&sockname_temp.len) < 0) {
|
334
396
|
goto error;
|
335
397
|
}
|
336
398
|
|
@@ -362,163 +424,140 @@ error:
|
|
362
424
|
return -1;
|
363
425
|
}
|
364
426
|
|
365
|
-
static
|
366
|
-
|
367
|
-
|
427
|
+
// static
|
428
|
+
void GrpcUdpListener::do_read(void* arg, grpc_error* error) {
|
429
|
+
GrpcUdpListener* sp = static_cast<GrpcUdpListener*>(arg);
|
430
|
+
GPR_ASSERT(error == GRPC_ERROR_NONE);
|
368
431
|
/* TODO: the reason we hold server->mu here is merely to prevent fd
|
369
432
|
* shutdown while we are reading. However, it blocks do_write(). Switch to
|
370
433
|
* read lock if available. */
|
371
|
-
gpr_mu_lock(
|
434
|
+
gpr_mu_lock(sp->mutex());
|
372
435
|
/* Tell the registered callback that data is available to read. */
|
373
|
-
if (!sp->
|
436
|
+
if (!sp->already_shutdown_ && sp->udp_handler_->Read()) {
|
374
437
|
/* There maybe more packets to read. Schedule read_more_cb_ closure to run
|
375
438
|
* after finishing this event loop. */
|
376
|
-
GRPC_CLOSURE_SCHED(&sp->
|
439
|
+
GRPC_CLOSURE_SCHED(&sp->do_read_closure_, GRPC_ERROR_NONE);
|
377
440
|
} else {
|
378
441
|
/* Finish reading all the packets, re-arm the notification event so we can
|
379
442
|
* get another chance to read. Or fd already shutdown, re-arm to get a
|
380
443
|
* notification with shutdown error. */
|
381
|
-
grpc_fd_notify_on_read(sp->
|
444
|
+
grpc_fd_notify_on_read(sp->emfd_, &sp->read_closure_);
|
382
445
|
}
|
383
|
-
gpr_mu_unlock(
|
446
|
+
gpr_mu_unlock(sp->mutex());
|
384
447
|
}
|
385
448
|
|
386
|
-
|
387
|
-
|
388
|
-
|
449
|
+
// static
|
450
|
+
void GrpcUdpListener::on_read(void* arg, grpc_error* error) {
|
451
|
+
GrpcUdpListener* sp = static_cast<GrpcUdpListener*>(arg);
|
452
|
+
sp->OnRead(error, arg);
|
453
|
+
}
|
389
454
|
|
390
|
-
|
455
|
+
void GrpcUdpListener::OnRead(grpc_error* error, void* do_read_arg) {
|
391
456
|
if (error != GRPC_ERROR_NONE) {
|
392
|
-
|
393
|
-
|
394
|
-
|
457
|
+
gpr_mu_lock(&server_->mu);
|
458
|
+
if (0 == --server_->active_ports && server_->shutdown) {
|
459
|
+
gpr_mu_unlock(&server_->mu);
|
460
|
+
deactivated_all_ports(server_);
|
395
461
|
} else {
|
396
|
-
gpr_mu_unlock(&
|
462
|
+
gpr_mu_unlock(&server_->mu);
|
397
463
|
}
|
398
464
|
return;
|
399
465
|
}
|
466
|
+
|
400
467
|
/* Read once. If there is more data to read, off load the work to another
|
401
468
|
* thread to finish. */
|
402
|
-
|
403
|
-
if (sp->read_cb(sp->emfd)) {
|
469
|
+
if (udp_handler_->Read()) {
|
404
470
|
/* There maybe more packets to read. Schedule read_more_cb_ closure to run
|
405
471
|
* after finishing this event loop. */
|
406
|
-
GRPC_CLOSURE_INIT(&
|
472
|
+
GRPC_CLOSURE_INIT(&do_read_closure_, do_read, do_read_arg,
|
407
473
|
grpc_executor_scheduler(GRPC_EXECUTOR_LONG));
|
408
|
-
GRPC_CLOSURE_SCHED(&
|
474
|
+
GRPC_CLOSURE_SCHED(&do_read_closure_, GRPC_ERROR_NONE);
|
409
475
|
} else {
|
410
476
|
/* Finish reading all the packets, re-arm the notification event so we can
|
411
477
|
* get another chance to read. Or fd already shutdown, re-arm to get a
|
412
478
|
* notification with shutdown error. */
|
413
|
-
grpc_fd_notify_on_read(
|
479
|
+
grpc_fd_notify_on_read(emfd_, &read_closure_);
|
414
480
|
}
|
415
|
-
gpr_mu_unlock(&sp->server->mu);
|
416
481
|
}
|
417
482
|
|
483
|
+
// static
|
418
484
|
// Wrapper of grpc_fd_notify_on_write() with a grpc_closure callback interface.
|
419
|
-
void fd_notify_on_write_wrapper(void* arg, grpc_error* error) {
|
420
|
-
|
421
|
-
gpr_mu_lock(
|
422
|
-
if (!sp->
|
423
|
-
grpc_fd_notify_on_write(sp->
|
424
|
-
sp->
|
425
|
-
}
|
426
|
-
gpr_mu_unlock(
|
485
|
+
void GrpcUdpListener::fd_notify_on_write_wrapper(void* arg, grpc_error* error) {
|
486
|
+
GrpcUdpListener* sp = static_cast<GrpcUdpListener*>(arg);
|
487
|
+
gpr_mu_lock(sp->mutex());
|
488
|
+
if (!sp->notify_on_write_armed_) {
|
489
|
+
grpc_fd_notify_on_write(sp->emfd_, &sp->write_closure_);
|
490
|
+
sp->notify_on_write_armed_ = true;
|
491
|
+
}
|
492
|
+
gpr_mu_unlock(sp->mutex());
|
427
493
|
}
|
428
494
|
|
429
|
-
static
|
430
|
-
|
431
|
-
|
432
|
-
|
495
|
+
// static
|
496
|
+
void GrpcUdpListener::do_write(void* arg, grpc_error* error) {
|
497
|
+
GrpcUdpListener* sp = static_cast<GrpcUdpListener*>(arg);
|
498
|
+
gpr_mu_lock(sp->mutex());
|
499
|
+
if (sp->already_shutdown_) {
|
433
500
|
// If fd has been shutdown, don't write any more and re-arm notification.
|
434
|
-
grpc_fd_notify_on_write(sp->
|
501
|
+
grpc_fd_notify_on_write(sp->emfd_, &sp->write_closure_);
|
435
502
|
} else {
|
436
|
-
sp->
|
503
|
+
sp->notify_on_write_armed_ = false;
|
437
504
|
/* Tell the registered callback that the socket is writeable. */
|
438
|
-
GPR_ASSERT(
|
439
|
-
GRPC_CLOSURE_INIT(&sp->
|
505
|
+
GPR_ASSERT(error == GRPC_ERROR_NONE);
|
506
|
+
GRPC_CLOSURE_INIT(&sp->notify_on_write_closure_, fd_notify_on_write_wrapper,
|
440
507
|
arg, grpc_schedule_on_exec_ctx);
|
441
|
-
sp->
|
508
|
+
sp->udp_handler_->OnCanWrite(sp->server_->user_data,
|
509
|
+
&sp->notify_on_write_closure_);
|
442
510
|
}
|
443
|
-
gpr_mu_unlock(
|
511
|
+
gpr_mu_unlock(sp->mutex());
|
444
512
|
}
|
445
513
|
|
446
|
-
static
|
447
|
-
|
514
|
+
// static
|
515
|
+
void GrpcUdpListener::on_write(void* arg, grpc_error* error) {
|
516
|
+
GrpcUdpListener* sp = static_cast<GrpcUdpListener*>(arg);
|
517
|
+
sp->OnCanWrite(error, arg);
|
518
|
+
}
|
448
519
|
|
449
|
-
|
520
|
+
void GrpcUdpListener::OnCanWrite(grpc_error* error, void* do_write_arg) {
|
450
521
|
if (error != GRPC_ERROR_NONE) {
|
451
|
-
|
452
|
-
|
453
|
-
|
522
|
+
gpr_mu_lock(&server_->mu);
|
523
|
+
if (0 == --server_->active_ports && server_->shutdown) {
|
524
|
+
gpr_mu_unlock(&server_->mu);
|
525
|
+
deactivated_all_ports(server_);
|
454
526
|
} else {
|
455
|
-
gpr_mu_unlock(&
|
527
|
+
gpr_mu_unlock(&server_->mu);
|
456
528
|
}
|
457
529
|
return;
|
458
530
|
}
|
459
531
|
|
460
532
|
/* Schedule actual write in another thread. */
|
461
|
-
GRPC_CLOSURE_INIT(&
|
533
|
+
GRPC_CLOSURE_INIT(&do_write_closure_, do_write, do_write_arg,
|
462
534
|
grpc_executor_scheduler(GRPC_EXECUTOR_LONG));
|
463
535
|
|
464
|
-
GRPC_CLOSURE_SCHED(&
|
465
|
-
gpr_mu_unlock(&sp->server->mu);
|
536
|
+
GRPC_CLOSURE_SCHED(&do_write_closure_, GRPC_ERROR_NONE);
|
466
537
|
}
|
467
538
|
|
468
539
|
static int add_socket_to_server(grpc_udp_server* s, int fd,
|
469
540
|
const grpc_resolved_address* addr,
|
470
|
-
int rcv_buf_size, int snd_buf_size
|
471
|
-
|
472
|
-
grpc_udp_server_read_cb read_cb,
|
473
|
-
grpc_udp_server_write_cb write_cb,
|
474
|
-
grpc_udp_server_orphan_cb orphan_cb) {
|
475
|
-
grpc_udp_listener* sp;
|
476
|
-
int port;
|
477
|
-
char* addr_str;
|
478
|
-
char* name;
|
541
|
+
int rcv_buf_size, int snd_buf_size) {
|
542
|
+
gpr_log(GPR_DEBUG, "add socket %d to server", fd);
|
479
543
|
|
480
|
-
port =
|
544
|
+
int port =
|
481
545
|
prepare_socket(s->socket_factory, fd, addr, rcv_buf_size, snd_buf_size);
|
482
546
|
if (port >= 0) {
|
483
|
-
grpc_sockaddr_to_string(&addr_str, addr, 1);
|
484
|
-
gpr_asprintf(&name, "udp-server-listener:%s", addr_str);
|
485
|
-
gpr_free(addr_str);
|
486
547
|
gpr_mu_lock(&s->mu);
|
487
|
-
s->
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
s->head = sp;
|
492
|
-
} else {
|
493
|
-
s->tail->next = sp;
|
494
|
-
}
|
495
|
-
s->tail = sp;
|
496
|
-
sp->server = s;
|
497
|
-
sp->fd = fd;
|
498
|
-
sp->emfd = grpc_fd_create(fd, name);
|
499
|
-
memcpy(&sp->addr, addr, sizeof(grpc_resolved_address));
|
500
|
-
sp->read_cb = read_cb;
|
501
|
-
sp->write_cb = write_cb;
|
502
|
-
sp->orphan_cb = orphan_cb;
|
503
|
-
sp->start_cb = start_cb;
|
504
|
-
sp->orphan_notified = false;
|
505
|
-
sp->already_shutdown = false;
|
506
|
-
GPR_ASSERT(sp->emfd);
|
548
|
+
s->listeners.emplace_back(s, fd, addr);
|
549
|
+
gpr_log(GPR_DEBUG,
|
550
|
+
"add socket %d to server for port %d, %zu listener(s) in total", fd,
|
551
|
+
port, s->listeners.size());
|
507
552
|
gpr_mu_unlock(&s->mu);
|
508
|
-
gpr_free(name);
|
509
553
|
}
|
510
|
-
|
511
554
|
return port;
|
512
555
|
}
|
513
556
|
|
514
557
|
int grpc_udp_server_add_port(grpc_udp_server* s,
|
515
558
|
const grpc_resolved_address* addr,
|
516
559
|
int rcv_buf_size, int snd_buf_size,
|
517
|
-
|
518
|
-
grpc_udp_server_read_cb read_cb,
|
519
|
-
grpc_udp_server_write_cb write_cb,
|
520
|
-
grpc_udp_server_orphan_cb orphan_cb) {
|
521
|
-
grpc_udp_listener* sp;
|
560
|
+
GrpcUdpHandlerFactory* handler_factory) {
|
522
561
|
int allocated_port1 = -1;
|
523
562
|
int allocated_port2 = -1;
|
524
563
|
int fd;
|
@@ -534,12 +573,12 @@ int grpc_udp_server_add_port(grpc_udp_server* s,
|
|
534
573
|
/* Check if this is a wildcard port, and if so, try to keep the port the same
|
535
574
|
as some previously created listener. */
|
536
575
|
if (grpc_sockaddr_get_port(addr) == 0) {
|
537
|
-
for (
|
538
|
-
sockname_temp.len =
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
576
|
+
for (size_t i = 0; i < s->listeners.size(); ++i) {
|
577
|
+
sockname_temp.len =
|
578
|
+
static_cast<socklen_t>(sizeof(struct sockaddr_storage));
|
579
|
+
if (0 == getsockname(s->listeners[i].fd(),
|
580
|
+
reinterpret_cast<grpc_sockaddr*>(sockname_temp.addr),
|
581
|
+
&sockname_temp.len)) {
|
543
582
|
port = grpc_sockaddr_get_port(&sockname_temp);
|
544
583
|
if (port > 0) {
|
545
584
|
allocated_addr = static_cast<grpc_resolved_address*>(
|
@@ -557,6 +596,7 @@ int grpc_udp_server_add_port(grpc_udp_server* s,
|
|
557
596
|
addr = &addr6_v4mapped;
|
558
597
|
}
|
559
598
|
|
599
|
+
s->handler_factory = handler_factory;
|
560
600
|
/* Treat :: or 0.0.0.0 as a family-agnostic wildcard. */
|
561
601
|
if (grpc_sockaddr_is_wildcard(addr, &port)) {
|
562
602
|
grpc_sockaddr_make_wildcards(port, &wild4, &wild6);
|
@@ -567,8 +607,7 @@ int grpc_udp_server_add_port(grpc_udp_server* s,
|
|
567
607
|
GRPC_ERROR_UNREF(grpc_create_dualstack_socket_using_factory(
|
568
608
|
s->socket_factory, addr, SOCK_DGRAM, IPPROTO_UDP, &dsmode, &fd));
|
569
609
|
allocated_port1 =
|
570
|
-
add_socket_to_server(s, fd, addr, rcv_buf_size, snd_buf_size
|
571
|
-
read_cb, write_cb, orphan_cb);
|
610
|
+
add_socket_to_server(s, fd, addr, rcv_buf_size, snd_buf_size);
|
572
611
|
if (fd >= 0 && dsmode == GRPC_DSMODE_DUALSTACK) {
|
573
612
|
goto done;
|
574
613
|
}
|
@@ -591,8 +630,7 @@ int grpc_udp_server_add_port(grpc_udp_server* s,
|
|
591
630
|
addr = &addr4_copy;
|
592
631
|
}
|
593
632
|
allocated_port2 =
|
594
|
-
add_socket_to_server(s, fd, addr, rcv_buf_size, snd_buf_size
|
595
|
-
read_cb, write_cb, orphan_cb);
|
633
|
+
add_socket_to_server(s, fd, addr, rcv_buf_size, snd_buf_size);
|
596
634
|
|
597
635
|
done:
|
598
636
|
gpr_free(allocated_addr);
|
@@ -600,52 +638,55 @@ done:
|
|
600
638
|
}
|
601
639
|
|
602
640
|
int grpc_udp_server_get_fd(grpc_udp_server* s, unsigned port_index) {
|
603
|
-
|
604
|
-
if (port_index >= s->nports) {
|
641
|
+
if (port_index >= s->listeners.size()) {
|
605
642
|
return -1;
|
606
643
|
}
|
607
644
|
|
608
|
-
|
609
|
-
--port_index;
|
610
|
-
}
|
611
|
-
GPR_ASSERT(sp); // if this fails, our check earlier was bogus
|
612
|
-
return sp->fd;
|
645
|
+
return s->listeners[port_index].fd();
|
613
646
|
}
|
614
647
|
|
615
648
|
void grpc_udp_server_start(grpc_udp_server* s, grpc_pollset** pollsets,
|
616
649
|
size_t pollset_count, void* user_data) {
|
617
650
|
gpr_log(GPR_DEBUG, "grpc_udp_server_start");
|
618
|
-
size_t i;
|
619
651
|
gpr_mu_lock(&s->mu);
|
620
|
-
grpc_udp_listener* sp;
|
621
652
|
GPR_ASSERT(s->active_ports == 0);
|
622
653
|
s->pollsets = pollsets;
|
623
654
|
s->user_data = user_data;
|
624
655
|
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
for (i = 0; i < pollset_count; i++) {
|
629
|
-
grpc_pollset_add_fd(pollsets[i], sp->emfd);
|
630
|
-
}
|
631
|
-
GRPC_CLOSURE_INIT(&sp->read_closure, on_read, sp,
|
632
|
-
grpc_schedule_on_exec_ctx);
|
633
|
-
grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
|
656
|
+
for (size_t i = 0; i < s->listeners.size(); ++i) {
|
657
|
+
s->listeners[i].StartListening(pollsets, pollset_count, s->handler_factory);
|
658
|
+
}
|
634
659
|
|
635
|
-
|
636
|
-
|
637
|
-
sp->notify_on_write_armed = true;
|
638
|
-
grpc_fd_notify_on_write(sp->emfd, &sp->write_closure);
|
660
|
+
gpr_mu_unlock(&s->mu);
|
661
|
+
}
|
639
662
|
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
663
|
+
void GrpcUdpListener::StartListening(grpc_pollset** pollsets,
|
664
|
+
size_t pollset_count,
|
665
|
+
GrpcUdpHandlerFactory* handler_factory) {
|
666
|
+
gpr_mu_lock(&mutex_);
|
667
|
+
handler_factory_ = handler_factory;
|
668
|
+
udp_handler_ = handler_factory->CreateUdpHandler(emfd_, server_->user_data);
|
669
|
+
for (size_t i = 0; i < pollset_count; i++) {
|
670
|
+
grpc_pollset_add_fd(pollsets[i], emfd_);
|
671
|
+
}
|
672
|
+
GRPC_CLOSURE_INIT(&read_closure_, on_read, this, grpc_schedule_on_exec_ctx);
|
673
|
+
grpc_fd_notify_on_read(emfd_, &read_closure_);
|
674
|
+
|
675
|
+
GRPC_CLOSURE_INIT(&write_closure_, on_write, this, grpc_schedule_on_exec_ctx);
|
676
|
+
notify_on_write_armed_ = true;
|
677
|
+
grpc_fd_notify_on_write(emfd_, &write_closure_);
|
678
|
+
|
679
|
+
/* Registered for both read and write callbacks: increment active_ports
|
680
|
+
* twice to account for this, and delay free-ing of memory until both
|
681
|
+
* on_read and on_write have fired. */
|
682
|
+
server_->active_ports += 2;
|
683
|
+
gpr_mu_unlock(&mutex_);
|
684
|
+
}
|
644
685
|
|
645
|
-
|
686
|
+
void GrpcUdpListener::OnDestroy() {
|
687
|
+
if (udp_handler_ != nullptr) {
|
688
|
+
handler_factory_->DestroyUdpHandler(udp_handler_);
|
646
689
|
}
|
647
|
-
|
648
|
-
gpr_mu_unlock(&s->mu);
|
649
690
|
}
|
650
691
|
|
651
692
|
#endif
|