grpc 1.14.2 → 1.15.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 +307 -12
- data/etc/roots.pem +40 -163
- data/include/grpc/grpc.h +49 -0
- data/include/grpc/grpc_security.h +0 -6
- data/include/grpc/grpc_security_constants.h +6 -0
- data/include/grpc/impl/codegen/grpc_types.h +17 -2
- data/include/grpc/impl/codegen/port_platform.h +41 -4
- data/include/grpc/support/sync.h +0 -16
- data/src/{cpp → core}/ext/filters/census/grpc_context.cc +0 -0
- data/src/core/ext/filters/client_channel/client_channel.cc +40 -11
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +11 -9
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +4 -2
- data/src/core/ext/filters/client_channel/lb_policy.h +14 -11
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +67 -90
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +108 -91
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +79 -25
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +40 -0
- data/src/core/ext/filters/client_channel/resolver.h +8 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +11 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +13 -10
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +18 -4
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +13 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +537 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +6 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +11 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc +29 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +29 -0
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +9 -0
- data/src/core/ext/filters/client_channel/subchannel.cc +21 -8
- data/src/core/ext/filters/client_channel/subchannel.h +7 -0
- data/src/core/ext/filters/http/client_authority_filter.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +24 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +10 -7
- data/src/core/lib/channel/channel_stack.h +1 -1
- data/src/core/lib/channel/channel_trace.cc +1 -1
- data/src/core/lib/channel/channel_trace.h +1 -1
- data/src/core/lib/channel/channelz.cc +37 -27
- data/src/core/lib/channel/channelz.h +13 -4
- data/src/core/lib/channel/channelz_registry.cc +89 -4
- data/src/core/lib/channel/channelz_registry.h +56 -39
- data/src/core/lib/gpr/arena.cc +33 -40
- data/src/core/lib/gprpp/fork.cc +41 -33
- data/src/core/lib/gprpp/fork.h +13 -4
- data/src/core/lib/gprpp/mutex_lock.h +42 -0
- data/src/core/lib/gprpp/orphanable.h +4 -2
- data/src/core/lib/gprpp/ref_counted.h +4 -2
- data/src/core/lib/gprpp/ref_counted_ptr.h +65 -13
- data/src/core/lib/iomgr/call_combiner.h +4 -1
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +77 -17
- data/src/core/lib/iomgr/ev_epollex_linux.cc +8 -26
- data/src/core/lib/iomgr/ev_epollsig_linux.cc +10 -28
- data/src/core/lib/iomgr/ev_poll_posix.cc +144 -35
- data/src/core/lib/iomgr/ev_posix.cc +58 -9
- data/src/core/lib/iomgr/ev_posix.h +22 -8
- data/src/core/lib/iomgr/exec_ctx.cc +6 -0
- data/src/core/lib/iomgr/exec_ctx.h +2 -0
- data/src/core/lib/iomgr/executor.cc +148 -72
- data/src/core/lib/iomgr/executor.h +39 -6
- data/src/core/lib/iomgr/fork_posix.cc +12 -1
- data/src/core/lib/iomgr/iocp_windows.cc +9 -4
- data/src/core/lib/iomgr/lockfree_event.cc +5 -1
- data/src/core/lib/iomgr/port.h +15 -2
- data/src/core/lib/iomgr/resolve_address_posix.cc +3 -2
- data/src/core/lib/iomgr/resolve_address_windows.cc +3 -2
- data/src/core/lib/iomgr/resource_quota.cc +78 -0
- data/src/core/lib/iomgr/resource_quota.h +16 -0
- data/src/core/lib/iomgr/socket_mutator.cc +1 -1
- data/src/core/lib/iomgr/socket_mutator.h +1 -1
- data/src/core/lib/iomgr/socket_windows.cc +33 -0
- data/src/core/lib/iomgr/socket_windows.h +6 -0
- data/src/core/lib/iomgr/tcp_windows.cc +2 -2
- data/src/core/lib/iomgr/tcp_windows.h +2 -0
- data/src/core/lib/iomgr/timer.h +3 -2
- data/src/core/lib/json/json.cc +2 -1
- data/src/core/lib/security/credentials/jwt/json_token.h +2 -0
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +2 -0
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -1
- data/src/core/lib/security/security_connector/load_system_roots.h +29 -0
- data/src/core/lib/security/security_connector/load_system_roots_fallback.cc +32 -0
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +165 -0
- data/src/core/lib/security/security_connector/load_system_roots_linux.h +44 -0
- data/src/core/lib/security/security_connector/security_connector.cc +23 -4
- data/src/core/lib/security/transport/client_auth_filter.cc +0 -4
- data/src/core/lib/security/transport/server_auth_filter.cc +0 -2
- data/src/core/lib/surface/call.cc +7 -3
- data/src/core/lib/surface/channel.cc +18 -2
- data/src/core/lib/surface/completion_queue.cc +152 -15
- data/src/core/lib/surface/completion_queue.h +20 -1
- data/src/core/lib/surface/completion_queue_factory.cc +13 -4
- data/src/core/lib/surface/init.cc +2 -2
- data/src/core/lib/surface/init.h +0 -1
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/service_config.cc +2 -2
- data/src/core/lib/transport/service_config.h +3 -3
- data/src/core/lib/transport/transport.h +2 -0
- data/src/core/tsi/alts/crypt/aes_gcm.cc +2 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +8 -0
- data/src/core/tsi/grpc_shadow_boringssl.h +3006 -0
- data/src/core/tsi/ssl/session_cache/ssl_session.h +2 -0
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +5 -5
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +2 -0
- data/src/core/tsi/ssl_transport_security.cc +5 -3
- data/src/core/tsi/ssl_types.h +2 -0
- data/src/ruby/ext/grpc/extconf.rb +1 -26
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +12 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +18 -0
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/generic/client_stub_spec.rb +3 -3
- data/third_party/address_sorting/address_sorting.c +7 -2
- data/third_party/address_sorting/address_sorting_windows.c +43 -3
- data/third_party/address_sorting/include/address_sorting/address_sorting.h +3 -0
- metadata +40 -31
@@ -22,7 +22,6 @@
|
|
22
22
|
|
23
23
|
#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
|
24
24
|
#include "src/core/lib/iomgr/sockaddr.h"
|
25
|
-
#include "src/core/lib/iomgr/socket_utils_posix.h"
|
26
25
|
|
27
26
|
#include <string.h>
|
28
27
|
#include <sys/types.h>
|
@@ -50,6 +49,8 @@ static gpr_mu g_init_mu;
|
|
50
49
|
grpc_core::TraceFlag grpc_trace_cares_address_sorting(false,
|
51
50
|
"cares_address_sorting");
|
52
51
|
|
52
|
+
grpc_core::TraceFlag grpc_trace_cares_resolver(false, "cares_resolver");
|
53
|
+
|
53
54
|
struct grpc_ares_request {
|
54
55
|
/** indicates the DNS server to use, if specified */
|
55
56
|
struct ares_addr_port_node dns_server_addr;
|
@@ -215,7 +216,7 @@ static void on_hostbyname_done_locked(void* arg, int status, int timeouts,
|
|
215
216
|
memset(&addr, 0, addr_len);
|
216
217
|
memcpy(&addr.sin6_addr, hostent->h_addr_list[i - prev_naddr],
|
217
218
|
sizeof(struct in6_addr));
|
218
|
-
addr.sin6_family = static_cast<
|
219
|
+
addr.sin6_family = static_cast<unsigned char>(hostent->h_addrtype);
|
219
220
|
addr.sin6_port = hr->port;
|
220
221
|
grpc_lb_addresses_set_address(
|
221
222
|
*lb_addresses, i, &addr, addr_len,
|
@@ -236,7 +237,7 @@ static void on_hostbyname_done_locked(void* arg, int status, int timeouts,
|
|
236
237
|
memset(&addr, 0, addr_len);
|
237
238
|
memcpy(&addr.sin_addr, hostent->h_addr_list[i - prev_naddr],
|
238
239
|
sizeof(struct in_addr));
|
239
|
-
addr.sin_family = static_cast<
|
240
|
+
addr.sin_family = static_cast<unsigned char>(hostent->h_addrtype);
|
240
241
|
addr.sin_port = hr->port;
|
241
242
|
grpc_lb_addresses_set_address(
|
242
243
|
*lb_addresses, i, &addr, addr_len,
|
@@ -281,7 +282,7 @@ static void on_srv_query_done_locked(void* arg, int status, int timeouts,
|
|
281
282
|
grpc_ares_ev_driver_get_channel_locked(r->ev_driver);
|
282
283
|
for (struct ares_srv_reply* srv_it = reply; srv_it != nullptr;
|
283
284
|
srv_it = srv_it->next) {
|
284
|
-
if (
|
285
|
+
if (grpc_ares_query_ipv6()) {
|
285
286
|
grpc_ares_hostbyname_request* hr = create_hostbyname_request_locked(
|
286
287
|
r, srv_it->host, htons(srv_it->port), true /* is_balancer */);
|
287
288
|
ares_gethostbyname(*channel, hr->host, AF_INET6,
|
@@ -452,7 +453,7 @@ static grpc_ares_request* grpc_dns_lookup_ares_locked_impl(
|
|
452
453
|
}
|
453
454
|
}
|
454
455
|
r->pending_queries = 1;
|
455
|
-
if (
|
456
|
+
if (grpc_ares_query_ipv6()) {
|
456
457
|
hr = create_hostbyname_request_locked(r, host, strhtons(port),
|
457
458
|
false /* is_balancer */);
|
458
459
|
ares_gethostbyname(*channel, hr->host, AF_INET6, on_hostbyname_done_locked,
|
@@ -28,6 +28,13 @@
|
|
28
28
|
|
29
29
|
extern grpc_core::TraceFlag grpc_trace_cares_address_sorting;
|
30
30
|
|
31
|
+
extern grpc_core::TraceFlag grpc_trace_cares_resolver;
|
32
|
+
|
33
|
+
#define GRPC_CARES_TRACE_LOG(format, ...) \
|
34
|
+
if (grpc_trace_cares_resolver.enabled()) { \
|
35
|
+
gpr_log(GPR_DEBUG, "(c-ares resolver) " format, __VA_ARGS__); \
|
36
|
+
}
|
37
|
+
|
31
38
|
typedef struct grpc_ares_request grpc_ares_request;
|
32
39
|
|
33
40
|
/* Asynchronously resolve \a name. Use \a default_port if a port isn't
|
@@ -70,6 +77,10 @@ void grpc_ares_cleanup(void);
|
|
70
77
|
* and destroys the grpc_ares_request */
|
71
78
|
void grpc_ares_complete_request_locked(grpc_ares_request* request);
|
72
79
|
|
80
|
+
/* Indicates whether or not AAAA queries should be attempted. */
|
81
|
+
/* E.g., return false if ipv6 is known to not be available. */
|
82
|
+
bool grpc_ares_query_ipv6();
|
83
|
+
|
73
84
|
/* Exposed only for testing */
|
74
85
|
void grpc_cares_wrapper_test_only_address_sorting_sort(
|
75
86
|
grpc_lb_addresses* lb_addrs);
|
@@ -0,0 +1,29 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2016 gRPC authors.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include <grpc/support/port_platform.h>
|
20
|
+
|
21
|
+
#include "src/core/lib/iomgr/port.h"
|
22
|
+
#if GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_ARES_EV_DRIVER)
|
23
|
+
|
24
|
+
#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
|
25
|
+
#include "src/core/lib/iomgr/socket_utils_posix.h"
|
26
|
+
|
27
|
+
bool grpc_ares_query_ipv6() { return grpc_ipv6_loopback_available(); }
|
28
|
+
|
29
|
+
#endif /* GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_ARES_EV_DRIVER) */
|
@@ -0,0 +1,29 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2016 gRPC authors.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include <grpc/support/port_platform.h>
|
20
|
+
|
21
|
+
#include "src/core/lib/iomgr/port.h"
|
22
|
+
#if GRPC_ARES == 1 && defined(GPR_WINDOWS)
|
23
|
+
|
24
|
+
#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
|
25
|
+
#include "src/core/lib/iomgr/socket_windows.h"
|
26
|
+
|
27
|
+
bool grpc_ares_query_ipv6() { return grpc_ipv6_loopback_available(); }
|
28
|
+
|
29
|
+
#endif /* GRPC_ARES == 1 && defined(GPR_WINDOWS) */
|
@@ -58,6 +58,8 @@ class NativeDnsResolver : public Resolver {
|
|
58
58
|
|
59
59
|
void RequestReresolutionLocked() override;
|
60
60
|
|
61
|
+
void ResetBackoffLocked() override;
|
62
|
+
|
61
63
|
void ShutdownLocked() override;
|
62
64
|
|
63
65
|
private:
|
@@ -158,6 +160,13 @@ void NativeDnsResolver::RequestReresolutionLocked() {
|
|
158
160
|
}
|
159
161
|
}
|
160
162
|
|
163
|
+
void NativeDnsResolver::ResetBackoffLocked() {
|
164
|
+
if (have_next_resolution_timer_) {
|
165
|
+
grpc_timer_cancel(&next_resolution_timer_);
|
166
|
+
}
|
167
|
+
backoff_.Reset();
|
168
|
+
}
|
169
|
+
|
161
170
|
void NativeDnsResolver::ShutdownLocked() {
|
162
171
|
if (have_next_resolution_timer_) {
|
163
172
|
grpc_timer_cancel(&next_resolution_timer_);
|
@@ -132,6 +132,8 @@ struct grpc_subchannel {
|
|
132
132
|
bool have_alarm;
|
133
133
|
/** have we started the backoff loop */
|
134
134
|
bool backoff_begun;
|
135
|
+
// reset_backoff() was called while alarm was pending
|
136
|
+
bool deferred_reset_backoff;
|
135
137
|
/** our alarm */
|
136
138
|
grpc_timer alarm;
|
137
139
|
|
@@ -390,8 +392,8 @@ grpc_subchannel* grpc_subchannel_create(grpc_connector* connector,
|
|
390
392
|
}
|
391
393
|
|
392
394
|
grpc_core::channelz::SubchannelNode* grpc_subchannel_get_channelz_node(
|
393
|
-
grpc_subchannel*
|
394
|
-
return
|
395
|
+
grpc_subchannel* subchannel) {
|
396
|
+
return subchannel->channelz_subchannel.get();
|
395
397
|
}
|
396
398
|
|
397
399
|
static void continue_connect_locked(grpc_subchannel* c) {
|
@@ -403,7 +405,7 @@ static void continue_connect_locked(grpc_subchannel* c) {
|
|
403
405
|
args.deadline = std::max(c->next_attempt_deadline, min_deadline);
|
404
406
|
args.channel_args = c->args;
|
405
407
|
grpc_connectivity_state_set(&c->state_tracker, GRPC_CHANNEL_CONNECTING,
|
406
|
-
GRPC_ERROR_NONE, "
|
408
|
+
GRPC_ERROR_NONE, "connecting");
|
407
409
|
grpc_connector_connect(c->connector, &args, &c->connecting_result,
|
408
410
|
&c->on_connected);
|
409
411
|
}
|
@@ -440,6 +442,9 @@ static void on_alarm(void* arg, grpc_error* error) {
|
|
440
442
|
if (c->disconnected) {
|
441
443
|
error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Disconnected",
|
442
444
|
&error, 1);
|
445
|
+
} else if (c->deferred_reset_backoff) {
|
446
|
+
c->deferred_reset_backoff = false;
|
447
|
+
error = GRPC_ERROR_NONE;
|
443
448
|
} else {
|
444
449
|
GRPC_ERROR_REF(error);
|
445
450
|
}
|
@@ -459,25 +464,20 @@ static void maybe_start_connecting_locked(grpc_subchannel* c) {
|
|
459
464
|
/* Don't try to connect if we're already disconnected */
|
460
465
|
return;
|
461
466
|
}
|
462
|
-
|
463
467
|
if (c->connecting) {
|
464
468
|
/* Already connecting: don't restart */
|
465
469
|
return;
|
466
470
|
}
|
467
|
-
|
468
471
|
if (c->connected_subchannel != nullptr) {
|
469
472
|
/* Already connected: don't restart */
|
470
473
|
return;
|
471
474
|
}
|
472
|
-
|
473
475
|
if (!grpc_connectivity_state_has_watchers(&c->state_tracker)) {
|
474
476
|
/* Nobody is interested in connecting: so don't just yet */
|
475
477
|
return;
|
476
478
|
}
|
477
|
-
|
478
479
|
c->connecting = true;
|
479
480
|
GRPC_SUBCHANNEL_WEAK_REF(c, "connecting");
|
480
|
-
|
481
481
|
if (!c->backoff_begun) {
|
482
482
|
c->backoff_begun = true;
|
483
483
|
continue_connect_locked(c);
|
@@ -675,6 +675,19 @@ static void on_subchannel_connected(void* arg, grpc_error* error) {
|
|
675
675
|
grpc_channel_args_destroy(delete_channel_args);
|
676
676
|
}
|
677
677
|
|
678
|
+
void grpc_subchannel_reset_backoff(grpc_subchannel* subchannel) {
|
679
|
+
gpr_mu_lock(&subchannel->mu);
|
680
|
+
if (subchannel->have_alarm) {
|
681
|
+
subchannel->deferred_reset_backoff = true;
|
682
|
+
grpc_timer_cancel(&subchannel->alarm);
|
683
|
+
} else {
|
684
|
+
subchannel->backoff_begun = false;
|
685
|
+
subchannel->backoff->Reset();
|
686
|
+
maybe_start_connecting_locked(subchannel);
|
687
|
+
}
|
688
|
+
gpr_mu_unlock(&subchannel->mu);
|
689
|
+
}
|
690
|
+
|
678
691
|
/*
|
679
692
|
* grpc_subchannel_call implementation
|
680
693
|
*/
|
@@ -145,6 +145,13 @@ grpc_subchannel_get_connected_subchannel(grpc_subchannel* c);
|
|
145
145
|
const grpc_subchannel_key* grpc_subchannel_get_key(
|
146
146
|
const grpc_subchannel* subchannel);
|
147
147
|
|
148
|
+
// Resets the connection backoff of the subchannel.
|
149
|
+
// TODO(roth): Move connection backoff out of subchannels and up into LB
|
150
|
+
// policy code (probably by adding a SubchannelGroup between
|
151
|
+
// SubchannelList and SubchannelData), at which point this method can
|
152
|
+
// go away.
|
153
|
+
void grpc_subchannel_reset_backoff(grpc_subchannel* subchannel);
|
154
|
+
|
148
155
|
/** continue processing a transport op */
|
149
156
|
void grpc_subchannel_call_process_op(grpc_subchannel_call* subchannel_call,
|
150
157
|
grpc_transport_stream_op_batch* op);
|
@@ -94,7 +94,7 @@ grpc_error* init_channel_elem(grpc_channel_element* elem,
|
|
94
94
|
if (default_authority_arg == nullptr) {
|
95
95
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
96
96
|
"GRPC_ARG_DEFAULT_AUTHORITY channel arg. not found. Note that direct "
|
97
|
-
"channels must
|
97
|
+
"channels must explicitly specify a value for this argument.");
|
98
98
|
}
|
99
99
|
const char* default_authority_str =
|
100
100
|
grpc_channel_arg_get_string(default_authority_arg);
|
@@ -812,6 +812,12 @@ static void set_write_state(grpc_chttp2_transport* t,
|
|
812
812
|
write_state_name(t->write_state),
|
813
813
|
write_state_name(st), reason));
|
814
814
|
t->write_state = st;
|
815
|
+
/* If the state is being reset back to idle, it means a write was just
|
816
|
+
* finished. Make sure all the run_after_write closures are scheduled.
|
817
|
+
*
|
818
|
+
* This is also our chance to close the transport if the transport was marked
|
819
|
+
* to be closed after all writes finish (for example, if we received a go-away
|
820
|
+
* from peer while we had some pending writes) */
|
815
821
|
if (st == GRPC_CHTTP2_WRITE_STATE_IDLE) {
|
816
822
|
GRPC_CLOSURE_LIST_SCHED(&t->run_after_write);
|
817
823
|
if (t->close_transport_on_writes_finished != nullptr) {
|
@@ -899,6 +905,22 @@ void grpc_chttp2_initiate_write(grpc_chttp2_transport* t,
|
|
899
905
|
grpc_chttp2_initiate_write_reason_string(reason));
|
900
906
|
t->is_first_write_in_batch = true;
|
901
907
|
GRPC_CHTTP2_REF_TRANSPORT(t, "writing");
|
908
|
+
/* Note that the 'write_action_begin_locked' closure is being scheduled
|
909
|
+
* on the 'finally_scheduler' of t->combiner. This means that
|
910
|
+
* 'write_action_begin_locked' is called only *after* all the other
|
911
|
+
* closures (some of which are potentially initiating more writes on the
|
912
|
+
* transport) are executed on the t->combiner.
|
913
|
+
*
|
914
|
+
* The reason for scheduling on finally_scheduler is to make sure we batch
|
915
|
+
* as many writes as possible. 'write_action_begin_locked' is the function
|
916
|
+
* that gathers all the relevant bytes (which are at various places in the
|
917
|
+
* grpc_chttp2_transport structure) and append them to 'outbuf' field in
|
918
|
+
* grpc_chttp2_transport thereby batching what would have been potentially
|
919
|
+
* multiple write operations.
|
920
|
+
*
|
921
|
+
* Also, 'write_action_begin_locked' only gathers the bytes into outbuf.
|
922
|
+
* It does not call the endpoint to write the bytes. That is done by the
|
923
|
+
* 'write_action' (which is scheduled by 'write_action_begin_locked') */
|
902
924
|
GRPC_CLOSURE_SCHED(
|
903
925
|
GRPC_CLOSURE_INIT(&t->write_action_begin_locked,
|
904
926
|
write_action_begin_locked, t,
|
@@ -1010,6 +1032,8 @@ static void write_action(void* gt, grpc_error* error) {
|
|
1010
1032
|
grpc_combiner_scheduler(t->combiner)));
|
1011
1033
|
}
|
1012
1034
|
|
1035
|
+
/* Callback from the grpc_endpoint after bytes have been written by calling
|
1036
|
+
* sendmsg */
|
1013
1037
|
static void write_action_end_locked(void* tp, grpc_error* error) {
|
1014
1038
|
GPR_TIMER_SCOPE("terminate_writing_with_lock", 0);
|
1015
1039
|
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
|
@@ -40,6 +40,7 @@ namespace chttp2 {
|
|
40
40
|
namespace {
|
41
41
|
|
42
42
|
static constexpr const int kTracePadding = 30;
|
43
|
+
static constexpr const uint32_t kMaxWindowUpdateSize = (1u << 31) - 1;
|
43
44
|
|
44
45
|
static char* fmt_int64_diff_str(int64_t old_val, int64_t new_val) {
|
45
46
|
char* str;
|
@@ -55,7 +56,7 @@ static char* fmt_int64_diff_str(int64_t old_val, int64_t new_val) {
|
|
55
56
|
|
56
57
|
static char* fmt_uint32_diff_str(uint32_t old_val, uint32_t new_val) {
|
57
58
|
char* str;
|
58
|
-
if (
|
59
|
+
if (old_val != new_val) {
|
59
60
|
gpr_asprintf(&str, "%" PRIu32 " -> %" PRIu32 "", old_val, new_val);
|
60
61
|
} else {
|
61
62
|
gpr_asprintf(&str, "%" PRIu32 "", old_val);
|
@@ -98,10 +99,12 @@ void FlowControlTrace::Finish() {
|
|
98
99
|
if (sfc_ != nullptr) {
|
99
100
|
srw_str = fmt_int64_diff_str(remote_window_delta_ + remote_window,
|
100
101
|
sfc_->remote_window_delta() + remote_window);
|
101
|
-
slw_str =
|
102
|
-
|
103
|
-
|
104
|
-
|
102
|
+
slw_str =
|
103
|
+
fmt_int64_diff_str(local_window_delta_ + acked_local_window,
|
104
|
+
sfc_->local_window_delta() + acked_local_window);
|
105
|
+
saw_str =
|
106
|
+
fmt_int64_diff_str(announced_window_delta_ + acked_local_window,
|
107
|
+
sfc_->announced_window_delta() + acked_local_window);
|
105
108
|
} else {
|
106
109
|
srw_str = gpr_leftpad("", ' ', kTracePadding);
|
107
110
|
slw_str = gpr_leftpad("", ' ', kTracePadding);
|
@@ -191,7 +194,7 @@ uint32_t TransportFlowControl::MaybeSendUpdate(bool writing_anyway) {
|
|
191
194
|
if ((writing_anyway || announced_window_ <= target_announced_window / 2) &&
|
192
195
|
announced_window_ != target_announced_window) {
|
193
196
|
const uint32_t announce = static_cast<uint32_t> GPR_CLAMP(
|
194
|
-
target_announced_window - announced_window_, 0,
|
197
|
+
target_announced_window - announced_window_, 0, kMaxWindowUpdateSize);
|
195
198
|
announced_window_ += announce;
|
196
199
|
return announce;
|
197
200
|
}
|
@@ -265,7 +268,7 @@ uint32_t StreamFlowControl::MaybeSendUpdate() {
|
|
265
268
|
FlowControlTrace trace("s updt sent", tfc_, this);
|
266
269
|
if (local_window_delta_ > announced_window_delta_) {
|
267
270
|
uint32_t announce = static_cast<uint32_t> GPR_CLAMP(
|
268
|
-
local_window_delta_ - announced_window_delta_, 0,
|
271
|
+
local_window_delta_ - announced_window_delta_, 0, kMaxWindowUpdateSize);
|
269
272
|
UpdateAnnouncedWindowDelta(tfc_, announce);
|
270
273
|
return announce;
|
271
274
|
}
|
@@ -174,7 +174,7 @@ void ChannelTrace::TraceEvent::RenderTraceEvent(grpc_json* json) const {
|
|
174
174
|
}
|
175
175
|
}
|
176
176
|
|
177
|
-
grpc_json* ChannelTrace::
|
177
|
+
grpc_json* ChannelTrace::RenderJson() const {
|
178
178
|
if (!max_list_size_)
|
179
179
|
return nullptr; // tracing is disabled if max_events == 0
|
180
180
|
grpc_json* json = grpc_json_create(GRPC_JSON_OBJECT);
|
@@ -71,7 +71,7 @@ class ChannelTrace {
|
|
71
71
|
|
72
72
|
// Creates and returns the raw grpc_json object, so a parent channelz
|
73
73
|
// object may incorporate the json before rendering.
|
74
|
-
grpc_json*
|
74
|
+
grpc_json* RenderJson() const;
|
75
75
|
|
76
76
|
private:
|
77
77
|
// Types of objects that can be references by trace events.
|
@@ -41,18 +41,22 @@
|
|
41
41
|
namespace grpc_core {
|
42
42
|
namespace channelz {
|
43
43
|
|
44
|
-
ChannelNode::ChannelNode(grpc_channel* channel, size_t channel_tracer_max_nodes
|
45
|
-
|
44
|
+
ChannelNode::ChannelNode(grpc_channel* channel, size_t channel_tracer_max_nodes,
|
45
|
+
bool is_top_level_channel)
|
46
|
+
: channel_(channel),
|
47
|
+
target_(nullptr),
|
48
|
+
channel_uuid_(-1),
|
49
|
+
is_top_level_channel_(is_top_level_channel) {
|
46
50
|
trace_.Init(channel_tracer_max_nodes);
|
47
51
|
target_ = UniquePtr<char>(grpc_channel_get_target(channel_));
|
48
|
-
channel_uuid_ = ChannelzRegistry::
|
52
|
+
channel_uuid_ = ChannelzRegistry::RegisterChannelNode(this);
|
49
53
|
gpr_atm_no_barrier_store(&last_call_started_millis_,
|
50
54
|
(gpr_atm)ExecCtx::Get()->Now());
|
51
55
|
}
|
52
56
|
|
53
57
|
ChannelNode::~ChannelNode() {
|
54
58
|
trace_.Destroy();
|
55
|
-
ChannelzRegistry::
|
59
|
+
ChannelzRegistry::UnregisterChannelNode(channel_uuid_);
|
56
60
|
}
|
57
61
|
|
58
62
|
void ChannelNode::RecordCallStarted() {
|
@@ -65,7 +69,7 @@ void ChannelNode::PopulateConnectivityState(grpc_json* json) {}
|
|
65
69
|
|
66
70
|
void ChannelNode::PopulateChildRefs(grpc_json* json) {}
|
67
71
|
|
68
|
-
|
72
|
+
grpc_json* ChannelNode::RenderJson() {
|
69
73
|
// We need to track these three json objects to build our object
|
70
74
|
grpc_json* top_level_json = grpc_json_create(GRPC_JSON_OBJECT);
|
71
75
|
grpc_json* json = top_level_json;
|
@@ -86,30 +90,32 @@ char* ChannelNode::RenderJSON() {
|
|
86
90
|
json = data;
|
87
91
|
json_iterator = nullptr;
|
88
92
|
PopulateConnectivityState(json);
|
93
|
+
GPR_ASSERT(target_.get() != nullptr);
|
89
94
|
json_iterator = grpc_json_create_child(
|
90
95
|
json_iterator, json, "target", target_.get(), GRPC_JSON_STRING, false);
|
91
96
|
// fill in the channel trace if applicable
|
92
|
-
grpc_json* trace = trace_->
|
97
|
+
grpc_json* trace = trace_->RenderJson();
|
93
98
|
if (trace != nullptr) {
|
94
|
-
// we
|
95
|
-
// ChannelTrace::
|
99
|
+
// we manually link up and fill the child since it was created for us in
|
100
|
+
// ChannelTrace::RenderJson
|
101
|
+
trace->key = "trace"; // this object is named trace in channelz.proto
|
96
102
|
json_iterator = grpc_json_link_child(json, trace, json_iterator);
|
97
|
-
trace->parent = json;
|
98
|
-
trace->value = nullptr;
|
99
|
-
trace->key = "trace";
|
100
|
-
trace->owns_value = false;
|
101
103
|
}
|
102
104
|
// reset the parent to be the data object.
|
103
105
|
json = data;
|
104
106
|
json_iterator = nullptr;
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
107
|
+
if (calls_started_ != 0) {
|
108
|
+
json_iterator = grpc_json_add_number_string_child(
|
109
|
+
json, json_iterator, "callsStarted", calls_started_);
|
110
|
+
}
|
111
|
+
if (calls_succeeded_ != 0) {
|
112
|
+
json_iterator = grpc_json_add_number_string_child(
|
113
|
+
json, json_iterator, "callsSucceeded", calls_succeeded_);
|
114
|
+
}
|
115
|
+
if (calls_failed_) {
|
116
|
+
json_iterator = grpc_json_add_number_string_child(
|
117
|
+
json, json_iterator, "callsFailed", calls_failed_);
|
118
|
+
}
|
113
119
|
gpr_timespec ts =
|
114
120
|
grpc_millis_to_timespec(last_call_started_millis_, GPR_CLOCK_REALTIME);
|
115
121
|
json_iterator =
|
@@ -118,25 +124,29 @@ char* ChannelNode::RenderJSON() {
|
|
118
124
|
json = top_level_json;
|
119
125
|
json_iterator = nullptr;
|
120
126
|
PopulateChildRefs(json);
|
127
|
+
return top_level_json;
|
128
|
+
}
|
121
129
|
|
122
|
-
|
123
|
-
|
124
|
-
|
130
|
+
char* ChannelNode::RenderJsonString() {
|
131
|
+
grpc_json* json = RenderJson();
|
132
|
+
char* json_str = grpc_json_dump_to_string(json, 0);
|
133
|
+
grpc_json_destroy(json);
|
125
134
|
return json_str;
|
126
135
|
}
|
127
136
|
|
128
137
|
RefCountedPtr<ChannelNode> ChannelNode::MakeChannelNode(
|
129
|
-
grpc_channel* channel, size_t channel_tracer_max_nodes
|
138
|
+
grpc_channel* channel, size_t channel_tracer_max_nodes,
|
139
|
+
bool is_top_level_channel) {
|
130
140
|
return MakeRefCounted<grpc_core::channelz::ChannelNode>(
|
131
|
-
channel, channel_tracer_max_nodes);
|
141
|
+
channel, channel_tracer_max_nodes, is_top_level_channel);
|
132
142
|
}
|
133
143
|
|
134
144
|
SubchannelNode::SubchannelNode() {
|
135
|
-
subchannel_uuid_ = ChannelzRegistry::
|
145
|
+
subchannel_uuid_ = ChannelzRegistry::RegisterSubchannelNode(this);
|
136
146
|
}
|
137
147
|
|
138
148
|
SubchannelNode::~SubchannelNode() {
|
139
|
-
ChannelzRegistry::
|
149
|
+
ChannelzRegistry::UnregisterSubchannelNode(subchannel_uuid_);
|
140
150
|
}
|
141
151
|
|
142
152
|
} // namespace channelz
|