grpc 1.17.1 → 1.18.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 +1228 -988
- data/etc/roots.pem +242 -30
- data/include/grpc/grpc.h +2 -1
- data/include/grpc/grpc_security_constants.h +3 -3
- data/include/grpc/impl/codegen/atm_gcc_sync.h +2 -0
- data/include/grpc/impl/codegen/atm_windows.h +2 -0
- data/include/grpc/impl/codegen/compression_types.h +2 -1
- data/include/grpc/impl/codegen/grpc_types.h +1 -1
- data/include/grpc/impl/codegen/port_platform.h +9 -0
- data/src/core/ext/filters/client_channel/client_channel.cc +163 -882
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +2 -4
- data/src/core/ext/filters/client_channel/health/health_check_client.h +2 -3
- data/src/core/ext/filters/client_channel/lb_policy.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy.h +8 -17
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +176 -216
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +20 -23
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +49 -52
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +13 -35
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +31 -30
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +69 -225
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc +20 -23
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +2 -84
- data/src/core/ext/filters/client_channel/request_routing.cc +936 -0
- data/src/core/ext/filters/client_channel/request_routing.h +177 -0
- data/src/core/ext/filters/client_channel/resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver.h +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +37 -26
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +30 -18
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +119 -100
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +8 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +5 -4
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc +2 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +12 -14
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +5 -9
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +2 -1
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +1 -2
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +17 -17
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +45 -52
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +13 -17
- data/src/core/ext/filters/client_channel/server_address.cc +103 -0
- data/src/core/ext/filters/client_channel/server_address.h +108 -0
- data/src/core/ext/filters/client_channel/subchannel.cc +10 -8
- data/src/core/ext/filters/client_channel/subchannel.h +9 -6
- data/src/core/ext/filters/client_channel/subchannel_index.cc +20 -27
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +3 -2
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +8 -9
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +1 -1
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +1 -1
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +8 -11
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +24 -54
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +3 -1
- data/src/core/ext/transport/chttp2/transport/context_list.cc +67 -0
- data/src/core/ext/transport/chttp2/transport/context_list.h +53 -0
- data/src/core/ext/transport/chttp2/transport/internal.h +38 -11
- data/src/core/ext/transport/chttp2/transport/writing.cc +5 -0
- data/src/core/ext/transport/inproc/inproc_transport.cc +1 -1
- data/src/core/lib/channel/channelz.cc +19 -18
- data/src/core/lib/channel/channelz.h +7 -1
- data/src/core/lib/channel/channelz_registry.cc +3 -2
- data/src/core/lib/debug/trace.cc +3 -0
- data/src/core/lib/debug/trace.h +5 -3
- data/src/core/lib/gpr/sync_posix.cc +96 -4
- data/src/core/lib/gprpp/inlined_vector.h +25 -19
- data/src/core/lib/gprpp/memory.h +2 -11
- data/src/core/lib/gprpp/orphanable.h +18 -82
- data/src/core/lib/gprpp/ref_counted.h +75 -84
- data/src/core/lib/gprpp/ref_counted_ptr.h +22 -17
- data/src/core/lib/http/httpcli_security_connector.cc +101 -94
- data/src/core/lib/http/parser.h +5 -5
- data/src/core/lib/iomgr/buffer_list.cc +16 -5
- data/src/core/lib/iomgr/buffer_list.h +10 -3
- data/src/core/lib/iomgr/call_combiner.cc +50 -2
- data/src/core/lib/iomgr/call_combiner.h +29 -2
- data/src/core/lib/iomgr/dynamic_annotations.h +67 -0
- data/src/core/lib/iomgr/endpoint.cc +4 -0
- data/src/core/lib/iomgr/endpoint.h +3 -0
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +2 -2
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +4 -0
- data/src/core/lib/iomgr/ev_epollex_linux.cc +4 -0
- data/src/core/lib/iomgr/ev_poll_posix.cc +4 -0
- data/src/core/lib/iomgr/ev_posix.cc +15 -7
- data/src/core/lib/iomgr/ev_posix.h +10 -0
- data/src/core/lib/iomgr/exec_ctx.cc +13 -0
- data/src/core/lib/iomgr/fork_posix.cc +1 -1
- data/src/core/lib/iomgr/internal_errqueue.cc +36 -3
- data/src/core/lib/iomgr/internal_errqueue.h +7 -1
- data/src/core/lib/iomgr/iomgr.cc +7 -0
- data/src/core/lib/iomgr/iomgr.h +4 -0
- data/src/core/lib/iomgr/iomgr_custom.cc +3 -1
- data/src/core/lib/iomgr/iomgr_internal.cc +4 -0
- data/src/core/lib/iomgr/iomgr_internal.h +4 -0
- data/src/core/lib/iomgr/iomgr_posix.cc +6 -1
- data/src/core/lib/iomgr/iomgr_windows.cc +4 -1
- data/src/core/lib/iomgr/port.h +1 -2
- data/src/core/lib/iomgr/resource_quota.cc +1 -0
- data/src/core/lib/iomgr/sockaddr_utils.cc +1 -0
- data/src/core/lib/iomgr/tcp_custom.cc +4 -1
- data/src/core/lib/iomgr/tcp_posix.cc +95 -35
- data/src/core/lib/iomgr/tcp_windows.cc +4 -1
- data/src/core/lib/iomgr/timer_manager.cc +6 -0
- data/src/core/lib/security/context/security_context.cc +75 -108
- data/src/core/lib/security/context/security_context.h +59 -35
- data/src/core/lib/security/credentials/alts/alts_credentials.cc +36 -48
- data/src/core/lib/security/credentials/alts/alts_credentials.h +37 -10
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +97 -157
- data/src/core/lib/security/credentials/composite/composite_credentials.h +60 -24
- data/src/core/lib/security/credentials/credentials.cc +18 -142
- data/src/core/lib/security/credentials/credentials.h +119 -95
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +46 -71
- data/src/core/lib/security/credentials/fake/fake_credentials.h +23 -5
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +144 -51
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +28 -5
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +27 -35
- data/src/core/lib/security/credentials/iam/iam_credentials.h +18 -4
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +60 -69
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +29 -10
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +2 -0
- data/src/core/lib/security/credentials/local/local_credentials.cc +19 -32
- data/src/core/lib/security/credentials/local/local_credentials.h +32 -11
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +130 -149
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +74 -29
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +59 -77
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +40 -17
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +66 -83
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +58 -15
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +152 -177
- data/src/core/lib/security/security_connector/alts/alts_security_connector.h +12 -10
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +210 -215
- data/src/core/lib/security/security_connector/fake/fake_security_connector.h +9 -6
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +176 -169
- data/src/core/lib/security/security_connector/local/local_security_connector.h +10 -9
- data/src/core/lib/security/security_connector/security_connector.cc +41 -124
- data/src/core/lib/security/security_connector/security_connector.h +102 -105
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +348 -370
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.h +14 -12
- data/src/core/lib/security/security_connector/ssl_utils.cc +13 -9
- data/src/core/lib/security/security_connector/ssl_utils.h +3 -1
- data/src/core/lib/security/transport/client_auth_filter.cc +50 -50
- data/src/core/lib/security/transport/secure_endpoint.cc +7 -1
- data/src/core/lib/security/transport/security_handshaker.cc +82 -66
- data/src/core/lib/security/transport/server_auth_filter.cc +15 -13
- data/src/core/lib/surface/init.cc +1 -0
- data/src/core/lib/surface/server.cc +13 -11
- data/src/core/lib/surface/server.h +6 -6
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/metadata.cc +1 -0
- data/src/core/lib/transport/static_metadata.cc +228 -221
- data/src/core/lib/transport/static_metadata.h +75 -71
- data/src/core/lib/transport/transport.cc +2 -1
- data/src/core/lib/transport/transport.h +5 -1
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +9 -2
- data/src/core/tsi/ssl_transport_security.cc +35 -24
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +1 -1
- data/src/ruby/lib/grpc/generic/rpc_server.rb +61 -0
- data/src/ruby/lib/grpc/generic/service.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/checker.rb +2 -3
- data/src/ruby/spec/generic/rpc_server_spec.rb +22 -0
- data/src/ruby/spec/support/services.rb +1 -0
- metadata +37 -32
- data/src/core/ext/filters/client_channel/lb_policy_factory.cc +0 -163
@@ -110,14 +110,14 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
|
|
110
110
|
grpc_channel_args* args_with_authority =
|
111
111
|
grpc_channel_args_copy_and_add(args->args, args_to_add, num_args_to_add);
|
112
112
|
grpc_uri_destroy(server_uri);
|
113
|
-
grpc_channel_security_connector* subchannel_security_connector = nullptr;
|
114
113
|
// Create the security connector using the credentials and target name.
|
115
114
|
grpc_channel_args* new_args_from_connector = nullptr;
|
116
|
-
|
117
|
-
|
118
|
-
channel_credentials
|
119
|
-
|
120
|
-
|
115
|
+
grpc_core::RefCountedPtr<grpc_channel_security_connector>
|
116
|
+
subchannel_security_connector =
|
117
|
+
channel_credentials->create_security_connector(
|
118
|
+
/*call_creds=*/nullptr, authority.get(), args_with_authority,
|
119
|
+
&new_args_from_connector);
|
120
|
+
if (subchannel_security_connector == nullptr) {
|
121
121
|
gpr_log(GPR_ERROR,
|
122
122
|
"Failed to create secure subchannel for secure name '%s'",
|
123
123
|
authority.get());
|
@@ -125,15 +125,14 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
|
|
125
125
|
return nullptr;
|
126
126
|
}
|
127
127
|
grpc_arg new_security_connector_arg =
|
128
|
-
grpc_security_connector_to_arg(
|
128
|
+
grpc_security_connector_to_arg(subchannel_security_connector.get());
|
129
129
|
|
130
130
|
grpc_channel_args* new_args = grpc_channel_args_copy_and_add(
|
131
131
|
new_args_from_connector != nullptr ? new_args_from_connector
|
132
132
|
: args_with_authority,
|
133
133
|
&new_security_connector_arg, 1);
|
134
134
|
|
135
|
-
|
136
|
-
"lb_channel_create");
|
135
|
+
subchannel_security_connector.reset(DEBUG_LOCATION, "lb_channel_create");
|
137
136
|
if (new_args_from_connector != nullptr) {
|
138
137
|
grpc_channel_args_destroy(new_args_from_connector);
|
139
138
|
}
|
@@ -149,7 +149,7 @@ static void on_handshake_done(void* arg, grpc_error* error) {
|
|
149
149
|
grpc_server_setup_transport(
|
150
150
|
connection_state->svr_state->server, transport,
|
151
151
|
connection_state->accepting_pollset, args->args,
|
152
|
-
|
152
|
+
grpc_chttp2_transport_get_socket_node(transport), resource_user);
|
153
153
|
// Use notify_on_receive_settings callback to enforce the
|
154
154
|
// handshake deadline.
|
155
155
|
connection_state->transport =
|
@@ -61,7 +61,7 @@ void grpc_server_add_insecure_channel_from_fd(grpc_server* server,
|
|
61
61
|
grpc_endpoint_add_to_pollset(server_endpoint, pollsets[i]);
|
62
62
|
}
|
63
63
|
|
64
|
-
grpc_server_setup_transport(server, transport, nullptr, server_args,
|
64
|
+
grpc_server_setup_transport(server, transport, nullptr, server_args, nullptr);
|
65
65
|
grpc_chttp2_transport_start_reading(transport, nullptr, nullptr);
|
66
66
|
}
|
67
67
|
|
@@ -31,6 +31,7 @@
|
|
31
31
|
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
|
32
32
|
#include "src/core/lib/channel/channel_args.h"
|
33
33
|
#include "src/core/lib/channel/handshaker.h"
|
34
|
+
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
34
35
|
#include "src/core/lib/security/context/security_context.h"
|
35
36
|
#include "src/core/lib/security/credentials/credentials.h"
|
36
37
|
#include "src/core/lib/surface/api_trace.h"
|
@@ -40,9 +41,8 @@ int grpc_server_add_secure_http2_port(grpc_server* server, const char* addr,
|
|
40
41
|
grpc_server_credentials* creds) {
|
41
42
|
grpc_core::ExecCtx exec_ctx;
|
42
43
|
grpc_error* err = GRPC_ERROR_NONE;
|
43
|
-
grpc_server_security_connector
|
44
|
+
grpc_core::RefCountedPtr<grpc_server_security_connector> sc;
|
44
45
|
int port_num = 0;
|
45
|
-
grpc_security_status status;
|
46
46
|
grpc_channel_args* args = nullptr;
|
47
47
|
GRPC_API_TRACE(
|
48
48
|
"grpc_server_add_secure_http2_port("
|
@@ -54,30 +54,27 @@ int grpc_server_add_secure_http2_port(grpc_server* server, const char* addr,
|
|
54
54
|
"No credentials specified for secure server port (creds==NULL)");
|
55
55
|
goto done;
|
56
56
|
}
|
57
|
-
|
58
|
-
if (
|
57
|
+
sc = creds->create_security_connector();
|
58
|
+
if (sc == nullptr) {
|
59
59
|
char* msg;
|
60
60
|
gpr_asprintf(&msg,
|
61
61
|
"Unable to create secure server with credentials of type %s.",
|
62
|
-
creds->type);
|
63
|
-
err =
|
64
|
-
GRPC_ERROR_INT_SECURITY_STATUS, status);
|
62
|
+
creds->type());
|
63
|
+
err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
|
65
64
|
gpr_free(msg);
|
66
65
|
goto done;
|
67
66
|
}
|
68
67
|
// Create channel args.
|
69
68
|
grpc_arg args_to_add[2];
|
70
69
|
args_to_add[0] = grpc_server_credentials_to_arg(creds);
|
71
|
-
args_to_add[1] = grpc_security_connector_to_arg(
|
70
|
+
args_to_add[1] = grpc_security_connector_to_arg(sc.get());
|
72
71
|
args =
|
73
72
|
grpc_channel_args_copy_and_add(grpc_server_get_channel_args(server),
|
74
73
|
args_to_add, GPR_ARRAY_SIZE(args_to_add));
|
75
74
|
// Add server port.
|
76
75
|
err = grpc_chttp2_server_add_port(server, addr, args, &port_num);
|
77
76
|
done:
|
78
|
-
|
79
|
-
GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "server");
|
80
|
-
}
|
77
|
+
sc.reset(DEBUG_LOCATION, "server");
|
81
78
|
|
82
79
|
if (err != GRPC_ERROR_NONE) {
|
83
80
|
const char* msg = grpc_error_string(err);
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
*
|
3
|
-
* Copyright
|
3
|
+
* Copyright 2018 gRPC authors.
|
4
4
|
*
|
5
5
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
* you may not use this file except in compliance with the License.
|
@@ -31,6 +31,7 @@
|
|
31
31
|
#include <grpc/support/log.h>
|
32
32
|
#include <grpc/support/string_util.h>
|
33
33
|
|
34
|
+
#include "src/core/ext/transport/chttp2/transport/context_list.h"
|
34
35
|
#include "src/core/ext/transport/chttp2/transport/frame_data.h"
|
35
36
|
#include "src/core/ext/transport/chttp2/transport/internal.h"
|
36
37
|
#include "src/core/ext/transport/chttp2/transport/varint.h"
|
@@ -154,6 +155,7 @@ bool g_flow_control_enabled = true;
|
|
154
155
|
/*******************************************************************************
|
155
156
|
* CONSTRUCTION/DESTRUCTION/REFCOUNTING
|
156
157
|
*/
|
158
|
+
|
157
159
|
grpc_chttp2_transport::~grpc_chttp2_transport() {
|
158
160
|
size_t i;
|
159
161
|
|
@@ -168,6 +170,14 @@ grpc_chttp2_transport::~grpc_chttp2_transport() {
|
|
168
170
|
grpc_slice_buffer_destroy_internal(&outbuf);
|
169
171
|
grpc_chttp2_hpack_compressor_destroy(&hpack_compressor);
|
170
172
|
|
173
|
+
grpc_error* error =
|
174
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport destroyed");
|
175
|
+
// ContextList::Execute follows semantics of a callback function and does not
|
176
|
+
// take a ref on error
|
177
|
+
grpc_core::ContextList::Execute(cl, nullptr, error);
|
178
|
+
GRPC_ERROR_UNREF(error);
|
179
|
+
cl = nullptr;
|
180
|
+
|
171
181
|
grpc_slice_buffer_destroy_internal(&read_buffer);
|
172
182
|
grpc_chttp2_hpack_parser_destroy(&hpack_parser);
|
173
183
|
grpc_chttp2_goaway_parser_destroy(&goaway_parser);
|
@@ -202,38 +212,6 @@ grpc_chttp2_transport::~grpc_chttp2_transport() {
|
|
202
212
|
gpr_free(peer_string);
|
203
213
|
}
|
204
214
|
|
205
|
-
#ifndef NDEBUG
|
206
|
-
void grpc_chttp2_unref_transport(grpc_chttp2_transport* t, const char* reason,
|
207
|
-
const char* file, int line) {
|
208
|
-
if (grpc_trace_chttp2_refcount.enabled()) {
|
209
|
-
gpr_atm val = gpr_atm_no_barrier_load(&t->refs.count);
|
210
|
-
gpr_log(GPR_DEBUG, "chttp2:unref:%p %" PRIdPTR "->%" PRIdPTR " %s [%s:%d]",
|
211
|
-
t, val, val - 1, reason, file, line);
|
212
|
-
}
|
213
|
-
if (!gpr_unref(&t->refs)) return;
|
214
|
-
t->~grpc_chttp2_transport();
|
215
|
-
gpr_free(t);
|
216
|
-
}
|
217
|
-
|
218
|
-
void grpc_chttp2_ref_transport(grpc_chttp2_transport* t, const char* reason,
|
219
|
-
const char* file, int line) {
|
220
|
-
if (grpc_trace_chttp2_refcount.enabled()) {
|
221
|
-
gpr_atm val = gpr_atm_no_barrier_load(&t->refs.count);
|
222
|
-
gpr_log(GPR_DEBUG, "chttp2: ref:%p %" PRIdPTR "->%" PRIdPTR " %s [%s:%d]",
|
223
|
-
t, val, val + 1, reason, file, line);
|
224
|
-
}
|
225
|
-
gpr_ref(&t->refs);
|
226
|
-
}
|
227
|
-
#else
|
228
|
-
void grpc_chttp2_unref_transport(grpc_chttp2_transport* t) {
|
229
|
-
if (!gpr_unref(&t->refs)) return;
|
230
|
-
t->~grpc_chttp2_transport();
|
231
|
-
gpr_free(t);
|
232
|
-
}
|
233
|
-
|
234
|
-
void grpc_chttp2_ref_transport(grpc_chttp2_transport* t) { gpr_ref(&t->refs); }
|
235
|
-
#endif
|
236
|
-
|
237
215
|
static const grpc_transport_vtable* get_vtable(void);
|
238
216
|
|
239
217
|
/* Returns whether bdp is enabled */
|
@@ -485,7 +463,8 @@ static void init_keepalive_pings_if_enabled(grpc_chttp2_transport* t) {
|
|
485
463
|
grpc_chttp2_transport::grpc_chttp2_transport(
|
486
464
|
const grpc_channel_args* channel_args, grpc_endpoint* ep, bool is_client,
|
487
465
|
grpc_resource_user* resource_user)
|
488
|
-
:
|
466
|
+
: refs(1, &grpc_trace_chttp2_refcount),
|
467
|
+
ep(ep),
|
489
468
|
peer_string(grpc_endpoint_get_peer(ep)),
|
490
469
|
resource_user(resource_user),
|
491
470
|
combiner(grpc_combiner_create()),
|
@@ -495,8 +474,6 @@ grpc_chttp2_transport::grpc_chttp2_transport(
|
|
495
474
|
GPR_ASSERT(strlen(GRPC_CHTTP2_CLIENT_CONNECT_STRING) ==
|
496
475
|
GRPC_CHTTP2_CLIENT_CONNECT_STRLEN);
|
497
476
|
base.vtable = get_vtable();
|
498
|
-
/* one ref is for destroy */
|
499
|
-
gpr_ref_init(&refs, 1);
|
500
477
|
/* 8 is a random stab in the dark as to a good initial size: it's small enough
|
501
478
|
that it shouldn't waste memory for infrequently used connections, yet
|
502
479
|
large enough that the exponential growth should happen nicely when it's
|
@@ -1065,11 +1042,13 @@ static void write_action_begin_locked(void* gt, grpc_error* error_ignored) {
|
|
1065
1042
|
static void write_action(void* gt, grpc_error* error) {
|
1066
1043
|
GPR_TIMER_SCOPE("write_action", 0);
|
1067
1044
|
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(gt);
|
1045
|
+
void* cl = t->cl;
|
1046
|
+
t->cl = nullptr;
|
1068
1047
|
grpc_endpoint_write(
|
1069
1048
|
t->ep, &t->outbuf,
|
1070
1049
|
GRPC_CLOSURE_INIT(&t->write_action_end_locked, write_action_end_locked, t,
|
1071
1050
|
grpc_combiner_scheduler(t->combiner)),
|
1072
|
-
|
1051
|
+
cl);
|
1073
1052
|
}
|
1074
1053
|
|
1075
1054
|
/* Callback from the grpc_endpoint after bytes have been written by calling
|
@@ -1393,6 +1372,8 @@ static void perform_stream_op_locked(void* stream_op,
|
|
1393
1372
|
|
1394
1373
|
GRPC_STATS_INC_HTTP2_OP_BATCHES();
|
1395
1374
|
|
1375
|
+
s->context = op->payload->context;
|
1376
|
+
s->traced = op->is_traced;
|
1396
1377
|
if (grpc_http_trace.enabled()) {
|
1397
1378
|
char* str = grpc_transport_stream_op_batch_string(op);
|
1398
1379
|
gpr_log(GPR_INFO, "perform_stream_op_locked: %s; on_complete = %p", str,
|
@@ -2837,8 +2818,8 @@ Chttp2IncomingByteStream::Chttp2IncomingByteStream(
|
|
2837
2818
|
: ByteStream(frame_size, flags),
|
2838
2819
|
transport_(transport),
|
2839
2820
|
stream_(stream),
|
2821
|
+
refs_(2),
|
2840
2822
|
remaining_bytes_(frame_size) {
|
2841
|
-
gpr_ref_init(&refs_, 2);
|
2842
2823
|
GRPC_ERROR_UNREF(stream->byte_stream_error);
|
2843
2824
|
stream->byte_stream_error = GRPC_ERROR_NONE;
|
2844
2825
|
}
|
@@ -2863,14 +2844,6 @@ void Chttp2IncomingByteStream::Orphan() {
|
|
2863
2844
|
GRPC_ERROR_NONE);
|
2864
2845
|
}
|
2865
2846
|
|
2866
|
-
void Chttp2IncomingByteStream::Unref() {
|
2867
|
-
if (gpr_unref(&refs_)) {
|
2868
|
-
Delete(this);
|
2869
|
-
}
|
2870
|
-
}
|
2871
|
-
|
2872
|
-
void Chttp2IncomingByteStream::Ref() { gpr_ref(&refs_); }
|
2873
|
-
|
2874
2847
|
void Chttp2IncomingByteStream::NextLocked(void* arg,
|
2875
2848
|
grpc_error* error_ignored) {
|
2876
2849
|
Chttp2IncomingByteStream* bs = static_cast<Chttp2IncomingByteStream*>(arg);
|
@@ -3177,21 +3150,18 @@ static const grpc_transport_vtable vtable = {sizeof(grpc_chttp2_stream),
|
|
3177
3150
|
|
3178
3151
|
static const grpc_transport_vtable* get_vtable(void) { return &vtable; }
|
3179
3152
|
|
3180
|
-
|
3153
|
+
grpc_core::RefCountedPtr<grpc_core::channelz::SocketNode>
|
3154
|
+
grpc_chttp2_transport_get_socket_node(grpc_transport* transport) {
|
3181
3155
|
grpc_chttp2_transport* t =
|
3182
3156
|
reinterpret_cast<grpc_chttp2_transport*>(transport);
|
3183
|
-
|
3184
|
-
return t->channelz_socket->uuid();
|
3185
|
-
} else {
|
3186
|
-
return 0;
|
3187
|
-
}
|
3157
|
+
return t->channelz_socket;
|
3188
3158
|
}
|
3189
3159
|
|
3190
3160
|
grpc_transport* grpc_create_chttp2_transport(
|
3191
3161
|
const grpc_channel_args* channel_args, grpc_endpoint* ep, bool is_client,
|
3192
3162
|
grpc_resource_user* resource_user) {
|
3193
|
-
auto t =
|
3194
|
-
|
3163
|
+
auto t = grpc_core::New<grpc_chttp2_transport>(channel_args, ep, is_client,
|
3164
|
+
resource_user);
|
3195
3165
|
return &t->base;
|
3196
3166
|
}
|
3197
3167
|
|
@@ -21,6 +21,7 @@
|
|
21
21
|
|
22
22
|
#include <grpc/support/port_platform.h>
|
23
23
|
|
24
|
+
#include "src/core/lib/channel/channelz.h"
|
24
25
|
#include "src/core/lib/debug/trace.h"
|
25
26
|
#include "src/core/lib/iomgr/endpoint.h"
|
26
27
|
#include "src/core/lib/transport/transport.h"
|
@@ -35,7 +36,8 @@ grpc_transport* grpc_create_chttp2_transport(
|
|
35
36
|
const grpc_channel_args* channel_args, grpc_endpoint* ep, bool is_client,
|
36
37
|
grpc_resource_user* resource_user = nullptr);
|
37
38
|
|
38
|
-
|
39
|
+
grpc_core::RefCountedPtr<grpc_core::channelz::SocketNode>
|
40
|
+
grpc_chttp2_transport_get_socket_node(grpc_transport* transport);
|
39
41
|
|
40
42
|
/// Takes ownership of \a read_buffer, which (if non-NULL) contains
|
41
43
|
/// leftover bytes previously read from the endpoint (e.g., by handshakers).
|
@@ -0,0 +1,67 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2018 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/ext/transport/chttp2/transport/context_list.h"
|
22
|
+
|
23
|
+
namespace {
|
24
|
+
void (*write_timestamps_callback_g)(void*, grpc_core::Timestamps*,
|
25
|
+
grpc_error* error) = nullptr;
|
26
|
+
void* (*get_copied_context_fn_g)(void*) = nullptr;
|
27
|
+
} // namespace
|
28
|
+
|
29
|
+
namespace grpc_core {
|
30
|
+
void ContextList::Append(ContextList** head, grpc_chttp2_stream* s) {
|
31
|
+
if (get_copied_context_fn_g == nullptr ||
|
32
|
+
write_timestamps_callback_g == nullptr) {
|
33
|
+
return;
|
34
|
+
}
|
35
|
+
/* Create a new element in the list and add it at the front */
|
36
|
+
ContextList* elem = grpc_core::New<ContextList>();
|
37
|
+
elem->trace_context_ = get_copied_context_fn_g(s->context);
|
38
|
+
elem->byte_offset_ = s->byte_counter;
|
39
|
+
elem->next_ = *head;
|
40
|
+
*head = elem;
|
41
|
+
}
|
42
|
+
|
43
|
+
void ContextList::Execute(void* arg, grpc_core::Timestamps* ts,
|
44
|
+
grpc_error* error) {
|
45
|
+
ContextList* head = static_cast<ContextList*>(arg);
|
46
|
+
ContextList* to_be_freed;
|
47
|
+
while (head != nullptr) {
|
48
|
+
if (write_timestamps_callback_g) {
|
49
|
+
ts->byte_offset = static_cast<uint32_t>(head->byte_offset_);
|
50
|
+
write_timestamps_callback_g(head->trace_context_, ts, error);
|
51
|
+
}
|
52
|
+
to_be_freed = head;
|
53
|
+
head = head->next_;
|
54
|
+
grpc_core::Delete(to_be_freed);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
void grpc_http2_set_write_timestamps_callback(void (*fn)(void*,
|
59
|
+
grpc_core::Timestamps*,
|
60
|
+
grpc_error* error)) {
|
61
|
+
write_timestamps_callback_g = fn;
|
62
|
+
}
|
63
|
+
|
64
|
+
void grpc_http2_set_fn_get_copied_context(void* (*fn)(void*)) {
|
65
|
+
get_copied_context_fn_g = fn;
|
66
|
+
}
|
67
|
+
} /* namespace grpc_core */
|
@@ -0,0 +1,53 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2018 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
|
+
#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CONTEXT_LIST_H
|
20
|
+
#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CONTEXT_LIST_H
|
21
|
+
|
22
|
+
#include <grpc/support/port_platform.h>
|
23
|
+
|
24
|
+
#include "src/core/lib/iomgr/buffer_list.h"
|
25
|
+
|
26
|
+
#include "src/core/ext/transport/chttp2/transport/internal.h"
|
27
|
+
|
28
|
+
namespace grpc_core {
|
29
|
+
/** A list of RPC Contexts */
|
30
|
+
class ContextList {
|
31
|
+
public:
|
32
|
+
/* Creates a new element with \a context as the value and appends it to the
|
33
|
+
* list. */
|
34
|
+
static void Append(ContextList** head, grpc_chttp2_stream* s);
|
35
|
+
|
36
|
+
/* Executes a function \a fn with each context in the list and \a ts. It also
|
37
|
+
* frees up the entire list after this operation. It is intended as a callback
|
38
|
+
* and hence does not take a ref on \a error */
|
39
|
+
static void Execute(void* arg, grpc_core::Timestamps* ts, grpc_error* error);
|
40
|
+
|
41
|
+
private:
|
42
|
+
void* trace_context_ = nullptr;
|
43
|
+
ContextList* next_ = nullptr;
|
44
|
+
size_t byte_offset_ = 0;
|
45
|
+
};
|
46
|
+
|
47
|
+
void grpc_http2_set_write_timestamps_callback(void (*fn)(void*,
|
48
|
+
grpc_core::Timestamps*,
|
49
|
+
grpc_error* error));
|
50
|
+
void grpc_http2_set_fn_get_copied_context(void* (*fn)(void*));
|
51
|
+
} /* namespace grpc_core */
|
52
|
+
|
53
|
+
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CONTEXT_LIST_H */
|
@@ -45,6 +45,10 @@
|
|
45
45
|
#include "src/core/lib/transport/connectivity_state.h"
|
46
46
|
#include "src/core/lib/transport/transport_impl.h"
|
47
47
|
|
48
|
+
namespace grpc_core {
|
49
|
+
class ContextList;
|
50
|
+
}
|
51
|
+
|
48
52
|
/* streams are kept in various linked lists depending on what things need to
|
49
53
|
happen to them... this enum labels each list */
|
50
54
|
typedef enum {
|
@@ -232,8 +236,12 @@ class Chttp2IncomingByteStream : public ByteStream {
|
|
232
236
|
// alone for now. We can revisit this once we're able to link against
|
233
237
|
// libc++, at which point we can eliminate New<> and Delete<> and
|
234
238
|
// switch to std::shared_ptr<>.
|
235
|
-
void Ref();
|
236
|
-
void Unref()
|
239
|
+
void Ref() { refs_.Ref(); }
|
240
|
+
void Unref() {
|
241
|
+
if (refs_.Unref()) {
|
242
|
+
grpc_core::Delete(this);
|
243
|
+
}
|
244
|
+
}
|
237
245
|
|
238
246
|
void PublishError(grpc_error* error);
|
239
247
|
|
@@ -252,7 +260,7 @@ class Chttp2IncomingByteStream : public ByteStream {
|
|
252
260
|
grpc_chttp2_transport* transport_; // Immutable.
|
253
261
|
grpc_chttp2_stream* stream_; // Immutable.
|
254
262
|
|
255
|
-
|
263
|
+
grpc_core::RefCount refs_;
|
256
264
|
|
257
265
|
/* Accessed only by transport thread when stream->pending_byte_stream == false
|
258
266
|
* Accessed only by application thread when stream->pending_byte_stream ==
|
@@ -286,7 +294,7 @@ struct grpc_chttp2_transport {
|
|
286
294
|
~grpc_chttp2_transport();
|
287
295
|
|
288
296
|
grpc_transport base; /* must be first */
|
289
|
-
|
297
|
+
grpc_core::RefCount refs;
|
290
298
|
grpc_endpoint* ep;
|
291
299
|
char* peer_string;
|
292
300
|
|
@@ -481,7 +489,7 @@ struct grpc_chttp2_transport {
|
|
481
489
|
bool keepalive_permit_without_calls = false;
|
482
490
|
/** keep-alive state machine state */
|
483
491
|
grpc_chttp2_keepalive_state keepalive_state;
|
484
|
-
|
492
|
+
grpc_core::ContextList* cl = nullptr;
|
485
493
|
grpc_core::RefCountedPtr<grpc_core::channelz::SocketNode> channelz_socket;
|
486
494
|
uint32_t num_messages_in_next_write = 0;
|
487
495
|
};
|
@@ -498,6 +506,7 @@ struct grpc_chttp2_stream {
|
|
498
506
|
const void* server_data, gpr_arena* arena);
|
499
507
|
~grpc_chttp2_stream();
|
500
508
|
|
509
|
+
void* context;
|
501
510
|
grpc_chttp2_transport* t;
|
502
511
|
grpc_stream_refcount* refcount;
|
503
512
|
|
@@ -633,8 +642,12 @@ struct grpc_chttp2_stream {
|
|
633
642
|
/** Whether bytes stored in unprocessed_incoming_byte_stream is decompressed
|
634
643
|
*/
|
635
644
|
bool unprocessed_incoming_frames_decompressed = false;
|
645
|
+
/** Whether the bytes needs to be traced using Fathom */
|
646
|
+
bool traced = false;
|
636
647
|
/** gRPC header bytes that are already decompressed */
|
637
648
|
size_t decompressed_header_bytes = 0;
|
649
|
+
/** Byte counter for number of bytes written */
|
650
|
+
size_t byte_counter = 0;
|
638
651
|
};
|
639
652
|
|
640
653
|
/** Transport writing call flow:
|
@@ -779,15 +792,29 @@ void grpc_chttp2_stream_unref(grpc_chttp2_stream* s);
|
|
779
792
|
grpc_chttp2_ref_transport(t, r, __FILE__, __LINE__)
|
780
793
|
#define GRPC_CHTTP2_UNREF_TRANSPORT(t, r) \
|
781
794
|
grpc_chttp2_unref_transport(t, r, __FILE__, __LINE__)
|
782
|
-
void grpc_chttp2_unref_transport(grpc_chttp2_transport* t,
|
783
|
-
|
784
|
-
|
785
|
-
|
795
|
+
inline void grpc_chttp2_unref_transport(grpc_chttp2_transport* t,
|
796
|
+
const char* reason, const char* file,
|
797
|
+
int line) {
|
798
|
+
if (t->refs.Unref(grpc_core::DebugLocation(file, line), reason)) {
|
799
|
+
grpc_core::Delete(t);
|
800
|
+
}
|
801
|
+
}
|
802
|
+
inline void grpc_chttp2_ref_transport(grpc_chttp2_transport* t,
|
803
|
+
const char* reason, const char* file,
|
804
|
+
int line) {
|
805
|
+
t->refs.Ref(grpc_core::DebugLocation(file, line), reason);
|
806
|
+
}
|
786
807
|
#else
|
787
808
|
#define GRPC_CHTTP2_REF_TRANSPORT(t, r) grpc_chttp2_ref_transport(t)
|
788
809
|
#define GRPC_CHTTP2_UNREF_TRANSPORT(t, r) grpc_chttp2_unref_transport(t)
|
789
|
-
void grpc_chttp2_unref_transport(grpc_chttp2_transport* t)
|
790
|
-
|
810
|
+
inline void grpc_chttp2_unref_transport(grpc_chttp2_transport* t) {
|
811
|
+
if (t->refs.Unref()) {
|
812
|
+
grpc_core::Delete(t);
|
813
|
+
}
|
814
|
+
}
|
815
|
+
inline void grpc_chttp2_ref_transport(grpc_chttp2_transport* t) {
|
816
|
+
t->refs.Ref();
|
817
|
+
}
|
791
818
|
#endif
|
792
819
|
|
793
820
|
void grpc_chttp2_ack_ping(grpc_chttp2_transport* t, uint64_t id);
|