grpc 1.16.0 → 1.17.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 +299 -133
- data/include/grpc/grpc.h +11 -1
- data/include/grpc/grpc_posix.h +0 -8
- data/include/grpc/impl/codegen/grpc_types.h +3 -0
- data/src/core/ext/filters/client_channel/client_channel.cc +336 -345
- data/src/core/ext/filters/client_channel/client_channel.h +6 -2
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +3 -1
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +0 -7
- data/src/core/ext/filters/client_channel/health/health.pb.c +23 -0
- data/src/core/ext/filters/client_channel/health/health.pb.h +73 -0
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +652 -0
- data/src/core/ext/filters/client_channel/health/health_check_client.h +173 -0
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +2 -1
- data/src/core/ext/filters/client_channel/http_proxy.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy.h +17 -14
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +15 -11
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +21 -15
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +18 -10
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +12 -9
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +19 -8
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +1832 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +36 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h +36 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc +107 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc +85 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h +72 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc +307 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +89 -0
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +5 -0
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +4 -0
- data/src/core/ext/filters/client_channel/parse_address.h +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +19 -22
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +41 -39
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +3 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +4 -1
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +15 -2
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +5 -1
- data/src/core/ext/filters/client_channel/resolver_factory.h +1 -1
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +384 -0
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +146 -0
- data/src/core/ext/filters/client_channel/subchannel.cc +361 -103
- data/src/core/ext/filters/client_channel/subchannel.h +14 -8
- data/src/core/ext/filters/deadline/deadline_filter.cc +19 -23
- data/src/core/ext/filters/deadline/deadline_filter.h +9 -13
- data/src/core/ext/filters/http/client/http_client_filter.cc +29 -19
- data/src/core/ext/filters/http/client_authority_filter.cc +2 -3
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +28 -16
- data/src/core/ext/filters/http/server/http_server_filter.cc +31 -20
- data/src/core/ext/filters/message_size/message_size_filter.cc +50 -45
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +13 -6
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +1 -1
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +58 -8
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +175 -173
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +4 -10
- data/src/core/ext/transport/chttp2/transport/frame_data.h +10 -12
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +28 -25
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +0 -12
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +12 -9
- data/src/core/ext/transport/chttp2/transport/internal.h +109 -94
- data/src/core/ext/transport/chttp2/transport/parsing.cc +4 -2
- data/src/core/ext/transport/inproc/inproc_transport.cc +280 -300
- data/src/core/lib/channel/channel_stack.cc +5 -4
- data/src/core/lib/channel/channel_stack.h +4 -4
- data/src/core/lib/channel/channel_stack_builder.cc +14 -2
- data/src/core/lib/channel/channel_stack_builder.h +8 -0
- data/src/core/lib/channel/channel_trace.cc +6 -2
- data/src/core/lib/channel/channelz.cc +137 -5
- data/src/core/lib/channel/channelz.h +32 -6
- data/src/core/lib/channel/channelz_registry.cc +134 -28
- data/src/core/lib/channel/channelz_registry.h +25 -3
- data/src/core/lib/channel/context.h +4 -4
- data/src/core/lib/channel/handshaker.cc +7 -6
- data/src/core/lib/channel/handshaker.h +7 -8
- data/src/core/lib/channel/handshaker_factory.cc +3 -2
- data/src/core/lib/channel/handshaker_factory.h +2 -0
- data/src/core/lib/channel/handshaker_registry.cc +6 -2
- data/src/core/lib/channel/handshaker_registry.h +1 -0
- data/src/core/lib/gpr/arena.cc +84 -37
- data/src/core/lib/gpr/arena.h +2 -0
- data/src/core/lib/gpr/mpscq.h +4 -2
- data/src/core/lib/gprpp/inlined_vector.h +8 -0
- data/src/core/lib/gprpp/ref_counted.h +105 -18
- data/src/core/lib/gprpp/ref_counted_ptr.h +11 -0
- data/src/core/lib/http/httpcli_security_connector.cc +7 -4
- data/src/core/lib/iomgr/call_combiner.cc +2 -0
- data/src/core/lib/iomgr/call_combiner.h +2 -2
- data/src/core/lib/iomgr/closure.h +1 -0
- data/src/core/lib/iomgr/error.cc +16 -31
- data/src/core/lib/iomgr/error.h +29 -4
- data/src/core/lib/iomgr/error_internal.h +0 -2
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +7 -3
- data/src/core/lib/iomgr/ev_posix.cc +0 -2
- data/src/core/lib/iomgr/polling_entity.h +4 -4
- data/src/core/lib/iomgr/resource_quota.cc +64 -10
- data/src/core/lib/iomgr/resource_quota.h +21 -6
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +11 -5
- data/src/core/lib/iomgr/tcp_client_custom.cc +14 -3
- data/src/core/lib/iomgr/tcp_client_posix.cc +2 -0
- data/src/core/lib/iomgr/tcp_posix.cc +4 -2
- data/src/core/lib/iomgr/timer_manager.cc +1 -1
- data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +3 -4
- data/src/core/lib/security/context/security_context.cc +20 -13
- data/src/core/lib/security/context/security_context.h +27 -19
- data/src/core/lib/security/credentials/alts/alts_credentials.cc +1 -1
- data/src/core/lib/security/credentials/credentials.h +2 -2
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +1 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +39 -54
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +3 -2
- data/src/core/lib/security/credentials/local/local_credentials.cc +1 -1
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +1 -2
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +2 -0
- data/src/core/lib/security/security_connector/{alts_security_connector.cc → alts/alts_security_connector.cc} +10 -9
- data/src/core/lib/security/security_connector/{alts_security_connector.h → alts/alts_security_connector.h} +3 -3
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +310 -0
- data/src/core/lib/security/security_connector/fake/fake_security_connector.h +42 -0
- data/src/core/lib/security/security_connector/{local_security_connector.cc → local/local_security_connector.cc} +4 -3
- data/src/core/lib/security/security_connector/{local_security_connector.h → local/local_security_connector.h} +3 -3
- data/src/core/lib/security/security_connector/security_connector.cc +4 -1039
- data/src/core/lib/security/security_connector/security_connector.h +6 -114
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +474 -0
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.h +77 -0
- data/src/core/lib/security/security_connector/ssl_utils.cc +345 -0
- data/src/core/lib/security/security_connector/ssl_utils.h +93 -0
- data/src/core/lib/security/transport/client_auth_filter.cc +28 -17
- data/src/core/lib/security/transport/secure_endpoint.cc +51 -41
- data/src/core/lib/security/transport/security_handshaker.cc +6 -7
- data/src/core/lib/security/transport/server_auth_filter.cc +39 -31
- data/src/core/lib/surface/call.cc +100 -80
- data/src/core/lib/surface/call.h +4 -0
- data/src/core/lib/surface/channel.cc +27 -13
- data/src/core/lib/surface/channel.h +4 -3
- data/src/core/lib/surface/completion_queue.cc +8 -1
- data/src/core/lib/surface/init.cc +1 -0
- data/src/core/lib/surface/server.cc +111 -46
- data/src/core/lib/surface/server.h +16 -2
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/error_utils.cc +4 -2
- data/src/core/lib/transport/metadata.cc +3 -2
- data/src/core/lib/transport/metadata.h +3 -2
- data/src/core/lib/transport/metadata_batch.cc +1 -0
- data/src/core/lib/transport/metadata_batch.h +4 -2
- data/src/core/lib/transport/static_metadata.cc +225 -221
- data/src/core/lib/transport/static_metadata.h +74 -71
- data/src/core/lib/transport/transport.h +44 -26
- data/src/core/{ext/filters/client_channel → lib/uri}/uri_parser.cc +1 -1
- data/src/core/{ext/filters/client_channel → lib/uri}/uri_parser.h +3 -3
- data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -4
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +356 -77
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +46 -36
- data/src/core/tsi/alts/handshaker/alts_shared_resource.cc +83 -0
- data/src/core/tsi/alts/handshaker/alts_shared_resource.h +73 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +122 -175
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +33 -22
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +38 -10
- data/src/core/tsi/transport_security.cc +18 -1
- data/src/core/tsi/transport_security.h +2 -1
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +6 -3
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options.proto +28 -0
- data/src/ruby/spec/pb/codegen/package_option_spec.rb +2 -3
- metadata +58 -40
- data/src/core/ext/filters/client_channel/method_params.cc +0 -178
- data/src/core/ext/filters/client_channel/method_params.h +0 -78
- data/src/core/tsi/alts/handshaker/alts_tsi_event.cc +0 -75
- data/src/core/tsi/alts/handshaker/alts_tsi_event.h +0 -93
- data/src/core/tsi/alts_transport_security.cc +0 -65
- data/src/core/tsi/alts_transport_security.h +0 -47
@@ -32,6 +32,7 @@
|
|
32
32
|
#include "src/core/lib/security/context/security_context.h"
|
33
33
|
#include "src/core/lib/security/credentials/credentials.h"
|
34
34
|
#include "src/core/lib/security/security_connector/security_connector.h"
|
35
|
+
#include "src/core/lib/security/security_connector/ssl_utils.h"
|
35
36
|
#include "src/core/lib/slice/slice_internal.h"
|
36
37
|
#include "src/core/lib/slice/slice_string_helpers.h"
|
37
38
|
#include "src/core/lib/surface/call.h"
|
@@ -42,20 +43,39 @@
|
|
42
43
|
namespace {
|
43
44
|
/* We can have a per-call credentials. */
|
44
45
|
struct call_data {
|
46
|
+
call_data(grpc_call_element* elem, const grpc_call_element_args& args)
|
47
|
+
: arena(args.arena),
|
48
|
+
owning_call(args.call_stack),
|
49
|
+
call_combiner(args.call_combiner) {}
|
50
|
+
|
51
|
+
// This method is technically the dtor of this class. However, since
|
52
|
+
// `get_request_metadata_cancel_closure` can run in parallel to
|
53
|
+
// `destroy_call_elem`, we cannot call the dtor in them. Otherwise,
|
54
|
+
// fields will be accessed after calling dtor, and msan correctly complains
|
55
|
+
// that the memory is not initialized.
|
56
|
+
void destroy() {
|
57
|
+
grpc_credentials_mdelem_array_destroy(&md_array);
|
58
|
+
grpc_call_credentials_unref(creds);
|
59
|
+
grpc_slice_unref_internal(host);
|
60
|
+
grpc_slice_unref_internal(method);
|
61
|
+
grpc_auth_metadata_context_reset(&auth_md_context);
|
62
|
+
}
|
63
|
+
|
45
64
|
gpr_arena* arena;
|
46
65
|
grpc_call_stack* owning_call;
|
47
66
|
grpc_call_combiner* call_combiner;
|
48
|
-
grpc_call_credentials* creds;
|
49
|
-
grpc_slice host;
|
50
|
-
grpc_slice method;
|
67
|
+
grpc_call_credentials* creds = nullptr;
|
68
|
+
grpc_slice host = grpc_empty_slice();
|
69
|
+
grpc_slice method = grpc_empty_slice();
|
51
70
|
/* pollset{_set} bound to this call; if we need to make external
|
52
71
|
network requests, they should be done under a pollset added to this
|
53
72
|
pollset_set so that work can progress when this call wants work to progress
|
54
73
|
*/
|
55
|
-
grpc_polling_entity* pollent;
|
74
|
+
grpc_polling_entity* pollent = nullptr;
|
56
75
|
grpc_credentials_mdelem_array md_array;
|
57
|
-
grpc_linked_mdelem md_links[MAX_CREDENTIALS_METADATA_COUNT];
|
58
|
-
grpc_auth_metadata_context auth_md_context
|
76
|
+
grpc_linked_mdelem md_links[MAX_CREDENTIALS_METADATA_COUNT] = {};
|
77
|
+
grpc_auth_metadata_context auth_md_context =
|
78
|
+
grpc_auth_metadata_context(); // Zero-initialize the C struct.
|
59
79
|
grpc_closure async_result_closure;
|
60
80
|
grpc_closure check_call_host_cancel_closure;
|
61
81
|
grpc_closure get_request_metadata_cancel_closure;
|
@@ -333,12 +353,7 @@ static void auth_start_transport_stream_op_batch(
|
|
333
353
|
/* Constructor for call_data */
|
334
354
|
static grpc_error* init_call_elem(grpc_call_element* elem,
|
335
355
|
const grpc_call_element_args* args) {
|
336
|
-
|
337
|
-
calld->arena = args->arena;
|
338
|
-
calld->owning_call = args->call_stack;
|
339
|
-
calld->call_combiner = args->call_combiner;
|
340
|
-
calld->host = grpc_empty_slice();
|
341
|
-
calld->method = grpc_empty_slice();
|
356
|
+
new (elem->call_data) call_data(elem, *args);
|
342
357
|
return GRPC_ERROR_NONE;
|
343
358
|
}
|
344
359
|
|
@@ -353,11 +368,7 @@ static void destroy_call_elem(grpc_call_element* elem,
|
|
353
368
|
const grpc_call_final_info* final_info,
|
354
369
|
grpc_closure* ignored) {
|
355
370
|
call_data* calld = static_cast<call_data*>(elem->call_data);
|
356
|
-
|
357
|
-
grpc_call_credentials_unref(calld->creds);
|
358
|
-
grpc_slice_unref_internal(calld->host);
|
359
|
-
grpc_slice_unref_internal(calld->method);
|
360
|
-
grpc_auth_metadata_context_reset(&calld->auth_md_context);
|
371
|
+
calld->destroy();
|
361
372
|
}
|
362
373
|
|
363
374
|
/* Constructor for channel_data */
|
@@ -22,6 +22,8 @@
|
|
22
22
|
headers. Therefore, sockaddr.h must always be included first */
|
23
23
|
#include <grpc/support/port_platform.h>
|
24
24
|
|
25
|
+
#include <new>
|
26
|
+
|
25
27
|
#include "src/core/lib/iomgr/sockaddr.h"
|
26
28
|
|
27
29
|
#include <grpc/slice.h>
|
@@ -31,6 +33,7 @@
|
|
31
33
|
#include <grpc/support/sync.h>
|
32
34
|
#include "src/core/lib/debug/trace.h"
|
33
35
|
#include "src/core/lib/gpr/string.h"
|
36
|
+
#include "src/core/lib/gprpp/memory.h"
|
34
37
|
#include "src/core/lib/profiling/timers.h"
|
35
38
|
#include "src/core/lib/security/transport/secure_endpoint.h"
|
36
39
|
#include "src/core/lib/security/transport/tsi_error.h"
|
@@ -40,44 +43,68 @@
|
|
40
43
|
|
41
44
|
#define STAGING_BUFFER_SIZE 8192
|
42
45
|
|
43
|
-
|
46
|
+
static void on_read(void* user_data, grpc_error* error);
|
47
|
+
|
48
|
+
namespace {
|
49
|
+
struct secure_endpoint {
|
50
|
+
secure_endpoint(const grpc_endpoint_vtable* vtable,
|
51
|
+
tsi_frame_protector* protector,
|
52
|
+
tsi_zero_copy_grpc_protector* zero_copy_protector,
|
53
|
+
grpc_endpoint* transport, grpc_slice* leftover_slices,
|
54
|
+
size_t leftover_nslices)
|
55
|
+
: wrapped_ep(transport),
|
56
|
+
protector(protector),
|
57
|
+
zero_copy_protector(zero_copy_protector) {
|
58
|
+
base.vtable = vtable;
|
59
|
+
gpr_mu_init(&protector_mu);
|
60
|
+
GRPC_CLOSURE_INIT(&on_read, ::on_read, this, grpc_schedule_on_exec_ctx);
|
61
|
+
grpc_slice_buffer_init(&source_buffer);
|
62
|
+
grpc_slice_buffer_init(&leftover_bytes);
|
63
|
+
for (size_t i = 0; i < leftover_nslices; i++) {
|
64
|
+
grpc_slice_buffer_add(&leftover_bytes,
|
65
|
+
grpc_slice_ref_internal(leftover_slices[i]));
|
66
|
+
}
|
67
|
+
grpc_slice_buffer_init(&output_buffer);
|
68
|
+
gpr_ref_init(&ref, 1);
|
69
|
+
}
|
70
|
+
|
71
|
+
~secure_endpoint() {
|
72
|
+
grpc_endpoint_destroy(wrapped_ep);
|
73
|
+
tsi_frame_protector_destroy(protector);
|
74
|
+
tsi_zero_copy_grpc_protector_destroy(zero_copy_protector);
|
75
|
+
grpc_slice_buffer_destroy_internal(&source_buffer);
|
76
|
+
grpc_slice_buffer_destroy_internal(&leftover_bytes);
|
77
|
+
grpc_slice_unref_internal(read_staging_buffer);
|
78
|
+
grpc_slice_unref_internal(write_staging_buffer);
|
79
|
+
grpc_slice_buffer_destroy_internal(&output_buffer);
|
80
|
+
gpr_mu_destroy(&protector_mu);
|
81
|
+
}
|
82
|
+
|
44
83
|
grpc_endpoint base;
|
45
84
|
grpc_endpoint* wrapped_ep;
|
46
85
|
struct tsi_frame_protector* protector;
|
47
86
|
struct tsi_zero_copy_grpc_protector* zero_copy_protector;
|
48
87
|
gpr_mu protector_mu;
|
49
88
|
/* saved upper level callbacks and user_data. */
|
50
|
-
grpc_closure* read_cb;
|
51
|
-
grpc_closure* write_cb;
|
89
|
+
grpc_closure* read_cb = nullptr;
|
90
|
+
grpc_closure* write_cb = nullptr;
|
52
91
|
grpc_closure on_read;
|
53
|
-
grpc_slice_buffer* read_buffer;
|
92
|
+
grpc_slice_buffer* read_buffer = nullptr;
|
54
93
|
grpc_slice_buffer source_buffer;
|
55
94
|
/* saved handshaker leftover data to unprotect. */
|
56
95
|
grpc_slice_buffer leftover_bytes;
|
57
96
|
/* buffers for read and write */
|
58
|
-
grpc_slice read_staging_buffer;
|
59
|
-
|
60
|
-
grpc_slice write_staging_buffer;
|
97
|
+
grpc_slice read_staging_buffer = GRPC_SLICE_MALLOC(STAGING_BUFFER_SIZE);
|
98
|
+
grpc_slice write_staging_buffer = GRPC_SLICE_MALLOC(STAGING_BUFFER_SIZE);
|
61
99
|
grpc_slice_buffer output_buffer;
|
62
100
|
|
63
101
|
gpr_refcount ref;
|
64
|
-
}
|
102
|
+
};
|
103
|
+
} // namespace
|
65
104
|
|
66
105
|
grpc_core::TraceFlag grpc_trace_secure_endpoint(false, "secure_endpoint");
|
67
106
|
|
68
|
-
static void destroy(secure_endpoint*
|
69
|
-
secure_endpoint* ep = secure_ep;
|
70
|
-
grpc_endpoint_destroy(ep->wrapped_ep);
|
71
|
-
tsi_frame_protector_destroy(ep->protector);
|
72
|
-
tsi_zero_copy_grpc_protector_destroy(ep->zero_copy_protector);
|
73
|
-
grpc_slice_buffer_destroy_internal(&ep->leftover_bytes);
|
74
|
-
grpc_slice_unref_internal(ep->read_staging_buffer);
|
75
|
-
grpc_slice_unref_internal(ep->write_staging_buffer);
|
76
|
-
grpc_slice_buffer_destroy_internal(&ep->output_buffer);
|
77
|
-
grpc_slice_buffer_destroy_internal(&ep->source_buffer);
|
78
|
-
gpr_mu_destroy(&ep->protector_mu);
|
79
|
-
gpr_free(ep);
|
80
|
-
}
|
107
|
+
static void destroy(secure_endpoint* ep) { grpc_core::Delete(ep); }
|
81
108
|
|
82
109
|
#ifndef NDEBUG
|
83
110
|
#define SECURE_ENDPOINT_UNREF(ep, reason) \
|
@@ -405,25 +432,8 @@ grpc_endpoint* grpc_secure_endpoint_create(
|
|
405
432
|
struct tsi_zero_copy_grpc_protector* zero_copy_protector,
|
406
433
|
grpc_endpoint* transport, grpc_slice* leftover_slices,
|
407
434
|
size_t leftover_nslices) {
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
ep->base.vtable = &vtable;
|
412
|
-
ep->wrapped_ep = transport;
|
413
|
-
ep->protector = protector;
|
414
|
-
ep->zero_copy_protector = zero_copy_protector;
|
415
|
-
grpc_slice_buffer_init(&ep->leftover_bytes);
|
416
|
-
for (i = 0; i < leftover_nslices; i++) {
|
417
|
-
grpc_slice_buffer_add(&ep->leftover_bytes,
|
418
|
-
grpc_slice_ref_internal(leftover_slices[i]));
|
419
|
-
}
|
420
|
-
ep->write_staging_buffer = GRPC_SLICE_MALLOC(STAGING_BUFFER_SIZE);
|
421
|
-
ep->read_staging_buffer = GRPC_SLICE_MALLOC(STAGING_BUFFER_SIZE);
|
422
|
-
grpc_slice_buffer_init(&ep->output_buffer);
|
423
|
-
grpc_slice_buffer_init(&ep->source_buffer);
|
424
|
-
ep->read_buffer = nullptr;
|
425
|
-
GRPC_CLOSURE_INIT(&ep->on_read, on_read, ep, grpc_schedule_on_exec_ctx);
|
426
|
-
gpr_mu_init(&ep->protector_mu);
|
427
|
-
gpr_ref_init(&ep->ref, 1);
|
435
|
+
secure_endpoint* ep = grpc_core::New<secure_endpoint>(
|
436
|
+
&vtable, protector, zero_copy_protector, transport, leftover_slices,
|
437
|
+
leftover_nslices);
|
428
438
|
return &ep->base;
|
429
439
|
}
|
@@ -275,9 +275,6 @@ static void on_handshake_next_done_grpc_wrapper(
|
|
275
275
|
tsi_result result, void* user_data, const unsigned char* bytes_to_send,
|
276
276
|
size_t bytes_to_send_size, tsi_handshaker_result* handshaker_result) {
|
277
277
|
security_handshaker* h = static_cast<security_handshaker*>(user_data);
|
278
|
-
// This callback will be invoked by TSI in a non-grpc thread, so it's
|
279
|
-
// safe to create our own exec_ctx here.
|
280
|
-
grpc_core::ExecCtx exec_ctx;
|
281
278
|
gpr_mu_lock(&h->mu);
|
282
279
|
grpc_error* error = on_handshake_next_done_locked(
|
283
280
|
h, result, bytes_to_send, bytes_to_send_size, handshaker_result);
|
@@ -475,22 +472,24 @@ static grpc_handshaker* fail_handshaker_create() {
|
|
475
472
|
|
476
473
|
static void client_handshaker_factory_add_handshakers(
|
477
474
|
grpc_handshaker_factory* handshaker_factory, const grpc_channel_args* args,
|
475
|
+
grpc_pollset_set* interested_parties,
|
478
476
|
grpc_handshake_manager* handshake_mgr) {
|
479
477
|
grpc_channel_security_connector* security_connector =
|
480
478
|
reinterpret_cast<grpc_channel_security_connector*>(
|
481
479
|
grpc_security_connector_find_in_args(args));
|
482
|
-
grpc_channel_security_connector_add_handshakers(
|
483
|
-
|
480
|
+
grpc_channel_security_connector_add_handshakers(
|
481
|
+
security_connector, interested_parties, handshake_mgr);
|
484
482
|
}
|
485
483
|
|
486
484
|
static void server_handshaker_factory_add_handshakers(
|
487
485
|
grpc_handshaker_factory* hf, const grpc_channel_args* args,
|
486
|
+
grpc_pollset_set* interested_parties,
|
488
487
|
grpc_handshake_manager* handshake_mgr) {
|
489
488
|
grpc_server_security_connector* security_connector =
|
490
489
|
reinterpret_cast<grpc_server_security_connector*>(
|
491
490
|
grpc_security_connector_find_in_args(args));
|
492
|
-
grpc_server_security_connector_add_handshakers(
|
493
|
-
|
491
|
+
grpc_server_security_connector_add_handshakers(
|
492
|
+
security_connector, interested_parties, handshake_mgr);
|
494
493
|
}
|
495
494
|
|
496
495
|
static void handshaker_factory_destroy(
|
@@ -28,6 +28,9 @@
|
|
28
28
|
#include "src/core/lib/security/transport/auth_filters.h"
|
29
29
|
#include "src/core/lib/slice/slice_internal.h"
|
30
30
|
|
31
|
+
static void recv_initial_metadata_ready(void* arg, grpc_error* error);
|
32
|
+
static void recv_trailing_metadata_ready(void* user_data, grpc_error* error);
|
33
|
+
|
31
34
|
namespace {
|
32
35
|
enum async_state {
|
33
36
|
STATE_INIT = 0,
|
@@ -35,28 +38,55 @@ enum async_state {
|
|
35
38
|
STATE_CANCELLED,
|
36
39
|
};
|
37
40
|
|
41
|
+
struct channel_data {
|
42
|
+
grpc_auth_context* auth_context;
|
43
|
+
grpc_server_credentials* creds;
|
44
|
+
};
|
45
|
+
|
38
46
|
struct call_data {
|
47
|
+
call_data(grpc_call_element* elem, const grpc_call_element_args& args)
|
48
|
+
: call_combiner(args.call_combiner), owning_call(args.call_stack) {
|
49
|
+
GRPC_CLOSURE_INIT(&recv_initial_metadata_ready,
|
50
|
+
::recv_initial_metadata_ready, elem,
|
51
|
+
grpc_schedule_on_exec_ctx);
|
52
|
+
GRPC_CLOSURE_INIT(&recv_trailing_metadata_ready,
|
53
|
+
::recv_trailing_metadata_ready, elem,
|
54
|
+
grpc_schedule_on_exec_ctx);
|
55
|
+
// Create server security context. Set its auth context from channel
|
56
|
+
// data and save it in the call context.
|
57
|
+
grpc_server_security_context* server_ctx =
|
58
|
+
grpc_server_security_context_create(args.arena);
|
59
|
+
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
60
|
+
server_ctx->auth_context =
|
61
|
+
GRPC_AUTH_CONTEXT_REF(chand->auth_context, "server_auth_filter");
|
62
|
+
if (args.context[GRPC_CONTEXT_SECURITY].value != nullptr) {
|
63
|
+
args.context[GRPC_CONTEXT_SECURITY].destroy(
|
64
|
+
args.context[GRPC_CONTEXT_SECURITY].value);
|
65
|
+
}
|
66
|
+
args.context[GRPC_CONTEXT_SECURITY].value = server_ctx;
|
67
|
+
args.context[GRPC_CONTEXT_SECURITY].destroy =
|
68
|
+
grpc_server_security_context_destroy;
|
69
|
+
}
|
70
|
+
|
71
|
+
~call_data() { GRPC_ERROR_UNREF(recv_initial_metadata_error); }
|
72
|
+
|
39
73
|
grpc_call_combiner* call_combiner;
|
40
74
|
grpc_call_stack* owning_call;
|
41
75
|
grpc_transport_stream_op_batch* recv_initial_metadata_batch;
|
42
76
|
grpc_closure* original_recv_initial_metadata_ready;
|
43
77
|
grpc_closure recv_initial_metadata_ready;
|
44
|
-
grpc_error* recv_initial_metadata_error;
|
78
|
+
grpc_error* recv_initial_metadata_error = GRPC_ERROR_NONE;
|
45
79
|
grpc_closure recv_trailing_metadata_ready;
|
46
80
|
grpc_closure* original_recv_trailing_metadata_ready;
|
47
81
|
grpc_error* recv_trailing_metadata_error;
|
48
|
-
bool seen_recv_trailing_metadata_ready;
|
82
|
+
bool seen_recv_trailing_metadata_ready = false;
|
49
83
|
grpc_metadata_array md;
|
50
84
|
const grpc_metadata* consumed_md;
|
51
85
|
size_t num_consumed_md;
|
52
86
|
grpc_closure cancel_closure;
|
53
|
-
gpr_atm state; // async_state
|
87
|
+
gpr_atm state = STATE_INIT; // async_state
|
54
88
|
};
|
55
89
|
|
56
|
-
struct channel_data {
|
57
|
-
grpc_auth_context* auth_context;
|
58
|
-
grpc_server_credentials* creds;
|
59
|
-
};
|
60
90
|
} // namespace
|
61
91
|
|
62
92
|
static grpc_metadata_array metadata_batch_to_md_array(
|
@@ -244,29 +274,7 @@ static void auth_start_transport_stream_op_batch(
|
|
244
274
|
/* Constructor for call_data */
|
245
275
|
static grpc_error* init_call_elem(grpc_call_element* elem,
|
246
276
|
const grpc_call_element_args* args) {
|
247
|
-
|
248
|
-
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
249
|
-
calld->call_combiner = args->call_combiner;
|
250
|
-
calld->owning_call = args->call_stack;
|
251
|
-
GRPC_CLOSURE_INIT(&calld->recv_initial_metadata_ready,
|
252
|
-
recv_initial_metadata_ready, elem,
|
253
|
-
grpc_schedule_on_exec_ctx);
|
254
|
-
GRPC_CLOSURE_INIT(&calld->recv_trailing_metadata_ready,
|
255
|
-
recv_trailing_metadata_ready, elem,
|
256
|
-
grpc_schedule_on_exec_ctx);
|
257
|
-
// Create server security context. Set its auth context from channel
|
258
|
-
// data and save it in the call context.
|
259
|
-
grpc_server_security_context* server_ctx =
|
260
|
-
grpc_server_security_context_create(args->arena);
|
261
|
-
server_ctx->auth_context =
|
262
|
-
GRPC_AUTH_CONTEXT_REF(chand->auth_context, "server_auth_filter");
|
263
|
-
if (args->context[GRPC_CONTEXT_SECURITY].value != nullptr) {
|
264
|
-
args->context[GRPC_CONTEXT_SECURITY].destroy(
|
265
|
-
args->context[GRPC_CONTEXT_SECURITY].value);
|
266
|
-
}
|
267
|
-
args->context[GRPC_CONTEXT_SECURITY].value = server_ctx;
|
268
|
-
args->context[GRPC_CONTEXT_SECURITY].destroy =
|
269
|
-
grpc_server_security_context_destroy;
|
277
|
+
new (elem->call_data) call_data(elem, *args);
|
270
278
|
return GRPC_ERROR_NONE;
|
271
279
|
}
|
272
280
|
|
@@ -275,7 +283,7 @@ static void destroy_call_elem(grpc_call_element* elem,
|
|
275
283
|
const grpc_call_final_info* final_info,
|
276
284
|
grpc_closure* ignored) {
|
277
285
|
call_data* calld = static_cast<call_data*>(elem->call_data);
|
278
|
-
|
286
|
+
calld->~call_data();
|
279
287
|
}
|
280
288
|
|
281
289
|
/* Constructor for channel_data */
|
@@ -72,8 +72,11 @@
|
|
72
72
|
// Used to create arena for the first call.
|
73
73
|
#define ESTIMATED_MDELEM_COUNT 16
|
74
74
|
|
75
|
-
|
76
|
-
|
75
|
+
struct batch_control {
|
76
|
+
batch_control() { gpr_ref_init(&steps_to_complete, 0); }
|
77
|
+
|
78
|
+
grpc_call* call = nullptr;
|
79
|
+
grpc_transport_stream_op_batch op;
|
77
80
|
/* Share memory for cq_completion and notify_tag as they are never needed
|
78
81
|
simultaneously. Each byte used in this data structure count as six bytes
|
79
82
|
per call, so any savings we can make are worthwhile,
|
@@ -96,84 +99,110 @@ typedef struct batch_control {
|
|
96
99
|
grpc_closure start_batch;
|
97
100
|
grpc_closure finish_batch;
|
98
101
|
gpr_refcount steps_to_complete;
|
99
|
-
gpr_atm batch_error;
|
100
|
-
|
101
|
-
|
102
|
+
gpr_atm batch_error = reinterpret_cast<gpr_atm>(GRPC_ERROR_NONE);
|
103
|
+
};
|
104
|
+
|
105
|
+
struct parent_call {
|
106
|
+
parent_call() { gpr_mu_init(&child_list_mu); }
|
107
|
+
~parent_call() { gpr_mu_destroy(&child_list_mu); }
|
102
108
|
|
103
|
-
typedef struct {
|
104
109
|
gpr_mu child_list_mu;
|
105
|
-
grpc_call* first_child;
|
106
|
-
}
|
110
|
+
grpc_call* first_child = nullptr;
|
111
|
+
};
|
107
112
|
|
108
|
-
|
113
|
+
struct child_call {
|
114
|
+
child_call(grpc_call* parent) : parent(parent) {}
|
109
115
|
grpc_call* parent;
|
110
116
|
/** siblings: children of the same parent form a list, and this list is
|
111
117
|
protected under
|
112
118
|
parent->mu */
|
113
|
-
grpc_call* sibling_next;
|
114
|
-
grpc_call* sibling_prev;
|
115
|
-
}
|
119
|
+
grpc_call* sibling_next = nullptr;
|
120
|
+
grpc_call* sibling_prev = nullptr;
|
121
|
+
};
|
116
122
|
|
117
123
|
#define RECV_NONE ((gpr_atm)0)
|
118
124
|
#define RECV_INITIAL_METADATA_FIRST ((gpr_atm)1)
|
119
125
|
|
120
126
|
struct grpc_call {
|
127
|
+
grpc_call(gpr_arena* arena, const grpc_call_create_args& args)
|
128
|
+
: arena(arena),
|
129
|
+
cq(args.cq),
|
130
|
+
channel(args.channel),
|
131
|
+
is_client(args.server_transport_data == nullptr),
|
132
|
+
stream_op_payload(context) {
|
133
|
+
gpr_ref_init(&ext_ref, 1);
|
134
|
+
grpc_call_combiner_init(&call_combiner);
|
135
|
+
for (int i = 0; i < 2; i++) {
|
136
|
+
for (int j = 0; j < 2; j++) {
|
137
|
+
metadata_batch[i][j].deadline = GRPC_MILLIS_INF_FUTURE;
|
138
|
+
}
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
~grpc_call() {
|
143
|
+
gpr_free(static_cast<void*>(const_cast<char*>(final_info.error_string)));
|
144
|
+
grpc_call_combiner_destroy(&call_combiner);
|
145
|
+
}
|
146
|
+
|
121
147
|
gpr_refcount ext_ref;
|
122
148
|
gpr_arena* arena;
|
123
149
|
grpc_call_combiner call_combiner;
|
124
150
|
grpc_completion_queue* cq;
|
125
151
|
grpc_polling_entity pollent;
|
126
152
|
grpc_channel* channel;
|
127
|
-
gpr_timespec start_time;
|
128
|
-
/* parent_call* */ gpr_atm parent_call_atm;
|
129
|
-
child_call* child;
|
153
|
+
gpr_timespec start_time = gpr_now(GPR_CLOCK_MONOTONIC);
|
154
|
+
/* parent_call* */ gpr_atm parent_call_atm = 0;
|
155
|
+
child_call* child = nullptr;
|
130
156
|
|
131
157
|
/* client or server call */
|
132
158
|
bool is_client;
|
133
159
|
/** has grpc_call_unref been called */
|
134
|
-
bool destroy_called;
|
160
|
+
bool destroy_called = false;
|
135
161
|
/** flag indicating that cancellation is inherited */
|
136
|
-
bool cancellation_is_inherited;
|
162
|
+
bool cancellation_is_inherited = false;
|
137
163
|
/** which ops are in-flight */
|
138
|
-
bool sent_initial_metadata;
|
139
|
-
bool sending_message;
|
140
|
-
bool sent_final_op;
|
141
|
-
bool received_initial_metadata;
|
142
|
-
bool receiving_message;
|
143
|
-
bool requested_final_op;
|
144
|
-
gpr_atm any_ops_sent_atm;
|
145
|
-
gpr_atm received_final_op_atm;
|
146
|
-
|
147
|
-
batch_control* active_batches[MAX_CONCURRENT_BATCHES];
|
164
|
+
bool sent_initial_metadata = false;
|
165
|
+
bool sending_message = false;
|
166
|
+
bool sent_final_op = false;
|
167
|
+
bool received_initial_metadata = false;
|
168
|
+
bool receiving_message = false;
|
169
|
+
bool requested_final_op = false;
|
170
|
+
gpr_atm any_ops_sent_atm = 0;
|
171
|
+
gpr_atm received_final_op_atm = 0;
|
172
|
+
|
173
|
+
batch_control* active_batches[MAX_CONCURRENT_BATCHES] = {};
|
148
174
|
grpc_transport_stream_op_batch_payload stream_op_payload;
|
149
175
|
|
150
176
|
/* first idx: is_receiving, second idx: is_trailing */
|
151
|
-
grpc_metadata_batch metadata_batch[2][2];
|
177
|
+
grpc_metadata_batch metadata_batch[2][2] = {};
|
152
178
|
|
153
179
|
/* Buffered read metadata waiting to be returned to the application.
|
154
180
|
Element 0 is initial metadata, element 1 is trailing metadata. */
|
155
|
-
grpc_metadata_array* buffered_metadata[2];
|
181
|
+
grpc_metadata_array* buffered_metadata[2] = {};
|
156
182
|
|
157
183
|
grpc_metadata compression_md;
|
158
184
|
|
159
185
|
// A char* indicating the peer name.
|
160
|
-
gpr_atm peer_string;
|
186
|
+
gpr_atm peer_string = 0;
|
161
187
|
|
162
188
|
/* Call data useful used for reporting. Only valid after the call has
|
163
189
|
* completed */
|
164
190
|
grpc_call_final_info final_info;
|
165
191
|
|
166
192
|
/* Compression algorithm for *incoming* data */
|
167
|
-
grpc_message_compression_algorithm incoming_message_compression_algorithm
|
193
|
+
grpc_message_compression_algorithm incoming_message_compression_algorithm =
|
194
|
+
GRPC_MESSAGE_COMPRESS_NONE;
|
168
195
|
/* Stream compression algorithm for *incoming* data */
|
169
|
-
grpc_stream_compression_algorithm incoming_stream_compression_algorithm
|
170
|
-
|
171
|
-
|
196
|
+
grpc_stream_compression_algorithm incoming_stream_compression_algorithm =
|
197
|
+
GRPC_STREAM_COMPRESS_NONE;
|
198
|
+
/* Supported encodings (compression algorithms), a bitset.
|
199
|
+
* Always support no compression. */
|
200
|
+
uint32_t encodings_accepted_by_peer = 1 << GRPC_MESSAGE_COMPRESS_NONE;
|
172
201
|
/* Supported stream encodings (stream compression algorithms), a bitset */
|
173
|
-
uint32_t stream_encodings_accepted_by_peer;
|
202
|
+
uint32_t stream_encodings_accepted_by_peer = 0;
|
174
203
|
|
175
204
|
/* Contexts for various subsystems (security, tracing, ...). */
|
176
|
-
grpc_call_context_element context[GRPC_CONTEXT_COUNT];
|
205
|
+
grpc_call_context_element context[GRPC_CONTEXT_COUNT] = {};
|
177
206
|
|
178
207
|
/* for the client, extra metadata is initial metadata; for the
|
179
208
|
server, it's trailing metadata */
|
@@ -184,14 +213,14 @@ struct grpc_call {
|
|
184
213
|
grpc_core::ManualConstructor<grpc_core::SliceBufferByteStream> sending_stream;
|
185
214
|
|
186
215
|
grpc_core::OrphanablePtr<grpc_core::ByteStream> receiving_stream;
|
187
|
-
grpc_byte_buffer** receiving_buffer;
|
188
|
-
grpc_slice receiving_slice;
|
216
|
+
grpc_byte_buffer** receiving_buffer = nullptr;
|
217
|
+
grpc_slice receiving_slice = grpc_empty_slice();
|
189
218
|
grpc_closure receiving_slice_ready;
|
190
219
|
grpc_closure receiving_stream_ready;
|
191
220
|
grpc_closure receiving_initial_metadata_ready;
|
192
221
|
grpc_closure receiving_trailing_metadata_ready;
|
193
|
-
uint32_t test_only_last_message_flags;
|
194
|
-
gpr_atm cancelled;
|
222
|
+
uint32_t test_only_last_message_flags = 0;
|
223
|
+
gpr_atm cancelled = 0;
|
195
224
|
|
196
225
|
grpc_closure release_call;
|
197
226
|
|
@@ -207,7 +236,7 @@ struct grpc_call {
|
|
207
236
|
grpc_server* server;
|
208
237
|
} server;
|
209
238
|
} final_op;
|
210
|
-
gpr_atm status_error;
|
239
|
+
gpr_atm status_error = 0;
|
211
240
|
|
212
241
|
/* recv_state can contain one of the following values:
|
213
242
|
RECV_NONE : : no initial metadata and messages received
|
@@ -225,7 +254,7 @@ struct grpc_call {
|
|
225
254
|
|
226
255
|
For 1, 4: See receiving_initial_metadata_ready() function
|
227
256
|
For 2, 3: See receiving_stream_ready() function */
|
228
|
-
gpr_atm recv_state;
|
257
|
+
gpr_atm recv_state = 0;
|
229
258
|
};
|
230
259
|
|
231
260
|
grpc_core::TraceFlag grpc_call_error_trace(false, "call_error");
|
@@ -269,11 +298,10 @@ void* grpc_call_arena_alloc(grpc_call* call, size_t size) {
|
|
269
298
|
static parent_call* get_or_create_parent_call(grpc_call* call) {
|
270
299
|
parent_call* p = (parent_call*)gpr_atm_acq_load(&call->parent_call_atm);
|
271
300
|
if (p == nullptr) {
|
272
|
-
p =
|
273
|
-
gpr_mu_init(&p->child_list_mu);
|
301
|
+
p = new (gpr_arena_alloc(call->arena, sizeof(*p))) parent_call();
|
274
302
|
if (!gpr_atm_rel_cas(&call->parent_call_atm, (gpr_atm) nullptr,
|
275
303
|
(gpr_atm)p)) {
|
276
|
-
|
304
|
+
p->~parent_call();
|
277
305
|
p = (parent_call*)gpr_atm_acq_load(&call->parent_call_atm);
|
278
306
|
}
|
279
307
|
}
|
@@ -292,7 +320,9 @@ size_t grpc_call_get_initial_size_estimate() {
|
|
292
320
|
grpc_error* grpc_call_create(const grpc_call_create_args* args,
|
293
321
|
grpc_call** out_call) {
|
294
322
|
GPR_TIMER_SCOPE("grpc_call_create", 0);
|
295
|
-
|
323
|
+
|
324
|
+
GRPC_CHANNEL_INTERNAL_REF(args->channel, "call");
|
325
|
+
|
296
326
|
grpc_error* error = GRPC_ERROR_NONE;
|
297
327
|
grpc_channel_stack* channel_stack =
|
298
328
|
grpc_channel_get_channel_stack(args->channel);
|
@@ -300,27 +330,19 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args,
|
|
300
330
|
size_t initial_size = grpc_channel_get_call_size_estimate(args->channel);
|
301
331
|
GRPC_STATS_INC_CALL_INITIAL_SIZE(initial_size);
|
302
332
|
gpr_arena* arena = gpr_arena_create(initial_size);
|
303
|
-
call =
|
304
|
-
|
305
|
-
|
306
|
-
gpr_ref_init(&call->ext_ref, 1);
|
307
|
-
gpr_atm_no_barrier_store(&call->cancelled, 0);
|
308
|
-
call->arena = arena;
|
309
|
-
grpc_call_combiner_init(&call->call_combiner);
|
333
|
+
call = new (gpr_arena_alloc(
|
334
|
+
arena, GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call)) +
|
335
|
+
channel_stack->call_stack_size)) grpc_call(arena, *args);
|
310
336
|
*out_call = call;
|
311
|
-
call->channel = args->channel;
|
312
|
-
call->cq = args->cq;
|
313
|
-
call->start_time = gpr_now(GPR_CLOCK_MONOTONIC);
|
314
|
-
/* Always support no compression */
|
315
|
-
GPR_BITSET(&call->encodings_accepted_by_peer, GRPC_MESSAGE_COMPRESS_NONE);
|
316
|
-
call->is_client = args->server_transport_data == nullptr;
|
317
|
-
call->stream_op_payload.context = call->context;
|
318
337
|
grpc_slice path = grpc_empty_slice();
|
319
338
|
if (call->is_client) {
|
339
|
+
call->final_op.client.status_details = nullptr;
|
340
|
+
call->final_op.client.status = nullptr;
|
341
|
+
call->final_op.client.error_string = nullptr;
|
320
342
|
GRPC_STATS_INC_CLIENT_CALLS_CREATED();
|
321
343
|
GPR_ASSERT(args->add_initial_metadata_count <
|
322
344
|
MAX_SEND_EXTRA_METADATA_COUNT);
|
323
|
-
for (i = 0; i < args->add_initial_metadata_count; i++) {
|
345
|
+
for (size_t i = 0; i < args->add_initial_metadata_count; i++) {
|
324
346
|
call->send_extra_metadata[i].md = args->add_initial_metadata[i];
|
325
347
|
if (grpc_slice_eq(GRPC_MDKEY(args->add_initial_metadata[i]),
|
326
348
|
GRPC_MDSTR_PATH)) {
|
@@ -332,23 +354,18 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args,
|
|
332
354
|
static_cast<int>(args->add_initial_metadata_count);
|
333
355
|
} else {
|
334
356
|
GRPC_STATS_INC_SERVER_CALLS_CREATED();
|
357
|
+
call->final_op.server.cancelled = nullptr;
|
335
358
|
call->final_op.server.server = args->server;
|
336
359
|
GPR_ASSERT(args->add_initial_metadata_count == 0);
|
337
360
|
call->send_extra_metadata_count = 0;
|
338
361
|
}
|
339
|
-
for (i = 0; i < 2; i++) {
|
340
|
-
for (j = 0; j < 2; j++) {
|
341
|
-
call->metadata_batch[i][j].deadline = GRPC_MILLIS_INF_FUTURE;
|
342
|
-
}
|
343
|
-
}
|
344
|
-
grpc_millis send_deadline = args->send_deadline;
|
345
362
|
|
363
|
+
grpc_millis send_deadline = args->send_deadline;
|
346
364
|
bool immediately_cancel = false;
|
347
365
|
|
348
366
|
if (args->parent != nullptr) {
|
349
|
-
call->child =
|
350
|
-
|
351
|
-
call->child->parent = args->parent;
|
367
|
+
call->child = new (gpr_arena_alloc(arena, sizeof(child_call)))
|
368
|
+
child_call(args->parent);
|
352
369
|
|
353
370
|
GRPC_CALL_INTERNAL_REF(args->parent, "child");
|
354
371
|
GPR_ASSERT(call->is_client);
|
@@ -382,10 +399,7 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args,
|
|
382
399
|
}
|
383
400
|
}
|
384
401
|
}
|
385
|
-
|
386
402
|
call->send_deadline = send_deadline;
|
387
|
-
|
388
|
-
GRPC_CHANNEL_INTERNAL_REF(args->channel, "call");
|
389
403
|
/* initial refcount dropped by grpc_call_unref */
|
390
404
|
grpc_call_element_args call_args = {CALL_STACK_FROM_CALL(call),
|
391
405
|
args->server_transport_data,
|
@@ -413,6 +427,7 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args,
|
|
413
427
|
}
|
414
428
|
gpr_mu_unlock(&pc->child_list_mu);
|
415
429
|
}
|
430
|
+
|
416
431
|
if (error != GRPC_ERROR_NONE) {
|
417
432
|
cancel_with_error(call, GRPC_ERROR_REF(error));
|
418
433
|
}
|
@@ -487,9 +502,9 @@ void grpc_call_internal_unref(grpc_call* c REF_ARG) {
|
|
487
502
|
static void release_call(void* call, grpc_error* error) {
|
488
503
|
grpc_call* c = static_cast<grpc_call*>(call);
|
489
504
|
grpc_channel* channel = c->channel;
|
490
|
-
|
491
|
-
|
492
|
-
grpc_channel_update_call_size_estimate(channel, gpr_arena_destroy(
|
505
|
+
gpr_arena* arena = c->arena;
|
506
|
+
c->~grpc_call();
|
507
|
+
grpc_channel_update_call_size_estimate(channel, gpr_arena_destroy(arena));
|
493
508
|
GRPC_CHANNEL_INTERNAL_UNREF(channel, "call");
|
494
509
|
}
|
495
510
|
|
@@ -505,7 +520,7 @@ static void destroy_call(void* call, grpc_error* error) {
|
|
505
520
|
c->receiving_stream.reset();
|
506
521
|
parent_call* pc = get_parent_call(c);
|
507
522
|
if (pc != nullptr) {
|
508
|
-
|
523
|
+
pc->~parent_call();
|
509
524
|
}
|
510
525
|
for (ii = 0; ii < c->send_extra_metadata_count; ii++) {
|
511
526
|
GRPC_MDELEM_UNREF(c->send_extra_metadata[ii].md);
|
@@ -679,6 +694,10 @@ static void cancel_with_error(grpc_call* c, grpc_error* error) {
|
|
679
694
|
execute_batch(c, op, &state->start_batch);
|
680
695
|
}
|
681
696
|
|
697
|
+
void grpc_call_cancel_internal(grpc_call* call) {
|
698
|
+
cancel_with_error(call, GRPC_ERROR_CANCELLED);
|
699
|
+
}
|
700
|
+
|
682
701
|
static grpc_error* error_from_status(grpc_status_code status,
|
683
702
|
const char* description) {
|
684
703
|
// copying 'description' is needed to ensure the grpc_call_cancel_with_status
|
@@ -1100,10 +1119,11 @@ static batch_control* reuse_or_allocate_batch_control(grpc_call* call,
|
|
1100
1119
|
if (bctl->call != nullptr) {
|
1101
1120
|
return nullptr;
|
1102
1121
|
}
|
1103
|
-
|
1122
|
+
bctl->~batch_control();
|
1123
|
+
bctl->op = {};
|
1104
1124
|
} else {
|
1105
|
-
bctl =
|
1106
|
-
|
1125
|
+
bctl = new (gpr_arena_alloc(call->arena, sizeof(batch_control)))
|
1126
|
+
batch_control();
|
1107
1127
|
*pslot = bctl;
|
1108
1128
|
}
|
1109
1129
|
bctl->call = call;
|