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
@@ -37,6 +37,7 @@
|
|
37
37
|
#include <grpc/support/tls.h>
|
38
38
|
#include <grpc/support/useful.h>
|
39
39
|
|
40
|
+
#include "src/core/lib/debug/stats.h"
|
40
41
|
#include "src/core/lib/iomgr/ev_posix.h"
|
41
42
|
#include "src/core/lib/iomgr/iomgr_internal.h"
|
42
43
|
#include "src/core/lib/iomgr/is_epollexclusive_available.h"
|
@@ -49,7 +50,7 @@
|
|
49
50
|
#include "src/core/lib/support/spinlock.h"
|
50
51
|
|
51
52
|
/*******************************************************************************
|
52
|
-
*
|
53
|
+
* Polling object
|
53
54
|
*/
|
54
55
|
|
55
56
|
typedef enum {
|
@@ -141,7 +142,7 @@ static grpc_error *pollable_materialize(pollable *p);
|
|
141
142
|
*/
|
142
143
|
|
143
144
|
struct grpc_fd {
|
144
|
-
pollable
|
145
|
+
pollable pollable_obj;
|
145
146
|
int fd;
|
146
147
|
/* refst format:
|
147
148
|
bit 0 : 1=Active / 0=Orphaned
|
@@ -192,15 +193,15 @@ struct grpc_pollset_worker {
|
|
192
193
|
pollset_worker_link links[POLLSET_WORKER_LINK_COUNT];
|
193
194
|
gpr_cv cv;
|
194
195
|
grpc_pollset *pollset;
|
195
|
-
pollable *
|
196
|
+
pollable *pollable_obj;
|
196
197
|
};
|
197
198
|
|
198
199
|
#define MAX_EPOLL_EVENTS 100
|
199
200
|
#define MAX_EPOLL_EVENTS_HANDLED_EACH_POLL_CALL 5
|
200
201
|
|
201
202
|
struct grpc_pollset {
|
202
|
-
pollable
|
203
|
-
pollable *
|
203
|
+
pollable pollable_obj;
|
204
|
+
pollable *current_pollable_obj;
|
204
205
|
int kick_alls_pending;
|
205
206
|
bool kicked_without_poller;
|
206
207
|
grpc_closure *shutdown_closure;
|
@@ -278,10 +279,10 @@ static void ref_by(grpc_fd *fd, int n) {
|
|
278
279
|
}
|
279
280
|
|
280
281
|
static void fd_destroy(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
|
281
|
-
grpc_fd *fd = arg;
|
282
|
+
grpc_fd *fd = (grpc_fd *)arg;
|
282
283
|
/* Add the fd to the freelist */
|
283
284
|
grpc_iomgr_unregister_object(&fd->iomgr_object);
|
284
|
-
pollable_destroy(&fd->
|
285
|
+
pollable_destroy(&fd->pollable_obj);
|
285
286
|
gpr_mu_destroy(&fd->orphaned_mu);
|
286
287
|
gpr_mu_lock(&fd_freelist_mu);
|
287
288
|
fd->freelist_next = fd_freelist;
|
@@ -339,10 +340,10 @@ static grpc_fd *fd_create(int fd, const char *name) {
|
|
339
340
|
gpr_mu_unlock(&fd_freelist_mu);
|
340
341
|
|
341
342
|
if (new_fd == NULL) {
|
342
|
-
new_fd = gpr_malloc(sizeof(grpc_fd));
|
343
|
+
new_fd = (grpc_fd *)gpr_malloc(sizeof(grpc_fd));
|
343
344
|
}
|
344
345
|
|
345
|
-
pollable_init(&new_fd->
|
346
|
+
pollable_init(&new_fd->pollable_obj, PO_FD);
|
346
347
|
|
347
348
|
gpr_atm_rel_store(&new_fd->refst, (gpr_atm)1);
|
348
349
|
new_fd->fd = fd;
|
@@ -384,7 +385,7 @@ static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
|
384
385
|
bool is_fd_closed = already_closed;
|
385
386
|
grpc_error *error = GRPC_ERROR_NONE;
|
386
387
|
|
387
|
-
gpr_mu_lock(&fd->
|
388
|
+
gpr_mu_lock(&fd->pollable_obj.po.mu);
|
388
389
|
gpr_mu_lock(&fd->orphaned_mu);
|
389
390
|
fd->on_done_closure = on_done;
|
390
391
|
|
@@ -410,7 +411,7 @@ static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
|
410
411
|
GRPC_CLOSURE_SCHED(exec_ctx, fd->on_done_closure, GRPC_ERROR_REF(error));
|
411
412
|
|
412
413
|
gpr_mu_unlock(&fd->orphaned_mu);
|
413
|
-
gpr_mu_unlock(&fd->
|
414
|
+
gpr_mu_unlock(&fd->pollable_obj.po.mu);
|
414
415
|
UNREF_BY(exec_ctx, fd, 2, reason); /* Drop the reference */
|
415
416
|
GRPC_LOG_IF_ERROR("fd_orphan", GRPC_ERROR_REF(error));
|
416
417
|
GRPC_ERROR_UNREF(error);
|
@@ -476,8 +477,9 @@ static grpc_error *pollable_materialize(pollable *p) {
|
|
476
477
|
close(new_epfd);
|
477
478
|
return err;
|
478
479
|
}
|
479
|
-
struct epoll_event ev
|
480
|
-
|
480
|
+
struct epoll_event ev;
|
481
|
+
ev.events = (uint32_t)(EPOLLIN | EPOLLET);
|
482
|
+
ev.data.ptr = (void *)(1 | (intptr_t)&p->wakeup);
|
481
483
|
if (epoll_ctl(new_epfd, EPOLL_CTL_ADD, p->wakeup.read_fd, &ev) != 0) {
|
482
484
|
err = GRPC_OS_ERROR(errno, "epoll_ctl");
|
483
485
|
close(new_epfd);
|
@@ -506,9 +508,9 @@ static grpc_error *pollable_add_fd(pollable *p, grpc_fd *fd) {
|
|
506
508
|
gpr_mu_unlock(&fd->orphaned_mu);
|
507
509
|
return GRPC_ERROR_NONE;
|
508
510
|
}
|
509
|
-
struct epoll_event ev_fd
|
510
|
-
|
511
|
-
|
511
|
+
struct epoll_event ev_fd;
|
512
|
+
ev_fd.events = (uint32_t)(EPOLLET | EPOLLIN | EPOLLOUT | EPOLLEXCLUSIVE);
|
513
|
+
ev_fd.data.ptr = fd;
|
512
514
|
if (epoll_ctl(epfd, EPOLL_CTL_ADD, fd->fd, &ev_fd) != 0) {
|
513
515
|
switch (errno) {
|
514
516
|
case EEXIST:
|
@@ -555,31 +557,35 @@ static void pollset_maybe_finish_shutdown(grpc_exec_ctx *exec_ctx,
|
|
555
557
|
static void do_kick_all(grpc_exec_ctx *exec_ctx, void *arg,
|
556
558
|
grpc_error *error_unused) {
|
557
559
|
grpc_error *error = GRPC_ERROR_NONE;
|
558
|
-
grpc_pollset *pollset = arg;
|
559
|
-
gpr_mu_lock(&pollset->
|
560
|
+
grpc_pollset *pollset = (grpc_pollset *)arg;
|
561
|
+
gpr_mu_lock(&pollset->pollable_obj.po.mu);
|
560
562
|
if (pollset->root_worker != NULL) {
|
561
563
|
grpc_pollset_worker *worker = pollset->root_worker;
|
562
564
|
do {
|
563
|
-
|
564
|
-
|
565
|
+
GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
|
566
|
+
if (worker->pollable_obj != &pollset->pollable_obj) {
|
567
|
+
gpr_mu_lock(&worker->pollable_obj->po.mu);
|
565
568
|
}
|
566
569
|
if (worker->initialized_cv && worker != pollset->root_worker) {
|
567
570
|
if (GRPC_TRACER_ON(grpc_polling_trace)) {
|
568
571
|
gpr_log(GPR_DEBUG, "PS:%p kickall_via_cv %p (pollable %p vs %p)",
|
569
|
-
pollset, worker, &pollset->
|
572
|
+
pollset, worker, &pollset->pollable_obj,
|
573
|
+
worker->pollable_obj);
|
570
574
|
}
|
571
575
|
worker->kicked = true;
|
572
576
|
gpr_cv_signal(&worker->cv);
|
573
577
|
} else {
|
574
578
|
if (GRPC_TRACER_ON(grpc_polling_trace)) {
|
575
579
|
gpr_log(GPR_DEBUG, "PS:%p kickall_via_wakeup %p (pollable %p vs %p)",
|
576
|
-
pollset, worker, &pollset->
|
580
|
+
pollset, worker, &pollset->pollable_obj,
|
581
|
+
worker->pollable_obj);
|
577
582
|
}
|
578
|
-
append_error(&error,
|
583
|
+
append_error(&error,
|
584
|
+
grpc_wakeup_fd_wakeup(&worker->pollable_obj->wakeup),
|
579
585
|
"pollset_shutdown");
|
580
586
|
}
|
581
|
-
if (worker->
|
582
|
-
gpr_mu_unlock(&worker->
|
587
|
+
if (worker->pollable_obj != &pollset->pollable_obj) {
|
588
|
+
gpr_mu_unlock(&worker->pollable_obj->po.mu);
|
583
589
|
}
|
584
590
|
|
585
591
|
worker = worker->links[PWL_POLLSET].next;
|
@@ -587,7 +593,7 @@ static void do_kick_all(grpc_exec_ctx *exec_ctx, void *arg,
|
|
587
593
|
}
|
588
594
|
pollset->kick_alls_pending--;
|
589
595
|
pollset_maybe_finish_shutdown(exec_ctx, pollset);
|
590
|
-
gpr_mu_unlock(&pollset->
|
596
|
+
gpr_mu_unlock(&pollset->pollable_obj.po.mu);
|
591
597
|
GRPC_LOG_IF_ERROR("kick_all", error);
|
592
598
|
}
|
593
599
|
|
@@ -661,26 +667,27 @@ static grpc_error *pollset_kick_inner(grpc_pollset *pollset, pollable *p,
|
|
661
667
|
}
|
662
668
|
|
663
669
|
/* p->po.mu must be held before calling this function */
|
664
|
-
static grpc_error *pollset_kick(grpc_pollset *pollset,
|
670
|
+
static grpc_error *pollset_kick(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
665
671
|
grpc_pollset_worker *specific_worker) {
|
666
|
-
pollable *p = pollset->
|
667
|
-
|
672
|
+
pollable *p = pollset->current_pollable_obj;
|
673
|
+
GRPC_STATS_INC_POLLSET_KICK(exec_ctx);
|
674
|
+
if (p != &pollset->pollable_obj) {
|
668
675
|
gpr_mu_lock(&p->po.mu);
|
669
676
|
}
|
670
677
|
grpc_error *error = pollset_kick_inner(pollset, p, specific_worker);
|
671
|
-
if (p != &pollset->
|
678
|
+
if (p != &pollset->pollable_obj) {
|
672
679
|
gpr_mu_unlock(&p->po.mu);
|
673
680
|
}
|
674
681
|
return error;
|
675
682
|
}
|
676
683
|
|
677
684
|
static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
|
678
|
-
pollable_init(&pollset->
|
679
|
-
pollset->
|
685
|
+
pollable_init(&pollset->pollable_obj, PO_POLLSET);
|
686
|
+
pollset->current_pollable_obj = &g_empty_pollable;
|
680
687
|
pollset->kicked_without_poller = false;
|
681
688
|
pollset->shutdown_closure = NULL;
|
682
689
|
pollset->root_worker = NULL;
|
683
|
-
*mu = &pollset->
|
690
|
+
*mu = &pollset->pollable_obj.po.mu;
|
684
691
|
}
|
685
692
|
|
686
693
|
/* Convert a timespec to milliseconds:
|
@@ -702,7 +709,10 @@ static int poll_deadline_to_millis_timeout(gpr_timespec deadline,
|
|
702
709
|
}
|
703
710
|
|
704
711
|
static const gpr_timespec round_up = {
|
705
|
-
|
712
|
+
0, /* tv_sec */
|
713
|
+
GPR_NS_PER_MS - 1, /* tv_nsec */
|
714
|
+
GPR_TIMESPAN /* clock_type */
|
715
|
+
};
|
706
716
|
timeout = gpr_time_sub(deadline, now);
|
707
717
|
int millis = gpr_time_to_millis(gpr_time_add(timeout, round_up));
|
708
718
|
return millis >= 1 ? millis : 1;
|
@@ -728,8 +738,8 @@ static void fd_become_writable(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
|
|
728
738
|
static grpc_error *fd_become_pollable_locked(grpc_fd *fd) {
|
729
739
|
grpc_error *error = GRPC_ERROR_NONE;
|
730
740
|
static const char *err_desc = "fd_become_pollable";
|
731
|
-
if (append_error(&error, pollable_materialize(&fd->
|
732
|
-
append_error(&error, pollable_add_fd(&fd->
|
741
|
+
if (append_error(&error, pollable_materialize(&fd->pollable_obj), err_desc)) {
|
742
|
+
append_error(&error, pollable_add_fd(&fd->pollable_obj, fd), err_desc);
|
733
743
|
}
|
734
744
|
return error;
|
735
745
|
}
|
@@ -744,7 +754,7 @@ static void pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
744
754
|
}
|
745
755
|
|
746
756
|
static bool pollset_is_pollable_fd(grpc_pollset *pollset, pollable *p) {
|
747
|
-
return p != &g_empty_pollable && p != &pollset->
|
757
|
+
return p != &g_empty_pollable && p != &pollset->pollable_obj;
|
748
758
|
}
|
749
759
|
|
750
760
|
static grpc_error *pollset_process_events(grpc_exec_ctx *exec_ctx,
|
@@ -761,8 +771,9 @@ static grpc_error *pollset_process_events(grpc_exec_ctx *exec_ctx,
|
|
761
771
|
if (GRPC_TRACER_ON(grpc_polling_trace)) {
|
762
772
|
gpr_log(GPR_DEBUG, "PS:%p got pollset_wakeup %p", pollset, data_ptr);
|
763
773
|
}
|
764
|
-
append_error(&error,
|
765
|
-
|
774
|
+
append_error(&error,
|
775
|
+
grpc_wakeup_fd_consume_wakeup(
|
776
|
+
(grpc_wakeup_fd *)((~(intptr_t)1) & (intptr_t)data_ptr)),
|
766
777
|
err_desc);
|
767
778
|
} else {
|
768
779
|
grpc_fd *fd = (grpc_fd *)data_ptr;
|
@@ -789,9 +800,9 @@ static grpc_error *pollset_process_events(grpc_exec_ctx *exec_ctx,
|
|
789
800
|
|
790
801
|
/* pollset_shutdown is guaranteed to be called before pollset_destroy. */
|
791
802
|
static void pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
|
792
|
-
pollable_destroy(&pollset->
|
793
|
-
if (pollset_is_pollable_fd(pollset, pollset->
|
794
|
-
UNREF_BY(exec_ctx, (grpc_fd *)pollset->
|
803
|
+
pollable_destroy(&pollset->pollable_obj);
|
804
|
+
if (pollset_is_pollable_fd(pollset, pollset->current_pollable_obj)) {
|
805
|
+
UNREF_BY(exec_ctx, (grpc_fd *)pollset->current_pollable_obj, 2,
|
795
806
|
"pollset_pollable");
|
796
807
|
}
|
797
808
|
GRPC_LOG_IF_ERROR("pollset_process_events",
|
@@ -814,6 +825,7 @@ static grpc_error *pollset_epoll(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
814
825
|
}
|
815
826
|
int r;
|
816
827
|
do {
|
828
|
+
GRPC_STATS_INC_SYSCALL_POLL(exec_ctx);
|
817
829
|
r = epoll_wait(p->epfd, pollset->events, MAX_EPOLL_EVENTS, timeout);
|
818
830
|
} while (r < 0 && errno == EINTR);
|
819
831
|
if (timeout != 0) {
|
@@ -880,68 +892,69 @@ static bool begin_worker(grpc_pollset *pollset, grpc_pollset_worker *worker,
|
|
880
892
|
worker->initialized_cv = false;
|
881
893
|
worker->kicked = false;
|
882
894
|
worker->pollset = pollset;
|
883
|
-
worker->
|
895
|
+
worker->pollable_obj = pollset->current_pollable_obj;
|
884
896
|
|
885
|
-
if (pollset_is_pollable_fd(pollset, worker->
|
886
|
-
REF_BY((grpc_fd *)worker->
|
897
|
+
if (pollset_is_pollable_fd(pollset, worker->pollable_obj)) {
|
898
|
+
REF_BY((grpc_fd *)worker->pollable_obj, 2, "one_poll");
|
887
899
|
}
|
888
900
|
|
889
901
|
worker_insert(&pollset->root_worker, PWL_POLLSET, worker);
|
890
|
-
if (!worker_insert(&worker->
|
902
|
+
if (!worker_insert(&worker->pollable_obj->root_worker, PWL_POLLABLE,
|
903
|
+
worker)) {
|
891
904
|
worker->initialized_cv = true;
|
892
905
|
gpr_cv_init(&worker->cv);
|
893
|
-
if (worker->
|
894
|
-
gpr_mu_unlock(&pollset->
|
906
|
+
if (worker->pollable_obj != &pollset->pollable_obj) {
|
907
|
+
gpr_mu_unlock(&pollset->pollable_obj.po.mu);
|
895
908
|
}
|
896
909
|
if (GRPC_TRACER_ON(grpc_polling_trace) &&
|
897
|
-
worker->
|
910
|
+
worker->pollable_obj->root_worker != worker) {
|
898
911
|
gpr_log(GPR_DEBUG, "PS:%p wait %p w=%p for %dms", pollset,
|
899
|
-
worker->
|
912
|
+
worker->pollable_obj, worker,
|
900
913
|
poll_deadline_to_millis_timeout(deadline, *now));
|
901
914
|
}
|
902
|
-
while (do_poll && worker->
|
903
|
-
if (gpr_cv_wait(&worker->cv, &worker->
|
915
|
+
while (do_poll && worker->pollable_obj->root_worker != worker) {
|
916
|
+
if (gpr_cv_wait(&worker->cv, &worker->pollable_obj->po.mu, deadline)) {
|
904
917
|
if (GRPC_TRACER_ON(grpc_polling_trace)) {
|
905
918
|
gpr_log(GPR_DEBUG, "PS:%p timeout_wait %p w=%p", pollset,
|
906
|
-
worker->
|
919
|
+
worker->pollable_obj, worker);
|
907
920
|
}
|
908
921
|
do_poll = false;
|
909
922
|
} else if (worker->kicked) {
|
910
923
|
if (GRPC_TRACER_ON(grpc_polling_trace)) {
|
911
|
-
gpr_log(GPR_DEBUG, "PS:%p wakeup %p w=%p", pollset,
|
912
|
-
worker);
|
924
|
+
gpr_log(GPR_DEBUG, "PS:%p wakeup %p w=%p", pollset,
|
925
|
+
worker->pollable_obj, worker);
|
913
926
|
}
|
914
927
|
do_poll = false;
|
915
928
|
} else if (GRPC_TRACER_ON(grpc_polling_trace) &&
|
916
|
-
worker->
|
929
|
+
worker->pollable_obj->root_worker != worker) {
|
917
930
|
gpr_log(GPR_DEBUG, "PS:%p spurious_wakeup %p w=%p", pollset,
|
918
|
-
worker->
|
931
|
+
worker->pollable_obj, worker);
|
919
932
|
}
|
920
933
|
}
|
921
|
-
if (worker->
|
922
|
-
gpr_mu_unlock(&worker->
|
923
|
-
gpr_mu_lock(&pollset->
|
924
|
-
gpr_mu_lock(&worker->
|
934
|
+
if (worker->pollable_obj != &pollset->pollable_obj) {
|
935
|
+
gpr_mu_unlock(&worker->pollable_obj->po.mu);
|
936
|
+
gpr_mu_lock(&pollset->pollable_obj.po.mu);
|
937
|
+
gpr_mu_lock(&worker->pollable_obj->po.mu);
|
925
938
|
}
|
926
939
|
*now = gpr_now(now->clock_type);
|
927
940
|
}
|
928
941
|
|
929
942
|
return do_poll && pollset->shutdown_closure == NULL &&
|
930
|
-
pollset->
|
943
|
+
pollset->current_pollable_obj == worker->pollable_obj;
|
931
944
|
}
|
932
945
|
|
933
946
|
static void end_worker(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
934
947
|
grpc_pollset_worker *worker,
|
935
948
|
grpc_pollset_worker **worker_hdl) {
|
936
949
|
if (NEW_ROOT ==
|
937
|
-
worker_remove(&worker->
|
938
|
-
gpr_cv_signal(&worker->
|
950
|
+
worker_remove(&worker->pollable_obj->root_worker, PWL_POLLABLE, worker)) {
|
951
|
+
gpr_cv_signal(&worker->pollable_obj->root_worker->cv);
|
939
952
|
}
|
940
953
|
if (worker->initialized_cv) {
|
941
954
|
gpr_cv_destroy(&worker->cv);
|
942
955
|
}
|
943
|
-
if (pollset_is_pollable_fd(pollset, worker->
|
944
|
-
UNREF_BY(exec_ctx, (grpc_fd *)worker->
|
956
|
+
if (pollset_is_pollable_fd(pollset, worker->pollable_obj)) {
|
957
|
+
UNREF_BY(exec_ctx, (grpc_fd *)worker->pollable_obj, 2, "one_poll");
|
945
958
|
}
|
946
959
|
if (EMPTIED == worker_remove(&pollset->root_worker, PWL_POLLSET, worker)) {
|
947
960
|
pollset_maybe_finish_shutdown(exec_ctx, pollset);
|
@@ -969,48 +982,48 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
969
982
|
pollset->kicked_without_poller = false;
|
970
983
|
return GRPC_ERROR_NONE;
|
971
984
|
}
|
972
|
-
if (pollset->
|
973
|
-
gpr_mu_lock(&pollset->
|
985
|
+
if (pollset->current_pollable_obj != &pollset->pollable_obj) {
|
986
|
+
gpr_mu_lock(&pollset->current_pollable_obj->po.mu);
|
974
987
|
}
|
975
988
|
if (begin_worker(pollset, &worker, worker_hdl, &now, deadline)) {
|
976
989
|
gpr_tls_set(&g_current_thread_pollset, (intptr_t)pollset);
|
977
990
|
gpr_tls_set(&g_current_thread_worker, (intptr_t)&worker);
|
978
991
|
GPR_ASSERT(!pollset->shutdown_closure);
|
979
|
-
append_error(&error, pollable_materialize(worker.
|
980
|
-
if (worker.
|
981
|
-
gpr_mu_unlock(&worker.
|
992
|
+
append_error(&error, pollable_materialize(worker.pollable_obj), err_desc);
|
993
|
+
if (worker.pollable_obj != &pollset->pollable_obj) {
|
994
|
+
gpr_mu_unlock(&worker.pollable_obj->po.mu);
|
982
995
|
}
|
983
|
-
gpr_mu_unlock(&pollset->
|
996
|
+
gpr_mu_unlock(&pollset->pollable_obj.po.mu);
|
984
997
|
if (pollset->event_cursor == pollset->event_count) {
|
985
|
-
append_error(&error, pollset_epoll(exec_ctx, pollset, worker.
|
998
|
+
append_error(&error, pollset_epoll(exec_ctx, pollset, worker.pollable_obj,
|
986
999
|
now, deadline),
|
987
1000
|
err_desc);
|
988
1001
|
}
|
989
1002
|
append_error(&error, pollset_process_events(exec_ctx, pollset, false),
|
990
1003
|
err_desc);
|
991
|
-
gpr_mu_lock(&pollset->
|
992
|
-
if (worker.
|
993
|
-
gpr_mu_lock(&worker.
|
1004
|
+
gpr_mu_lock(&pollset->pollable_obj.po.mu);
|
1005
|
+
if (worker.pollable_obj != &pollset->pollable_obj) {
|
1006
|
+
gpr_mu_lock(&worker.pollable_obj->po.mu);
|
994
1007
|
}
|
995
1008
|
gpr_tls_set(&g_current_thread_pollset, 0);
|
996
1009
|
gpr_tls_set(&g_current_thread_worker, 0);
|
997
1010
|
pollset_maybe_finish_shutdown(exec_ctx, pollset);
|
998
1011
|
}
|
999
1012
|
end_worker(exec_ctx, pollset, &worker, worker_hdl);
|
1000
|
-
if (worker.
|
1001
|
-
gpr_mu_unlock(&worker.
|
1013
|
+
if (worker.pollable_obj != &pollset->pollable_obj) {
|
1014
|
+
gpr_mu_unlock(&worker.pollable_obj->po.mu);
|
1002
1015
|
}
|
1003
1016
|
if (grpc_exec_ctx_has_work(exec_ctx)) {
|
1004
|
-
gpr_mu_unlock(&pollset->
|
1017
|
+
gpr_mu_unlock(&pollset->pollable_obj.po.mu);
|
1005
1018
|
grpc_exec_ctx_flush(exec_ctx);
|
1006
|
-
gpr_mu_lock(&pollset->
|
1019
|
+
gpr_mu_lock(&pollset->pollable_obj.po.mu);
|
1007
1020
|
}
|
1008
1021
|
return error;
|
1009
1022
|
}
|
1010
1023
|
|
1011
1024
|
static void unref_fd_no_longer_poller(grpc_exec_ctx *exec_ctx, void *arg,
|
1012
1025
|
grpc_error *error) {
|
1013
|
-
grpc_fd *fd = arg;
|
1026
|
+
grpc_fd *fd = (grpc_fd *)arg;
|
1014
1027
|
UNREF_BY(exec_ctx, fd, 2, "pollset_pollable");
|
1015
1028
|
}
|
1016
1029
|
|
@@ -1020,7 +1033,7 @@ static grpc_error *pollset_add_fd_locked(grpc_exec_ctx *exec_ctx,
|
|
1020
1033
|
bool fd_locked) {
|
1021
1034
|
static const char *err_desc = "pollset_add_fd";
|
1022
1035
|
grpc_error *error = GRPC_ERROR_NONE;
|
1023
|
-
if (pollset->
|
1036
|
+
if (pollset->current_pollable_obj == &g_empty_pollable) {
|
1024
1037
|
if (GRPC_TRACER_ON(grpc_polling_trace)) {
|
1025
1038
|
gpr_log(GPR_DEBUG,
|
1026
1039
|
"PS:%p add fd %p; transition pollable from empty to fd", pollset,
|
@@ -1028,19 +1041,19 @@ static grpc_error *pollset_add_fd_locked(grpc_exec_ctx *exec_ctx,
|
|
1028
1041
|
}
|
1029
1042
|
/* empty pollable --> single fd pollable */
|
1030
1043
|
pollset_kick_all(exec_ctx, pollset);
|
1031
|
-
pollset->
|
1032
|
-
if (!fd_locked) gpr_mu_lock(&fd->
|
1044
|
+
pollset->current_pollable_obj = &fd->pollable_obj;
|
1045
|
+
if (!fd_locked) gpr_mu_lock(&fd->pollable_obj.po.mu);
|
1033
1046
|
append_error(&error, fd_become_pollable_locked(fd), err_desc);
|
1034
|
-
if (!fd_locked) gpr_mu_unlock(&fd->
|
1047
|
+
if (!fd_locked) gpr_mu_unlock(&fd->pollable_obj.po.mu);
|
1035
1048
|
REF_BY(fd, 2, "pollset_pollable");
|
1036
|
-
} else if (pollset->
|
1049
|
+
} else if (pollset->current_pollable_obj == &pollset->pollable_obj) {
|
1037
1050
|
if (GRPC_TRACER_ON(grpc_polling_trace)) {
|
1038
1051
|
gpr_log(GPR_DEBUG, "PS:%p add fd %p; already multipolling", pollset, fd);
|
1039
1052
|
}
|
1040
|
-
append_error(&error, pollable_add_fd(pollset->
|
1053
|
+
append_error(&error, pollable_add_fd(pollset->current_pollable_obj, fd),
|
1041
1054
|
err_desc);
|
1042
|
-
} else if (pollset->
|
1043
|
-
grpc_fd *had_fd = (grpc_fd *)pollset->
|
1055
|
+
} else if (pollset->current_pollable_obj != &fd->pollable_obj) {
|
1056
|
+
grpc_fd *had_fd = (grpc_fd *)pollset->current_pollable_obj;
|
1044
1057
|
if (GRPC_TRACER_ON(grpc_polling_trace)) {
|
1045
1058
|
gpr_log(GPR_DEBUG,
|
1046
1059
|
"PS:%p add fd %p; transition pollable from fd %p to multipoller",
|
@@ -1052,11 +1065,11 @@ static grpc_error *pollset_add_fd_locked(grpc_exec_ctx *exec_ctx,
|
|
1052
1065
|
grpc_lfev_set_ready(exec_ctx, &had_fd->read_closure, "read");
|
1053
1066
|
grpc_lfev_set_ready(exec_ctx, &had_fd->write_closure, "write");
|
1054
1067
|
pollset_kick_all(exec_ctx, pollset);
|
1055
|
-
pollset->
|
1056
|
-
if (append_error(&error, pollable_materialize(&pollset->
|
1068
|
+
pollset->current_pollable_obj = &pollset->pollable_obj;
|
1069
|
+
if (append_error(&error, pollable_materialize(&pollset->pollable_obj),
|
1057
1070
|
err_desc)) {
|
1058
|
-
pollable_add_fd(&pollset->
|
1059
|
-
pollable_add_fd(&pollset->
|
1071
|
+
pollable_add_fd(&pollset->pollable_obj, had_fd);
|
1072
|
+
pollable_add_fd(&pollset->pollable_obj, fd);
|
1060
1073
|
}
|
1061
1074
|
GRPC_CLOSURE_SCHED(exec_ctx,
|
1062
1075
|
GRPC_CLOSURE_CREATE(unref_fd_no_longer_poller, had_fd,
|
@@ -1068,9 +1081,9 @@ static grpc_error *pollset_add_fd_locked(grpc_exec_ctx *exec_ctx,
|
|
1068
1081
|
|
1069
1082
|
static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
1070
1083
|
grpc_fd *fd) {
|
1071
|
-
gpr_mu_lock(&pollset->
|
1084
|
+
gpr_mu_lock(&pollset->pollable_obj.po.mu);
|
1072
1085
|
grpc_error *error = pollset_add_fd_locked(exec_ctx, pollset, fd, false);
|
1073
|
-
gpr_mu_unlock(&pollset->
|
1086
|
+
gpr_mu_unlock(&pollset->pollable_obj.po.mu);
|
1074
1087
|
GRPC_LOG_IF_ERROR("pollset_add_fd", error);
|
1075
1088
|
}
|
1076
1089
|
|
@@ -1079,7 +1092,7 @@ static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
1079
1092
|
*/
|
1080
1093
|
|
1081
1094
|
static grpc_pollset_set *pollset_set_create(void) {
|
1082
|
-
grpc_pollset_set *pss = gpr_zalloc(sizeof(*pss));
|
1095
|
+
grpc_pollset_set *pss = (grpc_pollset_set *)gpr_zalloc(sizeof(*pss));
|
1083
1096
|
po_init(&pss->po, PO_POLLSET_SET);
|
1084
1097
|
return pss;
|
1085
1098
|
}
|
@@ -1092,7 +1105,7 @@ static void pollset_set_destroy(grpc_exec_ctx *exec_ctx,
|
|
1092
1105
|
|
1093
1106
|
static void pollset_set_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset_set *pss,
|
1094
1107
|
grpc_fd *fd) {
|
1095
|
-
po_join(exec_ctx, &pss->po, &fd->
|
1108
|
+
po_join(exec_ctx, &pss->po, &fd->pollable_obj.po);
|
1096
1109
|
}
|
1097
1110
|
|
1098
1111
|
static void pollset_set_del_fd(grpc_exec_ctx *exec_ctx, grpc_pollset_set *pss,
|
@@ -1100,7 +1113,7 @@ static void pollset_set_del_fd(grpc_exec_ctx *exec_ctx, grpc_pollset_set *pss,
|
|
1100
1113
|
|
1101
1114
|
static void pollset_set_add_pollset(grpc_exec_ctx *exec_ctx,
|
1102
1115
|
grpc_pollset_set *pss, grpc_pollset *ps) {
|
1103
|
-
po_join(exec_ctx, &pss->po, &ps->
|
1116
|
+
po_join(exec_ctx, &pss->po, &ps->pollable_obj.po);
|
1104
1117
|
}
|
1105
1118
|
|
1106
1119
|
static void pollset_set_del_pollset(grpc_exec_ctx *exec_ctx,
|
@@ -1241,7 +1254,7 @@ static void pg_broadcast(grpc_exec_ctx *exec_ctx, polling_group *from,
|
|
1241
1254
|
static void pg_create(grpc_exec_ctx *exec_ctx, polling_obj **initial_po,
|
1242
1255
|
size_t initial_po_count) {
|
1243
1256
|
/* assumes all polling objects in initial_po are locked */
|
1244
|
-
polling_group *pg = gpr_malloc(sizeof(*pg));
|
1257
|
+
polling_group *pg = (polling_group *)gpr_malloc(sizeof(*pg));
|
1245
1258
|
po_init(&pg->po, PO_POLLING_GROUP);
|
1246
1259
|
gpr_ref_init(&pg->refs, (int)initial_po_count);
|
1247
1260
|
for (size_t i = 0; i < initial_po_count; i++) {
|
@@ -1351,7 +1364,7 @@ static void pg_merge(grpc_exec_ctx *exec_ctx, polling_group *a,
|
|
1351
1364
|
gpr_mu_lock(&po->mu);
|
1352
1365
|
if (unref_count == unref_cap) {
|
1353
1366
|
unref_cap = GPR_MAX(8, 3 * unref_cap / 2);
|
1354
|
-
unref = gpr_realloc(unref, unref_cap * sizeof(*unref));
|
1367
|
+
unref = (polling_group **)gpr_realloc(unref, unref_cap * sizeof(*unref));
|
1355
1368
|
}
|
1356
1369
|
unref[unref_count++] = po->group;
|
1357
1370
|
po->group = pg_ref(a);
|
@@ -1383,34 +1396,34 @@ static void shutdown_engine(void) {
|
|
1383
1396
|
}
|
1384
1397
|
|
1385
1398
|
static const grpc_event_engine_vtable vtable = {
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1399
|
+
sizeof(grpc_pollset),
|
1400
|
+
|
1401
|
+
fd_create,
|
1402
|
+
fd_wrapped_fd,
|
1403
|
+
fd_orphan,
|
1404
|
+
fd_shutdown,
|
1405
|
+
fd_notify_on_read,
|
1406
|
+
fd_notify_on_write,
|
1407
|
+
fd_is_shutdown,
|
1408
|
+
fd_get_read_notifier_pollset,
|
1409
|
+
|
1410
|
+
pollset_init,
|
1411
|
+
pollset_shutdown,
|
1412
|
+
pollset_destroy,
|
1413
|
+
pollset_work,
|
1414
|
+
pollset_kick,
|
1415
|
+
pollset_add_fd,
|
1416
|
+
|
1417
|
+
pollset_set_create,
|
1418
|
+
pollset_set_destroy,
|
1419
|
+
pollset_set_add_pollset,
|
1420
|
+
pollset_set_del_pollset,
|
1421
|
+
pollset_set_add_pollset_set,
|
1422
|
+
pollset_set_del_pollset_set,
|
1423
|
+
pollset_set_add_fd,
|
1424
|
+
pollset_set_del_fd,
|
1425
|
+
|
1426
|
+
shutdown_engine,
|
1414
1427
|
};
|
1415
1428
|
|
1416
1429
|
const grpc_event_engine_vtable *grpc_init_epollex_linux(
|