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
@@ -39,6 +39,7 @@
|
|
39
39
|
#include <grpc/support/tls.h>
|
40
40
|
#include <grpc/support/useful.h>
|
41
41
|
|
42
|
+
#include "src/core/lib/debug/stats.h"
|
42
43
|
#include "src/core/lib/iomgr/ev_posix.h"
|
43
44
|
#include "src/core/lib/iomgr/iomgr_internal.h"
|
44
45
|
#include "src/core/lib/iomgr/lockfree_event.h"
|
@@ -362,7 +363,8 @@ static void polling_island_add_fds_locked(polling_island *pi, grpc_fd **fds,
|
|
362
363
|
|
363
364
|
if (pi->fd_cnt == pi->fd_capacity) {
|
364
365
|
pi->fd_capacity = GPR_MAX(pi->fd_capacity + 8, pi->fd_cnt * 3 / 2);
|
365
|
-
pi->fds =
|
366
|
+
pi->fds =
|
367
|
+
(grpc_fd **)gpr_realloc(pi->fds, sizeof(grpc_fd *) * pi->fd_capacity);
|
366
368
|
}
|
367
369
|
|
368
370
|
pi->fds[pi->fd_cnt++] = fds[i];
|
@@ -465,7 +467,7 @@ static polling_island *polling_island_create(grpc_exec_ctx *exec_ctx,
|
|
465
467
|
|
466
468
|
*error = GRPC_ERROR_NONE;
|
467
469
|
|
468
|
-
pi = gpr_malloc(sizeof(*pi));
|
470
|
+
pi = (polling_island *)gpr_malloc(sizeof(*pi));
|
469
471
|
gpr_mu_init(&pi->mu);
|
470
472
|
pi->fd_cnt = 0;
|
471
473
|
pi->fd_capacity = 0;
|
@@ -809,7 +811,7 @@ static grpc_fd *fd_create(int fd, const char *name) {
|
|
809
811
|
gpr_mu_unlock(&fd_freelist_mu);
|
810
812
|
|
811
813
|
if (new_fd == NULL) {
|
812
|
-
new_fd = gpr_malloc(sizeof(grpc_fd));
|
814
|
+
new_fd = (grpc_fd *)gpr_malloc(sizeof(grpc_fd));
|
813
815
|
gpr_mu_init(&new_fd->po.mu);
|
814
816
|
}
|
815
817
|
|
@@ -1019,10 +1021,11 @@ static void push_front_worker(grpc_pollset *p, grpc_pollset_worker *worker) {
|
|
1019
1021
|
}
|
1020
1022
|
|
1021
1023
|
/* p->mu must be held before calling this function */
|
1022
|
-
static grpc_error *pollset_kick(grpc_pollset *p,
|
1024
|
+
static grpc_error *pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
|
1023
1025
|
grpc_pollset_worker *specific_worker) {
|
1024
1026
|
GPR_TIMER_BEGIN("pollset_kick", 0);
|
1025
1027
|
grpc_error *error = GRPC_ERROR_NONE;
|
1028
|
+
GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
|
1026
1029
|
const char *err_desc = "Kick Failure";
|
1027
1030
|
grpc_pollset_worker *worker = specific_worker;
|
1028
1031
|
if (worker != NULL) {
|
@@ -1130,7 +1133,8 @@ static void fd_become_writable(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
|
|
1130
1133
|
}
|
1131
1134
|
|
1132
1135
|
static void pollset_release_polling_island(grpc_exec_ctx *exec_ctx,
|
1133
|
-
grpc_pollset *ps,
|
1136
|
+
grpc_pollset *ps,
|
1137
|
+
const char *reason) {
|
1134
1138
|
if (ps->po.pi != NULL) {
|
1135
1139
|
PI_UNREF(exec_ctx, ps->po.pi, reason);
|
1136
1140
|
}
|
@@ -1156,7 +1160,7 @@ static void pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
1156
1160
|
GPR_ASSERT(!pollset->shutting_down);
|
1157
1161
|
pollset->shutting_down = true;
|
1158
1162
|
pollset->shutdown_done = closure;
|
1159
|
-
pollset_kick(pollset, GRPC_POLLSET_KICK_BROADCAST);
|
1163
|
+
pollset_kick(exec_ctx, pollset, GRPC_POLLSET_KICK_BROADCAST);
|
1160
1164
|
|
1161
1165
|
/* If the pollset has any workers, we cannot call finish_shutdown_locked()
|
1162
1166
|
because it would release the underlying polling island. In such a case, we
|
@@ -1236,6 +1240,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx,
|
|
1236
1240
|
g_current_thread_polling_island = pi;
|
1237
1241
|
|
1238
1242
|
GRPC_SCHEDULING_START_BLOCKING_REGION;
|
1243
|
+
GRPC_STATS_INC_SYSCALL_POLL(exec_ctx);
|
1239
1244
|
ep_rv =
|
1240
1245
|
epoll_pwait(epoll_fd, ep_ev, GRPC_EPOLL_MAX_EVENTS, timeout_ms, sig_mask);
|
1241
1246
|
GRPC_SCHEDULING_END_BLOCKING_REGION;
|
@@ -1271,7 +1276,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx,
|
|
1271
1276
|
to the function pollset_work_and_unlock() will pick up the correct
|
1272
1277
|
epoll_fd */
|
1273
1278
|
} else {
|
1274
|
-
grpc_fd *fd = data_ptr;
|
1279
|
+
grpc_fd *fd = (grpc_fd *)data_ptr;
|
1275
1280
|
int cancel = ep_ev[i].events & (EPOLLERR | EPOLLHUP);
|
1276
1281
|
int read_ev = ep_ev[i].events & (EPOLLIN | EPOLLPRI);
|
1277
1282
|
int write_ev = ep_ev[i].events & EPOLLOUT;
|
@@ -1567,7 +1572,7 @@ static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
1567
1572
|
*/
|
1568
1573
|
|
1569
1574
|
static grpc_pollset_set *pollset_set_create(void) {
|
1570
|
-
grpc_pollset_set *pss = gpr_malloc(sizeof(*pss));
|
1575
|
+
grpc_pollset_set *pss = (grpc_pollset_set *)gpr_malloc(sizeof(*pss));
|
1571
1576
|
gpr_mu_init(&pss->po.mu);
|
1572
1577
|
pss->po.pi = NULL;
|
1573
1578
|
#ifndef NDEBUG
|
@@ -1645,8 +1650,8 @@ void *grpc_pollset_get_polling_island(grpc_pollset *ps) {
|
|
1645
1650
|
}
|
1646
1651
|
|
1647
1652
|
bool grpc_are_polling_islands_equal(void *p, void *q) {
|
1648
|
-
polling_island *p1 = p;
|
1649
|
-
polling_island *p2 = q;
|
1653
|
+
polling_island *p1 = (polling_island *)p;
|
1654
|
+
polling_island *p2 = (polling_island *)q;
|
1650
1655
|
|
1651
1656
|
/* Note: polling_island_lock_pair() may change p1 and p2 to point to the
|
1652
1657
|
latest polling islands in their respective linked lists */
|
@@ -1667,34 +1672,34 @@ static void shutdown_engine(void) {
|
|
1667
1672
|
}
|
1668
1673
|
|
1669
1674
|
static const grpc_event_engine_vtable vtable = {
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1675
|
+
sizeof(grpc_pollset),
|
1676
|
+
|
1677
|
+
fd_create,
|
1678
|
+
fd_wrapped_fd,
|
1679
|
+
fd_orphan,
|
1680
|
+
fd_shutdown,
|
1681
|
+
fd_notify_on_read,
|
1682
|
+
fd_notify_on_write,
|
1683
|
+
fd_is_shutdown,
|
1684
|
+
fd_get_read_notifier_pollset,
|
1685
|
+
|
1686
|
+
pollset_init,
|
1687
|
+
pollset_shutdown,
|
1688
|
+
pollset_destroy,
|
1689
|
+
pollset_work,
|
1690
|
+
pollset_kick,
|
1691
|
+
pollset_add_fd,
|
1692
|
+
|
1693
|
+
pollset_set_create,
|
1694
|
+
pollset_set_destroy,
|
1695
|
+
pollset_set_add_pollset,
|
1696
|
+
pollset_set_del_pollset,
|
1697
|
+
pollset_set_add_pollset_set,
|
1698
|
+
pollset_set_del_pollset_set,
|
1699
|
+
pollset_set_add_fd,
|
1700
|
+
pollset_set_del_fd,
|
1701
|
+
|
1702
|
+
shutdown_engine,
|
1698
1703
|
};
|
1699
1704
|
|
1700
1705
|
/* It is possible that GLIBC has epoll but the underlying kernel doesn't.
|
@@ -1728,9 +1733,7 @@ const grpc_event_engine_vtable *grpc_init_epollsig_linux(
|
|
1728
1733
|
}
|
1729
1734
|
|
1730
1735
|
if (!is_grpc_wakeup_signal_initialized) {
|
1731
|
-
|
1732
|
-
* force this to be explitly chosen if needed */
|
1733
|
-
if (true || explicit_request) {
|
1736
|
+
if (explicit_request) {
|
1734
1737
|
grpc_use_signal(SIGRTMIN + 6);
|
1735
1738
|
} else {
|
1736
1739
|
return NULL;
|
@@ -36,6 +36,7 @@
|
|
36
36
|
#include <grpc/support/tls.h>
|
37
37
|
#include <grpc/support/useful.h>
|
38
38
|
|
39
|
+
#include "src/core/lib/debug/stats.h"
|
39
40
|
#include "src/core/lib/iomgr/iomgr_internal.h"
|
40
41
|
#include "src/core/lib/iomgr/timer.h"
|
41
42
|
#include "src/core/lib/iomgr/wakeup_fd_cv.h"
|
@@ -208,7 +209,7 @@ static int poll_deadline_to_millis_timeout(gpr_timespec deadline,
|
|
208
209
|
#define GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP 2
|
209
210
|
/* As per pollset_kick, with an extended set of flags (defined above)
|
210
211
|
-- mostly for fd_posix's use. */
|
211
|
-
static grpc_error *pollset_kick_ext(grpc_pollset *p,
|
212
|
+
static grpc_error *pollset_kick_ext(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
|
212
213
|
grpc_pollset_worker *specific_worker,
|
213
214
|
uint32_t flags) GRPC_MUST_USE_RESULT;
|
214
215
|
|
@@ -326,7 +327,7 @@ static void unref_by(grpc_fd *fd, int n) {
|
|
326
327
|
}
|
327
328
|
|
328
329
|
static grpc_fd *fd_create(int fd, const char *name) {
|
329
|
-
grpc_fd *r = gpr_malloc(sizeof(*r));
|
330
|
+
grpc_fd *r = (grpc_fd *)gpr_malloc(sizeof(*r));
|
330
331
|
gpr_mu_init(&r->mu);
|
331
332
|
gpr_atm_rel_store(&r->refst, 1);
|
332
333
|
r->shutdown = 0;
|
@@ -364,36 +365,39 @@ static grpc_pollset *fd_get_read_notifier_pollset(grpc_exec_ctx *exec_ctx,
|
|
364
365
|
return notifier;
|
365
366
|
}
|
366
367
|
|
367
|
-
static grpc_error *pollset_kick_locked(
|
368
|
+
static grpc_error *pollset_kick_locked(grpc_exec_ctx *exec_ctx,
|
369
|
+
grpc_fd_watcher *watcher) {
|
368
370
|
gpr_mu_lock(&watcher->pollset->mu);
|
369
371
|
GPR_ASSERT(watcher->worker);
|
370
|
-
grpc_error *err =
|
371
|
-
|
372
|
+
grpc_error *err =
|
373
|
+
pollset_kick_ext(exec_ctx, watcher->pollset, watcher->worker,
|
374
|
+
GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP);
|
372
375
|
gpr_mu_unlock(&watcher->pollset->mu);
|
373
376
|
return err;
|
374
377
|
}
|
375
378
|
|
376
|
-
static void maybe_wake_one_watcher_locked(
|
379
|
+
static void maybe_wake_one_watcher_locked(grpc_exec_ctx *exec_ctx,
|
380
|
+
grpc_fd *fd) {
|
377
381
|
if (fd->inactive_watcher_root.next != &fd->inactive_watcher_root) {
|
378
|
-
pollset_kick_locked(fd->inactive_watcher_root.next);
|
382
|
+
pollset_kick_locked(exec_ctx, fd->inactive_watcher_root.next);
|
379
383
|
} else if (fd->read_watcher) {
|
380
|
-
pollset_kick_locked(fd->read_watcher);
|
384
|
+
pollset_kick_locked(exec_ctx, fd->read_watcher);
|
381
385
|
} else if (fd->write_watcher) {
|
382
|
-
pollset_kick_locked(fd->write_watcher);
|
386
|
+
pollset_kick_locked(exec_ctx, fd->write_watcher);
|
383
387
|
}
|
384
388
|
}
|
385
389
|
|
386
|
-
static void wake_all_watchers_locked(grpc_fd *fd) {
|
390
|
+
static void wake_all_watchers_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
|
387
391
|
grpc_fd_watcher *watcher;
|
388
392
|
for (watcher = fd->inactive_watcher_root.next;
|
389
393
|
watcher != &fd->inactive_watcher_root; watcher = watcher->next) {
|
390
|
-
pollset_kick_locked(watcher);
|
394
|
+
pollset_kick_locked(exec_ctx, watcher);
|
391
395
|
}
|
392
396
|
if (fd->read_watcher) {
|
393
|
-
pollset_kick_locked(fd->read_watcher);
|
397
|
+
pollset_kick_locked(exec_ctx, fd->read_watcher);
|
394
398
|
}
|
395
399
|
if (fd->write_watcher && fd->write_watcher != fd->read_watcher) {
|
396
|
-
pollset_kick_locked(fd->write_watcher);
|
400
|
+
pollset_kick_locked(exec_ctx, fd->write_watcher);
|
397
401
|
}
|
398
402
|
}
|
399
403
|
|
@@ -434,7 +438,7 @@ static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
|
434
438
|
if (!has_watchers(fd)) {
|
435
439
|
close_fd_locked(exec_ctx, fd);
|
436
440
|
} else {
|
437
|
-
wake_all_watchers_locked(fd);
|
441
|
+
wake_all_watchers_locked(exec_ctx, fd);
|
438
442
|
}
|
439
443
|
gpr_mu_unlock(&fd->mu);
|
440
444
|
UNREF_BY(fd, 2, reason); /* drop the reference */
|
@@ -478,7 +482,7 @@ static void notify_on_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
|
478
482
|
/* already ready ==> queue the closure to run immediately */
|
479
483
|
*st = CLOSURE_NOT_READY;
|
480
484
|
GRPC_CLOSURE_SCHED(exec_ctx, closure, fd_shutdown_error(fd));
|
481
|
-
maybe_wake_one_watcher_locked(fd);
|
485
|
+
maybe_wake_one_watcher_locked(exec_ctx, fd);
|
482
486
|
} else {
|
483
487
|
/* upcallptr was set to a different closure. This is an error! */
|
484
488
|
gpr_log(GPR_ERROR,
|
@@ -647,7 +651,7 @@ static void fd_end_poll(grpc_exec_ctx *exec_ctx, grpc_fd_watcher *watcher,
|
|
647
651
|
}
|
648
652
|
}
|
649
653
|
if (kick) {
|
650
|
-
maybe_wake_one_watcher_locked(fd);
|
654
|
+
maybe_wake_one_watcher_locked(exec_ctx, fd);
|
651
655
|
}
|
652
656
|
if (fd_is_orphaned(fd) && !has_watchers(fd) && !fd->closed) {
|
653
657
|
close_fd_locked(exec_ctx, fd);
|
@@ -711,11 +715,12 @@ static void kick_append_error(grpc_error **composite, grpc_error *error) {
|
|
711
715
|
*composite = grpc_error_add_child(*composite, error);
|
712
716
|
}
|
713
717
|
|
714
|
-
static grpc_error *pollset_kick_ext(grpc_pollset *p,
|
718
|
+
static grpc_error *pollset_kick_ext(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
|
715
719
|
grpc_pollset_worker *specific_worker,
|
716
720
|
uint32_t flags) {
|
717
721
|
GPR_TIMER_BEGIN("pollset_kick_ext", 0);
|
718
722
|
grpc_error *error = GRPC_ERROR_NONE;
|
723
|
+
GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
|
719
724
|
|
720
725
|
/* pollset->mu already held */
|
721
726
|
if (specific_worker != NULL) {
|
@@ -781,9 +786,9 @@ static grpc_error *pollset_kick_ext(grpc_pollset *p,
|
|
781
786
|
return error;
|
782
787
|
}
|
783
788
|
|
784
|
-
static grpc_error *pollset_kick(grpc_pollset *p,
|
789
|
+
static grpc_error *pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *p,
|
785
790
|
grpc_pollset_worker *specific_worker) {
|
786
|
-
return pollset_kick_ext(p, specific_worker, 0);
|
791
|
+
return pollset_kick_ext(exec_ctx, p, specific_worker, 0);
|
787
792
|
}
|
788
793
|
|
789
794
|
/* global state management */
|
@@ -841,12 +846,12 @@ static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
841
846
|
if (pollset->fd_count == pollset->fd_capacity) {
|
842
847
|
pollset->fd_capacity =
|
843
848
|
GPR_MAX(pollset->fd_capacity + 8, pollset->fd_count * 3 / 2);
|
844
|
-
pollset->fds =
|
845
|
-
|
849
|
+
pollset->fds = (grpc_fd **)gpr_realloc(
|
850
|
+
pollset->fds, sizeof(grpc_fd *) * pollset->fd_capacity);
|
846
851
|
}
|
847
852
|
pollset->fds[pollset->fd_count++] = fd;
|
848
853
|
GRPC_FD_REF(fd, "multipoller");
|
849
|
-
pollset_kick(pollset, NULL);
|
854
|
+
pollset_kick(exec_ctx, pollset, NULL);
|
850
855
|
exit:
|
851
856
|
gpr_mu_unlock(&pollset->mu);
|
852
857
|
}
|
@@ -894,7 +899,8 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
894
899
|
worker.wakeup_fd = pollset->local_wakeup_cache;
|
895
900
|
pollset->local_wakeup_cache = worker.wakeup_fd->next;
|
896
901
|
} else {
|
897
|
-
worker.wakeup_fd =
|
902
|
+
worker.wakeup_fd =
|
903
|
+
(grpc_cached_wakeup_fd *)gpr_malloc(sizeof(*worker.wakeup_fd));
|
898
904
|
error = grpc_wakeup_fd_init(&worker.wakeup_fd->fd);
|
899
905
|
if (error != GRPC_ERROR_NONE) {
|
900
906
|
GRPC_LOG_IF_ERROR("pollset_work", GRPC_ERROR_REF(error));
|
@@ -949,8 +955,8 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
949
955
|
const size_t pfd_size = sizeof(*pfds) * (pollset->fd_count + 2);
|
950
956
|
const size_t watch_size = sizeof(*watchers) * (pollset->fd_count + 2);
|
951
957
|
void *buf = gpr_malloc(pfd_size + watch_size);
|
952
|
-
pfds = buf;
|
953
|
-
watchers = (void *)((char *)buf + pfd_size);
|
958
|
+
pfds = (struct pollfd *)buf;
|
959
|
+
watchers = (grpc_fd_watcher *)(void *)((char *)buf + pfd_size);
|
954
960
|
}
|
955
961
|
|
956
962
|
fd_count = 0;
|
@@ -983,9 +989,14 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
983
989
|
/* TODO(vpai): Consider first doing a 0 timeout poll here to avoid
|
984
990
|
even going into the blocking annotation if possible */
|
985
991
|
GRPC_SCHEDULING_START_BLOCKING_REGION;
|
992
|
+
GRPC_STATS_INC_SYSCALL_POLL(exec_ctx);
|
986
993
|
r = grpc_poll_function(pfds, pfd_count, timeout);
|
987
994
|
GRPC_SCHEDULING_END_BLOCKING_REGION;
|
988
995
|
|
996
|
+
if (GRPC_TRACER_ON(grpc_polling_trace)) {
|
997
|
+
gpr_log(GPR_DEBUG, "%p poll=%d", pollset, r);
|
998
|
+
}
|
999
|
+
|
989
1000
|
if (r < 0) {
|
990
1001
|
if (errno != EINTR) {
|
991
1002
|
work_combine_error(&error, GRPC_OS_ERROR(errno, "poll"));
|
@@ -1006,6 +1017,9 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
1006
1017
|
}
|
1007
1018
|
} else {
|
1008
1019
|
if (pfds[0].revents & POLLIN_CHECK) {
|
1020
|
+
if (GRPC_TRACER_ON(grpc_polling_trace)) {
|
1021
|
+
gpr_log(GPR_DEBUG, "%p: got_wakeup", pollset);
|
1022
|
+
}
|
1009
1023
|
work_combine_error(
|
1010
1024
|
&error, grpc_wakeup_fd_consume_wakeup(&worker.wakeup_fd->fd));
|
1011
1025
|
}
|
@@ -1013,6 +1027,11 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
1013
1027
|
if (watchers[i].fd == NULL) {
|
1014
1028
|
fd_end_poll(exec_ctx, &watchers[i], 0, 0, NULL);
|
1015
1029
|
} else {
|
1030
|
+
if (GRPC_TRACER_ON(grpc_polling_trace)) {
|
1031
|
+
gpr_log(GPR_DEBUG, "%p got_event: %d r:%d w:%d [%d]", pollset,
|
1032
|
+
pfds[i].fd, (pfds[i].revents & POLLIN_CHECK) != 0,
|
1033
|
+
(pfds[i].revents & POLLOUT_CHECK) != 0, pfds[i].revents);
|
1034
|
+
}
|
1016
1035
|
fd_end_poll(exec_ctx, &watchers[i], pfds[i].revents & POLLIN_CHECK,
|
1017
1036
|
pfds[i].revents & POLLOUT_CHECK, pollset);
|
1018
1037
|
}
|
@@ -1068,7 +1087,7 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
1068
1087
|
/* check shutdown conditions */
|
1069
1088
|
if (pollset->shutting_down) {
|
1070
1089
|
if (pollset_has_workers(pollset)) {
|
1071
|
-
pollset_kick(pollset, NULL);
|
1090
|
+
pollset_kick(exec_ctx, pollset, NULL);
|
1072
1091
|
} else if (!pollset->called_shutdown && !pollset_has_observers(pollset)) {
|
1073
1092
|
pollset->called_shutdown = 1;
|
1074
1093
|
gpr_mu_unlock(&pollset->mu);
|
@@ -1097,7 +1116,7 @@ static void pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
1097
1116
|
GPR_ASSERT(!pollset->shutting_down);
|
1098
1117
|
pollset->shutting_down = 1;
|
1099
1118
|
pollset->shutdown_done = closure;
|
1100
|
-
pollset_kick(pollset, GRPC_POLLSET_KICK_BROADCAST);
|
1119
|
+
pollset_kick(exec_ctx, pollset, GRPC_POLLSET_KICK_BROADCAST);
|
1101
1120
|
if (!pollset_has_workers(pollset)) {
|
1102
1121
|
GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pollset->idle_jobs);
|
1103
1122
|
}
|
@@ -1129,7 +1148,8 @@ static int poll_deadline_to_millis_timeout(gpr_timespec deadline,
|
|
1129
1148
|
*/
|
1130
1149
|
|
1131
1150
|
static grpc_pollset_set *pollset_set_create(void) {
|
1132
|
-
grpc_pollset_set *pollset_set =
|
1151
|
+
grpc_pollset_set *pollset_set =
|
1152
|
+
(grpc_pollset_set *)gpr_zalloc(sizeof(*pollset_set));
|
1133
1153
|
gpr_mu_init(&pollset_set->mu);
|
1134
1154
|
return pollset_set;
|
1135
1155
|
}
|
@@ -1172,9 +1192,9 @@ static void pollset_set_add_pollset(grpc_exec_ctx *exec_ctx,
|
|
1172
1192
|
if (pollset_set->pollset_count == pollset_set->pollset_capacity) {
|
1173
1193
|
pollset_set->pollset_capacity =
|
1174
1194
|
GPR_MAX(8, 2 * pollset_set->pollset_capacity);
|
1175
|
-
pollset_set->pollsets =
|
1176
|
-
|
1177
|
-
|
1195
|
+
pollset_set->pollsets = (grpc_pollset **)gpr_realloc(
|
1196
|
+
pollset_set->pollsets,
|
1197
|
+
pollset_set->pollset_capacity * sizeof(*pollset_set->pollsets));
|
1178
1198
|
}
|
1179
1199
|
pollset_set->pollsets[pollset_set->pollset_count++] = pollset;
|
1180
1200
|
for (i = 0, j = 0; i < pollset_set->fd_count; i++) {
|
@@ -1223,9 +1243,9 @@ static void pollset_set_add_pollset_set(grpc_exec_ctx *exec_ctx,
|
|
1223
1243
|
gpr_mu_lock(&bag->mu);
|
1224
1244
|
if (bag->pollset_set_count == bag->pollset_set_capacity) {
|
1225
1245
|
bag->pollset_set_capacity = GPR_MAX(8, 2 * bag->pollset_set_capacity);
|
1226
|
-
bag->pollset_sets =
|
1227
|
-
|
1228
|
-
|
1246
|
+
bag->pollset_sets = (grpc_pollset_set **)gpr_realloc(
|
1247
|
+
bag->pollset_sets,
|
1248
|
+
bag->pollset_set_capacity * sizeof(*bag->pollset_sets));
|
1229
1249
|
}
|
1230
1250
|
bag->pollset_sets[bag->pollset_set_count++] = item;
|
1231
1251
|
for (i = 0, j = 0; i < bag->fd_count; i++) {
|
@@ -1262,7 +1282,7 @@ static void pollset_set_add_fd(grpc_exec_ctx *exec_ctx,
|
|
1262
1282
|
gpr_mu_lock(&pollset_set->mu);
|
1263
1283
|
if (pollset_set->fd_count == pollset_set->fd_capacity) {
|
1264
1284
|
pollset_set->fd_capacity = GPR_MAX(8, 2 * pollset_set->fd_capacity);
|
1265
|
-
pollset_set->fds = gpr_realloc(
|
1285
|
+
pollset_set->fds = (grpc_fd **)gpr_realloc(
|
1266
1286
|
pollset_set->fds, pollset_set->fd_capacity * sizeof(*pollset_set->fds));
|
1267
1287
|
}
|
1268
1288
|
GRPC_FD_REF(fd, "pollset_set");
|
@@ -1316,11 +1336,12 @@ static void cache_insert_locked(poll_args *args) {
|
|
1316
1336
|
}
|
1317
1337
|
|
1318
1338
|
static void init_result(poll_args *pargs) {
|
1319
|
-
pargs->result = gpr_malloc(sizeof(poll_result));
|
1339
|
+
pargs->result = (poll_result *)gpr_malloc(sizeof(poll_result));
|
1320
1340
|
gpr_ref_init(&pargs->result->refcount, 1);
|
1321
1341
|
pargs->result->watchers = NULL;
|
1322
1342
|
pargs->result->watchcount = 0;
|
1323
|
-
pargs->result->fds =
|
1343
|
+
pargs->result->fds =
|
1344
|
+
(struct pollfd *)gpr_malloc(sizeof(struct pollfd) * pargs->nfds);
|
1324
1345
|
memcpy(pargs->result->fds, pargs->fds, sizeof(struct pollfd) * pargs->nfds);
|
1325
1346
|
pargs->result->nfds = pargs->nfds;
|
1326
1347
|
pargs->result->retval = 0;
|
@@ -1359,7 +1380,7 @@ static poll_args *get_poller_locked(struct pollfd *fds, nfds_t count) {
|
|
1359
1380
|
return pargs;
|
1360
1381
|
}
|
1361
1382
|
|
1362
|
-
poll_args *pargs = gpr_malloc(sizeof(struct poll_args));
|
1383
|
+
poll_args *pargs = (poll_args *)gpr_malloc(sizeof(struct poll_args));
|
1363
1384
|
gpr_cv_init(&pargs->trigger);
|
1364
1385
|
pargs->fds = fds;
|
1365
1386
|
pargs->nfds = count;
|
@@ -1406,7 +1427,8 @@ static void cache_poller_locked(poll_args *args) {
|
|
1406
1427
|
poll_args **old_active_pollers = poll_cache.active_pollers;
|
1407
1428
|
poll_cache.size = poll_cache.size * 2;
|
1408
1429
|
poll_cache.count = 0;
|
1409
|
-
poll_cache.active_pollers =
|
1430
|
+
poll_cache.active_pollers =
|
1431
|
+
(poll_args **)gpr_malloc(sizeof(void *) * poll_cache.size);
|
1410
1432
|
for (unsigned int i = 0; i < poll_cache.size; i++) {
|
1411
1433
|
poll_cache.active_pollers[i] = NULL;
|
1412
1434
|
}
|
@@ -1511,17 +1533,17 @@ static int cvfd_poll(struct pollfd *fds, nfds_t nfds, int timeout) {
|
|
1511
1533
|
nfds_t nsockfds = 0;
|
1512
1534
|
poll_result *result = NULL;
|
1513
1535
|
gpr_mu_lock(&g_cvfds.mu);
|
1514
|
-
pollcv = gpr_malloc(sizeof(cv_node));
|
1536
|
+
pollcv = (cv_node *)gpr_malloc(sizeof(cv_node));
|
1515
1537
|
pollcv->next = NULL;
|
1516
1538
|
gpr_cv pollcv_cv;
|
1517
1539
|
gpr_cv_init(&pollcv_cv);
|
1518
1540
|
pollcv->cv = &pollcv_cv;
|
1519
|
-
cv_node *fd_cvs = gpr_malloc(nfds * sizeof(cv_node));
|
1541
|
+
cv_node *fd_cvs = (cv_node *)gpr_malloc(nfds * sizeof(cv_node));
|
1520
1542
|
|
1521
1543
|
for (i = 0; i < nfds; i++) {
|
1522
1544
|
fds[i].revents = 0;
|
1523
1545
|
if (fds[i].fd < 0 && (fds[i].events & POLLIN)) {
|
1524
|
-
idx =
|
1546
|
+
idx = GRPC_FD_TO_IDX(fds[i].fd);
|
1525
1547
|
fd_cvs[i].cv = &pollcv_cv;
|
1526
1548
|
fd_cvs[i].prev = NULL;
|
1527
1549
|
fd_cvs[i].next = g_cvfds.cvfds[idx].cvs;
|
@@ -1548,7 +1570,8 @@ static int cvfd_poll(struct pollfd *fds, nfds_t nfds, int timeout) {
|
|
1548
1570
|
|
1549
1571
|
res = 0;
|
1550
1572
|
if (!skip_poll && nsockfds > 0) {
|
1551
|
-
struct pollfd *pollfds =
|
1573
|
+
struct pollfd *pollfds =
|
1574
|
+
(struct pollfd *)gpr_malloc(sizeof(struct pollfd) * nsockfds);
|
1552
1575
|
idx = 0;
|
1553
1576
|
for (i = 0; i < nfds; i++) {
|
1554
1577
|
if (fds[i].fd >= 0) {
|
@@ -1583,8 +1606,8 @@ static int cvfd_poll(struct pollfd *fds, nfds_t nfds, int timeout) {
|
|
1583
1606
|
idx = 0;
|
1584
1607
|
for (i = 0; i < nfds; i++) {
|
1585
1608
|
if (fds[i].fd < 0 && (fds[i].events & POLLIN)) {
|
1586
|
-
remove_cvn(&g_cvfds.cvfds[
|
1587
|
-
if (g_cvfds.cvfds[
|
1609
|
+
remove_cvn(&g_cvfds.cvfds[GRPC_FD_TO_IDX(fds[i].fd)].cvs, &(fd_cvs[i]));
|
1610
|
+
if (g_cvfds.cvfds[GRPC_FD_TO_IDX(fds[i].fd)].is_set) {
|
1588
1611
|
fds[i].revents = POLLIN;
|
1589
1612
|
if (res >= 0) res++;
|
1590
1613
|
}
|
@@ -1611,7 +1634,8 @@ static void global_cv_fd_table_init() {
|
|
1611
1634
|
gpr_cv_init(&g_cvfds.shutdown_cv);
|
1612
1635
|
gpr_ref_init(&g_cvfds.pollcount, 1);
|
1613
1636
|
g_cvfds.size = CV_DEFAULT_TABLE_SIZE;
|
1614
|
-
g_cvfds.cvfds =
|
1637
|
+
g_cvfds.cvfds =
|
1638
|
+
(fd_node *)gpr_malloc(sizeof(fd_node) * CV_DEFAULT_TABLE_SIZE);
|
1615
1639
|
g_cvfds.free_fds = NULL;
|
1616
1640
|
thread_grace = gpr_time_from_millis(POLLCV_THREAD_GRACE_MS, GPR_TIMESPAN);
|
1617
1641
|
for (int i = 0; i < CV_DEFAULT_TABLE_SIZE; i++) {
|
@@ -1628,7 +1652,7 @@ static void global_cv_fd_table_init() {
|
|
1628
1652
|
poll_cache.size = 32;
|
1629
1653
|
poll_cache.count = 0;
|
1630
1654
|
poll_cache.free_pollers = NULL;
|
1631
|
-
poll_cache.active_pollers = gpr_malloc(sizeof(void *) * 32);
|
1655
|
+
poll_cache.active_pollers = (poll_args **)gpr_malloc(sizeof(void *) * 32);
|
1632
1656
|
for (unsigned int i = 0; i < poll_cache.size; i++) {
|
1633
1657
|
poll_cache.active_pollers[i] = NULL;
|
1634
1658
|
}
|
@@ -1668,34 +1692,34 @@ static void shutdown_engine(void) {
|
|
1668
1692
|
}
|
1669
1693
|
|
1670
1694
|
static const grpc_event_engine_vtable vtable = {
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1695
|
+
sizeof(grpc_pollset),
|
1696
|
+
|
1697
|
+
fd_create,
|
1698
|
+
fd_wrapped_fd,
|
1699
|
+
fd_orphan,
|
1700
|
+
fd_shutdown,
|
1701
|
+
fd_notify_on_read,
|
1702
|
+
fd_notify_on_write,
|
1703
|
+
fd_is_shutdown,
|
1704
|
+
fd_get_read_notifier_pollset,
|
1705
|
+
|
1706
|
+
pollset_init,
|
1707
|
+
pollset_shutdown,
|
1708
|
+
pollset_destroy,
|
1709
|
+
pollset_work,
|
1710
|
+
pollset_kick,
|
1711
|
+
pollset_add_fd,
|
1712
|
+
|
1713
|
+
pollset_set_create,
|
1714
|
+
pollset_set_destroy,
|
1715
|
+
pollset_set_add_pollset,
|
1716
|
+
pollset_set_del_pollset,
|
1717
|
+
pollset_set_add_pollset_set,
|
1718
|
+
pollset_set_del_pollset_set,
|
1719
|
+
pollset_set_add_fd,
|
1720
|
+
pollset_set_del_fd,
|
1721
|
+
|
1722
|
+
shutdown_engine,
|
1699
1723
|
};
|
1700
1724
|
|
1701
1725
|
const grpc_event_engine_vtable *grpc_init_poll_posix(bool explicit_request) {
|