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
@@ -52,12 +52,4 @@ void grpc_iocp_flush(void);
|
|
52
52
|
void grpc_iocp_shutdown(void);
|
53
53
|
void grpc_iocp_add_socket(grpc_winsocket *);
|
54
54
|
|
55
|
-
void grpc_socket_notify_on_write(grpc_exec_ctx *exec_ctx,
|
56
|
-
grpc_winsocket *winsocket,
|
57
|
-
grpc_closure *closure);
|
58
|
-
|
59
|
-
void grpc_socket_notify_on_read(grpc_exec_ctx *exec_ctx,
|
60
|
-
grpc_winsocket *winsocket,
|
61
|
-
grpc_closure *closure);
|
62
|
-
|
63
55
|
#endif /* GRPC_CORE_LIB_IOMGR_IOCP_WINDOWS_H */
|
data/src/core/lib/iomgr/iomgr.c
CHANGED
@@ -96,7 +96,8 @@ void grpc_iomgr_shutdown(void) {
|
|
96
96
|
gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), last_warning_time),
|
97
97
|
gpr_time_from_seconds(1, GPR_TIMESPAN)) >= 0) {
|
98
98
|
if (g_root_object.next != &g_root_object) {
|
99
|
-
gpr_log(GPR_DEBUG,
|
99
|
+
gpr_log(GPR_DEBUG,
|
100
|
+
"Waiting for %" PRIuPTR " iomgr objects to be destroyed",
|
100
101
|
count_objects());
|
101
102
|
}
|
102
103
|
last_warning_time = gpr_now(GPR_CLOCK_REALTIME);
|
@@ -114,9 +115,9 @@ void grpc_iomgr_shutdown(void) {
|
|
114
115
|
if (gpr_cv_wait(&g_rcv, &g_mu, short_deadline)) {
|
115
116
|
if (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), shutdown_deadline) > 0) {
|
116
117
|
if (g_root_object.next != &g_root_object) {
|
117
|
-
gpr_log(GPR_DEBUG,
|
118
|
-
|
119
|
-
|
118
|
+
gpr_log(GPR_DEBUG, "Failed to free %" PRIuPTR
|
119
|
+
" iomgr objects before shutdown deadline: "
|
120
|
+
"memory leaks are likely",
|
120
121
|
count_objects());
|
121
122
|
dump_objects("LEAKED");
|
122
123
|
if (grpc_iomgr_abort_on_leaks()) {
|
@@ -41,12 +41,16 @@
|
|
41
41
|
#include "src/core/lib/iomgr/tcp_posix.h"
|
42
42
|
|
43
43
|
void grpc_iomgr_platform_init(void) {
|
44
|
+
grpc_wakeup_fd_global_init();
|
44
45
|
grpc_event_engine_init();
|
45
46
|
grpc_register_tracer("tcp", &grpc_tcp_trace);
|
46
47
|
}
|
47
48
|
|
48
49
|
void grpc_iomgr_platform_flush(void) {}
|
49
50
|
|
50
|
-
void grpc_iomgr_platform_shutdown(void) {
|
51
|
+
void grpc_iomgr_platform_shutdown(void) {
|
52
|
+
grpc_event_engine_shutdown();
|
53
|
+
grpc_wakeup_fd_global_destroy();
|
54
|
+
}
|
51
55
|
|
52
56
|
#endif /* GRPC_POSIX_SOCKET */
|
@@ -31,7 +31,7 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
-
#include "src/core/lib/
|
34
|
+
#include "src/core/lib/iomgr/load_file.h"
|
35
35
|
|
36
36
|
#include <errno.h>
|
37
37
|
#include <string.h>
|
@@ -43,21 +43,19 @@
|
|
43
43
|
#include "src/core/lib/support/block_annotate.h"
|
44
44
|
#include "src/core/lib/support/string.h"
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
grpc_error *grpc_load_file(const char *filename, int add_null_terminator,
|
47
|
+
gpr_slice *output) {
|
48
48
|
unsigned char *contents = NULL;
|
49
49
|
size_t contents_size = 0;
|
50
|
-
char *error_msg = NULL;
|
51
50
|
gpr_slice result = gpr_empty_slice();
|
52
51
|
FILE *file;
|
53
52
|
size_t bytes_read = 0;
|
53
|
+
grpc_error *error = GRPC_ERROR_NONE;
|
54
54
|
|
55
55
|
GRPC_SCHEDULING_START_BLOCKING_REGION;
|
56
56
|
file = fopen(filename, "rb");
|
57
57
|
if (file == NULL) {
|
58
|
-
|
59
|
-
strerror(errno));
|
60
|
-
GPR_ASSERT(error_msg != NULL);
|
58
|
+
error = GRPC_OS_ERROR(errno, "fopen");
|
61
59
|
goto end;
|
62
60
|
}
|
63
61
|
fseek(file, 0, SEEK_END);
|
@@ -67,25 +65,25 @@ gpr_slice gpr_load_file(const char *filename, int add_null_terminator,
|
|
67
65
|
contents = gpr_malloc(contents_size + (add_null_terminator ? 1 : 0));
|
68
66
|
bytes_read = fread(contents, 1, contents_size, file);
|
69
67
|
if (bytes_read < contents_size) {
|
68
|
+
error = GRPC_OS_ERROR(errno, "fread");
|
70
69
|
GPR_ASSERT(ferror(file));
|
71
|
-
gpr_asprintf(&error_msg, "Error %s occured while reading file %s.",
|
72
|
-
strerror(errno), filename);
|
73
|
-
GPR_ASSERT(error_msg != NULL);
|
74
70
|
goto end;
|
75
71
|
}
|
76
|
-
if (success != NULL) *success = 1;
|
77
72
|
if (add_null_terminator) {
|
78
73
|
contents[contents_size++] = 0;
|
79
74
|
}
|
80
75
|
result = gpr_slice_new(contents, contents_size, gpr_free);
|
81
76
|
|
82
77
|
end:
|
83
|
-
|
84
|
-
gpr_log(GPR_ERROR, "%s", error_msg);
|
85
|
-
gpr_free(error_msg);
|
86
|
-
if (success != NULL) *success = 0;
|
87
|
-
}
|
78
|
+
*output = result;
|
88
79
|
if (file != NULL) fclose(file);
|
80
|
+
if (error != GRPC_ERROR_NONE) {
|
81
|
+
grpc_error *error_out = grpc_error_set_str(
|
82
|
+
GRPC_ERROR_CREATE_REFERENCING("Failed to load file", &error, 1),
|
83
|
+
GRPC_ERROR_STR_FILENAME, filename);
|
84
|
+
GRPC_ERROR_UNREF(error);
|
85
|
+
error = error_out;
|
86
|
+
}
|
89
87
|
GRPC_SCHEDULING_END_BLOCKING_REGION;
|
90
|
-
return
|
88
|
+
return error;
|
91
89
|
}
|
@@ -31,25 +31,26 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
-
#ifndef
|
35
|
-
#define
|
34
|
+
#ifndef GRPC_CORE_LIB_IOMGR_LOAD_FILE_H
|
35
|
+
#define GRPC_CORE_LIB_IOMGR_LOAD_FILE_H
|
36
36
|
|
37
37
|
#include <stdio.h>
|
38
38
|
|
39
39
|
#include <grpc/support/slice.h>
|
40
40
|
|
41
|
+
#include "src/core/lib/iomgr/error.h"
|
42
|
+
|
41
43
|
#ifdef __cplusplus
|
42
44
|
extern "C" {
|
43
45
|
#endif
|
44
46
|
|
45
47
|
/* Loads the content of a file into a slice. add_null_terminator will add
|
46
|
-
a NULL terminator if non-zero.
|
47
|
-
|
48
|
-
gpr_slice
|
49
|
-
int *success);
|
48
|
+
a NULL terminator if non-zero. */
|
49
|
+
grpc_error *grpc_load_file(const char *filename, int add_null_terminator,
|
50
|
+
gpr_slice *slice);
|
50
51
|
|
51
52
|
#ifdef __cplusplus
|
52
53
|
}
|
53
54
|
#endif
|
54
55
|
|
55
|
-
#endif /*
|
56
|
+
#endif /* GRPC_CORE_LIB_IOMGR_LOAD_FILE_H */
|
@@ -0,0 +1,104 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2016, Google Inc.
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are
|
8
|
+
* met:
|
9
|
+
*
|
10
|
+
* * Redistributions of source code must retain the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
12
|
+
* * Redistributions in binary form must reproduce the above
|
13
|
+
* copyright notice, this list of conditions and the following disclaimer
|
14
|
+
* in the documentation and/or other materials provided with the
|
15
|
+
* distribution.
|
16
|
+
* * Neither the name of Google Inc. nor the names of its
|
17
|
+
* contributors may be used to endorse or promote products derived from
|
18
|
+
* this software without specific prior written permission.
|
19
|
+
*
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
21
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
22
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
23
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
24
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
27
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
28
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
29
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
30
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
*
|
32
|
+
*/
|
33
|
+
|
34
|
+
#include <grpc/support/alloc.h>
|
35
|
+
#include <grpc/support/log.h>
|
36
|
+
|
37
|
+
#include "src/core/lib/iomgr/polling_entity.h"
|
38
|
+
|
39
|
+
grpc_polling_entity grpc_polling_entity_create_from_pollset_set(
|
40
|
+
grpc_pollset_set *pollset_set) {
|
41
|
+
grpc_polling_entity pollent;
|
42
|
+
pollent.pollent.pollset_set = pollset_set;
|
43
|
+
pollent.tag = POPS_POLLSET_SET;
|
44
|
+
return pollent;
|
45
|
+
}
|
46
|
+
|
47
|
+
grpc_polling_entity grpc_polling_entity_create_from_pollset(
|
48
|
+
grpc_pollset *pollset) {
|
49
|
+
grpc_polling_entity pollent;
|
50
|
+
pollent.pollent.pollset = pollset;
|
51
|
+
pollent.tag = POPS_POLLSET;
|
52
|
+
return pollent;
|
53
|
+
}
|
54
|
+
|
55
|
+
grpc_pollset *grpc_polling_entity_pollset(grpc_polling_entity *pollent) {
|
56
|
+
if (pollent->tag == POPS_POLLSET) {
|
57
|
+
return pollent->pollent.pollset;
|
58
|
+
}
|
59
|
+
return NULL;
|
60
|
+
}
|
61
|
+
|
62
|
+
grpc_pollset_set *grpc_polling_entity_pollset_set(
|
63
|
+
grpc_polling_entity *pollent) {
|
64
|
+
if (pollent->tag == POPS_POLLSET_SET) {
|
65
|
+
return pollent->pollent.pollset_set;
|
66
|
+
}
|
67
|
+
return NULL;
|
68
|
+
}
|
69
|
+
|
70
|
+
bool grpc_polling_entity_is_empty(const grpc_polling_entity *pollent) {
|
71
|
+
return pollent->tag == POPS_NONE;
|
72
|
+
}
|
73
|
+
|
74
|
+
void grpc_polling_entity_add_to_pollset_set(grpc_exec_ctx *exec_ctx,
|
75
|
+
grpc_polling_entity *pollent,
|
76
|
+
grpc_pollset_set *pss_dst) {
|
77
|
+
if (pollent->tag == POPS_POLLSET) {
|
78
|
+
GPR_ASSERT(pollent->pollent.pollset != NULL);
|
79
|
+
grpc_pollset_set_add_pollset(exec_ctx, pss_dst, pollent->pollent.pollset);
|
80
|
+
} else if (pollent->tag == POPS_POLLSET_SET) {
|
81
|
+
GPR_ASSERT(pollent->pollent.pollset_set != NULL);
|
82
|
+
grpc_pollset_set_add_pollset_set(exec_ctx, pss_dst,
|
83
|
+
pollent->pollent.pollset_set);
|
84
|
+
} else {
|
85
|
+
gpr_log(GPR_ERROR, "Invalid grpc_polling_entity tag '%d'", pollent->tag);
|
86
|
+
abort();
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
void grpc_polling_entity_del_from_pollset_set(grpc_exec_ctx *exec_ctx,
|
91
|
+
grpc_polling_entity *pollent,
|
92
|
+
grpc_pollset_set *pss_dst) {
|
93
|
+
if (pollent->tag == POPS_POLLSET) {
|
94
|
+
GPR_ASSERT(pollent->pollent.pollset != NULL);
|
95
|
+
grpc_pollset_set_del_pollset(exec_ctx, pss_dst, pollent->pollent.pollset);
|
96
|
+
} else if (pollent->tag == POPS_POLLSET_SET) {
|
97
|
+
GPR_ASSERT(pollent->pollent.pollset_set != NULL);
|
98
|
+
grpc_pollset_set_del_pollset_set(exec_ctx, pss_dst,
|
99
|
+
pollent->pollent.pollset_set);
|
100
|
+
} else {
|
101
|
+
gpr_log(GPR_ERROR, "Invalid grpc_polling_entity tag '%d'", pollent->tag);
|
102
|
+
abort();
|
103
|
+
}
|
104
|
+
}
|
@@ -0,0 +1,81 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2015, Google Inc.
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are
|
8
|
+
* met:
|
9
|
+
*
|
10
|
+
* * Redistributions of source code must retain the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
12
|
+
* * Redistributions in binary form must reproduce the above
|
13
|
+
* copyright notice, this list of conditions and the following disclaimer
|
14
|
+
* in the documentation and/or other materials provided with the
|
15
|
+
* distribution.
|
16
|
+
* * Neither the name of Google Inc. nor the names of its
|
17
|
+
* contributors may be used to endorse or promote products derived from
|
18
|
+
* this software without specific prior written permission.
|
19
|
+
*
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
21
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
22
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
23
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
24
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
27
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
28
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
29
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
30
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
*
|
32
|
+
*/
|
33
|
+
|
34
|
+
#ifndef GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H
|
35
|
+
#define GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H
|
36
|
+
|
37
|
+
#include "src/core/lib/iomgr/pollset.h"
|
38
|
+
#include "src/core/lib/iomgr/pollset_set.h"
|
39
|
+
|
40
|
+
/* A grpc_polling_entity is a pollset-or-pollset_set container. It allows
|
41
|
+
* functions that
|
42
|
+
* accept a pollset XOR a pollset_set to do so through an abstract interface.
|
43
|
+
* No ownership is taken. */
|
44
|
+
|
45
|
+
typedef struct grpc_polling_entity {
|
46
|
+
union {
|
47
|
+
grpc_pollset *pollset;
|
48
|
+
grpc_pollset_set *pollset_set;
|
49
|
+
} pollent;
|
50
|
+
enum pops_tag { POPS_NONE, POPS_POLLSET, POPS_POLLSET_SET } tag;
|
51
|
+
} grpc_polling_entity;
|
52
|
+
|
53
|
+
grpc_polling_entity grpc_polling_entity_create_from_pollset_set(
|
54
|
+
grpc_pollset_set *pollset_set);
|
55
|
+
grpc_polling_entity grpc_polling_entity_create_from_pollset(
|
56
|
+
grpc_pollset *pollset);
|
57
|
+
|
58
|
+
/** If \a pollent contains a pollset, return it. Otherwise, return NULL */
|
59
|
+
grpc_pollset *grpc_polling_entity_pollset(grpc_polling_entity *pollent);
|
60
|
+
|
61
|
+
/** If \a pollent contains a pollset_set, return it. Otherwise, return NULL */
|
62
|
+
grpc_pollset_set *grpc_polling_entity_pollset_set(grpc_polling_entity *pollent);
|
63
|
+
|
64
|
+
bool grpc_polling_entity_is_empty(const grpc_polling_entity *pollent);
|
65
|
+
|
66
|
+
/** Add the pollset or pollset_set in \a pollent to the destination pollset_set
|
67
|
+
* \a
|
68
|
+
* pss_dst */
|
69
|
+
void grpc_polling_entity_add_to_pollset_set(grpc_exec_ctx *exec_ctx,
|
70
|
+
grpc_polling_entity *pollent,
|
71
|
+
grpc_pollset_set *pss_dst);
|
72
|
+
|
73
|
+
/** Delete the pollset or pollset_set in \a pollent from the destination
|
74
|
+
* pollset_set \a
|
75
|
+
* pss_dst */
|
76
|
+
void grpc_polling_entity_del_from_pollset_set(grpc_exec_ctx *exec_ctx,
|
77
|
+
grpc_polling_entity *pollent,
|
78
|
+
grpc_pollset_set *pss_dst);
|
79
|
+
/* pollset_set specific */
|
80
|
+
|
81
|
+
#endif /* GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H */
|
@@ -81,14 +81,15 @@ void grpc_pollset_destroy(grpc_pollset *pollset);
|
|
81
81
|
May call grpc_closure_list_run on grpc_closure_list, without holding the
|
82
82
|
pollset
|
83
83
|
lock */
|
84
|
-
|
85
|
-
|
86
|
-
|
84
|
+
grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
85
|
+
grpc_pollset_worker **worker, gpr_timespec now,
|
86
|
+
gpr_timespec deadline) GRPC_MUST_USE_RESULT;
|
87
87
|
|
88
88
|
/* Break one polling thread out of polling work for this pollset.
|
89
89
|
If specific_worker is GRPC_POLLSET_KICK_BROADCAST, kick ALL the workers.
|
90
90
|
Otherwise, if specific_worker is non-NULL, then kick that worker. */
|
91
|
-
|
92
|
-
|
91
|
+
grpc_error *grpc_pollset_kick(grpc_pollset *pollset,
|
92
|
+
grpc_pollset_worker *specific_worker)
|
93
|
+
GRPC_MUST_USE_RESULT;
|
93
94
|
|
94
95
|
#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_H */
|
@@ -32,12 +32,15 @@
|
|
32
32
|
*/
|
33
33
|
|
34
34
|
#include <grpc/support/port_platform.h>
|
35
|
+
#include <stdint.h>
|
35
36
|
|
36
37
|
#ifdef GPR_WINSOCK_SOCKET
|
37
38
|
|
38
39
|
#include "src/core/lib/iomgr/pollset_set_windows.h"
|
39
40
|
|
40
|
-
grpc_pollset_set* grpc_pollset_set_create(void) {
|
41
|
+
grpc_pollset_set* grpc_pollset_set_create(void) {
|
42
|
+
return (grpc_pollset_set*)((intptr_t)0xdeafbeef);
|
43
|
+
}
|
41
44
|
|
42
45
|
void grpc_pollset_set_destroy(grpc_pollset_set* pollset_set) {}
|
43
46
|
|
@@ -109,7 +109,7 @@ void grpc_pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
109
109
|
pollset->shutting_down = 1;
|
110
110
|
grpc_pollset_kick(pollset, GRPC_POLLSET_KICK_BROADCAST);
|
111
111
|
if (!pollset->is_iocp_worker) {
|
112
|
-
|
112
|
+
grpc_exec_ctx_sched(exec_ctx, closure, GRPC_ERROR_NONE, NULL);
|
113
113
|
} else {
|
114
114
|
pollset->on_shutdown = closure;
|
115
115
|
}
|
@@ -127,9 +127,9 @@ void grpc_pollset_reset(grpc_pollset *pollset) {
|
|
127
127
|
pollset->on_shutdown = NULL;
|
128
128
|
}
|
129
129
|
|
130
|
-
|
131
|
-
|
132
|
-
|
130
|
+
grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
131
|
+
grpc_pollset_worker **worker_hdl,
|
132
|
+
gpr_timespec now, gpr_timespec deadline) {
|
133
133
|
grpc_pollset_worker worker;
|
134
134
|
*worker_hdl = &worker;
|
135
135
|
|
@@ -167,7 +167,8 @@ void grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
|
167
167
|
}
|
168
168
|
|
169
169
|
if (pollset->shutting_down && pollset->on_shutdown != NULL) {
|
170
|
-
|
170
|
+
grpc_exec_ctx_sched(exec_ctx, pollset->on_shutdown, GRPC_ERROR_NONE,
|
171
|
+
NULL);
|
171
172
|
pollset->on_shutdown = NULL;
|
172
173
|
}
|
173
174
|
goto done;
|
@@ -197,9 +198,11 @@ done:
|
|
197
198
|
}
|
198
199
|
gpr_cv_destroy(&worker.cv);
|
199
200
|
*worker_hdl = NULL;
|
201
|
+
return GRPC_ERROR_NONE;
|
200
202
|
}
|
201
203
|
|
202
|
-
|
204
|
+
grpc_error *grpc_pollset_kick(grpc_pollset *p,
|
205
|
+
grpc_pollset_worker *specific_worker) {
|
203
206
|
if (specific_worker != NULL) {
|
204
207
|
if (specific_worker == GRPC_POLLSET_KICK_BROADCAST) {
|
205
208
|
for (specific_worker =
|
@@ -233,6 +236,7 @@ void grpc_pollset_kick(grpc_pollset *p, grpc_pollset_worker *specific_worker) {
|
|
233
236
|
p->kicked_without_pollers = 1;
|
234
237
|
}
|
235
238
|
}
|
239
|
+
return GRPC_ERROR_NONE;
|
236
240
|
}
|
237
241
|
|
238
242
|
void grpc_kick_poller(void) { grpc_iocp_kick(); }
|