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
@@ -42,7 +42,8 @@ struct grpc_grpclb_client_stats {
|
|
42
42
|
};
|
43
43
|
|
44
44
|
grpc_grpclb_client_stats* grpc_grpclb_client_stats_create() {
|
45
|
-
grpc_grpclb_client_stats* client_stats =
|
45
|
+
grpc_grpclb_client_stats* client_stats =
|
46
|
+
(grpc_grpclb_client_stats*)gpr_zalloc(sizeof(*client_stats));
|
46
47
|
gpr_ref_init(&client_stats->refs, 1);
|
47
48
|
return client_stats;
|
48
49
|
}
|
@@ -88,7 +89,8 @@ void grpc_grpclb_client_stats_add_call_dropped_locked(
|
|
88
89
|
// Record the drop.
|
89
90
|
if (client_stats->drop_token_counts == NULL) {
|
90
91
|
client_stats->drop_token_counts =
|
91
|
-
|
92
|
+
(grpc_grpclb_dropped_call_counts*)gpr_zalloc(
|
93
|
+
sizeof(grpc_grpclb_dropped_call_counts));
|
92
94
|
}
|
93
95
|
grpc_grpclb_dropped_call_counts* drop_token_counts =
|
94
96
|
client_stats->drop_token_counts;
|
@@ -103,9 +105,9 @@ void grpc_grpclb_client_stats_add_call_dropped_locked(
|
|
103
105
|
while (new_num_entries < drop_token_counts->num_entries + 1) {
|
104
106
|
new_num_entries *= 2;
|
105
107
|
}
|
106
|
-
drop_token_counts->token_counts =
|
107
|
-
|
108
|
-
|
108
|
+
drop_token_counts->token_counts = (grpc_grpclb_drop_token_count*)gpr_realloc(
|
109
|
+
drop_token_counts->token_counts,
|
110
|
+
new_num_entries * sizeof(grpc_grpclb_drop_token_count));
|
109
111
|
grpc_grpclb_drop_token_count* new_entry =
|
110
112
|
&drop_token_counts->token_counts[drop_token_counts->num_entries++];
|
111
113
|
new_entry->token = gpr_strdup(token);
|
@@ -25,7 +25,7 @@
|
|
25
25
|
/* invoked once for every Server in ServerList */
|
26
26
|
static bool count_serverlist(pb_istream_t *stream, const pb_field_t *field,
|
27
27
|
void **arg) {
|
28
|
-
grpc_grpclb_serverlist *sl = *arg;
|
28
|
+
grpc_grpclb_serverlist *sl = (grpc_grpclb_serverlist *)*arg;
|
29
29
|
grpc_grpclb_server server;
|
30
30
|
if (!pb_decode(stream, grpc_lb_v1_Server_fields, &server)) {
|
31
31
|
gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(stream));
|
@@ -46,9 +46,10 @@ typedef struct decode_serverlist_arg {
|
|
46
46
|
/* invoked once for every Server in ServerList */
|
47
47
|
static bool decode_serverlist(pb_istream_t *stream, const pb_field_t *field,
|
48
48
|
void **arg) {
|
49
|
-
decode_serverlist_arg *dec_arg = *arg;
|
49
|
+
decode_serverlist_arg *dec_arg = (decode_serverlist_arg *)*arg;
|
50
50
|
GPR_ASSERT(dec_arg->serverlist->num_servers >= dec_arg->decoding_idx);
|
51
|
-
grpc_grpclb_server *server =
|
51
|
+
grpc_grpclb_server *server =
|
52
|
+
(grpc_grpclb_server *)gpr_zalloc(sizeof(grpc_grpclb_server));
|
52
53
|
if (!pb_decode(stream, grpc_lb_v1_Server_fields, server)) {
|
53
54
|
gpr_free(server);
|
54
55
|
gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(stream));
|
@@ -59,7 +60,8 @@ static bool decode_serverlist(pb_istream_t *stream, const pb_field_t *field,
|
|
59
60
|
}
|
60
61
|
|
61
62
|
grpc_grpclb_request *grpc_grpclb_request_create(const char *lb_service_name) {
|
62
|
-
grpc_grpclb_request *req =
|
63
|
+
grpc_grpclb_request *req =
|
64
|
+
(grpc_grpclb_request *)gpr_malloc(sizeof(grpc_grpclb_request));
|
63
65
|
req->has_client_stats = false;
|
64
66
|
req->has_initial_request = true;
|
65
67
|
req->initial_request.has_name = true;
|
@@ -78,14 +80,15 @@ static void populate_timestamp(gpr_timespec timestamp,
|
|
78
80
|
|
79
81
|
static bool encode_string(pb_ostream_t *stream, const pb_field_t *field,
|
80
82
|
void *const *arg) {
|
81
|
-
char *str = *arg;
|
83
|
+
char *str = (char *)*arg;
|
82
84
|
if (!pb_encode_tag_for_field(stream, field)) return false;
|
83
85
|
return pb_encode_string(stream, (uint8_t *)str, strlen(str));
|
84
86
|
}
|
85
87
|
|
86
88
|
static bool encode_drops(pb_ostream_t *stream, const pb_field_t *field,
|
87
89
|
void *const *arg) {
|
88
|
-
grpc_grpclb_dropped_call_counts *drop_entries =
|
90
|
+
grpc_grpclb_dropped_call_counts *drop_entries =
|
91
|
+
(grpc_grpclb_dropped_call_counts *)*arg;
|
89
92
|
if (drop_entries == NULL) return true;
|
90
93
|
for (size_t i = 0; i < drop_entries->num_entries; ++i) {
|
91
94
|
if (!pb_encode_tag_for_field(stream, field)) return false;
|
@@ -104,7 +107,8 @@ static bool encode_drops(pb_ostream_t *stream, const pb_field_t *field,
|
|
104
107
|
|
105
108
|
grpc_grpclb_request *grpc_grpclb_load_report_request_create_locked(
|
106
109
|
grpc_grpclb_client_stats *client_stats) {
|
107
|
-
grpc_grpclb_request *req =
|
110
|
+
grpc_grpclb_request *req =
|
111
|
+
(grpc_grpclb_request *)gpr_zalloc(sizeof(grpc_grpclb_request));
|
108
112
|
req->has_client_stats = true;
|
109
113
|
req->client_stats.has_timestamp = true;
|
110
114
|
populate_timestamp(gpr_now(GPR_CLOCK_REALTIME), &req->client_stats.timestamp);
|
@@ -144,7 +148,8 @@ grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request) {
|
|
144
148
|
void grpc_grpclb_request_destroy(grpc_grpclb_request *request) {
|
145
149
|
if (request->has_client_stats) {
|
146
150
|
grpc_grpclb_dropped_call_counts *drop_entries =
|
147
|
-
|
151
|
+
(grpc_grpclb_dropped_call_counts *)
|
152
|
+
request->client_stats.calls_finished_with_drop.arg;
|
148
153
|
grpc_grpclb_dropped_call_counts_destroy(drop_entries);
|
149
154
|
}
|
150
155
|
gpr_free(request);
|
@@ -166,7 +171,8 @@ grpc_grpclb_initial_response *grpc_grpclb_initial_response_parse(
|
|
166
171
|
if (!res.has_initial_response) return NULL;
|
167
172
|
|
168
173
|
grpc_grpclb_initial_response *initial_res =
|
169
|
-
|
174
|
+
(grpc_grpclb_initial_response *)gpr_malloc(
|
175
|
+
sizeof(grpc_grpclb_initial_response));
|
170
176
|
memcpy(initial_res, &res.initial_response,
|
171
177
|
sizeof(grpc_grpclb_initial_response));
|
172
178
|
|
@@ -179,7 +185,8 @@ grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist(
|
|
179
185
|
pb_istream_from_buffer(GRPC_SLICE_START_PTR(encoded_grpc_grpclb_response),
|
180
186
|
GRPC_SLICE_LENGTH(encoded_grpc_grpclb_response));
|
181
187
|
pb_istream_t stream_at_start = stream;
|
182
|
-
grpc_grpclb_serverlist *sl =
|
188
|
+
grpc_grpclb_serverlist *sl =
|
189
|
+
(grpc_grpclb_serverlist *)gpr_zalloc(sizeof(grpc_grpclb_serverlist));
|
183
190
|
grpc_grpclb_response res;
|
184
191
|
memset(&res, 0, sizeof(grpc_grpclb_response));
|
185
192
|
// First pass: count number of servers.
|
@@ -193,7 +200,8 @@ grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist(
|
|
193
200
|
}
|
194
201
|
// Second pass: populate servers.
|
195
202
|
if (sl->num_servers > 0) {
|
196
|
-
sl->servers =
|
203
|
+
sl->servers = (grpc_grpclb_server **)gpr_zalloc(
|
204
|
+
sizeof(grpc_grpclb_server *) * sl->num_servers);
|
197
205
|
decode_serverlist_arg decode_arg;
|
198
206
|
memset(&decode_arg, 0, sizeof(decode_arg));
|
199
207
|
decode_arg.serverlist = sl;
|
@@ -226,13 +234,16 @@ void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist *serverlist) {
|
|
226
234
|
|
227
235
|
grpc_grpclb_serverlist *grpc_grpclb_serverlist_copy(
|
228
236
|
const grpc_grpclb_serverlist *sl) {
|
229
|
-
grpc_grpclb_serverlist *copy =
|
237
|
+
grpc_grpclb_serverlist *copy =
|
238
|
+
(grpc_grpclb_serverlist *)gpr_zalloc(sizeof(grpc_grpclb_serverlist));
|
230
239
|
copy->num_servers = sl->num_servers;
|
231
240
|
memcpy(©->expiration_interval, &sl->expiration_interval,
|
232
241
|
sizeof(grpc_grpclb_duration));
|
233
|
-
copy->servers =
|
242
|
+
copy->servers = (grpc_grpclb_server **)gpr_malloc(
|
243
|
+
sizeof(grpc_grpclb_server *) * sl->num_servers);
|
234
244
|
for (size_t i = 0; i < sl->num_servers; i++) {
|
235
|
-
copy->servers[i] =
|
245
|
+
copy->servers[i] =
|
246
|
+
(grpc_grpclb_server *)gpr_malloc(sizeof(grpc_grpclb_server));
|
236
247
|
memcpy(copy->servers[i], sl->servers[i], sizeof(grpc_grpclb_server));
|
237
248
|
}
|
238
249
|
return copy;
|
@@ -89,6 +89,7 @@ static void pf_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
|
|
89
89
|
"picked_first_destroy");
|
90
90
|
}
|
91
91
|
grpc_connectivity_state_destroy(exec_ctx, &p->state_tracker);
|
92
|
+
grpc_subchannel_index_unref();
|
92
93
|
if (p->pending_update_args != NULL) {
|
93
94
|
grpc_channel_args_destroy(exec_ctx, p->pending_update_args->args);
|
94
95
|
gpr_free(p->pending_update_args);
|
@@ -217,7 +218,7 @@ static int pf_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
|
217
218
|
if (!p->started_picking) {
|
218
219
|
start_picking_locked(exec_ctx, p);
|
219
220
|
}
|
220
|
-
pp = gpr_malloc(sizeof(*pp));
|
221
|
+
pp = (pending_pick *)gpr_malloc(sizeof(*pp));
|
221
222
|
pp->next = p->pending_picks;
|
222
223
|
pp->target = target;
|
223
224
|
pp->initial_metadata_flags = pick_args->initial_metadata_flags;
|
@@ -296,8 +297,6 @@ static void stop_connectivity_watchers(grpc_exec_ctx *exec_ctx,
|
|
296
297
|
static void pf_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
297
298
|
const grpc_lb_policy_args *args) {
|
298
299
|
pick_first_lb_policy *p = (pick_first_lb_policy *)policy;
|
299
|
-
/* Find the number of backend addresses. We ignore balancer
|
300
|
-
* addresses, since we don't know how to handle them. */
|
301
300
|
const grpc_arg *arg =
|
302
301
|
grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES);
|
303
302
|
if (arg == NULL || arg->type != GRPC_ARG_POINTER) {
|
@@ -316,12 +315,9 @@ static void pf_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
|
316
315
|
}
|
317
316
|
return;
|
318
317
|
}
|
319
|
-
const grpc_lb_addresses *addresses =
|
320
|
-
|
321
|
-
|
322
|
-
if (!addresses->addresses[i].is_balancer) ++num_addrs;
|
323
|
-
}
|
324
|
-
if (num_addrs == 0) {
|
318
|
+
const grpc_lb_addresses *addresses =
|
319
|
+
(const grpc_lb_addresses *)arg->value.pointer.p;
|
320
|
+
if (addresses->num_addresses == 0) {
|
325
321
|
// Empty update. Unsubscribe from all current subchannels and put the
|
326
322
|
// channel in TRANSIENT_FAILURE.
|
327
323
|
grpc_connectivity_state_set(
|
@@ -333,9 +329,10 @@ static void pf_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
|
333
329
|
}
|
334
330
|
if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
|
335
331
|
gpr_log(GPR_INFO, "Pick First %p received update with %lu addresses",
|
336
|
-
(void *)p, (unsigned long)
|
332
|
+
(void *)p, (unsigned long)addresses->num_addresses);
|
337
333
|
}
|
338
|
-
grpc_subchannel_args *sc_args =
|
334
|
+
grpc_subchannel_args *sc_args = (grpc_subchannel_args *)gpr_zalloc(
|
335
|
+
sizeof(*sc_args) * addresses->num_addresses);
|
339
336
|
/* We remove the following keys in order for subchannel keys belonging to
|
340
337
|
* subchannels point to the same address to match. */
|
341
338
|
static const char *keys_to_remove[] = {GRPC_ARG_SUBCHANNEL_ADDRESS,
|
@@ -344,7 +341,8 @@ static void pf_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
|
344
341
|
|
345
342
|
/* Create list of subchannel args for new addresses in \a args. */
|
346
343
|
for (size_t i = 0; i < addresses->num_addresses; i++) {
|
347
|
-
|
344
|
+
// If there were any balancer, we would have chosen grpclb policy instead.
|
345
|
+
GPR_ASSERT(!addresses->addresses[i].is_balancer);
|
348
346
|
if (addresses->addresses[i].user_data != NULL) {
|
349
347
|
gpr_log(GPR_ERROR,
|
350
348
|
"This LB policy doesn't support user data. It will be ignored");
|
@@ -396,7 +394,8 @@ static void pf_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
|
396
394
|
grpc_channel_args_destroy(exec_ctx, p->pending_update_args->args);
|
397
395
|
gpr_free(p->pending_update_args);
|
398
396
|
}
|
399
|
-
p->pending_update_args =
|
397
|
+
p->pending_update_args =
|
398
|
+
(grpc_lb_policy_args *)gpr_zalloc(sizeof(*p->pending_update_args));
|
400
399
|
p->pending_update_args->client_channel_factory =
|
401
400
|
args->client_channel_factory;
|
402
401
|
p->pending_update_args->args = grpc_channel_args_copy(args->args);
|
@@ -405,7 +404,7 @@ static void pf_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
|
405
404
|
}
|
406
405
|
/* Create the subchannels for the new subchannel args/addresses. */
|
407
406
|
grpc_subchannel **new_subchannels =
|
408
|
-
gpr_zalloc(sizeof(*new_subchannels) * sc_args_count);
|
407
|
+
(grpc_subchannel **)gpr_zalloc(sizeof(*new_subchannels) * sc_args_count);
|
409
408
|
size_t num_new_subchannels = 0;
|
410
409
|
for (size_t i = 0; i < sc_args_count; i++) {
|
411
410
|
grpc_subchannel *subchannel = grpc_client_channel_factory_create_subchannel(
|
@@ -460,7 +459,7 @@ static void pf_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
|
460
459
|
|
461
460
|
static void pf_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg,
|
462
461
|
grpc_error *error) {
|
463
|
-
pick_first_lb_policy *p = arg;
|
462
|
+
pick_first_lb_policy *p = (pick_first_lb_policy *)arg;
|
464
463
|
grpc_subchannel *selected_subchannel;
|
465
464
|
pending_pick *pp;
|
466
465
|
|
@@ -682,12 +681,13 @@ static grpc_lb_policy *create_pick_first(grpc_exec_ctx *exec_ctx,
|
|
682
681
|
grpc_lb_policy_factory *factory,
|
683
682
|
grpc_lb_policy_args *args) {
|
684
683
|
GPR_ASSERT(args->client_channel_factory != NULL);
|
685
|
-
pick_first_lb_policy *p = gpr_zalloc(sizeof(*p));
|
684
|
+
pick_first_lb_policy *p = (pick_first_lb_policy *)gpr_zalloc(sizeof(*p));
|
686
685
|
if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) {
|
687
686
|
gpr_log(GPR_DEBUG, "Pick First %p created.", (void *)p);
|
688
687
|
}
|
689
688
|
pf_update_locked(exec_ctx, &p->base, args);
|
690
689
|
grpc_lb_policy_init(&p->base, &pick_first_lb_policy_vtable, args->combiner);
|
690
|
+
grpc_subchannel_index_ref();
|
691
691
|
GRPC_CLOSURE_INIT(&p->connectivity_changed, pf_connectivity_changed_locked, p,
|
692
692
|
grpc_combiner_scheduler(args->combiner));
|
693
693
|
return &p->base;
|
@@ -30,6 +30,7 @@
|
|
30
30
|
|
31
31
|
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
|
32
32
|
#include "src/core/ext/filters/client_channel/subchannel.h"
|
33
|
+
#include "src/core/ext/filters/client_channel/subchannel_index.h"
|
33
34
|
#include "src/core/lib/channel/channel_args.h"
|
34
35
|
#include "src/core/lib/debug/trace.h"
|
35
36
|
#include "src/core/lib/iomgr/combiner.h"
|
@@ -74,9 +75,6 @@ typedef struct round_robin_lb_policy {
|
|
74
75
|
bool started_picking;
|
75
76
|
/** are we shutting down? */
|
76
77
|
bool shutdown;
|
77
|
-
/** has the policy gotten into the GRPC_CHANNEL_SHUTDOWN? No picks can be
|
78
|
-
* service after this point, the policy will never transition out. */
|
79
|
-
bool in_connectivity_shutdown;
|
80
78
|
/** List of picks that are waiting on connectivity */
|
81
79
|
pending_pick *pending_picks;
|
82
80
|
|
@@ -147,10 +145,11 @@ struct rr_subchannel_list {
|
|
147
145
|
|
148
146
|
static rr_subchannel_list *rr_subchannel_list_create(round_robin_lb_policy *p,
|
149
147
|
size_t num_subchannels) {
|
150
|
-
rr_subchannel_list *subchannel_list =
|
148
|
+
rr_subchannel_list *subchannel_list =
|
149
|
+
(rr_subchannel_list *)gpr_zalloc(sizeof(*subchannel_list));
|
151
150
|
subchannel_list->policy = p;
|
152
151
|
subchannel_list->subchannels =
|
153
|
-
gpr_zalloc(sizeof(subchannel_data) * num_subchannels);
|
152
|
+
(subchannel_data *)gpr_zalloc(sizeof(subchannel_data) * num_subchannels);
|
154
153
|
subchannel_list->num_subchannels = num_subchannels;
|
155
154
|
gpr_ref_init(&subchannel_list->refcount, 1);
|
156
155
|
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
|
@@ -312,6 +311,7 @@ static void rr_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
|
|
312
311
|
(void *)pol, (void *)pol);
|
313
312
|
}
|
314
313
|
grpc_connectivity_state_destroy(exec_ctx, &p->state_tracker);
|
314
|
+
grpc_subchannel_index_unref();
|
315
315
|
gpr_free(p);
|
316
316
|
}
|
317
317
|
|
@@ -424,7 +424,6 @@ static int rr_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
|
424
424
|
grpc_closure *on_complete) {
|
425
425
|
round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
|
426
426
|
GPR_ASSERT(!p->shutdown);
|
427
|
-
GPR_ASSERT(!p->in_connectivity_shutdown);
|
428
427
|
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
|
429
428
|
gpr_log(GPR_INFO, "[RR %p] Trying to pick", (void *)pol);
|
430
429
|
}
|
@@ -456,7 +455,7 @@ static int rr_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
|
456
455
|
if (!p->started_picking) {
|
457
456
|
start_picking_locked(exec_ctx, p);
|
458
457
|
}
|
459
|
-
pending_pick *pp = gpr_malloc(sizeof(*pp));
|
458
|
+
pending_pick *pp = (pending_pick *)gpr_malloc(sizeof(*pp));
|
460
459
|
pp->next = p->pending_picks;
|
461
460
|
pp->target = target;
|
462
461
|
pp->on_complete = on_complete;
|
@@ -537,7 +536,7 @@ static grpc_connectivity_state update_lb_connectivity_status_locked(
|
|
537
536
|
grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
|
538
537
|
GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_REF(error),
|
539
538
|
"rr_shutdown");
|
540
|
-
p->
|
539
|
+
p->shutdown = true;
|
541
540
|
new_state = GRPC_CHANNEL_SHUTDOWN;
|
542
541
|
} else if (subchannel_list->num_transient_failures ==
|
543
542
|
p->subchannel_list->num_subchannels) { /* 4) TRANSIENT_FAILURE */
|
@@ -557,7 +556,7 @@ static grpc_connectivity_state update_lb_connectivity_status_locked(
|
|
557
556
|
|
558
557
|
static void rr_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg,
|
559
558
|
grpc_error *error) {
|
560
|
-
subchannel_data *sd = arg;
|
559
|
+
subchannel_data *sd = (subchannel_data *)arg;
|
561
560
|
round_robin_lb_policy *p = sd->subchannel_list->policy;
|
562
561
|
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
|
563
562
|
gpr_log(
|
@@ -590,7 +589,7 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg,
|
|
590
589
|
// Dispose of outdated subchannel lists.
|
591
590
|
if (sd->subchannel_list != p->subchannel_list &&
|
592
591
|
sd->subchannel_list != p->latest_pending_subchannel_list) {
|
593
|
-
char *reason = NULL;
|
592
|
+
const char *reason = NULL;
|
594
593
|
if (sd->subchannel_list->shutting_down) {
|
595
594
|
reason = "sl_outdated_straggler";
|
596
595
|
rr_subchannel_list_unref(exec_ctx, sd->subchannel_list, reason);
|
@@ -741,8 +740,6 @@ static void rr_ping_one_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
|
741
740
|
static void rr_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
742
741
|
const grpc_lb_policy_args *args) {
|
743
742
|
round_robin_lb_policy *p = (round_robin_lb_policy *)policy;
|
744
|
-
/* Find the number of backend addresses. We ignore balancer addresses, since
|
745
|
-
* we don't know how to handle them. */
|
746
743
|
const grpc_arg *arg =
|
747
744
|
grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES);
|
748
745
|
if (arg == NULL || arg->type != GRPC_ARG_POINTER) {
|
@@ -760,13 +757,10 @@ static void rr_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
|
760
757
|
}
|
761
758
|
return;
|
762
759
|
}
|
763
|
-
grpc_lb_addresses *addresses = arg->value.pointer.p;
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
}
|
768
|
-
rr_subchannel_list *subchannel_list = rr_subchannel_list_create(p, num_addrs);
|
769
|
-
if (num_addrs == 0) {
|
760
|
+
grpc_lb_addresses *addresses = (grpc_lb_addresses *)arg->value.pointer.p;
|
761
|
+
rr_subchannel_list *subchannel_list =
|
762
|
+
rr_subchannel_list_create(p, addresses->num_addresses);
|
763
|
+
if (addresses->num_addresses == 0) {
|
770
764
|
grpc_connectivity_state_set(
|
771
765
|
exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
|
772
766
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty update"),
|
@@ -798,9 +792,8 @@ static void rr_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
|
798
792
|
GRPC_ARG_LB_ADDRESSES};
|
799
793
|
/* Create subchannels for addresses in the update. */
|
800
794
|
for (size_t i = 0; i < addresses->num_addresses; i++) {
|
801
|
-
|
802
|
-
|
803
|
-
GPR_ASSERT(i < num_addrs);
|
795
|
+
// If there were any balancer, we would have chosen grpclb policy instead.
|
796
|
+
GPR_ASSERT(!addresses->addresses[i].is_balancer);
|
804
797
|
memset(&sc_args, 0, sizeof(grpc_subchannel_args));
|
805
798
|
grpc_arg addr_arg =
|
806
799
|
grpc_create_subchannel_address_arg(&addresses->addresses[i].address);
|
@@ -811,19 +804,30 @@ static void rr_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
|
811
804
|
sc_args.args = new_args;
|
812
805
|
grpc_subchannel *subchannel = grpc_client_channel_factory_create_subchannel(
|
813
806
|
exec_ctx, args->client_channel_factory, &sc_args);
|
807
|
+
grpc_channel_args_destroy(exec_ctx, new_args);
|
808
|
+
grpc_error *error;
|
809
|
+
// Get the connectivity state of the subchannel. Already existing ones may
|
810
|
+
// be in a state other than INIT.
|
811
|
+
const grpc_connectivity_state subchannel_connectivity_state =
|
812
|
+
grpc_subchannel_check_connectivity(subchannel, &error);
|
813
|
+
if (error != GRPC_ERROR_NONE) {
|
814
|
+
// The subchannel is in error (e.g. shutting down). Ignore it.
|
815
|
+
GRPC_SUBCHANNEL_UNREF(exec_ctx, subchannel, "new_sc_connectivity_error");
|
816
|
+
GRPC_ERROR_UNREF(error);
|
817
|
+
continue;
|
818
|
+
}
|
814
819
|
if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) {
|
815
820
|
char *address_uri =
|
816
821
|
grpc_sockaddr_to_uri(&addresses->addresses[i].address);
|
817
822
|
gpr_log(
|
818
823
|
GPR_DEBUG,
|
819
824
|
"[RR %p] index %lu: Created subchannel %p for address uri %s into "
|
820
|
-
"subchannel_list %p",
|
825
|
+
"subchannel_list %p. Connectivity state %s",
|
821
826
|
(void *)p, (unsigned long)subchannel_index, (void *)subchannel,
|
822
|
-
address_uri, (void *)subchannel_list
|
827
|
+
address_uri, (void *)subchannel_list,
|
828
|
+
grpc_connectivity_state_name(subchannel_connectivity_state));
|
823
829
|
gpr_free(address_uri);
|
824
830
|
}
|
825
|
-
grpc_channel_args_destroy(exec_ctx, new_args);
|
826
|
-
|
827
831
|
subchannel_data *sd = &subchannel_list->subchannels[subchannel_index++];
|
828
832
|
sd->subchannel_list = subchannel_list;
|
829
833
|
sd->subchannel = subchannel;
|
@@ -835,7 +839,7 @@ static void rr_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
|
835
839
|
* won't be referring to this value again and it'll be overwritten after
|
836
840
|
* the first call to rr_connectivity_changed_locked */
|
837
841
|
sd->prev_connectivity_state = GRPC_CHANNEL_INIT;
|
838
|
-
sd->curr_connectivity_state =
|
842
|
+
sd->curr_connectivity_state = subchannel_connectivity_state;
|
839
843
|
sd->user_data_vtable = addresses->user_data_vtable;
|
840
844
|
if (sd->user_data_vtable != NULL) {
|
841
845
|
sd->user_data =
|
@@ -886,8 +890,9 @@ static grpc_lb_policy *round_robin_create(grpc_exec_ctx *exec_ctx,
|
|
886
890
|
grpc_lb_policy_factory *factory,
|
887
891
|
grpc_lb_policy_args *args) {
|
888
892
|
GPR_ASSERT(args->client_channel_factory != NULL);
|
889
|
-
round_robin_lb_policy *p = gpr_zalloc(sizeof(*p));
|
893
|
+
round_robin_lb_policy *p = (round_robin_lb_policy *)gpr_zalloc(sizeof(*p));
|
890
894
|
grpc_lb_policy_init(&p->base, &round_robin_lb_policy_vtable, args->combiner);
|
895
|
+
grpc_subchannel_index_ref();
|
891
896
|
grpc_connectivity_state_init(&p->state_tracker, GRPC_CHANNEL_IDLE,
|
892
897
|
"round_robin");
|
893
898
|
rr_update_locked(exec_ctx, &p->base, args);
|
@@ -28,11 +28,12 @@
|
|
28
28
|
|
29
29
|
grpc_lb_addresses* grpc_lb_addresses_create(
|
30
30
|
size_t num_addresses, const grpc_lb_user_data_vtable* user_data_vtable) {
|
31
|
-
grpc_lb_addresses* addresses =
|
31
|
+
grpc_lb_addresses* addresses =
|
32
|
+
(grpc_lb_addresses*)gpr_zalloc(sizeof(grpc_lb_addresses));
|
32
33
|
addresses->num_addresses = num_addresses;
|
33
34
|
addresses->user_data_vtable = user_data_vtable;
|
34
35
|
const size_t addresses_size = sizeof(grpc_lb_address) * num_addresses;
|
35
|
-
addresses->addresses = gpr_zalloc(addresses_size);
|
36
|
+
addresses->addresses = (grpc_lb_address*)gpr_zalloc(addresses_size);
|
36
37
|
return addresses;
|
37
38
|
}
|
38
39
|
|
@@ -55,7 +56,7 @@ grpc_lb_addresses* grpc_lb_addresses_copy(const grpc_lb_addresses* addresses) {
|
|
55
56
|
}
|
56
57
|
|
57
58
|
void grpc_lb_addresses_set_address(grpc_lb_addresses* addresses, size_t index,
|
58
|
-
void* address, size_t address_len,
|
59
|
+
const void* address, size_t address_len,
|
59
60
|
bool is_balancer, const char* balancer_name,
|
60
61
|
void* user_data) {
|
61
62
|
GPR_ASSERT(index < addresses->num_addresses);
|
@@ -125,13 +126,14 @@ void grpc_lb_addresses_destroy(grpc_exec_ctx* exec_ctx,
|
|
125
126
|
}
|
126
127
|
|
127
128
|
static void* lb_addresses_copy(void* addresses) {
|
128
|
-
return grpc_lb_addresses_copy(addresses);
|
129
|
+
return grpc_lb_addresses_copy((grpc_lb_addresses*)addresses);
|
129
130
|
}
|
130
131
|
static void lb_addresses_destroy(grpc_exec_ctx* exec_ctx, void* addresses) {
|
131
|
-
grpc_lb_addresses_destroy(exec_ctx, addresses);
|
132
|
+
grpc_lb_addresses_destroy(exec_ctx, (grpc_lb_addresses*)addresses);
|
132
133
|
}
|
133
134
|
static int lb_addresses_cmp(void* addresses1, void* addresses2) {
|
134
|
-
return grpc_lb_addresses_cmp(addresses1,
|
135
|
+
return grpc_lb_addresses_cmp((grpc_lb_addresses*)addresses1,
|
136
|
+
(grpc_lb_addresses*)addresses2);
|
135
137
|
}
|
136
138
|
static const grpc_arg_pointer_vtable lb_addresses_arg_vtable = {
|
137
139
|
lb_addresses_copy, lb_addresses_destroy, lb_addresses_cmp};
|
@@ -139,7 +141,7 @@ static const grpc_arg_pointer_vtable lb_addresses_arg_vtable = {
|
|
139
141
|
grpc_arg grpc_lb_addresses_create_channel_arg(
|
140
142
|
const grpc_lb_addresses* addresses) {
|
141
143
|
return grpc_channel_arg_pointer_create(
|
142
|
-
GRPC_ARG_LB_ADDRESSES, (void*)addresses, &lb_addresses_arg_vtable);
|
144
|
+
(char*)GRPC_ARG_LB_ADDRESSES, (void*)addresses, &lb_addresses_arg_vtable);
|
143
145
|
}
|
144
146
|
|
145
147
|
grpc_lb_addresses* grpc_lb_addresses_find_channel_arg(
|
@@ -148,7 +150,7 @@ grpc_lb_addresses* grpc_lb_addresses_find_channel_arg(
|
|
148
150
|
grpc_channel_args_find(channel_args, GRPC_ARG_LB_ADDRESSES);
|
149
151
|
if (lb_addresses_arg == NULL || lb_addresses_arg->type != GRPC_ARG_POINTER)
|
150
152
|
return NULL;
|
151
|
-
return lb_addresses_arg->value.pointer.p;
|
153
|
+
return (grpc_lb_addresses*)lb_addresses_arg->value.pointer.p;
|
152
154
|
}
|
153
155
|
|
154
156
|
void grpc_lb_policy_factory_ref(grpc_lb_policy_factory* factory) {
|