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
@@ -292,7 +292,7 @@ static void pi_add_ref_dbg(polling_island* pi, const char* reason,
|
|
292
292
|
const char* file, int line) {
|
293
293
|
if (grpc_polling_trace.enabled()) {
|
294
294
|
gpr_atm old_cnt = gpr_atm_acq_load(&pi->ref_count);
|
295
|
-
gpr_log(
|
295
|
+
gpr_log(GPR_INFO,
|
296
296
|
"Add ref pi: %p, old:%" PRIdPTR " -> new:%" PRIdPTR
|
297
297
|
" (%s) - (%s, %d)",
|
298
298
|
pi, old_cnt, old_cnt + 1, reason, file, line);
|
@@ -304,7 +304,7 @@ static void pi_unref_dbg(polling_island* pi, const char* reason,
|
|
304
304
|
const char* file, int line) {
|
305
305
|
if (grpc_polling_trace.enabled()) {
|
306
306
|
gpr_atm old_cnt = gpr_atm_acq_load(&pi->ref_count);
|
307
|
-
gpr_log(
|
307
|
+
gpr_log(GPR_INFO,
|
308
308
|
"Unref pi: %p, old:%" PRIdPTR " -> new:%" PRIdPTR
|
309
309
|
" (%s) - (%s, %d)",
|
310
310
|
pi, old_cnt, (old_cnt - 1), reason, file, line);
|
@@ -983,7 +983,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset,
|
|
983
983
|
GRPC_SCHEDULING_END_BLOCKING_REGION;
|
984
984
|
|
985
985
|
if (grpc_polling_trace.enabled()) {
|
986
|
-
gpr_log(
|
986
|
+
gpr_log(GPR_INFO, "%p poll=%d", pollset, r);
|
987
987
|
}
|
988
988
|
|
989
989
|
if (r < 0) {
|
@@ -1007,7 +1007,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset,
|
|
1007
1007
|
} else {
|
1008
1008
|
if (pfds[0].revents & POLLIN_CHECK) {
|
1009
1009
|
if (grpc_polling_trace.enabled()) {
|
1010
|
-
gpr_log(
|
1010
|
+
gpr_log(GPR_INFO, "%p: got_wakeup", pollset);
|
1011
1011
|
}
|
1012
1012
|
work_combine_error(
|
1013
1013
|
&error, grpc_wakeup_fd_consume_wakeup(&worker.wakeup_fd->fd));
|
@@ -1017,7 +1017,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset,
|
|
1017
1017
|
fd_end_poll(&watchers[i], 0, 0, nullptr);
|
1018
1018
|
} else {
|
1019
1019
|
if (grpc_polling_trace.enabled()) {
|
1020
|
-
gpr_log(
|
1020
|
+
gpr_log(GPR_INFO, "%p got_event: %d r:%d w:%d [%d]", pollset,
|
1021
1021
|
pfds[i].fd, (pfds[i].revents & POLLIN_CHECK) != 0,
|
1022
1022
|
(pfds[i].revents & POLLOUT_CHECK) != 0, pfds[i].revents);
|
1023
1023
|
}
|
@@ -1530,6 +1530,12 @@ static void run_poll(void* args) {
|
|
1530
1530
|
|
1531
1531
|
// This function overrides poll() to handle condition variable wakeup fds
|
1532
1532
|
static int cvfd_poll(struct pollfd* fds, nfds_t nfds, int timeout) {
|
1533
|
+
if (timeout == 0) {
|
1534
|
+
// Don't bother using background threads for polling if timeout is 0,
|
1535
|
+
// poll-cv might not wait for a poll to return otherwise.
|
1536
|
+
// https://github.com/grpc/grpc/issues/13298
|
1537
|
+
return poll(fds, nfds, 0);
|
1538
|
+
}
|
1533
1539
|
unsigned int i;
|
1534
1540
|
int res, idx;
|
1535
1541
|
grpc_cv_node* pollcv;
|
@@ -46,9 +46,9 @@ grpc_core::DebugOnlyTraceFlag grpc_polling_api_trace(false, "polling_api");
|
|
46
46
|
#ifndef NDEBUG
|
47
47
|
|
48
48
|
// Polling API trace only enabled in debug builds
|
49
|
-
#define GRPC_POLLING_API_TRACE(format, ...)
|
50
|
-
if (grpc_polling_api_trace.enabled()) {
|
51
|
-
gpr_log(
|
49
|
+
#define GRPC_POLLING_API_TRACE(format, ...) \
|
50
|
+
if (grpc_polling_api_trace.enabled()) { \
|
51
|
+
gpr_log(GPR_INFO, "(polling-api) " format, __VA_ARGS__); \
|
52
52
|
}
|
53
53
|
#else
|
54
54
|
#define GRPC_POLLING_API_TRACE(...)
|
@@ -69,7 +69,7 @@ static size_t run_closures(grpc_closure_list list) {
|
|
69
69
|
gpr_log(GPR_DEBUG, "EXECUTOR: run %p [created by %s:%d]", c,
|
70
70
|
c->file_created, c->line_created);
|
71
71
|
#else
|
72
|
-
gpr_log(
|
72
|
+
gpr_log(GPR_INFO, "EXECUTOR: run %p", c);
|
73
73
|
#endif
|
74
74
|
}
|
75
75
|
#ifndef NDEBUG
|
@@ -150,7 +150,7 @@ static void executor_thread(void* arg) {
|
|
150
150
|
size_t subtract_depth = 0;
|
151
151
|
for (;;) {
|
152
152
|
if (executor_trace.enabled()) {
|
153
|
-
gpr_log(
|
153
|
+
gpr_log(GPR_INFO, "EXECUTOR[%d]: step (sub_depth=%" PRIdPTR ")",
|
154
154
|
static_cast<int>(ts - g_thread_state), subtract_depth);
|
155
155
|
}
|
156
156
|
gpr_mu_lock(&ts->mu);
|
@@ -161,7 +161,7 @@ static void executor_thread(void* arg) {
|
|
161
161
|
}
|
162
162
|
if (ts->shutdown) {
|
163
163
|
if (executor_trace.enabled()) {
|
164
|
-
gpr_log(
|
164
|
+
gpr_log(GPR_INFO, "EXECUTOR[%d]: shutdown",
|
165
165
|
static_cast<int>(ts - g_thread_state));
|
166
166
|
}
|
167
167
|
gpr_mu_unlock(&ts->mu);
|
@@ -172,7 +172,7 @@ static void executor_thread(void* arg) {
|
|
172
172
|
ts->elems = GRPC_CLOSURE_LIST_INIT;
|
173
173
|
gpr_mu_unlock(&ts->mu);
|
174
174
|
if (executor_trace.enabled()) {
|
175
|
-
gpr_log(
|
175
|
+
gpr_log(GPR_INFO, "EXECUTOR[%d]: execute",
|
176
176
|
static_cast<int>(ts - g_thread_state));
|
177
177
|
}
|
178
178
|
|
@@ -199,7 +199,7 @@ static void executor_push(grpc_closure* closure, grpc_error* error,
|
|
199
199
|
gpr_log(GPR_DEBUG, "EXECUTOR: schedule %p (created %s:%d) inline",
|
200
200
|
closure, closure->file_created, closure->line_created);
|
201
201
|
#else
|
202
|
-
gpr_log(
|
202
|
+
gpr_log(GPR_INFO, "EXECUTOR: schedule %p inline", closure);
|
203
203
|
#endif
|
204
204
|
}
|
205
205
|
grpc_closure_list_append(grpc_core::ExecCtx::Get()->closure_list(),
|
@@ -225,7 +225,7 @@ static void executor_push(grpc_closure* closure, grpc_error* error,
|
|
225
225
|
closure, is_short ? "short" : "long", closure->file_created,
|
226
226
|
closure->line_created, static_cast<int>(ts - g_thread_state));
|
227
227
|
#else
|
228
|
-
gpr_log(
|
228
|
+
gpr_log(GPR_INFO, "EXECUTOR: try to schedule %p (%s) to thread %d",
|
229
229
|
closure, is_short ? "short" : "long",
|
230
230
|
(int)(ts - g_thread_state));
|
231
231
|
#endif
|
@@ -289,7 +289,7 @@ static bool rq_alloc(grpc_resource_quota* resource_quota) {
|
|
289
289
|
GRPC_RULIST_AWAITING_ALLOCATION))) {
|
290
290
|
gpr_mu_lock(&resource_user->mu);
|
291
291
|
if (grpc_resource_quota_trace.enabled()) {
|
292
|
-
gpr_log(
|
292
|
+
gpr_log(GPR_INFO,
|
293
293
|
"RQ: check allocation for user %p shutdown=%" PRIdPTR
|
294
294
|
" free_pool=%" PRId64,
|
295
295
|
resource_user, gpr_atm_no_barrier_load(&resource_user->shutdown),
|
@@ -315,7 +315,7 @@ static bool rq_alloc(grpc_resource_quota* resource_quota) {
|
|
315
315
|
resource_quota->free_pool -= amt;
|
316
316
|
rq_update_estimate(resource_quota);
|
317
317
|
if (grpc_resource_quota_trace.enabled()) {
|
318
|
-
gpr_log(
|
318
|
+
gpr_log(GPR_INFO,
|
319
319
|
"RQ %s %s: grant alloc %" PRId64
|
320
320
|
" bytes; rq_free_pool -> %" PRId64,
|
321
321
|
resource_quota->name, resource_user->name, amt,
|
@@ -323,7 +323,7 @@ static bool rq_alloc(grpc_resource_quota* resource_quota) {
|
|
323
323
|
}
|
324
324
|
} else if (grpc_resource_quota_trace.enabled() &&
|
325
325
|
resource_user->free_pool >= 0) {
|
326
|
-
gpr_log(
|
326
|
+
gpr_log(GPR_INFO, "RQ %s %s: discard already satisfied alloc request",
|
327
327
|
resource_quota->name, resource_user->name);
|
328
328
|
}
|
329
329
|
if (resource_user->free_pool >= 0) {
|
@@ -353,7 +353,7 @@ static bool rq_reclaim_from_per_user_free_pool(
|
|
353
353
|
resource_quota->free_pool += amt;
|
354
354
|
rq_update_estimate(resource_quota);
|
355
355
|
if (grpc_resource_quota_trace.enabled()) {
|
356
|
-
gpr_log(
|
356
|
+
gpr_log(GPR_INFO,
|
357
357
|
"RQ %s %s: reclaim_from_per_user_free_pool %" PRId64
|
358
358
|
" bytes; rq_free_pool -> %" PRId64,
|
359
359
|
resource_quota->name, resource_user->name, amt,
|
@@ -376,9 +376,8 @@ static bool rq_reclaim(grpc_resource_quota* resource_quota, bool destructive) {
|
|
376
376
|
grpc_resource_user* resource_user = rulist_pop_head(resource_quota, list);
|
377
377
|
if (resource_user == nullptr) return false;
|
378
378
|
if (grpc_resource_quota_trace.enabled()) {
|
379
|
-
gpr_log(
|
380
|
-
|
381
|
-
destructive ? "destructive" : "benign");
|
379
|
+
gpr_log(GPR_INFO, "RQ %s %s: initiate %s reclamation", resource_quota->name,
|
380
|
+
resource_user->name, destructive ? "destructive" : "benign");
|
382
381
|
}
|
383
382
|
resource_quota->reclaiming = true;
|
384
383
|
grpc_resource_quota_ref_internal(resource_quota);
|
@@ -506,7 +505,7 @@ static void ru_post_destructive_reclaimer(void* ru, grpc_error* error) {
|
|
506
505
|
|
507
506
|
static void ru_shutdown(void* ru, grpc_error* error) {
|
508
507
|
if (grpc_resource_quota_trace.enabled()) {
|
509
|
-
gpr_log(
|
508
|
+
gpr_log(GPR_INFO, "RU shutdown %p", ru);
|
510
509
|
}
|
511
510
|
grpc_resource_user* resource_user = static_cast<grpc_resource_user*>(ru);
|
512
511
|
gpr_mu_lock(&resource_user->mu);
|
@@ -793,7 +792,7 @@ void grpc_resource_user_alloc(grpc_resource_user* resource_user, size_t size,
|
|
793
792
|
resource_user->free_pool -= static_cast<int64_t>(size);
|
794
793
|
resource_user->outstanding_allocations += static_cast<int64_t>(size);
|
795
794
|
if (grpc_resource_quota_trace.enabled()) {
|
796
|
-
gpr_log(
|
795
|
+
gpr_log(GPR_INFO, "RQ %s %s: alloc %" PRIdPTR "; free_pool -> %" PRId64,
|
797
796
|
resource_user->resource_quota->name, resource_user->name, size,
|
798
797
|
resource_user->free_pool);
|
799
798
|
}
|
@@ -816,7 +815,7 @@ void grpc_resource_user_free(grpc_resource_user* resource_user, size_t size) {
|
|
816
815
|
bool was_zero_or_negative = resource_user->free_pool <= 0;
|
817
816
|
resource_user->free_pool += static_cast<int64_t>(size);
|
818
817
|
if (grpc_resource_quota_trace.enabled()) {
|
819
|
-
gpr_log(
|
818
|
+
gpr_log(GPR_INFO, "RQ %s %s: free %" PRIdPTR "; free_pool -> %" PRId64,
|
820
819
|
resource_user->resource_quota->name, resource_user->name, size,
|
821
820
|
resource_user->free_pool);
|
822
821
|
}
|
@@ -842,7 +841,7 @@ void grpc_resource_user_post_reclaimer(grpc_resource_user* resource_user,
|
|
842
841
|
|
843
842
|
void grpc_resource_user_finish_reclamation(grpc_resource_user* resource_user) {
|
844
843
|
if (grpc_resource_quota_trace.enabled()) {
|
845
|
-
gpr_log(
|
844
|
+
gpr_log(GPR_INFO, "RQ %s %s: reclamation complete",
|
846
845
|
resource_user->resource_quota->name, resource_user->name);
|
847
846
|
}
|
848
847
|
GRPC_CLOSURE_SCHED(
|
@@ -181,6 +181,30 @@ grpc_error* grpc_set_socket_reuse_port(int fd, int reuse) {
|
|
181
181
|
#endif
|
182
182
|
}
|
183
183
|
|
184
|
+
static gpr_once g_probe_so_reuesport_once = GPR_ONCE_INIT;
|
185
|
+
static int g_support_so_reuseport = false;
|
186
|
+
|
187
|
+
void probe_so_reuseport_once(void) {
|
188
|
+
#ifndef GPR_MANYLINUX1
|
189
|
+
int s = socket(AF_INET, SOCK_STREAM, 0);
|
190
|
+
if (s < 0) {
|
191
|
+
/* This might be an ipv6-only environment in which case 'socket(AF_INET,..)'
|
192
|
+
call would fail. Try creating IPv6 socket in that case */
|
193
|
+
s = socket(AF_INET6, SOCK_STREAM, 0);
|
194
|
+
}
|
195
|
+
if (s >= 0) {
|
196
|
+
g_support_so_reuseport = GRPC_LOG_IF_ERROR(
|
197
|
+
"check for SO_REUSEPORT", grpc_set_socket_reuse_port(s, 1));
|
198
|
+
close(s);
|
199
|
+
}
|
200
|
+
#endif
|
201
|
+
}
|
202
|
+
|
203
|
+
bool grpc_is_socket_reuse_port_supported() {
|
204
|
+
gpr_once_init(&g_probe_so_reuesport_once, probe_so_reuseport_once);
|
205
|
+
return g_support_so_reuseport;
|
206
|
+
}
|
207
|
+
|
184
208
|
/* disable nagle */
|
185
209
|
grpc_error* grpc_set_socket_low_latency(int fd, int low_latency) {
|
186
210
|
int val = (low_latency != 0);
|
@@ -33,7 +33,6 @@
|
|
33
33
|
int grpc_accept4(int sockfd, grpc_resolved_address* resolved_addr, int nonblock,
|
34
34
|
int cloexec) {
|
35
35
|
int flags = 0;
|
36
|
-
GPR_ASSERT(sizeof(socklen_t) <= sizeof(size_t));
|
37
36
|
flags |= nonblock ? SOCK_NONBLOCK : 0;
|
38
37
|
flags |= cloexec ? SOCK_CLOEXEC : 0;
|
39
38
|
return accept4(sockfd, reinterpret_cast<grpc_sockaddr*>(resolved_addr->addr),
|
@@ -34,9 +34,8 @@
|
|
34
34
|
int grpc_accept4(int sockfd, grpc_resolved_address* resolved_addr, int nonblock,
|
35
35
|
int cloexec) {
|
36
36
|
int fd, flags;
|
37
|
-
|
38
|
-
|
39
|
-
(socklen_t*)&resolved_addr->len);
|
37
|
+
fd = accept(sockfd, reinterpret_cast<grpc_sockaddr*>(resolved_addr->addr),
|
38
|
+
&resolved_addr->len);
|
40
39
|
if (fd >= 0) {
|
41
40
|
if (nonblock) {
|
42
41
|
flags = fcntl(fd, F_GETFL, 0);
|
@@ -44,6 +44,9 @@ grpc_error* grpc_set_socket_cloexec(int fd, int close_on_exec);
|
|
44
44
|
/* set a socket to reuse old addresses */
|
45
45
|
grpc_error* grpc_set_socket_reuse_addr(int fd, int reuse);
|
46
46
|
|
47
|
+
/* return true if SO_REUSEPORT is supported */
|
48
|
+
bool grpc_is_socket_reuse_port_supported();
|
49
|
+
|
47
50
|
/* disable nagle */
|
48
51
|
grpc_error* grpc_set_socket_low_latency(int fd, int low_latency);
|
49
52
|
|
@@ -66,7 +66,7 @@ static void on_alarm(void* acp, grpc_error* error) {
|
|
66
66
|
grpc_custom_tcp_connect* connect = socket->connector;
|
67
67
|
if (grpc_tcp_trace.enabled()) {
|
68
68
|
const char* str = grpc_error_string(error);
|
69
|
-
gpr_log(
|
69
|
+
gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: on_alarm: error=%s",
|
70
70
|
connect->addr_name, str);
|
71
71
|
}
|
72
72
|
if (error == GRPC_ERROR_NONE) {
|
@@ -136,7 +136,7 @@ static void tcp_connect(grpc_closure* closure, grpc_endpoint** ep,
|
|
136
136
|
connect->refs = 2;
|
137
137
|
|
138
138
|
if (grpc_tcp_trace.enabled()) {
|
139
|
-
gpr_log(
|
139
|
+
gpr_log(GPR_INFO, "CLIENT_CONNECT: %p %s: asynchronously connecting",
|
140
140
|
socket, connect->addr_name);
|
141
141
|
}
|
142
142
|
|
@@ -104,7 +104,7 @@ static void tc_on_alarm(void* acp, grpc_error* error) {
|
|
104
104
|
async_connect* ac = static_cast<async_connect*>(acp);
|
105
105
|
if (grpc_tcp_trace.enabled()) {
|
106
106
|
const char* str = grpc_error_string(error);
|
107
|
-
gpr_log(
|
107
|
+
gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: on_alarm: error=%s", ac->addr_str,
|
108
108
|
str);
|
109
109
|
}
|
110
110
|
gpr_mu_lock(&ac->mu);
|
@@ -141,8 +141,8 @@ static void on_writable(void* acp, grpc_error* error) {
|
|
141
141
|
|
142
142
|
if (grpc_tcp_trace.enabled()) {
|
143
143
|
const char* str = grpc_error_string(error);
|
144
|
-
gpr_log(
|
145
|
-
|
144
|
+
gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: on_writable: error=%s", ac->addr_str,
|
145
|
+
str);
|
146
146
|
}
|
147
147
|
|
148
148
|
gpr_mu_lock(&ac->mu);
|
@@ -325,7 +325,7 @@ void grpc_tcp_client_create_from_prepared_fd(
|
|
325
325
|
ac->channel_args = grpc_channel_args_copy(channel_args);
|
326
326
|
|
327
327
|
if (grpc_tcp_trace.enabled()) {
|
328
|
-
gpr_log(
|
328
|
+
gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: asynchronously connecting fd %p",
|
329
329
|
ac->addr_str, fdobj);
|
330
330
|
}
|
331
331
|
|
@@ -125,16 +125,16 @@ static void tcp_ref(custom_tcp_endpoint* tcp) { gpr_ref(&tcp->refcount); }
|
|
125
125
|
static void call_read_cb(custom_tcp_endpoint* tcp, grpc_error* error) {
|
126
126
|
grpc_closure* cb = tcp->read_cb;
|
127
127
|
if (grpc_tcp_trace.enabled()) {
|
128
|
-
gpr_log(
|
128
|
+
gpr_log(GPR_INFO, "TCP:%p call_cb %p %p:%p", tcp->socket, cb, cb->cb,
|
129
129
|
cb->cb_arg);
|
130
130
|
size_t i;
|
131
131
|
const char* str = grpc_error_string(error);
|
132
|
-
gpr_log(
|
132
|
+
gpr_log(GPR_INFO, "read: error=%s", str);
|
133
133
|
|
134
134
|
for (i = 0; i < tcp->read_slices->count; i++) {
|
135
135
|
char* dump = grpc_dump_slice(tcp->read_slices->slices[i],
|
136
136
|
GPR_DUMP_HEX | GPR_DUMP_ASCII);
|
137
|
-
gpr_log(
|
137
|
+
gpr_log(GPR_INFO, "READ %p (peer=%s): %s", tcp, tcp->peer_string, dump);
|
138
138
|
gpr_free(dump);
|
139
139
|
}
|
140
140
|
}
|
@@ -171,7 +171,7 @@ static void custom_read_callback(grpc_custom_socket* socket, size_t nread,
|
|
171
171
|
static void tcp_read_allocation_done(void* tcpp, grpc_error* error) {
|
172
172
|
custom_tcp_endpoint* tcp = (custom_tcp_endpoint*)tcpp;
|
173
173
|
if (grpc_tcp_trace.enabled()) {
|
174
|
-
gpr_log(
|
174
|
+
gpr_log(GPR_INFO, "TCP:%p read_allocation_done: %s", tcp->socket,
|
175
175
|
grpc_error_string(error));
|
176
176
|
}
|
177
177
|
if (error == GRPC_ERROR_NONE) {
|
@@ -188,7 +188,7 @@ static void tcp_read_allocation_done(void* tcpp, grpc_error* error) {
|
|
188
188
|
}
|
189
189
|
if (grpc_tcp_trace.enabled()) {
|
190
190
|
const char* str = grpc_error_string(error);
|
191
|
-
gpr_log(
|
191
|
+
gpr_log(GPR_INFO, "Initiating read on %p: error=%s", tcp->socket, str);
|
192
192
|
}
|
193
193
|
}
|
194
194
|
|
@@ -214,7 +214,7 @@ static void custom_write_callback(grpc_custom_socket* socket,
|
|
214
214
|
tcp->write_cb = nullptr;
|
215
215
|
if (grpc_tcp_trace.enabled()) {
|
216
216
|
const char* str = grpc_error_string(error);
|
217
|
-
gpr_log(
|
217
|
+
gpr_log(GPR_INFO, "write complete on %p: error=%s", tcp->socket, str);
|
218
218
|
}
|
219
219
|
TCP_UNREF(tcp, "write");
|
220
220
|
GRPC_CLOSURE_SCHED(cb, error);
|
@@ -231,8 +231,8 @@ static void endpoint_write(grpc_endpoint* ep, grpc_slice_buffer* write_slices,
|
|
231
231
|
for (j = 0; j < write_slices->count; j++) {
|
232
232
|
char* data = grpc_dump_slice(write_slices->slices[j],
|
233
233
|
GPR_DUMP_HEX | GPR_DUMP_ASCII);
|
234
|
-
gpr_log(
|
235
|
-
|
234
|
+
gpr_log(GPR_INFO, "WRITE %p (peer=%s): %s", tcp->socket, tcp->peer_string,
|
235
|
+
data);
|
236
236
|
gpr_free(data);
|
237
237
|
}
|
238
238
|
}
|
@@ -283,7 +283,7 @@ static void endpoint_shutdown(grpc_endpoint* ep, grpc_error* why) {
|
|
283
283
|
if (!tcp->shutting_down) {
|
284
284
|
if (grpc_tcp_trace.enabled()) {
|
285
285
|
const char* str = grpc_error_string(why);
|
286
|
-
gpr_log(
|
286
|
+
gpr_log(GPR_INFO, "TCP %p shutdown why=%s", tcp->socket, str);
|
287
287
|
}
|
288
288
|
tcp->shutting_down = true;
|
289
289
|
// GRPC_CLOSURE_SCHED(tcp->read_cb, GRPC_ERROR_REF(why));
|
@@ -345,7 +345,7 @@ grpc_endpoint* custom_tcp_endpoint_create(grpc_custom_socket* socket,
|
|
345
345
|
grpc_core::ExecCtx exec_ctx;
|
346
346
|
|
347
347
|
if (grpc_tcp_trace.enabled()) {
|
348
|
-
gpr_log(
|
348
|
+
gpr_log(GPR_INFO, "Creating TCP endpoint %p", socket);
|
349
349
|
}
|
350
350
|
memset(tcp, 0, sizeof(custom_tcp_endpoint));
|
351
351
|
socket->refs++;
|
@@ -120,7 +120,7 @@ static void tcp_drop_uncovered_then_handle_write(void* arg /* grpc_tcp */,
|
|
120
120
|
static void done_poller(void* bp, grpc_error* error_ignored) {
|
121
121
|
backup_poller* p = static_cast<backup_poller*>(bp);
|
122
122
|
if (grpc_tcp_trace.enabled()) {
|
123
|
-
gpr_log(
|
123
|
+
gpr_log(GPR_INFO, "BACKUP_POLLER:%p destroy", p);
|
124
124
|
}
|
125
125
|
grpc_pollset_destroy(BACKUP_POLLER_POLLSET(p));
|
126
126
|
gpr_free(p);
|
@@ -129,7 +129,7 @@ static void done_poller(void* bp, grpc_error* error_ignored) {
|
|
129
129
|
static void run_poller(void* bp, grpc_error* error_ignored) {
|
130
130
|
backup_poller* p = static_cast<backup_poller*>(bp);
|
131
131
|
if (grpc_tcp_trace.enabled()) {
|
132
|
-
gpr_log(
|
132
|
+
gpr_log(GPR_INFO, "BACKUP_POLLER:%p run", p);
|
133
133
|
}
|
134
134
|
gpr_mu_lock(p->pollset_mu);
|
135
135
|
grpc_millis deadline = grpc_core::ExecCtx::Get()->Now() + 10 * GPR_MS_PER_SEC;
|
@@ -145,18 +145,18 @@ static void run_poller(void* bp, grpc_error* error_ignored) {
|
|
145
145
|
gpr_mu_lock(p->pollset_mu);
|
146
146
|
bool cas_ok = gpr_atm_full_cas(&g_backup_poller, (gpr_atm)p, 0);
|
147
147
|
if (grpc_tcp_trace.enabled()) {
|
148
|
-
gpr_log(
|
148
|
+
gpr_log(GPR_INFO, "BACKUP_POLLER:%p done cas_ok=%d", p, cas_ok);
|
149
149
|
}
|
150
150
|
gpr_mu_unlock(p->pollset_mu);
|
151
151
|
if (grpc_tcp_trace.enabled()) {
|
152
|
-
gpr_log(
|
152
|
+
gpr_log(GPR_INFO, "BACKUP_POLLER:%p shutdown", p);
|
153
153
|
}
|
154
154
|
grpc_pollset_shutdown(BACKUP_POLLER_POLLSET(p),
|
155
155
|
GRPC_CLOSURE_INIT(&p->run_poller, done_poller, p,
|
156
156
|
grpc_schedule_on_exec_ctx));
|
157
157
|
} else {
|
158
158
|
if (grpc_tcp_trace.enabled()) {
|
159
|
-
gpr_log(
|
159
|
+
gpr_log(GPR_INFO, "BACKUP_POLLER:%p reschedule", p);
|
160
160
|
}
|
161
161
|
GRPC_CLOSURE_SCHED(&p->run_poller, GRPC_ERROR_NONE);
|
162
162
|
}
|
@@ -167,7 +167,7 @@ static void drop_uncovered(grpc_tcp* tcp) {
|
|
167
167
|
gpr_atm old_count =
|
168
168
|
gpr_atm_no_barrier_fetch_add(&g_uncovered_notifications_pending, -1);
|
169
169
|
if (grpc_tcp_trace.enabled()) {
|
170
|
-
gpr_log(
|
170
|
+
gpr_log(GPR_INFO, "BACKUP_POLLER:%p uncover cnt %d->%d", p,
|
171
171
|
static_cast<int>(old_count), static_cast<int>(old_count) - 1);
|
172
172
|
}
|
173
173
|
GPR_ASSERT(old_count != 1);
|
@@ -178,7 +178,7 @@ static void cover_self(grpc_tcp* tcp) {
|
|
178
178
|
gpr_atm old_count =
|
179
179
|
gpr_atm_no_barrier_fetch_add(&g_uncovered_notifications_pending, 2);
|
180
180
|
if (grpc_tcp_trace.enabled()) {
|
181
|
-
gpr_log(
|
181
|
+
gpr_log(GPR_INFO, "BACKUP_POLLER: cover cnt %d->%d",
|
182
182
|
static_cast<int>(old_count), 2 + static_cast<int>(old_count));
|
183
183
|
}
|
184
184
|
if (old_count == 0) {
|
@@ -186,7 +186,7 @@ static void cover_self(grpc_tcp* tcp) {
|
|
186
186
|
p = static_cast<backup_poller*>(
|
187
187
|
gpr_zalloc(sizeof(*p) + grpc_pollset_size()));
|
188
188
|
if (grpc_tcp_trace.enabled()) {
|
189
|
-
gpr_log(
|
189
|
+
gpr_log(GPR_INFO, "BACKUP_POLLER:%p create", p);
|
190
190
|
}
|
191
191
|
grpc_pollset_init(BACKUP_POLLER_POLLSET(p), &p->pollset_mu);
|
192
192
|
gpr_atm_rel_store(&g_backup_poller, (gpr_atm)p);
|
@@ -201,7 +201,7 @@ static void cover_self(grpc_tcp* tcp) {
|
|
201
201
|
}
|
202
202
|
}
|
203
203
|
if (grpc_tcp_trace.enabled()) {
|
204
|
-
gpr_log(
|
204
|
+
gpr_log(GPR_INFO, "BACKUP_POLLER:%p add %p", p, tcp);
|
205
205
|
}
|
206
206
|
grpc_pollset_add_fd(BACKUP_POLLER_POLLSET(p), tcp->em_fd);
|
207
207
|
if (old_count != 0) {
|
@@ -211,7 +211,7 @@ static void cover_self(grpc_tcp* tcp) {
|
|
211
211
|
|
212
212
|
static void notify_on_read(grpc_tcp* tcp) {
|
213
213
|
if (grpc_tcp_trace.enabled()) {
|
214
|
-
gpr_log(
|
214
|
+
gpr_log(GPR_INFO, "TCP:%p notify_on_read", tcp);
|
215
215
|
}
|
216
216
|
GRPC_CLOSURE_INIT(&tcp->read_done_closure, tcp_handle_read, tcp,
|
217
217
|
grpc_schedule_on_exec_ctx);
|
@@ -220,7 +220,7 @@ static void notify_on_read(grpc_tcp* tcp) {
|
|
220
220
|
|
221
221
|
static void notify_on_write(grpc_tcp* tcp) {
|
222
222
|
if (grpc_tcp_trace.enabled()) {
|
223
|
-
gpr_log(
|
223
|
+
gpr_log(GPR_INFO, "TCP:%p notify_on_write", tcp);
|
224
224
|
}
|
225
225
|
cover_self(tcp);
|
226
226
|
GRPC_CLOSURE_INIT(&tcp->write_done_closure,
|
@@ -231,7 +231,7 @@ static void notify_on_write(grpc_tcp* tcp) {
|
|
231
231
|
|
232
232
|
static void tcp_drop_uncovered_then_handle_write(void* arg, grpc_error* error) {
|
233
233
|
if (grpc_tcp_trace.enabled()) {
|
234
|
-
gpr_log(
|
234
|
+
gpr_log(GPR_INFO, "TCP:%p got_write: %s", arg, grpc_error_string(error));
|
235
235
|
}
|
236
236
|
drop_uncovered(static_cast<grpc_tcp*>(arg));
|
237
237
|
tcp_handle_write(arg, error);
|
@@ -351,15 +351,15 @@ static void call_read_cb(grpc_tcp* tcp, grpc_error* error) {
|
|
351
351
|
grpc_closure* cb = tcp->read_cb;
|
352
352
|
|
353
353
|
if (grpc_tcp_trace.enabled()) {
|
354
|
-
gpr_log(
|
354
|
+
gpr_log(GPR_INFO, "TCP:%p call_cb %p %p:%p", tcp, cb, cb->cb, cb->cb_arg);
|
355
355
|
size_t i;
|
356
356
|
const char* str = grpc_error_string(error);
|
357
|
-
gpr_log(
|
357
|
+
gpr_log(GPR_INFO, "read: error=%s", str);
|
358
358
|
|
359
359
|
for (i = 0; i < tcp->incoming_buffer->count; i++) {
|
360
360
|
char* dump = grpc_dump_slice(tcp->incoming_buffer->slices[i],
|
361
361
|
GPR_DUMP_HEX | GPR_DUMP_ASCII);
|
362
|
-
gpr_log(
|
362
|
+
gpr_log(GPR_INFO, "READ %p (peer=%s): %s", tcp, tcp->peer_string, dump);
|
363
363
|
gpr_free(dump);
|
364
364
|
}
|
365
365
|
}
|
@@ -371,7 +371,7 @@ static void call_read_cb(grpc_tcp* tcp, grpc_error* error) {
|
|
371
371
|
|
372
372
|
#define MAX_READ_IOVEC 4
|
373
373
|
static void tcp_do_read(grpc_tcp* tcp) {
|
374
|
-
GPR_TIMER_SCOPE("
|
374
|
+
GPR_TIMER_SCOPE("tcp_do_read", 0);
|
375
375
|
struct msghdr msg;
|
376
376
|
struct iovec iov[MAX_READ_IOVEC];
|
377
377
|
ssize_t read_bytes;
|
@@ -441,7 +441,7 @@ static void tcp_do_read(grpc_tcp* tcp) {
|
|
441
441
|
static void tcp_read_allocation_done(void* tcpp, grpc_error* error) {
|
442
442
|
grpc_tcp* tcp = static_cast<grpc_tcp*>(tcpp);
|
443
443
|
if (grpc_tcp_trace.enabled()) {
|
444
|
-
gpr_log(
|
444
|
+
gpr_log(GPR_INFO, "TCP:%p read_allocation_done: %s", tcp,
|
445
445
|
grpc_error_string(error));
|
446
446
|
}
|
447
447
|
if (error != GRPC_ERROR_NONE) {
|
@@ -459,13 +459,13 @@ static void tcp_continue_read(grpc_tcp* tcp) {
|
|
459
459
|
if (tcp->incoming_buffer->length < target_read_size &&
|
460
460
|
tcp->incoming_buffer->count < MAX_READ_IOVEC) {
|
461
461
|
if (grpc_tcp_trace.enabled()) {
|
462
|
-
gpr_log(
|
462
|
+
gpr_log(GPR_INFO, "TCP:%p alloc_slices", tcp);
|
463
463
|
}
|
464
464
|
grpc_resource_user_alloc_slices(&tcp->slice_allocator, target_read_size, 1,
|
465
465
|
tcp->incoming_buffer);
|
466
466
|
} else {
|
467
467
|
if (grpc_tcp_trace.enabled()) {
|
468
|
-
gpr_log(
|
468
|
+
gpr_log(GPR_INFO, "TCP:%p do_read", tcp);
|
469
469
|
}
|
470
470
|
tcp_do_read(tcp);
|
471
471
|
}
|
@@ -475,7 +475,7 @@ static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error* error) {
|
|
475
475
|
grpc_tcp* tcp = static_cast<grpc_tcp*>(arg);
|
476
476
|
GPR_ASSERT(!tcp->finished_edge);
|
477
477
|
if (grpc_tcp_trace.enabled()) {
|
478
|
-
gpr_log(
|
478
|
+
gpr_log(GPR_INFO, "TCP:%p got_read: %s", tcp, grpc_error_string(error));
|
479
479
|
}
|
480
480
|
|
481
481
|
if (error != GRPC_ERROR_NONE) {
|
@@ -618,7 +618,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) {
|
|
618
618
|
|
619
619
|
if (!tcp_flush(tcp, &error)) {
|
620
620
|
if (grpc_tcp_trace.enabled()) {
|
621
|
-
gpr_log(
|
621
|
+
gpr_log(GPR_INFO, "write: delayed");
|
622
622
|
}
|
623
623
|
notify_on_write(tcp);
|
624
624
|
} else {
|
@@ -626,7 +626,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) {
|
|
626
626
|
tcp->write_cb = nullptr;
|
627
627
|
if (grpc_tcp_trace.enabled()) {
|
628
628
|
const char* str = grpc_error_string(error);
|
629
|
-
gpr_log(
|
629
|
+
gpr_log(GPR_INFO, "write: %s", str);
|
630
630
|
}
|
631
631
|
|
632
632
|
GRPC_CLOSURE_RUN(cb, error);
|
@@ -646,7 +646,7 @@ static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf,
|
|
646
646
|
for (i = 0; i < buf->count; i++) {
|
647
647
|
char* data =
|
648
648
|
grpc_dump_slice(buf->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII);
|
649
|
-
gpr_log(
|
649
|
+
gpr_log(GPR_INFO, "WRITE %p (peer=%s): %s", tcp, tcp->peer_string, data);
|
650
650
|
gpr_free(data);
|
651
651
|
}
|
652
652
|
}
|
@@ -668,13 +668,13 @@ static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf,
|
|
668
668
|
TCP_REF(tcp, "write");
|
669
669
|
tcp->write_cb = cb;
|
670
670
|
if (grpc_tcp_trace.enabled()) {
|
671
|
-
gpr_log(
|
671
|
+
gpr_log(GPR_INFO, "write: delayed");
|
672
672
|
}
|
673
673
|
notify_on_write(tcp);
|
674
674
|
} else {
|
675
675
|
if (grpc_tcp_trace.enabled()) {
|
676
676
|
const char* str = grpc_error_string(error);
|
677
|
-
gpr_log(
|
677
|
+
gpr_log(GPR_INFO, "write: %s", str);
|
678
678
|
}
|
679
679
|
GRPC_CLOSURE_SCHED(cb, error);
|
680
680
|
}
|