grpc 1.13.0 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +403 -153
- data/include/grpc/grpc.h +0 -8
- data/include/grpc/grpc_security.h +59 -2
- data/include/grpc/impl/codegen/grpc_types.h +8 -2
- data/include/grpc/impl/codegen/log.h +112 -0
- data/include/grpc/module.modulemap +2 -0
- data/include/grpc/support/log.h +2 -88
- data/include/grpc/support/string_util.h +2 -0
- data/src/boringssl/err_data.c +597 -593
- data/src/core/ext/filters/client_channel/client_channel.cc +715 -770
- data/src/core/ext/filters/client_channel/client_channel.h +5 -0
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +111 -0
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +69 -0
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +9 -0
- data/src/core/ext/filters/client_channel/http_proxy.cc +22 -5
- data/src/core/ext/filters/client_channel/lb_policy.h +15 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +3 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +3 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c +19 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h +54 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c +19 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h +54 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +4 -17
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +37 -63
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +79 -0
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +5 -2
- data/src/core/ext/filters/client_channel/lb_policy_factory.cc +8 -0
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +4 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +317 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +48 -9
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +40 -293
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +106 -84
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +6 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +6 -5
- data/src/core/ext/filters/client_channel/subchannel.cc +36 -6
- data/src/core/ext/filters/client_channel/subchannel.h +4 -0
- data/src/core/ext/filters/deadline/deadline_filter.cc +18 -15
- data/src/core/ext/filters/deadline/deadline_filter.h +5 -5
- data/src/core/ext/filters/http/client/http_client_filter.cc +10 -9
- data/src/core/ext/filters/http/server/http_server_filter.h +1 -1
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +1 -1
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +3 -2
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +33 -22
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/internal.h +10 -3
- data/src/core/ext/transport/chttp2/transport/stream_lists.cc +17 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +21 -16
- data/src/core/ext/transport/inproc/inproc_transport.cc +46 -6
- data/src/core/lib/channel/channel_stack.cc +22 -24
- data/src/core/lib/channel/channel_trace.cc +28 -63
- data/src/core/lib/channel/channel_trace.h +13 -17
- data/src/core/lib/channel/channelz.cc +143 -0
- data/src/core/lib/channel/channelz.h +124 -0
- data/src/core/lib/channel/channelz_registry.cc +7 -24
- data/src/core/lib/channel/channelz_registry.h +12 -8
- data/src/core/lib/channel/connected_channel.cc +8 -1
- data/src/core/{ext/filters/load_reporting/server_load_reporting_filter.h → lib/gpr/alloc.h} +7 -9
- data/src/core/lib/gpr/arena.cc +8 -8
- data/src/core/lib/gpr/string.cc +28 -0
- data/src/core/lib/gpr/string.h +10 -0
- data/src/core/lib/gprpp/abstract.h +5 -2
- data/src/core/lib/gprpp/inlined_vector.h +57 -3
- data/src/core/lib/gprpp/memory.h +2 -2
- data/src/core/lib/gprpp/ref_counted_ptr.h +5 -0
- data/src/core/lib/gprpp/thd_posix.cc +1 -1
- data/src/core/lib/iomgr/call_combiner.h +80 -0
- data/src/core/lib/iomgr/closure.h +3 -2
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +2 -2
- data/src/core/lib/iomgr/error.cc +12 -0
- data/src/core/lib/iomgr/error.h +5 -0
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +36 -9
- data/src/core/lib/iomgr/ev_epollex_linux.cc +172 -46
- data/src/core/lib/iomgr/ev_epollsig_linux.cc +47 -21
- data/src/core/lib/iomgr/ev_poll_posix.cc +10 -4
- data/src/core/lib/iomgr/ev_posix.cc +17 -9
- data/src/core/lib/iomgr/ev_posix.h +20 -4
- data/src/core/lib/iomgr/executor.cc +196 -140
- data/src/core/lib/iomgr/executor.h +47 -14
- data/src/core/lib/iomgr/iomgr.cc +2 -0
- data/src/core/lib/iomgr/iomgr.h +5 -0
- data/src/core/lib/iomgr/is_epollexclusive_available.cc +1 -0
- data/src/core/lib/iomgr/socket_utils.h +9 -0
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -0
- data/src/core/lib/iomgr/socket_utils_uv.cc +4 -0
- data/src/core/lib/iomgr/socket_utils_windows.cc +4 -0
- data/src/core/lib/iomgr/tcp_client_posix.cc +3 -5
- data/src/core/lib/iomgr/tcp_posix.cc +6 -1
- data/src/core/lib/iomgr/tcp_server_posix.cc +3 -3
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +1 -1
- data/src/core/lib/iomgr/timer_manager.cc +0 -1
- data/src/core/lib/iomgr/udp_server.cc +2 -3
- data/src/core/lib/json/json.cc +10 -0
- data/src/core/lib/json/json.h +5 -0
- data/src/core/lib/security/context/security_context.cc +8 -8
- data/src/core/lib/security/context/security_context.h +6 -2
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +2 -1
- data/src/core/lib/security/credentials/local/local_credentials.cc +77 -0
- data/src/core/lib/security/credentials/local/local_credentials.h +40 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +17 -3
- data/src/core/lib/security/security_connector/local_security_connector.cc +245 -0
- data/src/core/lib/security/security_connector/local_security_connector.h +58 -0
- data/src/core/lib/security/security_connector/security_connector.cc +30 -5
- data/src/core/lib/security/security_connector/security_connector.h +1 -0
- data/src/core/lib/security/transport/client_auth_filter.cc +5 -1
- data/src/core/lib/security/transport/server_auth_filter.cc +4 -5
- data/src/core/lib/surface/call.cc +75 -32
- data/src/core/lib/surface/call.h +2 -0
- data/src/core/lib/surface/channel.cc +32 -13
- data/src/core/lib/surface/channel.h +4 -0
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/transport.cc +20 -9
- data/src/core/lib/transport/transport.h +12 -10
- data/src/core/lib/transport/transport_op_string.cc +0 -7
- data/src/core/plugin_registry/grpc_plugin_registry.cc +0 -4
- data/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h +2 -2
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +2 -1
- data/src/core/tsi/alts/handshaker/altscontext.pb.c +0 -1
- data/src/core/tsi/alts/handshaker/altscontext.pb.h +1 -2
- data/src/core/tsi/alts/handshaker/handshaker.pb.c +0 -1
- data/src/core/tsi/alts/handshaker/handshaker.pb.h +1 -2
- data/src/core/tsi/alts/handshaker/transport_security_common.pb.c +0 -1
- data/src/core/tsi/alts/handshaker/transport_security_common.pb.h +1 -1
- data/src/core/tsi/alts/handshaker/transport_security_common_api.h +2 -2
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc +47 -1
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h +3 -1
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +12 -11
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h +7 -2
- data/src/core/tsi/local_transport_security.cc +209 -0
- data/src/core/tsi/local_transport_security.h +51 -0
- data/src/core/tsi/ssl_transport_security.cc +2 -3
- data/src/{core/ext → cpp/ext/filters}/census/grpc_context.cc +0 -0
- data/src/ruby/ext/grpc/rb_channel_credentials.c +3 -3
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +18 -18
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +29 -29
- data/src/ruby/lib/grpc/generic/active_call.rb +19 -23
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/call_credentials_spec.rb +1 -1
- data/src/ruby/spec/call_spec.rb +1 -1
- data/src/ruby/spec/channel_credentials_spec.rb +1 -1
- data/src/ruby/spec/channel_spec.rb +1 -1
- data/src/ruby/spec/client_auth_spec.rb +1 -12
- data/src/ruby/spec/client_server_spec.rb +1 -1
- data/src/ruby/spec/compression_options_spec.rb +1 -1
- data/src/ruby/spec/error_sanity_spec.rb +1 -1
- data/src/ruby/spec/generic/client_stub_spec.rb +13 -1
- data/src/ruby/spec/generic/rpc_desc_spec.rb +1 -1
- data/src/ruby/spec/generic/rpc_server_pool_spec.rb +1 -1
- data/src/ruby/spec/generic/service_spec.rb +1 -1
- data/src/ruby/spec/google_rpc_status_utils_spec.rb +1 -12
- data/src/ruby/spec/pb/duplicate/codegen_spec.rb +1 -0
- data/src/ruby/spec/pb/health/checker_spec.rb +1 -1
- data/src/ruby/spec/server_credentials_spec.rb +1 -1
- data/src/ruby/spec/server_spec.rb +1 -1
- data/src/ruby/spec/spec_helper.rb +1 -0
- data/src/ruby/spec/support/services.rb +1 -1
- data/src/ruby/spec/time_consts_spec.rb +1 -1
- data/third_party/boringssl/crypto/asn1/tasn_dec.c +40 -19
- data/third_party/boringssl/crypto/bytestring/cbs.c +1 -0
- data/third_party/boringssl/crypto/cipher_extra/e_aesccm.c +47 -15
- data/third_party/boringssl/crypto/ec_extra/ec_asn1.c +9 -10
- data/third_party/boringssl/crypto/ecdh/ecdh.c +4 -3
- data/third_party/boringssl/crypto/fipsmodule/bn/add.c +30 -54
- data/third_party/boringssl/crypto/fipsmodule/bn/bn.c +7 -1
- data/third_party/boringssl/crypto/fipsmodule/bn/cmp.c +8 -8
- data/third_party/boringssl/crypto/fipsmodule/bn/div.c +97 -11
- data/third_party/boringssl/crypto/fipsmodule/bn/gcd.c +274 -218
- data/third_party/boringssl/crypto/fipsmodule/bn/internal.h +111 -34
- data/third_party/boringssl/crypto/fipsmodule/bn/montgomery.c +2 -2
- data/third_party/boringssl/crypto/fipsmodule/bn/montgomery_inv.c +1 -1
- data/third_party/boringssl/crypto/fipsmodule/bn/mul.c +24 -6
- data/third_party/boringssl/crypto/fipsmodule/bn/prime.c +324 -63
- data/third_party/boringssl/crypto/fipsmodule/bn/random.c +74 -21
- data/third_party/boringssl/crypto/fipsmodule/bn/shift.c +128 -86
- data/third_party/boringssl/crypto/fipsmodule/bn/sqrt.c +1 -1
- data/third_party/boringssl/crypto/fipsmodule/ec/ec_key.c +67 -112
- data/third_party/boringssl/crypto/fipsmodule/ec/internal.h +8 -1
- data/third_party/boringssl/crypto/fipsmodule/ec/oct.c +5 -5
- data/third_party/boringssl/crypto/fipsmodule/ec/p224-64.c +9 -17
- data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64-table.h +5378 -5418
- data/third_party/boringssl/crypto/fipsmodule/ec/simple.c +32 -32
- data/third_party/boringssl/crypto/fipsmodule/ecdsa/ecdsa.c +5 -11
- data/third_party/boringssl/crypto/fipsmodule/rsa/blinding.c +16 -40
- data/third_party/boringssl/crypto/fipsmodule/rsa/internal.h +1 -6
- data/third_party/boringssl/crypto/fipsmodule/rsa/rsa.c +41 -29
- data/third_party/boringssl/crypto/fipsmodule/rsa/rsa_impl.c +63 -49
- data/third_party/boringssl/crypto/x509/vpm_int.h +1 -0
- data/third_party/boringssl/crypto/x509/x509_vfy.c +4 -0
- data/third_party/boringssl/crypto/x509/x509_vpm.c +44 -22
- data/third_party/boringssl/include/openssl/aead.h +8 -2
- data/third_party/boringssl/include/openssl/asn1.h +1 -0
- data/third_party/boringssl/include/openssl/base.h +4 -0
- data/third_party/boringssl/include/openssl/bn.h +13 -3
- data/third_party/boringssl/include/openssl/bytestring.h +4 -4
- data/third_party/boringssl/include/openssl/ec.h +10 -4
- data/third_party/boringssl/include/openssl/ec_key.h +0 -3
- data/third_party/boringssl/include/openssl/rsa.h +1 -0
- data/third_party/boringssl/include/openssl/ssl.h +8 -3
- data/third_party/boringssl/include/openssl/ssl3.h +0 -1
- data/third_party/boringssl/include/openssl/x509.h +1 -0
- data/third_party/boringssl/include/openssl/x509v3.h +1 -0
- data/third_party/boringssl/ssl/handshake_client.cc +36 -64
- data/third_party/boringssl/ssl/ssl_cipher.cc +4 -0
- data/third_party/boringssl/ssl/ssl_lib.cc +1 -1
- metadata +45 -38
- data/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc +0 -222
- data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc +0 -71
- data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h +0 -61
- data/src/ruby/spec/pb/package_with_underscore/checker_spec.rb +0 -51
- data/src/ruby/spec/pb/package_with_underscore/data.proto +0 -23
- data/src/ruby/spec/pb/package_with_underscore/service.proto +0 -23
@@ -63,10 +63,8 @@ struct grpc_ares_request {
|
|
63
63
|
/** the evernt driver used by this request */
|
64
64
|
grpc_ares_ev_driver* ev_driver;
|
65
65
|
/** number of ongoing queries */
|
66
|
-
|
66
|
+
size_t pending_queries;
|
67
67
|
|
68
|
-
/** mutex guarding the rest of the state */
|
69
|
-
gpr_mu mu;
|
70
68
|
/** is there at least one successful query, set in on_done_cb */
|
71
69
|
bool success;
|
72
70
|
/** the errors explaining the request failure, set in on_done_cb */
|
@@ -74,7 +72,8 @@ struct grpc_ares_request {
|
|
74
72
|
};
|
75
73
|
|
76
74
|
typedef struct grpc_ares_hostbyname_request {
|
77
|
-
/** following members are set in
|
75
|
+
/** following members are set in create_hostbyname_request_locked
|
76
|
+
*/
|
78
77
|
/** the top-level request instance */
|
79
78
|
grpc_ares_request* parent_request;
|
80
79
|
/** host to resolve, parsed from the name to resolve */
|
@@ -96,10 +95,6 @@ static uint16_t strhtons(const char* port) {
|
|
96
95
|
return htons(static_cast<unsigned short>(atoi(port)));
|
97
96
|
}
|
98
97
|
|
99
|
-
static void grpc_ares_request_ref(grpc_ares_request* r) {
|
100
|
-
gpr_ref(&r->pending_queries);
|
101
|
-
}
|
102
|
-
|
103
98
|
static void log_address_sorting_list(grpc_lb_addresses* lb_addrs,
|
104
99
|
const char* input_output_str) {
|
105
100
|
for (size_t i = 0; i < lb_addrs->num_addresses; i++) {
|
@@ -149,22 +144,29 @@ void grpc_cares_wrapper_test_only_address_sorting_sort(
|
|
149
144
|
grpc_cares_wrapper_address_sorting_sort(lb_addrs);
|
150
145
|
}
|
151
146
|
|
152
|
-
static void
|
153
|
-
|
147
|
+
static void grpc_ares_request_ref_locked(grpc_ares_request* r) {
|
148
|
+
r->pending_queries++;
|
149
|
+
}
|
150
|
+
|
151
|
+
static void grpc_ares_request_unref_locked(grpc_ares_request* r) {
|
152
|
+
r->pending_queries--;
|
153
|
+
if (r->pending_queries == 0u) {
|
154
|
+
grpc_ares_ev_driver_on_queries_complete_locked(r->ev_driver);
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
void grpc_ares_complete_request_locked(grpc_ares_request* r) {
|
159
|
+
/* Invoke on_done callback and destroy the
|
154
160
|
request */
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
grpc_cares_wrapper_address_sorting_sort(lb_addrs);
|
159
|
-
}
|
160
|
-
GRPC_CLOSURE_SCHED(r->on_done, r->error);
|
161
|
-
gpr_mu_destroy(&r->mu);
|
162
|
-
grpc_ares_ev_driver_destroy(r->ev_driver);
|
163
|
-
gpr_free(r);
|
161
|
+
grpc_lb_addresses* lb_addrs = *(r->lb_addrs_out);
|
162
|
+
if (lb_addrs != nullptr) {
|
163
|
+
grpc_cares_wrapper_address_sorting_sort(lb_addrs);
|
164
164
|
}
|
165
|
+
GRPC_CLOSURE_SCHED(r->on_done, r->error);
|
166
|
+
gpr_free(r);
|
165
167
|
}
|
166
168
|
|
167
|
-
static grpc_ares_hostbyname_request*
|
169
|
+
static grpc_ares_hostbyname_request* create_hostbyname_request_locked(
|
168
170
|
grpc_ares_request* parent_request, char* host, uint16_t port,
|
169
171
|
bool is_balancer) {
|
170
172
|
grpc_ares_hostbyname_request* hr = static_cast<grpc_ares_hostbyname_request*>(
|
@@ -173,22 +175,22 @@ static grpc_ares_hostbyname_request* create_hostbyname_request(
|
|
173
175
|
hr->host = gpr_strdup(host);
|
174
176
|
hr->port = port;
|
175
177
|
hr->is_balancer = is_balancer;
|
176
|
-
|
178
|
+
grpc_ares_request_ref_locked(parent_request);
|
177
179
|
return hr;
|
178
180
|
}
|
179
181
|
|
180
|
-
static void
|
181
|
-
|
182
|
+
static void destroy_hostbyname_request_locked(
|
183
|
+
grpc_ares_hostbyname_request* hr) {
|
184
|
+
grpc_ares_request_unref_locked(hr->parent_request);
|
182
185
|
gpr_free(hr->host);
|
183
186
|
gpr_free(hr);
|
184
187
|
}
|
185
188
|
|
186
|
-
static void
|
187
|
-
|
189
|
+
static void on_hostbyname_done_locked(void* arg, int status, int timeouts,
|
190
|
+
struct hostent* hostent) {
|
188
191
|
grpc_ares_hostbyname_request* hr =
|
189
192
|
static_cast<grpc_ares_hostbyname_request*>(arg);
|
190
193
|
grpc_ares_request* r = hr->parent_request;
|
191
|
-
gpr_mu_lock(&r->mu);
|
192
194
|
if (status == ARES_SUCCESS) {
|
193
195
|
GRPC_ERROR_UNREF(r->error);
|
194
196
|
r->error = GRPC_ERROR_NONE;
|
@@ -263,33 +265,33 @@ static void on_hostbyname_done_cb(void* arg, int status, int timeouts,
|
|
263
265
|
r->error = grpc_error_add_child(error, r->error);
|
264
266
|
}
|
265
267
|
}
|
266
|
-
|
267
|
-
destroy_hostbyname_request(hr);
|
268
|
+
destroy_hostbyname_request_locked(hr);
|
268
269
|
}
|
269
270
|
|
270
|
-
static void
|
271
|
-
|
271
|
+
static void on_srv_query_done_locked(void* arg, int status, int timeouts,
|
272
|
+
unsigned char* abuf, int alen) {
|
272
273
|
grpc_ares_request* r = static_cast<grpc_ares_request*>(arg);
|
273
|
-
gpr_log(GPR_DEBUG, "
|
274
|
+
gpr_log(GPR_DEBUG, "on_query_srv_done_locked");
|
274
275
|
if (status == ARES_SUCCESS) {
|
275
|
-
gpr_log(GPR_DEBUG, "
|
276
|
+
gpr_log(GPR_DEBUG, "on_query_srv_done_locked ARES_SUCCESS");
|
276
277
|
struct ares_srv_reply* reply;
|
277
278
|
const int parse_status = ares_parse_srv_reply(abuf, alen, &reply);
|
278
279
|
if (parse_status == ARES_SUCCESS) {
|
279
|
-
ares_channel* channel =
|
280
|
+
ares_channel* channel =
|
281
|
+
grpc_ares_ev_driver_get_channel_locked(r->ev_driver);
|
280
282
|
for (struct ares_srv_reply* srv_it = reply; srv_it != nullptr;
|
281
283
|
srv_it = srv_it->next) {
|
282
284
|
if (grpc_ipv6_loopback_available()) {
|
283
|
-
grpc_ares_hostbyname_request* hr =
|
285
|
+
grpc_ares_hostbyname_request* hr = create_hostbyname_request_locked(
|
284
286
|
r, srv_it->host, htons(srv_it->port), true /* is_balancer */);
|
285
287
|
ares_gethostbyname(*channel, hr->host, AF_INET6,
|
286
|
-
|
288
|
+
on_hostbyname_done_locked, hr);
|
287
289
|
}
|
288
|
-
grpc_ares_hostbyname_request* hr =
|
290
|
+
grpc_ares_hostbyname_request* hr = create_hostbyname_request_locked(
|
289
291
|
r, srv_it->host, htons(srv_it->port), true /* is_balancer */);
|
290
|
-
ares_gethostbyname(*channel, hr->host, AF_INET,
|
291
|
-
hr);
|
292
|
-
|
292
|
+
ares_gethostbyname(*channel, hr->host, AF_INET,
|
293
|
+
on_hostbyname_done_locked, hr);
|
294
|
+
grpc_ares_ev_driver_start_locked(r->ev_driver);
|
293
295
|
}
|
294
296
|
}
|
295
297
|
if (reply != nullptr) {
|
@@ -307,21 +309,20 @@ static void on_srv_query_done_cb(void* arg, int status, int timeouts,
|
|
307
309
|
r->error = grpc_error_add_child(error, r->error);
|
308
310
|
}
|
309
311
|
}
|
310
|
-
|
312
|
+
grpc_ares_request_unref_locked(r);
|
311
313
|
}
|
312
314
|
|
313
315
|
static const char g_service_config_attribute_prefix[] = "grpc_config=";
|
314
316
|
|
315
|
-
static void
|
316
|
-
|
317
|
-
gpr_log(GPR_DEBUG, "
|
317
|
+
static void on_txt_done_locked(void* arg, int status, int timeouts,
|
318
|
+
unsigned char* buf, int len) {
|
319
|
+
gpr_log(GPR_DEBUG, "on_txt_done_locked");
|
318
320
|
char* error_msg;
|
319
321
|
grpc_ares_request* r = static_cast<grpc_ares_request*>(arg);
|
320
322
|
const size_t prefix_len = sizeof(g_service_config_attribute_prefix) - 1;
|
321
323
|
struct ares_txt_ext* result = nullptr;
|
322
324
|
struct ares_txt_ext* reply = nullptr;
|
323
325
|
grpc_error* error = GRPC_ERROR_NONE;
|
324
|
-
gpr_mu_lock(&r->mu);
|
325
326
|
if (status != ARES_SUCCESS) goto fail;
|
326
327
|
status = ares_parse_txt_reply_ext(buf, len, &reply);
|
327
328
|
if (status != ARES_SUCCESS) goto fail;
|
@@ -366,14 +367,14 @@ fail:
|
|
366
367
|
r->error = grpc_error_add_child(error, r->error);
|
367
368
|
}
|
368
369
|
done:
|
369
|
-
|
370
|
-
grpc_ares_request_unref(r);
|
370
|
+
grpc_ares_request_unref_locked(r);
|
371
371
|
}
|
372
372
|
|
373
|
-
static grpc_ares_request*
|
373
|
+
static grpc_ares_request* grpc_dns_lookup_ares_locked_impl(
|
374
374
|
const char* dns_server, const char* name, const char* default_port,
|
375
375
|
grpc_pollset_set* interested_parties, grpc_closure* on_done,
|
376
|
-
grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json
|
376
|
+
grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json,
|
377
|
+
grpc_combiner* combiner) {
|
377
378
|
grpc_error* error = GRPC_ERROR_NONE;
|
378
379
|
grpc_ares_hostbyname_request* hr = nullptr;
|
379
380
|
grpc_ares_request* r = nullptr;
|
@@ -402,21 +403,18 @@ static grpc_ares_request* grpc_dns_lookup_ares_impl(
|
|
402
403
|
}
|
403
404
|
port = gpr_strdup(default_port);
|
404
405
|
}
|
405
|
-
|
406
|
-
grpc_ares_ev_driver* ev_driver;
|
407
|
-
error = grpc_ares_ev_driver_create(&ev_driver, interested_parties);
|
408
|
-
if (error != GRPC_ERROR_NONE) goto error_cleanup;
|
409
|
-
|
410
406
|
r = static_cast<grpc_ares_request*>(gpr_zalloc(sizeof(grpc_ares_request)));
|
411
|
-
|
412
|
-
r->ev_driver = ev_driver;
|
407
|
+
r->ev_driver = nullptr;
|
413
408
|
r->on_done = on_done;
|
414
409
|
r->lb_addrs_out = addrs;
|
415
410
|
r->service_config_json_out = service_config_json;
|
416
411
|
r->success = false;
|
417
412
|
r->error = GRPC_ERROR_NONE;
|
418
|
-
|
419
|
-
|
413
|
+
r->pending_queries = 0;
|
414
|
+
error = grpc_ares_ev_driver_create_locked(&r->ev_driver, interested_parties,
|
415
|
+
combiner, r);
|
416
|
+
if (error != GRPC_ERROR_NONE) goto error_cleanup;
|
417
|
+
channel = grpc_ares_ev_driver_get_channel_locked(r->ev_driver);
|
420
418
|
// If dns_server is specified, use it.
|
421
419
|
if (dns_server != nullptr) {
|
422
420
|
gpr_log(GPR_INFO, "Using DNS server %s", dns_server);
|
@@ -441,7 +439,6 @@ static grpc_ares_request* grpc_dns_lookup_ares_impl(
|
|
441
439
|
error = grpc_error_set_str(
|
442
440
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("cannot parse authority"),
|
443
441
|
GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(name));
|
444
|
-
gpr_free(r);
|
445
442
|
goto error_cleanup;
|
446
443
|
}
|
447
444
|
int status = ares_set_servers_ports(*channel, &r->dns_server_addr);
|
@@ -451,58 +448,60 @@ static grpc_ares_request* grpc_dns_lookup_ares_impl(
|
|
451
448
|
ares_strerror(status));
|
452
449
|
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg);
|
453
450
|
gpr_free(error_msg);
|
454
|
-
gpr_free(r);
|
455
451
|
goto error_cleanup;
|
456
452
|
}
|
457
453
|
}
|
458
|
-
|
454
|
+
r->pending_queries = 1;
|
459
455
|
if (grpc_ipv6_loopback_available()) {
|
460
|
-
hr =
|
461
|
-
|
462
|
-
ares_gethostbyname(*channel, hr->host, AF_INET6,
|
456
|
+
hr = create_hostbyname_request_locked(r, host, strhtons(port),
|
457
|
+
false /* is_balancer */);
|
458
|
+
ares_gethostbyname(*channel, hr->host, AF_INET6, on_hostbyname_done_locked,
|
459
|
+
hr);
|
463
460
|
}
|
464
|
-
hr =
|
465
|
-
|
466
|
-
ares_gethostbyname(*channel, hr->host, AF_INET,
|
461
|
+
hr = create_hostbyname_request_locked(r, host, strhtons(port),
|
462
|
+
false /* is_balancer */);
|
463
|
+
ares_gethostbyname(*channel, hr->host, AF_INET, on_hostbyname_done_locked,
|
464
|
+
hr);
|
467
465
|
if (check_grpclb) {
|
468
466
|
/* Query the SRV record */
|
469
|
-
|
467
|
+
grpc_ares_request_ref_locked(r);
|
470
468
|
char* service_name;
|
471
469
|
gpr_asprintf(&service_name, "_grpclb._tcp.%s", host);
|
472
|
-
ares_query(*channel, service_name, ns_c_in, ns_t_srv,
|
473
|
-
r);
|
470
|
+
ares_query(*channel, service_name, ns_c_in, ns_t_srv,
|
471
|
+
on_srv_query_done_locked, r);
|
474
472
|
gpr_free(service_name);
|
475
473
|
}
|
476
474
|
if (service_config_json != nullptr) {
|
477
|
-
|
475
|
+
grpc_ares_request_ref_locked(r);
|
478
476
|
char* config_name;
|
479
477
|
gpr_asprintf(&config_name, "_grpc_config.%s", host);
|
480
|
-
ares_search(*channel, config_name, ns_c_in, ns_t_txt,
|
478
|
+
ares_search(*channel, config_name, ns_c_in, ns_t_txt, on_txt_done_locked,
|
479
|
+
r);
|
481
480
|
gpr_free(config_name);
|
482
481
|
}
|
483
|
-
|
484
|
-
|
485
|
-
grpc_ares_request_unref(r);
|
482
|
+
grpc_ares_ev_driver_start_locked(r->ev_driver);
|
483
|
+
grpc_ares_request_unref_locked(r);
|
486
484
|
gpr_free(host);
|
487
485
|
gpr_free(port);
|
488
486
|
return r;
|
489
487
|
|
490
488
|
error_cleanup:
|
491
489
|
GRPC_CLOSURE_SCHED(on_done, error);
|
490
|
+
gpr_free(r);
|
492
491
|
gpr_free(host);
|
493
492
|
gpr_free(port);
|
494
493
|
return nullptr;
|
495
494
|
}
|
496
495
|
|
497
|
-
grpc_ares_request* (*
|
496
|
+
grpc_ares_request* (*grpc_dns_lookup_ares_locked)(
|
498
497
|
const char* dns_server, const char* name, const char* default_port,
|
499
498
|
grpc_pollset_set* interested_parties, grpc_closure* on_done,
|
500
|
-
grpc_lb_addresses** addrs, bool check_grpclb,
|
501
|
-
|
499
|
+
grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json,
|
500
|
+
grpc_combiner* combiner) = grpc_dns_lookup_ares_locked_impl;
|
502
501
|
|
503
502
|
void grpc_cancel_ares_request(grpc_ares_request* r) {
|
504
|
-
if (
|
505
|
-
|
503
|
+
if (grpc_dns_lookup_ares_locked == grpc_dns_lookup_ares_locked_impl) {
|
504
|
+
grpc_ares_ev_driver_shutdown_locked(r->ev_driver);
|
506
505
|
}
|
507
506
|
}
|
508
507
|
|
@@ -534,6 +533,8 @@ void grpc_ares_cleanup(void) {
|
|
534
533
|
*/
|
535
534
|
|
536
535
|
typedef struct grpc_resolve_address_ares_request {
|
536
|
+
/* combiner that queries and related callbacks run under */
|
537
|
+
grpc_combiner* combiner;
|
537
538
|
/** the pointer to receive the resolved addresses */
|
538
539
|
grpc_resolved_addresses** addrs_out;
|
539
540
|
/** currently resolving lb addresses */
|
@@ -541,8 +542,14 @@ typedef struct grpc_resolve_address_ares_request {
|
|
541
542
|
/** closure to call when the resolve_address_ares request completes */
|
542
543
|
grpc_closure* on_resolve_address_done;
|
543
544
|
/** a closure wrapping on_dns_lookup_done_cb, which should be invoked when the
|
544
|
-
|
545
|
+
grpc_dns_lookup_ares_locked operation is done. */
|
545
546
|
grpc_closure on_dns_lookup_done;
|
547
|
+
/* target name */
|
548
|
+
const char* name;
|
549
|
+
/* default port to use if none is specified */
|
550
|
+
const char* default_port;
|
551
|
+
/* pollset_set to be driven by */
|
552
|
+
grpc_pollset_set* interested_parties;
|
546
553
|
} grpc_resolve_address_ares_request;
|
547
554
|
|
548
555
|
static void on_dns_lookup_done_cb(void* arg, grpc_error* error) {
|
@@ -566,9 +573,20 @@ static void on_dns_lookup_done_cb(void* arg, grpc_error* error) {
|
|
566
573
|
}
|
567
574
|
GRPC_CLOSURE_SCHED(r->on_resolve_address_done, GRPC_ERROR_REF(error));
|
568
575
|
if (r->lb_addrs != nullptr) grpc_lb_addresses_destroy(r->lb_addrs);
|
576
|
+
GRPC_COMBINER_UNREF(r->combiner, "on_dns_lookup_done_cb");
|
569
577
|
gpr_free(r);
|
570
578
|
}
|
571
579
|
|
580
|
+
static void grpc_resolve_address_invoke_dns_lookup_ares_locked(
|
581
|
+
void* arg, grpc_error* unused_error) {
|
582
|
+
grpc_resolve_address_ares_request* r =
|
583
|
+
static_cast<grpc_resolve_address_ares_request*>(arg);
|
584
|
+
grpc_dns_lookup_ares_locked(
|
585
|
+
nullptr /* dns_server */, r->name, r->default_port, r->interested_parties,
|
586
|
+
&r->on_dns_lookup_done, &r->lb_addrs, false /* check_grpclb */,
|
587
|
+
nullptr /* service_config_json */, r->combiner);
|
588
|
+
}
|
589
|
+
|
572
590
|
static void grpc_resolve_address_ares_impl(const char* name,
|
573
591
|
const char* default_port,
|
574
592
|
grpc_pollset_set* interested_parties,
|
@@ -577,14 +595,18 @@ static void grpc_resolve_address_ares_impl(const char* name,
|
|
577
595
|
grpc_resolve_address_ares_request* r =
|
578
596
|
static_cast<grpc_resolve_address_ares_request*>(
|
579
597
|
gpr_zalloc(sizeof(grpc_resolve_address_ares_request)));
|
598
|
+
r->combiner = grpc_combiner_create();
|
580
599
|
r->addrs_out = addrs;
|
581
600
|
r->on_resolve_address_done = on_done;
|
582
601
|
GRPC_CLOSURE_INIT(&r->on_dns_lookup_done, on_dns_lookup_done_cb, r,
|
583
602
|
grpc_schedule_on_exec_ctx);
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
603
|
+
r->name = name;
|
604
|
+
r->default_port = default_port;
|
605
|
+
r->interested_parties = interested_parties;
|
606
|
+
GRPC_CLOSURE_SCHED(
|
607
|
+
GRPC_CLOSURE_CREATE(grpc_resolve_address_invoke_dns_lookup_ares_locked, r,
|
608
|
+
grpc_combiner_scheduler(r->combiner)),
|
609
|
+
GRPC_ERROR_NONE);
|
588
610
|
}
|
589
611
|
|
590
612
|
void (*grpc_resolve_address_ares)(
|
@@ -48,11 +48,11 @@ extern void (*grpc_resolve_address_ares)(const char* name,
|
|
48
48
|
function. \a on_done may be called directly in this function without being
|
49
49
|
scheduled with \a exec_ctx, so it must not try to acquire locks that are
|
50
50
|
being held by the caller. */
|
51
|
-
extern grpc_ares_request* (*
|
51
|
+
extern grpc_ares_request* (*grpc_dns_lookup_ares_locked)(
|
52
52
|
const char* dns_server, const char* name, const char* default_port,
|
53
53
|
grpc_pollset_set* interested_parties, grpc_closure* on_done,
|
54
54
|
grpc_lb_addresses** addresses, bool check_grpclb,
|
55
|
-
char** service_config_json);
|
55
|
+
char** service_config_json, grpc_combiner* combiner);
|
56
56
|
|
57
57
|
/* Cancel the pending grpc_ares_request \a request */
|
58
58
|
void grpc_cancel_ares_request(grpc_ares_request* request);
|
@@ -66,6 +66,10 @@ grpc_error* grpc_ares_init(void);
|
|
66
66
|
it has been called the same number of times as grpc_ares_init(). */
|
67
67
|
void grpc_ares_cleanup(void);
|
68
68
|
|
69
|
+
/** Schedules the desired callback for request completion
|
70
|
+
* and destroys the grpc_ares_request */
|
71
|
+
void grpc_ares_complete_request_locked(grpc_ares_request* request);
|
72
|
+
|
69
73
|
/* Exposed only for testing */
|
70
74
|
void grpc_cares_wrapper_test_only_address_sorting_sort(
|
71
75
|
grpc_lb_addresses* lb_addrs);
|
@@ -26,18 +26,19 @@ struct grpc_ares_request {
|
|
26
26
|
char val;
|
27
27
|
};
|
28
28
|
|
29
|
-
static grpc_ares_request*
|
29
|
+
static grpc_ares_request* grpc_dns_lookup_ares_locked_impl(
|
30
30
|
const char* dns_server, const char* name, const char* default_port,
|
31
31
|
grpc_pollset_set* interested_parties, grpc_closure* on_done,
|
32
|
-
grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json
|
32
|
+
grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json,
|
33
|
+
grpc_combiner* combiner) {
|
33
34
|
return NULL;
|
34
35
|
}
|
35
36
|
|
36
|
-
grpc_ares_request* (*
|
37
|
+
grpc_ares_request* (*grpc_dns_lookup_ares_locked)(
|
37
38
|
const char* dns_server, const char* name, const char* default_port,
|
38
39
|
grpc_pollset_set* interested_parties, grpc_closure* on_done,
|
39
|
-
grpc_lb_addresses** addrs, bool check_grpclb,
|
40
|
-
|
40
|
+
grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json,
|
41
|
+
grpc_combiner* combiner) = grpc_dns_lookup_ares_locked_impl;
|
41
42
|
|
42
43
|
void grpc_cancel_ares_request(grpc_ares_request* r) {}
|
43
44
|
|
@@ -38,6 +38,7 @@
|
|
38
38
|
#include "src/core/lib/channel/channel_args.h"
|
39
39
|
#include "src/core/lib/channel/connected_channel.h"
|
40
40
|
#include "src/core/lib/debug/stats.h"
|
41
|
+
#include "src/core/lib/gpr/alloc.h"
|
41
42
|
#include "src/core/lib/gprpp/debug_location.h"
|
42
43
|
#include "src/core/lib/gprpp/manual_constructor.h"
|
43
44
|
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
@@ -133,6 +134,9 @@ struct grpc_subchannel {
|
|
133
134
|
bool backoff_begun;
|
134
135
|
/** our alarm */
|
135
136
|
grpc_timer alarm;
|
137
|
+
|
138
|
+
grpc_core::RefCountedPtr<grpc_core::channelz::SubchannelNode>
|
139
|
+
channelz_subchannel;
|
136
140
|
};
|
137
141
|
|
138
142
|
struct grpc_subchannel_call {
|
@@ -140,9 +144,13 @@ struct grpc_subchannel_call {
|
|
140
144
|
grpc_closure* schedule_closure_after_destroy;
|
141
145
|
};
|
142
146
|
|
143
|
-
#define SUBCHANNEL_CALL_TO_CALL_STACK(call)
|
144
|
-
|
145
|
-
|
147
|
+
#define SUBCHANNEL_CALL_TO_CALL_STACK(call) \
|
148
|
+
(grpc_call_stack*)((char*)(call) + GPR_ROUND_UP_TO_ALIGNMENT_SIZE( \
|
149
|
+
sizeof(grpc_subchannel_call)))
|
150
|
+
#define CALLSTACK_TO_SUBCHANNEL_CALL(callstack) \
|
151
|
+
(grpc_subchannel_call*)(((char*)(call_stack)) - \
|
152
|
+
GPR_ROUND_UP_TO_ALIGNMENT_SIZE( \
|
153
|
+
sizeof(grpc_subchannel_call)))
|
146
154
|
|
147
155
|
static void on_subchannel_connected(void* subchannel, grpc_error* error);
|
148
156
|
|
@@ -173,6 +181,7 @@ static void connection_destroy(void* arg, grpc_error* error) {
|
|
173
181
|
|
174
182
|
static void subchannel_destroy(void* arg, grpc_error* error) {
|
175
183
|
grpc_subchannel* c = static_cast<grpc_subchannel*>(arg);
|
184
|
+
c->channelz_subchannel.reset();
|
176
185
|
gpr_free((void*)c->filters);
|
177
186
|
grpc_channel_args_destroy(c->args);
|
178
187
|
grpc_connectivity_state_destroy(&c->state_tracker);
|
@@ -369,9 +378,22 @@ grpc_subchannel* grpc_subchannel_create(grpc_connector* connector,
|
|
369
378
|
c->backoff.Init(backoff_options);
|
370
379
|
gpr_mu_init(&c->mu);
|
371
380
|
|
381
|
+
const grpc_arg* arg =
|
382
|
+
grpc_channel_args_find(c->args, GRPC_ARG_ENABLE_CHANNELZ);
|
383
|
+
bool channelz_enabled = grpc_channel_arg_get_bool(arg, false);
|
384
|
+
if (channelz_enabled) {
|
385
|
+
c->channelz_subchannel =
|
386
|
+
grpc_core::MakeRefCounted<grpc_core::channelz::SubchannelNode>();
|
387
|
+
}
|
388
|
+
|
372
389
|
return grpc_subchannel_index_register(key, c);
|
373
390
|
}
|
374
391
|
|
392
|
+
grpc_core::channelz::SubchannelNode* grpc_subchannel_get_channelz_node(
|
393
|
+
grpc_subchannel* s) {
|
394
|
+
return s->channelz_subchannel.get();
|
395
|
+
}
|
396
|
+
|
375
397
|
static void continue_connect_locked(grpc_subchannel* c) {
|
376
398
|
grpc_connect_in_args args;
|
377
399
|
args.interested_parties = c->pollset_set;
|
@@ -783,9 +805,17 @@ void ConnectedSubchannel::Ping(grpc_closure* on_initiate,
|
|
783
805
|
|
784
806
|
grpc_error* ConnectedSubchannel::CreateCall(const CallArgs& args,
|
785
807
|
grpc_subchannel_call** call) {
|
786
|
-
|
787
|
-
|
788
|
-
|
808
|
+
size_t allocation_size =
|
809
|
+
GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_subchannel_call));
|
810
|
+
if (args.parent_data_size > 0) {
|
811
|
+
allocation_size +=
|
812
|
+
GPR_ROUND_UP_TO_ALIGNMENT_SIZE(channel_stack_->call_stack_size) +
|
813
|
+
args.parent_data_size;
|
814
|
+
} else {
|
815
|
+
allocation_size += channel_stack_->call_stack_size;
|
816
|
+
}
|
817
|
+
*call = static_cast<grpc_subchannel_call*>(
|
818
|
+
gpr_arena_alloc(args.arena, allocation_size));
|
789
819
|
grpc_call_stack* callstk = SUBCHANNEL_CALL_TO_CALL_STACK(*call);
|
790
820
|
RefCountedPtr<ConnectedSubchannel> connection =
|
791
821
|
Ref(DEBUG_LOCATION, "subchannel_call");
|