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
@@ -21,6 +21,14 @@
|
|
21
21
|
|
22
22
|
#include "src/core/lib/channel/channel_stack.h"
|
23
23
|
|
24
|
+
#ifdef __cplusplus
|
25
|
+
extern "C" {
|
26
|
+
#endif
|
27
|
+
|
24
28
|
extern const grpc_channel_filter grpc_lame_filter;
|
25
29
|
|
30
|
+
#ifdef __cplusplus
|
31
|
+
}
|
32
|
+
#endif
|
33
|
+
|
26
34
|
#endif /* GRPC_CORE_LIB_SURFACE_LAME_CLIENT_H */
|
File without changes
|
@@ -33,7 +33,8 @@
|
|
33
33
|
#include "src/core/lib/iomgr/executor.h"
|
34
34
|
#include "src/core/lib/iomgr/iomgr.h"
|
35
35
|
#include "src/core/lib/slice/slice_internal.h"
|
36
|
-
#include "src/core/lib/support/
|
36
|
+
#include "src/core/lib/support/mpscq.h"
|
37
|
+
#include "src/core/lib/support/spinlock.h"
|
37
38
|
#include "src/core/lib/support/string.h"
|
38
39
|
#include "src/core/lib/surface/api_trace.h"
|
39
40
|
#include "src/core/lib/surface/call.h"
|
@@ -44,12 +45,12 @@
|
|
44
45
|
#include "src/core/lib/transport/static_metadata.h"
|
45
46
|
|
46
47
|
typedef struct listener {
|
47
|
-
void
|
48
|
-
void (*start)(grpc_exec_ctx
|
49
|
-
grpc_pollset
|
50
|
-
void (*destroy)(grpc_exec_ctx
|
51
|
-
grpc_closure
|
52
|
-
struct listener
|
48
|
+
void* arg;
|
49
|
+
void (*start)(grpc_exec_ctx* exec_ctx, grpc_server* server, void* arg,
|
50
|
+
grpc_pollset** pollsets, size_t pollset_count);
|
51
|
+
void (*destroy)(grpc_exec_ctx* exec_ctx, grpc_server* server, void* arg,
|
52
|
+
grpc_closure* closure);
|
53
|
+
struct listener* next;
|
53
54
|
grpc_closure destroy_done;
|
54
55
|
} listener;
|
55
56
|
|
@@ -59,32 +60,32 @@ typedef struct registered_method registered_method;
|
|
59
60
|
|
60
61
|
typedef enum { BATCH_CALL, REGISTERED_CALL } requested_call_type;
|
61
62
|
|
62
|
-
|
63
|
-
GRPC_TRACER_INITIALIZER(false, "server_channel");
|
63
|
+
grpc_core::TraceFlag grpc_server_channel_trace(false, "server_channel");
|
64
64
|
|
65
65
|
typedef struct requested_call {
|
66
|
+
gpr_mpscq_node request_link; /* must be first */
|
66
67
|
requested_call_type type;
|
67
68
|
size_t cq_idx;
|
68
|
-
void
|
69
|
-
grpc_server
|
70
|
-
grpc_completion_queue
|
71
|
-
grpc_call
|
69
|
+
void* tag;
|
70
|
+
grpc_server* server;
|
71
|
+
grpc_completion_queue* cq_bound_to_call;
|
72
|
+
grpc_call** call;
|
72
73
|
grpc_cq_completion completion;
|
73
|
-
grpc_metadata_array
|
74
|
+
grpc_metadata_array* initial_metadata;
|
74
75
|
union {
|
75
76
|
struct {
|
76
|
-
grpc_call_details
|
77
|
+
grpc_call_details* details;
|
77
78
|
} batch;
|
78
79
|
struct {
|
79
|
-
registered_method
|
80
|
-
gpr_timespec
|
81
|
-
grpc_byte_buffer
|
80
|
+
registered_method* method;
|
81
|
+
gpr_timespec* deadline;
|
82
|
+
grpc_byte_buffer** optional_payload;
|
82
83
|
} registered;
|
83
84
|
} data;
|
84
85
|
} requested_call;
|
85
86
|
|
86
87
|
typedef struct channel_registered_method {
|
87
|
-
registered_method
|
88
|
+
registered_method* server_registered_method;
|
88
89
|
uint32_t flags;
|
89
90
|
bool has_host;
|
90
91
|
grpc_slice method;
|
@@ -92,14 +93,14 @@ typedef struct channel_registered_method {
|
|
92
93
|
} channel_registered_method;
|
93
94
|
|
94
95
|
struct channel_data {
|
95
|
-
grpc_server
|
96
|
+
grpc_server* server;
|
96
97
|
grpc_connectivity_state connectivity_state;
|
97
|
-
grpc_channel
|
98
|
+
grpc_channel* channel;
|
98
99
|
size_t cq_idx;
|
99
100
|
/* linked list of all channels on a server */
|
100
|
-
channel_data
|
101
|
-
channel_data
|
102
|
-
channel_registered_method
|
101
|
+
channel_data* next;
|
102
|
+
channel_data* prev;
|
103
|
+
channel_registered_method* registered_methods;
|
103
104
|
uint32_t registered_method_slots;
|
104
105
|
uint32_t registered_method_max_probes;
|
105
106
|
grpc_closure finish_destroy_channel_closure;
|
@@ -107,8 +108,8 @@ struct channel_data {
|
|
107
108
|
};
|
108
109
|
|
109
110
|
typedef struct shutdown_tag {
|
110
|
-
void
|
111
|
-
grpc_completion_queue
|
111
|
+
void* tag;
|
112
|
+
grpc_completion_queue* cq;
|
112
113
|
grpc_cq_completion completion;
|
113
114
|
} shutdown_tag;
|
114
115
|
|
@@ -126,65 +127,62 @@ typedef enum {
|
|
126
127
|
typedef struct request_matcher request_matcher;
|
127
128
|
|
128
129
|
struct call_data {
|
129
|
-
grpc_call
|
130
|
+
grpc_call* call;
|
130
131
|
|
131
|
-
|
132
|
-
gpr_mu mu_state;
|
133
|
-
/** the current state of a call - see call_state */
|
134
|
-
call_state state;
|
132
|
+
gpr_atm state;
|
135
133
|
|
136
134
|
bool path_set;
|
137
135
|
bool host_set;
|
138
136
|
grpc_slice path;
|
139
137
|
grpc_slice host;
|
140
|
-
|
138
|
+
grpc_millis deadline;
|
141
139
|
|
142
|
-
grpc_completion_queue
|
140
|
+
grpc_completion_queue* cq_new;
|
143
141
|
|
144
|
-
grpc_metadata_batch
|
142
|
+
grpc_metadata_batch* recv_initial_metadata;
|
145
143
|
uint32_t recv_initial_metadata_flags;
|
146
144
|
grpc_metadata_array initial_metadata;
|
147
145
|
|
148
|
-
request_matcher
|
149
|
-
grpc_byte_buffer
|
146
|
+
request_matcher* matcher;
|
147
|
+
grpc_byte_buffer* payload;
|
150
148
|
|
151
149
|
grpc_closure got_initial_metadata;
|
152
150
|
grpc_closure server_on_recv_initial_metadata;
|
153
151
|
grpc_closure kill_zombie_closure;
|
154
|
-
grpc_closure
|
152
|
+
grpc_closure* on_done_recv_initial_metadata;
|
155
153
|
|
156
154
|
grpc_closure publish;
|
157
155
|
|
158
|
-
call_data
|
156
|
+
call_data* pending_next;
|
159
157
|
};
|
160
158
|
|
161
159
|
struct request_matcher {
|
162
|
-
grpc_server
|
163
|
-
call_data
|
164
|
-
call_data
|
165
|
-
|
160
|
+
grpc_server* server;
|
161
|
+
call_data* pending_head;
|
162
|
+
call_data* pending_tail;
|
163
|
+
gpr_locked_mpscq* requests_per_cq;
|
166
164
|
};
|
167
165
|
|
168
166
|
struct registered_method {
|
169
|
-
char
|
170
|
-
char
|
167
|
+
char* method;
|
168
|
+
char* host;
|
171
169
|
grpc_server_register_method_payload_handling payload_handling;
|
172
170
|
uint32_t flags;
|
173
171
|
/* one request matcher per method */
|
174
172
|
request_matcher matcher;
|
175
|
-
registered_method
|
173
|
+
registered_method* next;
|
176
174
|
};
|
177
175
|
|
178
176
|
typedef struct {
|
179
|
-
grpc_channel
|
177
|
+
grpc_channel** channels;
|
180
178
|
size_t num_channels;
|
181
179
|
} channel_broadcaster;
|
182
180
|
|
183
181
|
struct grpc_server {
|
184
|
-
grpc_channel_args
|
182
|
+
grpc_channel_args* channel_args;
|
185
183
|
|
186
|
-
grpc_completion_queue
|
187
|
-
grpc_pollset
|
184
|
+
grpc_completion_queue** cqs;
|
185
|
+
grpc_pollset** pollsets;
|
188
186
|
size_t cq_count;
|
189
187
|
size_t pollset_count;
|
190
188
|
bool started;
|
@@ -204,23 +202,18 @@ struct grpc_server {
|
|
204
202
|
bool starting;
|
205
203
|
gpr_cv starting_cv;
|
206
204
|
|
207
|
-
registered_method
|
205
|
+
registered_method* registered_methods;
|
208
206
|
/** one request matcher for unregistered methods */
|
209
207
|
request_matcher unregistered_request_matcher;
|
210
|
-
/** free list of available requested_calls_per_cq indices */
|
211
|
-
gpr_stack_lockfree **request_freelist_per_cq;
|
212
|
-
/** requested call backing data */
|
213
|
-
requested_call **requested_calls_per_cq;
|
214
|
-
int max_requested_calls_per_cq;
|
215
208
|
|
216
209
|
gpr_atm shutdown_flag;
|
217
210
|
uint8_t shutdown_published;
|
218
211
|
size_t num_shutdown_tags;
|
219
|
-
shutdown_tag
|
212
|
+
shutdown_tag* shutdown_tags;
|
220
213
|
|
221
214
|
channel_data root_channel_data;
|
222
215
|
|
223
|
-
listener
|
216
|
+
listener* listeners;
|
224
217
|
int listeners_destroyed;
|
225
218
|
gpr_refcount internal_refcount;
|
226
219
|
|
@@ -229,30 +222,30 @@ struct grpc_server {
|
|
229
222
|
};
|
230
223
|
|
231
224
|
#define SERVER_FROM_CALL_ELEM(elem) \
|
232
|
-
(((channel_data
|
225
|
+
(((channel_data*)(elem)->channel_data)->server)
|
233
226
|
|
234
|
-
static void publish_new_rpc(grpc_exec_ctx
|
235
|
-
grpc_error
|
236
|
-
static void fail_call(grpc_exec_ctx
|
237
|
-
size_t cq_idx, requested_call
|
227
|
+
static void publish_new_rpc(grpc_exec_ctx* exec_ctx, void* calld,
|
228
|
+
grpc_error* error);
|
229
|
+
static void fail_call(grpc_exec_ctx* exec_ctx, grpc_server* server,
|
230
|
+
size_t cq_idx, requested_call* rc, grpc_error* error);
|
238
231
|
/* Before calling maybe_finish_shutdown, we must hold mu_global and not
|
239
232
|
hold mu_call */
|
240
|
-
static void maybe_finish_shutdown(grpc_exec_ctx
|
233
|
+
static void maybe_finish_shutdown(grpc_exec_ctx* exec_ctx, grpc_server* server);
|
241
234
|
|
242
235
|
/*
|
243
236
|
* channel broadcaster
|
244
237
|
*/
|
245
238
|
|
246
239
|
/* assumes server locked */
|
247
|
-
static void channel_broadcaster_init(grpc_server
|
248
|
-
channel_data
|
240
|
+
static void channel_broadcaster_init(grpc_server* s, channel_broadcaster* cb) {
|
241
|
+
channel_data* c;
|
249
242
|
size_t count = 0;
|
250
243
|
for (c = s->root_channel_data.next; c != &s->root_channel_data; c = c->next) {
|
251
244
|
count++;
|
252
245
|
}
|
253
246
|
cb->num_channels = count;
|
254
247
|
cb->channels =
|
255
|
-
(grpc_channel
|
248
|
+
(grpc_channel**)gpr_malloc(sizeof(*cb->channels) * cb->num_channels);
|
256
249
|
count = 0;
|
257
250
|
for (c = s->root_channel_data.next; c != &s->root_channel_data; c = c->next) {
|
258
251
|
cb->channels[count++] = c->channel;
|
@@ -265,21 +258,21 @@ struct shutdown_cleanup_args {
|
|
265
258
|
grpc_slice slice;
|
266
259
|
};
|
267
260
|
|
268
|
-
static void shutdown_cleanup(grpc_exec_ctx
|
269
|
-
grpc_error
|
270
|
-
struct shutdown_cleanup_args
|
261
|
+
static void shutdown_cleanup(grpc_exec_ctx* exec_ctx, void* arg,
|
262
|
+
grpc_error* error) {
|
263
|
+
struct shutdown_cleanup_args* a = (struct shutdown_cleanup_args*)arg;
|
271
264
|
grpc_slice_unref_internal(exec_ctx, a->slice);
|
272
265
|
gpr_free(a);
|
273
266
|
}
|
274
267
|
|
275
|
-
static void send_shutdown(grpc_exec_ctx
|
276
|
-
bool send_goaway, grpc_error
|
277
|
-
struct shutdown_cleanup_args
|
278
|
-
(struct shutdown_cleanup_args
|
268
|
+
static void send_shutdown(grpc_exec_ctx* exec_ctx, grpc_channel* channel,
|
269
|
+
bool send_goaway, grpc_error* send_disconnect) {
|
270
|
+
struct shutdown_cleanup_args* sc =
|
271
|
+
(struct shutdown_cleanup_args*)gpr_malloc(sizeof(*sc));
|
279
272
|
GRPC_CLOSURE_INIT(&sc->closure, shutdown_cleanup, sc,
|
280
273
|
grpc_schedule_on_exec_ctx);
|
281
|
-
grpc_transport_op
|
282
|
-
grpc_channel_element
|
274
|
+
grpc_transport_op* op = grpc_make_transport_op(&sc->closure);
|
275
|
+
grpc_channel_element* elem;
|
283
276
|
|
284
277
|
op->goaway_error =
|
285
278
|
send_goaway ? grpc_error_set_int(
|
@@ -294,10 +287,10 @@ static void send_shutdown(grpc_exec_ctx *exec_ctx, grpc_channel *channel,
|
|
294
287
|
elem->filter->start_transport_op(exec_ctx, elem, op);
|
295
288
|
}
|
296
289
|
|
297
|
-
static void channel_broadcaster_shutdown(grpc_exec_ctx
|
298
|
-
channel_broadcaster
|
290
|
+
static void channel_broadcaster_shutdown(grpc_exec_ctx* exec_ctx,
|
291
|
+
channel_broadcaster* cb,
|
299
292
|
bool send_goaway,
|
300
|
-
grpc_error
|
293
|
+
grpc_error* force_disconnect) {
|
301
294
|
size_t i;
|
302
295
|
|
303
296
|
for (i = 0; i < cb->num_channels; i++) {
|
@@ -313,38 +306,35 @@ static void channel_broadcaster_shutdown(grpc_exec_ctx *exec_ctx,
|
|
313
306
|
* request_matcher
|
314
307
|
*/
|
315
308
|
|
316
|
-
static void request_matcher_init(request_matcher
|
317
|
-
grpc_server *server) {
|
309
|
+
static void request_matcher_init(request_matcher* rm, grpc_server* server) {
|
318
310
|
memset(rm, 0, sizeof(*rm));
|
319
311
|
rm->server = server;
|
320
|
-
rm->requests_per_cq = (
|
312
|
+
rm->requests_per_cq = (gpr_locked_mpscq*)gpr_malloc(
|
321
313
|
sizeof(*rm->requests_per_cq) * server->cq_count);
|
322
314
|
for (size_t i = 0; i < server->cq_count; i++) {
|
323
|
-
rm->requests_per_cq[i]
|
315
|
+
gpr_locked_mpscq_init(&rm->requests_per_cq[i]);
|
324
316
|
}
|
325
317
|
}
|
326
318
|
|
327
|
-
static void request_matcher_destroy(request_matcher
|
319
|
+
static void request_matcher_destroy(request_matcher* rm) {
|
328
320
|
for (size_t i = 0; i < rm->server->cq_count; i++) {
|
329
|
-
GPR_ASSERT(
|
330
|
-
|
321
|
+
GPR_ASSERT(gpr_locked_mpscq_pop(&rm->requests_per_cq[i]) == nullptr);
|
322
|
+
gpr_locked_mpscq_destroy(&rm->requests_per_cq[i]);
|
331
323
|
}
|
332
324
|
gpr_free(rm->requests_per_cq);
|
333
325
|
}
|
334
326
|
|
335
|
-
static void kill_zombie(grpc_exec_ctx
|
336
|
-
grpc_error
|
337
|
-
grpc_call_unref(grpc_call_from_top_element((grpc_call_element
|
327
|
+
static void kill_zombie(grpc_exec_ctx* exec_ctx, void* elem,
|
328
|
+
grpc_error* error) {
|
329
|
+
grpc_call_unref(grpc_call_from_top_element((grpc_call_element*)elem));
|
338
330
|
}
|
339
331
|
|
340
|
-
static void request_matcher_zombify_all_pending_calls(grpc_exec_ctx
|
341
|
-
request_matcher
|
332
|
+
static void request_matcher_zombify_all_pending_calls(grpc_exec_ctx* exec_ctx,
|
333
|
+
request_matcher* rm) {
|
342
334
|
while (rm->pending_head) {
|
343
|
-
call_data
|
335
|
+
call_data* calld = rm->pending_head;
|
344
336
|
rm->pending_head = calld->pending_next;
|
345
|
-
|
346
|
-
calld->state = ZOMBIED;
|
347
|
-
gpr_mu_unlock(&calld->mu_state);
|
337
|
+
gpr_atm_no_barrier_store(&calld->state, ZOMBIED);
|
348
338
|
GRPC_CLOSURE_INIT(
|
349
339
|
&calld->kill_zombie_closure, kill_zombie,
|
350
340
|
grpc_call_stack_element(grpc_call_get_call_stack(calld->call), 0),
|
@@ -353,17 +343,15 @@ static void request_matcher_zombify_all_pending_calls(grpc_exec_ctx *exec_ctx,
|
|
353
343
|
}
|
354
344
|
}
|
355
345
|
|
356
|
-
static void request_matcher_kill_requests(grpc_exec_ctx
|
357
|
-
grpc_server
|
358
|
-
request_matcher
|
359
|
-
grpc_error
|
360
|
-
|
346
|
+
static void request_matcher_kill_requests(grpc_exec_ctx* exec_ctx,
|
347
|
+
grpc_server* server,
|
348
|
+
request_matcher* rm,
|
349
|
+
grpc_error* error) {
|
350
|
+
requested_call* rc;
|
361
351
|
for (size_t i = 0; i < server->cq_count; i++) {
|
362
|
-
while ((
|
363
|
-
|
364
|
-
fail_call(exec_ctx, server, i,
|
365
|
-
&server->requested_calls_per_cq[i][request_id],
|
366
|
-
GRPC_ERROR_REF(error));
|
352
|
+
while ((rc = (requested_call*)gpr_locked_mpscq_pop(
|
353
|
+
&rm->requests_per_cq[i])) != nullptr) {
|
354
|
+
fail_call(exec_ctx, server, i, rc, GRPC_ERROR_REF(error));
|
367
355
|
}
|
368
356
|
}
|
369
357
|
GRPC_ERROR_UNREF(error);
|
@@ -373,18 +361,18 @@ static void request_matcher_kill_requests(grpc_exec_ctx *exec_ctx,
|
|
373
361
|
* server proper
|
374
362
|
*/
|
375
363
|
|
376
|
-
static void server_ref(grpc_server
|
364
|
+
static void server_ref(grpc_server* server) {
|
377
365
|
gpr_ref(&server->internal_refcount);
|
378
366
|
}
|
379
367
|
|
380
|
-
static void server_delete(grpc_exec_ctx
|
381
|
-
registered_method
|
368
|
+
static void server_delete(grpc_exec_ctx* exec_ctx, grpc_server* server) {
|
369
|
+
registered_method* rm;
|
382
370
|
size_t i;
|
383
371
|
grpc_channel_args_destroy(exec_ctx, server->channel_args);
|
384
372
|
gpr_mu_destroy(&server->mu_global);
|
385
373
|
gpr_mu_destroy(&server->mu_call);
|
386
374
|
gpr_cv_destroy(&server->starting_cv);
|
387
|
-
while ((rm = server->registered_methods) !=
|
375
|
+
while ((rm = server->registered_methods) != nullptr) {
|
388
376
|
server->registered_methods = rm->next;
|
389
377
|
if (server->started) {
|
390
378
|
request_matcher_destroy(&rm->matcher);
|
@@ -398,60 +386,54 @@ static void server_delete(grpc_exec_ctx *exec_ctx, grpc_server *server) {
|
|
398
386
|
}
|
399
387
|
for (i = 0; i < server->cq_count; i++) {
|
400
388
|
GRPC_CQ_INTERNAL_UNREF(exec_ctx, server->cqs[i], "server");
|
401
|
-
if (server->started) {
|
402
|
-
gpr_stack_lockfree_destroy(server->request_freelist_per_cq[i]);
|
403
|
-
gpr_free(server->requested_calls_per_cq[i]);
|
404
|
-
}
|
405
389
|
}
|
406
|
-
gpr_free(server->request_freelist_per_cq);
|
407
|
-
gpr_free(server->requested_calls_per_cq);
|
408
390
|
gpr_free(server->cqs);
|
409
391
|
gpr_free(server->pollsets);
|
410
392
|
gpr_free(server->shutdown_tags);
|
411
393
|
gpr_free(server);
|
412
394
|
}
|
413
395
|
|
414
|
-
static void server_unref(grpc_exec_ctx
|
396
|
+
static void server_unref(grpc_exec_ctx* exec_ctx, grpc_server* server) {
|
415
397
|
if (gpr_unref(&server->internal_refcount)) {
|
416
398
|
server_delete(exec_ctx, server);
|
417
399
|
}
|
418
400
|
}
|
419
401
|
|
420
|
-
static int is_channel_orphaned(channel_data
|
402
|
+
static int is_channel_orphaned(channel_data* chand) {
|
421
403
|
return chand->next == chand;
|
422
404
|
}
|
423
405
|
|
424
|
-
static void orphan_channel(channel_data
|
406
|
+
static void orphan_channel(channel_data* chand) {
|
425
407
|
chand->next->prev = chand->prev;
|
426
408
|
chand->prev->next = chand->next;
|
427
409
|
chand->next = chand->prev = chand;
|
428
410
|
}
|
429
411
|
|
430
|
-
static void finish_destroy_channel(grpc_exec_ctx
|
431
|
-
grpc_error
|
432
|
-
channel_data
|
433
|
-
grpc_server
|
412
|
+
static void finish_destroy_channel(grpc_exec_ctx* exec_ctx, void* cd,
|
413
|
+
grpc_error* error) {
|
414
|
+
channel_data* chand = (channel_data*)cd;
|
415
|
+
grpc_server* server = chand->server;
|
434
416
|
GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, chand->channel, "server");
|
435
417
|
server_unref(exec_ctx, server);
|
436
418
|
}
|
437
419
|
|
438
|
-
static void destroy_channel(grpc_exec_ctx
|
439
|
-
grpc_error
|
420
|
+
static void destroy_channel(grpc_exec_ctx* exec_ctx, channel_data* chand,
|
421
|
+
grpc_error* error) {
|
440
422
|
if (is_channel_orphaned(chand)) return;
|
441
|
-
GPR_ASSERT(chand->server !=
|
423
|
+
GPR_ASSERT(chand->server != nullptr);
|
442
424
|
orphan_channel(chand);
|
443
425
|
server_ref(chand->server);
|
444
426
|
maybe_finish_shutdown(exec_ctx, chand->server);
|
445
427
|
GRPC_CLOSURE_INIT(&chand->finish_destroy_channel_closure,
|
446
428
|
finish_destroy_channel, chand, grpc_schedule_on_exec_ctx);
|
447
429
|
|
448
|
-
if (
|
449
|
-
const char
|
430
|
+
if (grpc_server_channel_trace.enabled() && error != GRPC_ERROR_NONE) {
|
431
|
+
const char* msg = grpc_error_string(error);
|
450
432
|
gpr_log(GPR_INFO, "Disconnected client: %s", msg);
|
451
433
|
}
|
452
434
|
GRPC_ERROR_UNREF(error);
|
453
435
|
|
454
|
-
grpc_transport_op
|
436
|
+
grpc_transport_op* op =
|
455
437
|
grpc_make_transport_op(&chand->finish_destroy_channel_closure);
|
456
438
|
op->set_accept_stream = true;
|
457
439
|
grpc_channel_next_op(exec_ctx,
|
@@ -460,29 +442,15 @@ static void destroy_channel(grpc_exec_ctx *exec_ctx, channel_data *chand,
|
|
460
442
|
op);
|
461
443
|
}
|
462
444
|
|
463
|
-
static void done_request_event(grpc_exec_ctx
|
464
|
-
grpc_cq_completion
|
465
|
-
|
466
|
-
grpc_server *server = rc->server;
|
467
|
-
|
468
|
-
if (rc >= server->requested_calls_per_cq[rc->cq_idx] &&
|
469
|
-
rc < server->requested_calls_per_cq[rc->cq_idx] +
|
470
|
-
server->max_requested_calls_per_cq) {
|
471
|
-
GPR_ASSERT(rc - server->requested_calls_per_cq[rc->cq_idx] <= INT_MAX);
|
472
|
-
gpr_stack_lockfree_push(
|
473
|
-
server->request_freelist_per_cq[rc->cq_idx],
|
474
|
-
(int)(rc - server->requested_calls_per_cq[rc->cq_idx]));
|
475
|
-
} else {
|
476
|
-
gpr_free(req);
|
477
|
-
}
|
478
|
-
|
479
|
-
server_unref(exec_ctx, server);
|
445
|
+
static void done_request_event(grpc_exec_ctx* exec_ctx, void* req,
|
446
|
+
grpc_cq_completion* c) {
|
447
|
+
gpr_free(req);
|
480
448
|
}
|
481
449
|
|
482
|
-
static void publish_call(grpc_exec_ctx
|
483
|
-
call_data
|
450
|
+
static void publish_call(grpc_exec_ctx* exec_ctx, grpc_server* server,
|
451
|
+
call_data* calld, size_t cq_idx, requested_call* rc) {
|
484
452
|
grpc_call_set_completion_queue(exec_ctx, calld->call, rc->cq_bound_to_call);
|
485
|
-
grpc_call
|
453
|
+
grpc_call* call = calld->call;
|
486
454
|
*rc->call = call;
|
487
455
|
calld->cq_new = server->cqs[cq_idx];
|
488
456
|
GPR_SWAP(grpc_metadata_array, *rc->initial_metadata, calld->initial_metadata);
|
@@ -492,40 +460,36 @@ static void publish_call(grpc_exec_ctx *exec_ctx, grpc_server *server,
|
|
492
460
|
GPR_ASSERT(calld->path_set);
|
493
461
|
rc->data.batch.details->host = grpc_slice_ref_internal(calld->host);
|
494
462
|
rc->data.batch.details->method = grpc_slice_ref_internal(calld->path);
|
495
|
-
rc->data.batch.details->deadline =
|
463
|
+
rc->data.batch.details->deadline =
|
464
|
+
grpc_millis_to_timespec(calld->deadline, GPR_CLOCK_MONOTONIC);
|
496
465
|
rc->data.batch.details->flags = calld->recv_initial_metadata_flags;
|
497
466
|
break;
|
498
467
|
case REGISTERED_CALL:
|
499
|
-
*rc->data.registered.deadline =
|
468
|
+
*rc->data.registered.deadline =
|
469
|
+
grpc_millis_to_timespec(calld->deadline, GPR_CLOCK_MONOTONIC);
|
500
470
|
if (rc->data.registered.optional_payload) {
|
501
471
|
*rc->data.registered.optional_payload = calld->payload;
|
502
|
-
calld->payload =
|
472
|
+
calld->payload = nullptr;
|
503
473
|
}
|
504
474
|
break;
|
505
475
|
default:
|
506
476
|
GPR_UNREACHABLE_CODE(return );
|
507
477
|
}
|
508
478
|
|
509
|
-
grpc_call_element *elem =
|
510
|
-
grpc_call_stack_element(grpc_call_get_call_stack(call), 0);
|
511
|
-
channel_data *chand = (channel_data *)elem->channel_data;
|
512
|
-
server_ref(chand->server);
|
513
479
|
grpc_cq_end_op(exec_ctx, calld->cq_new, rc->tag, GRPC_ERROR_NONE,
|
514
480
|
done_request_event, rc, &rc->completion);
|
515
481
|
}
|
516
482
|
|
517
|
-
static void publish_new_rpc(grpc_exec_ctx
|
518
|
-
grpc_error
|
519
|
-
grpc_call_element
|
520
|
-
call_data
|
521
|
-
channel_data
|
522
|
-
request_matcher
|
523
|
-
grpc_server
|
483
|
+
static void publish_new_rpc(grpc_exec_ctx* exec_ctx, void* arg,
|
484
|
+
grpc_error* error) {
|
485
|
+
grpc_call_element* call_elem = (grpc_call_element*)arg;
|
486
|
+
call_data* calld = (call_data*)call_elem->call_data;
|
487
|
+
channel_data* chand = (channel_data*)call_elem->channel_data;
|
488
|
+
request_matcher* rm = calld->matcher;
|
489
|
+
grpc_server* server = rm->server;
|
524
490
|
|
525
491
|
if (error != GRPC_ERROR_NONE || gpr_atm_acq_load(&server->shutdown_flag)) {
|
526
|
-
|
527
|
-
calld->state = ZOMBIED;
|
528
|
-
gpr_mu_unlock(&calld->mu_state);
|
492
|
+
gpr_atm_no_barrier_store(&calld->state, ZOMBIED);
|
529
493
|
GRPC_CLOSURE_INIT(
|
530
494
|
&calld->kill_zombie_closure, kill_zombie,
|
531
495
|
grpc_call_stack_element(grpc_call_get_call_stack(calld->call), 0),
|
@@ -537,16 +501,14 @@ static void publish_new_rpc(grpc_exec_ctx *exec_ctx, void *arg,
|
|
537
501
|
|
538
502
|
for (size_t i = 0; i < server->cq_count; i++) {
|
539
503
|
size_t cq_idx = (chand->cq_idx + i) % server->cq_count;
|
540
|
-
|
541
|
-
|
504
|
+
requested_call* rc =
|
505
|
+
(requested_call*)gpr_locked_mpscq_try_pop(&rm->requests_per_cq[cq_idx]);
|
506
|
+
if (rc == nullptr) {
|
542
507
|
continue;
|
543
508
|
} else {
|
544
509
|
GRPC_STATS_INC_SERVER_CQS_CHECKED(exec_ctx, i);
|
545
|
-
|
546
|
-
calld
|
547
|
-
gpr_mu_unlock(&calld->mu_state);
|
548
|
-
publish_call(exec_ctx, server, calld, cq_idx,
|
549
|
-
&server->requested_calls_per_cq[cq_idx][request_id]);
|
510
|
+
gpr_atm_no_barrier_store(&calld->state, ACTIVATED);
|
511
|
+
publish_call(exec_ctx, server, calld, cq_idx, rc);
|
550
512
|
return; /* early out */
|
551
513
|
}
|
552
514
|
}
|
@@ -554,29 +516,45 @@ static void publish_new_rpc(grpc_exec_ctx *exec_ctx, void *arg,
|
|
554
516
|
/* no cq to take the request found: queue it on the slow list */
|
555
517
|
GRPC_STATS_INC_SERVER_SLOWPATH_REQUESTS_QUEUED(exec_ctx);
|
556
518
|
gpr_mu_lock(&server->mu_call);
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
519
|
+
|
520
|
+
// We need to ensure that all the queues are empty. We do this under
|
521
|
+
// the server mu_call lock to ensure that if something is added to
|
522
|
+
// an empty request queue, it will block until the call is actually
|
523
|
+
// added to the pending list.
|
524
|
+
for (size_t i = 0; i < server->cq_count; i++) {
|
525
|
+
size_t cq_idx = (chand->cq_idx + i) % server->cq_count;
|
526
|
+
requested_call* rc =
|
527
|
+
(requested_call*)gpr_locked_mpscq_pop(&rm->requests_per_cq[cq_idx]);
|
528
|
+
if (rc == nullptr) {
|
529
|
+
continue;
|
530
|
+
} else {
|
531
|
+
gpr_mu_unlock(&server->mu_call);
|
532
|
+
GRPC_STATS_INC_SERVER_CQS_CHECKED(exec_ctx, i + server->cq_count);
|
533
|
+
gpr_atm_no_barrier_store(&calld->state, ACTIVATED);
|
534
|
+
publish_call(exec_ctx, server, calld, cq_idx, rc);
|
535
|
+
return; /* early out */
|
536
|
+
}
|
537
|
+
}
|
538
|
+
|
539
|
+
gpr_atm_no_barrier_store(&calld->state, PENDING);
|
540
|
+
if (rm->pending_head == nullptr) {
|
561
541
|
rm->pending_tail = rm->pending_head = calld;
|
562
542
|
} else {
|
563
543
|
rm->pending_tail->pending_next = calld;
|
564
544
|
rm->pending_tail = calld;
|
565
545
|
}
|
566
|
-
calld->pending_next =
|
546
|
+
calld->pending_next = nullptr;
|
567
547
|
gpr_mu_unlock(&server->mu_call);
|
568
548
|
}
|
569
549
|
|
570
550
|
static void finish_start_new_rpc(
|
571
|
-
grpc_exec_ctx
|
572
|
-
request_matcher
|
551
|
+
grpc_exec_ctx* exec_ctx, grpc_server* server, grpc_call_element* elem,
|
552
|
+
request_matcher* rm,
|
573
553
|
grpc_server_register_method_payload_handling payload_handling) {
|
574
|
-
call_data
|
554
|
+
call_data* calld = (call_data*)elem->call_data;
|
575
555
|
|
576
556
|
if (gpr_atm_acq_load(&server->shutdown_flag)) {
|
577
|
-
|
578
|
-
calld->state = ZOMBIED;
|
579
|
-
gpr_mu_unlock(&calld->mu_state);
|
557
|
+
gpr_atm_no_barrier_store(&calld->state, ZOMBIED);
|
580
558
|
GRPC_CLOSURE_INIT(&calld->kill_zombie_closure, kill_zombie, elem,
|
581
559
|
grpc_schedule_on_exec_ctx);
|
582
560
|
GRPC_CLOSURE_SCHED(exec_ctx, &calld->kill_zombie_closure, GRPC_ERROR_NONE);
|
@@ -603,13 +581,13 @@ static void finish_start_new_rpc(
|
|
603
581
|
}
|
604
582
|
}
|
605
583
|
|
606
|
-
static void start_new_rpc(grpc_exec_ctx
|
607
|
-
channel_data
|
608
|
-
call_data
|
609
|
-
grpc_server
|
584
|
+
static void start_new_rpc(grpc_exec_ctx* exec_ctx, grpc_call_element* elem) {
|
585
|
+
channel_data* chand = (channel_data*)elem->channel_data;
|
586
|
+
call_data* calld = (call_data*)elem->call_data;
|
587
|
+
grpc_server* server = chand->server;
|
610
588
|
uint32_t i;
|
611
589
|
uint32_t hash;
|
612
|
-
channel_registered_method
|
590
|
+
channel_registered_method* rm;
|
613
591
|
|
614
592
|
if (chand->registered_methods && calld->path_set && calld->host_set) {
|
615
593
|
/* TODO(ctiller): unify these two searches */
|
@@ -657,8 +635,8 @@ static void start_new_rpc(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
|
|
657
635
|
GRPC_SRM_PAYLOAD_NONE);
|
658
636
|
}
|
659
637
|
|
660
|
-
static int num_listeners(grpc_server
|
661
|
-
listener
|
638
|
+
static int num_listeners(grpc_server* server) {
|
639
|
+
listener* l;
|
662
640
|
int n = 0;
|
663
641
|
for (l = server->listeners; l; l = l->next) {
|
664
642
|
n++;
|
@@ -666,13 +644,13 @@ static int num_listeners(grpc_server *server) {
|
|
666
644
|
return n;
|
667
645
|
}
|
668
646
|
|
669
|
-
static void done_shutdown_event(grpc_exec_ctx
|
670
|
-
grpc_cq_completion
|
671
|
-
server_unref(exec_ctx, (grpc_server
|
647
|
+
static void done_shutdown_event(grpc_exec_ctx* exec_ctx, void* server,
|
648
|
+
grpc_cq_completion* completion) {
|
649
|
+
server_unref(exec_ctx, (grpc_server*)server);
|
672
650
|
}
|
673
651
|
|
674
|
-
static int num_channels(grpc_server
|
675
|
-
channel_data
|
652
|
+
static int num_channels(grpc_server* server) {
|
653
|
+
channel_data* chand;
|
676
654
|
int n = 0;
|
677
655
|
for (chand = server->root_channel_data.next;
|
678
656
|
chand != &server->root_channel_data; chand = chand->next) {
|
@@ -681,15 +659,15 @@ static int num_channels(grpc_server *server) {
|
|
681
659
|
return n;
|
682
660
|
}
|
683
661
|
|
684
|
-
static void kill_pending_work_locked(grpc_exec_ctx
|
685
|
-
grpc_server
|
662
|
+
static void kill_pending_work_locked(grpc_exec_ctx* exec_ctx,
|
663
|
+
grpc_server* server, grpc_error* error) {
|
686
664
|
if (server->started) {
|
687
665
|
request_matcher_kill_requests(exec_ctx, server,
|
688
666
|
&server->unregistered_request_matcher,
|
689
667
|
GRPC_ERROR_REF(error));
|
690
668
|
request_matcher_zombify_all_pending_calls(
|
691
669
|
exec_ctx, &server->unregistered_request_matcher);
|
692
|
-
for (registered_method
|
670
|
+
for (registered_method* rm = server->registered_methods; rm;
|
693
671
|
rm = rm->next) {
|
694
672
|
request_matcher_kill_requests(exec_ctx, server, &rm->matcher,
|
695
673
|
GRPC_ERROR_REF(error));
|
@@ -699,8 +677,8 @@ static void kill_pending_work_locked(grpc_exec_ctx *exec_ctx,
|
|
699
677
|
GRPC_ERROR_UNREF(error);
|
700
678
|
}
|
701
679
|
|
702
|
-
static void maybe_finish_shutdown(grpc_exec_ctx
|
703
|
-
grpc_server
|
680
|
+
static void maybe_finish_shutdown(grpc_exec_ctx* exec_ctx,
|
681
|
+
grpc_server* server) {
|
704
682
|
size_t i;
|
705
683
|
if (!gpr_atm_acq_load(&server->shutdown_flag) || server->shutdown_published) {
|
706
684
|
return;
|
@@ -735,15 +713,15 @@ static void maybe_finish_shutdown(grpc_exec_ctx *exec_ctx,
|
|
735
713
|
}
|
736
714
|
}
|
737
715
|
|
738
|
-
static void server_on_recv_initial_metadata(grpc_exec_ctx
|
739
|
-
grpc_error
|
740
|
-
grpc_call_element
|
741
|
-
call_data
|
742
|
-
|
716
|
+
static void server_on_recv_initial_metadata(grpc_exec_ctx* exec_ctx, void* ptr,
|
717
|
+
grpc_error* error) {
|
718
|
+
grpc_call_element* elem = (grpc_call_element*)ptr;
|
719
|
+
call_data* calld = (call_data*)elem->call_data;
|
720
|
+
grpc_millis op_deadline;
|
743
721
|
|
744
722
|
if (error == GRPC_ERROR_NONE) {
|
745
|
-
GPR_ASSERT(calld->recv_initial_metadata->idx.named.path !=
|
746
|
-
GPR_ASSERT(calld->recv_initial_metadata->idx.named.authority !=
|
723
|
+
GPR_ASSERT(calld->recv_initial_metadata->idx.named.path != nullptr);
|
724
|
+
GPR_ASSERT(calld->recv_initial_metadata->idx.named.authority != nullptr);
|
747
725
|
calld->path = grpc_slice_ref_internal(
|
748
726
|
GRPC_MDVALUE(calld->recv_initial_metadata->idx.named.path->md));
|
749
727
|
calld->host = grpc_slice_ref_internal(
|
@@ -759,13 +737,13 @@ static void server_on_recv_initial_metadata(grpc_exec_ctx *exec_ctx, void *ptr,
|
|
759
737
|
GRPC_ERROR_REF(error);
|
760
738
|
}
|
761
739
|
op_deadline = calld->recv_initial_metadata->deadline;
|
762
|
-
if (
|
740
|
+
if (op_deadline != GRPC_MILLIS_INF_FUTURE) {
|
763
741
|
calld->deadline = op_deadline;
|
764
742
|
}
|
765
743
|
if (calld->host_set && calld->path_set) {
|
766
744
|
/* do nothing */
|
767
745
|
} else {
|
768
|
-
grpc_error
|
746
|
+
grpc_error* src_error = error;
|
769
747
|
error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
770
748
|
"Missing :authority or :path", &error, 1);
|
771
749
|
GRPC_ERROR_UNREF(src_error);
|
@@ -774,12 +752,12 @@ static void server_on_recv_initial_metadata(grpc_exec_ctx *exec_ctx, void *ptr,
|
|
774
752
|
GRPC_CLOSURE_RUN(exec_ctx, calld->on_done_recv_initial_metadata, error);
|
775
753
|
}
|
776
754
|
|
777
|
-
static void server_mutate_op(grpc_call_element
|
778
|
-
grpc_transport_stream_op_batch
|
779
|
-
call_data
|
755
|
+
static void server_mutate_op(grpc_call_element* elem,
|
756
|
+
grpc_transport_stream_op_batch* op) {
|
757
|
+
call_data* calld = (call_data*)elem->call_data;
|
780
758
|
|
781
759
|
if (op->recv_initial_metadata) {
|
782
|
-
GPR_ASSERT(op->payload->recv_initial_metadata.recv_flags ==
|
760
|
+
GPR_ASSERT(op->payload->recv_initial_metadata.recv_flags == nullptr);
|
783
761
|
calld->recv_initial_metadata =
|
784
762
|
op->payload->recv_initial_metadata.recv_initial_metadata;
|
785
763
|
calld->on_done_recv_initial_metadata =
|
@@ -792,58 +770,51 @@ static void server_mutate_op(grpc_call_element *elem,
|
|
792
770
|
}
|
793
771
|
|
794
772
|
static void server_start_transport_stream_op_batch(
|
795
|
-
grpc_exec_ctx
|
796
|
-
grpc_transport_stream_op_batch
|
773
|
+
grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
|
774
|
+
grpc_transport_stream_op_batch* op) {
|
797
775
|
server_mutate_op(elem, op);
|
798
776
|
grpc_call_next_op(exec_ctx, elem, op);
|
799
777
|
}
|
800
778
|
|
801
|
-
static void got_initial_metadata(grpc_exec_ctx
|
802
|
-
grpc_error
|
803
|
-
grpc_call_element
|
804
|
-
call_data
|
779
|
+
static void got_initial_metadata(grpc_exec_ctx* exec_ctx, void* ptr,
|
780
|
+
grpc_error* error) {
|
781
|
+
grpc_call_element* elem = (grpc_call_element*)ptr;
|
782
|
+
call_data* calld = (call_data*)elem->call_data;
|
805
783
|
if (error == GRPC_ERROR_NONE) {
|
806
784
|
start_new_rpc(exec_ctx, elem);
|
807
785
|
} else {
|
808
|
-
|
809
|
-
if (calld->state == NOT_STARTED) {
|
810
|
-
calld->state = ZOMBIED;
|
811
|
-
gpr_mu_unlock(&calld->mu_state);
|
786
|
+
if (gpr_atm_full_cas(&calld->state, NOT_STARTED, ZOMBIED)) {
|
812
787
|
GRPC_CLOSURE_INIT(&calld->kill_zombie_closure, kill_zombie, elem,
|
813
788
|
grpc_schedule_on_exec_ctx);
|
814
789
|
GRPC_CLOSURE_SCHED(exec_ctx, &calld->kill_zombie_closure,
|
815
790
|
GRPC_ERROR_NONE);
|
816
|
-
} else if (calld->state
|
817
|
-
calld->state = ZOMBIED;
|
818
|
-
gpr_mu_unlock(&calld->mu_state);
|
791
|
+
} else if (gpr_atm_full_cas(&calld->state, PENDING, ZOMBIED)) {
|
819
792
|
/* zombied call will be destroyed when it's removed from the pending
|
820
793
|
queue... later */
|
821
|
-
} else {
|
822
|
-
gpr_mu_unlock(&calld->mu_state);
|
823
794
|
}
|
824
795
|
}
|
825
796
|
}
|
826
797
|
|
827
|
-
static void accept_stream(grpc_exec_ctx
|
828
|
-
grpc_transport
|
829
|
-
const void
|
830
|
-
channel_data
|
798
|
+
static void accept_stream(grpc_exec_ctx* exec_ctx, void* cd,
|
799
|
+
grpc_transport* transport,
|
800
|
+
const void* transport_server_data) {
|
801
|
+
channel_data* chand = (channel_data*)cd;
|
831
802
|
/* create a call */
|
832
803
|
grpc_call_create_args args;
|
833
804
|
memset(&args, 0, sizeof(args));
|
834
805
|
args.channel = chand->channel;
|
835
806
|
args.server_transport_data = transport_server_data;
|
836
|
-
args.send_deadline =
|
837
|
-
grpc_call
|
838
|
-
grpc_error
|
839
|
-
grpc_call_element
|
807
|
+
args.send_deadline = GRPC_MILLIS_INF_FUTURE;
|
808
|
+
grpc_call* call;
|
809
|
+
grpc_error* error = grpc_call_create(exec_ctx, &args, &call);
|
810
|
+
grpc_call_element* elem =
|
840
811
|
grpc_call_stack_element(grpc_call_get_call_stack(call), 0);
|
841
812
|
if (error != GRPC_ERROR_NONE) {
|
842
813
|
got_initial_metadata(exec_ctx, elem, error);
|
843
814
|
GRPC_ERROR_UNREF(error);
|
844
815
|
return;
|
845
816
|
}
|
846
|
-
call_data
|
817
|
+
call_data* calld = (call_data*)elem->call_data;
|
847
818
|
grpc_op op;
|
848
819
|
memset(&op, 0, sizeof(op));
|
849
820
|
op.op = GRPC_OP_RECV_INITIAL_METADATA;
|
@@ -855,13 +826,13 @@ static void accept_stream(grpc_exec_ctx *exec_ctx, void *cd,
|
|
855
826
|
&calld->got_initial_metadata);
|
856
827
|
}
|
857
828
|
|
858
|
-
static void channel_connectivity_changed(grpc_exec_ctx
|
859
|
-
grpc_error
|
860
|
-
channel_data
|
861
|
-
grpc_server
|
829
|
+
static void channel_connectivity_changed(grpc_exec_ctx* exec_ctx, void* cd,
|
830
|
+
grpc_error* error) {
|
831
|
+
channel_data* chand = (channel_data*)cd;
|
832
|
+
grpc_server* server = chand->server;
|
862
833
|
if (chand->connectivity_state != GRPC_CHANNEL_SHUTDOWN) {
|
863
|
-
grpc_transport_op
|
864
|
-
op->on_connectivity_state_change = &chand->channel_connectivity_changed
|
834
|
+
grpc_transport_op* op = grpc_make_transport_op(nullptr);
|
835
|
+
op->on_connectivity_state_change = &chand->channel_connectivity_changed;
|
865
836
|
op->connectivity_state = &chand->connectivity_state;
|
866
837
|
grpc_channel_next_op(exec_ctx,
|
867
838
|
grpc_channel_stack_element(
|
@@ -875,15 +846,14 @@ static void channel_connectivity_changed(grpc_exec_ctx *exec_ctx, void *cd,
|
|
875
846
|
}
|
876
847
|
}
|
877
848
|
|
878
|
-
static grpc_error
|
879
|
-
grpc_call_element
|
880
|
-
const grpc_call_element_args
|
881
|
-
call_data
|
882
|
-
channel_data
|
849
|
+
static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
|
850
|
+
grpc_call_element* elem,
|
851
|
+
const grpc_call_element_args* args) {
|
852
|
+
call_data* calld = (call_data*)elem->call_data;
|
853
|
+
channel_data* chand = (channel_data*)elem->channel_data;
|
883
854
|
memset(calld, 0, sizeof(call_data));
|
884
|
-
calld->deadline =
|
855
|
+
calld->deadline = GRPC_MILLIS_INF_FUTURE;
|
885
856
|
calld->call = grpc_call_from_top_element(elem);
|
886
|
-
gpr_mu_init(&calld->mu_state);
|
887
857
|
|
888
858
|
GRPC_CLOSURE_INIT(&calld->server_on_recv_initial_metadata,
|
889
859
|
server_on_recv_initial_metadata, elem,
|
@@ -893,11 +863,11 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
|
|
893
863
|
return GRPC_ERROR_NONE;
|
894
864
|
}
|
895
865
|
|
896
|
-
static void destroy_call_elem(grpc_exec_ctx
|
897
|
-
const grpc_call_final_info
|
898
|
-
grpc_closure
|
899
|
-
channel_data
|
900
|
-
call_data
|
866
|
+
static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
|
867
|
+
const grpc_call_final_info* final_info,
|
868
|
+
grpc_closure* ignored) {
|
869
|
+
channel_data* chand = (channel_data*)elem->channel_data;
|
870
|
+
call_data* calld = (call_data*)elem->call_data;
|
901
871
|
|
902
872
|
GPR_ASSERT(calld->state != PENDING);
|
903
873
|
|
@@ -910,21 +880,19 @@ static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
|
910
880
|
grpc_metadata_array_destroy(&calld->initial_metadata);
|
911
881
|
grpc_byte_buffer_destroy(calld->payload);
|
912
882
|
|
913
|
-
gpr_mu_destroy(&calld->mu_state);
|
914
|
-
|
915
883
|
server_unref(exec_ctx, chand->server);
|
916
884
|
}
|
917
885
|
|
918
|
-
static grpc_error
|
919
|
-
grpc_channel_element
|
920
|
-
grpc_channel_element_args
|
921
|
-
channel_data
|
886
|
+
static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
|
887
|
+
grpc_channel_element* elem,
|
888
|
+
grpc_channel_element_args* args) {
|
889
|
+
channel_data* chand = (channel_data*)elem->channel_data;
|
922
890
|
GPR_ASSERT(args->is_first);
|
923
891
|
GPR_ASSERT(!args->is_last);
|
924
|
-
chand->server =
|
925
|
-
chand->channel =
|
892
|
+
chand->server = nullptr;
|
893
|
+
chand->channel = nullptr;
|
926
894
|
chand->next = chand->prev = chand;
|
927
|
-
chand->registered_methods =
|
895
|
+
chand->registered_methods = nullptr;
|
928
896
|
chand->connectivity_state = GRPC_CHANNEL_IDLE;
|
929
897
|
GRPC_CLOSURE_INIT(&chand->channel_connectivity_changed,
|
930
898
|
channel_connectivity_changed, chand,
|
@@ -932,10 +900,10 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
|
|
932
900
|
return GRPC_ERROR_NONE;
|
933
901
|
}
|
934
902
|
|
935
|
-
static void destroy_channel_elem(grpc_exec_ctx
|
936
|
-
grpc_channel_element
|
903
|
+
static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
|
904
|
+
grpc_channel_element* elem) {
|
937
905
|
size_t i;
|
938
|
-
channel_data
|
906
|
+
channel_data* chand = (channel_data*)elem->channel_data;
|
939
907
|
if (chand->registered_methods) {
|
940
908
|
for (i = 0; i < chand->registered_method_slots; i++) {
|
941
909
|
grpc_slice_unref_internal(exec_ctx, chand->registered_methods[i].method);
|
@@ -970,9 +938,9 @@ const grpc_channel_filter grpc_server_top_filter = {
|
|
970
938
|
"server",
|
971
939
|
};
|
972
940
|
|
973
|
-
static void register_completion_queue(grpc_server
|
974
|
-
grpc_completion_queue
|
975
|
-
void
|
941
|
+
static void register_completion_queue(grpc_server* server,
|
942
|
+
grpc_completion_queue* cq,
|
943
|
+
void* reserved) {
|
976
944
|
size_t i, n;
|
977
945
|
GPR_ASSERT(!reserved);
|
978
946
|
for (i = 0; i < server->cq_count; i++) {
|
@@ -981,14 +949,14 @@ static void register_completion_queue(grpc_server *server,
|
|
981
949
|
|
982
950
|
GRPC_CQ_INTERNAL_REF(cq, "server");
|
983
951
|
n = server->cq_count++;
|
984
|
-
server->cqs = (grpc_completion_queue
|
985
|
-
server->cqs, server->cq_count * sizeof(grpc_completion_queue
|
952
|
+
server->cqs = (grpc_completion_queue**)gpr_realloc(
|
953
|
+
server->cqs, server->cq_count * sizeof(grpc_completion_queue*));
|
986
954
|
server->cqs[n] = cq;
|
987
955
|
}
|
988
956
|
|
989
|
-
void grpc_server_register_completion_queue(grpc_server
|
990
|
-
grpc_completion_queue
|
991
|
-
void
|
957
|
+
void grpc_server_register_completion_queue(grpc_server* server,
|
958
|
+
grpc_completion_queue* cq,
|
959
|
+
void* reserved) {
|
992
960
|
GRPC_API_TRACE(
|
993
961
|
"grpc_server_register_completion_queue(server=%p, cq=%p, reserved=%p)", 3,
|
994
962
|
(server, cq, reserved));
|
@@ -1004,10 +972,10 @@ void grpc_server_register_completion_queue(grpc_server *server,
|
|
1004
972
|
register_completion_queue(server, cq, reserved);
|
1005
973
|
}
|
1006
974
|
|
1007
|
-
grpc_server
|
975
|
+
grpc_server* grpc_server_create(const grpc_channel_args* args, void* reserved) {
|
1008
976
|
GRPC_API_TRACE("grpc_server_create(%p, %p)", 2, (args, reserved));
|
1009
977
|
|
1010
|
-
grpc_server
|
978
|
+
grpc_server* server = (grpc_server*)gpr_zalloc(sizeof(grpc_server));
|
1011
979
|
|
1012
980
|
gpr_mu_init(&server->mu_global);
|
1013
981
|
gpr_mu_init(&server->mu_call);
|
@@ -1018,25 +986,23 @@ grpc_server *grpc_server_create(const grpc_channel_args *args, void *reserved) {
|
|
1018
986
|
server->root_channel_data.next = server->root_channel_data.prev =
|
1019
987
|
&server->root_channel_data;
|
1020
988
|
|
1021
|
-
/* TODO(ctiller): expose a channel_arg for this */
|
1022
|
-
server->max_requested_calls_per_cq = 32768;
|
1023
989
|
server->channel_args = grpc_channel_args_copy(args);
|
1024
990
|
|
1025
991
|
return server;
|
1026
992
|
}
|
1027
993
|
|
1028
|
-
static int streq(const char
|
1029
|
-
if (a ==
|
1030
|
-
if (a ==
|
1031
|
-
if (b ==
|
994
|
+
static int streq(const char* a, const char* b) {
|
995
|
+
if (a == nullptr && b == nullptr) return 1;
|
996
|
+
if (a == nullptr) return 0;
|
997
|
+
if (b == nullptr) return 0;
|
1032
998
|
return 0 == strcmp(a, b);
|
1033
999
|
}
|
1034
1000
|
|
1035
|
-
void
|
1036
|
-
grpc_server
|
1001
|
+
void* grpc_server_register_method(
|
1002
|
+
grpc_server* server, const char* method, const char* host,
|
1037
1003
|
grpc_server_register_method_payload_handling payload_handling,
|
1038
1004
|
uint32_t flags) {
|
1039
|
-
registered_method
|
1005
|
+
registered_method* m;
|
1040
1006
|
GRPC_API_TRACE(
|
1041
1007
|
"grpc_server_register_method(server=%p, method=%s, host=%s, "
|
1042
1008
|
"flags=0x%08x)",
|
@@ -1044,21 +1010,21 @@ void *grpc_server_register_method(
|
|
1044
1010
|
if (!method) {
|
1045
1011
|
gpr_log(GPR_ERROR,
|
1046
1012
|
"grpc_server_register_method method string cannot be NULL");
|
1047
|
-
return
|
1013
|
+
return nullptr;
|
1048
1014
|
}
|
1049
1015
|
for (m = server->registered_methods; m; m = m->next) {
|
1050
1016
|
if (streq(m->method, method) && streq(m->host, host)) {
|
1051
1017
|
gpr_log(GPR_ERROR, "duplicate registration for %s@%s", method,
|
1052
1018
|
host ? host : "*");
|
1053
|
-
return
|
1019
|
+
return nullptr;
|
1054
1020
|
}
|
1055
1021
|
}
|
1056
1022
|
if ((flags & ~GRPC_INITIAL_METADATA_USED_MASK) != 0) {
|
1057
1023
|
gpr_log(GPR_ERROR, "grpc_server_register_method invalid flags 0x%08x",
|
1058
1024
|
flags);
|
1059
|
-
return
|
1025
|
+
return nullptr;
|
1060
1026
|
}
|
1061
|
-
m = (registered_method
|
1027
|
+
m = (registered_method*)gpr_zalloc(sizeof(registered_method));
|
1062
1028
|
m->method = gpr_strdup(method);
|
1063
1029
|
m->host = gpr_strdup(host);
|
1064
1030
|
m->next = server->registered_methods;
|
@@ -1068,10 +1034,10 @@ void *grpc_server_register_method(
|
|
1068
1034
|
return m;
|
1069
1035
|
}
|
1070
1036
|
|
1071
|
-
static void start_listeners(grpc_exec_ctx
|
1072
|
-
grpc_error
|
1073
|
-
grpc_server
|
1074
|
-
for (listener
|
1037
|
+
static void start_listeners(grpc_exec_ctx* exec_ctx, void* s,
|
1038
|
+
grpc_error* error) {
|
1039
|
+
grpc_server* server = (grpc_server*)s;
|
1040
|
+
for (listener* l = server->listeners; l; l = l->next) {
|
1075
1041
|
l->start(exec_ctx, server, l->arg, server->pollsets, server->pollset_count);
|
1076
1042
|
}
|
1077
1043
|
|
@@ -1083,7 +1049,7 @@ static void start_listeners(grpc_exec_ctx *exec_ctx, void *s,
|
|
1083
1049
|
server_unref(exec_ctx, server);
|
1084
1050
|
}
|
1085
1051
|
|
1086
|
-
void grpc_server_start(grpc_server
|
1052
|
+
void grpc_server_start(grpc_server* server) {
|
1087
1053
|
size_t i;
|
1088
1054
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
1089
1055
|
|
@@ -1092,30 +1058,16 @@ void grpc_server_start(grpc_server *server) {
|
|
1092
1058
|
server->started = true;
|
1093
1059
|
server->pollset_count = 0;
|
1094
1060
|
server->pollsets =
|
1095
|
-
(grpc_pollset
|
1096
|
-
server->request_freelist_per_cq = (gpr_stack_lockfree **)gpr_malloc(
|
1097
|
-
sizeof(*server->request_freelist_per_cq) * server->cq_count);
|
1098
|
-
server->requested_calls_per_cq = (requested_call **)gpr_malloc(
|
1099
|
-
sizeof(*server->requested_calls_per_cq) * server->cq_count);
|
1061
|
+
(grpc_pollset**)gpr_malloc(sizeof(grpc_pollset*) * server->cq_count);
|
1100
1062
|
for (i = 0; i < server->cq_count; i++) {
|
1101
1063
|
if (grpc_cq_can_listen(server->cqs[i])) {
|
1102
1064
|
server->pollsets[server->pollset_count++] =
|
1103
1065
|
grpc_cq_pollset(server->cqs[i]);
|
1104
1066
|
}
|
1105
|
-
server->request_freelist_per_cq[i] =
|
1106
|
-
gpr_stack_lockfree_create((size_t)server->max_requested_calls_per_cq);
|
1107
|
-
for (int j = 0; j < server->max_requested_calls_per_cq; j++) {
|
1108
|
-
gpr_stack_lockfree_push(server->request_freelist_per_cq[i], j);
|
1109
|
-
}
|
1110
|
-
server->requested_calls_per_cq[i] = (requested_call *)gpr_malloc(
|
1111
|
-
(size_t)server->max_requested_calls_per_cq *
|
1112
|
-
sizeof(*server->requested_calls_per_cq[i]));
|
1113
1067
|
}
|
1114
|
-
request_matcher_init(&server->unregistered_request_matcher,
|
1115
|
-
|
1116
|
-
|
1117
|
-
request_matcher_init(&rm->matcher,
|
1118
|
-
(size_t)server->max_requested_calls_per_cq, server);
|
1068
|
+
request_matcher_init(&server->unregistered_request_matcher, server);
|
1069
|
+
for (registered_method* rm = server->registered_methods; rm; rm = rm->next) {
|
1070
|
+
request_matcher_init(&rm->matcher, server);
|
1119
1071
|
}
|
1120
1072
|
|
1121
1073
|
server_ref(server);
|
@@ -1129,31 +1081,31 @@ void grpc_server_start(grpc_server *server) {
|
|
1129
1081
|
grpc_exec_ctx_finish(&exec_ctx);
|
1130
1082
|
}
|
1131
1083
|
|
1132
|
-
void grpc_server_get_pollsets(grpc_server
|
1133
|
-
size_t
|
1084
|
+
void grpc_server_get_pollsets(grpc_server* server, grpc_pollset*** pollsets,
|
1085
|
+
size_t* pollset_count) {
|
1134
1086
|
*pollset_count = server->pollset_count;
|
1135
1087
|
*pollsets = server->pollsets;
|
1136
1088
|
}
|
1137
1089
|
|
1138
|
-
void grpc_server_setup_transport(grpc_exec_ctx
|
1139
|
-
grpc_transport
|
1140
|
-
grpc_pollset
|
1141
|
-
const grpc_channel_args
|
1090
|
+
void grpc_server_setup_transport(grpc_exec_ctx* exec_ctx, grpc_server* s,
|
1091
|
+
grpc_transport* transport,
|
1092
|
+
grpc_pollset* accepting_pollset,
|
1093
|
+
const grpc_channel_args* args) {
|
1142
1094
|
size_t num_registered_methods;
|
1143
1095
|
size_t alloc;
|
1144
|
-
registered_method
|
1145
|
-
channel_registered_method
|
1146
|
-
grpc_channel
|
1147
|
-
channel_data
|
1096
|
+
registered_method* rm;
|
1097
|
+
channel_registered_method* crm;
|
1098
|
+
grpc_channel* channel;
|
1099
|
+
channel_data* chand;
|
1148
1100
|
uint32_t hash;
|
1149
1101
|
size_t slots;
|
1150
1102
|
uint32_t probes;
|
1151
1103
|
uint32_t max_probes = 0;
|
1152
|
-
grpc_transport_op
|
1104
|
+
grpc_transport_op* op = nullptr;
|
1153
1105
|
|
1154
|
-
channel =
|
1155
|
-
|
1156
|
-
chand = (channel_data
|
1106
|
+
channel = grpc_channel_create(exec_ctx, nullptr, args, GRPC_SERVER_CHANNEL,
|
1107
|
+
transport);
|
1108
|
+
chand = (channel_data*)grpc_channel_stack_element(
|
1157
1109
|
grpc_channel_get_channel_stack(channel), 0)
|
1158
1110
|
->channel_data;
|
1159
1111
|
chand->server = s;
|
@@ -1179,12 +1131,12 @@ void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *s,
|
|
1179
1131
|
if (num_registered_methods > 0) {
|
1180
1132
|
slots = 2 * num_registered_methods;
|
1181
1133
|
alloc = sizeof(channel_registered_method) * slots;
|
1182
|
-
chand->registered_methods = (channel_registered_method
|
1134
|
+
chand->registered_methods = (channel_registered_method*)gpr_zalloc(alloc);
|
1183
1135
|
for (rm = s->registered_methods; rm; rm = rm->next) {
|
1184
1136
|
grpc_slice host;
|
1185
1137
|
bool has_host;
|
1186
1138
|
grpc_slice method;
|
1187
|
-
if (rm->host !=
|
1139
|
+
if (rm->host != nullptr) {
|
1188
1140
|
host = grpc_slice_intern(grpc_slice_from_static_string(rm->host));
|
1189
1141
|
has_host = true;
|
1190
1142
|
} else {
|
@@ -1194,7 +1146,7 @@ void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *s,
|
|
1194
1146
|
hash = GRPC_MDSTR_KV_HASH(has_host ? grpc_slice_hash(host) : 0,
|
1195
1147
|
grpc_slice_hash(method));
|
1196
1148
|
for (probes = 0; chand->registered_methods[(hash + probes) % slots]
|
1197
|
-
.server_registered_method !=
|
1149
|
+
.server_registered_method != nullptr;
|
1198
1150
|
probes++)
|
1199
1151
|
;
|
1200
1152
|
if (probes > max_probes) max_probes = probes;
|
@@ -1219,7 +1171,7 @@ void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *s,
|
|
1219
1171
|
gpr_mu_unlock(&s->mu_global);
|
1220
1172
|
|
1221
1173
|
GRPC_CHANNEL_INTERNAL_REF(channel, "connectivity");
|
1222
|
-
op = grpc_make_transport_op(
|
1174
|
+
op = grpc_make_transport_op(nullptr);
|
1223
1175
|
op->set_accept_stream = true;
|
1224
1176
|
op->set_accept_stream_fn = accept_stream;
|
1225
1177
|
op->set_accept_stream_user_data = chand;
|
@@ -1232,25 +1184,25 @@ void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *s,
|
|
1232
1184
|
grpc_transport_perform_op(exec_ctx, transport, op);
|
1233
1185
|
}
|
1234
1186
|
|
1235
|
-
void done_published_shutdown(grpc_exec_ctx
|
1236
|
-
grpc_cq_completion
|
1187
|
+
void done_published_shutdown(grpc_exec_ctx* exec_ctx, void* done_arg,
|
1188
|
+
grpc_cq_completion* storage) {
|
1237
1189
|
(void)done_arg;
|
1238
1190
|
gpr_free(storage);
|
1239
1191
|
}
|
1240
1192
|
|
1241
|
-
static void listener_destroy_done(grpc_exec_ctx
|
1242
|
-
grpc_error
|
1243
|
-
grpc_server
|
1193
|
+
static void listener_destroy_done(grpc_exec_ctx* exec_ctx, void* s,
|
1194
|
+
grpc_error* error) {
|
1195
|
+
grpc_server* server = (grpc_server*)s;
|
1244
1196
|
gpr_mu_lock(&server->mu_global);
|
1245
1197
|
server->listeners_destroyed++;
|
1246
1198
|
maybe_finish_shutdown(exec_ctx, server);
|
1247
1199
|
gpr_mu_unlock(&server->mu_global);
|
1248
1200
|
}
|
1249
1201
|
|
1250
|
-
void grpc_server_shutdown_and_notify(grpc_server
|
1251
|
-
grpc_completion_queue
|
1252
|
-
listener
|
1253
|
-
shutdown_tag
|
1202
|
+
void grpc_server_shutdown_and_notify(grpc_server* server,
|
1203
|
+
grpc_completion_queue* cq, void* tag) {
|
1204
|
+
listener* l;
|
1205
|
+
shutdown_tag* sdt;
|
1254
1206
|
channel_broadcaster broadcaster;
|
1255
1207
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
1256
1208
|
|
@@ -1267,13 +1219,13 @@ void grpc_server_shutdown_and_notify(grpc_server *server,
|
|
1267
1219
|
/* stay locked, and gather up some stuff to do */
|
1268
1220
|
GPR_ASSERT(grpc_cq_begin_op(cq, tag));
|
1269
1221
|
if (server->shutdown_published) {
|
1270
|
-
grpc_cq_end_op(
|
1271
|
-
|
1272
|
-
|
1222
|
+
grpc_cq_end_op(&exec_ctx, cq, tag, GRPC_ERROR_NONE, done_published_shutdown,
|
1223
|
+
nullptr,
|
1224
|
+
(grpc_cq_completion*)gpr_malloc(sizeof(grpc_cq_completion)));
|
1273
1225
|
gpr_mu_unlock(&server->mu_global);
|
1274
1226
|
goto done;
|
1275
1227
|
}
|
1276
|
-
server->shutdown_tags = (shutdown_tag
|
1228
|
+
server->shutdown_tags = (shutdown_tag*)gpr_realloc(
|
1277
1229
|
server->shutdown_tags,
|
1278
1230
|
sizeof(shutdown_tag) * (server->num_shutdown_tags + 1));
|
1279
1231
|
sdt = &server->shutdown_tags[server->num_shutdown_tags++];
|
@@ -1314,7 +1266,7 @@ done:
|
|
1314
1266
|
grpc_exec_ctx_finish(&exec_ctx);
|
1315
1267
|
}
|
1316
1268
|
|
1317
|
-
void grpc_server_cancel_all_calls(grpc_server
|
1269
|
+
void grpc_server_cancel_all_calls(grpc_server* server) {
|
1318
1270
|
channel_broadcaster broadcaster;
|
1319
1271
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
1320
1272
|
|
@@ -1330,8 +1282,8 @@ void grpc_server_cancel_all_calls(grpc_server *server) {
|
|
1330
1282
|
grpc_exec_ctx_finish(&exec_ctx);
|
1331
1283
|
}
|
1332
1284
|
|
1333
|
-
void grpc_server_destroy(grpc_server
|
1334
|
-
listener
|
1285
|
+
void grpc_server_destroy(grpc_server* server) {
|
1286
|
+
listener* l;
|
1335
1287
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
1336
1288
|
|
1337
1289
|
GRPC_API_TRACE("grpc_server_destroy(server=%p)", 1, (server));
|
@@ -1353,12 +1305,12 @@ void grpc_server_destroy(grpc_server *server) {
|
|
1353
1305
|
}
|
1354
1306
|
|
1355
1307
|
void grpc_server_add_listener(
|
1356
|
-
grpc_exec_ctx
|
1357
|
-
void (*start)(grpc_exec_ctx
|
1358
|
-
grpc_pollset
|
1359
|
-
void (*destroy)(grpc_exec_ctx
|
1360
|
-
grpc_closure
|
1361
|
-
listener
|
1308
|
+
grpc_exec_ctx* exec_ctx, grpc_server* server, void* arg,
|
1309
|
+
void (*start)(grpc_exec_ctx* exec_ctx, grpc_server* server, void* arg,
|
1310
|
+
grpc_pollset** pollsets, size_t pollset_count),
|
1311
|
+
void (*destroy)(grpc_exec_ctx* exec_ctx, grpc_server* server, void* arg,
|
1312
|
+
grpc_closure* on_done)) {
|
1313
|
+
listener* l = (listener*)gpr_malloc(sizeof(listener));
|
1362
1314
|
l->arg = arg;
|
1363
1315
|
l->start = start;
|
1364
1316
|
l->destroy = destroy;
|
@@ -1366,26 +1318,16 @@ void grpc_server_add_listener(
|
|
1366
1318
|
server->listeners = l;
|
1367
1319
|
}
|
1368
1320
|
|
1369
|
-
static grpc_call_error queue_call_request(grpc_exec_ctx
|
1370
|
-
grpc_server
|
1371
|
-
requested_call
|
1372
|
-
call_data
|
1373
|
-
request_matcher
|
1374
|
-
int request_id;
|
1321
|
+
static grpc_call_error queue_call_request(grpc_exec_ctx* exec_ctx,
|
1322
|
+
grpc_server* server, size_t cq_idx,
|
1323
|
+
requested_call* rc) {
|
1324
|
+
call_data* calld = nullptr;
|
1325
|
+
request_matcher* rm = nullptr;
|
1375
1326
|
if (gpr_atm_acq_load(&server->shutdown_flag)) {
|
1376
1327
|
fail_call(exec_ctx, server, cq_idx, rc,
|
1377
1328
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server Shutdown"));
|
1378
1329
|
return GRPC_CALL_OK;
|
1379
1330
|
}
|
1380
|
-
request_id = gpr_stack_lockfree_pop(server->request_freelist_per_cq[cq_idx]);
|
1381
|
-
if (request_id == -1) {
|
1382
|
-
/* out of request ids: just fail this one */
|
1383
|
-
fail_call(exec_ctx, server, cq_idx, rc,
|
1384
|
-
grpc_error_set_int(
|
1385
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Out of request ids"),
|
1386
|
-
GRPC_ERROR_INT_LIMIT, server->max_requested_calls_per_cq));
|
1387
|
-
return GRPC_CALL_OK;
|
1388
|
-
}
|
1389
1331
|
switch (rc->type) {
|
1390
1332
|
case BATCH_CALL:
|
1391
1333
|
rm = &server->unregistered_request_matcher;
|
@@ -1394,20 +1336,17 @@ static grpc_call_error queue_call_request(grpc_exec_ctx *exec_ctx,
|
|
1394
1336
|
rm = &rc->data.registered.method->matcher;
|
1395
1337
|
break;
|
1396
1338
|
}
|
1397
|
-
|
1398
|
-
gpr_free(rc);
|
1399
|
-
if (gpr_stack_lockfree_push(rm->requests_per_cq[cq_idx], request_id)) {
|
1339
|
+
if (gpr_locked_mpscq_push(&rm->requests_per_cq[cq_idx], &rc->request_link)) {
|
1400
1340
|
/* this was the first queued request: we need to lock and start
|
1401
1341
|
matching calls */
|
1402
1342
|
gpr_mu_lock(&server->mu_call);
|
1403
|
-
while ((calld = rm->pending_head) !=
|
1404
|
-
|
1405
|
-
if (
|
1343
|
+
while ((calld = rm->pending_head) != nullptr) {
|
1344
|
+
rc = (requested_call*)gpr_locked_mpscq_pop(&rm->requests_per_cq[cq_idx]);
|
1345
|
+
if (rc == nullptr) break;
|
1406
1346
|
rm->pending_head = calld->pending_next;
|
1407
1347
|
gpr_mu_unlock(&server->mu_call);
|
1408
|
-
|
1409
|
-
|
1410
|
-
gpr_mu_unlock(&calld->mu_state);
|
1348
|
+
if (!gpr_atm_full_cas(&calld->state, PENDING, ACTIVATED)) {
|
1349
|
+
// Zombied Call
|
1411
1350
|
GRPC_CLOSURE_INIT(
|
1412
1351
|
&calld->kill_zombie_closure, kill_zombie,
|
1413
1352
|
grpc_call_stack_element(grpc_call_get_call_stack(calld->call), 0),
|
@@ -1415,11 +1354,7 @@ static grpc_call_error queue_call_request(grpc_exec_ctx *exec_ctx,
|
|
1415
1354
|
GRPC_CLOSURE_SCHED(exec_ctx, &calld->kill_zombie_closure,
|
1416
1355
|
GRPC_ERROR_NONE);
|
1417
1356
|
} else {
|
1418
|
-
|
1419
|
-
calld->state = ACTIVATED;
|
1420
|
-
gpr_mu_unlock(&calld->mu_state);
|
1421
|
-
publish_call(exec_ctx, server, calld, cq_idx,
|
1422
|
-
&server->requested_calls_per_cq[cq_idx][request_id]);
|
1357
|
+
publish_call(exec_ctx, server, calld, cq_idx, rc);
|
1423
1358
|
}
|
1424
1359
|
gpr_mu_lock(&server->mu_call);
|
1425
1360
|
}
|
@@ -1429,20 +1364,21 @@ static grpc_call_error queue_call_request(grpc_exec_ctx *exec_ctx,
|
|
1429
1364
|
}
|
1430
1365
|
|
1431
1366
|
grpc_call_error grpc_server_request_call(
|
1432
|
-
grpc_server
|
1433
|
-
grpc_metadata_array
|
1434
|
-
grpc_completion_queue
|
1435
|
-
grpc_completion_queue
|
1367
|
+
grpc_server* server, grpc_call** call, grpc_call_details* details,
|
1368
|
+
grpc_metadata_array* initial_metadata,
|
1369
|
+
grpc_completion_queue* cq_bound_to_call,
|
1370
|
+
grpc_completion_queue* cq_for_notification, void* tag) {
|
1436
1371
|
grpc_call_error error;
|
1437
1372
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
1438
|
-
requested_call
|
1373
|
+
requested_call* rc = (requested_call*)gpr_malloc(sizeof(*rc));
|
1439
1374
|
GRPC_STATS_INC_SERVER_REQUESTED_CALLS(&exec_ctx);
|
1440
1375
|
GRPC_API_TRACE(
|
1441
1376
|
"grpc_server_request_call("
|
1442
1377
|
"server=%p, call=%p, details=%p, initial_metadata=%p, "
|
1443
1378
|
"cq_bound_to_call=%p, cq_for_notification=%p, tag=%p)",
|
1444
|
-
7,
|
1445
|
-
|
1379
|
+
7,
|
1380
|
+
(server, call, details, initial_metadata, cq_bound_to_call,
|
1381
|
+
cq_for_notification, tag));
|
1446
1382
|
size_t cq_idx;
|
1447
1383
|
for (cq_idx = 0; cq_idx < server->cq_count; cq_idx++) {
|
1448
1384
|
if (server->cqs[cq_idx] == cq_for_notification) {
|
@@ -1459,7 +1395,7 @@ grpc_call_error grpc_server_request_call(
|
|
1459
1395
|
error = GRPC_CALL_ERROR_COMPLETION_QUEUE_SHUTDOWN;
|
1460
1396
|
goto done;
|
1461
1397
|
}
|
1462
|
-
details->reserved =
|
1398
|
+
details->reserved = nullptr;
|
1463
1399
|
rc->cq_idx = cq_idx;
|
1464
1400
|
rc->type = BATCH_CALL;
|
1465
1401
|
rc->server = server;
|
@@ -1475,22 +1411,23 @@ done:
|
|
1475
1411
|
}
|
1476
1412
|
|
1477
1413
|
grpc_call_error grpc_server_request_registered_call(
|
1478
|
-
grpc_server
|
1479
|
-
grpc_metadata_array
|
1480
|
-
grpc_completion_queue
|
1481
|
-
grpc_completion_queue
|
1414
|
+
grpc_server* server, void* rmp, grpc_call** call, gpr_timespec* deadline,
|
1415
|
+
grpc_metadata_array* initial_metadata, grpc_byte_buffer** optional_payload,
|
1416
|
+
grpc_completion_queue* cq_bound_to_call,
|
1417
|
+
grpc_completion_queue* cq_for_notification, void* tag) {
|
1482
1418
|
grpc_call_error error;
|
1483
1419
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
1484
|
-
requested_call
|
1485
|
-
registered_method
|
1420
|
+
requested_call* rc = (requested_call*)gpr_malloc(sizeof(*rc));
|
1421
|
+
registered_method* rm = (registered_method*)rmp;
|
1486
1422
|
GRPC_STATS_INC_SERVER_REQUESTED_CALLS(&exec_ctx);
|
1487
1423
|
GRPC_API_TRACE(
|
1488
1424
|
"grpc_server_request_registered_call("
|
1489
1425
|
"server=%p, rmp=%p, call=%p, deadline=%p, initial_metadata=%p, "
|
1490
1426
|
"optional_payload=%p, cq_bound_to_call=%p, cq_for_notification=%p, "
|
1491
1427
|
"tag=%p)",
|
1492
|
-
9,
|
1493
|
-
|
1428
|
+
9,
|
1429
|
+
(server, rmp, call, deadline, initial_metadata, optional_payload,
|
1430
|
+
cq_bound_to_call, cq_for_notification, tag));
|
1494
1431
|
|
1495
1432
|
size_t cq_idx;
|
1496
1433
|
for (cq_idx = 0; cq_idx < server->cq_count; cq_idx++) {
|
@@ -1503,7 +1440,7 @@ grpc_call_error grpc_server_request_registered_call(
|
|
1503
1440
|
error = GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE;
|
1504
1441
|
goto done;
|
1505
1442
|
}
|
1506
|
-
if ((optional_payload ==
|
1443
|
+
if ((optional_payload == nullptr) !=
|
1507
1444
|
(rm->payload_handling == GRPC_SRM_PAYLOAD_NONE)) {
|
1508
1445
|
gpr_free(rc);
|
1509
1446
|
error = GRPC_CALL_ERROR_PAYLOAD_TYPE_MISMATCH;
|
@@ -1530,22 +1467,21 @@ done:
|
|
1530
1467
|
return error;
|
1531
1468
|
}
|
1532
1469
|
|
1533
|
-
static void fail_call(grpc_exec_ctx
|
1534
|
-
size_t cq_idx, requested_call
|
1535
|
-
*rc->call =
|
1470
|
+
static void fail_call(grpc_exec_ctx* exec_ctx, grpc_server* server,
|
1471
|
+
size_t cq_idx, requested_call* rc, grpc_error* error) {
|
1472
|
+
*rc->call = nullptr;
|
1536
1473
|
rc->initial_metadata->count = 0;
|
1537
1474
|
GPR_ASSERT(error != GRPC_ERROR_NONE);
|
1538
1475
|
|
1539
|
-
server_ref(server);
|
1540
1476
|
grpc_cq_end_op(exec_ctx, server->cqs[cq_idx], rc->tag, error,
|
1541
1477
|
done_request_event, rc, &rc->completion);
|
1542
1478
|
}
|
1543
1479
|
|
1544
|
-
const grpc_channel_args
|
1480
|
+
const grpc_channel_args* grpc_server_get_channel_args(grpc_server* server) {
|
1545
1481
|
return server->channel_args;
|
1546
1482
|
}
|
1547
1483
|
|
1548
|
-
int grpc_server_has_open_connections(grpc_server
|
1484
|
+
int grpc_server_has_open_connections(grpc_server* server) {
|
1549
1485
|
int r;
|
1550
1486
|
gpr_mu_lock(&server->mu_global);
|
1551
1487
|
r = server->root_channel_data.next != &server->root_channel_data;
|