grpc 0.14.1 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +1398 -817
- data/include/grpc/compression.h +2 -1
- data/include/grpc/grpc.h +10 -1
- data/include/grpc/grpc_cronet.h +51 -0
- data/include/grpc/grpc_posix.h +70 -0
- data/include/grpc/impl/codegen/atm.h +2 -2
- data/include/grpc/impl/codegen/{atm_win32.h → atm_windows.h} +3 -3
- data/include/grpc/impl/codegen/compression_types.h +39 -5
- data/include/grpc/impl/codegen/connectivity_state.h +1 -1
- data/include/grpc/impl/codegen/grpc_types.h +10 -0
- data/include/grpc/impl/codegen/log.h +2 -1
- data/include/grpc/impl/codegen/port_platform.h +30 -12
- data/include/grpc/impl/codegen/slice_buffer.h +2 -3
- data/include/grpc/impl/codegen/sync.h +2 -2
- data/include/grpc/impl/codegen/{sync_win32.h → sync_windows.h} +3 -3
- data/include/grpc/support/{sync_win32.h → atm_windows.h} +4 -4
- data/include/grpc/support/avl.h +5 -0
- data/include/grpc/support/{log_win32.h → log_windows.h} +3 -3
- data/include/grpc/support/string_util.h +2 -1
- data/include/grpc/support/{atm_win32.h → sync_windows.h} +4 -4
- data/src/core/ext/census/gen/census.pb.c +179 -0
- data/src/core/ext/census/gen/census.pb.h +294 -0
- data/src/core/ext/census/grpc_filter.c +11 -7
- data/src/core/ext/client_config/channel_connectivity.c +28 -14
- data/src/core/ext/client_config/client_channel.c +77 -53
- data/src/core/ext/client_config/connector.h +1 -1
- data/src/core/ext/client_config/lb_policy.c +9 -6
- data/src/core/ext/client_config/lb_policy.h +9 -5
- data/src/core/ext/client_config/subchannel.c +58 -39
- data/src/core/ext/client_config/subchannel.h +3 -2
- data/src/core/ext/client_config/subchannel_call_holder.c +34 -19
- data/src/core/ext/client_config/subchannel_call_holder.h +2 -1
- data/src/core/ext/client_config/subchannel_index.c +20 -9
- data/src/core/ext/lb_policy/grpclb/load_balancer_api.c +7 -7
- data/src/core/ext/lb_policy/grpclb/load_balancer_api.h +5 -5
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/{v0 → v1}/load_balancer.pb.c +29 -30
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +178 -0
- data/src/core/ext/lb_policy/pick_first/pick_first.c +65 -45
- data/src/core/ext/lb_policy/round_robin/round_robin.c +84 -43
- data/src/core/ext/load_reporting/load_reporting.c +133 -0
- data/src/core/ext/load_reporting/load_reporting.h +75 -0
- data/src/core/ext/load_reporting/load_reporting_filter.c +151 -0
- data/src/core/ext/load_reporting/load_reporting_filter.h +41 -0
- data/src/core/ext/resolver/dns/native/dns_resolver.c +22 -8
- data/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +2 -2
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +4 -4
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +95 -0
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +14 -18
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +49 -24
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +82 -0
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +104 -60
- data/src/core/ext/transport/chttp2/transport/bin_decoder.c +232 -0
- data/src/{ruby/ext/grpc/rb_signal.c → core/ext/transport/chttp2/transport/bin_decoder.h} +27 -31
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +481 -260
- data/src/core/ext/transport/chttp2/transport/frame.h +1 -7
- data/src/core/ext/transport/chttp2/transport/frame_data.c +44 -27
- data/src/core/ext/transport/chttp2/transport/frame_data.h +6 -5
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +23 -17
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +12 -7
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -3
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +25 -12
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +23 -21
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +17 -9
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +365 -287
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +8 -6
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +24 -20
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +5 -4
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +1 -0
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +1 -0
- data/src/core/ext/transport/chttp2/transport/internal.h +34 -32
- data/src/core/ext/transport/chttp2/transport/parsing.c +296 -212
- data/src/core/ext/transport/chttp2/transport/writing.c +12 -9
- data/src/core/lib/channel/channel_args.c +26 -12
- data/src/core/lib/channel/channel_args.h +1 -1
- data/src/core/lib/channel/channel_stack.c +12 -8
- data/src/core/lib/channel/channel_stack.h +27 -11
- data/src/core/lib/channel/channel_stack_builder.c +2 -2
- data/src/core/lib/channel/compress_filter.c +26 -31
- data/src/core/lib/channel/compress_filter.h +4 -4
- data/src/core/lib/channel/connected_channel.c +7 -5
- data/src/core/lib/channel/http_client_filter.c +34 -8
- data/src/core/lib/channel/http_client_filter.h +1 -1
- data/src/core/lib/channel/http_server_filter.c +21 -12
- data/src/core/lib/compression/{compression_algorithm.c → compression.c} +22 -21
- data/src/core/lib/http/httpcli.c +81 -59
- data/src/core/lib/http/httpcli.h +11 -15
- data/src/core/lib/http/httpcli_security_connector.c +5 -3
- data/src/core/lib/http/parser.c +127 -118
- data/src/core/lib/http/parser.h +11 -6
- data/src/core/lib/iomgr/closure.c +20 -16
- data/src/core/lib/iomgr/closure.h +19 -15
- data/src/core/lib/iomgr/endpoint.h +1 -1
- data/src/core/lib/iomgr/endpoint_pair_posix.c +2 -2
- data/src/core/lib/iomgr/error.c +535 -0
- data/src/core/lib/iomgr/error.h +192 -0
- data/src/core/lib/iomgr/ev_poll_and_epoll_posix.c +190 -83
- data/src/core/lib/iomgr/ev_poll_posix.c +1267 -0
- data/src/{ruby/ext/grpc/rb_signal.h → core/lib/iomgr/ev_poll_posix.h} +7 -5
- data/src/core/lib/iomgr/ev_posix.c +104 -14
- data/src/core/lib/iomgr/ev_posix.h +17 -7
- data/src/core/lib/iomgr/exec_ctx.c +25 -7
- data/src/core/lib/iomgr/exec_ctx.h +27 -8
- data/src/core/lib/iomgr/executor.c +2 -2
- data/src/core/lib/iomgr/executor.h +1 -1
- data/src/core/lib/iomgr/iocp_windows.c +2 -41
- data/src/core/lib/iomgr/iocp_windows.h +0 -8
- data/src/core/lib/iomgr/iomgr.c +5 -4
- data/src/core/lib/iomgr/iomgr_posix.c +5 -1
- data/src/core/lib/iomgr/iomgr_windows.c +1 -1
- data/src/core/lib/{support → iomgr}/load_file.c +15 -17
- data/src/core/lib/{support → iomgr}/load_file.h +8 -7
- data/src/core/lib/iomgr/polling_entity.c +104 -0
- data/src/core/lib/iomgr/polling_entity.h +81 -0
- data/src/core/lib/iomgr/pollset.h +6 -5
- data/src/core/lib/iomgr/pollset_set_windows.c +4 -1
- data/src/core/lib/iomgr/pollset_windows.c +10 -6
- data/src/core/lib/iomgr/resolve_address.h +5 -9
- data/src/core/lib/iomgr/resolve_address_posix.c +55 -38
- data/src/core/lib/iomgr/resolve_address_windows.c +51 -37
- data/src/core/lib/iomgr/sockaddr.h +2 -2
- data/src/core/lib/iomgr/{sockaddr_win32.h → sockaddr_windows.h} +3 -3
- data/src/core/lib/iomgr/socket_utils_common_posix.c +92 -45
- data/src/core/lib/iomgr/socket_utils_posix.h +19 -12
- data/src/core/lib/iomgr/socket_windows.c +61 -2
- data/src/core/lib/iomgr/socket_windows.h +13 -0
- data/src/core/lib/iomgr/tcp_client_posix.c +54 -39
- data/src/core/lib/iomgr/tcp_client_windows.c +34 -34
- data/src/core/lib/iomgr/tcp_posix.c +43 -39
- data/src/core/lib/iomgr/tcp_server.h +5 -3
- data/src/core/lib/iomgr/tcp_server_posix.c +103 -64
- data/src/core/lib/iomgr/tcp_server_windows.c +114 -101
- data/src/core/lib/iomgr/tcp_windows.c +45 -50
- data/src/core/lib/iomgr/tcp_windows.h +1 -1
- data/src/core/lib/iomgr/timer.c +26 -13
- data/src/core/lib/iomgr/udp_server.c +28 -4
- data/src/core/lib/iomgr/udp_server.h +5 -1
- data/src/core/lib/iomgr/unix_sockets_posix.c +8 -7
- data/src/core/lib/iomgr/unix_sockets_posix.h +2 -1
- data/src/core/lib/iomgr/unix_sockets_posix_noop.c +4 -2
- data/src/core/lib/iomgr/wakeup_fd_eventfd.c +15 -5
- data/src/core/lib/iomgr/wakeup_fd_pipe.c +13 -9
- data/src/core/lib/iomgr/wakeup_fd_posix.c +6 -6
- data/src/core/lib/iomgr/wakeup_fd_posix.h +9 -6
- data/src/core/lib/iomgr/workqueue.h +5 -4
- data/src/core/lib/iomgr/workqueue_posix.c +40 -26
- data/src/core/lib/iomgr/workqueue_windows.c +2 -2
- data/src/core/lib/profiling/basic_timers.c +2 -2
- data/src/core/lib/security/{security_context.c → context/security_context.c} +1 -1
- data/src/core/lib/security/{security_context.h → context/security_context.h} +4 -4
- data/src/core/lib/security/credentials/composite/composite_credentials.c +263 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.h +72 -0
- data/src/core/lib/security/credentials/credentials.c +233 -0
- data/src/core/lib/security/{credentials.h → credentials/credentials.h} +19 -157
- data/src/core/lib/security/{credentials_metadata.c → credentials/credentials_metadata.c} +1 -1
- data/src/core/lib/security/credentials/fake/fake_credentials.c +139 -0
- data/src/core/lib/security/credentials/fake/fake_credentials.h +56 -0
- data/src/core/lib/security/{credentials_posix.c → credentials/google_default/credentials_posix.c} +1 -1
- data/src/core/lib/security/{credentials_win32.c → credentials/google_default/credentials_windows.c} +3 -3
- data/src/core/lib/security/{google_default_credentials.c → credentials/google_default/google_default_credentials.c} +93 -35
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +46 -0
- data/src/core/lib/security/credentials/iam/iam_credentials.c +85 -0
- data/src/core/lib/security/credentials/iam/iam_credentials.h +44 -0
- data/src/core/lib/security/{json_token.c → credentials/jwt/json_token.c} +10 -101
- data/src/core/lib/security/{json_token.h → credentials/jwt/json_token.h} +3 -33
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +160 -0
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +62 -0
- data/src/core/lib/security/{jwt_verifier.c → credentials/jwt/jwt_verifier.c} +35 -15
- data/src/core/lib/security/{jwt_verifier.h → credentials/jwt/jwt_verifier.h} +3 -3
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +433 -0
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +109 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +129 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +45 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +240 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +48 -0
- data/src/core/lib/security/{auth_filters.h → transport/auth_filters.h} +3 -3
- data/src/core/lib/security/{client_auth_filter.c → transport/client_auth_filter.c} +27 -20
- data/src/core/lib/security/{handshake.c → transport/handshake.c} +77 -45
- data/src/core/lib/security/{handshake.h → transport/handshake.h} +9 -11
- data/src/core/lib/security/{secure_endpoint.c → transport/secure_endpoint.c} +19 -12
- data/src/core/lib/security/{secure_endpoint.h → transport/secure_endpoint.h} +3 -3
- data/src/core/lib/security/{security_connector.c → transport/security_connector.c} +26 -17
- data/src/core/lib/security/{security_connector.h → transport/security_connector.h} +8 -8
- data/src/core/lib/security/{server_auth_filter.c → transport/server_auth_filter.c} +24 -16
- data/src/core/lib/security/transport/tsi_error.c +40 -0
- data/src/core/lib/security/transport/tsi_error.h +42 -0
- data/src/core/lib/security/{b64.c → util/b64.c} +1 -1
- data/src/core/lib/security/{b64.h → util/b64.h} +3 -3
- data/src/core/lib/security/util/json_util.c +61 -0
- data/src/core/lib/security/util/json_util.h +55 -0
- data/src/core/lib/support/avl.c +11 -0
- data/src/core/lib/support/cpu_windows.c +2 -2
- data/src/core/lib/support/{env_win32.c → env_windows.c} +3 -3
- data/src/core/lib/support/log.c +3 -1
- data/src/core/lib/support/log_linux.c +2 -2
- data/src/core/lib/support/{log_win32.c → log_windows.c} +4 -4
- data/src/core/lib/support/murmur_hash.c +3 -5
- data/src/core/lib/support/string.c +10 -0
- data/src/core/lib/support/string.h +4 -0
- data/src/core/lib/support/{string_util_win32.c → string_util_windows.c} +3 -3
- data/src/core/lib/support/{string_win32.c → string_windows.c} +2 -2
- data/src/core/lib/support/{string_win32.h → string_windows.h} +5 -5
- data/src/core/lib/support/subprocess_windows.c +1 -1
- data/src/core/lib/support/{sync_win32.c → sync_windows.c} +2 -2
- data/src/core/lib/support/{thd_win32.c → thd_windows.c} +2 -2
- data/src/core/lib/support/{time_win32.c → time_windows.c} +2 -2
- data/src/core/lib/support/tmpfile_msys.c +1 -1
- data/src/core/lib/support/{tmpfile_win32.c → tmpfile_windows.c} +3 -3
- data/src/core/lib/surface/alarm.c +2 -2
- data/src/core/lib/surface/byte_buffer_reader.c +13 -6
- data/src/core/lib/surface/call.c +323 -123
- data/src/core/lib/surface/call.h +2 -0
- data/src/core/lib/surface/call_log_batch.c +1 -1
- data/src/core/lib/surface/channel.c +64 -15
- data/src/core/lib/surface/channel.h +9 -0
- data/src/core/lib/surface/channel_ping.c +3 -3
- data/src/core/lib/surface/completion_queue.c +75 -19
- data/src/core/lib/surface/completion_queue.h +7 -2
- data/src/core/lib/surface/init.c +2 -1
- data/src/core/lib/surface/init_secure.c +4 -4
- data/src/core/lib/surface/lame_client.c +12 -8
- data/src/core/lib/surface/server.c +213 -120
- data/src/core/lib/surface/server.h +1 -0
- data/src/core/lib/surface/version.c +1 -1
- data/src/core/lib/transport/connectivity_state.c +40 -18
- data/src/core/lib/transport/connectivity_state.h +4 -1
- data/src/core/lib/transport/metadata.c +23 -23
- data/src/core/lib/transport/metadata.h +4 -0
- data/src/core/lib/transport/metadata_batch.c +9 -0
- data/src/core/lib/transport/metadata_batch.h +3 -0
- data/src/core/lib/transport/static_metadata.c +6 -5
- data/src/core/lib/transport/static_metadata.h +64 -60
- data/src/core/lib/transport/transport.c +24 -12
- data/src/core/lib/transport/transport.h +6 -5
- data/src/core/lib/transport/transport_impl.h +4 -0
- data/src/core/lib/transport/transport_op_string.c +2 -2
- data/src/core/plugin_registry/grpc_plugin_registry.c +4 -0
- data/src/ruby/bin/math_services.rb +41 -2
- data/src/ruby/ext/grpc/rb_call.c +42 -40
- data/src/ruby/ext/grpc/rb_channel.c +1 -1
- data/src/ruby/ext/grpc/rb_completion_queue.c +59 -6
- data/src/ruby/ext/grpc/rb_completion_queue.h +1 -1
- data/src/ruby/ext/grpc/rb_grpc.c +1 -3
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +12 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +21 -5
- data/src/ruby/ext/grpc/rb_loader.c +1 -1
- data/src/ruby/ext/grpc/rb_server.c +5 -3
- data/src/ruby/lib/grpc.rb +0 -3
- data/src/ruby/lib/grpc/errors.rb +3 -2
- data/src/ruby/lib/grpc/generic/active_call.rb +32 -42
- data/src/ruby/lib/grpc/generic/bidi_call.rb +20 -0
- data/src/ruby/lib/grpc/generic/client_stub.rb +31 -54
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +4 -4
- data/src/ruby/lib/grpc/generic/rpc_server.rb +12 -23
- data/src/ruby/lib/grpc/generic/service.rb +8 -8
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/v1/health_services.rb +30 -2
- data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services.rb +34 -4
- data/src/ruby/pb/grpc/testing/metrics_services.rb +39 -2
- data/src/ruby/pb/src/proto/grpc/testing/empty.rb +15 -0
- data/src/ruby/pb/src/proto/grpc/testing/messages.rb +84 -0
- data/src/ruby/pb/src/proto/grpc/testing/test.rb +14 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_services.rb +110 -0
- data/src/ruby/pb/test/client.rb +5 -2
- data/src/ruby/spec/generic/active_call_spec.rb +3 -2
- data/src/ruby/spec/generic/client_stub_spec.rb +27 -24
- data/src/ruby/spec/generic/rpc_desc_spec.rb +11 -11
- data/src/ruby/spec/generic/rpc_server_spec.rb +42 -61
- data/src/ruby/spec/pb/health/checker_spec.rb +3 -5
- metadata +86 -48
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h +0 -182
- data/src/core/lib/security/credentials.c +0 -1296
- data/src/ruby/lib/grpc/signals.rb +0 -69
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
*
|
3
|
-
* Copyright 2016, Google Inc.
|
3
|
+
* Copyright 2015-2016, Google Inc.
|
4
4
|
* All rights reserved.
|
5
5
|
*
|
6
6
|
* Redistribution and use in source and binary forms, with or without
|
@@ -31,9 +31,11 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
-
#ifndef
|
35
|
-
#define
|
34
|
+
#ifndef GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H
|
35
|
+
#define GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H
|
36
36
|
|
37
|
-
|
37
|
+
#include "src/core/lib/iomgr/ev_posix.h"
|
38
38
|
|
39
|
-
|
39
|
+
const grpc_event_engine_vtable *grpc_init_poll_posix(void);
|
40
|
+
|
41
|
+
#endif /* GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H */
|
@@ -37,23 +37,104 @@
|
|
37
37
|
|
38
38
|
#include "src/core/lib/iomgr/ev_posix.h"
|
39
39
|
|
40
|
+
#include <string.h>
|
41
|
+
|
42
|
+
#include <grpc/support/alloc.h>
|
40
43
|
#include <grpc/support/log.h>
|
44
|
+
#include <grpc/support/string_util.h>
|
45
|
+
#include <grpc/support/useful.h>
|
41
46
|
|
42
47
|
#include "src/core/lib/iomgr/ev_poll_and_epoll_posix.h"
|
48
|
+
#include "src/core/lib/iomgr/ev_poll_posix.h"
|
49
|
+
#include "src/core/lib/support/env.h"
|
50
|
+
|
51
|
+
/** Default poll() function - a pointer so that it can be overridden by some
|
52
|
+
* tests */
|
53
|
+
grpc_poll_function_type grpc_poll_function = poll;
|
43
54
|
|
44
55
|
static const grpc_event_engine_vtable *g_event_engine;
|
45
56
|
|
46
|
-
|
57
|
+
typedef const grpc_event_engine_vtable *(*event_engine_factory_fn)(void);
|
58
|
+
|
59
|
+
typedef struct {
|
60
|
+
const char *name;
|
61
|
+
event_engine_factory_fn factory;
|
62
|
+
} event_engine_factory;
|
63
|
+
|
64
|
+
static const event_engine_factory g_factories[] = {
|
65
|
+
{"poll", grpc_init_poll_posix}, {"legacy", grpc_init_poll_and_epoll_posix},
|
66
|
+
};
|
67
|
+
|
68
|
+
static void add(const char *beg, const char *end, char ***ss, size_t *ns) {
|
69
|
+
size_t n = *ns;
|
70
|
+
size_t np = n + 1;
|
71
|
+
char *s;
|
72
|
+
size_t len;
|
73
|
+
GPR_ASSERT(end >= beg);
|
74
|
+
len = (size_t)(end - beg);
|
75
|
+
s = gpr_malloc(len + 1);
|
76
|
+
memcpy(s, beg, len);
|
77
|
+
s[len] = 0;
|
78
|
+
*ss = gpr_realloc(*ss, sizeof(char **) * np);
|
79
|
+
(*ss)[n] = s;
|
80
|
+
*ns = np;
|
81
|
+
}
|
82
|
+
|
83
|
+
static void split(const char *s, char ***ss, size_t *ns) {
|
84
|
+
const char *c = strchr(s, ',');
|
85
|
+
if (c == NULL) {
|
86
|
+
add(s, s + strlen(s), ss, ns);
|
87
|
+
} else {
|
88
|
+
add(s, c, ss, ns);
|
89
|
+
split(c + 1, ss, ns);
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
static bool is(const char *want, const char *have) {
|
94
|
+
return 0 == strcmp(want, "all") || 0 == strcmp(want, have);
|
95
|
+
}
|
96
|
+
|
97
|
+
static void try_engine(const char *engine) {
|
98
|
+
for (size_t i = 0; i < GPR_ARRAY_SIZE(g_factories); i++) {
|
99
|
+
if (is(engine, g_factories[i].name)) {
|
100
|
+
if ((g_event_engine = g_factories[i].factory())) {
|
101
|
+
gpr_log(GPR_DEBUG, "Using polling engine: %s", g_factories[i].name);
|
102
|
+
return;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
47
107
|
|
48
108
|
void grpc_event_engine_init(void) {
|
49
|
-
|
50
|
-
|
109
|
+
char *s = gpr_getenv("GRPC_POLL_STRATEGY");
|
110
|
+
if (s == NULL) {
|
111
|
+
s = gpr_strdup("all");
|
112
|
+
}
|
113
|
+
|
114
|
+
char **strings = NULL;
|
115
|
+
size_t nstrings = 0;
|
116
|
+
split(s, &strings, &nstrings);
|
117
|
+
|
118
|
+
for (size_t i = 0; g_event_engine == NULL && i < nstrings; i++) {
|
119
|
+
try_engine(strings[i]);
|
120
|
+
}
|
121
|
+
|
122
|
+
for (size_t i = 0; i < nstrings; i++) {
|
123
|
+
gpr_free(strings[i]);
|
124
|
+
}
|
125
|
+
gpr_free(strings);
|
126
|
+
gpr_free(s);
|
127
|
+
|
128
|
+
if (g_event_engine == NULL) {
|
129
|
+
gpr_log(GPR_ERROR, "No event engine could be initialized");
|
130
|
+
abort();
|
51
131
|
}
|
52
|
-
gpr_log(GPR_ERROR, "No event engine could be initialized");
|
53
|
-
abort();
|
54
132
|
}
|
55
133
|
|
56
|
-
void grpc_event_engine_shutdown(void) {
|
134
|
+
void grpc_event_engine_shutdown(void) {
|
135
|
+
g_event_engine->shutdown_engine();
|
136
|
+
g_event_engine = NULL;
|
137
|
+
}
|
57
138
|
|
58
139
|
grpc_fd *grpc_fd_create(int fd, const char *name) {
|
59
140
|
return g_event_engine->fd_create(fd, name);
|
@@ -72,6 +153,10 @@ void grpc_fd_shutdown(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
|
|
72
153
|
g_event_engine->fd_shutdown(exec_ctx, fd);
|
73
154
|
}
|
74
155
|
|
156
|
+
bool grpc_fd_is_shutdown(grpc_fd *fd) {
|
157
|
+
return g_event_engine->fd_is_shutdown(fd);
|
158
|
+
}
|
159
|
+
|
75
160
|
void grpc_fd_notify_on_read(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
76
161
|
grpc_closure *closure) {
|
77
162
|
g_event_engine->fd_notify_on_read(exec_ctx, fd, closure);
|
@@ -82,6 +167,11 @@ void grpc_fd_notify_on_write(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
|
82
167
|
g_event_engine->fd_notify_on_write(exec_ctx, fd, closure);
|
83
168
|
}
|
84
169
|
|
170
|
+
grpc_pollset *grpc_fd_get_read_notifier_pollset(grpc_exec_ctx *exec_ctx,
|
171
|
+
grpc_fd *fd) {
|
172
|
+
return g_event_engine->fd_get_read_notifier_pollset(exec_ctx, fd);
|
173
|
+
}
|
174
|
+
|
85
175
|
size_t grpc_pollset_size(void) { return g_event_engine->pollset_size; }
|
86
176
|
|
87
177
|
void grpc_pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
|
@@ -101,15 +191,15 @@ void grpc_pollset_destroy(grpc_pollset *pollset) {
|
|
101
191
|
g_event_engine->pollset_destroy(pollset);
|
102
192
|
}
|
103
193
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
g_event_engine->pollset_work(exec_ctx, pollset, worker, now, deadline);
|
194
|
+
grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
195
|
+
grpc_pollset_worker **worker, gpr_timespec now,
|
196
|
+
gpr_timespec deadline) {
|
197
|
+
return g_event_engine->pollset_work(exec_ctx, pollset, worker, now, deadline);
|
108
198
|
}
|
109
199
|
|
110
|
-
|
111
|
-
|
112
|
-
g_event_engine->pollset_kick(pollset, specific_worker);
|
200
|
+
grpc_error *grpc_pollset_kick(grpc_pollset *pollset,
|
201
|
+
grpc_pollset_worker *specific_worker) {
|
202
|
+
return g_event_engine->pollset_kick(pollset, specific_worker);
|
113
203
|
}
|
114
204
|
|
115
205
|
void grpc_pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
@@ -159,6 +249,6 @@ void grpc_pollset_set_del_fd(grpc_exec_ctx *exec_ctx,
|
|
159
249
|
g_event_engine->pollset_set_del_fd(exec_ctx, pollset_set, fd);
|
160
250
|
}
|
161
251
|
|
162
|
-
|
252
|
+
grpc_error *grpc_kick_poller(void) { return g_event_engine->kick_poller(); }
|
163
253
|
|
164
254
|
#endif // GPR_POSIX_SOCKET
|
@@ -55,17 +55,20 @@ typedef struct grpc_event_engine_vtable {
|
|
55
55
|
grpc_closure *closure);
|
56
56
|
void (*fd_notify_on_write)(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
57
57
|
grpc_closure *closure);
|
58
|
+
bool (*fd_is_shutdown)(grpc_fd *fd);
|
59
|
+
grpc_pollset *(*fd_get_read_notifier_pollset)(grpc_exec_ctx *exec_ctx,
|
60
|
+
grpc_fd *fd);
|
58
61
|
|
59
62
|
void (*pollset_init)(grpc_pollset *pollset, gpr_mu **mu);
|
60
63
|
void (*pollset_shutdown)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
61
64
|
grpc_closure *closure);
|
62
65
|
void (*pollset_reset)(grpc_pollset *pollset);
|
63
66
|
void (*pollset_destroy)(grpc_pollset *pollset);
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
67
|
+
grpc_error *(*pollset_work)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
68
|
+
grpc_pollset_worker **worker, gpr_timespec now,
|
69
|
+
gpr_timespec deadline);
|
70
|
+
grpc_error *(*pollset_kick)(grpc_pollset *pollset,
|
71
|
+
grpc_pollset_worker *specific_worker);
|
69
72
|
void (*pollset_add_fd)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
70
73
|
struct grpc_fd *fd);
|
71
74
|
|
@@ -88,7 +91,7 @@ typedef struct grpc_event_engine_vtable {
|
|
88
91
|
void (*pollset_set_del_fd)(grpc_exec_ctx *exec_ctx,
|
89
92
|
grpc_pollset_set *pollset_set, grpc_fd *fd);
|
90
93
|
|
91
|
-
|
94
|
+
grpc_error *(*kick_poller)(void);
|
92
95
|
|
93
96
|
void (*shutdown_engine)(void);
|
94
97
|
} grpc_event_engine_vtable;
|
@@ -114,7 +117,10 @@ int grpc_fd_wrapped_fd(grpc_fd *fd);
|
|
114
117
|
void grpc_fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_closure *on_done,
|
115
118
|
int *release_fd, const char *reason);
|
116
119
|
|
117
|
-
/*
|
120
|
+
/* Has grpc_fd_shutdown been called on an fd? */
|
121
|
+
bool grpc_fd_is_shutdown(grpc_fd *fd);
|
122
|
+
|
123
|
+
/* Cause any current and future callbacks to fail. */
|
118
124
|
void grpc_fd_shutdown(grpc_exec_ctx *exec_ctx, grpc_fd *fd);
|
119
125
|
|
120
126
|
/* Register read interest, causing read_cb to be called once when fd becomes
|
@@ -137,6 +143,10 @@ void grpc_fd_notify_on_read(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
|
137
143
|
void grpc_fd_notify_on_write(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
138
144
|
grpc_closure *closure);
|
139
145
|
|
146
|
+
/* Return the read notifier pollset from the fd */
|
147
|
+
grpc_pollset *grpc_fd_get_read_notifier_pollset(grpc_exec_ctx *exec_ctx,
|
148
|
+
grpc_fd *fd);
|
149
|
+
|
140
150
|
/* pollset_posix functions */
|
141
151
|
|
142
152
|
/* Add an fd to a pollset */
|
@@ -39,6 +39,22 @@
|
|
39
39
|
|
40
40
|
#include "src/core/lib/profiling/timers.h"
|
41
41
|
|
42
|
+
bool grpc_exec_ctx_ready_to_finish(grpc_exec_ctx *exec_ctx) {
|
43
|
+
if (!exec_ctx->cached_ready_to_finish) {
|
44
|
+
exec_ctx->cached_ready_to_finish = exec_ctx->check_ready_to_finish(
|
45
|
+
exec_ctx, exec_ctx->check_ready_to_finish_arg);
|
46
|
+
}
|
47
|
+
return exec_ctx->cached_ready_to_finish;
|
48
|
+
}
|
49
|
+
|
50
|
+
bool grpc_never_ready_to_finish(grpc_exec_ctx *exec_ctx, void *arg_ignored) {
|
51
|
+
return false;
|
52
|
+
}
|
53
|
+
|
54
|
+
bool grpc_always_ready_to_finish(grpc_exec_ctx *exec_ctx, void *arg_ignored) {
|
55
|
+
return true;
|
56
|
+
}
|
57
|
+
|
42
58
|
#ifndef GRPC_EXECUTION_CONTEXT_SANITIZER
|
43
59
|
bool grpc_exec_ctx_flush(grpc_exec_ctx *exec_ctx) {
|
44
60
|
bool did_something = 0;
|
@@ -47,11 +63,12 @@ bool grpc_exec_ctx_flush(grpc_exec_ctx *exec_ctx) {
|
|
47
63
|
grpc_closure *c = exec_ctx->closure_list.head;
|
48
64
|
exec_ctx->closure_list.head = exec_ctx->closure_list.tail = NULL;
|
49
65
|
while (c != NULL) {
|
50
|
-
|
51
|
-
|
66
|
+
grpc_closure *next = c->next_data.next;
|
67
|
+
grpc_error *error = c->error;
|
52
68
|
did_something = true;
|
53
69
|
GPR_TIMER_BEGIN("grpc_exec_ctx_flush.cb", 0);
|
54
|
-
c->cb(exec_ctx, c->cb_arg,
|
70
|
+
c->cb(exec_ctx, c->cb_arg, error);
|
71
|
+
GRPC_ERROR_UNREF(error);
|
55
72
|
GPR_TIMER_END("grpc_exec_ctx_flush.cb", 0);
|
56
73
|
c = next;
|
57
74
|
}
|
@@ -61,14 +78,15 @@ bool grpc_exec_ctx_flush(grpc_exec_ctx *exec_ctx) {
|
|
61
78
|
}
|
62
79
|
|
63
80
|
void grpc_exec_ctx_finish(grpc_exec_ctx *exec_ctx) {
|
81
|
+
exec_ctx->cached_ready_to_finish = true;
|
64
82
|
grpc_exec_ctx_flush(exec_ctx);
|
65
83
|
}
|
66
84
|
|
67
|
-
void
|
68
|
-
|
69
|
-
|
85
|
+
void grpc_exec_ctx_sched(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
|
86
|
+
grpc_error *error,
|
87
|
+
grpc_workqueue *offload_target_or_null) {
|
70
88
|
GPR_ASSERT(offload_target_or_null == NULL);
|
71
|
-
|
89
|
+
grpc_closure_list_append(&exec_ctx->closure_list, closure, error);
|
72
90
|
}
|
73
91
|
|
74
92
|
void grpc_exec_ctx_enqueue_list(grpc_exec_ctx *exec_ctx,
|
@@ -53,6 +53,9 @@ typedef struct grpc_workqueue grpc_workqueue;
|
|
53
53
|
* - track a list of work that needs to be delayed until the top of the
|
54
54
|
* call stack (this provides a convenient mechanism to run callbacks
|
55
55
|
* without worrying about locking issues)
|
56
|
+
* - provide a decision maker (via grpc_exec_ctx_ready_to_finish) that provides
|
57
|
+
* signal as to whether a borrowed thread should continue to do work or
|
58
|
+
* should actively try to finish up and get this thread back to its owner
|
56
59
|
*
|
57
60
|
* CONVENTIONS:
|
58
61
|
* Instance of this must ALWAYS be constructed on the stack, never
|
@@ -63,18 +66,26 @@ typedef struct grpc_workqueue grpc_workqueue;
|
|
63
66
|
*/
|
64
67
|
struct grpc_exec_ctx {
|
65
68
|
grpc_closure_list closure_list;
|
69
|
+
bool cached_ready_to_finish;
|
70
|
+
void *check_ready_to_finish_arg;
|
71
|
+
bool (*check_ready_to_finish)(grpc_exec_ctx *exec_ctx, void *arg);
|
66
72
|
};
|
67
73
|
|
68
|
-
#define
|
69
|
-
{ GRPC_CLOSURE_LIST_INIT }
|
74
|
+
#define GRPC_EXEC_CTX_INIT_WITH_FINISH_CHECK(finish_check, finish_check_arg) \
|
75
|
+
{ GRPC_CLOSURE_LIST_INIT, false, finish_check_arg, finish_check }
|
70
76
|
#else
|
71
77
|
struct grpc_exec_ctx {
|
72
|
-
|
78
|
+
bool cached_ready_to_finish;
|
79
|
+
void *check_ready_to_finish_arg;
|
80
|
+
bool (*check_ready_to_finish)(grpc_exec_ctx *exec_ctx, void *arg);
|
73
81
|
};
|
74
|
-
#define
|
75
|
-
{
|
82
|
+
#define GRPC_EXEC_CTX_INIT_WITH_FINISH_CHECK(finish_check, finish_check_arg) \
|
83
|
+
{ false, finish_check_arg, finish_check }
|
76
84
|
#endif
|
77
85
|
|
86
|
+
#define GRPC_EXEC_CTX_INIT \
|
87
|
+
GRPC_EXEC_CTX_INIT_WITH_FINISH_CHECK(grpc_never_ready_to_finish, NULL)
|
88
|
+
|
78
89
|
/** Flush any work that has been enqueued onto this grpc_exec_ctx.
|
79
90
|
* Caller must guarantee that no interfering locks are held.
|
80
91
|
* Returns true if work was performed, false otherwise. */
|
@@ -83,9 +94,17 @@ bool grpc_exec_ctx_flush(grpc_exec_ctx *exec_ctx);
|
|
83
94
|
* the instance is destroyed, or work may be lost. */
|
84
95
|
void grpc_exec_ctx_finish(grpc_exec_ctx *exec_ctx);
|
85
96
|
/** Add a closure to be executed at the next flush/finish point */
|
86
|
-
void
|
87
|
-
|
88
|
-
|
97
|
+
void grpc_exec_ctx_sched(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
|
98
|
+
grpc_error *error,
|
99
|
+
grpc_workqueue *offload_target_or_null);
|
100
|
+
/** Returns true if we'd like to leave this execution context as soon as
|
101
|
+
possible: useful for deciding whether to do something more or not depending
|
102
|
+
on outside context */
|
103
|
+
bool grpc_exec_ctx_ready_to_finish(grpc_exec_ctx *exec_ctx);
|
104
|
+
/** A finish check that is never ready to finish */
|
105
|
+
bool grpc_never_ready_to_finish(grpc_exec_ctx *exec_ctx, void *arg_ignored);
|
106
|
+
/** A finish check that is always ready to finish */
|
107
|
+
bool grpc_always_ready_to_finish(grpc_exec_ctx *exec_ctx, void *arg_ignored);
|
89
108
|
/** Add a list of closures to be executed at the next flush/finish point.
|
90
109
|
* Leaves \a list empty. */
|
91
110
|
void grpc_exec_ctx_enqueue_list(grpc_exec_ctx *exec_ctx,
|
@@ -112,10 +112,10 @@ static void maybe_spawn_locked() {
|
|
112
112
|
g_executor.pending_join = 1;
|
113
113
|
}
|
114
114
|
|
115
|
-
void
|
115
|
+
void grpc_executor_push(grpc_closure *closure, grpc_error *error) {
|
116
116
|
gpr_mu_lock(&g_executor.mu);
|
117
117
|
if (g_executor.shutting_down == 0) {
|
118
|
-
|
118
|
+
grpc_closure_list_append(&g_executor.closures, closure, error);
|
119
119
|
maybe_spawn_locked();
|
120
120
|
}
|
121
121
|
gpr_mu_unlock(&g_executor.mu);
|
@@ -45,7 +45,7 @@ void grpc_executor_init();
|
|
45
45
|
|
46
46
|
/** Enqueue \a closure for its eventual execution of \a f(arg) on a separate
|
47
47
|
* thread */
|
48
|
-
void
|
48
|
+
void grpc_executor_push(grpc_closure *closure, grpc_error *error);
|
49
49
|
|
50
50
|
/** Shutdown the executor, running all pending work as part of the call */
|
51
51
|
void grpc_executor_shutdown();
|
@@ -39,7 +39,7 @@
|
|
39
39
|
|
40
40
|
#include <grpc/support/alloc.h>
|
41
41
|
#include <grpc/support/log.h>
|
42
|
-
#include <grpc/support/
|
42
|
+
#include <grpc/support/log_windows.h>
|
43
43
|
#include <grpc/support/thd.h>
|
44
44
|
|
45
45
|
#include "src/core/lib/iomgr/iocp_windows.h"
|
@@ -104,7 +104,6 @@ grpc_iocp_work_status grpc_iocp_work(grpc_exec_ctx *exec_ctx,
|
|
104
104
|
} else if (overlapped == &socket->read_info.overlapped) {
|
105
105
|
info = &socket->read_info;
|
106
106
|
} else {
|
107
|
-
gpr_log(GPR_ERROR, "Unknown IOCP operation");
|
108
107
|
abort();
|
109
108
|
}
|
110
109
|
success = WSAGetOverlappedResult(socket->socket, &info->overlapped, &bytes,
|
@@ -112,16 +111,7 @@ grpc_iocp_work_status grpc_iocp_work(grpc_exec_ctx *exec_ctx,
|
|
112
111
|
info->bytes_transfered = bytes;
|
113
112
|
info->wsa_error = success ? 0 : WSAGetLastError();
|
114
113
|
GPR_ASSERT(overlapped == &info->overlapped);
|
115
|
-
|
116
|
-
gpr_mu_lock(&socket->state_mu);
|
117
|
-
if (info->closure) {
|
118
|
-
closure = info->closure;
|
119
|
-
info->closure = NULL;
|
120
|
-
} else {
|
121
|
-
info->has_pending_iocp = 1;
|
122
|
-
}
|
123
|
-
gpr_mu_unlock(&socket->state_mu);
|
124
|
-
grpc_exec_ctx_enqueue(exec_ctx, closure, true, NULL);
|
114
|
+
grpc_socket_become_ready(exec_ctx, socket, info);
|
125
115
|
return GRPC_IOCP_WORK_WORK;
|
126
116
|
}
|
127
117
|
|
@@ -176,33 +166,4 @@ void grpc_iocp_add_socket(grpc_winsocket *socket) {
|
|
176
166
|
GPR_ASSERT(ret == g_iocp);
|
177
167
|
}
|
178
168
|
|
179
|
-
/* Calling notify_on_read or write means either of two things:
|
180
|
-
-) The IOCP already completed in the background, and we need to call
|
181
|
-
the callback now.
|
182
|
-
-) The IOCP hasn't completed yet, and we're queuing it for later. */
|
183
|
-
static void socket_notify_on_iocp(grpc_exec_ctx *exec_ctx,
|
184
|
-
grpc_winsocket *socket, grpc_closure *closure,
|
185
|
-
grpc_winsocket_callback_info *info) {
|
186
|
-
GPR_ASSERT(info->closure == NULL);
|
187
|
-
gpr_mu_lock(&socket->state_mu);
|
188
|
-
if (info->has_pending_iocp) {
|
189
|
-
info->has_pending_iocp = 0;
|
190
|
-
grpc_exec_ctx_enqueue(exec_ctx, closure, true, NULL);
|
191
|
-
} else {
|
192
|
-
info->closure = closure;
|
193
|
-
}
|
194
|
-
gpr_mu_unlock(&socket->state_mu);
|
195
|
-
}
|
196
|
-
|
197
|
-
void grpc_socket_notify_on_write(grpc_exec_ctx *exec_ctx,
|
198
|
-
grpc_winsocket *socket,
|
199
|
-
grpc_closure *closure) {
|
200
|
-
socket_notify_on_iocp(exec_ctx, socket, closure, &socket->write_info);
|
201
|
-
}
|
202
|
-
|
203
|
-
void grpc_socket_notify_on_read(grpc_exec_ctx *exec_ctx, grpc_winsocket *socket,
|
204
|
-
grpc_closure *closure) {
|
205
|
-
socket_notify_on_iocp(exec_ctx, socket, closure, &socket->read_info);
|
206
|
-
}
|
207
|
-
|
208
169
|
#endif /* GPR_WINSOCK_SOCKET */
|