grpc 1.6.7 → 1.7.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +579 -77
- data/include/grpc/byte_buffer.h +1 -63
- data/include/grpc/compression.h +27 -5
- data/include/grpc/fork.h +24 -0
- data/include/grpc/grpc.h +12 -6
- data/include/grpc/grpc_security.h +28 -7
- data/include/grpc/impl/codegen/atm.h +1 -0
- data/include/grpc/impl/codegen/byte_buffer.h +86 -0
- data/include/grpc/impl/codegen/compression_types.h +63 -5
- data/include/grpc/impl/codegen/fork.h +48 -0
- data/include/grpc/impl/codegen/grpc_types.h +26 -9
- data/include/grpc/impl/codegen/port_platform.h +11 -4
- data/include/grpc/impl/codegen/slice.h +6 -1
- data/include/grpc/impl/codegen/sync.h +3 -1
- data/include/grpc/impl/codegen/sync_custom.h +36 -0
- data/include/grpc/module.modulemap +75 -3
- data/include/grpc/slice.h +1 -5
- data/include/grpc/support/sync_custom.h +24 -0
- data/src/core/ext/census/base_resources.c +14 -14
- data/src/core/ext/census/context.c +7 -5
- data/src/core/ext/census/grpc_filter.c +12 -14
- data/src/core/ext/census/mlog.c +2 -1
- data/src/core/ext/census/resource.c +13 -9
- data/src/core/ext/filters/client_channel/channel_connectivity.c +15 -8
- data/src/core/ext/filters/client_channel/client_channel.c +418 -439
- data/src/core/ext/filters/client_channel/client_channel_factory.c +4 -5
- data/src/core/ext/filters/client_channel/client_channel_plugin.c +2 -2
- data/src/core/ext/filters/client_channel/http_connect_handshaker.c +7 -5
- data/src/core/ext/filters/client_channel/http_proxy.c +17 -21
- data/src/core/ext/filters/client_channel/lb_policy.c +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c +7 -7
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +371 -257
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c +7 -5
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +25 -14
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +16 -16
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +33 -28
- data/src/core/ext/filters/client_channel/lb_policy_factory.c +10 -8
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -1
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.c +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +7 -6
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +62 -28
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +29 -23
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c +25 -14
- data/src/core/ext/filters/client_channel/retry_throttle.c +9 -6
- data/src/core/ext/filters/client_channel/subchannel.c +30 -30
- data/src/core/ext/filters/client_channel/subchannel.h +1 -4
- data/src/core/ext/filters/client_channel/subchannel_index.c +31 -15
- data/src/core/ext/filters/client_channel/subchannel_index.h +7 -0
- data/src/core/ext/filters/client_channel/uri_parser.c +4 -3
- data/src/core/ext/filters/deadline/deadline_filter.c +78 -39
- data/src/core/ext/filters/deadline/deadline_filter.h +7 -1
- data/src/core/ext/filters/http/client/http_client_filter.c +14 -14
- data/src/core/ext/filters/http/http_filters_plugin.c +1 -1
- data/src/core/ext/filters/http/message_compress/message_compress_filter.c +240 -175
- data/src/core/ext/filters/http/server/http_server_filter.c +48 -36
- data/src/core/ext/filters/load_reporting/{load_reporting_filter.c → server_load_reporting_filter.c} +11 -12
- data/src/core/ext/filters/load_reporting/{load_reporting_filter.h → server_load_reporting_filter.h} +6 -5
- data/src/core/ext/filters/load_reporting/{load_reporting.c → server_load_reporting_plugin.c} +19 -13
- data/src/core/ext/filters/load_reporting/{load_reporting.h → server_load_reporting_plugin.h} +4 -3
- data/src/core/ext/filters/max_age/max_age_filter.c +2 -3
- data/src/core/ext/filters/message_size/message_size_filter.c +4 -2
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c +0 -1
- data/src/core/ext/transport/chttp2/client/chttp2_connector.c +5 -5
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +1 -1
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +1 -1
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +20 -18
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +1 -0
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +493 -210
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +1 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.c +9 -8
- data/src/core/ext/transport/chttp2/transport/frame_data.c +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +5 -4
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +10 -9
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +9 -5
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +62 -41
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +52 -8
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +2 -2
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +3 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +60 -30
- data/src/core/ext/transport/chttp2/transport/parsing.c +16 -5
- data/src/core/ext/transport/chttp2/transport/stream_lists.c +36 -16
- data/src/core/ext/transport/chttp2/transport/stream_map.c +6 -4
- data/src/core/ext/transport/chttp2/transport/writing.c +133 -105
- data/src/core/ext/transport/inproc/inproc_transport.c +61 -65
- data/src/core/lib/channel/channel_args.c +112 -12
- data/src/core/lib/channel/channel_args.h +31 -0
- data/src/core/lib/channel/channel_stack.c +1 -15
- data/src/core/lib/channel/channel_stack.h +3 -10
- data/src/core/lib/channel/channel_stack_builder.c +41 -10
- data/src/core/lib/channel/channel_stack_builder.h +10 -0
- data/src/core/lib/channel/connected_channel.c +94 -23
- data/src/core/lib/channel/handshaker.c +8 -6
- data/src/core/lib/channel/handshaker_registry.c +1 -1
- data/src/core/lib/compression/algorithm_metadata.h +14 -0
- data/src/core/lib/compression/compression.c +101 -1
- data/src/core/lib/compression/stream_compression.c +32 -146
- data/src/core/lib/compression/stream_compression.h +28 -4
- data/src/core/lib/compression/stream_compression_gzip.c +228 -0
- data/src/core/lib/{iomgr/ev_epoll_thread_pool_linux.h → compression/stream_compression_gzip.h} +5 -7
- data/src/core/lib/compression/stream_compression_identity.c +94 -0
- data/src/core/lib/{iomgr/ev_epoll_limited_pollers_linux.h → compression/stream_compression_identity.h} +7 -8
- data/src/core/lib/debug/stats.c +174 -0
- data/src/core/lib/debug/stats.h +61 -0
- data/src/core/lib/debug/stats_data.c +687 -0
- data/src/core/lib/debug/stats_data.h +470 -0
- data/src/core/lib/debug/trace.c +3 -3
- data/src/core/lib/debug/trace.h +1 -1
- data/src/core/lib/http/format_request.c +1 -1
- data/src/core/lib/http/httpcli.c +8 -7
- data/src/core/lib/http/httpcli_security_connector.c +2 -1
- data/src/core/lib/http/parser.c +4 -3
- data/src/core/lib/iomgr/call_combiner.c +202 -0
- data/src/core/lib/iomgr/call_combiner.h +121 -0
- data/src/core/lib/iomgr/closure.c +18 -4
- data/src/core/lib/iomgr/combiner.c +11 -4
- data/src/core/lib/iomgr/error.c +26 -24
- data/src/core/lib/iomgr/ev_epoll1_linux.c +395 -212
- data/src/core/lib/iomgr/ev_epollex_linux.c +141 -128
- data/src/core/lib/iomgr/ev_epollsig_linux.c +44 -41
- data/src/core/lib/iomgr/ev_poll_posix.c +99 -75
- data/src/core/lib/iomgr/ev_posix.c +5 -9
- data/src/core/lib/iomgr/ev_posix.h +1 -1
- data/src/core/lib/iomgr/exec_ctx.h +6 -1
- data/src/core/lib/iomgr/executor.c +142 -36
- data/src/core/lib/iomgr/executor.h +6 -1
- data/src/core/lib/iomgr/fork_posix.c +88 -0
- data/src/core/lib/iomgr/fork_windows.c +39 -0
- data/src/core/lib/iomgr/iocp_windows.c +2 -0
- data/src/core/lib/iomgr/iomgr.c +2 -8
- data/src/core/lib/iomgr/is_epollexclusive_available.c +6 -6
- data/src/core/lib/iomgr/load_file.c +2 -1
- data/src/core/lib/iomgr/polling_entity.c +9 -9
- data/src/core/lib/iomgr/polling_entity.h +7 -1
- data/src/core/lib/iomgr/pollset.h +1 -1
- data/src/core/lib/iomgr/pollset_uv.c +1 -1
- data/src/core/lib/iomgr/pollset_windows.c +3 -3
- data/src/core/lib/iomgr/port.h +4 -0
- data/src/core/lib/iomgr/resolve_address_posix.c +8 -7
- data/src/core/lib/iomgr/resolve_address_windows.c +1 -1
- data/src/core/lib/iomgr/resource_quota.c +24 -19
- data/src/core/lib/iomgr/socket_factory_posix.c +4 -4
- data/src/core/lib/iomgr/socket_mutator.c +4 -4
- data/src/core/lib/iomgr/socket_utils_windows.c +0 -4
- data/src/core/lib/iomgr/tcp_client_posix.c +5 -4
- data/src/core/lib/iomgr/tcp_posix.c +181 -20
- data/src/core/lib/iomgr/tcp_server_posix.c +8 -7
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +1 -1
- data/src/core/lib/iomgr/timer.h +4 -0
- data/src/core/lib/iomgr/timer_generic.c +138 -3
- data/src/core/lib/iomgr/timer_generic.h +3 -0
- data/src/core/lib/iomgr/timer_heap.c +4 -4
- data/src/core/lib/iomgr/timer_manager.c +2 -2
- data/src/core/lib/iomgr/timer_uv.c +2 -0
- data/src/core/lib/iomgr/udp_server.c +10 -8
- data/src/core/lib/iomgr/unix_sockets_posix.c +4 -2
- data/src/core/lib/iomgr/wakeup_fd_cv.c +9 -8
- data/src/core/lib/iomgr/wakeup_fd_cv.h +2 -2
- data/src/core/lib/json/json.c +1 -1
- data/src/core/lib/json/json_string.c +13 -13
- data/src/core/lib/profiling/timers.h +18 -8
- data/src/core/lib/security/credentials/composite/composite_credentials.c +4 -10
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +2 -1
- data/src/core/lib/security/credentials/jwt/jwt_verifier.c +11 -6
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +4 -4
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +132 -50
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -0
- data/src/core/lib/security/transport/client_auth_filter.c +68 -135
- data/src/core/lib/security/transport/secure_endpoint.c +110 -90
- data/src/core/lib/security/transport/secure_endpoint.h +8 -3
- data/src/core/lib/security/transport/security_connector.c +10 -12
- data/src/core/lib/security/transport/security_handshaker.c +45 -24
- data/src/core/lib/security/transport/server_auth_filter.c +71 -20
- data/src/core/lib/slice/b64.c +2 -2
- data/src/core/lib/slice/slice.c +16 -14
- data/src/core/lib/slice/slice_buffer.c +5 -4
- data/src/core/lib/slice/slice_hash_table.c +3 -2
- data/src/core/lib/slice/slice_intern.c +8 -5
- data/src/core/lib/support/block_annotate.h +22 -0
- data/src/core/lib/support/fork.c +62 -0
- data/src/core/lib/support/fork.h +35 -0
- data/src/core/lib/support/log_linux.c +1 -1
- data/src/core/lib/support/string.c +15 -1
- data/src/core/lib/support/string.h +3 -0
- data/src/core/lib/support/thd_internal.h +6 -0
- data/src/core/lib/support/thd_posix.c +56 -0
- data/src/core/lib/support/thd_windows.c +2 -0
- data/src/core/lib/surface/alarm.c +22 -15
- data/src/core/lib/surface/byte_buffer.c +4 -2
- data/src/core/lib/surface/call.c +442 -141
- data/src/core/lib/surface/call.h +6 -6
- data/src/core/lib/surface/call_log_batch.c +1 -1
- data/src/core/lib/surface/call_test_only.h +12 -0
- data/src/core/lib/surface/channel.c +39 -4
- data/src/core/lib/surface/channel_init.c +6 -6
- data/src/core/lib/surface/channel_ping.c +2 -2
- data/src/core/lib/surface/completion_queue.c +56 -57
- data/src/core/lib/surface/init.c +17 -3
- data/src/core/lib/surface/init_secure.c +5 -1
- data/src/core/lib/surface/lame_client.cc +9 -10
- data/src/core/lib/surface/server.c +81 -72
- data/src/core/lib/surface/version.c +2 -2
- data/src/core/lib/transport/byte_stream.c +1 -0
- data/src/core/lib/transport/byte_stream.h +3 -1
- data/src/core/lib/transport/connectivity_state.c +2 -1
- data/src/core/lib/transport/metadata.c +7 -4
- data/src/core/lib/transport/metadata_batch.c +18 -16
- data/src/core/lib/transport/metadata_batch.h +1 -0
- data/src/core/lib/transport/service_config.c +5 -3
- data/src/core/lib/transport/static_metadata.c +395 -614
- data/src/core/lib/transport/static_metadata.h +165 -133
- data/src/core/lib/transport/status_conversion.c +1 -1
- data/src/core/lib/transport/transport.c +20 -20
- data/src/core/lib/transport/transport.h +8 -5
- data/src/core/lib/transport/transport_impl.h +0 -3
- data/src/core/lib/transport/transport_op_string.c +8 -1
- data/src/core/plugin_registry/grpc_plugin_registry.c +4 -4
- data/src/core/tsi/fake_transport_security.c +133 -2
- data/src/core/tsi/fake_transport_security.h +5 -0
- data/src/core/tsi/ssl_transport_security.c +105 -8
- data/src/core/tsi/ssl_transport_security.h +30 -7
- data/src/core/tsi/transport_security.h +8 -2
- data/src/core/tsi/transport_security_grpc.c +20 -13
- data/src/core/tsi/transport_security_grpc.h +13 -9
- data/src/ruby/ext/grpc/rb_call_credentials.c +6 -2
- data/src/ruby/ext/grpc/rb_grpc.c +1 -1
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +30 -20
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +50 -35
- data/src/ruby/lib/grpc.rb +1 -0
- data/src/ruby/lib/grpc/generic/active_call.rb +34 -9
- data/src/ruby/lib/grpc/generic/bidi_call.rb +19 -10
- data/src/ruby/lib/grpc/generic/client_stub.rb +95 -38
- data/src/ruby/lib/grpc/generic/interceptor_registry.rb +53 -0
- data/src/ruby/lib/grpc/generic/interceptors.rb +186 -0
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +66 -20
- data/src/ruby/lib/grpc/generic/rpc_server.rb +15 -3
- data/src/ruby/lib/grpc/google_rpc_status_utils.rb +1 -2
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb +1 -0
- data/src/ruby/spec/channel_connection_spec.rb +1 -34
- data/src/ruby/spec/client_server_spec.rb +188 -82
- data/src/ruby/spec/generic/active_call_spec.rb +65 -11
- data/src/ruby/spec/generic/client_interceptors_spec.rb +153 -0
- data/src/ruby/spec/generic/interceptor_registry_spec.rb +65 -0
- data/src/ruby/spec/generic/rpc_desc_spec.rb +38 -0
- data/src/ruby/spec/generic/rpc_server_spec.rb +1 -34
- data/src/ruby/spec/generic/server_interceptors_spec.rb +218 -0
- data/src/ruby/spec/spec_helper.rb +4 -0
- data/src/ruby/spec/support/helpers.rb +73 -0
- data/src/ruby/spec/support/services.rb +147 -0
- data/third_party/cares/ares_build.h +21 -62
- data/third_party/cares/cares/ares.h +23 -1
- data/third_party/cares/cares/ares__close_sockets.c +2 -2
- data/third_party/cares/cares/ares_create_query.c +3 -3
- data/third_party/cares/cares/ares_expand_name.c +6 -2
- data/third_party/cares/cares/ares_expand_string.c +1 -1
- data/third_party/cares/cares/ares_getnameinfo.c +27 -7
- data/third_party/cares/cares/ares_init.c +407 -39
- data/third_party/cares/cares/ares_library_init.c +10 -0
- data/third_party/cares/cares/ares_library_init.h +2 -1
- data/third_party/cares/cares/ares_nowarn.c +6 -6
- data/third_party/cares/cares/ares_nowarn.h +2 -2
- data/third_party/cares/cares/ares_parse_naptr_reply.c +6 -1
- data/third_party/cares/cares/ares_private.h +11 -0
- data/third_party/cares/cares/ares_process.c +126 -37
- data/third_party/cares/cares/ares_version.h +2 -2
- data/third_party/cares/cares/ares_writev.c +2 -2
- data/third_party/cares/cares/config-win32.h +8 -34
- data/third_party/cares/cares/inet_net_pton.c +2 -2
- data/third_party/cares/cares/setup_once.h +5 -5
- data/third_party/cares/config_darwin/ares_config.h +98 -196
- data/third_party/cares/config_linux/ares_config.h +103 -203
- metadata +47 -20
- data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +0 -1957
- data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +0 -1182
@@ -26,7 +26,15 @@
|
|
26
26
|
#include "src/core/lib/security/transport/auth_filters.h"
|
27
27
|
#include "src/core/lib/slice/slice_internal.h"
|
28
28
|
|
29
|
+
typedef enum {
|
30
|
+
STATE_INIT = 0,
|
31
|
+
STATE_DONE,
|
32
|
+
STATE_CANCELLED,
|
33
|
+
} async_state;
|
34
|
+
|
29
35
|
typedef struct call_data {
|
36
|
+
grpc_call_combiner *call_combiner;
|
37
|
+
grpc_call_stack *owning_call;
|
30
38
|
grpc_transport_stream_op_batch *recv_initial_metadata_batch;
|
31
39
|
grpc_closure *original_recv_initial_metadata_ready;
|
32
40
|
grpc_closure recv_initial_metadata_ready;
|
@@ -34,6 +42,8 @@ typedef struct call_data {
|
|
34
42
|
const grpc_metadata *consumed_md;
|
35
43
|
size_t num_consumed_md;
|
36
44
|
grpc_auth_context *auth_context;
|
45
|
+
grpc_closure cancel_closure;
|
46
|
+
gpr_atm state; // async_state
|
37
47
|
} call_data;
|
38
48
|
|
39
49
|
typedef struct channel_data {
|
@@ -78,54 +88,94 @@ static grpc_filtered_mdelem remove_consumed_md(grpc_exec_ctx *exec_ctx,
|
|
78
88
|
return GRPC_FILTERED_MDELEM(md);
|
79
89
|
}
|
80
90
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
91
|
+
static void on_md_processing_done_inner(grpc_exec_ctx *exec_ctx,
|
92
|
+
grpc_call_element *elem,
|
93
|
+
const grpc_metadata *consumed_md,
|
94
|
+
size_t num_consumed_md,
|
95
|
+
const grpc_metadata *response_md,
|
96
|
+
size_t num_response_md,
|
97
|
+
grpc_error *error) {
|
87
98
|
call_data *calld = elem->call_data;
|
88
99
|
grpc_transport_stream_op_batch *batch = calld->recv_initial_metadata_batch;
|
89
|
-
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
90
100
|
/* TODO(jboeuf): Implement support for response_md. */
|
91
101
|
if (response_md != NULL && num_response_md > 0) {
|
92
102
|
gpr_log(GPR_INFO,
|
93
103
|
"response_md in auth metadata processing not supported for now. "
|
94
104
|
"Ignoring...");
|
95
105
|
}
|
96
|
-
|
97
|
-
if (status == GRPC_STATUS_OK) {
|
106
|
+
if (error == GRPC_ERROR_NONE) {
|
98
107
|
calld->consumed_md = consumed_md;
|
99
108
|
calld->num_consumed_md = num_consumed_md;
|
100
109
|
error = grpc_metadata_batch_filter(
|
101
|
-
|
110
|
+
exec_ctx, batch->payload->recv_initial_metadata.recv_initial_metadata,
|
102
111
|
remove_consumed_md, elem, "Response metadata filtering error");
|
103
|
-
}
|
104
|
-
|
105
|
-
|
112
|
+
}
|
113
|
+
GRPC_CLOSURE_SCHED(exec_ctx, calld->original_recv_initial_metadata_ready,
|
114
|
+
error);
|
115
|
+
}
|
116
|
+
|
117
|
+
// Called from application code.
|
118
|
+
static void on_md_processing_done(
|
119
|
+
void *user_data, const grpc_metadata *consumed_md, size_t num_consumed_md,
|
120
|
+
const grpc_metadata *response_md, size_t num_response_md,
|
121
|
+
grpc_status_code status, const char *error_details) {
|
122
|
+
grpc_call_element *elem = user_data;
|
123
|
+
call_data *calld = elem->call_data;
|
124
|
+
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
125
|
+
// If the call was not cancelled while we were in flight, process the result.
|
126
|
+
if (gpr_atm_full_cas(&calld->state, (gpr_atm)STATE_INIT,
|
127
|
+
(gpr_atm)STATE_DONE)) {
|
128
|
+
grpc_error *error = GRPC_ERROR_NONE;
|
129
|
+
if (status != GRPC_STATUS_OK) {
|
130
|
+
if (error_details == NULL) {
|
131
|
+
error_details = "Authentication metadata processing failed.";
|
132
|
+
}
|
133
|
+
error = grpc_error_set_int(
|
134
|
+
GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_details),
|
135
|
+
GRPC_ERROR_INT_GRPC_STATUS, status);
|
106
136
|
}
|
107
|
-
|
108
|
-
|
109
|
-
GRPC_ERROR_INT_GRPC_STATUS, status);
|
137
|
+
on_md_processing_done_inner(&exec_ctx, elem, consumed_md, num_consumed_md,
|
138
|
+
response_md, num_response_md, error);
|
110
139
|
}
|
140
|
+
// Clean up.
|
111
141
|
for (size_t i = 0; i < calld->md.count; i++) {
|
112
142
|
grpc_slice_unref_internal(&exec_ctx, calld->md.metadata[i].key);
|
113
143
|
grpc_slice_unref_internal(&exec_ctx, calld->md.metadata[i].value);
|
114
144
|
}
|
115
145
|
grpc_metadata_array_destroy(&calld->md);
|
116
|
-
|
117
|
-
error);
|
146
|
+
GRPC_CALL_STACK_UNREF(&exec_ctx, calld->owning_call, "server_auth_metadata");
|
118
147
|
grpc_exec_ctx_finish(&exec_ctx);
|
119
148
|
}
|
120
149
|
|
150
|
+
static void cancel_call(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
|
151
|
+
grpc_call_element *elem = (grpc_call_element *)arg;
|
152
|
+
call_data *calld = elem->call_data;
|
153
|
+
// If the result was not already processed, invoke the callback now.
|
154
|
+
if (error != GRPC_ERROR_NONE &&
|
155
|
+
gpr_atm_full_cas(&calld->state, (gpr_atm)STATE_INIT,
|
156
|
+
(gpr_atm)STATE_CANCELLED)) {
|
157
|
+
on_md_processing_done_inner(exec_ctx, elem, NULL, 0, NULL, 0,
|
158
|
+
GRPC_ERROR_REF(error));
|
159
|
+
}
|
160
|
+
GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "cancel_call");
|
161
|
+
}
|
162
|
+
|
121
163
|
static void recv_initial_metadata_ready(grpc_exec_ctx *exec_ctx, void *arg,
|
122
164
|
grpc_error *error) {
|
123
|
-
grpc_call_element *elem = arg;
|
165
|
+
grpc_call_element *elem = (grpc_call_element *)arg;
|
124
166
|
channel_data *chand = elem->channel_data;
|
125
167
|
call_data *calld = elem->call_data;
|
126
168
|
grpc_transport_stream_op_batch *batch = calld->recv_initial_metadata_batch;
|
127
169
|
if (error == GRPC_ERROR_NONE) {
|
128
170
|
if (chand->creds != NULL && chand->creds->processor.process != NULL) {
|
171
|
+
// We're calling out to the application, so we need to make sure
|
172
|
+
// to drop the call combiner early if we get cancelled.
|
173
|
+
GRPC_CALL_STACK_REF(calld->owning_call, "cancel_call");
|
174
|
+
GRPC_CLOSURE_INIT(&calld->cancel_closure, cancel_call, elem,
|
175
|
+
grpc_schedule_on_exec_ctx);
|
176
|
+
grpc_call_combiner_set_notify_on_cancel(exec_ctx, calld->call_combiner,
|
177
|
+
&calld->cancel_closure);
|
178
|
+
GRPC_CALL_STACK_REF(calld->owning_call, "server_auth_metadata");
|
129
179
|
calld->md = metadata_batch_to_md_array(
|
130
180
|
batch->payload->recv_initial_metadata.recv_initial_metadata);
|
131
181
|
chand->creds->processor.process(
|
@@ -159,6 +209,8 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
|
|
159
209
|
const grpc_call_element_args *args) {
|
160
210
|
call_data *calld = elem->call_data;
|
161
211
|
channel_data *chand = elem->channel_data;
|
212
|
+
calld->call_combiner = args->call_combiner;
|
213
|
+
calld->owning_call = args->call_stack;
|
162
214
|
GRPC_CLOSURE_INIT(&calld->recv_initial_metadata_ready,
|
163
215
|
recv_initial_metadata_ready, elem,
|
164
216
|
grpc_schedule_on_exec_ctx);
|
@@ -218,6 +270,5 @@ const grpc_channel_filter grpc_server_auth_filter = {
|
|
218
270
|
sizeof(channel_data),
|
219
271
|
init_channel_elem,
|
220
272
|
destroy_channel_elem,
|
221
|
-
grpc_call_next_get_peer,
|
222
273
|
grpc_channel_next_get_info,
|
223
274
|
"server-auth"};
|
data/src/core/lib/slice/b64.c
CHANGED
@@ -58,7 +58,7 @@ char *grpc_base64_encode(const void *vdata, size_t data_size, int url_safe,
|
|
58
58
|
int multiline) {
|
59
59
|
size_t result_projected_size =
|
60
60
|
grpc_base64_estimate_encoded_size(data_size, url_safe, multiline);
|
61
|
-
char *result = gpr_malloc(result_projected_size);
|
61
|
+
char *result = (char *)gpr_malloc(result_projected_size);
|
62
62
|
grpc_base64_encode_core(result, vdata, data_size, url_safe, multiline);
|
63
63
|
return result;
|
64
64
|
}
|
@@ -75,7 +75,7 @@ size_t grpc_base64_estimate_encoded_size(size_t data_size, int url_safe,
|
|
75
75
|
|
76
76
|
void grpc_base64_encode_core(char *result, const void *vdata, size_t data_size,
|
77
77
|
int url_safe, int multiline) {
|
78
|
-
const unsigned char *data = vdata;
|
78
|
+
const unsigned char *data = (const unsigned char *)vdata;
|
79
79
|
const char *base64_chars =
|
80
80
|
url_safe ? base64_url_safe_chars : base64_url_unsafe_chars;
|
81
81
|
const size_t result_projected_size =
|
data/src/core/lib/slice/slice.c
CHANGED
@@ -27,7 +27,7 @@
|
|
27
27
|
#include "src/core/lib/iomgr/exec_ctx.h"
|
28
28
|
|
29
29
|
char *grpc_slice_to_c_string(grpc_slice slice) {
|
30
|
-
char *out = gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1);
|
30
|
+
char *out = (char *)gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1);
|
31
31
|
memcpy(out, GRPC_SLICE_START_PTR(slice), GRPC_SLICE_LENGTH(slice));
|
32
32
|
out[GRPC_SLICE_LENGTH(slice)] = 0;
|
33
33
|
return out;
|
@@ -105,12 +105,12 @@ typedef struct new_slice_refcount {
|
|
105
105
|
} new_slice_refcount;
|
106
106
|
|
107
107
|
static void new_slice_ref(void *p) {
|
108
|
-
new_slice_refcount *r = p;
|
108
|
+
new_slice_refcount *r = (new_slice_refcount *)p;
|
109
109
|
gpr_ref(&r->refs);
|
110
110
|
}
|
111
111
|
|
112
112
|
static void new_slice_unref(grpc_exec_ctx *exec_ctx, void *p) {
|
113
|
-
new_slice_refcount *r = p;
|
113
|
+
new_slice_refcount *r = (new_slice_refcount *)p;
|
114
114
|
if (gpr_unref(&r->refs)) {
|
115
115
|
r->user_destroy(r->user_data);
|
116
116
|
gpr_free(r);
|
@@ -125,7 +125,8 @@ grpc_slice grpc_slice_new_with_user_data(void *p, size_t len,
|
|
125
125
|
void (*destroy)(void *),
|
126
126
|
void *user_data) {
|
127
127
|
grpc_slice slice;
|
128
|
-
new_slice_refcount *rc =
|
128
|
+
new_slice_refcount *rc =
|
129
|
+
(new_slice_refcount *)gpr_malloc(sizeof(new_slice_refcount));
|
129
130
|
gpr_ref_init(&rc->refs, 1);
|
130
131
|
rc->rc.vtable = &new_slice_vtable;
|
131
132
|
rc->rc.sub_refcount = &rc->rc;
|
@@ -133,7 +134,7 @@ grpc_slice grpc_slice_new_with_user_data(void *p, size_t len,
|
|
133
134
|
rc->user_data = user_data;
|
134
135
|
|
135
136
|
slice.refcount = &rc->rc;
|
136
|
-
slice.data.refcounted.bytes = p;
|
137
|
+
slice.data.refcounted.bytes = (uint8_t *)p;
|
137
138
|
slice.data.refcounted.length = len;
|
138
139
|
return slice;
|
139
140
|
}
|
@@ -154,12 +155,12 @@ typedef struct new_with_len_slice_refcount {
|
|
154
155
|
} new_with_len_slice_refcount;
|
155
156
|
|
156
157
|
static void new_with_len_ref(void *p) {
|
157
|
-
new_with_len_slice_refcount *r = p;
|
158
|
+
new_with_len_slice_refcount *r = (new_with_len_slice_refcount *)p;
|
158
159
|
gpr_ref(&r->refs);
|
159
160
|
}
|
160
161
|
|
161
162
|
static void new_with_len_unref(grpc_exec_ctx *exec_ctx, void *p) {
|
162
|
-
new_with_len_slice_refcount *r = p;
|
163
|
+
new_with_len_slice_refcount *r = (new_with_len_slice_refcount *)p;
|
163
164
|
if (gpr_unref(&r->refs)) {
|
164
165
|
r->user_destroy(r->user_data, r->user_length);
|
165
166
|
gpr_free(r);
|
@@ -173,8 +174,8 @@ static const grpc_slice_refcount_vtable new_with_len_vtable = {
|
|
173
174
|
grpc_slice grpc_slice_new_with_len(void *p, size_t len,
|
174
175
|
void (*destroy)(void *, size_t)) {
|
175
176
|
grpc_slice slice;
|
176
|
-
new_with_len_slice_refcount *rc =
|
177
|
-
|
177
|
+
new_with_len_slice_refcount *rc = (new_with_len_slice_refcount *)gpr_malloc(
|
178
|
+
sizeof(new_with_len_slice_refcount));
|
178
179
|
gpr_ref_init(&rc->refs, 1);
|
179
180
|
rc->rc.vtable = &new_with_len_vtable;
|
180
181
|
rc->rc.sub_refcount = &rc->rc;
|
@@ -183,7 +184,7 @@ grpc_slice grpc_slice_new_with_len(void *p, size_t len,
|
|
183
184
|
rc->user_length = len;
|
184
185
|
|
185
186
|
slice.refcount = &rc->rc;
|
186
|
-
slice.data.refcounted.bytes = p;
|
187
|
+
slice.data.refcounted.bytes = (uint8_t *)p;
|
187
188
|
slice.data.refcounted.length = len;
|
188
189
|
return slice;
|
189
190
|
}
|
@@ -205,12 +206,12 @@ typedef struct {
|
|
205
206
|
} malloc_refcount;
|
206
207
|
|
207
208
|
static void malloc_ref(void *p) {
|
208
|
-
malloc_refcount *r = p;
|
209
|
+
malloc_refcount *r = (malloc_refcount *)p;
|
209
210
|
gpr_ref(&r->refs);
|
210
211
|
}
|
211
212
|
|
212
213
|
static void malloc_unref(grpc_exec_ctx *exec_ctx, void *p) {
|
213
|
-
malloc_refcount *r = p;
|
214
|
+
malloc_refcount *r = (malloc_refcount *)p;
|
214
215
|
if (gpr_unref(&r->refs)) {
|
215
216
|
gpr_free(r);
|
216
217
|
}
|
@@ -232,7 +233,8 @@ grpc_slice grpc_slice_malloc_large(size_t length) {
|
|
232
233
|
refcount is a malloc_refcount
|
233
234
|
bytes is an array of bytes of the requested length
|
234
235
|
Both parts are placed in the same allocation returned from gpr_malloc */
|
235
|
-
malloc_refcount *rc =
|
236
|
+
malloc_refcount *rc =
|
237
|
+
(malloc_refcount *)gpr_malloc(sizeof(malloc_refcount) + length);
|
236
238
|
|
237
239
|
/* Initial refcount on rc is 1 - and it's up to the caller to release
|
238
240
|
this reference. */
|
@@ -451,7 +453,7 @@ int grpc_slice_rchr(grpc_slice s, char c) {
|
|
451
453
|
|
452
454
|
int grpc_slice_chr(grpc_slice s, char c) {
|
453
455
|
const char *b = (const char *)GRPC_SLICE_START_PTR(s);
|
454
|
-
const char *p = memchr(b, c, GRPC_SLICE_LENGTH(s));
|
456
|
+
const char *p = (const char *)memchr(b, c, GRPC_SLICE_LENGTH(s));
|
455
457
|
return p == NULL ? -1 : (int)(p - b);
|
456
458
|
}
|
457
459
|
|
@@ -45,11 +45,12 @@ static void maybe_embiggen(grpc_slice_buffer *sb) {
|
|
45
45
|
sb->capacity = GROW(sb->capacity);
|
46
46
|
GPR_ASSERT(sb->capacity > slice_count);
|
47
47
|
if (sb->base_slices == sb->inlined) {
|
48
|
-
sb->base_slices =
|
48
|
+
sb->base_slices =
|
49
|
+
(grpc_slice *)gpr_malloc(sb->capacity * sizeof(grpc_slice));
|
49
50
|
memcpy(sb->base_slices, sb->inlined, slice_count * sizeof(grpc_slice));
|
50
51
|
} else {
|
51
|
-
sb->base_slices =
|
52
|
-
|
52
|
+
sb->base_slices = (grpc_slice *)gpr_realloc(
|
53
|
+
sb->base_slices, sb->capacity * sizeof(grpc_slice));
|
53
54
|
}
|
54
55
|
|
55
56
|
sb->slices = sb->base_slices + slice_offset;
|
@@ -291,7 +292,7 @@ void grpc_slice_buffer_move_first_no_ref(grpc_slice_buffer *src, size_t n,
|
|
291
292
|
void grpc_slice_buffer_move_first_into_buffer(grpc_exec_ctx *exec_ctx,
|
292
293
|
grpc_slice_buffer *src, size_t n,
|
293
294
|
void *dst) {
|
294
|
-
char *dstp = dst;
|
295
|
+
char *dstp = (char *)dst;
|
295
296
|
GPR_ASSERT(src->length >= n);
|
296
297
|
|
297
298
|
while (n > 0) {
|
@@ -60,14 +60,15 @@ grpc_slice_hash_table* grpc_slice_hash_table_create(
|
|
60
60
|
size_t num_entries, grpc_slice_hash_table_entry* entries,
|
61
61
|
void (*destroy_value)(grpc_exec_ctx* exec_ctx, void* value),
|
62
62
|
int (*value_cmp)(void* a, void* b)) {
|
63
|
-
grpc_slice_hash_table* table =
|
63
|
+
grpc_slice_hash_table* table =
|
64
|
+
(grpc_slice_hash_table*)gpr_zalloc(sizeof(*table));
|
64
65
|
gpr_ref_init(&table->refs, 1);
|
65
66
|
table->destroy_value = destroy_value;
|
66
67
|
table->value_cmp = value_cmp;
|
67
68
|
// Keep load factor low to improve performance of lookups.
|
68
69
|
table->size = num_entries * 2;
|
69
70
|
const size_t entry_size = sizeof(grpc_slice_hash_table_entry) * table->size;
|
70
|
-
table->entries = gpr_zalloc(entry_size);
|
71
|
+
table->entries = (grpc_slice_hash_table_entry*)gpr_zalloc(entry_size);
|
71
72
|
for (size_t i = 0; i < num_entries; ++i) {
|
72
73
|
grpc_slice_hash_table_entry* entry = &entries[i];
|
73
74
|
grpc_slice_hash_table_add(table, entry->key, entry->value);
|
@@ -69,7 +69,7 @@ static uint32_t max_static_metadata_hash_probe;
|
|
69
69
|
static uint32_t static_metadata_hash_values[GRPC_STATIC_MDSTR_COUNT];
|
70
70
|
|
71
71
|
static void interned_slice_ref(void *p) {
|
72
|
-
interned_slice_refcount *s = p;
|
72
|
+
interned_slice_refcount *s = (interned_slice_refcount *)p;
|
73
73
|
GPR_ASSERT(gpr_atm_no_barrier_fetch_add(&s->refcnt, 1) > 0);
|
74
74
|
}
|
75
75
|
|
@@ -90,7 +90,7 @@ static void interned_slice_destroy(interned_slice_refcount *s) {
|
|
90
90
|
}
|
91
91
|
|
92
92
|
static void interned_slice_unref(grpc_exec_ctx *exec_ctx, void *p) {
|
93
|
-
interned_slice_refcount *s = p;
|
93
|
+
interned_slice_refcount *s = (interned_slice_refcount *)p;
|
94
94
|
if (1 == gpr_atm_full_fetch_add(&s->refcnt, -1)) {
|
95
95
|
interned_slice_destroy(s);
|
96
96
|
}
|
@@ -129,7 +129,8 @@ static void grow_shard(slice_shard *shard) {
|
|
129
129
|
|
130
130
|
GPR_TIMER_BEGIN("grow_strtab", 0);
|
131
131
|
|
132
|
-
strtab =
|
132
|
+
strtab = (interned_slice_refcount **)gpr_zalloc(
|
133
|
+
sizeof(interned_slice_refcount *) * capacity);
|
133
134
|
|
134
135
|
for (i = 0; i < shard->capacity; i++) {
|
135
136
|
for (s = shard->strs[i]; s; s = next) {
|
@@ -242,7 +243,8 @@ grpc_slice grpc_slice_intern(grpc_slice slice) {
|
|
242
243
|
|
243
244
|
/* not found: create a new string */
|
244
245
|
/* string data goes after the internal_string header */
|
245
|
-
s = gpr_malloc(sizeof(*s) +
|
246
|
+
s = (interned_slice_refcount *)gpr_malloc(sizeof(*s) +
|
247
|
+
GRPC_SLICE_LENGTH(slice));
|
246
248
|
gpr_atm_rel_store(&s->refcnt, 1);
|
247
249
|
s->length = GRPC_SLICE_LENGTH(slice);
|
248
250
|
s->hash = hash;
|
@@ -280,7 +282,8 @@ void grpc_slice_intern_init(void) {
|
|
280
282
|
gpr_mu_init(&shard->mu);
|
281
283
|
shard->count = 0;
|
282
284
|
shard->capacity = INITIAL_SHARD_CAPACITY;
|
283
|
-
shard->strs = gpr_zalloc(sizeof(*shard->strs) *
|
285
|
+
shard->strs = (interned_slice_refcount **)gpr_zalloc(sizeof(*shard->strs) *
|
286
|
+
shard->capacity);
|
284
287
|
}
|
285
288
|
for (size_t i = 0; i < GPR_ARRAY_SIZE(static_metadata_hash); i++) {
|
286
289
|
static_metadata_hash[i].hash = 0;
|
@@ -19,15 +19,37 @@
|
|
19
19
|
#ifndef GRPC_CORE_LIB_SUPPORT_BLOCK_ANNOTATE_H
|
20
20
|
#define GRPC_CORE_LIB_SUPPORT_BLOCK_ANNOTATE_H
|
21
21
|
|
22
|
+
#ifdef __cplusplus
|
23
|
+
extern "C" {
|
24
|
+
#endif
|
25
|
+
|
26
|
+
void gpr_thd_start_blocking_region();
|
27
|
+
void gpr_thd_end_blocking_region();
|
28
|
+
|
29
|
+
#ifdef __cplusplus
|
30
|
+
}
|
31
|
+
#endif
|
32
|
+
|
22
33
|
/* These annotations identify the beginning and end of regions where
|
23
34
|
the code may block for reasons other than synchronization functions.
|
24
35
|
These include poll, epoll, and getaddrinfo. */
|
25
36
|
|
37
|
+
#ifdef GRPC_SCHEDULING_MARK_BLOCKING_REGION
|
38
|
+
#define GRPC_SCHEDULING_START_BLOCKING_REGION \
|
39
|
+
do { \
|
40
|
+
gpr_thd_start_blocking_region(); \
|
41
|
+
} while (0)
|
42
|
+
#define GRPC_SCHEDULING_END_BLOCKING_REGION \
|
43
|
+
do { \
|
44
|
+
gpr_thd_end_blocking_region(); \
|
45
|
+
} while (0)
|
46
|
+
#else
|
26
47
|
#define GRPC_SCHEDULING_START_BLOCKING_REGION \
|
27
48
|
do { \
|
28
49
|
} while (0)
|
29
50
|
#define GRPC_SCHEDULING_END_BLOCKING_REGION \
|
30
51
|
do { \
|
31
52
|
} while (0)
|
53
|
+
#endif
|
32
54
|
|
33
55
|
#endif /* GRPC_CORE_LIB_SUPPORT_BLOCK_ANNOTATE_H */
|
@@ -0,0 +1,62 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2017 gRPC authors.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include "src/core/lib/support/fork.h"
|
20
|
+
|
21
|
+
#include <string.h>
|
22
|
+
|
23
|
+
#include <grpc/support/alloc.h>
|
24
|
+
#include <grpc/support/useful.h>
|
25
|
+
|
26
|
+
#include "src/core/lib/support/env.h"
|
27
|
+
|
28
|
+
/*
|
29
|
+
* NOTE: FORKING IS NOT GENERALLY SUPPORTED, THIS IS ONLY INTENDED TO WORK
|
30
|
+
* AROUND VERY SPECIFIC USE CASES.
|
31
|
+
*/
|
32
|
+
|
33
|
+
static int override_fork_support_enabled = -1;
|
34
|
+
static int fork_support_enabled;
|
35
|
+
|
36
|
+
void grpc_fork_support_init() {
|
37
|
+
#ifdef GRPC_ENABLE_FORK_SUPPORT
|
38
|
+
fork_support_enabled = 1;
|
39
|
+
#else
|
40
|
+
fork_support_enabled = 0;
|
41
|
+
char *env = gpr_getenv("GRPC_ENABLE_FORK_SUPPORT");
|
42
|
+
if (env != NULL) {
|
43
|
+
static const char *truthy[] = {"yes", "Yes", "YES", "true",
|
44
|
+
"True", "TRUE", "1"};
|
45
|
+
for (size_t i = 0; i < GPR_ARRAY_SIZE(truthy); i++) {
|
46
|
+
if (0 == strcmp(env, truthy[i])) {
|
47
|
+
fork_support_enabled = 1;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
gpr_free(env);
|
51
|
+
}
|
52
|
+
#endif
|
53
|
+
if (override_fork_support_enabled != -1) {
|
54
|
+
fork_support_enabled = override_fork_support_enabled;
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
int grpc_fork_support_enabled() { return fork_support_enabled; }
|
59
|
+
|
60
|
+
void grpc_enable_fork_support(int enable) {
|
61
|
+
override_fork_support_enabled = enable;
|
62
|
+
}
|