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
data/src/core/lib/iomgr/timer.c
CHANGED
@@ -73,7 +73,7 @@ static shard_type *g_shard_queue[NUM_SHARDS];
|
|
73
73
|
static bool g_initialized = false;
|
74
74
|
|
75
75
|
static int run_some_expired_timers(grpc_exec_ctx *exec_ctx, gpr_timespec now,
|
76
|
-
gpr_timespec *next,
|
76
|
+
gpr_timespec *next, grpc_error *error);
|
77
77
|
|
78
78
|
static gpr_timespec compute_min_deadline(shard_type *shard) {
|
79
79
|
return grpc_timer_heap_is_empty(&shard->heap)
|
@@ -105,7 +105,8 @@ void grpc_timer_list_init(gpr_timespec now) {
|
|
105
105
|
|
106
106
|
void grpc_timer_list_shutdown(grpc_exec_ctx *exec_ctx) {
|
107
107
|
int i;
|
108
|
-
run_some_expired_timers(exec_ctx, gpr_inf_future(g_clock_type), NULL,
|
108
|
+
run_some_expired_timers(exec_ctx, gpr_inf_future(g_clock_type), NULL,
|
109
|
+
GRPC_ERROR_CREATE("Timer list shutdown"));
|
109
110
|
for (i = 0; i < NUM_SHARDS; i++) {
|
110
111
|
shard_type *shard = &g_shards[i];
|
111
112
|
gpr_mu_destroy(&shard->mu);
|
@@ -185,13 +186,16 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer,
|
|
185
186
|
|
186
187
|
if (!g_initialized) {
|
187
188
|
timer->triggered = 1;
|
188
|
-
|
189
|
+
grpc_exec_ctx_sched(
|
190
|
+
exec_ctx, &timer->closure,
|
191
|
+
GRPC_ERROR_CREATE("Attempt to create timer before initialization"),
|
192
|
+
NULL);
|
189
193
|
return;
|
190
194
|
}
|
191
195
|
|
192
196
|
if (gpr_time_cmp(deadline, now) <= 0) {
|
193
197
|
timer->triggered = 1;
|
194
|
-
|
198
|
+
grpc_exec_ctx_sched(exec_ctx, &timer->closure, GRPC_ERROR_NONE, NULL);
|
195
199
|
return;
|
196
200
|
}
|
197
201
|
|
@@ -235,10 +239,15 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer,
|
|
235
239
|
}
|
236
240
|
|
237
241
|
void grpc_timer_cancel(grpc_exec_ctx *exec_ctx, grpc_timer *timer) {
|
242
|
+
if (!g_initialized) {
|
243
|
+
/* must have already been cancelled, also the shard mutex is invalid */
|
244
|
+
return;
|
245
|
+
}
|
246
|
+
|
238
247
|
shard_type *shard = &g_shards[shard_idx(timer)];
|
239
248
|
gpr_mu_lock(&shard->mu);
|
240
249
|
if (!timer->triggered) {
|
241
|
-
|
250
|
+
grpc_exec_ctx_sched(exec_ctx, &timer->closure, GRPC_ERROR_CANCELLED, NULL);
|
242
251
|
timer->triggered = 1;
|
243
252
|
if (timer->heap_index == INVALID_HEAP_INDEX) {
|
244
253
|
list_remove(timer);
|
@@ -278,8 +287,8 @@ static int refill_queue(shard_type *shard, gpr_timespec now) {
|
|
278
287
|
return !grpc_timer_heap_is_empty(&shard->heap);
|
279
288
|
}
|
280
289
|
|
281
|
-
/* This pops the next non-cancelled timer with deadline <= now from the
|
282
|
-
or returns NULL if there isn't one.
|
290
|
+
/* This pops the next non-cancelled timer with deadline <= now from the
|
291
|
+
queue, or returns NULL if there isn't one.
|
283
292
|
REQUIRES: shard->mu locked */
|
284
293
|
static grpc_timer *pop_one(shard_type *shard, gpr_timespec now) {
|
285
294
|
grpc_timer *timer;
|
@@ -299,12 +308,12 @@ static grpc_timer *pop_one(shard_type *shard, gpr_timespec now) {
|
|
299
308
|
/* REQUIRES: shard->mu unlocked */
|
300
309
|
static size_t pop_timers(grpc_exec_ctx *exec_ctx, shard_type *shard,
|
301
310
|
gpr_timespec now, gpr_timespec *new_min_deadline,
|
302
|
-
|
311
|
+
grpc_error *error) {
|
303
312
|
size_t n = 0;
|
304
313
|
grpc_timer *timer;
|
305
314
|
gpr_mu_lock(&shard->mu);
|
306
315
|
while ((timer = pop_one(shard, now))) {
|
307
|
-
|
316
|
+
grpc_exec_ctx_sched(exec_ctx, &timer->closure, GRPC_ERROR_REF(error), NULL);
|
308
317
|
n++;
|
309
318
|
}
|
310
319
|
*new_min_deadline = compute_min_deadline(shard);
|
@@ -313,7 +322,7 @@ static size_t pop_timers(grpc_exec_ctx *exec_ctx, shard_type *shard,
|
|
313
322
|
}
|
314
323
|
|
315
324
|
static int run_some_expired_timers(grpc_exec_ctx *exec_ctx, gpr_timespec now,
|
316
|
-
gpr_timespec *next,
|
325
|
+
gpr_timespec *next, grpc_error *error) {
|
317
326
|
size_t n = 0;
|
318
327
|
|
319
328
|
/* TODO(ctiller): verify that there are any timers (atomically) here */
|
@@ -327,8 +336,8 @@ static int run_some_expired_timers(grpc_exec_ctx *exec_ctx, gpr_timespec now,
|
|
327
336
|
/* For efficiency, we pop as many available timers as we can from the
|
328
337
|
shard. This may violate perfect timer deadline ordering, but that
|
329
338
|
shouldn't be a big deal because we don't make ordering guarantees. */
|
330
|
-
n +=
|
331
|
-
|
339
|
+
n +=
|
340
|
+
pop_timers(exec_ctx, g_shard_queue[0], now, &new_min_deadline, error);
|
332
341
|
|
333
342
|
/* An grpc_timer_init() on the shard could intervene here, adding a new
|
334
343
|
timer that is earlier than new_min_deadline. However,
|
@@ -359,6 +368,8 @@ static int run_some_expired_timers(grpc_exec_ctx *exec_ctx, gpr_timespec now,
|
|
359
368
|
*next, gpr_time_add(now, gpr_time_from_millis(1, GPR_TIMESPAN)));
|
360
369
|
}
|
361
370
|
|
371
|
+
GRPC_ERROR_UNREF(error);
|
372
|
+
|
362
373
|
return (int)n;
|
363
374
|
}
|
364
375
|
|
@@ -367,5 +378,7 @@ bool grpc_timer_check(grpc_exec_ctx *exec_ctx, gpr_timespec now,
|
|
367
378
|
GPR_ASSERT(now.clock_type == g_clock_type);
|
368
379
|
return run_some_expired_timers(
|
369
380
|
exec_ctx, now, next,
|
370
|
-
gpr_time_cmp(now, gpr_inf_future(now.clock_type)) != 0
|
381
|
+
gpr_time_cmp(now, gpr_inf_future(now.clock_type)) != 0
|
382
|
+
? GRPC_ERROR_NONE
|
383
|
+
: GRPC_ERROR_CREATE("Shutting down timer system"));
|
371
384
|
}
|
@@ -81,6 +81,7 @@ typedef struct {
|
|
81
81
|
grpc_closure read_closure;
|
82
82
|
grpc_closure destroyed_closure;
|
83
83
|
grpc_udp_server_read_cb read_cb;
|
84
|
+
grpc_udp_server_orphan_cb orphan_cb;
|
84
85
|
} server_port;
|
85
86
|
|
86
87
|
/* the overall server */
|
@@ -168,6 +169,10 @@ static void deactivated_all_ports(grpc_exec_ctx *exec_ctx, grpc_udp_server *s) {
|
|
168
169
|
server_port *sp = &s->ports[i];
|
169
170
|
sp->destroyed_closure.cb = destroyed_port;
|
170
171
|
sp->destroyed_closure.cb_arg = s;
|
172
|
+
|
173
|
+
GPR_ASSERT(sp->orphan_cb);
|
174
|
+
sp->orphan_cb(sp->emfd);
|
175
|
+
|
171
176
|
grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL,
|
172
177
|
"udp_listener_shutdown");
|
173
178
|
}
|
@@ -205,6 +210,8 @@ static int prepare_socket(int fd, const struct sockaddr *addr,
|
|
205
210
|
size_t addr_len) {
|
206
211
|
struct sockaddr_storage sockname_temp;
|
207
212
|
socklen_t sockname_len;
|
213
|
+
/* Set send/receive socket buffers to 1 MB */
|
214
|
+
int buffer_size_bytes = 1024 * 1024;
|
208
215
|
|
209
216
|
if (fd < 0) {
|
210
217
|
goto error;
|
@@ -234,6 +241,18 @@ static int prepare_socket(int fd, const struct sockaddr *addr,
|
|
234
241
|
goto error;
|
235
242
|
}
|
236
243
|
|
244
|
+
if (!grpc_set_socket_sndbuf(fd, buffer_size_bytes)) {
|
245
|
+
gpr_log(GPR_ERROR, "Failed to set send buffer size to %d bytes",
|
246
|
+
buf_size_bytes);
|
247
|
+
goto error;
|
248
|
+
}
|
249
|
+
|
250
|
+
if (!grpc_set_socket_rcvbuf(fd, buffer_size_bytes)) {
|
251
|
+
gpr_log(GPR_ERROR, "Failed to set receive buffer size to %d bytes",
|
252
|
+
buf_size_bytes);
|
253
|
+
goto error;
|
254
|
+
}
|
255
|
+
|
237
256
|
return grpc_sockaddr_get_port((struct sockaddr *)&sockname_temp);
|
238
257
|
|
239
258
|
error:
|
@@ -268,7 +287,8 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
|
|
268
287
|
|
269
288
|
static int add_socket_to_server(grpc_udp_server *s, int fd,
|
270
289
|
const struct sockaddr *addr, size_t addr_len,
|
271
|
-
grpc_udp_server_read_cb read_cb
|
290
|
+
grpc_udp_server_read_cb read_cb,
|
291
|
+
grpc_udp_server_orphan_cb orphan_cb) {
|
272
292
|
server_port *sp;
|
273
293
|
int port;
|
274
294
|
char *addr_str;
|
@@ -292,6 +312,7 @@ static int add_socket_to_server(grpc_udp_server *s, int fd,
|
|
292
312
|
memcpy(sp->addr.untyped, addr, addr_len);
|
293
313
|
sp->addr_len = addr_len;
|
294
314
|
sp->read_cb = read_cb;
|
315
|
+
sp->orphan_cb = orphan_cb;
|
295
316
|
GPR_ASSERT(sp->emfd);
|
296
317
|
gpr_mu_unlock(&s->mu);
|
297
318
|
gpr_free(name);
|
@@ -301,7 +322,8 @@ static int add_socket_to_server(grpc_udp_server *s, int fd,
|
|
301
322
|
}
|
302
323
|
|
303
324
|
int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr,
|
304
|
-
size_t addr_len, grpc_udp_server_read_cb read_cb
|
325
|
+
size_t addr_len, grpc_udp_server_read_cb read_cb,
|
326
|
+
grpc_udp_server_orphan_cb orphan_cb) {
|
305
327
|
int allocated_port1 = -1;
|
306
328
|
int allocated_port2 = -1;
|
307
329
|
unsigned i;
|
@@ -348,7 +370,8 @@ int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr,
|
|
348
370
|
addr = (struct sockaddr *)&wild6;
|
349
371
|
addr_len = sizeof(wild6);
|
350
372
|
fd = grpc_create_dualstack_socket(addr, SOCK_DGRAM, IPPROTO_UDP, &dsmode);
|
351
|
-
allocated_port1 =
|
373
|
+
allocated_port1 =
|
374
|
+
add_socket_to_server(s, fd, addr, addr_len, read_cb, orphan_cb);
|
352
375
|
if (fd >= 0 && dsmode == GRPC_DSMODE_DUALSTACK) {
|
353
376
|
goto done;
|
354
377
|
}
|
@@ -370,7 +393,8 @@ int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr,
|
|
370
393
|
addr = (struct sockaddr *)&addr4_copy;
|
371
394
|
addr_len = sizeof(addr4_copy);
|
372
395
|
}
|
373
|
-
allocated_port2 =
|
396
|
+
allocated_port2 =
|
397
|
+
add_socket_to_server(s, fd, addr, addr_len, read_cb, orphan_cb);
|
374
398
|
|
375
399
|
done:
|
376
400
|
gpr_free(allocated_addr);
|
@@ -48,6 +48,9 @@ typedef struct grpc_udp_server grpc_udp_server;
|
|
48
48
|
typedef void (*grpc_udp_server_read_cb)(grpc_exec_ctx *exec_ctx, grpc_fd *emfd,
|
49
49
|
struct grpc_server *server);
|
50
50
|
|
51
|
+
/* Called when the grpc_fd is about to be orphaned (and the FD closed). */
|
52
|
+
typedef void (*grpc_udp_server_orphan_cb)(grpc_fd *emfd);
|
53
|
+
|
51
54
|
/* Create a server, initially not bound to any ports */
|
52
55
|
grpc_udp_server *grpc_udp_server_create(void);
|
53
56
|
|
@@ -69,7 +72,8 @@ int grpc_udp_server_get_fd(grpc_udp_server *s, unsigned index);
|
|
69
72
|
/* TODO(ctiller): deprecate this, and make grpc_udp_server_add_ports to handle
|
70
73
|
all of the multiple socket port matching logic in one place */
|
71
74
|
int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr,
|
72
|
-
size_t addr_len, grpc_udp_server_read_cb read_cb
|
75
|
+
size_t addr_len, grpc_udp_server_read_cb read_cb,
|
76
|
+
grpc_udp_server_orphan_cb orphan_cb);
|
73
77
|
|
74
78
|
void grpc_udp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_udp_server *server,
|
75
79
|
grpc_closure *on_done);
|
@@ -47,17 +47,18 @@ void grpc_create_socketpair_if_unix(int sv[2]) {
|
|
47
47
|
GPR_ASSERT(socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == 0);
|
48
48
|
}
|
49
49
|
|
50
|
-
|
50
|
+
grpc_error *grpc_resolve_unix_domain_address(const char *name,
|
51
|
+
grpc_resolved_addresses **addrs) {
|
51
52
|
struct sockaddr_un *un;
|
52
53
|
|
53
|
-
|
54
|
-
addrs->naddrs = 1;
|
55
|
-
addrs->addrs = gpr_malloc(sizeof(grpc_resolved_address));
|
56
|
-
un = (struct sockaddr_un *)addrs->addrs->addr;
|
54
|
+
*addrs = gpr_malloc(sizeof(grpc_resolved_addresses));
|
55
|
+
(*addrs)->naddrs = 1;
|
56
|
+
(*addrs)->addrs = gpr_malloc(sizeof(grpc_resolved_address));
|
57
|
+
un = (struct sockaddr_un *)(*addrs)->addrs->addr;
|
57
58
|
un->sun_family = AF_UNIX;
|
58
59
|
strcpy(un->sun_path, name);
|
59
|
-
addrs->addrs->len = strlen(un->sun_path) + sizeof(un->sun_family) + 1;
|
60
|
-
return
|
60
|
+
(*addrs)->addrs->len = strlen(un->sun_path) + sizeof(un->sun_family) + 1;
|
61
|
+
return GRPC_ERROR_NONE;
|
61
62
|
}
|
62
63
|
|
63
64
|
int grpc_is_unix_socket(const struct sockaddr *addr) {
|
@@ -43,7 +43,8 @@
|
|
43
43
|
|
44
44
|
void grpc_create_socketpair_if_unix(int sv[2]);
|
45
45
|
|
46
|
-
|
46
|
+
grpc_error *grpc_resolve_unix_domain_address(
|
47
|
+
const char *name, grpc_resolved_addresses **addresses);
|
47
48
|
|
48
49
|
int grpc_is_unix_socket(const struct sockaddr *addr);
|
49
50
|
|
@@ -44,8 +44,10 @@ void grpc_create_socketpair_if_unix(int sv[2]) {
|
|
44
44
|
GPR_ASSERT(0);
|
45
45
|
}
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
grpc_error *grpc_resolve_unix_domain_address(
|
48
|
+
const char *name, grpc_resolved_addresses **addresses) {
|
49
|
+
*addresses = NULL;
|
50
|
+
return GRPC_ERROR_CREATE("Unix domain sockets are not supported on Windows");
|
49
51
|
}
|
50
52
|
|
51
53
|
int grpc_is_unix_socket(const struct sockaddr *addr) { return false; }
|
@@ -44,29 +44,39 @@
|
|
44
44
|
#include "src/core/lib/iomgr/wakeup_fd_posix.h"
|
45
45
|
#include "src/core/lib/profiling/timers.h"
|
46
46
|
|
47
|
-
static
|
47
|
+
static grpc_error* eventfd_create(grpc_wakeup_fd* fd_info) {
|
48
48
|
int efd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
|
49
|
-
|
50
|
-
|
49
|
+
if (efd < 0) {
|
50
|
+
return GRPC_OS_ERROR(errno, "eventfd");
|
51
|
+
}
|
51
52
|
fd_info->read_fd = efd;
|
52
53
|
fd_info->write_fd = -1;
|
54
|
+
return GRPC_ERROR_NONE;
|
53
55
|
}
|
54
56
|
|
55
|
-
static
|
57
|
+
static grpc_error* eventfd_consume(grpc_wakeup_fd* fd_info) {
|
56
58
|
eventfd_t value;
|
57
59
|
int err;
|
58
60
|
do {
|
59
61
|
err = eventfd_read(fd_info->read_fd, &value);
|
60
62
|
} while (err < 0 && errno == EINTR);
|
63
|
+
if (err < 0 && errno != EAGAIN) {
|
64
|
+
return GRPC_OS_ERROR(errno, "eventfd_read");
|
65
|
+
}
|
66
|
+
return GRPC_ERROR_NONE;
|
61
67
|
}
|
62
68
|
|
63
|
-
static
|
69
|
+
static grpc_error* eventfd_wakeup(grpc_wakeup_fd* fd_info) {
|
64
70
|
int err;
|
65
71
|
GPR_TIMER_BEGIN("eventfd_wakeup", 0);
|
66
72
|
do {
|
67
73
|
err = eventfd_write(fd_info->read_fd, 1);
|
68
74
|
} while (err < 0 && errno == EINTR);
|
75
|
+
if (err < 0) {
|
76
|
+
return GRPC_OS_ERROR(errno, "eventfd_write");
|
77
|
+
}
|
69
78
|
GPR_TIMER_END("eventfd_wakeup", 0);
|
79
|
+
return GRPC_ERROR_NONE;
|
70
80
|
}
|
71
81
|
|
72
82
|
static void eventfd_destroy(grpc_wakeup_fd* fd_info) {
|
@@ -45,7 +45,7 @@
|
|
45
45
|
|
46
46
|
#include "src/core/lib/iomgr/socket_utils_posix.h"
|
47
47
|
|
48
|
-
static
|
48
|
+
static grpc_error* pipe_init(grpc_wakeup_fd* fd_info) {
|
49
49
|
int pipefd[2];
|
50
50
|
/* TODO(klempner): Make this nonfatal */
|
51
51
|
int r = pipe(pipefd);
|
@@ -53,36 +53,40 @@ static void pipe_init(grpc_wakeup_fd* fd_info) {
|
|
53
53
|
gpr_log(GPR_ERROR, "pipe creation failed (%d): %s", errno, strerror(errno));
|
54
54
|
abort();
|
55
55
|
}
|
56
|
-
|
57
|
-
|
56
|
+
grpc_error* err;
|
57
|
+
err = grpc_set_socket_nonblocking(pipefd[0], 1);
|
58
|
+
if (err != GRPC_ERROR_NONE) return err;
|
59
|
+
err = grpc_set_socket_nonblocking(pipefd[1], 1);
|
60
|
+
if (err != GRPC_ERROR_NONE) return err;
|
58
61
|
fd_info->read_fd = pipefd[0];
|
59
62
|
fd_info->write_fd = pipefd[1];
|
63
|
+
return GRPC_ERROR_NONE;
|
60
64
|
}
|
61
65
|
|
62
|
-
static
|
66
|
+
static grpc_error* pipe_consume(grpc_wakeup_fd* fd_info) {
|
63
67
|
char buf[128];
|
64
68
|
ssize_t r;
|
65
69
|
|
66
70
|
for (;;) {
|
67
71
|
r = read(fd_info->read_fd, buf, sizeof(buf));
|
68
72
|
if (r > 0) continue;
|
69
|
-
if (r == 0) return;
|
73
|
+
if (r == 0) return GRPC_ERROR_NONE;
|
70
74
|
switch (errno) {
|
71
75
|
case EAGAIN:
|
72
|
-
return;
|
76
|
+
return GRPC_ERROR_NONE;
|
73
77
|
case EINTR:
|
74
78
|
continue;
|
75
79
|
default:
|
76
|
-
|
77
|
-
return;
|
80
|
+
return GRPC_OS_ERROR(errno, "read");
|
78
81
|
}
|
79
82
|
}
|
80
83
|
}
|
81
84
|
|
82
|
-
static
|
85
|
+
static grpc_error* pipe_wakeup(grpc_wakeup_fd* fd_info) {
|
83
86
|
char c = 0;
|
84
87
|
while (write(fd_info->write_fd, &c, 1) != 1 && errno == EINTR)
|
85
88
|
;
|
89
|
+
return GRPC_ERROR_NONE;
|
86
90
|
}
|
87
91
|
|
88
92
|
static void pipe_destroy(grpc_wakeup_fd* fd_info) {
|
@@ -53,16 +53,16 @@ void grpc_wakeup_fd_global_init(void) {
|
|
53
53
|
|
54
54
|
void grpc_wakeup_fd_global_destroy(void) { wakeup_fd_vtable = NULL; }
|
55
55
|
|
56
|
-
|
57
|
-
wakeup_fd_vtable->init(fd_info);
|
56
|
+
grpc_error *grpc_wakeup_fd_init(grpc_wakeup_fd *fd_info) {
|
57
|
+
return wakeup_fd_vtable->init(fd_info);
|
58
58
|
}
|
59
59
|
|
60
|
-
|
61
|
-
wakeup_fd_vtable->consume(fd_info);
|
60
|
+
grpc_error *grpc_wakeup_fd_consume_wakeup(grpc_wakeup_fd *fd_info) {
|
61
|
+
return wakeup_fd_vtable->consume(fd_info);
|
62
62
|
}
|
63
63
|
|
64
|
-
|
65
|
-
wakeup_fd_vtable->wakeup(fd_info);
|
64
|
+
grpc_error *grpc_wakeup_fd_wakeup(grpc_wakeup_fd *fd_info) {
|
65
|
+
return wakeup_fd_vtable->wakeup(fd_info);
|
66
66
|
}
|
67
67
|
|
68
68
|
void grpc_wakeup_fd_destroy(grpc_wakeup_fd *fd_info) {
|
@@ -62,6 +62,8 @@
|
|
62
62
|
#ifndef GRPC_CORE_LIB_IOMGR_WAKEUP_FD_POSIX_H
|
63
63
|
#define GRPC_CORE_LIB_IOMGR_WAKEUP_FD_POSIX_H
|
64
64
|
|
65
|
+
#include "src/core/lib/iomgr/error.h"
|
66
|
+
|
65
67
|
void grpc_wakeup_fd_global_init(void);
|
66
68
|
void grpc_wakeup_fd_global_destroy(void);
|
67
69
|
|
@@ -72,9 +74,9 @@ void grpc_wakeup_fd_global_init_force_fallback(void);
|
|
72
74
|
typedef struct grpc_wakeup_fd grpc_wakeup_fd;
|
73
75
|
|
74
76
|
typedef struct grpc_wakeup_fd_vtable {
|
75
|
-
|
76
|
-
|
77
|
-
|
77
|
+
grpc_error* (*init)(grpc_wakeup_fd* fd_info);
|
78
|
+
grpc_error* (*consume)(grpc_wakeup_fd* fd_info);
|
79
|
+
grpc_error* (*wakeup)(grpc_wakeup_fd* fd_info);
|
78
80
|
void (*destroy)(grpc_wakeup_fd* fd_info);
|
79
81
|
/* Must be called before calling any other functions */
|
80
82
|
int (*check_availability)(void);
|
@@ -89,9 +91,10 @@ extern int grpc_allow_specialized_wakeup_fd;
|
|
89
91
|
|
90
92
|
#define GRPC_WAKEUP_FD_GET_READ_FD(fd_info) ((fd_info)->read_fd)
|
91
93
|
|
92
|
-
|
93
|
-
|
94
|
-
|
94
|
+
grpc_error* grpc_wakeup_fd_init(grpc_wakeup_fd* fd_info) GRPC_MUST_USE_RESULT;
|
95
|
+
grpc_error* grpc_wakeup_fd_consume_wakeup(grpc_wakeup_fd* fd_info)
|
96
|
+
GRPC_MUST_USE_RESULT;
|
97
|
+
grpc_error* grpc_wakeup_fd_wakeup(grpc_wakeup_fd* fd_info) GRPC_MUST_USE_RESULT;
|
95
98
|
void grpc_wakeup_fd_destroy(grpc_wakeup_fd* fd_info);
|
96
99
|
|
97
100
|
/* Defined in some specialized implementation's .c file, or by
|