grpc 1.11.1 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +225 -87
- data/etc/roots.pem +0 -33
- data/include/grpc/grpc_security.h +70 -0
- data/include/grpc/impl/codegen/port_platform.h +11 -0
- data/include/grpc/support/log.h +9 -1
- data/src/core/ext/filters/client_channel/client_channel.cc +305 -210
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy.cc +2 -2
- data/src/core/ext/filters/client_channel/lb_policy.h +4 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +12 -9
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +168 -197
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +368 -373
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +498 -98
- data/src/core/ext/filters/client_channel/method_params.h +4 -0
- data/src/core/ext/filters/client_channel/resolver.h +4 -0
- data/src/core/ext/filters/client_channel/retry_throttle.h +4 -0
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +40 -15
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +3 -3
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/stream_lists.cc +3 -3
- data/src/core/ext/transport/chttp2/transport/writing.cc +5 -5
- data/src/core/ext/transport/inproc/inproc_transport.cc +41 -43
- data/src/core/lib/channel/channel_args.cc +28 -0
- data/src/core/lib/channel/channel_args.h +4 -0
- data/src/core/lib/channel/handshaker.cc +47 -0
- data/src/core/lib/channel/handshaker.h +4 -0
- data/src/core/lib/debug/trace.cc +2 -1
- data/src/core/lib/debug/trace.h +10 -1
- data/src/core/lib/gpr/log.cc +8 -2
- data/src/core/lib/gpr/log_android.cc +4 -0
- data/src/core/lib/gpr/log_linux.cc +4 -0
- data/src/core/lib/gpr/log_posix.cc +4 -0
- data/src/core/lib/gpr/log_windows.cc +5 -0
- data/src/core/lib/gprpp/inlined_vector.h +30 -34
- data/src/core/lib/gprpp/orphanable.h +4 -4
- data/src/core/lib/gprpp/ref_counted.h +4 -4
- data/src/core/lib/iomgr/call_combiner.cc +13 -13
- data/src/core/lib/iomgr/closure.h +3 -3
- data/src/core/lib/iomgr/combiner.cc +11 -11
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +24 -24
- data/src/core/lib/iomgr/ev_epollex_linux.cc +48 -29
- data/src/core/lib/iomgr/ev_epollsig_linux.cc +2 -2
- data/src/core/lib/iomgr/ev_poll_posix.cc +9 -3
- data/src/core/lib/iomgr/ev_posix.cc +3 -3
- data/src/core/lib/iomgr/executor.cc +6 -6
- data/src/core/lib/iomgr/resource_quota.cc +10 -11
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +24 -0
- data/src/core/lib/iomgr/socket_utils_linux.cc +0 -1
- data/src/core/lib/iomgr/socket_utils_posix.cc +2 -3
- data/src/core/lib/iomgr/socket_utils_posix.h +3 -0
- data/src/core/lib/iomgr/tcp_client_custom.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_posix.cc +4 -4
- data/src/core/lib/iomgr/tcp_custom.cc +10 -10
- data/src/core/lib/iomgr/tcp_posix.cc +25 -25
- data/src/core/lib/iomgr/tcp_server_custom.cc +5 -5
- data/src/core/lib/iomgr/tcp_server_posix.cc +4 -25
- data/src/core/lib/iomgr/tcp_server_windows.cc +1 -0
- data/src/core/lib/iomgr/tcp_uv.cc +3 -0
- data/src/core/lib/iomgr/tcp_windows.cc +16 -0
- data/src/core/lib/iomgr/timer_generic.cc +27 -17
- data/src/core/lib/iomgr/timer_manager.cc +11 -12
- data/src/core/lib/iomgr/timer_uv.cc +3 -0
- data/src/core/lib/iomgr/udp_server.cc +104 -49
- data/src/core/lib/iomgr/udp_server.h +8 -4
- data/src/core/lib/profiling/basic_timers.cc +1 -0
- data/src/core/lib/security/credentials/alts/alts_credentials.h +0 -20
- data/src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc +7 -7
- data/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h +1 -38
- data/src/core/lib/security/security_connector/security_connector.cc +19 -16
- data/src/core/lib/security/security_connector/security_connector.h +4 -3
- data/src/core/lib/security/transport/secure_endpoint.cc +2 -2
- data/src/core/lib/security/transport/security_handshaker.cc +6 -2
- data/src/core/lib/slice/slice.cc +6 -2
- data/src/core/lib/slice/slice_buffer.cc +12 -4
- data/src/core/lib/slice/slice_hash_table.h +4 -0
- data/src/core/lib/slice/slice_weak_hash_table.h +4 -0
- data/src/core/lib/surface/call.cc +6 -6
- data/src/core/lib/surface/server.cc +16 -0
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/bdp_estimator.cc +3 -3
- data/src/core/lib/transport/bdp_estimator.h +2 -2
- data/src/core/lib/transport/connectivity_state.cc +6 -7
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +4 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +14 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +21 -0
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/generate_proto_ruby.sh +7 -1
- data/src/ruby/spec/pb/package_with_underscore/checker_spec.rb +2 -5
- data/third_party/address_sorting/address_sorting.c +10 -9
- metadata +27 -28
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc +0 -253
@@ -411,3 +411,31 @@ grpc_arg grpc_channel_arg_pointer_create(
|
|
411
411
|
arg.value.pointer.vtable = vtable;
|
412
412
|
return arg;
|
413
413
|
}
|
414
|
+
|
415
|
+
char* grpc_channel_args_string(const grpc_channel_args* args) {
|
416
|
+
if (args == nullptr) return nullptr;
|
417
|
+
gpr_strvec v;
|
418
|
+
gpr_strvec_init(&v);
|
419
|
+
for (size_t i = 0; i < args->num_args; ++i) {
|
420
|
+
const grpc_arg& arg = args->args[i];
|
421
|
+
char* s;
|
422
|
+
switch (arg.type) {
|
423
|
+
case GRPC_ARG_INTEGER:
|
424
|
+
gpr_asprintf(&s, "%s=%d", arg.key, arg.value.integer);
|
425
|
+
break;
|
426
|
+
case GRPC_ARG_STRING:
|
427
|
+
gpr_asprintf(&s, "%s=%s", arg.key, arg.value.string);
|
428
|
+
break;
|
429
|
+
case GRPC_ARG_POINTER:
|
430
|
+
gpr_asprintf(&s, "%s=%p", arg.key, arg.value.pointer.p);
|
431
|
+
break;
|
432
|
+
default:
|
433
|
+
gpr_asprintf(&s, "arg with unknown type");
|
434
|
+
}
|
435
|
+
gpr_strvec_add(&v, s);
|
436
|
+
}
|
437
|
+
char* result =
|
438
|
+
gpr_strjoin_sep(const_cast<const char**>(v.strs), v.count, ", ", nullptr);
|
439
|
+
gpr_strvec_destroy(&v);
|
440
|
+
return result;
|
441
|
+
}
|
@@ -124,4 +124,8 @@ grpc_arg grpc_channel_arg_integer_create(char* name, int value);
|
|
124
124
|
grpc_arg grpc_channel_arg_pointer_create(char* name, void* value,
|
125
125
|
const grpc_arg_pointer_vtable* vtable);
|
126
126
|
|
127
|
+
// Returns a string representing channel args in human-readable form.
|
128
|
+
// Callers takes ownership of result.
|
129
|
+
char* grpc_channel_args_string(const grpc_channel_args* args);
|
130
|
+
|
127
131
|
#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_ARGS_H */
|
@@ -22,11 +22,15 @@
|
|
22
22
|
|
23
23
|
#include <grpc/support/alloc.h>
|
24
24
|
#include <grpc/support/log.h>
|
25
|
+
#include <grpc/support/string_util.h>
|
25
26
|
|
26
27
|
#include "src/core/lib/channel/channel_args.h"
|
27
28
|
#include "src/core/lib/channel/handshaker.h"
|
29
|
+
#include "src/core/lib/debug/trace.h"
|
28
30
|
#include "src/core/lib/iomgr/timer.h"
|
29
31
|
|
32
|
+
grpc_core::TraceFlag grpc_handshaker_trace(false, "handshaker");
|
33
|
+
|
30
34
|
//
|
31
35
|
// grpc_handshaker
|
32
36
|
//
|
@@ -52,6 +56,10 @@ void grpc_handshaker_do_handshake(grpc_handshaker* handshaker,
|
|
52
56
|
args);
|
53
57
|
}
|
54
58
|
|
59
|
+
const char* grpc_handshaker_name(grpc_handshaker* handshaker) {
|
60
|
+
return handshaker->vtable->name;
|
61
|
+
}
|
62
|
+
|
55
63
|
//
|
56
64
|
// grpc_handshake_manager
|
57
65
|
//
|
@@ -127,6 +135,12 @@ static bool is_power_of_2(size_t n) { return (n & (n - 1)) == 0; }
|
|
127
135
|
|
128
136
|
void grpc_handshake_manager_add(grpc_handshake_manager* mgr,
|
129
137
|
grpc_handshaker* handshaker) {
|
138
|
+
if (grpc_handshaker_trace.enabled()) {
|
139
|
+
gpr_log(
|
140
|
+
GPR_INFO,
|
141
|
+
"handshake_manager %p: adding handshaker %s [%p] at index %" PRIuPTR,
|
142
|
+
mgr, grpc_handshaker_name(handshaker), handshaker, mgr->count);
|
143
|
+
}
|
130
144
|
gpr_mu_lock(&mgr->mu);
|
131
145
|
// To avoid allocating memory for each handshaker we add, we double
|
132
146
|
// the number of elements every time we need more.
|
@@ -172,23 +186,56 @@ void grpc_handshake_manager_shutdown(grpc_handshake_manager* mgr,
|
|
172
186
|
GRPC_ERROR_UNREF(why);
|
173
187
|
}
|
174
188
|
|
189
|
+
static char* handshaker_args_string(grpc_handshaker_args* args) {
|
190
|
+
char* args_str = grpc_channel_args_string(args->args);
|
191
|
+
size_t num_args = args->args != nullptr ? args->args->num_args : 0;
|
192
|
+
size_t read_buffer_length =
|
193
|
+
args->read_buffer != nullptr ? args->read_buffer->length : 0;
|
194
|
+
char* str;
|
195
|
+
gpr_asprintf(&str,
|
196
|
+
"{endpoint=%p, args=%p {size=%" PRIuPTR
|
197
|
+
": %s}, read_buffer=%p (length=%" PRIuPTR "), exit_early=%d}",
|
198
|
+
args->endpoint, args->args, num_args, args_str,
|
199
|
+
args->read_buffer, read_buffer_length, args->exit_early);
|
200
|
+
gpr_free(args_str);
|
201
|
+
return str;
|
202
|
+
}
|
203
|
+
|
175
204
|
// Helper function to call either the next handshaker or the
|
176
205
|
// on_handshake_done callback.
|
177
206
|
// Returns true if we've scheduled the on_handshake_done callback.
|
178
207
|
static bool call_next_handshaker_locked(grpc_handshake_manager* mgr,
|
179
208
|
grpc_error* error) {
|
209
|
+
if (grpc_handshaker_trace.enabled()) {
|
210
|
+
char* args_str = handshaker_args_string(&mgr->args);
|
211
|
+
gpr_log(GPR_INFO,
|
212
|
+
"handshake_manager %p: error=%s shutdown=%d index=%" PRIuPTR
|
213
|
+
", args=%s",
|
214
|
+
mgr, grpc_error_string(error), mgr->shutdown, mgr->index, args_str);
|
215
|
+
gpr_free(args_str);
|
216
|
+
}
|
180
217
|
GPR_ASSERT(mgr->index <= mgr->count);
|
181
218
|
// If we got an error or we've been shut down or we're exiting early or
|
182
219
|
// we've finished the last handshaker, invoke the on_handshake_done
|
183
220
|
// callback. Otherwise, call the next handshaker.
|
184
221
|
if (error != GRPC_ERROR_NONE || mgr->shutdown || mgr->args.exit_early ||
|
185
222
|
mgr->index == mgr->count) {
|
223
|
+
if (grpc_handshaker_trace.enabled()) {
|
224
|
+
gpr_log(GPR_INFO, "handshake_manager %p: handshaking complete", mgr);
|
225
|
+
}
|
186
226
|
// Cancel deadline timer, since we're invoking the on_handshake_done
|
187
227
|
// callback now.
|
188
228
|
grpc_timer_cancel(&mgr->deadline_timer);
|
189
229
|
GRPC_CLOSURE_SCHED(&mgr->on_handshake_done, error);
|
190
230
|
mgr->shutdown = true;
|
191
231
|
} else {
|
232
|
+
if (grpc_handshaker_trace.enabled()) {
|
233
|
+
gpr_log(
|
234
|
+
GPR_INFO,
|
235
|
+
"handshake_manager %p: calling handshaker %s [%p] at index %" PRIuPTR,
|
236
|
+
mgr, grpc_handshaker_name(mgr->handshakers[mgr->index]),
|
237
|
+
mgr->handshakers[mgr->index], mgr->index);
|
238
|
+
}
|
192
239
|
grpc_handshaker_do_handshake(mgr->handshakers[mgr->index], mgr->acceptor,
|
193
240
|
&mgr->call_next_handshaker, &mgr->args);
|
194
241
|
}
|
@@ -84,6 +84,9 @@ typedef struct {
|
|
84
84
|
grpc_tcp_server_acceptor* acceptor,
|
85
85
|
grpc_closure* on_handshake_done,
|
86
86
|
grpc_handshaker_args* args);
|
87
|
+
|
88
|
+
/// The name of the handshaker, for debugging purposes.
|
89
|
+
const char* name;
|
87
90
|
} grpc_handshaker_vtable;
|
88
91
|
|
89
92
|
/// Base struct. To subclass, make this the first member of the
|
@@ -102,6 +105,7 @@ void grpc_handshaker_do_handshake(grpc_handshaker* handshaker,
|
|
102
105
|
grpc_tcp_server_acceptor* acceptor,
|
103
106
|
grpc_closure* on_handshake_done,
|
104
107
|
grpc_handshaker_args* args);
|
108
|
+
const char* grpc_handshaker_name(grpc_handshaker* handshaker);
|
105
109
|
|
106
110
|
///
|
107
111
|
/// grpc_handshake_manager
|
data/src/core/lib/debug/trace.cc
CHANGED
@@ -55,7 +55,8 @@ bool TraceFlagList::Set(const char* name, bool enabled) {
|
|
55
55
|
found = true;
|
56
56
|
}
|
57
57
|
}
|
58
|
-
|
58
|
+
// check for unknowns, but ignore "", to allow to GRPC_TRACE=
|
59
|
+
if (!found && 0 != strcmp(name, "")) {
|
59
60
|
gpr_log(GPR_ERROR, "Unknown trace var: '%s'", name);
|
60
61
|
return false; /* early return */
|
61
62
|
}
|
data/src/core/lib/debug/trace.h
CHANGED
@@ -57,13 +57,22 @@ class TraceFlag {
|
|
57
57
|
|
58
58
|
const char* name() const { return name_; }
|
59
59
|
|
60
|
+
// This following define may be commented out to ensure that the compiler
|
61
|
+
// deletes any "if (tracer.enabled()) {...}" codeblocks. This is useful to
|
62
|
+
// test the performance impact tracers have on the system.
|
63
|
+
//
|
64
|
+
// #define COMPILE_OUT_ALL_TRACERS_IN_OPT_BUILD
|
65
|
+
#ifdef COMPILE_OUT_ALL_TRACERS_IN_OPT_BUILD
|
66
|
+
bool enabled() { return false; }
|
67
|
+
#else
|
60
68
|
bool enabled() {
|
61
69
|
#ifdef GRPC_THREADSAFE_TRACER
|
62
70
|
return gpr_atm_no_barrier_load(&value_) != 0;
|
63
71
|
#else
|
64
72
|
return value_;
|
65
|
-
#endif
|
73
|
+
#endif // GRPC_THREADSAFE_TRACER
|
66
74
|
}
|
75
|
+
#endif // COMPILE_OUT_ALL_TRACERS_IN_OPT_BUILD
|
67
76
|
|
68
77
|
private:
|
69
78
|
friend void grpc_core::testing::grpc_tracer_enable_flag(TraceFlag* flag);
|
data/src/core/lib/gpr/log.cc
CHANGED
@@ -44,10 +44,16 @@ const char* gpr_log_severity_string(gpr_log_severity severity) {
|
|
44
44
|
GPR_UNREACHABLE_CODE(return "UNKNOWN");
|
45
45
|
}
|
46
46
|
|
47
|
+
int gpr_should_log(gpr_log_severity severity) {
|
48
|
+
return static_cast<gpr_atm>(severity) >=
|
49
|
+
gpr_atm_no_barrier_load(&g_min_severity_to_print)
|
50
|
+
? 1
|
51
|
+
: 0;
|
52
|
+
}
|
53
|
+
|
47
54
|
void gpr_log_message(const char* file, int line, gpr_log_severity severity,
|
48
55
|
const char* message) {
|
49
|
-
if (
|
50
|
-
gpr_atm_no_barrier_load(&g_min_severity_to_print)) {
|
56
|
+
if (gpr_should_log(severity) == 0) {
|
51
57
|
return;
|
52
58
|
}
|
53
59
|
|
@@ -41,6 +41,10 @@ static android_LogPriority severity_to_log_priority(gpr_log_severity severity) {
|
|
41
41
|
|
42
42
|
void gpr_log(const char* file, int line, gpr_log_severity severity,
|
43
43
|
const char* format, ...) {
|
44
|
+
/* Avoid message construction if gpr_log_message won't log */
|
45
|
+
if (gpr_should_log(severity) == 0) {
|
46
|
+
return;
|
47
|
+
}
|
44
48
|
char* message = NULL;
|
45
49
|
va_list args;
|
46
50
|
va_start(args, format);
|
@@ -44,6 +44,10 @@ static long gettid(void) { return syscall(__NR_gettid); }
|
|
44
44
|
|
45
45
|
void gpr_log(const char* file, int line, gpr_log_severity severity,
|
46
46
|
const char* format, ...) {
|
47
|
+
/* Avoid message construction if gpr_log_message won't log */
|
48
|
+
if (gpr_should_log(severity) == 0) {
|
49
|
+
return;
|
50
|
+
}
|
47
51
|
char* message = nullptr;
|
48
52
|
va_list args;
|
49
53
|
va_start(args, format);
|
@@ -34,6 +34,10 @@ static intptr_t gettid(void) { return (intptr_t)pthread_self(); }
|
|
34
34
|
|
35
35
|
void gpr_log(const char* file, int line, gpr_log_severity severity,
|
36
36
|
const char* format, ...) {
|
37
|
+
/* Avoid message construction if gpr_log_message won't log */
|
38
|
+
if (gpr_should_log(severity) == 0) {
|
39
|
+
return;
|
40
|
+
}
|
37
41
|
char buf[64];
|
38
42
|
char* allocated = nullptr;
|
39
43
|
char* message = nullptr;
|
@@ -34,6 +34,11 @@
|
|
34
34
|
|
35
35
|
void gpr_log(const char* file, int line, gpr_log_severity severity,
|
36
36
|
const char* format, ...) {
|
37
|
+
/* Avoid message construction if gpr_log_message won't log */
|
38
|
+
if (gpr_should_log(severity) == 0) {
|
39
|
+
return;
|
40
|
+
}
|
41
|
+
|
37
42
|
char* message = NULL;
|
38
43
|
va_list args;
|
39
44
|
int ret;
|
@@ -54,43 +54,43 @@ class InlinedVector {
|
|
54
54
|
InlinedVector(const InlinedVector&) = delete;
|
55
55
|
InlinedVector& operator=(const InlinedVector&) = delete;
|
56
56
|
|
57
|
+
T* data() {
|
58
|
+
return dynamic_ != nullptr ? dynamic_ : reinterpret_cast<T*>(inline_);
|
59
|
+
}
|
60
|
+
|
61
|
+
const T* data() const {
|
62
|
+
return dynamic_ != nullptr ? dynamic_ : reinterpret_cast<const T*>(inline_);
|
63
|
+
}
|
64
|
+
|
57
65
|
T& operator[](size_t offset) {
|
58
66
|
assert(offset < size_);
|
59
|
-
|
60
|
-
return *reinterpret_cast<T*>(inline_ + offset);
|
61
|
-
} else {
|
62
|
-
return dynamic_[offset - N];
|
63
|
-
}
|
67
|
+
return data()[offset];
|
64
68
|
}
|
65
69
|
|
66
70
|
const T& operator[](size_t offset) const {
|
67
71
|
assert(offset < size_);
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
+
return data()[offset];
|
73
|
+
}
|
74
|
+
|
75
|
+
void reserve(size_t capacity) {
|
76
|
+
if (capacity > capacity_) {
|
77
|
+
T* new_dynamic = static_cast<T*>(gpr_malloc(sizeof(T) * capacity));
|
78
|
+
for (size_t i = 0; i < size_; ++i) {
|
79
|
+
new (&new_dynamic[i]) T(std::move(data()[i]));
|
80
|
+
data()[i].~T();
|
81
|
+
}
|
82
|
+
gpr_free(dynamic_);
|
83
|
+
dynamic_ = new_dynamic;
|
84
|
+
capacity_ = capacity;
|
72
85
|
}
|
73
86
|
}
|
74
87
|
|
75
88
|
template <typename... Args>
|
76
89
|
void emplace_back(Args&&... args) {
|
77
|
-
if (size_
|
78
|
-
|
79
|
-
} else {
|
80
|
-
if (size_ - N == dynamic_capacity_) {
|
81
|
-
size_t new_capacity =
|
82
|
-
dynamic_capacity_ == 0 ? 2 : dynamic_capacity_ * 2;
|
83
|
-
T* new_dynamic = static_cast<T*>(gpr_malloc(sizeof(T) * new_capacity));
|
84
|
-
for (size_t i = 0; i < dynamic_capacity_; ++i) {
|
85
|
-
new (&new_dynamic[i]) T(std::move(dynamic_[i]));
|
86
|
-
dynamic_[i].~T();
|
87
|
-
}
|
88
|
-
gpr_free(dynamic_);
|
89
|
-
dynamic_ = new_dynamic;
|
90
|
-
dynamic_capacity_ = new_capacity;
|
91
|
-
}
|
92
|
-
new (&dynamic_[size_ - N]) T(std::forward<Args>(args)...);
|
90
|
+
if (size_ == capacity_) {
|
91
|
+
reserve(capacity_ * 2);
|
93
92
|
}
|
93
|
+
new (&(data()[size_])) T(std::forward<Args>(args)...);
|
94
94
|
++size_;
|
95
95
|
}
|
96
96
|
|
@@ -99,6 +99,7 @@ class InlinedVector {
|
|
99
99
|
void push_back(T&& value) { emplace_back(std::move(value)); }
|
100
100
|
|
101
101
|
size_t size() const { return size_; }
|
102
|
+
size_t capacity() const { return capacity_; }
|
102
103
|
|
103
104
|
void clear() {
|
104
105
|
destroy_elements();
|
@@ -109,26 +110,21 @@ class InlinedVector {
|
|
109
110
|
void init_data() {
|
110
111
|
dynamic_ = nullptr;
|
111
112
|
size_ = 0;
|
112
|
-
|
113
|
+
capacity_ = N;
|
113
114
|
}
|
114
115
|
|
115
116
|
void destroy_elements() {
|
116
|
-
for (size_t i = 0; i < size_
|
117
|
-
T& value =
|
117
|
+
for (size_t i = 0; i < size_; ++i) {
|
118
|
+
T& value = data()[i];
|
118
119
|
value.~T();
|
119
120
|
}
|
120
|
-
if (size_ > N) { // Avoid subtracting two signed values.
|
121
|
-
for (size_t i = 0; i < size_ - N; ++i) {
|
122
|
-
dynamic_[i].~T();
|
123
|
-
}
|
124
|
-
}
|
125
121
|
gpr_free(dynamic_);
|
126
122
|
}
|
127
123
|
|
128
124
|
typename std::aligned_storage<sizeof(T)>::type inline_[N];
|
129
125
|
T* dynamic_;
|
130
126
|
size_t size_;
|
131
|
-
size_t
|
127
|
+
size_t capacity_;
|
132
128
|
};
|
133
129
|
|
134
130
|
} // namespace grpc_core
|
@@ -100,7 +100,7 @@ class InternallyRefCounted : public Orphanable {
|
|
100
100
|
|
101
101
|
void Unref() {
|
102
102
|
if (gpr_unref(&refs_)) {
|
103
|
-
Delete(this);
|
103
|
+
Delete(static_cast<Child*>(this));
|
104
104
|
}
|
105
105
|
}
|
106
106
|
|
@@ -159,7 +159,7 @@ class InternallyRefCountedWithTracing : public Orphanable {
|
|
159
159
|
const char* reason) GRPC_MUST_USE_RESULT {
|
160
160
|
if (location.Log() && trace_flag_ != nullptr && trace_flag_->enabled()) {
|
161
161
|
gpr_atm old_refs = gpr_atm_no_barrier_load(&refs_.count);
|
162
|
-
gpr_log(
|
162
|
+
gpr_log(GPR_INFO, "%s:%p %s:%d ref %" PRIdPTR " -> %" PRIdPTR " %s",
|
163
163
|
trace_flag_->name(), this, location.file(), location.line(),
|
164
164
|
old_refs, old_refs + 1, reason);
|
165
165
|
}
|
@@ -173,14 +173,14 @@ class InternallyRefCountedWithTracing : public Orphanable {
|
|
173
173
|
|
174
174
|
void Unref() {
|
175
175
|
if (gpr_unref(&refs_)) {
|
176
|
-
Delete(this);
|
176
|
+
Delete(static_cast<Child*>(this));
|
177
177
|
}
|
178
178
|
}
|
179
179
|
|
180
180
|
void Unref(const DebugLocation& location, const char* reason) {
|
181
181
|
if (location.Log() && trace_flag_ != nullptr && trace_flag_->enabled()) {
|
182
182
|
gpr_atm old_refs = gpr_atm_no_barrier_load(&refs_.count);
|
183
|
-
gpr_log(
|
183
|
+
gpr_log(GPR_INFO, "%s:%p %s:%d unref %" PRIdPTR " -> %" PRIdPTR " %s",
|
184
184
|
trace_flag_->name(), this, location.file(), location.line(),
|
185
185
|
old_refs, old_refs - 1, reason);
|
186
186
|
}
|
@@ -54,7 +54,7 @@ class RefCounted {
|
|
54
54
|
// friend of this class.
|
55
55
|
void Unref() {
|
56
56
|
if (gpr_unref(&refs_)) {
|
57
|
-
Delete(this);
|
57
|
+
Delete(static_cast<Child*>(this));
|
58
58
|
}
|
59
59
|
}
|
60
60
|
|
@@ -100,7 +100,7 @@ class RefCountedWithTracing {
|
|
100
100
|
const char* reason) GRPC_MUST_USE_RESULT {
|
101
101
|
if (location.Log() && trace_flag_ != nullptr && trace_flag_->enabled()) {
|
102
102
|
gpr_atm old_refs = gpr_atm_no_barrier_load(&refs_.count);
|
103
|
-
gpr_log(
|
103
|
+
gpr_log(GPR_INFO, "%s:%p %s:%d ref %" PRIdPTR " -> %" PRIdPTR " %s",
|
104
104
|
trace_flag_->name(), this, location.file(), location.line(),
|
105
105
|
old_refs, old_refs + 1, reason);
|
106
106
|
}
|
@@ -114,14 +114,14 @@ class RefCountedWithTracing {
|
|
114
114
|
|
115
115
|
void Unref() {
|
116
116
|
if (gpr_unref(&refs_)) {
|
117
|
-
Delete(this);
|
117
|
+
Delete(static_cast<Child*>(this));
|
118
118
|
}
|
119
119
|
}
|
120
120
|
|
121
121
|
void Unref(const DebugLocation& location, const char* reason) {
|
122
122
|
if (location.Log() && trace_flag_ != nullptr && trace_flag_->enabled()) {
|
123
123
|
gpr_atm old_refs = gpr_atm_no_barrier_load(&refs_.count);
|
124
|
-
gpr_log(
|
124
|
+
gpr_log(GPR_INFO, "%s:%p %s:%d unref %" PRIdPTR " -> %" PRIdPTR " %s",
|
125
125
|
trace_flag_->name(), this, location.file(), location.line(),
|
126
126
|
old_refs, old_refs - 1, reason);
|
127
127
|
}
|
@@ -64,7 +64,7 @@ void grpc_call_combiner_start(grpc_call_combiner* call_combiner,
|
|
64
64
|
const char* reason) {
|
65
65
|
GPR_TIMER_SCOPE("call_combiner_start", 0);
|
66
66
|
if (grpc_call_combiner_trace.enabled()) {
|
67
|
-
gpr_log(
|
67
|
+
gpr_log(GPR_INFO,
|
68
68
|
"==> grpc_call_combiner_start() [%p] closure=%p [" DEBUG_FMT_STR
|
69
69
|
"%s] error=%s",
|
70
70
|
call_combiner, closure DEBUG_FMT_ARGS, reason,
|
@@ -73,7 +73,7 @@ void grpc_call_combiner_start(grpc_call_combiner* call_combiner,
|
|
73
73
|
size_t prev_size = static_cast<size_t>(
|
74
74
|
gpr_atm_full_fetch_add(&call_combiner->size, (gpr_atm)1));
|
75
75
|
if (grpc_call_combiner_trace.enabled()) {
|
76
|
-
gpr_log(
|
76
|
+
gpr_log(GPR_INFO, " size: %" PRIdPTR " -> %" PRIdPTR, prev_size,
|
77
77
|
prev_size + 1);
|
78
78
|
}
|
79
79
|
GRPC_STATS_INC_CALL_COMBINER_LOCKS_SCHEDULED_ITEMS();
|
@@ -82,7 +82,7 @@ void grpc_call_combiner_start(grpc_call_combiner* call_combiner,
|
|
82
82
|
|
83
83
|
GPR_TIMER_MARK("call_combiner_initiate", 0);
|
84
84
|
if (grpc_call_combiner_trace.enabled()) {
|
85
|
-
gpr_log(
|
85
|
+
gpr_log(GPR_INFO, " EXECUTING IMMEDIATELY");
|
86
86
|
}
|
87
87
|
// Queue was empty, so execute this closure immediately.
|
88
88
|
GRPC_CLOSURE_SCHED(closure, error);
|
@@ -101,21 +101,21 @@ void grpc_call_combiner_stop(grpc_call_combiner* call_combiner DEBUG_ARGS,
|
|
101
101
|
const char* reason) {
|
102
102
|
GPR_TIMER_SCOPE("call_combiner_stop", 0);
|
103
103
|
if (grpc_call_combiner_trace.enabled()) {
|
104
|
-
gpr_log(
|
104
|
+
gpr_log(GPR_INFO,
|
105
105
|
"==> grpc_call_combiner_stop() [%p] [" DEBUG_FMT_STR "%s]",
|
106
106
|
call_combiner DEBUG_FMT_ARGS, reason);
|
107
107
|
}
|
108
108
|
size_t prev_size = static_cast<size_t>(
|
109
109
|
gpr_atm_full_fetch_add(&call_combiner->size, (gpr_atm)-1));
|
110
110
|
if (grpc_call_combiner_trace.enabled()) {
|
111
|
-
gpr_log(
|
111
|
+
gpr_log(GPR_INFO, " size: %" PRIdPTR " -> %" PRIdPTR, prev_size,
|
112
112
|
prev_size - 1);
|
113
113
|
}
|
114
114
|
GPR_ASSERT(prev_size >= 1);
|
115
115
|
if (prev_size > 1) {
|
116
116
|
while (true) {
|
117
117
|
if (grpc_call_combiner_trace.enabled()) {
|
118
|
-
gpr_log(
|
118
|
+
gpr_log(GPR_INFO, " checking queue");
|
119
119
|
}
|
120
120
|
bool empty;
|
121
121
|
grpc_closure* closure = reinterpret_cast<grpc_closure*>(
|
@@ -124,19 +124,19 @@ void grpc_call_combiner_stop(grpc_call_combiner* call_combiner DEBUG_ARGS,
|
|
124
124
|
// This can happen either due to a race condition within the mpscq
|
125
125
|
// code or because of a race with grpc_call_combiner_start().
|
126
126
|
if (grpc_call_combiner_trace.enabled()) {
|
127
|
-
gpr_log(
|
127
|
+
gpr_log(GPR_INFO, " queue returned no result; checking again");
|
128
128
|
}
|
129
129
|
continue;
|
130
130
|
}
|
131
131
|
if (grpc_call_combiner_trace.enabled()) {
|
132
|
-
gpr_log(
|
132
|
+
gpr_log(GPR_INFO, " EXECUTING FROM QUEUE: closure=%p error=%s",
|
133
133
|
closure, grpc_error_string(closure->error_data.error));
|
134
134
|
}
|
135
135
|
GRPC_CLOSURE_SCHED(closure, closure->error_data.error);
|
136
136
|
break;
|
137
137
|
}
|
138
138
|
} else if (grpc_call_combiner_trace.enabled()) {
|
139
|
-
gpr_log(
|
139
|
+
gpr_log(GPR_INFO, " queue empty");
|
140
140
|
}
|
141
141
|
}
|
142
142
|
|
@@ -151,7 +151,7 @@ void grpc_call_combiner_set_notify_on_cancel(grpc_call_combiner* call_combiner,
|
|
151
151
|
// Otherwise, store the new closure.
|
152
152
|
if (original_error != GRPC_ERROR_NONE) {
|
153
153
|
if (grpc_call_combiner_trace.enabled()) {
|
154
|
-
gpr_log(
|
154
|
+
gpr_log(GPR_INFO,
|
155
155
|
"call_combiner=%p: scheduling notify_on_cancel callback=%p "
|
156
156
|
"for pre-existing cancellation",
|
157
157
|
call_combiner, closure);
|
@@ -162,7 +162,7 @@ void grpc_call_combiner_set_notify_on_cancel(grpc_call_combiner* call_combiner,
|
|
162
162
|
if (gpr_atm_full_cas(&call_combiner->cancel_state, original_state,
|
163
163
|
(gpr_atm)closure)) {
|
164
164
|
if (grpc_call_combiner_trace.enabled()) {
|
165
|
-
gpr_log(
|
165
|
+
gpr_log(GPR_INFO, "call_combiner=%p: setting notify_on_cancel=%p",
|
166
166
|
call_combiner, closure);
|
167
167
|
}
|
168
168
|
// If we replaced an earlier closure, invoke the original
|
@@ -171,7 +171,7 @@ void grpc_call_combiner_set_notify_on_cancel(grpc_call_combiner* call_combiner,
|
|
171
171
|
if (original_state != 0) {
|
172
172
|
closure = (grpc_closure*)original_state;
|
173
173
|
if (grpc_call_combiner_trace.enabled()) {
|
174
|
-
gpr_log(
|
174
|
+
gpr_log(GPR_INFO,
|
175
175
|
"call_combiner=%p: scheduling old cancel callback=%p",
|
176
176
|
call_combiner, closure);
|
177
177
|
}
|
@@ -199,7 +199,7 @@ void grpc_call_combiner_cancel(grpc_call_combiner* call_combiner,
|
|
199
199
|
if (original_state != 0) {
|
200
200
|
grpc_closure* notify_on_cancel = (grpc_closure*)original_state;
|
201
201
|
if (grpc_call_combiner_trace.enabled()) {
|
202
|
-
gpr_log(
|
202
|
+
gpr_log(GPR_INFO,
|
203
203
|
"call_combiner=%p: scheduling notify_on_cancel callback=%p",
|
204
204
|
call_combiner, notify_on_cancel);
|
205
205
|
}
|