grpc 1.1.2 → 1.2.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 +1257 -404
- data/etc/roots.pem +189 -102
- data/include/grpc/census.h +7 -7
- data/include/grpc/compression.h +4 -4
- data/include/grpc/grpc.h +13 -7
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +26 -9
- data/include/grpc/impl/codegen/grpc_types.h +39 -30
- data/include/grpc/impl/codegen/slice.h +24 -6
- data/include/grpc/impl/codegen/sync.h +8 -0
- data/include/grpc/load_reporting.h +63 -0
- data/include/grpc/slice.h +37 -1
- data/include/grpc/slice_buffer.h +7 -0
- data/include/grpc/support/alloc.h +3 -0
- data/include/grpc/support/useful.h +3 -0
- data/src/core/ext/census/gen/census.pb.h +1 -1
- data/src/core/ext/census/gen/trace_context.pb.c +9 -36
- data/src/core/ext/census/gen/trace_context.pb.h +20 -26
- data/src/core/ext/census/grpc_filter.c +3 -5
- data/src/core/ext/census/trace_context.c +1 -1
- data/src/core/ext/census/trace_context.h +3 -0
- data/src/core/ext/census/trace_label.h +61 -0
- data/src/core/ext/census/trace_propagation.h +63 -0
- data/src/core/ext/census/trace_status.h +45 -0
- data/src/core/ext/census/trace_string.h +50 -0
- data/src/core/ext/census/tracing.c +31 -11
- data/src/core/ext/census/tracing.h +124 -0
- data/src/core/ext/client_channel/client_channel.c +456 -368
- data/src/core/ext/client_channel/client_channel.h +4 -0
- data/src/core/ext/client_channel/client_channel_plugin.c +6 -1
- data/src/core/ext/client_channel/connector.c +3 -3
- data/src/core/ext/client_channel/connector.h +4 -3
- data/src/core/ext/client_channel/http_connect_handshaker.c +62 -72
- data/src/core/ext/client_channel/http_connect_handshaker.h +7 -10
- data/src/core/ext/client_channel/http_proxy.c +125 -0
- data/src/core/ext/client_channel/http_proxy.h +39 -0
- data/src/core/ext/client_channel/lb_policy.c +56 -35
- data/src/core/ext/client_channel/lb_policy.h +46 -39
- data/src/core/ext/client_channel/lb_policy_factory.h +1 -0
- data/src/core/ext/client_channel/parse_address.c +32 -6
- data/src/core/ext/client_channel/proxy_mapper.c +63 -0
- data/src/core/ext/client_channel/proxy_mapper.h +89 -0
- data/src/core/ext/client_channel/proxy_mapper_registry.c +133 -0
- data/src/core/ext/client_channel/proxy_mapper_registry.h +59 -0
- data/src/core/ext/client_channel/resolver.c +16 -9
- data/src/core/ext/client_channel/resolver.h +23 -12
- data/src/core/ext/client_channel/resolver_factory.h +1 -0
- data/src/core/ext/client_channel/resolver_registry.c +15 -11
- data/src/core/ext/client_channel/resolver_registry.h +5 -3
- data/src/core/ext/client_channel/subchannel.c +44 -27
- data/src/core/ext/client_channel/subchannel.h +6 -2
- data/src/core/ext/client_channel/uri_parser.c +26 -14
- data/src/core/ext/client_channel/uri_parser.h +3 -1
- data/src/core/ext/lb_policy/grpclb/grpclb.c +220 -209
- data/src/core/ext/lb_policy/grpclb/grpclb_channel.h +56 -0
- data/src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c +107 -0
- data/src/core/ext/lb_policy/grpclb/load_balancer_api.c +3 -6
- data/src/core/ext/lb_policy/pick_first/pick_first.c +71 -116
- data/src/core/ext/lb_policy/round_robin/round_robin.c +52 -67
- data/src/core/ext/load_reporting/load_reporting.c +20 -0
- data/src/core/ext/load_reporting/load_reporting.h +1 -16
- data/src/core/ext/load_reporting/load_reporting_filter.c +28 -54
- data/src/core/ext/resolver/dns/native/dns_resolver.c +31 -45
- data/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +20 -29
- data/src/core/ext/transport/chttp2/client/chttp2_connector.c +11 -8
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +11 -2
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +143 -46
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +12 -50
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +1 -1
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +1 -1
- data/src/core/ext/transport/chttp2/transport/bin_decoder.c +7 -7
- data/src/core/ext/transport/chttp2/transport/bin_encoder.c +1 -2
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +1 -2
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +0 -3
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +606 -374
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +17 -5
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +9 -13
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +12 -11
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +5 -6
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +100 -53
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +126 -70
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +13 -7
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +22 -19
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +6 -6
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +23 -11
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +6 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +169 -42
- data/src/core/ext/transport/chttp2/transport/parsing.c +98 -41
- data/src/core/ext/transport/chttp2/transport/stream_lists.c +29 -14
- data/src/core/ext/transport/chttp2/transport/writing.c +137 -15
- data/src/core/lib/channel/channel_stack.c +14 -44
- data/src/core/lib/channel/channel_stack.h +10 -17
- data/src/core/lib/channel/channel_stack_builder.c +2 -3
- data/src/core/lib/channel/compress_filter.c +54 -46
- data/src/core/lib/channel/connected_channel.c +4 -4
- data/src/core/lib/channel/connected_channel.h +5 -0
- data/src/core/lib/channel/context.h +3 -0
- data/src/core/lib/channel/deadline_filter.c +61 -61
- data/src/core/lib/channel/deadline_filter.h +8 -5
- data/src/core/lib/channel/handshaker.c +47 -7
- data/src/core/lib/channel/handshaker.h +21 -3
- data/src/core/lib/channel/http_client_filter.c +149 -99
- data/src/core/lib/channel/http_server_filter.c +163 -147
- data/src/core/lib/channel/message_size_filter.c +15 -10
- data/src/core/lib/compression/algorithm_metadata.h +4 -4
- data/src/core/lib/compression/compression.c +17 -23
- data/src/core/lib/http/httpcli.c +3 -2
- data/src/core/lib/http/httpcli.h +2 -1
- data/src/core/lib/http/httpcli_security_connector.c +2 -3
- data/src/core/lib/http/parser.c +2 -2
- data/src/core/lib/iomgr/closure.c +6 -3
- data/src/core/lib/iomgr/closure.h +4 -2
- data/src/core/lib/iomgr/combiner.c +35 -5
- data/src/core/lib/iomgr/combiner.h +21 -2
- data/src/core/lib/iomgr/endpoint.c +3 -2
- data/src/core/lib/iomgr/endpoint.h +3 -2
- data/src/core/lib/iomgr/error.c +60 -94
- data/src/core/lib/iomgr/error.h +7 -10
- data/src/core/lib/iomgr/error_internal.h +54 -0
- data/src/core/lib/iomgr/ev_epoll_linux.c +253 -109
- data/src/core/lib/iomgr/ev_poll_posix.c +61 -29
- data/src/core/lib/iomgr/ev_posix.c +7 -8
- data/src/core/lib/iomgr/ev_posix.h +4 -4
- data/src/core/lib/iomgr/exec_ctx.c +11 -6
- data/src/core/lib/iomgr/exec_ctx.h +11 -14
- data/src/core/lib/iomgr/executor.c +2 -2
- data/src/core/lib/iomgr/load_file.c +1 -1
- data/src/core/lib/iomgr/network_status_tracker.c +5 -81
- data/src/core/lib/iomgr/pollset.h +1 -3
- data/src/core/lib/iomgr/pollset_set.h +2 -1
- data/src/core/lib/iomgr/pollset_set_uv.c +2 -1
- data/src/core/lib/iomgr/pollset_set_windows.c +2 -1
- data/src/core/lib/iomgr/pollset_uv.c +25 -11
- data/src/core/lib/iomgr/pollset_windows.c +0 -11
- data/src/core/lib/iomgr/resolve_address_uv.c +50 -2
- data/src/core/lib/iomgr/resource_quota.c +41 -11
- data/src/core/lib/iomgr/resource_quota.h +6 -0
- data/src/core/lib/iomgr/sockaddr_utils.c +33 -17
- data/src/core/lib/iomgr/sockaddr_utils.h +4 -0
- data/src/core/lib/iomgr/tcp_client_posix.c +2 -3
- data/src/core/lib/iomgr/tcp_client_uv.c +1 -3
- data/src/core/lib/iomgr/tcp_client_windows.c +21 -6
- data/src/core/lib/iomgr/tcp_posix.c +4 -5
- data/src/core/lib/iomgr/tcp_server_posix.c +269 -94
- data/src/core/lib/iomgr/tcp_server_windows.c +1 -1
- data/src/core/lib/iomgr/tcp_uv.c +11 -5
- data/src/core/lib/iomgr/tcp_windows.c +20 -7
- data/src/core/lib/iomgr/timer_generic.c +15 -22
- data/src/core/lib/iomgr/timer_generic.h +1 -1
- data/src/core/lib/iomgr/timer_uv.c +10 -6
- data/src/core/lib/iomgr/timer_uv.h +1 -1
- data/src/core/lib/iomgr/udp_server.c +45 -6
- data/src/core/lib/iomgr/udp_server.h +7 -1
- data/src/core/lib/iomgr/unix_sockets_posix.c +11 -1
- data/src/core/lib/json/json.c +1 -2
- data/src/core/lib/profiling/basic_timers.c +17 -3
- data/src/core/lib/security/context/security_context.c +3 -10
- data/src/core/lib/security/credentials/composite/composite_credentials.c +4 -8
- data/src/core/lib/security/credentials/credentials.c +48 -2
- data/src/core/lib/security/credentials/credentials.h +13 -0
- data/src/core/lib/security/credentials/credentials_metadata.c +1 -2
- data/src/core/lib/security/credentials/fake/fake_credentials.c +6 -8
- data/src/core/lib/security/credentials/fake/fake_credentials.h +15 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +3 -3
- data/src/core/lib/security/credentials/iam/iam_credentials.c +1 -2
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +1 -2
- data/src/core/lib/security/credentials/jwt/jwt_verifier.c +5 -8
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +3 -5
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +15 -13
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +2 -4
- data/src/core/lib/security/transport/client_auth_filter.c +72 -47
- data/src/core/lib/security/transport/lb_targets_info.c +70 -0
- data/src/core/lib/security/transport/lb_targets_info.h +47 -0
- data/src/core/lib/security/transport/secure_endpoint.c +3 -3
- data/src/core/lib/security/transport/security_connector.c +125 -28
- data/src/core/lib/security/transport/security_connector.h +4 -3
- data/src/core/lib/security/transport/security_handshaker.c +13 -9
- data/src/core/lib/security/transport/server_auth_filter.c +31 -40
- data/src/core/lib/security/util/b64.c +1 -1
- data/src/core/lib/slice/slice.c +110 -20
- data/src/core/lib/slice/slice_buffer.c +92 -39
- data/src/core/lib/{transport/mdstr_hash_table.c → slice/slice_hash_table.c} +40 -33
- data/src/core/lib/{transport/mdstr_hash_table.h → slice/slice_hash_table.h} +21 -21
- data/src/core/lib/slice/slice_intern.c +346 -0
- data/src/core/lib/slice/slice_internal.h +15 -0
- data/src/core/lib/slice/slice_string_helpers.c +5 -0
- data/src/core/lib/slice/slice_string_helpers.h +5 -0
- data/src/core/lib/support/alloc.c +26 -1
- data/src/core/lib/support/cmdline.c +2 -4
- data/src/core/lib/support/cpu_posix.c +2 -7
- data/src/core/lib/support/histogram.c +1 -2
- data/src/core/lib/support/log_posix.c +8 -4
- data/src/core/lib/support/spinlock.h +52 -0
- data/src/core/lib/support/subprocess_posix.c +1 -2
- data/src/core/lib/support/sync.c +7 -1
- data/src/core/lib/support/sync_posix.c +9 -0
- data/src/core/lib/support/time_windows.c +7 -1
- data/src/core/lib/surface/call.c +647 -629
- data/src/core/lib/surface/call.h +4 -1
- data/src/core/lib/surface/call_details.c +8 -2
- data/src/core/lib/surface/call_log_batch.c +17 -6
- data/src/core/lib/surface/channel.c +49 -59
- data/src/core/lib/surface/channel.h +5 -6
- data/src/core/lib/surface/completion_queue.c +16 -45
- data/src/core/lib/surface/completion_queue.h +0 -3
- data/src/core/lib/surface/init.c +6 -2
- data/src/core/lib/surface/init_secure.c +1 -1
- data/src/core/lib/surface/lame_client.c +14 -4
- data/src/core/lib/surface/server.c +79 -82
- data/src/core/lib/surface/validate_metadata.c +46 -15
- data/src/core/lib/surface/validate_metadata.h +43 -0
- data/src/core/lib/surface/version.c +2 -2
- data/src/core/lib/transport/bdp_estimator.c +104 -0
- data/src/core/lib/transport/bdp_estimator.h +76 -0
- data/src/core/lib/transport/connectivity_state.c +33 -13
- data/src/core/lib/transport/connectivity_state.h +15 -5
- data/src/core/lib/transport/error_utils.c +124 -0
- data/src/core/lib/transport/error_utils.h +56 -0
- data/src/core/{ext/transport/chttp2 → lib}/transport/http2_errors.h +18 -18
- data/src/core/lib/transport/metadata.c +259 -503
- data/src/core/lib/transport/metadata.h +69 -68
- data/src/core/lib/transport/metadata_batch.c +183 -63
- data/src/core/lib/transport/metadata_batch.h +50 -26
- data/src/core/lib/transport/pid_controller.c +28 -8
- data/src/core/lib/transport/pid_controller.h +15 -2
- data/src/core/lib/transport/service_config.c +21 -18
- data/src/core/lib/transport/service_config.h +5 -5
- data/src/core/lib/transport/static_metadata.c +753 -112
- data/src/core/lib/transport/static_metadata.h +403 -264
- data/src/core/{ext/transport/chttp2 → lib}/transport/status_conversion.c +18 -20
- data/src/core/{ext/transport/chttp2 → lib}/transport/status_conversion.h +9 -10
- data/src/core/lib/transport/timeout_encoding.c +11 -9
- data/src/core/lib/transport/timeout_encoding.h +3 -1
- data/src/core/lib/transport/transport.c +47 -87
- data/src/core/lib/transport/transport.h +20 -25
- data/src/core/lib/transport/transport_op_string.c +7 -19
- data/src/core/lib/tsi/fake_transport_security.c +2 -4
- data/src/core/lib/tsi/ssl_transport_security.c +7 -16
- data/src/core/lib/tsi/transport_security.c +2 -4
- data/src/ruby/ext/grpc/extconf.rb +4 -1
- data/src/ruby/ext/grpc/rb_byte_buffer.c +7 -0
- data/src/ruby/ext/grpc/rb_byte_buffer.h +3 -0
- data/src/ruby/ext/grpc/rb_call.c +47 -46
- data/src/ruby/ext/grpc/rb_channel.c +21 -6
- data/src/ruby/ext/grpc/rb_compression_options.c +9 -6
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +36 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +59 -8
- data/src/ruby/ext/grpc/rb_server.c +6 -4
- data/src/ruby/lib/grpc/generic/client_stub.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- metadata +33 -9
@@ -0,0 +1,39 @@
|
|
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
|
+
#ifndef GRPC_CORE_EXT_CLIENT_CHANNEL_HTTP_PROXY_H
|
35
|
+
#define GRPC_CORE_EXT_CLIENT_CHANNEL_HTTP_PROXY_H
|
36
|
+
|
37
|
+
void grpc_register_http_proxy_mapper();
|
38
|
+
|
39
|
+
#endif /* GRPC_CORE_EXT_CLIENT_CHANNEL_HTTP_PROXY_H */
|
@@ -32,14 +32,17 @@
|
|
32
32
|
*/
|
33
33
|
|
34
34
|
#include "src/core/ext/client_channel/lb_policy.h"
|
35
|
+
#include "src/core/lib/iomgr/combiner.h"
|
35
36
|
|
36
37
|
#define WEAK_REF_BITS 16
|
37
38
|
|
38
39
|
void grpc_lb_policy_init(grpc_lb_policy *policy,
|
39
|
-
const grpc_lb_policy_vtable *vtable
|
40
|
+
const grpc_lb_policy_vtable *vtable,
|
41
|
+
grpc_combiner *combiner) {
|
40
42
|
policy->vtable = vtable;
|
41
43
|
gpr_atm_no_barrier_store(&policy->ref_pair, 1 << WEAK_REF_BITS);
|
42
44
|
policy->interested_parties = grpc_pollset_set_create();
|
45
|
+
policy->combiner = GRPC_COMBINER_REF(combiner, "lb_policy");
|
43
46
|
}
|
44
47
|
|
45
48
|
#ifdef GRPC_LB_POLICY_REFCOUNT_DEBUG
|
@@ -71,6 +74,13 @@ void grpc_lb_policy_ref(grpc_lb_policy *policy REF_FUNC_EXTRA_ARGS) {
|
|
71
74
|
ref_mutate(policy, 1 << WEAK_REF_BITS, 0 REF_MUTATE_PASS_ARGS("STRONG_REF"));
|
72
75
|
}
|
73
76
|
|
77
|
+
static void shutdown_locked(grpc_exec_ctx *exec_ctx, void *arg,
|
78
|
+
grpc_error *error) {
|
79
|
+
grpc_lb_policy *policy = arg;
|
80
|
+
policy->vtable->shutdown_locked(exec_ctx, policy);
|
81
|
+
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, policy, "strong-unref");
|
82
|
+
}
|
83
|
+
|
74
84
|
void grpc_lb_policy_unref(grpc_exec_ctx *exec_ctx,
|
75
85
|
grpc_lb_policy *policy REF_FUNC_EXTRA_ARGS) {
|
76
86
|
gpr_atm old_val =
|
@@ -79,10 +89,15 @@ void grpc_lb_policy_unref(grpc_exec_ctx *exec_ctx,
|
|
79
89
|
gpr_atm mask = ~(gpr_atm)((1 << WEAK_REF_BITS) - 1);
|
80
90
|
gpr_atm check = 1 << WEAK_REF_BITS;
|
81
91
|
if ((old_val & mask) == check) {
|
82
|
-
|
92
|
+
grpc_closure_sched(
|
93
|
+
exec_ctx,
|
94
|
+
grpc_closure_create(shutdown_locked, policy,
|
95
|
+
grpc_combiner_scheduler(policy->combiner, false)),
|
96
|
+
GRPC_ERROR_NONE);
|
97
|
+
} else {
|
98
|
+
grpc_lb_policy_weak_unref(exec_ctx,
|
99
|
+
policy REF_FUNC_PASS_ARGS("strong-unref"));
|
83
100
|
}
|
84
|
-
grpc_lb_policy_weak_unref(exec_ctx,
|
85
|
-
policy REF_FUNC_PASS_ARGS("strong-unref"));
|
86
101
|
}
|
87
102
|
|
88
103
|
void grpc_lb_policy_weak_ref(grpc_lb_policy *policy REF_FUNC_EXTRA_ARGS) {
|
@@ -94,53 +109,59 @@ void grpc_lb_policy_weak_unref(grpc_exec_ctx *exec_ctx,
|
|
94
109
|
gpr_atm old_val =
|
95
110
|
ref_mutate(policy, -(gpr_atm)1, 1 REF_MUTATE_PASS_ARGS("WEAK_UNREF"));
|
96
111
|
if (old_val == 1) {
|
97
|
-
grpc_pollset_set_destroy(policy->interested_parties);
|
112
|
+
grpc_pollset_set_destroy(exec_ctx, policy->interested_parties);
|
113
|
+
grpc_combiner *combiner = policy->combiner;
|
98
114
|
policy->vtable->destroy(exec_ctx, policy);
|
115
|
+
GRPC_COMBINER_UNREF(exec_ctx, combiner, "lb_policy");
|
99
116
|
}
|
100
117
|
}
|
101
118
|
|
102
|
-
int
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
return policy->vtable->
|
107
|
-
|
119
|
+
int grpc_lb_policy_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
120
|
+
const grpc_lb_policy_pick_args *pick_args,
|
121
|
+
grpc_connected_subchannel **target,
|
122
|
+
void **user_data, grpc_closure *on_complete) {
|
123
|
+
return policy->vtable->pick_locked(exec_ctx, policy, pick_args, target,
|
124
|
+
user_data, on_complete);
|
108
125
|
}
|
109
126
|
|
110
|
-
void
|
111
|
-
|
112
|
-
|
113
|
-
|
127
|
+
void grpc_lb_policy_cancel_pick_locked(grpc_exec_ctx *exec_ctx,
|
128
|
+
grpc_lb_policy *policy,
|
129
|
+
grpc_connected_subchannel **target,
|
130
|
+
grpc_error *error) {
|
131
|
+
policy->vtable->cancel_pick_locked(exec_ctx, policy, target, error);
|
114
132
|
}
|
115
133
|
|
116
|
-
void
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
policy->vtable->
|
122
|
-
|
134
|
+
void grpc_lb_policy_cancel_picks_locked(grpc_exec_ctx *exec_ctx,
|
135
|
+
grpc_lb_policy *policy,
|
136
|
+
uint32_t initial_metadata_flags_mask,
|
137
|
+
uint32_t initial_metadata_flags_eq,
|
138
|
+
grpc_error *error) {
|
139
|
+
policy->vtable->cancel_picks_locked(exec_ctx, policy,
|
140
|
+
initial_metadata_flags_mask,
|
141
|
+
initial_metadata_flags_eq, error);
|
123
142
|
}
|
124
143
|
|
125
|
-
void
|
126
|
-
|
144
|
+
void grpc_lb_policy_exit_idle_locked(grpc_exec_ctx *exec_ctx,
|
145
|
+
grpc_lb_policy *policy) {
|
146
|
+
policy->vtable->exit_idle_locked(exec_ctx, policy);
|
127
147
|
}
|
128
148
|
|
129
|
-
void
|
130
|
-
|
131
|
-
|
149
|
+
void grpc_lb_policy_ping_one_locked(grpc_exec_ctx *exec_ctx,
|
150
|
+
grpc_lb_policy *policy,
|
151
|
+
grpc_closure *closure) {
|
152
|
+
policy->vtable->ping_one_locked(exec_ctx, policy, closure);
|
132
153
|
}
|
133
154
|
|
134
|
-
void
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
155
|
+
void grpc_lb_policy_notify_on_state_change_locked(
|
156
|
+
grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
157
|
+
grpc_connectivity_state *state, grpc_closure *closure) {
|
158
|
+
policy->vtable->notify_on_state_change_locked(exec_ctx, policy, state,
|
159
|
+
closure);
|
139
160
|
}
|
140
161
|
|
141
|
-
grpc_connectivity_state
|
162
|
+
grpc_connectivity_state grpc_lb_policy_check_connectivity_locked(
|
142
163
|
grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
143
164
|
grpc_error **connectivity_error) {
|
144
|
-
return policy->vtable->
|
145
|
-
|
165
|
+
return policy->vtable->check_connectivity_locked(exec_ctx, policy,
|
166
|
+
connectivity_error);
|
146
167
|
}
|
@@ -51,6 +51,8 @@ struct grpc_lb_policy {
|
|
51
51
|
gpr_atm ref_pair;
|
52
52
|
/* owned pointer to interested parties in load balancing decisions */
|
53
53
|
grpc_pollset_set *interested_parties;
|
54
|
+
/* combiner under which lb_policy actions take place */
|
55
|
+
grpc_combiner *combiner;
|
54
56
|
};
|
55
57
|
|
56
58
|
/** Extra arguments for an LB pick */
|
@@ -69,42 +71,44 @@ typedef struct grpc_lb_policy_pick_args {
|
|
69
71
|
|
70
72
|
struct grpc_lb_policy_vtable {
|
71
73
|
void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy);
|
72
|
-
void (*
|
74
|
+
void (*shutdown_locked)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy);
|
73
75
|
|
74
76
|
/** \see grpc_lb_policy_pick */
|
75
|
-
int (*
|
76
|
-
|
77
|
-
|
78
|
-
|
77
|
+
int (*pick_locked)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
78
|
+
const grpc_lb_policy_pick_args *pick_args,
|
79
|
+
grpc_connected_subchannel **target, void **user_data,
|
80
|
+
grpc_closure *on_complete);
|
79
81
|
|
80
82
|
/** \see grpc_lb_policy_cancel_pick */
|
81
|
-
void (*
|
82
|
-
|
83
|
+
void (*cancel_pick_locked)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
84
|
+
grpc_connected_subchannel **target,
|
85
|
+
grpc_error *error);
|
83
86
|
|
84
87
|
/** \see grpc_lb_policy_cancel_picks */
|
85
|
-
void (*
|
86
|
-
|
87
|
-
|
88
|
+
void (*cancel_picks_locked)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
89
|
+
uint32_t initial_metadata_flags_mask,
|
90
|
+
uint32_t initial_metadata_flags_eq,
|
91
|
+
grpc_error *error);
|
88
92
|
|
89
93
|
/** \see grpc_lb_policy_ping_one */
|
90
|
-
void (*
|
91
|
-
|
94
|
+
void (*ping_one_locked)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
95
|
+
grpc_closure *closure);
|
92
96
|
|
93
97
|
/** Try to enter a READY connectivity state */
|
94
|
-
void (*
|
98
|
+
void (*exit_idle_locked)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy);
|
95
99
|
|
96
100
|
/** check the current connectivity of the lb_policy */
|
97
|
-
grpc_connectivity_state (*
|
101
|
+
grpc_connectivity_state (*check_connectivity_locked)(
|
98
102
|
grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
99
103
|
grpc_error **connectivity_error);
|
100
104
|
|
101
105
|
/** call notify when the connectivity state of a channel changes from *state.
|
102
106
|
Updates *state with the new state of the policy. Calling with a NULL \a
|
103
107
|
state cancels the subscription. */
|
104
|
-
void (*
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
+
void (*notify_on_state_change_locked)(grpc_exec_ctx *exec_ctx,
|
109
|
+
grpc_lb_policy *policy,
|
110
|
+
grpc_connectivity_state *state,
|
111
|
+
grpc_closure *closure);
|
108
112
|
};
|
109
113
|
|
110
114
|
/*#define GRPC_LB_POLICY_REFCOUNT_DEBUG*/
|
@@ -144,7 +148,8 @@ void grpc_lb_policy_weak_unref(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy);
|
|
144
148
|
|
145
149
|
/** called by concrete implementations to initialize the base struct */
|
146
150
|
void grpc_lb_policy_init(grpc_lb_policy *policy,
|
147
|
-
const grpc_lb_policy_vtable *vtable
|
151
|
+
const grpc_lb_policy_vtable *vtable,
|
152
|
+
grpc_combiner *combiner);
|
148
153
|
|
149
154
|
/** Finds an appropriate subchannel for a call, based on \a pick_args.
|
150
155
|
|
@@ -159,43 +164,45 @@ void grpc_lb_policy_init(grpc_lb_policy *policy,
|
|
159
164
|
|
160
165
|
Any IO should be done under the \a interested_parties \a grpc_pollset_set
|
161
166
|
in the \a grpc_lb_policy struct. */
|
162
|
-
int
|
163
|
-
|
164
|
-
|
165
|
-
|
167
|
+
int grpc_lb_policy_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
168
|
+
const grpc_lb_policy_pick_args *pick_args,
|
169
|
+
grpc_connected_subchannel **target,
|
170
|
+
void **user_data, grpc_closure *on_complete);
|
166
171
|
|
167
172
|
/** Perform a connected subchannel ping (see \a grpc_connected_subchannel_ping)
|
168
173
|
against one of the connected subchannels managed by \a policy. */
|
169
|
-
void
|
170
|
-
|
174
|
+
void grpc_lb_policy_ping_one_locked(grpc_exec_ctx *exec_ctx,
|
175
|
+
grpc_lb_policy *policy,
|
176
|
+
grpc_closure *closure);
|
171
177
|
|
172
178
|
/** Cancel picks for \a target.
|
173
179
|
The \a on_complete callback of the pending picks will be invoked with \a
|
174
180
|
*target set to NULL. */
|
175
|
-
void
|
176
|
-
|
177
|
-
|
181
|
+
void grpc_lb_policy_cancel_pick_locked(grpc_exec_ctx *exec_ctx,
|
182
|
+
grpc_lb_policy *policy,
|
183
|
+
grpc_connected_subchannel **target,
|
184
|
+
grpc_error *error);
|
178
185
|
|
179
186
|
/** Cancel all pending picks for which their \a initial_metadata_flags (as given
|
180
187
|
in the call to \a grpc_lb_policy_pick) matches \a initial_metadata_flags_eq
|
181
188
|
when AND'd with \a initial_metadata_flags_mask */
|
182
|
-
void
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
189
|
+
void grpc_lb_policy_cancel_picks_locked(grpc_exec_ctx *exec_ctx,
|
190
|
+
grpc_lb_policy *policy,
|
191
|
+
uint32_t initial_metadata_flags_mask,
|
192
|
+
uint32_t initial_metadata_flags_eq,
|
193
|
+
grpc_error *error);
|
187
194
|
|
188
195
|
/** Try to enter a READY connectivity state */
|
189
|
-
void
|
196
|
+
void grpc_lb_policy_exit_idle_locked(grpc_exec_ctx *exec_ctx,
|
197
|
+
grpc_lb_policy *policy);
|
190
198
|
|
191
199
|
/* Call notify when the connectivity state of a channel changes from \a *state.
|
192
200
|
* Updates \a *state with the new state of the policy */
|
193
|
-
void
|
194
|
-
|
195
|
-
|
196
|
-
grpc_closure *closure);
|
201
|
+
void grpc_lb_policy_notify_on_state_change_locked(
|
202
|
+
grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
203
|
+
grpc_connectivity_state *state, grpc_closure *closure);
|
197
204
|
|
198
|
-
grpc_connectivity_state
|
205
|
+
grpc_connectivity_state grpc_lb_policy_check_connectivity_locked(
|
199
206
|
grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
200
207
|
grpc_error **connectivity_error);
|
201
208
|
|
@@ -107,6 +107,7 @@ grpc_arg grpc_lb_addresses_create_channel_arg(
|
|
107
107
|
typedef struct grpc_lb_policy_args {
|
108
108
|
grpc_client_channel_factory *client_channel_factory;
|
109
109
|
grpc_channel_args *args;
|
110
|
+
grpc_combiner *combiner;
|
110
111
|
} grpc_lb_policy_args;
|
111
112
|
|
112
113
|
struct grpc_lb_policy_factory_vtable {
|
@@ -44,16 +44,18 @@
|
|
44
44
|
#include <grpc/support/host_port.h>
|
45
45
|
#include <grpc/support/log.h>
|
46
46
|
#include <grpc/support/string_util.h>
|
47
|
+
#include "src/core/lib/support/string.h"
|
47
48
|
|
48
49
|
#ifdef GRPC_HAVE_UNIX_SOCKET
|
49
50
|
|
50
51
|
int parse_unix(grpc_uri *uri, grpc_resolved_address *resolved_addr) {
|
51
52
|
struct sockaddr_un *un = (struct sockaddr_un *)resolved_addr->addr;
|
52
|
-
|
53
|
+
const size_t maxlen = sizeof(un->sun_path);
|
54
|
+
const size_t path_len = strnlen(uri->path, maxlen);
|
55
|
+
if (path_len == maxlen) return 0;
|
53
56
|
un->sun_family = AF_UNIX;
|
54
57
|
strcpy(un->sun_path, uri->path);
|
55
|
-
resolved_addr->len =
|
56
|
-
|
58
|
+
resolved_addr->len = sizeof(*un);
|
57
59
|
return 1;
|
58
60
|
}
|
59
61
|
|
@@ -119,9 +121,33 @@ int parse_ipv6(grpc_uri *uri, grpc_resolved_address *resolved_addr) {
|
|
119
121
|
memset(in6, 0, sizeof(*in6));
|
120
122
|
resolved_addr->len = sizeof(*in6);
|
121
123
|
in6->sin6_family = AF_INET6;
|
122
|
-
|
123
|
-
|
124
|
-
|
124
|
+
|
125
|
+
/* Handle the RFC6874 syntax for IPv6 zone identifiers. */
|
126
|
+
char *host_end = (char *)gpr_memrchr(host, '%', strlen(host));
|
127
|
+
if (host_end != NULL) {
|
128
|
+
GPR_ASSERT(host_end >= host);
|
129
|
+
char host_without_scope[INET6_ADDRSTRLEN];
|
130
|
+
size_t host_without_scope_len = (size_t)(host_end - host);
|
131
|
+
uint32_t sin6_scope_id = 0;
|
132
|
+
strncpy(host_without_scope, host, host_without_scope_len);
|
133
|
+
host_without_scope[host_without_scope_len] = '\0';
|
134
|
+
if (inet_pton(AF_INET6, host_without_scope, &in6->sin6_addr) == 0) {
|
135
|
+
gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host_without_scope);
|
136
|
+
goto done;
|
137
|
+
}
|
138
|
+
if (gpr_parse_bytes_to_uint32(host_end + 1,
|
139
|
+
strlen(host) - host_without_scope_len - 1,
|
140
|
+
&sin6_scope_id) == 0) {
|
141
|
+
gpr_log(GPR_ERROR, "invalid ipv6 scope id: '%s'", host_end + 1);
|
142
|
+
goto done;
|
143
|
+
}
|
144
|
+
// Handle "sin6_scope_id" being type "u_long". See grpc issue ##10027.
|
145
|
+
in6->sin6_scope_id = sin6_scope_id;
|
146
|
+
} else {
|
147
|
+
if (inet_pton(AF_INET6, host, &in6->sin6_addr) == 0) {
|
148
|
+
gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host);
|
149
|
+
goto done;
|
150
|
+
}
|
125
151
|
}
|
126
152
|
|
127
153
|
if (port != NULL) {
|
@@ -0,0 +1,63 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2017, 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 "src/core/ext/client_channel/proxy_mapper.h"
|
35
|
+
|
36
|
+
void grpc_proxy_mapper_init(const grpc_proxy_mapper_vtable* vtable,
|
37
|
+
grpc_proxy_mapper* mapper) {
|
38
|
+
mapper->vtable = vtable;
|
39
|
+
}
|
40
|
+
|
41
|
+
bool grpc_proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
|
42
|
+
grpc_proxy_mapper* mapper,
|
43
|
+
const char* server_uri,
|
44
|
+
const grpc_channel_args* args,
|
45
|
+
char** name_to_resolve,
|
46
|
+
grpc_channel_args** new_args) {
|
47
|
+
return mapper->vtable->map_name(exec_ctx, mapper, server_uri, args,
|
48
|
+
name_to_resolve, new_args);
|
49
|
+
}
|
50
|
+
|
51
|
+
bool grpc_proxy_mapper_map_address(grpc_exec_ctx* exec_ctx,
|
52
|
+
grpc_proxy_mapper* mapper,
|
53
|
+
const grpc_resolved_address* address,
|
54
|
+
const grpc_channel_args* args,
|
55
|
+
grpc_resolved_address** new_address,
|
56
|
+
grpc_channel_args** new_args) {
|
57
|
+
return mapper->vtable->map_address(exec_ctx, mapper, address, args,
|
58
|
+
new_address, new_args);
|
59
|
+
}
|
60
|
+
|
61
|
+
void grpc_proxy_mapper_destroy(grpc_proxy_mapper* mapper) {
|
62
|
+
mapper->vtable->destroy(mapper);
|
63
|
+
}
|