grpc 1.6.7 → 1.7.0.pre1
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 +579 -77
- data/include/grpc/byte_buffer.h +1 -63
- data/include/grpc/compression.h +27 -5
- data/include/grpc/fork.h +24 -0
- data/include/grpc/grpc.h +12 -6
- data/include/grpc/grpc_security.h +28 -7
- data/include/grpc/impl/codegen/atm.h +1 -0
- data/include/grpc/impl/codegen/byte_buffer.h +86 -0
- data/include/grpc/impl/codegen/compression_types.h +63 -5
- data/include/grpc/impl/codegen/fork.h +48 -0
- data/include/grpc/impl/codegen/grpc_types.h +26 -9
- data/include/grpc/impl/codegen/port_platform.h +11 -4
- data/include/grpc/impl/codegen/slice.h +6 -1
- data/include/grpc/impl/codegen/sync.h +3 -1
- data/include/grpc/impl/codegen/sync_custom.h +36 -0
- data/include/grpc/module.modulemap +75 -3
- data/include/grpc/slice.h +1 -5
- data/include/grpc/support/sync_custom.h +24 -0
- data/src/core/ext/census/base_resources.c +14 -14
- data/src/core/ext/census/context.c +7 -5
- data/src/core/ext/census/grpc_filter.c +12 -14
- data/src/core/ext/census/mlog.c +2 -1
- data/src/core/ext/census/resource.c +13 -9
- data/src/core/ext/filters/client_channel/channel_connectivity.c +15 -8
- data/src/core/ext/filters/client_channel/client_channel.c +418 -439
- data/src/core/ext/filters/client_channel/client_channel_factory.c +4 -5
- data/src/core/ext/filters/client_channel/client_channel_plugin.c +2 -2
- data/src/core/ext/filters/client_channel/http_connect_handshaker.c +7 -5
- data/src/core/ext/filters/client_channel/http_proxy.c +17 -21
- data/src/core/ext/filters/client_channel/lb_policy.c +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c +7 -7
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +371 -257
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c +7 -5
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +25 -14
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +16 -16
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +33 -28
- data/src/core/ext/filters/client_channel/lb_policy_factory.c +10 -8
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -1
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.c +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +7 -6
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +62 -28
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +29 -23
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c +25 -14
- data/src/core/ext/filters/client_channel/retry_throttle.c +9 -6
- data/src/core/ext/filters/client_channel/subchannel.c +30 -30
- data/src/core/ext/filters/client_channel/subchannel.h +1 -4
- data/src/core/ext/filters/client_channel/subchannel_index.c +31 -15
- data/src/core/ext/filters/client_channel/subchannel_index.h +7 -0
- data/src/core/ext/filters/client_channel/uri_parser.c +4 -3
- data/src/core/ext/filters/deadline/deadline_filter.c +78 -39
- data/src/core/ext/filters/deadline/deadline_filter.h +7 -1
- data/src/core/ext/filters/http/client/http_client_filter.c +14 -14
- data/src/core/ext/filters/http/http_filters_plugin.c +1 -1
- data/src/core/ext/filters/http/message_compress/message_compress_filter.c +240 -175
- data/src/core/ext/filters/http/server/http_server_filter.c +48 -36
- data/src/core/ext/filters/load_reporting/{load_reporting_filter.c → server_load_reporting_filter.c} +11 -12
- data/src/core/ext/filters/load_reporting/{load_reporting_filter.h → server_load_reporting_filter.h} +6 -5
- data/src/core/ext/filters/load_reporting/{load_reporting.c → server_load_reporting_plugin.c} +19 -13
- data/src/core/ext/filters/load_reporting/{load_reporting.h → server_load_reporting_plugin.h} +4 -3
- data/src/core/ext/filters/max_age/max_age_filter.c +2 -3
- data/src/core/ext/filters/message_size/message_size_filter.c +4 -2
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c +0 -1
- data/src/core/ext/transport/chttp2/client/chttp2_connector.c +5 -5
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +1 -1
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +1 -1
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +20 -18
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +1 -0
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +493 -210
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +1 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.c +9 -8
- data/src/core/ext/transport/chttp2/transport/frame_data.c +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +5 -4
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +10 -9
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +9 -5
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +62 -41
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +52 -8
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +2 -2
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +3 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +60 -30
- data/src/core/ext/transport/chttp2/transport/parsing.c +16 -5
- data/src/core/ext/transport/chttp2/transport/stream_lists.c +36 -16
- data/src/core/ext/transport/chttp2/transport/stream_map.c +6 -4
- data/src/core/ext/transport/chttp2/transport/writing.c +133 -105
- data/src/core/ext/transport/inproc/inproc_transport.c +61 -65
- data/src/core/lib/channel/channel_args.c +112 -12
- data/src/core/lib/channel/channel_args.h +31 -0
- data/src/core/lib/channel/channel_stack.c +1 -15
- data/src/core/lib/channel/channel_stack.h +3 -10
- data/src/core/lib/channel/channel_stack_builder.c +41 -10
- data/src/core/lib/channel/channel_stack_builder.h +10 -0
- data/src/core/lib/channel/connected_channel.c +94 -23
- data/src/core/lib/channel/handshaker.c +8 -6
- data/src/core/lib/channel/handshaker_registry.c +1 -1
- data/src/core/lib/compression/algorithm_metadata.h +14 -0
- data/src/core/lib/compression/compression.c +101 -1
- data/src/core/lib/compression/stream_compression.c +32 -146
- data/src/core/lib/compression/stream_compression.h +28 -4
- data/src/core/lib/compression/stream_compression_gzip.c +228 -0
- data/src/core/lib/{iomgr/ev_epoll_thread_pool_linux.h → compression/stream_compression_gzip.h} +5 -7
- data/src/core/lib/compression/stream_compression_identity.c +94 -0
- data/src/core/lib/{iomgr/ev_epoll_limited_pollers_linux.h → compression/stream_compression_identity.h} +7 -8
- data/src/core/lib/debug/stats.c +174 -0
- data/src/core/lib/debug/stats.h +61 -0
- data/src/core/lib/debug/stats_data.c +687 -0
- data/src/core/lib/debug/stats_data.h +470 -0
- data/src/core/lib/debug/trace.c +3 -3
- data/src/core/lib/debug/trace.h +1 -1
- data/src/core/lib/http/format_request.c +1 -1
- data/src/core/lib/http/httpcli.c +8 -7
- data/src/core/lib/http/httpcli_security_connector.c +2 -1
- data/src/core/lib/http/parser.c +4 -3
- data/src/core/lib/iomgr/call_combiner.c +202 -0
- data/src/core/lib/iomgr/call_combiner.h +121 -0
- data/src/core/lib/iomgr/closure.c +18 -4
- data/src/core/lib/iomgr/combiner.c +11 -4
- data/src/core/lib/iomgr/error.c +26 -24
- data/src/core/lib/iomgr/ev_epoll1_linux.c +395 -212
- data/src/core/lib/iomgr/ev_epollex_linux.c +141 -128
- data/src/core/lib/iomgr/ev_epollsig_linux.c +44 -41
- data/src/core/lib/iomgr/ev_poll_posix.c +99 -75
- data/src/core/lib/iomgr/ev_posix.c +5 -9
- data/src/core/lib/iomgr/ev_posix.h +1 -1
- data/src/core/lib/iomgr/exec_ctx.h +6 -1
- data/src/core/lib/iomgr/executor.c +142 -36
- data/src/core/lib/iomgr/executor.h +6 -1
- data/src/core/lib/iomgr/fork_posix.c +88 -0
- data/src/core/lib/iomgr/fork_windows.c +39 -0
- data/src/core/lib/iomgr/iocp_windows.c +2 -0
- data/src/core/lib/iomgr/iomgr.c +2 -8
- data/src/core/lib/iomgr/is_epollexclusive_available.c +6 -6
- data/src/core/lib/iomgr/load_file.c +2 -1
- data/src/core/lib/iomgr/polling_entity.c +9 -9
- data/src/core/lib/iomgr/polling_entity.h +7 -1
- data/src/core/lib/iomgr/pollset.h +1 -1
- data/src/core/lib/iomgr/pollset_uv.c +1 -1
- data/src/core/lib/iomgr/pollset_windows.c +3 -3
- data/src/core/lib/iomgr/port.h +4 -0
- data/src/core/lib/iomgr/resolve_address_posix.c +8 -7
- data/src/core/lib/iomgr/resolve_address_windows.c +1 -1
- data/src/core/lib/iomgr/resource_quota.c +24 -19
- data/src/core/lib/iomgr/socket_factory_posix.c +4 -4
- data/src/core/lib/iomgr/socket_mutator.c +4 -4
- data/src/core/lib/iomgr/socket_utils_windows.c +0 -4
- data/src/core/lib/iomgr/tcp_client_posix.c +5 -4
- data/src/core/lib/iomgr/tcp_posix.c +181 -20
- data/src/core/lib/iomgr/tcp_server_posix.c +8 -7
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +1 -1
- data/src/core/lib/iomgr/timer.h +4 -0
- data/src/core/lib/iomgr/timer_generic.c +138 -3
- data/src/core/lib/iomgr/timer_generic.h +3 -0
- data/src/core/lib/iomgr/timer_heap.c +4 -4
- data/src/core/lib/iomgr/timer_manager.c +2 -2
- data/src/core/lib/iomgr/timer_uv.c +2 -0
- data/src/core/lib/iomgr/udp_server.c +10 -8
- data/src/core/lib/iomgr/unix_sockets_posix.c +4 -2
- data/src/core/lib/iomgr/wakeup_fd_cv.c +9 -8
- data/src/core/lib/iomgr/wakeup_fd_cv.h +2 -2
- data/src/core/lib/json/json.c +1 -1
- data/src/core/lib/json/json_string.c +13 -13
- data/src/core/lib/profiling/timers.h +18 -8
- data/src/core/lib/security/credentials/composite/composite_credentials.c +4 -10
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +2 -1
- data/src/core/lib/security/credentials/jwt/jwt_verifier.c +11 -6
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +4 -4
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +132 -50
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -0
- data/src/core/lib/security/transport/client_auth_filter.c +68 -135
- data/src/core/lib/security/transport/secure_endpoint.c +110 -90
- data/src/core/lib/security/transport/secure_endpoint.h +8 -3
- data/src/core/lib/security/transport/security_connector.c +10 -12
- data/src/core/lib/security/transport/security_handshaker.c +45 -24
- data/src/core/lib/security/transport/server_auth_filter.c +71 -20
- data/src/core/lib/slice/b64.c +2 -2
- data/src/core/lib/slice/slice.c +16 -14
- data/src/core/lib/slice/slice_buffer.c +5 -4
- data/src/core/lib/slice/slice_hash_table.c +3 -2
- data/src/core/lib/slice/slice_intern.c +8 -5
- data/src/core/lib/support/block_annotate.h +22 -0
- data/src/core/lib/support/fork.c +62 -0
- data/src/core/lib/support/fork.h +35 -0
- data/src/core/lib/support/log_linux.c +1 -1
- data/src/core/lib/support/string.c +15 -1
- data/src/core/lib/support/string.h +3 -0
- data/src/core/lib/support/thd_internal.h +6 -0
- data/src/core/lib/support/thd_posix.c +56 -0
- data/src/core/lib/support/thd_windows.c +2 -0
- data/src/core/lib/surface/alarm.c +22 -15
- data/src/core/lib/surface/byte_buffer.c +4 -2
- data/src/core/lib/surface/call.c +442 -141
- data/src/core/lib/surface/call.h +6 -6
- data/src/core/lib/surface/call_log_batch.c +1 -1
- data/src/core/lib/surface/call_test_only.h +12 -0
- data/src/core/lib/surface/channel.c +39 -4
- data/src/core/lib/surface/channel_init.c +6 -6
- data/src/core/lib/surface/channel_ping.c +2 -2
- data/src/core/lib/surface/completion_queue.c +56 -57
- data/src/core/lib/surface/init.c +17 -3
- data/src/core/lib/surface/init_secure.c +5 -1
- data/src/core/lib/surface/lame_client.cc +9 -10
- data/src/core/lib/surface/server.c +81 -72
- data/src/core/lib/surface/version.c +2 -2
- data/src/core/lib/transport/byte_stream.c +1 -0
- data/src/core/lib/transport/byte_stream.h +3 -1
- data/src/core/lib/transport/connectivity_state.c +2 -1
- data/src/core/lib/transport/metadata.c +7 -4
- data/src/core/lib/transport/metadata_batch.c +18 -16
- data/src/core/lib/transport/metadata_batch.h +1 -0
- data/src/core/lib/transport/service_config.c +5 -3
- data/src/core/lib/transport/static_metadata.c +395 -614
- data/src/core/lib/transport/static_metadata.h +165 -133
- data/src/core/lib/transport/status_conversion.c +1 -1
- data/src/core/lib/transport/transport.c +20 -20
- data/src/core/lib/transport/transport.h +8 -5
- data/src/core/lib/transport/transport_impl.h +0 -3
- data/src/core/lib/transport/transport_op_string.c +8 -1
- data/src/core/plugin_registry/grpc_plugin_registry.c +4 -4
- data/src/core/tsi/fake_transport_security.c +133 -2
- data/src/core/tsi/fake_transport_security.h +5 -0
- data/src/core/tsi/ssl_transport_security.c +105 -8
- data/src/core/tsi/ssl_transport_security.h +30 -7
- data/src/core/tsi/transport_security.h +8 -2
- data/src/core/tsi/transport_security_grpc.c +20 -13
- data/src/core/tsi/transport_security_grpc.h +13 -9
- data/src/ruby/ext/grpc/rb_call_credentials.c +6 -2
- data/src/ruby/ext/grpc/rb_grpc.c +1 -1
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +30 -20
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +50 -35
- data/src/ruby/lib/grpc.rb +1 -0
- data/src/ruby/lib/grpc/generic/active_call.rb +34 -9
- data/src/ruby/lib/grpc/generic/bidi_call.rb +19 -10
- data/src/ruby/lib/grpc/generic/client_stub.rb +95 -38
- data/src/ruby/lib/grpc/generic/interceptor_registry.rb +53 -0
- data/src/ruby/lib/grpc/generic/interceptors.rb +186 -0
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +66 -20
- data/src/ruby/lib/grpc/generic/rpc_server.rb +15 -3
- data/src/ruby/lib/grpc/google_rpc_status_utils.rb +1 -2
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb +1 -0
- data/src/ruby/spec/channel_connection_spec.rb +1 -34
- data/src/ruby/spec/client_server_spec.rb +188 -82
- data/src/ruby/spec/generic/active_call_spec.rb +65 -11
- data/src/ruby/spec/generic/client_interceptors_spec.rb +153 -0
- data/src/ruby/spec/generic/interceptor_registry_spec.rb +65 -0
- data/src/ruby/spec/generic/rpc_desc_spec.rb +38 -0
- data/src/ruby/spec/generic/rpc_server_spec.rb +1 -34
- data/src/ruby/spec/generic/server_interceptors_spec.rb +218 -0
- data/src/ruby/spec/spec_helper.rb +4 -0
- data/src/ruby/spec/support/helpers.rb +73 -0
- data/src/ruby/spec/support/services.rb +147 -0
- data/third_party/cares/ares_build.h +21 -62
- data/third_party/cares/cares/ares.h +23 -1
- data/third_party/cares/cares/ares__close_sockets.c +2 -2
- data/third_party/cares/cares/ares_create_query.c +3 -3
- data/third_party/cares/cares/ares_expand_name.c +6 -2
- data/third_party/cares/cares/ares_expand_string.c +1 -1
- data/third_party/cares/cares/ares_getnameinfo.c +27 -7
- data/third_party/cares/cares/ares_init.c +407 -39
- data/third_party/cares/cares/ares_library_init.c +10 -0
- data/third_party/cares/cares/ares_library_init.h +2 -1
- data/third_party/cares/cares/ares_nowarn.c +6 -6
- data/third_party/cares/cares/ares_nowarn.h +2 -2
- data/third_party/cares/cares/ares_parse_naptr_reply.c +6 -1
- data/third_party/cares/cares/ares_private.h +11 -0
- data/third_party/cares/cares/ares_process.c +126 -37
- data/third_party/cares/cares/ares_version.h +2 -2
- data/third_party/cares/cares/ares_writev.c +2 -2
- data/third_party/cares/cares/config-win32.h +8 -34
- data/third_party/cares/cares/inet_net_pton.c +2 -2
- data/third_party/cares/cares/setup_once.h +5 -5
- data/third_party/cares/config_darwin/ares_config.h +98 -196
- data/third_party/cares/config_linux/ares_config.h +103 -203
- metadata +47 -20
- data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +0 -1957
- data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +0 -1182
@@ -69,11 +69,11 @@ void grpc_socket_factory_unref(grpc_socket_factory *factory) {
|
|
69
69
|
}
|
70
70
|
|
71
71
|
static void *socket_factory_arg_copy(void *p) {
|
72
|
-
return grpc_socket_factory_ref(p);
|
72
|
+
return grpc_socket_factory_ref((grpc_socket_factory *)p);
|
73
73
|
}
|
74
74
|
|
75
75
|
static void socket_factory_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) {
|
76
|
-
grpc_socket_factory_unref(p);
|
76
|
+
grpc_socket_factory_unref((grpc_socket_factory *)p);
|
77
77
|
}
|
78
78
|
|
79
79
|
static int socket_factory_cmp(void *a, void *b) {
|
@@ -85,8 +85,8 @@ static const grpc_arg_pointer_vtable socket_factory_arg_vtable = {
|
|
85
85
|
socket_factory_arg_copy, socket_factory_arg_destroy, socket_factory_cmp};
|
86
86
|
|
87
87
|
grpc_arg grpc_socket_factory_to_arg(grpc_socket_factory *factory) {
|
88
|
-
return grpc_channel_arg_pointer_create(GRPC_ARG_SOCKET_FACTORY,
|
89
|
-
&socket_factory_arg_vtable);
|
88
|
+
return grpc_channel_arg_pointer_create((char *)GRPC_ARG_SOCKET_FACTORY,
|
89
|
+
factory, &socket_factory_arg_vtable);
|
90
90
|
}
|
91
91
|
|
92
92
|
#endif
|
@@ -60,11 +60,11 @@ void grpc_socket_mutator_unref(grpc_socket_mutator *mutator) {
|
|
60
60
|
}
|
61
61
|
|
62
62
|
static void *socket_mutator_arg_copy(void *p) {
|
63
|
-
return grpc_socket_mutator_ref(p);
|
63
|
+
return grpc_socket_mutator_ref((grpc_socket_mutator *)p);
|
64
64
|
}
|
65
65
|
|
66
66
|
static void socket_mutator_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) {
|
67
|
-
grpc_socket_mutator_unref(p);
|
67
|
+
grpc_socket_mutator_unref((grpc_socket_mutator *)p);
|
68
68
|
}
|
69
69
|
|
70
70
|
static int socket_mutator_cmp(void *a, void *b) {
|
@@ -76,6 +76,6 @@ static const grpc_arg_pointer_vtable socket_mutator_arg_vtable = {
|
|
76
76
|
socket_mutator_arg_copy, socket_mutator_arg_destroy, socket_mutator_cmp};
|
77
77
|
|
78
78
|
grpc_arg grpc_socket_mutator_to_arg(grpc_socket_mutator *mutator) {
|
79
|
-
return grpc_channel_arg_pointer_create(GRPC_ARG_SOCKET_MUTATOR,
|
80
|
-
&socket_mutator_arg_vtable);
|
79
|
+
return grpc_channel_arg_pointer_create((char *)GRPC_ARG_SOCKET_MUTATOR,
|
80
|
+
mutator, &socket_mutator_arg_vtable);
|
81
81
|
}
|
@@ -26,12 +26,8 @@
|
|
26
26
|
#include <grpc/support/log.h>
|
27
27
|
|
28
28
|
const char *grpc_inet_ntop(int af, const void *src, char *dst, size_t size) {
|
29
|
-
#ifdef GPR_WIN_INET_NTOP
|
30
|
-
return inet_ntop(af, src, dst, size);
|
31
|
-
#else
|
32
29
|
/* Windows InetNtopA wants a mutable ip pointer */
|
33
30
|
return InetNtopA(af, (void *)src, dst, size);
|
34
|
-
#endif /* GPR_WIN_INET_NTOP */
|
35
31
|
}
|
36
32
|
|
37
33
|
#endif /* GRPC_WINDOWS_SOCKETUTILS */
|
@@ -80,7 +80,8 @@ static grpc_error *prepare_socket(const grpc_resolved_address *addr, int fd,
|
|
80
80
|
for (size_t i = 0; i < channel_args->num_args; i++) {
|
81
81
|
if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_SOCKET_MUTATOR)) {
|
82
82
|
GPR_ASSERT(channel_args->args[i].type == GRPC_ARG_POINTER);
|
83
|
-
grpc_socket_mutator *mutator =
|
83
|
+
grpc_socket_mutator *mutator =
|
84
|
+
(grpc_socket_mutator *)channel_args->args[i].value.pointer.p;
|
84
85
|
err = grpc_set_socket_with_mutator(fd, mutator);
|
85
86
|
if (err != GRPC_ERROR_NONE) goto error;
|
86
87
|
}
|
@@ -98,7 +99,7 @@ done:
|
|
98
99
|
|
99
100
|
static void tc_on_alarm(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
|
100
101
|
int done;
|
101
|
-
async_connect *ac = acp;
|
102
|
+
async_connect *ac = (async_connect *)acp;
|
102
103
|
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
103
104
|
const char *str = grpc_error_string(error);
|
104
105
|
gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: on_alarm: error=%s", ac->addr_str,
|
@@ -126,7 +127,7 @@ grpc_endpoint *grpc_tcp_client_create_from_fd(
|
|
126
127
|
}
|
127
128
|
|
128
129
|
static void on_writable(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
|
129
|
-
async_connect *ac = acp;
|
130
|
+
async_connect *ac = (async_connect *)acp;
|
130
131
|
int so_error = 0;
|
131
132
|
socklen_t so_error_size;
|
132
133
|
int err;
|
@@ -304,7 +305,7 @@ static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx,
|
|
304
305
|
|
305
306
|
grpc_pollset_set_add_fd(exec_ctx, interested_parties, fdobj);
|
306
307
|
|
307
|
-
ac = gpr_malloc(sizeof(async_connect));
|
308
|
+
ac = (async_connect *)gpr_malloc(sizeof(async_connect));
|
308
309
|
ac->closure = closure;
|
309
310
|
ac->ep = ep;
|
310
311
|
ac->fd = fdobj;
|
@@ -40,8 +40,10 @@
|
|
40
40
|
#include <grpc/support/useful.h>
|
41
41
|
|
42
42
|
#include "src/core/lib/channel/channel_args.h"
|
43
|
+
#include "src/core/lib/debug/stats.h"
|
43
44
|
#include "src/core/lib/debug/trace.h"
|
44
45
|
#include "src/core/lib/iomgr/ev_posix.h"
|
46
|
+
#include "src/core/lib/iomgr/executor.h"
|
45
47
|
#include "src/core/lib/profiling/timers.h"
|
46
48
|
#include "src/core/lib/slice/slice_internal.h"
|
47
49
|
#include "src/core/lib/slice/slice_string_helpers.h"
|
@@ -66,7 +68,6 @@ typedef struct {
|
|
66
68
|
grpc_fd *em_fd;
|
67
69
|
int fd;
|
68
70
|
bool finished_edge;
|
69
|
-
msg_iovlen_type iov_size; /* Number of slices to allocate per read attempt */
|
70
71
|
double target_length;
|
71
72
|
double bytes_read_this_round;
|
72
73
|
gpr_refcount refcount;
|
@@ -90,8 +91,8 @@ typedef struct {
|
|
90
91
|
grpc_closure *release_fd_cb;
|
91
92
|
int *release_fd;
|
92
93
|
|
93
|
-
grpc_closure
|
94
|
-
grpc_closure
|
94
|
+
grpc_closure read_done_closure;
|
95
|
+
grpc_closure write_done_closure;
|
95
96
|
|
96
97
|
char *peer_string;
|
97
98
|
|
@@ -99,6 +100,148 @@ typedef struct {
|
|
99
100
|
grpc_resource_user_slice_allocator slice_allocator;
|
100
101
|
} grpc_tcp;
|
101
102
|
|
103
|
+
typedef struct backup_poller {
|
104
|
+
gpr_mu *pollset_mu;
|
105
|
+
grpc_closure run_poller;
|
106
|
+
} backup_poller;
|
107
|
+
|
108
|
+
#define BACKUP_POLLER_POLLSET(b) ((grpc_pollset *)((b) + 1))
|
109
|
+
|
110
|
+
static gpr_atm g_uncovered_notifications_pending;
|
111
|
+
static gpr_atm g_backup_poller; /* backup_poller* */
|
112
|
+
|
113
|
+
static void tcp_handle_read(grpc_exec_ctx *exec_ctx, void *arg /* grpc_tcp */,
|
114
|
+
grpc_error *error);
|
115
|
+
static void tcp_handle_write(grpc_exec_ctx *exec_ctx, void *arg /* grpc_tcp */,
|
116
|
+
grpc_error *error);
|
117
|
+
static void tcp_drop_uncovered_then_handle_write(grpc_exec_ctx *exec_ctx,
|
118
|
+
void *arg /* grpc_tcp */,
|
119
|
+
grpc_error *error);
|
120
|
+
|
121
|
+
static void done_poller(grpc_exec_ctx *exec_ctx, void *bp,
|
122
|
+
grpc_error *error_ignored) {
|
123
|
+
backup_poller *p = (backup_poller *)bp;
|
124
|
+
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
125
|
+
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p destroy", p);
|
126
|
+
}
|
127
|
+
grpc_pollset_destroy(exec_ctx, BACKUP_POLLER_POLLSET(p));
|
128
|
+
gpr_free(p);
|
129
|
+
}
|
130
|
+
|
131
|
+
static void run_poller(grpc_exec_ctx *exec_ctx, void *bp,
|
132
|
+
grpc_error *error_ignored) {
|
133
|
+
backup_poller *p = (backup_poller *)bp;
|
134
|
+
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
135
|
+
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p run", p);
|
136
|
+
}
|
137
|
+
gpr_mu_lock(p->pollset_mu);
|
138
|
+
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
|
139
|
+
gpr_timespec deadline =
|
140
|
+
gpr_time_add(now, gpr_time_from_seconds(10, GPR_TIMESPAN));
|
141
|
+
GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS(exec_ctx);
|
142
|
+
GRPC_LOG_IF_ERROR("backup_poller:pollset_work",
|
143
|
+
grpc_pollset_work(exec_ctx, BACKUP_POLLER_POLLSET(p), NULL,
|
144
|
+
now, deadline));
|
145
|
+
gpr_mu_unlock(p->pollset_mu);
|
146
|
+
/* last "uncovered" notification is the ref that keeps us polling, if we get
|
147
|
+
* there try a cas to release it */
|
148
|
+
if (gpr_atm_no_barrier_load(&g_uncovered_notifications_pending) == 1 &&
|
149
|
+
gpr_atm_full_cas(&g_uncovered_notifications_pending, 1, 0)) {
|
150
|
+
gpr_mu_lock(p->pollset_mu);
|
151
|
+
bool cas_ok = gpr_atm_full_cas(&g_backup_poller, (gpr_atm)p, 0);
|
152
|
+
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
153
|
+
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p done cas_ok=%d", p, cas_ok);
|
154
|
+
}
|
155
|
+
gpr_mu_unlock(p->pollset_mu);
|
156
|
+
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
157
|
+
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p shutdown", p);
|
158
|
+
}
|
159
|
+
grpc_pollset_shutdown(exec_ctx, BACKUP_POLLER_POLLSET(p),
|
160
|
+
GRPC_CLOSURE_INIT(&p->run_poller, done_poller, p,
|
161
|
+
grpc_schedule_on_exec_ctx));
|
162
|
+
} else {
|
163
|
+
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
164
|
+
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p reschedule", p);
|
165
|
+
}
|
166
|
+
GRPC_CLOSURE_SCHED(exec_ctx, &p->run_poller, GRPC_ERROR_NONE);
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
170
|
+
static void drop_uncovered(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
|
171
|
+
backup_poller *p = (backup_poller *)gpr_atm_acq_load(&g_backup_poller);
|
172
|
+
gpr_atm old_count =
|
173
|
+
gpr_atm_no_barrier_fetch_add(&g_uncovered_notifications_pending, -1);
|
174
|
+
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
175
|
+
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p uncover cnt %d->%d", p, (int)old_count,
|
176
|
+
(int)old_count - 1);
|
177
|
+
}
|
178
|
+
GPR_ASSERT(old_count != 1);
|
179
|
+
}
|
180
|
+
|
181
|
+
static void cover_self(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
|
182
|
+
backup_poller *p;
|
183
|
+
gpr_atm old_count =
|
184
|
+
gpr_atm_no_barrier_fetch_add(&g_uncovered_notifications_pending, 2);
|
185
|
+
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
186
|
+
gpr_log(GPR_DEBUG, "BACKUP_POLLER: cover cnt %d->%d", (int)old_count,
|
187
|
+
2 + (int)old_count);
|
188
|
+
}
|
189
|
+
if (old_count == 0) {
|
190
|
+
GRPC_STATS_INC_TCP_BACKUP_POLLERS_CREATED(exec_ctx);
|
191
|
+
p = (backup_poller *)gpr_malloc(sizeof(*p) + grpc_pollset_size());
|
192
|
+
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
193
|
+
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p create", p);
|
194
|
+
}
|
195
|
+
grpc_pollset_init(BACKUP_POLLER_POLLSET(p), &p->pollset_mu);
|
196
|
+
gpr_atm_rel_store(&g_backup_poller, (gpr_atm)p);
|
197
|
+
GRPC_CLOSURE_SCHED(
|
198
|
+
exec_ctx,
|
199
|
+
GRPC_CLOSURE_INIT(&p->run_poller, run_poller, p,
|
200
|
+
grpc_executor_scheduler(GRPC_EXECUTOR_LONG)),
|
201
|
+
GRPC_ERROR_NONE);
|
202
|
+
} else {
|
203
|
+
while ((p = (backup_poller *)gpr_atm_acq_load(&g_backup_poller)) == NULL) {
|
204
|
+
// spin waiting for backup poller
|
205
|
+
}
|
206
|
+
}
|
207
|
+
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
208
|
+
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p add %p", p, tcp);
|
209
|
+
}
|
210
|
+
grpc_pollset_add_fd(exec_ctx, BACKUP_POLLER_POLLSET(p), tcp->em_fd);
|
211
|
+
if (old_count != 0) {
|
212
|
+
drop_uncovered(exec_ctx, tcp);
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
static void notify_on_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
|
217
|
+
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
218
|
+
gpr_log(GPR_DEBUG, "TCP:%p notify_on_read", tcp);
|
219
|
+
}
|
220
|
+
GRPC_CLOSURE_INIT(&tcp->read_done_closure, tcp_handle_read, tcp,
|
221
|
+
grpc_schedule_on_exec_ctx);
|
222
|
+
grpc_fd_notify_on_read(exec_ctx, tcp->em_fd, &tcp->read_done_closure);
|
223
|
+
}
|
224
|
+
|
225
|
+
static void notify_on_write(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
|
226
|
+
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
227
|
+
gpr_log(GPR_DEBUG, "TCP:%p notify_on_write", tcp);
|
228
|
+
}
|
229
|
+
cover_self(exec_ctx, tcp);
|
230
|
+
GRPC_CLOSURE_INIT(&tcp->write_done_closure,
|
231
|
+
tcp_drop_uncovered_then_handle_write, tcp,
|
232
|
+
grpc_schedule_on_exec_ctx);
|
233
|
+
grpc_fd_notify_on_write(exec_ctx, tcp->em_fd, &tcp->write_done_closure);
|
234
|
+
}
|
235
|
+
|
236
|
+
static void tcp_drop_uncovered_then_handle_write(grpc_exec_ctx *exec_ctx,
|
237
|
+
void *arg, grpc_error *error) {
|
238
|
+
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
239
|
+
gpr_log(GPR_DEBUG, "TCP:%p got_write: %s", arg, grpc_error_string(error));
|
240
|
+
}
|
241
|
+
drop_uncovered(exec_ctx, (grpc_tcp *)arg);
|
242
|
+
tcp_handle_write(exec_ctx, arg, error);
|
243
|
+
}
|
244
|
+
|
102
245
|
static void add_to_estimate(grpc_tcp *tcp, size_t bytes) {
|
103
246
|
tcp->bytes_read_this_round += (double)bytes;
|
104
247
|
}
|
@@ -214,6 +357,7 @@ static void call_read_cb(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp,
|
|
214
357
|
grpc_closure *cb = tcp->read_cb;
|
215
358
|
|
216
359
|
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
360
|
+
gpr_log(GPR_DEBUG, "TCP:%p call_cb %p %p:%p", tcp, cb, cb->cb, cb->cb_arg);
|
217
361
|
size_t i;
|
218
362
|
const char *str = grpc_error_string(error);
|
219
363
|
gpr_log(GPR_DEBUG, "read: error=%s", str);
|
@@ -239,7 +383,6 @@ static void tcp_do_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
|
|
239
383
|
size_t i;
|
240
384
|
|
241
385
|
GPR_ASSERT(!tcp->finished_edge);
|
242
|
-
GPR_ASSERT(tcp->iov_size <= MAX_READ_IOVEC);
|
243
386
|
GPR_ASSERT(tcp->incoming_buffer->count <= MAX_READ_IOVEC);
|
244
387
|
GPR_TIMER_BEGIN("tcp_continue_read", 0);
|
245
388
|
|
@@ -251,13 +394,17 @@ static void tcp_do_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
|
|
251
394
|
msg.msg_name = NULL;
|
252
395
|
msg.msg_namelen = 0;
|
253
396
|
msg.msg_iov = iov;
|
254
|
-
msg.msg_iovlen = tcp->
|
397
|
+
msg.msg_iovlen = (msg_iovlen_type)tcp->incoming_buffer->count;
|
255
398
|
msg.msg_control = NULL;
|
256
399
|
msg.msg_controllen = 0;
|
257
400
|
msg.msg_flags = 0;
|
258
401
|
|
402
|
+
GRPC_STATS_INC_TCP_READ_OFFER(exec_ctx, tcp->incoming_buffer->length);
|
403
|
+
GRPC_STATS_INC_TCP_READ_OFFER_IOV_SIZE(exec_ctx, tcp->incoming_buffer->count);
|
404
|
+
|
259
405
|
GPR_TIMER_BEGIN("recvmsg", 0);
|
260
406
|
do {
|
407
|
+
GRPC_STATS_INC_SYSCALL_READ(exec_ctx);
|
261
408
|
read_bytes = recvmsg(tcp->fd, &msg, 0);
|
262
409
|
} while (read_bytes < 0 && errno == EINTR);
|
263
410
|
GPR_TIMER_END("recvmsg", read_bytes >= 0);
|
@@ -268,7 +415,7 @@ static void tcp_do_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
|
|
268
415
|
if (errno == EAGAIN) {
|
269
416
|
finish_estimate(tcp);
|
270
417
|
/* We've consumed the edge, request a new one */
|
271
|
-
|
418
|
+
notify_on_read(exec_ctx, tcp);
|
272
419
|
} else {
|
273
420
|
grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
|
274
421
|
tcp->incoming_buffer);
|
@@ -285,6 +432,7 @@ static void tcp_do_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
|
|
285
432
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Socket closed"), tcp));
|
286
433
|
TCP_UNREF(exec_ctx, tcp, "read");
|
287
434
|
} else {
|
435
|
+
GRPC_STATS_INC_TCP_READ_SIZE(exec_ctx, read_bytes);
|
288
436
|
add_to_estimate(tcp, (size_t)read_bytes);
|
289
437
|
GPR_ASSERT((size_t)read_bytes <= tcp->incoming_buffer->length);
|
290
438
|
if ((size_t)read_bytes < tcp->incoming_buffer->length) {
|
@@ -303,7 +451,11 @@ static void tcp_do_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
|
|
303
451
|
|
304
452
|
static void tcp_read_allocation_done(grpc_exec_ctx *exec_ctx, void *tcpp,
|
305
453
|
grpc_error *error) {
|
306
|
-
grpc_tcp *tcp = tcpp;
|
454
|
+
grpc_tcp *tcp = (grpc_tcp *)tcpp;
|
455
|
+
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
456
|
+
gpr_log(GPR_DEBUG, "TCP:%p read_allocation_done: %s", tcp,
|
457
|
+
grpc_error_string(error));
|
458
|
+
}
|
307
459
|
if (error != GRPC_ERROR_NONE) {
|
308
460
|
grpc_slice_buffer_reset_and_unref_internal(exec_ctx, tcp->incoming_buffer);
|
309
461
|
grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
|
@@ -319,9 +471,15 @@ static void tcp_continue_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
|
|
319
471
|
size_t target_read_size = get_target_read_size(tcp);
|
320
472
|
if (tcp->incoming_buffer->length < target_read_size &&
|
321
473
|
tcp->incoming_buffer->count < MAX_READ_IOVEC) {
|
474
|
+
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
475
|
+
gpr_log(GPR_DEBUG, "TCP:%p alloc_slices", tcp);
|
476
|
+
}
|
322
477
|
grpc_resource_user_alloc_slices(exec_ctx, &tcp->slice_allocator,
|
323
478
|
target_read_size, 1, tcp->incoming_buffer);
|
324
479
|
} else {
|
480
|
+
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
481
|
+
gpr_log(GPR_DEBUG, "TCP:%p do_read", tcp);
|
482
|
+
}
|
325
483
|
tcp_do_read(exec_ctx, tcp);
|
326
484
|
}
|
327
485
|
}
|
@@ -330,6 +488,9 @@ static void tcp_handle_read(grpc_exec_ctx *exec_ctx, void *arg /* grpc_tcp */,
|
|
330
488
|
grpc_error *error) {
|
331
489
|
grpc_tcp *tcp = (grpc_tcp *)arg;
|
332
490
|
GPR_ASSERT(!tcp->finished_edge);
|
491
|
+
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
492
|
+
gpr_log(GPR_DEBUG, "TCP:%p got_read: %s", tcp, grpc_error_string(error));
|
493
|
+
}
|
333
494
|
|
334
495
|
if (error != GRPC_ERROR_NONE) {
|
335
496
|
grpc_slice_buffer_reset_and_unref_internal(exec_ctx, tcp->incoming_buffer);
|
@@ -353,15 +514,16 @@ static void tcp_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
|
|
353
514
|
TCP_REF(tcp, "read");
|
354
515
|
if (tcp->finished_edge) {
|
355
516
|
tcp->finished_edge = false;
|
356
|
-
|
517
|
+
notify_on_read(exec_ctx, tcp);
|
357
518
|
} else {
|
358
|
-
GRPC_CLOSURE_SCHED(exec_ctx, &tcp->
|
519
|
+
GRPC_CLOSURE_SCHED(exec_ctx, &tcp->read_done_closure, GRPC_ERROR_NONE);
|
359
520
|
}
|
360
521
|
}
|
361
522
|
|
362
523
|
/* returns true if done, false if pending; if returning true, *error is set */
|
363
524
|
#define MAX_WRITE_IOVEC 1000
|
364
|
-
static bool tcp_flush(grpc_tcp *tcp,
|
525
|
+
static bool tcp_flush(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp,
|
526
|
+
grpc_error **error) {
|
365
527
|
struct msghdr msg;
|
366
528
|
struct iovec iov[MAX_WRITE_IOVEC];
|
367
529
|
msg_iovlen_type iov_size;
|
@@ -400,9 +562,13 @@ static bool tcp_flush(grpc_tcp *tcp, grpc_error **error) {
|
|
400
562
|
msg.msg_controllen = 0;
|
401
563
|
msg.msg_flags = 0;
|
402
564
|
|
565
|
+
GRPC_STATS_INC_TCP_WRITE_SIZE(exec_ctx, sending_length);
|
566
|
+
GRPC_STATS_INC_TCP_WRITE_IOV_SIZE(exec_ctx, iov_size);
|
567
|
+
|
403
568
|
GPR_TIMER_BEGIN("sendmsg", 1);
|
404
569
|
do {
|
405
570
|
/* TODO(klempner): Cork if this is a partial write */
|
571
|
+
GRPC_STATS_INC_SYSCALL_WRITE(exec_ctx);
|
406
572
|
sent_length = sendmsg(tcp->fd, &msg, SENDMSG_FLAGS);
|
407
573
|
} while (sent_length < 0 && errno == EINTR);
|
408
574
|
GPR_TIMER_END("sendmsg", 0);
|
@@ -459,11 +625,11 @@ static void tcp_handle_write(grpc_exec_ctx *exec_ctx, void *arg /* grpc_tcp */,
|
|
459
625
|
return;
|
460
626
|
}
|
461
627
|
|
462
|
-
if (!tcp_flush(tcp, &error)) {
|
628
|
+
if (!tcp_flush(exec_ctx, tcp, &error)) {
|
463
629
|
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
464
630
|
gpr_log(GPR_DEBUG, "write: delayed");
|
465
631
|
}
|
466
|
-
|
632
|
+
notify_on_write(exec_ctx, tcp);
|
467
633
|
} else {
|
468
634
|
cb = tcp->write_cb;
|
469
635
|
tcp->write_cb = NULL;
|
@@ -510,13 +676,13 @@ static void tcp_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
|
|
510
676
|
tcp->outgoing_slice_idx = 0;
|
511
677
|
tcp->outgoing_byte_idx = 0;
|
512
678
|
|
513
|
-
if (!tcp_flush(tcp, &error)) {
|
679
|
+
if (!tcp_flush(exec_ctx, tcp, &error)) {
|
514
680
|
TCP_REF(tcp, "write");
|
515
681
|
tcp->write_cb = cb;
|
516
682
|
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
517
683
|
gpr_log(GPR_DEBUG, "write: delayed");
|
518
684
|
}
|
519
|
-
|
685
|
+
notify_on_write(exec_ctx, tcp);
|
520
686
|
} else {
|
521
687
|
if (GRPC_TRACER_ON(grpc_tcp_trace)) {
|
522
688
|
const char *str = grpc_error_string(error);
|
@@ -593,7 +759,7 @@ grpc_endpoint *grpc_tcp_create(grpc_exec_ctx *exec_ctx, grpc_fd *em_fd,
|
|
593
759
|
strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) {
|
594
760
|
grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
|
595
761
|
resource_quota = grpc_resource_quota_ref_internal(
|
596
|
-
channel_args->args[i].value.pointer.p);
|
762
|
+
(grpc_resource_quota *)channel_args->args[i].value.pointer.p);
|
597
763
|
}
|
598
764
|
}
|
599
765
|
}
|
@@ -617,16 +783,11 @@ grpc_endpoint *grpc_tcp_create(grpc_exec_ctx *exec_ctx, grpc_fd *em_fd,
|
|
617
783
|
tcp->min_read_chunk_size = tcp_min_read_chunk_size;
|
618
784
|
tcp->max_read_chunk_size = tcp_max_read_chunk_size;
|
619
785
|
tcp->bytes_read_this_round = 0;
|
620
|
-
tcp->iov_size = 1;
|
621
786
|
tcp->finished_edge = true;
|
622
787
|
/* paired with unref in grpc_tcp_destroy */
|
623
788
|
gpr_ref_init(&tcp->refcount, 1);
|
624
789
|
gpr_atm_no_barrier_store(&tcp->shutdown_count, 0);
|
625
790
|
tcp->em_fd = em_fd;
|
626
|
-
GRPC_CLOSURE_INIT(&tcp->read_closure, tcp_handle_read, tcp,
|
627
|
-
grpc_schedule_on_exec_ctx);
|
628
|
-
GRPC_CLOSURE_INIT(&tcp->write_closure, tcp_handle_write, tcp,
|
629
|
-
grpc_schedule_on_exec_ctx);
|
630
791
|
grpc_slice_buffer_init(&tcp->last_read_buffer);
|
631
792
|
tcp->resource_user = grpc_resource_user_create(resource_quota, peer_string);
|
632
793
|
grpc_resource_user_slice_allocator_init(
|
@@ -74,7 +74,7 @@ grpc_error *grpc_tcp_server_create(grpc_exec_ctx *exec_ctx,
|
|
74
74
|
grpc_tcp_server **server) {
|
75
75
|
gpr_once_init(&check_init, init);
|
76
76
|
|
77
|
-
grpc_tcp_server *s = gpr_zalloc(sizeof(grpc_tcp_server));
|
77
|
+
grpc_tcp_server *s = (grpc_tcp_server *)gpr_zalloc(sizeof(grpc_tcp_server));
|
78
78
|
s->so_reuseport = has_so_reuseport;
|
79
79
|
s->expand_wildcard_addrs = false;
|
80
80
|
for (size_t i = 0; i < (args == NULL ? 0 : args->num_args); i++) {
|
@@ -138,7 +138,7 @@ static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
|
|
138
138
|
|
139
139
|
static void destroyed_port(grpc_exec_ctx *exec_ctx, void *server,
|
140
140
|
grpc_error *error) {
|
141
|
-
grpc_tcp_server *s = server;
|
141
|
+
grpc_tcp_server *s = (grpc_tcp_server *)server;
|
142
142
|
gpr_mu_lock(&s->mu);
|
143
143
|
s->destroyed_ports++;
|
144
144
|
if (s->destroyed_ports == s->nports) {
|
@@ -197,13 +197,13 @@ static void tcp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
|
|
197
197
|
|
198
198
|
/* event manager callback when reads are ready */
|
199
199
|
static void on_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *err) {
|
200
|
-
grpc_tcp_listener *sp = arg;
|
201
|
-
|
200
|
+
grpc_tcp_listener *sp = (grpc_tcp_listener *)arg;
|
201
|
+
grpc_pollset *read_notifier_pollset;
|
202
202
|
if (err != GRPC_ERROR_NONE) {
|
203
203
|
goto error;
|
204
204
|
}
|
205
205
|
|
206
|
-
|
206
|
+
read_notifier_pollset =
|
207
207
|
sp->server->pollsets[(size_t)gpr_atm_no_barrier_fetch_add(
|
208
208
|
&sp->server->next_pollset_to_assign, 1) %
|
209
209
|
sp->server->pollset_count];
|
@@ -251,7 +251,8 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *err) {
|
|
251
251
|
grpc_pollset_add_fd(exec_ctx, read_notifier_pollset, fdobj);
|
252
252
|
|
253
253
|
// Create acceptor.
|
254
|
-
grpc_tcp_server_acceptor *acceptor =
|
254
|
+
grpc_tcp_server_acceptor *acceptor =
|
255
|
+
(grpc_tcp_server_acceptor *)gpr_malloc(sizeof(*acceptor));
|
255
256
|
acceptor->from_server = sp->server;
|
256
257
|
acceptor->port_index = sp->port_index;
|
257
258
|
acceptor->fd_index = sp->fd_index;
|
@@ -365,7 +366,7 @@ static grpc_error *clone_port(grpc_tcp_listener *listener, unsigned count) {
|
|
365
366
|
listener->server->nports++;
|
366
367
|
grpc_sockaddr_to_string(&addr_str, &listener->addr, 1);
|
367
368
|
gpr_asprintf(&name, "tcp-server-listener:%s/clone-%d", addr_str, i);
|
368
|
-
sp = gpr_malloc(sizeof(grpc_tcp_listener));
|
369
|
+
sp = (grpc_tcp_listener *)gpr_malloc(sizeof(grpc_tcp_listener));
|
369
370
|
sp->next = listener->next;
|
370
371
|
listener->next = sp;
|
371
372
|
/* sp (the new listener) is a sibling of 'listener' (the original
|