From c0fa4da234d06eb33857569fd36b9d353d66fe3e Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 11 May 2017 16:27:08 -0700 Subject: [PATCH 001/142] Fix run_tests for non-C/C++ --- tools/run_tests/run_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 83a83948a57..a0782d68ba7 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1457,7 +1457,7 @@ def _build_and_run( suite_name=args.report_suite_name) return [] - if not args.travis and not _has_epollexclusive() and 'epollex' in _POLLING_STRATEGIES[platform_string()]: + if 'epollex' in _POLLING_STRATEGIES[platform_string()] and not args.travis and not _has_epollexclusive(): print('\n\nOmitting EPOLLEXCLUSIVE tests\n\n') _POLLING_STRATEGIES[platform_string()].remove('epollex') From 909a984a9248a7ccfc6aadb750dcf9e689b208bd Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 11 May 2017 16:32:58 -0700 Subject: [PATCH 002/142] A few tweaks for EPOLLEXCLUSIVE checks in gRPC --- tools/run_tests/run_tests.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index a0782d68ba7..0f88e18e413 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -1433,8 +1433,11 @@ class BuildAndRunError(object): def _has_epollexclusive(): + binary = 'bins/%s/check_epollexclusive' % args.config + if not os.path.exists(binary): + return False try: - subprocess.check_call('bins/%s/check_epollexclusive' % args.config) + subprocess.check_call(binary) return True except subprocess.CalledProcessError, e: return False From dc3998e7103a0f5e325787da3ab0a32ec402468e Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 12 May 2017 09:55:30 -0700 Subject: [PATCH 003/142] Converting code --- .../client_channel/channel_connectivity.c | 3 +- .../ext/filters/client_channel/subchannel.c | 3 +- .../transport/chttp2/server/chttp2_server.c | 4 +- .../chttp2/transport/chttp2_transport.c | 112 +++++++---------- .../transport/chttp2/transport/frame_ping.c | 14 +-- .../ext/transport/chttp2/transport/internal.h | 12 +- .../ext/transport/chttp2/transport/writing.c | 27 ++--- src/core/lib/channel/handshaker.c | 6 +- src/core/lib/channel/handshaker.h | 2 +- src/core/lib/http/httpcli.c | 13 +- src/core/lib/http/httpcli.h | 12 +- .../lib/http/httpcli_security_connector.c | 2 +- src/core/lib/iomgr/ev_poll_posix.c | 37 +++--- src/core/lib/iomgr/ev_posix.c | 6 +- src/core/lib/iomgr/ev_posix.h | 4 +- src/core/lib/iomgr/exec_ctx.c | 35 +++++- src/core/lib/iomgr/exec_ctx.h | 23 +++- src/core/lib/iomgr/iomgr.c | 8 +- src/core/lib/iomgr/pollset.h | 4 +- src/core/lib/iomgr/tcp_client.h | 2 +- src/core/lib/iomgr/tcp_client_posix.c | 10 +- src/core/lib/iomgr/timer.h | 8 +- src/core/lib/iomgr/timer_generic.c | 114 +++++------------- src/core/lib/iomgr/timer_manager.c | 17 ++- .../google_default_credentials.c | 7 +- .../security/credentials/jwt/jwt_verifier.c | 12 +- .../security/credentials/jwt/jwt_verifier.h | 2 +- .../credentials/oauth2/oauth2_credentials.c | 30 ++--- .../credentials/oauth2/oauth2_credentials.h | 6 +- src/core/lib/surface/alarm.c | 4 +- src/core/lib/surface/completion_queue.c | 45 ++++--- .../end2end/fixtures/http_proxy_fixture.c | 10 +- test/core/iomgr/endpoint_tests.c | 14 +-- test/core/security/oauth2_utils.c | 3 +- test/core/util/port_server_client.c | 14 +-- 35 files changed, 280 insertions(+), 345 deletions(-) diff --git a/src/core/ext/filters/client_channel/channel_connectivity.c b/src/core/ext/filters/client_channel/channel_connectivity.c index f83670db82e..4ccbd5c13d3 100644 --- a/src/core/ext/filters/client_channel/channel_connectivity.c +++ b/src/core/ext/filters/client_channel/channel_connectivity.c @@ -210,8 +210,7 @@ void grpc_channel_watch_connectivity_state( w->channel = channel; grpc_timer_init(&exec_ctx, &w->alarm, - gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC), - &w->on_timeout, gpr_now(GPR_CLOCK_MONOTONIC)); + grpc_timespec_to_millis(&exec_ctx, deadline), &w->on_timeout); if (client_channel_elem->filter == &grpc_client_channel_filter) { GRPC_CHANNEL_INTERNAL_REF(channel, "watch_channel_connectivity"); diff --git a/src/core/ext/filters/client_channel/subchannel.c b/src/core/ext/filters/client_channel/subchannel.c index 1af3393a62c..ddc24f7c713 100644 --- a/src/core/ext/filters/client_channel/subchannel.c +++ b/src/core/ext/filters/client_channel/subchannel.c @@ -131,7 +131,7 @@ struct grpc_subchannel { external_state_watcher root_external_state_watcher; /** next connect attempt time */ - gpr_timespec next_attempt; + grpc_millis next_attempt; /** backoff state */ gpr_backoff backoff_state; /** do we have an active alarm? */ @@ -486,7 +486,6 @@ static void maybe_start_connecting_locked(grpc_exec_ctx *exec_ctx, c->connecting = true; GRPC_SUBCHANNEL_WEAK_REF(c, "connecting"); - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); if (!c->backoff_begun) { c->backoff_begun = true; c->next_attempt = gpr_backoff_begin(&c->backoff_state, now); diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.c b/src/core/ext/transport/chttp2/server/chttp2_server.c index b9c62c376a1..a888dc02646 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.c +++ b/src/core/ext/transport/chttp2/server/chttp2_server.c @@ -146,8 +146,8 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, connection_state->handshake_mgr); // TODO(roth): We should really get this timeout value from channel // args instead of hard-coding it. - const gpr_timespec deadline = gpr_time_add( - gpr_now(GPR_CLOCK_MONOTONIC), gpr_time_from_seconds(120, GPR_TIMESPAN)); + const grpc_millis deadline = + grpc_exec_ctx_now(exec_ctx) + 120 * GPR_MS_PER_SEC; grpc_handshake_manager_do_handshake(exec_ctx, connection_state->handshake_mgr, tcp, state->args, deadline, acceptor, on_handshake_done, connection_state); diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index fb8ceaecb06..eaf880708f9 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -370,36 +370,27 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, t->ping_policy = (grpc_chttp2_repeated_ping_policy){ .max_pings_without_data = DEFAULT_MAX_PINGS_BETWEEN_DATA, - .min_time_between_pings = - gpr_time_from_millis(DEFAULT_MIN_TIME_BETWEEN_PINGS_MS, GPR_TIMESPAN), + .min_time_between_pings = DEFAULT_MIN_TIME_BETWEEN_PINGS_MS, .max_ping_strikes = DEFAULT_MAX_PING_STRIKES, - .min_ping_interval_without_data = gpr_time_from_millis( - DEFAULT_MIN_PING_INTERVAL_WITHOUT_DATA_MS, GPR_TIMESPAN), + .min_ping_interval_without_data = + DEFAULT_MIN_PING_INTERVAL_WITHOUT_DATA_MS, }; /* Keepalive setting */ if (t->is_client) { - t->keepalive_time = - g_default_client_keepalive_time_ms == INT_MAX - ? gpr_inf_future(GPR_TIMESPAN) - : gpr_time_from_millis(g_default_client_keepalive_time_ms, - GPR_TIMESPAN); - t->keepalive_timeout = - g_default_client_keepalive_timeout_ms == INT_MAX - ? gpr_inf_future(GPR_TIMESPAN) - : gpr_time_from_millis(g_default_client_keepalive_timeout_ms, - GPR_TIMESPAN); + t->keepalive_time = g_default_client_keepalive_time_ms == INT_MAX + ? GRPC_MILLIS_INF_FUTURE + : g_default_client_keepalive_time_ms; + t->keepalive_timeout = g_default_client_keepalive_timeout_ms == INT_MAX + ? GRPC_MILLIS_INF_FUTURE + : g_default_client_keepalive_timeout_ms; } else { - t->keepalive_time = - g_default_server_keepalive_time_ms == INT_MAX - ? gpr_inf_future(GPR_TIMESPAN) - : gpr_time_from_millis(g_default_server_keepalive_time_ms, - GPR_TIMESPAN); - t->keepalive_timeout = - g_default_server_keepalive_timeout_ms == INT_MAX - ? gpr_inf_future(GPR_TIMESPAN) - : gpr_time_from_millis(g_default_server_keepalive_timeout_ms, - GPR_TIMESPAN); + t->keepalive_time = g_default_server_keepalive_time_ms == INT_MAX + ? GRPC_MILLIS_INF_FUTURE + : g_default_server_keepalive_time_ms; + t->keepalive_timeout = g_default_server_keepalive_timeout_ms == INT_MAX + ? GRPC_MILLIS_INF_FUTURE + : g_default_server_keepalive_timeout_ms; } t->keepalive_permit_without_calls = g_default_keepalive_permit_without_calls; @@ -440,21 +431,18 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, (grpc_integer_options){DEFAULT_MAX_PING_STRIKES, 0, INT_MAX}); } else if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_HTTP2_MIN_TIME_BETWEEN_PINGS_MS)) { - t->ping_policy.min_time_between_pings = gpr_time_from_millis( - grpc_channel_arg_get_integer( - &channel_args->args[i], - (grpc_integer_options){DEFAULT_MIN_TIME_BETWEEN_PINGS_MS, 0, - INT_MAX}), - GPR_TIMESPAN); + t->ping_policy.min_time_between_pings = grpc_channel_arg_get_integer( + &channel_args->args[i], + (grpc_integer_options){DEFAULT_MIN_TIME_BETWEEN_PINGS_MS, 0, + INT_MAX}); } else if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_HTTP2_MIN_PING_INTERVAL_WITHOUT_DATA_MS)) { - t->ping_policy.min_ping_interval_without_data = gpr_time_from_millis( + t->ping_policy.min_ping_interval_without_data = grpc_channel_arg_get_integer( &channel_args->args[i], (grpc_integer_options){ - DEFAULT_MIN_PING_INTERVAL_WITHOUT_DATA_MS, 0, INT_MAX}), - GPR_TIMESPAN); + DEFAULT_MIN_PING_INTERVAL_WITHOUT_DATA_MS, 0, INT_MAX}); } else if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE)) { t->write_buffer_size = (uint32_t)grpc_channel_arg_get_integer( @@ -472,9 +460,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, ? g_default_client_keepalive_time_ms : g_default_server_keepalive_time_ms, 1, INT_MAX}); - t->keepalive_time = value == INT_MAX - ? gpr_inf_future(GPR_TIMESPAN) - : gpr_time_from_millis(value, GPR_TIMESPAN); + t->keepalive_time = value == INT_MAX ? GRPC_MILLIS_INF_FUTURE : value; } else if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_KEEPALIVE_TIMEOUT_MS)) { const int value = grpc_channel_arg_get_integer( @@ -483,9 +469,8 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, ? g_default_client_keepalive_timeout_ms : g_default_server_keepalive_timeout_ms, 0, INT_MAX}); - t->keepalive_timeout = value == INT_MAX - ? gpr_inf_future(GPR_TIMESPAN) - : gpr_time_from_millis(value, GPR_TIMESPAN); + t->keepalive_timeout = + value == INT_MAX ? GRPC_MILLIS_INF_FUTURE : value; } else if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS)) { t->keepalive_permit_without_calls = @@ -548,17 +533,16 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, t->ping_policy.max_pings_without_data; t->ping_state.is_delayed_ping_timer_set = false; - t->ping_recv_state.last_ping_recv_time = gpr_inf_past(GPR_CLOCK_MONOTONIC); + t->ping_recv_state.last_ping_recv_time = 0; t->ping_recv_state.ping_strikes = 0; /* Start keepalive pings */ - if (gpr_time_cmp(t->keepalive_time, gpr_inf_future(GPR_TIMESPAN)) != 0) { + if (t->keepalive_time != GRPC_MILLIS_INF_FUTURE) { t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING; GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping"); - grpc_timer_init( - exec_ctx, &t->keepalive_ping_timer, - gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), t->keepalive_time), - &t->init_keepalive_ping_locked, gpr_now(GPR_CLOCK_MONOTONIC)); + grpc_timer_init(exec_ctx, &t->keepalive_ping_timer, + grpc_exec_ctx_now(exec_ctx) + t->keepalive_time, + &t->init_keepalive_ping_locked); } else { /* Use GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED to indicate there are no inflight keeaplive timers */ @@ -1005,14 +989,12 @@ void grpc_chttp2_add_incoming_goaway(grpc_exec_ctx *exec_ctx, gpr_log(GPR_ERROR, "Received a GOAWAY with error code ENHANCE_YOUR_CALM and debug " "data equal to \"too_many_pings\""); - double current_keepalive_time_ms = - gpr_timespec_to_micros(t->keepalive_time) / 1000; + double current_keepalive_time_ms = (double)t->keepalive_time; t->keepalive_time = current_keepalive_time_ms > INT_MAX / KEEPALIVE_TIME_BACKOFF_MULTIPLIER - ? gpr_inf_future(GPR_TIMESPAN) - : gpr_time_from_millis((int64_t)(current_keepalive_time_ms * - KEEPALIVE_TIME_BACKOFF_MULTIPLIER), - GPR_TIMESPAN); + ? GRPC_MILLIS_INF_FUTURE + : (grpc_millis)(current_keepalive_time_ms * + KEEPALIVE_TIME_BACKOFF_MULTIPLIER); } /* lie: use transient failure from the transport to indicate goaway has been @@ -2391,18 +2373,16 @@ static void init_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg, &t->finish_keepalive_ping_locked); } else { GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping"); - grpc_timer_init( - exec_ctx, &t->keepalive_ping_timer, - gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), t->keepalive_time), - &t->init_keepalive_ping_locked, gpr_now(GPR_CLOCK_MONOTONIC)); + grpc_timer_init(exec_ctx, &t->keepalive_ping_timer, + grpc_exec_ctx_now(exec_ctx) + t->keepalive_time, + &t->init_keepalive_ping_locked); } } else if (error == GRPC_ERROR_CANCELLED) { /* The keepalive ping timer may be cancelled by bdp */ GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping"); - grpc_timer_init( - exec_ctx, &t->keepalive_ping_timer, - gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), t->keepalive_time), - &t->init_keepalive_ping_locked, gpr_now(GPR_CLOCK_MONOTONIC)); + grpc_timer_init(exec_ctx, &t->keepalive_ping_timer, + grpc_exec_ctx_now(exec_ctx) + t->keepalive_time, + &t->init_keepalive_ping_locked); } GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "init keepalive ping"); } @@ -2411,10 +2391,9 @@ static void start_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { grpc_chttp2_transport *t = arg; GRPC_CHTTP2_REF_TRANSPORT(t, "keepalive watchdog"); - grpc_timer_init( - exec_ctx, &t->keepalive_watchdog_timer, - gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), t->keepalive_timeout), - &t->keepalive_watchdog_fired_locked, gpr_now(GPR_CLOCK_MONOTONIC)); + grpc_timer_init(exec_ctx, &t->keepalive_watchdog_timer, + grpc_exec_ctx_now(exec_ctx) + t->keepalive_time, + &t->keepalive_watchdog_fired_locked); } static void finish_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg, @@ -2425,10 +2404,9 @@ static void finish_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg, t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING; grpc_timer_cancel(exec_ctx, &t->keepalive_watchdog_timer); GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping"); - grpc_timer_init( - exec_ctx, &t->keepalive_ping_timer, - gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), t->keepalive_time), - &t->init_keepalive_ping_locked, gpr_now(GPR_CLOCK_MONOTONIC)); + grpc_timer_init(exec_ctx, &t->keepalive_ping_timer, + grpc_exec_ctx_now(exec_ctx) + t->keepalive_time, + &t->init_keepalive_ping_locked); } } GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keepalive ping end"); diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.c b/src/core/ext/transport/chttp2/transport/frame_ping.c index f09ca607397..41337749865 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.c +++ b/src/core/ext/transport/chttp2/transport/frame_ping.c @@ -104,10 +104,9 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_ack_ping(exec_ctx, t, p->opaque_8bytes); } else { if (!t->is_client) { - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - gpr_timespec next_allowed_ping = - gpr_time_add(t->ping_recv_state.last_ping_recv_time, - t->ping_policy.min_ping_interval_without_data); + grpc_millis next_allowed_ping = + t->ping_recv_state.last_ping_recv_time + + t->ping_policy.min_ping_interval_without_data; if (t->keepalive_permit_without_calls == 0 && grpc_chttp2_stream_map_size(&t->stream_map) == 0) { @@ -115,15 +114,14 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, no less than two hours. When there is no outstanding streams, we restrict the number of PINGS equivalent to TCP Keep-Alive. */ next_allowed_ping = - gpr_time_add(t->ping_recv_state.last_ping_recv_time, - gpr_time_from_seconds(7200, GPR_TIMESPAN)); + t->ping_recv_state.last_ping_recv_time + 7200 * GPR_MS_PER_SEC; } - if (gpr_time_cmp(next_allowed_ping, now) > 0) { + if (next_allowed_ping > grpc_exec_ctx_now(exec_ctx)) { grpc_chttp2_add_ping_strike(exec_ctx, t); } - t->ping_recv_state.last_ping_recv_time = now; + t->ping_recv_state.last_ping_recv_time = grpc_exec_ctx_now(exec_ctx); } if (!g_disable_ping_ack) { if (t->ping_ack_count == t->ping_ack_capacity) { diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 8d66e396ee8..9eed73cd717 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -95,21 +95,21 @@ typedef struct { } grpc_chttp2_ping_queue; typedef struct { - gpr_timespec min_time_between_pings; + grpc_millis min_time_between_pings; int max_pings_without_data; int max_ping_strikes; - gpr_timespec min_ping_interval_without_data; + grpc_millis min_ping_interval_without_data; } grpc_chttp2_repeated_ping_policy; typedef struct { - gpr_timespec last_ping_sent_time; + grpc_millis last_ping_sent_time; int pings_before_data_required; grpc_timer delayed_ping_timer; bool is_delayed_ping_timer_set; } grpc_chttp2_repeated_ping_state; typedef struct { - gpr_timespec last_ping_recv_time; + grpc_millis last_ping_recv_time; int ping_strikes; } grpc_chttp2_server_ping_recv_state; @@ -414,9 +414,9 @@ struct grpc_chttp2_transport { /** watchdog to kill the transport when waiting for the keepalive ping */ grpc_timer keepalive_watchdog_timer; /** time duration in between pings */ - gpr_timespec keepalive_time; + grpc_millis keepalive_time; /** grace period for a ping to complete before watchdog kicks in */ - gpr_timespec keepalive_timeout; + grpc_millis keepalive_timeout; /** if keepalive pings are allowed when there's no outstanding streams */ bool keepalive_permit_without_calls; /** keep-alive state machine state */ diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index 5be1092946a..1ab94ca54f5 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -91,12 +91,12 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, } return; } - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - gpr_timespec elapsed = gpr_time_sub(now, t->ping_state.last_ping_sent_time); + grpc_millis elapsed = + grpc_exec_ctx_now(exec_ctx) - t->ping_state.last_ping_sent_time; /*gpr_log(GPR_DEBUG, "elapsed:%d.%09d min:%d.%09d", (int)elapsed.tv_sec, elapsed.tv_nsec, (int)t->ping_policy.min_time_between_pings.tv_sec, (int)t->ping_policy.min_time_between_pings.tv_nsec);*/ - if (gpr_time_cmp(elapsed, t->ping_policy.min_time_between_pings) < 0) { + if (elapsed < t->ping_policy.min_time_between_pings) { /* not enough elapsed time between successive pings */ if (GRPC_TRACER_ON(grpc_http_trace) || GRPC_TRACER_ON(grpc_bdp_estimator_trace)) { @@ -107,10 +107,9 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, if (!t->ping_state.is_delayed_ping_timer_set) { t->ping_state.is_delayed_ping_timer_set = true; grpc_timer_init(exec_ctx, &t->ping_state.delayed_ping_timer, - gpr_time_add(t->ping_state.last_ping_sent_time, - t->ping_policy.min_time_between_pings), - &t->retry_initiate_ping_locked, - gpr_now(GPR_CLOCK_MONOTONIC)); + t->ping_state.last_ping_sent_time + + t->ping_policy.min_time_between_pings, + &t->retry_initiate_ping_locked); } return; } @@ -131,7 +130,7 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, &pq->lists[GRPC_CHTTP2_PCL_INFLIGHT]); grpc_slice_buffer_add(&t->outbuf, grpc_chttp2_ping_create(false, pq->inflight_id)); - t->ping_state.last_ping_sent_time = now; + t->ping_state.last_ping_sent_time = grpc_exec_ctx_now(exec_ctx); t->ping_state.pings_before_data_required -= (t->ping_state.pings_before_data_required != 0); } @@ -255,8 +254,7 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( t->ping_state.pings_before_data_required = t->ping_policy.max_pings_without_data; if (!t->is_client) { - t->ping_recv_state.last_ping_recv_time = - gpr_inf_past(GPR_CLOCK_MONOTONIC); + t->ping_recv_state.last_ping_recv_time = 0; t->ping_recv_state.ping_strikes = 0; } } @@ -269,8 +267,7 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( t->ping_state.pings_before_data_required = t->ping_policy.max_pings_without_data; if (!t->is_client) { - t->ping_recv_state.last_ping_recv_time = - gpr_inf_past(GPR_CLOCK_MONOTONIC); + t->ping_recv_state.last_ping_recv_time = 0; t->ping_recv_state.ping_strikes = 0; } GRPC_CHTTP2_FLOW_DEBIT_STREAM("write", t, s, announce_window, announce); @@ -306,8 +303,7 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( t->ping_state.pings_before_data_required = t->ping_policy.max_pings_without_data; if (!t->is_client) { - t->ping_recv_state.last_ping_recv_time = - gpr_inf_past(GPR_CLOCK_MONOTONIC); + t->ping_recv_state.last_ping_recv_time = 0; t->ping_recv_state.ping_strikes = 0; } if (is_last_frame) { @@ -396,8 +392,7 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( t->ping_state.pings_before_data_required = t->ping_policy.max_pings_without_data; if (!t->is_client) { - t->ping_recv_state.last_ping_recv_time = - gpr_inf_past(GPR_CLOCK_MONOTONIC); + t->ping_recv_state.last_ping_recv_time = 0; t->ping_recv_state.ping_strikes = 0; } } diff --git a/src/core/lib/channel/handshaker.c b/src/core/lib/channel/handshaker.c index 5861fa6f54c..ed05b26458a 100644 --- a/src/core/lib/channel/handshaker.c +++ b/src/core/lib/channel/handshaker.c @@ -246,7 +246,7 @@ static void on_timeout(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { void grpc_handshake_manager_do_handshake( grpc_exec_ctx* exec_ctx, grpc_handshake_manager* mgr, grpc_endpoint* endpoint, const grpc_channel_args* channel_args, - gpr_timespec deadline, grpc_tcp_server_acceptor* acceptor, + grpc_millis deadline, grpc_tcp_server_acceptor* acceptor, grpc_iomgr_cb_func on_handshake_done, void* user_data) { gpr_mu_lock(&mgr->mu); GPR_ASSERT(mgr->index == 0); @@ -268,9 +268,7 @@ void grpc_handshake_manager_do_handshake( gpr_ref(&mgr->refs); grpc_closure_init(&mgr->on_timeout, on_timeout, mgr, grpc_schedule_on_exec_ctx); - grpc_timer_init(exec_ctx, &mgr->deadline_timer, - gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC), - &mgr->on_timeout, gpr_now(GPR_CLOCK_MONOTONIC)); + grpc_timer_init(exec_ctx, &mgr->deadline_timer, deadline, &mgr->on_timeout); // Start first handshaker, which also owns a ref. gpr_ref(&mgr->refs); bool done = call_next_handshaker_locked(exec_ctx, mgr, GRPC_ERROR_NONE); diff --git a/src/core/lib/channel/handshaker.h b/src/core/lib/channel/handshaker.h index 5f97c3fc736..4abbbd0e7ba 100644 --- a/src/core/lib/channel/handshaker.h +++ b/src/core/lib/channel/handshaker.h @@ -160,7 +160,7 @@ void grpc_handshake_manager_shutdown(grpc_exec_ctx* exec_ctx, void grpc_handshake_manager_do_handshake( grpc_exec_ctx* exec_ctx, grpc_handshake_manager* mgr, grpc_endpoint* endpoint, const grpc_channel_args* channel_args, - gpr_timespec deadline, grpc_tcp_server_acceptor* acceptor, + grpc_millis deadline, grpc_tcp_server_acceptor* acceptor, grpc_iomgr_cb_func on_handshake_done, void* user_data); /// Add \a mgr to the server side list of all pending handshake managers, the diff --git a/src/core/lib/http/httpcli.c b/src/core/lib/http/httpcli.c index 0ac2c2ad52a..f1a3abd1e95 100644 --- a/src/core/lib/http/httpcli.c +++ b/src/core/lib/http/httpcli.c @@ -58,7 +58,7 @@ typedef struct { grpc_endpoint *ep; char *host; char *ssl_host_override; - gpr_timespec deadline; + grpc_millis deadline; int have_read_byte; const grpc_httpcli_handshaker *handshaker; grpc_closure *on_done; @@ -79,7 +79,7 @@ static grpc_httpcli_post_override g_post_override = NULL; static void plaintext_handshake(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *endpoint, const char *host, - gpr_timespec deadline, + grpc_millis deadline, void (*on_done)(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *endpoint)) { @@ -256,7 +256,7 @@ static void internal_request_begin(grpc_exec_ctx *exec_ctx, grpc_polling_entity *pollent, grpc_resource_quota *resource_quota, const grpc_httpcli_request *request, - gpr_timespec deadline, grpc_closure *on_done, + grpc_millis deadline, grpc_closure *on_done, grpc_httpcli_response *response, const char *name, grpc_slice request_text) { internal_request *req = gpr_malloc(sizeof(internal_request)); @@ -293,9 +293,8 @@ static void internal_request_begin(grpc_exec_ctx *exec_ctx, void grpc_httpcli_get(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context, grpc_polling_entity *pollent, grpc_resource_quota *resource_quota, - const grpc_httpcli_request *request, - gpr_timespec deadline, grpc_closure *on_done, - grpc_httpcli_response *response) { + const grpc_httpcli_request *request, grpc_millis deadline, + grpc_closure *on_done, grpc_httpcli_response *response) { char *name; if (g_get_override && g_get_override(exec_ctx, request, deadline, on_done, response)) { @@ -313,7 +312,7 @@ void grpc_httpcli_post(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context, grpc_resource_quota *resource_quota, const grpc_httpcli_request *request, const char *body_bytes, size_t body_size, - gpr_timespec deadline, grpc_closure *on_done, + grpc_millis deadline, grpc_closure *on_done, grpc_httpcli_response *response) { char *name; if (g_post_override && diff --git a/src/core/lib/http/httpcli.h b/src/core/lib/http/httpcli.h index 8ae03ee78f4..ad994fd811c 100644 --- a/src/core/lib/http/httpcli.h +++ b/src/core/lib/http/httpcli.h @@ -57,7 +57,7 @@ typedef struct grpc_httpcli_context { typedef struct { const char *default_port; void (*handshake)(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *endpoint, - const char *host, gpr_timespec deadline, + const char *host, grpc_millis deadline, void (*on_done)(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *endpoint)); } grpc_httpcli_handshaker; @@ -98,8 +98,8 @@ void grpc_httpcli_context_destroy(grpc_exec_ctx *exec_ctx, void grpc_httpcli_get(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context, grpc_polling_entity *pollent, grpc_resource_quota *resource_quota, - const grpc_httpcli_request *request, - gpr_timespec deadline, grpc_closure *on_complete, + const grpc_httpcli_request *request, grpc_millis deadline, + grpc_closure *on_complete, grpc_httpcli_response *response); /* Asynchronously perform a HTTP POST. @@ -121,18 +121,18 @@ void grpc_httpcli_post(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context, grpc_resource_quota *resource_quota, const grpc_httpcli_request *request, const char *body_bytes, size_t body_size, - gpr_timespec deadline, grpc_closure *on_complete, + grpc_millis deadline, grpc_closure *on_complete, grpc_httpcli_response *response); /* override functions return 1 if they handled the request, 0 otherwise */ typedef int (*grpc_httpcli_get_override)(grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - gpr_timespec deadline, + grpc_millis deadline, grpc_closure *on_complete, grpc_httpcli_response *response); typedef int (*grpc_httpcli_post_override)( grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - const char *body_bytes, size_t body_size, gpr_timespec deadline, + const char *body_bytes, size_t body_size, grpc_millis deadline, grpc_closure *on_complete, grpc_httpcli_response *response); void grpc_httpcli_set_override(grpc_httpcli_get_override get, diff --git a/src/core/lib/http/httpcli_security_connector.c b/src/core/lib/http/httpcli_security_connector.c index 76946434f06..fd25a8d3e07 100644 --- a/src/core/lib/http/httpcli_security_connector.c +++ b/src/core/lib/http/httpcli_security_connector.c @@ -167,7 +167,7 @@ static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg, static void ssl_handshake(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, const char *host, - gpr_timespec deadline, + grpc_millis deadline, void (*on_done)(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *endpoint)) { grpc_channel_security_connector *sc = NULL; diff --git a/src/core/lib/iomgr/ev_poll_posix.c b/src/core/lib/iomgr/ev_poll_posix.c index 3a7648ac329..19a80ce2355 100644 --- a/src/core/lib/iomgr/ev_poll_posix.c +++ b/src/core/lib/iomgr/ev_poll_posix.c @@ -39,6 +39,7 @@ #include #include +#include #include #include #include @@ -215,8 +216,8 @@ static void pollset_set_add_fd(grpc_exec_ctx *exec_ctx, - longer than a millisecond polls are rounded up to the next nearest millisecond to avoid spinning - infinite timeouts are converted to -1 */ -static int poll_deadline_to_millis_timeout(gpr_timespec deadline, - gpr_timespec now); +static int poll_deadline_to_millis_timeout(grpc_exec_ctx *exec_ctx, + grpc_millis deadline); /* Allow kick to wakeup the currently polling worker */ #define GRPC_POLLSET_CAN_KICK_SELF 1 @@ -864,7 +865,7 @@ static void work_combine_error(grpc_error **composite, grpc_error *error) { static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, grpc_pollset_worker **worker_hdl, - gpr_timespec now, gpr_timespec deadline) { + grpc_millis deadline) { grpc_pollset_worker worker; if (worker_hdl) *worker_hdl = &worker; grpc_error *error = GRPC_ERROR_NONE; @@ -932,7 +933,7 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, grpc_fd_watcher *watchers; struct pollfd *pfds; - timeout = poll_deadline_to_millis_timeout(deadline, now); + timeout = poll_deadline_to_millis_timeout(exec_ctx, deadline); if (pollset->fd_count + 2 <= inline_elements) { pfds = pollfd_space; @@ -1042,13 +1043,10 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, if (queued_work || worker.kicked_specifically) { /* If there's queued work on the list, then set the deadline to be immediate so we get back out of the polling loop quickly */ - deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC); + deadline = 0; } keep_polling = 1; } - if (keep_polling) { - now = gpr_now(now.clock_type); - } } gpr_tls_set(&g_current_thread_poller, 0); if (added_worker) { @@ -1100,21 +1098,14 @@ static void pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, } } -static int poll_deadline_to_millis_timeout(gpr_timespec deadline, - gpr_timespec now) { - gpr_timespec timeout; - static const int64_t max_spin_polling_us = 10; - if (gpr_time_cmp(deadline, gpr_inf_future(deadline.clock_type)) == 0) { - return -1; - } - if (gpr_time_cmp(deadline, gpr_time_add(now, gpr_time_from_micros( - max_spin_polling_us, - GPR_TIMESPAN))) <= 0) { - return 0; - } - timeout = gpr_time_sub(deadline, now); - return gpr_time_to_millis(gpr_time_add( - timeout, gpr_time_from_nanos(GPR_NS_PER_MS - 1, GPR_TIMESPAN))); +static int poll_deadline_to_millis_timeout(grpc_exec_ctx *exec_ctx, + grpc_millis deadline) { + if (deadline == GRPC_MILLIS_INF_FUTURE) return -1; + if (deadline == 0) return 0; + grpc_millis n = deadline - grpc_exec_ctx_now(exec_ctx); + if (n < 0) return 0; + if (n > INT_MAX) return -1; + return (int)n; } /******************************************************************************* diff --git a/src/core/lib/iomgr/ev_posix.c b/src/core/lib/iomgr/ev_posix.c index c4d2f23e291..e79cec640c2 100644 --- a/src/core/lib/iomgr/ev_posix.c +++ b/src/core/lib/iomgr/ev_posix.c @@ -218,9 +218,9 @@ void grpc_pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) { } grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, - grpc_pollset_worker **worker, gpr_timespec now, - gpr_timespec deadline) { - return g_event_engine->pollset_work(exec_ctx, pollset, worker, now, deadline); + grpc_pollset_worker **worker, + grpc_millis deadline) { + return g_event_engine->pollset_work(exec_ctx, pollset, worker, deadline); } grpc_error *grpc_pollset_kick(grpc_pollset *pollset, diff --git a/src/core/lib/iomgr/ev_posix.h b/src/core/lib/iomgr/ev_posix.h index 80619aab5fc..e505e704123 100644 --- a/src/core/lib/iomgr/ev_posix.h +++ b/src/core/lib/iomgr/ev_posix.h @@ -69,8 +69,8 @@ typedef struct grpc_event_engine_vtable { grpc_closure *closure); void (*pollset_destroy)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset); grpc_error *(*pollset_work)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, - grpc_pollset_worker **worker, gpr_timespec now, - gpr_timespec deadline); + grpc_pollset_worker **worker, + grpc_millis deadline); grpc_error *(*pollset_kick)(grpc_pollset *pollset, grpc_pollset_worker *specific_worker); void (*pollset_add_fd)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, diff --git a/src/core/lib/iomgr/exec_ctx.c b/src/core/lib/iomgr/exec_ctx.c index 318bb2b7133..3423379e8dc 100644 --- a/src/core/lib/iomgr/exec_ctx.c +++ b/src/core/lib/iomgr/exec_ctx.c @@ -113,9 +113,42 @@ static void exec_ctx_sched(grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_closure_list_append(&exec_ctx->closure_list, closure, error); } -void grpc_exec_ctx_global_init(void) {} +static gpr_timespec g_start_time; + +void grpc_exec_ctx_global_init(void) { + g_start_time = gpr_now(GPR_CLOCK_MONOTONIC); +} + void grpc_exec_ctx_global_shutdown(void) {} +static gpr_atm timespec_to_atm_round_down(gpr_timespec ts) { + ts = gpr_time_sub(ts, g_start_time); + double x = + GPR_MS_PER_SEC * (double)ts.tv_sec + (double)ts.tv_nsec / GPR_NS_PER_MS; + if (x < 0) return 0; + if (x > GPR_ATM_MAX) return GPR_ATM_MAX; + return (gpr_atm)x; +} + +grpc_millis grpc_exec_ctx_now(grpc_exec_ctx *exec_ctx) { + if (!exec_ctx->now_is_valid) { + exec_ctx->now = timespec_to_atm_round_down(gpr_now(GPR_CLOCK_MONOTONIC)); + exec_ctx->now_is_valid = true; + } + return exec_ctx->now; +} + +void grpc_exec_ctx_invalidate_now(grpc_exec_ctx *exec_ctx) { + exec_ctx->now_is_valid = false; +} + +gpr_timespec grpc_millis_to_timespec(grpc_exec_ctx *exec_ctx, + grpc_millis millis, + gpr_clock_type clock_type) { + return gpr_time_add(gpr_convert_clock_type(g_start_time, clock_type), + gpr_time_from_millis(millis, GPR_TIMESPAN)); +} + static const grpc_closure_scheduler_vtable exec_ctx_scheduler_vtable = { exec_ctx_run, exec_ctx_sched, "exec_ctx"}; static grpc_closure_scheduler exec_ctx_scheduler = {&exec_ctx_scheduler_vtable}; diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h index 759a3ae2d56..26da4d0a731 100644 --- a/src/core/lib/iomgr/exec_ctx.h +++ b/src/core/lib/iomgr/exec_ctx.h @@ -34,9 +34,13 @@ #ifndef GRPC_CORE_LIB_IOMGR_EXEC_CTX_H #define GRPC_CORE_LIB_IOMGR_EXEC_CTX_H +#include + #include "src/core/lib/iomgr/closure.h" -/* #define GRPC_EXECUTION_CONTEXT_SANITIZER 1 */ +typedef gpr_atm grpc_millis; + +#define GRPC_MILLIS_INF_FUTURE GPR_ATM_MAX /** A workqueue represents a list of work to be executed asynchronously. Forward declared here to avoid a circular dependency with workqueue.h. */ @@ -79,12 +83,18 @@ struct grpc_exec_ctx { uintptr_t flags; void *check_ready_to_finish_arg; bool (*check_ready_to_finish)(grpc_exec_ctx *exec_ctx, void *arg); + + bool now_is_valid; + grpc_millis now; }; /* initializer for grpc_exec_ctx: prefer to use GRPC_EXEC_CTX_INIT whenever possible */ -#define GRPC_EXEC_CTX_INITIALIZER(flags, finish_check, finish_check_arg) \ - { GRPC_CLOSURE_LIST_INIT, NULL, NULL, flags, finish_check_arg, finish_check } +#define GRPC_EXEC_CTX_INITIALIZER(flags, finish_check, finish_check_arg) \ + { \ + GRPC_CLOSURE_LIST_INIT, NULL, NULL, flags, finish_check_arg, finish_check, \ + false, 0 \ + } /* initialize an execution context at the top level of an API call into grpc (this is safe to use elsewhere, though possibly not as efficient) */ @@ -116,4 +126,11 @@ void grpc_exec_ctx_global_init(void); void grpc_exec_ctx_global_init(void); void grpc_exec_ctx_global_shutdown(void); +grpc_millis grpc_exec_ctx_now(grpc_exec_ctx *exec_ctx); +void grpc_exec_ctx_invalidate_now(grpc_exec_ctx *exec_ctx); +gpr_timespec grpc_millis_to_timespec(grpc_exec_ctx *exec_ctx, + grpc_millis millis, gpr_clock_type clock); +grpc_millis grpc_timespec_to_millis(grpc_exec_ctx *exec_ctx, + gpr_timespec timespec); + #endif /* GRPC_CORE_LIB_IOMGR_EXEC_CTX_H */ diff --git a/src/core/lib/iomgr/iomgr.c b/src/core/lib/iomgr/iomgr.c index 1fd41c2f880..bdee4b3e523 100644 --- a/src/core/lib/iomgr/iomgr.c +++ b/src/core/lib/iomgr/iomgr.c @@ -61,7 +61,9 @@ void grpc_iomgr_init(void) { gpr_mu_init(&g_mu); gpr_cv_init(&g_rcv); grpc_exec_ctx_global_init(); - grpc_timer_list_init(gpr_now(GPR_CLOCK_MONOTONIC)); + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_timer_list_init(&exec_ctx); + grpc_exec_ctx_finish(&exec_ctx); g_root_object.next = g_root_object.prev = &g_root_object; g_root_object.name = "root"; grpc_network_status_init(); @@ -107,7 +109,9 @@ void grpc_iomgr_shutdown(grpc_exec_ctx *exec_ctx) { } last_warning_time = gpr_now(GPR_CLOCK_REALTIME); } - if (grpc_timer_check(exec_ctx, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL)) { + exec_ctx->now_is_valid = true; + exec_ctx->now = GRPC_MILLIS_INF_FUTURE; + if (grpc_timer_check(exec_ctx, NULL)) { gpr_mu_unlock(&g_mu); grpc_exec_ctx_flush(exec_ctx); grpc_iomgr_platform_flush(); diff --git a/src/core/lib/iomgr/pollset.h b/src/core/lib/iomgr/pollset.h index 69e20098d70..e771ecf7a55 100644 --- a/src/core/lib/iomgr/pollset.h +++ b/src/core/lib/iomgr/pollset.h @@ -82,8 +82,8 @@ void grpc_pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset); pollset lock */ grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, - grpc_pollset_worker **worker, gpr_timespec now, - gpr_timespec deadline) GRPC_MUST_USE_RESULT; + grpc_pollset_worker **worker, + grpc_millis deadline) GRPC_MUST_USE_RESULT; /* Break one polling thread out of polling work for this pollset. If specific_worker is non-NULL, then kick that worker. */ diff --git a/src/core/lib/iomgr/tcp_client.h b/src/core/lib/iomgr/tcp_client.h index bc367bdfa5d..6f05967fac6 100644 --- a/src/core/lib/iomgr/tcp_client.h +++ b/src/core/lib/iomgr/tcp_client.h @@ -50,6 +50,6 @@ void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *on_connect, grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args, const grpc_resolved_address *addr, - gpr_timespec deadline); + grpc_millis deadline); #endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_H */ diff --git a/src/core/lib/iomgr/tcp_client_posix.c b/src/core/lib/iomgr/tcp_client_posix.c index 5c7da999e0e..9ce7f8904de 100644 --- a/src/core/lib/iomgr/tcp_client_posix.c +++ b/src/core/lib/iomgr/tcp_client_posix.c @@ -257,7 +257,7 @@ static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx, grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args, const grpc_resolved_address *addr, - gpr_timespec deadline) { + grpc_millis deadline) { int fd; grpc_dualstack_mode dsmode; int err; @@ -337,9 +337,7 @@ static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx, gpr_mu_lock(&ac->mu); grpc_closure_init(&ac->on_alarm, tc_on_alarm, ac, grpc_schedule_on_exec_ctx); - grpc_timer_init(exec_ctx, &ac->alarm, - gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC), - &ac->on_alarm, gpr_now(GPR_CLOCK_MONOTONIC)); + grpc_timer_init(exec_ctx, &ac->alarm, deadline, &ac->on_alarm); grpc_fd_notify_on_write(exec_ctx, ac->fd, &ac->write_closure); gpr_mu_unlock(&ac->mu); @@ -353,14 +351,14 @@ void (*grpc_tcp_client_connect_impl)( grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep, grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args, const grpc_resolved_address *addr, - gpr_timespec deadline) = tcp_client_connect_impl; + grpc_millis deadline) = tcp_client_connect_impl; void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep, grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args, const grpc_resolved_address *addr, - gpr_timespec deadline) { + grpc_millis deadline) { grpc_tcp_client_connect_impl(exec_ctx, closure, ep, interested_parties, channel_args, addr, deadline); } diff --git a/src/core/lib/iomgr/timer.h b/src/core/lib/iomgr/timer.h index e0338f93c7d..8ce785629d6 100644 --- a/src/core/lib/iomgr/timer.h +++ b/src/core/lib/iomgr/timer.h @@ -56,8 +56,7 @@ typedef struct grpc_timer grpc_timer; application callback is also responsible for maintaining information about when to free up any user-level state. */ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer, - gpr_timespec deadline, grpc_closure *closure, - gpr_timespec now); + grpc_millis deadline, grpc_closure *closure); /* Note that there is no timer destroy function. This is because the timer is a one-time occurrence with a guarantee that the callback will @@ -96,9 +95,8 @@ void grpc_timer_cancel(grpc_exec_ctx *exec_ctx, grpc_timer *timer); *next is never guaranteed to be updated on any given execution; however, with high probability at least one thread in the system will see an update at any time slice. */ -bool grpc_timer_check(grpc_exec_ctx *exec_ctx, gpr_timespec now, - gpr_timespec *next); -void grpc_timer_list_init(gpr_timespec now); +bool grpc_timer_check(grpc_exec_ctx *exec_ctx, grpc_millis *next); +void grpc_timer_list_init(grpc_exec_ctx *exec_ctx); void grpc_timer_list_shutdown(grpc_exec_ctx *exec_ctx); /* Consume a kick issued by grpc_kick_poller */ diff --git a/src/core/lib/iomgr/timer_generic.c b/src/core/lib/iomgr/timer_generic.c index b28340b71c7..bca05bd07df 100644 --- a/src/core/lib/iomgr/timer_generic.c +++ b/src/core/lib/iomgr/timer_generic.c @@ -86,11 +86,9 @@ struct shared_mutables { static struct shared_mutables g_shared_mutables = { .checker_mu = GPR_SPINLOCK_STATIC_INITIALIZER, .initialized = false, }; -static gpr_clock_type g_clock_type; static shard_type g_shards[NUM_SHARDS]; /* Protected by g_shared_mutables.mu */ static shard_type *g_shard_queue[NUM_SHARDS]; -static gpr_timespec g_start_time; GPR_TLS_DECL(g_last_seen_min_timer); @@ -104,51 +102,18 @@ static gpr_atm saturating_add(gpr_atm a, gpr_atm b) { static int run_some_expired_timers(grpc_exec_ctx *exec_ctx, gpr_atm now, gpr_atm *next, grpc_error *error); -static gpr_timespec dbl_to_ts(double d) { - gpr_timespec ts; - ts.tv_sec = (int64_t)d; - ts.tv_nsec = (int32_t)(1e9 * (d - (double)ts.tv_sec)); - ts.clock_type = GPR_TIMESPAN; - return ts; -} - -static gpr_atm timespec_to_atm_round_up(gpr_timespec ts) { - ts = gpr_time_sub(ts, g_start_time); - double x = GPR_MS_PER_SEC * (double)ts.tv_sec + - (double)ts.tv_nsec / GPR_NS_PER_MS + - (double)(GPR_NS_PER_SEC - 1) / (double)GPR_NS_PER_SEC; - if (x < 0) return 0; - if (x > GPR_ATM_MAX) return GPR_ATM_MAX; - return (gpr_atm)x; -} - -static gpr_atm timespec_to_atm_round_down(gpr_timespec ts) { - ts = gpr_time_sub(ts, g_start_time); - double x = - GPR_MS_PER_SEC * (double)ts.tv_sec + (double)ts.tv_nsec / GPR_NS_PER_MS; - if (x < 0) return 0; - if (x > GPR_ATM_MAX) return GPR_ATM_MAX; - return (gpr_atm)x; -} - -static gpr_timespec atm_to_timespec(gpr_atm x) { - return gpr_time_add(g_start_time, dbl_to_ts((double)x / 1000.0)); -} - static gpr_atm compute_min_deadline(shard_type *shard) { return grpc_timer_heap_is_empty(&shard->heap) ? saturating_add(shard->queue_deadline_cap, 1) : grpc_timer_heap_top(&shard->heap)->deadline; } -void grpc_timer_list_init(gpr_timespec now) { +void grpc_timer_list_init(grpc_exec_ctx *exec_ctx) { uint32_t i; g_shared_mutables.initialized = true; gpr_mu_init(&g_shared_mutables.mu); - g_clock_type = now.clock_type; - g_start_time = now; - g_shared_mutables.min_timer = timespec_to_atm_round_down(now); + g_shared_mutables.min_timer = grpc_exec_ctx_now(exec_ctx); gpr_tls_init(&g_last_seen_min_timer); gpr_tls_set(&g_last_seen_min_timer, 0); grpc_register_tracer("timer", &grpc_timer_trace); @@ -183,10 +148,6 @@ void grpc_timer_list_shutdown(grpc_exec_ctx *exec_ctx) { g_shared_mutables.initialized = false; } -static double ts_to_dbl(gpr_timespec ts) { - return (double)ts.tv_sec + 1e-9 * ts.tv_nsec; -} - /* returns true if the first element in the list */ static void list_join(grpc_timer *head, grpc_timer *timer) { timer->next = head; @@ -225,20 +186,15 @@ static void note_deadline_change(shard_type *shard) { } void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer, - gpr_timespec deadline, grpc_closure *closure, - gpr_timespec now) { + grpc_millis deadline, grpc_closure *closure) { int is_first_timer = 0; shard_type *shard = &g_shards[GPR_HASH_POINTER(timer, NUM_SHARDS)]; - GPR_ASSERT(deadline.clock_type == g_clock_type); - GPR_ASSERT(now.clock_type == g_clock_type); timer->closure = closure; - gpr_atm deadline_atm = timer->deadline = timespec_to_atm_round_up(deadline); if (GRPC_TRACER_ON(grpc_timer_trace)) { - gpr_log(GPR_DEBUG, "TIMER %p: SET %" PRId64 ".%09d [%" PRIdPTR - "] now %" PRId64 ".%09d [%" PRIdPTR "] call %p[%p]", - timer, deadline.tv_sec, deadline.tv_nsec, deadline_atm, now.tv_sec, - now.tv_nsec, timespec_to_atm_round_down(now), closure, closure->cb); + gpr_log(GPR_DEBUG, + "TIMER %p: SET %" PRIdPTR " now %" PRIdPTR " call %p[%p]", timer, + deadline, grpc_exec_ctx_now(exec_ctx), closure, closure->cb); } if (!g_shared_mutables.initialized) { @@ -251,7 +207,8 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer, gpr_mu_lock(&shard->mu); timer->pending = true; - if (gpr_time_cmp(deadline, now) <= 0) { + grpc_millis now = grpc_exec_ctx_now(exec_ctx); + if (deadline <= now) { timer->pending = false; grpc_closure_sched(exec_ctx, timer->closure, GRPC_ERROR_NONE); gpr_mu_unlock(&shard->mu); @@ -259,9 +216,8 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer, return; } - grpc_time_averaged_stats_add_sample(&shard->stats, - ts_to_dbl(gpr_time_sub(deadline, now))); - if (deadline_atm < shard->queue_deadline_cap) { + grpc_time_averaged_stats_add_sample(&shard->stats, (deadline - now) / 1000.0); + if (deadline < shard->queue_deadline_cap) { is_first_timer = grpc_timer_heap_add(&shard->heap, timer); } else { timer->heap_index = INVALID_HEAP_INDEX; @@ -292,12 +248,12 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer, gpr_log(GPR_DEBUG, " .. old shard min_deadline=%" PRIdPTR, shard->min_deadline); } - if (deadline_atm < shard->min_deadline) { + if (deadline < shard->min_deadline) { gpr_atm old_min_deadline = g_shard_queue[0]->min_deadline; - shard->min_deadline = deadline_atm; + shard->min_deadline = deadline; note_deadline_change(shard); - if (shard->shard_queue_index == 0 && deadline_atm < old_min_deadline) { - gpr_atm_no_barrier_store(&g_shared_mutables.min_timer, deadline_atm); + if (shard->shard_queue_index == 0 && deadline < old_min_deadline) { + gpr_atm_no_barrier_store(&g_shared_mutables.min_timer, deadline); grpc_kick_poller(); } } @@ -494,30 +450,27 @@ static int run_some_expired_timers(grpc_exec_ctx *exec_ctx, gpr_atm now, return (int)n; } -bool grpc_timer_check(grpc_exec_ctx *exec_ctx, gpr_timespec now, - gpr_timespec *next) { +bool grpc_timer_check(grpc_exec_ctx *exec_ctx, grpc_millis *next) { // prelude - GPR_ASSERT(now.clock_type == g_clock_type); - gpr_atm now_atm = timespec_to_atm_round_down(now); + grpc_millis now = grpc_exec_ctx_now(exec_ctx); /* fetch from a thread-local first: this avoids contention on a globally mutable cacheline in the common case */ - gpr_atm min_timer = gpr_tls_get(&g_last_seen_min_timer); - if (now_atm < min_timer) { + grpc_millis min_timer = gpr_tls_get(&g_last_seen_min_timer); + if (now < min_timer) { if (next != NULL) { - *next = - atm_to_timespec(GPR_MIN(timespec_to_atm_round_up(*next), min_timer)); + *next = GPR_MIN(*next, min_timer); } if (GRPC_TRACER_ON(grpc_timer_check_trace)) { gpr_log(GPR_DEBUG, - "TIMER CHECK SKIP: now_atm=%" PRIdPTR " min_timer=%" PRIdPTR, - now_atm, min_timer); + "TIMER CHECK SKIP: now=%" PRIdPTR " min_timer=%" PRIdPTR, now, + min_timer); } return 0; } grpc_error *shutdown_error = - gpr_time_cmp(now, gpr_inf_future(now.clock_type)) != 0 + now != GRPC_MILLIS_INF_FUTURE ? GRPC_ERROR_NONE : GRPC_ERROR_CREATE_FROM_STATIC_STRING("Shutting down timer system"); @@ -527,34 +480,23 @@ bool grpc_timer_check(grpc_exec_ctx *exec_ctx, gpr_timespec now, if (next == NULL) { next_str = gpr_strdup("NULL"); } else { - gpr_asprintf(&next_str, "%" PRId64 ".%09d [%" PRIdPTR "]", next->tv_sec, - next->tv_nsec, timespec_to_atm_round_down(*next)); + gpr_asprintf(&next_str, "%" PRIdPTR, *next); } - gpr_log(GPR_DEBUG, "TIMER CHECK BEGIN: now=%" PRId64 ".%09d [%" PRIdPTR - "] next=%s tls_min=%" PRIdPTR " glob_min=%" PRIdPTR, - now.tv_sec, now.tv_nsec, now_atm, next_str, - gpr_tls_get(&g_last_seen_min_timer), + gpr_log(GPR_DEBUG, "TIMER CHECK BEGIN: now=%" PRIdPTR + " next=%s tls_min=%" PRIdPTR " glob_min=%" PRIdPTR, + now, next_str, gpr_tls_get(&g_last_seen_min_timer), gpr_atm_no_barrier_load(&g_shared_mutables.min_timer)); gpr_free(next_str); } // actual code - bool r; - gpr_atm next_atm; - if (next == NULL) { - r = run_some_expired_timers(exec_ctx, now_atm, NULL, shutdown_error); - } else { - next_atm = timespec_to_atm_round_down(*next); - r = run_some_expired_timers(exec_ctx, now_atm, &next_atm, shutdown_error); - *next = atm_to_timespec(next_atm); - } + bool r = run_some_expired_timers(exec_ctx, now, next, shutdown_error); // tracing if (GRPC_TRACER_ON(grpc_timer_check_trace)) { char *next_str; if (next == NULL) { next_str = gpr_strdup("NULL"); } else { - gpr_asprintf(&next_str, "%" PRId64 ".%09d [%" PRIdPTR "]", next->tv_sec, - next->tv_nsec, next_atm); + gpr_asprintf(&next_str, "%" PRIdPTR, *next); } gpr_log(GPR_DEBUG, "TIMER CHECK END: %d timers triggered; next=%s", r, next_str); diff --git a/src/core/lib/iomgr/timer_manager.c b/src/core/lib/iomgr/timer_manager.c index 24085093e70..66ccf1d19a7 100644 --- a/src/core/lib/iomgr/timer_manager.c +++ b/src/core/lib/iomgr/timer_manager.c @@ -101,9 +101,8 @@ static void start_timer_thread_and_unlock(void) { void grpc_timer_manager_tick() { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - gpr_timespec next = gpr_inf_future(GPR_CLOCK_MONOTONIC); - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - grpc_timer_check(&exec_ctx, now, &next); + grpc_millis next = GRPC_MILLIS_INF_FUTURE; + grpc_timer_check(&exec_ctx, &next); grpc_exec_ctx_finish(&exec_ctx); } @@ -112,12 +111,10 @@ static void timer_thread(void *unused) { // since it's easy to spin up new threads grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, NULL); - const gpr_timespec inf_future = gpr_inf_future(GPR_CLOCK_MONOTONIC); for (;;) { - gpr_timespec next = inf_future; - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); + grpc_millis next = GRPC_MILLIS_INF_FUTURE; // check timer state, updates next to the next time to run a check - if (grpc_timer_check(&exec_ctx, now, &next)) { + if (grpc_timer_check(&exec_ctx, &next)) { // if there's something to execute... gpr_mu_lock(&g_mu); // remove a waiter from the pool, and start another thread if necessary @@ -161,12 +158,14 @@ static void timer_thread(void *unused) { gpr_log(GPR_DEBUG, "sleep for a while"); } } else { - next = inf_future; + next = GRPC_MILLIS_INF_FUTURE; if (GRPC_TRACER_ON(grpc_timer_check_trace)) { gpr_log(GPR_DEBUG, "sleep until kicked"); } } - gpr_cv_wait(&g_cv_wait, &g_mu, next); + gpr_cv_wait(&g_cv_wait, &g_mu, + grpc_millis_to_timespec(&exec_ctx, next, GPR_CLOCK_REALTIME)); + grpc_exec_ctx_invalidate_now(&exec_ctx); if (GRPC_TRACER_ON(grpc_timer_check_trace)) { gpr_log(GPR_DEBUG, "wait ended: was_timed:%d kicked:%d", my_timed_waiter_generation == g_timed_waiter_generation, diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.c b/src/core/lib/security/credentials/google_default/google_default_credentials.c index 4d8c451ea80..f0807ab7eae 100644 --- a/src/core/lib/security/credentials/google_default/google_default_credentials.c +++ b/src/core/lib/security/credentials/google_default/google_default_credentials.c @@ -110,7 +110,7 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx *exec_ctx) { /* The http call is local. If it takes more than one sec, it is for sure not on compute engine. */ - gpr_timespec max_detection_delay = gpr_time_from_seconds(1, GPR_TIMESPAN); + grpc_millis max_detection_delay = GPR_MS_PER_SEC; grpc_pollset *pollset = gpr_zalloc(grpc_pollset_size()); grpc_pollset_init(pollset, &g_polling_mu); @@ -129,7 +129,7 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx *exec_ctx) { grpc_resource_quota_create("google_default_credentials"); grpc_httpcli_get( exec_ctx, &context, &detector.pollent, resource_quota, &request, - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), max_detection_delay), + grpc_exec_ctx_now(exec_ctx) + max_detection_delay, grpc_closure_create(on_compute_engine_detection_http_response, &detector, grpc_schedule_on_exec_ctx), &detector.response); @@ -146,8 +146,7 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx *exec_ctx) { "pollset_work", grpc_pollset_work(exec_ctx, grpc_polling_entity_pollset(&detector.pollent), - &worker, gpr_now(GPR_CLOCK_MONOTONIC), - gpr_inf_future(GPR_CLOCK_MONOTONIC)))) { + &worker, GRPC_MILLIS_INF_FUTURE))) { detector.is_done = 1; detector.success = 0; } diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.c b/src/core/lib/security/credentials/jwt/jwt_verifier.c index 0e2a2643716..c7fea6c2e65 100644 --- a/src/core/lib/security/credentials/jwt/jwt_verifier.c +++ b/src/core/lib/security/credentials/jwt/jwt_verifier.c @@ -395,7 +395,7 @@ void verifier_cb_ctx_destroy(grpc_exec_ctx *exec_ctx, verifier_cb_ctx *ctx) { gpr_timespec grpc_jwt_verifier_clock_skew = {60, 0, GPR_TIMESPAN}; /* Max delay defaults to one minute. */ -gpr_timespec grpc_jwt_verifier_max_delay = {60, 0, GPR_TIMESPAN}; +grpc_millis grpc_jwt_verifier_max_delay = 60 * GPR_MS_PER_SEC; typedef struct { char *email_domain; @@ -682,7 +682,7 @@ static void on_openid_config_retrieved(grpc_exec_ctx *exec_ctx, void *user_data, grpc_resource_quota_create("jwt_verifier"); grpc_httpcli_get( exec_ctx, &ctx->verifier->http_ctx, &ctx->pollent, resource_quota, &req, - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), grpc_jwt_verifier_max_delay), + grpc_exec_ctx_now(exec_ctx) + grpc_jwt_verifier_max_delay, grpc_closure_create(on_keys_retrieved, ctx, grpc_schedule_on_exec_ctx), &ctx->responses[HTTP_RESPONSE_KEYS]); grpc_resource_quota_unref_internal(exec_ctx, resource_quota); @@ -808,10 +808,10 @@ static void retrieve_key_and_verify(grpc_exec_ctx *exec_ctx, extreme memory pressure. */ grpc_resource_quota *resource_quota = grpc_resource_quota_create("jwt_verifier"); - grpc_httpcli_get( - exec_ctx, &ctx->verifier->http_ctx, &ctx->pollent, resource_quota, &req, - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), grpc_jwt_verifier_max_delay), - http_cb, &ctx->responses[rsp_idx]); + grpc_httpcli_get(exec_ctx, &ctx->verifier->http_ctx, &ctx->pollent, + resource_quota, &req, + grpc_exec_ctx_now(exec_ctx) + grpc_jwt_verifier_max_delay, + http_cb, &ctx->responses[rsp_idx]); grpc_resource_quota_unref_internal(exec_ctx, resource_quota); gpr_free(req.host); gpr_free(req.http.path); diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.h b/src/core/lib/security/credentials/jwt/jwt_verifier.h index 5c3d2a77887..68fafce4c98 100644 --- a/src/core/lib/security/credentials/jwt/jwt_verifier.h +++ b/src/core/lib/security/credentials/jwt/jwt_verifier.h @@ -96,7 +96,7 @@ typedef struct { /* Globals to control the verifier. Not thread-safe. */ extern gpr_timespec grpc_jwt_verifier_clock_skew; -extern gpr_timespec grpc_jwt_verifier_max_delay; +extern grpc_millis grpc_jwt_verifier_max_delay; /* The verifier can be created with some custom mappings to help with key discovery in the case where the issuer is an email address. diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.c b/src/core/lib/security/credentials/oauth2/oauth2_credentials.c index 29235b6eb30..eaaf6367c37 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.c @@ -130,7 +130,7 @@ static void oauth2_token_fetcher_destruct(grpc_exec_ctx *exec_ctx, grpc_credentials_status grpc_oauth2_token_fetcher_credentials_parse_server_response( grpc_exec_ctx *exec_ctx, const grpc_http_response *response, - grpc_credentials_md_store **token_md, gpr_timespec *token_lifetime) { + grpc_credentials_md_store **token_md, grpc_millis *token_lifetime) { char *null_terminated_body = NULL; char *new_access_token = NULL; grpc_credentials_status status = GRPC_CREDENTIALS_OK; @@ -196,9 +196,7 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response( } gpr_asprintf(&new_access_token, "%s %s", token_type->value, access_token->value); - token_lifetime->tv_sec = strtol(expires_in->value, NULL, 10); - token_lifetime->tv_nsec = 0; - token_lifetime->clock_type = GPR_TIMESPAN; + *token_lifetime = strtol(expires_in->value, NULL, 10) * GPR_MS_PER_SEC; if (*token_md != NULL) grpc_credentials_md_store_unref(exec_ctx, *token_md); *token_md = grpc_credentials_md_store_create(1); grpc_credentials_md_store_add_cstrings( @@ -224,7 +222,7 @@ static void on_oauth2_token_fetcher_http_response(grpc_exec_ctx *exec_ctx, (grpc_credentials_metadata_request *)user_data; grpc_oauth2_token_fetcher_credentials *c = (grpc_oauth2_token_fetcher_credentials *)r->creds; - gpr_timespec token_lifetime; + grpc_millis token_lifetime; grpc_credentials_status status; GRPC_LOG_IF_ERROR("oauth_fetch", GRPC_ERROR_REF(error)); @@ -233,12 +231,11 @@ static void on_oauth2_token_fetcher_http_response(grpc_exec_ctx *exec_ctx, status = grpc_oauth2_token_fetcher_credentials_parse_server_response( exec_ctx, &r->response, &c->access_token_md, &token_lifetime); if (status == GRPC_CREDENTIALS_OK) { - c->token_expiration = - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), token_lifetime); + c->token_expiration = grpc_exec_ctx_now(exec_ctx) + token_lifetime; r->cb(exec_ctx, r->user_data, c->access_token_md->entries, c->access_token_md->num_entries, GRPC_CREDENTIALS_OK, NULL); } else { - c->token_expiration = gpr_inf_past(GPR_CLOCK_REALTIME); + c->token_expiration = 0; r->cb(exec_ctx, r->user_data, NULL, 0, status, "Error occured when fetching oauth2 token."); } @@ -252,15 +249,14 @@ static void oauth2_token_fetcher_get_request_metadata( grpc_credentials_metadata_cb cb, void *user_data) { grpc_oauth2_token_fetcher_credentials *c = (grpc_oauth2_token_fetcher_credentials *)creds; - gpr_timespec refresh_threshold = gpr_time_from_seconds( - GRPC_SECURE_TOKEN_REFRESH_THRESHOLD_SECS, GPR_TIMESPAN); + grpc_millis refresh_threshold = + GRPC_SECURE_TOKEN_REFRESH_THRESHOLD_SECS * GPR_MS_PER_SEC; grpc_credentials_md_store *cached_access_token_md = NULL; { gpr_mu_lock(&c->mu); if (c->access_token_md != NULL && - (gpr_time_cmp( - gpr_time_sub(c->token_expiration, gpr_now(GPR_CLOCK_REALTIME)), - refresh_threshold) > 0)) { + (c->token_expiration + grpc_exec_ctx_now(exec_ctx) > + refresh_threshold)) { cached_access_token_md = grpc_credentials_md_store_ref(c->access_token_md); } @@ -275,7 +271,7 @@ static void oauth2_token_fetcher_get_request_metadata( exec_ctx, grpc_credentials_metadata_request_create(creds, cb, user_data), &c->httpcli_context, pollent, on_oauth2_token_fetcher_http_response, - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), refresh_threshold)); + grpc_exec_ctx_now(exec_ctx) + refresh_threshold); } } @@ -285,7 +281,7 @@ static void init_oauth2_token_fetcher(grpc_oauth2_token_fetcher_credentials *c, c->base.type = GRPC_CALL_CREDENTIALS_TYPE_OAUTH2; gpr_ref_init(&c->base.refcount, 1); gpr_mu_init(&c->mu); - c->token_expiration = gpr_inf_past(GPR_CLOCK_REALTIME); + c->token_expiration = 0; c->fetch_func = fetch_func; grpc_httpcli_context_init(&c->httpcli_context); } @@ -300,7 +296,7 @@ static grpc_call_credentials_vtable compute_engine_vtable = { static void compute_engine_fetch_oauth2( grpc_exec_ctx *exec_ctx, grpc_credentials_metadata_request *metadata_req, grpc_httpcli_context *httpcli_context, grpc_polling_entity *pollent, - grpc_iomgr_cb_func response_cb, gpr_timespec deadline) { + grpc_iomgr_cb_func response_cb, grpc_millis deadline) { grpc_http_header header = {"Metadata-Flavor", "Google"}; grpc_httpcli_request request; memset(&request, 0, sizeof(grpc_httpcli_request)); @@ -351,7 +347,7 @@ static grpc_call_credentials_vtable refresh_token_vtable = { static void refresh_token_fetch_oauth2( grpc_exec_ctx *exec_ctx, grpc_credentials_metadata_request *metadata_req, grpc_httpcli_context *httpcli_context, grpc_polling_entity *pollent, - grpc_iomgr_cb_func response_cb, gpr_timespec deadline) { + grpc_iomgr_cb_func response_cb, grpc_millis deadline) { grpc_google_refresh_token_credentials *c = (grpc_google_refresh_token_credentials *)metadata_req->creds; grpc_http_header header = {"Content-Type", diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h index 2d7c02ccf57..88f5351f367 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h @@ -72,12 +72,12 @@ typedef void (*grpc_fetch_oauth2_func)(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *http_context, grpc_polling_entity *pollent, grpc_iomgr_cb_func cb, - gpr_timespec deadline); + grpc_millis deadline); typedef struct { grpc_call_credentials base; gpr_mu mu; grpc_credentials_md_store *access_token_md; - gpr_timespec token_expiration; + grpc_millis token_expiration; grpc_httpcli_context httpcli_context; grpc_fetch_oauth2_func fetch_func; } grpc_oauth2_token_fetcher_credentials; @@ -104,6 +104,6 @@ grpc_refresh_token_credentials_create_from_auth_refresh_token( grpc_credentials_status grpc_oauth2_token_fetcher_credentials_parse_server_response( grpc_exec_ctx *exec_ctx, const struct grpc_http_response *response, - grpc_credentials_md_store **token_md, gpr_timespec *token_lifetime); + grpc_credentials_md_store **token_md, grpc_millis *token_lifetime); #endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_OAUTH2_OAUTH2_CREDENTIALS_H */ diff --git a/src/core/lib/surface/alarm.c b/src/core/lib/surface/alarm.c index b72d534b7ef..6593f145239 100644 --- a/src/core/lib/surface/alarm.c +++ b/src/core/lib/surface/alarm.c @@ -68,8 +68,8 @@ grpc_alarm *grpc_alarm_create(grpc_completion_queue *cq, gpr_timespec deadline, grpc_closure_init(&alarm->on_alarm, alarm_cb, alarm, grpc_schedule_on_exec_ctx); grpc_timer_init(&exec_ctx, &alarm->alarm, - gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC), - &alarm->on_alarm, gpr_now(GPR_CLOCK_MONOTONIC)); + grpc_timespec_to_millis(&exec_ctx, deadline), + &alarm->on_alarm); grpc_exec_ctx_finish(&exec_ctx); return alarm; } diff --git a/src/core/lib/surface/completion_queue.c b/src/core/lib/surface/completion_queue.c index df5b70205cb..d26df33b5ca 100644 --- a/src/core/lib/surface/completion_queue.c +++ b/src/core/lib/surface/completion_queue.c @@ -68,8 +68,7 @@ typedef struct { grpc_error *(*kick)(grpc_pollset *pollset, grpc_pollset_worker *specific_worker); grpc_error *(*work)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, - grpc_pollset_worker **worker, gpr_timespec now, - gpr_timespec deadline); + grpc_pollset_worker **worker, grpc_millis deadline); void (*shutdown)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, grpc_closure *closure); void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset); @@ -107,8 +106,7 @@ static void non_polling_poller_destroy(grpc_exec_ctx *exec_ctx, static grpc_error *non_polling_poller_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, grpc_pollset_worker **worker, - gpr_timespec now, - gpr_timespec deadline) { + grpc_millis deadline) { non_polling_poller *npp = (non_polling_poller *)pollset; if (npp->shutdown) return GRPC_ERROR_NONE; non_polling_worker w; @@ -122,7 +120,10 @@ static grpc_error *non_polling_poller_work(grpc_exec_ctx *exec_ctx, w.next->prev = w.prev->next = &w; } w.kicked = false; - while (!npp->shutdown && !w.kicked && !gpr_cv_wait(&w.cv, &npp->mu, deadline)) + gpr_timespec deadline_ts = + grpc_millis_to_timespec(exec_ctx, deadline, GPR_CLOCK_REALTIME); + while (!npp->shutdown && !w.kicked && + !gpr_cv_wait(&w.cv, &npp->mu, deadline_ts)) ; if (&w == npp->root) { npp->root = w.next; @@ -453,7 +454,7 @@ void grpc_cq_end_op(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cc, typedef struct { gpr_atm last_seen_things_queued_ever; grpc_completion_queue *cq; - gpr_timespec deadline; + grpc_millis deadline; grpc_cq_completion *stolen_completion; void *tag; /* for pluck */ bool first_loop; @@ -480,8 +481,7 @@ static bool cq_is_next_finished(grpc_exec_ctx *exec_ctx, void *arg) { } gpr_mu_unlock(cq->mu); } - return !a->first_loop && - gpr_time_cmp(a->deadline, gpr_now(a->deadline.clock_type)) < 0; + return !a->first_loop && a->deadline < grpc_exec_ctx_now(exec_ctx); } #ifndef NDEBUG @@ -510,7 +510,6 @@ static void dump_pending_tags(grpc_completion_queue *cc) {} grpc_event grpc_completion_queue_next(grpc_completion_queue *cc, gpr_timespec deadline, void *reserved) { grpc_event ret; - gpr_timespec now; if (cc->completion_type != GRPC_CQ_NEXT) { gpr_log(GPR_ERROR, @@ -533,20 +532,20 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc, dump_pending_tags(cc); - deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC); - GRPC_CQ_INTERNAL_REF(cc, "next"); gpr_mu_lock(cc->mu); cq_is_finished_arg is_finished_arg = { .last_seen_things_queued_ever = gpr_atm_no_barrier_load(&cc->things_queued_ever), .cq = cc, - .deadline = deadline, + .deadline = 0, /* set below */ .stolen_completion = NULL, .tag = NULL, .first_loop = true}; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INITIALIZER(0, cq_is_next_finished, &is_finished_arg); + grpc_millis deadline_millis = is_finished_arg.deadline = + grpc_timespec_to_millis(&exec_ctx, deadline); for (;;) { if (is_finished_arg.stolen_completion != NULL) { gpr_mu_unlock(cc->mu); @@ -577,8 +576,8 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc, ret.type = GRPC_QUEUE_SHUTDOWN; break; } - now = gpr_now(GPR_CLOCK_MONOTONIC); - if (!is_finished_arg.first_loop && gpr_time_cmp(now, deadline) >= 0) { + if (!is_finished_arg.first_loop && + grpc_exec_ctx_now(&exec_ctx) >= deadline_millis) { gpr_mu_unlock(cc->mu); memset(&ret, 0, sizeof(ret)); ret.type = GRPC_QUEUE_TIMEOUT; @@ -586,7 +585,7 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc, break; } grpc_error *err = cc->poller_vtable->work(&exec_ctx, POLLSET_FROM_CQ(cc), - NULL, now, deadline); + NULL, deadline_millis); if (err != GRPC_ERROR_NONE) { gpr_mu_unlock(cc->mu); const char *msg = grpc_error_string(err); @@ -661,8 +660,7 @@ static bool cq_is_pluck_finished(grpc_exec_ctx *exec_ctx, void *arg) { } gpr_mu_unlock(cq->mu); } - return !a->first_loop && - gpr_time_cmp(a->deadline, gpr_now(a->deadline.clock_type)) < 0; + return !a->first_loop && a->deadline < grpc_exec_ctx_now(exec_ctx); } grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag, @@ -671,7 +669,6 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag, grpc_cq_completion *c; grpc_cq_completion *prev; grpc_pollset_worker *worker = NULL; - gpr_timespec now; GPR_TIMER_BEGIN("grpc_completion_queue_pluck", 0); @@ -696,20 +693,20 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag, dump_pending_tags(cc); - deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC); - GRPC_CQ_INTERNAL_REF(cc, "pluck"); gpr_mu_lock(cc->mu); cq_is_finished_arg is_finished_arg = { .last_seen_things_queued_ever = gpr_atm_no_barrier_load(&cc->things_queued_ever), .cq = cc, - .deadline = deadline, + .deadline = 0, /* set below */ .stolen_completion = NULL, .tag = tag, .first_loop = true}; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INITIALIZER(0, cq_is_pluck_finished, &is_finished_arg); + grpc_millis deadline_millis = is_finished_arg.deadline = + grpc_timespec_to_millis(&exec_ctx, deadline); for (;;) { if (is_finished_arg.stolen_completion != NULL) { gpr_mu_unlock(cc->mu); @@ -756,8 +753,8 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag, dump_pending_tags(cc); break; } - now = gpr_now(GPR_CLOCK_MONOTONIC); - if (!is_finished_arg.first_loop && gpr_time_cmp(now, deadline) >= 0) { + if (!is_finished_arg.first_loop && + grpc_exec_ctx_now(&exec_ctx) >= deadline_millis) { del_plucker(cc, tag, &worker); gpr_mu_unlock(cc->mu); memset(&ret, 0, sizeof(ret)); @@ -766,7 +763,7 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag, break; } grpc_error *err = cc->poller_vtable->work(&exec_ctx, POLLSET_FROM_CQ(cc), - &worker, now, deadline); + &worker, deadline_millis); if (err != GRPC_ERROR_NONE) { del_plucker(cc, tag, &worker); gpr_mu_unlock(cc->mu); diff --git a/test/core/end2end/fixtures/http_proxy_fixture.c b/test/core/end2end/fixtures/http_proxy_fixture.c index c2d8480e69a..2bdaa962ae3 100644 --- a/test/core/end2end/fixtures/http_proxy_fixture.c +++ b/test/core/end2end/fixtures/http_proxy_fixture.c @@ -377,8 +377,8 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg, GPR_ASSERT(resolved_addresses->naddrs >= 1); // Connect to requested address. // The connection callback inherits our reference to conn. - const gpr_timespec deadline = gpr_time_add( - gpr_now(GPR_CLOCK_MONOTONIC), gpr_time_from_seconds(10, GPR_TIMESPAN)); + const grpc_millis deadline = + grpc_exec_ctx_now(exec_ctx) + 10 * GPR_MS_PER_SEC; grpc_tcp_client_connect(exec_ctx, &conn->on_server_connect_done, &conn->server_endpoint, conn->pollset_set, NULL, &resolved_addresses->addrs[0], deadline); @@ -434,14 +434,12 @@ static void thread_main(void* arg) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; do { gpr_ref(&proxy->users); - const gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - const gpr_timespec deadline = - gpr_time_add(now, gpr_time_from_seconds(1, GPR_TIMESPAN)); grpc_pollset_worker* worker = NULL; gpr_mu_lock(proxy->mu); GRPC_LOG_IF_ERROR( "grpc_pollset_work", - grpc_pollset_work(&exec_ctx, proxy->pollset, &worker, now, deadline)); + grpc_pollset_work(&exec_ctx, proxy->pollset, &worker, + grpc_exec_ctx_now(&exec_ctx) + GPR_MS_PER_SEC)); gpr_mu_unlock(proxy->mu); grpc_exec_ctx_flush(&exec_ctx); } while (!gpr_unref(&proxy->users)); diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c index e274796e237..2fece9b667a 100644 --- a/test/core/iomgr/endpoint_tests.c +++ b/test/core/iomgr/endpoint_tests.c @@ -187,10 +187,11 @@ static void read_and_write_test(grpc_endpoint_test_config config, size_t num_bytes, size_t write_size, size_t slice_size, bool shutdown) { struct read_and_write_test_state state; - gpr_timespec deadline = grpc_timeout_seconds_to_deadline(20); grpc_endpoint_test_fixture f = begin_test(config, "read_and_write_test", slice_size); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_millis deadline = + grpc_timespec_to_millis(&exec_ctx, grpc_timeout_seconds_to_deadline(20)); gpr_log(GPR_DEBUG, "num_bytes=%" PRIuPTR " write_size=%" PRIuPTR " slice_size=%" PRIuPTR " shutdown=%d", num_bytes, write_size, slice_size, shutdown); @@ -246,11 +247,10 @@ static void read_and_write_test(grpc_endpoint_test_config config, gpr_mu_lock(g_mu); while (!state.read_done || !state.write_done) { grpc_pollset_worker *worker = NULL; - GPR_ASSERT(gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), deadline) < 0); + GPR_ASSERT(grpc_exec_ctx_now(&exec_ctx) < deadline); GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", - grpc_pollset_work(&exec_ctx, g_pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), deadline))); + grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline))); } gpr_mu_unlock(g_mu); grpc_exec_ctx_flush(&exec_ctx); @@ -273,13 +273,11 @@ static void wait_for_fail_count(grpc_exec_ctx *exec_ctx, int *fail_count, grpc_exec_ctx_flush(exec_ctx); for (int i = 0; i < 5 && *fail_count < want_fail_count; i++) { grpc_pollset_worker *worker = NULL; - gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME); - gpr_timespec deadline = - gpr_time_add(now, gpr_time_from_seconds(1, GPR_TIMESPAN)); gpr_mu_lock(g_mu); GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", - grpc_pollset_work(exec_ctx, g_pollset, &worker, now, deadline))); + grpc_pollset_work(exec_ctx, g_pollset, &worker, + grpc_exec_ctx_now(exec_ctx) + GPR_MS_PER_SEC))); gpr_mu_unlock(g_mu); grpc_exec_ctx_flush(exec_ctx); } diff --git a/test/core/security/oauth2_utils.c b/test/core/security/oauth2_utils.c index 838625705dd..9238adeaef1 100644 --- a/test/core/security/oauth2_utils.c +++ b/test/core/security/oauth2_utils.c @@ -107,8 +107,7 @@ char *grpc_test_fetch_oauth2_token_with_credentials( "pollset_work", grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&request.pops), - &worker, gpr_now(GPR_CLOCK_MONOTONIC), - gpr_inf_future(GPR_CLOCK_MONOTONIC)))) { + &worker, GRPC_MILLIS_INF_FUTURE))) { request.is_done = 1; } } diff --git a/test/core/util/port_server_client.c b/test/core/util/port_server_client.c index 6ef0acfc29b..efe20756824 100644 --- a/test/core/util/port_server_client.c +++ b/test/core/util/port_server_client.c @@ -102,7 +102,7 @@ void grpc_free_port_using_server(int port) { grpc_resource_quota *resource_quota = grpc_resource_quota_create("port_server_client/free"); grpc_httpcli_get(&exec_ctx, &context, &pr.pops, resource_quota, &req, - grpc_timeout_seconds_to_deadline(30), + grpc_exec_ctx_now(&exec_ctx) + 30 * GPR_MS_PER_SEC, grpc_closure_create(freed_port_from_server, &pr, grpc_schedule_on_exec_ctx), &rsp); @@ -113,8 +113,8 @@ void grpc_free_port_using_server(int port) { if (!GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&pr.pops), - &worker, gpr_now(GPR_CLOCK_MONOTONIC), - grpc_timeout_seconds_to_deadline(1)))) { + &worker, + grpc_exec_ctx_now(&exec_ctx) + GPR_MS_PER_SEC))) { pr.done = 1; } } @@ -185,7 +185,7 @@ static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg, grpc_resource_quota *resource_quota = grpc_resource_quota_create("port_server_client/pick_retry"); grpc_httpcli_get(exec_ctx, pr->ctx, &pr->pops, resource_quota, &req, - grpc_timeout_seconds_to_deadline(10), + grpc_exec_ctx_now(exec_ctx) + 30 * GPR_MS_PER_SEC, grpc_closure_create(got_port_from_server, pr, grpc_schedule_on_exec_ctx), &pr->response); @@ -235,7 +235,7 @@ int grpc_pick_port_using_server(void) { grpc_resource_quota_create("port_server_client/pick"); grpc_httpcli_get( &exec_ctx, &context, &pr.pops, resource_quota, &req, - grpc_timeout_seconds_to_deadline(30), + grpc_exec_ctx_now(&exec_ctx) + 30 * GPR_MS_PER_SEC, grpc_closure_create(got_port_from_server, &pr, grpc_schedule_on_exec_ctx), &pr.response); grpc_resource_quota_unref_internal(&exec_ctx, resource_quota); @@ -245,8 +245,8 @@ int grpc_pick_port_using_server(void) { if (!GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&pr.pops), - &worker, gpr_now(GPR_CLOCK_MONOTONIC), - grpc_timeout_seconds_to_deadline(1)))) { + &worker, + grpc_exec_ctx_now(&exec_ctx) + GPR_MS_PER_SEC))) { pr.port = 0; } } From 565d4c1e8863202fcc1d2f0c7bf56cca206e4f88 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 17 Jul 2017 14:23:46 -0700 Subject: [PATCH 004/142] Progress --- .../filters/client_channel/channel_connectivity.c | 4 ++-- src/core/ext/filters/client_channel/connector.h | 2 +- src/core/ext/transport/chttp2/transport/writing.c | 3 +-- src/core/lib/iomgr/iomgr.c | 8 +------- test/core/util/test_tcp_server.c | 12 ++++++------ 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/core/ext/filters/client_channel/channel_connectivity.c b/src/core/ext/filters/client_channel/channel_connectivity.c index c3dca14305d..39dd927d705 100644 --- a/src/core/ext/filters/client_channel/channel_connectivity.c +++ b/src/core/ext/filters/client_channel/channel_connectivity.c @@ -186,8 +186,8 @@ static void watcher_timer_init(grpc_exec_ctx *exec_ctx, void *arg, watcher_timer_init_arg *wa = (watcher_timer_init_arg *)arg; grpc_timer_init(exec_ctx, &wa->w->alarm, - gpr_convert_clock_type(wa->deadline, GPR_CLOCK_MONOTONIC), - &wa->w->on_timeout, gpr_now(GPR_CLOCK_MONOTONIC)); + grpc_timespec_to_millis(exec_ctx, wa->deadline), + &wa->w->on_timeout); gpr_free(wa); } diff --git a/src/core/ext/filters/client_channel/connector.h b/src/core/ext/filters/client_channel/connector.h index 7f3d4a1cc03..bf79f261b0b 100644 --- a/src/core/ext/filters/client_channel/connector.h +++ b/src/core/ext/filters/client_channel/connector.h @@ -34,7 +34,7 @@ typedef struct { /** set of pollsets interested in this connection */ grpc_pollset_set *interested_parties; /** deadline for connection */ - gpr_timespec deadline; + grpc_millis deadline; /** channel arguments (to be passed to transport) */ const grpc_channel_args *channel_args; } grpc_connect_in_args; diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index 3e16fda6dc1..69e8c8f062c 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -261,8 +261,7 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( t->ping_state.pings_before_data_required = t->ping_policy.max_pings_without_data; if (!t->is_client) { - t->ping_recv_state.last_ping_recv_time = - gpr_inf_past(GPR_CLOCK_MONOTONIC); + t->ping_recv_state.last_ping_recv_time = 0; t->ping_recv_state.ping_strikes = 0; } } else { diff --git a/src/core/lib/iomgr/iomgr.c b/src/core/lib/iomgr/iomgr.c index 5e15b01ffd8..55a9604c6b3 100644 --- a/src/core/lib/iomgr/iomgr.c +++ b/src/core/lib/iomgr/iomgr.c @@ -47,14 +47,8 @@ void grpc_iomgr_init(grpc_exec_ctx *exec_ctx) { gpr_mu_init(&g_mu); gpr_cv_init(&g_rcv); grpc_exec_ctx_global_init(); -<<<<<<< HEAD - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_timer_list_init(&exec_ctx); - grpc_exec_ctx_finish(&exec_ctx); -======= grpc_executor_init(exec_ctx); - grpc_timer_list_init(gpr_now(GPR_CLOCK_MONOTONIC)); ->>>>>>> 4708a21c8144f9fed3c90ea8fa153aa20302a1d7 + grpc_timer_list_init(exec_ctx); g_root_object.next = g_root_object.prev = &g_root_object; g_root_object.name = "root"; grpc_network_status_init(); diff --git a/test/core/util/test_tcp_server.c b/test/core/util/test_tcp_server.c index d3a1de8a3b1..cf21ec50ae8 100644 --- a/test/core/util/test_tcp_server.c +++ b/test/core/util/test_tcp_server.c @@ -31,6 +31,7 @@ #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/tcp_server.h" #include "test/core/util/port.h" +#include "test/core/util/test_config.h" static void on_server_destroyed(grpc_exec_ctx *exec_ctx, void *data, grpc_error *error) { @@ -78,14 +79,13 @@ void test_tcp_server_start(test_tcp_server *server, int port) { void test_tcp_server_poll(test_tcp_server *server, int seconds) { grpc_pollset_worker *worker = NULL; - gpr_timespec deadline = - gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_seconds(seconds, GPR_TIMESPAN)); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_millis deadline = grpc_timespec_to_millis( + &exec_ctx, grpc_timeout_seconds_to_deadline(seconds)); gpr_mu_lock(server->mu); - GRPC_LOG_IF_ERROR("pollset_work", - grpc_pollset_work(&exec_ctx, server->pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), deadline)); + GRPC_LOG_IF_ERROR( + "pollset_work", + grpc_pollset_work(&exec_ctx, server->pollset, &worker, deadline)); gpr_mu_unlock(server->mu); grpc_exec_ctx_finish(&exec_ctx); } From c0df1c0f9a04d9b150af5ba710090f7f8c19f7d5 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 17 Jul 2017 16:12:33 -0700 Subject: [PATCH 005/142] Compiling again --- BUILD | 4 +- CMakeLists.txt | 64 ++++---- Makefile | 74 ++++----- binding.gyp | 2 +- build.yaml | 22 +-- config.m4 | 3 +- config.w32 | 3 +- gRPC-Core.podspec | 10 +- grpc.gemspec | 4 +- package.xml | 4 +- .../client_channel/channel_connectivity.c | 3 +- .../client_channel/lb_policy/grpclb/grpclb.c | 56 ++++--- .../lb_policy/grpclb/load_balancer_api.c | 11 +- .../lb_policy/grpclb/load_balancer_api.h | 3 +- .../resolver/dns/c_ares/dns_resolver_ares.c | 30 ++-- .../resolver/dns/native/dns_resolver.c | 30 ++-- .../ext/filters/client_channel/subchannel.c | 22 ++- .../ext/filters/deadline/deadline_filter.c | 7 +- src/core/ext/filters/max_age/max_age_filter.c | 62 +++----- src/core/lib/{support => backoff}/backoff.c | 26 ++-- src/core/lib/{support => backoff}/backoff.h | 19 +-- src/core/lib/iomgr/exec_ctx.c | 8 +- src/core/lib/iomgr/exec_ctx.h | 6 +- src/core/lib/iomgr/timer_manager.c | 2 +- src/core/lib/surface/alarm.c | 3 +- src/core/lib/surface/completion_queue.c | 14 +- src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/backoff/BUILD | 34 ++++ test/core/backoff/backoff_test.c | 147 ++++++++++++++++++ .../dns_resolver_connectivity_test.c | 2 +- test/core/end2end/fuzzers/api_fuzzer.c | 18 +-- test/core/http/httpcli_test.c | 10 +- test/core/http/httpscli_test.c | 10 +- test/core/iomgr/endpoint_tests.c | 4 +- test/core/iomgr/fd_posix_test.c | 24 +-- test/core/iomgr/resolve_address_posix_test.c | 27 ++-- test/core/iomgr/resolve_address_test.c | 27 ++-- test/core/iomgr/tcp_client_posix_test.c | 23 ++- test/core/iomgr/tcp_posix_test.c | 31 ++-- test/core/iomgr/tcp_server_posix_test.c | 8 +- test/core/iomgr/timer_list_test.c | 83 ++++------ test/core/iomgr/udp_server_test.c | 11 +- test/core/security/credentials_test.c | 33 ++-- test/core/security/jwt_verifier_test.c | 14 +- test/core/security/ssl_server_fuzzer.c | 3 +- test/core/support/BUILD | 10 -- test/core/support/backoff_test.c | 143 ----------------- .../surface/concurrent_connectivity_test.c | 10 +- test/core/util/test_tcp_server.c | 4 +- tools/doxygen/Doxyfile.core.internal | 4 +- .../generated/sources_and_headers.json | 38 ++--- tools/run_tests/generated/tests.json | 44 +++--- vsprojects/buildtests_c.sln | 52 ++++--- vsprojects/vcxproj/gpr/gpr.vcxproj | 6 +- vsprojects/vcxproj/gpr/gpr.vcxproj.filters | 15 +- .../backoff_test.vcxproj} | 14 +- .../backoff_test.vcxproj.filters} | 12 +- 57 files changed, 662 insertions(+), 693 deletions(-) rename src/core/lib/{support => backoff}/backoff.c (69%) rename src/core/lib/{support => backoff}/backoff.h (72%) create mode 100644 test/core/backoff/BUILD create mode 100644 test/core/backoff/backoff_test.c delete mode 100644 test/core/support/backoff_test.c rename vsprojects/vcxproj/test/{gpr_backoff_test/gpr_backoff_test.vcxproj => backoff_test/backoff_test.vcxproj} (95%) rename vsprojects/vcxproj/test/{gpr_backoff_test/gpr_backoff_test.vcxproj.filters => backoff_test/backoff_test.vcxproj.filters} (53%) diff --git a/BUILD b/BUILD index 9f1ab2a5384..c69dd5e4613 100644 --- a/BUILD +++ b/BUILD @@ -465,7 +465,7 @@ grpc_cc_library( "src/core/lib/support/arena.c", "src/core/lib/support/atm.c", "src/core/lib/support/avl.c", - "src/core/lib/support/backoff.c", + "src/core/lib/backoff/backoff.c", "src/core/lib/support/cmdline.c", "src/core/lib/support/cpu_iphone.c", "src/core/lib/support/cpu_linux.c", @@ -512,7 +512,7 @@ grpc_cc_library( "src/core/lib/support/atomic.h", "src/core/lib/support/atomic_with_atm.h", "src/core/lib/support/atomic_with_std.h", - "src/core/lib/support/backoff.h", + "src/core/lib/backoff/backoff.h", "src/core/lib/support/block_annotate.h", "src/core/lib/support/env.h", "src/core/lib/support/memory.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 5413bbcc0f3..ca68050ff3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -390,6 +390,7 @@ add_dependencies(buildtests_c algorithm_test) add_dependencies(buildtests_c alloc_test) add_dependencies(buildtests_c alpn_test) add_dependencies(buildtests_c arena_test) +add_dependencies(buildtests_c backoff_test) add_dependencies(buildtests_c bad_server_response_test) add_dependencies(buildtests_c bdp_estimator_test) add_dependencies(buildtests_c bin_decoder_test) @@ -435,7 +436,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_c goaway_server_test) endif() add_dependencies(buildtests_c gpr_avl_test) -add_dependencies(buildtests_c gpr_backoff_test) add_dependencies(buildtests_c gpr_cmdline_test) add_dependencies(buildtests_c gpr_cpu_test) add_dependencies(buildtests_c gpr_env_test) @@ -769,13 +769,13 @@ endif (gRPC_BUILD_TESTS) add_library(gpr + src/core/lib/backoff/backoff.c src/core/lib/profiling/basic_timers.c src/core/lib/profiling/stap_timers.c src/core/lib/support/alloc.c src/core/lib/support/arena.c src/core/lib/support/atm.c src/core/lib/support/avl.c - src/core/lib/support/backoff.c src/core/lib/support/cmdline.c src/core/lib/support/cpu_iphone.c src/core/lib/support/cpu_linux.c @@ -4659,6 +4659,37 @@ target_link_libraries(arena_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) +add_executable(backoff_test + test/core/backoff/backoff_test.c +) + + +target_include_directories(backoff_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${BORINGSSL_ROOT_DIR}/include + PRIVATE ${PROTOBUF_ROOT_DIR}/src + PRIVATE ${BENCHMARK_ROOT_DIR}/include + PRIVATE ${ZLIB_ROOT_DIR} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib + PRIVATE ${CARES_BUILD_INCLUDE_DIR} + PRIVATE ${CARES_INCLUDE_DIR} + PRIVATE ${CARES_PLATFORM_INCLUDE_DIR} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include +) + +target_link_libraries(backoff_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + grpc + gpr_test_util + gpr +) + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + add_executable(bad_server_response_test test/core/end2end/bad_server_response_test.c ) @@ -5769,35 +5800,6 @@ target_link_libraries(gpr_avl_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) -add_executable(gpr_backoff_test - test/core/support/backoff_test.c -) - - -target_include_directories(gpr_backoff_test - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${BORINGSSL_ROOT_DIR}/include - PRIVATE ${PROTOBUF_ROOT_DIR}/src - PRIVATE ${BENCHMARK_ROOT_DIR}/include - PRIVATE ${ZLIB_ROOT_DIR} - PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib - PRIVATE ${CARES_BUILD_INCLUDE_DIR} - PRIVATE ${CARES_INCLUDE_DIR} - PRIVATE ${CARES_PLATFORM_INCLUDE_DIR} - PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares - PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include -) - -target_link_libraries(gpr_backoff_test - ${_gRPC_ALLTARGETS_LIBRARIES} - gpr_test_util - gpr -) - -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) - add_executable(gpr_cmdline_test test/core/support/cmdline_test.c ) diff --git a/Makefile b/Makefile index 210d6768222..76ac2ca374e 100644 --- a/Makefile +++ b/Makefile @@ -950,6 +950,7 @@ alloc_test: $(BINDIR)/$(CONFIG)/alloc_test alpn_test: $(BINDIR)/$(CONFIG)/alpn_test api_fuzzer: $(BINDIR)/$(CONFIG)/api_fuzzer arena_test: $(BINDIR)/$(CONFIG)/arena_test +backoff_test: $(BINDIR)/$(CONFIG)/backoff_test bad_server_response_test: $(BINDIR)/$(CONFIG)/bad_server_response_test bdp_estimator_test: $(BINDIR)/$(CONFIG)/bdp_estimator_test bin_decoder_test: $(BINDIR)/$(CONFIG)/bin_decoder_test @@ -986,7 +987,6 @@ gen_legal_metadata_characters: $(BINDIR)/$(CONFIG)/gen_legal_metadata_characters gen_percent_encoding_tables: $(BINDIR)/$(CONFIG)/gen_percent_encoding_tables goaway_server_test: $(BINDIR)/$(CONFIG)/goaway_server_test gpr_avl_test: $(BINDIR)/$(CONFIG)/gpr_avl_test -gpr_backoff_test: $(BINDIR)/$(CONFIG)/gpr_backoff_test gpr_cmdline_test: $(BINDIR)/$(CONFIG)/gpr_cmdline_test gpr_cpu_test: $(BINDIR)/$(CONFIG)/gpr_cpu_test gpr_env_test: $(BINDIR)/$(CONFIG)/gpr_env_test @@ -1340,6 +1340,7 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/alloc_test \ $(BINDIR)/$(CONFIG)/alpn_test \ $(BINDIR)/$(CONFIG)/arena_test \ + $(BINDIR)/$(CONFIG)/backoff_test \ $(BINDIR)/$(CONFIG)/bad_server_response_test \ $(BINDIR)/$(CONFIG)/bdp_estimator_test \ $(BINDIR)/$(CONFIG)/bin_decoder_test \ @@ -1371,7 +1372,6 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/fling_test \ $(BINDIR)/$(CONFIG)/goaway_server_test \ $(BINDIR)/$(CONFIG)/gpr_avl_test \ - $(BINDIR)/$(CONFIG)/gpr_backoff_test \ $(BINDIR)/$(CONFIG)/gpr_cmdline_test \ $(BINDIR)/$(CONFIG)/gpr_cpu_test \ $(BINDIR)/$(CONFIG)/gpr_env_test \ @@ -1735,6 +1735,8 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/alpn_test || ( echo test alpn_test failed ; exit 1 ) $(E) "[RUN] Testing arena_test" $(Q) $(BINDIR)/$(CONFIG)/arena_test || ( echo test arena_test failed ; exit 1 ) + $(E) "[RUN] Testing backoff_test" + $(Q) $(BINDIR)/$(CONFIG)/backoff_test || ( echo test backoff_test failed ; exit 1 ) $(E) "[RUN] Testing bad_server_response_test" $(Q) $(BINDIR)/$(CONFIG)/bad_server_response_test || ( echo test bad_server_response_test failed ; exit 1 ) $(E) "[RUN] Testing bdp_estimator_test" @@ -1793,8 +1795,6 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/goaway_server_test || ( echo test goaway_server_test failed ; exit 1 ) $(E) "[RUN] Testing gpr_avl_test" $(Q) $(BINDIR)/$(CONFIG)/gpr_avl_test || ( echo test gpr_avl_test failed ; exit 1 ) - $(E) "[RUN] Testing gpr_backoff_test" - $(Q) $(BINDIR)/$(CONFIG)/gpr_backoff_test || ( echo test gpr_backoff_test failed ; exit 1 ) $(E) "[RUN] Testing gpr_cmdline_test" $(Q) $(BINDIR)/$(CONFIG)/gpr_cmdline_test || ( echo test gpr_cmdline_test failed ; exit 1 ) $(E) "[RUN] Testing gpr_cpu_test" @@ -2736,13 +2736,13 @@ clean: LIBGPR_SRC = \ + src/core/lib/backoff/backoff.c \ src/core/lib/profiling/basic_timers.c \ src/core/lib/profiling/stap_timers.c \ src/core/lib/support/alloc.c \ src/core/lib/support/arena.c \ src/core/lib/support/atm.c \ src/core/lib/support/avl.c \ - src/core/lib/support/backoff.c \ src/core/lib/support/cmdline.c \ src/core/lib/support/cpu_iphone.c \ src/core/lib/support/cpu_linux.c \ @@ -8274,6 +8274,38 @@ endif endif +BACKOFF_TEST_SRC = \ + test/core/backoff/backoff_test.c \ + +BACKOFF_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BACKOFF_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/backoff_test: openssl_dep_error + +else + + + +$(BINDIR)/$(CONFIG)/backoff_test: $(BACKOFF_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LD) $(LDFLAGS) $(BACKOFF_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/backoff_test + +endif + +$(OBJDIR)/$(CONFIG)/test/core/backoff/backoff_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_backoff_test: $(BACKOFF_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(BACKOFF_TEST_OBJS:.o=.dep) +endif +endif + + BAD_SERVER_RESPONSE_TEST_SRC = \ test/core/end2end/bad_server_response_test.c \ @@ -9426,38 +9458,6 @@ endif endif -GPR_BACKOFF_TEST_SRC = \ - test/core/support/backoff_test.c \ - -GPR_BACKOFF_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_BACKOFF_TEST_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/gpr_backoff_test: openssl_dep_error - -else - - - -$(BINDIR)/$(CONFIG)/gpr_backoff_test: $(GPR_BACKOFF_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_BACKOFF_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_backoff_test - -endif - -$(OBJDIR)/$(CONFIG)/test/core/support/backoff_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - -deps_gpr_backoff_test: $(GPR_BACKOFF_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(GPR_BACKOFF_TEST_OBJS:.o=.dep) -endif -endif - - GPR_CMDLINE_TEST_SRC = \ test/core/support/cmdline_test.c \ diff --git a/binding.gyp b/binding.gyp index ae78d931f2d..92562648237 100644 --- a/binding.gyp +++ b/binding.gyp @@ -579,13 +579,13 @@ 'dependencies': [ ], 'sources': [ + 'src/core/lib/backoff/backoff.c', 'src/core/lib/profiling/basic_timers.c', 'src/core/lib/profiling/stap_timers.c', 'src/core/lib/support/alloc.c', 'src/core/lib/support/arena.c', 'src/core/lib/support/atm.c', 'src/core/lib/support/avl.c', - 'src/core/lib/support/backoff.c', 'src/core/lib/support/cmdline.c', 'src/core/lib/support/cpu_iphone.c', 'src/core/lib/support/cpu_linux.c', diff --git a/build.yaml b/build.yaml index 581fa65a235..01c6b42baa7 100644 --- a/build.yaml +++ b/build.yaml @@ -87,12 +87,12 @@ filegroups: - include/grpc/support/tls_pthread.h - include/grpc/support/useful.h headers: + - src/core/lib/backoff/backoff.h - src/core/lib/profiling/timers.h - src/core/lib/support/arena.h - src/core/lib/support/atomic.h - src/core/lib/support/atomic_with_atm.h - src/core/lib/support/atomic_with_std.h - - src/core/lib/support/backoff.h - src/core/lib/support/block_annotate.h - src/core/lib/support/env.h - src/core/lib/support/memory.h @@ -106,13 +106,13 @@ filegroups: - src/core/lib/support/time_precise.h - src/core/lib/support/tmpfile.h src: + - src/core/lib/backoff/backoff.c - src/core/lib/profiling/basic_timers.c - src/core/lib/profiling/stap_timers.c - src/core/lib/support/alloc.c - src/core/lib/support/arena.c - src/core/lib/support/atm.c - src/core/lib/support/avl.c - - src/core/lib/support/backoff.c - src/core/lib/support/cmdline.c - src/core/lib/support/cpu_iphone.c - src/core/lib/support/cpu_linux.c @@ -1658,6 +1658,16 @@ targets: deps: - gpr_test_util - gpr +- name: backoff_test + build: test + language: c + src: + - test/core/backoff/backoff_test.c + deps: + - grpc_test_util + - grpc + - gpr_test_util + - gpr - name: bad_server_response_test build: test language: c @@ -2061,14 +2071,6 @@ targets: deps: - gpr_test_util - gpr -- name: gpr_backoff_test - build: test - language: c - src: - - test/core/support/backoff_test.c - deps: - - gpr_test_util - - gpr - name: gpr_cmdline_test build: test language: c diff --git a/config.m4 b/config.m4 index e214f9c5464..37c641f4cef 100644 --- a/config.m4 +++ b/config.m4 @@ -39,13 +39,13 @@ if test "$PHP_GRPC" != "no"; then src/php/ext/grpc/server.c \ src/php/ext/grpc/server_credentials.c \ src/php/ext/grpc/timeval.c \ + src/core/lib/backoff/backoff.c \ src/core/lib/profiling/basic_timers.c \ src/core/lib/profiling/stap_timers.c \ src/core/lib/support/alloc.c \ src/core/lib/support/arena.c \ src/core/lib/support/atm.c \ src/core/lib/support/avl.c \ - src/core/lib/support/backoff.c \ src/core/lib/support/cmdline.c \ src/core/lib/support/cpu_iphone.c \ src/core/lib/support/cpu_linux.c \ @@ -677,6 +677,7 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/server/secure) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/transport) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/inproc) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/backoff) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/channel) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/compression) PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/debug) diff --git a/config.w32 b/config.w32 index 6d50712fb54..1d3b7b810a8 100644 --- a/config.w32 +++ b/config.w32 @@ -16,13 +16,13 @@ if (PHP_GRPC != "no") { "src\\php\\ext\\grpc\\server.c " + "src\\php\\ext\\grpc\\server_credentials.c " + "src\\php\\ext\\grpc\\timeval.c " + + "src\\core\\lib\\backoff\\backoff.c " + "src\\core\\lib\\profiling\\basic_timers.c " + "src\\core\\lib\\profiling\\stap_timers.c " + "src\\core\\lib\\support\\alloc.c " + "src\\core\\lib\\support\\arena.c " + "src\\core\\lib\\support\\atm.c " + "src\\core\\lib\\support\\avl.c " + - "src\\core\\lib\\support\\backoff.c " + "src\\core\\lib\\support\\cmdline.c " + "src\\core\\lib\\support\\cpu_iphone.c " + "src\\core\\lib\\support\\cpu_linux.c " + @@ -690,6 +690,7 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2\\transport"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\inproc"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\backoff"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\channel"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\compression"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\debug"); diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index cf3fc3598a2..5e1f663bb6e 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -180,12 +180,12 @@ Pod::Spec.new do |s| ss.dependency 'nanopb', '~> 0.3' # To save you from scrolling, this is the last part of the podspec. - ss.source_files = 'src/core/lib/profiling/timers.h', + ss.source_files = 'src/core/lib/backoff/backoff.h', + 'src/core/lib/profiling/timers.h', 'src/core/lib/support/arena.h', 'src/core/lib/support/atomic.h', 'src/core/lib/support/atomic_with_atm.h', 'src/core/lib/support/atomic_with_std.h', - 'src/core/lib/support/backoff.h', 'src/core/lib/support/block_annotate.h', 'src/core/lib/support/env.h', 'src/core/lib/support/memory.h', @@ -198,13 +198,13 @@ Pod::Spec.new do |s| 'src/core/lib/support/thd_internal.h', 'src/core/lib/support/time_precise.h', 'src/core/lib/support/tmpfile.h', + 'src/core/lib/backoff/backoff.c', 'src/core/lib/profiling/basic_timers.c', 'src/core/lib/profiling/stap_timers.c', 'src/core/lib/support/alloc.c', 'src/core/lib/support/arena.c', 'src/core/lib/support/atm.c', 'src/core/lib/support/avl.c', - 'src/core/lib/support/backoff.c', 'src/core/lib/support/cmdline.c', 'src/core/lib/support/cpu_iphone.c', 'src/core/lib/support/cpu_linux.c', @@ -708,12 +708,12 @@ Pod::Spec.new do |s| 'src/core/ext/filters/workarounds/workaround_utils.c', 'src/core/plugin_registry/grpc_plugin_registry.c' - ss.private_header_files = 'src/core/lib/profiling/timers.h', + ss.private_header_files = 'src/core/lib/backoff/backoff.h', + 'src/core/lib/profiling/timers.h', 'src/core/lib/support/arena.h', 'src/core/lib/support/atomic.h', 'src/core/lib/support/atomic_with_atm.h', 'src/core/lib/support/atomic_with_std.h', - 'src/core/lib/support/backoff.h', 'src/core/lib/support/block_annotate.h', 'src/core/lib/support/env.h', 'src/core/lib/support/memory.h', diff --git a/grpc.gemspec b/grpc.gemspec index a87c113b04b..45fed61c272 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -80,12 +80,12 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/impl/codegen/sync_generic.h ) s.files += %w( include/grpc/impl/codegen/sync_posix.h ) s.files += %w( include/grpc/impl/codegen/sync_windows.h ) + s.files += %w( src/core/lib/backoff/backoff.h ) s.files += %w( src/core/lib/profiling/timers.h ) s.files += %w( src/core/lib/support/arena.h ) s.files += %w( src/core/lib/support/atomic.h ) s.files += %w( src/core/lib/support/atomic_with_atm.h ) s.files += %w( src/core/lib/support/atomic_with_std.h ) - s.files += %w( src/core/lib/support/backoff.h ) s.files += %w( src/core/lib/support/block_annotate.h ) s.files += %w( src/core/lib/support/env.h ) s.files += %w( src/core/lib/support/memory.h ) @@ -98,13 +98,13 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/support/thd_internal.h ) s.files += %w( src/core/lib/support/time_precise.h ) s.files += %w( src/core/lib/support/tmpfile.h ) + s.files += %w( src/core/lib/backoff/backoff.c ) s.files += %w( src/core/lib/profiling/basic_timers.c ) s.files += %w( src/core/lib/profiling/stap_timers.c ) s.files += %w( src/core/lib/support/alloc.c ) s.files += %w( src/core/lib/support/arena.c ) s.files += %w( src/core/lib/support/atm.c ) s.files += %w( src/core/lib/support/avl.c ) - s.files += %w( src/core/lib/support/backoff.c ) s.files += %w( src/core/lib/support/cmdline.c ) s.files += %w( src/core/lib/support/cpu_iphone.c ) s.files += %w( src/core/lib/support/cpu_linux.c ) diff --git a/package.xml b/package.xml index 256a21d017b..0d5f49c889b 100644 --- a/package.xml +++ b/package.xml @@ -94,12 +94,12 @@ + - @@ -112,13 +112,13 @@ + - diff --git a/src/core/ext/filters/client_channel/channel_connectivity.c b/src/core/ext/filters/client_channel/channel_connectivity.c index 39dd927d705..72324d7eb1f 100644 --- a/src/core/ext/filters/client_channel/channel_connectivity.c +++ b/src/core/ext/filters/client_channel/channel_connectivity.c @@ -186,8 +186,7 @@ static void watcher_timer_init(grpc_exec_ctx *exec_ctx, void *arg, watcher_timer_init_arg *wa = (watcher_timer_init_arg *)arg; grpc_timer_init(exec_ctx, &wa->w->alarm, - grpc_timespec_to_millis(exec_ctx, wa->deadline), - &wa->w->on_timeout); + grpc_timespec_to_millis(wa->deadline), &wa->w->on_timeout); gpr_free(wa); } diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c index cccc3e871a6..c55fffee4d8 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c @@ -101,6 +101,7 @@ #include "src/core/ext/filters/client_channel/lb_policy_registry.h" #include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" +#include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/iomgr/combiner.h" @@ -110,7 +111,6 @@ #include "src/core/lib/slice/slice_hash_table.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_string_helpers.h" -#include "src/core/lib/support/backoff.h" #include "src/core/lib/support/string.h" #include "src/core/lib/surface/call.h" #include "src/core/lib/surface/channel.h" @@ -384,7 +384,7 @@ typedef struct glb_lb_policy { grpc_slice lb_call_status_details; /** LB call retry backoff state */ - gpr_backoff lb_call_backoff_state; + grpc_backoff lb_call_backoff_state; /** LB call retry timer */ grpc_timer lb_call_retry_timer; @@ -396,7 +396,7 @@ typedef struct glb_lb_policy { * recreated whenever lb_call is replaced. */ grpc_grpclb_client_stats *client_stats; /* Interval and timer for next client load report. */ - gpr_timespec client_stats_report_interval; + grpc_millis client_stats_report_interval; grpc_timer client_load_report_timer; bool client_load_report_timer_pending; bool last_client_load_report_counters_were_zero; @@ -1140,7 +1140,7 @@ static void query_for_backends_locked(grpc_exec_ctx *exec_ctx, static void start_picking_locked(grpc_exec_ctx *exec_ctx, glb_lb_policy *glb_policy) { glb_policy->started_picking = true; - gpr_backoff_reset(&glb_policy->lb_call_backoff_state); + grpc_backoff_reset(&glb_policy->lb_call_backoff_state); query_for_backends_locked(exec_ctx, glb_policy); } @@ -1245,15 +1245,14 @@ static void send_client_load_report_locked(grpc_exec_ctx *exec_ctx, void *arg, static void schedule_next_client_load_report(grpc_exec_ctx *exec_ctx, glb_lb_policy *glb_policy) { - const gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - const gpr_timespec next_client_load_report_time = - gpr_time_add(now, glb_policy->client_stats_report_interval); + const grpc_millis next_client_load_report_time = + grpc_exec_ctx_now(exec_ctx) + glb_policy->client_stats_report_interval; GRPC_CLOSURE_INIT(&glb_policy->client_load_report_closure, send_client_load_report_locked, glb_policy, grpc_combiner_scheduler(glb_policy->base.combiner)); grpc_timer_init(exec_ctx, &glb_policy->client_load_report_timer, next_client_load_report_time, - &glb_policy->client_load_report_closure, now); + &glb_policy->client_load_report_closure); } static void client_load_report_done_locked(grpc_exec_ctx *exec_ctx, void *arg, @@ -1392,12 +1391,12 @@ static void lb_call_init_locked(grpc_exec_ctx *exec_ctx, lb_on_response_received_locked, glb_policy, grpc_combiner_scheduler(glb_policy->base.combiner)); - gpr_backoff_init(&glb_policy->lb_call_backoff_state, - GRPC_GRPCLB_INITIAL_CONNECT_BACKOFF_SECONDS, - GRPC_GRPCLB_RECONNECT_BACKOFF_MULTIPLIER, - GRPC_GRPCLB_RECONNECT_JITTER, - GRPC_GRPCLB_MIN_CONNECT_TIMEOUT_SECONDS * 1000, - GRPC_GRPCLB_RECONNECT_MAX_BACKOFF_SECONDS * 1000); + grpc_backoff_init(&glb_policy->lb_call_backoff_state, + GRPC_GRPCLB_INITIAL_CONNECT_BACKOFF_SECONDS, + GRPC_GRPCLB_RECONNECT_BACKOFF_MULTIPLIER, + GRPC_GRPCLB_RECONNECT_JITTER, + GRPC_GRPCLB_MIN_CONNECT_TIMEOUT_SECONDS * 1000, + GRPC_GRPCLB_RECONNECT_MAX_BACKOFF_SECONDS * 1000); glb_policy->initial_request_sent = false; glb_policy->seen_initial_response = false; @@ -1522,7 +1521,7 @@ static void lb_on_response_received_locked(grpc_exec_ctx *exec_ctx, void *arg, memset(ops, 0, sizeof(ops)); grpc_op *op = ops; if (glb_policy->lb_response_payload != NULL) { - gpr_backoff_reset(&glb_policy->lb_call_backoff_state); + grpc_backoff_reset(&glb_policy->lb_call_backoff_state); /* Received data from the LB server. Look inside * glb_policy->lb_response_payload, for a serverlist. */ grpc_byte_buffer_reader bbr; @@ -1535,16 +1534,14 @@ static void lb_on_response_received_locked(grpc_exec_ctx *exec_ctx, void *arg, (response = grpc_grpclb_initial_response_parse(response_slice)) != NULL) { if (response->has_client_stats_report_interval) { - glb_policy->client_stats_report_interval = - gpr_time_max(gpr_time_from_seconds(1, GPR_TIMESPAN), - grpc_grpclb_duration_to_timespec( - &response->client_stats_report_interval)); + glb_policy->client_stats_report_interval = GPR_MAX( + GPR_MS_PER_SEC, grpc_grpclb_duration_to_millis( + &response->client_stats_report_interval)); if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { gpr_log(GPR_INFO, "received initial LB response message; " - "client load reporting interval = %" PRId64 ".%09d sec", - glb_policy->client_stats_report_interval.tv_sec, - glb_policy->client_stats_report_interval.tv_nsec); + "client load reporting interval = %" PRIdPTR " milliseconds", + glb_policy->client_stats_report_interval); } /* take a weak ref (won't prevent calling of \a glb_shutdown() if the * strong ref count goes to zero) to be unref'd in @@ -1675,17 +1672,16 @@ static void lb_on_server_status_received_locked(grpc_exec_ctx *exec_ctx, glb_policy->updating_lb_call = false; } else if (!glb_policy->shutting_down) { /* if we aren't shutting down, restart the LB client call after some time */ - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - gpr_timespec next_try = - gpr_backoff_step(&glb_policy->lb_call_backoff_state, now); + grpc_millis next_try = + grpc_backoff_step(exec_ctx, &glb_policy->lb_call_backoff_state); if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { gpr_log(GPR_DEBUG, "Connection to LB server lost (grpclb: %p)...", (void *)glb_policy); - gpr_timespec timeout = gpr_time_sub(next_try, now); - if (gpr_time_cmp(timeout, gpr_time_0(timeout.clock_type)) > 0) { + grpc_millis timeout = next_try - grpc_exec_ctx_now(exec_ctx); + if (timeout > 0) { gpr_log(GPR_DEBUG, - "... retry_timer_active in %" PRId64 ".%09d seconds.", - timeout.tv_sec, timeout.tv_nsec); + "... retry_timer_active in %" PRIdPTR " milliseconds.", + timeout); } else { gpr_log(GPR_DEBUG, "... retry_timer_active immediately."); } @@ -1696,7 +1692,7 @@ static void lb_on_server_status_received_locked(grpc_exec_ctx *exec_ctx, grpc_combiner_scheduler(glb_policy->base.combiner)); glb_policy->retry_timer_active = true; grpc_timer_init(exec_ctx, &glb_policy->lb_call_retry_timer, next_try, - &glb_policy->lb_on_call_retry, now); + &glb_policy->lb_on_call_retry); } GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base, "lb_on_server_status_received"); diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c index bec7c97a787..6bf93a42c26 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c @@ -258,13 +258,10 @@ int grpc_grpclb_duration_compare(const grpc_grpclb_duration *lhs, return 0; } -gpr_timespec grpc_grpclb_duration_to_timespec( - grpc_grpclb_duration *duration_pb) { - gpr_timespec duration; - duration.tv_sec = duration_pb->has_seconds ? duration_pb->seconds : 0; - duration.tv_nsec = duration_pb->has_nanos ? duration_pb->nanos : 0; - duration.clock_type = GPR_TIMESPAN; - return duration; +grpc_millis grpc_grpclb_duration_to_millis(grpc_grpclb_duration *duration_pb) { + return (duration_pb->has_seconds ? duration_pb->seconds : 0) * + GPR_MS_PER_SEC + + (duration_pb->has_nanos ? duration_pb->nanos : 0) / GPR_NS_PER_MS; } void grpc_grpclb_initial_response_destroy( diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h index ef8d563edcd..4f79629f124 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h @@ -81,8 +81,7 @@ void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist *serverlist); int grpc_grpclb_duration_compare(const grpc_grpclb_duration *lhs, const grpc_grpclb_duration *rhs); -gpr_timespec grpc_grpclb_duration_to_timespec( - grpc_grpclb_duration *duration_pb); +grpc_millis grpc_grpclb_duration_to_millis(grpc_grpclb_duration *duration_pb); /** Destroy \a initial_response */ void grpc_grpclb_initial_response_destroy( diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c index 04a7852323d..ad91b83c85e 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c @@ -29,11 +29,11 @@ #include "src/core/ext/filters/client_channel/lb_policy_registry.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" +#include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/timer.h" -#include "src/core/lib/support/backoff.h" #include "src/core/lib/support/env.h" #include "src/core/lib/support/string.h" @@ -81,7 +81,7 @@ typedef struct { bool have_retry_timer; grpc_timer retry_timer; /** retry backoff state */ - gpr_backoff backoff_state; + grpc_backoff backoff_state; /** currently resolving addresses */ grpc_lb_addresses *lb_addresses; @@ -127,7 +127,7 @@ static void dns_ares_channel_saw_error_locked(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver) { ares_dns_resolver *r = (ares_dns_resolver *)resolver; if (!r->resolving) { - gpr_backoff_reset(&r->backoff_state); + grpc_backoff_reset(&r->backoff_state); dns_ares_start_resolving_locked(exec_ctx, r); } } @@ -158,22 +158,20 @@ static void dns_ares_on_resolved_locked(grpc_exec_ctx *exec_ctx, void *arg, } else { const char *msg = grpc_error_string(error); gpr_log(GPR_DEBUG, "dns resolution failed: %s", msg); - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - gpr_timespec next_try = gpr_backoff_step(&r->backoff_state, now); - gpr_timespec timeout = gpr_time_sub(next_try, now); + grpc_millis next_try = grpc_backoff_step(exec_ctx, &r->backoff_state); + grpc_millis timeout = next_try - grpc_exec_ctx_now(exec_ctx); gpr_log(GPR_INFO, "dns resolution failed (will retry): %s", grpc_error_string(error)); GPR_ASSERT(!r->have_retry_timer); r->have_retry_timer = true; GRPC_RESOLVER_REF(&r->base, "retry-timer"); - if (gpr_time_cmp(timeout, gpr_time_0(timeout.clock_type)) > 0) { - gpr_log(GPR_DEBUG, "retrying in %" PRId64 ".%09d seconds", timeout.tv_sec, - timeout.tv_nsec); + if (timeout > 0) { + gpr_log(GPR_DEBUG, "retrying in %" PRIdPTR " milliseconds", timeout); } else { gpr_log(GPR_DEBUG, "retrying immediately"); } grpc_timer_init(exec_ctx, &r->retry_timer, next_try, - &r->dns_ares_on_retry_timer_locked, now); + &r->dns_ares_on_retry_timer_locked); } if (r->resolved_result != NULL) { grpc_channel_args_destroy(exec_ctx, r->resolved_result); @@ -194,7 +192,7 @@ static void dns_ares_next_locked(grpc_exec_ctx *exec_ctx, r->next_completion = on_complete; r->target_result = target_result; if (r->resolved_version == 0 && !r->resolving) { - gpr_backoff_reset(&r->backoff_state); + grpc_backoff_reset(&r->backoff_state); dns_ares_start_resolving_locked(exec_ctx, r); } else { dns_ares_maybe_finish_next_locked(exec_ctx, r); @@ -261,11 +259,11 @@ static grpc_resolver *dns_ares_create(grpc_exec_ctx *exec_ctx, grpc_pollset_set_add_pollset_set(exec_ctx, r->interested_parties, args->pollset_set); } - gpr_backoff_init(&r->backoff_state, GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS, - GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER, - GRPC_DNS_RECONNECT_JITTER, - GRPC_DNS_MIN_CONNECT_TIMEOUT_SECONDS * 1000, - GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS * 1000); + grpc_backoff_init(&r->backoff_state, GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS, + GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER, + GRPC_DNS_RECONNECT_JITTER, + GRPC_DNS_MIN_CONNECT_TIMEOUT_SECONDS * 1000, + GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS * 1000); GRPC_CLOSURE_INIT(&r->dns_ares_on_retry_timer_locked, dns_ares_on_retry_timer_locked, r, grpc_combiner_scheduler(r->base.combiner)); diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c index 5ea75f05549..7287a5dabce 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c @@ -24,11 +24,11 @@ #include "src/core/ext/filters/client_channel/lb_policy_registry.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" +#include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/timer.h" -#include "src/core/lib/support/backoff.h" #include "src/core/lib/support/env.h" #include "src/core/lib/support/string.h" @@ -67,7 +67,7 @@ typedef struct { grpc_timer retry_timer; grpc_closure on_retry; /** retry backoff state */ - gpr_backoff backoff_state; + grpc_backoff backoff_state; /** currently resolving addresses */ grpc_resolved_addresses *addresses; @@ -110,7 +110,7 @@ static void dns_channel_saw_error_locked(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver) { dns_resolver *r = (dns_resolver *)resolver; if (!r->resolving) { - gpr_backoff_reset(&r->backoff_state); + grpc_backoff_reset(&r->backoff_state); dns_start_resolving_locked(exec_ctx, r); } } @@ -123,7 +123,7 @@ static void dns_next_locked(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, r->next_completion = on_complete; r->target_result = target_result; if (r->resolved_version == 0 && !r->resolving) { - gpr_backoff_reset(&r->backoff_state); + grpc_backoff_reset(&r->backoff_state); dns_start_resolving_locked(exec_ctx, r); } else { dns_maybe_finish_next_locked(exec_ctx, r); @@ -164,23 +164,21 @@ static void dns_on_resolved_locked(grpc_exec_ctx *exec_ctx, void *arg, grpc_resolved_addresses_destroy(r->addresses); grpc_lb_addresses_destroy(exec_ctx, addresses); } else { - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - gpr_timespec next_try = gpr_backoff_step(&r->backoff_state, now); - gpr_timespec timeout = gpr_time_sub(next_try, now); + grpc_millis next_try = grpc_backoff_step(exec_ctx, &r->backoff_state); + grpc_millis timeout = next_try - grpc_exec_ctx_now(exec_ctx); gpr_log(GPR_INFO, "dns resolution failed (will retry): %s", grpc_error_string(error)); GPR_ASSERT(!r->have_retry_timer); r->have_retry_timer = true; GRPC_RESOLVER_REF(&r->base, "retry-timer"); - if (gpr_time_cmp(timeout, gpr_time_0(timeout.clock_type)) > 0) { - gpr_log(GPR_DEBUG, "retrying in %" PRId64 ".%09d seconds", timeout.tv_sec, - timeout.tv_nsec); + if (timeout > 0) { + gpr_log(GPR_DEBUG, "retrying in %" PRIdPTR " milliseconds", timeout); } else { gpr_log(GPR_DEBUG, "retrying immediately"); } GRPC_CLOSURE_INIT(&r->on_retry, dns_on_retry_timer_locked, r, grpc_combiner_scheduler(r->base.combiner)); - grpc_timer_init(exec_ctx, &r->retry_timer, next_try, &r->on_retry, now); + grpc_timer_init(exec_ctx, &r->retry_timer, next_try, &r->on_retry); } if (r->resolved_result != NULL) { grpc_channel_args_destroy(exec_ctx, r->resolved_result); @@ -251,11 +249,11 @@ static grpc_resolver *dns_create(grpc_exec_ctx *exec_ctx, grpc_pollset_set_add_pollset_set(exec_ctx, r->interested_parties, args->pollset_set); } - gpr_backoff_init(&r->backoff_state, GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS, - GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER, - GRPC_DNS_RECONNECT_JITTER, - GRPC_DNS_MIN_CONNECT_TIMEOUT_SECONDS * 1000, - GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS * 1000); + grpc_backoff_init(&r->backoff_state, GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS, + GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER, + GRPC_DNS_RECONNECT_JITTER, + GRPC_DNS_MIN_CONNECT_TIMEOUT_SECONDS * 1000, + GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS * 1000); return &r->base; } diff --git a/src/core/ext/filters/client_channel/subchannel.c b/src/core/ext/filters/client_channel/subchannel.c index bdaf567d6a2..22829c39b34 100644 --- a/src/core/ext/filters/client_channel/subchannel.c +++ b/src/core/ext/filters/client_channel/subchannel.c @@ -30,13 +30,13 @@ #include "src/core/ext/filters/client_channel/proxy_mapper_registry.h" #include "src/core/ext/filters/client_channel/subchannel_index.h" #include "src/core/ext/filters/client_channel/uri_parser.h" +#include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/profiling/timers.h" #include "src/core/lib/slice/slice_internal.h" -#include "src/core/lib/support/backoff.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/channel_init.h" #include "src/core/lib/transport/connectivity_state.h" @@ -118,7 +118,7 @@ struct grpc_subchannel { /** next connect attempt time */ grpc_millis next_attempt; /** backoff state */ - gpr_backoff backoff_state; + grpc_backoff backoff_state; /** do we have an active alarm? */ bool have_alarm; /** have we started the backoff loop */ @@ -363,7 +363,7 @@ grpc_subchannel *grpc_subchannel_create(grpc_exec_ctx *exec_ctx, } } } - gpr_backoff_init( + grpc_backoff_init( &c->backoff_state, initial_backoff_ms, fixed_reconnect_backoff ? 1.0 : GRPC_SUBCHANNEL_RECONNECT_BACKOFF_MULTIPLIER, @@ -427,8 +427,7 @@ static void on_alarm(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { } if (error == GRPC_ERROR_NONE) { gpr_log(GPR_INFO, "Failed to connect to channel, retrying"); - c->next_attempt = - gpr_backoff_step(&c->backoff_state, gpr_now(GPR_CLOCK_MONOTONIC)); + c->next_attempt = grpc_backoff_step(exec_ctx, &c->backoff_state); continue_connect_locked(exec_ctx, c); gpr_mu_unlock(&c->mu); } else { @@ -465,21 +464,20 @@ static void maybe_start_connecting_locked(grpc_exec_ctx *exec_ctx, if (!c->backoff_begun) { c->backoff_begun = true; - c->next_attempt = gpr_backoff_begin(&c->backoff_state, now); + c->next_attempt = grpc_backoff_begin(exec_ctx, &c->backoff_state); continue_connect_locked(exec_ctx, c); } else { GPR_ASSERT(!c->have_alarm); c->have_alarm = true; - gpr_timespec time_til_next = gpr_time_sub(c->next_attempt, now); - if (gpr_time_cmp(time_til_next, gpr_time_0(time_til_next.clock_type)) <= - 0) { + const grpc_millis time_til_next = + c->next_attempt - grpc_exec_ctx_now(exec_ctx); + if (time_til_next <= 0) { gpr_log(GPR_INFO, "Retry immediately"); } else { - gpr_log(GPR_INFO, "Retry in %" PRId64 ".%09d seconds", - time_til_next.tv_sec, time_til_next.tv_nsec); + gpr_log(GPR_INFO, "Retry in %" PRIdPTR " milliseconds", time_til_next); } GRPC_CLOSURE_INIT(&c->on_alarm, on_alarm, c, grpc_schedule_on_exec_ctx); - grpc_timer_init(exec_ctx, &c->alarm, c->next_attempt, &c->on_alarm, now); + grpc_timer_init(exec_ctx, &c->alarm, c->next_attempt, &c->on_alarm); } } diff --git a/src/core/ext/filters/deadline/deadline_filter.c b/src/core/ext/filters/deadline/deadline_filter.c index 6789903c95d..035f5abf3e3 100644 --- a/src/core/ext/filters/deadline/deadline_filter.c +++ b/src/core/ext/filters/deadline/deadline_filter.c @@ -53,8 +53,8 @@ static void timer_callback(grpc_exec_ctx* exec_ctx, void* arg, static void start_timer_if_needed(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, gpr_timespec deadline) { - deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC); - if (gpr_time_cmp(deadline, gpr_inf_future(GPR_CLOCK_MONOTONIC)) == 0) { + grpc_millis deadline_millis = grpc_timespec_to_millis(deadline); + if (deadline_millis == GRPC_MILLIS_INF_FUTURE) { return; } grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data; @@ -94,8 +94,7 @@ retry: } GPR_ASSERT(closure); GRPC_CALL_STACK_REF(deadline_state->call_stack, "deadline_timer"); - grpc_timer_init(exec_ctx, &deadline_state->timer, deadline, closure, - gpr_now(GPR_CLOCK_MONOTONIC)); + grpc_timer_init(exec_ctx, &deadline_state->timer, deadline_millis, closure); } // Cancels the deadline timer. diff --git a/src/core/ext/filters/max_age/max_age_filter.c b/src/core/ext/filters/max_age/max_age_filter.c index 7d748b9c320..14565fd5308 100644 --- a/src/core/ext/filters/max_age/max_age_filter.c +++ b/src/core/ext/filters/max_age/max_age_filter.c @@ -56,11 +56,11 @@ typedef struct channel_data { max_connection_idle */ grpc_timer max_idle_timer; /* Allowed max time a channel may have no outstanding rpcs */ - gpr_timespec max_connection_idle; + grpc_millis max_connection_idle; /* Allowed max time a channel may exist */ - gpr_timespec max_connection_age; + grpc_millis max_connection_age; /* Allowed grace period after the channel reaches its max age */ - gpr_timespec max_connection_age_grace; + grpc_millis max_connection_age_grace; /* Closure to run when the channel's idle duration reaches max_connection_idle and should be closed gracefully */ grpc_closure close_max_idle_channel; @@ -99,10 +99,9 @@ static void increase_call_count(grpc_exec_ctx* exec_ctx, channel_data* chand) { static void decrease_call_count(grpc_exec_ctx* exec_ctx, channel_data* chand) { if (gpr_atm_full_fetch_add(&chand->call_count, -1) == 1) { GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_idle_timer"); - grpc_timer_init( - exec_ctx, &chand->max_idle_timer, - gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), chand->max_connection_idle), - &chand->close_max_idle_channel, gpr_now(GPR_CLOCK_MONOTONIC)); + grpc_timer_init(exec_ctx, &chand->max_idle_timer, + grpc_exec_ctx_now(exec_ctx) + chand->max_connection_idle, + &chand->close_max_idle_channel); } } @@ -123,10 +122,9 @@ static void start_max_age_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg, gpr_mu_lock(&chand->max_age_timer_mu); chand->max_age_timer_pending = true; GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_age_timer"); - grpc_timer_init( - exec_ctx, &chand->max_age_timer, - gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), chand->max_connection_age), - &chand->close_max_age_channel, gpr_now(GPR_CLOCK_MONOTONIC)); + grpc_timer_init(exec_ctx, &chand->max_age_timer, + grpc_exec_ctx_now(exec_ctx) + chand->max_connection_age, + &chand->close_max_age_channel); gpr_mu_unlock(&chand->max_age_timer_mu); grpc_transport_op* op = grpc_make_transport_op(NULL); op->on_connectivity_state_change = &chand->channel_connectivity_changed, @@ -145,10 +143,8 @@ static void start_max_age_grace_timer_after_goaway_op(grpc_exec_ctx* exec_ctx, chand->max_age_grace_timer_pending = true; GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_age_grace_timer"); grpc_timer_init(exec_ctx, &chand->max_age_grace_timer, - gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - chand->max_connection_age_grace), - &chand->force_close_max_age_channel, - gpr_now(GPR_CLOCK_MONOTONIC)); + grpc_exec_ctx_now(exec_ctx) + chand->max_connection_age_grace, + &chand->force_close_max_age_channel); gpr_mu_unlock(&chand->max_age_timer_mu); GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack, "max_age start_max_age_grace_timer_after_goaway_op"); @@ -288,29 +284,23 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx, chand->channel_stack = args->channel_stack; chand->max_connection_age = DEFAULT_MAX_CONNECTION_AGE_MS == INT_MAX - ? gpr_inf_future(GPR_TIMESPAN) - : gpr_time_from_millis(add_random_max_connection_age_jitter( - DEFAULT_MAX_CONNECTION_AGE_MS), - GPR_TIMESPAN); + ? GRPC_MILLIS_INF_FUTURE + : add_random_max_connection_age_jitter(DEFAULT_MAX_CONNECTION_AGE_MS); chand->max_connection_age_grace = DEFAULT_MAX_CONNECTION_AGE_GRACE_MS == INT_MAX - ? gpr_inf_future(GPR_TIMESPAN) - : gpr_time_from_millis(DEFAULT_MAX_CONNECTION_AGE_GRACE_MS, - GPR_TIMESPAN); - chand->max_connection_idle = - DEFAULT_MAX_CONNECTION_IDLE_MS == INT_MAX - ? gpr_inf_future(GPR_TIMESPAN) - : gpr_time_from_millis(DEFAULT_MAX_CONNECTION_IDLE_MS, GPR_TIMESPAN); + ? GRPC_MILLIS_INF_FUTURE + : DEFAULT_MAX_CONNECTION_AGE_GRACE_MS; + chand->max_connection_idle = DEFAULT_MAX_CONNECTION_IDLE_MS == INT_MAX + ? GRPC_MILLIS_INF_FUTURE + : DEFAULT_MAX_CONNECTION_IDLE_MS; for (size_t i = 0; i < args->channel_args->num_args; ++i) { if (0 == strcmp(args->channel_args->args[i].key, GRPC_ARG_MAX_CONNECTION_AGE_MS)) { const int value = grpc_channel_arg_get_integer( &args->channel_args->args[i], MAX_CONNECTION_AGE_INTEGER_OPTIONS); chand->max_connection_age = - value == INT_MAX - ? gpr_inf_future(GPR_TIMESPAN) - : gpr_time_from_millis( - add_random_max_connection_age_jitter(value), GPR_TIMESPAN); + value == INT_MAX ? GRPC_MILLIS_INF_FUTURE + : add_random_max_connection_age_jitter(value); } else if (0 == strcmp(args->channel_args->args[i].key, GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS)) { const int value = grpc_channel_arg_get_integer( @@ -318,15 +308,13 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx, (grpc_integer_options){DEFAULT_MAX_CONNECTION_AGE_GRACE_MS, 0, INT_MAX}); chand->max_connection_age_grace = - value == INT_MAX ? gpr_inf_future(GPR_TIMESPAN) - : gpr_time_from_millis(value, GPR_TIMESPAN); + value == INT_MAX ? GRPC_MILLIS_INF_FUTURE : value; } else if (0 == strcmp(args->channel_args->args[i].key, GRPC_ARG_MAX_CONNECTION_IDLE_MS)) { const int value = grpc_channel_arg_get_integer( &args->channel_args->args[i], MAX_CONNECTION_IDLE_INTEGER_OPTIONS); chand->max_connection_idle = - value == INT_MAX ? gpr_inf_future(GPR_TIMESPAN) - : gpr_time_from_millis(value, GPR_TIMESPAN); + value == INT_MAX ? GRPC_MILLIS_INF_FUTURE : value; } } GRPC_CLOSURE_INIT(&chand->close_max_idle_channel, close_max_idle_channel, @@ -349,8 +337,7 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx, channel_connectivity_changed, chand, grpc_schedule_on_exec_ctx); - if (gpr_time_cmp(chand->max_connection_age, gpr_inf_future(GPR_TIMESPAN)) != - 0) { + if (chand->max_connection_age != GRPC_MILLIS_INF_FUTURE) { /* When the channel reaches its max age, we send down an op with goaway_error set. However, we can't send down any ops until after the channel stack is fully initialized. If we start the timer here, we have @@ -367,8 +354,7 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx, /* Initialize the number of calls as 1, so that the max_idle_timer will not start until start_max_idle_timer_after_init is invoked. */ gpr_atm_rel_store(&chand->call_count, 1); - if (gpr_time_cmp(chand->max_connection_idle, gpr_inf_future(GPR_TIMESPAN)) != - 0) { + if (chand->max_connection_idle != GRPC_MILLIS_INF_FUTURE) { GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age start_max_idle_timer_after_init"); GRPC_CLOSURE_SCHED(exec_ctx, &chand->start_max_idle_timer_after_init, diff --git a/src/core/lib/support/backoff.c b/src/core/lib/backoff/backoff.c similarity index 69% rename from src/core/lib/support/backoff.c rename to src/core/lib/backoff/backoff.c index 6dc0df473b5..141b952134f 100644 --- a/src/core/lib/support/backoff.c +++ b/src/core/lib/backoff/backoff.c @@ -16,13 +16,13 @@ * */ -#include "src/core/lib/support/backoff.h" +#include "src/core/lib/backoff/backoff.h" #include -void gpr_backoff_init(gpr_backoff *backoff, int64_t initial_connect_timeout, - double multiplier, double jitter, - int64_t min_timeout_millis, int64_t max_timeout_millis) { +void grpc_backoff_init(grpc_backoff *backoff, int64_t initial_connect_timeout, + double multiplier, double jitter, + int64_t min_timeout_millis, int64_t max_timeout_millis) { backoff->initial_connect_timeout = initial_connect_timeout; backoff->multiplier = multiplier; backoff->jitter = jitter; @@ -31,11 +31,11 @@ void gpr_backoff_init(gpr_backoff *backoff, int64_t initial_connect_timeout, backoff->rng_state = (uint32_t)gpr_now(GPR_CLOCK_REALTIME).tv_nsec; } -gpr_timespec gpr_backoff_begin(gpr_backoff *backoff, gpr_timespec now) { +grpc_millis grpc_backoff_begin(grpc_exec_ctx *exec_ctx, grpc_backoff *backoff) { backoff->current_timeout_millis = backoff->initial_connect_timeout; const int64_t first_timeout = GPR_MAX(backoff->current_timeout_millis, backoff->min_timeout_millis); - return gpr_time_add(now, gpr_time_from_millis(first_timeout, GPR_TIMESPAN)); + return grpc_exec_ctx_now(exec_ctx) + first_timeout; } /* Generate a random number between 0 and 1. */ @@ -44,7 +44,7 @@ static double generate_uniform_random_number(uint32_t *rng_state) { return *rng_state / (double)((uint32_t)1 << 31); } -gpr_timespec gpr_backoff_step(gpr_backoff *backoff, gpr_timespec now) { +grpc_millis grpc_backoff_step(grpc_exec_ctx *exec_ctx, grpc_backoff *backoff) { const double new_timeout_millis = backoff->multiplier * (double)backoff->current_timeout_millis; backoff->current_timeout_millis = @@ -58,15 +58,15 @@ gpr_timespec gpr_backoff_step(gpr_backoff *backoff, gpr_timespec now) { backoff->current_timeout_millis = (int64_t)((double)(backoff->current_timeout_millis) + jitter); - const gpr_timespec current_deadline = gpr_time_add( - now, gpr_time_from_millis(backoff->current_timeout_millis, GPR_TIMESPAN)); + const grpc_millis current_deadline = + grpc_exec_ctx_now(exec_ctx) + backoff->current_timeout_millis; - const gpr_timespec min_deadline = gpr_time_add( - now, gpr_time_from_millis(backoff->min_timeout_millis, GPR_TIMESPAN)); + const grpc_millis min_deadline = + grpc_exec_ctx_now(exec_ctx) + backoff->min_timeout_millis; - return gpr_time_max(current_deadline, min_deadline); + return GPR_MAX(current_deadline, min_deadline); } -void gpr_backoff_reset(gpr_backoff *backoff) { +void grpc_backoff_reset(grpc_backoff *backoff) { backoff->current_timeout_millis = backoff->initial_connect_timeout; } diff --git a/src/core/lib/support/backoff.h b/src/core/lib/backoff/backoff.h similarity index 72% rename from src/core/lib/support/backoff.h rename to src/core/lib/backoff/backoff.h index 6e0cc3a4b69..f1258bcdc5b 100644 --- a/src/core/lib/support/backoff.h +++ b/src/core/lib/backoff/backoff.h @@ -19,7 +19,7 @@ #ifndef GRPC_CORE_LIB_SUPPORT_BACKOFF_H #define GRPC_CORE_LIB_SUPPORT_BACKOFF_H -#include +#include "src/core/lib/iomgr/exec_ctx.h" typedef struct { /// const: how long to wait after the first failure before retrying @@ -38,19 +38,20 @@ typedef struct { /// current retry timeout in milliseconds int64_t current_timeout_millis; -} gpr_backoff; +} grpc_backoff; /// Initialize backoff machinery - does not need to be destroyed -void gpr_backoff_init(gpr_backoff *backoff, int64_t initial_connect_timeout, - double multiplier, double jitter, - int64_t min_timeout_millis, int64_t max_timeout_millis); +void grpc_backoff_init(grpc_backoff *backoff, int64_t initial_connect_timeout, + double multiplier, double jitter, + int64_t min_timeout_millis, int64_t max_timeout_millis); /// Begin retry loop: returns a timespec for the NEXT retry -gpr_timespec gpr_backoff_begin(gpr_backoff *backoff, gpr_timespec now); +grpc_millis grpc_backoff_begin(grpc_exec_ctx *exec_ctx, grpc_backoff *backoff); /// Step a retry loop: returns a timespec for the NEXT retry -gpr_timespec gpr_backoff_step(gpr_backoff *backoff, gpr_timespec now); -/// Reset the backoff, so the next gpr_backoff_step will be a gpr_backoff_begin +grpc_millis grpc_backoff_step(grpc_exec_ctx *exec_ctx, grpc_backoff *backoff); +/// Reset the backoff, so the next grpc_backoff_step will be a +/// grpc_backoff_begin /// instead -void gpr_backoff_reset(gpr_backoff *backoff); +void grpc_backoff_reset(grpc_backoff *backoff); #endif /* GRPC_CORE_LIB_SUPPORT_BACKOFF_H */ diff --git a/src/core/lib/iomgr/exec_ctx.c b/src/core/lib/iomgr/exec_ctx.c index 5d2fc4af868..80aaaee0cb6 100644 --- a/src/core/lib/iomgr/exec_ctx.c +++ b/src/core/lib/iomgr/exec_ctx.c @@ -137,13 +137,17 @@ void grpc_exec_ctx_invalidate_now(grpc_exec_ctx *exec_ctx) { exec_ctx->now_is_valid = false; } -gpr_timespec grpc_millis_to_timespec(grpc_exec_ctx *exec_ctx, - grpc_millis millis, +gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_clock_type clock_type) { return gpr_time_add(gpr_convert_clock_type(g_start_time, clock_type), gpr_time_from_millis(millis, GPR_TIMESPAN)); } +grpc_millis grpc_timespec_to_millis(gpr_timespec ts) { + return timespec_to_atm_round_down( + gpr_convert_clock_type(ts, g_start_time.clock_type)); +} + static const grpc_closure_scheduler_vtable exec_ctx_scheduler_vtable = { exec_ctx_run, exec_ctx_sched, "exec_ctx"}; static grpc_closure_scheduler exec_ctx_scheduler = {&exec_ctx_scheduler_vtable}; diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h index 8e030bf7418..87383809f3d 100644 --- a/src/core/lib/iomgr/exec_ctx.h +++ b/src/core/lib/iomgr/exec_ctx.h @@ -113,9 +113,7 @@ void grpc_exec_ctx_global_shutdown(void); grpc_millis grpc_exec_ctx_now(grpc_exec_ctx *exec_ctx); void grpc_exec_ctx_invalidate_now(grpc_exec_ctx *exec_ctx); -gpr_timespec grpc_millis_to_timespec(grpc_exec_ctx *exec_ctx, - grpc_millis millis, gpr_clock_type clock); -grpc_millis grpc_timespec_to_millis(grpc_exec_ctx *exec_ctx, - gpr_timespec timespec); +gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_clock_type clock); +grpc_millis grpc_timespec_to_millis(gpr_timespec timespec); #endif /* GRPC_CORE_LIB_IOMGR_EXEC_CTX_H */ diff --git a/src/core/lib/iomgr/timer_manager.c b/src/core/lib/iomgr/timer_manager.c index 751314c23f1..cd2a3a8c784 100644 --- a/src/core/lib/iomgr/timer_manager.c +++ b/src/core/lib/iomgr/timer_manager.c @@ -188,7 +188,7 @@ static bool wait_until(grpc_exec_ctx *exec_ctx, grpc_millis next) { } gpr_cv_wait(&g_cv_wait, &g_mu, - grpc_millis_to_timespec(exec_ctx, next, GPR_CLOCK_REALTIME)); + grpc_millis_to_timespec(next, GPR_CLOCK_REALTIME)); if (GRPC_TRACER_ON(grpc_timer_check_trace)) { gpr_log(GPR_DEBUG, "wait ended: was_timed:%d kicked:%d", diff --git a/src/core/lib/surface/alarm.c b/src/core/lib/surface/alarm.c index 911ac010e0f..5140780bacc 100644 --- a/src/core/lib/surface/alarm.c +++ b/src/core/lib/surface/alarm.c @@ -52,8 +52,7 @@ grpc_alarm *grpc_alarm_create(grpc_completion_queue *cq, gpr_timespec deadline, grpc_cq_begin_op(cq, tag); GRPC_CLOSURE_INIT(&alarm->on_alarm, alarm_cb, alarm, grpc_schedule_on_exec_ctx); - grpc_timer_init(&exec_ctx, &alarm->alarm, - grpc_timespec_to_millis(&exec_ctx, deadline), + grpc_timer_init(&exec_ctx, &alarm->alarm, grpc_timespec_to_millis(deadline), &alarm->on_alarm); grpc_exec_ctx_finish(&exec_ctx); return alarm; diff --git a/src/core/lib/surface/completion_queue.c b/src/core/lib/surface/completion_queue.c index cefa8a2a895..e0547415201 100644 --- a/src/core/lib/surface/completion_queue.c +++ b/src/core/lib/surface/completion_queue.c @@ -110,7 +110,7 @@ static grpc_error *non_polling_poller_work(grpc_exec_ctx *exec_ctx, } w.kicked = false; gpr_timespec deadline_ts = - grpc_millis_to_timespec(exec_ctx, deadline, GPR_CLOCK_REALTIME); + grpc_millis_to_timespec(deadline, GPR_CLOCK_REALTIME); while (!npp->shutdown && !w.kicked && !gpr_cv_wait(&w.cv, &npp->mu, deadline_ts)) ; @@ -815,18 +815,17 @@ static grpc_event cq_next(grpc_completion_queue *cq, gpr_timespec deadline, GRPC_CQ_INTERNAL_REF(cq, "next"); + grpc_millis deadline_millis = grpc_timespec_to_millis(deadline); cq_is_finished_arg is_finished_arg = { .last_seen_things_queued_ever = gpr_atm_no_barrier_load(&cqd->things_queued_ever), .cq = cq, - .deadline = 0, + .deadline = deadline_millis, .stolen_completion = NULL, .tag = NULL, .first_loop = true}; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INITIALIZER(0, cq_is_next_finished, &is_finished_arg); - grpc_millis deadline_millis = is_finished_arg.deadline = - grpc_timespec_to_millis(&exec_ctx, deadline); for (;;) { grpc_millis iteration_deadline = deadline_millis; @@ -1047,22 +1046,19 @@ static grpc_event cq_pluck(grpc_completion_queue *cq, void *tag, dump_pending_tags(cq); - deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC); - GRPC_CQ_INTERNAL_REF(cq, "pluck"); gpr_mu_lock(cq->mu); + grpc_millis deadline_millis = grpc_timespec_to_millis(deadline); cq_is_finished_arg is_finished_arg = { .last_seen_things_queued_ever = gpr_atm_no_barrier_load(&cqd->things_queued_ever), .cq = cq, - .deadline = 0, + .deadline = deadline_millis, .stolen_completion = NULL, .tag = tag, .first_loop = true}; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INITIALIZER(0, cq_is_pluck_finished, &is_finished_arg); - grpc_millis deadline_millis = is_finished_arg.deadline = - grpc_timespec_to_millis(&exec_ctx, deadline); for (;;) { if (is_finished_arg.stolen_completion != NULL) { gpr_mu_unlock(cq->mu); diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index e7f7332b995..56a72d7c8b0 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -15,13 +15,13 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_core_dependencies.py.template`!!! CORE_SOURCE_FILES = [ + 'src/core/lib/backoff/backoff.c', 'src/core/lib/profiling/basic_timers.c', 'src/core/lib/profiling/stap_timers.c', 'src/core/lib/support/alloc.c', 'src/core/lib/support/arena.c', 'src/core/lib/support/atm.c', 'src/core/lib/support/avl.c', - 'src/core/lib/support/backoff.c', 'src/core/lib/support/cmdline.c', 'src/core/lib/support/cpu_iphone.c', 'src/core/lib/support/cpu_linux.c', diff --git a/test/core/backoff/BUILD b/test/core/backoff/BUILD new file mode 100644 index 00000000000..6c2ceb499b7 --- /dev/null +++ b/test/core/backoff/BUILD @@ -0,0 +1,34 @@ +# Copyright 2016 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_cc_binary") + +licenses(["notice"]) # Apache v2 + +package( + features = [ + "-layering_check", + "-parse_headers", + ], +) + +grpc_cc_test( + name = "backoff_test", + srcs = ["backoff_test.c"], + language = "C", + deps = [ + "//:gpr", + "//test/core/util:gpr_test_util", + ], +) diff --git a/test/core/backoff/backoff_test.c b/test/core/backoff/backoff_test.c new file mode 100644 index 00000000000..302ac7b3a01 --- /dev/null +++ b/test/core/backoff/backoff_test.c @@ -0,0 +1,147 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "src/core/lib/backoff/backoff.h" + +#include + +#include "test/core/util/test_config.h" + +static void test_constant_backoff(void) { + grpc_backoff backoff; + grpc_backoff_init(&backoff, 200 /* initial timeout */, 1.0 /* multiplier */, + 0.0 /* jitter */, 100 /* min timeout */, + 1000 /* max timeout */); + + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_millis next = grpc_backoff_begin(&exec_ctx, &backoff); + GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 200); + for (int i = 0; i < 10000; i++) { + next = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 200); + exec_ctx.now = next; + } + grpc_exec_ctx_finish(&exec_ctx); +} + +static void test_min_connect(void) { + grpc_backoff backoff; + grpc_backoff_init(&backoff, 100 /* initial timeout */, 1.0 /* multiplier */, + 0.0 /* jitter */, 200 /* min timeout */, + 1000 /* max timeout */); + + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_millis next = grpc_backoff_begin(&exec_ctx, &backoff); + GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 200); + grpc_exec_ctx_finish(&exec_ctx); +} + +static void test_no_jitter_backoff(void) { + grpc_backoff backoff; + grpc_backoff_init(&backoff, 2 /* initial timeout */, 2.0 /* multiplier */, + 0.0 /* jitter */, 1 /* min timeout */, + 513 /* max timeout */); + // x_1 = 2 + // x_n = 2**i + x_{i-1} ( = 2**(n+1) - 2 ) + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_millis next = grpc_backoff_begin(&exec_ctx, &backoff); + GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 2); + exec_ctx.now = next; + next = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 6); + exec_ctx.now = next; + next = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 14); + exec_ctx.now = next; + next = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 30); + exec_ctx.now = next; + next = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 62); + exec_ctx.now = next; + next = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 126); + exec_ctx.now = next; + next = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 254); + exec_ctx.now = next; + next = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 510); + exec_ctx.now = next; + next = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 1022); + exec_ctx.now = next; + next = grpc_backoff_step(&exec_ctx, &backoff); + // Hit the maximum timeout. From this point onwards, retries will increase + // only by max timeout. + GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 1535); + exec_ctx.now = next; + next = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 2048); + exec_ctx.now = next; + next = grpc_backoff_step(&exec_ctx, &backoff); + GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 2561); + grpc_exec_ctx_finish(&exec_ctx); +} + +static void test_jitter_backoff(void) { + const int64_t initial_timeout = 500; + const double jitter = 0.1; + grpc_backoff backoff; + grpc_backoff_init(&backoff, initial_timeout, 1.0 /* multiplier */, jitter, + 100 /* min timeout */, 1000 /* max timeout */); + + backoff.rng_state = 0; // force consistent PRNG + + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_millis next = grpc_backoff_begin(&exec_ctx, &backoff); + GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 500); + + int64_t expected_next_lower_bound = + (int64_t)((double)initial_timeout * (1 - jitter)); + int64_t expected_next_upper_bound = + (int64_t)((double)initial_timeout * (1 + jitter)); + + for (int i = 0; i < 10000; i++) { + next = grpc_backoff_step(&exec_ctx, &backoff); + + // next-now must be within (jitter*100)% of the previous timeout. + const int64_t timeout_millis = next - grpc_exec_ctx_now(&exec_ctx); + GPR_ASSERT(timeout_millis >= expected_next_lower_bound); + GPR_ASSERT(timeout_millis <= expected_next_upper_bound); + + expected_next_lower_bound = + (int64_t)((double)timeout_millis * (1 - jitter)); + expected_next_upper_bound = + (int64_t)((double)timeout_millis * (1 + jitter)); + exec_ctx.now = next; + } + grpc_exec_ctx_finish(&exec_ctx); +} + +int main(int argc, char **argv) { + grpc_test_init(argc, argv); + gpr_time_init(); + + test_constant_backoff(); + test_min_connect(); + test_no_jitter_backoff(); + test_jitter_backoff(); + + return 0; +} diff --git a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c index 6e3d69c2653..d6713c51632 100644 --- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c +++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c @@ -105,7 +105,7 @@ static bool wait_loop(int deadline_seconds, gpr_event *ev) { deadline_seconds--; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_timer_check(&exec_ctx, gpr_now(GPR_CLOCK_MONOTONIC), NULL); + grpc_timer_check(&exec_ctx, NULL); grpc_exec_ctx_finish(&exec_ctx); } return false; diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index 281a1af20c3..4b1036b382c 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -406,10 +406,8 @@ void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr, r->addrs = addresses; r->lb_addrs = NULL; grpc_timer_init( - exec_ctx, &r->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_seconds(1, GPR_TIMESPAN)), - GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx), - gpr_now(GPR_CLOCK_MONOTONIC)); + exec_ctx, &r->timer, GPR_MS_PER_SEC + grpc_exec_ctx_now(exec_ctx), + GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx)); } grpc_ares_request *my_dns_lookup_ares( @@ -422,10 +420,8 @@ grpc_ares_request *my_dns_lookup_ares( r->addrs = NULL; r->lb_addrs = lb_addrs; grpc_timer_init( - exec_ctx, &r->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_seconds(1, GPR_TIMESPAN)), - GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx), - gpr_now(GPR_CLOCK_MONOTONIC)); + exec_ctx, &r->timer, GPR_MS_PER_SEC + grpc_exec_ctx_now(exec_ctx), + GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx)); return NULL; } @@ -485,10 +481,8 @@ static void sched_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure, fc->ep = ep; fc->deadline = deadline; grpc_timer_init( - exec_ctx, &fc->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_millis(1, GPR_TIMESPAN)), - GRPC_CLOSURE_CREATE(do_connect, fc, grpc_schedule_on_exec_ctx), - gpr_now(GPR_CLOCK_MONOTONIC)); + exec_ctx, &fc->timer, GPR_MS_PER_SEC + grpc_exec_ctx_now(exec_ctx), + GRPC_CLOSURE_CREATE(do_connect, fc, grpc_schedule_on_exec_ctx)); } static void my_tcp_client_connect(grpc_exec_ctx *exec_ctx, diff --git a/test/core/http/httpcli_test.c b/test/core/http/httpcli_test.c index b8b96d673ce..ea63cd1df83 100644 --- a/test/core/http/httpcli_test.c +++ b/test/core/http/httpcli_test.c @@ -35,8 +35,8 @@ static grpc_httpcli_context g_context; static gpr_mu *g_mu; static grpc_polling_entity g_pops; -static gpr_timespec n_seconds_time(int seconds) { - return grpc_timeout_seconds_to_deadline(seconds); +static grpc_millis n_seconds_time(int seconds) { + return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(seconds)); } static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { @@ -86,8 +86,7 @@ static void test_get(int port) { GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops), - &worker, gpr_now(GPR_CLOCK_MONOTONIC), - n_seconds_time(1)))); + &worker, n_seconds_time(1)))); gpr_mu_unlock(g_mu); grpc_exec_ctx_finish(&exec_ctx); gpr_mu_lock(g_mu); @@ -128,8 +127,7 @@ static void test_post(int port) { GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops), - &worker, gpr_now(GPR_CLOCK_MONOTONIC), - n_seconds_time(1)))); + &worker, n_seconds_time(1)))); gpr_mu_unlock(g_mu); grpc_exec_ctx_finish(&exec_ctx); gpr_mu_lock(g_mu); diff --git a/test/core/http/httpscli_test.c b/test/core/http/httpscli_test.c index a9d7abdcffd..6d575d683d2 100644 --- a/test/core/http/httpscli_test.c +++ b/test/core/http/httpscli_test.c @@ -35,8 +35,8 @@ static grpc_httpcli_context g_context; static gpr_mu *g_mu; static grpc_polling_entity g_pops; -static gpr_timespec n_seconds_time(int seconds) { - return grpc_timeout_seconds_to_deadline(seconds); +static grpc_millis n_seconds_time(int seconds) { + return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(seconds)); } static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { @@ -87,8 +87,7 @@ static void test_get(int port) { GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops), - &worker, gpr_now(GPR_CLOCK_MONOTONIC), - n_seconds_time(1)))); + &worker, n_seconds_time(1)))); gpr_mu_unlock(g_mu); grpc_exec_ctx_finish(&exec_ctx); gpr_mu_lock(g_mu); @@ -130,8 +129,7 @@ static void test_post(int port) { GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops), - &worker, gpr_now(GPR_CLOCK_MONOTONIC), - n_seconds_time(1)))); + &worker, n_seconds_time(1)))); gpr_mu_unlock(g_mu); grpc_exec_ctx_finish(&exec_ctx); gpr_mu_lock(g_mu); diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c index b7cbba63c13..e80dce01cf4 100644 --- a/test/core/iomgr/endpoint_tests.c +++ b/test/core/iomgr/endpoint_tests.c @@ -176,7 +176,7 @@ static void read_and_write_test(grpc_endpoint_test_config config, begin_test(config, "read_and_write_test", slice_size); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_millis deadline = - grpc_timespec_to_millis(&exec_ctx, grpc_timeout_seconds_to_deadline(20)); + grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(20)); gpr_log(GPR_DEBUG, "num_bytes=%" PRIuPTR " write_size=%" PRIuPTR " slice_size=%" PRIuPTR " shutdown=%d", num_bytes, write_size, slice_size, shutdown); @@ -261,7 +261,7 @@ static void wait_for_fail_count(grpc_exec_ctx *exec_ctx, int *fail_count, grpc_exec_ctx_flush(exec_ctx); gpr_mu_lock(g_mu); grpc_millis deadline = - grpc_timespec_to_millis(exec_ctx, grpc_timeout_seconds_to_deadline(10)); + grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(10)); while (grpc_exec_ctx_now(exec_ctx) < deadline && *fail_count < want_fail_count) { grpc_pollset_worker *worker = NULL; diff --git a/test/core/iomgr/fd_posix_test.c b/test/core/iomgr/fd_posix_test.c index 02596450d22..206d14424fd 100644 --- a/test/core/iomgr/fd_posix_test.c +++ b/test/core/iomgr/fd_posix_test.c @@ -249,10 +249,8 @@ static void server_wait_and_shutdown(server *sv) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_pollset_worker *worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( - "pollset_work", - grpc_pollset_work(&exec_ctx, g_pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), - gpr_inf_future(GPR_CLOCK_MONOTONIC)))); + "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, + GRPC_MILLIS_INF_FUTURE))); gpr_mu_unlock(g_mu); grpc_exec_ctx_finish(&exec_ctx); gpr_mu_lock(g_mu); @@ -367,10 +365,8 @@ static void client_wait_and_shutdown(client *cl) { grpc_pollset_worker *worker = NULL; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; GPR_ASSERT(GRPC_LOG_IF_ERROR( - "pollset_work", - grpc_pollset_work(&exec_ctx, g_pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), - gpr_inf_future(GPR_CLOCK_MONOTONIC)))); + "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, + GRPC_MILLIS_INF_FUTURE))); gpr_mu_unlock(g_mu); grpc_exec_ctx_finish(&exec_ctx); gpr_mu_lock(g_mu); @@ -473,10 +469,8 @@ static void test_grpc_fd_change(void) { while (a.cb_that_ran == NULL) { grpc_pollset_worker *worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( - "pollset_work", - grpc_pollset_work(&exec_ctx, g_pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), - gpr_inf_future(GPR_CLOCK_MONOTONIC)))); + "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, + GRPC_MILLIS_INF_FUTURE))); gpr_mu_unlock(g_mu); grpc_exec_ctx_finish(&exec_ctx); gpr_mu_lock(g_mu); @@ -499,10 +493,8 @@ static void test_grpc_fd_change(void) { while (b.cb_that_ran == NULL) { grpc_pollset_worker *worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( - "pollset_work", - grpc_pollset_work(&exec_ctx, g_pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), - gpr_inf_future(GPR_CLOCK_MONOTONIC)))); + "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, + GRPC_MILLIS_INF_FUTURE))); gpr_mu_unlock(g_mu); grpc_exec_ctx_finish(&exec_ctx); gpr_mu_lock(g_mu); diff --git a/test/core/iomgr/resolve_address_posix_test.c b/test/core/iomgr/resolve_address_posix_test.c index 9cc09ed5d3a..d9d200d2c4c 100644 --- a/test/core/iomgr/resolve_address_posix_test.c +++ b/test/core/iomgr/resolve_address_posix_test.c @@ -70,35 +70,32 @@ void args_finish(grpc_exec_ctx *exec_ctx, args_struct *args) { gpr_free(args->pollset); } -static gpr_timespec n_sec_deadline(int seconds) { - return gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_seconds(seconds, GPR_TIMESPAN)); +static grpc_millis n_sec_deadline(int seconds) { + return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(seconds)); } static void actually_poll(void *argsp) { args_struct *args = argsp; - gpr_timespec deadline = n_sec_deadline(10); + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_millis deadline = n_sec_deadline(10); while (true) { bool done = gpr_atm_acq_load(&args->done_atm) != 0; if (done) { break; } - gpr_timespec time_left = - gpr_time_sub(deadline, gpr_now(GPR_CLOCK_REALTIME)); - gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64 ".%09d", done, - time_left.tv_sec, time_left.tv_nsec); - GPR_ASSERT(gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)) >= 0); + grpc_millis time_left = deadline - grpc_exec_ctx_now(&exec_ctx); + gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left); + GPR_ASSERT(time_left >= 0); grpc_pollset_worker *worker = NULL; - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_mu_lock(args->mu); - GRPC_LOG_IF_ERROR( - "pollset_work", - grpc_pollset_work(&exec_ctx, args->pollset, &worker, - gpr_now(GPR_CLOCK_REALTIME), n_sec_deadline(1))); + GRPC_LOG_IF_ERROR("pollset_work", + grpc_pollset_work(&exec_ctx, args->pollset, &worker, + n_sec_deadline(1))); gpr_mu_unlock(args->mu); - grpc_exec_ctx_finish(&exec_ctx); + grpc_exec_ctx_flush(&exec_ctx); } gpr_event_set(&args->ev, (void *)1); + grpc_exec_ctx_finish(&exec_ctx); } static void poll_pollset_until_request_done(args_struct *args) { diff --git a/test/core/iomgr/resolve_address_test.c b/test/core/iomgr/resolve_address_test.c index cb156ee61e3..c6c53be5ca7 100644 --- a/test/core/iomgr/resolve_address_test.c +++ b/test/core/iomgr/resolve_address_test.c @@ -67,34 +67,31 @@ void args_finish(grpc_exec_ctx *exec_ctx, args_struct *args) { gpr_free(args->pollset); } -static gpr_timespec n_sec_deadline(int seconds) { - return gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_seconds(seconds, GPR_TIMESPAN)); +static grpc_millis n_sec_deadline(int seconds) { + return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(seconds)); } static void poll_pollset_until_request_done(args_struct *args) { - gpr_timespec deadline = n_sec_deadline(10); + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_millis deadline = n_sec_deadline(10); while (true) { bool done = gpr_atm_acq_load(&args->done_atm) != 0; if (done) { break; } - gpr_timespec time_left = - gpr_time_sub(deadline, gpr_now(GPR_CLOCK_REALTIME)); - gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64 ".%09d", done, - time_left.tv_sec, time_left.tv_nsec); - GPR_ASSERT(gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)) >= 0); + grpc_millis time_left = deadline - grpc_exec_ctx_now(&exec_ctx); + gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left); + GPR_ASSERT(time_left >= 0); grpc_pollset_worker *worker = NULL; - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_mu_lock(args->mu); - GRPC_LOG_IF_ERROR( - "pollset_work", - grpc_pollset_work(&exec_ctx, args->pollset, &worker, - gpr_now(GPR_CLOCK_REALTIME), n_sec_deadline(1))); + GRPC_LOG_IF_ERROR("pollset_work", + grpc_pollset_work(&exec_ctx, args->pollset, &worker, + n_sec_deadline(1))); gpr_mu_unlock(args->mu); - grpc_exec_ctx_finish(&exec_ctx); + grpc_exec_ctx_flush(&exec_ctx); } gpr_event_set(&args->ev, (void *)1); + grpc_exec_ctx_finish(&exec_ctx); } static void must_succeed(grpc_exec_ctx *exec_ctx, void *argsp, diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.c index 00ea495bbe3..69dc82f45e1 100644 --- a/test/core/iomgr/tcp_client_posix_test.c +++ b/test/core/iomgr/tcp_client_posix_test.c @@ -46,8 +46,8 @@ static grpc_pollset *g_pollset; static int g_connections_complete = 0; static grpc_endpoint *g_connecting = NULL; -static gpr_timespec test_deadline(void) { - return grpc_timeout_seconds_to_deadline(10); +static grpc_millis test_deadline(void) { + return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(10)); } static void finish_connection() { @@ -107,7 +107,7 @@ void test_succeeds(void) { (socklen_t *)&resolved_addr.len) == 0); GRPC_CLOSURE_INIT(&done, must_succeed, NULL, grpc_schedule_on_exec_ctx); grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, g_pollset_set, NULL, - &resolved_addr, gpr_inf_future(GPR_CLOCK_REALTIME)); + &resolved_addr, GRPC_MILLIS_INF_FUTURE); /* await the connection */ do { @@ -124,9 +124,9 @@ void test_succeeds(void) { grpc_pollset_worker *worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", - grpc_pollset_work(&exec_ctx, g_pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), - grpc_timeout_seconds_to_deadline(5)))); + grpc_pollset_work( + &exec_ctx, g_pollset, &worker, + grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(5))))); gpr_mu_unlock(g_mu); grpc_exec_ctx_flush(&exec_ctx); gpr_mu_lock(g_mu); @@ -157,25 +157,24 @@ void test_fails(void) { /* connect to a broken address */ GRPC_CLOSURE_INIT(&done, must_fail, NULL, grpc_schedule_on_exec_ctx); grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, g_pollset_set, NULL, - &resolved_addr, gpr_inf_future(GPR_CLOCK_REALTIME)); + &resolved_addr, GRPC_MILLIS_INF_FUTURE); gpr_mu_lock(g_mu); /* wait for the connection callback to finish */ while (g_connections_complete == connections_complete_before) { grpc_pollset_worker *worker = NULL; - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - gpr_timespec polling_deadline = test_deadline(); - switch (grpc_timer_check(&exec_ctx, now, &polling_deadline)) { + grpc_millis polling_deadline = test_deadline(); + switch (grpc_timer_check(&exec_ctx, &polling_deadline)) { case GRPC_TIMERS_FIRED: break; case GRPC_TIMERS_NOT_CHECKED: - polling_deadline = now; + polling_deadline = 0; /* fall through */ case GRPC_TIMERS_CHECKED_AND_EMPTY: GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, - now, polling_deadline))); + polling_deadline))); break; } gpr_mu_unlock(g_mu); diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c index c45068e7ec5..aa55b717255 100644 --- a/test/core/iomgr/tcp_posix_test.c +++ b/test/core/iomgr/tcp_posix_test.c @@ -161,7 +161,8 @@ static void read_test(size_t num_bytes, size_t slice_size) { grpc_endpoint *ep; struct read_socket_state state; size_t written_bytes; - gpr_timespec deadline = grpc_timeout_seconds_to_deadline(20); + grpc_millis deadline = + grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(20)); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_log(GPR_INFO, "Read test of size %" PRIuPTR ", slice size %" PRIuPTR, @@ -193,8 +194,7 @@ static void read_test(size_t num_bytes, size_t slice_size) { grpc_pollset_worker *worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", - grpc_pollset_work(&exec_ctx, g_pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), deadline))); + grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline))); gpr_mu_unlock(g_mu); grpc_exec_ctx_finish(&exec_ctx); gpr_mu_lock(g_mu); @@ -214,7 +214,8 @@ static void large_read_test(size_t slice_size) { grpc_endpoint *ep; struct read_socket_state state; ssize_t written_bytes; - gpr_timespec deadline = grpc_timeout_seconds_to_deadline(20); + grpc_millis deadline = + grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(20)); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_log(GPR_INFO, "Start large read test, slice size %" PRIuPTR, slice_size); @@ -245,8 +246,7 @@ static void large_read_test(size_t slice_size) { grpc_pollset_worker *worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", - grpc_pollset_work(&exec_ctx, g_pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), deadline))); + grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline))); gpr_mu_unlock(g_mu); grpc_exec_ctx_finish(&exec_ctx); gpr_mu_lock(g_mu); @@ -318,8 +318,8 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) { GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), - grpc_timeout_milliseconds_to_deadline(10)))); + grpc_timespec_to_millis( + grpc_timeout_milliseconds_to_deadline(10))))); gpr_mu_unlock(g_mu); grpc_exec_ctx_finish(&exec_ctx); do { @@ -352,7 +352,8 @@ static void write_test(size_t num_bytes, size_t slice_size) { uint8_t current_data = 0; grpc_slice_buffer outgoing; grpc_closure write_done_closure; - gpr_timespec deadline = grpc_timeout_seconds_to_deadline(20); + grpc_millis deadline = + grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(20)); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_log(GPR_INFO, @@ -389,8 +390,7 @@ static void write_test(size_t num_bytes, size_t slice_size) { } GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", - grpc_pollset_work(&exec_ctx, g_pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), deadline))); + grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline))); gpr_mu_unlock(g_mu); grpc_exec_ctx_finish(&exec_ctx); gpr_mu_lock(g_mu); @@ -418,7 +418,8 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) { struct read_socket_state state; size_t written_bytes; int fd; - gpr_timespec deadline = grpc_timeout_seconds_to_deadline(20); + grpc_millis deadline = + grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(20)); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_closure fd_released_cb; int fd_released_done = 0; @@ -456,8 +457,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) { grpc_pollset_worker *worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", - grpc_pollset_work(&exec_ctx, g_pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), deadline))); + grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline))); gpr_log(GPR_DEBUG, "wakeup: read=%" PRIdPTR " target=%" PRIdPTR, state.read_bytes, state.target_read_bytes); gpr_mu_unlock(g_mu); @@ -475,8 +475,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) { grpc_pollset_worker *worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", - grpc_pollset_work(&exec_ctx, g_pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), deadline))); + grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline))); gpr_log(GPR_DEBUG, "wakeup: fd_released_done=%d", fd_released_done); } gpr_mu_unlock(g_mu); diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.c index 2371721a608..13ff92cb5be 100644 --- a/test/core/iomgr/tcp_server_posix_test.c +++ b/test/core/iomgr/tcp_server_posix_test.c @@ -230,7 +230,8 @@ static void test_no_op_with_port_and_start(void) { static grpc_error *tcp_connect(grpc_exec_ctx *exec_ctx, const test_addr *remote, on_connect_result *result) { - gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10); + grpc_millis deadline = + grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(10)); int clifd; int nconnects_before; const struct sockaddr *remote_addr = @@ -253,11 +254,10 @@ static grpc_error *tcp_connect(grpc_exec_ctx *exec_ctx, const test_addr *remote, } gpr_log(GPR_DEBUG, "wait"); while (g_nconnects == nconnects_before && - gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0) { + deadline > grpc_exec_ctx_now(exec_ctx)) { grpc_pollset_worker *worker = NULL; grpc_error *err; - if ((err = grpc_pollset_work(exec_ctx, g_pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), deadline)) != + if ((err = grpc_pollset_work(exec_ctx, g_pollset, &worker, deadline)) != GRPC_ERROR_NONE) { gpr_mu_unlock(g_mu); close(clifd); diff --git a/test/core/iomgr/timer_list_test.c b/test/core/iomgr/timer_list_test.c index 5f8b01fdc46..c3d9f9d88d4 100644 --- a/test/core/iomgr/timer_list_test.c +++ b/test/core/iomgr/timer_list_test.c @@ -41,51 +41,45 @@ static void cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { } static void add_test(void) { - gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME); int i; grpc_timer timers[20]; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_log(GPR_INFO, "add_test"); - grpc_timer_list_init(start); + grpc_timer_list_init(&exec_ctx); grpc_timer_trace.value = 1; grpc_timer_check_trace.value = 1; memset(cb_called, 0, sizeof(cb_called)); + grpc_millis start = grpc_exec_ctx_now(&exec_ctx); + /* 10 ms timers. will expire in the current epoch */ for (i = 0; i < 10; i++) { - grpc_timer_init( - &exec_ctx, &timers[i], - gpr_time_add(start, gpr_time_from_millis(10, GPR_TIMESPAN)), - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)i, grpc_schedule_on_exec_ctx), - start); + grpc_timer_init(&exec_ctx, &timers[i], start + 10, + GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)i, + grpc_schedule_on_exec_ctx)); } /* 1010 ms timers. will expire in the next epoch */ for (i = 10; i < 20; i++) { - grpc_timer_init( - &exec_ctx, &timers[i], - gpr_time_add(start, gpr_time_from_millis(1010, GPR_TIMESPAN)), - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)i, grpc_schedule_on_exec_ctx), - start); + grpc_timer_init(&exec_ctx, &timers[i], start + 1010, + GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)i, + grpc_schedule_on_exec_ctx)); } /* collect timers. Only the first batch should be ready. */ - GPR_ASSERT(grpc_timer_check( - &exec_ctx, - gpr_time_add(start, gpr_time_from_millis(500, GPR_TIMESPAN)), - NULL) == GRPC_TIMERS_FIRED); + exec_ctx.now = start + 500; + GPR_ASSERT(grpc_timer_check(&exec_ctx, NULL) == GRPC_TIMERS_FIRED); grpc_exec_ctx_finish(&exec_ctx); for (i = 0; i < 20; i++) { GPR_ASSERT(cb_called[i][1] == (i < 10)); GPR_ASSERT(cb_called[i][0] == 0); } - GPR_ASSERT(grpc_timer_check( - &exec_ctx, - gpr_time_add(start, gpr_time_from_millis(600, GPR_TIMESPAN)), - NULL) == GRPC_TIMERS_CHECKED_AND_EMPTY); + exec_ctx.now = start + 600; + GPR_ASSERT(grpc_timer_check(&exec_ctx, NULL) == + GRPC_TIMERS_CHECKED_AND_EMPTY); grpc_exec_ctx_finish(&exec_ctx); for (i = 0; i < 30; i++) { GPR_ASSERT(cb_called[i][1] == (i < 10)); @@ -93,20 +87,17 @@ static void add_test(void) { } /* collect the rest of the timers */ - GPR_ASSERT(grpc_timer_check( - &exec_ctx, - gpr_time_add(start, gpr_time_from_millis(1500, GPR_TIMESPAN)), - NULL) == GRPC_TIMERS_FIRED); + exec_ctx.now = start + 1500; + GPR_ASSERT(grpc_timer_check(&exec_ctx, NULL) == GRPC_TIMERS_FIRED); grpc_exec_ctx_finish(&exec_ctx); for (i = 0; i < 30; i++) { GPR_ASSERT(cb_called[i][1] == (i < 20)); GPR_ASSERT(cb_called[i][0] == 0); } - GPR_ASSERT(grpc_timer_check( - &exec_ctx, - gpr_time_add(start, gpr_time_from_millis(1600, GPR_TIMESPAN)), - NULL) == GRPC_TIMERS_CHECKED_AND_EMPTY); + exec_ctx.now = start + 1600; + GPR_ASSERT(grpc_timer_check(&exec_ctx, NULL) == + GRPC_TIMERS_CHECKED_AND_EMPTY); for (i = 0; i < 30; i++) { GPR_ASSERT(cb_called[i][1] == (i < 20)); GPR_ASSERT(cb_called[i][0] == 0); @@ -116,10 +107,6 @@ static void add_test(void) { grpc_exec_ctx_finish(&exec_ctx); } -static gpr_timespec tfm(int m) { - return gpr_time_from_millis(m, GPR_CLOCK_REALTIME); -} - /* Cleaning up a list with pending timers. */ void destruction_test(void) { grpc_timer timers[5]; @@ -127,32 +114,30 @@ void destruction_test(void) { gpr_log(GPR_INFO, "destruction_test"); - grpc_timer_list_init(gpr_time_0(GPR_CLOCK_REALTIME)); + exec_ctx.now_is_valid = true; + exec_ctx.now = 0; + grpc_timer_list_init(&exec_ctx); grpc_timer_trace.value = 1; grpc_timer_check_trace.value = 1; memset(cb_called, 0, sizeof(cb_called)); grpc_timer_init( - &exec_ctx, &timers[0], tfm(100), - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)0, grpc_schedule_on_exec_ctx), - gpr_time_0(GPR_CLOCK_REALTIME)); + &exec_ctx, &timers[0], 100, + GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)0, grpc_schedule_on_exec_ctx)); grpc_timer_init( - &exec_ctx, &timers[1], tfm(3), - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)1, grpc_schedule_on_exec_ctx), - gpr_time_0(GPR_CLOCK_REALTIME)); + &exec_ctx, &timers[1], 3, + GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)1, grpc_schedule_on_exec_ctx)); grpc_timer_init( - &exec_ctx, &timers[2], tfm(100), - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)2, grpc_schedule_on_exec_ctx), - gpr_time_0(GPR_CLOCK_REALTIME)); + &exec_ctx, &timers[2], 100, + GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)2, grpc_schedule_on_exec_ctx)); grpc_timer_init( - &exec_ctx, &timers[3], tfm(3), - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)3, grpc_schedule_on_exec_ctx), - gpr_time_0(GPR_CLOCK_REALTIME)); + &exec_ctx, &timers[3], 3, + GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)3, grpc_schedule_on_exec_ctx)); grpc_timer_init( - &exec_ctx, &timers[4], tfm(1), - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)4, grpc_schedule_on_exec_ctx), - gpr_time_0(GPR_CLOCK_REALTIME)); - GPR_ASSERT(grpc_timer_check(&exec_ctx, tfm(2), NULL) == GRPC_TIMERS_FIRED); + &exec_ctx, &timers[4], 1, + GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)4, grpc_schedule_on_exec_ctx)); + exec_ctx.now = 2; + GPR_ASSERT(grpc_timer_check(&exec_ctx, NULL) == GRPC_TIMERS_FIRED); grpc_exec_ctx_finish(&exec_ctx); GPR_ASSERT(1 == cb_called[4][1]); grpc_timer_cancel(&exec_ctx, &timers[0]); diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c index aa34857dbd1..2f6f5034434 100644 --- a/test/core/iomgr/udp_server_test.c +++ b/test/core/iomgr/udp_server_test.c @@ -226,7 +226,7 @@ static void test_receive(int number_of_clients) { grpc_udp_server *s = grpc_udp_server_create(NULL); int i; int number_of_reads_before; - gpr_timespec deadline; + grpc_millis deadline; grpc_pollset *pollsets[1]; LOG_TEST("test_receive"); gpr_log(GPR_INFO, "clients=%d", number_of_clients); @@ -252,7 +252,7 @@ static void test_receive(int number_of_clients) { gpr_mu_lock(g_mu); for (i = 0; i < number_of_clients; i++) { - deadline = grpc_timeout_seconds_to_deadline(10); + deadline = grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(10)); number_of_reads_before = g_number_of_reads; /* Create a socket, send a packet to the UDP server. */ @@ -262,14 +262,13 @@ static void test_receive(int number_of_clients) { (socklen_t)resolved_addr.len) == 0); GPR_ASSERT(5 == write(clifd, "hello", 5)); while (g_number_of_reads == number_of_reads_before && - gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0) { + deadline > grpc_exec_ctx_now(&exec_ctx)) { grpc_pollset_worker *worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", - grpc_pollset_work(&exec_ctx, g_pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), deadline))); + grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline))); gpr_mu_unlock(g_mu); - grpc_exec_ctx_finish(&exec_ctx); + grpc_exec_ctx_flush(&exec_ctx); gpr_mu_lock(g_mu); } GPR_ASSERT(g_number_of_reads == number_of_reads_before + 1); diff --git a/test/core/security/credentials_test.c b/test/core/security/credentials_test.c index a76cb0499d8..bc63221b0cd 100644 --- a/test/core/security/credentials_test.c +++ b/test/core/security/credentials_test.c @@ -233,14 +233,13 @@ static void test_add_abunch_to_md_store(void) { static void test_oauth2_token_fetcher_creds_parsing_ok(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_credentials_md_store *token_md = NULL; - gpr_timespec token_lifetime; + grpc_millis token_lifetime; grpc_httpcli_response response = http_response(200, valid_oauth2_json_response); GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response( &exec_ctx, &response, &token_md, &token_lifetime) == GRPC_CREDENTIALS_OK); - GPR_ASSERT(token_lifetime.tv_sec == 3599); - GPR_ASSERT(token_lifetime.tv_nsec == 0); + GPR_ASSERT(token_lifetime == 3599 * GPR_MS_PER_SEC); GPR_ASSERT(token_md->num_entries == 1); GPR_ASSERT(grpc_slice_str_cmp(token_md->entries[0].key, "authorization") == 0); @@ -255,7 +254,7 @@ static void test_oauth2_token_fetcher_creds_parsing_ok(void) { static void test_oauth2_token_fetcher_creds_parsing_bad_http_status(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_credentials_md_store *token_md = NULL; - gpr_timespec token_lifetime; + grpc_millis token_lifetime; grpc_httpcli_response response = http_response(401, valid_oauth2_json_response); GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response( @@ -268,7 +267,7 @@ static void test_oauth2_token_fetcher_creds_parsing_bad_http_status(void) { static void test_oauth2_token_fetcher_creds_parsing_empty_http_body(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_credentials_md_store *token_md = NULL; - gpr_timespec token_lifetime; + grpc_millis token_lifetime; grpc_httpcli_response response = http_response(200, ""); GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response( &exec_ctx, &response, &token_md, &token_lifetime) == @@ -280,7 +279,7 @@ static void test_oauth2_token_fetcher_creds_parsing_empty_http_body(void) { static void test_oauth2_token_fetcher_creds_parsing_invalid_json(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_credentials_md_store *token_md = NULL; - gpr_timespec token_lifetime; + grpc_millis token_lifetime; grpc_httpcli_response response = http_response(200, "{\"access_token\":\"ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_\"," @@ -296,7 +295,7 @@ static void test_oauth2_token_fetcher_creds_parsing_invalid_json(void) { static void test_oauth2_token_fetcher_creds_parsing_missing_token(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_credentials_md_store *token_md = NULL; - gpr_timespec token_lifetime; + grpc_millis token_lifetime; grpc_httpcli_response response = http_response(200, "{" " \"expires_in\":3599, " @@ -311,7 +310,7 @@ static void test_oauth2_token_fetcher_creds_parsing_missing_token(void) { static void test_oauth2_token_fetcher_creds_parsing_missing_token_type(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_credentials_md_store *token_md = NULL; - gpr_timespec token_lifetime; + grpc_millis token_lifetime; grpc_httpcli_response response = http_response(200, "{\"access_token\":\"ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_\"," @@ -328,7 +327,7 @@ static void test_oauth2_token_fetcher_creds_parsing_missing_token_lifetime( void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_credentials_md_store *token_md = NULL; - gpr_timespec token_lifetime; + grpc_millis token_lifetime; grpc_httpcli_response response = http_response(200, "{\"access_token\":\"ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_\"," @@ -579,7 +578,7 @@ static void validate_compute_engine_http_request( static int compute_engine_httpcli_get_success_override( grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - gpr_timespec deadline, grpc_closure *on_done, + grpc_millis deadline, grpc_closure *on_done, grpc_httpcli_response *response) { validate_compute_engine_http_request(request); *response = http_response(200, valid_oauth2_json_response); @@ -589,7 +588,7 @@ static int compute_engine_httpcli_get_success_override( static int compute_engine_httpcli_get_failure_override( grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - gpr_timespec deadline, grpc_closure *on_done, + grpc_millis deadline, grpc_closure *on_done, grpc_httpcli_response *response) { validate_compute_engine_http_request(request); *response = http_response(403, "Not Authorized."); @@ -599,7 +598,7 @@ static int compute_engine_httpcli_get_failure_override( static int httpcli_post_should_not_be_called( grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - const char *body_bytes, size_t body_size, gpr_timespec deadline, + const char *body_bytes, size_t body_size, grpc_millis deadline, grpc_closure *on_done, grpc_httpcli_response *response) { GPR_ASSERT("HTTP POST should not be called" == NULL); return 1; @@ -607,7 +606,7 @@ static int httpcli_post_should_not_be_called( static int httpcli_get_should_not_be_called(grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - gpr_timespec deadline, + grpc_millis deadline, grpc_closure *on_done, grpc_httpcli_response *response) { GPR_ASSERT("HTTP GET should not be called" == NULL); @@ -682,7 +681,7 @@ static void validate_refresh_token_http_request( static int refresh_token_httpcli_post_success( grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - const char *body, size_t body_size, gpr_timespec deadline, + const char *body, size_t body_size, grpc_millis deadline, grpc_closure *on_done, grpc_httpcli_response *response) { validate_refresh_token_http_request(request, body, body_size); *response = http_response(200, valid_oauth2_json_response); @@ -692,7 +691,7 @@ static int refresh_token_httpcli_post_success( static int refresh_token_httpcli_post_failure( grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - const char *body, size_t body_size, gpr_timespec deadline, + const char *body, size_t body_size, grpc_millis deadline, grpc_closure *on_done, grpc_httpcli_response *response) { validate_refresh_token_http_request(request, body, body_size); *response = http_response(403, "Not Authorized."); @@ -968,7 +967,7 @@ static void test_google_default_creds_refresh_token(void) { static int default_creds_gce_detection_httpcli_get_success_override( grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - gpr_timespec deadline, grpc_closure *on_done, + grpc_millis deadline, grpc_closure *on_done, grpc_httpcli_response *response) { *response = http_response(200, ""); grpc_http_header *headers = gpr_malloc(sizeof(*headers) * 1); @@ -1030,7 +1029,7 @@ static void test_google_default_creds_gce(void) { static int default_creds_gce_detection_httpcli_get_failure_override( grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - gpr_timespec deadline, grpc_closure *on_done, + grpc_millis deadline, grpc_closure *on_done, grpc_httpcli_response *response) { /* No magic header. */ GPR_ASSERT(strcmp(request->http.path, "/") == 0); diff --git a/test/core/security/jwt_verifier_test.c b/test/core/security/jwt_verifier_test.c index 9b17fb516d0..a4bfe0130ee 100644 --- a/test/core/security/jwt_verifier_test.c +++ b/test/core/security/jwt_verifier_test.c @@ -324,7 +324,7 @@ static grpc_httpcli_response http_response(int status, char *body) { static int httpcli_post_should_not_be_called( grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - const char *body_bytes, size_t body_size, gpr_timespec deadline, + const char *body_bytes, size_t body_size, grpc_millis deadline, grpc_closure *on_done, grpc_httpcli_response *response) { GPR_ASSERT("HTTP POST should not be called" == NULL); return 1; @@ -332,7 +332,7 @@ static int httpcli_post_should_not_be_called( static int httpcli_get_google_keys_for_email( grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - gpr_timespec deadline, grpc_closure *on_done, + grpc_millis deadline, grpc_closure *on_done, grpc_httpcli_response *response) { *response = http_response(200, good_google_email_keys()); GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl); @@ -379,7 +379,7 @@ static void test_jwt_verifier_google_email_issuer_success(void) { static int httpcli_get_custom_keys_for_email( grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - gpr_timespec deadline, grpc_closure *on_done, + grpc_millis deadline, grpc_closure *on_done, grpc_httpcli_response *response) { *response = http_response(200, gpr_strdup(good_jwk_set)); GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl); @@ -413,7 +413,7 @@ static void test_jwt_verifier_custom_email_issuer_success(void) { static int httpcli_get_jwk_set(grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - gpr_timespec deadline, grpc_closure *on_done, + grpc_millis deadline, grpc_closure *on_done, grpc_httpcli_response *response) { *response = http_response(200, gpr_strdup(good_jwk_set)); GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl); @@ -425,7 +425,7 @@ static int httpcli_get_jwk_set(grpc_exec_ctx *exec_ctx, static int httpcli_get_openid_config(grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - gpr_timespec deadline, + grpc_millis deadline, grpc_closure *on_done, grpc_httpcli_response *response) { *response = http_response(200, gpr_strdup(good_openid_config)); @@ -471,7 +471,7 @@ static void on_verification_key_retrieval_error(grpc_exec_ctx *exec_ctx, static int httpcli_get_bad_json(grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - gpr_timespec deadline, grpc_closure *on_done, + grpc_millis deadline, grpc_closure *on_done, grpc_httpcli_response *response) { *response = http_response(200, gpr_strdup("{\"bad\": \"stuff\"}")); GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl); @@ -581,7 +581,7 @@ static void test_jwt_verifier_bad_signature(void) { static int httpcli_get_should_not_be_called(grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, - gpr_timespec deadline, + grpc_millis deadline, grpc_closure *on_done, grpc_httpcli_response *response) { GPR_ASSERT(0); diff --git a/test/core/security/ssl_server_fuzzer.c b/test/core/security/ssl_server_fuzzer.c index 9858b11c7c3..f9b754b8f21 100644 --- a/test/core/security/ssl_server_fuzzer.c +++ b/test/core/security/ssl_server_fuzzer.c @@ -84,8 +84,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_security_status status = grpc_server_credentials_create_security_connector(&exec_ctx, creds, &sc); GPR_ASSERT(status == GRPC_SECURITY_OK); - gpr_timespec deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_seconds(1, GPR_TIMESPAN)); + grpc_millis deadline = GPR_MS_PER_SEC + grpc_exec_ctx_now(&exec_ctx); struct handshake_state state; state.done_callback_called = false; diff --git a/test/core/support/BUILD b/test/core/support/BUILD index 7e142c1e3fc..7420f37ae8b 100644 --- a/test/core/support/BUILD +++ b/test/core/support/BUILD @@ -43,16 +43,6 @@ grpc_cc_test( ], ) -grpc_cc_test( - name = "backoff_test", - srcs = ["backoff_test.c"], - language = "C", - deps = [ - "//:gpr", - "//test/core/util:gpr_test_util", - ], -) - grpc_cc_test( name = "cmdline_test", srcs = ["cmdline_test.c"], diff --git a/test/core/support/backoff_test.c b/test/core/support/backoff_test.c deleted file mode 100644 index 23e3005af0a..00000000000 --- a/test/core/support/backoff_test.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "src/core/lib/support/backoff.h" - -#include - -#include "test/core/util/test_config.h" - -static void test_constant_backoff(void) { - gpr_backoff backoff; - gpr_backoff_init(&backoff, 200 /* initial timeout */, 1.0 /* multiplier */, - 0.0 /* jitter */, 100 /* min timeout */, - 1000 /* max timeout */); - - gpr_timespec now = gpr_time_0(GPR_TIMESPAN); - gpr_timespec next = gpr_backoff_begin(&backoff, now); - GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 200); - for (int i = 0; i < 10000; i++) { - next = gpr_backoff_step(&backoff, now); - GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 200); - now = next; - } -} - -static void test_min_connect(void) { - gpr_backoff backoff; - gpr_backoff_init(&backoff, 100 /* initial timeout */, 1.0 /* multiplier */, - 0.0 /* jitter */, 200 /* min timeout */, - 1000 /* max timeout */); - - gpr_timespec now = gpr_time_0(GPR_TIMESPAN); - gpr_timespec next = gpr_backoff_begin(&backoff, now); - GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 200); -} - -static void test_no_jitter_backoff(void) { - gpr_backoff backoff; - gpr_backoff_init(&backoff, 2 /* initial timeout */, 2.0 /* multiplier */, - 0.0 /* jitter */, 1 /* min timeout */, - 513 /* max timeout */); - // x_1 = 2 - // x_n = 2**i + x_{i-1} ( = 2**(n+1) - 2 ) - gpr_timespec now = gpr_time_0(GPR_TIMESPAN); - gpr_timespec next = gpr_backoff_begin(&backoff, now); - GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(2, GPR_TIMESPAN), next) == 0); - now = next; - next = gpr_backoff_step(&backoff, now); - GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(6, GPR_TIMESPAN), next) == 0); - now = next; - next = gpr_backoff_step(&backoff, now); - GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(14, GPR_TIMESPAN), next) == 0); - now = next; - next = gpr_backoff_step(&backoff, now); - GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(30, GPR_TIMESPAN), next) == 0); - now = next; - next = gpr_backoff_step(&backoff, now); - GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(62, GPR_TIMESPAN), next) == 0); - now = next; - next = gpr_backoff_step(&backoff, now); - GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(126, GPR_TIMESPAN), next) == 0); - now = next; - next = gpr_backoff_step(&backoff, now); - GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(254, GPR_TIMESPAN), next) == 0); - now = next; - next = gpr_backoff_step(&backoff, now); - GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(510, GPR_TIMESPAN), next) == 0); - now = next; - next = gpr_backoff_step(&backoff, now); - GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(1022, GPR_TIMESPAN), next) == 0); - now = next; - next = gpr_backoff_step(&backoff, now); - // Hit the maximum timeout. From this point onwards, retries will increase - // only by max timeout. - GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(1535, GPR_TIMESPAN), next) == 0); - now = next; - next = gpr_backoff_step(&backoff, now); - GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(2048, GPR_TIMESPAN), next) == 0); - now = next; - next = gpr_backoff_step(&backoff, now); - GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(2561, GPR_TIMESPAN), next) == 0); -} - -static void test_jitter_backoff(void) { - const int64_t initial_timeout = 500; - const double jitter = 0.1; - gpr_backoff backoff; - gpr_backoff_init(&backoff, initial_timeout, 1.0 /* multiplier */, jitter, - 100 /* min timeout */, 1000 /* max timeout */); - - backoff.rng_state = 0; // force consistent PRNG - - gpr_timespec now = gpr_time_0(GPR_TIMESPAN); - gpr_timespec next = gpr_backoff_begin(&backoff, now); - GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 500); - - int64_t expected_next_lower_bound = - (int64_t)((double)initial_timeout * (1 - jitter)); - int64_t expected_next_upper_bound = - (int64_t)((double)initial_timeout * (1 + jitter)); - - for (int i = 0; i < 10000; i++) { - next = gpr_backoff_step(&backoff, now); - - // next-now must be within (jitter*100)% of the previous timeout. - const int64_t timeout_millis = gpr_time_to_millis(gpr_time_sub(next, now)); - GPR_ASSERT(timeout_millis >= expected_next_lower_bound); - GPR_ASSERT(timeout_millis <= expected_next_upper_bound); - - expected_next_lower_bound = - (int64_t)((double)timeout_millis * (1 - jitter)); - expected_next_upper_bound = - (int64_t)((double)timeout_millis * (1 + jitter)); - now = next; - } -} - -int main(int argc, char **argv) { - grpc_test_init(argc, argv); - gpr_time_init(); - - test_constant_backoff(); - test_min_connect(); - test_no_jitter_backoff(); - test_jitter_backoff(); - - return 0; -} diff --git a/test/core/surface/concurrent_connectivity_test.c b/test/core/surface/concurrent_connectivity_test.c index 08079b6091a..1778054e746 100644 --- a/test/core/surface/concurrent_connectivity_test.c +++ b/test/core/surface/concurrent_connectivity_test.c @@ -134,14 +134,12 @@ void bad_server_thread(void *vargs) { gpr_mu_lock(args->mu); while (gpr_atm_acq_load(&args->stop) == 0) { - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - gpr_timespec deadline = - gpr_time_add(now, gpr_time_from_millis(100, GPR_TIMESPAN)); + grpc_millis deadline = grpc_exec_ctx_now(&exec_ctx) + 100; grpc_pollset_worker *worker = NULL; - if (!GRPC_LOG_IF_ERROR("pollset_work", - grpc_pollset_work(&exec_ctx, args->pollset, &worker, - now, deadline))) { + if (!GRPC_LOG_IF_ERROR( + "pollset_work", + grpc_pollset_work(&exec_ctx, args->pollset, &worker, deadline))) { gpr_atm_rel_store(&args->stop, 1); } gpr_mu_unlock(args->mu); diff --git a/test/core/util/test_tcp_server.c b/test/core/util/test_tcp_server.c index cf21ec50ae8..ce05833aa9a 100644 --- a/test/core/util/test_tcp_server.c +++ b/test/core/util/test_tcp_server.c @@ -80,8 +80,8 @@ void test_tcp_server_start(test_tcp_server *server, int port) { void test_tcp_server_poll(test_tcp_server *server, int seconds) { grpc_pollset_worker *worker = NULL; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_millis deadline = grpc_timespec_to_millis( - &exec_ctx, grpc_timeout_seconds_to_deadline(seconds)); + grpc_millis deadline = + grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(seconds)); gpr_mu_lock(server->mu); GRPC_LOG_IF_ERROR( "pollset_work", diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 7c1e75a99cd..cb625e2a8ec 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1051,6 +1051,8 @@ src/core/ext/transport/inproc/inproc_plugin.c \ src/core/ext/transport/inproc/inproc_transport.c \ src/core/ext/transport/inproc/inproc_transport.h \ src/core/lib/README.md \ +src/core/lib/backoff/backoff.c \ +src/core/lib/backoff/backoff.h \ src/core/lib/channel/README.md \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_args.h \ @@ -1284,8 +1286,6 @@ src/core/lib/support/atomic.h \ src/core/lib/support/atomic_with_atm.h \ src/core/lib/support/atomic_with_std.h \ src/core/lib/support/avl.c \ -src/core/lib/support/backoff.c \ -src/core/lib/support/backoff.h \ src/core/lib/support/block_annotate.h \ src/core/lib/support/cmdline.c \ src/core/lib/support/cpu_iphone.c \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index c7cc9cb6945..589cafa29b4 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -99,6 +99,23 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "gpr_test_util", + "grpc", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c", + "name": "backoff_test", + "src": [ + "test/core/backoff/backoff_test.c" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", @@ -692,21 +709,6 @@ "third_party": false, "type": "target" }, - { - "deps": [ - "gpr", - "gpr_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "gpr_backoff_test", - "src": [ - "test/core/support/backoff_test.c" - ], - "third_party": false, - "type": "target" - }, { "deps": [ "gpr", @@ -7510,12 +7512,12 @@ "include/grpc/support/tls_msvc.h", "include/grpc/support/tls_pthread.h", "include/grpc/support/useful.h", + "src/core/lib/backoff/backoff.h", "src/core/lib/profiling/timers.h", "src/core/lib/support/arena.h", "src/core/lib/support/atomic.h", "src/core/lib/support/atomic_with_atm.h", "src/core/lib/support/atomic_with_std.h", - "src/core/lib/support/backoff.h", "src/core/lib/support/block_annotate.h", "src/core/lib/support/env.h", "src/core/lib/support/memory.h", @@ -7559,6 +7561,8 @@ "include/grpc/support/tls_msvc.h", "include/grpc/support/tls_pthread.h", "include/grpc/support/useful.h", + "src/core/lib/backoff/backoff.c", + "src/core/lib/backoff/backoff.h", "src/core/lib/profiling/basic_timers.c", "src/core/lib/profiling/stap_timers.c", "src/core/lib/profiling/timers.h", @@ -7570,8 +7574,6 @@ "src/core/lib/support/atomic_with_atm.h", "src/core/lib/support/atomic_with_std.h", "src/core/lib/support/avl.c", - "src/core/lib/support/backoff.c", - "src/core/lib/support/backoff.h", "src/core/lib/support/block_annotate.h", "src/core/lib/support/cmdline.c", "src/core/lib/support/cpu_iphone.c", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index d24209506a7..72a5f3be3f4 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -111,6 +111,28 @@ "windows" ] }, + { + "args": [], + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": false, + "language": "c", + "name": "backoff_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ] + }, { "args": [], "ci_platforms": [ @@ -749,28 +771,6 @@ "windows" ] }, - { - "args": [], - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": false, - "language": "c", - "name": "gpr_backoff_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ] - }, { "args": [], "ci_platforms": [ diff --git a/vsprojects/buildtests_c.sln b/vsprojects/buildtests_c.sln index 55de734b427..17a1302a896 100644 --- a/vsprojects/buildtests_c.sln +++ b/vsprojects/buildtests_c.sln @@ -54,6 +54,17 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "arena_test", "vcxproj\test\ {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "backoff_test", "vcxproj\test\backoff_test\backoff_test.vcxproj", "{F0B4300E-693E-CAD6-E6DD-7DEBD136C202}" + ProjectSection(myProperties) = preProject + lib = "False" + EndProjectSection + ProjectSection(ProjectDependencies) = postProject + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} = {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} + {29D16885-7228-4C31-81ED-5F9187C7F2A9} = {29D16885-7228-4C31-81ED-5F9187C7F2A9} + {EAB0A629-17A9-44DB-B5FF-E91A721FE037} = {EAB0A629-17A9-44DB-B5FF-E91A721FE037} + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} + EndProjectSection +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bad_client_test", "vcxproj\test/bad_client\bad_client_test\bad_client_test.vcxproj", "{BA67B418-B699-E41A-9CC4-0279C49481A5}" ProjectSection(myProperties) = preProject lib = "True" @@ -403,15 +414,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr_avl_test", "vcxproj\tes {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr_backoff_test", "vcxproj\test\gpr_backoff_test\gpr_backoff_test.vcxproj", "{889F570D-E046-BD52-9E4C-B4CD13DFE2DB}" - ProjectSection(myProperties) = preProject - lib = "False" - EndProjectSection - ProjectSection(ProjectDependencies) = postProject - {EAB0A629-17A9-44DB-B5FF-E91A721FE037} = {EAB0A629-17A9-44DB-B5FF-E91A721FE037} - {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr_cmdline_test", "vcxproj\test\gpr_cmdline_test\gpr_cmdline_test.vcxproj", "{10668A5D-65CD-F530-22D0-747B395B4C26}" ProjectSection(myProperties) = preProject lib = "False" @@ -1844,6 +1846,22 @@ Global {D85AC722-A88F-4280-F62E-672F571787FF}.Release-DLL|Win32.Build.0 = Release|Win32 {D85AC722-A88F-4280-F62E-672F571787FF}.Release-DLL|x64.ActiveCfg = Release|x64 {D85AC722-A88F-4280-F62E-672F571787FF}.Release-DLL|x64.Build.0 = Release|x64 + {F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Debug|Win32.ActiveCfg = Debug|Win32 + {F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Debug|x64.ActiveCfg = Debug|x64 + {F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Release|Win32.ActiveCfg = Release|Win32 + {F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Release|x64.ActiveCfg = Release|x64 + {F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Debug|Win32.Build.0 = Debug|Win32 + {F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Debug|x64.Build.0 = Debug|x64 + {F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Release|Win32.Build.0 = Release|Win32 + {F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Release|x64.Build.0 = Release|x64 + {F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Debug-DLL|Win32.ActiveCfg = Debug|Win32 + {F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Debug-DLL|Win32.Build.0 = Debug|Win32 + {F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Debug-DLL|x64.ActiveCfg = Debug|x64 + {F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Debug-DLL|x64.Build.0 = Debug|x64 + {F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Release-DLL|Win32.ActiveCfg = Release|Win32 + {F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Release-DLL|Win32.Build.0 = Release|Win32 + {F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Release-DLL|x64.ActiveCfg = Release|x64 + {F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Release-DLL|x64.Build.0 = Release|x64 {BA67B418-B699-E41A-9CC4-0279C49481A5}.Debug|Win32.ActiveCfg = Debug|Win32 {BA67B418-B699-E41A-9CC4-0279C49481A5}.Debug|x64.ActiveCfg = Debug|x64 {BA67B418-B699-E41A-9CC4-0279C49481A5}.Release|Win32.ActiveCfg = Release|Win32 @@ -2388,22 +2406,6 @@ Global {144D8CFF-2737-A18A-DCFD-01603533D63F}.Release-DLL|Win32.Build.0 = Release|Win32 {144D8CFF-2737-A18A-DCFD-01603533D63F}.Release-DLL|x64.ActiveCfg = Release|x64 {144D8CFF-2737-A18A-DCFD-01603533D63F}.Release-DLL|x64.Build.0 = Release|x64 - {889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Debug|Win32.ActiveCfg = Debug|Win32 - {889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Debug|x64.ActiveCfg = Debug|x64 - {889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Release|Win32.ActiveCfg = Release|Win32 - {889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Release|x64.ActiveCfg = Release|x64 - {889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Debug|Win32.Build.0 = Debug|Win32 - {889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Debug|x64.Build.0 = Debug|x64 - {889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Release|Win32.Build.0 = Release|Win32 - {889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Release|x64.Build.0 = Release|x64 - {889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Debug-DLL|Win32.ActiveCfg = Debug|Win32 - {889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Debug-DLL|Win32.Build.0 = Debug|Win32 - {889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Debug-DLL|x64.ActiveCfg = Debug|x64 - {889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Debug-DLL|x64.Build.0 = Debug|x64 - {889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Release-DLL|Win32.ActiveCfg = Release|Win32 - {889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Release-DLL|Win32.Build.0 = Release|Win32 - {889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Release-DLL|x64.ActiveCfg = Release|x64 - {889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Release-DLL|x64.Build.0 = Release|x64 {10668A5D-65CD-F530-22D0-747B395B4C26}.Debug|Win32.ActiveCfg = Debug|Win32 {10668A5D-65CD-F530-22D0-747B395B4C26}.Debug|x64.ActiveCfg = Debug|x64 {10668A5D-65CD-F530-22D0-747B395B4C26}.Release|Win32.ActiveCfg = Release|Win32 diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj b/vsprojects/vcxproj/gpr/gpr.vcxproj index 7fb81a7fbca..2386fddd02a 100644 --- a/vsprojects/vcxproj/gpr/gpr.vcxproj +++ b/vsprojects/vcxproj/gpr/gpr.vcxproj @@ -186,12 +186,12 @@ + - @@ -206,6 +206,8 @@ + + @@ -218,8 +220,6 @@ - - diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters index 27d9d2f38f4..c5fce455f4b 100644 --- a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters +++ b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters @@ -1,6 +1,9 @@ + + src\core\lib\backoff + src\core\lib\profiling @@ -19,9 +22,6 @@ src\core\lib\support - - src\core\lib\support - src\core\lib\support @@ -254,6 +254,9 @@ + + src\core\lib\backoff + src\core\lib\profiling @@ -269,9 +272,6 @@ src\core\lib\support - - src\core\lib\support - src\core\lib\support @@ -335,6 +335,9 @@ {52037bcb-5719-a548-224d-834fbe569045} + + {5a917a34-e4b4-01c0-4565-2be560176bec} + {ba38d79d-d5de-a89e-9ca2-c5235a03ca7f} diff --git a/vsprojects/vcxproj/test/gpr_backoff_test/gpr_backoff_test.vcxproj b/vsprojects/vcxproj/test/backoff_test/backoff_test.vcxproj similarity index 95% rename from vsprojects/vcxproj/test/gpr_backoff_test/gpr_backoff_test.vcxproj rename to vsprojects/vcxproj/test/backoff_test/backoff_test.vcxproj index 6aa292ef4f5..22ba2f7d0a1 100644 --- a/vsprojects/vcxproj/test/gpr_backoff_test/gpr_backoff_test.vcxproj +++ b/vsprojects/vcxproj/test/backoff_test/backoff_test.vcxproj @@ -20,7 +20,7 @@ - {889F570D-E046-BD52-9E4C-B4CD13DFE2DB} + {F0B4300E-693E-CAD6-E6DD-7DEBD136C202} true $(SolutionDir)IntDir\$(MSBuildProjectName)\ @@ -60,14 +60,14 @@ - gpr_backoff_test + backoff_test static Debug static Debug - gpr_backoff_test + backoff_test static Release static @@ -158,10 +158,16 @@ - + + + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} + + + {29D16885-7228-4C31-81ED-5F9187C7F2A9} + {EAB0A629-17A9-44DB-B5FF-E91A721FE037} diff --git a/vsprojects/vcxproj/test/gpr_backoff_test/gpr_backoff_test.vcxproj.filters b/vsprojects/vcxproj/test/backoff_test/backoff_test.vcxproj.filters similarity index 53% rename from vsprojects/vcxproj/test/gpr_backoff_test/gpr_backoff_test.vcxproj.filters rename to vsprojects/vcxproj/test/backoff_test/backoff_test.vcxproj.filters index eb3c1bbd8c2..c2189ddd962 100644 --- a/vsprojects/vcxproj/test/gpr_backoff_test/gpr_backoff_test.vcxproj.filters +++ b/vsprojects/vcxproj/test/backoff_test/backoff_test.vcxproj.filters @@ -1,20 +1,20 @@ - - test\core\support + + test\core\backoff - {4b7f1d25-d344-0bcb-63d8-2ba959874ea8} + {05e21e2a-bc8e-8c99-d00c-486e055f3b4a} - {2bd2fba5-8799-2c78-469f-ec3ba6b01da8} + {42a371ec-543d-205f-0fbc-7ba3d2b2deca} - - {2ef0cfa7-fe3d-2b82-7d0e-f9e293e8f98c} + + {467ad11c-0245-020b-4558-5b324ac725be} From 781e91a3e9ea2daf94a3a759bb61a28f66136f3d Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 17 Jul 2017 16:21:00 -0700 Subject: [PATCH 006/142] Add invalidate_now calls --- src/core/lib/iomgr/ev_epoll1_linux.c | 2 +- src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c | 2 +- src/core/lib/iomgr/ev_epoll_thread_pool_linux.c | 2 +- src/core/lib/iomgr/ev_epollex_linux.c | 2 +- src/core/lib/iomgr/ev_epollsig_linux.c | 2 +- src/core/lib/iomgr/ev_poll_posix.c | 2 +- src/core/lib/iomgr/load_file.c | 2 +- src/core/lib/iomgr/resolve_address_posix.c | 4 ++-- src/core/lib/iomgr/resolve_address_windows.c | 2 +- src/core/lib/support/block_annotate.h | 8 ++++++-- src/core/lib/support/time_posix.c | 2 +- src/core/lib/support/time_windows.c | 2 +- 12 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/core/lib/iomgr/ev_epoll1_linux.c b/src/core/lib/iomgr/ev_epoll1_linux.c index 66ba601adb9..b52e6ee9ecb 100644 --- a/src/core/lib/iomgr/ev_epoll1_linux.c +++ b/src/core/lib/iomgr/ev_epoll1_linux.c @@ -477,7 +477,7 @@ static grpc_error *pollset_epoll(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, r = epoll_wait(g_epfd, events, MAX_EPOLL_EVENTS, timeout); } while (r < 0 && errno == EINTR); if (timeout != 0) { - GRPC_SCHEDULING_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(exec_ctx); } if (r < 0) return GRPC_OS_ERROR(errno, "epoll_wait"); diff --git a/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c b/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c index 9f82c480bc4..57baef16ec1 100644 --- a/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +++ b/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c @@ -1309,7 +1309,7 @@ static bool acquire_polling_lease(grpc_pollset_worker *worker, struct timespec sigwait_timeout = millis_to_timespec(timeout_ms); GRPC_SCHEDULING_START_BLOCKING_REGION; ret = sigtimedwait(&g_wakeup_sig_set, NULL, &sigwait_timeout); - GRPC_SCHEDULING_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(exec_ctx); } if (ret == -1) { diff --git a/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c b/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c index 49be72c03e0..0daa49727c4 100644 --- a/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +++ b/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c @@ -778,7 +778,7 @@ static void do_epoll_wait(grpc_exec_ctx *exec_ctx, int epoll_fd, epoll_set *eps, acquire_epoll_lease(eps); ep_rv = epoll_wait(epoll_fd, ep_ev, GRPC_EPOLL_MAX_EVENTS, timeout_ms); release_epoll_lease(eps); - GRPC_SCHEDULING_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(exec_ctx); if (ep_rv < 0) { gpr_asprintf(&err_msg, diff --git a/src/core/lib/iomgr/ev_epollex_linux.c b/src/core/lib/iomgr/ev_epollex_linux.c index 56904317592..416ef8c16b0 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.c +++ b/src/core/lib/iomgr/ev_epollex_linux.c @@ -817,7 +817,7 @@ static grpc_error *pollset_epoll(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, r = epoll_wait(p->epfd, pollset->events, MAX_EPOLL_EVENTS, timeout); } while (r < 0 && errno == EINTR); if (timeout != 0) { - GRPC_SCHEDULING_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(exec_ctx); } if (r < 0) return GRPC_OS_ERROR(errno, "epoll_wait"); diff --git a/src/core/lib/iomgr/ev_epollsig_linux.c b/src/core/lib/iomgr/ev_epollsig_linux.c index 3c4ca9c7c59..a2130a3f786 100644 --- a/src/core/lib/iomgr/ev_epollsig_linux.c +++ b/src/core/lib/iomgr/ev_epollsig_linux.c @@ -1240,7 +1240,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx, GRPC_SCHEDULING_START_BLOCKING_REGION; ep_rv = epoll_pwait(epoll_fd, ep_ev, GRPC_EPOLL_MAX_EVENTS, timeout_ms, sig_mask); - GRPC_SCHEDULING_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(exec_ctx); if (ep_rv < 0) { if (errno != EINTR) { gpr_asprintf(&err_msg, diff --git a/src/core/lib/iomgr/ev_poll_posix.c b/src/core/lib/iomgr/ev_poll_posix.c index 4dc22fbcea5..e7cdfc18603 100644 --- a/src/core/lib/iomgr/ev_poll_posix.c +++ b/src/core/lib/iomgr/ev_poll_posix.c @@ -960,7 +960,7 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, even going into the blocking annotation if possible */ GRPC_SCHEDULING_START_BLOCKING_REGION; r = grpc_poll_function(pfds, pfd_count, timeout); - GRPC_SCHEDULING_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(exec_ctx); if (r < 0) { if (errno != EINTR) { diff --git a/src/core/lib/iomgr/load_file.c b/src/core/lib/iomgr/load_file.c index ba77a52afce..a8c0fa13390 100644 --- a/src/core/lib/iomgr/load_file.c +++ b/src/core/lib/iomgr/load_file.c @@ -72,6 +72,6 @@ end: GRPC_ERROR_UNREF(error); error = error_out; } - GRPC_SCHEDULING_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX; return error; } diff --git a/src/core/lib/iomgr/resolve_address_posix.c b/src/core/lib/iomgr/resolve_address_posix.c index 35dedc23de3..160235ca99d 100644 --- a/src/core/lib/iomgr/resolve_address_posix.c +++ b/src/core/lib/iomgr/resolve_address_posix.c @@ -81,7 +81,7 @@ static grpc_error *blocking_resolve_address_impl( GRPC_SCHEDULING_START_BLOCKING_REGION; s = getaddrinfo(host, port, &hints, &result); - GRPC_SCHEDULING_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX; if (s != 0) { /* Retry if well-known service name is recognized */ @@ -90,7 +90,7 @@ static grpc_error *blocking_resolve_address_impl( if (strcmp(port, svc[i][0]) == 0) { GRPC_SCHEDULING_START_BLOCKING_REGION; s = getaddrinfo(host, svc[i][1], &hints, &result); - GRPC_SCHEDULING_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX; break; } } diff --git a/src/core/lib/iomgr/resolve_address_windows.c b/src/core/lib/iomgr/resolve_address_windows.c index 45cfd7248d5..c5d8dd9893e 100644 --- a/src/core/lib/iomgr/resolve_address_windows.c +++ b/src/core/lib/iomgr/resolve_address_windows.c @@ -86,7 +86,7 @@ static grpc_error *blocking_resolve_address_impl( GRPC_SCHEDULING_START_BLOCKING_REGION; s = getaddrinfo(host, port, &hints, &result); - GRPC_SCHEDULING_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(exec_ctx); if (s != 0) { error = GRPC_WSA_ERROR(WSAGetLastError(), "getaddrinfo"); goto done; diff --git a/src/core/lib/support/block_annotate.h b/src/core/lib/support/block_annotate.h index 0a2cb450186..e20faea9001 100644 --- a/src/core/lib/support/block_annotate.h +++ b/src/core/lib/support/block_annotate.h @@ -26,8 +26,12 @@ #define GRPC_SCHEDULING_START_BLOCKING_REGION \ do { \ } while (0) -#define GRPC_SCHEDULING_END_BLOCKING_REGION \ - do { \ +#define GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX \ + do { \ + } while (0) +#define GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(ec) \ + do { \ + grpc_exec_ctx_invalidate_now((ec)); \ } while (0) #endif /* GRPC_CORE_LIB_SUPPORT_BLOCK_ANNOTATE_H */ diff --git a/src/core/lib/support/time_posix.c b/src/core/lib/support/time_posix.c index 3ead40d8078..1248d875edd 100644 --- a/src/core/lib/support/time_posix.c +++ b/src/core/lib/support/time_posix.c @@ -159,7 +159,7 @@ void gpr_sleep_until(gpr_timespec until) { delta_ts = timespec_from_gpr(delta); GRPC_SCHEDULING_START_BLOCKING_REGION; ns_result = nanosleep(&delta_ts, NULL); - GRPC_SCHEDULING_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX; if (ns_result == 0) { break; } diff --git a/src/core/lib/support/time_windows.c b/src/core/lib/support/time_windows.c index 40df3761c00..e28cf0f4cbc 100644 --- a/src/core/lib/support/time_windows.c +++ b/src/core/lib/support/time_windows.c @@ -94,7 +94,7 @@ void gpr_sleep_until(gpr_timespec until) { GPR_ASSERT((sleep_millis >= 0) && (sleep_millis <= INT_MAX)); GRPC_SCHEDULING_START_BLOCKING_REGION; Sleep((DWORD)sleep_millis); - GRPC_SCHEDULING_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX; } } From 19b9af0cb88f7c5d8e9bafb475e95fb32fc14aa0 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 17 Jul 2017 16:26:24 -0700 Subject: [PATCH 007/142] Fix tools compilation --- test/core/security/print_google_default_creds_token.c | 3 +-- test/core/security/verify_jwt.c | 8 +++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/test/core/security/print_google_default_creds_token.c b/test/core/security/print_google_default_creds_token.c index 3c3d3a7c105..8094febaca4 100644 --- a/test/core/security/print_google_default_creds_token.c +++ b/test/core/security/print_google_default_creds_token.c @@ -99,8 +99,7 @@ int main(int argc, char **argv) { "pollset_work", grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&sync.pops), &worker, - gpr_now(GPR_CLOCK_MONOTONIC), - gpr_inf_future(GPR_CLOCK_MONOTONIC)))) + GRPC_MILLIS_INF_FUTURE))) sync.is_done = 1; gpr_mu_unlock(sync.mu); grpc_exec_ctx_flush(&exec_ctx); diff --git a/test/core/security/verify_jwt.c b/test/core/security/verify_jwt.c index 259038f4d6c..e3d7d9d8aad 100644 --- a/test/core/security/verify_jwt.c +++ b/test/core/security/verify_jwt.c @@ -101,11 +101,9 @@ int main(int argc, char **argv) { gpr_mu_lock(sync.mu); while (!sync.is_done) { grpc_pollset_worker *worker = NULL; - if (!GRPC_LOG_IF_ERROR( - "pollset_work", - grpc_pollset_work(&exec_ctx, sync.pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), - gpr_inf_future(GPR_CLOCK_MONOTONIC)))) + if (!GRPC_LOG_IF_ERROR("pollset_work", + grpc_pollset_work(&exec_ctx, sync.pollset, &worker, + GRPC_MILLIS_INF_FUTURE))) sync.is_done = true; gpr_mu_unlock(sync.mu); grpc_exec_ctx_flush(&exec_ctx); From 203977925ccf04599336897a694b300d4f922464 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 18 Jul 2017 11:35:27 -0700 Subject: [PATCH 008/142] Linux compile fixes --- src/core/lib/iomgr/ev_epoll1_linux.c | 48 ++++++------- .../iomgr/ev_epoll_limited_pollers_linux.c | 70 +++++++------------ .../lib/iomgr/ev_epoll_thread_pool_linux.c | 4 +- src/core/lib/iomgr/ev_epollex_linux.c | 68 ++++++++---------- src/core/lib/iomgr/ev_epollsig_linux.c | 37 ++++------ src/core/lib/iomgr/timer_generic.c | 3 +- test/core/iomgr/ev_epollsig_linux_test.c | 6 +- test/core/iomgr/pollset_set_test.c | 22 +++--- 8 files changed, 103 insertions(+), 155 deletions(-) diff --git a/src/core/lib/iomgr/ev_epoll1_linux.c b/src/core/lib/iomgr/ev_epoll1_linux.c index b52e6ee9ecb..4eaaaa06dda 100644 --- a/src/core/lib/iomgr/ev_epoll1_linux.c +++ b/src/core/lib/iomgr/ev_epoll1_linux.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -444,30 +445,24 @@ static void pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, #define MAX_EPOLL_EVENTS 100 -static int poll_deadline_to_millis_timeout(gpr_timespec deadline, - gpr_timespec now) { - gpr_timespec timeout; - if (gpr_time_cmp(deadline, gpr_inf_future(deadline.clock_type)) == 0) { - return -1; - } - - if (gpr_time_cmp(deadline, now) <= 0) { +static int poll_deadline_to_millis_timeout(grpc_exec_ctx *exec_ctx, + grpc_millis millis) { + if (millis == GRPC_MILLIS_INF_FUTURE) return -1; + grpc_millis delta = millis - grpc_exec_ctx_now(exec_ctx); + if (delta > INT_MAX) + return INT_MAX; + else if (delta < 0) return 0; - } - - static const gpr_timespec round_up = { - .clock_type = GPR_TIMESPAN, .tv_sec = 0, .tv_nsec = GPR_NS_PER_MS - 1}; - timeout = gpr_time_sub(deadline, now); - int millis = gpr_time_to_millis(gpr_time_add(timeout, round_up)); - return millis >= 1 ? millis : 1; + else + return (int)delta; } static grpc_error *pollset_epoll(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, - gpr_timespec now, gpr_timespec deadline) { + grpc_millis deadline) { struct epoll_event events[MAX_EPOLL_EVENTS]; static const char *err_desc = "pollset_poll"; - int timeout = poll_deadline_to_millis_timeout(deadline, now); + int timeout = poll_deadline_to_millis_timeout(exec_ctx, deadline); if (timeout != 0) { GRPC_SCHEDULING_START_BLOCKING_REGION; @@ -505,9 +500,10 @@ static grpc_error *pollset_epoll(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, return error; } -static bool begin_worker(grpc_pollset *pollset, grpc_pollset_worker *worker, - grpc_pollset_worker **worker_hdl, gpr_timespec *now, - gpr_timespec deadline) { +static bool begin_worker(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, + grpc_pollset_worker *worker, + grpc_pollset_worker **worker_hdl, + grpc_millis deadline) { if (worker_hdl != NULL) *worker_hdl = worker; worker->initialized_cv = false; worker->kick_state = UNKICKED; @@ -562,12 +558,13 @@ static bool begin_worker(grpc_pollset *pollset, grpc_pollset_worker *worker, gpr_cv_init(&worker->cv); while (worker->kick_state == UNKICKED && pollset->shutdown_closure == NULL) { - if (gpr_cv_wait(&worker->cv, &pollset->mu, deadline) && + if (gpr_cv_wait(&worker->cv, &pollset->mu, + grpc_millis_to_timespec(deadline, GPR_CLOCK_REALTIME)) && worker->kick_state == UNKICKED) { worker->kick_state = KICKED; } } - *now = gpr_now(now->clock_type); + grpc_exec_ctx_invalidate_now(exec_ctx); } return worker->kick_state == DESIGNATED_POLLER && @@ -694,7 +691,7 @@ static void end_worker(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, ensure that it is held by the time the function returns */ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, grpc_pollset_worker **worker_hdl, - gpr_timespec now, gpr_timespec deadline) { + grpc_millis deadline) { grpc_pollset_worker worker; grpc_error *error = GRPC_ERROR_NONE; static const char *err_desc = "pollset_work"; @@ -703,13 +700,12 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, return GRPC_ERROR_NONE; } gpr_tls_set(&g_current_thread_pollset, (intptr_t)pollset); - if (begin_worker(pollset, &worker, worker_hdl, &now, deadline)) { + if (begin_worker(exec_ctx, pollset, &worker, worker_hdl, deadline)) { gpr_tls_set(&g_current_thread_worker, (intptr_t)&worker); GPR_ASSERT(!pollset->shutdown_closure); GPR_ASSERT(!pollset->seen_inactive); gpr_mu_unlock(&pollset->mu); - append_error(&error, pollset_epoll(exec_ctx, pollset, now, deadline), - err_desc); + append_error(&error, pollset_epoll(exec_ctx, pollset, deadline), err_desc); gpr_mu_lock(&pollset->mu); gpr_tls_set(&g_current_thread_worker, 0); } diff --git a/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c b/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c index 57baef16ec1..055acffbdd4 100644 --- a/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +++ b/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c @@ -1196,30 +1196,16 @@ static struct timespec millis_to_timespec(int millis) { return linux_ts; } -/* Convert a timespec to milliseconds: - - Very small or negative poll times are clamped to zero to do a non-blocking - poll (which becomes spin polling) - - Other small values are rounded up to one millisecond - - Longer than a millisecond polls are rounded up to the next nearest - millisecond to avoid spinning - - Infinite timeouts are converted to -1 */ -static int poll_deadline_to_millis_timeout(gpr_timespec deadline, - gpr_timespec now) { - gpr_timespec timeout; - static const int64_t max_spin_polling_us = 10; - if (gpr_time_cmp(deadline, gpr_inf_future(deadline.clock_type)) == 0) { - return -1; - } - - if (gpr_time_cmp(deadline, gpr_time_add(now, gpr_time_from_micros( - max_spin_polling_us, - GPR_TIMESPAN))) <= 0) { +static int poll_deadline_to_millis_timeout(grpc_exec_ctx *exec_ctx, + grpc_millis millis) { + if (millis == GRPC_MILLIS_INF_FUTURE) return -1; + grpc_millis delta = millis - grpc_exec_ctx_now(exec_ctx); + if (delta > INT_MAX) + return INT_MAX; + else if (delta < 0) return 0; - } - timeout = gpr_time_sub(deadline, now); - int millis = gpr_time_to_millis(gpr_time_add( - timeout, gpr_time_from_nanos(GPR_NS_PER_MS - 1, GPR_TIMESPAN))); - return millis >= 1 ? millis : 1; + else + return (int)delta; } static void fd_become_readable(grpc_exec_ctx *exec_ctx, grpc_fd *fd, @@ -1287,10 +1273,9 @@ static void pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) { gpr_mu_destroy(&pollset->po.mu); } -/* NOTE: This function may modify 'now' */ -static bool acquire_polling_lease(grpc_pollset_worker *worker, - polling_island *pi, gpr_timespec deadline, - gpr_timespec *now) { +static bool acquire_polling_lease(grpc_exec_ctx *exec_ctx, + grpc_pollset_worker *worker, + polling_island *pi, grpc_millis *deadline) { bool is_lease_acquired = false; gpr_mu_lock(&pi->worker_list_mu); // LOCK @@ -1302,7 +1287,7 @@ static bool acquire_polling_lease(grpc_pollset_worker *worker, bool is_timeout = false; int ret; - int timeout_ms = poll_deadline_to_millis_timeout(deadline, *now); + int timeout_ms = poll_deadline_to_millis_timeout(exec_ctx, *deadline); if (timeout_ms == -1) { ret = sigwaitinfo(&g_wakeup_sig_set, NULL); } else { @@ -1325,18 +1310,13 @@ static bool acquire_polling_lease(grpc_pollset_worker *worker, } } - /* Did the worker come out of sigtimedwait due to a thread that just - exited epoll and kicking it (in release_polling_lease function). */ - bool is_polling_turn = gpr_atm_acq_load(&worker->is_polling_turn); - /* Did the worker come out of sigtimedwait due to a thread alerting it that some completion event was (likely) available in the completion queue */ bool is_kicked = gpr_atm_no_barrier_load(&worker->is_kicked); if (is_kicked || is_timeout) { - *now = deadline; /* Essentially make the epoll timeout = 0 */ - } else if (is_polling_turn) { - *now = gpr_now(GPR_CLOCK_MONOTONIC); /* Reduce the epoll timeout */ + *deadline = grpc_exec_ctx_now( + exec_ctx); /* Essentially make the epoll timeout = 0 */ } gpr_mu_lock(&pi->worker_list_mu); // LOCK @@ -1376,11 +1356,11 @@ static void release_polling_lease(polling_island *pi, grpc_error **error) { static void pollset_do_epoll_pwait(grpc_exec_ctx *exec_ctx, int epoll_fd, grpc_pollset *pollset, polling_island *pi, grpc_pollset_worker *worker, - gpr_timespec now, gpr_timespec deadline, - sigset_t *sig_mask, grpc_error **error) { + grpc_millis deadline, sigset_t *sig_mask, + grpc_error **error) { /* Only g_max_pollers_per_pi threads can be doing polling in parallel. If we cannot get a lease, we cannot continue to do epoll_pwait() */ - if (!acquire_polling_lease(worker, pi, deadline, &now)) { + if (!acquire_polling_lease(exec_ctx, worker, pi, &deadline)) { return; } @@ -1390,12 +1370,12 @@ static void pollset_do_epoll_pwait(grpc_exec_ctx *exec_ctx, int epoll_fd, const char *err_desc = "pollset_work_and_unlock"; /* timeout_ms is the time between 'now' and 'deadline' */ - int timeout_ms = poll_deadline_to_millis_timeout(deadline, now); + int timeout_ms = poll_deadline_to_millis_timeout(exec_ctx, deadline); GRPC_SCHEDULING_START_BLOCKING_REGION; ep_rv = epoll_pwait(epoll_fd, ep_ev, GRPC_EPOLL_MAX_EVENTS, timeout_ms, sig_mask); - GRPC_SCHEDULING_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(exec_ctx); /* Give back the lease right away so that some other thread can enter */ release_polling_lease(pi, error); @@ -1450,8 +1430,8 @@ static void pollset_do_epoll_pwait(grpc_exec_ctx *exec_ctx, int epoll_fd, static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, grpc_pollset_worker *worker, - gpr_timespec now, gpr_timespec deadline, - sigset_t *sig_mask, grpc_error **error) { + grpc_millis deadline, sigset_t *sig_mask, + grpc_error **error) { int epoll_fd = -1; polling_island *pi = NULL; GPR_TIMER_BEGIN("pollset_work_and_unlock", 0); @@ -1499,7 +1479,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx, gpr_mu_unlock(&pollset->po.mu); g_current_thread_polling_island = pi; - pollset_do_epoll_pwait(exec_ctx, epoll_fd, pollset, pi, worker, now, deadline, + pollset_do_epoll_pwait(exec_ctx, epoll_fd, pollset, pi, worker, deadline, sig_mask, error); g_current_thread_polling_island = NULL; @@ -1521,7 +1501,7 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx, ensure that it is held by the time the function returns */ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, grpc_pollset_worker **worker_hdl, - gpr_timespec now, gpr_timespec deadline) { + grpc_millis deadline) { GPR_TIMER_BEGIN("pollset_work", 0); grpc_error *error = GRPC_ERROR_NONE; @@ -1577,7 +1557,7 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, push_front_worker(pollset, &worker); /* Add worker to pollset */ - pollset_work_and_unlock(exec_ctx, pollset, &worker, now, deadline, + pollset_work_and_unlock(exec_ctx, pollset, &worker, deadline, &g_orig_sigmask, &error); grpc_exec_ctx_flush(exec_ctx); diff --git a/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c b/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c index 0daa49727c4..46bf828cabe 100644 --- a/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +++ b/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c @@ -838,7 +838,7 @@ static void epoll_set_work(grpc_exec_ctx *exec_ctx, epoll_set *eps, ensure that it is held by the time the function returns */ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, grpc_pollset_worker **worker_hdl, - gpr_timespec now, gpr_timespec deadline) { + grpc_millis deadline) { GPR_TIMER_BEGIN("pollset_work", 0); grpc_error *error = GRPC_ERROR_NONE; @@ -861,7 +861,7 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, push_front_worker(pollset, &worker); gpr_cv_wait(&worker.kick_cv, &pollset->mu, - gpr_convert_clock_type(deadline, GPR_CLOCK_REALTIME)); + grpc_millis_to_timespec(deadline, GPR_CLOCK_REALTIME)); /* pollset->mu locked here */ remove_worker(pollset, &worker); diff --git a/src/core/lib/iomgr/ev_epollex_linux.c b/src/core/lib/iomgr/ev_epollex_linux.c index 416ef8c16b0..030f18aaf25 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.c +++ b/src/core/lib/iomgr/ev_epollex_linux.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -683,29 +684,16 @@ static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) { *mu = &pollset->pollable.po.mu; } -/* Convert a timespec to milliseconds: - - Very small or negative poll times are clamped to zero to do a non-blocking - poll (which becomes spin polling) - - Other small values are rounded up to one millisecond - - Longer than a millisecond polls are rounded up to the next nearest - millisecond to avoid spinning - - Infinite timeouts are converted to -1 */ -static int poll_deadline_to_millis_timeout(gpr_timespec deadline, - gpr_timespec now) { - gpr_timespec timeout; - if (gpr_time_cmp(deadline, gpr_inf_future(deadline.clock_type)) == 0) { - return -1; - } - - if (gpr_time_cmp(deadline, now) <= 0) { +static int poll_deadline_to_millis_timeout(grpc_exec_ctx *exec_ctx, + grpc_millis millis) { + if (millis == GRPC_MILLIS_INF_FUTURE) return -1; + grpc_millis delta = millis - grpc_exec_ctx_now(exec_ctx); + if (delta > INT_MAX) + return INT_MAX; + else if (delta < 0) return 0; - } - - static const gpr_timespec round_up = { - .clock_type = GPR_TIMESPAN, .tv_sec = 0, .tv_nsec = GPR_NS_PER_MS - 1}; - timeout = gpr_time_sub(deadline, now); - int millis = gpr_time_to_millis(gpr_time_add(timeout, round_up)); - return millis >= 1 ? millis : 1; + else + return (int)delta; } static void fd_become_readable(grpc_exec_ctx *exec_ctx, grpc_fd *fd, @@ -799,9 +787,8 @@ static void pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) { } static grpc_error *pollset_epoll(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, - pollable *p, gpr_timespec now, - gpr_timespec deadline) { - int timeout = poll_deadline_to_millis_timeout(deadline, now); + pollable *p, grpc_millis deadline) { + int timeout = poll_deadline_to_millis_timeout(exec_ctx, deadline); if (GRPC_TRACER_ON(grpc_polling_trace)) { char *desc = pollable_desc(p); @@ -872,9 +859,10 @@ static worker_remove_result worker_remove(grpc_pollset_worker **root, } /* Return true if this thread should poll */ -static bool begin_worker(grpc_pollset *pollset, grpc_pollset_worker *worker, - grpc_pollset_worker **worker_hdl, gpr_timespec *now, - gpr_timespec deadline) { +static bool begin_worker(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, + grpc_pollset_worker *worker, + grpc_pollset_worker **worker_hdl, + grpc_millis deadline) { bool do_poll = true; if (worker_hdl != NULL) *worker_hdl = worker; worker->initialized_cv = false; @@ -897,10 +885,11 @@ static bool begin_worker(grpc_pollset *pollset, grpc_pollset_worker *worker, worker->pollable->root_worker != worker) { gpr_log(GPR_DEBUG, "PS:%p wait %p w=%p for %dms", pollset, worker->pollable, worker, - poll_deadline_to_millis_timeout(deadline, *now)); + poll_deadline_to_millis_timeout(exec_ctx, deadline)); } while (do_poll && worker->pollable->root_worker != worker) { - if (gpr_cv_wait(&worker->cv, &worker->pollable->po.mu, deadline)) { + if (gpr_cv_wait(&worker->cv, &worker->pollable->po.mu, + grpc_millis_to_timespec(deadline, GPR_CLOCK_REALTIME))) { if (GRPC_TRACER_ON(grpc_polling_trace)) { gpr_log(GPR_DEBUG, "PS:%p timeout_wait %p w=%p", pollset, worker->pollable, worker); @@ -923,7 +912,7 @@ static bool begin_worker(grpc_pollset *pollset, grpc_pollset_worker *worker, gpr_mu_lock(&pollset->pollable.po.mu); gpr_mu_lock(&worker->pollable->po.mu); } - *now = gpr_now(now->clock_type); + grpc_exec_ctx_invalidate_now(exec_ctx); } return do_poll && pollset->shutdown_closure == NULL && @@ -954,14 +943,13 @@ static void end_worker(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, ensure that it is held by the time the function returns */ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, grpc_pollset_worker **worker_hdl, - gpr_timespec now, gpr_timespec deadline) { + grpc_millis deadline) { grpc_pollset_worker worker; if (0 && GRPC_TRACER_ON(grpc_polling_trace)) { - gpr_log(GPR_DEBUG, "PS:%p work hdl=%p worker=%p now=%" PRId64 - ".%09d deadline=%" PRId64 ".%09d kwp=%d root_worker=%p", - pollset, worker_hdl, &worker, now.tv_sec, now.tv_nsec, - deadline.tv_sec, deadline.tv_nsec, pollset->kicked_without_poller, - pollset->root_worker); + gpr_log(GPR_DEBUG, "PS:%p work hdl=%p worker=%p now=%" PRIdPTR + " deadline=%" PRIdPTR " kwp=%d root_worker=%p", + pollset, worker_hdl, &worker, grpc_exec_ctx_now(exec_ctx), deadline, + pollset->kicked_without_poller, pollset->root_worker); } grpc_error *error = GRPC_ERROR_NONE; static const char *err_desc = "pollset_work"; @@ -972,7 +960,7 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, if (pollset->current_pollable != &pollset->pollable) { gpr_mu_lock(&pollset->current_pollable->po.mu); } - if (begin_worker(pollset, &worker, worker_hdl, &now, deadline)) { + if (begin_worker(exec_ctx, pollset, &worker, worker_hdl, deadline)) { gpr_tls_set(&g_current_thread_pollset, (intptr_t)pollset); gpr_tls_set(&g_current_thread_worker, (intptr_t)&worker); GPR_ASSERT(!pollset->shutdown_closure); @@ -982,8 +970,8 @@ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, } gpr_mu_unlock(&pollset->pollable.po.mu); if (pollset->event_cursor == pollset->event_count) { - append_error(&error, pollset_epoll(exec_ctx, pollset, worker.pollable, - now, deadline), + append_error(&error, + pollset_epoll(exec_ctx, pollset, worker.pollable, deadline), err_desc); } append_error(&error, pollset_process_events(exec_ctx, pollset, false), diff --git a/src/core/lib/iomgr/ev_epollsig_linux.c b/src/core/lib/iomgr/ev_epollsig_linux.c index a2130a3f786..1e7ec0a1bc0 100644 --- a/src/core/lib/iomgr/ev_epollsig_linux.c +++ b/src/core/lib/iomgr/ev_epollsig_linux.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -1088,30 +1089,16 @@ static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) { pollset->shutdown_done = NULL; } -/* Convert a timespec to milliseconds: - - Very small or negative poll times are clamped to zero to do a non-blocking - poll (which becomes spin polling) - - Other small values are rounded up to one millisecond - - Longer than a millisecond polls are rounded up to the next nearest - millisecond to avoid spinning - - Infinite timeouts are converted to -1 */ -static int poll_deadline_to_millis_timeout(gpr_timespec deadline, - gpr_timespec now) { - gpr_timespec timeout; - static const int64_t max_spin_polling_us = 10; - if (gpr_time_cmp(deadline, gpr_inf_future(deadline.clock_type)) == 0) { - return -1; - } - - if (gpr_time_cmp(deadline, gpr_time_add(now, gpr_time_from_micros( - max_spin_polling_us, - GPR_TIMESPAN))) <= 0) { +static int poll_deadline_to_millis_timeout(grpc_exec_ctx *exec_ctx, + grpc_millis millis) { + if (millis == GRPC_MILLIS_INF_FUTURE) return -1; + grpc_millis delta = millis - grpc_exec_ctx_now(exec_ctx); + if (delta > INT_MAX) + return INT_MAX; + else if (delta < 0) return 0; - } - timeout = gpr_time_sub(deadline, now); - int millis = gpr_time_to_millis(gpr_time_add( - timeout, gpr_time_from_nanos(GPR_NS_PER_MS - 1, GPR_TIMESPAN))); - return millis >= 1 ? millis : 1; + else + return (int)delta; } static void fd_become_readable(grpc_exec_ctx *exec_ctx, grpc_fd *fd, @@ -1307,10 +1294,10 @@ static void pollset_work_and_unlock(grpc_exec_ctx *exec_ctx, ensure that it is held by the time the function returns */ static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, grpc_pollset_worker **worker_hdl, - gpr_timespec now, gpr_timespec deadline) { + grpc_millis deadline) { GPR_TIMER_BEGIN("pollset_work", 0); grpc_error *error = GRPC_ERROR_NONE; - int timeout_ms = poll_deadline_to_millis_timeout(deadline, now); + int timeout_ms = poll_deadline_to_millis_timeout(exec_ctx, deadline); sigset_t new_mask; diff --git a/src/core/lib/iomgr/timer_generic.c b/src/core/lib/iomgr/timer_generic.c index 11d0b338f19..3446e11a95e 100644 --- a/src/core/lib/iomgr/timer_generic.c +++ b/src/core/lib/iomgr/timer_generic.c @@ -225,7 +225,8 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer, return; } - grpc_time_averaged_stats_add_sample(&shard->stats, (deadline - now) / 1000.0); + grpc_time_averaged_stats_add_sample(&shard->stats, + (double)(deadline - now) / 1000.0); if (deadline < shard->queue_deadline_cap) { is_first_timer = grpc_timer_heap_add(&shard->heap, timer); } else { diff --git a/test/core/iomgr/ev_epollsig_linux_test.c b/test/core/iomgr/ev_epollsig_linux_test.c index 1d272fa4065..2c384d2b7b2 100644 --- a/test/core/iomgr/ev_epollsig_linux_test.c +++ b/test/core/iomgr/ev_epollsig_linux_test.c @@ -236,10 +236,8 @@ static void test_threading_loop(void *arg) { grpc_pollset_worker *worker; gpr_mu_lock(shared->mu); GPR_ASSERT(GRPC_LOG_IF_ERROR( - "pollset_work", - grpc_pollset_work(&exec_ctx, shared->pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), - gpr_inf_future(GPR_CLOCK_MONOTONIC)))); + "pollset_work", grpc_pollset_work(&exec_ctx, shared->pollset, &worker, + GRPC_MILLIS_INF_FUTURE))); gpr_mu_unlock(shared->mu); grpc_exec_ctx_finish(&exec_ctx); } diff --git a/test/core/iomgr/pollset_set_test.c b/test/core/iomgr/pollset_set_test.c index 6aedaf1081a..09067998043 100644 --- a/test/core/iomgr/pollset_set_test.c +++ b/test/core/iomgr/pollset_set_test.c @@ -202,7 +202,7 @@ static void pollset_set_test_basic() { */ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_pollset_worker *worker; - gpr_timespec deadline; + grpc_millis deadline; test_fd tfds[10]; test_pollset pollsets[3]; @@ -255,10 +255,10 @@ static void pollset_set_test_basic() { make_test_fds_readable(tfds, num_fds); gpr_mu_lock(pollsets[i].mu); - deadline = grpc_timeout_milliseconds_to_deadline(2); + deadline = + grpc_timespec_to_millis(grpc_timeout_milliseconds_to_deadline(2)); GPR_ASSERT(GRPC_ERROR_NONE == - grpc_pollset_work(&exec_ctx, pollsets[i].ps, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), deadline)); + grpc_pollset_work(&exec_ctx, pollsets[i].ps, &worker, deadline)); gpr_mu_unlock(pollsets[i].mu); grpc_exec_ctx_flush(&exec_ctx); @@ -307,7 +307,7 @@ void pollset_set_test_dup_fds() { */ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_pollset_worker *worker; - gpr_timespec deadline; + grpc_millis deadline; test_fd tfds[3]; test_pollset pollset; @@ -337,10 +337,9 @@ void pollset_set_test_dup_fds() { make_test_fds_readable(tfds, num_fds); gpr_mu_lock(pollset.mu); - deadline = grpc_timeout_milliseconds_to_deadline(2); + deadline = grpc_timespec_to_millis(grpc_timeout_milliseconds_to_deadline(2)); GPR_ASSERT(GRPC_ERROR_NONE == - grpc_pollset_work(&exec_ctx, pollset.ps, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), deadline)); + grpc_pollset_work(&exec_ctx, pollset.ps, &worker, deadline)); gpr_mu_unlock(pollset.mu); grpc_exec_ctx_flush(&exec_ctx); @@ -380,7 +379,7 @@ void pollset_set_test_empty_pollset() { */ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_pollset_worker *worker; - gpr_timespec deadline; + grpc_millis deadline; test_fd tfds[3]; test_pollset pollsets[2]; @@ -406,10 +405,9 @@ void pollset_set_test_empty_pollset() { make_test_fds_readable(tfds, num_fds); gpr_mu_lock(pollsets[0].mu); - deadline = grpc_timeout_milliseconds_to_deadline(2); + deadline = grpc_timespec_to_millis(grpc_timeout_milliseconds_to_deadline(2)); GPR_ASSERT(GRPC_ERROR_NONE == - grpc_pollset_work(&exec_ctx, pollsets[0].ps, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), deadline)); + grpc_pollset_work(&exec_ctx, pollsets[0].ps, &worker, deadline)); gpr_mu_unlock(pollsets[0].mu); grpc_exec_ctx_flush(&exec_ctx); From 2e37d001a3bd56cde5f11083cd7f679a50b49022 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 19 Jul 2017 13:34:31 -0700 Subject: [PATCH 009/142] Review feedback --- BUILD | 2 +- build.yaml | 2 +- gRPC-Core.podspec | 4 ++-- grpc.gemspec | 2 +- package.xml | 2 +- src/core/ext/filters/max_age/max_age_filter.c | 15 ++++++++------- src/core/lib/{support => iomgr}/block_annotate.h | 0 src/core/lib/iomgr/ev_epoll1_linux.c | 2 +- .../lib/iomgr/ev_epoll_limited_pollers_linux.c | 2 +- src/core/lib/iomgr/ev_epoll_thread_pool_linux.c | 2 +- src/core/lib/iomgr/ev_epollex_linux.c | 2 +- src/core/lib/iomgr/ev_epollsig_linux.c | 2 +- src/core/lib/iomgr/ev_poll_posix.c | 2 +- src/core/lib/iomgr/load_file.c | 2 +- src/core/lib/iomgr/resolve_address_posix.c | 2 +- src/core/lib/iomgr/resolve_address_windows.c | 2 +- src/core/lib/support/time_posix.c | 2 +- src/core/lib/support/time_windows.c | 2 +- src/core/lib/surface/completion_queue.c | 1 + tools/doxygen/Doxyfile.core.internal | 2 +- .../run_tests/generated/sources_and_headers.json | 4 ++-- 21 files changed, 29 insertions(+), 27 deletions(-) rename src/core/lib/{support => iomgr}/block_annotate.h (100%) diff --git a/BUILD b/BUILD index c69dd5e4613..8294b0be2e3 100644 --- a/BUILD +++ b/BUILD @@ -513,7 +513,7 @@ grpc_cc_library( "src/core/lib/support/atomic_with_atm.h", "src/core/lib/support/atomic_with_std.h", "src/core/lib/backoff/backoff.h", - "src/core/lib/support/block_annotate.h", + "src/core/lib/iomgr/block_annotate.h", "src/core/lib/support/env.h", "src/core/lib/support/memory.h", "src/core/lib/support/mpscq.h", diff --git a/build.yaml b/build.yaml index 01c6b42baa7..ac631ddadcf 100644 --- a/build.yaml +++ b/build.yaml @@ -93,7 +93,7 @@ filegroups: - src/core/lib/support/atomic.h - src/core/lib/support/atomic_with_atm.h - src/core/lib/support/atomic_with_std.h - - src/core/lib/support/block_annotate.h + - src/core/lib/iomgr/block_annotate.h - src/core/lib/support/env.h - src/core/lib/support/memory.h - src/core/lib/support/mpscq.h diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 5e1f663bb6e..01995401a31 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -186,7 +186,7 @@ Pod::Spec.new do |s| 'src/core/lib/support/atomic.h', 'src/core/lib/support/atomic_with_atm.h', 'src/core/lib/support/atomic_with_std.h', - 'src/core/lib/support/block_annotate.h', + 'src/core/lib/iomgr/block_annotate.h', 'src/core/lib/support/env.h', 'src/core/lib/support/memory.h', 'src/core/lib/support/mpscq.h', @@ -714,7 +714,7 @@ Pod::Spec.new do |s| 'src/core/lib/support/atomic.h', 'src/core/lib/support/atomic_with_atm.h', 'src/core/lib/support/atomic_with_std.h', - 'src/core/lib/support/block_annotate.h', + 'src/core/lib/iomgr/block_annotate.h', 'src/core/lib/support/env.h', 'src/core/lib/support/memory.h', 'src/core/lib/support/mpscq.h', diff --git a/grpc.gemspec b/grpc.gemspec index 45fed61c272..10b4e92a3be 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -86,7 +86,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/support/atomic.h ) s.files += %w( src/core/lib/support/atomic_with_atm.h ) s.files += %w( src/core/lib/support/atomic_with_std.h ) - s.files += %w( src/core/lib/support/block_annotate.h ) + s.files += %w( src/core/lib/iomgr/block_annotate.h ) s.files += %w( src/core/lib/support/env.h ) s.files += %w( src/core/lib/support/memory.h ) s.files += %w( src/core/lib/support/mpscq.h ) diff --git a/package.xml b/package.xml index 0d5f49c889b..9a030850b0a 100644 --- a/package.xml +++ b/package.xml @@ -100,7 +100,7 @@ - + diff --git a/src/core/ext/filters/max_age/max_age_filter.c b/src/core/ext/filters/max_age/max_age_filter.c index 14565fd5308..2a785efc045 100644 --- a/src/core/ext/filters/max_age/max_age_filter.c +++ b/src/core/ext/filters/max_age/max_age_filter.c @@ -245,7 +245,8 @@ static void channel_connectivity_changed(grpc_exec_ctx* exec_ctx, void* arg, connection storms. Note that the MAX_CONNECTION_AGE option without jitter would not create connection storms by itself, but if there happened to be a connection storm it could cause it to repeat at a fixed period. */ -static int add_random_max_connection_age_jitter(int value) { +static grpc_millis +add_random_max_connection_age_jitter_and_convert_to_grpc_millis(int value) { /* generate a random number between 1 - MAX_CONNECTION_AGE_JITTER and 1 + MAX_CONNECTION_AGE_JITTER */ double multiplier = rand() * MAX_CONNECTION_AGE_JITTER * 2.0 / RAND_MAX + @@ -253,7 +254,8 @@ static int add_random_max_connection_age_jitter(int value) { double result = multiplier * value; /* INT_MAX - 0.5 converts the value to float, so that result will not be cast to int implicitly before the comparison. */ - return result > INT_MAX - 0.5 ? INT_MAX : (int)result; + return result > GRPC_MILLIS_INF_FUTURE - 0.5 ? GRPC_MILLIS_INF_FUTURE + : (int)result; } /* Constructor for call_data. */ @@ -283,9 +285,8 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx, chand->max_age_grace_timer_pending = false; chand->channel_stack = args->channel_stack; chand->max_connection_age = - DEFAULT_MAX_CONNECTION_AGE_MS == INT_MAX - ? GRPC_MILLIS_INF_FUTURE - : add_random_max_connection_age_jitter(DEFAULT_MAX_CONNECTION_AGE_MS); + add_random_max_connection_age_jitter_and_convert_to_grpc_millis( + DEFAULT_MAX_CONNECTION_AGE_MS); chand->max_connection_age_grace = DEFAULT_MAX_CONNECTION_AGE_GRACE_MS == INT_MAX ? GRPC_MILLIS_INF_FUTURE @@ -299,8 +300,8 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx, const int value = grpc_channel_arg_get_integer( &args->channel_args->args[i], MAX_CONNECTION_AGE_INTEGER_OPTIONS); chand->max_connection_age = - value == INT_MAX ? GRPC_MILLIS_INF_FUTURE - : add_random_max_connection_age_jitter(value); + add_random_max_connection_age_jitter_and_convert_to_grpc_millis( + value); } else if (0 == strcmp(args->channel_args->args[i].key, GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS)) { const int value = grpc_channel_arg_get_integer( diff --git a/src/core/lib/support/block_annotate.h b/src/core/lib/iomgr/block_annotate.h similarity index 100% rename from src/core/lib/support/block_annotate.h rename to src/core/lib/iomgr/block_annotate.h diff --git a/src/core/lib/iomgr/ev_epoll1_linux.c b/src/core/lib/iomgr/ev_epoll1_linux.c index 4eaaaa06dda..a3586547d46 100644 --- a/src/core/lib/iomgr/ev_epoll1_linux.c +++ b/src/core/lib/iomgr/ev_epoll1_linux.c @@ -45,7 +45,7 @@ #include "src/core/lib/iomgr/lockfree_event.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/profiling/timers.h" -#include "src/core/lib/support/block_annotate.h" +#include "src/core/lib/iomgr/block_annotate.h" static grpc_wakeup_fd global_wakeup_fd; static int g_epfd; diff --git a/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c b/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c index 055acffbdd4..05e9ca448a7 100644 --- a/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +++ b/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c @@ -47,7 +47,7 @@ #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/profiling/timers.h" -#include "src/core/lib/support/block_annotate.h" +#include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/support/env.h" #define GRPC_POLLING_TRACE(fmt, ...) \ diff --git a/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c b/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c index 46bf828cabe..bbcc475d7ed 100644 --- a/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +++ b/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c @@ -47,7 +47,7 @@ #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/profiling/timers.h" -#include "src/core/lib/support/block_annotate.h" +#include "src/core/lib/iomgr/block_annotate.h" /* TODO: sreek - Move this to init.c and initialize this like other tracers. */ #define GRPC_POLLING_TRACE(fmt, ...) \ diff --git a/src/core/lib/iomgr/ev_epollex_linux.c b/src/core/lib/iomgr/ev_epollex_linux.c index 030f18aaf25..7db95fe9b43 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.c +++ b/src/core/lib/iomgr/ev_epollex_linux.c @@ -46,7 +46,7 @@ #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/profiling/timers.h" -#include "src/core/lib/support/block_annotate.h" +#include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/support/spinlock.h" /******************************************************************************* diff --git a/src/core/lib/iomgr/ev_epollsig_linux.c b/src/core/lib/iomgr/ev_epollsig_linux.c index 1e7ec0a1bc0..fc5212ab5e4 100644 --- a/src/core/lib/iomgr/ev_epollsig_linux.c +++ b/src/core/lib/iomgr/ev_epollsig_linux.c @@ -46,7 +46,7 @@ #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/profiling/timers.h" -#include "src/core/lib/support/block_annotate.h" +#include "src/core/lib/iomgr/block_annotate.h" #define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1) diff --git a/src/core/lib/iomgr/ev_poll_posix.c b/src/core/lib/iomgr/ev_poll_posix.c index e7cdfc18603..c6456bee188 100644 --- a/src/core/lib/iomgr/ev_poll_posix.c +++ b/src/core/lib/iomgr/ev_poll_posix.c @@ -42,7 +42,7 @@ #include "src/core/lib/iomgr/wakeup_fd_cv.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/profiling/timers.h" -#include "src/core/lib/support/block_annotate.h" +#include "src/core/lib/iomgr/block_annotate.h" #define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1) diff --git a/src/core/lib/iomgr/load_file.c b/src/core/lib/iomgr/load_file.c index a8c0fa13390..aafcd79e38d 100644 --- a/src/core/lib/iomgr/load_file.c +++ b/src/core/lib/iomgr/load_file.c @@ -25,7 +25,7 @@ #include #include -#include "src/core/lib/support/block_annotate.h" +#include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/support/string.h" grpc_error *grpc_load_file(const char *filename, int add_null_terminator, diff --git a/src/core/lib/iomgr/resolve_address_posix.c b/src/core/lib/iomgr/resolve_address_posix.c index 160235ca99d..d58ec4168ef 100644 --- a/src/core/lib/iomgr/resolve_address_posix.c +++ b/src/core/lib/iomgr/resolve_address_posix.c @@ -36,7 +36,7 @@ #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr_internal.h" #include "src/core/lib/iomgr/unix_sockets_posix.h" -#include "src/core/lib/support/block_annotate.h" +#include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/support/string.h" static grpc_error *blocking_resolve_address_impl( diff --git a/src/core/lib/iomgr/resolve_address_windows.c b/src/core/lib/iomgr/resolve_address_windows.c index c5d8dd9893e..ee09d127b45 100644 --- a/src/core/lib/iomgr/resolve_address_windows.c +++ b/src/core/lib/iomgr/resolve_address_windows.c @@ -36,7 +36,7 @@ #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr_internal.h" #include "src/core/lib/iomgr/sockaddr_utils.h" -#include "src/core/lib/support/block_annotate.h" +#include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/support/string.h" typedef struct { diff --git a/src/core/lib/support/time_posix.c b/src/core/lib/support/time_posix.c index 1248d875edd..ad7c5036dae 100644 --- a/src/core/lib/support/time_posix.c +++ b/src/core/lib/support/time_posix.c @@ -30,7 +30,7 @@ #include #include #include -#include "src/core/lib/support/block_annotate.h" +#include "src/core/lib/iomgr/block_annotate.h" static struct timespec timespec_from_gpr(gpr_timespec gts) { struct timespec rv; diff --git a/src/core/lib/support/time_windows.c b/src/core/lib/support/time_windows.c index e28cf0f4cbc..b8015c272f8 100644 --- a/src/core/lib/support/time_windows.c +++ b/src/core/lib/support/time_windows.c @@ -28,7 +28,7 @@ #include #include -#include "src/core/lib/support/block_annotate.h" +#include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/support/time_precise.h" static LARGE_INTEGER g_start_time; diff --git a/src/core/lib/surface/completion_queue.c b/src/core/lib/surface/completion_queue.c index e0547415201..f3a89772411 100644 --- a/src/core/lib/surface/completion_queue.c +++ b/src/core/lib/surface/completion_queue.c @@ -1114,6 +1114,7 @@ static grpc_event cq_pluck(grpc_completion_queue *cq, void *tag, dump_pending_tags(cq); break; } + cq->num_polls++; grpc_error *err = cq->poller_vtable->work(&exec_ctx, POLLSET_FROM_CQ(cq), &worker, deadline_millis); if (err != GRPC_ERROR_NONE) { diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index cb625e2a8ec..c0ff8c9806b 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1286,7 +1286,7 @@ src/core/lib/support/atomic.h \ src/core/lib/support/atomic_with_atm.h \ src/core/lib/support/atomic_with_std.h \ src/core/lib/support/avl.c \ -src/core/lib/support/block_annotate.h \ +src/core/lib/iomgr/block_annotate.h \ src/core/lib/support/cmdline.c \ src/core/lib/support/cpu_iphone.c \ src/core/lib/support/cpu_linux.c \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 589cafa29b4..51252724ace 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7518,7 +7518,7 @@ "src/core/lib/support/atomic.h", "src/core/lib/support/atomic_with_atm.h", "src/core/lib/support/atomic_with_std.h", - "src/core/lib/support/block_annotate.h", + "src/core/lib/iomgr/block_annotate.h", "src/core/lib/support/env.h", "src/core/lib/support/memory.h", "src/core/lib/support/mpscq.h", @@ -7574,7 +7574,7 @@ "src/core/lib/support/atomic_with_atm.h", "src/core/lib/support/atomic_with_std.h", "src/core/lib/support/avl.c", - "src/core/lib/support/block_annotate.h", + "src/core/lib/iomgr/block_annotate.h", "src/core/lib/support/cmdline.c", "src/core/lib/support/cpu_iphone.c", "src/core/lib/support/cpu_linux.c", From 89c1428a60a6c5423ccad9ede60079c5e4cc79ac Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 19 Jul 2017 15:32:27 -0700 Subject: [PATCH 010/142] Propagate grpc_millis further --- .../filters/client_channel/client_channel.c | 36 +++--- .../client_channel/lb_policy/grpclb/grpclb.c | 8 +- .../ext/filters/client_channel/subchannel.h | 2 +- .../ext/filters/deadline/deadline_filter.c | 16 ++- .../ext/filters/deadline/deadline_filter.h | 4 +- .../chttp2/transport/chttp2_transport.c | 27 +++-- .../chttp2/transport/hpack_encoder.c | 10 +- .../chttp2/transport/incoming_metadata.c | 4 +- .../chttp2/transport/incoming_metadata.h | 2 +- .../ext/transport/chttp2/transport/internal.h | 2 +- .../ext/transport/chttp2/transport/parsing.c | 11 +- .../ext/transport/inproc/inproc_transport.c | 16 +-- src/core/lib/channel/channel_stack.h | 2 +- src/core/lib/surface/call.c | 54 +++++---- src/core/lib/surface/call.h | 2 +- src/core/lib/surface/channel.c | 9 +- src/core/lib/surface/channel.h | 2 +- src/core/lib/surface/lame_client.cc | 2 +- src/core/lib/surface/server.c | 16 +-- src/core/lib/transport/error_utils.c | 9 +- src/core/lib/transport/error_utils.h | 6 +- src/core/lib/transport/metadata_batch.c | 6 +- src/core/lib/transport/metadata_batch.h | 4 +- src/core/lib/transport/status_conversion.c | 7 +- src/core/lib/transport/status_conversion.h | 6 +- src/core/lib/transport/timeout_encoding.c | 73 ++++-------- src/core/lib/transport/timeout_encoding.h | 5 +- src/core/lib/transport/transport_op_string.c | 5 +- test/core/channel/channel_stack_test.c | 2 +- test/core/transport/status_conversion_test.c | 13 ++- test/core/transport/timeout_encoding_test.c | 105 +++++++++--------- test/cpp/microbenchmarks/bm_call_create.cc | 2 +- .../microbenchmarks/bm_chttp2_transport.cc | 6 +- .../microbenchmarks/bm_cq_multiple_threads.cc | 6 +- test/cpp/microbenchmarks/bm_error.cc | 42 ++++--- test/cpp/microbenchmarks/bm_pollset.cc | 9 +- 36 files changed, 254 insertions(+), 277 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel.c b/src/core/ext/filters/client_channel/client_channel.c index 58e31d7b45b..508c473c6ac 100644 --- a/src/core/ext/filters/client_channel/client_channel.c +++ b/src/core/ext/filters/client_channel/client_channel.c @@ -68,7 +68,7 @@ typedef enum { typedef struct { gpr_refcount refs; - gpr_timespec timeout; + grpc_millis timeout; wait_for_ready_value wait_for_ready; } method_parameters; @@ -98,17 +98,18 @@ static bool parse_wait_for_ready(grpc_json *field, return true; } -static bool parse_timeout(grpc_json *field, gpr_timespec *timeout) { +static bool parse_timeout(grpc_json *field, grpc_millis *timeout) { if (field->type != GRPC_JSON_STRING) return false; size_t len = strlen(field->value); if (field->value[len - 1] != 's') return false; char *buf = gpr_strdup(field->value); buf[len - 1] = '\0'; // Remove trailing 's'. char *decimal_point = strchr(buf, '.'); + int nanos = 0; if (decimal_point != NULL) { *decimal_point = '\0'; - timeout->tv_nsec = gpr_parse_nonnegative_int(decimal_point + 1); - if (timeout->tv_nsec == -1) { + nanos = gpr_parse_nonnegative_int(decimal_point + 1); + if (nanos == -1) { gpr_free(buf); return false; } @@ -127,24 +128,25 @@ static bool parse_timeout(grpc_json *field, gpr_timespec *timeout) { gpr_free(buf); return false; } - timeout->tv_nsec *= multiplier; + nanos *= multiplier; } - timeout->tv_sec = gpr_parse_nonnegative_int(buf); + int seconds = gpr_parse_nonnegative_int(buf); gpr_free(buf); - if (timeout->tv_sec == -1) return false; + if (seconds == -1) return false; + *timeout = seconds * GPR_MS_PER_SEC + nanos / GPR_NS_PER_MS; return true; } static void *method_parameters_create_from_json(const grpc_json *json) { wait_for_ready_value wait_for_ready = WAIT_FOR_READY_UNSET; - gpr_timespec timeout = {0, 0, GPR_TIMESPAN}; + grpc_millis timeout = 0; for (grpc_json *field = json->child; field != NULL; field = field->next) { if (field->key == NULL) continue; if (strcmp(field->key, "waitForReady") == 0) { if (wait_for_ready != WAIT_FOR_READY_UNSET) return NULL; // Duplicate. if (!parse_wait_for_ready(field, &wait_for_ready)) return NULL; } else if (strcmp(field->key, "timeout") == 0) { - if (timeout.tv_sec > 0 || timeout.tv_nsec > 0) return NULL; // Duplicate. + if (timeout > 0) return NULL; // Duplicate. if (!parse_timeout(field, &timeout)) return NULL; } } @@ -814,7 +816,7 @@ typedef struct client_channel_call_data { grpc_slice path; // Request path. gpr_timespec call_start_time; - gpr_timespec deadline; + grpc_millis deadline; grpc_server_retry_throttle_data *retry_throttle_data; method_parameters *method_params; @@ -952,11 +954,11 @@ static void apply_service_config_to_call_locked(grpc_exec_ctx *exec_ctx, // If the deadline from the service config is shorter than the one // from the client API, reset the deadline timer. if (chand->deadline_checking_enabled && - gpr_time_cmp(calld->method_params->timeout, - gpr_time_0(GPR_TIMESPAN)) != 0) { - const gpr_timespec per_method_deadline = - gpr_time_add(calld->call_start_time, calld->method_params->timeout); - if (gpr_time_cmp(per_method_deadline, calld->deadline) < 0) { + calld->method_params->timeout != 0) { + const grpc_millis per_method_deadline = + grpc_timespec_to_millis(calld->call_start_time) + + calld->method_params->timeout; + if (per_method_deadline < calld->deadline) { calld->deadline = per_method_deadline; grpc_deadline_state_reset(exec_ctx, elem, calld->deadline); } @@ -1026,7 +1028,7 @@ static void subchannel_ready_locked(grpc_exec_ctx *exec_ctx, "Cancelled before creating subchannel", child_errors, GPR_ARRAY_SIZE(child_errors)); /* if due to deadline, attach the deadline exceeded status to the error */ - if (gpr_time_cmp(calld->deadline, gpr_now(GPR_CLOCK_MONOTONIC)) < 0) { + if (calld->deadline < grpc_exec_ctx_now(exec_ctx)) { cancellation_error = grpc_error_set_int(cancellation_error, GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_DEADLINE_EXCEEDED); @@ -1440,7 +1442,7 @@ static grpc_error *cc_init_call_elem(grpc_exec_ctx *exec_ctx, // Initialize data members. calld->path = grpc_slice_ref_internal(args->path); calld->call_start_time = args->start_time; - calld->deadline = gpr_convert_clock_type(args->deadline, GPR_CLOCK_MONOTONIC); + calld->deadline = args->deadline; calld->owning_call = args->call_stack; calld->arena = args->arena; if (chand->deadline_checking_enabled) { diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c index c55fffee4d8..38ca829a140 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c @@ -1352,12 +1352,10 @@ static void lb_call_init_locked(grpc_exec_ctx *exec_ctx, * glb_policy->base.interested_parties, which is comprised of the polling * entities from \a client_channel. */ grpc_slice host = grpc_slice_from_copied_string(glb_policy->server_name); - gpr_timespec deadline = + grpc_millis deadline = glb_policy->lb_call_timeout_ms == 0 - ? gpr_inf_future(GPR_CLOCK_MONOTONIC) - : gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_millis(glb_policy->lb_call_timeout_ms, - GPR_TIMESPAN)); + ? GRPC_MILLIS_INF_FUTURE + : grpc_exec_ctx_now(exec_ctx) + glb_policy->lb_call_timeout_ms; glb_policy->lb_call = grpc_channel_create_pollset_set_call( exec_ctx, glb_policy->lb_channel, NULL, GRPC_PROPAGATE_DEFAULTS, glb_policy->base.interested_parties, diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h index 6d2abb04df5..5ffc6405738 100644 --- a/src/core/ext/filters/client_channel/subchannel.h +++ b/src/core/ext/filters/client_channel/subchannel.h @@ -103,7 +103,7 @@ typedef struct { grpc_polling_entity *pollent; grpc_slice path; gpr_timespec start_time; - gpr_timespec deadline; + grpc_millis deadline; gpr_arena *arena; grpc_call_context_element *context; } grpc_connected_subchannel_call_args; diff --git a/src/core/ext/filters/deadline/deadline_filter.c b/src/core/ext/filters/deadline/deadline_filter.c index 035f5abf3e3..fcd0d9c3b12 100644 --- a/src/core/ext/filters/deadline/deadline_filter.c +++ b/src/core/ext/filters/deadline/deadline_filter.c @@ -52,9 +52,8 @@ static void timer_callback(grpc_exec_ctx* exec_ctx, void* arg, // Starts the deadline timer. static void start_timer_if_needed(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - gpr_timespec deadline) { - grpc_millis deadline_millis = grpc_timespec_to_millis(deadline); - if (deadline_millis == GRPC_MILLIS_INF_FUTURE) { + grpc_millis deadline) { + if (deadline == GRPC_MILLIS_INF_FUTURE) { return; } grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data; @@ -94,7 +93,7 @@ retry: } GPR_ASSERT(closure); GRPC_CALL_STACK_REF(deadline_state->call_stack, "deadline_timer"); - grpc_timer_init(exec_ctx, &deadline_state->timer, deadline_millis, closure); + grpc_timer_init(exec_ctx, &deadline_state->timer, deadline, closure); } // Cancels the deadline timer. @@ -131,7 +130,7 @@ static void inject_on_complete_cb(grpc_deadline_state* deadline_state, // initialization has been completed. struct start_timer_after_init_state { grpc_call_element* elem; - gpr_timespec deadline; + grpc_millis deadline; grpc_closure closure; }; static void start_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg, @@ -143,13 +142,12 @@ static void start_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg, void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, grpc_call_stack* call_stack, - gpr_timespec deadline) { + grpc_millis deadline) { grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data; deadline_state->call_stack = call_stack; // Deadline will always be infinite on servers, so the timer will only be // set on clients with a finite deadline. - deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC); - if (gpr_time_cmp(deadline, gpr_inf_future(GPR_CLOCK_MONOTONIC)) != 0) { + if (deadline != GRPC_MILLIS_INF_FUTURE) { // When the deadline passes, we indicate the failure by sending down // an op with cancel_error set. However, we can't send down any ops // until after the call stack is fully initialized. If we start the @@ -173,7 +171,7 @@ void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx, } void grpc_deadline_state_reset(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - gpr_timespec new_deadline) { + grpc_millis new_deadline) { grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data; cancel_timer_if_needed(exec_ctx, deadline_state); start_timer_if_needed(exec_ctx, elem, new_deadline); diff --git a/src/core/ext/filters/deadline/deadline_filter.h b/src/core/ext/filters/deadline/deadline_filter.h index 420bf7065a3..776e6e56497 100644 --- a/src/core/ext/filters/deadline/deadline_filter.h +++ b/src/core/ext/filters/deadline/deadline_filter.h @@ -50,7 +50,7 @@ typedef struct grpc_deadline_state { // assumes elem->call_data is zero'd void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, grpc_call_stack* call_stack, - gpr_timespec deadline); + grpc_millis deadline); void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx, grpc_call_element* elem); @@ -62,7 +62,7 @@ void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx, // process of being reset, which means that attempting to increase the // deadline may result in the timer being called twice. void grpc_deadline_state_reset(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - gpr_timespec new_deadline); + grpc_millis new_deadline); // To be called from the client-side filter's start_transport_stream_op_batch() // method. Ensures that the deadline timer is cancelled when the call diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index ffcd715cf6e..658d2d1e7b2 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -676,7 +676,7 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt, grpc_chttp2_incoming_metadata_buffer_init(&s->metadata_buffer[1], arena); grpc_chttp2_data_parser_init(&s->data_parser); grpc_slice_buffer_init(&s->flow_controlled_buffer); - s->deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); + s->deadline = GRPC_MILLIS_INF_FUTURE; GRPC_CLOSURE_INIT(&s->complete_fetch_locked, complete_fetch_locked, s, grpc_schedule_on_exec_ctx); grpc_slice_buffer_init(&s->unprocessed_incoming_frames_buffer); @@ -1276,8 +1276,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op, t->settings[GRPC_PEER_SETTINGS] [GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE]; if (t->is_client) { - s->deadline = - gpr_time_min(s->deadline, s->send_initial_metadata->deadline); + s->deadline = GPR_MIN(s->deadline, s->send_initial_metadata->deadline); } if (metadata_size > metadata_peer_limit) { grpc_chttp2_cancel_stream( @@ -1473,16 +1472,14 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt, if (!t->is_client) { if (op->send_initial_metadata) { - gpr_timespec deadline = + grpc_millis deadline = op->payload->send_initial_metadata.send_initial_metadata->deadline; - GPR_ASSERT(0 == - gpr_time_cmp(gpr_inf_future(deadline.clock_type), deadline)); + GPR_ASSERT(deadline == GRPC_MILLIS_INF_FUTURE); } if (op->send_trailing_metadata) { - gpr_timespec deadline = + grpc_millis deadline = op->payload->send_trailing_metadata.send_trailing_metadata->deadline; - GPR_ASSERT(0 == - gpr_time_cmp(gpr_inf_future(deadline.clock_type), deadline)); + GPR_ASSERT(deadline == GRPC_MILLIS_INF_FUTURE); } } @@ -1556,8 +1553,8 @@ static void send_goaway(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, t->sent_goaway_state = GRPC_CHTTP2_GOAWAY_SEND_SCHEDULED; grpc_http2_error_code http_error; grpc_slice slice; - grpc_error_get_status(error, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL, - &slice, &http_error); + grpc_error_get_status(exec_ctx, error, GRPC_MILLIS_INF_FUTURE, NULL, &slice, + &http_error); grpc_chttp2_goaway_append(t->last_new_stream_id, (uint32_t)http_error, grpc_slice_ref_internal(slice), &t->qbuf); grpc_chttp2_initiate_write(exec_ctx, t, "goaway_sent"); @@ -1786,7 +1783,8 @@ void grpc_chttp2_cancel_stream(grpc_exec_ctx *exec_ctx, if (!s->read_closed || !s->write_closed) { if (s->id != 0) { grpc_http2_error_code http_error; - grpc_error_get_status(due_to_error, s->deadline, NULL, NULL, &http_error); + grpc_error_get_status(exec_ctx, due_to_error, s->deadline, NULL, NULL, + &http_error); grpc_slice_buffer_add( &t->qbuf, grpc_chttp2_rst_stream_create(s->id, (uint32_t)http_error, &s->stats.outgoing)); @@ -1803,7 +1801,7 @@ void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_stream *s, grpc_error *error) { grpc_status_code status; grpc_slice slice; - grpc_error_get_status(error, s->deadline, &status, &slice, NULL); + grpc_error_get_status(exec_ctx, error, s->deadline, &status, &slice, NULL); if (status != GRPC_STATUS_OK) { s->seen_error = true; @@ -1960,7 +1958,8 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, uint32_t len = 0; grpc_status_code grpc_status; grpc_slice slice; - grpc_error_get_status(error, s->deadline, &grpc_status, &slice, NULL); + grpc_error_get_status(exec_ctx, error, s->deadline, &grpc_status, &slice, + NULL); GPR_ASSERT(grpc_status >= 0 && (int)grpc_status < 100); diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.c b/src/core/ext/transport/chttp2/transport/hpack_encoder.c index a0e748e7b11..207ef6c4512 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.c +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.c @@ -515,12 +515,12 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c, #define TIMEOUT_KEY "grpc-timeout" static void deadline_enc(grpc_exec_ctx *exec_ctx, - grpc_chttp2_hpack_compressor *c, gpr_timespec deadline, + grpc_chttp2_hpack_compressor *c, grpc_millis deadline, framer_state *st) { char timeout_str[GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE]; grpc_mdelem mdelem; - grpc_http2_encode_timeout( - gpr_time_sub(deadline, gpr_now(deadline.clock_type)), timeout_str); + grpc_http2_encode_timeout(deadline - grpc_exec_ctx_now(exec_ctx), + timeout_str); mdelem = grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_GRPC_TIMEOUT, grpc_slice_from_copied_string(timeout_str)); hpack_enc(exec_ctx, c, mdelem, st); @@ -639,8 +639,8 @@ void grpc_chttp2_encode_header(grpc_exec_ctx *exec_ctx, for (grpc_linked_mdelem *l = metadata->list.head; l; l = l->next) { hpack_enc(exec_ctx, c, l->md, &st); } - gpr_timespec deadline = metadata->deadline; - if (gpr_time_cmp(deadline, gpr_inf_future(deadline.clock_type)) != 0) { + grpc_millis deadline = metadata->deadline; + if (deadline != GRPC_MILLIS_INF_FUTURE) { deadline_enc(exec_ctx, c, deadline, &st); } diff --git a/src/core/ext/transport/chttp2/transport/incoming_metadata.c b/src/core/ext/transport/chttp2/transport/incoming_metadata.c index cf0a9ca9201..089b360ecf7 100644 --- a/src/core/ext/transport/chttp2/transport/incoming_metadata.c +++ b/src/core/ext/transport/chttp2/transport/incoming_metadata.c @@ -29,7 +29,7 @@ void grpc_chttp2_incoming_metadata_buffer_init( grpc_chttp2_incoming_metadata_buffer *buffer, gpr_arena *arena) { buffer->arena = arena; grpc_metadata_batch_init(&buffer->batch); - buffer->batch.deadline = gpr_inf_future(GPR_CLOCK_REALTIME); + buffer->batch.deadline = GRPC_MILLIS_INF_FUTURE; } void grpc_chttp2_incoming_metadata_buffer_destroy( @@ -61,7 +61,7 @@ grpc_error *grpc_chttp2_incoming_metadata_buffer_replace_or_add( } void grpc_chttp2_incoming_metadata_buffer_set_deadline( - grpc_chttp2_incoming_metadata_buffer *buffer, gpr_timespec deadline) { + grpc_chttp2_incoming_metadata_buffer *buffer, grpc_millis deadline) { buffer->batch.deadline = deadline; } diff --git a/src/core/ext/transport/chttp2/transport/incoming_metadata.h b/src/core/ext/transport/chttp2/transport/incoming_metadata.h index a951d8764c4..0fc90b2d80d 100644 --- a/src/core/ext/transport/chttp2/transport/incoming_metadata.h +++ b/src/core/ext/transport/chttp2/transport/incoming_metadata.h @@ -43,6 +43,6 @@ grpc_error *grpc_chttp2_incoming_metadata_buffer_replace_or_add( grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer, grpc_mdelem elem) GRPC_MUST_USE_RESULT; void grpc_chttp2_incoming_metadata_buffer_set_deadline( - grpc_chttp2_incoming_metadata_buffer *buffer, gpr_timespec deadline); + grpc_chttp2_incoming_metadata_buffer *buffer, grpc_millis deadline); #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H */ diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 44ea3bdc610..7701a21ea92 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -499,7 +499,7 @@ struct grpc_chttp2_stream { grpc_error *byte_stream_error; /* protected by t combiner */ bool received_last_frame; /* protected by t combiner */ - gpr_timespec deadline; + grpc_millis deadline; /** saw some stream level error */ grpc_error *forced_close_error; diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index 3c8b470b4f9..a76ec8e930f 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -494,16 +494,16 @@ static void on_initial_header(grpc_exec_ctx *exec_ctx, void *tp, } if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_TIMEOUT)) { - gpr_timespec *cached_timeout = grpc_mdelem_get_user_data(md, free_timeout); - gpr_timespec timeout; + grpc_millis *cached_timeout = grpc_mdelem_get_user_data(md, free_timeout); + grpc_millis timeout; if (cached_timeout == NULL) { /* not already parsed: parse it now, and store the result away */ - cached_timeout = gpr_malloc(sizeof(gpr_timespec)); + cached_timeout = gpr_malloc(sizeof(grpc_millis)); if (!grpc_http2_decode_timeout(GRPC_MDVALUE(md), cached_timeout)) { char *val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'", val); gpr_free(val); - *cached_timeout = gpr_inf_future(GPR_TIMESPAN); + *cached_timeout = GRPC_MILLIS_INF_FUTURE; } timeout = *cached_timeout; grpc_mdelem_set_user_data(md, free_timeout, cached_timeout); @@ -511,8 +511,7 @@ static void on_initial_header(grpc_exec_ctx *exec_ctx, void *tp, timeout = *cached_timeout; } grpc_chttp2_incoming_metadata_buffer_set_deadline( - &s->metadata_buffer[0], - gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), timeout)); + &s->metadata_buffer[0], grpc_exec_ctx_now(exec_ctx) + timeout); GRPC_MDELEM_UNREF(exec_ctx, md); } else { const size_t new_size = s->metadata_buffer[0].size + GRPC_MDELEM_LENGTH(md); diff --git a/src/core/ext/transport/inproc/inproc_transport.c b/src/core/ext/transport/inproc/inproc_transport.c index 4df64d81e2b..02ed3d8a405 100644 --- a/src/core/ext/transport/inproc/inproc_transport.c +++ b/src/core/ext/transport/inproc/inproc_transport.c @@ -150,7 +150,7 @@ typedef struct inproc_stream { grpc_metadata_batch write_buffer_initial_md; bool write_buffer_initial_md_filled; uint32_t write_buffer_initial_md_flags; - gpr_timespec write_buffer_deadline; + grpc_millis write_buffer_deadline; slice_buffer_list write_buffer_message; grpc_metadata_batch write_buffer_trailing_md; bool write_buffer_trailing_md_filled; @@ -180,7 +180,7 @@ typedef struct inproc_stream { grpc_error *cancel_self_error; grpc_error *cancel_other_error; - gpr_timespec deadline; + grpc_millis deadline; bool listed; struct inproc_stream *stream_list_prev; @@ -358,8 +358,8 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt, s->cancel_self_error = GRPC_ERROR_NONE; s->cancel_other_error = GRPC_ERROR_NONE; s->write_buffer_cancel_error = GRPC_ERROR_NONE; - s->deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); - s->write_buffer_deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); + s->deadline = GRPC_MILLIS_INF_FUTURE; + s->write_buffer_deadline = GRPC_MILLIS_INF_FUTURE; s->stream_list_prev = NULL; gpr_mu_lock(&t->mu->mu); @@ -402,7 +402,7 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt, cs->write_buffer_initial_md_flags, &s->to_read_initial_md, &s->to_read_initial_md_flags, &s->to_read_initial_md_filled); - s->deadline = gpr_time_min(s->deadline, cs->write_buffer_deadline); + s->deadline = GPR_MIN(s->deadline, cs->write_buffer_deadline); grpc_metadata_batch_clear(exec_ctx, &cs->write_buffer_initial_md); cs->write_buffer_initial_md_filled = false; } @@ -935,10 +935,10 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt, dest, destflags, destfilled); } if (s->t->is_client) { - gpr_timespec *dl = + grpc_millis *dl = (other == NULL) ? &s->write_buffer_deadline : &other->deadline; - *dl = gpr_time_min(*dl, op->payload->send_initial_metadata - .send_initial_metadata->deadline); + *dl = GPR_MIN(*dl, op->payload->send_initial_metadata + .send_initial_metadata->deadline); s->initial_md_sent = true; } } diff --git a/src/core/lib/channel/channel_stack.h b/src/core/lib/channel/channel_stack.h index a80f8aa8268..19506e492be 100644 --- a/src/core/lib/channel/channel_stack.h +++ b/src/core/lib/channel/channel_stack.h @@ -69,7 +69,7 @@ typedef struct { grpc_call_context_element *context; grpc_slice path; gpr_timespec start_time; - gpr_timespec deadline; + grpc_millis deadline; gpr_arena *arena; } grpc_call_element_args; diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c index 2365d27307c..cfcf0c96a6b 100644 --- a/src/core/lib/surface/call.c +++ b/src/core/lib/surface/call.c @@ -202,7 +202,7 @@ struct grpc_call { server, it's trailing metadata */ grpc_linked_mdelem send_extra_metadata[MAX_SEND_EXTRA_METADATA_COUNT]; int send_extra_metadata_count; - gpr_timespec send_deadline; + grpc_millis send_deadline; grpc_slice_buffer_stream sending_stream; @@ -252,7 +252,7 @@ static void destroy_call(grpc_exec_ctx *exec_ctx, void *call_stack, grpc_error *error); static void receiving_slice_ready(grpc_exec_ctx *exec_ctx, void *bctlp, grpc_error *error); -static void get_final_status(grpc_call *call, +static void get_final_status(grpc_exec_ctx *exec_ctx, grpc_call *call, void (*set_value)(grpc_status_code code, void *user_data), void *set_value_user_data, grpc_slice *details); @@ -334,11 +334,10 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx, } for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { - call->metadata_batch[i][j].deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); + call->metadata_batch[i][j].deadline = GRPC_MILLIS_INF_FUTURE; } } - gpr_timespec send_deadline = - gpr_convert_clock_type(args->send_deadline, GPR_CLOCK_MONOTONIC); + grpc_millis send_deadline = args->send_deadline; bool immediately_cancel = false; @@ -356,10 +355,7 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx, gpr_mu_lock(&pc->child_list_mu); if (args->propagation_mask & GRPC_PROPAGATE_DEADLINE) { - send_deadline = gpr_time_min( - gpr_convert_clock_type(send_deadline, - args->parent_call->send_deadline.clock_type), - args->parent_call->send_deadline); + send_deadline = GPR_MIN(send_deadline, args->parent_call->send_deadline); } /* for now GRPC_PROPAGATE_TRACING_CONTEXT *MUST* be passed with * GRPC_PROPAGATE_STATS_CONTEXT */ @@ -511,8 +507,8 @@ static void destroy_call(grpc_exec_ctx *exec_ctx, void *call, GRPC_CQ_INTERNAL_UNREF(exec_ctx, c->cq, "bind"); } - get_final_status(call, set_status_value_directly, &c->final_info.final_status, - NULL); + get_final_status(exec_ctx, call, set_status_value_directly, + &c->final_info.final_status, NULL); c->final_info.stats.latency = gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), c->start_time); @@ -662,13 +658,16 @@ static void cancel_with_status(grpc_exec_ctx *exec_ctx, grpc_call *c, * FINAL STATUS CODE MANIPULATION */ -static bool get_final_status_from( - grpc_call *call, grpc_error *error, bool allow_ok_status, - void (*set_value)(grpc_status_code code, void *user_data), - void *set_value_user_data, grpc_slice *details) { +static bool get_final_status_from(grpc_exec_ctx *exec_ctx, grpc_call *call, + grpc_error *error, bool allow_ok_status, + void (*set_value)(grpc_status_code code, + void *user_data), + void *set_value_user_data, + grpc_slice *details) { grpc_status_code code; grpc_slice slice = grpc_empty_slice(); - grpc_error_get_status(error, call->send_deadline, &code, &slice, NULL); + grpc_error_get_status(exec_ctx, error, call->send_deadline, &code, &slice, + NULL); if (code == GRPC_STATUS_OK && !allow_ok_status) { return false; } @@ -680,7 +679,7 @@ static bool get_final_status_from( return true; } -static void get_final_status(grpc_call *call, +static void get_final_status(grpc_exec_ctx *exec_ctx, grpc_call *call, void (*set_value)(grpc_status_code code, void *user_data), void *set_value_user_data, grpc_slice *details) { @@ -705,8 +704,9 @@ static void get_final_status(grpc_call *call, for (i = 0; i < STATUS_SOURCE_COUNT; i++) { if (status[i].is_set && grpc_error_has_clear_grpc_status(status[i].error)) { - if (get_final_status_from(call, status[i].error, allow_ok_status != 0, - set_value, set_value_user_data, details)) { + if (get_final_status_from(exec_ctx, call, status[i].error, + allow_ok_status != 0, set_value, + set_value_user_data, details)) { return; } } @@ -714,8 +714,9 @@ static void get_final_status(grpc_call *call, /* If no clearly defined status exists, search for 'anything' */ for (i = 0; i < STATUS_SOURCE_COUNT; i++) { if (status[i].is_set) { - if (get_final_status_from(call, status[i].error, allow_ok_status != 0, - set_value, set_value_user_data, details)) { + if (get_final_status_from(exec_ctx, call, status[i].error, + allow_ok_status != 0, set_value, + set_value_user_data, details)) { return; } } @@ -1146,11 +1147,11 @@ static void post_batch_completion(grpc_exec_ctx *exec_ctx, } if (call->is_client) { - get_final_status(call, set_status_value_directly, + get_final_status(exec_ctx, call, set_status_value_directly, call->final_op.client.status, call->final_op.client.status_details); } else { - get_final_status(call, set_cancelled_value, + get_final_status(exec_ctx, call, set_cancelled_value, call->final_op.server.cancelled, NULL); } @@ -1371,11 +1372,8 @@ static void receiving_initial_metadata_ready(grpc_exec_ctx *exec_ctx, validate_filtered_metadata(exec_ctx, bctl); GPR_TIMER_END("validate_filtered_metadata", 0); - if (gpr_time_cmp(md->deadline, gpr_inf_future(md->deadline.clock_type)) != - 0 && - !call->is_client) { - call->send_deadline = - gpr_convert_clock_type(md->deadline, GPR_CLOCK_MONOTONIC); + if (md->deadline != GRPC_MILLIS_INF_FUTURE && !call->is_client) { + call->send_deadline = md->deadline; } } diff --git a/src/core/lib/surface/call.h b/src/core/lib/surface/call.h index 185bfccb77d..4c9652a6e90 100644 --- a/src/core/lib/surface/call.h +++ b/src/core/lib/surface/call.h @@ -49,7 +49,7 @@ typedef struct grpc_call_create_args { grpc_mdelem *add_initial_metadata; size_t add_initial_metadata_count; - gpr_timespec send_deadline; + grpc_millis send_deadline; } grpc_call_create_args; /* Create a new call based on \a args. diff --git a/src/core/lib/surface/channel.c b/src/core/lib/surface/channel.c index 5780a18ce8e..b0ff428393f 100644 --- a/src/core/lib/surface/channel.c +++ b/src/core/lib/surface/channel.c @@ -230,7 +230,7 @@ static grpc_call *grpc_channel_create_call_internal( grpc_exec_ctx *exec_ctx, grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, grpc_completion_queue *cq, grpc_pollset_set *pollset_set_alternative, grpc_mdelem path_mdelem, - grpc_mdelem authority_mdelem, gpr_timespec deadline) { + grpc_mdelem authority_mdelem, grpc_millis deadline) { grpc_mdelem send_metadata[2]; size_t num_metadata = 0; @@ -276,7 +276,7 @@ grpc_call *grpc_channel_create_call(grpc_channel *channel, host != NULL ? grpc_mdelem_from_slices(&exec_ctx, GRPC_MDSTR_AUTHORITY, grpc_slice_ref_internal(*host)) : GRPC_MDNULL, - deadline); + grpc_timespec_to_millis(deadline)); grpc_exec_ctx_finish(&exec_ctx); return call; } @@ -284,7 +284,7 @@ grpc_call *grpc_channel_create_call(grpc_channel *channel, grpc_call *grpc_channel_create_pollset_set_call( grpc_exec_ctx *exec_ctx, grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, grpc_pollset_set *pollset_set, grpc_slice method, - const grpc_slice *host, gpr_timespec deadline, void *reserved) { + const grpc_slice *host, grpc_millis deadline, void *reserved) { GPR_ASSERT(!reserved); return grpc_channel_create_call_internal( exec_ctx, channel, parent_call, propagation_mask, NULL, pollset_set, @@ -340,7 +340,8 @@ grpc_call *grpc_channel_create_registered_call( grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_call *call = grpc_channel_create_call_internal( &exec_ctx, channel, parent_call, propagation_mask, completion_queue, NULL, - GRPC_MDELEM_REF(rc->path), GRPC_MDELEM_REF(rc->authority), deadline); + GRPC_MDELEM_REF(rc->path), GRPC_MDELEM_REF(rc->authority), + grpc_timespec_to_millis(deadline)); grpc_exec_ctx_finish(&exec_ctx); return call; } diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h index 528bb868e2c..827dd992b55 100644 --- a/src/core/lib/surface/channel.h +++ b/src/core/lib/surface/channel.h @@ -43,7 +43,7 @@ grpc_channel *grpc_channel_create_with_builder( grpc_call *grpc_channel_create_pollset_set_call( grpc_exec_ctx *exec_ctx, grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, grpc_pollset_set *pollset_set, grpc_slice method, - const grpc_slice *host, gpr_timespec deadline, void *reserved); + const grpc_slice *host, grpc_millis deadline, void *reserved); /** Get a (borrowed) pointer to this channels underlying channel stack */ grpc_channel_stack *grpc_channel_get_channel_stack(grpc_channel *channel); diff --git a/src/core/lib/surface/lame_client.cc b/src/core/lib/surface/lame_client.cc index a0791080a98..d71de8a2bf6 100644 --- a/src/core/lib/surface/lame_client.cc +++ b/src/core/lib/surface/lame_client.cc @@ -73,7 +73,7 @@ static void fill_metadata(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, mdb->list.head = &calld->status; mdb->list.tail = &calld->details; mdb->list.count = 2; - mdb->deadline = gpr_inf_future(GPR_CLOCK_REALTIME); + mdb->deadline = GRPC_MILLIS_INF_FUTURE; } static void lame_start_transport_stream_op_batch( diff --git a/src/core/lib/surface/server.c b/src/core/lib/surface/server.c index fce7f8dca11..bad36241eb6 100644 --- a/src/core/lib/surface/server.c +++ b/src/core/lib/surface/server.c @@ -136,7 +136,7 @@ struct call_data { bool host_set; grpc_slice path; grpc_slice host; - gpr_timespec deadline; + grpc_millis deadline; grpc_completion_queue *cq_new; @@ -489,11 +489,13 @@ static void publish_call(grpc_exec_ctx *exec_ctx, grpc_server *server, GPR_ASSERT(calld->path_set); rc->data.batch.details->host = grpc_slice_ref_internal(calld->host); rc->data.batch.details->method = grpc_slice_ref_internal(calld->path); - rc->data.batch.details->deadline = calld->deadline; + rc->data.batch.details->deadline = + grpc_millis_to_timespec(calld->deadline, GPR_CLOCK_REALTIME); rc->data.batch.details->flags = calld->recv_initial_metadata_flags; break; case REGISTERED_CALL: - *rc->data.registered.deadline = calld->deadline; + *rc->data.registered.deadline = + grpc_millis_to_timespec(calld->deadline, GPR_CLOCK_REALTIME); if (rc->data.registered.optional_payload) { *rc->data.registered.optional_payload = calld->payload; calld->payload = NULL; @@ -734,7 +736,7 @@ static void server_on_recv_initial_metadata(grpc_exec_ctx *exec_ctx, void *ptr, grpc_error *error) { grpc_call_element *elem = ptr; call_data *calld = elem->call_data; - gpr_timespec op_deadline; + grpc_millis op_deadline; if (error == GRPC_ERROR_NONE) { GPR_ASSERT(calld->recv_initial_metadata->idx.named.path != NULL); @@ -754,7 +756,7 @@ static void server_on_recv_initial_metadata(grpc_exec_ctx *exec_ctx, void *ptr, GRPC_ERROR_REF(error); } op_deadline = calld->recv_initial_metadata->deadline; - if (0 != gpr_time_cmp(op_deadline, gpr_inf_future(op_deadline.clock_type))) { + if (op_deadline != GRPC_MILLIS_INF_FUTURE) { calld->deadline = op_deadline; } if (calld->host_set && calld->path_set) { @@ -829,7 +831,7 @@ static void accept_stream(grpc_exec_ctx *exec_ctx, void *cd, memset(&args, 0, sizeof(args)); args.channel = chand->channel; args.server_transport_data = transport_server_data; - args.send_deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); + args.send_deadline = GRPC_MILLIS_INF_FUTURE; grpc_call *call; grpc_error *error = grpc_call_create(exec_ctx, &args, &call); grpc_call_element *elem = @@ -877,7 +879,7 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; memset(calld, 0, sizeof(call_data)); - calld->deadline = gpr_inf_future(GPR_CLOCK_REALTIME); + calld->deadline = GRPC_MILLIS_INF_FUTURE; calld->call = grpc_call_from_top_element(elem); gpr_mu_init(&calld->mu_state); diff --git a/src/core/lib/transport/error_utils.c b/src/core/lib/transport/error_utils.c index 5e3920b627e..2e3b61b7abc 100644 --- a/src/core/lib/transport/error_utils.c +++ b/src/core/lib/transport/error_utils.c @@ -39,8 +39,9 @@ static grpc_error *recursively_find_error_with_field(grpc_error *error, return NULL; } -void grpc_error_get_status(grpc_error *error, gpr_timespec deadline, - grpc_status_code *code, grpc_slice *slice, +void grpc_error_get_status(grpc_exec_ctx *exec_ctx, grpc_error *error, + grpc_millis deadline, grpc_status_code *code, + grpc_slice *slice, grpc_http2_error_code *http_error) { // Start with the parent error and recurse through the tree of children // until we find the first one that has a status code. @@ -63,8 +64,8 @@ void grpc_error_get_status(grpc_error *error, gpr_timespec deadline, status = (grpc_status_code)integer; } else if (grpc_error_get_int(found_error, GRPC_ERROR_INT_HTTP2_ERROR, &integer)) { - status = grpc_http2_error_to_grpc_status((grpc_http2_error_code)integer, - deadline); + status = grpc_http2_error_to_grpc_status( + exec_ctx, (grpc_http2_error_code)integer, deadline); } if (code != NULL) *code = status; diff --git a/src/core/lib/transport/error_utils.h b/src/core/lib/transport/error_utils.h index e530884215b..6211031a243 100644 --- a/src/core/lib/transport/error_utils.h +++ b/src/core/lib/transport/error_utils.h @@ -20,6 +20,7 @@ #define GRPC_CORE_LIB_TRANSPORT_ERROR_UTILS_H #include "src/core/lib/iomgr/error.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/transport/http2_errors.h" /// A utility function to get the status code and message to be returned @@ -28,8 +29,9 @@ /// All attributes are pulled from the same child error. If any of the /// attributes (code, msg, http_status) are unneeded, they can be passed as /// NULL. -void grpc_error_get_status(grpc_error *error, gpr_timespec deadline, - grpc_status_code *code, grpc_slice *slice, +void grpc_error_get_status(grpc_exec_ctx *exec_ctx, grpc_error *error, + grpc_millis deadline, grpc_status_code *code, + grpc_slice *slice, grpc_http2_error_code *http_status); /// A utility function to check whether there is a clear status code that diff --git a/src/core/lib/transport/metadata_batch.c b/src/core/lib/transport/metadata_batch.c index 8f24b8527c8..a5ff9c96851 100644 --- a/src/core/lib/transport/metadata_batch.c +++ b/src/core/lib/transport/metadata_batch.c @@ -74,7 +74,7 @@ void grpc_metadata_batch_assert_ok(grpc_metadata_batch *batch) { void grpc_metadata_batch_init(grpc_metadata_batch *batch) { memset(batch, 0, sizeof(*batch)); - batch->deadline = gpr_inf_future(GPR_CLOCK_REALTIME); + batch->deadline = GRPC_MILLIS_INF_FUTURE; } void grpc_metadata_batch_destroy(grpc_exec_ctx *exec_ctx, @@ -268,9 +268,7 @@ void grpc_metadata_batch_clear(grpc_exec_ctx *exec_ctx, } bool grpc_metadata_batch_is_empty(grpc_metadata_batch *batch) { - return batch->list.head == NULL && - gpr_time_cmp(gpr_inf_future(batch->deadline.clock_type), - batch->deadline) == 0; + return batch->list.head == NULL && batch->deadline == GRPC_MILLIS_INF_FUTURE; } size_t grpc_metadata_batch_size(grpc_metadata_batch *batch) { diff --git a/src/core/lib/transport/metadata_batch.h b/src/core/lib/transport/metadata_batch.h index 1b11a3e2525..3498cdd926b 100644 --- a/src/core/lib/transport/metadata_batch.h +++ b/src/core/lib/transport/metadata_batch.h @@ -50,9 +50,9 @@ typedef struct grpc_metadata_batch { grpc_mdelem_list list; grpc_metadata_batch_callouts idx; /** Used to calculate grpc-timeout at the point of sending, - or gpr_inf_future if this batch does not need to send a + or GRPC_MILLIS_INF_FUTURE if this batch does not need to send a grpc-timeout */ - gpr_timespec deadline; + grpc_millis deadline; } grpc_metadata_batch; void grpc_metadata_batch_init(grpc_metadata_batch *batch); diff --git a/src/core/lib/transport/status_conversion.c b/src/core/lib/transport/status_conversion.c index 9a76977e4b8..73d20a170b2 100644 --- a/src/core/lib/transport/status_conversion.c +++ b/src/core/lib/transport/status_conversion.c @@ -37,8 +37,9 @@ int grpc_status_to_http2_error(grpc_status_code status) { } } -grpc_status_code grpc_http2_error_to_grpc_status(grpc_http2_error_code error, - gpr_timespec deadline) { +grpc_status_code grpc_http2_error_to_grpc_status(grpc_exec_ctx *exec_ctx, + grpc_http2_error_code error, + grpc_millis deadline) { switch (error) { case GRPC_HTTP2_NO_ERROR: /* should never be received */ @@ -46,7 +47,7 @@ grpc_status_code grpc_http2_error_to_grpc_status(grpc_http2_error_code error, case GRPC_HTTP2_CANCEL: /* http2 cancel translates to STATUS_CANCELLED iff deadline hasn't been * exceeded */ - return gpr_time_cmp(gpr_now(deadline.clock_type), deadline) >= 0 + return grpc_exec_ctx_now(exec_ctx) > deadline ? GRPC_STATUS_DEADLINE_EXCEEDED : GRPC_STATUS_CANCELLED; case GRPC_HTTP2_ENHANCE_YOUR_CALM: diff --git a/src/core/lib/transport/status_conversion.h b/src/core/lib/transport/status_conversion.h index e93f3dfd9bc..a05ed7658c9 100644 --- a/src/core/lib/transport/status_conversion.h +++ b/src/core/lib/transport/status_conversion.h @@ -20,12 +20,14 @@ #define GRPC_CORE_LIB_TRANSPORT_STATUS_CONVERSION_H #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/transport/http2_errors.h" /* Conversion of grpc status codes to http2 error codes (for RST_STREAM) */ grpc_http2_error_code grpc_status_to_http2_error(grpc_status_code status); -grpc_status_code grpc_http2_error_to_grpc_status(grpc_http2_error_code error, - gpr_timespec deadline); +grpc_status_code grpc_http2_error_to_grpc_status(grpc_exec_ctx *exec_ctx, + grpc_http2_error_code error, + grpc_millis deadline); /* Conversion of HTTP status codes (:status) to grpc status codes */ grpc_status_code grpc_http2_status_to_grpc_status(int status); diff --git a/src/core/lib/transport/timeout_encoding.c b/src/core/lib/transport/timeout_encoding.c index 02f179d6a3a..779d016ca6b 100644 --- a/src/core/lib/transport/timeout_encoding.c +++ b/src/core/lib/transport/timeout_encoding.c @@ -59,60 +59,27 @@ static void enc_seconds(char *buffer, int64_t sec) { } } -static void enc_nanos(char *buffer, int64_t x) { +static void enc_millis(char *buffer, int64_t x) { x = round_up_to_three_sig_figs(x); - if (x < 100000) { - if (x % 1000 == 0) { - enc_ext(buffer, x / 1000, 'u'); - } else { - enc_ext(buffer, x, 'n'); - } - } else if (x < 100000000) { - if (x % 1000000 == 0) { - enc_ext(buffer, x / 1000000, 'm'); - } else { - enc_ext(buffer, x / 1000, 'u'); - } - } else if (x < 1000000000) { - enc_ext(buffer, x / 1000000, 'm'); + if (x < GPR_MS_PER_SEC) { + enc_ext(buffer, x, 'm'); } else { - /* note that this is only ever called with times of less than one second, - so if we reach here the time must have been rounded up to a whole second - (and no more) */ - memcpy(buffer, "1S", 3); - } -} - -static void enc_micros(char *buffer, int64_t x) { - x = round_up_to_three_sig_figs(x); - if (x < 100000) { - if (x % 1000 == 0) { - enc_ext(buffer, x / 1000, 'm'); + if (x % GPR_MS_PER_SEC == 0) { + enc_seconds(buffer, x / GPR_MS_PER_SEC); } else { - enc_ext(buffer, x, 'u'); + enc_ext(buffer, x, 'm'); } - } else if (x < 100000000) { - if (x % 1000000 == 0) { - enc_ext(buffer, x / 1000000, 'S'); - } else { - enc_ext(buffer, x / 1000, 'm'); - } - } else { - enc_ext(buffer, x / 1000000, 'S'); } } -void grpc_http2_encode_timeout(gpr_timespec timeout, char *buffer) { - if (timeout.tv_sec < 0) { +void grpc_http2_encode_timeout(grpc_millis timeout, char *buffer) { + if (timeout <= 0) { enc_tiny(buffer); - } else if (timeout.tv_sec == 0) { - enc_nanos(buffer, timeout.tv_nsec); - } else if (timeout.tv_sec < 1000 && timeout.tv_nsec != 0) { - enc_micros(buffer, - (int64_t)(timeout.tv_sec * 1000000) + - (timeout.tv_nsec / 1000 + (timeout.tv_nsec % 1000 != 0))); + } else if (timeout < 1000 * GPR_MS_PER_SEC) { + enc_millis(buffer, timeout); } else { - enc_seconds(buffer, timeout.tv_sec + (timeout.tv_nsec != 0)); + enc_seconds(buffer, + timeout / GPR_MS_PER_SEC + (timeout % GPR_MS_PER_SEC != 0)); } } @@ -121,7 +88,7 @@ static int is_all_whitespace(const char *p, const char *end) { return p == end; } -int grpc_http2_decode_timeout(grpc_slice text, gpr_timespec *timeout) { +int grpc_http2_decode_timeout(grpc_slice text, grpc_millis *timeout) { int32_t x = 0; const uint8_t *p = GRPC_SLICE_START_PTR(text); const uint8_t *end = GRPC_SLICE_END_PTR(text); @@ -136,7 +103,7 @@ int grpc_http2_decode_timeout(grpc_slice text, gpr_timespec *timeout) { /* spec allows max. 8 digits, but we allow values up to 1,000,000,000 */ if (x >= (100 * 1000 * 1000)) { if (x != (100 * 1000 * 1000) || digit != 0) { - *timeout = gpr_inf_future(GPR_TIMESPAN); + *timeout = GRPC_MILLIS_INF_FUTURE; return 1; } } @@ -150,22 +117,22 @@ int grpc_http2_decode_timeout(grpc_slice text, gpr_timespec *timeout) { /* decode unit specifier */ switch (*p) { case 'n': - *timeout = gpr_time_from_nanos(x, GPR_TIMESPAN); + *timeout = x / GPR_NS_PER_MS + (x % GPR_NS_PER_MS != 0); break; case 'u': - *timeout = gpr_time_from_micros(x, GPR_TIMESPAN); + *timeout = x / GPR_US_PER_MS + (x % GPR_US_PER_MS != 0); break; case 'm': - *timeout = gpr_time_from_millis(x, GPR_TIMESPAN); + *timeout = x; break; case 'S': - *timeout = gpr_time_from_seconds(x, GPR_TIMESPAN); + *timeout = x * GPR_MS_PER_SEC; break; case 'M': - *timeout = gpr_time_from_minutes(x, GPR_TIMESPAN); + *timeout = x * 60 * GPR_MS_PER_SEC; break; case 'H': - *timeout = gpr_time_from_hours(x, GPR_TIMESPAN); + *timeout = x * 60 * 60 * GPR_MS_PER_SEC; break; default: return 0; diff --git a/src/core/lib/transport/timeout_encoding.h b/src/core/lib/transport/timeout_encoding.h index 7ff35c40836..c8677719c4e 100644 --- a/src/core/lib/transport/timeout_encoding.h +++ b/src/core/lib/transport/timeout_encoding.h @@ -22,13 +22,14 @@ #include #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/support/string.h" #define GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE (GPR_LTOA_MIN_BUFSIZE + 1) /* Encode/decode timeouts to the GRPC over HTTP/2 format; encoding may round up arbitrarily */ -void grpc_http2_encode_timeout(gpr_timespec timeout, char *buffer); -int grpc_http2_decode_timeout(grpc_slice text, gpr_timespec *timeout); +void grpc_http2_encode_timeout(grpc_millis timeout, char *buffer); +int grpc_http2_decode_timeout(grpc_slice text, grpc_millis *timeout); #endif /* GRPC_CORE_LIB_TRANSPORT_TIMEOUT_ENCODING_H */ diff --git a/src/core/lib/transport/transport_op_string.c b/src/core/lib/transport/transport_op_string.c index 7b18229ba65..14414c7ee98 100644 --- a/src/core/lib/transport/transport_op_string.c +++ b/src/core/lib/transport/transport_op_string.c @@ -48,10 +48,9 @@ static void put_metadata_list(gpr_strvec *b, grpc_metadata_batch md) { if (m != md.list.head) gpr_strvec_add(b, gpr_strdup(", ")); put_metadata(b, m->md); } - if (gpr_time_cmp(md.deadline, gpr_inf_future(md.deadline.clock_type)) != 0) { + if (md.deadline != GRPC_MILLIS_INF_FUTURE) { char *tmp; - gpr_asprintf(&tmp, " deadline=%" PRId64 ".%09d", md.deadline.tv_sec, - md.deadline.tv_nsec); + gpr_asprintf(&tmp, " deadline=%" PRIdPTR, md.deadline); gpr_strvec_add(b, tmp); } } diff --git a/test/core/channel/channel_stack_test.c b/test/core/channel/channel_stack_test.c index 0c4bae6dedb..f78ebe7efac 100644 --- a/test/core/channel/channel_stack_test.c +++ b/test/core/channel/channel_stack_test.c @@ -130,7 +130,7 @@ static void test_create_channel_stack(void) { .context = NULL, .path = path, .start_time = gpr_now(GPR_CLOCK_MONOTONIC), - .deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC), + .deadline = GRPC_MILLIS_INF_FUTURE, .arena = NULL}; grpc_error *error = grpc_call_stack_init(&exec_ctx, channel_stack, 1, free_call, call_stack, &args); diff --git a/test/core/transport/status_conversion_test.c b/test/core/transport/status_conversion_test.c index 89558964c1c..de8fa4458a6 100644 --- a/test/core/transport/status_conversion_test.c +++ b/test/core/transport/status_conversion_test.c @@ -22,8 +22,13 @@ #define GRPC_STATUS_TO_HTTP2_ERROR(a, b) \ GPR_ASSERT(grpc_status_to_http2_error(a) == (b)) -#define HTTP2_ERROR_TO_GRPC_STATUS(a, deadline, b) \ - GPR_ASSERT(grpc_http2_error_to_grpc_status(a, deadline) == (b)) +#define HTTP2_ERROR_TO_GRPC_STATUS(a, deadline, b) \ + do { \ + grpc_exec_ctx my_exec_ctx = GRPC_EXEC_CTX_INIT; \ + GPR_ASSERT(grpc_http2_error_to_grpc_status(&my_exec_ctx, a, deadline) == \ + (b)); \ + grpc_exec_ctx_finish(&my_exec_ctx); \ + } while (0) #define GRPC_STATUS_TO_HTTP2_STATUS(a, b) \ GPR_ASSERT(grpc_status_to_http2_status(a) == (b)) #define HTTP2_STATUS_TO_GRPC_STATUS(a, b) \ @@ -79,7 +84,7 @@ int main(int argc, char **argv) { GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_UNAVAILABLE, 200); GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_DATA_LOSS, 200); - const gpr_timespec before_deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis before_deadline = GRPC_MILLIS_INF_FUTURE; HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_NO_ERROR, before_deadline, GRPC_STATUS_INTERNAL); HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_PROTOCOL_ERROR, before_deadline, @@ -107,7 +112,7 @@ int main(int argc, char **argv) { HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_INADEQUATE_SECURITY, before_deadline, GRPC_STATUS_PERMISSION_DENIED); - const gpr_timespec after_deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC); + const grpc_millis after_deadline = 0; HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_NO_ERROR, after_deadline, GRPC_STATUS_INTERNAL); HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_PROTOCOL_ERROR, after_deadline, diff --git a/test/core/transport/timeout_encoding_test.c b/test/core/transport/timeout_encoding_test.c index 6388ffbcec6..fcd263f1043 100644 --- a/test/core/transport/timeout_encoding_test.c +++ b/test/core/transport/timeout_encoding_test.c @@ -30,7 +30,7 @@ #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) -static void assert_encodes_as(gpr_timespec ts, const char *s) { +static void assert_encodes_as(grpc_millis ts, const char *s) { char buffer[GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE]; grpc_http2_encode_timeout(ts, buffer); gpr_log(GPR_INFO, "check '%s' == '%s'", buffer, s); @@ -39,47 +39,38 @@ static void assert_encodes_as(gpr_timespec ts, const char *s) { void test_encoding(void) { LOG_TEST("test_encoding"); - assert_encodes_as(gpr_time_from_micros(-1, GPR_TIMESPAN), "1n"); - assert_encodes_as(gpr_time_from_seconds(-10, GPR_TIMESPAN), "1n"); - assert_encodes_as(gpr_time_from_nanos(10, GPR_TIMESPAN), "10n"); - assert_encodes_as(gpr_time_from_nanos(999999999, GPR_TIMESPAN), "1S"); - assert_encodes_as(gpr_time_from_micros(1, GPR_TIMESPAN), "1u"); - assert_encodes_as(gpr_time_from_micros(10, GPR_TIMESPAN), "10u"); - assert_encodes_as(gpr_time_from_micros(100, GPR_TIMESPAN), "100u"); - assert_encodes_as(gpr_time_from_micros(890, GPR_TIMESPAN), "890u"); - assert_encodes_as(gpr_time_from_micros(900, GPR_TIMESPAN), "900u"); - assert_encodes_as(gpr_time_from_micros(901, GPR_TIMESPAN), "901u"); - assert_encodes_as(gpr_time_from_millis(1, GPR_TIMESPAN), "1m"); - assert_encodes_as(gpr_time_from_millis(2, GPR_TIMESPAN), "2m"); - assert_encodes_as(gpr_time_from_micros(10001, GPR_TIMESPAN), "10100u"); - assert_encodes_as(gpr_time_from_micros(999999, GPR_TIMESPAN), "1S"); - assert_encodes_as(gpr_time_from_millis(1000, GPR_TIMESPAN), "1S"); - assert_encodes_as(gpr_time_from_millis(2000, GPR_TIMESPAN), "2S"); - assert_encodes_as(gpr_time_from_millis(2500, GPR_TIMESPAN), "2500m"); - assert_encodes_as(gpr_time_from_millis(59900, GPR_TIMESPAN), "59900m"); - assert_encodes_as(gpr_time_from_seconds(50, GPR_TIMESPAN), "50S"); - assert_encodes_as(gpr_time_from_seconds(59, GPR_TIMESPAN), "59S"); - assert_encodes_as(gpr_time_from_seconds(60, GPR_TIMESPAN), "1M"); - assert_encodes_as(gpr_time_from_seconds(80, GPR_TIMESPAN), "80S"); - assert_encodes_as(gpr_time_from_seconds(90, GPR_TIMESPAN), "90S"); - assert_encodes_as(gpr_time_from_minutes(2, GPR_TIMESPAN), "2M"); - assert_encodes_as(gpr_time_from_minutes(20, GPR_TIMESPAN), "20M"); - assert_encodes_as(gpr_time_from_hours(1, GPR_TIMESPAN), "1H"); - assert_encodes_as(gpr_time_from_hours(10, GPR_TIMESPAN), "10H"); - assert_encodes_as(gpr_time_from_seconds(1000000000, GPR_TIMESPAN), - "1000000000S"); + assert_encodes_as(-1, "1n"); + assert_encodes_as(-10, "1n"); + assert_encodes_as(1, "1m"); + assert_encodes_as(10, "10m"); + assert_encodes_as(100, "100m"); + assert_encodes_as(890, "890m"); + assert_encodes_as(900, "900m"); + assert_encodes_as(901, "901m"); + assert_encodes_as(1000, "1S"); + assert_encodes_as(2000, "2S"); + assert_encodes_as(2500, "2500m"); + assert_encodes_as(59900, "59900m"); + assert_encodes_as(50000, "50S"); + assert_encodes_as(59000, "59S"); + assert_encodes_as(60000, "1M"); + assert_encodes_as(80000, "80S"); + assert_encodes_as(90000, "90S"); + assert_encodes_as(120000, "2M"); + assert_encodes_as(20 * 60 * GPR_MS_PER_SEC, "20M"); + assert_encodes_as(60 * 60 * GPR_MS_PER_SEC, "1H"); + assert_encodes_as(10 * 60 * 60 * GPR_MS_PER_SEC, "10H"); } -static void assert_decodes_as(const char *buffer, gpr_timespec expected) { - gpr_timespec got; +static void assert_decodes_as(const char *buffer, grpc_millis expected) { + grpc_millis got; gpr_log(GPR_INFO, "check decoding '%s'", buffer); GPR_ASSERT(1 == grpc_http2_decode_timeout( grpc_slice_from_static_string(buffer), &got)); - GPR_ASSERT(0 == gpr_time_cmp(got, expected)); + GPR_ASSERT(got == expected); } -void decode_suite(char ext, - gpr_timespec (*answer)(int64_t x, gpr_clock_type clock)) { +void decode_suite(char ext, grpc_millis (*answer)(int64_t x)) { long test_vals[] = {1, 12, 123, 1234, 12345, 123456, 1234567, 12345678, 123456789, 98765432, 9876543, 987654, 98765, 9876, 987, 98, 9}; @@ -87,41 +78,51 @@ void decode_suite(char ext, char *input; for (i = 0; i < GPR_ARRAY_SIZE(test_vals); i++) { gpr_asprintf(&input, "%ld%c", test_vals[i], ext); - assert_decodes_as(input, answer(test_vals[i], GPR_TIMESPAN)); + assert_decodes_as(input, answer(test_vals[i])); gpr_free(input); gpr_asprintf(&input, " %ld%c", test_vals[i], ext); - assert_decodes_as(input, answer(test_vals[i], GPR_TIMESPAN)); + assert_decodes_as(input, answer(test_vals[i])); gpr_free(input); gpr_asprintf(&input, "%ld %c", test_vals[i], ext); - assert_decodes_as(input, answer(test_vals[i], GPR_TIMESPAN)); + assert_decodes_as(input, answer(test_vals[i])); gpr_free(input); gpr_asprintf(&input, "%ld %c ", test_vals[i], ext); - assert_decodes_as(input, answer(test_vals[i], GPR_TIMESPAN)); + assert_decodes_as(input, answer(test_vals[i])); gpr_free(input); } } +static grpc_millis millis_from_nanos(int64_t x) { return x / GPR_NS_PER_MS; } +static grpc_millis millis_from_micros(int64_t x) { return x / GPR_US_PER_MS; } +static grpc_millis millis_from_millis(int64_t x) { return x; } +static grpc_millis millis_from_seconds(int64_t x) { return x * GPR_MS_PER_SEC; } +static grpc_millis millis_from_minutes(int64_t x) { + return x * 60 * GPR_MS_PER_SEC; +} +static grpc_millis millis_from_hours(int64_t x) { + return x * 3600 * GPR_MS_PER_SEC; +} + void test_decoding(void) { LOG_TEST("test_decoding"); - decode_suite('n', gpr_time_from_nanos); - decode_suite('u', gpr_time_from_micros); - decode_suite('m', gpr_time_from_millis); - decode_suite('S', gpr_time_from_seconds); - decode_suite('M', gpr_time_from_minutes); - decode_suite('H', gpr_time_from_hours); - assert_decodes_as("1000000000S", - gpr_time_from_seconds(1000 * 1000 * 1000, GPR_TIMESPAN)); - assert_decodes_as("1000000000000000000000u", gpr_inf_future(GPR_TIMESPAN)); - assert_decodes_as("1000000001S", gpr_inf_future(GPR_TIMESPAN)); - assert_decodes_as("2000000001S", gpr_inf_future(GPR_TIMESPAN)); - assert_decodes_as("9999999999S", gpr_inf_future(GPR_TIMESPAN)); + decode_suite('n', millis_from_nanos); + decode_suite('u', millis_from_micros); + decode_suite('m', millis_from_millis); + decode_suite('S', millis_from_seconds); + decode_suite('M', millis_from_minutes); + decode_suite('H', millis_from_hours); + assert_decodes_as("1000000000S", millis_from_seconds(1000 * 1000 * 1000)); + assert_decodes_as("1000000000000000000000u", GRPC_MILLIS_INF_FUTURE); + assert_decodes_as("1000000001S", GRPC_MILLIS_INF_FUTURE); + assert_decodes_as("2000000001S", GRPC_MILLIS_INF_FUTURE); + assert_decodes_as("9999999999S", GRPC_MILLIS_INF_FUTURE); } static void assert_decoding_fails(const char *s) { - gpr_timespec x; + grpc_millis x; GPR_ASSERT(0 == grpc_http2_decode_timeout(grpc_slice_from_static_string(s), &x)); } diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 508f7f94d6f..c248c2348c8 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -563,7 +563,7 @@ static void BM_IsolatedFilter(benchmark::State &state) { grpc_exec_ctx_flush(&exec_ctx); grpc_call_stack *call_stack = static_cast( gpr_zalloc(channel_stack->call_stack_size)); - gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); + grpc_millis deadline = GRPC_MILLIS_INF_FUTURE; gpr_timespec start_time = gpr_now(GPR_CLOCK_MONOTONIC); grpc_slice method = grpc_slice_from_static_string("/foo/bar"); grpc_call_final_info final_info; diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc index 567ef1cf24c..d3b98f4493d 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc @@ -296,7 +296,7 @@ static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State &state) { grpc_metadata_batch b; grpc_metadata_batch_init(&b); - b.deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); + b.deadline = GRPC_MILLIS_INF_FUTURE; std::vector elems = Metadata::GetElems(f.exec_ctx()); std::vector storage(elems.size()); for (size_t i = 0; i < elems.size(); i++) { @@ -377,7 +377,7 @@ static void BM_TransportStreamSend(benchmark::State &state) { grpc_metadata_batch b; grpc_metadata_batch_init(&b); - b.deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); + b.deadline = GRPC_MILLIS_INF_FUTURE; std::vector elems = RepresentativeClientInitialMetadata::GetElems(f.exec_ctx()); std::vector storage(elems.size()); @@ -497,7 +497,7 @@ static void BM_TransportStreamRecv(benchmark::State &state) { grpc_metadata_batch_init(&b); grpc_metadata_batch b_recv; grpc_metadata_batch_init(&b_recv); - b.deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); + b.deadline = GRPC_MILLIS_INF_FUTURE; std::vector elems = RepresentativeClientInitialMetadata::GetElems(f.exec_ctx()); std::vector storage(elems.size()); diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc index f79db15a473..574e76bfbd8 100644 --- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc +++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc @@ -70,9 +70,9 @@ static void cq_done_cb(grpc_exec_ctx* exec_ctx, void* done_arg, /* Queues a completion tag if deadline is > 0. * Does nothing if deadline is 0 (i.e gpr_time_0(GPR_CLOCK_MONOTONIC)) */ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* ps, - grpc_pollset_worker** worker, gpr_timespec now, - gpr_timespec deadline) { - if (gpr_time_cmp(deadline, gpr_time_0(GPR_CLOCK_MONOTONIC)) == 0) { + grpc_pollset_worker** worker, + grpc_millis deadline) { + if (deadline == 0) { gpr_log(GPR_DEBUG, "no-op"); return GRPC_ERROR_NONE; } diff --git a/test/cpp/microbenchmarks/bm_error.cc b/test/cpp/microbenchmarks/bm_error.cc index bd5f02e172e..56b80dfcf6d 100644 --- a/test/cpp/microbenchmarks/bm_error.cc +++ b/test/cpp/microbenchmarks/bm_error.cc @@ -159,39 +159,39 @@ BENCHMARK(BM_ErrorGetPresentInt); // Fixtures for tests: generate different kinds of errors class ErrorNone { public: - gpr_timespec deadline() const { return deadline_; } + grpc_millis deadline() const { return deadline_; } grpc_error* error() const { return GRPC_ERROR_NONE; } private: - const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE; }; class ErrorCancelled { public: - gpr_timespec deadline() const { return deadline_; } + grpc_millis deadline() const { return deadline_; } grpc_error* error() const { return GRPC_ERROR_CANCELLED; } private: - const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE; }; class SimpleError { public: - gpr_timespec deadline() const { return deadline_; } + grpc_millis deadline() const { return deadline_; } grpc_error* error() const { return error_.get(); } private: - const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE; ErrorPtr error_{GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error")}; }; class ErrorWithGrpcStatus { public: - gpr_timespec deadline() const { return deadline_; } + grpc_millis deadline() const { return deadline_; } grpc_error* error() const { return error_.get(); } private: - const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE; ErrorPtr error_{grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNIMPLEMENTED)}; @@ -199,11 +199,11 @@ class ErrorWithGrpcStatus { class ErrorWithHttpError { public: - gpr_timespec deadline() const { return deadline_; } + grpc_millis deadline() const { return deadline_; } grpc_error* error() const { return error_.get(); } private: - const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE; ErrorPtr error_{grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_COMPRESSION_ERROR)}; @@ -211,11 +211,11 @@ class ErrorWithHttpError { class ErrorWithNestedGrpcStatus { public: - gpr_timespec deadline() const { return deadline_; } + grpc_millis deadline() const { return deadline_; } grpc_error* error() const { return error_.get(); } private: - const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE; ErrorPtr nested_error_{grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNIMPLEMENTED)}; @@ -248,12 +248,14 @@ template static void BM_ErrorGetStatus(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { grpc_status_code status; grpc_slice slice; - grpc_error_get_status(fixture.error(), fixture.deadline(), &status, &slice, - NULL); + grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(), + &status, &slice, NULL); } + grpc_exec_ctx_finish(&exec_ctx); track_counters.Finish(state); } @@ -261,11 +263,13 @@ template static void BM_ErrorGetStatusCode(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { grpc_status_code status; - grpc_error_get_status(fixture.error(), fixture.deadline(), &status, NULL, - NULL); + grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(), + &status, NULL, NULL); } + grpc_exec_ctx_finish(&exec_ctx); track_counters.Finish(state); } @@ -273,11 +277,13 @@ template static void BM_ErrorHttpError(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { grpc_http2_error_code error; - grpc_error_get_status(fixture.error(), fixture.deadline(), NULL, NULL, - &error); + grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(), NULL, + NULL, &error); } + grpc_exec_ctx_finish(&exec_ctx); track_counters.Finish(state); } diff --git a/test/cpp/microbenchmarks/bm_pollset.cc b/test/cpp/microbenchmarks/bm_pollset.cc index 683f4703c2a..cd62e691d67 100644 --- a/test/cpp/microbenchmarks/bm_pollset.cc +++ b/test/cpp/microbenchmarks/bm_pollset.cc @@ -117,11 +117,9 @@ static void BM_PollEmptyPollset(benchmark::State& state) { gpr_mu* mu; grpc_pollset_init(ps, &mu); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - gpr_timespec now = gpr_time_0(GPR_CLOCK_MONOTONIC); - gpr_timespec deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC); gpr_mu_lock(mu); while (state.KeepRunning()) { - GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, NULL, now, deadline)); + GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, NULL, 0)); } grpc_closure shutdown_ps_closure; GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps, @@ -223,8 +221,6 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) { gpr_mu* mu; grpc_pollset_init(ps, &mu); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - gpr_timespec now = gpr_time_0(GPR_CLOCK_MONOTONIC); - gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); grpc_wakeup_fd wakeup_fd; GRPC_ERROR_UNREF(grpc_wakeup_fd_init(&wakeup_fd)); grpc_fd* wakeup = grpc_fd_create(wakeup_fd.read_fd, "wakeup_read"); @@ -245,7 +241,8 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) { grpc_fd_notify_on_read(&exec_ctx, wakeup, continue_closure); gpr_mu_lock(mu); while (!done) { - GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, NULL, now, deadline)); + GRPC_ERROR_UNREF( + grpc_pollset_work(&exec_ctx, ps, NULL, GRPC_MILLIS_INF_FUTURE)); } grpc_fd_orphan(&exec_ctx, wakeup, NULL, NULL, "done"); wakeup_fd.read_fd = 0; From 6b7c1fbe3e1bcc8f5e20a72acdfec501ac837133 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 19 Jul 2017 15:45:03 -0700 Subject: [PATCH 011/142] Distrib stuff --- src/core/lib/backoff/backoff.h | 6 +++--- src/core/lib/compression/stream_compression.h | 2 +- src/core/lib/iomgr/block_annotate.h | 6 +++--- src/core/lib/iomgr/ev_epoll1_linux.c | 2 +- src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c | 2 +- src/core/lib/iomgr/ev_epoll_thread_pool_linux.c | 2 +- src/core/lib/iomgr/ev_epollex_linux.c | 2 +- src/core/lib/iomgr/ev_epollsig_linux.c | 2 +- src/core/lib/iomgr/ev_poll_posix.c | 2 +- src/core/lib/iomgr/resolve_address_posix.c | 2 +- src/core/lib/iomgr/resolve_address_windows.c | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/core/lib/backoff/backoff.h b/src/core/lib/backoff/backoff.h index f1258bcdc5b..de708e686ed 100644 --- a/src/core/lib/backoff/backoff.h +++ b/src/core/lib/backoff/backoff.h @@ -16,8 +16,8 @@ * */ -#ifndef GRPC_CORE_LIB_SUPPORT_BACKOFF_H -#define GRPC_CORE_LIB_SUPPORT_BACKOFF_H +#ifndef GRPC_CORE_LIB_BACKOFF_BACKOFF_H +#define GRPC_CORE_LIB_BACKOFF_BACKOFF_H #include "src/core/lib/iomgr/exec_ctx.h" @@ -54,4 +54,4 @@ grpc_millis grpc_backoff_step(grpc_exec_ctx *exec_ctx, grpc_backoff *backoff); /// instead void grpc_backoff_reset(grpc_backoff *backoff); -#endif /* GRPC_CORE_LIB_SUPPORT_BACKOFF_H */ +#endif /* GRPC_CORE_LIB_BACKOFF_BACKOFF_H */ diff --git a/src/core/lib/compression/stream_compression.h b/src/core/lib/compression/stream_compression.h index 844dff81a3b..0daaa9e655e 100644 --- a/src/core/lib/compression/stream_compression.h +++ b/src/core/lib/compression/stream_compression.h @@ -87,4 +87,4 @@ grpc_stream_compression_context *grpc_stream_compression_context_create( void grpc_stream_compression_context_destroy( grpc_stream_compression_context *ctx); -#endif +#endif /* GRPC_CORE_LIB_COMPRESSION_STREAM_COMPRESSION_H */ diff --git a/src/core/lib/iomgr/block_annotate.h b/src/core/lib/iomgr/block_annotate.h index e20faea9001..7d6d547ff0c 100644 --- a/src/core/lib/iomgr/block_annotate.h +++ b/src/core/lib/iomgr/block_annotate.h @@ -16,8 +16,8 @@ * */ -#ifndef GRPC_CORE_LIB_SUPPORT_BLOCK_ANNOTATE_H -#define GRPC_CORE_LIB_SUPPORT_BLOCK_ANNOTATE_H +#ifndef GRPC_CORE_LIB_IOMGR_BLOCK_ANNOTATE_H +#define GRPC_CORE_LIB_IOMGR_BLOCK_ANNOTATE_H /* These annotations identify the beginning and end of regions where the code may block for reasons other than synchronization functions. @@ -34,4 +34,4 @@ grpc_exec_ctx_invalidate_now((ec)); \ } while (0) -#endif /* GRPC_CORE_LIB_SUPPORT_BLOCK_ANNOTATE_H */ +#endif /* GRPC_CORE_LIB_IOMGR_BLOCK_ANNOTATE_H */ diff --git a/src/core/lib/iomgr/ev_epoll1_linux.c b/src/core/lib/iomgr/ev_epoll1_linux.c index a3586547d46..de950af3dcb 100644 --- a/src/core/lib/iomgr/ev_epoll1_linux.c +++ b/src/core/lib/iomgr/ev_epoll1_linux.c @@ -40,12 +40,12 @@ #include #include +#include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/iomgr_internal.h" #include "src/core/lib/iomgr/lockfree_event.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/profiling/timers.h" -#include "src/core/lib/iomgr/block_annotate.h" static grpc_wakeup_fd global_wakeup_fd; static int g_epfd; diff --git a/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c b/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c index 05e9ca448a7..1116a124db3 100644 --- a/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +++ b/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c @@ -41,13 +41,13 @@ #include #include "src/core/lib/debug/trace.h" +#include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/iomgr_internal.h" #include "src/core/lib/iomgr/lockfree_event.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/profiling/timers.h" -#include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/support/env.h" #define GRPC_POLLING_TRACE(fmt, ...) \ diff --git a/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c b/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c index bbcc475d7ed..d71d11fe434 100644 --- a/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +++ b/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c @@ -41,13 +41,13 @@ #include #include +#include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/iomgr_internal.h" #include "src/core/lib/iomgr/lockfree_event.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/profiling/timers.h" -#include "src/core/lib/iomgr/block_annotate.h" /* TODO: sreek - Move this to init.c and initialize this like other tracers. */ #define GRPC_POLLING_TRACE(fmt, ...) \ diff --git a/src/core/lib/iomgr/ev_epollex_linux.c b/src/core/lib/iomgr/ev_epollex_linux.c index 7db95fe9b43..a126f09a42e 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.c +++ b/src/core/lib/iomgr/ev_epollex_linux.c @@ -38,6 +38,7 @@ #include #include +#include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/iomgr_internal.h" #include "src/core/lib/iomgr/is_epollexclusive_available.h" @@ -46,7 +47,6 @@ #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/profiling/timers.h" -#include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/support/spinlock.h" /******************************************************************************* diff --git a/src/core/lib/iomgr/ev_epollsig_linux.c b/src/core/lib/iomgr/ev_epollsig_linux.c index fc5212ab5e4..cd03f0720e2 100644 --- a/src/core/lib/iomgr/ev_epollsig_linux.c +++ b/src/core/lib/iomgr/ev_epollsig_linux.c @@ -40,13 +40,13 @@ #include #include +#include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/iomgr_internal.h" #include "src/core/lib/iomgr/lockfree_event.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/profiling/timers.h" -#include "src/core/lib/iomgr/block_annotate.h" #define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1) diff --git a/src/core/lib/iomgr/ev_poll_posix.c b/src/core/lib/iomgr/ev_poll_posix.c index c6456bee188..efe92c0cba1 100644 --- a/src/core/lib/iomgr/ev_poll_posix.c +++ b/src/core/lib/iomgr/ev_poll_posix.c @@ -37,12 +37,12 @@ #include #include +#include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/iomgr_internal.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/iomgr/wakeup_fd_cv.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/profiling/timers.h" -#include "src/core/lib/iomgr/block_annotate.h" #define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1) diff --git a/src/core/lib/iomgr/resolve_address_posix.c b/src/core/lib/iomgr/resolve_address_posix.c index d58ec4168ef..8044f8c12a9 100644 --- a/src/core/lib/iomgr/resolve_address_posix.c +++ b/src/core/lib/iomgr/resolve_address_posix.c @@ -33,10 +33,10 @@ #include #include #include +#include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr_internal.h" #include "src/core/lib/iomgr/unix_sockets_posix.h" -#include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/support/string.h" static grpc_error *blocking_resolve_address_impl( diff --git a/src/core/lib/iomgr/resolve_address_windows.c b/src/core/lib/iomgr/resolve_address_windows.c index ee09d127b45..3217bb4b2c5 100644 --- a/src/core/lib/iomgr/resolve_address_windows.c +++ b/src/core/lib/iomgr/resolve_address_windows.c @@ -33,10 +33,10 @@ #include #include #include +#include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr_internal.h" #include "src/core/lib/iomgr/sockaddr_utils.h" -#include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/support/string.h" typedef struct { From f7c7e14438315442df818cb0c350e7d88657e1ce Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 19 Jul 2017 20:20:35 -0700 Subject: [PATCH 012/142] Casting --- src/core/ext/filters/max_age/max_age_filter.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/ext/filters/max_age/max_age_filter.c b/src/core/ext/filters/max_age/max_age_filter.c index 2a785efc045..62b28d7cc9a 100644 --- a/src/core/ext/filters/max_age/max_age_filter.c +++ b/src/core/ext/filters/max_age/max_age_filter.c @@ -254,8 +254,9 @@ add_random_max_connection_age_jitter_and_convert_to_grpc_millis(int value) { double result = multiplier * value; /* INT_MAX - 0.5 converts the value to float, so that result will not be cast to int implicitly before the comparison. */ - return result > GRPC_MILLIS_INF_FUTURE - 0.5 ? GRPC_MILLIS_INF_FUTURE - : (int)result; + return result > ((double)GRPC_MILLIS_INF_FUTURE) - 0.5 + ? GRPC_MILLIS_INF_FUTURE + : (grpc_millis)result; } /* Constructor for call_data. */ From f71f68e685039ae43e06e995048dc3cd555637a1 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 20 Jul 2017 09:08:47 -0700 Subject: [PATCH 013/142] Swap some more types --- src/core/lib/backoff/backoff.c | 7 ++++--- src/core/lib/backoff/backoff.h | 13 +++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/core/lib/backoff/backoff.c b/src/core/lib/backoff/backoff.c index 141b952134f..e964af8f397 100644 --- a/src/core/lib/backoff/backoff.c +++ b/src/core/lib/backoff/backoff.c @@ -20,9 +20,10 @@ #include -void grpc_backoff_init(grpc_backoff *backoff, int64_t initial_connect_timeout, - double multiplier, double jitter, - int64_t min_timeout_millis, int64_t max_timeout_millis) { +void grpc_backoff_init(grpc_backoff *backoff, + grpc_millis initial_connect_timeout, double multiplier, + double jitter, grpc_millis min_timeout_millis, + grpc_millis max_timeout_millis) { backoff->initial_connect_timeout = initial_connect_timeout; backoff->multiplier = multiplier; backoff->jitter = jitter; diff --git a/src/core/lib/backoff/backoff.h b/src/core/lib/backoff/backoff.h index de708e686ed..c0798bbe5b0 100644 --- a/src/core/lib/backoff/backoff.h +++ b/src/core/lib/backoff/backoff.h @@ -23,15 +23,15 @@ typedef struct { /// const: how long to wait after the first failure before retrying - int64_t initial_connect_timeout; + grpc_millis initial_connect_timeout; /// const: factor with which to multiply backoff after a failed retry double multiplier; /// const: amount to randomize backoffs double jitter; /// const: minimum time between retries in milliseconds - int64_t min_timeout_millis; + grpc_millis min_timeout_millis; /// const: maximum time between retries in milliseconds - int64_t max_timeout_millis; + grpc_millis max_timeout_millis; /// random number generator uint32_t rng_state; @@ -41,9 +41,10 @@ typedef struct { } grpc_backoff; /// Initialize backoff machinery - does not need to be destroyed -void grpc_backoff_init(grpc_backoff *backoff, int64_t initial_connect_timeout, - double multiplier, double jitter, - int64_t min_timeout_millis, int64_t max_timeout_millis); +void grpc_backoff_init(grpc_backoff *backoff, + grpc_millis initial_connect_timeout, double multiplier, + double jitter, grpc_millis min_timeout_millis, + grpc_millis max_timeout_millis); /// Begin retry loop: returns a timespec for the NEXT retry grpc_millis grpc_backoff_begin(grpc_exec_ctx *exec_ctx, grpc_backoff *backoff); From d8df87b6d29c5b240f0ee19da11e2c60fcdaaa24 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 20 Jul 2017 09:12:30 -0700 Subject: [PATCH 014/142] Avoid infinite loop --- src/core/lib/iomgr/timer_manager.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/lib/iomgr/timer_manager.c b/src/core/lib/iomgr/timer_manager.c index cd2a3a8c784..3d056ad18f7 100644 --- a/src/core/lib/iomgr/timer_manager.c +++ b/src/core/lib/iomgr/timer_manager.c @@ -189,6 +189,7 @@ static bool wait_until(grpc_exec_ctx *exec_ctx, grpc_millis next) { gpr_cv_wait(&g_cv_wait, &g_mu, grpc_millis_to_timespec(next, GPR_CLOCK_REALTIME)); + grpc_exec_ctx_invalidate_now(exec_ctx); if (GRPC_TRACER_ON(grpc_timer_check_trace)) { gpr_log(GPR_DEBUG, "wait ended: was_timed:%d kicked:%d", From d3b3037421c2ee74a097e48a25e110c240ed8d33 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 20 Jul 2017 10:05:54 -0700 Subject: [PATCH 015/142] Add fix for casting bug --- src/core/lib/iomgr/timer_generic.c | 15 +++++++++++---- src/core/lib/iomgr/timer_manager.c | 5 ++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/core/lib/iomgr/timer_generic.c b/src/core/lib/iomgr/timer_generic.c index 3446e11a95e..5fa35d97873 100644 --- a/src/core/lib/iomgr/timer_generic.c +++ b/src/core/lib/iomgr/timer_generic.c @@ -35,7 +35,7 @@ #define INVALID_HEAP_INDEX 0xffffffffu -#define LOG2_NUM_SHARDS 5 +#define LOG2_NUM_SHARDS 0 #define NUM_SHARDS (1 << LOG2_NUM_SHARDS) #define ADD_DEADLINE_SCALE 0.33 #define MIN_QUEUE_WINDOW_DURATION 0.01 @@ -199,6 +199,7 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer, int is_first_timer = 0; timer_shard *shard = &g_shards[GPR_HASH_POINTER(timer, NUM_SHARDS)]; timer->closure = closure; + timer->deadline = deadline; if (GRPC_TRACER_ON(grpc_timer_trace)) { gpr_log(GPR_DEBUG, @@ -362,8 +363,9 @@ static grpc_timer *pop_one(timer_shard *shard, gpr_atm now) { } if (timer->deadline > now) return NULL; if (GRPC_TRACER_ON(grpc_timer_trace)) { - gpr_log(GPR_DEBUG, "TIMER %p: FIRE %" PRIdPTR "ms late", timer, - now - timer->deadline); + gpr_log(GPR_DEBUG, "TIMER %p: FIRE %" PRIdPTR "ms late via %s scheduler", + timer, now - timer->deadline, + timer->closure->scheduler->vtable->name); } timer->pending = false; grpc_timer_heap_pop(&shard->heap); @@ -384,6 +386,10 @@ static size_t pop_timers(grpc_exec_ctx *exec_ctx, timer_shard *shard, } *new_min_deadline = compute_min_deadline(shard); gpr_mu_unlock(&shard->mu); + if (GRPC_TRACER_ON(grpc_timer_check_trace)) { + gpr_log(GPR_DEBUG, " .. shard[%d] popped %" PRIdPTR, + (int)(shard - g_shards), n); + } return n; } @@ -495,7 +501,8 @@ grpc_timer_check_result grpc_timer_check(grpc_exec_ctx *exec_ctx, gpr_free(next_str); } // actual code - bool r = run_some_expired_timers(exec_ctx, now, next, shutdown_error); + grpc_timer_check_result r = + run_some_expired_timers(exec_ctx, now, next, shutdown_error); // tracing if (GRPC_TRACER_ON(grpc_timer_check_trace)) { char *next_str; diff --git a/src/core/lib/iomgr/timer_manager.c b/src/core/lib/iomgr/timer_manager.c index 3d056ad18f7..6232172acae 100644 --- a/src/core/lib/iomgr/timer_manager.c +++ b/src/core/lib/iomgr/timer_manager.c @@ -120,6 +120,9 @@ static void run_some_timers(grpc_exec_ctx *exec_ctx) { gpr_mu_unlock(&g_mu); } // without our lock, flush the exec_ctx + if (GRPC_TRACER_ON(grpc_timer_check_trace)) { + gpr_log(GPR_DEBUG, "flush exec_ctx"); + } grpc_exec_ctx_flush(exec_ctx); gpr_mu_lock(&g_mu); // garbage collect any threads hanging out that are dead @@ -189,7 +192,6 @@ static bool wait_until(grpc_exec_ctx *exec_ctx, grpc_millis next) { gpr_cv_wait(&g_cv_wait, &g_mu, grpc_millis_to_timespec(next, GPR_CLOCK_REALTIME)); - grpc_exec_ctx_invalidate_now(exec_ctx); if (GRPC_TRACER_ON(grpc_timer_check_trace)) { gpr_log(GPR_DEBUG, "wait ended: was_timed:%d kicked:%d", @@ -219,6 +221,7 @@ static bool wait_until(grpc_exec_ctx *exec_ctx, grpc_millis next) { static void timer_main_loop(grpc_exec_ctx *exec_ctx) { for (;;) { grpc_millis next = GRPC_MILLIS_INF_FUTURE; + grpc_exec_ctx_invalidate_now(exec_ctx); // check timer state, updates next to the next time to run a check switch (grpc_timer_check(exec_ctx, &next)) { case GRPC_TIMERS_FIRED: From e0a90891db955f88cd3c8259255656d73c537725 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 20 Jul 2017 10:19:42 -0700 Subject: [PATCH 016/142] Fix shard count --- src/core/lib/iomgr/timer_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/timer_generic.c b/src/core/lib/iomgr/timer_generic.c index 5fa35d97873..8ed03620419 100644 --- a/src/core/lib/iomgr/timer_generic.c +++ b/src/core/lib/iomgr/timer_generic.c @@ -35,7 +35,7 @@ #define INVALID_HEAP_INDEX 0xffffffffu -#define LOG2_NUM_SHARDS 0 +#define LOG2_NUM_SHARDS 5 #define NUM_SHARDS (1 << LOG2_NUM_SHARDS) #define ADD_DEADLINE_SCALE 0.33 #define MIN_QUEUE_WINDOW_DURATION 0.01 From 07e81dd900e3040d7c12b30ce43e7f93b8cbb2b6 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 20 Jul 2017 13:55:58 -0700 Subject: [PATCH 017/142] Fix bad test --- .../chttp2/transport/chttp2_transport.c | 24 +++++++++++-------- test/core/end2end/tests/bad_ping.c | 17 ++++++------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 658d2d1e7b2..9e0253e4ade 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -1563,16 +1563,20 @@ static void send_goaway(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, void grpc_chttp2_add_ping_strike(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t) { - gpr_log(GPR_DEBUG, "PING strike"); - if (++t->ping_recv_state.ping_strikes > t->ping_policy.max_ping_strikes && - t->ping_policy.max_ping_strikes != 0) { - send_goaway(exec_ctx, t, - grpc_error_set_int( - GRPC_ERROR_CREATE_FROM_STATIC_STRING("too_many_pings"), - GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM)); - /*The transport will be closed after the write is done */ - close_transport_locked( - exec_ctx, t, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many pings")); + t->ping_recv_state.ping_strikes++; + if (t->ping_policy.max_ping_strikes != 0) { + gpr_log(GPR_DEBUG, "%s: PING strike %d/%d", t->peer_string, + t->ping_recv_state.ping_strikes, t->ping_policy.max_ping_strikes); + if (t->ping_recv_state.ping_strikes > t->ping_policy.max_ping_strikes) { + send_goaway( + exec_ctx, t, + grpc_error_set_int( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("too_many_pings"), + GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM)); + /*The transport will be closed after the write is done */ + close_transport_locked( + exec_ctx, t, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many pings")); + } } } diff --git a/test/core/end2end/tests/bad_ping.c b/test/core/end2end/tests/bad_ping.c index 12aceda6881..49810561922 100644 --- a/test/core/end2end/tests/bad_ping.c +++ b/test/core/end2end/tests/bad_ping.c @@ -154,14 +154,16 @@ static void test_bad_ping(grpc_end2end_test_config config) { cq_verify(cqv); // Send too many pings to the server to trigger the punishment: - // The first ping is sent after data frames, it won't trigger a ping strike. - // Each of the following pings will trigger a ping strike, and we need at - // least (MAX_PING_STRIKES + 1) strikes to trigger the punishment. So - // (MAX_PING_STRIKES + 2) pings are needed here. + // Each ping will trigger a ping strike, and we need at least MAX_PING_STRIKES + // strikes to trigger the punishment. So (MAX_PING_STRIKES + 1) pings are + // needed here. int i; - for (i = 200; i < 202 + MAX_PING_STRIKES; i++) { - grpc_channel_ping(f.client, f.cq, tag(i), NULL); - CQ_EXPECT_COMPLETION(cqv, tag(i), 1); + for (i = 1; i <= MAX_PING_STRIKES + 1; i++) { + grpc_channel_ping(f.client, f.cq, tag(200 + i), NULL); + CQ_EXPECT_COMPLETION(cqv, tag(200 + i), 1); + if (i == MAX_PING_STRIKES + 1) { + CQ_EXPECT_COMPLETION(cqv, tag(1), 1); + } cq_verify(cqv); } @@ -189,7 +191,6 @@ static void test_bad_ping(grpc_end2end_test_config config) { GPR_ASSERT(GRPC_CALL_OK == error); CQ_EXPECT_COMPLETION(cqv, tag(102), 1); - CQ_EXPECT_COMPLETION(cqv, tag(1), 1); cq_verify(cqv); grpc_server_shutdown_and_notify(f.server, f.cq, tag(0xdead)); From 81150aaab467f9ee3f7620c1fe8de0b585f51cc0 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 20 Jul 2017 16:24:03 -0700 Subject: [PATCH 018/142] Fix overflow --- src/core/ext/filters/max_age/max_age_filter.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/ext/filters/max_age/max_age_filter.c b/src/core/ext/filters/max_age/max_age_filter.c index 62b28d7cc9a..83e62c0191a 100644 --- a/src/core/ext/filters/max_age/max_age_filter.c +++ b/src/core/ext/filters/max_age/max_age_filter.c @@ -142,9 +142,12 @@ static void start_max_age_grace_timer_after_goaway_op(grpc_exec_ctx* exec_ctx, gpr_mu_lock(&chand->max_age_timer_mu); chand->max_age_grace_timer_pending = true; GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_age_grace_timer"); - grpc_timer_init(exec_ctx, &chand->max_age_grace_timer, - grpc_exec_ctx_now(exec_ctx) + chand->max_connection_age_grace, - &chand->force_close_max_age_channel); + grpc_timer_init( + exec_ctx, &chand->max_age_grace_timer, + chand->max_connection_age_grace == GRPC_MILLIS_INF_FUTURE + ? GRPC_MILLIS_INF_FUTURE + : grpc_exec_ctx_now(exec_ctx) + chand->max_connection_age_grace, + &chand->force_close_max_age_channel); gpr_mu_unlock(&chand->max_age_timer_mu); GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack, "max_age start_max_age_grace_timer_after_goaway_op"); From 9a8c3f398aed287decf6f8966a46478624f7c4f1 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 21 Jul 2017 13:14:14 -0700 Subject: [PATCH 019/142] Explicitly call out round up vs round down --- .../client_channel/channel_connectivity.c | 3 ++- .../ext/filters/client_channel/client_channel.c | 2 +- src/core/lib/iomgr/exec_ctx.c | 17 ++++++++++++++++- src/core/lib/iomgr/exec_ctx.h | 3 ++- src/core/lib/surface/alarm.c | 4 ++-- src/core/lib/surface/channel.c | 4 ++-- src/core/lib/surface/completion_queue.c | 4 ++-- test/core/http/httpcli_test.c | 3 ++- test/core/http/httpscli_test.c | 3 ++- test/core/iomgr/endpoint_tests.c | 4 ++-- test/core/iomgr/resolve_address_posix_test.c | 3 ++- test/core/iomgr/resolve_address_test.c | 3 ++- test/core/iomgr/tcp_client_posix_test.c | 8 ++++---- test/core/iomgr/tcp_posix_test.c | 10 +++++----- test/core/iomgr/tcp_server_posix_test.c | 2 +- test/core/iomgr/udp_server_test.c | 3 ++- test/core/util/test_tcp_server.c | 4 ++-- 17 files changed, 51 insertions(+), 29 deletions(-) diff --git a/src/core/ext/filters/client_channel/channel_connectivity.c b/src/core/ext/filters/client_channel/channel_connectivity.c index 72324d7eb1f..0a1d6f32079 100644 --- a/src/core/ext/filters/client_channel/channel_connectivity.c +++ b/src/core/ext/filters/client_channel/channel_connectivity.c @@ -186,7 +186,8 @@ static void watcher_timer_init(grpc_exec_ctx *exec_ctx, void *arg, watcher_timer_init_arg *wa = (watcher_timer_init_arg *)arg; grpc_timer_init(exec_ctx, &wa->w->alarm, - grpc_timespec_to_millis(wa->deadline), &wa->w->on_timeout); + grpc_timespec_to_millis_round_up(wa->deadline), + &wa->w->on_timeout); gpr_free(wa); } diff --git a/src/core/ext/filters/client_channel/client_channel.c b/src/core/ext/filters/client_channel/client_channel.c index 508c473c6ac..47bbd8416e5 100644 --- a/src/core/ext/filters/client_channel/client_channel.c +++ b/src/core/ext/filters/client_channel/client_channel.c @@ -956,7 +956,7 @@ static void apply_service_config_to_call_locked(grpc_exec_ctx *exec_ctx, if (chand->deadline_checking_enabled && calld->method_params->timeout != 0) { const grpc_millis per_method_deadline = - grpc_timespec_to_millis(calld->call_start_time) + + grpc_timespec_to_millis_round_up(calld->call_start_time) + calld->method_params->timeout; if (per_method_deadline < calld->deadline) { calld->deadline = per_method_deadline; diff --git a/src/core/lib/iomgr/exec_ctx.c b/src/core/lib/iomgr/exec_ctx.c index 80aaaee0cb6..884227b928b 100644 --- a/src/core/lib/iomgr/exec_ctx.c +++ b/src/core/lib/iomgr/exec_ctx.c @@ -125,6 +125,16 @@ static gpr_atm timespec_to_atm_round_down(gpr_timespec ts) { return (gpr_atm)x; } +static gpr_atm timespec_to_atm_round_up(gpr_timespec ts) { + ts = gpr_time_sub(ts, g_start_time); + double x = GPR_MS_PER_SEC * (double)ts.tv_sec + + (double)ts.tv_nsec / GPR_NS_PER_MS + + (double)(GPR_NS_PER_SEC - 1) / (double)GPR_NS_PER_SEC; + if (x < 0) return 0; + if (x > GPR_ATM_MAX) return GPR_ATM_MAX; + return (gpr_atm)x; +} + grpc_millis grpc_exec_ctx_now(grpc_exec_ctx *exec_ctx) { if (!exec_ctx->now_is_valid) { exec_ctx->now = timespec_to_atm_round_down(gpr_now(GPR_CLOCK_MONOTONIC)); @@ -143,11 +153,16 @@ gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_time_from_millis(millis, GPR_TIMESPAN)); } -grpc_millis grpc_timespec_to_millis(gpr_timespec ts) { +grpc_millis grpc_timespec_to_millis_round_down(gpr_timespec ts) { return timespec_to_atm_round_down( gpr_convert_clock_type(ts, g_start_time.clock_type)); } +grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec ts) { + return timespec_to_atm_round_up( + gpr_convert_clock_type(ts, g_start_time.clock_type)); +} + static const grpc_closure_scheduler_vtable exec_ctx_scheduler_vtable = { exec_ctx_run, exec_ctx_sched, "exec_ctx"}; static grpc_closure_scheduler exec_ctx_scheduler = {&exec_ctx_scheduler_vtable}; diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h index 87383809f3d..bb561ee1c88 100644 --- a/src/core/lib/iomgr/exec_ctx.h +++ b/src/core/lib/iomgr/exec_ctx.h @@ -114,6 +114,7 @@ void grpc_exec_ctx_global_shutdown(void); grpc_millis grpc_exec_ctx_now(grpc_exec_ctx *exec_ctx); void grpc_exec_ctx_invalidate_now(grpc_exec_ctx *exec_ctx); gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_clock_type clock); -grpc_millis grpc_timespec_to_millis(gpr_timespec timespec); +grpc_millis grpc_timespec_to_millis_round_down(gpr_timespec timespec); +grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec timespec); #endif /* GRPC_CORE_LIB_IOMGR_EXEC_CTX_H */ diff --git a/src/core/lib/surface/alarm.c b/src/core/lib/surface/alarm.c index 5140780bacc..39b9f45d057 100644 --- a/src/core/lib/surface/alarm.c +++ b/src/core/lib/surface/alarm.c @@ -52,8 +52,8 @@ grpc_alarm *grpc_alarm_create(grpc_completion_queue *cq, gpr_timespec deadline, grpc_cq_begin_op(cq, tag); GRPC_CLOSURE_INIT(&alarm->on_alarm, alarm_cb, alarm, grpc_schedule_on_exec_ctx); - grpc_timer_init(&exec_ctx, &alarm->alarm, grpc_timespec_to_millis(deadline), - &alarm->on_alarm); + grpc_timer_init(&exec_ctx, &alarm->alarm, + grpc_timespec_to_millis_round_up(deadline), &alarm->on_alarm); grpc_exec_ctx_finish(&exec_ctx); return alarm; } diff --git a/src/core/lib/surface/channel.c b/src/core/lib/surface/channel.c index b0ff428393f..9013e6338b8 100644 --- a/src/core/lib/surface/channel.c +++ b/src/core/lib/surface/channel.c @@ -276,7 +276,7 @@ grpc_call *grpc_channel_create_call(grpc_channel *channel, host != NULL ? grpc_mdelem_from_slices(&exec_ctx, GRPC_MDSTR_AUTHORITY, grpc_slice_ref_internal(*host)) : GRPC_MDNULL, - grpc_timespec_to_millis(deadline)); + grpc_timespec_to_millis_round_up(deadline)); grpc_exec_ctx_finish(&exec_ctx); return call; } @@ -341,7 +341,7 @@ grpc_call *grpc_channel_create_registered_call( grpc_call *call = grpc_channel_create_call_internal( &exec_ctx, channel, parent_call, propagation_mask, completion_queue, NULL, GRPC_MDELEM_REF(rc->path), GRPC_MDELEM_REF(rc->authority), - grpc_timespec_to_millis(deadline)); + grpc_timespec_to_millis_round_up(deadline)); grpc_exec_ctx_finish(&exec_ctx); return call; } diff --git a/src/core/lib/surface/completion_queue.c b/src/core/lib/surface/completion_queue.c index f3a89772411..25f8ff6b6a8 100644 --- a/src/core/lib/surface/completion_queue.c +++ b/src/core/lib/surface/completion_queue.c @@ -815,7 +815,7 @@ static grpc_event cq_next(grpc_completion_queue *cq, gpr_timespec deadline, GRPC_CQ_INTERNAL_REF(cq, "next"); - grpc_millis deadline_millis = grpc_timespec_to_millis(deadline); + grpc_millis deadline_millis = grpc_timespec_to_millis_round_up(deadline); cq_is_finished_arg is_finished_arg = { .last_seen_things_queued_ever = gpr_atm_no_barrier_load(&cqd->things_queued_ever), @@ -1048,7 +1048,7 @@ static grpc_event cq_pluck(grpc_completion_queue *cq, void *tag, GRPC_CQ_INTERNAL_REF(cq, "pluck"); gpr_mu_lock(cq->mu); - grpc_millis deadline_millis = grpc_timespec_to_millis(deadline); + grpc_millis deadline_millis = grpc_timespec_to_millis_round_up(deadline); cq_is_finished_arg is_finished_arg = { .last_seen_things_queued_ever = gpr_atm_no_barrier_load(&cqd->things_queued_ever), diff --git a/test/core/http/httpcli_test.c b/test/core/http/httpcli_test.c index ea63cd1df83..3634932ef17 100644 --- a/test/core/http/httpcli_test.c +++ b/test/core/http/httpcli_test.c @@ -36,7 +36,8 @@ static gpr_mu *g_mu; static grpc_polling_entity g_pops; static grpc_millis n_seconds_time(int seconds) { - return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(seconds)); + return grpc_timespec_to_millis_round_up( + grpc_timeout_seconds_to_deadline(seconds)); } static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { diff --git a/test/core/http/httpscli_test.c b/test/core/http/httpscli_test.c index 6d575d683d2..d03dcdf7795 100644 --- a/test/core/http/httpscli_test.c +++ b/test/core/http/httpscli_test.c @@ -36,7 +36,8 @@ static gpr_mu *g_mu; static grpc_polling_entity g_pops; static grpc_millis n_seconds_time(int seconds) { - return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(seconds)); + return grpc_timespec_to_millis_round_up( + grpc_timeout_seconds_to_deadline(seconds)); } static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c index e80dce01cf4..684858088fa 100644 --- a/test/core/iomgr/endpoint_tests.c +++ b/test/core/iomgr/endpoint_tests.c @@ -176,7 +176,7 @@ static void read_and_write_test(grpc_endpoint_test_config config, begin_test(config, "read_and_write_test", slice_size); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_millis deadline = - grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(20)); + grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20)); gpr_log(GPR_DEBUG, "num_bytes=%" PRIuPTR " write_size=%" PRIuPTR " slice_size=%" PRIuPTR " shutdown=%d", num_bytes, write_size, slice_size, shutdown); @@ -261,7 +261,7 @@ static void wait_for_fail_count(grpc_exec_ctx *exec_ctx, int *fail_count, grpc_exec_ctx_flush(exec_ctx); gpr_mu_lock(g_mu); grpc_millis deadline = - grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(10)); + grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); while (grpc_exec_ctx_now(exec_ctx) < deadline && *fail_count < want_fail_count) { grpc_pollset_worker *worker = NULL; diff --git a/test/core/iomgr/resolve_address_posix_test.c b/test/core/iomgr/resolve_address_posix_test.c index d9d200d2c4c..0a18ec75088 100644 --- a/test/core/iomgr/resolve_address_posix_test.c +++ b/test/core/iomgr/resolve_address_posix_test.c @@ -71,7 +71,8 @@ void args_finish(grpc_exec_ctx *exec_ctx, args_struct *args) { } static grpc_millis n_sec_deadline(int seconds) { - return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(seconds)); + return grpc_timespec_to_millis_round_up( + grpc_timeout_seconds_to_deadline(seconds)); } static void actually_poll(void *argsp) { diff --git a/test/core/iomgr/resolve_address_test.c b/test/core/iomgr/resolve_address_test.c index c6c53be5ca7..d475b552b0f 100644 --- a/test/core/iomgr/resolve_address_test.c +++ b/test/core/iomgr/resolve_address_test.c @@ -68,7 +68,8 @@ void args_finish(grpc_exec_ctx *exec_ctx, args_struct *args) { } static grpc_millis n_sec_deadline(int seconds) { - return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(seconds)); + return grpc_timespec_to_millis_round_up( + grpc_timeout_seconds_to_deadline(seconds)); } static void poll_pollset_until_request_done(args_struct *args) { diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.c index 69dc82f45e1..3cae13ba081 100644 --- a/test/core/iomgr/tcp_client_posix_test.c +++ b/test/core/iomgr/tcp_client_posix_test.c @@ -47,7 +47,7 @@ static int g_connections_complete = 0; static grpc_endpoint *g_connecting = NULL; static grpc_millis test_deadline(void) { - return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(10)); + return grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); } static void finish_connection() { @@ -124,9 +124,9 @@ void test_succeeds(void) { grpc_pollset_worker *worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", - grpc_pollset_work( - &exec_ctx, g_pollset, &worker, - grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(5))))); + grpc_pollset_work(&exec_ctx, g_pollset, &worker, + grpc_timespec_to_millis_round_up( + grpc_timeout_seconds_to_deadline(5))))); gpr_mu_unlock(g_mu); grpc_exec_ctx_flush(&exec_ctx); gpr_mu_lock(g_mu); diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c index aa55b717255..03b707c2471 100644 --- a/test/core/iomgr/tcp_posix_test.c +++ b/test/core/iomgr/tcp_posix_test.c @@ -162,7 +162,7 @@ static void read_test(size_t num_bytes, size_t slice_size) { struct read_socket_state state; size_t written_bytes; grpc_millis deadline = - grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(20)); + grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20)); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_log(GPR_INFO, "Read test of size %" PRIuPTR ", slice size %" PRIuPTR, @@ -215,7 +215,7 @@ static void large_read_test(size_t slice_size) { struct read_socket_state state; ssize_t written_bytes; grpc_millis deadline = - grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(20)); + grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20)); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_log(GPR_INFO, "Start large read test, slice size %" PRIuPTR, slice_size); @@ -318,7 +318,7 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) { GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, - grpc_timespec_to_millis( + grpc_timespec_to_millis_round_up( grpc_timeout_milliseconds_to_deadline(10))))); gpr_mu_unlock(g_mu); grpc_exec_ctx_finish(&exec_ctx); @@ -353,7 +353,7 @@ static void write_test(size_t num_bytes, size_t slice_size) { grpc_slice_buffer outgoing; grpc_closure write_done_closure; grpc_millis deadline = - grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(20)); + grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20)); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_log(GPR_INFO, @@ -419,7 +419,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) { size_t written_bytes; int fd; grpc_millis deadline = - grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(20)); + grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20)); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_closure fd_released_cb; int fd_released_done = 0; diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.c index 13ff92cb5be..0cde2d0e729 100644 --- a/test/core/iomgr/tcp_server_posix_test.c +++ b/test/core/iomgr/tcp_server_posix_test.c @@ -231,7 +231,7 @@ static void test_no_op_with_port_and_start(void) { static grpc_error *tcp_connect(grpc_exec_ctx *exec_ctx, const test_addr *remote, on_connect_result *result) { grpc_millis deadline = - grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(10)); + grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); int clifd; int nconnects_before; const struct sockaddr *remote_addr = diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c index 2f6f5034434..5977da3d448 100644 --- a/test/core/iomgr/udp_server_test.c +++ b/test/core/iomgr/udp_server_test.c @@ -252,7 +252,8 @@ static void test_receive(int number_of_clients) { gpr_mu_lock(g_mu); for (i = 0; i < number_of_clients; i++) { - deadline = grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(10)); + deadline = + grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); number_of_reads_before = g_number_of_reads; /* Create a socket, send a packet to the UDP server. */ diff --git a/test/core/util/test_tcp_server.c b/test/core/util/test_tcp_server.c index ce05833aa9a..611ecb330c1 100644 --- a/test/core/util/test_tcp_server.c +++ b/test/core/util/test_tcp_server.c @@ -80,8 +80,8 @@ void test_tcp_server_start(test_tcp_server *server, int port) { void test_tcp_server_poll(test_tcp_server *server, int seconds) { grpc_pollset_worker *worker = NULL; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_millis deadline = - grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(seconds)); + grpc_millis deadline = grpc_timespec_to_millis_round_up( + grpc_timeout_seconds_to_deadline(seconds)); gpr_mu_lock(server->mu); GRPC_LOG_IF_ERROR( "pollset_work", From 1af596adab6d17be1ba3afb2b279a123d2bbf11d Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 21 Jul 2017 14:22:58 -0700 Subject: [PATCH 020/142] fix --- test/core/iomgr/pollset_set_test.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/core/iomgr/pollset_set_test.c b/test/core/iomgr/pollset_set_test.c index 09067998043..84931f63171 100644 --- a/test/core/iomgr/pollset_set_test.c +++ b/test/core/iomgr/pollset_set_test.c @@ -255,8 +255,8 @@ static void pollset_set_test_basic() { make_test_fds_readable(tfds, num_fds); gpr_mu_lock(pollsets[i].mu); - deadline = - grpc_timespec_to_millis(grpc_timeout_milliseconds_to_deadline(2)); + deadline = grpc_timespec_to_millis_round_up( + grpc_timeout_milliseconds_to_deadline(2)); GPR_ASSERT(GRPC_ERROR_NONE == grpc_pollset_work(&exec_ctx, pollsets[i].ps, &worker, deadline)); gpr_mu_unlock(pollsets[i].mu); @@ -337,7 +337,8 @@ void pollset_set_test_dup_fds() { make_test_fds_readable(tfds, num_fds); gpr_mu_lock(pollset.mu); - deadline = grpc_timespec_to_millis(grpc_timeout_milliseconds_to_deadline(2)); + deadline = grpc_timespec_to_millis_round_up( + grpc_timeout_milliseconds_to_deadline(2)); GPR_ASSERT(GRPC_ERROR_NONE == grpc_pollset_work(&exec_ctx, pollset.ps, &worker, deadline)); gpr_mu_unlock(pollset.mu); @@ -405,7 +406,8 @@ void pollset_set_test_empty_pollset() { make_test_fds_readable(tfds, num_fds); gpr_mu_lock(pollsets[0].mu); - deadline = grpc_timespec_to_millis(grpc_timeout_milliseconds_to_deadline(2)); + deadline = grpc_timespec_to_millis_round_up( + grpc_timeout_milliseconds_to_deadline(2)); GPR_ASSERT(GRPC_ERROR_NONE == grpc_pollset_work(&exec_ctx, pollsets[0].ps, &worker, deadline)); gpr_mu_unlock(pollsets[0].mu); From 2014a37a5c77f0f878b885c922443fe67889bc78 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 21 Jul 2017 15:36:11 -0700 Subject: [PATCH 021/142] Fix projects --- BUILD | 4 ++-- CMakeLists.txt | 6 +++++- Makefile | 6 +++++- binding.gyp | 2 +- build.yaml | 6 +++--- config.m4 | 2 +- config.w32 | 2 +- gRPC-Core.podspec | 10 +++++----- grpc.gemspec | 6 +++--- package.xml | 6 +++--- src/python/grpcio/grpc_core_dependencies.py | 2 +- tools/doxygen/Doxyfile.core.internal | 2 +- tools/run_tests/generated/sources_and_headers.json | 10 +++++----- vsprojects/vcxproj/gpr/gpr.vcxproj | 5 +---- vsprojects/vcxproj/gpr/gpr.vcxproj.filters | 14 ++++---------- vsprojects/vcxproj/grpc/grpc.vcxproj | 3 +++ vsprojects/vcxproj/grpc/grpc.vcxproj.filters | 9 +++++++++ .../vcxproj/grpc_test_util/grpc_test_util.vcxproj | 3 +++ .../grpc_test_util/grpc_test_util.vcxproj.filters | 9 +++++++++ .../vcxproj/grpc_unsecure/grpc_unsecure.vcxproj | 3 +++ .../grpc_unsecure/grpc_unsecure.vcxproj.filters | 9 +++++++++ 21 files changed, 77 insertions(+), 42 deletions(-) diff --git a/BUILD b/BUILD index d1624ab13c0..e8d361fcb6f 100644 --- a/BUILD +++ b/BUILD @@ -465,7 +465,6 @@ grpc_cc_library( "src/core/lib/support/arena.c", "src/core/lib/support/atm.c", "src/core/lib/support/avl.c", - "src/core/lib/backoff/backoff.c", "src/core/lib/support/cmdline.c", "src/core/lib/support/cpu_iphone.c", "src/core/lib/support/cpu_linux.c", @@ -512,7 +511,6 @@ grpc_cc_library( "src/core/lib/support/atomic.h", "src/core/lib/support/atomic_with_atm.h", "src/core/lib/support/atomic_with_std.h", - "src/core/lib/backoff/backoff.h", "src/core/lib/iomgr/block_annotate.h", "src/core/lib/support/env.h", "src/core/lib/support/memory.h", @@ -686,6 +684,7 @@ grpc_cc_library( "src/core/lib/transport/timeout_encoding.c", "src/core/lib/transport/transport.c", "src/core/lib/transport/transport_op_string.c", + "src/core/lib/backoff/backoff.c", ], hdrs = [ "src/core/lib/channel/channel_args.h", @@ -799,6 +798,7 @@ grpc_cc_library( "src/core/lib/transport/timeout_encoding.h", "src/core/lib/transport/transport.h", "src/core/lib/transport/transport_impl.h", + "src/core/lib/backoff/backoff.h", ], external_deps = [ "zlib", diff --git a/CMakeLists.txt b/CMakeLists.txt index 817a1e4da9b..893c3669c0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -770,7 +770,6 @@ endif (gRPC_BUILD_TESTS) add_library(gpr - src/core/lib/backoff/backoff.c src/core/lib/profiling/basic_timers.c src/core/lib/profiling/stap_timers.c src/core/lib/support/alloc.c @@ -947,6 +946,7 @@ endif (gRPC_BUILD_TESTS) add_library(grpc src/core/lib/surface/init.c + src/core/lib/backoff/backoff.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c @@ -1290,6 +1290,7 @@ endif() add_library(grpc_cronet src/core/lib/surface/init.c + src/core/lib/backoff/backoff.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c @@ -1611,6 +1612,7 @@ add_library(grpc_test_util test/core/util/port_server_client.c test/core/util/slice_splitter.c test/core/util/trickle_endpoint.c + src/core/lib/backoff/backoff.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c @@ -1874,6 +1876,7 @@ endif (gRPC_BUILD_TESTS) add_library(grpc_unsecure src/core/lib/surface/init.c src/core/lib/surface/init_unsecure.c + src/core/lib/backoff/backoff.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c @@ -2533,6 +2536,7 @@ add_library(grpc++_cronet src/core/ext/transport/chttp2/transport/stream_map.c src/core/ext/transport/chttp2/transport/varint.c src/core/ext/transport/chttp2/transport/writing.c + src/core/lib/backoff/backoff.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c diff --git a/Makefile b/Makefile index bdffe1e4919..39f4ff92de5 100644 --- a/Makefile +++ b/Makefile @@ -2741,7 +2741,6 @@ clean: LIBGPR_SRC = \ - src/core/lib/backoff/backoff.c \ src/core/lib/profiling/basic_timers.c \ src/core/lib/profiling/stap_timers.c \ src/core/lib/support/alloc.c \ @@ -2891,6 +2890,7 @@ endif LIBGRPC_SRC = \ src/core/lib/surface/init.c \ + src/core/lib/backoff/backoff.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ @@ -3232,6 +3232,7 @@ endif LIBGRPC_CRONET_SRC = \ src/core/lib/surface/init.c \ + src/core/lib/backoff/backoff.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ @@ -3550,6 +3551,7 @@ LIBGRPC_TEST_UTIL_SRC = \ test/core/util/port_server_client.c \ test/core/util/slice_splitter.c \ test/core/util/trickle_endpoint.c \ + src/core/lib/backoff/backoff.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ @@ -3785,6 +3787,7 @@ endif LIBGRPC_UNSECURE_SRC = \ src/core/lib/surface/init.c \ src/core/lib/surface/init_unsecure.c \ + src/core/lib/backoff/backoff.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ @@ -4428,6 +4431,7 @@ LIBGRPC++_CRONET_SRC = \ src/core/ext/transport/chttp2/transport/stream_map.c \ src/core/ext/transport/chttp2/transport/varint.c \ src/core/ext/transport/chttp2/transport/writing.c \ + src/core/lib/backoff/backoff.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ diff --git a/binding.gyp b/binding.gyp index 01a5990cca2..13928d74dc1 100644 --- a/binding.gyp +++ b/binding.gyp @@ -579,7 +579,6 @@ 'dependencies': [ ], 'sources': [ - 'src/core/lib/backoff/backoff.c', 'src/core/lib/profiling/basic_timers.c', 'src/core/lib/profiling/stap_timers.c', 'src/core/lib/support/alloc.c', @@ -636,6 +635,7 @@ ], 'sources': [ 'src/core/lib/surface/init.c', + 'src/core/lib/backoff/backoff.c', 'src/core/lib/channel/channel_args.c', 'src/core/lib/channel/channel_stack.c', 'src/core/lib/channel/channel_stack_builder.c', diff --git a/build.yaml b/build.yaml index 4a55ea5dc5b..2f8368d2e42 100644 --- a/build.yaml +++ b/build.yaml @@ -87,13 +87,12 @@ filegroups: - include/grpc/support/tls_pthread.h - include/grpc/support/useful.h headers: - - src/core/lib/backoff/backoff.h + - src/core/lib/iomgr/block_annotate.h - src/core/lib/profiling/timers.h - src/core/lib/support/arena.h - src/core/lib/support/atomic.h - src/core/lib/support/atomic_with_atm.h - src/core/lib/support/atomic_with_std.h - - src/core/lib/iomgr/block_annotate.h - src/core/lib/support/env.h - src/core/lib/support/memory.h - src/core/lib/support/mpscq.h @@ -106,7 +105,6 @@ filegroups: - src/core/lib/support/time_precise.h - src/core/lib/support/tmpfile.h src: - - src/core/lib/backoff/backoff.c - src/core/lib/profiling/basic_timers.c - src/core/lib/profiling/stap_timers.c - src/core/lib/support/alloc.c @@ -181,6 +179,7 @@ filegroups: - include/grpc/status.h - include/grpc/support/workaround_list.h headers: + - src/core/lib/backoff/backoff.h - src/core/lib/channel/channel_args.h - src/core/lib/channel/channel_stack.h - src/core/lib/channel/channel_stack_builder.h @@ -293,6 +292,7 @@ filegroups: - src/core/lib/transport/transport.h - src/core/lib/transport/transport_impl.h src: + - src/core/lib/backoff/backoff.c - src/core/lib/channel/channel_args.c - src/core/lib/channel/channel_stack.c - src/core/lib/channel/channel_stack_builder.c diff --git a/config.m4 b/config.m4 index c2d8bb1d835..3173e98ca00 100644 --- a/config.m4 +++ b/config.m4 @@ -39,7 +39,6 @@ if test "$PHP_GRPC" != "no"; then src/php/ext/grpc/server.c \ src/php/ext/grpc/server_credentials.c \ src/php/ext/grpc/timeval.c \ - src/core/lib/backoff/backoff.c \ src/core/lib/profiling/basic_timers.c \ src/core/lib/profiling/stap_timers.c \ src/core/lib/support/alloc.c \ @@ -86,6 +85,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/support/tmpfile_windows.c \ src/core/lib/support/wrap_memcpy.c \ src/core/lib/surface/init.c \ + src/core/lib/backoff/backoff.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ diff --git a/config.w32 b/config.w32 index 4179d9c50fc..e6b30cce25f 100644 --- a/config.w32 +++ b/config.w32 @@ -16,7 +16,6 @@ if (PHP_GRPC != "no") { "src\\php\\ext\\grpc\\server.c " + "src\\php\\ext\\grpc\\server_credentials.c " + "src\\php\\ext\\grpc\\timeval.c " + - "src\\core\\lib\\backoff\\backoff.c " + "src\\core\\lib\\profiling\\basic_timers.c " + "src\\core\\lib\\profiling\\stap_timers.c " + "src\\core\\lib\\support\\alloc.c " + @@ -63,6 +62,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\support\\tmpfile_windows.c " + "src\\core\\lib\\support\\wrap_memcpy.c " + "src\\core\\lib\\surface\\init.c " + + "src\\core\\lib\\backoff\\backoff.c " + "src\\core\\lib\\channel\\channel_args.c " + "src\\core\\lib\\channel\\channel_stack.c " + "src\\core\\lib\\channel\\channel_stack_builder.c " + diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 896de2ba836..aaa1ff93ef4 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -180,13 +180,12 @@ Pod::Spec.new do |s| ss.dependency 'nanopb', '~> 0.3' # To save you from scrolling, this is the last part of the podspec. - ss.source_files = 'src/core/lib/backoff/backoff.h', + ss.source_files = 'src/core/lib/iomgr/block_annotate.h', 'src/core/lib/profiling/timers.h', 'src/core/lib/support/arena.h', 'src/core/lib/support/atomic.h', 'src/core/lib/support/atomic_with_atm.h', 'src/core/lib/support/atomic_with_std.h', - 'src/core/lib/iomgr/block_annotate.h', 'src/core/lib/support/env.h', 'src/core/lib/support/memory.h', 'src/core/lib/support/mpscq.h', @@ -198,7 +197,6 @@ Pod::Spec.new do |s| 'src/core/lib/support/thd_internal.h', 'src/core/lib/support/time_precise.h', 'src/core/lib/support/tmpfile.h', - 'src/core/lib/backoff/backoff.c', 'src/core/lib/profiling/basic_timers.c', 'src/core/lib/profiling/stap_timers.c', 'src/core/lib/support/alloc.c', @@ -244,6 +242,7 @@ Pod::Spec.new do |s| 'src/core/lib/support/tmpfile_posix.c', 'src/core/lib/support/tmpfile_windows.c', 'src/core/lib/support/wrap_memcpy.c', + 'src/core/lib/backoff/backoff.h', 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', @@ -461,6 +460,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h', 'src/core/ext/filters/workarounds/workaround_utils.h', 'src/core/lib/surface/init.c', + 'src/core/lib/backoff/backoff.c', 'src/core/lib/channel/channel_args.c', 'src/core/lib/channel/channel_stack.c', 'src/core/lib/channel/channel_stack_builder.c', @@ -711,13 +711,12 @@ Pod::Spec.new do |s| 'src/core/ext/filters/workarounds/workaround_utils.c', 'src/core/plugin_registry/grpc_plugin_registry.c' - ss.private_header_files = 'src/core/lib/backoff/backoff.h', + ss.private_header_files = 'src/core/lib/iomgr/block_annotate.h', 'src/core/lib/profiling/timers.h', 'src/core/lib/support/arena.h', 'src/core/lib/support/atomic.h', 'src/core/lib/support/atomic_with_atm.h', 'src/core/lib/support/atomic_with_std.h', - 'src/core/lib/iomgr/block_annotate.h', 'src/core/lib/support/env.h', 'src/core/lib/support/memory.h', 'src/core/lib/support/mpscq.h', @@ -729,6 +728,7 @@ Pod::Spec.new do |s| 'src/core/lib/support/thd_internal.h', 'src/core/lib/support/time_precise.h', 'src/core/lib/support/tmpfile.h', + 'src/core/lib/backoff/backoff.h', 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', diff --git a/grpc.gemspec b/grpc.gemspec index aca802e1860..d4df6a150d0 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -80,13 +80,12 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/impl/codegen/sync_generic.h ) s.files += %w( include/grpc/impl/codegen/sync_posix.h ) s.files += %w( include/grpc/impl/codegen/sync_windows.h ) - s.files += %w( src/core/lib/backoff/backoff.h ) + s.files += %w( src/core/lib/iomgr/block_annotate.h ) s.files += %w( src/core/lib/profiling/timers.h ) s.files += %w( src/core/lib/support/arena.h ) s.files += %w( src/core/lib/support/atomic.h ) s.files += %w( src/core/lib/support/atomic_with_atm.h ) s.files += %w( src/core/lib/support/atomic_with_std.h ) - s.files += %w( src/core/lib/iomgr/block_annotate.h ) s.files += %w( src/core/lib/support/env.h ) s.files += %w( src/core/lib/support/memory.h ) s.files += %w( src/core/lib/support/mpscq.h ) @@ -98,7 +97,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/support/thd_internal.h ) s.files += %w( src/core/lib/support/time_precise.h ) s.files += %w( src/core/lib/support/tmpfile.h ) - s.files += %w( src/core/lib/backoff/backoff.c ) s.files += %w( src/core/lib/profiling/basic_timers.c ) s.files += %w( src/core/lib/profiling/stap_timers.c ) s.files += %w( src/core/lib/support/alloc.c ) @@ -176,6 +174,7 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/impl/codegen/sync_windows.h ) s.files += %w( include/grpc/grpc_security.h ) s.files += %w( include/grpc/census.h ) + s.files += %w( src/core/lib/backoff/backoff.h ) s.files += %w( src/core/lib/channel/channel_args.h ) s.files += %w( src/core/lib/channel/channel_stack.h ) s.files += %w( src/core/lib/channel/channel_stack_builder.h ) @@ -397,6 +396,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h ) s.files += %w( src/core/ext/filters/workarounds/workaround_utils.h ) s.files += %w( src/core/lib/surface/init.c ) + s.files += %w( src/core/lib/backoff/backoff.c ) s.files += %w( src/core/lib/channel/channel_args.c ) s.files += %w( src/core/lib/channel/channel_stack.c ) s.files += %w( src/core/lib/channel/channel_stack_builder.c ) diff --git a/package.xml b/package.xml index 9c1e76ec165..e0098d2c610 100644 --- a/package.xml +++ b/package.xml @@ -94,13 +94,12 @@ - + - @@ -112,7 +111,6 @@ - @@ -190,6 +188,7 @@ + @@ -411,6 +410,7 @@ + diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index cf006515ee8..6493c09cd7b 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -15,7 +15,6 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_core_dependencies.py.template`!!! CORE_SOURCE_FILES = [ - 'src/core/lib/backoff/backoff.c', 'src/core/lib/profiling/basic_timers.c', 'src/core/lib/profiling/stap_timers.c', 'src/core/lib/support/alloc.c', @@ -62,6 +61,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/support/tmpfile_windows.c', 'src/core/lib/support/wrap_memcpy.c', 'src/core/lib/surface/init.c', + 'src/core/lib/backoff/backoff.c', 'src/core/lib/channel/channel_args.c', 'src/core/lib/channel/channel_stack.c', 'src/core/lib/channel/channel_stack_builder.c', diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 8ea50a94041..6352e507438 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1085,6 +1085,7 @@ src/core/lib/http/httpcli_security_connector.c \ src/core/lib/http/parser.c \ src/core/lib/http/parser.h \ src/core/lib/iomgr/README.md \ +src/core/lib/iomgr/block_annotate.h \ src/core/lib/iomgr/closure.c \ src/core/lib/iomgr/closure.h \ src/core/lib/iomgr/combiner.c \ @@ -1287,7 +1288,6 @@ src/core/lib/support/atomic.h \ src/core/lib/support/atomic_with_atm.h \ src/core/lib/support/atomic_with_std.h \ src/core/lib/support/avl.c \ -src/core/lib/iomgr/block_annotate.h \ src/core/lib/support/cmdline.c \ src/core/lib/support/cpu_iphone.c \ src/core/lib/support/cpu_linux.c \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 6874493d51d..39cf71e11f9 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7538,13 +7538,12 @@ "include/grpc/support/tls_msvc.h", "include/grpc/support/tls_pthread.h", "include/grpc/support/useful.h", - "src/core/lib/backoff/backoff.h", + "src/core/lib/iomgr/block_annotate.h", "src/core/lib/profiling/timers.h", "src/core/lib/support/arena.h", "src/core/lib/support/atomic.h", "src/core/lib/support/atomic_with_atm.h", "src/core/lib/support/atomic_with_std.h", - "src/core/lib/iomgr/block_annotate.h", "src/core/lib/support/env.h", "src/core/lib/support/memory.h", "src/core/lib/support/mpscq.h", @@ -7587,8 +7586,7 @@ "include/grpc/support/tls_msvc.h", "include/grpc/support/tls_pthread.h", "include/grpc/support/useful.h", - "src/core/lib/backoff/backoff.c", - "src/core/lib/backoff/backoff.h", + "src/core/lib/iomgr/block_annotate.h", "src/core/lib/profiling/basic_timers.c", "src/core/lib/profiling/stap_timers.c", "src/core/lib/profiling/timers.h", @@ -7600,7 +7598,6 @@ "src/core/lib/support/atomic_with_atm.h", "src/core/lib/support/atomic_with_std.h", "src/core/lib/support/avl.c", - "src/core/lib/iomgr/block_annotate.h", "src/core/lib/support/cmdline.c", "src/core/lib/support/cpu_iphone.c", "src/core/lib/support/cpu_linux.c", @@ -7707,6 +7704,7 @@ "include/grpc/slice_buffer.h", "include/grpc/status.h", "include/grpc/support/workaround_list.h", + "src/core/lib/backoff/backoff.h", "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", @@ -7834,6 +7832,8 @@ "include/grpc/slice_buffer.h", "include/grpc/status.h", "include/grpc/support/workaround_list.h", + "src/core/lib/backoff/backoff.c", + "src/core/lib/backoff/backoff.h", "src/core/lib/channel/channel_args.c", "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.c", diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj b/vsprojects/vcxproj/gpr/gpr.vcxproj index 2386fddd02a..59b6d5229c7 100644 --- a/vsprojects/vcxproj/gpr/gpr.vcxproj +++ b/vsprojects/vcxproj/gpr/gpr.vcxproj @@ -186,13 +186,12 @@ - + - @@ -206,8 +205,6 @@ - - diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters index c5fce455f4b..b1c605c4b4d 100644 --- a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters +++ b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters @@ -1,9 +1,6 @@ - - src\core\lib\backoff - src\core\lib\profiling @@ -254,8 +251,8 @@ - - src\core\lib\backoff + + src\core\lib\iomgr src\core\lib\profiling @@ -272,9 +269,6 @@ src\core\lib\support - - src\core\lib\support - src\core\lib\support @@ -335,8 +329,8 @@ {52037bcb-5719-a548-224d-834fbe569045} - - {5a917a34-e4b4-01c0-4565-2be560176bec} + + {05787953-1d14-fd71-51b0-03be31463e6a} {ba38d79d-d5de-a89e-9ca2-c5235a03ca7f} diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj index 57c0ac7bc4e..3d21a67502b 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj @@ -301,6 +301,7 @@ + @@ -525,6 +526,8 @@ + + diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters index e9bb52defa6..db8ca808674 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters @@ -4,6 +4,9 @@ src\core\lib\surface + + src\core\lib\backoff + src\core\lib\channel @@ -860,6 +863,9 @@ + + src\core\lib\backoff + src\core\lib\channel @@ -1664,6 +1670,9 @@ {5b2ded3f-84a5-f6b4-2060-286c7d1dc945} + + {fc07b929-526c-5567-9a7a-adb2a16da6b8} + {1931b044-90f3-cd68-b5f8-23be77ca8efc} diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj index 64bf54e557d..51247b2e514 100644 --- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj +++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj @@ -196,6 +196,7 @@ + @@ -350,6 +351,8 @@ + + diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters index 35fd87a4c58..8055456e2ce 100644 --- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters @@ -61,6 +61,9 @@ test\core\util + + src\core\lib\backoff + src\core\lib\channel @@ -584,6 +587,9 @@ test\core\util + + src\core\lib\backoff + src\core\lib\channel @@ -962,6 +968,9 @@ {f4e8c61e-1ca6-0fdd-7b5e-b7f9a30c9a21} + + {2fa7432f-c05f-eafe-2284-b8e7a6ac8313} + {1cd1503c-bec0-5ade-c75f-aa25c80975ec} diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj index 4ed59780a44..4f454bb4659 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj @@ -291,6 +291,7 @@ + @@ -491,6 +492,8 @@ + + diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters index 2c3319beae8..f7fbcad535b 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -7,6 +7,9 @@ src\core\lib\surface + + src\core\lib\backoff + src\core\lib\channel @@ -767,6 +770,9 @@ + + src\core\lib\backoff + src\core\lib\channel @@ -1487,6 +1493,9 @@ {8bd5b461-bff8-6aa8-b5a6-85da2834eb8a} + + {f724061f-f10a-014b-33d7-45b931e3a908} + {fb964f3d-a59c-a7ba-fee5-6072dbb94a7b} From 0f2f4eea4bdc32c7e229feba1d8867d4b6628185 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 29 Aug 2017 14:15:05 -0700 Subject: [PATCH 022/142] revert protobuf change --- third_party/protobuf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/protobuf b/third_party/protobuf index a6189acd18b..80a37e0782d 160000 --- a/third_party/protobuf +++ b/third_party/protobuf @@ -1 +1 @@ -Subproject commit a6189acd18b00611c1dc7042299ad75486f08a1a +Subproject commit 80a37e0782d2d702d52234b62dd4b9ec74fd2c95 From acc4c78dd5c65fc3ad013816924ed88c8936444e Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 1 Sep 2017 10:33:09 -0700 Subject: [PATCH 023/142] Fix merge error --- src/core/lib/iomgr/exec_ctx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h index 0b183a3c9a5..6220e41a4fb 100644 --- a/src/core/lib/iomgr/exec_ctx.h +++ b/src/core/lib/iomgr/exec_ctx.h @@ -80,7 +80,7 @@ struct grpc_exec_ctx { #define GRPC_EXEC_CTX_INITIALIZER(flags, finish_check, finish_check_arg) \ { \ GRPC_CLOSURE_LIST_INIT, NULL, NULL, flags, gpr_cpu_current_cpu(), \ - finish_check_arg, finish_check \ + finish_check_arg, finish_check, false, 0 \ } /* initialize an execution context at the top level of an API call into grpc From b61a26cff93b0ef97c98dad0c338d539ff44e7e4 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 8 Sep 2017 11:54:34 -0700 Subject: [PATCH 024/142] Eliminate redundant now calls --- src/core/lib/iomgr/exec_ctx.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/core/lib/iomgr/exec_ctx.c b/src/core/lib/iomgr/exec_ctx.c index 05ab9f629d2..3d17afcb8fb 100644 --- a/src/core/lib/iomgr/exec_ctx.c +++ b/src/core/lib/iomgr/exec_ctx.c @@ -104,16 +104,23 @@ static void exec_ctx_sched(grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_closure_list_append(&exec_ctx->closure_list, closure, error); } -static gpr_timespec g_start_time; +static gpr_timespec + g_start_time[GPR_TIMESPAN + 1]; // assumes GPR_TIMESPAN is the + // last enum value in + // gpr_clock_type void grpc_exec_ctx_global_init(void) { - g_start_time = gpr_now(GPR_CLOCK_MONOTONIC); + for (int i = 0; i < GPR_TIMESPAN; i++) { + g_start_time[i] = gpr_now((gpr_clock_type)i); + } + // allows uniform treatment in conversion functions + g_start_time[GPR_TIMESPAN] = gpr_time_0(GPR_TIMESPAN); } void grpc_exec_ctx_global_shutdown(void) {} static gpr_atm timespec_to_atm_round_down(gpr_timespec ts) { - ts = gpr_time_sub(ts, g_start_time); + ts = gpr_time_sub(ts, g_start_time[ts.clock_type]); double x = GPR_MS_PER_SEC * (double)ts.tv_sec + (double)ts.tv_nsec / GPR_NS_PER_MS; if (x < 0) return 0; @@ -122,7 +129,7 @@ static gpr_atm timespec_to_atm_round_down(gpr_timespec ts) { } static gpr_atm timespec_to_atm_round_up(gpr_timespec ts) { - ts = gpr_time_sub(ts, g_start_time); + ts = gpr_time_sub(ts, g_start_time[ts.clock_type]); double x = GPR_MS_PER_SEC * (double)ts.tv_sec + (double)ts.tv_nsec / GPR_NS_PER_MS + (double)(GPR_NS_PER_SEC - 1) / (double)GPR_NS_PER_SEC; @@ -145,18 +152,19 @@ void grpc_exec_ctx_invalidate_now(grpc_exec_ctx *exec_ctx) { gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_clock_type clock_type) { - return gpr_time_add(gpr_convert_clock_type(g_start_time, clock_type), + if (clock_type == GPR_TIMESPAN) { + return gpr_time_from_millis(millis, GPR_TIMESPAN); + } + return gpr_time_add(g_start_time[clock_type], gpr_time_from_millis(millis, GPR_TIMESPAN)); } grpc_millis grpc_timespec_to_millis_round_down(gpr_timespec ts) { - return timespec_to_atm_round_down( - gpr_convert_clock_type(ts, g_start_time.clock_type)); + return timespec_to_atm_round_down(ts); } grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec ts) { - return timespec_to_atm_round_up( - gpr_convert_clock_type(ts, g_start_time.clock_type)); + return timespec_to_atm_round_up(ts); } static const grpc_closure_scheduler_vtable exec_ctx_scheduler_vtable = { From e9af6f9214a1f00c326f382b7557aac36866a25f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 11 Sep 2017 12:13:48 -0700 Subject: [PATCH 025/142] Fix merge error --- src/core/lib/iomgr/tcp_posix.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/core/lib/iomgr/tcp_posix.c b/src/core/lib/iomgr/tcp_posix.c index 7e271294fd6..7fcaef76792 100644 --- a/src/core/lib/iomgr/tcp_posix.c +++ b/src/core/lib/iomgr/tcp_posix.c @@ -135,13 +135,11 @@ static void run_poller(grpc_exec_ctx *exec_ctx, void *bp, gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p run", p); } gpr_mu_lock(p->pollset_mu); - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - gpr_timespec deadline = - gpr_time_add(now, gpr_time_from_seconds(10, GPR_TIMESPAN)); + grpc_millis deadline = grpc_exec_ctx_now(exec_ctx) + 13 * GPR_MS_PER_SEC; GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS(exec_ctx); - GRPC_LOG_IF_ERROR("backup_poller:pollset_work", - grpc_pollset_work(exec_ctx, BACKUP_POLLER_POLLSET(p), NULL, - now, deadline)); + GRPC_LOG_IF_ERROR( + "backup_poller:pollset_work", + grpc_pollset_work(exec_ctx, BACKUP_POLLER_POLLSET(p), NULL, deadline)); gpr_mu_unlock(p->pollset_mu); /* last "uncovered" notification is the ref that keeps us polling, if we get * there try a cas to release it */ From 61539748f569e6a837500cdad0c6ed0b53b23d0f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 11 Sep 2017 15:08:31 -0700 Subject: [PATCH 026/142] Fix Windows compile error --- src/core/lib/iomgr/resolve_address_windows.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/resolve_address_windows.c b/src/core/lib/iomgr/resolve_address_windows.c index 958ea98c720..305930de446 100644 --- a/src/core/lib/iomgr/resolve_address_windows.c +++ b/src/core/lib/iomgr/resolve_address_windows.c @@ -86,7 +86,7 @@ static grpc_error *blocking_resolve_address_impl( GRPC_SCHEDULING_START_BLOCKING_REGION; s = getaddrinfo(host, port, &hints, &result); - GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(exec_ctx); + GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX; if (s != 0) { error = GRPC_WSA_ERROR(WSAGetLastError(), "getaddrinfo"); goto done; From 80ae895f1e1c07aa8b86e9d1ca564da2329f118b Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 11 Sep 2017 15:18:03 -0700 Subject: [PATCH 027/142] Fix Bazel build --- test/core/backoff/BUILD | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/core/backoff/BUILD b/test/core/backoff/BUILD index 6c2ceb499b7..4ae762007cb 100644 --- a/test/core/backoff/BUILD +++ b/test/core/backoff/BUILD @@ -28,6 +28,8 @@ grpc_cc_test( srcs = ["backoff_test.c"], language = "C", deps = [ + "//:grpc", + "//test/core/util:grpc_test_util", "//:gpr", "//test/core/util:gpr_test_util", ], From b7f36d75171eb563248be8f776518087e3dfaa0c Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 11 Sep 2017 15:18:21 -0700 Subject: [PATCH 028/142] Fix test math error --- test/core/backoff/backoff_test.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/test/core/backoff/backoff_test.c b/test/core/backoff/backoff_test.c index 302ac7b3a01..3848b2a54d4 100644 --- a/test/core/backoff/backoff_test.c +++ b/test/core/backoff/backoff_test.c @@ -59,43 +59,45 @@ static void test_no_jitter_backoff(void) { // x_1 = 2 // x_n = 2**i + x_{i-1} ( = 2**(n+1) - 2 ) grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + exec_ctx.now = 0; + exec_ctx.now_is_valid = true; grpc_millis next = grpc_backoff_begin(&exec_ctx, &backoff); - GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 2); + GPR_ASSERT(next == 2); exec_ctx.now = next; next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 6); + GPR_ASSERT(next == 6); exec_ctx.now = next; next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 14); + GPR_ASSERT(next == 14); exec_ctx.now = next; next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 30); + GPR_ASSERT(next == 30); exec_ctx.now = next; next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 62); + GPR_ASSERT(next == 62); exec_ctx.now = next; next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 126); + GPR_ASSERT(next == 126); exec_ctx.now = next; next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 254); + GPR_ASSERT(next == 254); exec_ctx.now = next; next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 510); + GPR_ASSERT(next == 510); exec_ctx.now = next; next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 1022); + GPR_ASSERT(next == 1022); exec_ctx.now = next; next = grpc_backoff_step(&exec_ctx, &backoff); // Hit the maximum timeout. From this point onwards, retries will increase // only by max timeout. - GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 1535); + GPR_ASSERT(next == 1535); exec_ctx.now = next; next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 2048); + GPR_ASSERT(next == 2048); exec_ctx.now = next; next = grpc_backoff_step(&exec_ctx, &backoff); - GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 2561); + GPR_ASSERT(next == 2561); grpc_exec_ctx_finish(&exec_ctx); } From 8e90f6955a3f3aca7ba99577fc59e910996dd380 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 12 Sep 2017 13:04:02 -0700 Subject: [PATCH 029/142] Fix API fuzzer --- test/core/end2end/fuzzers/api_fuzzer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index 46819d0dba0..0a787bbf300 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -60,7 +60,9 @@ extern gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type); static gpr_timespec now_impl(gpr_clock_type clock_type) { GPR_ASSERT(clock_type != GPR_TIMESPAN); - return g_now; + gpr_timespec ts = g_now; + ts.clock_type = clock_type; + return ts; } //////////////////////////////////////////////////////////////////////////////// From 31620ca54f2bd7a799d70d77abc29020e83a6798 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 15 Sep 2017 12:40:24 -0700 Subject: [PATCH 030/142] Squash ping queues, make BDP pings non-initiating, make BDP queries speedup/slowdown --- .../chttp2/transport/chttp2_transport.c | 63 +++++++------------ .../transport/chttp2/transport/flow_control.c | 9 --- .../ext/transport/chttp2/transport/internal.h | 12 +--- .../ext/transport/chttp2/transport/writing.c | 41 +++--------- src/core/lib/transport/bdp_estimator.c | 30 ++++++++- src/core/lib/transport/bdp_estimator.h | 5 ++ 6 files changed, 66 insertions(+), 94 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 79a9ed827f7..ecd4322b436 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -144,11 +144,9 @@ static void finish_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp, static void cancel_pings(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_error *error); -static void send_ping_locked( - grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, - grpc_chttp2_ping_type ping_type, grpc_closure *on_initiate, - grpc_closure *on_complete, - grpc_chttp2_initiate_write_reason initiate_write_reason); +static void send_ping_locked(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, + grpc_closure *on_initiate, + grpc_closure *on_complete); static void retry_initiate_ping_locked(grpc_exec_ctx *exec_ctx, void *tp, grpc_error *error); @@ -892,9 +890,6 @@ static void inc_initiate_write_reason( case GRPC_CHTTP2_INITIATE_WRITE_SEND_SETTINGS: GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_SETTINGS(exec_ctx); break; - case GRPC_CHTTP2_INITIATE_WRITE_BDP_ESTIMATOR_PING: - GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_BDP_ESTIMATOR_PING(exec_ctx); - break; case GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_SETTING: GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_SETTING( exec_ctx); @@ -1701,28 +1696,21 @@ static void cancel_pings(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_error *error) { /* callback remaining pings: they're not allowed to call into the transpot, and maybe they hold resources that need to be freed */ - for (size_t i = 0; i < GRPC_CHTTP2_PING_TYPE_COUNT; i++) { - grpc_chttp2_ping_queue *pq = &t->ping_queues[i]; - for (size_t j = 0; j < GRPC_CHTTP2_PCL_COUNT; j++) { - grpc_closure_list_fail_all(&pq->lists[j], GRPC_ERROR_REF(error)); - GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pq->lists[j]); - } + grpc_chttp2_ping_queue *pq = &t->ping_queue; + for (size_t j = 0; j < GRPC_CHTTP2_PCL_COUNT; j++) { + grpc_closure_list_fail_all(&pq->lists[j], GRPC_ERROR_REF(error)); + GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pq->lists[j]); } GRPC_ERROR_UNREF(error); } -static void send_ping_locked( - grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, - grpc_chttp2_ping_type ping_type, grpc_closure *on_initiate, - grpc_closure *on_ack, - grpc_chttp2_initiate_write_reason initiate_write_reason) { - grpc_chttp2_ping_queue *pq = &t->ping_queues[ping_type]; +static void send_ping_locked(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, + grpc_closure *on_initiate, grpc_closure *on_ack) { + grpc_chttp2_ping_queue *pq = &t->ping_queue; grpc_closure_list_append(&pq->lists[GRPC_CHTTP2_PCL_INITIATE], on_initiate, GRPC_ERROR_NONE); - if (grpc_closure_list_append(&pq->lists[GRPC_CHTTP2_PCL_NEXT], on_ack, - GRPC_ERROR_NONE)) { - grpc_chttp2_initiate_write(exec_ctx, t, initiate_write_reason); - } + grpc_closure_list_append(&pq->lists[GRPC_CHTTP2_PCL_NEXT], on_ack, + GRPC_ERROR_NONE); } static void retry_initiate_ping_locked(grpc_exec_ctx *exec_ctx, void *tp, @@ -1735,8 +1723,7 @@ static void retry_initiate_ping_locked(grpc_exec_ctx *exec_ctx, void *tp, void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, uint64_t id) { - grpc_chttp2_ping_queue *pq = - &t->ping_queues[id % GRPC_CHTTP2_PING_TYPE_COUNT]; + grpc_chttp2_ping_queue *pq = &t->ping_queue; if (pq->inflight_id != id) { char *from = grpc_endpoint_get_peer(t->ep); gpr_log(GPR_DEBUG, "Unknown ping response from %s: %" PRIx64, from, id); @@ -1806,9 +1793,9 @@ static void perform_transport_op_locked(grpc_exec_ctx *exec_ctx, } if (op->send_ping) { - send_ping_locked(exec_ctx, t, GRPC_CHTTP2_PING_ON_NEXT_WRITE, NULL, - op->send_ping, - GRPC_CHTTP2_INITIATE_WRITE_APPLICATION_PING); + send_ping_locked(exec_ctx, t, NULL, op->send_ping); + grpc_chttp2_initiate_write(exec_ctx, t, + GRPC_CHTTP2_INITIATE_WRITE_APPLICATION_PING); } if (op->on_connectivity_state_change != NULL) { @@ -2449,10 +2436,8 @@ void grpc_chttp2_act_on_flowctl_action(grpc_exec_ctx *exec_ctx, if (action.need_ping) { GRPC_CHTTP2_REF_TRANSPORT(t, "bdp_ping"); grpc_bdp_estimator_schedule_ping(&t->flow_control.bdp_estimator); - send_ping_locked(exec_ctx, t, - GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE, - &t->start_bdp_ping_locked, &t->finish_bdp_ping_locked, - GRPC_CHTTP2_INITIATE_WRITE_BDP_ESTIMATOR_PING); + send_ping_locked(exec_ctx, t, &t->start_bdp_ping_locked, + &t->finish_bdp_ping_locked); } } @@ -2560,7 +2545,7 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, grpc_endpoint_read(exec_ctx, t->ep, &t->read_buffer, &t->read_action_locked); grpc_chttp2_act_on_flowctl_action( - exec_ctx, grpc_chttp2_flowctl_get_bdp_action(&t->flow_control), t, + exec_ctx, grpc_chttp2_flowctl_get_action(&t->flow_control, NULL), t, NULL); GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keep_reading"); } else { @@ -2647,10 +2632,10 @@ static void init_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg, grpc_chttp2_stream_map_size(&t->stream_map) > 0) { t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_PINGING; GRPC_CHTTP2_REF_TRANSPORT(t, "keepalive ping end"); - send_ping_locked(exec_ctx, t, GRPC_CHTTP2_PING_ON_NEXT_WRITE, - &t->start_keepalive_ping_locked, - &t->finish_keepalive_ping_locked, - GRPC_CHTTP2_INITIATE_WRITE_KEEPALIVE_PING); + send_ping_locked(exec_ctx, t, &t->start_keepalive_ping_locked, + &t->finish_keepalive_ping_locked); + grpc_chttp2_initiate_write(exec_ctx, t, + GRPC_CHTTP2_INITIATE_WRITE_KEEPALIVE_PING); } else { GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping"); grpc_timer_init( @@ -3141,8 +3126,6 @@ const char *grpc_chttp2_initiate_write_reason_string( return "TRANSPORT_FLOW_CONTROL"; case GRPC_CHTTP2_INITIATE_WRITE_SEND_SETTINGS: return "SEND_SETTINGS"; - case GRPC_CHTTP2_INITIATE_WRITE_BDP_ESTIMATOR_PING: - return "BDP_ESTIMATOR_PING"; case GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_SETTING: return "FLOW_CONTROL_UNSTALLED_BY_SETTING"; case GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_UPDATE: diff --git a/src/core/ext/transport/chttp2/transport/flow_control.c b/src/core/ext/transport/chttp2/transport/flow_control.c index 569a6349d3d..704c0ad7bc7 100644 --- a/src/core/ext/transport/chttp2/transport/flow_control.c +++ b/src/core/ext/transport/chttp2/transport/flow_control.c @@ -441,14 +441,6 @@ grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_action( action.send_stream_update = GRPC_CHTTP2_FLOWCTL_QUEUE_UPDATE; } } - TRACEACTION(tfc, action); - return action; -} - -grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_bdp_action( - grpc_chttp2_transport_flowctl* tfc) { - grpc_chttp2_flowctl_action action; - memset(&action, 0, sizeof(action)); if (tfc->enable_bdp_probe) { action.need_ping = grpc_bdp_estimator_need_ping(&tfc->bdp_estimator); @@ -496,7 +488,6 @@ grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_bdp_action( } } } - TRACEACTION(tfc, action); return action; } diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index c2dfce7c9c7..2f5320985ae 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -61,12 +61,6 @@ typedef enum { GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE, } grpc_chttp2_write_state; -typedef enum { - GRPC_CHTTP2_PING_ON_NEXT_WRITE = 0, - GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE, - GRPC_CHTTP2_PING_TYPE_COUNT /* must be last */ -} grpc_chttp2_ping_type; - typedef enum { GRPC_CHTTP2_OPTIMIZE_FOR_LATENCY, GRPC_CHTTP2_OPTIMIZE_FOR_THROUGHPUT, @@ -93,7 +87,6 @@ typedef enum { GRPC_CHTTP2_INITIATE_WRITE_STREAM_FLOW_CONTROL, GRPC_CHTTP2_INITIATE_WRITE_TRANSPORT_FLOW_CONTROL, GRPC_CHTTP2_INITIATE_WRITE_SEND_SETTINGS, - GRPC_CHTTP2_INITIATE_WRITE_BDP_ESTIMATOR_PING, GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_SETTING, GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_UPDATE, GRPC_CHTTP2_INITIATE_WRITE_APPLICATION_PING, @@ -370,7 +363,7 @@ struct grpc_chttp2_transport { uint32_t last_new_stream_id; /** ping queues for various ping insertion points */ - grpc_chttp2_ping_queue ping_queues[GRPC_CHTTP2_PING_TYPE_COUNT]; + grpc_chttp2_ping_queue ping_queue; grpc_chttp2_repeated_ping_policy ping_policy; grpc_chttp2_repeated_ping_state ping_state; uint64_t ping_ctr; /* unique id for pings */ @@ -754,9 +747,6 @@ typedef struct { grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_action( grpc_chttp2_transport_flowctl *tfc, grpc_chttp2_stream_flowctl *sfc); -grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_bdp_action( - grpc_chttp2_transport_flowctl *tfc); - // Takes in a flow control action and performs all the needed operations. void grpc_chttp2_act_on_flowctl_action(grpc_exec_ctx *exec_ctx, grpc_chttp2_flowctl_action action, diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index 3ded801985d..c132195457e 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -42,18 +42,9 @@ static void finish_write_cb(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, t->write_cb_pool = cb; } -static void collapse_pings_from_into(grpc_chttp2_transport *t, - grpc_chttp2_ping_type ping_type, - grpc_chttp2_ping_queue *pq) { - for (size_t i = 0; i < GRPC_CHTTP2_PCL_COUNT; i++) { - grpc_closure_list_move(&t->ping_queues[ping_type].lists[i], &pq->lists[i]); - } -} - static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, - grpc_chttp2_transport *t, - grpc_chttp2_ping_type ping_type) { - grpc_chttp2_ping_queue *pq = &t->ping_queues[ping_type]; + grpc_chttp2_transport *t) { + grpc_chttp2_ping_queue *pq = &t->ping_queue; if (grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_NEXT])) { /* no ping needed: wait */ return; @@ -100,17 +91,7 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, } return; } - /* coalesce equivalent pings into this one */ - switch (ping_type) { - case GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE: - collapse_pings_from_into(t, GRPC_CHTTP2_PING_ON_NEXT_WRITE, pq); - break; - case GRPC_CHTTP2_PING_ON_NEXT_WRITE: - break; - case GRPC_CHTTP2_PING_TYPE_COUNT: - GPR_UNREACHABLE_CODE(break); - } - pq->inflight_id = t->ping_ctr * GRPC_CHTTP2_PING_TYPE_COUNT + ping_type; + pq->inflight_id = t->ping_ctr; t->ping_ctr++; GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pq->lists[GRPC_CHTTP2_PCL_INITIATE]); grpc_closure_list_move(&pq->lists[GRPC_CHTTP2_PCL_NEXT], @@ -179,6 +160,12 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( GPR_TIMER_BEGIN("grpc_chttp2_begin_write", 0); + for (size_t i = 0; i < t->ping_ack_count; i++) { + grpc_slice_buffer_add(&t->outbuf, + grpc_chttp2_ping_create(1, t->ping_acks[i])); + } + t->ping_ack_count = 0; + if (t->dirtied_local_settings && !t->sent_local_settings) { grpc_slice_buffer_add( &t->outbuf, @@ -481,8 +468,6 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( uint32_t transport_announce = grpc_chttp2_flowctl_maybe_send_transport_update(&t->flow_control); if (transport_announce) { - maybe_initiate_ping(exec_ctx, t, - GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE); grpc_transport_one_way_stats throwaway_stats; grpc_slice_buffer_add( &t->outbuf, grpc_chttp2_window_update_create(0, transport_announce, @@ -496,13 +481,7 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( } } - for (size_t i = 0; i < t->ping_ack_count; i++) { - grpc_slice_buffer_add(&t->outbuf, - grpc_chttp2_ping_create(1, t->ping_acks[i])); - } - t->ping_ack_count = 0; - - maybe_initiate_ping(exec_ctx, t, GRPC_CHTTP2_PING_ON_NEXT_WRITE); + maybe_initiate_ping(exec_ctx, t); GPR_TIMER_END("grpc_chttp2_begin_write", 0); diff --git a/src/core/lib/transport/bdp_estimator.c b/src/core/lib/transport/bdp_estimator.c index 8b576934134..2a3ffbbd018 100644 --- a/src/core/lib/transport/bdp_estimator.c +++ b/src/core/lib/transport/bdp_estimator.c @@ -29,8 +29,11 @@ grpc_tracer_flag grpc_bdp_estimator_trace = void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator, const char *name) { estimator->estimate = 65536; estimator->ping_state = GRPC_BDP_PING_UNSCHEDULED; + estimator->ping_start_time = gpr_time_0(GPR_CLOCK_MONOTONIC); estimator->name = name; estimator->bw_est = 0; + estimator->inter_ping_delay = 100.0; // start at 100ms + estimator->stable_estimate_count = 0; } bool grpc_bdp_estimator_get_estimate(const grpc_bdp_estimator *estimator, @@ -53,7 +56,8 @@ void grpc_bdp_estimator_add_incoming_bytes(grpc_bdp_estimator *estimator, bool grpc_bdp_estimator_need_ping(const grpc_bdp_estimator *estimator) { switch (estimator->ping_state) { case GRPC_BDP_PING_UNSCHEDULED: - return true; + return gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), + estimator->ping_start_time) >= 0; case GRPC_BDP_PING_SCHEDULED: return false; case GRPC_BDP_PING_STARTED: @@ -84,10 +88,11 @@ void grpc_bdp_estimator_start_ping(grpc_bdp_estimator *estimator) { } void grpc_bdp_estimator_complete_ping(grpc_bdp_estimator *estimator) { - gpr_timespec dt_ts = - gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), estimator->ping_start_time); + gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); + gpr_timespec dt_ts = gpr_time_sub(now, estimator->ping_start_time); double dt = (double)dt_ts.tv_sec + 1e-9 * (double)dt_ts.tv_nsec; double bw = dt > 0 ? ((double)estimator->accumulator / dt) : 0; + int start_inter_ping_delay = estimator->inter_ping_delay; if (GRPC_TRACER_ON(grpc_bdp_estimator_trace)) { gpr_log(GPR_DEBUG, "bdp[%s]:complete acc=%" PRId64 " est=%" PRId64 " dt=%lf bw=%lfMbs bw_est=%lfMbs", @@ -104,7 +109,26 @@ void grpc_bdp_estimator_complete_ping(grpc_bdp_estimator *estimator) { gpr_log(GPR_DEBUG, "bdp[%s]: estimate increased to %" PRId64, estimator->name, estimator->estimate); } + estimator->inter_ping_delay /= 2; // if the ping estimate changes, + // exponentially get faster at probing + } else if (estimator->inter_ping_delay < 10000) { + estimator->stable_estimate_count++; + if (estimator->stable_estimate_count >= 2) { + estimator->inter_ping_delay += + 100 + + (int)(rand() * 100.0 / RAND_MAX); // if the ping estimate is steady, + // slowly ramp down the probe time + } + } + if (start_inter_ping_delay != estimator->inter_ping_delay) { + estimator->stable_estimate_count = 0; + if (GRPC_TRACER_ON(grpc_bdp_estimator_trace)) { + gpr_log(GPR_DEBUG, "bdp[%s]:update_inter_time to %dms", estimator->name, + estimator->inter_ping_delay); + } } estimator->ping_state = GRPC_BDP_PING_UNSCHEDULED; estimator->accumulator = 0; + estimator->ping_start_time = gpr_time_add( + now, gpr_time_from_millis(estimator->inter_ping_delay, GPR_TIMESPAN)); } diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h index 1ef0dc99ddb..670e38dd4bb 100644 --- a/src/core/lib/transport/bdp_estimator.h +++ b/src/core/lib/transport/bdp_estimator.h @@ -39,7 +39,12 @@ typedef struct grpc_bdp_estimator { grpc_bdp_estimator_ping_state ping_state; int64_t accumulator; int64_t estimate; + // case ping_state of + // GRPC_BDP_PING_UNSCHEDULED => when to start the next ping + // GRPC_BDP_PING_STARTED => when the current ping was started gpr_timespec ping_start_time; + int inter_ping_delay; + int stable_estimate_count; double bw_est; const char *name; } grpc_bdp_estimator; From 149c4696e627db4ff226757fb3d6245154ec2926 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 15 Sep 2017 13:46:12 -0700 Subject: [PATCH 031/142] Fix pings racing initial settings --- src/core/ext/transport/chttp2/transport/writing.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index c132195457e..82f7df27243 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -160,12 +160,6 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( GPR_TIMER_BEGIN("grpc_chttp2_begin_write", 0); - for (size_t i = 0; i < t->ping_ack_count; i++) { - grpc_slice_buffer_add(&t->outbuf, - grpc_chttp2_ping_create(1, t->ping_acks[i])); - } - t->ping_ack_count = 0; - if (t->dirtied_local_settings && !t->sent_local_settings) { grpc_slice_buffer_add( &t->outbuf, @@ -178,6 +172,12 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( GRPC_STATS_INC_HTTP2_SETTINGS_WRITES(exec_ctx); } + for (size_t i = 0; i < t->ping_ack_count; i++) { + grpc_slice_buffer_add(&t->outbuf, + grpc_chttp2_ping_create(1, t->ping_acks[i])); + } + t->ping_ack_count = 0; + /* simple writes are queued to qbuf, and flushed here */ grpc_slice_buffer_move_into(&t->qbuf, &t->outbuf); GPR_ASSERT(t->qbuf.count == 0); From e932aca45df5cb8391635b4056ecaf14631967fb Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 15 Sep 2017 13:50:46 -0700 Subject: [PATCH 032/142] Add a counter for spurious writes --- .../ext/transport/chttp2/transport/chttp2_transport.c | 1 + src/core/lib/debug/stats_data.c | 2 ++ src/core/lib/debug/stats_data.h | 4 ++++ src/core/lib/debug/stats_data.yaml | 2 ++ src/core/lib/debug/stats_data_bq_schema.sql | 1 + tools/run_tests/performance/massage_qps_stats.py | 1 + .../run_tests/performance/scenario_result_schema.json | 10 ++++++++++ 7 files changed, 21 insertions(+) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index ecd4322b436..d1860512911 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -1027,6 +1027,7 @@ static void write_action_begin_locked(grpc_exec_ctx *exec_ctx, void *gt, write_action, t, scheduler), GRPC_ERROR_NONE); } else { + GRPC_STATS_INC_HTTP2_SPURIOUS_WRITES_BEGUN(exec_ctx); set_write_state(exec_ctx, t, GRPC_CHTTP2_WRITE_STATE_IDLE, "begin writing nothing"); GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "writing"); diff --git a/src/core/lib/debug/stats_data.c b/src/core/lib/debug/stats_data.c index b3e1ee9b4ec..173e075db3c 100644 --- a/src/core/lib/debug/stats_data.c +++ b/src/core/lib/debug/stats_data.c @@ -71,6 +71,7 @@ const char *grpc_stats_counter_name[GRPC_STATS_COUNTER_COUNT] = { "http2_initiate_write_due_to_transport_flow_control_unstalled", "http2_initiate_write_due_to_ping_response", "http2_initiate_write_due_to_force_rst_stream", + "http2_spurious_writes_begun", "combiner_locks_initiated", "combiner_locks_scheduled_items", "combiner_locks_scheduled_final_items", @@ -137,6 +138,7 @@ const char *grpc_stats_counter_doc[GRPC_STATS_COUNTER_COUNT] = { "'transport_flow_control_unstalled'", "Number of HTTP2 writes initiated due to 'ping_response'", "Number of HTTP2 writes initiated due to 'force_rst_stream'", + "Number of HTTP2 writes initiated with nothing to write", "Number of combiner lock entries by process (first items queued to a " "combiner)", "Number of items scheduled against combiner locks", diff --git a/src/core/lib/debug/stats_data.h b/src/core/lib/debug/stats_data.h index c9871c4a56c..235a93ba396 100644 --- a/src/core/lib/debug/stats_data.h +++ b/src/core/lib/debug/stats_data.h @@ -73,6 +73,7 @@ typedef enum { GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_TRANSPORT_FLOW_CONTROL_UNSTALLED, GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_PING_RESPONSE, GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_FORCE_RST_STREAM, + GRPC_STATS_COUNTER_HTTP2_SPURIOUS_WRITES_BEGUN, GRPC_STATS_COUNTER_COMBINER_LOCKS_INITIATED, GRPC_STATS_COUNTER_COMBINER_LOCKS_SCHEDULED_ITEMS, GRPC_STATS_COUNTER_COMBINER_LOCKS_SCHEDULED_FINAL_ITEMS, @@ -279,6 +280,9 @@ typedef enum { GRPC_STATS_INC_COUNTER( \ (exec_ctx), \ GRPC_STATS_COUNTER_HTTP2_INITIATE_WRITE_DUE_TO_FORCE_RST_STREAM) +#define GRPC_STATS_INC_HTTP2_SPURIOUS_WRITES_BEGUN(exec_ctx) \ + GRPC_STATS_INC_COUNTER((exec_ctx), \ + GRPC_STATS_COUNTER_HTTP2_SPURIOUS_WRITES_BEGUN) #define GRPC_STATS_INC_COMBINER_LOCKS_INITIATED(exec_ctx) \ GRPC_STATS_INC_COUNTER((exec_ctx), \ GRPC_STATS_COUNTER_COMBINER_LOCKS_INITIATED) diff --git a/src/core/lib/debug/stats_data.yaml b/src/core/lib/debug/stats_data.yaml index 84727fe6c47..fc6ca860bc9 100644 --- a/src/core/lib/debug/stats_data.yaml +++ b/src/core/lib/debug/stats_data.yaml @@ -159,6 +159,8 @@ doc: Number of HTTP2 writes initiated due to 'ping_response' - counter: http2_initiate_write_due_to_force_rst_stream doc: Number of HTTP2 writes initiated due to 'force_rst_stream' +- counter: http2_spurious_writes_begun + doc: Number of HTTP2 writes initiated with nothing to write # combiner locks - counter: combiner_locks_initiated doc: Number of combiner lock entries by process diff --git a/src/core/lib/debug/stats_data_bq_schema.sql b/src/core/lib/debug/stats_data_bq_schema.sql index d21afbbfe45..1680425eb65 100644 --- a/src/core/lib/debug/stats_data_bq_schema.sql +++ b/src/core/lib/debug/stats_data_bq_schema.sql @@ -46,6 +46,7 @@ http2_initiate_write_due_to_keepalive_ping_per_iteration:FLOAT, http2_initiate_write_due_to_transport_flow_control_unstalled_per_iteration:FLOAT, http2_initiate_write_due_to_ping_response_per_iteration:FLOAT, http2_initiate_write_due_to_force_rst_stream_per_iteration:FLOAT, +http2_spurious_writes_begun_per_iteration:FLOAT, combiner_locks_initiated_per_iteration:FLOAT, combiner_locks_scheduled_items_per_iteration:FLOAT, combiner_locks_scheduled_final_items_per_iteration:FLOAT, diff --git a/tools/run_tests/performance/massage_qps_stats.py b/tools/run_tests/performance/massage_qps_stats.py index 7994b544ac2..4d4c4944055 100644 --- a/tools/run_tests/performance/massage_qps_stats.py +++ b/tools/run_tests/performance/massage_qps_stats.py @@ -68,6 +68,7 @@ def massage_qps_stats(scenario_result): stats["core_http2_initiate_write_due_to_transport_flow_control_unstalled"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_transport_flow_control_unstalled") stats["core_http2_initiate_write_due_to_ping_response"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_ping_response") stats["core_http2_initiate_write_due_to_force_rst_stream"] = massage_qps_stats_helpers.counter(core_stats, "http2_initiate_write_due_to_force_rst_stream") + stats["core_http2_spurious_writes_begun"] = massage_qps_stats_helpers.counter(core_stats, "http2_spurious_writes_begun") stats["core_combiner_locks_initiated"] = massage_qps_stats_helpers.counter(core_stats, "combiner_locks_initiated") stats["core_combiner_locks_scheduled_items"] = massage_qps_stats_helpers.counter(core_stats, "combiner_locks_scheduled_items") stats["core_combiner_locks_scheduled_final_items"] = massage_qps_stats_helpers.counter(core_stats, "combiner_locks_scheduled_final_items") diff --git a/tools/run_tests/performance/scenario_result_schema.json b/tools/run_tests/performance/scenario_result_schema.json index 12a56dbec0e..725b3a70568 100644 --- a/tools/run_tests/performance/scenario_result_schema.json +++ b/tools/run_tests/performance/scenario_result_schema.json @@ -350,6 +350,11 @@ "name": "core_http2_initiate_write_due_to_force_rst_stream", "type": "INTEGER" }, + { + "mode": "NULLABLE", + "name": "core_http2_spurious_writes_begun", + "type": "INTEGER" + }, { "mode": "NULLABLE", "name": "core_combiner_locks_initiated", @@ -952,6 +957,11 @@ "name": "core_http2_initiate_write_due_to_force_rst_stream", "type": "INTEGER" }, + { + "mode": "NULLABLE", + "name": "core_http2_spurious_writes_begun", + "type": "INTEGER" + }, { "mode": "NULLABLE", "name": "core_combiner_locks_initiated", From 14df5f735274a8f05294e7eae0f5175e0713bdc5 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 15 Sep 2017 15:39:40 -0700 Subject: [PATCH 033/142] Large flow control windows under low memory pressure --- .../transport/chttp2/transport/flow_control.c | 17 ++++++++--- .../ext/transport/chttp2/transport/internal.h | 2 +- .../ext/transport/chttp2/transport/writing.c | 29 ++++++++++++++++--- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/flow_control.c b/src/core/ext/transport/chttp2/transport/flow_control.c index 704c0ad7bc7..e3be2e51980 100644 --- a/src/core/ext/transport/chttp2/transport/flow_control.c +++ b/src/core/ext/transport/chttp2/transport/flow_control.c @@ -281,13 +281,14 @@ grpc_error* grpc_chttp2_flowctl_recv_data(grpc_chttp2_transport_flowctl* tfc, // Returns a non zero announce integer if we should send a transport window // update uint32_t grpc_chttp2_flowctl_maybe_send_transport_update( - grpc_chttp2_transport_flowctl* tfc) { + grpc_chttp2_transport_flowctl* tfc, bool writing_anyway) { PRETRACE(tfc, NULL); uint32_t target_announced_window = grpc_chttp2_target_announced_window(tfc); uint32_t threshold_to_send_transport_window_update = tfc->t->outbuf.count > 0 ? 3 * target_announced_window / 4 : target_announced_window / 2; - if (tfc->announced_window <= threshold_to_send_transport_window_update && + if ((writing_anyway || + tfc->announced_window <= threshold_to_send_transport_window_update) && tfc->announced_window != target_announced_window) { uint32_t announce = (uint32_t)GPR_CLAMP( target_announced_window - tfc->announced_window, 0, UINT32_MAX); @@ -413,8 +414,16 @@ static double get_target_under_memory_pressure( // do not increase window under heavy memory pressure. double memory_pressure = grpc_resource_quota_get_memory_pressure( grpc_resource_user_quota(grpc_endpoint_get_resource_user(tfc->t->ep))); - if (memory_pressure > 0.8) { - target *= 1 - GPR_MIN(1, (memory_pressure - 0.8) / 0.1); + static const double kLowMemPressure = 0.1; + static const double kZeroTarget = 24; + static const double kHighMemPressure = 0.8; + static const double kMaxMemPressure = 0.9; + if (memory_pressure < kLowMemPressure && target < kZeroTarget) { + target = (target - kZeroTarget) * memory_pressure / kLowMemPressure + + kZeroTarget; + } else if (memory_pressure > kHighMemPressure) { + target *= 1 - GPR_MIN(1, (memory_pressure - kHighMemPressure) / + (kMaxMemPressure - kHighMemPressure)); } return target; } diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 2f5320985ae..8e23d92e78e 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -698,7 +698,7 @@ grpc_error *grpc_chttp2_flowctl_recv_data(grpc_chttp2_transport_flowctl *tfc, // returns an announce if we should send a transport update to our peer, // else returns zero uint32_t grpc_chttp2_flowctl_maybe_send_transport_update( - grpc_chttp2_transport_flowctl *tfc); + grpc_chttp2_transport_flowctl *tfc, bool writing_anyway); // returns an announce if we should send a stream update to our peer, else // returns zero diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index 82f7df27243..8c02ba1b904 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -126,6 +126,25 @@ static bool update_list(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, return sched_any; } +static void report_stall(grpc_chttp2_transport *t, grpc_chttp2_stream *s, + const char *staller) { + gpr_log( + GPR_DEBUG, + "%s:%p stream %d stalled by %s [fc:pending=%" PRIdPTR ":flowed=%" PRId64 + ":peer_initwin=%d:t_win=%" PRId64 ":s_win=%d:s_delta=%" PRId64 "]", + t->peer_string, t, s->id, staller, s->flow_controlled_buffer.length, + s->flow_controlled_bytes_flowed, + t->settings[GRPC_ACKED_SETTINGS] + [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE], + t->flow_control.remote_window, + (uint32_t)GPR_MAX( + 0, + s->flow_control.remote_window_delta + + (int64_t)t->settings[GRPC_PEER_SETTINGS] + [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]), + s->flow_control.remote_window_delta); +} + static bool stream_ref_if_not_destroyed(gpr_refcount *r) { gpr_atm count; do { @@ -394,9 +413,11 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( } message_writes++; } else if (t->flow_control.remote_window == 0) { + report_stall(t, s, "transport"); grpc_chttp2_list_add_stalled_by_transport(t, s); now_writing = true; } else if (stream_remote_window == 0) { + report_stall(t, s, "stream"); grpc_chttp2_list_add_stalled_by_stream(t, s); now_writing = true; } @@ -465,8 +486,10 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( } } - uint32_t transport_announce = - grpc_chttp2_flowctl_maybe_send_transport_update(&t->flow_control); + maybe_initiate_ping(exec_ctx, t); + + uint32_t transport_announce = grpc_chttp2_flowctl_maybe_send_transport_update( + &t->flow_control, t->outbuf.count > 0); if (transport_announce) { grpc_transport_one_way_stats throwaway_stats; grpc_slice_buffer_add( @@ -481,8 +504,6 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( } } - maybe_initiate_ping(exec_ctx, t); - GPR_TIMER_END("grpc_chttp2_begin_write", 0); result.writing = t->outbuf.count > 0; From 468d1e5b56a72f45ac7efe8f8ca6bca435fd1c39 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 18 Sep 2017 09:25:42 -0700 Subject: [PATCH 034/142] Fix keepalive test --- test/core/end2end/tests/keepalive_timeout.c | 32 +++++++++------------ 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/test/core/end2end/tests/keepalive_timeout.c b/test/core/end2end/tests/keepalive_timeout.c index e0ead4ab62a..c4280149c7e 100644 --- a/test/core/end2end/tests/keepalive_timeout.c +++ b/test/core/end2end/tests/keepalive_timeout.c @@ -98,21 +98,21 @@ static void test_keepalive_timeout(grpc_end2end_test_config config) { grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); - grpc_arg keepalive_args[] = {{.type = GRPC_ARG_INTEGER, - .key = GRPC_ARG_KEEPALIVE_TIME_MS, - .value.integer = 1500}, - {.type = GRPC_ARG_INTEGER, - .key = GRPC_ARG_KEEPALIVE_TIMEOUT_MS, - .value.integer = 0}, - {.type = GRPC_ARG_INTEGER, - .key = GRPC_ARG_HTTP2_BDP_PROBE, - .value.integer = 1}}; - - grpc_channel_args *client_args = NULL; - client_args = grpc_channel_args_copy_and_add(client_args, keepalive_args, 2); + grpc_arg keepalive_arg_elems[] = {{.type = GRPC_ARG_INTEGER, + .key = GRPC_ARG_KEEPALIVE_TIME_MS, + .value.integer = 1500}, + {.type = GRPC_ARG_INTEGER, + .key = GRPC_ARG_KEEPALIVE_TIMEOUT_MS, + .value.integer = 0}, + {.type = GRPC_ARG_INTEGER, + .key = GRPC_ARG_HTTP2_BDP_PROBE, + .value.integer = 0}}; + grpc_channel_args keepalive_args = { + .num_args = GPR_ARRAY_SIZE(keepalive_arg_elems), + .args = keepalive_arg_elems}; grpc_end2end_test_fixture f = - begin_test(config, "keepalive_timeout", client_args, NULL); + begin_test(config, "keepalive_timeout", &keepalive_args, NULL); cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; @@ -216,12 +216,6 @@ static void test_keepalive_timeout(grpc_end2end_test_config config) { grpc_byte_buffer_destroy(response_payload); grpc_byte_buffer_destroy(response_payload_recv); - if (client_args != NULL) { - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_channel_args_destroy(&exec_ctx, client_args); - grpc_exec_ctx_finish(&exec_ctx); - } - end_test(&f); config.tear_down_data(&f); } From 2c5bfacfdd531f1ed5b831f26de9c82d000088f5 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 18 Sep 2017 12:13:05 -0700 Subject: [PATCH 035/142] Mock time to resolve test error --- test/core/transport/bdp_estimator_test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/core/transport/bdp_estimator_test.c b/test/core/transport/bdp_estimator_test.c index dda48f45b18..a256eb3a4a8 100644 --- a/test/core/transport/bdp_estimator_test.c +++ b/test/core/transport/bdp_estimator_test.c @@ -27,6 +27,18 @@ #include "src/core/lib/support/string.h" #include "test/core/util/test_config.h" +extern gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type); + +static int g_clock = 0; + +static gpr_timespec fake_gpr_now(gpr_clock_type clock_type) { + return (gpr_timespec){ + .tv_sec = g_clock, .tv_nsec = 0, .clock_type = clock_type, + }; +} + +static void inc_time(void) { g_clock += 30; } + static void test_noop(void) { gpr_log(GPR_INFO, "test_noop"); grpc_bdp_estimator est; @@ -44,6 +56,7 @@ static void test_get_estimate_no_samples(void) { static void add_samples(grpc_bdp_estimator *estimator, int64_t *samples, size_t n) { grpc_bdp_estimator_add_incoming_bytes(estimator, 1234567); + inc_time(); GPR_ASSERT(grpc_bdp_estimator_need_ping(estimator) == true); grpc_bdp_estimator_schedule_ping(estimator); grpc_bdp_estimator_start_ping(estimator); @@ -130,6 +143,7 @@ static void test_get_estimate_random_values(size_t n) { int main(int argc, char **argv) { grpc_test_init(argc, argv); + gpr_now_impl = fake_gpr_now; grpc_init(); test_noop(); test_get_estimate_no_samples(); From a1bb6cad29ecc534051849e0574742e30130b72b Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 19 Sep 2017 18:05:09 +0000 Subject: [PATCH 036/142] Fix timeout encoding test --- src/core/lib/transport/timeout_encoding.c | 2 +- test/core/transport/timeout_encoding_test.c | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/core/lib/transport/timeout_encoding.c b/src/core/lib/transport/timeout_encoding.c index 779d016ca6b..23a9ef308f6 100644 --- a/src/core/lib/transport/timeout_encoding.c +++ b/src/core/lib/transport/timeout_encoding.c @@ -89,7 +89,7 @@ static int is_all_whitespace(const char *p, const char *end) { } int grpc_http2_decode_timeout(grpc_slice text, grpc_millis *timeout) { - int32_t x = 0; + grpc_millis x = 0; const uint8_t *p = GRPC_SLICE_START_PTR(text); const uint8_t *end = GRPC_SLICE_END_PTR(text); int have_digit = 0; diff --git a/test/core/transport/timeout_encoding_test.c b/test/core/transport/timeout_encoding_test.c index fcd263f1043..039bb333412 100644 --- a/test/core/transport/timeout_encoding_test.c +++ b/test/core/transport/timeout_encoding_test.c @@ -25,6 +25,7 @@ #include #include #include +#include "src/core/lib/support/murmur_hash.h" #include "src/core/lib/support/string.h" #include "test/core/util/test_config.h" @@ -64,10 +65,14 @@ void test_encoding(void) { static void assert_decodes_as(const char *buffer, grpc_millis expected) { grpc_millis got; - gpr_log(GPR_INFO, "check decoding '%s'", buffer); + uint32_t hash = gpr_murmur_hash3(buffer, strlen(buffer), 0); + gpr_log(GPR_INFO, "check decoding '%s' (hash=0x%x)", buffer, hash); GPR_ASSERT(1 == grpc_http2_decode_timeout( grpc_slice_from_static_string(buffer), &got)); - GPR_ASSERT(got == expected); + if (got != expected) { + gpr_log(GPR_ERROR, "got:'%"PRIdPTR"' != expected:'%"PRIdPTR"'", got, expected); + abort(); + } } void decode_suite(char ext, grpc_millis (*answer)(int64_t x)) { @@ -95,8 +100,8 @@ void decode_suite(char ext, grpc_millis (*answer)(int64_t x)) { } } -static grpc_millis millis_from_nanos(int64_t x) { return x / GPR_NS_PER_MS; } -static grpc_millis millis_from_micros(int64_t x) { return x / GPR_US_PER_MS; } +static grpc_millis millis_from_nanos(int64_t x) { return x / GPR_NS_PER_MS + (x % GPR_NS_PER_MS != 0); } +static grpc_millis millis_from_micros(int64_t x) { return x / GPR_US_PER_MS + (x % GPR_US_PER_MS != 0); } static grpc_millis millis_from_millis(int64_t x) { return x; } static grpc_millis millis_from_seconds(int64_t x) { return x * GPR_MS_PER_SEC; } static grpc_millis millis_from_minutes(int64_t x) { From 6ef8db92bc16ea23dd579f2706335c764f45bc4c Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 19 Sep 2017 18:39:59 +0000 Subject: [PATCH 037/142] Fix test --- .../filters/client_channel/resolver/dns/native/dns_resolver.c | 3 +++ test/core/end2end/invalid_call_argument_test.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c index 7287a5dabce..fd91ac86991 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c @@ -150,6 +150,8 @@ static void dns_on_resolved_locked(grpc_exec_ctx *exec_ctx, void *arg, grpc_channel_args *result = NULL; GPR_ASSERT(r->resolving); r->resolving = false; + GRPC_ERROR_REF(error); + error = grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(r->name_to_resolve)); if (r->addresses != NULL) { grpc_lb_addresses *addresses = grpc_lb_addresses_create( r->addresses->naddrs, NULL /* user_data_vtable */); @@ -186,6 +188,7 @@ static void dns_on_resolved_locked(grpc_exec_ctx *exec_ctx, void *arg, r->resolved_result = result; r->resolved_version++; dns_maybe_finish_next_locked(exec_ctx, r); + GRPC_ERROR_UNREF(error); GRPC_RESOLVER_UNREF(exec_ctx, &r->base, "dns-resolving"); } diff --git a/test/core/end2end/invalid_call_argument_test.c b/test/core/end2end/invalid_call_argument_test.c index bf0d08adecf..e3fd5a8fbe1 100644 --- a/test/core/end2end/invalid_call_argument_test.c +++ b/test/core/end2end/invalid_call_argument_test.c @@ -92,7 +92,7 @@ static void prepare_test(int is_client) { op = g_state.ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; - op->flags = 0; + op->flags = GRPC_INITIAL_METADATA_WAIT_FOR_READY; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(g_state.call, g_state.ops, From 4ebcab42f9fda2a045522caddf84296355e3b2a6 Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Tue, 19 Sep 2017 11:44:15 -0700 Subject: [PATCH 038/142] Reset server-side ping enforcement after send trailing metadata --- .../ext/transport/chttp2/transport/writing.c | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index 7d9d4867e14..66e6971326f 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -62,7 +62,8 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, /* ping already in-flight: wait */ if (GRPC_TRACER_ON(grpc_http_trace) || GRPC_TRACER_ON(grpc_bdp_estimator_trace)) { - gpr_log(GPR_DEBUG, "Ping delayed [%p]: already pinging", t->peer_string); + gpr_log(GPR_DEBUG, "%s: Ping delayed [%p]: already pinging", + t->is_client ? "CLIENT" : "SERVER", t->peer_string); } return; } @@ -71,8 +72,9 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, /* need to receive something of substance before sending a ping again */ if (GRPC_TRACER_ON(grpc_http_trace) || GRPC_TRACER_ON(grpc_bdp_estimator_trace)) { - gpr_log(GPR_DEBUG, "Ping delayed [%p]: too many recent pings: %d/%d", - t->peer_string, t->ping_state.pings_before_data_required, + gpr_log(GPR_DEBUG, "%s: Ping delayed [%p]: too many recent pings: %d/%d", + t->is_client ? "CLIENT" : "SERVER", t->peer_string, + t->ping_state.pings_before_data_required, t->ping_policy.max_pings_without_data); } return; @@ -94,8 +96,8 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, if (GRPC_TRACER_ON(grpc_http_trace) || GRPC_TRACER_ON(grpc_bdp_estimator_trace)) { gpr_log(GPR_DEBUG, - "Ping delayed [%p]: not enough time elapsed since last ping", - t->peer_string); + "%s: Ping delayed [%p]: not enough time elapsed since last ping", + t->is_client ? "CLIENT" : "SERVER", t->peer_string); } if (!t->ping_state.is_delayed_ping_timer_set) { t->ping_state.is_delayed_ping_timer_set = true; @@ -126,7 +128,8 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, t->ping_state.last_ping_sent_time = now; if (GRPC_TRACER_ON(grpc_http_trace) || GRPC_TRACER_ON(grpc_bdp_estimator_trace)) { - gpr_log(GPR_DEBUG, "Ping sent [%p]: %d/%d", t->peer_string, + gpr_log(GPR_DEBUG, "%s: Ping sent [%p]: %d/%d", + t->is_client ? "CLIENT" : "SERVER", t->peer_string, t->ping_state.pings_before_data_required, t->ping_policy.max_pings_without_data); } @@ -451,6 +454,11 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( } s->send_trailing_metadata = NULL; s->sent_trailing_metadata = true; + if (!t->is_client) { + t->ping_recv_state.last_ping_recv_time = + gpr_inf_past(GPR_CLOCK_MONOTONIC); + t->ping_recv_state.ping_strikes = 0; + } if (!t->is_client && !s->read_closed) { grpc_slice_buffer_add( &t->outbuf, grpc_chttp2_rst_stream_create( From 1f710e583117c3ef65733c59f1d3e5b50219828e Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 19 Sep 2017 18:52:34 +0000 Subject: [PATCH 039/142] Fix test --- test/core/end2end/fixtures/h2_ssl_cert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/end2end/fixtures/h2_ssl_cert.c b/test/core/end2end/fixtures/h2_ssl_cert.c index 9b1ddadfe4c..f0a2ee5430e 100644 --- a/test/core/end2end/fixtures/h2_ssl_cert.c +++ b/test/core/end2end/fixtures/h2_ssl_cert.c @@ -319,7 +319,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; - op->flags = 0; + op->flags = GRPC_INITIAL_METADATA_WAIT_FOR_READY; op->reserved = NULL; op++; error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); From 4aa2331958c5fd7b547f016457029b0943818317 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 19 Sep 2017 19:01:56 +0000 Subject: [PATCH 040/142] Fix compile --- test/cpp/naming/resolver_component_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index 0857fb6a32c..47dee5cb3af 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -202,7 +202,7 @@ void PollPollsetUntilRequestDone(ArgsStruct *args) { GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, args->pollset, &worker, - gpr_now(GPR_CLOCK_REALTIME), NSecondDeadline(1))); + grpc_timespec_to_millis_round_up(NSecondDeadline(1)))); gpr_mu_unlock(args->mu); grpc_exec_ctx_finish(&exec_ctx); } From d0ceb377a434e6d8807d461417df3d6de089a1e2 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 19 Sep 2017 12:02:31 -0700 Subject: [PATCH 041/142] clang-format --- .../client_channel/resolver/dns/native/dns_resolver.c | 3 ++- test/core/transport/timeout_encoding_test.c | 11 ++++++++--- test/cpp/naming/resolver_component_test.cc | 8 ++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c index fd91ac86991..e4bffbe8719 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c @@ -151,7 +151,8 @@ static void dns_on_resolved_locked(grpc_exec_ctx *exec_ctx, void *arg, GPR_ASSERT(r->resolving); r->resolving = false; GRPC_ERROR_REF(error); - error = grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(r->name_to_resolve)); + error = grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS, + grpc_slice_from_copied_string(r->name_to_resolve)); if (r->addresses != NULL) { grpc_lb_addresses *addresses = grpc_lb_addresses_create( r->addresses->naddrs, NULL /* user_data_vtable */); diff --git a/test/core/transport/timeout_encoding_test.c b/test/core/transport/timeout_encoding_test.c index 039bb333412..3010c6d057d 100644 --- a/test/core/transport/timeout_encoding_test.c +++ b/test/core/transport/timeout_encoding_test.c @@ -70,7 +70,8 @@ static void assert_decodes_as(const char *buffer, grpc_millis expected) { GPR_ASSERT(1 == grpc_http2_decode_timeout( grpc_slice_from_static_string(buffer), &got)); if (got != expected) { - gpr_log(GPR_ERROR, "got:'%"PRIdPTR"' != expected:'%"PRIdPTR"'", got, expected); + gpr_log(GPR_ERROR, "got:'%" PRIdPTR "' != expected:'%" PRIdPTR "'", got, + expected); abort(); } } @@ -100,8 +101,12 @@ void decode_suite(char ext, grpc_millis (*answer)(int64_t x)) { } } -static grpc_millis millis_from_nanos(int64_t x) { return x / GPR_NS_PER_MS + (x % GPR_NS_PER_MS != 0); } -static grpc_millis millis_from_micros(int64_t x) { return x / GPR_US_PER_MS + (x % GPR_US_PER_MS != 0); } +static grpc_millis millis_from_nanos(int64_t x) { + return x / GPR_NS_PER_MS + (x % GPR_NS_PER_MS != 0); +} +static grpc_millis millis_from_micros(int64_t x) { + return x / GPR_US_PER_MS + (x % GPR_US_PER_MS != 0); +} static grpc_millis millis_from_millis(int64_t x) { return x; } static grpc_millis millis_from_seconds(int64_t x) { return x * GPR_MS_PER_SEC; } static grpc_millis millis_from_minutes(int64_t x) { diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index 47dee5cb3af..34575e0fe5f 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -199,10 +199,10 @@ void PollPollsetUntilRequestDone(ArgsStruct *args) { grpc_pollset_worker *worker = NULL; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_mu_lock(args->mu); - GRPC_LOG_IF_ERROR( - "pollset_work", - grpc_pollset_work(&exec_ctx, args->pollset, &worker, - grpc_timespec_to_millis_round_up(NSecondDeadline(1)))); + GRPC_LOG_IF_ERROR("pollset_work", + grpc_pollset_work(&exec_ctx, args->pollset, &worker, + grpc_timespec_to_millis_round_up( + NSecondDeadline(1)))); gpr_mu_unlock(args->mu); grpc_exec_ctx_finish(&exec_ctx); } From 2c48148ebdcdfb62bc24c387f29d986606dc1bcd Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 19 Sep 2017 14:07:19 -0700 Subject: [PATCH 042/142] Make sure initial settings are as we would pick next iteration --- .../chttp2/transport/chttp2_transport.c | 17 ++----- .../transport/chttp2/transport/flow_control.c | 47 ++++++++++++------- .../ext/transport/chttp2/transport/internal.h | 3 ++ 3 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index b424bd2da5b..e1c2265be41 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -274,6 +274,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, t->is_client = is_client; t->flow_control.remote_window = DEFAULT_WINDOW; t->flow_control.announced_window = DEFAULT_WINDOW; + t->flow_control.target_initial_window_size = DEFAULT_WINDOW; t->flow_control.t = t; t->deframe_state = is_client ? GRPC_DTS_FH_0 : GRPC_DTS_CLIENT_PREFIX_0; t->is_first_frame = true; @@ -312,16 +313,6 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_combiner_scheduler(t->combiner)); grpc_bdp_estimator_init(&t->flow_control.bdp_estimator, t->peer_string); - t->flow_control.last_pid_update = gpr_now(GPR_CLOCK_MONOTONIC); - grpc_pid_controller_init( - &t->flow_control.pid_controller, - (grpc_pid_controller_args){.gain_p = 4, - .gain_i = 8, - .gain_d = 0, - .initial_control_value = log2(DEFAULT_WINDOW), - .min_control_value = -1, - .max_control_value = 25, - .integral_range = 10}); grpc_chttp2_goaway_parser_init(&t->goaway_parser); grpc_chttp2_hpack_parser_init(exec_ctx, &t->hpack_parser); @@ -360,8 +351,6 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, queue_setting_update(exec_ctx, t, GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, 0); } - queue_setting_update(exec_ctx, t, GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE, - DEFAULT_WINDOW); queue_setting_update(exec_ctx, t, GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE, DEFAULT_MAX_HEADER_LIST_SIZE); queue_setting_update(exec_ctx, t, @@ -591,6 +580,10 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED; } + grpc_chttp2_act_on_flowctl_action( + exec_ctx, grpc_chttp2_flowctl_get_action(&t->flow_control, NULL), t, + NULL); + grpc_chttp2_initiate_write(exec_ctx, t, GRPC_CHTTP2_INITIATE_WRITE_INITIAL_WRITE); post_benign_reclaimer(exec_ctx, t); diff --git a/src/core/ext/transport/chttp2/transport/flow_control.c b/src/core/ext/transport/chttp2/transport/flow_control.c index e3be2e51980..aa1dd2d3cbe 100644 --- a/src/core/ext/transport/chttp2/transport/flow_control.c +++ b/src/core/ext/transport/chttp2/transport/flow_control.c @@ -175,11 +175,9 @@ static void trace_action(grpc_chttp2_transport_flowctl* tfc, /* How many bytes of incoming flow control would we like to advertise */ static uint32_t grpc_chttp2_target_announced_window( const grpc_chttp2_transport_flowctl* tfc) { - return (uint32_t)GPR_MIN( - (int64_t)((1u << 31) - 1), - tfc->announced_stream_total_over_incoming_window + - tfc->t->settings[GRPC_SENT_SETTINGS] - [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]); + return (uint32_t)GPR_MIN((int64_t)((1u << 31) - 1), + tfc->announced_stream_total_over_incoming_window + + tfc->target_initial_window_size); } // we have sent data on the wire, we must track this in our bookkeeping for the @@ -395,8 +393,22 @@ static grpc_chttp2_flowctl_urgency delta_is_significant( // guess at the new bdp. static double get_pid_controller_guess(grpc_chttp2_transport_flowctl* tfc, double target) { - double bdp_error = target - grpc_pid_controller_last(&tfc->pid_controller); gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); + if (!tfc->pid_controller_initialized) { + tfc->last_pid_update = now; + tfc->pid_controller_initialized = true; + grpc_pid_controller_init( + &tfc->pid_controller, + (grpc_pid_controller_args){.gain_p = 4, + .gain_i = 8, + .gain_d = 0, + .initial_control_value = target, + .min_control_value = -1, + .max_control_value = 25, + .integral_range = 10}); + return pow(2, target); + } + double bdp_error = target - grpc_pid_controller_last(&tfc->pid_controller); gpr_timespec dt_timespec = gpr_time_sub(now, tfc->last_pid_update); double dt = (double)dt_timespec.tv_sec + dt_timespec.tv_nsec * 1e-9; if (dt > 0.1) { @@ -415,7 +427,7 @@ static double get_target_under_memory_pressure( double memory_pressure = grpc_resource_quota_get_memory_pressure( grpc_resource_user_quota(grpc_endpoint_get_resource_user(tfc->t->ep))); static const double kLowMemPressure = 0.1; - static const double kZeroTarget = 24; + static const double kZeroTarget = 22; static const double kHighMemPressure = 0.8; static const double kMaxMemPressure = 0.9; if (memory_pressure < kLowMemPressure && target < kZeroTarget) { @@ -432,10 +444,6 @@ grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_action( grpc_chttp2_transport_flowctl* tfc, grpc_chttp2_stream_flowctl* sfc) { grpc_chttp2_flowctl_action action; memset(&action, 0, sizeof(action)); - uint32_t target_announced_window = grpc_chttp2_target_announced_window(tfc); - if (tfc->announced_window < target_announced_window / 2) { - action.send_transport_update = GRPC_CHTTP2_FLOWCTL_UPDATE_IMMEDIATELY; - } // TODO(ncteisen): tune this if (sfc != NULL && !sfc->s->read_closed) { uint32_t sent_init_window = @@ -455,7 +463,6 @@ grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_action( // get bdp estimate and update initial_window accordingly. int64_t estimate = -1; - int32_t bdp = -1; if (grpc_bdp_estimator_get_estimate(&tfc->bdp_estimator, &estimate)) { double target = 1 + log2((double)estimate); @@ -469,14 +476,15 @@ grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_action( double bdp_guess = get_pid_controller_guess(tfc, target); // Though initial window 'could' drop to 0, we keep the floor at 128 - bdp = GPR_MAX((int32_t)bdp_guess, 128); + tfc->target_initial_window_size = + (int32_t)GPR_CLAMP(bdp_guess, 128, INT32_MAX); grpc_chttp2_flowctl_urgency init_window_update_urgency = - delta_is_significant(tfc, bdp, + delta_is_significant(tfc, tfc->target_initial_window_size, GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE); if (init_window_update_urgency != GRPC_CHTTP2_FLOWCTL_NO_ACTION_NEEDED) { action.send_setting_update = init_window_update_urgency; - action.initial_window_size = (uint32_t)bdp; + action.initial_window_size = (uint32_t)tfc->target_initial_window_size; } } @@ -485,8 +493,9 @@ grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_action( if (grpc_bdp_estimator_get_bw(&tfc->bdp_estimator, &bw_dbl)) { // we target the max of BDP or bandwidth in microseconds. int32_t frame_size = (int32_t)GPR_CLAMP( - GPR_MAX((int32_t)GPR_CLAMP(bw_dbl, 0, INT_MAX) / 1000, bdp), 16384, - 16777215); + GPR_MAX((int32_t)GPR_CLAMP(bw_dbl, 0, INT_MAX) / 1000, + tfc->target_initial_window_size), + 16384, 16777215); grpc_chttp2_flowctl_urgency frame_size_urgency = delta_is_significant( tfc, frame_size, GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE); if (frame_size_urgency != GRPC_CHTTP2_FLOWCTL_NO_ACTION_NEEDED) { @@ -497,6 +506,10 @@ grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_action( } } } + uint32_t target_announced_window = grpc_chttp2_target_announced_window(tfc); + if (tfc->announced_window < target_announced_window / 2) { + action.send_transport_update = GRPC_CHTTP2_FLOWCTL_UPDATE_IMMEDIATELY; + } TRACEACTION(tfc, action); return action; } diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 1506d613114..4b66f7d6ea2 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -258,6 +258,8 @@ typedef struct { * to send WINDOW_UPDATE frames. */ int64_t announced_window; + int32_t target_initial_window_size; + /** should we probe bdp? */ bool enable_bdp_probe; @@ -265,6 +267,7 @@ typedef struct { grpc_bdp_estimator bdp_estimator; /* pid controller */ + bool pid_controller_initialized; grpc_pid_controller pid_controller; gpr_timespec last_pid_update; From 18c77ccfdbb0adc3377557b7de4b1898f3eec3eb Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 19 Sep 2017 15:22:04 -0700 Subject: [PATCH 043/142] Fix pings --- include/grpc/impl/codegen/atm_gcc_atomic.h | 1 + include/grpc/impl/codegen/atm_gcc_sync.h | 1 + include/grpc/impl/codegen/atm_windows.h | 1 + .../chttp2/transport/chttp2_transport.c | 22 ++++++++----------- .../transport/chttp2/transport/frame_ping.c | 5 +++-- .../ext/transport/chttp2/transport/parsing.c | 4 ++-- .../ext/transport/chttp2/transport/writing.c | 11 ++++------ src/core/lib/iomgr/exec_ctx.h | 1 + 8 files changed, 22 insertions(+), 24 deletions(-) diff --git a/include/grpc/impl/codegen/atm_gcc_atomic.h b/include/grpc/impl/codegen/atm_gcc_atomic.h index 1793ec22b88..76ce8639141 100644 --- a/include/grpc/impl/codegen/atm_gcc_atomic.h +++ b/include/grpc/impl/codegen/atm_gcc_atomic.h @@ -25,6 +25,7 @@ typedef intptr_t gpr_atm; #define GPR_ATM_MAX INTPTR_MAX +#define GPR_ATM_MIN INTPTR_MIN #ifdef GPR_LOW_LEVEL_COUNTERS extern gpr_atm gpr_counter_atm_cas; diff --git a/include/grpc/impl/codegen/atm_gcc_sync.h b/include/grpc/impl/codegen/atm_gcc_sync.h index 27ae0f63d52..a9e4da3a0fe 100644 --- a/include/grpc/impl/codegen/atm_gcc_sync.h +++ b/include/grpc/impl/codegen/atm_gcc_sync.h @@ -25,6 +25,7 @@ typedef intptr_t gpr_atm; #define GPR_ATM_MAX INTPTR_MAX +#define GPR_ATM_MIN INTPTR_MIN #define GPR_ATM_COMPILE_BARRIER_() __asm__ __volatile__("" : : : "memory") diff --git a/include/grpc/impl/codegen/atm_windows.h b/include/grpc/impl/codegen/atm_windows.h index dfcaa4cc377..b868d79aef7 100644 --- a/include/grpc/impl/codegen/atm_windows.h +++ b/include/grpc/impl/codegen/atm_windows.h @@ -24,6 +24,7 @@ typedef intptr_t gpr_atm; #define GPR_ATM_MAX INTPTR_MAX +#define GPR_ATM_MIN INTPTR_MIN #define gpr_atm_full_barrier MemoryBarrier diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 640ad6351c0..1483dad432b 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -1766,19 +1766,15 @@ static void send_goaway(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, void grpc_chttp2_add_ping_strike(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t) { t->ping_recv_state.ping_strikes++; - if (t->ping_policy.max_ping_strikes != 0) { - gpr_log(GPR_DEBUG, "%s: PING strike %d/%d", t->peer_string, - t->ping_recv_state.ping_strikes, t->ping_policy.max_ping_strikes); - if (t->ping_recv_state.ping_strikes > t->ping_policy.max_ping_strikes) { - send_goaway( - exec_ctx, t, - grpc_error_set_int( - GRPC_ERROR_CREATE_FROM_STATIC_STRING("too_many_pings"), - GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM)); - /*The transport will be closed after the write is done */ - close_transport_locked( - exec_ctx, t, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many pings")); - } + if (++t->ping_recv_state.ping_strikes > t->ping_policy.max_ping_strikes && + t->ping_policy.max_ping_strikes != 0) { + send_goaway(exec_ctx, t, + grpc_error_set_int( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("too_many_pings"), + GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM)); + /*The transport will be closed after the write is done */ + close_transport_locked( + exec_ctx, t, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many pings")); } } diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.c b/src/core/ext/transport/chttp2/transport/frame_ping.c index 195a2a672f4..1cfa883ee15 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.c +++ b/src/core/ext/transport/chttp2/transport/frame_ping.c @@ -89,6 +89,7 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_ack_ping(exec_ctx, t, p->opaque_8bytes); } else { if (!t->is_client) { + grpc_millis now = grpc_exec_ctx_now(exec_ctx); grpc_millis next_allowed_ping = t->ping_recv_state.last_ping_recv_time + t->ping_policy.min_recv_ping_interval_without_data; @@ -102,11 +103,11 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, t->ping_recv_state.last_ping_recv_time + 7200 * GPR_MS_PER_SEC; } - if (next_allowed_ping > grpc_exec_ctx_now(exec_ctx)) { + if (next_allowed_ping > now) { grpc_chttp2_add_ping_strike(exec_ctx, t); } - t->ping_recv_state.last_ping_recv_time = grpc_exec_ctx_now(exec_ctx); + t->ping_recv_state.last_ping_recv_time = now; } if (!g_disable_ping_ack) { if (t->ping_ack_count == t->ping_ack_capacity) { diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index 1dde192ec96..b2b6da7992d 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -385,7 +385,7 @@ error_handler: t->parser_data = &s->data_parser; t->ping_state.pings_before_data_required = t->ping_policy.max_pings_without_data; - t->ping_state.last_ping_sent_time = 0; + t->ping_state.last_ping_sent_time = GRPC_MILLIS_INF_PAST; return GRPC_ERROR_NONE; } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, NULL)) { /* handle stream errors by closing the stream */ @@ -562,7 +562,7 @@ static grpc_error *init_header_frame_parser(grpc_exec_ctx *exec_ctx, t->ping_state.pings_before_data_required = t->ping_policy.max_pings_without_data; - t->ping_state.last_ping_sent_time = 0; + t->ping_state.last_ping_sent_time = GRPC_MILLIS_INF_PAST; /* could be a new grpc_chttp2_stream or an existing grpc_chttp2_stream */ s = grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id); diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index ea930b60e7e..6e5f3d6bc62 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -86,15 +86,12 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, next_allowed_ping = t->ping_recv_state.last_ping_recv_time + 7200 * GPR_MS_PER_SEC; } - /* gpr_log(GPR_DEBUG, "next_allowed_ping:%d.%09d now:%d.%09d", - (int)next_allowed_ping.tv_sec, (int)next_allowed_ping.tv_nsec, - (int)now.tv_sec, (int)now.tv_nsec); */ if (next_allowed_ping > now) { /* not enough elapsed time between successive pings */ if (GRPC_TRACER_ON(grpc_http_trace) || GRPC_TRACER_ON(grpc_bdp_estimator_trace)) { gpr_log(GPR_DEBUG, - "Ping delayed [%p]: not enough time elapsed since last ping", + "Ping delayed [%s]: not enough time elapsed since last ping", t->peer_string); } if (!t->ping_state.is_delayed_ping_timer_set) { @@ -269,7 +266,7 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( s->send_initial_metadata, &hopt, &t->outbuf); now_writing = true; if (!t->is_client) { - t->ping_recv_state.last_ping_recv_time = 0; + t->ping_recv_state.last_ping_recv_time = GRPC_MILLIS_INF_PAST; t->ping_recv_state.ping_strikes = 0; } initial_metadata_writes++; @@ -307,7 +304,7 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( &t->outbuf, grpc_chttp2_window_update_create(s->id, stream_announce, &s->stats.outgoing)); if (!t->is_client) { - t->ping_recv_state.last_ping_recv_time = 0; + t->ping_recv_state.last_ping_recv_time = GRPC_MILLIS_INF_PAST; t->ping_recv_state.ping_strikes = 0; } flow_control_writes++; @@ -491,7 +488,7 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( &t->outbuf, grpc_chttp2_window_update_create(0, transport_announce, &throwaway_stats)); if (!t->is_client) { - t->ping_recv_state.last_ping_recv_time = 0; + t->ping_recv_state.last_ping_recv_time = GRPC_MILLIS_INF_PAST; t->ping_recv_state.ping_strikes = 0; } } diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h index 6220e41a4fb..3caf7750138 100644 --- a/src/core/lib/iomgr/exec_ctx.h +++ b/src/core/lib/iomgr/exec_ctx.h @@ -27,6 +27,7 @@ typedef gpr_atm grpc_millis; #define GRPC_MILLIS_INF_FUTURE GPR_ATM_MAX +#define GRPC_MILLIS_INF_PAST GPR_ATM_MIN /** A workqueue represents a list of work to be executed asynchronously. Forward declared here to avoid a circular dependency with workqueue.h. */ From 34da2eeb42bf27ea4b292869822a721e273a1468 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 19 Sep 2017 15:52:39 -0700 Subject: [PATCH 044/142] Fix pings --- src/core/ext/transport/chttp2/transport/chttp2_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 1483dad432b..30d225a6984 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -561,7 +561,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, t->ping_state.pings_before_data_required = 0; t->ping_state.is_delayed_ping_timer_set = false; - t->ping_recv_state.last_ping_recv_time = 0; + t->ping_recv_state.last_ping_recv_time = GRPC_MILLIS_INF_PAST; t->ping_recv_state.ping_strikes = 0; /* Start keepalive pings */ From 183f2a6aaa9b4572c5cf2bb2ef76394dcd3f4f82 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 19 Sep 2017 20:34:07 -0700 Subject: [PATCH 045/142] clang-fmt --- src/core/ext/transport/chttp2/transport/chttp2_transport.c | 3 ++- src/core/lib/iomgr/ev_epollex_linux.c | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index dcdacc60c06..df386f83f08 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -370,7 +370,8 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA, 1); t->ping_policy.max_pings_without_data = g_default_max_pings_without_data; - t->ping_policy.min_sent_ping_interval_without_data = g_default_min_sent_ping_interval_without_data_ms; + t->ping_policy.min_sent_ping_interval_without_data = + g_default_min_sent_ping_interval_without_data_ms; t->ping_policy.max_ping_strikes = g_default_max_ping_strikes; t->ping_policy.min_recv_ping_interval_without_data = g_default_min_recv_ping_interval_without_data_ms; diff --git a/src/core/lib/iomgr/ev_epollex_linux.c b/src/core/lib/iomgr/ev_epollex_linux.c index f744ac5ca4b..8aaad8808a2 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.c +++ b/src/core/lib/iomgr/ev_epollex_linux.c @@ -699,7 +699,6 @@ static int poll_deadline_to_millis_timeout(grpc_exec_ctx *exec_ctx, return 0; else return (int)delta; - } } static void fd_become_readable(grpc_exec_ctx *exec_ctx, grpc_fd *fd, From 49a096443754bafe745a2e167a41c46fab41f206 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 20 Sep 2017 03:46:27 +0000 Subject: [PATCH 046/142] Fix executor time invalidation --- src/core/lib/iomgr/executor.c | 1 + src/core/lib/iomgr/tcp_client_posix.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/executor.c b/src/core/lib/iomgr/executor.c index 2439f15a8a9..cb4f506aedc 100644 --- a/src/core/lib/iomgr/executor.c +++ b/src/core/lib/iomgr/executor.c @@ -184,6 +184,7 @@ static void executor_thread(void *arg) { gpr_log(GPR_DEBUG, "EXECUTOR[%d]: execute", (int)(ts - g_thread_state)); } + grpc_exec_ctx_invalidate_now(&exec_ctx); run_closures(&exec_ctx, &ts->local_elems); } grpc_exec_ctx_finish(&exec_ctx); diff --git a/src/core/lib/iomgr/tcp_client_posix.c b/src/core/lib/iomgr/tcp_client_posix.c index bb348bdf724..64834d88f50 100644 --- a/src/core/lib/iomgr/tcp_client_posix.c +++ b/src/core/lib/iomgr/tcp_client_posix.c @@ -48,7 +48,6 @@ extern grpc_tracer_flag grpc_tcp_trace; typedef struct { gpr_mu mu; grpc_fd *fd; - gpr_timespec deadline; grpc_timer alarm; grpc_closure on_alarm; int refs; From 4d264c041ab35a97baf1c7251f6b149fde3b2c95 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 20 Sep 2017 11:05:07 -0700 Subject: [PATCH 047/142] Add a script to filter chttp2 refcount logs --- tools/debug/core/chttp2_ref_leak.py | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 tools/debug/core/chttp2_ref_leak.py diff --git a/tools/debug/core/chttp2_ref_leak.py b/tools/debug/core/chttp2_ref_leak.py new file mode 100755 index 00000000000..d693dd9e540 --- /dev/null +++ b/tools/debug/core/chttp2_ref_leak.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python2.7 +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Reads stdin to find chttp2_refcount log lines, and prints reference leaks +# to stdout + +import collections +import sys +import re + +def new_obj(): + return ['destroy'] + +outstanding = collections.defaultdict(new_obj) + +# Sample log line: +# chttp2:unref:0x629000005200 2->1 destroy [src/core/ext/transport/chttp2/transport/chttp2_transport.c:599] + +for line in sys.stdin: + m = re.search(r'chttp2:( ref|unref):0x([a-fA-F0-9]+) [^ ]+ ([^[]+) \[(.*)\]', line) + if m: + if m.group(1) == ' ref': + outstanding[m.group(2)].append(m.group(3)) + else: + outstanding[m.group(2)].remove(m.group(3)) + +for obj, remaining in outstanding.items(): + if remaining: + print 'LEAKED: %s %r' % (obj, remaining) + From f6343040bfa590881716e9820ab4779e931cd82f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 20 Sep 2017 11:11:58 -0700 Subject: [PATCH 048/142] Fix memory leak --- src/core/lib/surface/call.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c index 03f47553a14..1390f638960 100644 --- a/src/core/lib/surface/call.c +++ b/src/core/lib/surface/call.c @@ -1342,6 +1342,11 @@ static void post_batch_completion(grpc_exec_ctx *exec_ctx, GRPC_ERROR_UNREF(error); error = GRPC_ERROR_NONE; } + if (error != GRPC_ERROR_NONE && bctl->op.recv_message && + *call->receiving_buffer != NULL) { + grpc_byte_buffer_destroy(*call->receiving_buffer); + *call->receiving_buffer = NULL; + } if (bctl->completion_data.notify_tag.is_closure) { /* unrefs bctl->error */ From e46f2d2c8fea5aa61c72f1fe1696aac9fdef9efe Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 20 Sep 2017 14:24:19 -0700 Subject: [PATCH 049/142] Fix memory leak --- src/core/lib/iomgr/resource_quota.c | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/core/lib/iomgr/resource_quota.c b/src/core/lib/iomgr/resource_quota.c index 4895e0d1c92..2be2cad0ad2 100644 --- a/src/core/lib/iomgr/resource_quota.c +++ b/src/core/lib/iomgr/resource_quota.c @@ -87,6 +87,8 @@ struct grpc_resource_user { grpc_closure_list on_allocated; /* True if we are currently trying to allocate from the quota, false if not */ bool allocating; + /* How many bytes of allocations are outstanding */ + int64_t outstanding_allocations; /* True if we are currently trying to add ourselves to the non-free quota list, false otherwise */ bool added_to_free_pool; @@ -151,6 +153,9 @@ struct grpc_resource_quota { char *name; }; +static void ru_unref_by(grpc_exec_ctx *exec_ctx, + grpc_resource_user *resource_user, gpr_atm amount); + /******************************************************************************* * list management */ @@ -287,6 +292,25 @@ static bool rq_alloc(grpc_exec_ctx *exec_ctx, while ((resource_user = rulist_pop_head(resource_quota, GRPC_RULIST_AWAITING_ALLOCATION))) { gpr_mu_lock(&resource_user->mu); + if (GRPC_TRACER_ON(grpc_resource_quota_trace)) { + gpr_log(GPR_DEBUG, "RQ: check allocation for user %p shutdown=%" PRIdPTR + " free_pool=%" PRId64, + resource_user, gpr_atm_no_barrier_load(&resource_user->shutdown), + resource_user->free_pool); + } + if (gpr_atm_no_barrier_load(&resource_user->shutdown)) { + resource_user->allocating = false; + grpc_closure_list_fail_all( + &resource_user->on_allocated, + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resource user shutdown")); + int64_t aborted_allocations = resource_user->outstanding_allocations; + resource_user->outstanding_allocations = 0; + resource_user->free_pool += aborted_allocations; + GRPC_CLOSURE_LIST_SCHED(exec_ctx, &resource_user->on_allocated); + gpr_mu_unlock(&resource_user->mu); + ru_unref_by(exec_ctx, resource_user, aborted_allocations); + continue; + } if (resource_user->free_pool < 0 && -resource_user->free_pool <= resource_quota->free_pool) { int64_t amt = -resource_user->free_pool; @@ -306,6 +330,7 @@ static bool rq_alloc(grpc_exec_ctx *exec_ctx, } if (resource_user->free_pool >= 0) { resource_user->allocating = false; + resource_user->outstanding_allocations = 0; GRPC_CLOSURE_LIST_SCHED(exec_ctx, &resource_user->on_allocated); gpr_mu_unlock(&resource_user->mu); } else { @@ -486,6 +511,9 @@ static void ru_post_destructive_reclaimer(grpc_exec_ctx *exec_ctx, void *ru, } static void ru_shutdown(grpc_exec_ctx *exec_ctx, void *ru, grpc_error *error) { + if (GRPC_TRACER_ON(grpc_resource_quota_trace)) { + gpr_log(GPR_DEBUG, "RU shutdown %p", ru); + } grpc_resource_user *resource_user = (grpc_resource_user *)ru; GRPC_CLOSURE_SCHED(exec_ctx, resource_user->reclaimers[0], GRPC_ERROR_CANCELLED); @@ -716,6 +744,7 @@ grpc_resource_user *grpc_resource_user_create( resource_user->reclaimers[1] = NULL; resource_user->new_reclaimers[0] = NULL; resource_user->new_reclaimers[1] = NULL; + resource_user->outstanding_allocations = 0; for (int i = 0; i < GRPC_RULIST_COUNT; i++) { resource_user->links[i].next = resource_user->links[i].prev = NULL; } @@ -776,6 +805,7 @@ void grpc_resource_user_alloc(grpc_exec_ctx *exec_ctx, gpr_mu_lock(&resource_user->mu); ru_ref_by(resource_user, (gpr_atm)size); resource_user->free_pool -= (int64_t)size; + resource_user->outstanding_allocations += (int64_t)size; if (GRPC_TRACER_ON(grpc_resource_quota_trace)) { gpr_log(GPR_DEBUG, "RQ %s %s: alloc %" PRIdPTR "; free_pool -> %" PRId64, resource_user->resource_quota->name, resource_user->name, size, @@ -790,6 +820,7 @@ void grpc_resource_user_alloc(grpc_exec_ctx *exec_ctx, GRPC_ERROR_NONE); } } else { + resource_user->outstanding_allocations -= (int64_t)size; GRPC_CLOSURE_SCHED(exec_ctx, optional_on_done, GRPC_ERROR_NONE); } gpr_mu_unlock(&resource_user->mu); From bf21f0b02500e68e4feed2fd2ed1ab0f91f80068 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 20 Sep 2017 14:45:16 -0700 Subject: [PATCH 050/142] Fix ubsan failure --- src/core/ext/transport/chttp2/transport/parsing.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index b2b6da7992d..2086f42cb20 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -446,8 +446,10 @@ static void on_initial_header(grpc_exec_ctx *exec_ctx, void *tp, } else { timeout = *cached_timeout; } - grpc_chttp2_incoming_metadata_buffer_set_deadline( - &s->metadata_buffer[0], grpc_exec_ctx_now(exec_ctx) + timeout); + if (timeout != GRPC_MILLIS_INF_FUTURE) { + grpc_chttp2_incoming_metadata_buffer_set_deadline( + &s->metadata_buffer[0], grpc_exec_ctx_now(exec_ctx) + timeout); + } GRPC_MDELEM_UNREF(exec_ctx, md); } else { const size_t new_size = s->metadata_buffer[0].size + GRPC_MDELEM_LENGTH(md); From b6034896292085ac942887c0bce106278a4797a8 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 20 Sep 2017 16:01:19 -0700 Subject: [PATCH 051/142] Use monotonic times (as we used to) --- src/core/lib/surface/server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/surface/server.c b/src/core/lib/surface/server.c index 1d3980eb230..dd09cb91de4 100644 --- a/src/core/lib/surface/server.c +++ b/src/core/lib/surface/server.c @@ -493,12 +493,12 @@ static void publish_call(grpc_exec_ctx *exec_ctx, grpc_server *server, rc->data.batch.details->host = grpc_slice_ref_internal(calld->host); rc->data.batch.details->method = grpc_slice_ref_internal(calld->path); rc->data.batch.details->deadline = - grpc_millis_to_timespec(calld->deadline, GPR_CLOCK_REALTIME); + grpc_millis_to_timespec(calld->deadline, GPR_CLOCK_MONOTONIC); rc->data.batch.details->flags = calld->recv_initial_metadata_flags; break; case REGISTERED_CALL: *rc->data.registered.deadline = - grpc_millis_to_timespec(calld->deadline, GPR_CLOCK_REALTIME); + grpc_millis_to_timespec(calld->deadline, GPR_CLOCK_MONOTONIC); if (rc->data.registered.optional_payload) { *rc->data.registered.optional_payload = calld->payload; calld->payload = NULL; From a42a22b2bec661c5c46c8f884a98f7c004cd5b3a Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 20 Sep 2017 16:08:25 -0700 Subject: [PATCH 052/142] Update window overflow test --- test/core/bad_client/bad_client.c | 15 ++++++++++----- test/core/bad_client/tests/window_overflow.c | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/test/core/bad_client/bad_client.c b/test/core/bad_client/bad_client.c index 383d1240cb0..888a7c85a91 100644 --- a/test/core/bad_client/bad_client.c +++ b/test/core/bad_client/bad_client.c @@ -84,13 +84,18 @@ void grpc_run_bad_client_test( grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_completion_queue *shutdown_cq; - hex = gpr_dump(client_payload, client_payload_length, - GPR_DUMP_HEX | GPR_DUMP_ASCII); + if (client_payload_length < 4 * 1024) { + hex = gpr_dump(client_payload, client_payload_length, + GPR_DUMP_HEX | GPR_DUMP_ASCII); - /* Add a debug log */ - gpr_log(GPR_INFO, "TEST: %s", hex); + /* Add a debug log */ + gpr_log(GPR_INFO, "TEST: %s", hex); - gpr_free(hex); + gpr_free(hex); + } else { + gpr_log(GPR_INFO, "TEST: (%" PRIdPTR " byte long string)", + client_payload_length); + } /* Init grpc */ grpc_init(); diff --git a/test/core/bad_client/tests/window_overflow.c b/test/core/bad_client/tests/window_overflow.c index 1f29bd32fbd..9ced956957d 100644 --- a/test/core/bad_client/tests/window_overflow.c +++ b/test/core/bad_client/tests/window_overflow.c @@ -69,7 +69,7 @@ int main(int argc, char **argv) { #define MAX_FRAME_SIZE 16384 #define MESSAGES_PER_FRAME (MAX_FRAME_SIZE / 5) #define FRAME_SIZE (MESSAGES_PER_FRAME * 5) -#define SEND_SIZE (100 * 1024) +#define SEND_SIZE (6 * 1024 * 1024) #define NUM_FRAMES (SEND_SIZE / FRAME_SIZE + 1) grpc_test_init(argc, argv); From c1f288dedbe8eeb9591b78e305a277ddeb1f9f39 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 20 Sep 2017 21:59:21 -0700 Subject: [PATCH 053/142] Bug fixes, remove async e2e dependence on flow control size --- src/core/lib/iomgr/resource_quota.c | 2 +- test/core/transport/bdp_estimator_test.c | 2 + test/cpp/end2end/async_end2end_test.cc | 150 +++++++++++------------ 3 files changed, 76 insertions(+), 78 deletions(-) diff --git a/src/core/lib/iomgr/resource_quota.c b/src/core/lib/iomgr/resource_quota.c index 2be2cad0ad2..e0a9829cd73 100644 --- a/src/core/lib/iomgr/resource_quota.c +++ b/src/core/lib/iomgr/resource_quota.c @@ -308,7 +308,7 @@ static bool rq_alloc(grpc_exec_ctx *exec_ctx, resource_user->free_pool += aborted_allocations; GRPC_CLOSURE_LIST_SCHED(exec_ctx, &resource_user->on_allocated); gpr_mu_unlock(&resource_user->mu); - ru_unref_by(exec_ctx, resource_user, aborted_allocations); + ru_unref_by(exec_ctx, resource_user, (gpr_atm)aborted_allocations); continue; } if (resource_user->free_pool < 0 && diff --git a/test/core/transport/bdp_estimator_test.c b/test/core/transport/bdp_estimator_test.c index a256eb3a4a8..c672b535181 100644 --- a/test/core/transport/bdp_estimator_test.c +++ b/test/core/transport/bdp_estimator_test.c @@ -24,6 +24,7 @@ #include #include #include +#include "src/core/lib/iomgr/timer_manager.h" #include "src/core/lib/support/string.h" #include "test/core/util/test_config.h" @@ -145,6 +146,7 @@ int main(int argc, char **argv) { grpc_test_init(argc, argv); gpr_now_impl = fake_gpr_now; grpc_init(); + grpc_timer_manager_set_threading(false); test_noop(); test_get_estimate_no_samples(); test_get_estimate_1_sample(); diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 41090d161aa..e2531ef95af 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -105,6 +105,13 @@ class Verifier { expectations_[tag(i)] = expect_ok; return *this; } + // AcceptOnce sets the expected ok value for a specific tag, but does not + // require it to appear + // If it does, sets *seen to true + Verifier& AcceptOnce(int i, bool expect_ok, bool* seen) { + maybe_expectations_[tag(i)] = MaybeExpect{expect_ok, seen}; + return *this; + } // Next waits for 1 async tag to complete, checks its // expectations, and returns the tag @@ -122,12 +129,7 @@ class Verifier { } else { EXPECT_TRUE(cq->Next(&got_tag, &ok)); } - auto it = expectations_.find(got_tag); - EXPECT_TRUE(it != expectations_.end()); - if (!ignore_ok) { - EXPECT_EQ(it->second, ok); - } - expectations_.erase(it); + GotTag(got_tag, ok, ignore_ok); return detag(got_tag); } @@ -138,7 +140,7 @@ class Verifier { // This version of Verify allows optionally ignoring the // outcome of the expectation void Verify(CompletionQueue* cq, bool ignore_ok) { - GPR_ASSERT(!expectations_.empty()); + GPR_ASSERT(!expectations_.empty() || !maybe_expectations_.empty()); while (!expectations_.empty()) { Next(cq, ignore_ok); } @@ -177,16 +179,43 @@ class Verifier { EXPECT_EQ(cq->AsyncNext(&got_tag, &ok, deadline), CompletionQueue::GOT_EVENT); } - auto it = expectations_.find(got_tag); - EXPECT_TRUE(it != expectations_.end()); - EXPECT_EQ(it->second, ok); - expectations_.erase(it); + GotTag(got_tag, ok, false); } } } private: + void GotTag(void* got_tag, bool ok, bool ignore_ok) { + auto it = expectations_.find(got_tag); + if (it != expectations_.end()) { + if (!ignore_ok) { + EXPECT_EQ(it->second, ok); + } + expectations_.erase(it); + } else { + auto it2 = maybe_expectations_.find(got_tag); + if (it2 != maybe_expectations_.end()) { + if (it2->second.seen != nullptr) { + EXPECT_FALSE(*it2->second.seen); + *it2->second.seen = true; + } + if (!ignore_ok) { + EXPECT_EQ(it2->second.ok, ok); + } + } else { + gpr_log(GPR_ERROR, "Unexpected tag: %p", tag); + abort(); + } + } + } + + struct MaybeExpect { + bool ok; + bool* seen; + }; + std::map expectations_; + std::map maybe_expectations_; bool spin_; }; @@ -539,31 +568,19 @@ TEST_P(AsyncEnd2endTest, SimpleClientStreamingWithCoalescingApi) { cli_stream->Write(send_request, tag(3)); - // 65536(64KB) is the default flow control window size. Should change this - // number when default flow control window size changes. For the write of - // send_request larger than the flow control window size, tag:3 will not come - // up until server read is initiated. For write of send_request smaller than - // the flow control window size, the request can take the free ride with - // initial metadata due to coalescing, thus write tag:3 will come up here. - if (GetParam().message_content.length() < 65536 || GetParam().inproc) { - Verifier(GetParam().disable_blocking) - .Expect(2, true) - .Expect(3, true) - .Verify(cq_.get()); - } else { - Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get()); - } + bool seen3 = false; + + Verifier(GetParam().disable_blocking) + .Expect(2, true) + .AcceptOnce(3, true, &seen3) + .Verify(cq_.get()); srv_stream.Read(&recv_request, tag(4)); - if (GetParam().message_content.length() < 65536 || GetParam().inproc) { - Verifier(GetParam().disable_blocking).Expect(4, true).Verify(cq_.get()); - } else { - Verifier(GetParam().disable_blocking) - .Expect(3, true) - .Expect(4, true) - .Verify(cq_.get()); - } + Verifier(GetParam().disable_blocking) + .AcceptOnce(3, true, &seen3) + .Expect(4, true) + .Verify(cq_.get()); EXPECT_EQ(send_request.message(), recv_request.message()); @@ -588,6 +605,7 @@ TEST_P(AsyncEnd2endTest, SimpleClientStreamingWithCoalescingApi) { EXPECT_EQ(send_response.message(), recv_response.message()); EXPECT_TRUE(recv_status.ok()); + EXPECT_TRUE(seen3); } // One ping, two pongs. @@ -834,31 +852,19 @@ TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWAF) { cli_stream->WriteLast(send_request, WriteOptions(), tag(3)); - // 65536(64KB) is the default flow control window size. Should change this - // number when default flow control window size changes. For the write of - // send_request larger than the flow control window size, tag:3 will not come - // up until server read is initiated. For write of send_request smaller than - // the flow control window size, the request can take the free ride with - // initial metadata due to coalescing, thus write tag:3 will come up here. - if (GetParam().message_content.length() < 65536 || GetParam().inproc) { - Verifier(GetParam().disable_blocking) - .Expect(2, true) - .Expect(3, true) - .Verify(cq_.get()); - } else { - Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get()); - } + bool seen3 = false; + + Verifier(GetParam().disable_blocking) + .Expect(2, true) + .AcceptOnce(3, true, &seen3) + .Verify(cq_.get()); srv_stream.Read(&recv_request, tag(4)); - if (GetParam().message_content.length() < 65536 || GetParam().inproc) { - Verifier(GetParam().disable_blocking).Expect(4, true).Verify(cq_.get()); - } else { - Verifier(GetParam().disable_blocking) - .Expect(3, true) - .Expect(4, true) - .Verify(cq_.get()); - } + Verifier(GetParam().disable_blocking) + .AcceptOnce(3, true, &seen3) + .Expect(4, true) + .Verify(cq_.get()); EXPECT_EQ(send_request.message(), recv_request.message()); srv_stream.Read(&recv_request, tag(5)); @@ -877,6 +883,7 @@ TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWAF) { Verifier(GetParam().disable_blocking).Expect(8, true).Verify(cq_.get()); EXPECT_TRUE(recv_status.ok()); + EXPECT_TRUE(seen3); } // One ping, one pong. Using server:WriteLast api @@ -902,31 +909,19 @@ TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWL) { cli_stream->WriteLast(send_request, WriteOptions(), tag(3)); - // 65536(64KB) is the default flow control window size. Should change this - // number when default flow control window size changes. For the write of - // send_request larger than the flow control window size, tag:3 will not come - // up until server read is initiated. For write of send_request smaller than - // the flow control window size, the request can take the free ride with - // initial metadata due to coalescing, thus write tag:3 will come up here. - if (GetParam().message_content.length() < 65536 || GetParam().inproc) { - Verifier(GetParam().disable_blocking) - .Expect(2, true) - .Expect(3, true) - .Verify(cq_.get()); - } else { - Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get()); - } + bool seen3 = false; + + Verifier(GetParam().disable_blocking) + .Expect(2, true) + .AcceptOnce(3, true, &seen3) + .Verify(cq_.get()); srv_stream.Read(&recv_request, tag(4)); - if (GetParam().message_content.length() < 65536 || GetParam().inproc) { - Verifier(GetParam().disable_blocking).Expect(4, true).Verify(cq_.get()); - } else { - Verifier(GetParam().disable_blocking) - .Expect(3, true) - .Expect(4, true) - .Verify(cq_.get()); - } + Verifier(GetParam().disable_blocking) + .AcceptOnce(3, true, &seen3) + .Expect(4, true) + .Verify(cq_.get()); EXPECT_EQ(send_request.message(), recv_request.message()); srv_stream.Read(&recv_request, tag(5)); @@ -947,6 +942,7 @@ TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWL) { Verifier(GetParam().disable_blocking).Expect(9, true).Verify(cq_.get()); EXPECT_TRUE(recv_status.ok()); + EXPECT_TRUE(seen3); } // Metadata tests From de682c59cba06c0f5ce14046b4c8138cb28dc3f1 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 20 Sep 2017 22:18:16 -0700 Subject: [PATCH 054/142] Portability fixes --- src/core/lib/iomgr/pollset_uv.c | 7 ++++--- src/core/lib/iomgr/tcp_client_windows.c | 10 ++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/core/lib/iomgr/pollset_uv.c b/src/core/lib/iomgr/pollset_uv.c index 2651325e257..0127770a0dc 100644 --- a/src/core/lib/iomgr/pollset_uv.c +++ b/src/core/lib/iomgr/pollset_uv.c @@ -116,13 +116,14 @@ void grpc_pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) { grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, grpc_pollset_worker **worker_hdl, - gpr_timespec now, gpr_timespec deadline) { + grpc_millis deadline) { uint64_t timeout; GRPC_UV_ASSERT_SAME_THREAD(); gpr_mu_unlock(&grpc_polling_mu); if (grpc_pollset_work_run_loop) { - if (gpr_time_cmp(deadline, now) >= 0) { - timeout = (uint64_t)gpr_time_to_millis(gpr_time_sub(deadline, now)); + grpc_millis now = grpc_exec_ctx_now(exec_ctx); + if (deadline >= now) { + timeout = deadline - now; } else { timeout = 0; } diff --git a/src/core/lib/iomgr/tcp_client_windows.c b/src/core/lib/iomgr/tcp_client_windows.c index fc62105cc92..bf8016506aa 100644 --- a/src/core/lib/iomgr/tcp_client_windows.c +++ b/src/core/lib/iomgr/tcp_client_windows.c @@ -41,7 +41,6 @@ typedef struct { grpc_closure *on_done; gpr_mu mu; grpc_winsocket *socket; - gpr_timespec deadline; grpc_timer alarm; grpc_closure on_alarm; char *addr_name; @@ -124,7 +123,7 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) { static void tcp_client_connect_impl( grpc_exec_ctx *exec_ctx, grpc_closure *on_done, grpc_endpoint **endpoint, grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args, - const grpc_resolved_address *addr, gpr_timespec deadline) { + const grpc_resolved_address *addr, grpc_millis deadline) { SOCKET sock = INVALID_SOCKET; BOOL success; int status; @@ -204,8 +203,7 @@ static void tcp_client_connect_impl( GRPC_CLOSURE_INIT(&ac->on_connect, on_connect, ac, grpc_schedule_on_exec_ctx); GRPC_CLOSURE_INIT(&ac->on_alarm, on_alarm, ac, grpc_schedule_on_exec_ctx); - grpc_timer_init(exec_ctx, &ac->alarm, deadline, &ac->on_alarm, - gpr_now(GPR_CLOCK_MONOTONIC)); + grpc_timer_init(exec_ctx, &ac->alarm, deadline, &ac->on_alarm, ); grpc_socket_notify_on_write(exec_ctx, socket, &ac->on_connect); return; @@ -230,14 +228,14 @@ void (*grpc_tcp_client_connect_impl)( grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep, grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args, const grpc_resolved_address *addr, - gpr_timespec deadline) = tcp_client_connect_impl; + grpc_millis deadline) = tcp_client_connect_impl; void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep, grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args, const grpc_resolved_address *addr, - gpr_timespec deadline) { + grpc_millis deadline) { grpc_tcp_client_connect_impl(exec_ctx, closure, ep, interested_parties, channel_args, addr, deadline); } From 8070e361bd2c773aa8a12cea8cf34fd7aff7c293 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 21 Sep 2017 09:43:27 -0700 Subject: [PATCH 055/142] Fix type --- src/core/lib/backoff/backoff.c | 2 +- src/core/lib/backoff/backoff.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/backoff/backoff.c b/src/core/lib/backoff/backoff.c index e964af8f397..b34c4a852b5 100644 --- a/src/core/lib/backoff/backoff.c +++ b/src/core/lib/backoff/backoff.c @@ -34,7 +34,7 @@ void grpc_backoff_init(grpc_backoff *backoff, grpc_millis grpc_backoff_begin(grpc_exec_ctx *exec_ctx, grpc_backoff *backoff) { backoff->current_timeout_millis = backoff->initial_connect_timeout; - const int64_t first_timeout = + const grpc_millis first_timeout = GPR_MAX(backoff->current_timeout_millis, backoff->min_timeout_millis); return grpc_exec_ctx_now(exec_ctx) + first_timeout; } diff --git a/src/core/lib/backoff/backoff.h b/src/core/lib/backoff/backoff.h index c0798bbe5b0..32efdb9d927 100644 --- a/src/core/lib/backoff/backoff.h +++ b/src/core/lib/backoff/backoff.h @@ -37,7 +37,7 @@ typedef struct { uint32_t rng_state; /// current retry timeout in milliseconds - int64_t current_timeout_millis; + grpc_millis current_timeout_millis; } grpc_backoff; /// Initialize backoff machinery - does not need to be destroyed From 168fc97045a866a22db0b2079c14fd2775e32387 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 21 Sep 2017 09:49:32 -0700 Subject: [PATCH 056/142] (untested) windows conversion to grpc_millis --- src/core/lib/iomgr/iocp_windows.c | 24 ++++++++---------------- src/core/lib/iomgr/iocp_windows.h | 2 +- src/core/lib/iomgr/pollset_windows.c | 5 +++-- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/core/lib/iomgr/iocp_windows.c b/src/core/lib/iomgr/iocp_windows.c index c082179c0b4..3c38105ef99 100644 --- a/src/core/lib/iomgr/iocp_windows.c +++ b/src/core/lib/iomgr/iocp_windows.c @@ -40,25 +40,17 @@ static gpr_atm g_custom_events = 0; static HANDLE g_iocp; -static DWORD deadline_to_millis_timeout(gpr_timespec deadline, - gpr_timespec now) { +static DWORD deadline_to_millis_timeout(grpc_exec_ctx *exec_ctx, + grpc_millis deadline) { gpr_timespec timeout; - static const int64_t max_spin_polling_us = 10; - if (gpr_time_cmp(deadline, gpr_inf_future(deadline.clock_type)) == 0) { + if (deadline == GRPC_MILLIS_INF_FUTURE) == 0) { return INFINITE; } - if (gpr_time_cmp(deadline, gpr_time_add(now, gpr_time_from_micros( - max_spin_polling_us, - GPR_TIMESPAN))) <= 0) { - return 0; - } - timeout = gpr_time_sub(deadline, now); - return (DWORD)gpr_time_to_millis(gpr_time_add( - timeout, gpr_time_from_nanos(GPR_NS_PER_MS - 1, GPR_TIMESPAN))); + return (DWORD)GPR_MAX(0, deadline - grpc_exec_ctx_now(exec_ctx)); } grpc_iocp_work_status grpc_iocp_work(grpc_exec_ctx *exec_ctx, - gpr_timespec deadline) { + grpc_millis deadline) { BOOL success; DWORD bytes = 0; DWORD flags = 0; @@ -67,9 +59,9 @@ grpc_iocp_work_status grpc_iocp_work(grpc_exec_ctx *exec_ctx, grpc_winsocket *socket; grpc_winsocket_callback_info *info; GRPC_STATS_INC_SYSCALL_POLL(exec_ctx); - success = GetQueuedCompletionStatus( - g_iocp, &bytes, &completion_key, &overlapped, - deadline_to_millis_timeout(deadline, gpr_now(deadline.clock_type))); + success = + GetQueuedCompletionStatus(g_iocp, &bytes, &completion_key, &overlapped, + deadline_to_millis_timeout(exec_ctx, deadline)); if (success == 0 && overlapped == NULL) { return GRPC_IOCP_WORK_TIMEOUT; } diff --git a/src/core/lib/iomgr/iocp_windows.h b/src/core/lib/iomgr/iocp_windows.h index 9c89e868c5d..4314ff26174 100644 --- a/src/core/lib/iomgr/iocp_windows.h +++ b/src/core/lib/iomgr/iocp_windows.h @@ -30,7 +30,7 @@ typedef enum { } grpc_iocp_work_status; grpc_iocp_work_status grpc_iocp_work(grpc_exec_ctx *exec_ctx, - gpr_timespec deadline); + grpc_millis deadline); void grpc_iocp_init(void); void grpc_iocp_kick(void); void grpc_iocp_flush(void); diff --git a/src/core/lib/iomgr/pollset_windows.c b/src/core/lib/iomgr/pollset_windows.c index eb295d3eebd..bb4df83fc13 100644 --- a/src/core/lib/iomgr/pollset_windows.c +++ b/src/core/lib/iomgr/pollset_windows.c @@ -110,7 +110,7 @@ void grpc_pollset_destroy(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {} grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, grpc_pollset_worker **worker_hdl, - gpr_timespec now, gpr_timespec deadline) { + grpc_millis deadline) { grpc_pollset_worker worker; if (worker_hdl) *worker_hdl = &worker; @@ -159,7 +159,8 @@ grpc_error *grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, &worker); added_worker = 1; while (!worker.kicked) { - if (gpr_cv_wait(&worker.cv, &grpc_polling_mu, deadline)) { + if (gpr_cv_wait(&worker.cv, &grpc_polling_mu, + grpc_millis_to_timespec(deadline, GPR_CLOCK_REALTIME))) { break; } } From 1a8f1e831de1b98a5e616fbfd645a8458df29bad Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 21 Sep 2017 10:07:36 -0700 Subject: [PATCH 057/142] Make alarm_test tolerant of threading --- test/cpp/common/alarm_cpp_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cpp/common/alarm_cpp_test.cc b/test/cpp/common/alarm_cpp_test.cc index 212972d25d7..7adc3102f41 100644 --- a/test/cpp/common/alarm_cpp_test.cc +++ b/test/cpp/common/alarm_cpp_test.cc @@ -142,7 +142,7 @@ TEST(AlarmTest, ZeroExpiry) { void* output_tag; bool ok; const CompletionQueue::NextStatus status = cq.AsyncNext( - (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(0)); + (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(1)); EXPECT_EQ(status, CompletionQueue::GOT_EVENT); EXPECT_TRUE(ok); @@ -158,7 +158,7 @@ TEST(AlarmTest, NegativeExpiry) { void* output_tag; bool ok; const CompletionQueue::NextStatus status = cq.AsyncNext( - (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(0)); + (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(1)); EXPECT_EQ(status, CompletionQueue::GOT_EVENT); EXPECT_TRUE(ok); From ff58b27696f2cfbf4db5f79c8af7013361715de3 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 21 Sep 2017 10:40:42 -0700 Subject: [PATCH 058/142] Make generic_test tolerant of encoding --- test/cpp/end2end/generic_end2end_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index b9e6e18ca77..6e95a55283a 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -145,7 +145,7 @@ class GenericEnd2endTest : public ::testing::Test { if (check_deadline) { EXPECT_TRUE(gpr_time_similar(deadline, srv_ctx.raw_deadline(), - gpr_time_from_millis(100, GPR_TIMESPAN))); + gpr_time_from_millis(1000, GPR_TIMESPAN))); } ByteBuffer recv_buffer; From ddc81ca5566e463c5139b37248347aad2315bf63 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 21 Sep 2017 12:06:29 -0700 Subject: [PATCH 059/142] Fix resource user shutdown path while allocating --- src/core/lib/iomgr/resource_quota.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/lib/iomgr/resource_quota.c b/src/core/lib/iomgr/resource_quota.c index e0a9829cd73..85817080d62 100644 --- a/src/core/lib/iomgr/resource_quota.c +++ b/src/core/lib/iomgr/resource_quota.c @@ -523,6 +523,9 @@ static void ru_shutdown(grpc_exec_ctx *exec_ctx, void *ru, grpc_error *error) { resource_user->reclaimers[1] = NULL; rulist_remove(resource_user, GRPC_RULIST_RECLAIMER_BENIGN); rulist_remove(resource_user, GRPC_RULIST_RECLAIMER_DESTRUCTIVE); + if (resource_user->allocating) { + rq_step_sched(exec_ctx, resource_user->resource_quota); + } } static void ru_destroy(grpc_exec_ctx *exec_ctx, void *ru, grpc_error *error) { From dbff5a23feda108c427f9278079fbb1eec69a9d1 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 21 Sep 2017 12:50:07 -0700 Subject: [PATCH 060/142] Remove blocking annotations --- src/core/lib/support/time_posix.c | 3 --- src/core/lib/support/time_windows.c | 3 --- 2 files changed, 6 deletions(-) diff --git a/src/core/lib/support/time_posix.c b/src/core/lib/support/time_posix.c index ad7c5036dae..753a629e6e2 100644 --- a/src/core/lib/support/time_posix.c +++ b/src/core/lib/support/time_posix.c @@ -30,7 +30,6 @@ #include #include #include -#include "src/core/lib/iomgr/block_annotate.h" static struct timespec timespec_from_gpr(gpr_timespec gts) { struct timespec rv; @@ -157,9 +156,7 @@ void gpr_sleep_until(gpr_timespec until) { delta = gpr_time_sub(until, now); delta_ts = timespec_from_gpr(delta); - GRPC_SCHEDULING_START_BLOCKING_REGION; ns_result = nanosleep(&delta_ts, NULL); - GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX; if (ns_result == 0) { break; } diff --git a/src/core/lib/support/time_windows.c b/src/core/lib/support/time_windows.c index b8015c272f8..fb17e5c079f 100644 --- a/src/core/lib/support/time_windows.c +++ b/src/core/lib/support/time_windows.c @@ -28,7 +28,6 @@ #include #include -#include "src/core/lib/iomgr/block_annotate.h" #include "src/core/lib/support/time_precise.h" static LARGE_INTEGER g_start_time; @@ -92,9 +91,7 @@ void gpr_sleep_until(gpr_timespec until) { sleep_millis = delta.tv_sec * GPR_MS_PER_SEC + delta.tv_nsec / GPR_NS_PER_MS; GPR_ASSERT((sleep_millis >= 0) && (sleep_millis <= INT_MAX)); - GRPC_SCHEDULING_START_BLOCKING_REGION; Sleep((DWORD)sleep_millis); - GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX; } } From f7225eb5f67d766726a17a1623c1975dcdd57c26 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 21 Sep 2017 14:59:28 -0700 Subject: [PATCH 061/142] Fix some stalling in bm_fullstack_trickle, also switch to synthetic time --- .../microbenchmarks/bm_fullstack_trickle.cc | 33 +++++++++++++++++-- test/cpp/microbenchmarks/fullstack_fixtures.h | 4 +-- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc index 2656566a50b..b240e96fcab 100644 --- a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc +++ b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc @@ -29,6 +29,7 @@ extern "C" { #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/ext/transport/chttp2/transport/internal.h" +#include "src/core/lib/iomgr/timer_manager.h" #include "test/core/util/trickle_endpoint.h" } @@ -45,6 +46,22 @@ DEFINE_int32(warmup_max_time_seconds, 10, namespace grpc { namespace testing { +gpr_atm g_now_us = 0; + +static gpr_timespec fake_now(gpr_clock_type clock_type) { + gpr_timespec t; + gpr_atm now = gpr_atm_no_barrier_load(&g_now_us); + t.tv_sec = now / GPR_US_PER_SEC; + t.tv_nsec = (now % GPR_US_PER_SEC) * GPR_NS_PER_US; + t.clock_type = clock_type; + return t; +} + +static void inc_time() { + gpr_atm_no_barrier_fetch_add(&g_now_us, 100); + grpc_timer_manager_tick(); +} + static void* tag(intptr_t x) { return reinterpret_cast(x); } template @@ -158,6 +175,7 @@ class TrickledCHTTP2 : public EndpointPairFixture { void Step(bool update_stats) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + inc_time(); size_t client_backlog = grpc_trickle_endpoint_trickle(&exec_ctx, endpoint_pair_.client); size_t server_backlog = @@ -213,8 +231,7 @@ static void TrickleCQNext(TrickledCHTTP2* fixture, void** t, bool* ok, while (true) { fixture->Log(iteration); switch (fixture->cq()->AsyncNext( - t, ok, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_micros(100, GPR_TIMESPAN)))) { + t, ok, gpr_inf_past(GPR_CLOCK_MONOTONIC))) { case CompletionQueue::TIMEOUT: fixture->Step(iteration != -1); break; @@ -289,9 +306,15 @@ static void BM_PumpStreamServerToClient_Trickle(benchmark::State& state) { inner_loop(false); } response_rw.Finish(Status::OK, tag(1)); - need_tags = (1 << 0) | (1 << 1); + grpc::Status status; + request_rw->Finish(&status, tag(2)); + need_tags = (1 << 0) | (1 << 1) | (1 << 2); while (need_tags) { TrickleCQNext(fixture.get(), &t, &ok, -1); + if (t == tag(0) && ok) { + request_rw->Read(&recv_response, tag(0)); + continue; + } int i = (int)(intptr_t)t; GPR_ASSERT(need_tags & (1 << i)); need_tags &= ~(1 << i); @@ -419,8 +442,12 @@ BENCHMARK(BM_PumpUnbalancedUnary_Trickle)->Apply(UnaryTrickleArgs); } } +extern "C" gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type); + int main(int argc, char** argv) { ::benchmark::Initialize(&argc, argv); ::grpc::testing::InitTest(&argc, &argv, false); + grpc_timer_manager_set_threading(false); + gpr_now_impl = ::grpc::testing::fake_now; ::benchmark::RunSpecifiedBenchmarks(); } diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h index ecd28c3f8ac..a7f85045052 100644 --- a/test/cpp/microbenchmarks/fullstack_fixtures.h +++ b/test/cpp/microbenchmarks/fullstack_fixtures.h @@ -85,7 +85,7 @@ class FullstackFixture : public BaseFixture { } virtual ~FullstackFixture() { - server_->Shutdown(); + server_->Shutdown(gpr_inf_past(GPR_CLOCK_MONOTONIC)); cq_->Shutdown(); void* tag; bool ok; @@ -212,7 +212,7 @@ class EndpointPairFixture : public BaseFixture { } virtual ~EndpointPairFixture() { - server_->Shutdown(); + server_->Shutdown(gpr_inf_past(GPR_CLOCK_MONOTONIC)); cq_->Shutdown(); void* tag; bool ok; From c8027a3b0bf2f659f95cfe00ba269b09f9649cac Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 22 Sep 2017 07:31:48 -0700 Subject: [PATCH 062/142] Run pid controller with grpc_millis --- .../chttp2/transport/chttp2_transport.c | 16 +++++++++------- .../transport/chttp2/transport/flow_control.c | 16 +++++++--------- .../ext/transport/chttp2/transport/internal.h | 5 +++-- .../ext/transport/chttp2/transport/parsing.c | 5 +++-- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 4f381199486..4643a867b85 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -563,7 +563,8 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, } grpc_chttp2_act_on_flowctl_action( - exec_ctx, grpc_chttp2_flowctl_get_action(&t->flow_control, NULL), t, + exec_ctx, + grpc_chttp2_flowctl_get_action(exec_ctx, &t->flow_control, NULL), t, NULL); grpc_chttp2_initiate_write(exec_ctx, t, @@ -1620,8 +1621,8 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op, &t->flow_control, &s->flow_control, GRPC_HEADER_SIZE_IN_BYTES, already_received); grpc_chttp2_act_on_flowctl_action( - exec_ctx, - grpc_chttp2_flowctl_get_action(&t->flow_control, &s->flow_control), + exec_ctx, grpc_chttp2_flowctl_get_action(exec_ctx, &t->flow_control, + &s->flow_control), t, s); } } @@ -2538,7 +2539,8 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, grpc_endpoint_read(exec_ctx, t->ep, &t->read_buffer, &t->read_action_locked); grpc_chttp2_act_on_flowctl_action( - exec_ctx, grpc_chttp2_flowctl_get_action(&t->flow_control, NULL), t, + exec_ctx, + grpc_chttp2_flowctl_get_action(exec_ctx, &t->flow_control, NULL), t, NULL); GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keep_reading"); } else { @@ -2794,9 +2796,9 @@ static void incoming_byte_stream_next_locked(grpc_exec_ctx *exec_ctx, bs->next_action.max_size_hint, cur_length); grpc_chttp2_act_on_flowctl_action( - exec_ctx, - grpc_chttp2_flowctl_get_action(&t->flow_control, &s->flow_control), t, - s); + exec_ctx, grpc_chttp2_flowctl_get_action(exec_ctx, &t->flow_control, + &s->flow_control), + t, s); } GPR_ASSERT(s->unprocessed_incoming_frames_buffer.length == 0); if (s->frame_storage.length > 0) { diff --git a/src/core/ext/transport/chttp2/transport/flow_control.c b/src/core/ext/transport/chttp2/transport/flow_control.c index aa1dd2d3cbe..a95b4b3d052 100644 --- a/src/core/ext/transport/chttp2/transport/flow_control.c +++ b/src/core/ext/transport/chttp2/transport/flow_control.c @@ -391,9 +391,10 @@ static grpc_chttp2_flowctl_urgency delta_is_significant( // Takes in a target and uses the pid controller to return a stabilized // guess at the new bdp. -static double get_pid_controller_guess(grpc_chttp2_transport_flowctl* tfc, +static double get_pid_controller_guess(grpc_exec_ctx* exec_ctx, + grpc_chttp2_transport_flowctl* tfc, double target) { - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); + grpc_millis now = grpc_exec_ctx_now(exec_ctx); if (!tfc->pid_controller_initialized) { tfc->last_pid_update = now; tfc->pid_controller_initialized = true; @@ -409,11 +410,7 @@ static double get_pid_controller_guess(grpc_chttp2_transport_flowctl* tfc, return pow(2, target); } double bdp_error = target - grpc_pid_controller_last(&tfc->pid_controller); - gpr_timespec dt_timespec = gpr_time_sub(now, tfc->last_pid_update); - double dt = (double)dt_timespec.tv_sec + dt_timespec.tv_nsec * 1e-9; - if (dt > 0.1) { - dt = 0.1; - } + double dt = (double)(now - tfc->last_pid_update) * 1e-3; double log2_bdp_guess = grpc_pid_controller_update(&tfc->pid_controller, bdp_error, dt); tfc->last_pid_update = now; @@ -441,7 +438,8 @@ static double get_target_under_memory_pressure( } grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_action( - grpc_chttp2_transport_flowctl* tfc, grpc_chttp2_stream_flowctl* sfc) { + grpc_exec_ctx* exec_ctx, grpc_chttp2_transport_flowctl* tfc, + grpc_chttp2_stream_flowctl* sfc) { grpc_chttp2_flowctl_action action; memset(&action, 0, sizeof(action)); // TODO(ncteisen): tune this @@ -473,7 +471,7 @@ grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_action( // run our target through the pid controller to stabilize change. // TODO(ncteisen): experiment with other controllers here. - double bdp_guess = get_pid_controller_guess(tfc, target); + double bdp_guess = get_pid_controller_guess(exec_ctx, tfc, target); // Though initial window 'could' drop to 0, we keep the floor at 128 tfc->target_initial_window_size = diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index b5850564e02..7c890423a66 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -269,7 +269,7 @@ typedef struct { /* pid controller */ bool pid_controller_initialized; grpc_pid_controller pid_controller; - gpr_timespec last_pid_update; + grpc_millis last_pid_update; // pointer back to transport for tracing const grpc_chttp2_transport *t; @@ -748,7 +748,8 @@ typedef struct { // Reads the flow control data and returns and actionable struct that will tell // chttp2 exactly what it needs to do grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_action( - grpc_chttp2_transport_flowctl *tfc, grpc_chttp2_stream_flowctl *sfc); + grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_flowctl *tfc, + grpc_chttp2_stream_flowctl *sfc); // Takes in a flow control action and performs all the needed operations. void grpc_chttp2_act_on_flowctl_action(grpc_exec_ctx *exec_ctx, diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index 2086f42cb20..aab11e02d7b 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -359,8 +359,9 @@ static grpc_error *init_data_frame_parser(grpc_exec_ctx *exec_ctx, s == NULL ? NULL : &s->flow_control, t->incoming_frame_size); grpc_chttp2_act_on_flowctl_action( - exec_ctx, grpc_chttp2_flowctl_get_action( - &t->flow_control, s == NULL ? NULL : &s->flow_control), + exec_ctx, + grpc_chttp2_flowctl_get_action(exec_ctx, &t->flow_control, + s == NULL ? NULL : &s->flow_control), t, s); if (err != GRPC_ERROR_NONE) { goto error_handler; From 710334577ce1b2de94f656ec0762eeba6effd29b Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 22 Sep 2017 07:47:15 -0700 Subject: [PATCH 063/142] Fix sanity --- test/cpp/microbenchmarks/bm_fullstack_trickle.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc index b240e96fcab..adb5e6657f2 100644 --- a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc +++ b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc @@ -230,8 +230,8 @@ static void TrickleCQNext(TrickledCHTTP2* fixture, void** t, bool* ok, int64_t iteration) { while (true) { fixture->Log(iteration); - switch (fixture->cq()->AsyncNext( - t, ok, gpr_inf_past(GPR_CLOCK_MONOTONIC))) { + switch ( + fixture->cq()->AsyncNext(t, ok, gpr_inf_past(GPR_CLOCK_MONOTONIC))) { case CompletionQueue::TIMEOUT: fixture->Step(iteration != -1); break; From 2c357bc62e795affe6a9278193b579960aaf56ec Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 29 Sep 2017 11:10:14 -0700 Subject: [PATCH 064/142] Moving to allow fuzzer test to run entire corpora under bazel --- test/core/util/BUILD | 8 +- test/core/util/fuzzer_corpus_test.cc | 139 +++++++++++++++++++++++ test/core/util/grpc_fuzzer.bzl | 20 ++-- test/core/util/one_corpus_entry_fuzzer.c | 39 ------- 4 files changed, 154 insertions(+), 52 deletions(-) create mode 100644 test/core/util/fuzzer_corpus_test.cc delete mode 100644 test/core/util/one_corpus_entry_fuzzer.c diff --git a/test/core/util/BUILD b/test/core/util/BUILD index 10eefe159a8..abb50a0c996 100644 --- a/test/core/util/BUILD +++ b/test/core/util/BUILD @@ -89,12 +89,16 @@ grpc_cc_library( ) grpc_cc_library( - name = "one_corpus_entry_fuzzer", - srcs = ["one_corpus_entry_fuzzer.c"], + name = "fuzzer_corpus_test", + srcs = ["fuzzer_corpus_test.cc"], deps = [ ":gpr_test_util", "//:grpc", ], + external_deps = [ + "gtest", + "gflags", + ], ) sh_library( diff --git a/test/core/util/fuzzer_corpus_test.cc b/test/core/util/fuzzer_corpus_test.cc new file mode 100644 index 00000000000..75c6846cd7e --- /dev/null +++ b/test/core/util/fuzzer_corpus_test.cc @@ -0,0 +1,139 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include +#include +#include +#include +#include +#include + +#include "src/core/lib/iomgr/load_file.h" +#include "test/core/util/test_config.h" + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size); +extern "C" bool squelch; +extern "C" bool leak_check; + +DEFINE_string(file, "", "Use this file as test data"); +DEFINE_string(directory, "", "Use this directory as test data"); + +class FuzzerCorpusTest : public ::testing::TestWithParam {}; + +TEST_P(FuzzerCorpusTest, RunOneExample) { + grpc_slice buffer; + squelch = false; + leak_check = false; + GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file", + grpc_load_file(GetParam().c_str(), 0, &buffer))); + LLVMFuzzerTestOneInput(GRPC_SLICE_START_PTR(buffer), + GRPC_SLICE_LENGTH(buffer)); + grpc_slice_unref(buffer); +} + +class ExampleGenerator + : public ::testing::internal::ParamGeneratorInterface { + public: + virtual ::testing::internal::ParamIteratorInterface* Begin() + const; + virtual ::testing::internal::ParamIteratorInterface* End() const; + + private: + void Materialize() const { + if (examples_.empty()) { + if (!FLAGS_file.empty()) examples_.push_back(FLAGS_file); + if (!FLAGS_directory.empty()) { + DIR* dp; + struct dirent* ep; + dp = opendir("./"); + + if (dp != NULL) { + while ((ep = readdir(dp)) != nullptr) examples_.push_back(ep->d_name); + + (void)closedir(dp); + } else { + perror("Couldn't open the directory"); + abort(); + } + } + } + } + + mutable std::vector examples_; +}; + +class ExampleIterator + : public ::testing::internal::ParamIteratorInterface { + public: + ExampleIterator(const ExampleGenerator& base_, + std::vector::const_iterator begin) + : base_(base_), begin_(begin), current_(begin), current_string_(NULL) {} + + ~ExampleIterator() { delete current_string_; } + virtual const ExampleGenerator* BaseGenerator() const { return &base_; } + + virtual void Advance() { + current_++; + delete current_string_; + current_string_ = NULL; + } + virtual ExampleIterator* Clone() const { return new ExampleIterator(*this); } + virtual const std::string* Current() const; + + virtual bool Equals(const ParamIteratorInterface& other) const { + return &base_ == other.BaseGenerator() && + current_ == dynamic_cast(&other)->current_; + } + + private: + ExampleIterator(const ExampleIterator& other) + : base_(other.base_), + begin_(other.begin_), + current_(other.current_), + current_string_(NULL) {} + + const ExampleGenerator& base_; + const std::vector::const_iterator begin_; + std::vector::const_iterator current_; + mutable const std::string* current_string_; +}; + +::testing::internal::ParamIteratorInterface* +ExampleGenerator::Begin() const { + Materialize(); + return new ExampleIterator(*this, examples_.begin()); +} + +::testing::internal::ParamIteratorInterface* +ExampleGenerator::End() const { + Materialize(); + return new ExampleIterator(*this, examples_.end()); +} + +INSTANTIATE_TEST_CASE_P( + CorpusExamples, FuzzerCorpusTest, + ::testing::internal::ParamGenerator(new ExampleGenerator)); + +int main(int argc, char** argv) { + grpc_test_init(argc, argv); + ::testing::InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +} diff --git a/test/core/util/grpc_fuzzer.bzl b/test/core/util/grpc_fuzzer.bzl index 41f6cdc8ba6..55b6f1c1a5e 100644 --- a/test/core/util/grpc_fuzzer.bzl +++ b/test/core/util/grpc_fuzzer.bzl @@ -12,19 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("//bazel:grpc_build_system.bzl", "grpc_cc_binary") +load("//bazel:grpc_build_system.bzl", "grpc_cc_test") def grpc_fuzzer(name, corpus, srcs = [], deps = [], **kwargs): - grpc_cc_binary( - name = '%s/one_entry.bin' % name, + grpc_cc_test( + name = name, srcs = srcs, - deps = deps + ["//test/core/util:one_corpus_entry_fuzzer"], + deps = deps + ["//test/core/util:fuzzer_corpus_test"], + data = [corpus], + args = ['--directory', '$(location %s)' % corpus], + external_deps = [ + 'gtest', + ], **kwargs ) - for entry in native.glob(['%s/*' % corpus]): - native.sh_test( - name = '%s/one_entry/%s' % (name, entry), - data = [':%s/one_entry.bin' % name, entry], - srcs = ['//test/core/util:fuzzer_one_entry_runner'], - args = ['$(location :%s/one_entry.bin)' % name, '$(location %s)' % entry] - ) diff --git a/test/core/util/one_corpus_entry_fuzzer.c b/test/core/util/one_corpus_entry_fuzzer.c deleted file mode 100644 index 42467390f2d..00000000000 --- a/test/core/util/one_corpus_entry_fuzzer.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include -#include "src/core/lib/iomgr/load_file.h" - -extern int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); - -extern bool squelch; -extern bool leak_check; - -int main(int argc, char **argv) { - grpc_slice buffer; - squelch = false; - leak_check = false; - GPR_ASSERT( - GRPC_LOG_IF_ERROR("load_file", grpc_load_file(argv[1], 0, &buffer))); - LLVMFuzzerTestOneInput(GRPC_SLICE_START_PTR(buffer), - GRPC_SLICE_LENGTH(buffer)); - grpc_slice_unref(buffer); - return 0; -} From 43c1b5f4377d3f1640b7bdae099cd3300a624bc0 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 2 Oct 2017 14:42:49 -0700 Subject: [PATCH 065/142] Fixes --- build.yaml | 2 +- gRPC-Core.podspec | 4 ++-- grpc.gemspec | 2 +- package.xml | 2 +- .../transport/chttp2/transport/chttp2_transport.c | 2 +- .../ext/transport/chttp2/transport/flow_control.c | 3 ++- src/core/lib/iomgr/iocp_windows.c | 6 +++--- src/core/lib/transport/bdp_estimator.c | 14 ++++++++------ src/core/lib/transport/bdp_estimator.h | 13 ++++++++----- tools/doxygen/Doxyfile.c++.internal | 2 +- tools/doxygen/Doxyfile.core.internal | 2 +- tools/run_tests/generated/sources_and_headers.json | 4 ++-- 12 files changed, 31 insertions(+), 25 deletions(-) diff --git a/build.yaml b/build.yaml index 9fac2e11260..5843be28188 100644 --- a/build.yaml +++ b/build.yaml @@ -142,7 +142,6 @@ filegroups: - src/core/lib/support/atomic.h - src/core/lib/support/atomic_with_atm.h - src/core/lib/support/atomic_with_std.h - - src/core/lib/support/block_annotate.h - src/core/lib/support/env.h - src/core/lib/support/memory.h - src/core/lib/support/mpscq.h @@ -355,6 +354,7 @@ filegroups: - src/core/lib/http/format_request.h - src/core/lib/http/httpcli.h - src/core/lib/http/parser.h + - src/core/lib/iomgr/block_annotate.h - src/core/lib/iomgr/call_combiner.h - src/core/lib/iomgr/closure.h - src/core/lib/iomgr/combiner.h diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 8b7bdfc6177..804345a9cb1 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -189,7 +189,6 @@ Pod::Spec.new do |s| 'src/core/lib/support/atomic.h', 'src/core/lib/support/atomic_with_atm.h', 'src/core/lib/support/atomic_with_std.h', - 'src/core/lib/support/block_annotate.h', 'src/core/lib/support/env.h', 'src/core/lib/support/memory.h', 'src/core/lib/support/mpscq.h', @@ -336,6 +335,7 @@ Pod::Spec.new do |s| 'src/core/lib/http/format_request.h', 'src/core/lib/http/httpcli.h', 'src/core/lib/http/parser.h', + 'src/core/lib/iomgr/block_annotate.h', 'src/core/lib/iomgr/call_combiner.h', 'src/core/lib/iomgr/closure.h', 'src/core/lib/iomgr/combiner.h', @@ -734,7 +734,6 @@ Pod::Spec.new do |s| 'src/core/lib/support/atomic.h', 'src/core/lib/support/atomic_with_atm.h', 'src/core/lib/support/atomic_with_std.h', - 'src/core/lib/support/block_annotate.h', 'src/core/lib/support/env.h', 'src/core/lib/support/memory.h', 'src/core/lib/support/mpscq.h', @@ -836,6 +835,7 @@ Pod::Spec.new do |s| 'src/core/lib/http/format_request.h', 'src/core/lib/http/httpcli.h', 'src/core/lib/http/parser.h', + 'src/core/lib/iomgr/block_annotate.h', 'src/core/lib/iomgr/call_combiner.h', 'src/core/lib/iomgr/closure.h', 'src/core/lib/iomgr/combiner.h', diff --git a/grpc.gemspec b/grpc.gemspec index 26b123d47b0..f6927b2cb50 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -88,7 +88,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/support/atomic.h ) s.files += %w( src/core/lib/support/atomic_with_atm.h ) s.files += %w( src/core/lib/support/atomic_with_std.h ) - s.files += %w( src/core/lib/support/block_annotate.h ) s.files += %w( src/core/lib/support/env.h ) s.files += %w( src/core/lib/support/memory.h ) s.files += %w( src/core/lib/support/mpscq.h ) @@ -269,6 +268,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/http/format_request.h ) s.files += %w( src/core/lib/http/httpcli.h ) s.files += %w( src/core/lib/http/parser.h ) + s.files += %w( src/core/lib/iomgr/block_annotate.h ) s.files += %w( src/core/lib/iomgr/call_combiner.h ) s.files += %w( src/core/lib/iomgr/closure.h ) s.files += %w( src/core/lib/iomgr/combiner.h ) diff --git a/package.xml b/package.xml index 4c24070124e..824de0b8832 100644 --- a/package.xml +++ b/package.xml @@ -100,7 +100,6 @@ - @@ -281,6 +280,7 @@ + diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 1c575badb87..452651af900 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -2576,7 +2576,7 @@ static void finish_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp, if (GRPC_TRACER_ON(grpc_http_trace)) { gpr_log(GPR_DEBUG, "%s: Complete BDP ping", t->peer_string); } - grpc_bdp_estimator_complete_ping(&t->flow_control.bdp_estimator); + grpc_bdp_estimator_complete_ping(exec_ctx, &t->flow_control.bdp_estimator); GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "bdp_ping"); } diff --git a/src/core/ext/transport/chttp2/transport/flow_control.c b/src/core/ext/transport/chttp2/transport/flow_control.c index a95b4b3d052..a8ac80cf43b 100644 --- a/src/core/ext/transport/chttp2/transport/flow_control.c +++ b/src/core/ext/transport/chttp2/transport/flow_control.c @@ -457,7 +457,8 @@ grpc_chttp2_flowctl_action grpc_chttp2_flowctl_get_action( } } if (tfc->enable_bdp_probe) { - action.need_ping = grpc_bdp_estimator_need_ping(&tfc->bdp_estimator); + action.need_ping = + grpc_bdp_estimator_need_ping(exec_ctx, &tfc->bdp_estimator); // get bdp estimate and update initial_window accordingly. int64_t estimate = -1; diff --git a/src/core/lib/iomgr/iocp_windows.c b/src/core/lib/iomgr/iocp_windows.c index 3c38105ef99..a6e064c8c04 100644 --- a/src/core/lib/iomgr/iocp_windows.c +++ b/src/core/lib/iomgr/iocp_windows.c @@ -43,7 +43,7 @@ static HANDLE g_iocp; static DWORD deadline_to_millis_timeout(grpc_exec_ctx *exec_ctx, grpc_millis deadline) { gpr_timespec timeout; - if (deadline == GRPC_MILLIS_INF_FUTURE) == 0) { + if (deadline == GRPC_MILLIS_INF_FUTURE) { return INFINITE; } return (DWORD)GPR_MAX(0, deadline - grpc_exec_ctx_now(exec_ctx)); @@ -113,7 +113,7 @@ void grpc_iocp_flush(void) { grpc_iocp_work_status work_status; do { - work_status = grpc_iocp_work(&exec_ctx, gpr_inf_past(GPR_CLOCK_MONOTONIC)); + work_status = grpc_iocp_work(&exec_ctx, GRPC_MILLIS_INF_PAST); } while (work_status == GRPC_IOCP_WORK_KICK || grpc_exec_ctx_flush(&exec_ctx)); } @@ -121,7 +121,7 @@ void grpc_iocp_flush(void) { void grpc_iocp_shutdown(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (gpr_atm_acq_load(&g_custom_events)) { - grpc_iocp_work(&exec_ctx, gpr_inf_future(GPR_CLOCK_MONOTONIC)); + grpc_iocp_work(&exec_ctx, GRPC_MILLIS_INF_FUTURE); grpc_exec_ctx_flush(&exec_ctx); } grpc_exec_ctx_finish(&exec_ctx); diff --git a/src/core/lib/transport/bdp_estimator.c b/src/core/lib/transport/bdp_estimator.c index 2a3ffbbd018..2bf1d0b5e5c 100644 --- a/src/core/lib/transport/bdp_estimator.c +++ b/src/core/lib/transport/bdp_estimator.c @@ -30,6 +30,7 @@ void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator, const char *name) { estimator->estimate = 65536; estimator->ping_state = GRPC_BDP_PING_UNSCHEDULED; estimator->ping_start_time = gpr_time_0(GPR_CLOCK_MONOTONIC); + estimator->next_ping_scheduled = 0; estimator->name = name; estimator->bw_est = 0; estimator->inter_ping_delay = 100.0; // start at 100ms @@ -53,11 +54,11 @@ void grpc_bdp_estimator_add_incoming_bytes(grpc_bdp_estimator *estimator, estimator->accumulator += num_bytes; } -bool grpc_bdp_estimator_need_ping(const grpc_bdp_estimator *estimator) { +bool grpc_bdp_estimator_need_ping(grpc_exec_ctx *exec_ctx, + const grpc_bdp_estimator *estimator) { switch (estimator->ping_state) { case GRPC_BDP_PING_UNSCHEDULED: - return gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), - estimator->ping_start_time) >= 0; + return grpc_exec_ctx_now(exec_ctx) >= estimator->next_ping_scheduled; case GRPC_BDP_PING_SCHEDULED: return false; case GRPC_BDP_PING_STARTED: @@ -87,7 +88,8 @@ void grpc_bdp_estimator_start_ping(grpc_bdp_estimator *estimator) { estimator->ping_start_time = gpr_now(GPR_CLOCK_MONOTONIC); } -void grpc_bdp_estimator_complete_ping(grpc_bdp_estimator *estimator) { +void grpc_bdp_estimator_complete_ping(grpc_exec_ctx *exec_ctx, + grpc_bdp_estimator *estimator) { gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); gpr_timespec dt_ts = gpr_time_sub(now, estimator->ping_start_time); double dt = (double)dt_ts.tv_sec + 1e-9 * (double)dt_ts.tv_nsec; @@ -129,6 +131,6 @@ void grpc_bdp_estimator_complete_ping(grpc_bdp_estimator *estimator) { } estimator->ping_state = GRPC_BDP_PING_UNSCHEDULED; estimator->accumulator = 0; - estimator->ping_start_time = gpr_time_add( - now, gpr_time_from_millis(estimator->inter_ping_delay, GPR_TIMESPAN)); + estimator->next_ping_scheduled = + grpc_exec_ctx_now(exec_ctx) + estimator->inter_ping_delay; } diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h index 670e38dd4bb..c74de5a6bb8 100644 --- a/src/core/lib/transport/bdp_estimator.h +++ b/src/core/lib/transport/bdp_estimator.h @@ -23,6 +23,7 @@ #include #include #include "src/core/lib/debug/trace.h" +#include "src/core/lib/iomgr/exec_ctx.h" #define GRPC_BDP_SAMPLES 16 #define GRPC_BDP_MIN_SAMPLES_FOR_ESTIMATE 3 @@ -39,10 +40,10 @@ typedef struct grpc_bdp_estimator { grpc_bdp_estimator_ping_state ping_state; int64_t accumulator; int64_t estimate; - // case ping_state of - // GRPC_BDP_PING_UNSCHEDULED => when to start the next ping - // GRPC_BDP_PING_STARTED => when the current ping was started + // when was the current ping started? gpr_timespec ping_start_time; + // when should the next ping start? + grpc_millis next_ping_scheduled; int inter_ping_delay; int stable_estimate_count; double bw_est; @@ -60,7 +61,8 @@ bool grpc_bdp_estimator_get_bw(const grpc_bdp_estimator *estimator, double *bw); void grpc_bdp_estimator_add_incoming_bytes(grpc_bdp_estimator *estimator, int64_t num_bytes); // Returns true if the user should schedule a ping -bool grpc_bdp_estimator_need_ping(const grpc_bdp_estimator *estimator); +bool grpc_bdp_estimator_need_ping(grpc_exec_ctx *exec_ctx, + const grpc_bdp_estimator *estimator); // Schedule a ping: call in response to receiving a true from // grpc_bdp_estimator_add_incoming_bytes once a ping has been scheduled by a // transport (but not necessarily started) @@ -69,6 +71,7 @@ void grpc_bdp_estimator_schedule_ping(grpc_bdp_estimator *estimator); // the ping is on the wire void grpc_bdp_estimator_start_ping(grpc_bdp_estimator *estimator); // Completes a previously started ping -void grpc_bdp_estimator_complete_ping(grpc_bdp_estimator *estimator); +void grpc_bdp_estimator_complete_ping(grpc_exec_ctx *exec_ctx, + grpc_bdp_estimator *estimator); #endif /* GRPC_CORE_LIB_TRANSPORT_BDP_ESTIMATOR_H */ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index d220365fc07..cb8bb93c738 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -953,6 +953,7 @@ src/core/lib/debug/trace.h \ src/core/lib/http/format_request.h \ src/core/lib/http/httpcli.h \ src/core/lib/http/parser.h \ +src/core/lib/iomgr/block_annotate.h \ src/core/lib/iomgr/call_combiner.h \ src/core/lib/iomgr/closure.h \ src/core/lib/iomgr/combiner.h \ @@ -1029,7 +1030,6 @@ src/core/lib/support/arena.h \ src/core/lib/support/atomic.h \ src/core/lib/support/atomic_with_atm.h \ src/core/lib/support/atomic_with_std.h \ -src/core/lib/support/block_annotate.h \ src/core/lib/support/env.h \ src/core/lib/support/memory.h \ src/core/lib/support/mpscq.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 430566bfbef..792d0b3f684 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1098,6 +1098,7 @@ src/core/lib/http/httpcli_security_connector.c \ src/core/lib/http/parser.c \ src/core/lib/http/parser.h \ src/core/lib/iomgr/README.md \ +src/core/lib/iomgr/block_annotate.h \ src/core/lib/iomgr/call_combiner.c \ src/core/lib/iomgr/call_combiner.h \ src/core/lib/iomgr/closure.c \ @@ -1303,7 +1304,6 @@ src/core/lib/support/atomic.h \ src/core/lib/support/atomic_with_atm.h \ src/core/lib/support/atomic_with_std.h \ src/core/lib/support/avl.c \ -src/core/lib/support/block_annotate.h \ src/core/lib/support/cmdline.c \ src/core/lib/support/cpu_iphone.c \ src/core/lib/support/cpu_linux.c \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 5e825e2082a..07acce58a2f 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7855,7 +7855,6 @@ "src/core/lib/support/atomic.h", "src/core/lib/support/atomic_with_atm.h", "src/core/lib/support/atomic_with_std.h", - "src/core/lib/support/block_annotate.h", "src/core/lib/support/env.h", "src/core/lib/support/memory.h", "src/core/lib/support/mpscq.h", @@ -7903,7 +7902,6 @@ "src/core/lib/support/atomic.h", "src/core/lib/support/atomic_with_atm.h", "src/core/lib/support/atomic_with_std.h", - "src/core/lib/support/block_annotate.h", "src/core/lib/support/env.h", "src/core/lib/support/memory.h", "src/core/lib/support/mpscq.h", @@ -8169,6 +8167,7 @@ "src/core/lib/http/format_request.h", "src/core/lib/http/httpcli.h", "src/core/lib/http/parser.h", + "src/core/lib/iomgr/block_annotate.h", "src/core/lib/iomgr/call_combiner.h", "src/core/lib/iomgr/closure.h", "src/core/lib/iomgr/combiner.h", @@ -8303,6 +8302,7 @@ "src/core/lib/http/format_request.h", "src/core/lib/http/httpcli.h", "src/core/lib/http/parser.h", + "src/core/lib/iomgr/block_annotate.h", "src/core/lib/iomgr/call_combiner.h", "src/core/lib/iomgr/closure.h", "src/core/lib/iomgr/combiner.h", From 5bc68e9750d6046d348a3ef8ffa4909a435e3e3c Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 2 Oct 2017 15:16:46 -0700 Subject: [PATCH 066/142] Fixes --- src/core/lib/iomgr/iocp_windows.c | 1 + src/core/lib/iomgr/tcp_client_windows.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/iocp_windows.c b/src/core/lib/iomgr/iocp_windows.c index a6e064c8c04..336cc86c757 100644 --- a/src/core/lib/iomgr/iocp_windows.c +++ b/src/core/lib/iomgr/iocp_windows.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "src/core/lib/debug/stats.h" #include "src/core/lib/iomgr/iocp_windows.h" diff --git a/src/core/lib/iomgr/tcp_client_windows.c b/src/core/lib/iomgr/tcp_client_windows.c index bf8016506aa..532d956a8eb 100644 --- a/src/core/lib/iomgr/tcp_client_windows.c +++ b/src/core/lib/iomgr/tcp_client_windows.c @@ -203,7 +203,7 @@ static void tcp_client_connect_impl( GRPC_CLOSURE_INIT(&ac->on_connect, on_connect, ac, grpc_schedule_on_exec_ctx); GRPC_CLOSURE_INIT(&ac->on_alarm, on_alarm, ac, grpc_schedule_on_exec_ctx); - grpc_timer_init(exec_ctx, &ac->alarm, deadline, &ac->on_alarm, ); + grpc_timer_init(exec_ctx, &ac->alarm, deadline, &ac->on_alarm); grpc_socket_notify_on_write(exec_ctx, socket, &ac->on_connect); return; From a16be228f8c0e160d8bff2c4267517b3a4045fab Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 2 Oct 2017 15:57:01 -0700 Subject: [PATCH 067/142] Fix casts --- src/core/lib/backoff/backoff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/backoff/backoff.c b/src/core/lib/backoff/backoff.c index b34c4a852b5..fe0a7518171 100644 --- a/src/core/lib/backoff/backoff.c +++ b/src/core/lib/backoff/backoff.c @@ -49,7 +49,7 @@ grpc_millis grpc_backoff_step(grpc_exec_ctx *exec_ctx, grpc_backoff *backoff) { const double new_timeout_millis = backoff->multiplier * (double)backoff->current_timeout_millis; backoff->current_timeout_millis = - GPR_MIN((int64_t)new_timeout_millis, backoff->max_timeout_millis); + GPR_MIN((grpc_millis)new_timeout_millis, backoff->max_timeout_millis); const double jitter_range_width = backoff->jitter * new_timeout_millis; const double jitter = @@ -57,7 +57,7 @@ grpc_millis grpc_backoff_step(grpc_exec_ctx *exec_ctx, grpc_backoff *backoff) { jitter_range_width; backoff->current_timeout_millis = - (int64_t)((double)(backoff->current_timeout_millis) + jitter); + (grpc_millis)((double)(backoff->current_timeout_millis) + jitter); const grpc_millis current_deadline = grpc_exec_ctx_now(exec_ctx) + backoff->current_timeout_millis; From 12b29ec5f34c1769956d481193d6e2393fe07ee0 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 3 Oct 2017 09:41:24 -0700 Subject: [PATCH 068/142] Fix test --- test/core/transport/bdp_estimator_test.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/core/transport/bdp_estimator_test.c b/test/core/transport/bdp_estimator_test.c index c672b535181..4912ad58872 100644 --- a/test/core/transport/bdp_estimator_test.c +++ b/test/core/transport/bdp_estimator_test.c @@ -58,16 +58,18 @@ static void add_samples(grpc_bdp_estimator *estimator, int64_t *samples, size_t n) { grpc_bdp_estimator_add_incoming_bytes(estimator, 1234567); inc_time(); - GPR_ASSERT(grpc_bdp_estimator_need_ping(estimator) == true); + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + GPR_ASSERT(grpc_bdp_estimator_need_ping(&exec_ctx, estimator) == true); grpc_bdp_estimator_schedule_ping(estimator); grpc_bdp_estimator_start_ping(estimator); for (size_t i = 0; i < n; i++) { grpc_bdp_estimator_add_incoming_bytes(estimator, samples[i]); - GPR_ASSERT(grpc_bdp_estimator_need_ping(estimator) == false); + GPR_ASSERT(grpc_bdp_estimator_need_ping(&exec_ctx, estimator) == false); } gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(1, GPR_TIMESPAN))); - grpc_bdp_estimator_complete_ping(estimator); + grpc_bdp_estimator_complete_ping(&exec_ctx, estimator); + grpc_exec_ctx_finish(&exec_ctx); } static void add_sample(grpc_bdp_estimator *estimator, int64_t sample) { From 301d4c93a478ffbaa533e523a3683140bb783929 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 3 Oct 2017 09:43:01 -0700 Subject: [PATCH 069/142] Fix cast --- .../client_channel/lb_policy/grpclb/load_balancer_api.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c index 9c6fb94bf19..4d5fb2081cc 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c @@ -300,9 +300,9 @@ int grpc_grpclb_duration_compare(const grpc_grpclb_duration *lhs, } grpc_millis grpc_grpclb_duration_to_millis(grpc_grpclb_duration *duration_pb) { - return (duration_pb->has_seconds ? duration_pb->seconds : 0) * - GPR_MS_PER_SEC + - (duration_pb->has_nanos ? duration_pb->nanos : 0) / GPR_NS_PER_MS; + return (grpc_millis)( + (duration_pb->has_seconds ? duration_pb->seconds : 0) * GPR_MS_PER_SEC + + (duration_pb->has_nanos ? duration_pb->nanos : 0) / GPR_NS_PER_MS); } void grpc_grpclb_initial_response_destroy( From d75d90f055a664fb60a0b33954c6db06d2ceed57 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 3 Oct 2017 09:58:21 -0700 Subject: [PATCH 070/142] Make this work --- test/core/util/fuzzer_corpus_test.cc | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/test/core/util/fuzzer_corpus_test.cc b/test/core/util/fuzzer_corpus_test.cc index 75c6846cd7e..a5e99a1bacd 100644 --- a/test/core/util/fuzzer_corpus_test.cc +++ b/test/core/util/fuzzer_corpus_test.cc @@ -38,6 +38,7 @@ DEFINE_string(directory, "", "Use this directory as test data"); class FuzzerCorpusTest : public ::testing::TestWithParam {}; TEST_P(FuzzerCorpusTest, RunOneExample) { + gpr_log(GPR_DEBUG, "Example file: %s", GetParam().c_str()); grpc_slice buffer; squelch = false; leak_check = false; @@ -62,10 +63,14 @@ class ExampleGenerator if (!FLAGS_directory.empty()) { DIR* dp; struct dirent* ep; - dp = opendir("./"); + dp = opendir(FLAGS_directory.c_str()); if (dp != NULL) { - while ((ep = readdir(dp)) != nullptr) examples_.push_back(ep->d_name); + while ((ep = readdir(dp)) != nullptr) { + if (ep->d_type == DT_REG) { + examples_.push_back(FLAGS_directory + "/" + ep->d_name); + } + } (void)closedir(dp); } else { @@ -84,18 +89,13 @@ class ExampleIterator public: ExampleIterator(const ExampleGenerator& base_, std::vector::const_iterator begin) - : base_(base_), begin_(begin), current_(begin), current_string_(NULL) {} + : base_(base_), begin_(begin), current_(begin) {} - ~ExampleIterator() { delete current_string_; } virtual const ExampleGenerator* BaseGenerator() const { return &base_; } - virtual void Advance() { - current_++; - delete current_string_; - current_string_ = NULL; - } + virtual void Advance() { current_++; } virtual ExampleIterator* Clone() const { return new ExampleIterator(*this); } - virtual const std::string* Current() const; + virtual const std::string* Current() const { return &*current_; } virtual bool Equals(const ParamIteratorInterface& other) const { return &base_ == other.BaseGenerator() && @@ -104,15 +104,11 @@ class ExampleIterator private: ExampleIterator(const ExampleIterator& other) - : base_(other.base_), - begin_(other.begin_), - current_(other.current_), - current_string_(NULL) {} + : base_(other.base_), begin_(other.begin_), current_(other.current_) {} const ExampleGenerator& base_; const std::vector::const_iterator begin_; std::vector::const_iterator current_; - mutable const std::string* current_string_; }; ::testing::internal::ParamIteratorInterface* @@ -133,6 +129,7 @@ INSTANTIATE_TEST_CASE_P( int main(int argc, char** argv) { grpc_test_init(argc, argv); + ::gflags::ParseCommandLineFlags(&argc, &argv, true); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); From c680f757ac93bdb518db9f46b0f7c781dc569d40 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 3 Oct 2017 14:04:35 -0700 Subject: [PATCH 071/142] Fix UV compilation --- src/core/lib/iomgr/timer_uv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/core/lib/iomgr/timer_uv.c b/src/core/lib/iomgr/timer_uv.c index adced41f539..ebfd9647d7d 100644 --- a/src/core/lib/iomgr/timer_uv.c +++ b/src/core/lib/iomgr/timer_uv.c @@ -53,19 +53,18 @@ void run_expired_timer(uv_timer_t *handle) { } void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer, - gpr_timespec deadline, grpc_closure *closure, - gpr_timespec now) { + grpc_millis deadline, grpc_closure *closure) { uint64_t timeout; uv_timer_t *uv_timer; GRPC_UV_ASSERT_SAME_THREAD(); timer->closure = closure; - if (gpr_time_cmp(deadline, now) <= 0) { + if (deadline <= grpc_exec_ctx_now(exec_ctx)) { timer->pending = 0; GRPC_CLOSURE_SCHED(exec_ctx, timer->closure, GRPC_ERROR_NONE); return; } timer->pending = 1; - timeout = (uint64_t)gpr_time_to_millis(gpr_time_sub(deadline, now)); + timeout = (uint64_t)(deadline - now); uv_timer = gpr_malloc(sizeof(uv_timer_t)); uv_timer_init(uv_default_loop(), uv_timer); uv_timer->data = timer; From e86c7fd8c335a2bb9c283cbe5eac65483dc0cb1c Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 3 Oct 2017 14:05:50 -0700 Subject: [PATCH 072/142] Fix UV compilation --- src/core/lib/iomgr/tcp_client_uv.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/core/lib/iomgr/tcp_client_uv.c b/src/core/lib/iomgr/tcp_client_uv.c index 786c456b735..d456c6797ae 100644 --- a/src/core/lib/iomgr/tcp_client_uv.c +++ b/src/core/lib/iomgr/tcp_client_uv.c @@ -119,7 +119,7 @@ static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx, grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args, const grpc_resolved_address *resolved_addr, - gpr_timespec deadline) { + grpc_millis deadline) { grpc_uv_tcp_connect *connect; grpc_resource_quota *resource_quota = grpc_resource_quota_create(NULL); (void)channel_args; @@ -158,9 +158,7 @@ static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx, uv_tc_on_connect); GRPC_CLOSURE_INIT(&connect->on_alarm, uv_tc_on_alarm, connect, grpc_schedule_on_exec_ctx); - grpc_timer_init(exec_ctx, &connect->alarm, - gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC), - &connect->on_alarm, gpr_now(GPR_CLOCK_MONOTONIC)); + grpc_timer_init(exec_ctx, &connect->alarm, deadline, &connect->on_alarm); } // overridden by api_fuzzer.c @@ -168,14 +166,14 @@ void (*grpc_tcp_client_connect_impl)( grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep, grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args, const grpc_resolved_address *addr, - gpr_timespec deadline) = tcp_client_connect_impl; + grpc_millis deadline) = tcp_client_connect_impl; void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep, grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args, const grpc_resolved_address *addr, - gpr_timespec deadline) { + grpc_millis deadline) { grpc_tcp_client_connect_impl(exec_ctx, closure, ep, interested_parties, channel_args, addr, deadline); } From b44a7bf8c3d8390c78c56b6aff7bd30a2da5289f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 3 Oct 2017 14:35:38 -0700 Subject: [PATCH 073/142] Revert deleted file --- test/core/util/one_corpus_entry_fuzzer.c | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/core/util/one_corpus_entry_fuzzer.c diff --git a/test/core/util/one_corpus_entry_fuzzer.c b/test/core/util/one_corpus_entry_fuzzer.c new file mode 100644 index 00000000000..42467390f2d --- /dev/null +++ b/test/core/util/one_corpus_entry_fuzzer.c @@ -0,0 +1,39 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include +#include "src/core/lib/iomgr/load_file.h" + +extern int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); + +extern bool squelch; +extern bool leak_check; + +int main(int argc, char **argv) { + grpc_slice buffer; + squelch = false; + leak_check = false; + GPR_ASSERT( + GRPC_LOG_IF_ERROR("load_file", grpc_load_file(argv[1], 0, &buffer))); + LLVMFuzzerTestOneInput(GRPC_SLICE_START_PTR(buffer), + GRPC_SLICE_LENGTH(buffer)); + grpc_slice_unref(buffer); + return 0; +} From 2b86ea6206e9ca71f59acff9752d28495be81126 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 3 Oct 2017 15:49:14 -0700 Subject: [PATCH 074/142] Fixes --- src/core/lib/iomgr/timer_uv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/timer_uv.c b/src/core/lib/iomgr/timer_uv.c index ebfd9647d7d..4839deca66a 100644 --- a/src/core/lib/iomgr/timer_uv.c +++ b/src/core/lib/iomgr/timer_uv.c @@ -64,7 +64,7 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer, return; } timer->pending = 1; - timeout = (uint64_t)(deadline - now); + timeout = (uint64_t)(deadline - grpc_exec_ctx_now(exec_ctx)); uv_timer = gpr_malloc(sizeof(uv_timer_t)); uv_timer_init(uv_default_loop(), uv_timer); uv_timer->data = timer; @@ -88,7 +88,7 @@ void grpc_timer_cancel(grpc_exec_ctx *exec_ctx, grpc_timer *timer) { } grpc_timer_check_result grpc_timer_check(grpc_exec_ctx *exec_ctx, - gpr_timespec now, gpr_timespec *next) { + grpc_millis *next) { return GRPC_TIMERS_NOT_CHECKED; } From d3568c0a206b6c4b7529176e181f04c6624b1295 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 3 Oct 2017 15:49:33 -0700 Subject: [PATCH 075/142] Fixes --- test/core/slice/BUILD | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/core/slice/BUILD b/test/core/slice/BUILD index f86a3a6082c..ad2308a4d69 100644 --- a/test/core/slice/BUILD +++ b/test/core/slice/BUILD @@ -20,11 +20,23 @@ licenses(["notice"]) # Apache v2 load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") +grpc_fuzzer( + name = "percent_encode_fuzzer", + srcs = ["percent_encode_fuzzer.c"], + language = "C", + corpus = "percent_encode_corpus", + deps = [ + "//:gpr", + "//:grpc", + "//test/core/util:grpc_test_util", + ], +) + grpc_fuzzer( name = "percent_decode_fuzzer", srcs = ["percent_decode_fuzzer.c"], language = "C", - corpus = "response_corpus", + corpus = "percent_decode_corpus", deps = [ "//:gpr", "//:grpc", From 53a64b993623873e4abf7c745d8514780e755328 Mon Sep 17 00:00:00 2001 From: yang-g Date: Wed, 4 Oct 2017 12:35:27 -0700 Subject: [PATCH 076/142] Properly clean up stress test clients --- test/cpp/interop/stress_test.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/cpp/interop/stress_test.cc b/test/cpp/interop/stress_test.cc index 9cc5a8168b3..c6d3600be85 100644 --- a/test/cpp/interop/stress_test.cc +++ b/test/cpp/interop/stress_test.cc @@ -257,6 +257,7 @@ int main(int argc, char** argv) { gpr_log(GPR_INFO, "Starting test(s).."); std::vector test_threads; + std::vector> clients; // Create and start the test threads. // Note that: @@ -282,9 +283,9 @@ int main(int argc, char** argv) { // Create stub(s) for each channel for (int stub_idx = 0; stub_idx < FLAGS_num_stubs_per_channel; stub_idx++) { - StressTestInteropClient* client = new StressTestInteropClient( + clients.emplace_back(new StressTestInteropClient( ++thread_idx, *it, channel, test_selector, FLAGS_test_duration_secs, - FLAGS_sleep_duration_ms, FLAGS_do_not_abort_on_transient_failures); + FLAGS_sleep_duration_ms, FLAGS_do_not_abort_on_transient_failures)); bool is_already_created = false; // QpsGauge name @@ -293,7 +294,7 @@ int main(int argc, char** argv) { server_idx, channel_idx, stub_idx); test_threads.emplace_back(std::thread( - &StressTestInteropClient::MainLoop, client, + &StressTestInteropClient::MainLoop, clients.back().get(), metrics_service.CreateQpsGauge(buffer, &is_already_created))); // The QpsGauge should not have been already created From ac3d765041e39d235ca82d82230a57a65c9c544e Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 5 Oct 2017 15:27:01 +0200 Subject: [PATCH 077/142] retry when uploading results to bigquery --- .../run_tests/python_utils/upload_test_results.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/run_tests/python_utils/upload_test_results.py b/tools/run_tests/python_utils/upload_test_results.py index 580e7f7d810..15e827769e1 100644 --- a/tools/run_tests/python_utils/upload_test_results.py +++ b/tools/run_tests/python_utils/upload_test_results.py @@ -102,6 +102,15 @@ def upload_results_to_bq(resultset, bq_table, args, platform): test_results['timestamp'] = time.strftime('%Y-%m-%d %H:%M:%S') row = big_query_utils.make_row(str(uuid.uuid4()), test_results) - if not big_query_utils.insert_rows(bq, _PROJECT_ID, _DATASET_ID, bq_table, [row]): - print('Error uploading result to bigquery.') - sys.exit(1) + + # TODO(jtattermusch): rows are inserted one by one, very inefficient + max_retries = 3 + for attempt in range(max_retries): + if big_query_utils.insert_rows(bq, _PROJECT_ID, _DATASET_ID, bq_table, [row]): + break + else: + if attempt < max_retries - 1: + print('Error uploading result to bigquery, will retry.') + else: + print('Error uploading result to bigquery, all attempts failed.') + sys.exit(1) From 8dbc2364b3b68bbf7e43eac3dea8e4d79e649d1d Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 5 Oct 2017 17:15:27 +0200 Subject: [PATCH 078/142] report elapsed time for jobs that time out --- tools/run_tests/python_utils/jobset.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/run_tests/python_utils/jobset.py b/tools/run_tests/python_utils/jobset.py index 82a3bc14352..d523095e703 100755 --- a/tools/run_tests/python_utils/jobset.py +++ b/tools/run_tests/python_utils/jobset.py @@ -306,8 +306,8 @@ class Job(object): else: self._state = _FAILURE if not self._suppress_failure_message: - message('FAILED', '%s [ret=%d, pid=%d]' % ( - self._spec.shortname, self._process.returncode, self._process.pid), + message('FAILED', '%s [ret=%d, pid=%d, time=%.1fsec]' % ( + self._spec.shortname, self._process.returncode, self._process.pid, elapsed), stdout(), do_newline=True) self.result.state = 'FAILED' self.result.num_failures += 1 @@ -326,7 +326,7 @@ class Job(object): self.result.cpu_estimated = float('%.01f' % self._spec.cpu_cost) measurement = '; cpu_cost=%.01f; estimated=%.01f' % (self.result.cpu_measured, self.result.cpu_estimated) if not self._quiet_success: - message('PASSED', '%s [time=%.1fsec; retries=%d:%d%s]' % ( + message('PASSED', '%s [time=%.1fsec, retries=%d:%d%s]' % ( self._spec.shortname, elapsed, self._retries, self._timeout_retries, measurement), stdout() if self._spec.verbose_success else None, do_newline=self._newline_on_success or self._travis) @@ -334,6 +334,8 @@ class Job(object): elif (self._state == _RUNNING and self._spec.timeout_seconds is not None and time.time() - self._start > self._spec.timeout_seconds): + elapsed = time.time() - self._start + self.result.elapsed_time = elapsed if self._timeout_retries < self._spec.timeout_retries: message('TIMEOUT_FLAKE', '%s [pid=%d]' % (self._spec.shortname, self._process.pid), stdout(), do_newline=True) self._timeout_retries += 1 @@ -344,7 +346,7 @@ class Job(object): self._process.terminate() self.start() else: - message('TIMEOUT', '%s [pid=%d]' % (self._spec.shortname, self._process.pid), stdout(), do_newline=True) + message('TIMEOUT', '%s [pid=%d, time=%.1fsec]' % (self._spec.shortname, self._process.pid, elapsed), stdout(), do_newline=True) self.kill() self.result.state = 'TIMEOUT' self.result.num_failures += 1 From 8c12d9eae6ed064a80b85bd3867d4f7eec2ed642 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 5 Oct 2017 08:47:39 -0700 Subject: [PATCH 079/142] Add a test under ruby GC stress mode and fix non-GC-rooted variable bug --- .../load_grpc_with_gc_stress_driver.rb | 32 +++++++++++++++++++ src/ruby/ext/grpc/rb_grpc.c | 2 +- .../helper_scripts/run_ruby_end2end_tests.sh | 1 + 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100755 src/ruby/end2end/load_grpc_with_gc_stress_driver.rb diff --git a/src/ruby/end2end/load_grpc_with_gc_stress_driver.rb b/src/ruby/end2end/load_grpc_with_gc_stress_driver.rb new file mode 100755 index 00000000000..3668b95a052 --- /dev/null +++ b/src/ruby/end2end/load_grpc_with_gc_stress_driver.rb @@ -0,0 +1,32 @@ +#!/usr/bin/env ruby +# +# Copyright 2016 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +this_dir = File.expand_path(File.dirname(__FILE__)) +protos_lib_dir = File.join(this_dir, 'lib') +grpc_lib_dir = File.join(File.dirname(this_dir), 'lib') +$LOAD_PATH.unshift(grpc_lib_dir) unless $LOAD_PATH.include?(grpc_lib_dir) +$LOAD_PATH.unshift(protos_lib_dir) unless $LOAD_PATH.include?(protos_lib_dir) +$LOAD_PATH.unshift(this_dir) unless $LOAD_PATH.include?(this_dir) + +GC.stress = 0x04 + +require 'grpc' + +GRPC::Core::Channel.new('dummy_host', nil, :this_channel_is_insecure) +GRPC::Core::Server.new({}) +GRPC::Core::ChannelCredentials.new +GRPC::Core::CallCredentials.new(proc { |noop| noop }) +GRPC::Core::CompressionOptions.new diff --git a/src/ruby/ext/grpc/rb_grpc.c b/src/ruby/ext/grpc/rb_grpc.c index 933a3ac1525..b53f09edec4 100644 --- a/src/ruby/ext/grpc/rb_grpc.c +++ b/src/ruby/ext/grpc/rb_grpc.c @@ -315,8 +315,8 @@ void Init_grpc_c() { return; } - bg_thread_init_rb_mu = rb_mutex_new(); rb_global_variable(&bg_thread_init_rb_mu); + bg_thread_init_rb_mu = rb_mutex_new(); grpc_rb_mGRPC = rb_define_module("GRPC"); grpc_rb_mGrpcCore = rb_define_module_under(grpc_rb_mGRPC, "Core"); diff --git a/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh b/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh index 7914b0e29a0..5cfab14fee5 100755 --- a/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh +++ b/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh @@ -27,4 +27,5 @@ ruby src/ruby/end2end/killed_client_thread_driver.rb || EXIT_CODE=1 ruby src/ruby/end2end/forking_client_driver.rb || EXIT_CODE=1 ruby src/ruby/end2end/grpc_class_init_driver.rb || EXIT_CODE=1 ruby src/ruby/end2end/multiple_killed_watching_threads_driver.rb || EXIT_CODE=1 +ruby src/ruby/end2end/load_grpc_with_gc_stress_driver.rb || EXIT_CODE=1 exit $EXIT_CODE From e1a2b4ad59892daf7c84d9118a133724ccb034ad Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 5 Oct 2017 11:07:14 -0700 Subject: [PATCH 080/142] Fix merge --- BUILD | 184 +--------------------------------------------------------- 1 file changed, 1 insertion(+), 183 deletions(-) diff --git a/BUILD b/BUILD index 48b8aa9c83f..eaf369dce62 100644 --- a/BUILD +++ b/BUILD @@ -461,60 +461,12 @@ grpc_cc_library( grpc_cc_library( name = "gpr_base", srcs = [ -<<<<<<< HEAD - "src/core/lib/profiling/basic_timers.c", - "src/core/lib/profiling/stap_timers.c", - "src/core/lib/support/alloc.c", - "src/core/lib/support/arena.c", - "src/core/lib/support/atm.c", - "src/core/lib/support/avl.c", - "src/core/lib/support/cmdline.c", - "src/core/lib/support/cpu_iphone.c", - "src/core/lib/support/cpu_linux.c", - "src/core/lib/support/cpu_posix.c", - "src/core/lib/support/cpu_windows.c", - "src/core/lib/support/env_linux.c", - "src/core/lib/support/env_posix.c", - "src/core/lib/support/env_windows.c", - "src/core/lib/support/histogram.c", - "src/core/lib/support/host_port.c", - "src/core/lib/support/log.c", - "src/core/lib/support/log_android.c", - "src/core/lib/support/log_linux.c", - "src/core/lib/support/log_posix.c", - "src/core/lib/support/log_windows.c", - "src/core/lib/support/mpscq.c", - "src/core/lib/support/murmur_hash.c", - "src/core/lib/support/stack_lockfree.c", - "src/core/lib/support/string.c", - "src/core/lib/support/string_posix.c", - "src/core/lib/support/string_util_windows.c", - "src/core/lib/support/string_windows.c", - "src/core/lib/support/subprocess_posix.c", - "src/core/lib/support/subprocess_windows.c", - "src/core/lib/support/sync.c", - "src/core/lib/support/sync_posix.c", - "src/core/lib/support/sync_windows.c", - "src/core/lib/support/thd.c", - "src/core/lib/support/thd_posix.c", - "src/core/lib/support/thd_windows.c", - "src/core/lib/support/time.c", - "src/core/lib/support/time_posix.c", - "src/core/lib/support/time_precise.c", - "src/core/lib/support/time_windows.c", - "src/core/lib/support/tls_pthread.c", - "src/core/lib/support/tmpfile_msys.c", - "src/core/lib/support/tmpfile_posix.c", - "src/core/lib/support/tmpfile_windows.c", - "src/core/lib/support/wrap_memcpy.c", -======= "src/core/lib/profiling/basic_timers.cc", "src/core/lib/profiling/stap_timers.cc", "src/core/lib/support/alloc.cc", "src/core/lib/support/arena.cc", "src/core/lib/support/atm.cc", "src/core/lib/support/avl.cc", - "src/core/lib/support/backoff.cc", "src/core/lib/support/cmdline.cc", "src/core/lib/support/cpu_iphone.cc", "src/core/lib/support/cpu_linux.cc", @@ -554,7 +506,6 @@ grpc_cc_library( "src/core/lib/support/tmpfile_posix.cc", "src/core/lib/support/tmpfile_windows.cc", "src/core/lib/support/wrap_memcpy.cc", ->>>>>>> c277fc0818eb2e7408db6758c9690bb4eb2c6ff7 ], hdrs = [ "src/core/lib/profiling/timers.h", @@ -615,139 +566,7 @@ grpc_cc_library( grpc_cc_library( name = "grpc_base_c", srcs = [ -<<<<<<< HEAD - "src/core/lib/channel/channel_args.c", - "src/core/lib/channel/channel_stack.c", - "src/core/lib/channel/channel_stack_builder.c", - "src/core/lib/channel/connected_channel.c", - "src/core/lib/channel/handshaker.c", - "src/core/lib/channel/handshaker_factory.c", - "src/core/lib/channel/handshaker_registry.c", - "src/core/lib/compression/compression.c", - "src/core/lib/compression/message_compress.c", - "src/core/lib/compression/stream_compression.c", - "src/core/lib/compression/stream_compression_gzip.c", - "src/core/lib/compression/stream_compression_identity.c", - "src/core/lib/debug/stats.c", - "src/core/lib/debug/stats_data.c", - "src/core/lib/http/format_request.c", - "src/core/lib/http/httpcli.c", - "src/core/lib/http/parser.c", - "src/core/lib/iomgr/call_combiner.c", - "src/core/lib/iomgr/closure.c", - "src/core/lib/iomgr/combiner.c", - "src/core/lib/iomgr/endpoint.c", - "src/core/lib/iomgr/endpoint_pair_posix.c", - "src/core/lib/iomgr/endpoint_pair_uv.c", - "src/core/lib/iomgr/endpoint_pair_windows.c", - "src/core/lib/iomgr/error.c", - "src/core/lib/iomgr/ev_epoll1_linux.c", - "src/core/lib/iomgr/ev_epollex_linux.c", - "src/core/lib/iomgr/ev_epollsig_linux.c", - "src/core/lib/iomgr/ev_poll_posix.c", - "src/core/lib/iomgr/ev_posix.c", - "src/core/lib/iomgr/ev_windows.c", - "src/core/lib/iomgr/exec_ctx.c", - "src/core/lib/iomgr/executor.c", - "src/core/lib/iomgr/gethostname_fallback.c", - "src/core/lib/iomgr/gethostname_host_name_max.c", - "src/core/lib/iomgr/gethostname_sysconf.c", - "src/core/lib/iomgr/iocp_windows.c", - "src/core/lib/iomgr/iomgr.c", - "src/core/lib/iomgr/iomgr_posix.c", - "src/core/lib/iomgr/iomgr_uv.c", - "src/core/lib/iomgr/iomgr_windows.c", - "src/core/lib/iomgr/is_epollexclusive_available.c", - "src/core/lib/iomgr/load_file.c", - "src/core/lib/iomgr/lockfree_event.c", - "src/core/lib/iomgr/network_status_tracker.c", - "src/core/lib/iomgr/polling_entity.c", - "src/core/lib/iomgr/pollset_set_uv.c", - "src/core/lib/iomgr/pollset_set_windows.c", - "src/core/lib/iomgr/pollset_uv.c", - "src/core/lib/iomgr/pollset_windows.c", - "src/core/lib/iomgr/resolve_address_posix.c", - "src/core/lib/iomgr/resolve_address_uv.c", - "src/core/lib/iomgr/resolve_address_windows.c", - "src/core/lib/iomgr/resource_quota.c", - "src/core/lib/iomgr/sockaddr_utils.c", - "src/core/lib/iomgr/socket_factory_posix.c", - "src/core/lib/iomgr/socket_mutator.c", - "src/core/lib/iomgr/socket_utils_common_posix.c", - "src/core/lib/iomgr/socket_utils_linux.c", - "src/core/lib/iomgr/socket_utils_posix.c", - "src/core/lib/iomgr/socket_utils_uv.c", - "src/core/lib/iomgr/socket_utils_windows.c", - "src/core/lib/iomgr/socket_windows.c", - "src/core/lib/iomgr/tcp_client_posix.c", - "src/core/lib/iomgr/tcp_client_uv.c", - "src/core/lib/iomgr/tcp_client_windows.c", - "src/core/lib/iomgr/tcp_posix.c", - "src/core/lib/iomgr/tcp_server_posix.c", - "src/core/lib/iomgr/tcp_server_utils_posix_common.c", - "src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c", - "src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c", - "src/core/lib/iomgr/tcp_server_uv.c", - "src/core/lib/iomgr/tcp_server_windows.c", - "src/core/lib/iomgr/tcp_uv.c", - "src/core/lib/iomgr/tcp_windows.c", - "src/core/lib/iomgr/time_averaged_stats.c", - "src/core/lib/iomgr/timer_generic.c", - "src/core/lib/iomgr/timer_heap.c", - "src/core/lib/iomgr/timer_manager.c", - "src/core/lib/iomgr/timer_uv.c", - "src/core/lib/iomgr/udp_server.c", - "src/core/lib/iomgr/unix_sockets_posix.c", - "src/core/lib/iomgr/unix_sockets_posix_noop.c", - "src/core/lib/iomgr/wakeup_fd_cv.c", - "src/core/lib/iomgr/wakeup_fd_eventfd.c", - "src/core/lib/iomgr/wakeup_fd_nospecial.c", - "src/core/lib/iomgr/wakeup_fd_pipe.c", - "src/core/lib/iomgr/wakeup_fd_posix.c", - "src/core/lib/json/json.c", - "src/core/lib/json/json_reader.c", - "src/core/lib/json/json_string.c", - "src/core/lib/json/json_writer.c", - "src/core/lib/slice/b64.c", - "src/core/lib/slice/percent_encoding.c", - "src/core/lib/slice/slice.c", - "src/core/lib/slice/slice_buffer.c", - "src/core/lib/slice/slice_hash_table.c", - "src/core/lib/slice/slice_intern.c", - "src/core/lib/slice/slice_string_helpers.c", - "src/core/lib/surface/alarm.c", - "src/core/lib/surface/api_trace.c", - "src/core/lib/surface/byte_buffer.c", - "src/core/lib/surface/byte_buffer_reader.c", - "src/core/lib/surface/call.c", - "src/core/lib/surface/call_details.c", - "src/core/lib/surface/call_log_batch.c", - "src/core/lib/surface/channel.c", - "src/core/lib/surface/channel_init.c", - "src/core/lib/surface/channel_ping.c", - "src/core/lib/surface/channel_stack_type.c", - "src/core/lib/surface/completion_queue.c", - "src/core/lib/surface/completion_queue_factory.c", - "src/core/lib/surface/event_string.c", - "src/core/lib/surface/metadata_array.c", - "src/core/lib/surface/server.c", - "src/core/lib/surface/validate_metadata.c", - "src/core/lib/surface/version.c", - "src/core/lib/transport/bdp_estimator.c", - "src/core/lib/transport/byte_stream.c", - "src/core/lib/transport/connectivity_state.c", - "src/core/lib/transport/error_utils.c", - "src/core/lib/transport/metadata.c", - "src/core/lib/transport/metadata_batch.c", - "src/core/lib/transport/pid_controller.c", - "src/core/lib/transport/service_config.c", - "src/core/lib/transport/static_metadata.c", - "src/core/lib/transport/status_conversion.c", - "src/core/lib/transport/timeout_encoding.c", - "src/core/lib/transport/transport.c", - "src/core/lib/transport/transport_op_string.c", - "src/core/lib/backoff/backoff.c", -======= + "src/core/lib/backoff/backoff.cc", "src/core/lib/channel/channel_args.cc", "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", @@ -878,7 +697,6 @@ grpc_cc_library( "src/core/lib/transport/timeout_encoding.cc", "src/core/lib/transport/transport.cc", "src/core/lib/transport/transport_op_string.cc", ->>>>>>> c277fc0818eb2e7408db6758c9690bb4eb2c6ff7 ], hdrs = [ "src/core/lib/channel/channel_args.h", From 50f473e2ffed9cbe8ee3ad5e5a9b345990b8c618 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 5 Oct 2017 11:17:15 -0700 Subject: [PATCH 081/142] Fix merge --- BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD b/BUILD index eaf369dce62..8ccc7480397 100644 --- a/BUILD +++ b/BUILD @@ -513,7 +513,6 @@ grpc_cc_library( "src/core/lib/support/atomic.h", "src/core/lib/support/atomic_with_atm.h", "src/core/lib/support/atomic_with_std.h", - "src/core/lib/iomgr/block_annotate.h", "src/core/lib/support/env.h", "src/core/lib/support/memory.h", "src/core/lib/support/mpscq.h", @@ -761,6 +760,7 @@ grpc_cc_library( "src/core/lib/iomgr/socket_utils_posix.h", "src/core/lib/iomgr/socket_windows.h", "src/core/lib/iomgr/sys_epoll_wrapper.h", + "src/core/lib/iomgr/block_annotate.h", "src/core/lib/iomgr/tcp_client.h", "src/core/lib/iomgr/tcp_client_posix.h", "src/core/lib/iomgr/tcp_posix.h", From 1cd67ebb2d3ad00ecb4bffb3ec4d764eb3f069d9 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 5 Oct 2017 11:30:39 -0700 Subject: [PATCH 082/142] Add test for forward declaration --- src/objective-c/tests/RemoteTestClient/RemoteTest.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec index 1796c6d7462..ad834815951 100644 --- a/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec +++ b/src/objective-c/tests/RemoteTestClient/RemoteTest.podspec @@ -47,7 +47,7 @@ Pod::Spec.new do |s| s.pod_target_xcconfig = { # This is needed by all pods that depend on Protobuf: - 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1', + 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1 GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO=1', # This is needed by all pods that depend on gRPC-RxLibrary: 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES', } From 663f50c658b6f13dedac5541f8a0789257225a69 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Thu, 5 Oct 2017 14:36:13 -0700 Subject: [PATCH 083/142] Cancel fallback timer in glb_shutdown() --- .../ext/filters/client_channel/lb_policy/grpclb/grpclb.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index d8e314d1f9a..773ae29e410 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -1010,6 +1010,10 @@ static void glb_shutdown_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) { grpc_timer_cancel(exec_ctx, &glb_policy->lb_call_retry_timer); glb_policy->retry_timer_active = false; } + if (glb_policy->fallback_timer_active) { + grpc_timer_cancel(exec_ctx, &glb_policy->lb_fallback_timer); + glb_policy->fallback_timer_active = false; + } pending_pick *pp = glb_policy->pending_picks; glb_policy->pending_picks = NULL; From c4afc644f736d3fd070716579f41baa2de19dfc2 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 5 Oct 2017 14:40:34 -0700 Subject: [PATCH 084/142] Reduce # of message sizes used in each scenario --- test/cpp/end2end/async_end2end_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 41090d161aa..3adb0c5a175 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -1788,7 +1788,7 @@ std::vector CreateTestScenarios(bool test_disable_blocking, GPR_ASSERT(!credentials_types.empty()); messages.push_back("Hello"); - for (int sz = 1; sz < test_big_limit; sz *= 2) { + for (int sz = 1; sz <= test_big_limit; sz *= 32) { grpc::string big_msg; for (int i = 0; i < sz * 1024; i++) { char c = 'a' + (i % 26); From 541974a70927d60aa166d4ca98475f0d4e2e6d96 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 5 Oct 2017 15:12:13 -0700 Subject: [PATCH 085/142] Eliminate magic #s, follow API --- test/cpp/end2end/async_end2end_test.cc | 85 +++++++------------------- 1 file changed, 21 insertions(+), 64 deletions(-) diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 41090d161aa..93d973dc7dd 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -537,33 +537,18 @@ TEST_P(AsyncEnd2endTest, SimpleClientStreamingWithCoalescingApi) { service_->RequestRequestStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(), tag(2)); + auto verif = Verifier(GetParam().disable_blocking); + verif.Expect(2, true); + cli_stream->Write(send_request, tag(3)); + verif.Expect(3, true); - // 65536(64KB) is the default flow control window size. Should change this - // number when default flow control window size changes. For the write of - // send_request larger than the flow control window size, tag:3 will not come - // up until server read is initiated. For write of send_request smaller than - // the flow control window size, the request can take the free ride with - // initial metadata due to coalescing, thus write tag:3 will come up here. - if (GetParam().message_content.length() < 65536 || GetParam().inproc) { - Verifier(GetParam().disable_blocking) - .Expect(2, true) - .Expect(3, true) - .Verify(cq_.get()); - } else { - Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get()); + // Drain tag 2, optional to get tag 3 now + while (verif.Next(cq_.get(), false) != 2) { } srv_stream.Read(&recv_request, tag(4)); - - if (GetParam().message_content.length() < 65536 || GetParam().inproc) { - Verifier(GetParam().disable_blocking).Expect(4, true).Verify(cq_.get()); - } else { - Verifier(GetParam().disable_blocking) - .Expect(3, true) - .Expect(4, true) - .Verify(cq_.get()); - } + verif.Expect(4, true).Verify(cq_.get()); EXPECT_EQ(send_request.message(), recv_request.message()); @@ -832,33 +817,19 @@ TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWAF) { service_->RequestBidiStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(), tag(2)); + auto verif = Verifier(GetParam().disable_blocking); + verif.Expect(2, true); + cli_stream->WriteLast(send_request, WriteOptions(), tag(3)); + verif.Expect(3, true); - // 65536(64KB) is the default flow control window size. Should change this - // number when default flow control window size changes. For the write of - // send_request larger than the flow control window size, tag:3 will not come - // up until server read is initiated. For write of send_request smaller than - // the flow control window size, the request can take the free ride with - // initial metadata due to coalescing, thus write tag:3 will come up here. - if (GetParam().message_content.length() < 65536 || GetParam().inproc) { - Verifier(GetParam().disable_blocking) - .Expect(2, true) - .Expect(3, true) - .Verify(cq_.get()); - } else { - Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get()); + // Drain tag 2, optional to get tag 3 now + while (verif.Next(cq_.get(), false) != 2) { } srv_stream.Read(&recv_request, tag(4)); + verif.Expect(4, true).Verify(cq_.get()); - if (GetParam().message_content.length() < 65536 || GetParam().inproc) { - Verifier(GetParam().disable_blocking).Expect(4, true).Verify(cq_.get()); - } else { - Verifier(GetParam().disable_blocking) - .Expect(3, true) - .Expect(4, true) - .Verify(cq_.get()); - } EXPECT_EQ(send_request.message(), recv_request.message()); srv_stream.Read(&recv_request, tag(5)); @@ -900,33 +871,19 @@ TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWL) { service_->RequestBidiStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(), tag(2)); + auto verif = Verifier(GetParam().disable_blocking); + verif.Expect(2, true); + cli_stream->WriteLast(send_request, WriteOptions(), tag(3)); + verif.Expect(3, true); - // 65536(64KB) is the default flow control window size. Should change this - // number when default flow control window size changes. For the write of - // send_request larger than the flow control window size, tag:3 will not come - // up until server read is initiated. For write of send_request smaller than - // the flow control window size, the request can take the free ride with - // initial metadata due to coalescing, thus write tag:3 will come up here. - if (GetParam().message_content.length() < 65536 || GetParam().inproc) { - Verifier(GetParam().disable_blocking) - .Expect(2, true) - .Expect(3, true) - .Verify(cq_.get()); - } else { - Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get()); + // Drain tag 2, optional to get tag 3 now + while (verif.Next(cq_.get(), false) != 2) { } srv_stream.Read(&recv_request, tag(4)); + verif.Expect(4, true).Verify(cq_.get()); - if (GetParam().message_content.length() < 65536 || GetParam().inproc) { - Verifier(GetParam().disable_blocking).Expect(4, true).Verify(cq_.get()); - } else { - Verifier(GetParam().disable_blocking) - .Expect(3, true) - .Expect(4, true) - .Verify(cq_.get()); - } EXPECT_EQ(send_request.message(), recv_request.message()); srv_stream.Read(&recv_request, tag(5)); From f063f7951f9bc19f2a1667281fe8c15943a546e4 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 5 Oct 2017 15:41:40 -0700 Subject: [PATCH 086/142] Add some const that is now allowed --- test/cpp/end2end/async_end2end_test.cc | 7 ++----- test/cpp/end2end/end2end_test.cc | 5 +---- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 41090d161aa..e9a1eebe642 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -223,11 +223,8 @@ class TestScenario { bool disable_blocking; bool inproc; bool health_check_service; - // Although the below grpc::string's are logically const, we can't declare - // them const because of a limitation in the way old compilers (e.g., gcc-4.4) - // manage vector insertion using a copy constructor - grpc::string credentials_type; - grpc::string message_content; + const grpc::string credentials_type; + const grpc::string message_content; }; static std::ostream& operator<<(std::ostream& out, diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 5dae5b014bd..810ee303f2c 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -198,10 +198,7 @@ class TestScenario { void Log() const; bool use_proxy; bool inproc; - // Although the below grpc::string is logically const, we can't declare - // them const because of a limitation in the way old compilers (e.g., gcc-4.4) - // manage vector insertion using a copy constructor - grpc::string credentials_type; + const grpc::string credentials_type; }; static std::ostream& operator<<(std::ostream& out, From 40928b6173453c301199e1c217836412604ef03a Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 5 Oct 2017 16:08:52 -0700 Subject: [PATCH 087/142] Cleanup write path, fix some bugs --- .../ext/transport/chttp2/transport/internal.h | 4 +- .../ext/transport/chttp2/transport/writing.cc | 691 ++++++++++-------- 2 files changed, 404 insertions(+), 291 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 96af18f1d18..b6afd90427d 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -661,8 +661,8 @@ bool grpc_chttp2_list_add_writable_stream(grpc_chttp2_transport *t, returns non-zero if there was a stream available */ bool grpc_chttp2_list_pop_writable_stream(grpc_chttp2_transport *t, grpc_chttp2_stream **s); -bool grpc_chttp2_list_remove_writable_stream( - grpc_chttp2_transport *t, grpc_chttp2_stream *s) GRPC_MUST_USE_RESULT; +bool grpc_chttp2_list_remove_writable_stream(grpc_chttp2_transport *t, + grpc_chttp2_stream *s); bool grpc_chttp2_list_add_writing_stream(grpc_chttp2_transport *t, grpc_chttp2_stream *s); diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc index ba3d55abb3c..25d61dcc7a8 100644 --- a/src/core/ext/transport/chttp2/transport/writing.cc +++ b/src/core/ext/transport/chttp2/transport/writing.cc @@ -175,342 +175,455 @@ static bool is_default_initial_metadata(grpc_metadata_batch *initial_metadata) { return initial_metadata->list.default_count == initial_metadata->list.count; } -grpc_chttp2_begin_write_result grpc_chttp2_begin_write( - grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t) { - grpc_chttp2_stream *s; +namespace { +class StreamWriteContext; + +class WriteContext { + public: + WriteContext(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t) : t_(t) { + GRPC_STATS_INC_HTTP2_WRITES_BEGUN(exec_ctx); + GPR_TIMER_BEGIN("grpc_chttp2_begin_write", 0); + } - /* stats histogram counters: we increment these throughout this function, - and at the end publish to the central stats histograms */ - int flow_control_writes = 0; - int initial_metadata_writes = 0; - int trailing_metadata_writes = 0; - int message_writes = 0; + // TODO(ctiller): make this the destructor + void FlushStats(grpc_exec_ctx *exec_ctx) { + GRPC_STATS_INC_HTTP2_SEND_INITIAL_METADATA_PER_WRITE( + exec_ctx, initial_metadata_writes_); + GRPC_STATS_INC_HTTP2_SEND_MESSAGE_PER_WRITE(exec_ctx, message_writes_); + GRPC_STATS_INC_HTTP2_SEND_TRAILING_METADATA_PER_WRITE( + exec_ctx, trailing_metadata_writes_); + GRPC_STATS_INC_HTTP2_SEND_FLOWCTL_PER_WRITE(exec_ctx, flow_control_writes_); + } - GRPC_STATS_INC_HTTP2_WRITES_BEGUN(exec_ctx); + void FlushSettings(grpc_exec_ctx *exec_ctx) { + if (t_->dirtied_local_settings && !t_->sent_local_settings) { + grpc_slice_buffer_add( + &t_->outbuf, grpc_chttp2_settings_create( + t_->settings[GRPC_SENT_SETTINGS], + t_->settings[GRPC_LOCAL_SETTINGS], + t_->force_send_settings, GRPC_CHTTP2_NUM_SETTINGS)); + t_->force_send_settings = false; + t_->dirtied_local_settings = false; + t_->sent_local_settings = true; + GRPC_STATS_INC_HTTP2_SETTINGS_WRITES(exec_ctx); + } + } - GPR_TIMER_BEGIN("grpc_chttp2_begin_write", 0); + void FlushQueuedBuffers(grpc_exec_ctx *exec_ctx) { + /* simple writes are queued to qbuf, and flushed here */ + grpc_slice_buffer_move_into(&t_->qbuf, &t_->outbuf); + GPR_ASSERT(t_->qbuf.count == 0); + } - if (t->dirtied_local_settings && !t->sent_local_settings) { - grpc_slice_buffer_add( - &t->outbuf, - grpc_chttp2_settings_create( - t->settings[GRPC_SENT_SETTINGS], t->settings[GRPC_LOCAL_SETTINGS], - t->force_send_settings, GRPC_CHTTP2_NUM_SETTINGS)); - t->force_send_settings = 0; - t->dirtied_local_settings = 0; - t->sent_local_settings = 1; - GRPC_STATS_INC_HTTP2_SETTINGS_WRITES(exec_ctx); + void FlushWindowUpdates(grpc_exec_ctx *exec_ctx) { + uint32_t transport_announce = + grpc_chttp2_flowctl_maybe_send_transport_update(&t_->flow_control); + if (transport_announce) { + maybe_initiate_ping(exec_ctx, t_, + GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE); + grpc_transport_one_way_stats throwaway_stats; + grpc_slice_buffer_add( + &t_->outbuf, grpc_chttp2_window_update_create(0, transport_announce, + &throwaway_stats)); + ResetPingRecvClock(); + } } - /* simple writes are queued to qbuf, and flushed here */ - grpc_slice_buffer_move_into(&t->qbuf, &t->outbuf); - GPR_ASSERT(t->qbuf.count == 0); + void FlushPingAcks() { + for (size_t i = 0; i < t_->ping_ack_count; i++) { + grpc_slice_buffer_add(&t_->outbuf, + grpc_chttp2_ping_create(true, t_->ping_acks[i])); + } + t_->ping_ack_count = 0; + } - grpc_chttp2_hpack_compressor_set_max_table_size( - &t->hpack_compressor, - t->settings[GRPC_PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_HEADER_TABLE_SIZE]); + void EnactHpackSettings(grpc_exec_ctx *exec_ctx) { + grpc_chttp2_hpack_compressor_set_max_table_size( + &t_->hpack_compressor, + t_->settings[GRPC_PEER_SETTINGS] + [GRPC_CHTTP2_SETTINGS_HEADER_TABLE_SIZE]); + } - if (t->flow_control.remote_window > 0) { - while (grpc_chttp2_list_pop_stalled_by_transport(t, &s)) { - if (!t->closed && grpc_chttp2_list_add_writable_stream(t, s)) { - stream_ref_if_not_destroyed(&s->refcount->refs); + void UpdateStreamsNoLongerStalled() { + grpc_chttp2_stream *s; + while (grpc_chttp2_list_pop_stalled_by_transport(t_, &s)) { + if (!t_->closed && grpc_chttp2_list_add_writable_stream(t_, s)) { + if (!stream_ref_if_not_destroyed(&s->refcount->refs)) { + grpc_chttp2_list_remove_writable_stream(t_, s); + } } } } - grpc_chttp2_begin_write_result result = {false, false, false}; + grpc_chttp2_stream *NextStream() { + if (t_->outbuf.length > target_write_size(t_)) { + result_.partial = true; + return nullptr; + } - /* for each grpc_chttp2_stream that's become writable, frame it's data - (according to available window sizes) and add to the output buffer */ - while (true) { - if (t->outbuf.length > target_write_size(t)) { - result.partial = true; - break; + grpc_chttp2_stream *s; + if (!grpc_chttp2_list_pop_writable_stream(t_, &s)) { + return nullptr; } - if (!grpc_chttp2_list_pop_writable_stream(t, &s)) { - break; + return s; + } + + void ResetPingRecvClock() { + if (!t_->is_client) { + t_->ping_recv_state.last_ping_recv_time = + gpr_inf_past(GPR_CLOCK_MONOTONIC); + t_->ping_recv_state.ping_strikes = 0; + } + } + + void IncInitialMetadataWrites() { ++initial_metadata_writes_; } + void IncWindowUpdateWrites() { ++flow_control_writes_; } + void IncMessageWrites() { ++message_writes_; } + void IncTrailingMetadataWrites() { ++trailing_metadata_writes_; } + + void NoteScheduledResults() { result_.early_results_scheduled = true; } + + grpc_chttp2_transport *transport() const { return t_; } + + grpc_chttp2_begin_write_result Result() { + result_.writing = t_->outbuf.count > 0; + return result_; + } + + private: + grpc_chttp2_transport *const t_; + + /* stats histogram counters: we increment these throughout this function, + and at the end publish to the central stats histograms */ + int flow_control_writes_ = 0; + int initial_metadata_writes_ = 0; + int trailing_metadata_writes_ = 0; + int message_writes_ = 0; + grpc_chttp2_begin_write_result result_ = {false, false, false}; +}; + +class DataSendContext { + public: + DataSendContext(WriteContext *write_context, grpc_chttp2_transport *t, + grpc_chttp2_stream *s) + : write_context_(write_context), + t_(t), + s_(s), + sending_bytes_before_(s_->sending_bytes) {} + + uint32_t stream_remote_window() const { + return (uint32_t)GPR_MAX( + 0, s_->flow_control.remote_window_delta + + (int64_t)t_->settings[GRPC_PEER_SETTINGS] + [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]); + } + + uint32_t max_outgoing() const { + return (uint32_t)GPR_MIN( + t_->settings[GRPC_PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], + GPR_MIN(stream_remote_window(), t_->flow_control.remote_window)); + } + + bool AnyOutgoing() const { return max_outgoing() != 0; } + + void FlushCompressedBytes() { + uint32_t send_bytes = + (uint32_t)GPR_MIN(max_outgoing(), s_->compressed_data_buffer.length); + bool is_last_data_frame = + (send_bytes == s_->compressed_data_buffer.length && + s_->flow_controlled_buffer.length == 0 && + s_->fetching_send_message == NULL); + if (is_last_data_frame && s_->send_trailing_metadata != NULL && + s_->stream_compression_ctx != NULL) { + if (!grpc_stream_compress(s_->stream_compression_ctx, + &s_->flow_controlled_buffer, + &s_->compressed_data_buffer, NULL, MAX_SIZE_T, + GRPC_STREAM_COMPRESSION_FLUSH_FINISH)) { + gpr_log(GPR_ERROR, "Stream compression failed."); + } + grpc_stream_compression_context_destroy(s_->stream_compression_ctx); + s_->stream_compression_ctx = NULL; + /* After finish, bytes in s->compressed_data_buffer may be + * more than max_outgoing. Start another round of the current + * while loop so that send_bytes and is_last_data_frame are + * recalculated. */ + return; } + is_last_frame_ = is_last_data_frame && s_->send_trailing_metadata != NULL && + grpc_metadata_batch_is_empty(s_->send_trailing_metadata); + grpc_chttp2_encode_data(s_->id, &s_->compressed_data_buffer, send_bytes, + is_last_frame_, &s_->stats.outgoing, &t_->outbuf); + grpc_chttp2_flowctl_sent_data(&t_->flow_control, &s_->flow_control, + send_bytes); + if (s_->compressed_data_buffer.length == 0) { + s_->sending_bytes += s_->uncompressed_data_size; + } + } + + void CompressMoreBytes() { + if (s_->stream_compression_ctx == NULL) { + s_->stream_compression_ctx = + grpc_stream_compression_context_create(s_->stream_compression_method); + } + s_->uncompressed_data_size = s_->flow_controlled_buffer.length; + if (!grpc_stream_compress(s_->stream_compression_ctx, + &s_->flow_controlled_buffer, + &s_->compressed_data_buffer, NULL, MAX_SIZE_T, + GRPC_STREAM_COMPRESSION_FLUSH_SYNC)) { + gpr_log(GPR_ERROR, "Stream compression failed."); + } + } + + bool WasLastFrame() const { return is_last_frame_; } - bool sent_initial_metadata = s->sent_initial_metadata; - bool now_writing = false; + void CallCallbacks(grpc_exec_ctx *exec_ctx) { + if (update_list(exec_ctx, t_, s_, + (int64_t)(s_->sending_bytes - sending_bytes_before_), + &s_->on_flow_controlled_cbs, + &s_->flow_controlled_bytes_flowed, GRPC_ERROR_NONE)) { + write_context_->NoteScheduledResults(); + } + } + private: + WriteContext *write_context_; + grpc_chttp2_transport *t_; + grpc_chttp2_stream *s_; + const size_t sending_bytes_before_; + bool is_last_frame_ = false; +}; + +class StreamWriteContext { + public: + StreamWriteContext(WriteContext *write_context, grpc_chttp2_stream *s) + : write_context_(write_context), + t_(write_context->transport()), + s_(s), + sent_initial_metadata_(s->sent_initial_metadata) { GRPC_CHTTP2_IF_TRACING( - gpr_log(GPR_DEBUG, "W:%p %s[%d] im-(sent,send)=(%d,%d) announce=%d", t, - t->is_client ? "CLIENT" : "SERVER", s->id, - sent_initial_metadata, s->send_initial_metadata != NULL, + gpr_log(GPR_DEBUG, "W:%p %s[%d] im-(sent,send)=(%d,%d) announce=%d", t_, + t_->is_client ? "CLIENT" : "SERVER", s->id, + sent_initial_metadata_, s->send_initial_metadata != NULL, (int)(s->flow_control.local_window_delta - s->flow_control.announced_window_delta))); + } - grpc_mdelem *extra_headers_for_trailing_metadata[2]; - size_t num_extra_headers_for_trailing_metadata = 0; - + void FlushInitialMetadata(grpc_exec_ctx *exec_ctx) { /* send initial metadata if it's available */ - if (!sent_initial_metadata && s->send_initial_metadata != NULL) { - // We skip this on the server side if there is no custom initial - // metadata, there are no messages to send, and we are also sending - // trailing metadata. This results in a Trailers-Only response, - // which is required for retries, as per: - // https://github.com/grpc/proposal/blob/master/A6-client-retries.md#when-retries-are-valid - if (t->is_client || s->fetching_send_message != NULL || - s->flow_controlled_buffer.length != 0 || - s->send_trailing_metadata == NULL || - !is_default_initial_metadata(s->send_initial_metadata)) { - grpc_encode_header_options hopt = { - s->id, // stream_id - false, // is_eof - t->settings[GRPC_PEER_SETTINGS] - [GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA] != - 0, // use_true_binary_metadata - t->settings[GRPC_PEER_SETTINGS] - [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], // max_frame_size - &s->stats.outgoing // stats - }; - grpc_chttp2_encode_header(exec_ctx, &t->hpack_compressor, NULL, 0, - s->send_initial_metadata, &hopt, &t->outbuf); - now_writing = true; - if (!t->is_client) { - t->ping_recv_state.last_ping_recv_time = - gpr_inf_past(GPR_CLOCK_MONOTONIC); - t->ping_recv_state.ping_strikes = 0; - } - initial_metadata_writes++; - } else { - GRPC_CHTTP2_IF_TRACING( - gpr_log(GPR_INFO, "not sending initial_metadata (Trailers-Only)")); - // When sending Trailers-Only, we need to move the :status and - // content-type headers to the trailers. - if (s->send_initial_metadata->idx.named.status != NULL) { - extra_headers_for_trailing_metadata - [num_extra_headers_for_trailing_metadata++] = - &s->send_initial_metadata->idx.named.status->md; - } - if (s->send_initial_metadata->idx.named.content_type != NULL) { - extra_headers_for_trailing_metadata - [num_extra_headers_for_trailing_metadata++] = - &s->send_initial_metadata->idx.named.content_type->md; - } - trailing_metadata_writes++; - } - s->send_initial_metadata = NULL; - s->sent_initial_metadata = true; - sent_initial_metadata = true; - result.early_results_scheduled = true; - grpc_chttp2_complete_closure_step( - exec_ctx, t, s, &s->send_initial_metadata_finished, GRPC_ERROR_NONE, - "send_initial_metadata_finished"); + if (sent_initial_metadata_) return; + if (s_->send_initial_metadata == nullptr) return; + + // We skip this on the server side if there is no custom initial + // metadata, there are no messages to send, and we are also sending + // trailing metadata. This results in a Trailers-Only response, + // which is required for retries, as per: + // https://github.com/grpc/proposal/blob/master/A6-client-retries.md#when-retries-are-valid + if (!t_->is_client && s_->fetching_send_message == nullptr && + s_->flow_controlled_buffer.length == 0 && + s_->send_trailing_metadata == nullptr && + is_default_initial_metadata(s_->send_initial_metadata)) { + ConvertInitialMetadataToTrailingMetadata(); + return; // early out } + + grpc_encode_header_options hopt = { + s_->id, // stream_id + false, // is_eof + t_->settings[GRPC_PEER_SETTINGS] + [GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA] != + 0, // use_true_binary_metadata + t_->settings[GRPC_PEER_SETTINGS] + [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], // max_frame_size + &s_->stats.outgoing // stats + }; + grpc_chttp2_encode_header(exec_ctx, &t_->hpack_compressor, NULL, 0, + s_->send_initial_metadata, &hopt, &t_->outbuf); + stream_became_writable_ = true; + write_context_->ResetPingRecvClock(); + write_context_->IncInitialMetadataWrites(); + s_->send_initial_metadata = NULL; + s_->sent_initial_metadata = true; + sent_initial_metadata_ = true; + write_context_->NoteScheduledResults(); + grpc_chttp2_complete_closure_step( + exec_ctx, t_, s_, &s_->send_initial_metadata_finished, GRPC_ERROR_NONE, + "send_initial_metadata_finished"); + } + + void FlushWindowUpdates(grpc_exec_ctx *exec_ctx) { /* send any window updates */ uint32_t stream_announce = grpc_chttp2_flowctl_maybe_send_stream_update( - &t->flow_control, &s->flow_control); - if (stream_announce > 0) { - grpc_slice_buffer_add( - &t->outbuf, grpc_chttp2_window_update_create(s->id, stream_announce, - &s->stats.outgoing)); - if (!t->is_client) { - t->ping_recv_state.last_ping_recv_time = - gpr_inf_past(GPR_CLOCK_MONOTONIC); - t->ping_recv_state.ping_strikes = 0; + &t_->flow_control, &s_->flow_control); + if (stream_announce == 0) return; + + grpc_slice_buffer_add( + &t_->outbuf, grpc_chttp2_window_update_create(s_->id, stream_announce, + &s_->stats.outgoing)); + write_context_->ResetPingRecvClock(); + write_context_->IncWindowUpdateWrites(); + } + + void FlushData(grpc_exec_ctx *exec_ctx) { + if (!sent_initial_metadata_) return; + + if (s_->flow_controlled_buffer.length == 0 && + s_->compressed_data_buffer.length == 0) { + return; // early out: nothing to do + } + + DataSendContext data_send_context(write_context_, t_, s_); + + if (!data_send_context.AnyOutgoing()) { + if (t_->flow_control.remote_window == 0) { + grpc_chttp2_list_add_stalled_by_transport(t_, s_); + } else if (data_send_context.stream_remote_window() == 0) { + grpc_chttp2_list_add_stalled_by_stream(t_, s_); } - flow_control_writes++; + return; // early out: nothing to do } - if (sent_initial_metadata) { - /* send any body bytes, if allowed by flow control */ - if (s->flow_controlled_buffer.length > 0 || - s->compressed_data_buffer.length > 0) { - uint32_t stream_remote_window = (uint32_t)GPR_MAX( - 0, - s->flow_control.remote_window_delta + - (int64_t)t->settings[GRPC_PEER_SETTINGS] - [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]); - uint32_t max_outgoing = (uint32_t)GPR_MIN( - t->settings[GRPC_PEER_SETTINGS] - [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], - GPR_MIN(stream_remote_window, t->flow_control.remote_window)); - if (max_outgoing > 0) { - bool is_last_data_frame = false; - bool is_last_frame = false; - size_t sending_bytes_before = s->sending_bytes; - while ((s->flow_controlled_buffer.length > 0 || - s->compressed_data_buffer.length > 0) && - max_outgoing > 0) { - if (s->compressed_data_buffer.length > 0) { - uint32_t send_bytes = (uint32_t)GPR_MIN( - max_outgoing, s->compressed_data_buffer.length); - is_last_data_frame = - (send_bytes == s->compressed_data_buffer.length && - s->flow_controlled_buffer.length == 0 && - s->fetching_send_message == NULL); - if (is_last_data_frame && s->send_trailing_metadata != NULL && - s->stream_compression_ctx != NULL) { - if (!grpc_stream_compress( - s->stream_compression_ctx, &s->flow_controlled_buffer, - &s->compressed_data_buffer, NULL, MAX_SIZE_T, - GRPC_STREAM_COMPRESSION_FLUSH_FINISH)) { - gpr_log(GPR_ERROR, "Stream compression failed."); - } - grpc_stream_compression_context_destroy( - s->stream_compression_ctx); - s->stream_compression_ctx = NULL; - /* After finish, bytes in s->compressed_data_buffer may be - * more than max_outgoing. Start another round of the current - * while loop so that send_bytes and is_last_data_frame are - * recalculated. */ - continue; - } - is_last_frame = - is_last_data_frame && s->send_trailing_metadata != NULL && - grpc_metadata_batch_is_empty(s->send_trailing_metadata); - grpc_chttp2_encode_data(s->id, &s->compressed_data_buffer, - send_bytes, is_last_frame, - &s->stats.outgoing, &t->outbuf); - grpc_chttp2_flowctl_sent_data(&t->flow_control, &s->flow_control, - send_bytes); - max_outgoing -= send_bytes; - if (s->compressed_data_buffer.length == 0) { - s->sending_bytes += s->uncompressed_data_size; - } - } else { - if (s->stream_compression_ctx == NULL) { - s->stream_compression_ctx = - grpc_stream_compression_context_create( - s->stream_compression_method); - } - s->uncompressed_data_size = s->flow_controlled_buffer.length; - if (!grpc_stream_compress( - s->stream_compression_ctx, &s->flow_controlled_buffer, - &s->compressed_data_buffer, NULL, MAX_SIZE_T, - GRPC_STREAM_COMPRESSION_FLUSH_SYNC)) { - gpr_log(GPR_ERROR, "Stream compression failed."); - } - } - } - if (!t->is_client) { - t->ping_recv_state.last_ping_recv_time = - gpr_inf_past(GPR_CLOCK_MONOTONIC); - t->ping_recv_state.ping_strikes = 0; - } - if (is_last_frame) { - s->send_trailing_metadata = NULL; - s->sent_trailing_metadata = true; - if (!t->is_client && !s->read_closed) { - grpc_slice_buffer_add(&t->outbuf, grpc_chttp2_rst_stream_create( - s->id, GRPC_HTTP2_NO_ERROR, - &s->stats.outgoing)); - } - grpc_chttp2_mark_stream_closed(exec_ctx, t, s, !t->is_client, 1, - GRPC_ERROR_NONE); - } - result.early_results_scheduled |= - update_list(exec_ctx, t, s, - (int64_t)(s->sending_bytes - sending_bytes_before), - &s->on_flow_controlled_cbs, - &s->flow_controlled_bytes_flowed, GRPC_ERROR_NONE); - now_writing = true; - if (s->flow_controlled_buffer.length > 0 || - s->compressed_data_buffer.length > 0) { - GRPC_CHTTP2_STREAM_REF(s, "chttp2_writing:fork"); - grpc_chttp2_list_add_writable_stream(t, s); - } - message_writes++; - } else if (t->flow_control.remote_window == 0) { - grpc_chttp2_list_add_stalled_by_transport(t, s); - now_writing = true; - } else if (stream_remote_window == 0) { - grpc_chttp2_list_add_stalled_by_stream(t, s); - now_writing = true; - } + + while ((s_->flow_controlled_buffer.length > 0 || + s_->compressed_data_buffer.length > 0) && + data_send_context.max_outgoing() > 0) { + if (s_->compressed_data_buffer.length > 0) { + data_send_context.FlushCompressedBytes(); + } else { + data_send_context.CompressMoreBytes(); } - if (s->send_trailing_metadata != NULL && - s->fetching_send_message == NULL && - s->flow_controlled_buffer.length == 0 && - s->compressed_data_buffer.length == 0) { - GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_INFO, "sending trailing_metadata")); - if (grpc_metadata_batch_is_empty(s->send_trailing_metadata)) { - grpc_chttp2_encode_data(s->id, &s->flow_controlled_buffer, 0, true, - &s->stats.outgoing, &t->outbuf); - } else { - grpc_encode_header_options hopt = { - s->id, true, - - t->settings - [GRPC_PEER_SETTINGS] + } + write_context_->ResetPingRecvClock(); + if (data_send_context.WasLastFrame()) { + SentLastFrame(exec_ctx); + } + data_send_context.CallCallbacks(exec_ctx); + stream_became_writable_ = true; + if (s_->flow_controlled_buffer.length > 0 || + s_->compressed_data_buffer.length > 0) { + GRPC_CHTTP2_STREAM_REF(s_, "chttp2_writing:fork"); + grpc_chttp2_list_add_writable_stream(t_, s_); + } + write_context_->IncMessageWrites(); + } + + void FlushTrailingMetadata(grpc_exec_ctx *exec_ctx) { + if (!sent_initial_metadata_) return; + + if (s_->send_trailing_metadata == NULL) return; + if (s_->fetching_send_message != NULL) return; + if (s_->flow_controlled_buffer.length != 0) return; + if (s_->compressed_data_buffer.length != 0) return; + + GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_INFO, "sending trailing_metadata")); + if (grpc_metadata_batch_is_empty(s_->send_trailing_metadata)) { + grpc_chttp2_encode_data(s_->id, &s_->flow_controlled_buffer, 0, true, + &s_->stats.outgoing, &t_->outbuf); + } else { + grpc_encode_header_options hopt = { + s_->id, true, + t_->settings[GRPC_PEER_SETTINGS] [GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA] != - 0, - - t->settings[GRPC_PEER_SETTINGS] - [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], - &s->stats.outgoing}; - grpc_chttp2_encode_header(exec_ctx, &t->hpack_compressor, - extra_headers_for_trailing_metadata, - num_extra_headers_for_trailing_metadata, - s->send_trailing_metadata, &hopt, - &t->outbuf); - trailing_metadata_writes++; - } - s->send_trailing_metadata = NULL; - s->sent_trailing_metadata = true; - if (!t->is_client && !s->read_closed) { - grpc_slice_buffer_add( - &t->outbuf, grpc_chttp2_rst_stream_create( - s->id, GRPC_HTTP2_NO_ERROR, &s->stats.outgoing)); - } - grpc_chttp2_mark_stream_closed(exec_ctx, t, s, !t->is_client, 1, - GRPC_ERROR_NONE); - now_writing = true; - result.early_results_scheduled = true; - grpc_chttp2_complete_closure_step( - exec_ctx, t, s, &s->send_trailing_metadata_finished, - GRPC_ERROR_NONE, "send_trailing_metadata_finished"); - } + 0, + + t_->settings[GRPC_PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], + &s_->stats.outgoing}; + grpc_chttp2_encode_header(exec_ctx, &t_->hpack_compressor, + extra_headers_for_trailing_metadata_, + num_extra_headers_for_trailing_metadata_, + s_->send_trailing_metadata, &hopt, &t_->outbuf); } + write_context_->IncTrailingMetadataWrites(); + SentLastFrame(exec_ctx); - if (now_writing) { - GRPC_STATS_INC_HTTP2_SEND_INITIAL_METADATA_PER_WRITE( - exec_ctx, initial_metadata_writes); - GRPC_STATS_INC_HTTP2_SEND_MESSAGE_PER_WRITE(exec_ctx, message_writes); - GRPC_STATS_INC_HTTP2_SEND_TRAILING_METADATA_PER_WRITE( - exec_ctx, trailing_metadata_writes); - GRPC_STATS_INC_HTTP2_SEND_FLOWCTL_PER_WRITE(exec_ctx, - flow_control_writes); + write_context_->NoteScheduledResults(); + grpc_chttp2_complete_closure_step( + exec_ctx, t_, s_, &s_->send_trailing_metadata_finished, GRPC_ERROR_NONE, + "send_trailing_metadata_finished"); + } + + bool stream_became_writable() { return stream_became_writable_; } + + private: + void ConvertInitialMetadataToTrailingMetadata() { + GRPC_CHTTP2_IF_TRACING( + gpr_log(GPR_INFO, "not sending initial_metadata (Trailers-Only)")); + // When sending Trailers-Only, we need to move the :status and + // content-type headers to the trailers. + if (s_->send_initial_metadata->idx.named.status != NULL) { + extra_headers_for_trailing_metadata_ + [num_extra_headers_for_trailing_metadata_++] = + &s_->send_initial_metadata->idx.named.status->md; + } + if (s_->send_initial_metadata->idx.named.content_type != NULL) { + extra_headers_for_trailing_metadata_ + [num_extra_headers_for_trailing_metadata_++] = + &s_->send_initial_metadata->idx.named.content_type->md; + } + } + + void SentLastFrame(grpc_exec_ctx *exec_ctx) { + s_->send_trailing_metadata = NULL; + s_->sent_trailing_metadata = true; + + if (!t_->is_client && !s_->read_closed) { + grpc_slice_buffer_add( + &t_->outbuf, grpc_chttp2_rst_stream_create( + s_->id, GRPC_HTTP2_NO_ERROR, &s_->stats.outgoing)); + } + grpc_chttp2_mark_stream_closed(exec_ctx, t_, s_, !t_->is_client, true, + GRPC_ERROR_NONE); + } + + WriteContext *const write_context_; + grpc_chttp2_transport *const t_; + grpc_chttp2_stream *const s_; + bool sent_initial_metadata_; + bool stream_became_writable_ = false; + grpc_mdelem *extra_headers_for_trailing_metadata_[2]; + size_t num_extra_headers_for_trailing_metadata_ = 0; +}; +} // namespace + +grpc_chttp2_begin_write_result grpc_chttp2_begin_write( + grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t) { + WriteContext ctx(exec_ctx, t); + ctx.FlushSettings(exec_ctx); + ctx.FlushQueuedBuffers(exec_ctx); + ctx.EnactHpackSettings(exec_ctx); + if (t->flow_control.remote_window > 0) { + ctx.UpdateStreamsNoLongerStalled(); + } + + /* for each grpc_chttp2_stream that's become writable, frame it's data + (according to available window sizes) and add to the output buffer */ + while (grpc_chttp2_stream *s = ctx.NextStream()) { + StreamWriteContext stream_ctx(&ctx, s); + stream_ctx.FlushInitialMetadata(exec_ctx); + stream_ctx.FlushWindowUpdates(exec_ctx); + stream_ctx.FlushData(exec_ctx); + stream_ctx.FlushTrailingMetadata(exec_ctx); + + if (stream_ctx.stream_became_writable()) { if (!grpc_chttp2_list_add_writing_stream(t, s)) { /* already in writing list: drop ref */ GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "chttp2_writing:already_writing"); + } else { + /* ref will be dropped at end of write */ } } else { GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "chttp2_writing:no_write"); } } - uint32_t transport_announce = - grpc_chttp2_flowctl_maybe_send_transport_update(&t->flow_control); - if (transport_announce) { - maybe_initiate_ping(exec_ctx, t, - GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE); - grpc_transport_one_way_stats throwaway_stats; - grpc_slice_buffer_add( - &t->outbuf, grpc_chttp2_window_update_create(0, transport_announce, - &throwaway_stats)); - if (!t->is_client) { - t->ping_recv_state.last_ping_recv_time = - gpr_inf_past(GPR_CLOCK_MONOTONIC); - t->ping_recv_state.ping_strikes = 0; - } - } - - for (size_t i = 0; i < t->ping_ack_count; i++) { - grpc_slice_buffer_add(&t->outbuf, - grpc_chttp2_ping_create(1, t->ping_acks[i])); - } - t->ping_ack_count = 0; + ctx.FlushWindowUpdates(exec_ctx); + ctx.FlushPingAcks(); maybe_initiate_ping(exec_ctx, t, GRPC_CHTTP2_PING_ON_NEXT_WRITE); GPR_TIMER_END("grpc_chttp2_begin_write", 0); - result.writing = t->outbuf.count > 0; - return result; + return ctx.Result(); } void grpc_chttp2_end_write(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, From db78c2fa3b753f84940ff4fea0e7627b8779413e Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 6 Oct 2017 10:09:09 -0700 Subject: [PATCH 088/142] Set gpr_mpscq_test to not use polling, make that bit work again --- build.yaml | 1 + .../run_tests/generated/tests.json.template | 3 +- tools/run_tests/generated/tests.json | 603 ++++++++++++------ 3 files changed, 405 insertions(+), 202 deletions(-) diff --git a/build.yaml b/build.yaml index 7033d52542d..ffaafd8bad7 100644 --- a/build.yaml +++ b/build.yaml @@ -2269,6 +2269,7 @@ targets: deps: - gpr_test_util - gpr + uses_polling: false - name: gpr_spinlock_test cpu_cost: 3 build: test diff --git a/templates/tools/run_tests/generated/tests.json.template b/templates/tools/run_tests/generated/tests.json.template index 10ab2e445a4..0c9f0a14c47 100644 --- a/templates/tools/run_tests/generated/tests.json.template +++ b/templates/tools/run_tests/generated/tests.json.template @@ -13,7 +13,8 @@ "exclude_iomgrs": tgt.get("exclude_iomgrs", []), "args": tgt.get("args", []), "flaky": tgt.flaky, - "cpu_cost": tgt.get("cpu_cost", 1.0)} + "cpu_cost": tgt.get("cpu_cost", 1.0), + "uses_polling": tgt.get("uses_polling", True)} timeout_seconds = tgt.get("timeout_seconds", None) if timeout_seconds: out['timeout_seconds'] = timeout_seconds diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 1fefb52f07d..860f324d8af 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -21,7 +21,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -43,7 +44,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -65,7 +67,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -87,7 +90,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -109,7 +113,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -133,7 +138,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -155,7 +161,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -177,7 +184,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -199,7 +207,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -221,7 +230,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -243,7 +253,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -265,7 +276,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -287,7 +299,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -309,7 +322,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -331,7 +345,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -353,7 +368,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -375,7 +391,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -397,7 +414,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -419,7 +437,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -441,7 +460,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -465,7 +485,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -487,7 +508,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -511,7 +533,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -533,7 +556,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -555,7 +579,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -579,7 +604,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -601,7 +627,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -619,7 +646,8 @@ "name": "ev_epollsig_linux_test", "platforms": [ "linux" - ] + ], + "uses_polling": true }, { "args": [], @@ -641,7 +669,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -661,7 +690,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -683,7 +713,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -705,7 +736,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -725,7 +757,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -745,7 +778,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -767,7 +801,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -789,7 +824,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -811,7 +847,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -833,7 +870,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -855,7 +893,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -877,7 +916,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -899,7 +939,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -921,7 +962,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -943,7 +985,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -965,7 +1008,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": false }, { "args": [], @@ -987,7 +1031,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1009,7 +1054,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1031,7 +1077,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1053,7 +1100,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1075,7 +1123,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1097,7 +1146,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1119,7 +1169,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1141,7 +1192,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1163,7 +1215,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1185,7 +1238,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1207,7 +1261,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1229,7 +1284,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1251,7 +1307,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1273,7 +1330,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1295,7 +1353,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1319,7 +1378,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1341,7 +1401,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1363,7 +1424,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1383,7 +1445,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -1405,7 +1468,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1427,7 +1491,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1445,7 +1510,8 @@ "name": "handshake_client", "platforms": [ "linux" - ] + ], + "uses_polling": true }, { "args": [], @@ -1463,7 +1529,8 @@ "name": "handshake_server", "platforms": [ "linux" - ] + ], + "uses_polling": true }, { "args": [], @@ -1485,7 +1552,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1507,7 +1575,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1529,7 +1598,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1551,7 +1621,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1571,7 +1642,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -1587,7 +1659,8 @@ "name": "httpscli_test", "platforms": [ "linux" - ] + ], + "uses_polling": true }, { "args": [], @@ -1609,7 +1682,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1631,7 +1705,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1653,7 +1728,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1675,7 +1751,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1697,7 +1774,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1719,7 +1797,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1741,7 +1820,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1761,7 +1841,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -1783,7 +1864,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1805,7 +1887,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1827,7 +1910,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1849,7 +1933,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1871,7 +1956,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1893,7 +1979,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1917,7 +2004,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1939,7 +2027,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1961,7 +2050,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -1979,7 +2069,8 @@ "name": "pollset_set_test", "platforms": [ "linux" - ] + ], + "uses_polling": true }, { "args": [], @@ -2001,7 +2092,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -2023,7 +2115,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2045,7 +2138,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2067,7 +2161,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2091,7 +2186,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2115,7 +2211,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2137,7 +2234,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2159,7 +2257,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2181,7 +2280,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2203,7 +2303,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2225,7 +2326,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2247,7 +2349,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2269,7 +2372,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2291,7 +2395,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2313,7 +2418,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -2333,7 +2439,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -2355,7 +2462,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2377,7 +2485,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2399,7 +2508,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2421,7 +2531,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -2445,7 +2556,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2467,7 +2579,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -2489,7 +2602,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -2513,7 +2627,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2535,7 +2650,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2557,7 +2673,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2581,7 +2698,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2605,7 +2723,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2627,7 +2746,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2649,7 +2769,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2671,7 +2792,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2691,7 +2813,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -2713,7 +2836,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -2735,7 +2859,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2757,7 +2882,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -2779,7 +2905,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2801,7 +2928,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -2823,7 +2951,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [ @@ -2845,7 +2974,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [ @@ -2867,7 +2997,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [ @@ -2889,7 +3020,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [ @@ -2911,7 +3043,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [ @@ -2933,7 +3066,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [ @@ -2955,7 +3089,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [ @@ -2977,7 +3112,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [ @@ -2999,7 +3135,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [ @@ -3026,7 +3163,8 @@ "mac", "posix" ], - "timeout_seconds": 1200 + "timeout_seconds": 1200, + "uses_polling": true }, { "args": [ @@ -3053,7 +3191,8 @@ "mac", "posix" ], - "timeout_seconds": 1200 + "timeout_seconds": 1200, + "uses_polling": true }, { "args": [ @@ -3080,7 +3219,8 @@ "mac", "posix" ], - "timeout_seconds": 1200 + "timeout_seconds": 1200, + "uses_polling": true }, { "args": [ @@ -3107,7 +3247,8 @@ "mac", "posix" ], - "timeout_seconds": 1200 + "timeout_seconds": 1200, + "uses_polling": true }, { "args": [ @@ -3129,7 +3270,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [ @@ -3151,7 +3293,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -3173,7 +3316,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3195,7 +3339,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3217,7 +3362,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3237,7 +3383,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -3263,7 +3410,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3285,7 +3433,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3307,7 +3456,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3329,7 +3479,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3351,7 +3502,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3373,7 +3525,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3395,7 +3548,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3417,7 +3571,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3439,7 +3594,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3461,7 +3617,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3483,7 +3640,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3505,7 +3663,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [ @@ -3529,7 +3688,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3551,7 +3711,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3573,7 +3734,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3599,7 +3761,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3625,7 +3788,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3647,7 +3811,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3669,7 +3834,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3689,7 +3855,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -3711,7 +3878,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3733,7 +3901,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3755,7 +3924,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3777,7 +3947,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3799,7 +3970,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3819,7 +3991,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -3841,7 +4014,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3861,7 +4035,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -3883,7 +4058,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3905,7 +4081,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3927,7 +4104,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3947,7 +4125,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -3969,7 +4148,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -3991,7 +4171,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -4013,7 +4194,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -4035,7 +4217,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -4055,7 +4238,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -4077,7 +4261,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -4100,7 +4285,8 @@ "posix", "windows" ], - "timeout_seconds": 1200 + "timeout_seconds": 1200, + "uses_polling": true }, { "args": [], @@ -4120,7 +4306,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [], @@ -4142,7 +4329,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -4166,7 +4354,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -4190,7 +4379,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -4214,7 +4404,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -4238,7 +4429,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -4262,7 +4454,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -4286,7 +4479,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -4310,7 +4504,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -4334,7 +4529,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -4358,7 +4554,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -4382,7 +4579,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], @@ -4402,7 +4600,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [ @@ -4425,7 +4624,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [ @@ -4448,7 +4648,8 @@ "linux", "mac", "posix" - ] + ], + "uses_polling": true }, { "args": [ From a69912cb2c7abae2d930c4158bd56c33b9b7b898 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 6 Oct 2017 10:27:11 -0700 Subject: [PATCH 089/142] Fixes --- .../ext/transport/chttp2/transport/writing.cc | 35 ++++++++++--------- tools/run_tests/python_utils/jobset.py | 12 ++++--- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc index c61b70b0638..2f9a33d70be 100644 --- a/src/core/ext/transport/chttp2/transport/writing.cc +++ b/src/core/ext/transport/chttp2/transport/writing.cc @@ -418,27 +418,27 @@ class StreamWriteContext { // https://github.com/grpc/proposal/blob/master/A6-client-retries.md#when-retries-are-valid if (!t_->is_client && s_->fetching_send_message == nullptr && s_->flow_controlled_buffer.length == 0 && - s_->send_trailing_metadata == nullptr && + s_->compressed_data_buffer.length == 0 && + s_->send_trailing_metadata != nullptr && is_default_initial_metadata(s_->send_initial_metadata)) { ConvertInitialMetadataToTrailingMetadata(); - return; // early out + } else { + grpc_encode_header_options hopt = { + s_->id, // stream_id + false, // is_eof + t_->settings[GRPC_PEER_SETTINGS] + [GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA] != + 0, // use_true_binary_metadata + t_->settings[GRPC_PEER_SETTINGS] + [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], // max_frame_size + &s_->stats.outgoing // stats + }; + grpc_chttp2_encode_header(exec_ctx, &t_->hpack_compressor, NULL, 0, + s_->send_initial_metadata, &hopt, &t_->outbuf); + write_context_->ResetPingRecvClock(); + write_context_->IncInitialMetadataWrites(); } - grpc_encode_header_options hopt = { - s_->id, // stream_id - false, // is_eof - t_->settings[GRPC_PEER_SETTINGS] - [GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA] != - 0, // use_true_binary_metadata - t_->settings[GRPC_PEER_SETTINGS] - [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], // max_frame_size - &s_->stats.outgoing // stats - }; - grpc_chttp2_encode_header(exec_ctx, &t_->hpack_compressor, NULL, 0, - s_->send_initial_metadata, &hopt, &t_->outbuf); - stream_became_writable_ = true; - write_context_->ResetPingRecvClock(); - write_context_->IncInitialMetadataWrites(); s_->send_initial_metadata = NULL; s_->sent_initial_metadata = true; sent_initial_metadata_ = true; @@ -532,6 +532,7 @@ class StreamWriteContext { s_->send_trailing_metadata, &hopt, &t_->outbuf); } write_context_->IncTrailingMetadataWrites(); + write_context_->ResetPingRecvClock(); SentLastFrame(exec_ctx); write_context_->NoteScheduledResults(); diff --git a/tools/run_tests/python_utils/jobset.py b/tools/run_tests/python_utils/jobset.py index d523095e703..658b814d81f 100755 --- a/tools/run_tests/python_utils/jobset.py +++ b/tools/run_tests/python_utils/jobset.py @@ -412,7 +412,7 @@ class Jobset(object): if current_cpu_cost + spec.cpu_cost <= self._maxjobs: if len(self._running) < self._maxjobs_cpu_agnostic: break - self.reap() + self.reap(spec.shortname, spec.cpu_cost) if self.cancelled(): return False job = Job(spec, self._newline_on_success, @@ -424,7 +424,7 @@ class Jobset(object): self.resultset[job.GetSpec().shortname] = [] return True - def reap(self): + def reap(self, waiting_for=None, waiting_for_cost=None): """Collect the dead jobs.""" while self._running: dead = set() @@ -452,8 +452,12 @@ class Jobset(object): sofar = now - self._start_time remaining = sofar / self._completed * (self._remaining + len(self._running)) rstr = 'ETA %.1f sec; %s' % (remaining, rstr) - message('WAITING', '%s%d jobs running, %d complete, %d failed' % ( - rstr, len(self._running), self._completed, self._failures)) + if waiting_for is not None: + wstr = ' next: %s @ %.2f cpu' % (waiting_for, waiting_for_cost) + else: + wstr = '' + message('WAITING', '%s%d jobs running, %d complete, %d failed (load %.2f)%s' % ( + rstr, len(self._running), self._completed, self._failures, self.cpu_cost(), wstr)) if platform_string() == 'windows': time.sleep(0.1) else: From d48bd078d7f257db2d4c48e8e835bb2ff1ac7e73 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 6 Oct 2017 11:25:14 -0700 Subject: [PATCH 090/142] Fixes --- CMakeLists.txt | 12 ++++++------ Makefile | 12 ++++++------ binding.gyp | 2 +- build.yaml | 2 +- config.m4 | 2 +- config.w32 | 2 +- gRPC-Core.podspec | 2 +- grpc.gemspec | 2 +- grpc.gyp | 8 ++++---- package.xml | 2 +- src/python/grpcio/grpc_core_dependencies.py | 2 +- tools/doxygen/Doxyfile.core.internal | 2 +- tools/run_tests/generated/sources_and_headers.json | 2 +- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2321afc1b0b..139d1bd46cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -954,7 +954,7 @@ endif (gRPC_BUILD_TESTS) add_library(grpc src/core/lib/surface/init.cc - src/core/lib/backoff/backoff.c + src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc @@ -1306,7 +1306,7 @@ endif() add_library(grpc_cronet src/core/lib/surface/init.cc - src/core/lib/backoff/backoff.c + src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc @@ -1626,7 +1626,7 @@ add_library(grpc_test_util test/core/util/port_server_client.c test/core/util/slice_splitter.c test/core/util/trickle_endpoint.c - src/core/lib/backoff/backoff.c + src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc @@ -1890,7 +1890,7 @@ add_library(grpc_test_util_unsecure test/core/util/port_server_client.c test/core/util/slice_splitter.c test/core/util/trickle_endpoint.c - src/core/lib/backoff/backoff.c + src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc @@ -2140,7 +2140,7 @@ endif (gRPC_BUILD_TESTS) add_library(grpc_unsecure src/core/lib/surface/init.cc src/core/lib/surface/init_unsecure.cc - src/core/lib/backoff/backoff.c + src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc @@ -2898,7 +2898,7 @@ add_library(grpc++_cronet src/core/ext/transport/chttp2/transport/stream_map.cc src/core/ext/transport/chttp2/transport/varint.cc src/core/ext/transport/chttp2/transport/writing.cc - src/core/lib/backoff/backoff.c + src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc diff --git a/Makefile b/Makefile index 72aae9f2f6f..382956dc44e 100644 --- a/Makefile +++ b/Makefile @@ -2945,7 +2945,7 @@ endif LIBGRPC_SRC = \ src/core/lib/surface/init.cc \ - src/core/lib/backoff/backoff.c \ + src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ @@ -3297,7 +3297,7 @@ endif LIBGRPC_CRONET_SRC = \ src/core/lib/surface/init.cc \ - src/core/lib/backoff/backoff.c \ + src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ @@ -3616,7 +3616,7 @@ LIBGRPC_TEST_UTIL_SRC = \ test/core/util/port_server_client.c \ test/core/util/slice_splitter.c \ test/core/util/trickle_endpoint.c \ - src/core/lib/backoff/backoff.c \ + src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ @@ -3871,7 +3871,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ test/core/util/port_server_client.c \ test/core/util/slice_splitter.c \ test/core/util/trickle_endpoint.c \ - src/core/lib/backoff/backoff.c \ + src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ @@ -4099,7 +4099,7 @@ endif LIBGRPC_UNSECURE_SRC = \ src/core/lib/surface/init.cc \ src/core/lib/surface/init_unsecure.cc \ - src/core/lib/backoff/backoff.c \ + src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ @@ -4840,7 +4840,7 @@ LIBGRPC++_CRONET_SRC = \ src/core/ext/transport/chttp2/transport/stream_map.cc \ src/core/ext/transport/chttp2/transport/varint.cc \ src/core/ext/transport/chttp2/transport/writing.cc \ - src/core/lib/backoff/backoff.c \ + src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ diff --git a/binding.gyp b/binding.gyp index e10532e8e9e..91919c33305 100644 --- a/binding.gyp +++ b/binding.gyp @@ -657,7 +657,7 @@ ], 'sources': [ 'src/core/lib/surface/init.cc', - 'src/core/lib/backoff/backoff.c', + 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', diff --git a/build.yaml b/build.yaml index ead40766d88..d23716af2af 100644 --- a/build.yaml +++ b/build.yaml @@ -182,7 +182,7 @@ filegroups: - grpc++_codegen_base - name: grpc_base src: - - src/core/lib/backoff/backoff.c + - src/core/lib/backoff/backoff.cc - src/core/lib/channel/channel_args.cc - src/core/lib/channel/channel_stack.cc - src/core/lib/channel/channel_stack_builder.cc diff --git a/config.m4 b/config.m4 index c583ec4ea85..5d92a2ae348 100644 --- a/config.m4 +++ b/config.m4 @@ -85,7 +85,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/support/tmpfile_windows.cc \ src/core/lib/support/wrap_memcpy.cc \ src/core/lib/surface/init.cc \ - src/core/lib/backoff/backoff.c \ + src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ diff --git a/config.w32 b/config.w32 index 20ccf3a0689..67b5e2f5543 100644 --- a/config.w32 +++ b/config.w32 @@ -62,7 +62,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\support\\tmpfile_windows.cc " + "src\\core\\lib\\support\\wrap_memcpy.cc " + "src\\core\\lib\\surface\\init.cc " + - "src\\core\\lib\\backoff\\backoff.c " + + "src\\core\\lib\\backoff\\backoff.cc " + "src\\core\\lib\\channel\\channel_args.cc " + "src\\core\\lib\\channel\\channel_stack.cc " + "src\\core\\lib\\channel\\channel_stack_builder.cc " + diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 659ea07ba61..08ef7387322 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -460,7 +460,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h', 'src/core/ext/filters/workarounds/workaround_utils.h', 'src/core/lib/surface/init.cc', - 'src/core/lib/backoff/backoff.c', + 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', diff --git a/grpc.gemspec b/grpc.gemspec index fd3010b0441..ce23e6f7df5 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -407,7 +407,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h ) s.files += %w( src/core/ext/filters/workarounds/workaround_utils.h ) s.files += %w( src/core/lib/surface/init.cc ) - s.files += %w( src/core/lib/backoff/backoff.c ) + s.files += %w( src/core/lib/backoff/backoff.cc ) s.files += %w( src/core/lib/channel/channel_args.cc ) s.files += %w( src/core/lib/channel/channel_stack.cc ) s.files += %w( src/core/lib/channel/channel_stack_builder.cc ) diff --git a/grpc.gyp b/grpc.gyp index a38b2a36761..53e388561f9 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -223,7 +223,7 @@ ], 'sources': [ 'src/core/lib/surface/init.cc', - 'src/core/lib/backoff/backoff.c', + 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', @@ -525,7 +525,7 @@ 'test/core/util/port_server_client.c', 'test/core/util/slice_splitter.c', 'test/core/util/trickle_endpoint.c', - 'src/core/lib/backoff/backoff.c', + 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', @@ -732,7 +732,7 @@ 'test/core/util/port_server_client.c', 'test/core/util/slice_splitter.c', 'test/core/util/trickle_endpoint.c', - 'src/core/lib/backoff/backoff.c', + 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', @@ -924,7 +924,7 @@ 'sources': [ 'src/core/lib/surface/init.cc', 'src/core/lib/surface/init_unsecure.cc', - 'src/core/lib/backoff/backoff.c', + 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', diff --git a/package.xml b/package.xml index 0b527d78db2..df0142124d5 100644 --- a/package.xml +++ b/package.xml @@ -419,7 +419,7 @@ - + diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index e60dfb7c2c4..140f4ceee12 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -61,7 +61,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/support/tmpfile_windows.cc', 'src/core/lib/support/wrap_memcpy.cc', 'src/core/lib/surface/init.cc', - 'src/core/lib/backoff/backoff.c', + 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 37dc9b4ba52..d4654034f2c 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1056,7 +1056,7 @@ src/core/ext/transport/inproc/inproc_plugin.cc \ src/core/ext/transport/inproc/inproc_transport.cc \ src/core/ext/transport/inproc/inproc_transport.h \ src/core/lib/README.md \ -src/core/lib/backoff/backoff.c \ +src/core/lib/backoff/backoff.cc \ src/core/lib/backoff/backoff.h \ src/core/lib/channel/README.md \ src/core/lib/channel/channel_args.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 8b11bb742e0..babdfeb6858 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7994,7 +7994,7 @@ "language": "c", "name": "grpc_base", "src": [ - "src/core/lib/backoff/backoff.c", + "src/core/lib/backoff/backoff.cc", "src/core/lib/channel/channel_args.cc", "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", From 8aec8613c5f19ab5a2eb6589f6a5ed21b9f02bfa Mon Sep 17 00:00:00 2001 From: Adele Zhou Date: Fri, 6 Oct 2017 11:54:39 -0700 Subject: [PATCH 091/142] Set allow_flakes to true for cloud_to_prod tests --- tools/internal_ci/linux/grpc_interop_toprod.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/internal_ci/linux/grpc_interop_toprod.sh b/tools/internal_ci/linux/grpc_interop_toprod.sh index 3d06185406a..97a7d5d2393 100755 --- a/tools/internal_ci/linux/grpc_interop_toprod.sh +++ b/tools/internal_ci/linux/grpc_interop_toprod.sh @@ -28,5 +28,5 @@ tools/run_tests/run_interop_tests.py \ --cloud_to_prod \ --cloud_to_prod_auth \ --prod_servers default gateway_v4 \ - --use_docker --internal_ci -t -j 12 $@ + --use_docker --internal_ci --allow_flakes -t -j 12 $@ From 87bc56ab58b2f5fe8afaa92f94a9dfa0f9016c61 Mon Sep 17 00:00:00 2001 From: Matt Kwong Date: Fri, 6 Oct 2017 11:57:45 -0700 Subject: [PATCH 092/142] Install Mako to generate files in grpc/grpc-node --- .../tools/dockerfile/test/node_jessie_x64/Dockerfile.template | 3 +++ tools/dockerfile/test/node_jessie_x64/Dockerfile | 3 +++ tools/internal_ci/helper_scripts/prepare_build_macos_rc | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/templates/tools/dockerfile/test/node_jessie_x64/Dockerfile.template b/templates/tools/dockerfile/test/node_jessie_x64/Dockerfile.template index aa34a694fb0..af85a542358 100644 --- a/templates/tools/dockerfile/test/node_jessie_x64/Dockerfile.template +++ b/templates/tools/dockerfile/test/node_jessie_x64/Dockerfile.template @@ -32,5 +32,8 @@ <%include file="../../python_deps.include"/> <%include file="../../node_deps.include"/> <%include file="../../run_tests_addons.include"/> + # Install Mako to generate files in grpc/grpc-node + RUN pip install Mako + # Define the default command. CMD ["bash"] diff --git a/tools/dockerfile/test/node_jessie_x64/Dockerfile b/tools/dockerfile/test/node_jessie_x64/Dockerfile index 4f18dbae794..d0e5af64cc1 100644 --- a/tools/dockerfile/test/node_jessie_x64/Dockerfile +++ b/tools/dockerfile/test/node_jessie_x64/Dockerfile @@ -102,5 +102,8 @@ RUN ln -s /usr/bin/ccache /usr/local/bin/clang++ RUN mkdir /var/local/jenkins +# Install Mako to generate files in grpc/grpc-node +RUN pip install Mako + # Define the default command. CMD ["bash"] diff --git a/tools/internal_ci/helper_scripts/prepare_build_macos_rc b/tools/internal_ci/helper_scripts/prepare_build_macos_rc index dd98a12c65a..b6cc43e0ab0 100644 --- a/tools/internal_ci/helper_scripts/prepare_build_macos_rc +++ b/tools/internal_ci/helper_scripts/prepare_build_macos_rc @@ -60,7 +60,7 @@ pod repo update # needed by python # python pip install virtualenv --user python -pip install -U six tox setuptools twisted pyyaml --user python +pip install -U Mako six tox setuptools twisted pyyaml --user python export PYTHONPATH=/Library/Python/3.4/site-packages # set xcode version for Obj-C tests From 0f4d34493ef973a5aa70d3422cffd2c77068821f Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 6 Oct 2017 13:10:20 -0700 Subject: [PATCH 093/142] extern C for gpr_default_log in android --- src/core/lib/support/log_android.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/support/log_android.cc b/src/core/lib/support/log_android.cc index 6f1cec51f17..ca66eb15a13 100644 --- a/src/core/lib/support/log_android.cc +++ b/src/core/lib/support/log_android.cc @@ -50,7 +50,7 @@ void gpr_log(const char *file, int line, gpr_log_severity severity, free(message); } -void gpr_default_log(gpr_log_func_args *args) { +extern "C" void gpr_default_log(gpr_log_func_args *args) { char *final_slash; const char *display_file; char *output = NULL; From 56f8da0f9616ddea110a713a8daf2398493e7b8f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 6 Oct 2017 13:10:59 -0700 Subject: [PATCH 094/142] Import fixes --- src/core/lib/iomgr/block_annotate.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/core/lib/iomgr/block_annotate.h b/src/core/lib/iomgr/block_annotate.h index cbcb5d92f09..fcbfe9eb1a0 100644 --- a/src/core/lib/iomgr/block_annotate.h +++ b/src/core/lib/iomgr/block_annotate.h @@ -39,9 +39,14 @@ void gpr_thd_end_blocking_region(); do { \ gpr_thd_start_blocking_region(); \ } while (0) -#define GRPC_SCHEDULING_END_BLOCKING_REGION \ - do { \ - gpr_thd_end_blocking_region(); \ +#define GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX \ + do { \ + gpr_thd_end_blocking_region(); \ + } while (0) +#define GRPC_SCHEDULING_END_BLOCKING_REGION_WITH_EXEC_CTX(ec) \ + do { \ + gpr_thd_end_blocking_region(); \ + grpc_exec_ctx_invalidate_now((ec)); \ } while (0) #else #define GRPC_SCHEDULING_START_BLOCKING_REGION \ From 54b8cfc9060f8a219a224d7e4dbb98d4763d1857 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 6 Oct 2017 13:15:52 -0700 Subject: [PATCH 095/142] Missing extern C --- src/core/lib/support/log_android.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/support/log_android.cc b/src/core/lib/support/log_android.cc index ca66eb15a13..fab37bf841e 100644 --- a/src/core/lib/support/log_android.cc +++ b/src/core/lib/support/log_android.cc @@ -39,7 +39,7 @@ static android_LogPriority severity_to_log_priority(gpr_log_severity severity) { return ANDROID_LOG_DEFAULT; } -void gpr_log(const char *file, int line, gpr_log_severity severity, +extern "C" void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format, ...) { char *message = NULL; va_list args; From 598cbd882d5fc8caf7e72e8186c1896d4af1824c Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 6 Oct 2017 13:20:29 -0700 Subject: [PATCH 096/142] Clang tidy --- src/core/lib/support/log_android.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/support/log_android.cc b/src/core/lib/support/log_android.cc index fab37bf841e..fed535d0d22 100644 --- a/src/core/lib/support/log_android.cc +++ b/src/core/lib/support/log_android.cc @@ -40,7 +40,7 @@ static android_LogPriority severity_to_log_priority(gpr_log_severity severity) { } extern "C" void gpr_log(const char *file, int line, gpr_log_severity severity, - const char *format, ...) { + const char *format, ...) { char *message = NULL; va_list args; va_start(args, format); From 00181bd0369a34c59532737dd1a6c57fb6065331 Mon Sep 17 00:00:00 2001 From: Adele Zhou Date: Tue, 3 Oct 2017 14:04:07 -0700 Subject: [PATCH 097/142] Added cloud gateway4 backend and auth tests --- tools/interop_matrix/create_testcases.sh | 15 ++++++++++++--- tools/interop_matrix/testcases/cxx__master | 19 ++++++++++++++++++- tools/interop_matrix/testcases/go__master | 19 ++++++++++++++++++- tools/interop_matrix/testcases/java__master | 19 ++++++++++++++++++- 4 files changed, 66 insertions(+), 6 deletions(-) diff --git a/tools/interop_matrix/create_testcases.sh b/tools/interop_matrix/create_testcases.sh index d06fb34ff9a..e89bad93cce 100755 --- a/tools/interop_matrix/create_testcases.sh +++ b/tools/interop_matrix/create_testcases.sh @@ -31,9 +31,10 @@ TESTCASES_DIR=${GRPC_ROOT}/tools/interop_matrix/testcases echo "Create '$LANG' test cases for gRPC release '${RELEASE:=master}'" +echo $client_lang # Invoke run_interop_test in manual mode. ${GRPC_ROOT}/tools/run_tests/run_interop_tests.py -l $LANG --use_docker \ - --cloud_to_prod --manual_run + --cloud_to_prod --cloud_to_prod_auth --prod_servers default cloud_gateway_v4 --manual_run # Clean up function cleanup { @@ -52,11 +53,19 @@ function cleanup { [ -e "$CMDS_SH" ] && rm $CMDS_SH } trap cleanup EXIT +# TODO(adelez): skip sanity checks b/c auth tests only work in GCE. Need to be +# able to filter them out and bring back the check. # Running the testcases as sanity unless we are asked to skip. -[ -z "$SKIP_TEST" ] && (echo "Running test cases: $CMDS_SH"; sh $CMDS_SH) +#[ -z "$SKIP_TEST" ] && (echo "Running test cases: $CMDS_SH"; sh $CMDS_SH) +# Convert c++ to cxx. +client_lang=$LANG +if [ $LANG=="c++" ] + then + client_lang="cxx" +fi mkdir -p $TESTCASES_DIR -testcase=$TESTCASES_DIR/${LANG}__$RELEASE +testcase=$TESTCASES_DIR/${client_lang}__$RELEASE if [ -e $testcase ]; then echo "Updating: $testcase" diff $testcase $CMDS_SH || true diff --git a/tools/interop_matrix/testcases/cxx__master b/tools/interop_matrix/testcases/cxx__master index ccd28595301..2f2fc969b1d 100755 --- a/tools/interop_matrix/testcases/cxx__master +++ b/tools/interop_matrix/testcases/cxx__master @@ -1,5 +1,5 @@ #!/bin/bash -echo "Testing ${docker_image:=grpc_interop_cxx:1423f288-ac00-4f3a-9885-771258eecae3}" +echo "Testing ${docker_image:=grpc_interop_cxx:ff1e1fd8-fbc5-4499-85eb-565a1f02e7ab}" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" @@ -9,3 +9,20 @@ docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=compute_engine_creds --oauth_scope=https://www.googleapis.com/auth/xapi.zoo --default_service_account=830293263384-compute@developer.gserviceaccount.com" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=jwt_token_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=oauth2_auth_token --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo --default_service_account=830293263384-compute@developer.gserviceaccount.com" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=per_rpc_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=compute_engine_creds --oauth_scope=https://www.googleapis.com/auth/xapi.zoo --default_service_account=830293263384-compute@developer.gserviceaccount.com" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=jwt_token_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=oauth2_auth_token --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo --default_service_account=830293263384-compute@developer.gserviceaccount.com" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=per_rpc_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" diff --git a/tools/interop_matrix/testcases/go__master b/tools/interop_matrix/testcases/go__master index 2624c7f92c5..a6bb5ee9d9f 100755 --- a/tools/interop_matrix/testcases/go__master +++ b/tools/interop_matrix/testcases/go__master @@ -1,5 +1,5 @@ #!/bin/bash -echo "Testing ${docker_image:=grpc_interop_go:41fffd01-a6c8-41b6-8136-c0aaa1ec2437}" +echo "Testing ${docker_image:=grpc_interop_go:e7e7cdbd-56bd-490e-b33a-dd27e4cfb9c3}" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" @@ -9,3 +9,20 @@ docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=h docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=compute_engine_creds --oauth_scope=https://www.googleapis.com/auth/xapi.zoo --default_service_account=830293263384-compute@developer.gserviceaccount.com" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=jwt_token_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=oauth2_auth_token --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=per_rpc_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=compute_engine_creds --oauth_scope=https://www.googleapis.com/auth/xapi.zoo --default_service_account=830293263384-compute@developer.gserviceaccount.com" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=jwt_token_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=oauth2_auth_token --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=per_rpc_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" diff --git a/tools/interop_matrix/testcases/java__master b/tools/interop_matrix/testcases/java__master index cf431646e9a..9dab1e39d20 100755 --- a/tools/interop_matrix/testcases/java__master +++ b/tools/interop_matrix/testcases/java__master @@ -1,5 +1,5 @@ #!/bin/bash -echo "Testing ${docker_image:=grpc_interop_java:ea528843-be34-4ff3-a136-e4609424e061}" +echo "Testing ${docker_image:=grpc_interop_java:8541e45e-5275-43cb-a017-d4dde2d98f2f}" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" @@ -9,3 +9,20 @@ docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_i docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=compute_engine_creds --oauth_scope=https://www.googleapis.com/auth/xapi.zoo --default_service_account=830293263384-compute@developer.gserviceaccount.com" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=jwt_token_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=oauth2_auth_token --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=per_rpc_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=compute_engine_creds --oauth_scope=https://www.googleapis.com/auth/xapi.zoo --default_service_account=830293263384-compute@developer.gserviceaccount.com" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=jwt_token_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=oauth2_auth_token --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=per_rpc_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" From 744b656e6c316c6119c4dab0010dcc3cf301e538 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 6 Oct 2017 14:42:36 -0700 Subject: [PATCH 098/142] const required in log_android.cc --- src/core/lib/support/log_android.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/support/log_android.cc b/src/core/lib/support/log_android.cc index fed535d0d22..9e8529cbac8 100644 --- a/src/core/lib/support/log_android.cc +++ b/src/core/lib/support/log_android.cc @@ -51,7 +51,7 @@ extern "C" void gpr_log(const char *file, int line, gpr_log_severity severity, } extern "C" void gpr_default_log(gpr_log_func_args *args) { - char *final_slash; + const char *final_slash; const char *display_file; char *output = NULL; From a9712ba7ffb8b97c4b963ce894263914d3f42003 Mon Sep 17 00:00:00 2001 From: Matt Kwong Date: Wed, 4 Oct 2017 11:46:36 -0700 Subject: [PATCH 099/142] Add uploading interop result to BQ --- .../internal_ci/linux/grpc_interop_tocloud.sh | 7 ++- .../internal_ci/linux/grpc_interop_toprod.sh | 5 ++ .../python_utils/upload_test_results.py | 51 +++++++++++++++++++ tools/run_tests/run_interop_tests.py | 12 +++++ 4 files changed, 74 insertions(+), 1 deletion(-) diff --git a/tools/internal_ci/linux/grpc_interop_tocloud.sh b/tools/internal_ci/linux/grpc_interop_tocloud.sh index e3ba25af5df..c69c3fbea88 100755 --- a/tools/internal_ci/linux/grpc_interop_tocloud.sh +++ b/tools/internal_ci/linux/grpc_interop_tocloud.sh @@ -23,4 +23,9 @@ cd $(dirname $0)/../../.. source tools/internal_ci/helper_scripts/prepare_build_linux_rc source tools/internal_ci/helper_scripts/prepare_build_interop_rc -tools/run_tests/run_interop_tests.py -l all -s all --use_docker --http2_interop --internal_ci -t -j 12 $@ +tools/run_tests/run_interop_tests.py \ + -l all \ + -s all \ + --use_docker \ + --bq_result_table interop_test \ + --http2_interop --internal_ci -t -j 12 $@ diff --git a/tools/internal_ci/linux/grpc_interop_toprod.sh b/tools/internal_ci/linux/grpc_interop_toprod.sh index 97a7d5d2393..4f6fcf87dde 100755 --- a/tools/internal_ci/linux/grpc_interop_toprod.sh +++ b/tools/internal_ci/linux/grpc_interop_toprod.sh @@ -28,5 +28,10 @@ tools/run_tests/run_interop_tests.py \ --cloud_to_prod \ --cloud_to_prod_auth \ --prod_servers default gateway_v4 \ +<<<<<<< HEAD --use_docker --internal_ci --allow_flakes -t -j 12 $@ +======= + --bq_result_table interop_test \ + --use_docker --internal_ci -t -j 12 $@ +>>>>>>> Add uploading interop result to BQ diff --git a/tools/run_tests/python_utils/upload_test_results.py b/tools/run_tests/python_utils/upload_test_results.py index 15e827769e1..ea97bc0aec1 100644 --- a/tools/run_tests/python_utils/upload_test_results.py +++ b/tools/run_tests/python_utils/upload_test_results.py @@ -51,6 +51,19 @@ _RESULTS_SCHEMA = [ ('cpu_measured', 'FLOAT', 'Actual CPU usage of test'), ('return_code', 'INTEGER', 'Exit code of test'), ] +_INTEROP_RESULTS_SCHEMA = [ + ('job_name', 'STRING', 'Name of Jenkins/Kokoro job'), + ('build_id', 'INTEGER', 'Build ID of Jenkins/Kokoro job'), + ('build_url', 'STRING', 'URL of Jenkins/Kokoro job'), + ('test_name', 'STRING', 'Unique test name combining client, server, and test_name'), + ('suite', 'STRING', 'Test suite: cloud_to_cloud, cloud_to_prod, or cloud_to_prod_auth'), + ('client', 'STRING', 'Client language'), + ('server', 'STRING', 'Server host name'), + ('test_case', 'STRING', 'Name of test case'), + ('result', 'STRING', 'Test result: PASSED, TIMEOUT, FAILED, or SKIPPED'), + ('timestamp', 'TIMESTAMP', 'Timestamp of test run'), + ('elapsed_time', 'FLOAT', 'How long test took to run'), +] def _get_build_metadata(test_results): @@ -114,3 +127,41 @@ def upload_results_to_bq(resultset, bq_table, args, platform): else: print('Error uploading result to bigquery, all attempts failed.') sys.exit(1) + + +def upload_interop_results_to_bq(resultset, bq_table, args): + """Upload interop test results to a BQ table. + + Args: + resultset: dictionary generated by jobset.run + bq_table: string name of table to create/upload results to in BQ + args: args in run_interop_tests.py, generated by argparse + """ + bq = big_query_utils.create_big_query() + big_query_utils.create_partitioned_table(bq, _PROJECT_ID, _DATASET_ID, bq_table, _INTEROP_RESULTS_SCHEMA, _DESCRIPTION, + partition_type=_PARTITION_TYPE, expiration_ms= _EXPIRATION_MS) + + for shortname, results in six.iteritems(resultset): + for result in results: + test_results = {} + _get_build_metadata(test_results) + test_results['elapsed_time'] = '%.2f' % result.elapsed_time + test_results['result'] = result.state + test_results['test_name'] = shortname + test_results['suite'] = shortname.split(':')[0] + test_results['client'] = shortname.split(':')[1] + test_results['server'] = shortname.split(':')[2] + test_results['test_case'] = shortname.split(':')[3] + test_results['timestamp'] = time.strftime('%Y-%m-%d %H:%M:%S') + row = big_query_utils.make_row(str(uuid.uuid4()), test_results) + # TODO(jtattermusch): rows are inserted one by one, very inefficient + max_retries = 3 + for attempt in range(max_retries): + if big_query_utils.insert_rows(bq, _PROJECT_ID, _DATASET_ID, bq_table, [row]): + break + else: + if attempt < max_retries - 1: + print('Error uploading result to bigquery, will retry.') + else: + print('Error uploading result to bigquery, all attempts failed.') + sys.exit(1) diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py index 1537641aee9..192f8e76eb4 100755 --- a/tools/run_tests/run_interop_tests.py +++ b/tools/run_tests/run_interop_tests.py @@ -35,6 +35,11 @@ import traceback import python_utils.dockerjob as dockerjob import python_utils.jobset as jobset import python_utils.report_utils as report_utils +# It's ok to not import because this is only necessary to upload results to BQ. +try: + from python_utils.upload_test_results import upload_interop_results_to_bq +except ImportError as e: + print(e) # Docker doesn't clean up after itself, so we do it on exit. atexit.register(lambda: subprocess.call(['stty', 'echo'])) @@ -956,6 +961,11 @@ argp.add_argument('--internal_ci', const=True, help=('Put reports into subdirectories to improve ' 'presentation of results by Internal CI.')) +argp.add_argument('--bq_result_table', + default='', + type=str, + nargs='?', + help='Upload test results to a specified BQ table.') args = argp.parse_args() servers = set(s for s in itertools.chain.from_iterable(_SERVERS @@ -1205,6 +1215,8 @@ try: num_failures, resultset = jobset.run(jobs, newline_on_success=True, maxjobs=args.jobs, skip_jobs=args.manual_run) + if args.bq_result_table and resultset: + upload_interop_results_to_bq(resultset, args.bq_result_table, args) if num_failures: jobset.message('FAILED', 'Some tests failed', do_newline=True) else: From d0153898231c615d626176c2b3ffc42095eb42c3 Mon Sep 17 00:00:00 2001 From: ZhouyihaiDing Date: Thu, 28 Sep 2017 15:00:15 -0700 Subject: [PATCH 100/142] exclude uploading stats, add unconstained php benchmark php7 build once --- src/php/tests/qps/client.php | 56 ++- .../GPBMetadata/Src/Proto/Grpc/Core/Stats.php | 33 ++ .../Src/Proto/Grpc/Testing/Control.php | 215 ++++++----- .../Src/Proto/Grpc/Testing/ProxyService.php | 21 +- .../Src/Proto/Grpc/Testing/Services.php | 53 ++- .../Src/Proto/Grpc/Testing/Stats.php | 47 +-- .../qps/generated_code/Grpc/Core/Bucket.php | 75 ++++ .../generated_code/Grpc/Core/Histogram.php | 49 +++ .../qps/generated_code/Grpc/Core/Metric.php | 102 +++++ .../qps/generated_code/Grpc/Core/Stats.php | 49 +++ .../Grpc/Testing/BenchmarkServiceClient.php | 68 +++- .../generated_code/Grpc/Testing/BoolValue.php | 21 +- .../Grpc/Testing/ByteBufferParams.php | 24 +- .../Grpc/Testing/ChannelArg.php | 34 +- .../Grpc/Testing/ClientArgs.php | 27 +- .../Grpc/Testing/ClientConfig.php | 288 +++++++++----- .../Grpc/Testing/ClientStats.php | 147 ++++++-- .../Grpc/Testing/ClientStatus.php | 15 +- .../Grpc/Testing/ClientType.php | 12 +- .../Grpc/Testing/ClosedLoopParams.php | 4 +- .../Grpc/Testing/ComplexProtoParams.php | 4 +- .../Grpc/Testing/CoreRequest.php | 2 +- .../Grpc/Testing/CoreResponse.php | 19 +- .../Grpc/Testing/EchoStatus.php | 26 +- .../Grpc/Testing/HistogramData.php | 76 ++-- .../Grpc/Testing/HistogramParams.php | 38 +- .../Grpc/Testing/LoadParams.php | 27 +- .../qps/generated_code/Grpc/Testing/Mark.php | 21 +- .../generated_code/Grpc/Testing/Payload.php | 38 +- .../Grpc/Testing/PayloadConfig.php | 38 +- .../Grpc/Testing/PayloadType.php | 8 +- .../Grpc/Testing/PoissonParams.php | 21 +- .../Grpc/Testing/ProxyClientServiceClient.php | 34 +- .../generated_code/Grpc/Testing/ProxyStat.php | 13 +- .../Grpc/Testing/ReconnectInfo.php | 32 +- .../Grpc/Testing/ReconnectParams.php | 15 +- .../ReportQpsScenarioServiceClient.php | 50 +++ .../Grpc/Testing/RequestResultCount.php | 24 +- .../Grpc/Testing/ResponseParameters.php | 57 ++- .../generated_code/Grpc/Testing/RpcType.php | 18 +- .../generated_code/Grpc/Testing/Scenario.php | 144 ++++--- .../Grpc/Testing/ScenarioResult.php | 193 +++++----- .../Grpc/Testing/ScenarioResultSummary.php | 352 ++++++++++++------ .../generated_code/Grpc/Testing/Scenarios.php | 21 +- .../Grpc/Testing/SecurityParams.php | 52 ++- .../Grpc/Testing/ServerArgs.php | 27 +- .../Grpc/Testing/ServerConfig.php | 211 +++++++---- .../Grpc/Testing/ServerStats.php | 151 +++++--- .../Grpc/Testing/ServerStatus.php | 49 +-- .../Grpc/Testing/ServerType.php | 12 +- .../Grpc/Testing/SimpleProtoParams.php | 24 +- .../Grpc/Testing/SimpleRequest.php | 148 ++++---- .../Grpc/Testing/SimpleResponse.php | 57 ++- .../Testing/StreamingInputCallRequest.php | 42 +-- .../Testing/StreamingInputCallResponse.php | 21 +- .../Testing/StreamingOutputCallRequest.php | 82 ++-- .../Testing/StreamingOutputCallResponse.php | 23 +- .../qps/generated_code/Grpc/Testing/Void.php | 2 +- .../Grpc/Testing/WorkerServiceClient.php | 40 +- src/php/tests/qps/histogram.php | 93 +++++ src/proto/grpc/testing/proxy-service.proto | 2 + src/ruby/qps/histogram.rb | 15 + src/ruby/qps/proxy-worker.rb | 50 ++- .../proto/grpc/testing/proxy-service_pb.rb | 1 + .../grpc/testing/proxy-service_services_pb.rb | 1 + tools/jenkins/run_full_performance.sh | 2 +- .../performance/build_performance.sh | 9 + .../performance/build_performance_php7.sh | 30 ++ tools/run_tests/performance/run_worker_php.sh | 12 +- .../run_tests/performance/scenario_config.py | 43 ++- 70 files changed, 2498 insertions(+), 1312 deletions(-) create mode 100644 src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Core/Stats.php create mode 100644 src/php/tests/qps/generated_code/Grpc/Core/Bucket.php create mode 100644 src/php/tests/qps/generated_code/Grpc/Core/Histogram.php create mode 100644 src/php/tests/qps/generated_code/Grpc/Core/Metric.php create mode 100644 src/php/tests/qps/generated_code/Grpc/Core/Stats.php create mode 100644 src/php/tests/qps/generated_code/Grpc/Testing/ReportQpsScenarioServiceClient.php create mode 100644 src/php/tests/qps/histogram.php create mode 100755 tools/run_tests/performance/build_performance_php7.sh diff --git a/src/php/tests/qps/client.php b/src/php/tests/qps/client.php index a785d831b44..08904054eb3 100644 --- a/src/php/tests/qps/client.php +++ b/src/php/tests/qps/client.php @@ -37,6 +37,7 @@ */ require dirname(__FILE__).'/vendor/autoload.php'; +require dirname(__FILE__).'/histogram.php'; /** * Assertion function that always exits with an error code if the assertion is @@ -63,19 +64,19 @@ function hardAssertIfStatusOk($status) } /* Start the actual client */ - -function qps_client_main($proxy_address) { - echo "Initiating php client\n"; +function qps_client_main($proxy_address, $server_ind) { + echo "[php-client] Initiating php client\n"; $proxystubopts = []; $proxystubopts['credentials'] = Grpc\ChannelCredentials::createInsecure(); $proxystub = new Grpc\Testing\ProxyClientServiceClient($proxy_address, $proxystubopts); list($config, $status) = $proxystub->GetConfig(new Grpc\Testing\Void())->wait(); hardAssertIfStatusOk($status); - hardAssert($config->getClientChannels() == 1, "Only 1 channel supported"); hardAssert($config->getOutstandingRpcsPerChannel() == 1, "Only 1 outstanding RPC supported"); - echo "Got configuration from proxy, target is " . $config->getServerTargets()[0] . "\n"; + echo "[php-client] Got configuration from proxy, target is '$server_ind'th server" . $config->getServerTargets()[$server_ind] . "\n"; + $histres = $config->getHistogramParams()->getResolution(); + $histmax = $config->getHistogramParams()->getMaxPossible(); $stubopts = []; if ($config->getSecurityParams()) { @@ -93,10 +94,10 @@ function qps_client_main($proxy_address) { } else { $stubopts['credentials'] = Grpc\ChannelCredentials::createInsecure(); } - echo "Initiating php benchmarking client\n"; + echo "[php-client] Initiating php benchmarking client\n"; $stub = new Grpc\Testing\BenchmarkServiceClient( - $config->getServerTargets()[0], $stubopts); + $config->getServerTargets()[$server_ind], $stubopts); $req = new Grpc\Testing\SimpleRequest(); $req->setResponseType(Grpc\Testing\PayloadType::COMPRESSABLE); @@ -115,8 +116,11 @@ function qps_client_main($proxy_address) { } else { $poisson = false; } - $metric = new Grpc\Testing\ProxyStat; - $telemetry = $proxystub->ReportTime(); + $histogram = new Histogram($histres, $histmax); + $histogram->clean(); + $count = 0; + $histogram_result = new Grpc\Testing\HistogramData; + $telehist = $proxystub->ReportHist(); if ($config->getRpcType() == Grpc\Testing\RpcType::UNARY) { while (1) { if ($poisson) { @@ -126,8 +130,20 @@ function qps_client_main($proxy_address) { $startreq = microtime(true); list($resp,$status) = $stub->UnaryCall($req)->wait(); hardAssertIfStatusOk($status); - $metric->setLatency(microtime(true)-$startreq); - $telemetry->write($metric); + $histogram->add((microtime(true)-$startreq)*1e9); + $count += 1; + if ($count == 2000) { + $contents = $histogram->contents(); + $histogram_result->setBucket($contents); + $histogram_result->setMinSeen($histogram->minimum()); + $histogram_result->setMaxSeen($histogram->maximum()); + $histogram_result->setSum($histogram->sum()); + $histogram_result->setSumOfSquares($histogram->sum_of_squares()); + $histogram_result->setCount($histogram->count()); + $telehist->write($histogram_result); + $histogram->clean(); + $count = 0; + } } } else { $stream = $stub->StreamingCall(); @@ -139,8 +155,20 @@ function qps_client_main($proxy_address) { $startreq = microtime(true); $stream->write($req); $resp = $stream->read(); - $metric->setLatency(microtime(true)-$startreq); - $telemetry->write($metric); + $histogram->add((microtime(true)-$startreq)*1e9); + $count += 1; + if ($count == 2000) { + $contents = $histogram->contents(); + $histogram_result->setBucket($contents); + $histogram_result->setMinSeen($histogram->minimum()); + $histogram_result->setMaxSeen($histogram->maximum()); + $histogram_result->setSum($histogram->sum()); + $histogram_result->setSumOfSquares($histogram->sum_of_squares()); + $histogram_result->setCount($histogram->count()); + $telehist->write($histogram_result); + $histogram->clean(); + $count = 0; + } } } } @@ -148,4 +176,4 @@ function qps_client_main($proxy_address) { ini_set('display_startup_errors', 1); ini_set('display_errors', 1); error_reporting(-1); -qps_client_main($argv[1]); +qps_client_main($argv[1], $argv[2]); diff --git a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Core/Stats.php b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Core/Stats.php new file mode 100644 index 00000000000..f9c710cd4e0 --- /dev/null +++ b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Core/Stats.php @@ -0,0 +1,33 @@ +internalAddGeneratedFile(hex2bin( + "0a97020a1f7372632f70726f746f2f677270632f636f72652f7374617473" . + "2e70726f746f1209677270632e636f726522260a064275636b6574120d0a" . + "057374617274180120012801120d0a05636f756e74180220012804222f0a" . + "09486973746f6772616d12220a076275636b65747318012003280b32112e" . + "677270632e636f72652e4275636b6574225b0a064d6574726963120c0a04" . + "6e616d65180120012809120f0a05636f756e74180a20012804480012290a" . + "09686973746f6772616d180b2001280b32142e677270632e636f72652e48" . + "6973746f6772616d480042070a0576616c7565222b0a0553746174731222" . + "0a076d65747269637318012003280b32112e677270632e636f72652e4d65" . + "74726963620670726f746f33" + )); + + static::$is_initialized = true; + } +} + diff --git a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Control.php b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Control.php index efca18a0cb3..9b3a7529ec7 100644 --- a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Control.php +++ b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Control.php @@ -17,108 +17,119 @@ class Control \GPBMetadata\Src\Proto\Grpc\Testing\Payloads::initOnce(); \GPBMetadata\Src\Proto\Grpc\Testing\Stats::initOnce(); $pool->internalAddGeneratedFile(hex2bin( - "0add170a247372632f70726f746f2f677270632f74657374696e672f636f" . - "6e74726f6c2e70726f746f120c677270632e74657374696e671a25737263" . - "2f70726f746f2f677270632f74657374696e672f7061796c6f6164732e70" . - "726f746f1a227372632f70726f746f2f677270632f74657374696e672f73" . - "746174732e70726f746f22250a0d506f6973736f6e506172616d7312140a" . - "0c6f6666657265645f6c6f616418012001280122120a10436c6f7365644c" . - "6f6f70506172616d73227b0a0a4c6f6164506172616d7312350a0b636c6f" . - "7365645f6c6f6f7018012001280b321e2e677270632e74657374696e672e" . - "436c6f7365644c6f6f70506172616d734800122e0a07706f6973736f6e18" . - "022001280b321b2e677270632e74657374696e672e506f6973736f6e5061" . - "72616d73480042060a046c6f616422430a0e536563757269747950617261" . - "6d7312130a0b7573655f746573745f6361180120012808121c0a14736572" . - "7665725f686f73745f6f76657272696465180220012809224d0a0a436861" . - "6e6e656c417267120c0a046e616d6518012001280912130a097374725f76" . - "616c7565180220012809480012130a09696e745f76616c75651803200128" . - "05480042070a0576616c756522a0040a0c436c69656e74436f6e66696712" . - "160a0e7365727665725f74617267657473180120032809122d0a0b636c69" . - "656e745f7479706518022001280e32182e677270632e74657374696e672e" . - "436c69656e745479706512350a0f73656375726974795f706172616d7318" . - "032001280b321c2e677270632e74657374696e672e536563757269747950" . - "6172616d7312240a1c6f75747374616e64696e675f727063735f7065725f" . - "6368616e6e656c18042001280512170a0f636c69656e745f6368616e6e65" . - "6c73180520012805121c0a146173796e635f636c69656e745f7468726561" . - "647318072001280512270a087270635f7479706518082001280e32152e67" . - "7270632e74657374696e672e52706354797065122d0a0b6c6f61645f7061" . - "72616d73180a2001280b32182e677270632e74657374696e672e4c6f6164" . - "506172616d7312330a0e7061796c6f61645f636f6e666967180b2001280b" . - "321b2e677270632e74657374696e672e5061796c6f6164436f6e66696712" . - "370a10686973746f6772616d5f706172616d73180c2001280b321d2e6772" . - "70632e74657374696e672e486973746f6772616d506172616d7312110a09" . - "636f72655f6c697374180d2003280512120a0a636f72655f6c696d697418" . - "0e2001280512180a106f746865725f636c69656e745f617069180f200128" . - "09122e0a0c6368616e6e656c5f6172677318102003280b32182e67727063" . - "2e74657374696e672e4368616e6e656c41726722380a0c436c69656e7453" . - "746174757312280a05737461747318012001280b32192e677270632e7465" . - "7374696e672e436c69656e74537461747322150a044d61726b120d0a0572" . - "6573657418012001280822680a0a436c69656e7441726773122b0a057365" . - "74757018012001280b321a2e677270632e74657374696e672e436c69656e" . - "74436f6e666967480012220a046d61726b18022001280b32122e67727063" . - "2e74657374696e672e4d61726b480042090a076172677479706522b4020a" . - "0c536572766572436f6e666967122d0a0b7365727665725f747970651801" . - "2001280e32182e677270632e74657374696e672e53657276657254797065" . - "12350a0f73656375726974795f706172616d7318022001280b321c2e6772" . - "70632e74657374696e672e5365637572697479506172616d73120c0a0470" . - "6f7274180420012805121c0a146173796e635f7365727665725f74687265" . - "61647318072001280512120a0a636f72655f6c696d697418082001280512" . - "330a0e7061796c6f61645f636f6e66696718092001280b321b2e67727063" . - "2e74657374696e672e5061796c6f6164436f6e66696712110a09636f7265" . - "5f6c697374180a2003280512180a106f746865725f7365727665725f6170" . - "69180b20012809121c0a137265736f757263655f71756f74615f73697a65" . - "18e9072001280522680a0a53657276657241726773122b0a057365747570" . - "18012001280b321a2e677270632e74657374696e672e536572766572436f" . - "6e666967480012220a046d61726b18022001280b32122e677270632e7465" . - "7374696e672e4d61726b480042090a076172677479706522550a0c536572" . - "76657253746174757312280a05737461747318012001280b32192e677270" . - "632e74657374696e672e5365727665725374617473120c0a04706f727418" . - "0220012805120d0a05636f726573180320012805220d0a0b436f72655265" . - "7175657374221d0a0c436f7265526573706f6e7365120d0a05636f726573" . - "18012001280522060a04566f696422fd010a085363656e6172696f120c0a" . - "046e616d6518012001280912310a0d636c69656e745f636f6e6669671802" . - "2001280b321a2e677270632e74657374696e672e436c69656e74436f6e66" . - "696712130a0b6e756d5f636c69656e747318032001280512310a0d736572" . - "7665725f636f6e66696718042001280b321a2e677270632e74657374696e" . - "672e536572766572436f6e66696712130a0b6e756d5f7365727665727318" . - "052001280512160a0e7761726d75705f7365636f6e647318062001280512" . - "190a1162656e63686d61726b5f7365636f6e647318072001280512200a18" . - "737061776e5f6c6f63616c5f776f726b65725f636f756e74180820012805" . - "22360a095363656e6172696f7312290a097363656e6172696f7318012003" . - "280b32162e677270632e74657374696e672e5363656e6172696f22f8020a" . - "155363656e6172696f526573756c7453756d6d617279120b0a0371707318" . - "0120012801121b0a137170735f7065725f7365727665725f636f72651802" . - "20012801121a0a127365727665725f73797374656d5f74696d6518032001" . - "280112180a107365727665725f757365725f74696d65180420012801121a" . - "0a12636c69656e745f73797374656d5f74696d6518052001280112180a10" . - "636c69656e745f757365725f74696d6518062001280112120a0a6c617465" . - "6e63795f353018072001280112120a0a6c6174656e63795f393018082001" . - "280112120a0a6c6174656e63795f393518092001280112120a0a6c617465" . - "6e63795f3939180a2001280112130a0b6c6174656e63795f393939180b20" . - "01280112180a107365727665725f6370755f7573616765180c2001280112" . - "260a1e7375636365737366756c5f72657175657374735f7065725f736563" . - "6f6e64180d2001280112220a1a6661696c65645f72657175657374735f70" . - "65725f7365636f6e64180e200128012283030a0e5363656e6172696f5265" . - "73756c7412280a087363656e6172696f18012001280b32162e677270632e" . - "74657374696e672e5363656e6172696f122e0a096c6174656e6369657318" . - "022001280b321b2e677270632e74657374696e672e486973746f6772616d" . - "44617461122f0a0c636c69656e745f737461747318032003280b32192e67" . - "7270632e74657374696e672e436c69656e745374617473122f0a0c736572" . - "7665725f737461747318042003280b32192e677270632e74657374696e67" . - "2e536572766572537461747312140a0c7365727665725f636f7265731805" . - "2003280512340a0773756d6d61727918062001280b32232e677270632e74" . - "657374696e672e5363656e6172696f526573756c7453756d6d6172791216" . - "0a0e636c69656e745f7375636365737318072003280812160a0e73657276" . - "65725f7375636365737318082003280812390a0f726571756573745f7265" . - "73756c747318092003280b32202e677270632e74657374696e672e526571" . - "75657374526573756c74436f756e742a410a0a436c69656e745479706512" . - "0f0a0b53594e435f434c49454e54100012100a0c4153594e435f434c4945" . - "4e54100112100a0c4f544845525f434c49454e5410022a5b0a0a53657276" . - "657254797065120f0a0b53594e435f534552564552100012100a0c415359" . - "4e435f534552564552100112180a144153594e435f47454e455249435f53" . - "4552564552100212100a0c4f544845525f53455256455210032a230a0752" . - "70635479706512090a05554e4152591000120d0a0953545245414d494e47" . - "1001620670726f746f33" + "0aa21a0a247372632f70726f746f2f677270632f74657374696e672f636f" . + "6e74726f6c2e70726f746f120c677270632e74657374696e671a22737263" . + "2f70726f746f2f677270632f74657374696e672f73746174732e70726f74" . + "6f22250a0d506f6973736f6e506172616d7312140a0c6f6666657265645f" . + "6c6f616418012001280122120a10436c6f7365644c6f6f70506172616d73" . + "227b0a0a4c6f6164506172616d7312350a0b636c6f7365645f6c6f6f7018" . + "012001280b321e2e677270632e74657374696e672e436c6f7365644c6f6f" . + "70506172616d734800122e0a07706f6973736f6e18022001280b321b2e67" . + "7270632e74657374696e672e506f6973736f6e506172616d73480042060a" . + "046c6f616422560a0e5365637572697479506172616d7312130a0b757365" . + "5f746573745f6361180120012808121c0a147365727665725f686f73745f" . + "6f7665727269646518022001280912110a09637265645f74797065180320" . + "012809224d0a0a4368616e6e656c417267120c0a046e616d651801200128" . + "0912130a097374725f76616c7565180220012809480012130a09696e745f" . + "76616c7565180320012805480042070a0576616c756522d5040a0c436c69" . + "656e74436f6e66696712160a0e7365727665725f74617267657473180120" . + "032809122d0a0b636c69656e745f7479706518022001280e32182e677270" . + "632e74657374696e672e436c69656e745479706512350a0f736563757269" . + "74795f706172616d7318032001280b321c2e677270632e74657374696e67" . + "2e5365637572697479506172616d7312240a1c6f75747374616e64696e67" . + "5f727063735f7065725f6368616e6e656c18042001280512170a0f636c69" . + "656e745f6368616e6e656c73180520012805121c0a146173796e635f636c" . + "69656e745f7468726561647318072001280512270a087270635f74797065" . + "18082001280e32152e677270632e74657374696e672e5270635479706512" . + "2d0a0b6c6f61645f706172616d73180a2001280b32182e677270632e7465" . + "7374696e672e4c6f6164506172616d7312330a0e7061796c6f61645f636f" . + "6e666967180b2001280b321b2e677270632e74657374696e672e5061796c" . + "6f6164436f6e66696712370a10686973746f6772616d5f706172616d7318" . + "0c2001280b321d2e677270632e74657374696e672e486973746f6772616d" . + "506172616d7312110a09636f72655f6c697374180d2003280512120a0a63" . + "6f72655f6c696d6974180e2001280512180a106f746865725f636c69656e" . + "745f617069180f20012809122e0a0c6368616e6e656c5f61726773181020" . + "03280b32182e677270632e74657374696e672e4368616e6e656c41726712" . + "160a0e746872656164735f7065725f6371181120012805121b0a136d6573" . + "73616765735f7065725f73747265616d18122001280522380a0c436c6965" . + "6e7453746174757312280a05737461747318012001280b32192e67727063" . + "2e74657374696e672e436c69656e74537461747322150a044d61726b120d" . + "0a05726573657418012001280822680a0a436c69656e7441726773122b0a" . + "05736574757018012001280b321a2e677270632e74657374696e672e436c" . + "69656e74436f6e666967480012220a046d61726b18022001280b32122e67" . + "7270632e74657374696e672e4d61726b480042090a076172677479706522" . + "fd020a0c536572766572436f6e666967122d0a0b7365727665725f747970" . + "6518012001280e32182e677270632e74657374696e672e53657276657254" . + "79706512350a0f73656375726974795f706172616d7318022001280b321c" . + "2e677270632e74657374696e672e5365637572697479506172616d73120c" . + "0a04706f7274180420012805121c0a146173796e635f7365727665725f74" . + "68726561647318072001280512120a0a636f72655f6c696d697418082001" . + "280512330a0e7061796c6f61645f636f6e66696718092001280b321b2e67" . + "7270632e74657374696e672e5061796c6f6164436f6e66696712110a0963" . + "6f72655f6c697374180a2003280512180a106f746865725f736572766572" . + "5f617069180b2001280912160a0e746872656164735f7065725f6371180c" . + "20012805121c0a137265736f757263655f71756f74615f73697a6518e907" . + "20012805122f0a0c6368616e6e656c5f6172677318ea072003280b32182e" . + "677270632e74657374696e672e4368616e6e656c41726722680a0a536572" . + "76657241726773122b0a05736574757018012001280b321a2e677270632e" . + "74657374696e672e536572766572436f6e666967480012220a046d61726b" . + "18022001280b32122e677270632e74657374696e672e4d61726b48004209" . + "0a076172677479706522550a0c53657276657253746174757312280a0573" . + "7461747318012001280b32192e677270632e74657374696e672e53657276" . + "65725374617473120c0a04706f7274180220012805120d0a05636f726573" . + "180320012805220d0a0b436f726552657175657374221d0a0c436f726552" . + "6573706f6e7365120d0a05636f72657318012001280522060a04566f6964" . + "22fd010a085363656e6172696f120c0a046e616d6518012001280912310a" . + "0d636c69656e745f636f6e66696718022001280b321a2e677270632e7465" . + "7374696e672e436c69656e74436f6e66696712130a0b6e756d5f636c6965" . + "6e747318032001280512310a0d7365727665725f636f6e66696718042001" . + "280b321a2e677270632e74657374696e672e536572766572436f6e666967" . + "12130a0b6e756d5f7365727665727318052001280512160a0e7761726d75" . + "705f7365636f6e647318062001280512190a1162656e63686d61726b5f73" . + "65636f6e647318072001280512200a18737061776e5f6c6f63616c5f776f" . + "726b65725f636f756e7418082001280522360a095363656e6172696f7312" . + "290a097363656e6172696f7318012003280b32162e677270632e74657374" . + "696e672e5363656e6172696f2284040a155363656e6172696f526573756c" . + "7453756d6d617279120b0a03717073180120012801121b0a137170735f70" . + "65725f7365727665725f636f7265180220012801121a0a12736572766572" . + "5f73797374656d5f74696d6518032001280112180a107365727665725f75" . + "7365725f74696d65180420012801121a0a12636c69656e745f7379737465" . + "6d5f74696d6518052001280112180a10636c69656e745f757365725f7469" . + "6d6518062001280112120a0a6c6174656e63795f35301807200128011212" . + "0a0a6c6174656e63795f393018082001280112120a0a6c6174656e63795f" . + "393518092001280112120a0a6c6174656e63795f3939180a200128011213" . + "0a0b6c6174656e63795f393939180b2001280112180a107365727665725f" . + "6370755f7573616765180c2001280112260a1e7375636365737366756c5f" . + "72657175657374735f7065725f7365636f6e64180d2001280112220a1a66" . + "61696c65645f72657175657374735f7065725f7365636f6e64180e200128" . + "0112200a18636c69656e745f706f6c6c735f7065725f7265717565737418" . + "0f2001280112200a187365727665725f706f6c6c735f7065725f72657175" . + "65737418102001280112220a1a7365727665725f717565726965735f7065" . + "725f6370755f73656318112001280112220a1a636c69656e745f71756572" . + "6965735f7065725f6370755f7365631812200128012283030a0e5363656e" . + "6172696f526573756c7412280a087363656e6172696f18012001280b3216" . + "2e677270632e74657374696e672e5363656e6172696f122e0a096c617465" . + "6e6369657318022001280b321b2e677270632e74657374696e672e486973" . + "746f6772616d44617461122f0a0c636c69656e745f737461747318032003" . + "280b32192e677270632e74657374696e672e436c69656e74537461747312" . + "2f0a0c7365727665725f737461747318042003280b32192e677270632e74" . + "657374696e672e536572766572537461747312140a0c7365727665725f63" . + "6f72657318052003280512340a0773756d6d61727918062001280b32232e" . + "677270632e74657374696e672e5363656e6172696f526573756c7453756d" . + "6d61727912160a0e636c69656e745f737563636573731807200328081216" . + "0a0e7365727665725f7375636365737318082003280812390a0f72657175" . + "6573745f726573756c747318092003280b32202e677270632e7465737469" . + "6e672e52657175657374526573756c74436f756e742a410a0a436c69656e" . + "7454797065120f0a0b53594e435f434c49454e54100012100a0c4153594e" . + "435f434c49454e54100112100a0c4f544845525f434c49454e5410022a5b" . + "0a0a53657276657254797065120f0a0b53594e435f534552564552100012" . + "100a0c4153594e435f534552564552100112180a144153594e435f47454e" . + "455249435f534552564552100212100a0c4f544845525f53455256455210" . + "032a720a075270635479706512090a05554e4152591000120d0a09535452" . + "45414d494e47100112190a1553545245414d494e475f46524f4d5f434c49" . + "454e54100212190a1553545245414d494e475f46524f4d5f534552564552" . + "100312170a1353545245414d494e475f424f54485f574159531004620670" . + "726f746f33" )); static::$is_initialized = true; diff --git a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/ProxyService.php b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/ProxyService.php index e35944e1d82..e07f73679ea 100644 --- a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/ProxyService.php +++ b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/ProxyService.php @@ -15,17 +15,20 @@ class ProxyService return; } \GPBMetadata\Src\Proto\Grpc\Testing\Control::initOnce(); + \GPBMetadata\Src\Proto\Grpc\Testing\Stats::initOnce(); $pool->internalAddGeneratedFile(hex2bin( - "0a97020a2a7372632f70726f746f2f677270632f74657374696e672f7072" . + "0ad6020a2a7372632f70726f746f2f677270632f74657374696e672f7072" . "6f78792d736572766963652e70726f746f120c677270632e74657374696e" . - "671a247372632f70726f746f2f677270632f74657374696e672f636f6e74" . - "726f6c2e70726f746f221c0a0950726f787953746174120f0a076c617465" . - "6e6379180120012801328e010a1250726f7879436c69656e745365727669" . - "6365123b0a09476574436f6e66696712122e677270632e74657374696e67" . - "2e566f69641a1a2e677270632e74657374696e672e436c69656e74436f6e" . - "666967123b0a0a5265706f727454696d6512172e677270632e7465737469" . - "6e672e50726f7879537461741a122e677270632e74657374696e672e566f" . - "69642801620670726f746f33" + "671a227372632f70726f746f2f677270632f74657374696e672f73746174" . + "732e70726f746f221c0a0950726f787953746174120f0a076c6174656e63" . + "7918012001280132cf010a1250726f7879436c69656e7453657276696365" . + "123b0a09476574436f6e66696712122e677270632e74657374696e672e56" . + "6f69641a1a2e677270632e74657374696e672e436c69656e74436f6e6669" . + "67123b0a0a5265706f727454696d6512172e677270632e74657374696e67" . + "2e50726f7879537461741a122e677270632e74657374696e672e566f6964" . + "2801123f0a0a5265706f727448697374121b2e677270632e74657374696e" . + "672e486973746f6772616d446174611a122e677270632e74657374696e67" . + "2e566f69642801620670726f746f33" )); static::$is_initialized = true; diff --git a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Services.php b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Services.php index 7a9439a5b93..e4029182c74 100644 --- a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Services.php +++ b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Services.php @@ -16,27 +16,40 @@ class Services } \GPBMetadata\Src\Proto\Grpc\Testing\Messages::initOnce(); \GPBMetadata\Src\Proto\Grpc\Testing\Control::initOnce(); + \GPBMetadata\Src\Proto\Grpc\Testing\Stats::initOnce(); $pool->internalAddGeneratedFile(hex2bin( - "0ad1040a257372632f70726f746f2f677270632f74657374696e672f7365" . - "7276696365732e70726f746f120c677270632e74657374696e671a257372" . - "632f70726f746f2f677270632f74657374696e672f6d657373616765732e" . - "70726f746f1a247372632f70726f746f2f677270632f74657374696e672f" . - "636f6e74726f6c2e70726f746f32aa010a1042656e63686d61726b536572" . - "7669636512460a09556e61727943616c6c121b2e677270632e7465737469" . - "6e672e53696d706c65526571756573741a1c2e677270632e74657374696e" . - "672e53696d706c65526573706f6e7365124e0a0d53747265616d696e6743" . - "616c6c121b2e677270632e74657374696e672e53696d706c655265717565" . - "73741a1c2e677270632e74657374696e672e53696d706c65526573706f6e" . - "7365280130013297020a0d576f726b65725365727669636512450a095275" . - "6e53657276657212182e677270632e74657374696e672e53657276657241" . - "7267731a1a2e677270632e74657374696e672e5365727665725374617475" . - "732801300112450a0952756e436c69656e7412182e677270632e74657374" . - "696e672e436c69656e74417267731a1a2e677270632e74657374696e672e" . - "436c69656e745374617475732801300112420a09436f7265436f756e7412" . - "192e677270632e74657374696e672e436f7265526571756573741a1a2e67" . - "7270632e74657374696e672e436f7265526573706f6e736512340a0a5175" . - "6974576f726b657212122e677270632e74657374696e672e566f69641a12" . - "2e677270632e74657374696e672e566f6964620670726f746f33" + "0aaa070a257372632f70726f746f2f677270632f74657374696e672f7365" . + "7276696365732e70726f746f120c677270632e74657374696e671a247372" . + "632f70726f746f2f677270632f74657374696e672f636f6e74726f6c2e70" . + "726f746f1a227372632f70726f746f2f677270632f74657374696e672f73" . + "746174732e70726f746f32a6030a1042656e63686d61726b536572766963" . + "6512460a09556e61727943616c6c121b2e677270632e74657374696e672e" . + "53696d706c65526571756573741a1c2e677270632e74657374696e672e53" . + "696d706c65526573706f6e7365124e0a0d53747265616d696e6743616c6c" . + "121b2e677270632e74657374696e672e53696d706c65526571756573741a" . + "1c2e677270632e74657374696e672e53696d706c65526573706f6e736528" . + "01300112520a1353747265616d696e6746726f6d436c69656e74121b2e67" . + "7270632e74657374696e672e53696d706c65526571756573741a1c2e6772" . + "70632e74657374696e672e53696d706c65526573706f6e7365280112520a" . + "1353747265616d696e6746726f6d536572766572121b2e677270632e7465" . + "7374696e672e53696d706c65526571756573741a1c2e677270632e746573" . + "74696e672e53696d706c65526573706f6e7365300112520a115374726561" . + "6d696e67426f746857617973121b2e677270632e74657374696e672e5369" . + "6d706c65526571756573741a1c2e677270632e74657374696e672e53696d" . + "706c65526573706f6e7365280130013297020a0d576f726b657253657276" . + "69636512450a0952756e53657276657212182e677270632e74657374696e" . + "672e536572766572417267731a1a2e677270632e74657374696e672e5365" . + "727665725374617475732801300112450a0952756e436c69656e7412182e" . + "677270632e74657374696e672e436c69656e74417267731a1a2e67727063" . + "2e74657374696e672e436c69656e745374617475732801300112420a0943" . + "6f7265436f756e7412192e677270632e74657374696e672e436f72655265" . + "71756573741a1a2e677270632e74657374696e672e436f7265526573706f" . + "6e736512340a0a51756974576f726b657212122e677270632e7465737469" . + "6e672e566f69641a122e677270632e74657374696e672e566f6964325e0a" . + "185265706f72745170735363656e6172696f5365727669636512420a0e52" . + "65706f72745363656e6172696f121c2e677270632e74657374696e672e53" . + "63656e6172696f526573756c741a122e677270632e74657374696e672e56" . + "6f6964620670726f746f33" )); static::$is_initialized = true; diff --git a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Stats.php b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Stats.php index 99c0000a52c..3d23b75dfa0 100644 --- a/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Stats.php +++ b/src/php/tests/qps/generated_code/GPBMetadata/Src/Proto/Grpc/Testing/Stats.php @@ -14,28 +14,33 @@ class Stats if (static::$is_initialized == true) { return; } + \GPBMetadata\Src\Proto\Grpc\Core\Stats::initOnce(); $pool->internalAddGeneratedFile(hex2bin( - "0adf040a227372632f70726f746f2f677270632f74657374696e672f7374" . - "6174732e70726f746f120c677270632e74657374696e67227a0a0b536572" . - "766572537461747312140a0c74696d655f656c6170736564180120012801" . - "12110a0974696d655f7573657218022001280112130a0b74696d655f7379" . - "7374656d18032001280112160a0e746f74616c5f6370755f74696d651804" . - "2001280412150a0d69646c655f6370755f74696d65180520012804223b0a" . - "0f486973746f6772616d506172616d7312120a0a7265736f6c7574696f6e" . - "18012001280112140a0c6d61785f706f737369626c651802200128012277" . - "0a0d486973746f6772616d44617461120e0a066275636b65741801200328" . - "0d12100a086d696e5f7365656e18022001280112100a086d61785f736565" . - "6e180320012801120b0a0373756d18042001280112160a0e73756d5f6f66" . - "5f73717561726573180520012801120d0a05636f756e7418062001280122" . - "380a1252657175657374526573756c74436f756e7412130a0b7374617475" . - "735f636f6465180120012805120d0a05636f756e7418022001280322b601" . - "0a0b436c69656e745374617473122e0a096c6174656e6369657318012001" . - "280b321b2e677270632e74657374696e672e486973746f6772616d446174" . - "6112140a0c74696d655f656c617073656418022001280112110a0974696d" . - "655f7573657218032001280112130a0b74696d655f73797374656d180420" . - "01280112390a0f726571756573745f726573756c747318052003280b3220" . - "2e677270632e74657374696e672e52657175657374526573756c74436f75" . - "6e74620670726f746f33" + "0ada050a227372632f70726f746f2f677270632f74657374696e672f7374" . + "6174732e70726f746f120c677270632e74657374696e6722b7010a0b5365" . + "72766572537461747312140a0c74696d655f656c61707365641801200128" . + "0112110a0974696d655f7573657218022001280112130a0b74696d655f73" . + "797374656d18032001280112160a0e746f74616c5f6370755f74696d6518" . + "042001280412150a0d69646c655f6370755f74696d651805200128041215" . + "0a0d63715f706f6c6c5f636f756e7418062001280412240a0a636f72655f" . + "737461747318072001280b32102e677270632e636f72652e537461747322" . + "3b0a0f486973746f6772616d506172616d7312120a0a7265736f6c757469" . + "6f6e18012001280112140a0c6d61785f706f737369626c65180220012801" . + "22770a0d486973746f6772616d44617461120e0a066275636b6574180120" . + "03280d12100a086d696e5f7365656e18022001280112100a086d61785f73" . + "65656e180320012801120b0a0373756d18042001280112160a0e73756d5f" . + "6f665f73717561726573180520012801120d0a05636f756e741806200128" . + "0122380a1252657175657374526573756c74436f756e7412130a0b737461" . + "7475735f636f6465180120012805120d0a05636f756e7418022001280322" . + "f3010a0b436c69656e745374617473122e0a096c6174656e636965731801" . + "2001280b321b2e677270632e74657374696e672e486973746f6772616d44" . + "61746112140a0c74696d655f656c617073656418022001280112110a0974" . + "696d655f7573657218032001280112130a0b74696d655f73797374656d18" . + "042001280112390a0f726571756573745f726573756c747318052003280b" . + "32202e677270632e74657374696e672e52657175657374526573756c7443" . + "6f756e7412150a0d63715f706f6c6c5f636f756e7418062001280412240a" . + "0a636f72655f737461747318072001280b32102e677270632e636f72652e" . + "5374617473620670726f746f33" )); static::$is_initialized = true; diff --git a/src/php/tests/qps/generated_code/Grpc/Core/Bucket.php b/src/php/tests/qps/generated_code/Grpc/Core/Bucket.php new file mode 100644 index 00000000000..897d6271c28 --- /dev/null +++ b/src/php/tests/qps/generated_code/Grpc/Core/Bucket.php @@ -0,0 +1,75 @@ +grpc.core.Bucket + */ +class Bucket extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field double start = 1; + */ + private $start = 0.0; + /** + * Generated from protobuf field uint64 count = 2; + */ + private $count = 0; + + public function __construct() { + \GPBMetadata\Src\Proto\Grpc\Core\Stats::initOnce(); + parent::__construct(); + } + + /** + * Generated from protobuf field double start = 1; + * @return float + */ + public function getStart() + { + return $this->start; + } + + /** + * Generated from protobuf field double start = 1; + * @param float $var + * @return $this + */ + public function setStart($var) + { + GPBUtil::checkDouble($var); + $this->start = $var; + + return $this; + } + + /** + * Generated from protobuf field uint64 count = 2; + * @return int|string + */ + public function getCount() + { + return $this->count; + } + + /** + * Generated from protobuf field uint64 count = 2; + * @param int|string $var + * @return $this + */ + public function setCount($var) + { + GPBUtil::checkUint64($var); + $this->count = $var; + + return $this; + } + +} + diff --git a/src/php/tests/qps/generated_code/Grpc/Core/Histogram.php b/src/php/tests/qps/generated_code/Grpc/Core/Histogram.php new file mode 100644 index 00000000000..1902be8e4ac --- /dev/null +++ b/src/php/tests/qps/generated_code/Grpc/Core/Histogram.php @@ -0,0 +1,49 @@ +grpc.core.Histogram + */ +class Histogram extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field repeated .grpc.core.Bucket buckets = 1; + */ + private $buckets; + + public function __construct() { + \GPBMetadata\Src\Proto\Grpc\Core\Stats::initOnce(); + parent::__construct(); + } + + /** + * Generated from protobuf field repeated .grpc.core.Bucket buckets = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getBuckets() + { + return $this->buckets; + } + + /** + * Generated from protobuf field repeated .grpc.core.Bucket buckets = 1; + * @param \Grpc\Core\Bucket[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setBuckets($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Core\Bucket::class); + $this->buckets = $arr; + + return $this; + } + +} + diff --git a/src/php/tests/qps/generated_code/Grpc/Core/Metric.php b/src/php/tests/qps/generated_code/Grpc/Core/Metric.php new file mode 100644 index 00000000000..c3581b7d21b --- /dev/null +++ b/src/php/tests/qps/generated_code/Grpc/Core/Metric.php @@ -0,0 +1,102 @@ +grpc.core.Metric + */ +class Metric extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string name = 1; + */ + private $name = ''; + protected $value; + + public function __construct() { + \GPBMetadata\Src\Proto\Grpc\Core\Stats::initOnce(); + parent::__construct(); + } + + /** + * Generated from protobuf field string name = 1; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Generated from protobuf field uint64 count = 10; + * @return int|string + */ + public function getCount() + { + return $this->readOneof(10); + } + + /** + * Generated from protobuf field uint64 count = 10; + * @param int|string $var + * @return $this + */ + public function setCount($var) + { + GPBUtil::checkUint64($var); + $this->writeOneof(10, $var); + + return $this; + } + + /** + * Generated from protobuf field .grpc.core.Histogram histogram = 11; + * @return \Grpc\Core\Histogram + */ + public function getHistogram() + { + return $this->readOneof(11); + } + + /** + * Generated from protobuf field .grpc.core.Histogram histogram = 11; + * @param \Grpc\Core\Histogram $var + * @return $this + */ + public function setHistogram($var) + { + GPBUtil::checkMessage($var, \Grpc\Core\Histogram::class); + $this->writeOneof(11, $var); + + return $this; + } + + /** + * @return string + */ + public function getValue() + { + return $this->whichOneof("value"); + } + +} + diff --git a/src/php/tests/qps/generated_code/Grpc/Core/Stats.php b/src/php/tests/qps/generated_code/Grpc/Core/Stats.php new file mode 100644 index 00000000000..e6f3fb08992 --- /dev/null +++ b/src/php/tests/qps/generated_code/Grpc/Core/Stats.php @@ -0,0 +1,49 @@ +grpc.core.Stats + */ +class Stats extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field repeated .grpc.core.Metric metrics = 1; + */ + private $metrics; + + public function __construct() { + \GPBMetadata\Src\Proto\Grpc\Core\Stats::initOnce(); + parent::__construct(); + } + + /** + * Generated from protobuf field repeated .grpc.core.Metric metrics = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getMetrics() + { + return $this->metrics; + } + + /** + * Generated from protobuf field repeated .grpc.core.Metric metrics = 1; + * @param \Grpc\Core\Metric[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setMetrics($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Core\Metric::class); + $this->metrics = $arr; + + return $this; + } + +} + diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/BenchmarkServiceClient.php b/src/php/tests/qps/generated_code/Grpc/Testing/BenchmarkServiceClient.php index ddf750a94fc..fa3e1479091 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/BenchmarkServiceClient.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/BenchmarkServiceClient.php @@ -18,17 +18,19 @@ // // An integration test service that covers all the method signature permutations // of unary/streaming requests/responses. -namespace Grpc\Testing { +namespace Grpc\Testing; - class BenchmarkServiceClient extends \Grpc\BaseStub { +/** + */ +class BenchmarkServiceClient extends \Grpc\BaseStub { /** * @param string $hostname hostname * @param array $opts channel options - * @param Grpc\Channel $channel (optional) re-use channel object + * @param \Grpc\Channel $channel (optional) re-use channel object */ public function __construct($hostname, $opts, $channel = null) { - parent::__construct($hostname, $opts, $channel); + parent::__construct($hostname, $opts, $channel); } /** @@ -40,24 +42,62 @@ namespace Grpc\Testing { */ public function UnaryCall(\Grpc\Testing\SimpleRequest $argument, $metadata = [], $options = []) { - return $this->_simpleRequest('/grpc.testing.BenchmarkService/UnaryCall', - $argument, - ['\Grpc\Testing\SimpleResponse', 'decode'], - $metadata, $options); + return $this->_simpleRequest('/grpc.testing.BenchmarkService/UnaryCall', + $argument, + ['\Grpc\Testing\SimpleResponse', 'decode'], + $metadata, $options); } /** - * One request followed by one response. - * The server returns the client payload as-is. + * Repeated sequence of one request followed by one response. + * Should be called streaming ping-pong + * The server returns the client payload as-is on each response * @param array $metadata metadata * @param array $options call options */ public function StreamingCall($metadata = [], $options = []) { - return $this->_bidiRequest('/grpc.testing.BenchmarkService/StreamingCall', - ['\Grpc\Testing\SimpleResponse','decode'], - $metadata, $options); + return $this->_bidiRequest('/grpc.testing.BenchmarkService/StreamingCall', + ['\Grpc\Testing\SimpleResponse','decode'], + $metadata, $options); } - } + /** + * Single-sided unbounded streaming from client to server + * The server returns the client payload as-is once the client does WritesDone + * @param array $metadata metadata + * @param array $options call options + */ + public function StreamingFromClient($metadata = [], $options = []) { + return $this->_clientStreamRequest('/grpc.testing.BenchmarkService/StreamingFromClient', + ['\Grpc\Testing\SimpleResponse','decode'], + $metadata, $options); + } + + /** + * Single-sided unbounded streaming from server to client + * The server repeatedly returns the client payload as-is + * @param \Grpc\Testing\SimpleRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + */ + public function StreamingFromServer(\Grpc\Testing\SimpleRequest $argument, + $metadata = [], $options = []) { + return $this->_serverStreamRequest('/grpc.testing.BenchmarkService/StreamingFromServer', + $argument, + ['\Grpc\Testing\SimpleResponse', 'decode'], + $metadata, $options); + } + + /** + * Two-sided unbounded streaming between server to client + * Both sides send the content of their own choice to the other + * @param array $metadata metadata + * @param array $options call options + */ + public function StreamingBothWays($metadata = [], $options = []) { + return $this->_bidiRequest('/grpc.testing.BenchmarkService/StreamingBothWays', + ['\Grpc\Testing\SimpleResponse','decode'], + $metadata, $options); + } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/BoolValue.php b/src/php/tests/qps/generated_code/Grpc/Testing/BoolValue.php index f0497accfb2..7eb364b7a0b 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/BoolValue.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/BoolValue.php @@ -9,22 +9,18 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * TODO(dgq): Go back to using well-known types once
  * https://github.com/grpc/grpc/issues/6980 has been fixed.
  * import "google/protobuf/wrappers.proto";
- * 
* - * Protobuf type grpc.testing.BoolValue + * Generated from protobuf message grpc.testing.BoolValue */ class BoolValue extends \Google\Protobuf\Internal\Message { /** - *
      * The bool value.
-     * 
* - * bool value = 1; + * Generated from protobuf field bool value = 1; */ private $value = false; @@ -34,11 +30,10 @@ class BoolValue extends \Google\Protobuf\Internal\Message } /** - *
      * The bool value.
-     * 
* - * bool value = 1; + * Generated from protobuf field bool value = 1; + * @return bool */ public function getValue() { @@ -46,16 +41,18 @@ class BoolValue extends \Google\Protobuf\Internal\Message } /** - *
      * The bool value.
-     * 
* - * bool value = 1; + * Generated from protobuf field bool value = 1; + * @param bool $var + * @return $this */ public function setValue($var) { GPBUtil::checkBool($var); $this->value = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ByteBufferParams.php b/src/php/tests/qps/generated_code/Grpc/Testing/ByteBufferParams.php index 0057d387488..0511026ba74 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ByteBufferParams.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ByteBufferParams.php @@ -9,16 +9,16 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type grpc.testing.ByteBufferParams + * Generated from protobuf message grpc.testing.ByteBufferParams */ class ByteBufferParams extends \Google\Protobuf\Internal\Message { /** - * int32 req_size = 1; + * Generated from protobuf field int32 req_size = 1; */ private $req_size = 0; /** - * int32 resp_size = 2; + * Generated from protobuf field int32 resp_size = 2; */ private $resp_size = 0; @@ -28,7 +28,8 @@ class ByteBufferParams extends \Google\Protobuf\Internal\Message } /** - * int32 req_size = 1; + * Generated from protobuf field int32 req_size = 1; + * @return int */ public function getReqSize() { @@ -36,16 +37,21 @@ class ByteBufferParams extends \Google\Protobuf\Internal\Message } /** - * int32 req_size = 1; + * Generated from protobuf field int32 req_size = 1; + * @param int $var + * @return $this */ public function setReqSize($var) { GPBUtil::checkInt32($var); $this->req_size = $var; + + return $this; } /** - * int32 resp_size = 2; + * Generated from protobuf field int32 resp_size = 2; + * @return int */ public function getRespSize() { @@ -53,12 +59,16 @@ class ByteBufferParams extends \Google\Protobuf\Internal\Message } /** - * int32 resp_size = 2; + * Generated from protobuf field int32 resp_size = 2; + * @param int $var + * @return $this */ public function setRespSize($var) { GPBUtil::checkInt32($var); $this->resp_size = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ChannelArg.php b/src/php/tests/qps/generated_code/Grpc/Testing/ChannelArg.php index d2fe3ae5ffc..5c5fb861a40 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ChannelArg.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ChannelArg.php @@ -9,12 +9,12 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type grpc.testing.ChannelArg + * Generated from protobuf message grpc.testing.ChannelArg */ class ChannelArg extends \Google\Protobuf\Internal\Message { /** - * string name = 1; + * Generated from protobuf field string name = 1; */ private $name = ''; protected $value; @@ -25,7 +25,8 @@ class ChannelArg extends \Google\Protobuf\Internal\Message } /** - * string name = 1; + * Generated from protobuf field string name = 1; + * @return string */ public function getName() { @@ -33,16 +34,21 @@ class ChannelArg extends \Google\Protobuf\Internal\Message } /** - * string name = 1; + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this */ public function setName($var) { GPBUtil::checkString($var, True); $this->name = $var; + + return $this; } /** - * string str_value = 2; + * Generated from protobuf field string str_value = 2; + * @return string */ public function getStrValue() { @@ -50,16 +56,21 @@ class ChannelArg extends \Google\Protobuf\Internal\Message } /** - * string str_value = 2; + * Generated from protobuf field string str_value = 2; + * @param string $var + * @return $this */ public function setStrValue($var) { GPBUtil::checkString($var, True); $this->writeOneof(2, $var); + + return $this; } /** - * int32 int_value = 3; + * Generated from protobuf field int32 int_value = 3; + * @return int */ public function getIntValue() { @@ -67,14 +78,21 @@ class ChannelArg extends \Google\Protobuf\Internal\Message } /** - * int32 int_value = 3; + * Generated from protobuf field int32 int_value = 3; + * @param int $var + * @return $this */ public function setIntValue($var) { GPBUtil::checkInt32($var); $this->writeOneof(3, $var); + + return $this; } + /** + * @return string + */ public function getValue() { return $this->whichOneof("value"); diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ClientArgs.php b/src/php/tests/qps/generated_code/Grpc/Testing/ClientArgs.php index c878c5a7bc0..ee3fd46f0f6 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ClientArgs.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ClientArgs.php @@ -9,7 +9,7 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type grpc.testing.ClientArgs + * Generated from protobuf message grpc.testing.ClientArgs */ class ClientArgs extends \Google\Protobuf\Internal\Message { @@ -21,7 +21,8 @@ class ClientArgs extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.ClientConfig setup = 1; + * Generated from protobuf field .grpc.testing.ClientConfig setup = 1; + * @return \Grpc\Testing\ClientConfig */ public function getSetup() { @@ -29,16 +30,21 @@ class ClientArgs extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.ClientConfig setup = 1; + * Generated from protobuf field .grpc.testing.ClientConfig setup = 1; + * @param \Grpc\Testing\ClientConfig $var + * @return $this */ - public function setSetup(&$var) + public function setSetup($var) { GPBUtil::checkMessage($var, \Grpc\Testing\ClientConfig::class); $this->writeOneof(1, $var); + + return $this; } /** - * .grpc.testing.Mark mark = 2; + * Generated from protobuf field .grpc.testing.Mark mark = 2; + * @return \Grpc\Testing\Mark */ public function getMark() { @@ -46,14 +52,21 @@ class ClientArgs extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.Mark mark = 2; + * Generated from protobuf field .grpc.testing.Mark mark = 2; + * @param \Grpc\Testing\Mark $var + * @return $this */ - public function setMark(&$var) + public function setMark($var) { GPBUtil::checkMessage($var, \Grpc\Testing\Mark::class); $this->writeOneof(2, $var); + + return $this; } + /** + * @return string + */ public function getArgtype() { return $this->whichOneof("argtype"); diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ClientConfig.php b/src/php/tests/qps/generated_code/Grpc/Testing/ClientConfig.php index 52d6a75fb0e..f7bc21587c9 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ClientConfig.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ClientConfig.php @@ -9,96 +9,94 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type grpc.testing.ClientConfig + * Generated from protobuf message grpc.testing.ClientConfig */ class ClientConfig extends \Google\Protobuf\Internal\Message { /** - *
      * List of targets to connect to. At least one target needs to be specified.
-     * 
* - * repeated string server_targets = 1; + * Generated from protobuf field repeated string server_targets = 1; */ private $server_targets; /** - * .grpc.testing.ClientType client_type = 2; + * Generated from protobuf field .grpc.testing.ClientType client_type = 2; */ private $client_type = 0; /** - * .grpc.testing.SecurityParams security_params = 3; + * Generated from protobuf field .grpc.testing.SecurityParams security_params = 3; */ private $security_params = null; /** - *
      * How many concurrent RPCs to start for each channel.
      * For synchronous client, use a separate thread for each outstanding RPC.
-     * 
* - * int32 outstanding_rpcs_per_channel = 4; + * Generated from protobuf field int32 outstanding_rpcs_per_channel = 4; */ private $outstanding_rpcs_per_channel = 0; /** - *
      * Number of independent client channels to create.
      * i-th channel will connect to server_target[i % server_targets.size()]
-     * 
* - * int32 client_channels = 5; + * Generated from protobuf field int32 client_channels = 5; */ private $client_channels = 0; /** - *
      * Only for async client. Number of threads to use to start/manage RPCs.
-     * 
* - * int32 async_client_threads = 7; + * Generated from protobuf field int32 async_client_threads = 7; */ private $async_client_threads = 0; /** - * .grpc.testing.RpcType rpc_type = 8; + * Generated from protobuf field .grpc.testing.RpcType rpc_type = 8; */ private $rpc_type = 0; /** - *
      * The requested load for the entire client (aggregated over all the threads).
-     * 
* - * .grpc.testing.LoadParams load_params = 10; + * Generated from protobuf field .grpc.testing.LoadParams load_params = 10; */ private $load_params = null; /** - * .grpc.testing.PayloadConfig payload_config = 11; + * Generated from protobuf field .grpc.testing.PayloadConfig payload_config = 11; */ private $payload_config = null; /** - * .grpc.testing.HistogramParams histogram_params = 12; + * Generated from protobuf field .grpc.testing.HistogramParams histogram_params = 12; */ private $histogram_params = null; /** - *
      * Specify the cores we should run the client on, if desired
-     * 
* - * repeated int32 core_list = 13; + * Generated from protobuf field repeated int32 core_list = 13; */ private $core_list; /** - * int32 core_limit = 14; + * Generated from protobuf field int32 core_limit = 14; */ private $core_limit = 0; /** - *
      * If we use an OTHER_CLIENT client_type, this string gives more detail
-     * 
* - * string other_client_api = 15; + * Generated from protobuf field string other_client_api = 15; */ private $other_client_api = ''; /** - * repeated .grpc.testing.ChannelArg channel_args = 16; + * Generated from protobuf field repeated .grpc.testing.ChannelArg channel_args = 16; */ private $channel_args; + /** + * Number of threads that share each completion queue + * + * Generated from protobuf field int32 threads_per_cq = 17; + */ + private $threads_per_cq = 0; + /** + * Number of messages on a stream before it gets finished/restarted + * + * Generated from protobuf field int32 messages_per_stream = 18; + */ + private $messages_per_stream = 0; public function __construct() { \GPBMetadata\Src\Proto\Grpc\Testing\Control::initOnce(); @@ -106,11 +104,10 @@ class ClientConfig extends \Google\Protobuf\Internal\Message } /** - *
      * List of targets to connect to. At least one target needs to be specified.
-     * 
* - * repeated string server_targets = 1; + * Generated from protobuf field repeated string server_targets = 1; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getServerTargets() { @@ -118,20 +115,23 @@ class ClientConfig extends \Google\Protobuf\Internal\Message } /** - *
      * List of targets to connect to. At least one target needs to be specified.
-     * 
* - * repeated string server_targets = 1; + * Generated from protobuf field repeated string server_targets = 1; + * @param string[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ - public function setServerTargets(&$var) + public function setServerTargets($var) { - GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); - $this->server_targets = $var; + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->server_targets = $arr; + + return $this; } /** - * .grpc.testing.ClientType client_type = 2; + * Generated from protobuf field .grpc.testing.ClientType client_type = 2; + * @return int */ public function getClientType() { @@ -139,16 +139,21 @@ class ClientConfig extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.ClientType client_type = 2; + * Generated from protobuf field .grpc.testing.ClientType client_type = 2; + * @param int $var + * @return $this */ public function setClientType($var) { GPBUtil::checkEnum($var, \Grpc\Testing\ClientType::class); $this->client_type = $var; + + return $this; } /** - * .grpc.testing.SecurityParams security_params = 3; + * Generated from protobuf field .grpc.testing.SecurityParams security_params = 3; + * @return \Grpc\Testing\SecurityParams */ public function getSecurityParams() { @@ -156,21 +161,24 @@ class ClientConfig extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.SecurityParams security_params = 3; + * Generated from protobuf field .grpc.testing.SecurityParams security_params = 3; + * @param \Grpc\Testing\SecurityParams $var + * @return $this */ - public function setSecurityParams(&$var) + public function setSecurityParams($var) { GPBUtil::checkMessage($var, \Grpc\Testing\SecurityParams::class); $this->security_params = $var; + + return $this; } /** - *
      * How many concurrent RPCs to start for each channel.
      * For synchronous client, use a separate thread for each outstanding RPC.
-     * 
* - * int32 outstanding_rpcs_per_channel = 4; + * Generated from protobuf field int32 outstanding_rpcs_per_channel = 4; + * @return int */ public function getOutstandingRpcsPerChannel() { @@ -178,26 +186,27 @@ class ClientConfig extends \Google\Protobuf\Internal\Message } /** - *
      * How many concurrent RPCs to start for each channel.
      * For synchronous client, use a separate thread for each outstanding RPC.
-     * 
* - * int32 outstanding_rpcs_per_channel = 4; + * Generated from protobuf field int32 outstanding_rpcs_per_channel = 4; + * @param int $var + * @return $this */ public function setOutstandingRpcsPerChannel($var) { GPBUtil::checkInt32($var); $this->outstanding_rpcs_per_channel = $var; + + return $this; } /** - *
      * Number of independent client channels to create.
      * i-th channel will connect to server_target[i % server_targets.size()]
-     * 
* - * int32 client_channels = 5; + * Generated from protobuf field int32 client_channels = 5; + * @return int */ public function getClientChannels() { @@ -205,25 +214,26 @@ class ClientConfig extends \Google\Protobuf\Internal\Message } /** - *
      * Number of independent client channels to create.
      * i-th channel will connect to server_target[i % server_targets.size()]
-     * 
* - * int32 client_channels = 5; + * Generated from protobuf field int32 client_channels = 5; + * @param int $var + * @return $this */ public function setClientChannels($var) { GPBUtil::checkInt32($var); $this->client_channels = $var; + + return $this; } /** - *
      * Only for async client. Number of threads to use to start/manage RPCs.
-     * 
* - * int32 async_client_threads = 7; + * Generated from protobuf field int32 async_client_threads = 7; + * @return int */ public function getAsyncClientThreads() { @@ -231,20 +241,23 @@ class ClientConfig extends \Google\Protobuf\Internal\Message } /** - *
      * Only for async client. Number of threads to use to start/manage RPCs.
-     * 
* - * int32 async_client_threads = 7; + * Generated from protobuf field int32 async_client_threads = 7; + * @param int $var + * @return $this */ public function setAsyncClientThreads($var) { GPBUtil::checkInt32($var); $this->async_client_threads = $var; + + return $this; } /** - * .grpc.testing.RpcType rpc_type = 8; + * Generated from protobuf field .grpc.testing.RpcType rpc_type = 8; + * @return int */ public function getRpcType() { @@ -252,20 +265,23 @@ class ClientConfig extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.RpcType rpc_type = 8; + * Generated from protobuf field .grpc.testing.RpcType rpc_type = 8; + * @param int $var + * @return $this */ public function setRpcType($var) { GPBUtil::checkEnum($var, \Grpc\Testing\RpcType::class); $this->rpc_type = $var; + + return $this; } /** - *
      * The requested load for the entire client (aggregated over all the threads).
-     * 
* - * .grpc.testing.LoadParams load_params = 10; + * Generated from protobuf field .grpc.testing.LoadParams load_params = 10; + * @return \Grpc\Testing\LoadParams */ public function getLoadParams() { @@ -273,20 +289,23 @@ class ClientConfig extends \Google\Protobuf\Internal\Message } /** - *
      * The requested load for the entire client (aggregated over all the threads).
-     * 
* - * .grpc.testing.LoadParams load_params = 10; + * Generated from protobuf field .grpc.testing.LoadParams load_params = 10; + * @param \Grpc\Testing\LoadParams $var + * @return $this */ - public function setLoadParams(&$var) + public function setLoadParams($var) { GPBUtil::checkMessage($var, \Grpc\Testing\LoadParams::class); $this->load_params = $var; + + return $this; } /** - * .grpc.testing.PayloadConfig payload_config = 11; + * Generated from protobuf field .grpc.testing.PayloadConfig payload_config = 11; + * @return \Grpc\Testing\PayloadConfig */ public function getPayloadConfig() { @@ -294,16 +313,21 @@ class ClientConfig extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.PayloadConfig payload_config = 11; + * Generated from protobuf field .grpc.testing.PayloadConfig payload_config = 11; + * @param \Grpc\Testing\PayloadConfig $var + * @return $this */ - public function setPayloadConfig(&$var) + public function setPayloadConfig($var) { GPBUtil::checkMessage($var, \Grpc\Testing\PayloadConfig::class); $this->payload_config = $var; + + return $this; } /** - * .grpc.testing.HistogramParams histogram_params = 12; + * Generated from protobuf field .grpc.testing.HistogramParams histogram_params = 12; + * @return \Grpc\Testing\HistogramParams */ public function getHistogramParams() { @@ -311,20 +335,23 @@ class ClientConfig extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.HistogramParams histogram_params = 12; + * Generated from protobuf field .grpc.testing.HistogramParams histogram_params = 12; + * @param \Grpc\Testing\HistogramParams $var + * @return $this */ - public function setHistogramParams(&$var) + public function setHistogramParams($var) { GPBUtil::checkMessage($var, \Grpc\Testing\HistogramParams::class); $this->histogram_params = $var; + + return $this; } /** - *
      * Specify the cores we should run the client on, if desired
-     * 
* - * repeated int32 core_list = 13; + * Generated from protobuf field repeated int32 core_list = 13; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getCoreList() { @@ -332,20 +359,23 @@ class ClientConfig extends \Google\Protobuf\Internal\Message } /** - *
      * Specify the cores we should run the client on, if desired
-     * 
* - * repeated int32 core_list = 13; + * Generated from protobuf field repeated int32 core_list = 13; + * @param int[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ - public function setCoreList(&$var) + public function setCoreList($var) { - GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); - $this->core_list = $var; + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); + $this->core_list = $arr; + + return $this; } /** - * int32 core_limit = 14; + * Generated from protobuf field int32 core_limit = 14; + * @return int */ public function getCoreLimit() { @@ -353,20 +383,23 @@ class ClientConfig extends \Google\Protobuf\Internal\Message } /** - * int32 core_limit = 14; + * Generated from protobuf field int32 core_limit = 14; + * @param int $var + * @return $this */ public function setCoreLimit($var) { GPBUtil::checkInt32($var); $this->core_limit = $var; + + return $this; } /** - *
      * If we use an OTHER_CLIENT client_type, this string gives more detail
-     * 
* - * string other_client_api = 15; + * Generated from protobuf field string other_client_api = 15; + * @return string */ public function getOtherClientApi() { @@ -374,20 +407,23 @@ class ClientConfig extends \Google\Protobuf\Internal\Message } /** - *
      * If we use an OTHER_CLIENT client_type, this string gives more detail
-     * 
* - * string other_client_api = 15; + * Generated from protobuf field string other_client_api = 15; + * @param string $var + * @return $this */ public function setOtherClientApi($var) { GPBUtil::checkString($var, True); $this->other_client_api = $var; + + return $this; } /** - * repeated .grpc.testing.ChannelArg channel_args = 16; + * Generated from protobuf field repeated .grpc.testing.ChannelArg channel_args = 16; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getChannelArgs() { @@ -395,12 +431,68 @@ class ClientConfig extends \Google\Protobuf\Internal\Message } /** - * repeated .grpc.testing.ChannelArg channel_args = 16; + * Generated from protobuf field repeated .grpc.testing.ChannelArg channel_args = 16; + * @param \Grpc\Testing\ChannelArg[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setChannelArgs($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\ChannelArg::class); + $this->channel_args = $arr; + + return $this; + } + + /** + * Number of threads that share each completion queue + * + * Generated from protobuf field int32 threads_per_cq = 17; + * @return int + */ + public function getThreadsPerCq() + { + return $this->threads_per_cq; + } + + /** + * Number of threads that share each completion queue + * + * Generated from protobuf field int32 threads_per_cq = 17; + * @param int $var + * @return $this + */ + public function setThreadsPerCq($var) + { + GPBUtil::checkInt32($var); + $this->threads_per_cq = $var; + + return $this; + } + + /** + * Number of messages on a stream before it gets finished/restarted + * + * Generated from protobuf field int32 messages_per_stream = 18; + * @return int + */ + public function getMessagesPerStream() + { + return $this->messages_per_stream; + } + + /** + * Number of messages on a stream before it gets finished/restarted + * + * Generated from protobuf field int32 messages_per_stream = 18; + * @param int $var + * @return $this */ - public function setChannelArgs(&$var) + public function setMessagesPerStream($var) { - GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\ChannelArg::class); - $this->channel_args = $var; + GPBUtil::checkInt32($var); + $this->messages_per_stream = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ClientStats.php b/src/php/tests/qps/generated_code/Grpc/Testing/ClientStats.php index 8b9a0c33a46..f2a76217917 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ClientStats.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ClientStats.php @@ -9,42 +9,48 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type grpc.testing.ClientStats + * Generated from protobuf message grpc.testing.ClientStats */ class ClientStats extends \Google\Protobuf\Internal\Message { /** - *
      * Latency histogram. Data points are in nanoseconds.
-     * 
* - * .grpc.testing.HistogramData latencies = 1; + * Generated from protobuf field .grpc.testing.HistogramData latencies = 1; */ private $latencies = null; /** - *
      * See ServerStats for details.
-     * 
* - * double time_elapsed = 2; + * Generated from protobuf field double time_elapsed = 2; */ private $time_elapsed = 0.0; /** - * double time_user = 3; + * Generated from protobuf field double time_user = 3; */ private $time_user = 0.0; /** - * double time_system = 4; + * Generated from protobuf field double time_system = 4; */ private $time_system = 0.0; /** - *
      * Number of failed requests (one row per status code seen)
-     * 
* - * repeated .grpc.testing.RequestResultCount request_results = 5; + * Generated from protobuf field repeated .grpc.testing.RequestResultCount request_results = 5; */ private $request_results; + /** + * Number of polls called inside completion queue + * + * Generated from protobuf field uint64 cq_poll_count = 6; + */ + private $cq_poll_count = 0; + /** + * Core library stats + * + * Generated from protobuf field .grpc.core.Stats core_stats = 7; + */ + private $core_stats = null; public function __construct() { \GPBMetadata\Src\Proto\Grpc\Testing\Stats::initOnce(); @@ -52,11 +58,10 @@ class ClientStats extends \Google\Protobuf\Internal\Message } /** - *
      * Latency histogram. Data points are in nanoseconds.
-     * 
* - * .grpc.testing.HistogramData latencies = 1; + * Generated from protobuf field .grpc.testing.HistogramData latencies = 1; + * @return \Grpc\Testing\HistogramData */ public function getLatencies() { @@ -64,24 +69,25 @@ class ClientStats extends \Google\Protobuf\Internal\Message } /** - *
      * Latency histogram. Data points are in nanoseconds.
-     * 
* - * .grpc.testing.HistogramData latencies = 1; + * Generated from protobuf field .grpc.testing.HistogramData latencies = 1; + * @param \Grpc\Testing\HistogramData $var + * @return $this */ - public function setLatencies(&$var) + public function setLatencies($var) { GPBUtil::checkMessage($var, \Grpc\Testing\HistogramData::class); $this->latencies = $var; + + return $this; } /** - *
      * See ServerStats for details.
-     * 
* - * double time_elapsed = 2; + * Generated from protobuf field double time_elapsed = 2; + * @return float */ public function getTimeElapsed() { @@ -89,20 +95,23 @@ class ClientStats extends \Google\Protobuf\Internal\Message } /** - *
      * See ServerStats for details.
-     * 
* - * double time_elapsed = 2; + * Generated from protobuf field double time_elapsed = 2; + * @param float $var + * @return $this */ public function setTimeElapsed($var) { GPBUtil::checkDouble($var); $this->time_elapsed = $var; + + return $this; } /** - * double time_user = 3; + * Generated from protobuf field double time_user = 3; + * @return float */ public function getTimeUser() { @@ -110,16 +119,21 @@ class ClientStats extends \Google\Protobuf\Internal\Message } /** - * double time_user = 3; + * Generated from protobuf field double time_user = 3; + * @param float $var + * @return $this */ public function setTimeUser($var) { GPBUtil::checkDouble($var); $this->time_user = $var; + + return $this; } /** - * double time_system = 4; + * Generated from protobuf field double time_system = 4; + * @return float */ public function getTimeSystem() { @@ -127,20 +141,23 @@ class ClientStats extends \Google\Protobuf\Internal\Message } /** - * double time_system = 4; + * Generated from protobuf field double time_system = 4; + * @param float $var + * @return $this */ public function setTimeSystem($var) { GPBUtil::checkDouble($var); $this->time_system = $var; + + return $this; } /** - *
      * Number of failed requests (one row per status code seen)
-     * 
* - * repeated .grpc.testing.RequestResultCount request_results = 5; + * Generated from protobuf field repeated .grpc.testing.RequestResultCount request_results = 5; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getRequestResults() { @@ -148,16 +165,70 @@ class ClientStats extends \Google\Protobuf\Internal\Message } /** - *
      * Number of failed requests (one row per status code seen)
-     * 
* - * repeated .grpc.testing.RequestResultCount request_results = 5; + * Generated from protobuf field repeated .grpc.testing.RequestResultCount request_results = 5; + * @param \Grpc\Testing\RequestResultCount[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ - public function setRequestResults(&$var) + public function setRequestResults($var) { - GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\RequestResultCount::class); - $this->request_results = $var; + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\RequestResultCount::class); + $this->request_results = $arr; + + return $this; + } + + /** + * Number of polls called inside completion queue + * + * Generated from protobuf field uint64 cq_poll_count = 6; + * @return int|string + */ + public function getCqPollCount() + { + return $this->cq_poll_count; + } + + /** + * Number of polls called inside completion queue + * + * Generated from protobuf field uint64 cq_poll_count = 6; + * @param int|string $var + * @return $this + */ + public function setCqPollCount($var) + { + GPBUtil::checkUint64($var); + $this->cq_poll_count = $var; + + return $this; + } + + /** + * Core library stats + * + * Generated from protobuf field .grpc.core.Stats core_stats = 7; + * @return \Grpc\Core\Stats + */ + public function getCoreStats() + { + return $this->core_stats; + } + + /** + * Core library stats + * + * Generated from protobuf field .grpc.core.Stats core_stats = 7; + * @param \Grpc\Core\Stats $var + * @return $this + */ + public function setCoreStats($var) + { + GPBUtil::checkMessage($var, \Grpc\Core\Stats::class); + $this->core_stats = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ClientStatus.php b/src/php/tests/qps/generated_code/Grpc/Testing/ClientStatus.php index a59f87a9628..3ea40c4dfa0 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ClientStatus.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ClientStatus.php @@ -9,12 +9,12 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type grpc.testing.ClientStatus + * Generated from protobuf message grpc.testing.ClientStatus */ class ClientStatus extends \Google\Protobuf\Internal\Message { /** - * .grpc.testing.ClientStats stats = 1; + * Generated from protobuf field .grpc.testing.ClientStats stats = 1; */ private $stats = null; @@ -24,7 +24,8 @@ class ClientStatus extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.ClientStats stats = 1; + * Generated from protobuf field .grpc.testing.ClientStats stats = 1; + * @return \Grpc\Testing\ClientStats */ public function getStats() { @@ -32,12 +33,16 @@ class ClientStatus extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.ClientStats stats = 1; + * Generated from protobuf field .grpc.testing.ClientStats stats = 1; + * @param \Grpc\Testing\ClientStats $var + * @return $this */ - public function setStats(&$var) + public function setStats($var) { GPBUtil::checkMessage($var, \Grpc\Testing\ClientStats::class); $this->stats = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ClientType.php b/src/php/tests/qps/generated_code/Grpc/Testing/ClientType.php index 4f59da992f9..d1df4f19436 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ClientType.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ClientType.php @@ -5,29 +5,25 @@ namespace Grpc\Testing; /** - * Protobuf enum grpc.testing.ClientType + * Protobuf enum Grpc\Testing\ClientType */ class ClientType { /** - *
      * Many languages support a basic distinction between using
      * sync or async client, and this allows the specification
-     * 
* - * SYNC_CLIENT = 0; + * Generated from protobuf enum SYNC_CLIENT = 0; */ const SYNC_CLIENT = 0; /** - * ASYNC_CLIENT = 1; + * Generated from protobuf enum ASYNC_CLIENT = 1; */ const ASYNC_CLIENT = 1; /** - *
      * used for some language-specific variants
-     * 
* - * OTHER_CLIENT = 2; + * Generated from protobuf enum OTHER_CLIENT = 2; */ const OTHER_CLIENT = 2; } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ClosedLoopParams.php b/src/php/tests/qps/generated_code/Grpc/Testing/ClosedLoopParams.php index 53f2948af28..2772836f13d 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ClosedLoopParams.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ClosedLoopParams.php @@ -9,12 +9,10 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Once an RPC finishes, immediately start a new one.
  * No configuration parameters needed.
- * 
* - * Protobuf type grpc.testing.ClosedLoopParams + * Generated from protobuf message grpc.testing.ClosedLoopParams */ class ClosedLoopParams extends \Google\Protobuf\Internal\Message { diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ComplexProtoParams.php b/src/php/tests/qps/generated_code/Grpc/Testing/ComplexProtoParams.php index 6d990f1b064..b9013cdb300 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ComplexProtoParams.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ComplexProtoParams.php @@ -9,12 +9,10 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * TODO (vpai): Fill this in once the details of complex, representative
  *              protos are decided
- * 
* - * Protobuf type grpc.testing.ComplexProtoParams + * Generated from protobuf message grpc.testing.ComplexProtoParams */ class ComplexProtoParams extends \Google\Protobuf\Internal\Message { diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/CoreRequest.php b/src/php/tests/qps/generated_code/Grpc/Testing/CoreRequest.php index 2e078b3fcdb..7772572f1c5 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/CoreRequest.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/CoreRequest.php @@ -9,7 +9,7 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type grpc.testing.CoreRequest + * Generated from protobuf message grpc.testing.CoreRequest */ class CoreRequest extends \Google\Protobuf\Internal\Message { diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/CoreResponse.php b/src/php/tests/qps/generated_code/Grpc/Testing/CoreResponse.php index 85cb3418ada..e0b40ee3001 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/CoreResponse.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/CoreResponse.php @@ -9,16 +9,14 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type grpc.testing.CoreResponse + * Generated from protobuf message grpc.testing.CoreResponse */ class CoreResponse extends \Google\Protobuf\Internal\Message { /** - *
      * Number of cores available on the server
-     * 
* - * int32 cores = 1; + * Generated from protobuf field int32 cores = 1; */ private $cores = 0; @@ -28,11 +26,10 @@ class CoreResponse extends \Google\Protobuf\Internal\Message } /** - *
      * Number of cores available on the server
-     * 
* - * int32 cores = 1; + * Generated from protobuf field int32 cores = 1; + * @return int */ public function getCores() { @@ -40,16 +37,18 @@ class CoreResponse extends \Google\Protobuf\Internal\Message } /** - *
      * Number of cores available on the server
-     * 
* - * int32 cores = 1; + * Generated from protobuf field int32 cores = 1; + * @param int $var + * @return $this */ public function setCores($var) { GPBUtil::checkInt32($var); $this->cores = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/EchoStatus.php b/src/php/tests/qps/generated_code/Grpc/Testing/EchoStatus.php index 27340fb0efe..6a6623a042d 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/EchoStatus.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/EchoStatus.php @@ -9,21 +9,19 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * A protobuf representation for grpc status. This is used by test
  * clients to specify a status that the server should attempt to return.
- * 
* - * Protobuf type grpc.testing.EchoStatus + * Generated from protobuf message grpc.testing.EchoStatus */ class EchoStatus extends \Google\Protobuf\Internal\Message { /** - * int32 code = 1; + * Generated from protobuf field int32 code = 1; */ private $code = 0; /** - * string message = 2; + * Generated from protobuf field string message = 2; */ private $message = ''; @@ -33,7 +31,8 @@ class EchoStatus extends \Google\Protobuf\Internal\Message } /** - * int32 code = 1; + * Generated from protobuf field int32 code = 1; + * @return int */ public function getCode() { @@ -41,16 +40,21 @@ class EchoStatus extends \Google\Protobuf\Internal\Message } /** - * int32 code = 1; + * Generated from protobuf field int32 code = 1; + * @param int $var + * @return $this */ public function setCode($var) { GPBUtil::checkInt32($var); $this->code = $var; + + return $this; } /** - * string message = 2; + * Generated from protobuf field string message = 2; + * @return string */ public function getMessage() { @@ -58,12 +62,16 @@ class EchoStatus extends \Google\Protobuf\Internal\Message } /** - * string message = 2; + * Generated from protobuf field string message = 2; + * @param string $var + * @return $this */ public function setMessage($var) { GPBUtil::checkString($var, True); $this->message = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/HistogramData.php b/src/php/tests/qps/generated_code/Grpc/Testing/HistogramData.php index 056da6e5de5..136eac75e28 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/HistogramData.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/HistogramData.php @@ -9,36 +9,34 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Histogram data based on grpc/support/histogram.c
- * 
* - * Protobuf type grpc.testing.HistogramData + * Generated from protobuf message grpc.testing.HistogramData */ class HistogramData extends \Google\Protobuf\Internal\Message { /** - * repeated uint32 bucket = 1; + * Generated from protobuf field repeated uint32 bucket = 1; */ private $bucket; /** - * double min_seen = 2; + * Generated from protobuf field double min_seen = 2; */ private $min_seen = 0.0; /** - * double max_seen = 3; + * Generated from protobuf field double max_seen = 3; */ private $max_seen = 0.0; /** - * double sum = 4; + * Generated from protobuf field double sum = 4; */ private $sum = 0.0; /** - * double sum_of_squares = 5; + * Generated from protobuf field double sum_of_squares = 5; */ private $sum_of_squares = 0.0; /** - * double count = 6; + * Generated from protobuf field double count = 6; */ private $count = 0.0; @@ -48,7 +46,8 @@ class HistogramData extends \Google\Protobuf\Internal\Message } /** - * repeated uint32 bucket = 1; + * Generated from protobuf field repeated uint32 bucket = 1; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getBucket() { @@ -56,16 +55,21 @@ class HistogramData extends \Google\Protobuf\Internal\Message } /** - * repeated uint32 bucket = 1; + * Generated from protobuf field repeated uint32 bucket = 1; + * @param int[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ - public function setBucket(&$var) + public function setBucket($var) { - GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::UINT32); - $this->bucket = $var; + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::UINT32); + $this->bucket = $arr; + + return $this; } /** - * double min_seen = 2; + * Generated from protobuf field double min_seen = 2; + * @return float */ public function getMinSeen() { @@ -73,16 +77,21 @@ class HistogramData extends \Google\Protobuf\Internal\Message } /** - * double min_seen = 2; + * Generated from protobuf field double min_seen = 2; + * @param float $var + * @return $this */ public function setMinSeen($var) { GPBUtil::checkDouble($var); $this->min_seen = $var; + + return $this; } /** - * double max_seen = 3; + * Generated from protobuf field double max_seen = 3; + * @return float */ public function getMaxSeen() { @@ -90,16 +99,21 @@ class HistogramData extends \Google\Protobuf\Internal\Message } /** - * double max_seen = 3; + * Generated from protobuf field double max_seen = 3; + * @param float $var + * @return $this */ public function setMaxSeen($var) { GPBUtil::checkDouble($var); $this->max_seen = $var; + + return $this; } /** - * double sum = 4; + * Generated from protobuf field double sum = 4; + * @return float */ public function getSum() { @@ -107,16 +121,21 @@ class HistogramData extends \Google\Protobuf\Internal\Message } /** - * double sum = 4; + * Generated from protobuf field double sum = 4; + * @param float $var + * @return $this */ public function setSum($var) { GPBUtil::checkDouble($var); $this->sum = $var; + + return $this; } /** - * double sum_of_squares = 5; + * Generated from protobuf field double sum_of_squares = 5; + * @return float */ public function getSumOfSquares() { @@ -124,16 +143,21 @@ class HistogramData extends \Google\Protobuf\Internal\Message } /** - * double sum_of_squares = 5; + * Generated from protobuf field double sum_of_squares = 5; + * @param float $var + * @return $this */ public function setSumOfSquares($var) { GPBUtil::checkDouble($var); $this->sum_of_squares = $var; + + return $this; } /** - * double count = 6; + * Generated from protobuf field double count = 6; + * @return float */ public function getCount() { @@ -141,12 +165,16 @@ class HistogramData extends \Google\Protobuf\Internal\Message } /** - * double count = 6; + * Generated from protobuf field double count = 6; + * @param float $var + * @return $this */ public function setCount($var) { GPBUtil::checkDouble($var); $this->count = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/HistogramParams.php b/src/php/tests/qps/generated_code/Grpc/Testing/HistogramParams.php index 836c94b01d8..1a1b484f144 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/HistogramParams.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/HistogramParams.php @@ -9,28 +9,22 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Histogram params based on grpc/support/histogram.c
- * 
* - * Protobuf type grpc.testing.HistogramParams + * Generated from protobuf message grpc.testing.HistogramParams */ class HistogramParams extends \Google\Protobuf\Internal\Message { /** - *
      * first bucket is [0, 1 + resolution)
-     * 
* - * double resolution = 1; + * Generated from protobuf field double resolution = 1; */ private $resolution = 0.0; /** - *
      * use enough buckets to allow this value
-     * 
* - * double max_possible = 2; + * Generated from protobuf field double max_possible = 2; */ private $max_possible = 0.0; @@ -40,11 +34,10 @@ class HistogramParams extends \Google\Protobuf\Internal\Message } /** - *
      * first bucket is [0, 1 + resolution)
-     * 
* - * double resolution = 1; + * Generated from protobuf field double resolution = 1; + * @return float */ public function getResolution() { @@ -52,24 +45,25 @@ class HistogramParams extends \Google\Protobuf\Internal\Message } /** - *
      * first bucket is [0, 1 + resolution)
-     * 
* - * double resolution = 1; + * Generated from protobuf field double resolution = 1; + * @param float $var + * @return $this */ public function setResolution($var) { GPBUtil::checkDouble($var); $this->resolution = $var; + + return $this; } /** - *
      * use enough buckets to allow this value
-     * 
* - * double max_possible = 2; + * Generated from protobuf field double max_possible = 2; + * @return float */ public function getMaxPossible() { @@ -77,16 +71,18 @@ class HistogramParams extends \Google\Protobuf\Internal\Message } /** - *
      * use enough buckets to allow this value
-     * 
* - * double max_possible = 2; + * Generated from protobuf field double max_possible = 2; + * @param float $var + * @return $this */ public function setMaxPossible($var) { GPBUtil::checkDouble($var); $this->max_possible = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/LoadParams.php b/src/php/tests/qps/generated_code/Grpc/Testing/LoadParams.php index 1f32e49c8aa..04c345f2421 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/LoadParams.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/LoadParams.php @@ -9,7 +9,7 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type grpc.testing.LoadParams + * Generated from protobuf message grpc.testing.LoadParams */ class LoadParams extends \Google\Protobuf\Internal\Message { @@ -21,7 +21,8 @@ class LoadParams extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.ClosedLoopParams closed_loop = 1; + * Generated from protobuf field .grpc.testing.ClosedLoopParams closed_loop = 1; + * @return \Grpc\Testing\ClosedLoopParams */ public function getClosedLoop() { @@ -29,16 +30,21 @@ class LoadParams extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.ClosedLoopParams closed_loop = 1; + * Generated from protobuf field .grpc.testing.ClosedLoopParams closed_loop = 1; + * @param \Grpc\Testing\ClosedLoopParams $var + * @return $this */ - public function setClosedLoop(&$var) + public function setClosedLoop($var) { GPBUtil::checkMessage($var, \Grpc\Testing\ClosedLoopParams::class); $this->writeOneof(1, $var); + + return $this; } /** - * .grpc.testing.PoissonParams poisson = 2; + * Generated from protobuf field .grpc.testing.PoissonParams poisson = 2; + * @return \Grpc\Testing\PoissonParams */ public function getPoisson() { @@ -46,14 +52,21 @@ class LoadParams extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.PoissonParams poisson = 2; + * Generated from protobuf field .grpc.testing.PoissonParams poisson = 2; + * @param \Grpc\Testing\PoissonParams $var + * @return $this */ - public function setPoisson(&$var) + public function setPoisson($var) { GPBUtil::checkMessage($var, \Grpc\Testing\PoissonParams::class); $this->writeOneof(2, $var); + + return $this; } + /** + * @return string + */ public function getLoad() { return $this->whichOneof("load"); diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/Mark.php b/src/php/tests/qps/generated_code/Grpc/Testing/Mark.php index ce006efacd8..be058d51be8 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/Mark.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/Mark.php @@ -9,20 +9,16 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Request current stats
- * 
* - * Protobuf type grpc.testing.Mark + * Generated from protobuf message grpc.testing.Mark */ class Mark extends \Google\Protobuf\Internal\Message { /** - *
      * if true, the stats will be reset after taking their snapshot.
-     * 
* - * bool reset = 1; + * Generated from protobuf field bool reset = 1; */ private $reset = false; @@ -32,11 +28,10 @@ class Mark extends \Google\Protobuf\Internal\Message } /** - *
      * if true, the stats will be reset after taking their snapshot.
-     * 
* - * bool reset = 1; + * Generated from protobuf field bool reset = 1; + * @return bool */ public function getReset() { @@ -44,16 +39,18 @@ class Mark extends \Google\Protobuf\Internal\Message } /** - *
      * if true, the stats will be reset after taking their snapshot.
-     * 
* - * bool reset = 1; + * Generated from protobuf field bool reset = 1; + * @param bool $var + * @return $this */ public function setReset($var) { GPBUtil::checkBool($var); $this->reset = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/Payload.php b/src/php/tests/qps/generated_code/Grpc/Testing/Payload.php index d17c271af74..ad97890c93f 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/Payload.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/Payload.php @@ -9,29 +9,23 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * A block of data, to simply increase gRPC message size.
- * 
* - * Protobuf type grpc.testing.Payload + * Generated from protobuf message grpc.testing.Payload */ class Payload extends \Google\Protobuf\Internal\Message { /** - *
      * DEPRECATED, don't use. To be removed shortly.
      * The type of data in body.
-     * 
* - * .grpc.testing.PayloadType type = 1; + * Generated from protobuf field .grpc.testing.PayloadType type = 1; */ private $type = 0; /** - *
      * Primary contents of payload.
-     * 
* - * bytes body = 2; + * Generated from protobuf field bytes body = 2; */ private $body = ''; @@ -41,12 +35,11 @@ class Payload extends \Google\Protobuf\Internal\Message } /** - *
      * DEPRECATED, don't use. To be removed shortly.
      * The type of data in body.
-     * 
* - * .grpc.testing.PayloadType type = 1; + * Generated from protobuf field .grpc.testing.PayloadType type = 1; + * @return int */ public function getType() { @@ -54,25 +47,26 @@ class Payload extends \Google\Protobuf\Internal\Message } /** - *
      * DEPRECATED, don't use. To be removed shortly.
      * The type of data in body.
-     * 
* - * .grpc.testing.PayloadType type = 1; + * Generated from protobuf field .grpc.testing.PayloadType type = 1; + * @param int $var + * @return $this */ public function setType($var) { GPBUtil::checkEnum($var, \Grpc\Testing\PayloadType::class); $this->type = $var; + + return $this; } /** - *
      * Primary contents of payload.
-     * 
* - * bytes body = 2; + * Generated from protobuf field bytes body = 2; + * @return string */ public function getBody() { @@ -80,16 +74,18 @@ class Payload extends \Google\Protobuf\Internal\Message } /** - *
      * Primary contents of payload.
-     * 
* - * bytes body = 2; + * Generated from protobuf field bytes body = 2; + * @param string $var + * @return $this */ public function setBody($var) { GPBUtil::checkString($var, False); $this->body = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/PayloadConfig.php b/src/php/tests/qps/generated_code/Grpc/Testing/PayloadConfig.php index a2fe7109ba7..748f52da82d 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/PayloadConfig.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/PayloadConfig.php @@ -9,7 +9,7 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type grpc.testing.PayloadConfig + * Generated from protobuf message grpc.testing.PayloadConfig */ class PayloadConfig extends \Google\Protobuf\Internal\Message { @@ -21,7 +21,8 @@ class PayloadConfig extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.ByteBufferParams bytebuf_params = 1; + * Generated from protobuf field .grpc.testing.ByteBufferParams bytebuf_params = 1; + * @return \Grpc\Testing\ByteBufferParams */ public function getBytebufParams() { @@ -29,16 +30,21 @@ class PayloadConfig extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.ByteBufferParams bytebuf_params = 1; + * Generated from protobuf field .grpc.testing.ByteBufferParams bytebuf_params = 1; + * @param \Grpc\Testing\ByteBufferParams $var + * @return $this */ - public function setBytebufParams(&$var) + public function setBytebufParams($var) { GPBUtil::checkMessage($var, \Grpc\Testing\ByteBufferParams::class); $this->writeOneof(1, $var); + + return $this; } /** - * .grpc.testing.SimpleProtoParams simple_params = 2; + * Generated from protobuf field .grpc.testing.SimpleProtoParams simple_params = 2; + * @return \Grpc\Testing\SimpleProtoParams */ public function getSimpleParams() { @@ -46,16 +52,21 @@ class PayloadConfig extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.SimpleProtoParams simple_params = 2; + * Generated from protobuf field .grpc.testing.SimpleProtoParams simple_params = 2; + * @param \Grpc\Testing\SimpleProtoParams $var + * @return $this */ - public function setSimpleParams(&$var) + public function setSimpleParams($var) { GPBUtil::checkMessage($var, \Grpc\Testing\SimpleProtoParams::class); $this->writeOneof(2, $var); + + return $this; } /** - * .grpc.testing.ComplexProtoParams complex_params = 3; + * Generated from protobuf field .grpc.testing.ComplexProtoParams complex_params = 3; + * @return \Grpc\Testing\ComplexProtoParams */ public function getComplexParams() { @@ -63,14 +74,21 @@ class PayloadConfig extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.ComplexProtoParams complex_params = 3; + * Generated from protobuf field .grpc.testing.ComplexProtoParams complex_params = 3; + * @param \Grpc\Testing\ComplexProtoParams $var + * @return $this */ - public function setComplexParams(&$var) + public function setComplexParams($var) { GPBUtil::checkMessage($var, \Grpc\Testing\ComplexProtoParams::class); $this->writeOneof(3, $var); + + return $this; } + /** + * @return string + */ public function getPayload() { return $this->whichOneof("payload"); diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/PayloadType.php b/src/php/tests/qps/generated_code/Grpc/Testing/PayloadType.php index 189ef034b47..d8df1af7982 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/PayloadType.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/PayloadType.php @@ -5,21 +5,17 @@ namespace Grpc\Testing; /** - *
  * DEPRECATED, don't use. To be removed shortly.
  * The type of payload that should be returned.
- * 
* - * Protobuf enum grpc.testing.PayloadType + * Protobuf enum Grpc\Testing\PayloadType */ class PayloadType { /** - *
      * Compressable text format.
-     * 
* - * COMPRESSABLE = 0; + * Generated from protobuf enum COMPRESSABLE = 0; */ const COMPRESSABLE = 0; } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/PoissonParams.php b/src/php/tests/qps/generated_code/Grpc/Testing/PoissonParams.php index d64edd45f03..6a4047f2ece 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/PoissonParams.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/PoissonParams.php @@ -9,21 +9,17 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Parameters of poisson process distribution, which is a good representation
  * of activity coming in from independent identical stationary sources.
- * 
* - * Protobuf type grpc.testing.PoissonParams + * Generated from protobuf message grpc.testing.PoissonParams */ class PoissonParams extends \Google\Protobuf\Internal\Message { /** - *
      * The rate of arrivals (a.k.a. lambda parameter of the exp distribution).
-     * 
* - * double offered_load = 1; + * Generated from protobuf field double offered_load = 1; */ private $offered_load = 0.0; @@ -33,11 +29,10 @@ class PoissonParams extends \Google\Protobuf\Internal\Message } /** - *
      * The rate of arrivals (a.k.a. lambda parameter of the exp distribution).
-     * 
* - * double offered_load = 1; + * Generated from protobuf field double offered_load = 1; + * @return float */ public function getOfferedLoad() { @@ -45,16 +40,18 @@ class PoissonParams extends \Google\Protobuf\Internal\Message } /** - *
      * The rate of arrivals (a.k.a. lambda parameter of the exp distribution).
-     * 
* - * double offered_load = 1; + * Generated from protobuf field double offered_load = 1; + * @param float $var + * @return $this */ public function setOfferedLoad($var) { GPBUtil::checkDouble($var); $this->offered_load = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ProxyClientServiceClient.php b/src/php/tests/qps/generated_code/Grpc/Testing/ProxyClientServiceClient.php index a6da2e7aefe..5510b57064f 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ProxyClientServiceClient.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ProxyClientServiceClient.php @@ -16,17 +16,19 @@ // See the License for the specific language governing permissions and // limitations under the License. // -namespace Grpc\Testing { +namespace Grpc\Testing; - class ProxyClientServiceClient extends \Grpc\BaseStub { +/** + */ +class ProxyClientServiceClient extends \Grpc\BaseStub { /** * @param string $hostname hostname * @param array $opts channel options - * @param Grpc\Channel $channel (optional) re-use channel object + * @param \Grpc\Channel $channel (optional) re-use channel object */ public function __construct($hostname, $opts, $channel = null) { - parent::__construct($hostname, $opts, $channel); + parent::__construct($hostname, $opts, $channel); } /** @@ -36,10 +38,10 @@ namespace Grpc\Testing { */ public function GetConfig(\Grpc\Testing\Void $argument, $metadata = [], $options = []) { - return $this->_simpleRequest('/grpc.testing.ProxyClientService/GetConfig', - $argument, - ['\Grpc\Testing\ClientConfig', 'decode'], - $metadata, $options); + return $this->_simpleRequest('/grpc.testing.ProxyClientService/GetConfig', + $argument, + ['\Grpc\Testing\ClientConfig', 'decode'], + $metadata, $options); } /** @@ -47,11 +49,19 @@ namespace Grpc\Testing { * @param array $options call options */ public function ReportTime($metadata = [], $options = []) { - return $this->_clientStreamRequest('/grpc.testing.ProxyClientService/ReportTime', - ['\Grpc\Testing\Void','decode'], - $metadata, $options); + return $this->_clientStreamRequest('/grpc.testing.ProxyClientService/ReportTime', + ['\Grpc\Testing\Void','decode'], + $metadata, $options); } - } + /** + * @param array $metadata metadata + * @param array $options call options + */ + public function ReportHist($metadata = [], $options = []) { + return $this->_clientStreamRequest('/grpc.testing.ProxyClientService/ReportHist', + ['\Grpc\Testing\Void','decode'], + $metadata, $options); + } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ProxyStat.php b/src/php/tests/qps/generated_code/Grpc/Testing/ProxyStat.php index ed43be99cef..6fab6115342 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ProxyStat.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ProxyStat.php @@ -9,12 +9,12 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type grpc.testing.ProxyStat + * Generated from protobuf message grpc.testing.ProxyStat */ class ProxyStat extends \Google\Protobuf\Internal\Message { /** - * double latency = 1; + * Generated from protobuf field double latency = 1; */ private $latency = 0.0; @@ -24,7 +24,8 @@ class ProxyStat extends \Google\Protobuf\Internal\Message } /** - * double latency = 1; + * Generated from protobuf field double latency = 1; + * @return float */ public function getLatency() { @@ -32,12 +33,16 @@ class ProxyStat extends \Google\Protobuf\Internal\Message } /** - * double latency = 1; + * Generated from protobuf field double latency = 1; + * @param float $var + * @return $this */ public function setLatency($var) { GPBUtil::checkDouble($var); $this->latency = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ReconnectInfo.php b/src/php/tests/qps/generated_code/Grpc/Testing/ReconnectInfo.php index dfaaa606c3b..cd728705fa4 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ReconnectInfo.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ReconnectInfo.php @@ -9,22 +9,20 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * For reconnect interop test only.
  * Server tells client whether its reconnects are following the spec and the
  * reconnect backoffs it saw.
- * 
* - * Protobuf type grpc.testing.ReconnectInfo + * Generated from protobuf message grpc.testing.ReconnectInfo */ class ReconnectInfo extends \Google\Protobuf\Internal\Message { /** - * bool passed = 1; + * Generated from protobuf field bool passed = 1; */ private $passed = false; /** - * repeated int32 backoff_ms = 2; + * Generated from protobuf field repeated int32 backoff_ms = 2; */ private $backoff_ms; @@ -34,7 +32,8 @@ class ReconnectInfo extends \Google\Protobuf\Internal\Message } /** - * bool passed = 1; + * Generated from protobuf field bool passed = 1; + * @return bool */ public function getPassed() { @@ -42,16 +41,21 @@ class ReconnectInfo extends \Google\Protobuf\Internal\Message } /** - * bool passed = 1; + * Generated from protobuf field bool passed = 1; + * @param bool $var + * @return $this */ public function setPassed($var) { GPBUtil::checkBool($var); $this->passed = $var; + + return $this; } /** - * repeated int32 backoff_ms = 2; + * Generated from protobuf field repeated int32 backoff_ms = 2; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getBackoffMs() { @@ -59,12 +63,16 @@ class ReconnectInfo extends \Google\Protobuf\Internal\Message } /** - * repeated int32 backoff_ms = 2; + * Generated from protobuf field repeated int32 backoff_ms = 2; + * @param int[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ - public function setBackoffMs(&$var) + public function setBackoffMs($var) { - GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); - $this->backoff_ms = $var; + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); + $this->backoff_ms = $arr; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ReconnectParams.php b/src/php/tests/qps/generated_code/Grpc/Testing/ReconnectParams.php index 97158557836..f91dc410cb5 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ReconnectParams.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ReconnectParams.php @@ -9,17 +9,15 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * For reconnect interop test only.
  * Client tells server what reconnection parameters it used.
- * 
* - * Protobuf type grpc.testing.ReconnectParams + * Generated from protobuf message grpc.testing.ReconnectParams */ class ReconnectParams extends \Google\Protobuf\Internal\Message { /** - * int32 max_reconnect_backoff_ms = 1; + * Generated from protobuf field int32 max_reconnect_backoff_ms = 1; */ private $max_reconnect_backoff_ms = 0; @@ -29,7 +27,8 @@ class ReconnectParams extends \Google\Protobuf\Internal\Message } /** - * int32 max_reconnect_backoff_ms = 1; + * Generated from protobuf field int32 max_reconnect_backoff_ms = 1; + * @return int */ public function getMaxReconnectBackoffMs() { @@ -37,12 +36,16 @@ class ReconnectParams extends \Google\Protobuf\Internal\Message } /** - * int32 max_reconnect_backoff_ms = 1; + * Generated from protobuf field int32 max_reconnect_backoff_ms = 1; + * @param int $var + * @return $this */ public function setMaxReconnectBackoffMs($var) { GPBUtil::checkInt32($var); $this->max_reconnect_backoff_ms = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ReportQpsScenarioServiceClient.php b/src/php/tests/qps/generated_code/Grpc/Testing/ReportQpsScenarioServiceClient.php new file mode 100644 index 00000000000..72d44ffc667 --- /dev/null +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ReportQpsScenarioServiceClient.php @@ -0,0 +1,50 @@ +_simpleRequest('/grpc.testing.ReportQpsScenarioService/ReportScenario', + $argument, + ['\Grpc\Testing\Void', 'decode'], + $metadata, $options); + } + +} diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/RequestResultCount.php b/src/php/tests/qps/generated_code/Grpc/Testing/RequestResultCount.php index 1be42b2ac91..75fa6cafe28 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/RequestResultCount.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/RequestResultCount.php @@ -9,16 +9,16 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type grpc.testing.RequestResultCount + * Generated from protobuf message grpc.testing.RequestResultCount */ class RequestResultCount extends \Google\Protobuf\Internal\Message { /** - * int32 status_code = 1; + * Generated from protobuf field int32 status_code = 1; */ private $status_code = 0; /** - * int64 count = 2; + * Generated from protobuf field int64 count = 2; */ private $count = 0; @@ -28,7 +28,8 @@ class RequestResultCount extends \Google\Protobuf\Internal\Message } /** - * int32 status_code = 1; + * Generated from protobuf field int32 status_code = 1; + * @return int */ public function getStatusCode() { @@ -36,16 +37,21 @@ class RequestResultCount extends \Google\Protobuf\Internal\Message } /** - * int32 status_code = 1; + * Generated from protobuf field int32 status_code = 1; + * @param int $var + * @return $this */ public function setStatusCode($var) { GPBUtil::checkInt32($var); $this->status_code = $var; + + return $this; } /** - * int64 count = 2; + * Generated from protobuf field int64 count = 2; + * @return int|string */ public function getCount() { @@ -53,12 +59,16 @@ class RequestResultCount extends \Google\Protobuf\Internal\Message } /** - * int64 count = 2; + * Generated from protobuf field int64 count = 2; + * @param int|string $var + * @return $this */ public function setCount($var) { GPBUtil::checkInt64($var); $this->count = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ResponseParameters.php b/src/php/tests/qps/generated_code/Grpc/Testing/ResponseParameters.php index b7a8e5ece71..b2f0a827fe0 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ResponseParameters.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ResponseParameters.php @@ -9,40 +9,32 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Configuration for a particular response.
- * 
* - * Protobuf type grpc.testing.ResponseParameters + * Generated from protobuf message grpc.testing.ResponseParameters */ class ResponseParameters extends \Google\Protobuf\Internal\Message { /** - *
      * Desired payload sizes in responses from the server.
-     * 
* - * int32 size = 1; + * Generated from protobuf field int32 size = 1; */ private $size = 0; /** - *
      * Desired interval between consecutive responses in the response stream in
      * microseconds.
-     * 
* - * int32 interval_us = 2; + * Generated from protobuf field int32 interval_us = 2; */ private $interval_us = 0; /** - *
      * Whether to request the server to compress the response. This field is
      * "nullable" in order to interoperate seamlessly with clients not able to
      * implement the full compression tests by introspecting the call to verify
      * the response's compression status.
-     * 
* - * .grpc.testing.BoolValue compressed = 3; + * Generated from protobuf field .grpc.testing.BoolValue compressed = 3; */ private $compressed = null; @@ -52,11 +44,10 @@ class ResponseParameters extends \Google\Protobuf\Internal\Message } /** - *
      * Desired payload sizes in responses from the server.
-     * 
* - * int32 size = 1; + * Generated from protobuf field int32 size = 1; + * @return int */ public function getSize() { @@ -64,25 +55,26 @@ class ResponseParameters extends \Google\Protobuf\Internal\Message } /** - *
      * Desired payload sizes in responses from the server.
-     * 
* - * int32 size = 1; + * Generated from protobuf field int32 size = 1; + * @param int $var + * @return $this */ public function setSize($var) { GPBUtil::checkInt32($var); $this->size = $var; + + return $this; } /** - *
      * Desired interval between consecutive responses in the response stream in
      * microseconds.
-     * 
* - * int32 interval_us = 2; + * Generated from protobuf field int32 interval_us = 2; + * @return int */ public function getIntervalUs() { @@ -90,28 +82,29 @@ class ResponseParameters extends \Google\Protobuf\Internal\Message } /** - *
      * Desired interval between consecutive responses in the response stream in
      * microseconds.
-     * 
* - * int32 interval_us = 2; + * Generated from protobuf field int32 interval_us = 2; + * @param int $var + * @return $this */ public function setIntervalUs($var) { GPBUtil::checkInt32($var); $this->interval_us = $var; + + return $this; } /** - *
      * Whether to request the server to compress the response. This field is
      * "nullable" in order to interoperate seamlessly with clients not able to
      * implement the full compression tests by introspecting the call to verify
      * the response's compression status.
-     * 
* - * .grpc.testing.BoolValue compressed = 3; + * Generated from protobuf field .grpc.testing.BoolValue compressed = 3; + * @return \Grpc\Testing\BoolValue */ public function getCompressed() { @@ -119,19 +112,21 @@ class ResponseParameters extends \Google\Protobuf\Internal\Message } /** - *
      * Whether to request the server to compress the response. This field is
      * "nullable" in order to interoperate seamlessly with clients not able to
      * implement the full compression tests by introspecting the call to verify
      * the response's compression status.
-     * 
* - * .grpc.testing.BoolValue compressed = 3; + * Generated from protobuf field .grpc.testing.BoolValue compressed = 3; + * @param \Grpc\Testing\BoolValue $var + * @return $this */ - public function setCompressed(&$var) + public function setCompressed($var) { GPBUtil::checkMessage($var, \Grpc\Testing\BoolValue::class); $this->compressed = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/RpcType.php b/src/php/tests/qps/generated_code/Grpc/Testing/RpcType.php index 2e664fff477..73a66490ea9 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/RpcType.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/RpcType.php @@ -5,17 +5,29 @@ namespace Grpc\Testing; /** - * Protobuf enum grpc.testing.RpcType + * Protobuf enum Grpc\Testing\RpcType */ class RpcType { /** - * UNARY = 0; + * Generated from protobuf enum UNARY = 0; */ const UNARY = 0; /** - * STREAMING = 1; + * Generated from protobuf enum STREAMING = 1; */ const STREAMING = 1; + /** + * Generated from protobuf enum STREAMING_FROM_CLIENT = 2; + */ + const STREAMING_FROM_CLIENT = 2; + /** + * Generated from protobuf enum STREAMING_FROM_SERVER = 3; + */ + const STREAMING_FROM_SERVER = 3; + /** + * Generated from protobuf enum STREAMING_BOTH_WAYS = 4; + */ + const STREAMING_BOTH_WAYS = 4; } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/Scenario.php b/src/php/tests/qps/generated_code/Grpc/Testing/Scenario.php index 136ed299ea8..9ec284b71f2 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/Scenario.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/Scenario.php @@ -9,76 +9,58 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * A single performance scenario: input to qps_json_driver
- * 
* - * Protobuf type grpc.testing.Scenario + * Generated from protobuf message grpc.testing.Scenario */ class Scenario extends \Google\Protobuf\Internal\Message { /** - *
      * Human readable name for this scenario
-     * 
* - * string name = 1; + * Generated from protobuf field string name = 1; */ private $name = ''; /** - *
      * Client configuration
-     * 
* - * .grpc.testing.ClientConfig client_config = 2; + * Generated from protobuf field .grpc.testing.ClientConfig client_config = 2; */ private $client_config = null; /** - *
      * Number of clients to start for the test
-     * 
* - * int32 num_clients = 3; + * Generated from protobuf field int32 num_clients = 3; */ private $num_clients = 0; /** - *
      * Server configuration
-     * 
* - * .grpc.testing.ServerConfig server_config = 4; + * Generated from protobuf field .grpc.testing.ServerConfig server_config = 4; */ private $server_config = null; /** - *
      * Number of servers to start for the test
-     * 
* - * int32 num_servers = 5; + * Generated from protobuf field int32 num_servers = 5; */ private $num_servers = 0; /** - *
      * Warmup period, in seconds
-     * 
* - * int32 warmup_seconds = 6; + * Generated from protobuf field int32 warmup_seconds = 6; */ private $warmup_seconds = 0; /** - *
      * Benchmark time, in seconds
-     * 
* - * int32 benchmark_seconds = 7; + * Generated from protobuf field int32 benchmark_seconds = 7; */ private $benchmark_seconds = 0; /** - *
      * Number of workers to spawn locally (usually zero)
-     * 
* - * int32 spawn_local_worker_count = 8; + * Generated from protobuf field int32 spawn_local_worker_count = 8; */ private $spawn_local_worker_count = 0; @@ -88,11 +70,10 @@ class Scenario extends \Google\Protobuf\Internal\Message } /** - *
      * Human readable name for this scenario
-     * 
* - * string name = 1; + * Generated from protobuf field string name = 1; + * @return string */ public function getName() { @@ -100,24 +81,25 @@ class Scenario extends \Google\Protobuf\Internal\Message } /** - *
      * Human readable name for this scenario
-     * 
* - * string name = 1; + * Generated from protobuf field string name = 1; + * @param string $var + * @return $this */ public function setName($var) { GPBUtil::checkString($var, True); $this->name = $var; + + return $this; } /** - *
      * Client configuration
-     * 
* - * .grpc.testing.ClientConfig client_config = 2; + * Generated from protobuf field .grpc.testing.ClientConfig client_config = 2; + * @return \Grpc\Testing\ClientConfig */ public function getClientConfig() { @@ -125,24 +107,25 @@ class Scenario extends \Google\Protobuf\Internal\Message } /** - *
      * Client configuration
-     * 
* - * .grpc.testing.ClientConfig client_config = 2; + * Generated from protobuf field .grpc.testing.ClientConfig client_config = 2; + * @param \Grpc\Testing\ClientConfig $var + * @return $this */ - public function setClientConfig(&$var) + public function setClientConfig($var) { GPBUtil::checkMessage($var, \Grpc\Testing\ClientConfig::class); $this->client_config = $var; + + return $this; } /** - *
      * Number of clients to start for the test
-     * 
* - * int32 num_clients = 3; + * Generated from protobuf field int32 num_clients = 3; + * @return int */ public function getNumClients() { @@ -150,24 +133,25 @@ class Scenario extends \Google\Protobuf\Internal\Message } /** - *
      * Number of clients to start for the test
-     * 
* - * int32 num_clients = 3; + * Generated from protobuf field int32 num_clients = 3; + * @param int $var + * @return $this */ public function setNumClients($var) { GPBUtil::checkInt32($var); $this->num_clients = $var; + + return $this; } /** - *
      * Server configuration
-     * 
* - * .grpc.testing.ServerConfig server_config = 4; + * Generated from protobuf field .grpc.testing.ServerConfig server_config = 4; + * @return \Grpc\Testing\ServerConfig */ public function getServerConfig() { @@ -175,24 +159,25 @@ class Scenario extends \Google\Protobuf\Internal\Message } /** - *
      * Server configuration
-     * 
* - * .grpc.testing.ServerConfig server_config = 4; + * Generated from protobuf field .grpc.testing.ServerConfig server_config = 4; + * @param \Grpc\Testing\ServerConfig $var + * @return $this */ - public function setServerConfig(&$var) + public function setServerConfig($var) { GPBUtil::checkMessage($var, \Grpc\Testing\ServerConfig::class); $this->server_config = $var; + + return $this; } /** - *
      * Number of servers to start for the test
-     * 
* - * int32 num_servers = 5; + * Generated from protobuf field int32 num_servers = 5; + * @return int */ public function getNumServers() { @@ -200,24 +185,25 @@ class Scenario extends \Google\Protobuf\Internal\Message } /** - *
      * Number of servers to start for the test
-     * 
* - * int32 num_servers = 5; + * Generated from protobuf field int32 num_servers = 5; + * @param int $var + * @return $this */ public function setNumServers($var) { GPBUtil::checkInt32($var); $this->num_servers = $var; + + return $this; } /** - *
      * Warmup period, in seconds
-     * 
* - * int32 warmup_seconds = 6; + * Generated from protobuf field int32 warmup_seconds = 6; + * @return int */ public function getWarmupSeconds() { @@ -225,24 +211,25 @@ class Scenario extends \Google\Protobuf\Internal\Message } /** - *
      * Warmup period, in seconds
-     * 
* - * int32 warmup_seconds = 6; + * Generated from protobuf field int32 warmup_seconds = 6; + * @param int $var + * @return $this */ public function setWarmupSeconds($var) { GPBUtil::checkInt32($var); $this->warmup_seconds = $var; + + return $this; } /** - *
      * Benchmark time, in seconds
-     * 
* - * int32 benchmark_seconds = 7; + * Generated from protobuf field int32 benchmark_seconds = 7; + * @return int */ public function getBenchmarkSeconds() { @@ -250,24 +237,25 @@ class Scenario extends \Google\Protobuf\Internal\Message } /** - *
      * Benchmark time, in seconds
-     * 
* - * int32 benchmark_seconds = 7; + * Generated from protobuf field int32 benchmark_seconds = 7; + * @param int $var + * @return $this */ public function setBenchmarkSeconds($var) { GPBUtil::checkInt32($var); $this->benchmark_seconds = $var; + + return $this; } /** - *
      * Number of workers to spawn locally (usually zero)
-     * 
* - * int32 spawn_local_worker_count = 8; + * Generated from protobuf field int32 spawn_local_worker_count = 8; + * @return int */ public function getSpawnLocalWorkerCount() { @@ -275,16 +263,18 @@ class Scenario extends \Google\Protobuf\Internal\Message } /** - *
      * Number of workers to spawn locally (usually zero)
-     * 
* - * int32 spawn_local_worker_count = 8; + * Generated from protobuf field int32 spawn_local_worker_count = 8; + * @param int $var + * @return $this */ public function setSpawnLocalWorkerCount($var) { GPBUtil::checkInt32($var); $this->spawn_local_worker_count = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ScenarioResult.php b/src/php/tests/qps/generated_code/Grpc/Testing/ScenarioResult.php index 809cd96244d..31d9a39a1fc 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ScenarioResult.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ScenarioResult.php @@ -9,80 +9,62 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Results of a single benchmark scenario.
- * 
* - * Protobuf type grpc.testing.ScenarioResult + * Generated from protobuf message grpc.testing.ScenarioResult */ class ScenarioResult extends \Google\Protobuf\Internal\Message { /** - *
      * Inputs used to run the scenario.
-     * 
* - * .grpc.testing.Scenario scenario = 1; + * Generated from protobuf field .grpc.testing.Scenario scenario = 1; */ private $scenario = null; /** - *
      * Histograms from all clients merged into one histogram.
-     * 
* - * .grpc.testing.HistogramData latencies = 2; + * Generated from protobuf field .grpc.testing.HistogramData latencies = 2; */ private $latencies = null; /** - *
      * Client stats for each client
-     * 
* - * repeated .grpc.testing.ClientStats client_stats = 3; + * Generated from protobuf field repeated .grpc.testing.ClientStats client_stats = 3; */ private $client_stats; /** - *
      * Server stats for each server
-     * 
* - * repeated .grpc.testing.ServerStats server_stats = 4; + * Generated from protobuf field repeated .grpc.testing.ServerStats server_stats = 4; */ private $server_stats; /** - *
      * Number of cores available to each server
-     * 
* - * repeated int32 server_cores = 5; + * Generated from protobuf field repeated int32 server_cores = 5; */ private $server_cores; /** - *
      * An after-the-fact computed summary
-     * 
* - * .grpc.testing.ScenarioResultSummary summary = 6; + * Generated from protobuf field .grpc.testing.ScenarioResultSummary summary = 6; */ private $summary = null; /** - *
      * Information on success or failure of each worker
-     * 
* - * repeated bool client_success = 7; + * Generated from protobuf field repeated bool client_success = 7; */ private $client_success; /** - * repeated bool server_success = 8; + * Generated from protobuf field repeated bool server_success = 8; */ private $server_success; /** - *
      * Number of failed requests (one row per status code seen)
-     * 
* - * repeated .grpc.testing.RequestResultCount request_results = 9; + * Generated from protobuf field repeated .grpc.testing.RequestResultCount request_results = 9; */ private $request_results; @@ -92,11 +74,10 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message } /** - *
      * Inputs used to run the scenario.
-     * 
* - * .grpc.testing.Scenario scenario = 1; + * Generated from protobuf field .grpc.testing.Scenario scenario = 1; + * @return \Grpc\Testing\Scenario */ public function getScenario() { @@ -104,24 +85,25 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message } /** - *
      * Inputs used to run the scenario.
-     * 
* - * .grpc.testing.Scenario scenario = 1; + * Generated from protobuf field .grpc.testing.Scenario scenario = 1; + * @param \Grpc\Testing\Scenario $var + * @return $this */ - public function setScenario(&$var) + public function setScenario($var) { GPBUtil::checkMessage($var, \Grpc\Testing\Scenario::class); $this->scenario = $var; + + return $this; } /** - *
      * Histograms from all clients merged into one histogram.
-     * 
* - * .grpc.testing.HistogramData latencies = 2; + * Generated from protobuf field .grpc.testing.HistogramData latencies = 2; + * @return \Grpc\Testing\HistogramData */ public function getLatencies() { @@ -129,24 +111,25 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message } /** - *
      * Histograms from all clients merged into one histogram.
-     * 
* - * .grpc.testing.HistogramData latencies = 2; + * Generated from protobuf field .grpc.testing.HistogramData latencies = 2; + * @param \Grpc\Testing\HistogramData $var + * @return $this */ - public function setLatencies(&$var) + public function setLatencies($var) { GPBUtil::checkMessage($var, \Grpc\Testing\HistogramData::class); $this->latencies = $var; + + return $this; } /** - *
      * Client stats for each client
-     * 
* - * repeated .grpc.testing.ClientStats client_stats = 3; + * Generated from protobuf field repeated .grpc.testing.ClientStats client_stats = 3; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getClientStats() { @@ -154,24 +137,25 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message } /** - *
      * Client stats for each client
-     * 
* - * repeated .grpc.testing.ClientStats client_stats = 3; + * Generated from protobuf field repeated .grpc.testing.ClientStats client_stats = 3; + * @param \Grpc\Testing\ClientStats[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ - public function setClientStats(&$var) + public function setClientStats($var) { - GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\ClientStats::class); - $this->client_stats = $var; + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\ClientStats::class); + $this->client_stats = $arr; + + return $this; } /** - *
      * Server stats for each server
-     * 
* - * repeated .grpc.testing.ServerStats server_stats = 4; + * Generated from protobuf field repeated .grpc.testing.ServerStats server_stats = 4; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getServerStats() { @@ -179,24 +163,25 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message } /** - *
      * Server stats for each server
-     * 
* - * repeated .grpc.testing.ServerStats server_stats = 4; + * Generated from protobuf field repeated .grpc.testing.ServerStats server_stats = 4; + * @param \Grpc\Testing\ServerStats[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ - public function setServerStats(&$var) + public function setServerStats($var) { - GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\ServerStats::class); - $this->server_stats = $var; + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\ServerStats::class); + $this->server_stats = $arr; + + return $this; } /** - *
      * Number of cores available to each server
-     * 
* - * repeated int32 server_cores = 5; + * Generated from protobuf field repeated int32 server_cores = 5; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getServerCores() { @@ -204,24 +189,25 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message } /** - *
      * Number of cores available to each server
-     * 
* - * repeated int32 server_cores = 5; + * Generated from protobuf field repeated int32 server_cores = 5; + * @param int[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ - public function setServerCores(&$var) + public function setServerCores($var) { - GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); - $this->server_cores = $var; + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); + $this->server_cores = $arr; + + return $this; } /** - *
      * An after-the-fact computed summary
-     * 
* - * .grpc.testing.ScenarioResultSummary summary = 6; + * Generated from protobuf field .grpc.testing.ScenarioResultSummary summary = 6; + * @return \Grpc\Testing\ScenarioResultSummary */ public function getSummary() { @@ -229,24 +215,25 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message } /** - *
      * An after-the-fact computed summary
-     * 
* - * .grpc.testing.ScenarioResultSummary summary = 6; + * Generated from protobuf field .grpc.testing.ScenarioResultSummary summary = 6; + * @param \Grpc\Testing\ScenarioResultSummary $var + * @return $this */ - public function setSummary(&$var) + public function setSummary($var) { GPBUtil::checkMessage($var, \Grpc\Testing\ScenarioResultSummary::class); $this->summary = $var; + + return $this; } /** - *
      * Information on success or failure of each worker
-     * 
* - * repeated bool client_success = 7; + * Generated from protobuf field repeated bool client_success = 7; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getClientSuccess() { @@ -254,20 +241,23 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message } /** - *
      * Information on success or failure of each worker
-     * 
* - * repeated bool client_success = 7; + * Generated from protobuf field repeated bool client_success = 7; + * @param bool[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ - public function setClientSuccess(&$var) + public function setClientSuccess($var) { - GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::BOOL); - $this->client_success = $var; + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::BOOL); + $this->client_success = $arr; + + return $this; } /** - * repeated bool server_success = 8; + * Generated from protobuf field repeated bool server_success = 8; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getServerSuccess() { @@ -275,20 +265,23 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message } /** - * repeated bool server_success = 8; + * Generated from protobuf field repeated bool server_success = 8; + * @param bool[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ - public function setServerSuccess(&$var) + public function setServerSuccess($var) { - GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::BOOL); - $this->server_success = $var; + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::BOOL); + $this->server_success = $arr; + + return $this; } /** - *
      * Number of failed requests (one row per status code seen)
-     * 
* - * repeated .grpc.testing.RequestResultCount request_results = 9; + * Generated from protobuf field repeated .grpc.testing.RequestResultCount request_results = 9; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getRequestResults() { @@ -296,16 +289,18 @@ class ScenarioResult extends \Google\Protobuf\Internal\Message } /** - *
      * Number of failed requests (one row per status code seen)
-     * 
* - * repeated .grpc.testing.RequestResultCount request_results = 9; + * Generated from protobuf field repeated .grpc.testing.RequestResultCount request_results = 9; + * @param \Grpc\Testing\RequestResultCount[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ - public function setRequestResults(&$var) + public function setRequestResults($var) { - GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\RequestResultCount::class); - $this->request_results = $var; + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\RequestResultCount::class); + $this->request_results = $arr; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ScenarioResultSummary.php b/src/php/tests/qps/generated_code/Grpc/Testing/ScenarioResultSummary.php index 7520cff78e8..f7f1c987b53 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ScenarioResultSummary.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ScenarioResultSummary.php @@ -9,107 +9,107 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Basic summary that can be computed from ClientStats and ServerStats
  * once the scenario has finished.
- * 
* - * Protobuf type grpc.testing.ScenarioResultSummary + * Generated from protobuf message grpc.testing.ScenarioResultSummary */ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message { /** - *
      * Total number of operations per second over all clients.
-     * 
* - * double qps = 1; + * Generated from protobuf field double qps = 1; */ private $qps = 0.0; /** - *
      * QPS per one server core.
-     * 
* - * double qps_per_server_core = 2; + * Generated from protobuf field double qps_per_server_core = 2; */ private $qps_per_server_core = 0.0; /** - *
-     * server load based on system_time (0.85 => 85%)
-     * 
+ * server load based on system_time (0.85 => 85%) * - * double server_system_time = 3; + * Generated from protobuf field double server_system_time = 3; */ private $server_system_time = 0.0; /** - *
-     * server load based on user_time (0.85 => 85%)
-     * 
+ * server load based on user_time (0.85 => 85%) * - * double server_user_time = 4; + * Generated from protobuf field double server_user_time = 4; */ private $server_user_time = 0.0; /** - *
-     * client load based on system_time (0.85 => 85%)
-     * 
+ * client load based on system_time (0.85 => 85%) * - * double client_system_time = 5; + * Generated from protobuf field double client_system_time = 5; */ private $client_system_time = 0.0; /** - *
-     * client load based on user_time (0.85 => 85%)
-     * 
+ * client load based on user_time (0.85 => 85%) * - * double client_user_time = 6; + * Generated from protobuf field double client_user_time = 6; */ private $client_user_time = 0.0; /** - *
      * X% latency percentiles (in nanoseconds)
-     * 
* - * double latency_50 = 7; + * Generated from protobuf field double latency_50 = 7; */ private $latency_50 = 0.0; /** - * double latency_90 = 8; + * Generated from protobuf field double latency_90 = 8; */ private $latency_90 = 0.0; /** - * double latency_95 = 9; + * Generated from protobuf field double latency_95 = 9; */ private $latency_95 = 0.0; /** - * double latency_99 = 10; + * Generated from protobuf field double latency_99 = 10; */ private $latency_99 = 0.0; /** - * double latency_999 = 11; + * Generated from protobuf field double latency_999 = 11; */ private $latency_999 = 0.0; /** - *
      * server cpu usage percentage
-     * 
* - * double server_cpu_usage = 12; + * Generated from protobuf field double server_cpu_usage = 12; */ private $server_cpu_usage = 0.0; /** - *
      * Number of requests that succeeded/failed
-     * 
* - * double successful_requests_per_second = 13; + * Generated from protobuf field double successful_requests_per_second = 13; */ private $successful_requests_per_second = 0.0; /** - * double failed_requests_per_second = 14; + * Generated from protobuf field double failed_requests_per_second = 14; */ private $failed_requests_per_second = 0.0; + /** + * Number of polls called inside completion queue per request + * + * Generated from protobuf field double client_polls_per_request = 15; + */ + private $client_polls_per_request = 0.0; + /** + * Generated from protobuf field double server_polls_per_request = 16; + */ + private $server_polls_per_request = 0.0; + /** + * Queries per CPU-sec over all servers or clients + * + * Generated from protobuf field double server_queries_per_cpu_sec = 17; + */ + private $server_queries_per_cpu_sec = 0.0; + /** + * Generated from protobuf field double client_queries_per_cpu_sec = 18; + */ + private $client_queries_per_cpu_sec = 0.0; public function __construct() { \GPBMetadata\Src\Proto\Grpc\Testing\Control::initOnce(); @@ -117,11 +117,10 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message } /** - *
      * Total number of operations per second over all clients.
-     * 
* - * double qps = 1; + * Generated from protobuf field double qps = 1; + * @return float */ public function getQps() { @@ -129,24 +128,25 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message } /** - *
      * Total number of operations per second over all clients.
-     * 
* - * double qps = 1; + * Generated from protobuf field double qps = 1; + * @param float $var + * @return $this */ public function setQps($var) { GPBUtil::checkDouble($var); $this->qps = $var; + + return $this; } /** - *
      * QPS per one server core.
-     * 
* - * double qps_per_server_core = 2; + * Generated from protobuf field double qps_per_server_core = 2; + * @return float */ public function getQpsPerServerCore() { @@ -154,24 +154,25 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message } /** - *
      * QPS per one server core.
-     * 
* - * double qps_per_server_core = 2; + * Generated from protobuf field double qps_per_server_core = 2; + * @param float $var + * @return $this */ public function setQpsPerServerCore($var) { GPBUtil::checkDouble($var); $this->qps_per_server_core = $var; + + return $this; } /** - *
-     * server load based on system_time (0.85 => 85%)
-     * 
+ * server load based on system_time (0.85 => 85%) * - * double server_system_time = 3; + * Generated from protobuf field double server_system_time = 3; + * @return float */ public function getServerSystemTime() { @@ -179,24 +180,25 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message } /** - *
-     * server load based on system_time (0.85 => 85%)
-     * 
+ * server load based on system_time (0.85 => 85%) * - * double server_system_time = 3; + * Generated from protobuf field double server_system_time = 3; + * @param float $var + * @return $this */ public function setServerSystemTime($var) { GPBUtil::checkDouble($var); $this->server_system_time = $var; + + return $this; } /** - *
-     * server load based on user_time (0.85 => 85%)
-     * 
+ * server load based on user_time (0.85 => 85%) * - * double server_user_time = 4; + * Generated from protobuf field double server_user_time = 4; + * @return float */ public function getServerUserTime() { @@ -204,24 +206,25 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message } /** - *
-     * server load based on user_time (0.85 => 85%)
-     * 
+ * server load based on user_time (0.85 => 85%) * - * double server_user_time = 4; + * Generated from protobuf field double server_user_time = 4; + * @param float $var + * @return $this */ public function setServerUserTime($var) { GPBUtil::checkDouble($var); $this->server_user_time = $var; + + return $this; } /** - *
-     * client load based on system_time (0.85 => 85%)
-     * 
+ * client load based on system_time (0.85 => 85%) * - * double client_system_time = 5; + * Generated from protobuf field double client_system_time = 5; + * @return float */ public function getClientSystemTime() { @@ -229,24 +232,25 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message } /** - *
-     * client load based on system_time (0.85 => 85%)
-     * 
+ * client load based on system_time (0.85 => 85%) * - * double client_system_time = 5; + * Generated from protobuf field double client_system_time = 5; + * @param float $var + * @return $this */ public function setClientSystemTime($var) { GPBUtil::checkDouble($var); $this->client_system_time = $var; + + return $this; } /** - *
-     * client load based on user_time (0.85 => 85%)
-     * 
+ * client load based on user_time (0.85 => 85%) * - * double client_user_time = 6; + * Generated from protobuf field double client_user_time = 6; + * @return float */ public function getClientUserTime() { @@ -254,24 +258,25 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message } /** - *
-     * client load based on user_time (0.85 => 85%)
-     * 
+ * client load based on user_time (0.85 => 85%) * - * double client_user_time = 6; + * Generated from protobuf field double client_user_time = 6; + * @param float $var + * @return $this */ public function setClientUserTime($var) { GPBUtil::checkDouble($var); $this->client_user_time = $var; + + return $this; } /** - *
      * X% latency percentiles (in nanoseconds)
-     * 
* - * double latency_50 = 7; + * Generated from protobuf field double latency_50 = 7; + * @return float */ public function getLatency50() { @@ -279,20 +284,23 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message } /** - *
      * X% latency percentiles (in nanoseconds)
-     * 
* - * double latency_50 = 7; + * Generated from protobuf field double latency_50 = 7; + * @param float $var + * @return $this */ public function setLatency50($var) { GPBUtil::checkDouble($var); $this->latency_50 = $var; + + return $this; } /** - * double latency_90 = 8; + * Generated from protobuf field double latency_90 = 8; + * @return float */ public function getLatency90() { @@ -300,16 +308,21 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message } /** - * double latency_90 = 8; + * Generated from protobuf field double latency_90 = 8; + * @param float $var + * @return $this */ public function setLatency90($var) { GPBUtil::checkDouble($var); $this->latency_90 = $var; + + return $this; } /** - * double latency_95 = 9; + * Generated from protobuf field double latency_95 = 9; + * @return float */ public function getLatency95() { @@ -317,16 +330,21 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message } /** - * double latency_95 = 9; + * Generated from protobuf field double latency_95 = 9; + * @param float $var + * @return $this */ public function setLatency95($var) { GPBUtil::checkDouble($var); $this->latency_95 = $var; + + return $this; } /** - * double latency_99 = 10; + * Generated from protobuf field double latency_99 = 10; + * @return float */ public function getLatency99() { @@ -334,16 +352,21 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message } /** - * double latency_99 = 10; + * Generated from protobuf field double latency_99 = 10; + * @param float $var + * @return $this */ public function setLatency99($var) { GPBUtil::checkDouble($var); $this->latency_99 = $var; + + return $this; } /** - * double latency_999 = 11; + * Generated from protobuf field double latency_999 = 11; + * @return float */ public function getLatency999() { @@ -351,20 +374,23 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message } /** - * double latency_999 = 11; + * Generated from protobuf field double latency_999 = 11; + * @param float $var + * @return $this */ public function setLatency999($var) { GPBUtil::checkDouble($var); $this->latency_999 = $var; + + return $this; } /** - *
      * server cpu usage percentage
-     * 
* - * double server_cpu_usage = 12; + * Generated from protobuf field double server_cpu_usage = 12; + * @return float */ public function getServerCpuUsage() { @@ -372,24 +398,25 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message } /** - *
      * server cpu usage percentage
-     * 
* - * double server_cpu_usage = 12; + * Generated from protobuf field double server_cpu_usage = 12; + * @param float $var + * @return $this */ public function setServerCpuUsage($var) { GPBUtil::checkDouble($var); $this->server_cpu_usage = $var; + + return $this; } /** - *
      * Number of requests that succeeded/failed
-     * 
* - * double successful_requests_per_second = 13; + * Generated from protobuf field double successful_requests_per_second = 13; + * @return float */ public function getSuccessfulRequestsPerSecond() { @@ -397,20 +424,23 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message } /** - *
      * Number of requests that succeeded/failed
-     * 
* - * double successful_requests_per_second = 13; + * Generated from protobuf field double successful_requests_per_second = 13; + * @param float $var + * @return $this */ public function setSuccessfulRequestsPerSecond($var) { GPBUtil::checkDouble($var); $this->successful_requests_per_second = $var; + + return $this; } /** - * double failed_requests_per_second = 14; + * Generated from protobuf field double failed_requests_per_second = 14; + * @return float */ public function getFailedRequestsPerSecond() { @@ -418,12 +448,112 @@ class ScenarioResultSummary extends \Google\Protobuf\Internal\Message } /** - * double failed_requests_per_second = 14; + * Generated from protobuf field double failed_requests_per_second = 14; + * @param float $var + * @return $this */ public function setFailedRequestsPerSecond($var) { GPBUtil::checkDouble($var); $this->failed_requests_per_second = $var; + + return $this; + } + + /** + * Number of polls called inside completion queue per request + * + * Generated from protobuf field double client_polls_per_request = 15; + * @return float + */ + public function getClientPollsPerRequest() + { + return $this->client_polls_per_request; + } + + /** + * Number of polls called inside completion queue per request + * + * Generated from protobuf field double client_polls_per_request = 15; + * @param float $var + * @return $this + */ + public function setClientPollsPerRequest($var) + { + GPBUtil::checkDouble($var); + $this->client_polls_per_request = $var; + + return $this; + } + + /** + * Generated from protobuf field double server_polls_per_request = 16; + * @return float + */ + public function getServerPollsPerRequest() + { + return $this->server_polls_per_request; + } + + /** + * Generated from protobuf field double server_polls_per_request = 16; + * @param float $var + * @return $this + */ + public function setServerPollsPerRequest($var) + { + GPBUtil::checkDouble($var); + $this->server_polls_per_request = $var; + + return $this; + } + + /** + * Queries per CPU-sec over all servers or clients + * + * Generated from protobuf field double server_queries_per_cpu_sec = 17; + * @return float + */ + public function getServerQueriesPerCpuSec() + { + return $this->server_queries_per_cpu_sec; + } + + /** + * Queries per CPU-sec over all servers or clients + * + * Generated from protobuf field double server_queries_per_cpu_sec = 17; + * @param float $var + * @return $this + */ + public function setServerQueriesPerCpuSec($var) + { + GPBUtil::checkDouble($var); + $this->server_queries_per_cpu_sec = $var; + + return $this; + } + + /** + * Generated from protobuf field double client_queries_per_cpu_sec = 18; + * @return float + */ + public function getClientQueriesPerCpuSec() + { + return $this->client_queries_per_cpu_sec; + } + + /** + * Generated from protobuf field double client_queries_per_cpu_sec = 18; + * @param float $var + * @return $this + */ + public function setClientQueriesPerCpuSec($var) + { + GPBUtil::checkDouble($var); + $this->client_queries_per_cpu_sec = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/Scenarios.php b/src/php/tests/qps/generated_code/Grpc/Testing/Scenarios.php index 278f555b760..2146b4776e2 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/Scenarios.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/Scenarios.php @@ -9,16 +9,14 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * A set of scenarios to be run with qps_json_driver
- * 
* - * Protobuf type grpc.testing.Scenarios + * Generated from protobuf message grpc.testing.Scenarios */ class Scenarios extends \Google\Protobuf\Internal\Message { /** - * repeated .grpc.testing.Scenario scenarios = 1; + * Generated from protobuf field repeated .grpc.testing.Scenario scenarios = 1; */ private $scenarios; @@ -28,7 +26,8 @@ class Scenarios extends \Google\Protobuf\Internal\Message } /** - * repeated .grpc.testing.Scenario scenarios = 1; + * Generated from protobuf field repeated .grpc.testing.Scenario scenarios = 1; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getScenarios() { @@ -36,12 +35,16 @@ class Scenarios extends \Google\Protobuf\Internal\Message } /** - * repeated .grpc.testing.Scenario scenarios = 1; + * Generated from protobuf field repeated .grpc.testing.Scenario scenarios = 1; + * @param \Grpc\Testing\Scenario[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ - public function setScenarios(&$var) + public function setScenarios($var) { - GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\Scenario::class); - $this->scenarios = $var; + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\Scenario::class); + $this->scenarios = $arr; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/SecurityParams.php b/src/php/tests/qps/generated_code/Grpc/Testing/SecurityParams.php index 27a5b95cc94..8ce623a4bc1 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/SecurityParams.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/SecurityParams.php @@ -9,22 +9,24 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * presence of SecurityParams implies use of TLS
- * 
* - * Protobuf type grpc.testing.SecurityParams + * Generated from protobuf message grpc.testing.SecurityParams */ class SecurityParams extends \Google\Protobuf\Internal\Message { /** - * bool use_test_ca = 1; + * Generated from protobuf field bool use_test_ca = 1; */ private $use_test_ca = false; /** - * string server_host_override = 2; + * Generated from protobuf field string server_host_override = 2; */ private $server_host_override = ''; + /** + * Generated from protobuf field string cred_type = 3; + */ + private $cred_type = ''; public function __construct() { \GPBMetadata\Src\Proto\Grpc\Testing\Control::initOnce(); @@ -32,7 +34,8 @@ class SecurityParams extends \Google\Protobuf\Internal\Message } /** - * bool use_test_ca = 1; + * Generated from protobuf field bool use_test_ca = 1; + * @return bool */ public function getUseTestCa() { @@ -40,16 +43,21 @@ class SecurityParams extends \Google\Protobuf\Internal\Message } /** - * bool use_test_ca = 1; + * Generated from protobuf field bool use_test_ca = 1; + * @param bool $var + * @return $this */ public function setUseTestCa($var) { GPBUtil::checkBool($var); $this->use_test_ca = $var; + + return $this; } /** - * string server_host_override = 2; + * Generated from protobuf field string server_host_override = 2; + * @return string */ public function getServerHostOverride() { @@ -57,12 +65,38 @@ class SecurityParams extends \Google\Protobuf\Internal\Message } /** - * string server_host_override = 2; + * Generated from protobuf field string server_host_override = 2; + * @param string $var + * @return $this */ public function setServerHostOverride($var) { GPBUtil::checkString($var, True); $this->server_host_override = $var; + + return $this; + } + + /** + * Generated from protobuf field string cred_type = 3; + * @return string + */ + public function getCredType() + { + return $this->cred_type; + } + + /** + * Generated from protobuf field string cred_type = 3; + * @param string $var + * @return $this + */ + public function setCredType($var) + { + GPBUtil::checkString($var, True); + $this->cred_type = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ServerArgs.php b/src/php/tests/qps/generated_code/Grpc/Testing/ServerArgs.php index 0d84b80124a..acf7e18b6da 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ServerArgs.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ServerArgs.php @@ -9,7 +9,7 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type grpc.testing.ServerArgs + * Generated from protobuf message grpc.testing.ServerArgs */ class ServerArgs extends \Google\Protobuf\Internal\Message { @@ -21,7 +21,8 @@ class ServerArgs extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.ServerConfig setup = 1; + * Generated from protobuf field .grpc.testing.ServerConfig setup = 1; + * @return \Grpc\Testing\ServerConfig */ public function getSetup() { @@ -29,16 +30,21 @@ class ServerArgs extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.ServerConfig setup = 1; + * Generated from protobuf field .grpc.testing.ServerConfig setup = 1; + * @param \Grpc\Testing\ServerConfig $var + * @return $this */ - public function setSetup(&$var) + public function setSetup($var) { GPBUtil::checkMessage($var, \Grpc\Testing\ServerConfig::class); $this->writeOneof(1, $var); + + return $this; } /** - * .grpc.testing.Mark mark = 2; + * Generated from protobuf field .grpc.testing.Mark mark = 2; + * @return \Grpc\Testing\Mark */ public function getMark() { @@ -46,14 +52,21 @@ class ServerArgs extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.Mark mark = 2; + * Generated from protobuf field .grpc.testing.Mark mark = 2; + * @param \Grpc\Testing\Mark $var + * @return $this */ - public function setMark(&$var) + public function setMark($var) { GPBUtil::checkMessage($var, \Grpc\Testing\Mark::class); $this->writeOneof(2, $var); + + return $this; } + /** + * @return string + */ public function getArgtype() { return $this->whichOneof("argtype"); diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ServerConfig.php b/src/php/tests/qps/generated_code/Grpc/Testing/ServerConfig.php index e2bcede48cb..8bd4c69566b 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ServerConfig.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ServerConfig.php @@ -9,77 +9,73 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type grpc.testing.ServerConfig + * Generated from protobuf message grpc.testing.ServerConfig */ class ServerConfig extends \Google\Protobuf\Internal\Message { /** - * .grpc.testing.ServerType server_type = 1; + * Generated from protobuf field .grpc.testing.ServerType server_type = 1; */ private $server_type = 0; /** - * .grpc.testing.SecurityParams security_params = 2; + * Generated from protobuf field .grpc.testing.SecurityParams security_params = 2; */ private $security_params = null; /** - *
      * Port on which to listen. Zero means pick unused port.
-     * 
* - * int32 port = 4; + * Generated from protobuf field int32 port = 4; */ private $port = 0; /** - *
      * Only for async server. Number of threads used to serve the requests.
-     * 
* - * int32 async_server_threads = 7; + * Generated from protobuf field int32 async_server_threads = 7; */ private $async_server_threads = 0; /** - *
      * Specify the number of cores to limit server to, if desired
-     * 
* - * int32 core_limit = 8; + * Generated from protobuf field int32 core_limit = 8; */ private $core_limit = 0; /** - *
      * payload config, used in generic server.
      * Note this must NOT be used in proto (non-generic) servers. For proto servers,
      * 'response sizes' must be configured from the 'response_size' field of the
      * 'SimpleRequest' objects in RPC requests.
-     * 
* - * .grpc.testing.PayloadConfig payload_config = 9; + * Generated from protobuf field .grpc.testing.PayloadConfig payload_config = 9; */ private $payload_config = null; /** - *
      * Specify the cores we should run the server on, if desired
-     * 
* - * repeated int32 core_list = 10; + * Generated from protobuf field repeated int32 core_list = 10; */ private $core_list; /** - *
      * If we use an OTHER_SERVER client_type, this string gives more detail
-     * 
* - * string other_server_api = 11; + * Generated from protobuf field string other_server_api = 11; */ private $other_server_api = ''; /** - *
+     * Number of threads that share each completion queue
+     *
+     * Generated from protobuf field int32 threads_per_cq = 12;
+     */
+    private $threads_per_cq = 0;
+    /**
      * Buffer pool size (no buffer pool specified if unset)
-     * 
* - * int32 resource_quota_size = 1001; + * Generated from protobuf field int32 resource_quota_size = 1001; */ private $resource_quota_size = 0; + /** + * Generated from protobuf field repeated .grpc.testing.ChannelArg channel_args = 1002; + */ + private $channel_args; public function __construct() { \GPBMetadata\Src\Proto\Grpc\Testing\Control::initOnce(); @@ -87,7 +83,8 @@ class ServerConfig extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.ServerType server_type = 1; + * Generated from protobuf field .grpc.testing.ServerType server_type = 1; + * @return int */ public function getServerType() { @@ -95,16 +92,21 @@ class ServerConfig extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.ServerType server_type = 1; + * Generated from protobuf field .grpc.testing.ServerType server_type = 1; + * @param int $var + * @return $this */ public function setServerType($var) { GPBUtil::checkEnum($var, \Grpc\Testing\ServerType::class); $this->server_type = $var; + + return $this; } /** - * .grpc.testing.SecurityParams security_params = 2; + * Generated from protobuf field .grpc.testing.SecurityParams security_params = 2; + * @return \Grpc\Testing\SecurityParams */ public function getSecurityParams() { @@ -112,20 +114,23 @@ class ServerConfig extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.SecurityParams security_params = 2; + * Generated from protobuf field .grpc.testing.SecurityParams security_params = 2; + * @param \Grpc\Testing\SecurityParams $var + * @return $this */ - public function setSecurityParams(&$var) + public function setSecurityParams($var) { GPBUtil::checkMessage($var, \Grpc\Testing\SecurityParams::class); $this->security_params = $var; + + return $this; } /** - *
      * Port on which to listen. Zero means pick unused port.
-     * 
* - * int32 port = 4; + * Generated from protobuf field int32 port = 4; + * @return int */ public function getPort() { @@ -133,24 +138,25 @@ class ServerConfig extends \Google\Protobuf\Internal\Message } /** - *
      * Port on which to listen. Zero means pick unused port.
-     * 
* - * int32 port = 4; + * Generated from protobuf field int32 port = 4; + * @param int $var + * @return $this */ public function setPort($var) { GPBUtil::checkInt32($var); $this->port = $var; + + return $this; } /** - *
      * Only for async server. Number of threads used to serve the requests.
-     * 
* - * int32 async_server_threads = 7; + * Generated from protobuf field int32 async_server_threads = 7; + * @return int */ public function getAsyncServerThreads() { @@ -158,24 +164,25 @@ class ServerConfig extends \Google\Protobuf\Internal\Message } /** - *
      * Only for async server. Number of threads used to serve the requests.
-     * 
* - * int32 async_server_threads = 7; + * Generated from protobuf field int32 async_server_threads = 7; + * @param int $var + * @return $this */ public function setAsyncServerThreads($var) { GPBUtil::checkInt32($var); $this->async_server_threads = $var; + + return $this; } /** - *
      * Specify the number of cores to limit server to, if desired
-     * 
* - * int32 core_limit = 8; + * Generated from protobuf field int32 core_limit = 8; + * @return int */ public function getCoreLimit() { @@ -183,27 +190,28 @@ class ServerConfig extends \Google\Protobuf\Internal\Message } /** - *
      * Specify the number of cores to limit server to, if desired
-     * 
* - * int32 core_limit = 8; + * Generated from protobuf field int32 core_limit = 8; + * @param int $var + * @return $this */ public function setCoreLimit($var) { GPBUtil::checkInt32($var); $this->core_limit = $var; + + return $this; } /** - *
      * payload config, used in generic server.
      * Note this must NOT be used in proto (non-generic) servers. For proto servers,
      * 'response sizes' must be configured from the 'response_size' field of the
      * 'SimpleRequest' objects in RPC requests.
-     * 
* - * .grpc.testing.PayloadConfig payload_config = 9; + * Generated from protobuf field .grpc.testing.PayloadConfig payload_config = 9; + * @return \Grpc\Testing\PayloadConfig */ public function getPayloadConfig() { @@ -211,27 +219,28 @@ class ServerConfig extends \Google\Protobuf\Internal\Message } /** - *
      * payload config, used in generic server.
      * Note this must NOT be used in proto (non-generic) servers. For proto servers,
      * 'response sizes' must be configured from the 'response_size' field of the
      * 'SimpleRequest' objects in RPC requests.
-     * 
* - * .grpc.testing.PayloadConfig payload_config = 9; + * Generated from protobuf field .grpc.testing.PayloadConfig payload_config = 9; + * @param \Grpc\Testing\PayloadConfig $var + * @return $this */ - public function setPayloadConfig(&$var) + public function setPayloadConfig($var) { GPBUtil::checkMessage($var, \Grpc\Testing\PayloadConfig::class); $this->payload_config = $var; + + return $this; } /** - *
      * Specify the cores we should run the server on, if desired
-     * 
* - * repeated int32 core_list = 10; + * Generated from protobuf field repeated int32 core_list = 10; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getCoreList() { @@ -239,24 +248,25 @@ class ServerConfig extends \Google\Protobuf\Internal\Message } /** - *
      * Specify the cores we should run the server on, if desired
-     * 
* - * repeated int32 core_list = 10; + * Generated from protobuf field repeated int32 core_list = 10; + * @param int[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ - public function setCoreList(&$var) + public function setCoreList($var) { - GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); - $this->core_list = $var; + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::INT32); + $this->core_list = $arr; + + return $this; } /** - *
      * If we use an OTHER_SERVER client_type, this string gives more detail
-     * 
* - * string other_server_api = 11; + * Generated from protobuf field string other_server_api = 11; + * @return string */ public function getOtherServerApi() { @@ -264,24 +274,51 @@ class ServerConfig extends \Google\Protobuf\Internal\Message } /** - *
      * If we use an OTHER_SERVER client_type, this string gives more detail
-     * 
* - * string other_server_api = 11; + * Generated from protobuf field string other_server_api = 11; + * @param string $var + * @return $this */ public function setOtherServerApi($var) { GPBUtil::checkString($var, True); $this->other_server_api = $var; + + return $this; + } + + /** + * Number of threads that share each completion queue + * + * Generated from protobuf field int32 threads_per_cq = 12; + * @return int + */ + public function getThreadsPerCq() + { + return $this->threads_per_cq; + } + + /** + * Number of threads that share each completion queue + * + * Generated from protobuf field int32 threads_per_cq = 12; + * @param int $var + * @return $this + */ + public function setThreadsPerCq($var) + { + GPBUtil::checkInt32($var); + $this->threads_per_cq = $var; + + return $this; } /** - *
      * Buffer pool size (no buffer pool specified if unset)
-     * 
* - * int32 resource_quota_size = 1001; + * Generated from protobuf field int32 resource_quota_size = 1001; + * @return int */ public function getResourceQuotaSize() { @@ -289,16 +326,40 @@ class ServerConfig extends \Google\Protobuf\Internal\Message } /** - *
      * Buffer pool size (no buffer pool specified if unset)
-     * 
* - * int32 resource_quota_size = 1001; + * Generated from protobuf field int32 resource_quota_size = 1001; + * @param int $var + * @return $this */ public function setResourceQuotaSize($var) { GPBUtil::checkInt32($var); $this->resource_quota_size = $var; + + return $this; + } + + /** + * Generated from protobuf field repeated .grpc.testing.ChannelArg channel_args = 1002; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getChannelArgs() + { + return $this->channel_args; + } + + /** + * Generated from protobuf field repeated .grpc.testing.ChannelArg channel_args = 1002; + * @param \Grpc\Testing\ChannelArg[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setChannelArgs($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\ChannelArg::class); + $this->channel_args = $arr; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ServerStats.php b/src/php/tests/qps/generated_code/Grpc/Testing/ServerStats.php index 98b2af764c9..aea2cb0fce3 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ServerStats.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ServerStats.php @@ -9,51 +9,53 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type grpc.testing.ServerStats + * Generated from protobuf message grpc.testing.ServerStats */ class ServerStats extends \Google\Protobuf\Internal\Message { /** - *
      * wall clock time change in seconds since last reset
-     * 
* - * double time_elapsed = 1; + * Generated from protobuf field double time_elapsed = 1; */ private $time_elapsed = 0.0; /** - *
      * change in user time (in seconds) used by the server since last reset
-     * 
* - * double time_user = 2; + * Generated from protobuf field double time_user = 2; */ private $time_user = 0.0; /** - *
      * change in server time (in seconds) used by the server process and all
      * threads since last reset
-     * 
* - * double time_system = 3; + * Generated from protobuf field double time_system = 3; */ private $time_system = 0.0; /** - *
      * change in total cpu time of the server (data from proc/stat)
-     * 
* - * uint64 total_cpu_time = 4; + * Generated from protobuf field uint64 total_cpu_time = 4; */ private $total_cpu_time = 0; /** - *
      * change in idle time of the server (data from proc/stat)
-     * 
* - * uint64 idle_cpu_time = 5; + * Generated from protobuf field uint64 idle_cpu_time = 5; */ private $idle_cpu_time = 0; + /** + * Number of polls called inside completion queue + * + * Generated from protobuf field uint64 cq_poll_count = 6; + */ + private $cq_poll_count = 0; + /** + * Core library stats + * + * Generated from protobuf field .grpc.core.Stats core_stats = 7; + */ + private $core_stats = null; public function __construct() { \GPBMetadata\Src\Proto\Grpc\Testing\Stats::initOnce(); @@ -61,11 +63,10 @@ class ServerStats extends \Google\Protobuf\Internal\Message } /** - *
      * wall clock time change in seconds since last reset
-     * 
* - * double time_elapsed = 1; + * Generated from protobuf field double time_elapsed = 1; + * @return float */ public function getTimeElapsed() { @@ -73,24 +74,25 @@ class ServerStats extends \Google\Protobuf\Internal\Message } /** - *
      * wall clock time change in seconds since last reset
-     * 
* - * double time_elapsed = 1; + * Generated from protobuf field double time_elapsed = 1; + * @param float $var + * @return $this */ public function setTimeElapsed($var) { GPBUtil::checkDouble($var); $this->time_elapsed = $var; + + return $this; } /** - *
      * change in user time (in seconds) used by the server since last reset
-     * 
* - * double time_user = 2; + * Generated from protobuf field double time_user = 2; + * @return float */ public function getTimeUser() { @@ -98,25 +100,26 @@ class ServerStats extends \Google\Protobuf\Internal\Message } /** - *
      * change in user time (in seconds) used by the server since last reset
-     * 
* - * double time_user = 2; + * Generated from protobuf field double time_user = 2; + * @param float $var + * @return $this */ public function setTimeUser($var) { GPBUtil::checkDouble($var); $this->time_user = $var; + + return $this; } /** - *
      * change in server time (in seconds) used by the server process and all
      * threads since last reset
-     * 
* - * double time_system = 3; + * Generated from protobuf field double time_system = 3; + * @return float */ public function getTimeSystem() { @@ -124,25 +127,26 @@ class ServerStats extends \Google\Protobuf\Internal\Message } /** - *
      * change in server time (in seconds) used by the server process and all
      * threads since last reset
-     * 
* - * double time_system = 3; + * Generated from protobuf field double time_system = 3; + * @param float $var + * @return $this */ public function setTimeSystem($var) { GPBUtil::checkDouble($var); $this->time_system = $var; + + return $this; } /** - *
      * change in total cpu time of the server (data from proc/stat)
-     * 
* - * uint64 total_cpu_time = 4; + * Generated from protobuf field uint64 total_cpu_time = 4; + * @return int|string */ public function getTotalCpuTime() { @@ -150,24 +154,25 @@ class ServerStats extends \Google\Protobuf\Internal\Message } /** - *
      * change in total cpu time of the server (data from proc/stat)
-     * 
* - * uint64 total_cpu_time = 4; + * Generated from protobuf field uint64 total_cpu_time = 4; + * @param int|string $var + * @return $this */ public function setTotalCpuTime($var) { GPBUtil::checkUint64($var); $this->total_cpu_time = $var; + + return $this; } /** - *
      * change in idle time of the server (data from proc/stat)
-     * 
* - * uint64 idle_cpu_time = 5; + * Generated from protobuf field uint64 idle_cpu_time = 5; + * @return int|string */ public function getIdleCpuTime() { @@ -175,16 +180,70 @@ class ServerStats extends \Google\Protobuf\Internal\Message } /** - *
      * change in idle time of the server (data from proc/stat)
-     * 
* - * uint64 idle_cpu_time = 5; + * Generated from protobuf field uint64 idle_cpu_time = 5; + * @param int|string $var + * @return $this */ public function setIdleCpuTime($var) { GPBUtil::checkUint64($var); $this->idle_cpu_time = $var; + + return $this; + } + + /** + * Number of polls called inside completion queue + * + * Generated from protobuf field uint64 cq_poll_count = 6; + * @return int|string + */ + public function getCqPollCount() + { + return $this->cq_poll_count; + } + + /** + * Number of polls called inside completion queue + * + * Generated from protobuf field uint64 cq_poll_count = 6; + * @param int|string $var + * @return $this + */ + public function setCqPollCount($var) + { + GPBUtil::checkUint64($var); + $this->cq_poll_count = $var; + + return $this; + } + + /** + * Core library stats + * + * Generated from protobuf field .grpc.core.Stats core_stats = 7; + * @return \Grpc\Core\Stats + */ + public function getCoreStats() + { + return $this->core_stats; + } + + /** + * Core library stats + * + * Generated from protobuf field .grpc.core.Stats core_stats = 7; + * @param \Grpc\Core\Stats $var + * @return $this + */ + public function setCoreStats($var) + { + GPBUtil::checkMessage($var, \Grpc\Core\Stats::class); + $this->core_stats = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ServerStatus.php b/src/php/tests/qps/generated_code/Grpc/Testing/ServerStatus.php index d293f03fbdf..04f2ca7c4ae 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ServerStatus.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ServerStatus.php @@ -9,28 +9,24 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type grpc.testing.ServerStatus + * Generated from protobuf message grpc.testing.ServerStatus */ class ServerStatus extends \Google\Protobuf\Internal\Message { /** - * .grpc.testing.ServerStats stats = 1; + * Generated from protobuf field .grpc.testing.ServerStats stats = 1; */ private $stats = null; /** - *
      * the port bound by the server
-     * 
* - * int32 port = 2; + * Generated from protobuf field int32 port = 2; */ private $port = 0; /** - *
      * Number of cores available to the server
-     * 
* - * int32 cores = 3; + * Generated from protobuf field int32 cores = 3; */ private $cores = 0; @@ -40,7 +36,8 @@ class ServerStatus extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.ServerStats stats = 1; + * Generated from protobuf field .grpc.testing.ServerStats stats = 1; + * @return \Grpc\Testing\ServerStats */ public function getStats() { @@ -48,20 +45,23 @@ class ServerStatus extends \Google\Protobuf\Internal\Message } /** - * .grpc.testing.ServerStats stats = 1; + * Generated from protobuf field .grpc.testing.ServerStats stats = 1; + * @param \Grpc\Testing\ServerStats $var + * @return $this */ - public function setStats(&$var) + public function setStats($var) { GPBUtil::checkMessage($var, \Grpc\Testing\ServerStats::class); $this->stats = $var; + + return $this; } /** - *
      * the port bound by the server
-     * 
* - * int32 port = 2; + * Generated from protobuf field int32 port = 2; + * @return int */ public function getPort() { @@ -69,24 +69,25 @@ class ServerStatus extends \Google\Protobuf\Internal\Message } /** - *
      * the port bound by the server
-     * 
* - * int32 port = 2; + * Generated from protobuf field int32 port = 2; + * @param int $var + * @return $this */ public function setPort($var) { GPBUtil::checkInt32($var); $this->port = $var; + + return $this; } /** - *
      * Number of cores available to the server
-     * 
* - * int32 cores = 3; + * Generated from protobuf field int32 cores = 3; + * @return int */ public function getCores() { @@ -94,16 +95,18 @@ class ServerStatus extends \Google\Protobuf\Internal\Message } /** - *
      * Number of cores available to the server
-     * 
* - * int32 cores = 3; + * Generated from protobuf field int32 cores = 3; + * @param int $var + * @return $this */ public function setCores($var) { GPBUtil::checkInt32($var); $this->cores = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/ServerType.php b/src/php/tests/qps/generated_code/Grpc/Testing/ServerType.php index 605c83c3f76..4110e91c18a 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/ServerType.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/ServerType.php @@ -5,28 +5,26 @@ namespace Grpc\Testing; /** - * Protobuf enum grpc.testing.ServerType + * Protobuf enum Grpc\Testing\ServerType */ class ServerType { /** - * SYNC_SERVER = 0; + * Generated from protobuf enum SYNC_SERVER = 0; */ const SYNC_SERVER = 0; /** - * ASYNC_SERVER = 1; + * Generated from protobuf enum ASYNC_SERVER = 1; */ const ASYNC_SERVER = 1; /** - * ASYNC_GENERIC_SERVER = 2; + * Generated from protobuf enum ASYNC_GENERIC_SERVER = 2; */ const ASYNC_GENERIC_SERVER = 2; /** - *
      * used for some language-specific variants
-     * 
* - * OTHER_SERVER = 3; + * Generated from protobuf enum OTHER_SERVER = 3; */ const OTHER_SERVER = 3; } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/SimpleProtoParams.php b/src/php/tests/qps/generated_code/Grpc/Testing/SimpleProtoParams.php index 29834a3be71..507db598f03 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/SimpleProtoParams.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/SimpleProtoParams.php @@ -9,16 +9,16 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type grpc.testing.SimpleProtoParams + * Generated from protobuf message grpc.testing.SimpleProtoParams */ class SimpleProtoParams extends \Google\Protobuf\Internal\Message { /** - * int32 req_size = 1; + * Generated from protobuf field int32 req_size = 1; */ private $req_size = 0; /** - * int32 resp_size = 2; + * Generated from protobuf field int32 resp_size = 2; */ private $resp_size = 0; @@ -28,7 +28,8 @@ class SimpleProtoParams extends \Google\Protobuf\Internal\Message } /** - * int32 req_size = 1; + * Generated from protobuf field int32 req_size = 1; + * @return int */ public function getReqSize() { @@ -36,16 +37,21 @@ class SimpleProtoParams extends \Google\Protobuf\Internal\Message } /** - * int32 req_size = 1; + * Generated from protobuf field int32 req_size = 1; + * @param int $var + * @return $this */ public function setReqSize($var) { GPBUtil::checkInt32($var); $this->req_size = $var; + + return $this; } /** - * int32 resp_size = 2; + * Generated from protobuf field int32 resp_size = 2; + * @return int */ public function getRespSize() { @@ -53,12 +59,16 @@ class SimpleProtoParams extends \Google\Protobuf\Internal\Message } /** - * int32 resp_size = 2; + * Generated from protobuf field int32 resp_size = 2; + * @param int $var + * @return $this */ public function setRespSize($var) { GPBUtil::checkInt32($var); $this->resp_size = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/SimpleRequest.php b/src/php/tests/qps/generated_code/Grpc/Testing/SimpleRequest.php index f84c95319f4..e0c2d2d94ce 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/SimpleRequest.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/SimpleRequest.php @@ -9,81 +9,63 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Unary request.
- * 
* - * Protobuf type grpc.testing.SimpleRequest + * Generated from protobuf message grpc.testing.SimpleRequest */ class SimpleRequest extends \Google\Protobuf\Internal\Message { /** - *
      * DEPRECATED, don't use. To be removed shortly.
      * Desired payload type in the response from the server.
      * If response_type is RANDOM, server randomly chooses one from other formats.
-     * 
* - * .grpc.testing.PayloadType response_type = 1; + * Generated from protobuf field .grpc.testing.PayloadType response_type = 1; */ private $response_type = 0; /** - *
      * Desired payload size in the response from the server.
-     * 
* - * int32 response_size = 2; + * Generated from protobuf field int32 response_size = 2; */ private $response_size = 0; /** - *
      * Optional input payload sent along with the request.
-     * 
* - * .grpc.testing.Payload payload = 3; + * Generated from protobuf field .grpc.testing.Payload payload = 3; */ private $payload = null; /** - *
      * Whether SimpleResponse should include username.
-     * 
* - * bool fill_username = 4; + * Generated from protobuf field bool fill_username = 4; */ private $fill_username = false; /** - *
      * Whether SimpleResponse should include OAuth scope.
-     * 
* - * bool fill_oauth_scope = 5; + * Generated from protobuf field bool fill_oauth_scope = 5; */ private $fill_oauth_scope = false; /** - *
      * Whether to request the server to compress the response. This field is
      * "nullable" in order to interoperate seamlessly with clients not able to
      * implement the full compression tests by introspecting the call to verify
      * the response's compression status.
-     * 
* - * .grpc.testing.BoolValue response_compressed = 6; + * Generated from protobuf field .grpc.testing.BoolValue response_compressed = 6; */ private $response_compressed = null; /** - *
      * Whether server should return a given status
-     * 
* - * .grpc.testing.EchoStatus response_status = 7; + * Generated from protobuf field .grpc.testing.EchoStatus response_status = 7; */ private $response_status = null; /** - *
      * Whether the server should expect this request to be compressed.
-     * 
* - * .grpc.testing.BoolValue expect_compressed = 8; + * Generated from protobuf field .grpc.testing.BoolValue expect_compressed = 8; */ private $expect_compressed = null; @@ -93,13 +75,12 @@ class SimpleRequest extends \Google\Protobuf\Internal\Message } /** - *
      * DEPRECATED, don't use. To be removed shortly.
      * Desired payload type in the response from the server.
      * If response_type is RANDOM, server randomly chooses one from other formats.
-     * 
* - * .grpc.testing.PayloadType response_type = 1; + * Generated from protobuf field .grpc.testing.PayloadType response_type = 1; + * @return int */ public function getResponseType() { @@ -107,26 +88,27 @@ class SimpleRequest extends \Google\Protobuf\Internal\Message } /** - *
      * DEPRECATED, don't use. To be removed shortly.
      * Desired payload type in the response from the server.
      * If response_type is RANDOM, server randomly chooses one from other formats.
-     * 
* - * .grpc.testing.PayloadType response_type = 1; + * Generated from protobuf field .grpc.testing.PayloadType response_type = 1; + * @param int $var + * @return $this */ public function setResponseType($var) { GPBUtil::checkEnum($var, \Grpc\Testing\PayloadType::class); $this->response_type = $var; + + return $this; } /** - *
      * Desired payload size in the response from the server.
-     * 
* - * int32 response_size = 2; + * Generated from protobuf field int32 response_size = 2; + * @return int */ public function getResponseSize() { @@ -134,24 +116,25 @@ class SimpleRequest extends \Google\Protobuf\Internal\Message } /** - *
      * Desired payload size in the response from the server.
-     * 
* - * int32 response_size = 2; + * Generated from protobuf field int32 response_size = 2; + * @param int $var + * @return $this */ public function setResponseSize($var) { GPBUtil::checkInt32($var); $this->response_size = $var; + + return $this; } /** - *
      * Optional input payload sent along with the request.
-     * 
* - * .grpc.testing.Payload payload = 3; + * Generated from protobuf field .grpc.testing.Payload payload = 3; + * @return \Grpc\Testing\Payload */ public function getPayload() { @@ -159,24 +142,25 @@ class SimpleRequest extends \Google\Protobuf\Internal\Message } /** - *
      * Optional input payload sent along with the request.
-     * 
* - * .grpc.testing.Payload payload = 3; + * Generated from protobuf field .grpc.testing.Payload payload = 3; + * @param \Grpc\Testing\Payload $var + * @return $this */ - public function setPayload(&$var) + public function setPayload($var) { GPBUtil::checkMessage($var, \Grpc\Testing\Payload::class); $this->payload = $var; + + return $this; } /** - *
      * Whether SimpleResponse should include username.
-     * 
* - * bool fill_username = 4; + * Generated from protobuf field bool fill_username = 4; + * @return bool */ public function getFillUsername() { @@ -184,24 +168,25 @@ class SimpleRequest extends \Google\Protobuf\Internal\Message } /** - *
      * Whether SimpleResponse should include username.
-     * 
* - * bool fill_username = 4; + * Generated from protobuf field bool fill_username = 4; + * @param bool $var + * @return $this */ public function setFillUsername($var) { GPBUtil::checkBool($var); $this->fill_username = $var; + + return $this; } /** - *
      * Whether SimpleResponse should include OAuth scope.
-     * 
* - * bool fill_oauth_scope = 5; + * Generated from protobuf field bool fill_oauth_scope = 5; + * @return bool */ public function getFillOauthScope() { @@ -209,27 +194,28 @@ class SimpleRequest extends \Google\Protobuf\Internal\Message } /** - *
      * Whether SimpleResponse should include OAuth scope.
-     * 
* - * bool fill_oauth_scope = 5; + * Generated from protobuf field bool fill_oauth_scope = 5; + * @param bool $var + * @return $this */ public function setFillOauthScope($var) { GPBUtil::checkBool($var); $this->fill_oauth_scope = $var; + + return $this; } /** - *
      * Whether to request the server to compress the response. This field is
      * "nullable" in order to interoperate seamlessly with clients not able to
      * implement the full compression tests by introspecting the call to verify
      * the response's compression status.
-     * 
* - * .grpc.testing.BoolValue response_compressed = 6; + * Generated from protobuf field .grpc.testing.BoolValue response_compressed = 6; + * @return \Grpc\Testing\BoolValue */ public function getResponseCompressed() { @@ -237,27 +223,28 @@ class SimpleRequest extends \Google\Protobuf\Internal\Message } /** - *
      * Whether to request the server to compress the response. This field is
      * "nullable" in order to interoperate seamlessly with clients not able to
      * implement the full compression tests by introspecting the call to verify
      * the response's compression status.
-     * 
* - * .grpc.testing.BoolValue response_compressed = 6; + * Generated from protobuf field .grpc.testing.BoolValue response_compressed = 6; + * @param \Grpc\Testing\BoolValue $var + * @return $this */ - public function setResponseCompressed(&$var) + public function setResponseCompressed($var) { GPBUtil::checkMessage($var, \Grpc\Testing\BoolValue::class); $this->response_compressed = $var; + + return $this; } /** - *
      * Whether server should return a given status
-     * 
* - * .grpc.testing.EchoStatus response_status = 7; + * Generated from protobuf field .grpc.testing.EchoStatus response_status = 7; + * @return \Grpc\Testing\EchoStatus */ public function getResponseStatus() { @@ -265,24 +252,25 @@ class SimpleRequest extends \Google\Protobuf\Internal\Message } /** - *
      * Whether server should return a given status
-     * 
* - * .grpc.testing.EchoStatus response_status = 7; + * Generated from protobuf field .grpc.testing.EchoStatus response_status = 7; + * @param \Grpc\Testing\EchoStatus $var + * @return $this */ - public function setResponseStatus(&$var) + public function setResponseStatus($var) { GPBUtil::checkMessage($var, \Grpc\Testing\EchoStatus::class); $this->response_status = $var; + + return $this; } /** - *
      * Whether the server should expect this request to be compressed.
-     * 
* - * .grpc.testing.BoolValue expect_compressed = 8; + * Generated from protobuf field .grpc.testing.BoolValue expect_compressed = 8; + * @return \Grpc\Testing\BoolValue */ public function getExpectCompressed() { @@ -290,16 +278,18 @@ class SimpleRequest extends \Google\Protobuf\Internal\Message } /** - *
      * Whether the server should expect this request to be compressed.
-     * 
* - * .grpc.testing.BoolValue expect_compressed = 8; + * Generated from protobuf field .grpc.testing.BoolValue expect_compressed = 8; + * @param \Grpc\Testing\BoolValue $var + * @return $this */ - public function setExpectCompressed(&$var) + public function setExpectCompressed($var) { GPBUtil::checkMessage($var, \Grpc\Testing\BoolValue::class); $this->expect_compressed = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/SimpleResponse.php b/src/php/tests/qps/generated_code/Grpc/Testing/SimpleResponse.php index ccc628ec4c0..d49f33746e2 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/SimpleResponse.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/SimpleResponse.php @@ -9,37 +9,29 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Unary response, as configured by the request.
- * 
* - * Protobuf type grpc.testing.SimpleResponse + * Generated from protobuf message grpc.testing.SimpleResponse */ class SimpleResponse extends \Google\Protobuf\Internal\Message { /** - *
      * Payload to increase message size.
-     * 
* - * .grpc.testing.Payload payload = 1; + * Generated from protobuf field .grpc.testing.Payload payload = 1; */ private $payload = null; /** - *
      * The user the request came from, for verifying authentication was
      * successful when the client expected it.
-     * 
* - * string username = 2; + * Generated from protobuf field string username = 2; */ private $username = ''; /** - *
      * OAuth scope.
-     * 
* - * string oauth_scope = 3; + * Generated from protobuf field string oauth_scope = 3; */ private $oauth_scope = ''; @@ -49,11 +41,10 @@ class SimpleResponse extends \Google\Protobuf\Internal\Message } /** - *
      * Payload to increase message size.
-     * 
* - * .grpc.testing.Payload payload = 1; + * Generated from protobuf field .grpc.testing.Payload payload = 1; + * @return \Grpc\Testing\Payload */ public function getPayload() { @@ -61,25 +52,26 @@ class SimpleResponse extends \Google\Protobuf\Internal\Message } /** - *
      * Payload to increase message size.
-     * 
* - * .grpc.testing.Payload payload = 1; + * Generated from protobuf field .grpc.testing.Payload payload = 1; + * @param \Grpc\Testing\Payload $var + * @return $this */ - public function setPayload(&$var) + public function setPayload($var) { GPBUtil::checkMessage($var, \Grpc\Testing\Payload::class); $this->payload = $var; + + return $this; } /** - *
      * The user the request came from, for verifying authentication was
      * successful when the client expected it.
-     * 
* - * string username = 2; + * Generated from protobuf field string username = 2; + * @return string */ public function getUsername() { @@ -87,25 +79,26 @@ class SimpleResponse extends \Google\Protobuf\Internal\Message } /** - *
      * The user the request came from, for verifying authentication was
      * successful when the client expected it.
-     * 
* - * string username = 2; + * Generated from protobuf field string username = 2; + * @param string $var + * @return $this */ public function setUsername($var) { GPBUtil::checkString($var, True); $this->username = $var; + + return $this; } /** - *
      * OAuth scope.
-     * 
* - * string oauth_scope = 3; + * Generated from protobuf field string oauth_scope = 3; + * @return string */ public function getOauthScope() { @@ -113,16 +106,18 @@ class SimpleResponse extends \Google\Protobuf\Internal\Message } /** - *
      * OAuth scope.
-     * 
* - * string oauth_scope = 3; + * Generated from protobuf field string oauth_scope = 3; + * @param string $var + * @return $this */ public function setOauthScope($var) { GPBUtil::checkString($var, True); $this->oauth_scope = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/StreamingInputCallRequest.php b/src/php/tests/qps/generated_code/Grpc/Testing/StreamingInputCallRequest.php index d7bbc707799..a7460af83a3 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/StreamingInputCallRequest.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/StreamingInputCallRequest.php @@ -9,31 +9,25 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Client-streaming request.
- * 
* - * Protobuf type grpc.testing.StreamingInputCallRequest + * Generated from protobuf message grpc.testing.StreamingInputCallRequest */ class StreamingInputCallRequest extends \Google\Protobuf\Internal\Message { /** - *
      * Optional input payload sent along with the request.
-     * 
* - * .grpc.testing.Payload payload = 1; + * Generated from protobuf field .grpc.testing.Payload payload = 1; */ private $payload = null; /** - *
      * Whether the server should expect this request to be compressed. This field
      * is "nullable" in order to interoperate seamlessly with servers not able to
      * implement the full compression tests by introspecting the call to verify
      * the request's compression status.
-     * 
* - * .grpc.testing.BoolValue expect_compressed = 2; + * Generated from protobuf field .grpc.testing.BoolValue expect_compressed = 2; */ private $expect_compressed = null; @@ -43,11 +37,10 @@ class StreamingInputCallRequest extends \Google\Protobuf\Internal\Message } /** - *
      * Optional input payload sent along with the request.
-     * 
* - * .grpc.testing.Payload payload = 1; + * Generated from protobuf field .grpc.testing.Payload payload = 1; + * @return \Grpc\Testing\Payload */ public function getPayload() { @@ -55,27 +48,28 @@ class StreamingInputCallRequest extends \Google\Protobuf\Internal\Message } /** - *
      * Optional input payload sent along with the request.
-     * 
* - * .grpc.testing.Payload payload = 1; + * Generated from protobuf field .grpc.testing.Payload payload = 1; + * @param \Grpc\Testing\Payload $var + * @return $this */ - public function setPayload(&$var) + public function setPayload($var) { GPBUtil::checkMessage($var, \Grpc\Testing\Payload::class); $this->payload = $var; + + return $this; } /** - *
      * Whether the server should expect this request to be compressed. This field
      * is "nullable" in order to interoperate seamlessly with servers not able to
      * implement the full compression tests by introspecting the call to verify
      * the request's compression status.
-     * 
* - * .grpc.testing.BoolValue expect_compressed = 2; + * Generated from protobuf field .grpc.testing.BoolValue expect_compressed = 2; + * @return \Grpc\Testing\BoolValue */ public function getExpectCompressed() { @@ -83,19 +77,21 @@ class StreamingInputCallRequest extends \Google\Protobuf\Internal\Message } /** - *
      * Whether the server should expect this request to be compressed. This field
      * is "nullable" in order to interoperate seamlessly with servers not able to
      * implement the full compression tests by introspecting the call to verify
      * the request's compression status.
-     * 
* - * .grpc.testing.BoolValue expect_compressed = 2; + * Generated from protobuf field .grpc.testing.BoolValue expect_compressed = 2; + * @param \Grpc\Testing\BoolValue $var + * @return $this */ - public function setExpectCompressed(&$var) + public function setExpectCompressed($var) { GPBUtil::checkMessage($var, \Grpc\Testing\BoolValue::class); $this->expect_compressed = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/StreamingInputCallResponse.php b/src/php/tests/qps/generated_code/Grpc/Testing/StreamingInputCallResponse.php index fdd1d0dbf8a..41f3893aa3f 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/StreamingInputCallResponse.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/StreamingInputCallResponse.php @@ -9,20 +9,16 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Client-streaming response.
- * 
* - * Protobuf type grpc.testing.StreamingInputCallResponse + * Generated from protobuf message grpc.testing.StreamingInputCallResponse */ class StreamingInputCallResponse extends \Google\Protobuf\Internal\Message { /** - *
      * Aggregated size of payloads received from the client.
-     * 
* - * int32 aggregated_payload_size = 1; + * Generated from protobuf field int32 aggregated_payload_size = 1; */ private $aggregated_payload_size = 0; @@ -32,11 +28,10 @@ class StreamingInputCallResponse extends \Google\Protobuf\Internal\Message } /** - *
      * Aggregated size of payloads received from the client.
-     * 
* - * int32 aggregated_payload_size = 1; + * Generated from protobuf field int32 aggregated_payload_size = 1; + * @return int */ public function getAggregatedPayloadSize() { @@ -44,16 +39,18 @@ class StreamingInputCallResponse extends \Google\Protobuf\Internal\Message } /** - *
      * Aggregated size of payloads received from the client.
-     * 
* - * int32 aggregated_payload_size = 1; + * Generated from protobuf field int32 aggregated_payload_size = 1; + * @param int $var + * @return $this */ public function setAggregatedPayloadSize($var) { GPBUtil::checkInt32($var); $this->aggregated_payload_size = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/StreamingOutputCallRequest.php b/src/php/tests/qps/generated_code/Grpc/Testing/StreamingOutputCallRequest.php index 2aab5fadad7..69d9cecffa7 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/StreamingOutputCallRequest.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/StreamingOutputCallRequest.php @@ -9,48 +9,38 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Server-streaming request.
- * 
* - * Protobuf type grpc.testing.StreamingOutputCallRequest + * Generated from protobuf message grpc.testing.StreamingOutputCallRequest */ class StreamingOutputCallRequest extends \Google\Protobuf\Internal\Message { /** - *
      * DEPRECATED, don't use. To be removed shortly.
      * Desired payload type in the response from the server.
      * If response_type is RANDOM, the payload from each response in the stream
      * might be of different types. This is to simulate a mixed type of payload
      * stream.
-     * 
* - * .grpc.testing.PayloadType response_type = 1; + * Generated from protobuf field .grpc.testing.PayloadType response_type = 1; */ private $response_type = 0; /** - *
      * Configuration for each expected response message.
-     * 
* - * repeated .grpc.testing.ResponseParameters response_parameters = 2; + * Generated from protobuf field repeated .grpc.testing.ResponseParameters response_parameters = 2; */ private $response_parameters; /** - *
      * Optional input payload sent along with the request.
-     * 
* - * .grpc.testing.Payload payload = 3; + * Generated from protobuf field .grpc.testing.Payload payload = 3; */ private $payload = null; /** - *
      * Whether server should return a given status
-     * 
* - * .grpc.testing.EchoStatus response_status = 7; + * Generated from protobuf field .grpc.testing.EchoStatus response_status = 7; */ private $response_status = null; @@ -60,15 +50,14 @@ class StreamingOutputCallRequest extends \Google\Protobuf\Internal\Message } /** - *
      * DEPRECATED, don't use. To be removed shortly.
      * Desired payload type in the response from the server.
      * If response_type is RANDOM, the payload from each response in the stream
      * might be of different types. This is to simulate a mixed type of payload
      * stream.
-     * 
* - * .grpc.testing.PayloadType response_type = 1; + * Generated from protobuf field .grpc.testing.PayloadType response_type = 1; + * @return int */ public function getResponseType() { @@ -76,28 +65,29 @@ class StreamingOutputCallRequest extends \Google\Protobuf\Internal\Message } /** - *
      * DEPRECATED, don't use. To be removed shortly.
      * Desired payload type in the response from the server.
      * If response_type is RANDOM, the payload from each response in the stream
      * might be of different types. This is to simulate a mixed type of payload
      * stream.
-     * 
* - * .grpc.testing.PayloadType response_type = 1; + * Generated from protobuf field .grpc.testing.PayloadType response_type = 1; + * @param int $var + * @return $this */ public function setResponseType($var) { GPBUtil::checkEnum($var, \Grpc\Testing\PayloadType::class); $this->response_type = $var; + + return $this; } /** - *
      * Configuration for each expected response message.
-     * 
* - * repeated .grpc.testing.ResponseParameters response_parameters = 2; + * Generated from protobuf field repeated .grpc.testing.ResponseParameters response_parameters = 2; + * @return \Google\Protobuf\Internal\RepeatedField */ public function getResponseParameters() { @@ -105,24 +95,25 @@ class StreamingOutputCallRequest extends \Google\Protobuf\Internal\Message } /** - *
      * Configuration for each expected response message.
-     * 
* - * repeated .grpc.testing.ResponseParameters response_parameters = 2; + * Generated from protobuf field repeated .grpc.testing.ResponseParameters response_parameters = 2; + * @param \Grpc\Testing\ResponseParameters[]|\Google\Protobuf\Internal\RepeatedField $var + * @return $this */ - public function setResponseParameters(&$var) + public function setResponseParameters($var) { - GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\ResponseParameters::class); - $this->response_parameters = $var; + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Grpc\Testing\ResponseParameters::class); + $this->response_parameters = $arr; + + return $this; } /** - *
      * Optional input payload sent along with the request.
-     * 
* - * .grpc.testing.Payload payload = 3; + * Generated from protobuf field .grpc.testing.Payload payload = 3; + * @return \Grpc\Testing\Payload */ public function getPayload() { @@ -130,24 +121,25 @@ class StreamingOutputCallRequest extends \Google\Protobuf\Internal\Message } /** - *
      * Optional input payload sent along with the request.
-     * 
* - * .grpc.testing.Payload payload = 3; + * Generated from protobuf field .grpc.testing.Payload payload = 3; + * @param \Grpc\Testing\Payload $var + * @return $this */ - public function setPayload(&$var) + public function setPayload($var) { GPBUtil::checkMessage($var, \Grpc\Testing\Payload::class); $this->payload = $var; + + return $this; } /** - *
      * Whether server should return a given status
-     * 
* - * .grpc.testing.EchoStatus response_status = 7; + * Generated from protobuf field .grpc.testing.EchoStatus response_status = 7; + * @return \Grpc\Testing\EchoStatus */ public function getResponseStatus() { @@ -155,16 +147,18 @@ class StreamingOutputCallRequest extends \Google\Protobuf\Internal\Message } /** - *
      * Whether server should return a given status
-     * 
* - * .grpc.testing.EchoStatus response_status = 7; + * Generated from protobuf field .grpc.testing.EchoStatus response_status = 7; + * @param \Grpc\Testing\EchoStatus $var + * @return $this */ - public function setResponseStatus(&$var) + public function setResponseStatus($var) { GPBUtil::checkMessage($var, \Grpc\Testing\EchoStatus::class); $this->response_status = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/StreamingOutputCallResponse.php b/src/php/tests/qps/generated_code/Grpc/Testing/StreamingOutputCallResponse.php index c06c78c9d8f..52315bb4995 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/StreamingOutputCallResponse.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/StreamingOutputCallResponse.php @@ -9,20 +9,16 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - *
  * Server-streaming response, as configured by the request and parameters.
- * 
* - * Protobuf type grpc.testing.StreamingOutputCallResponse + * Generated from protobuf message grpc.testing.StreamingOutputCallResponse */ class StreamingOutputCallResponse extends \Google\Protobuf\Internal\Message { /** - *
      * Payload to increase response size.
-     * 
* - * .grpc.testing.Payload payload = 1; + * Generated from protobuf field .grpc.testing.Payload payload = 1; */ private $payload = null; @@ -32,11 +28,10 @@ class StreamingOutputCallResponse extends \Google\Protobuf\Internal\Message } /** - *
      * Payload to increase response size.
-     * 
* - * .grpc.testing.Payload payload = 1; + * Generated from protobuf field .grpc.testing.Payload payload = 1; + * @return \Grpc\Testing\Payload */ public function getPayload() { @@ -44,16 +39,18 @@ class StreamingOutputCallResponse extends \Google\Protobuf\Internal\Message } /** - *
      * Payload to increase response size.
-     * 
* - * .grpc.testing.Payload payload = 1; + * Generated from protobuf field .grpc.testing.Payload payload = 1; + * @param \Grpc\Testing\Payload $var + * @return $this */ - public function setPayload(&$var) + public function setPayload($var) { GPBUtil::checkMessage($var, \Grpc\Testing\Payload::class); $this->payload = $var; + + return $this; } } diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/Void.php b/src/php/tests/qps/generated_code/Grpc/Testing/Void.php index 38c100845a0..623021d99b9 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/Void.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/Void.php @@ -9,7 +9,7 @@ use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\Internal\GPBUtil; /** - * Protobuf type grpc.testing.Void + * Generated from protobuf message grpc.testing.Void */ class Void extends \Google\Protobuf\Internal\Message { diff --git a/src/php/tests/qps/generated_code/Grpc/Testing/WorkerServiceClient.php b/src/php/tests/qps/generated_code/Grpc/Testing/WorkerServiceClient.php index 959d839c80a..98c244ff9dc 100644 --- a/src/php/tests/qps/generated_code/Grpc/Testing/WorkerServiceClient.php +++ b/src/php/tests/qps/generated_code/Grpc/Testing/WorkerServiceClient.php @@ -18,17 +18,19 @@ // // An integration test service that covers all the method signature permutations // of unary/streaming requests/responses. -namespace Grpc\Testing { +namespace Grpc\Testing; - class WorkerServiceClient extends \Grpc\BaseStub { +/** + */ +class WorkerServiceClient extends \Grpc\BaseStub { /** * @param string $hostname hostname * @param array $opts channel options - * @param Grpc\Channel $channel (optional) re-use channel object + * @param \Grpc\Channel $channel (optional) re-use channel object */ public function __construct($hostname, $opts, $channel = null) { - parent::__construct($hostname, $opts, $channel); + parent::__construct($hostname, $opts, $channel); } /** @@ -42,9 +44,9 @@ namespace Grpc\Testing { * @param array $options call options */ public function RunServer($metadata = [], $options = []) { - return $this->_bidiRequest('/grpc.testing.WorkerService/RunServer', - ['\Grpc\Testing\ServerStatus','decode'], - $metadata, $options); + return $this->_bidiRequest('/grpc.testing.WorkerService/RunServer', + ['\Grpc\Testing\ServerStatus','decode'], + $metadata, $options); } /** @@ -58,9 +60,9 @@ namespace Grpc\Testing { * @param array $options call options */ public function RunClient($metadata = [], $options = []) { - return $this->_bidiRequest('/grpc.testing.WorkerService/RunClient', - ['\Grpc\Testing\ClientStatus','decode'], - $metadata, $options); + return $this->_bidiRequest('/grpc.testing.WorkerService/RunClient', + ['\Grpc\Testing\ClientStatus','decode'], + $metadata, $options); } /** @@ -71,10 +73,10 @@ namespace Grpc\Testing { */ public function CoreCount(\Grpc\Testing\CoreRequest $argument, $metadata = [], $options = []) { - return $this->_simpleRequest('/grpc.testing.WorkerService/CoreCount', - $argument, - ['\Grpc\Testing\CoreResponse', 'decode'], - $metadata, $options); + return $this->_simpleRequest('/grpc.testing.WorkerService/CoreCount', + $argument, + ['\Grpc\Testing\CoreResponse', 'decode'], + $metadata, $options); } /** @@ -85,12 +87,10 @@ namespace Grpc\Testing { */ public function QuitWorker(\Grpc\Testing\Void $argument, $metadata = [], $options = []) { - return $this->_simpleRequest('/grpc.testing.WorkerService/QuitWorker', - $argument, - ['\Grpc\Testing\Void', 'decode'], - $metadata, $options); + return $this->_simpleRequest('/grpc.testing.WorkerService/QuitWorker', + $argument, + ['\Grpc\Testing\Void', 'decode'], + $metadata, $options); } - } - } diff --git a/src/php/tests/qps/histogram.php b/src/php/tests/qps/histogram.php new file mode 100644 index 00000000000..c11a67c6186 --- /dev/null +++ b/src/php/tests/qps/histogram.php @@ -0,0 +1,93 @@ +multiplier)); + } + + public function __construct($resolution, $max_possible) { + $this->resolution = $resolution; + $this->max_possible = $max_possible; + $this->sum = 0; + $this->sum_of_squares = 0; + $this->multiplier = 1+$resolution; + $this->count = 0; + $this->min_seen = $max_possible; + $this->max_seen = 0; + $this->buckets = array_fill(0, $this->bucket_for($max_possible)+1, 0); + } + + public function add($value) { + $this->sum += $value; + $this->sum_of_squares += $value * $value; + $this->count += 1; + if ($value < $this->min_seen) { + $this->min_seen = $value; + } + if ($value > $this->max_seen) { + $this->max_seen = $value; + } + $this->buckets[$this->bucket_for($value)] += 1; + } + + public function minimum() { + return $this->min_seen; + } + + public function maximum() { + return $this->max_seen; + } + + public function sum() { + return $this->sum; + } + + public function sum_of_squares() { + return $this->sum_of_squares; + } + + public function count() { + return $this->count; + } + + public function contents() { + return $this->buckets; + } + + public function clean() { + $this->sum = 0; + $this->sum_of_squares = 0; + $this->count = 0; + $this->min_seen = $this->max_possible; + $this->max_seen = 0; + $this->buckets = array_fill(0, $this->bucket_for($this->max_possible)+1, 0); + } +} diff --git a/src/proto/grpc/testing/proxy-service.proto b/src/proto/grpc/testing/proxy-service.proto index 8d0a9498c02..deaabd13651 100644 --- a/src/proto/grpc/testing/proxy-service.proto +++ b/src/proto/grpc/testing/proxy-service.proto @@ -15,6 +15,7 @@ syntax = "proto3"; import "src/proto/grpc/testing/control.proto"; +import "src/proto/grpc/testing/stats.proto"; package grpc.testing; @@ -25,5 +26,6 @@ message ProxyStat { service ProxyClientService { rpc GetConfig(Void) returns (ClientConfig); rpc ReportTime(stream ProxyStat) returns (Void); + rpc ReportHist(stream HistogramData) returns (Void); } diff --git a/src/ruby/qps/histogram.rb b/src/ruby/qps/histogram.rb index 1a27e172180..e48fb842be4 100644 --- a/src/ruby/qps/histogram.rb +++ b/src/ruby/qps/histogram.rb @@ -16,6 +16,8 @@ # Histogram class for use in performance testing and measurement +require 'thread' + class Histogram # Determine the bucket index for a given value # @param {number} value The value to check @@ -27,6 +29,7 @@ class Histogram # @param {number} resolution The resolution of the histogram # @param {number} max_possible The maximum value for the histogram def initialize(resolution, max_possible) + @lock = Mutex.new @resolution=resolution @max_possible=max_possible @sum=0 @@ -70,4 +73,16 @@ class Histogram def contents @buckets end + + def merge(hist) + @lock.synchronize do + @min_seen = hist.min_seen + @max_seen = hist.max_seen + @sum += hist.sum + @sum_of_squares += hist.sum_of_squares + @count += hist.count + received_bucket = hist.bucket.to_a + @buckets = @buckets.map.with_index{ |m,i| m + received_bucket[i].to_i } + end + end end diff --git a/src/ruby/qps/proxy-worker.rb b/src/ruby/qps/proxy-worker.rb index ae7006e7d60..fc5db50c1c8 100755 --- a/src/ruby/qps/proxy-worker.rb +++ b/src/ruby/qps/proxy-worker.rb @@ -41,32 +41,49 @@ class ProxyBenchmarkClientServiceImpl < Grpc::Testing::ProxyClientService::Servi @histmax = config.histogram_params.max_possible @histogram = Histogram.new(@histres, @histmax) @start_time = Time.now - # TODO(vjpai): Support multiple client channels by spawning off a PHP client per channel - if @use_c_ext - puts "Use protobuf c extension" - command = "php -d extension=" + File.expand_path(File.dirname(__FILE__)) + "/../../php/tests/qps/vendor/google/protobuf/php/ext/google/protobuf/modules/protobuf.so " + "-d extension=" + File.expand_path(File.dirname(__FILE__)) + "/../../php/ext/grpc/modules/grpc.so " + File.expand_path(File.dirname(__FILE__)) + "/../../php/tests/qps/client.php " + @mytarget - else - puts "Use protobuf php extension" - command = "php -d extension=" + File.expand_path(File.dirname(__FILE__)) + "/../../php/ext/grpc/modules/grpc.so " + File.expand_path(File.dirname(__FILE__)) + "/../../php/tests/qps/client.php " + @mytarget - end - puts "Starting command: " + command - @php_pid = spawn(command) + @php_pid = Array.new(@config.client_channels) + (0..@config.client_channels-1).each do |chan| + Thread.new { + if @use_c_ext + puts "Use protobuf c extension" + command = "php -d extension=" + File.expand_path(File.dirname(__FILE__)) + + "/../../php/tests/qps/vendor/google/protobuf/php/ext/google/protobuf/modules/protobuf.so " + + "-d extension=" + File.expand_path(File.dirname(__FILE__)) + "/../../php/ext/grpc/modules/grpc.so " + + File.expand_path(File.dirname(__FILE__)) + "/../../php/tests/qps/client.php " + @mytarget + " #{chan%@config.server_targets.length}" + else + puts "Use protobuf php extension" + command = "php -d extension=" + File.expand_path(File.dirname(__FILE__)) + "/../../php/ext/grpc/modules/grpc.so " + + File.expand_path(File.dirname(__FILE__)) + "/../../php/tests/qps/client.php " + @mytarget + " #{chan%@config.server_targets.length}" + end + puts "[ruby proxy] Starting #{chan}th php-client command use c protobuf #{@use_c_ext}: " + command + @php_pid[chan] = spawn(command) + while true + sleep + end + } + end end def stop - Process.kill("TERM", @php_pid) - Process.wait(@php_pid) + (0..@config.client_channels-1).each do |chan| + Process.kill("TERM", @php_pid[chan]) + Process.wait(@php_pid[chan]) + end end def get_config(_args, _call) - puts "Answering get_config" @config end def report_time(call) - puts "Starting a time reporting stream" call.each_remote_read do |lat| @histogram.add((lat.latency)*1e9) end Grpc::Testing::Void.new end + def report_hist(call) + call.each_remote_read do |lat| + @histogram.merge(lat) + end + Grpc::Testing::Void.new + end def mark(reset) lat = Grpc::Testing::HistogramData.new( bucket: @histogram.contents, @@ -135,7 +152,7 @@ def proxymain opts.on('--driver_port PORT', '') do |v| options['driver_port'] = v end - opts.on("-c", "--[no-]c_proto_ext", "Use protobuf C-extention") do |c| + opts.on("-c", "--[no-]use_protobuf_c_extension", "Use protobuf C-extention") do |c| options[:c_ext] = c end end.parse! @@ -143,7 +160,8 @@ def proxymain # Configure any errors with client or server child threads to surface Thread.abort_on_exception = true - s = GRPC::RpcServer.new + # Make sure proxy_server can handle the large number of calls in benchmarks + s = GRPC::RpcServer.new(pool_size: 1024) port = s.add_http2_port("0.0.0.0:" + options['driver_port'].to_s, :this_port_is_insecure) bmc = ProxyBenchmarkClientServiceImpl.new(port, options[:c_ext]) diff --git a/src/ruby/qps/src/proto/grpc/testing/proxy-service_pb.rb b/src/ruby/qps/src/proto/grpc/testing/proxy-service_pb.rb index d238198cca3..583b2ea6558 100644 --- a/src/ruby/qps/src/proto/grpc/testing/proxy-service_pb.rb +++ b/src/ruby/qps/src/proto/grpc/testing/proxy-service_pb.rb @@ -4,6 +4,7 @@ require 'google/protobuf' require 'src/proto/grpc/testing/control_pb' +require 'src/proto/grpc/testing/stats_pb' Google::Protobuf::DescriptorPool.generated_pool.build do add_message "grpc.testing.ProxyStat" do optional :latency, :double, 1 diff --git a/src/ruby/qps/src/proto/grpc/testing/proxy-service_services_pb.rb b/src/ruby/qps/src/proto/grpc/testing/proxy-service_services_pb.rb index 484cf05f92f..e7bb59b8a09 100644 --- a/src/ruby/qps/src/proto/grpc/testing/proxy-service_services_pb.rb +++ b/src/ruby/qps/src/proto/grpc/testing/proxy-service_services_pb.rb @@ -32,6 +32,7 @@ module Grpc rpc :GetConfig, Void, ClientConfig rpc :ReportTime, stream(ProxyStat), Void + rpc :ReportHist, stream(HistogramData), Void end Stub = Service.rpc_stub_class diff --git a/tools/jenkins/run_full_performance.sh b/tools/jenkins/run_full_performance.sh index 9598fd77349..195cc68003d 100755 --- a/tools/jenkins/run_full_performance.sh +++ b/tools/jenkins/run_full_performance.sh @@ -21,7 +21,7 @@ cd $(dirname $0)/../.. # run 8core client vs 8core server tools/run_tests/run_performance_tests.py \ - -l c++ csharp node ruby java python go node_express php_protobuf_php php_protobuf_c \ + -l c++ csharp node ruby java python go node_express php7 php7_protobuf_c \ --netperf \ --category scalable \ --bq_result_table performance_test.performance_experiment \ diff --git a/tools/run_tests/performance/build_performance.sh b/tools/run_tests/performance/build_performance.sh index e46d4e00403..e7d8db8e3ea 100755 --- a/tools/run_tests/performance/build_performance.sh +++ b/tools/run_tests/performance/build_performance.sh @@ -31,6 +31,7 @@ then make CONFIG=${CONFIG} EMBED_OPENSSL=true EMBED_ZLIB=true qps_worker qps_json_driver -j8 fi +PHP_ALREADY_BUILT="" for language in $@ do case "$language" in @@ -43,6 +44,14 @@ do "go") tools/run_tests/performance/build_performance_go.sh ;; + "php7"|"php7_protobuf_c") + if [ -n "$PHP_ALREADY_BUILT" ]; then + echo "Skipping PHP build as already built by $PHP_ALREADY_BUILT" + else + PHP_ALREADY_BUILT=$language + tools/run_tests/performance/build_performance_php7.sh + fi + ;; "csharp") python tools/run_tests/run_tests.py -l $language -c $CONFIG --build_only -j 8 --compiler coreclr ;; diff --git a/tools/run_tests/performance/build_performance_php7.sh b/tools/run_tests/performance/build_performance_php7.sh new file mode 100755 index 00000000000..141c9fd1c81 --- /dev/null +++ b/tools/run_tests/performance/build_performance_php7.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +cd $(dirname $0)/../../.. +CONFIG=${CONFIG:-opt} +python tools/run_tests/run_tests.py -l php7 -c $CONFIG --build_only -j 8 + +# Set up all dependences needed for PHP QPS test +cd src/php/tests/qps +composer install +# Install protobuf C-extension for php +cd vendor/google/protobuf/php/ext/google/protobuf +phpize +./configure +make + diff --git a/tools/run_tests/performance/run_worker_php.sh b/tools/run_tests/performance/run_worker_php.sh index e524d5286d0..8c7ceef2ff7 100755 --- a/tools/run_tests/performance/run_worker_php.sh +++ b/tools/run_tests/performance/run_worker_php.sh @@ -17,17 +17,7 @@ source ~/.rvm/scripts/rvm set -ex cd $(dirname $0)/../../.. -repo=$(pwd) -# First set up all dependences needed for PHP QPS test -cd $repo -cd src/php/tests/qps -composer install -# Install protobuf C-extension for php -cd vendor/google/protobuf/php/ext/google/protobuf -phpize -./configure -make + # The proxy worker for PHP is implemented in Ruby -cd $repo ruby src/ruby/qps/proxy-worker.rb $@ diff --git a/tools/run_tests/performance/scenario_config.py b/tools/run_tests/performance/scenario_config.py index 5019358ab3e..8f01eb4b2aa 100644 --- a/tools/run_tests/performance/scenario_config.py +++ b/tools/run_tests/performance/scenario_config.py @@ -800,39 +800,54 @@ class RubyLanguage: return 'ruby' -class PhpLanguage: +class Php7Language: - def __init__(self, use_protobuf_c_extension=False): + def __init__(self, php7_protobuf_c=False): pass - self.use_protobuf_c_extension=use_protobuf_c_extension + self.php7_protobuf_c=php7_protobuf_c self.safename = str(self) def worker_cmdline(self): - if self.use_protobuf_c_extension: - return ['tools/run_tests/performance/run_worker_php.sh -c'] + if self.php7_protobuf_c: + return ['tools/run_tests/performance/run_worker_php.sh --use_protobuf_c_extension'] return ['tools/run_tests/performance/run_worker_php.sh'] def worker_port_offset(self): + if self.php7_protobuf_c: + return 900 return 800 def scenarios(self): - php_extension_mode='php_protobuf_php_extension' - if self.use_protobuf_c_extension: - php_extension_mode='php_protobuf_c_extension' + php7_extension_mode='php7_protobuf_php_extension' + if self.php7_protobuf_c: + php7_extension_mode='php7_protobuf_c_extension' yield _ping_pong_scenario( - '%s_to_cpp_protobuf_sync_unary_ping_pong' % php_extension_mode, + '%s_to_cpp_protobuf_sync_unary_ping_pong' % php7_extension_mode, rpc_type='UNARY', client_type='SYNC_CLIENT', server_type='SYNC_SERVER', server_language='c++', async_server_threads=1) yield _ping_pong_scenario( - '%s_to_cpp_protobuf_sync_streaming_ping_pong' % php_extension_mode, + '%s_to_cpp_protobuf_sync_streaming_ping_pong' % php7_extension_mode, rpc_type='STREAMING', client_type='SYNC_CLIENT', server_type='SYNC_SERVER', server_language='c++', async_server_threads=1) - def __str__(self): - return 'php' + # TODO(ddyihai): Investigate why when async_server_threads=1/CPU usage 340%, the QPS performs + # better than async_server_threads=0/CPU usage 490%. + yield _ping_pong_scenario( + '%s_to_cpp_protobuf_sync_unary_qps_unconstrained' % php7_extension_mode, + rpc_type='UNARY', client_type='SYNC_CLIENT', server_type='ASYNC_SERVER', + server_language='c++', outstanding=1, async_server_threads=1, unconstrained_client='sync') + yield _ping_pong_scenario( + '%s_to_cpp_protobuf_sync_streaming_qps_unconstrained' % php7_extension_mode, + rpc_type='STREAMING', client_type='SYNC_CLIENT', server_type='ASYNC_SERVER', + server_language='c++', outstanding=1, async_server_threads=1, unconstrained_client='sync') + + def __str__(self): + if self.php7_protobuf_c: + return 'php7_protobuf_c' + return 'php7' class JavaLanguage: @@ -1031,8 +1046,8 @@ LANGUAGES = { 'node' : NodeLanguage(), 'node_express': NodeExpressLanguage(), 'ruby' : RubyLanguage(), - 'php_protobuf_php' : PhpLanguage(), - 'php_protobuf_c' : PhpLanguage(use_protobuf_c_extension=True), + 'php7' : Php7Language(), + 'php7_protobuf_c' : Php7Language(php7_protobuf_c=True), 'java' : JavaLanguage(), 'python' : PythonLanguage(), 'go' : GoLanguage(), From cd42eb0a8ea21e3002f4377b24d5f54ae7791833 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Fri, 6 Oct 2017 15:26:00 -0700 Subject: [PATCH 101/142] Doc with plans for converting core to C++ --- doc/core/moving-to-c++.md | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 doc/core/moving-to-c++.md diff --git a/doc/core/moving-to-c++.md b/doc/core/moving-to-c++.md new file mode 100644 index 00000000000..33c3cfa0e66 --- /dev/null +++ b/doc/core/moving-to-c++.md @@ -0,0 +1,54 @@ +# Moving gRPC core to C++ + +October 2017 + +ctiller, markdroth, vjpai + +## Background and Goal + +gRPC core was originally written in C89 for several reasons (possibility of +kernel integration, ease of wrapping, compiler support, etc). Over time, this +was changed to C99 as all relevant compilers in active use came to support C99 +effectively. Now, gRPC core is C++ (although the code is still idiomatically C +code) with C linkage for public functions. Throughout all of these transitions, +the public header files are committed to remain in C89. + +The goal now is to make gRPC core true idiomatic C++ compatible with +[Google's C++ style guide](https://google.github.io/styleguide/cppguide.html). + +## Constraints + +- No use of standard library + - Standard library makes wrapping difficult/impossible and also reduces platform portability + - This takes precedence over using C++ style guide +- But lambdas are ok +- As are third-party libraries that meet our build requirements (such as many parts of abseil) +- There will be some C++ features that don't work + - `new` and `delete` + - pure virtual functions are not allowed because the message that prints out "Pure Virtual Function called" is part of the standard library + - Make a `#define GRPC_ABSTRACT {GPR_ASSERT(false);}` instead of `= 0;` +- The sanity for making sure that we don't depend on libstdc++ is that at least some tests should explicitly not include it + - Most tests can migrate to use gtest + - There are tremendous # of code paths that can now be exposed to unit tests because of the use of gtest and C++ + - But at least some tests should not use gtest + + +## Roadmap + +- What should be the phases of getting code converted to idiomatic C++ + - Opportunistically do leaf code that other parts don't depend on + - Spend a little time deciding how to do non-leaf stuff that isn't central or polymorphic (e.g., timer, call combiner) + - For big central or polymorphic interfaces, actually do an API review (for things like transport, filter API, endpoint, closure, exec_ctx, ...) . + - Core internal changes don't need a gRFC, but core surface changes do + - But an API review should include at least a PR with the header change and tests to use it before it gets used more broadly + - iomgr polling for POSIX is a gray area whether it's a leaf or central +- What is the schedule? + - In Q4 2017, if some stuff happens opportunistically, great; otherwise ¯\\\_(ツ)\_/¯ + - More updates as team time becomes available and committed to this project + +## Implications for C++ API and wrapped languages + +- For C++ structs, switch to `using` when possible (e.g., Slice, ByteBuffer, ...) +- Can we get wrapped languages to a point where we can statically link C++? This will take a year in probability but that would allow the use of `std::` + - Are there other environments that don't support std library, like maybe Android NDK? + - Probably, that might push things out to 18 months From c128440feb62cc0fa5baa94867d14b4d564d57c3 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 6 Oct 2017 15:43:05 -0700 Subject: [PATCH 102/142] Fix compile error --- .../chttp2/transport/flow_control.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/flow_control.cc b/src/core/ext/transport/chttp2/transport/flow_control.cc index 639e51da703..2428e2526d3 100644 --- a/src/core/ext/transport/chttp2/transport/flow_control.cc +++ b/src/core/ext/transport/chttp2/transport/flow_control.cc @@ -399,15 +399,16 @@ static double get_pid_controller_guess(grpc_exec_ctx* exec_ctx, if (!tfc->pid_controller_initialized) { tfc->last_pid_update = now; tfc->pid_controller_initialized = true; - grpc_pid_controller_init( - &tfc->pid_controller, - (grpc_pid_controller_args){.gain_p = 4, - .gain_i = 8, - .gain_d = 0, - .initial_control_value = target, - .min_control_value = -1, - .max_control_value = 25, - .integral_range = 10}); + grpc_pid_controller_args args; + memset(&args, 0, sizeof(args)); + args.gain_p = 4; + args.gain_i = 8; + args.gain_d = 0; + args.initial_control_value = target; + args.min_control_value = -1; + args.max_control_value = 25; + args.integral_range = 10; + grpc_pid_controller_init(&tfc->pid_controller, args); return pow(2, target); } double bdp_error = target - grpc_pid_controller_last(&tfc->pid_controller); From 412e7ca6e713cfbce3db09e22c3ca185f4f09460 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 6 Oct 2017 16:30:12 -0700 Subject: [PATCH 103/142] Adding PR #12882 changes --- .../chttp2/transport/flow_control.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/flow_control.cc b/src/core/ext/transport/chttp2/transport/flow_control.cc index 639e51da703..2428e2526d3 100644 --- a/src/core/ext/transport/chttp2/transport/flow_control.cc +++ b/src/core/ext/transport/chttp2/transport/flow_control.cc @@ -399,15 +399,16 @@ static double get_pid_controller_guess(grpc_exec_ctx* exec_ctx, if (!tfc->pid_controller_initialized) { tfc->last_pid_update = now; tfc->pid_controller_initialized = true; - grpc_pid_controller_init( - &tfc->pid_controller, - (grpc_pid_controller_args){.gain_p = 4, - .gain_i = 8, - .gain_d = 0, - .initial_control_value = target, - .min_control_value = -1, - .max_control_value = 25, - .integral_range = 10}); + grpc_pid_controller_args args; + memset(&args, 0, sizeof(args)); + args.gain_p = 4; + args.gain_i = 8; + args.gain_d = 0; + args.initial_control_value = target; + args.min_control_value = -1; + args.max_control_value = 25; + args.integral_range = 10; + grpc_pid_controller_init(&tfc->pid_controller, args); return pow(2, target); } double bdp_error = target - grpc_pid_controller_last(&tfc->pid_controller); From 4b6af749e3cf8015065e3a3a66aab931acdc3296 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 6 Oct 2017 16:21:11 -0700 Subject: [PATCH 104/142] explicit type conversion --- test/core/transport/timeout_encoding_test.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/core/transport/timeout_encoding_test.c b/test/core/transport/timeout_encoding_test.c index 3010c6d057d..30357faed36 100644 --- a/test/core/transport/timeout_encoding_test.c +++ b/test/core/transport/timeout_encoding_test.c @@ -102,18 +102,20 @@ void decode_suite(char ext, grpc_millis (*answer)(int64_t x)) { } static grpc_millis millis_from_nanos(int64_t x) { - return x / GPR_NS_PER_MS + (x % GPR_NS_PER_MS != 0); + return (grpc_millis)(x / GPR_NS_PER_MS + (x % GPR_NS_PER_MS != 0)); } static grpc_millis millis_from_micros(int64_t x) { - return x / GPR_US_PER_MS + (x % GPR_US_PER_MS != 0); + return (grpc_millis)(x / GPR_US_PER_MS + (x % GPR_US_PER_MS != 0)); +} +static grpc_millis millis_from_millis(int64_t x) { return (grpc_millis)x; } +static grpc_millis millis_from_seconds(int64_t x) { + return (grpc_millis)(x * GPR_MS_PER_SEC); } -static grpc_millis millis_from_millis(int64_t x) { return x; } -static grpc_millis millis_from_seconds(int64_t x) { return x * GPR_MS_PER_SEC; } static grpc_millis millis_from_minutes(int64_t x) { - return x * 60 * GPR_MS_PER_SEC; + return (grpc_millis)(x * 60 * GPR_MS_PER_SEC); } static grpc_millis millis_from_hours(int64_t x) { - return x * 3600 * GPR_MS_PER_SEC; + return (grpc_millis)(x * 3600 * GPR_MS_PER_SEC); } void test_decoding(void) { From 08708ae25d9855e7469abb2745352cc449541a9b Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 6 Oct 2017 17:03:53 -0700 Subject: [PATCH 105/142] backoff_test explicity conversion --- test/core/backoff/backoff_test.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/core/backoff/backoff_test.c b/test/core/backoff/backoff_test.c index 3848b2a54d4..a29cce6cc7b 100644 --- a/test/core/backoff/backoff_test.c +++ b/test/core/backoff/backoff_test.c @@ -105,8 +105,9 @@ static void test_jitter_backoff(void) { const int64_t initial_timeout = 500; const double jitter = 0.1; grpc_backoff backoff; - grpc_backoff_init(&backoff, initial_timeout, 1.0 /* multiplier */, jitter, - 100 /* min timeout */, 1000 /* max timeout */); + grpc_backoff_init(&backoff, (grpc_millis)initial_timeout, + 1.0 /* multiplier */, jitter, 100 /* min timeout */, + 1000 /* max timeout */); backoff.rng_state = 0; // force consistent PRNG From 656041b3cc7c1a4549154f062dc8004247e97051 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 6 Oct 2017 15:33:10 -0700 Subject: [PATCH 106/142] Fix GID related subspec lint problem --- gRPC.podspec | 3 +++ templates/gRPC.podspec.template | 3 +++ 2 files changed, 6 insertions(+) diff --git a/gRPC.podspec b/gRPC.podspec index 6bec50f0de3..4c6cd3535f6 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -63,10 +63,13 @@ Pod::Spec.new do |s| end s.subspec 'GID' do |ss| + ss.ios.deployment_target = '7.0' + ss.header_mappings_dir = "#{src_dir}" ss.source_files = "#{src_dir}/GRPCCall+GID.{h,m}" + ss.dependency "#{s.name}/Main", version ss.dependency 'Google/SignIn' end end diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template index 5c92f9f9c42..4b360cfb4c4 100644 --- a/templates/gRPC.podspec.template +++ b/templates/gRPC.podspec.template @@ -65,10 +65,13 @@ end s.subspec 'GID' do |ss| + ss.ios.deployment_target = '7.0' + ss.header_mappings_dir = "#{src_dir}" ss.source_files = "#{src_dir}/GRPCCall+GID.{h,m}" + ss.dependency "#{s.name}/Main", version ss.dependency 'Google/SignIn' end end From cd9729780afcb8894709ec19175a3a5cf337a78f Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 6 Oct 2017 13:46:27 -0700 Subject: [PATCH 107/142] Make platform-specific headers textual --- gRPC-Core.podspec | 11 +++++ include/grpc/module.modulemap | 32 ++++++++++----- src/objective-c/BoringSSL.podspec | 6 ++- templates/gRPC-Core.podspec.template | 10 +---- .../include/grpc/module.modulemap.template | 41 +++++++++++++++---- 5 files changed, 70 insertions(+), 30 deletions(-) diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 08ef7387322..f19b672f5ac 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -106,6 +106,8 @@ Pod::Spec.new do |s| ss.source_files = 'include/grpc/support/alloc.h', 'include/grpc/support/atm.h', 'include/grpc/support/atm_gcc_atomic.h', + 'include/grpc/support/atm_gcc_sync.h', + 'include/grpc/support/atm_windows.h', 'include/grpc/support/avl.h', 'include/grpc/support/cmdline.h', 'include/grpc/support/cpu.h', @@ -120,13 +122,18 @@ Pod::Spec.new do |s| 'include/grpc/support/sync_custom.h', 'include/grpc/support/sync_generic.h', 'include/grpc/support/sync_posix.h', + 'include/grpc/support/sync_windows.h', 'include/grpc/support/thd.h', 'include/grpc/support/time.h', 'include/grpc/support/tls.h', + 'include/grpc/support/tls_gcc.h', + 'include/grpc/support/tls_msvc.h', 'include/grpc/support/tls_pthread.h', 'include/grpc/support/useful.h', 'include/grpc/impl/codegen/atm.h', 'include/grpc/impl/codegen/atm_gcc_atomic.h', + 'include/grpc/impl/codegen/atm_gcc_sync.h', + 'include/grpc/impl/codegen/atm_windows.h', 'include/grpc/impl/codegen/gpr_slice.h', 'include/grpc/impl/codegen/gpr_types.h', 'include/grpc/impl/codegen/port_platform.h', @@ -134,6 +141,7 @@ Pod::Spec.new do |s| 'include/grpc/impl/codegen/sync_custom.h', 'include/grpc/impl/codegen/sync_generic.h', 'include/grpc/impl/codegen/sync_posix.h', + 'include/grpc/impl/codegen/sync_windows.h', 'include/grpc/impl/codegen/byte_buffer.h', 'include/grpc/impl/codegen/byte_buffer_reader.h', 'include/grpc/impl/codegen/compression_types.h', @@ -145,6 +153,8 @@ Pod::Spec.new do |s| 'include/grpc/impl/codegen/status.h', 'include/grpc/impl/codegen/atm.h', 'include/grpc/impl/codegen/atm_gcc_atomic.h', + 'include/grpc/impl/codegen/atm_gcc_sync.h', + 'include/grpc/impl/codegen/atm_windows.h', 'include/grpc/impl/codegen/gpr_slice.h', 'include/grpc/impl/codegen/gpr_types.h', 'include/grpc/impl/codegen/port_platform.h', @@ -152,6 +162,7 @@ Pod::Spec.new do |s| 'include/grpc/impl/codegen/sync_custom.h', 'include/grpc/impl/codegen/sync_generic.h', 'include/grpc/impl/codegen/sync_posix.h', + 'include/grpc/impl/codegen/sync_windows.h', 'include/grpc/grpc_security.h', 'include/grpc/byte_buffer.h', 'include/grpc/byte_buffer_reader.h', diff --git a/include/grpc/module.modulemap b/include/grpc/module.modulemap index 226cc6cf871..342adc0dc93 100644 --- a/include/grpc/module.modulemap +++ b/include/grpc/module.modulemap @@ -4,7 +4,6 @@ framework module grpc { header "support/alloc.h" header "support/atm.h" - header "support/atm_gcc_atomic.h" header "support/avl.h" header "support/cmdline.h" header "support/cpu.h" @@ -16,23 +15,17 @@ framework module grpc { header "support/string_util.h" header "support/subprocess.h" header "support/sync.h" - header "support/sync_custom.h" header "support/sync_generic.h" - header "support/sync_posix.h" header "support/thd.h" header "support/time.h" header "support/tls.h" - header "support/tls_pthread.h" header "support/useful.h" header "impl/codegen/atm.h" - header "impl/codegen/atm_gcc_atomic.h" header "impl/codegen/gpr_slice.h" header "impl/codegen/gpr_types.h" header "impl/codegen/port_platform.h" header "impl/codegen/sync.h" - header "impl/codegen/sync_custom.h" header "impl/codegen/sync_generic.h" - header "impl/codegen/sync_posix.h" header "impl/codegen/byte_buffer.h" header "impl/codegen/byte_buffer_reader.h" header "impl/codegen/compression_types.h" @@ -43,14 +36,11 @@ framework module grpc { header "impl/codegen/slice.h" header "impl/codegen/status.h" header "impl/codegen/atm.h" - header "impl/codegen/atm_gcc_atomic.h" header "impl/codegen/gpr_slice.h" header "impl/codegen/gpr_types.h" header "impl/codegen/port_platform.h" header "impl/codegen/sync.h" - header "impl/codegen/sync_custom.h" header "impl/codegen/sync_generic.h" - header "impl/codegen/sync_posix.h" header "grpc_security.h" header "byte_buffer.h" header "byte_buffer_reader.h" @@ -65,6 +55,28 @@ framework module grpc { header "support/workaround_list.h" header "census.h" + textual header "support/atm_gcc_atomic.h" + textual header "support/atm_gcc_sync.h" + textual header "support/atm_windows.h" + textual header "support/sync_custom.h" + textual header "support/sync_posix.h" + textual header "support/sync_windows.h" + textual header "support/tls_gcc.h" + textual header "support/tls_msvc.h" + textual header "support/tls_pthread.h" + textual header "impl/codegen/atm_gcc_atomic.h" + textual header "impl/codegen/atm_gcc_sync.h" + textual header "impl/codegen/atm_windows.h" + textual header "impl/codegen/sync_custom.h" + textual header "impl/codegen/sync_posix.h" + textual header "impl/codegen/sync_windows.h" + textual header "impl/codegen/atm_gcc_atomic.h" + textual header "impl/codegen/atm_gcc_sync.h" + textual header "impl/codegen/atm_windows.h" + textual header "impl/codegen/sync_custom.h" + textual header "impl/codegen/sync_posix.h" + textual header "impl/codegen/sync_windows.h" + export * module * { export * } } diff --git a/src/objective-c/BoringSSL.podspec b/src/objective-c/BoringSSL.podspec index 37798ec3c6b..c61afc1a8f7 100644 --- a/src/objective-c/BoringSSL.podspec +++ b/src/objective-c/BoringSSL.podspec @@ -31,7 +31,7 @@ Pod::Spec.new do |s| s.name = 'BoringSSL' - version = '9.0' + version = '9.1' s.version = version s.summary = 'BoringSSL is a fork of OpenSSL that is designed to meet Google’s needs.' # Adapted from the homepage: @@ -67,9 +67,10 @@ Pod::Spec.new do |s| # "The name and email addresses of the library maintainers, not the Podspec maintainer." s.authors = 'Adam Langley', 'David Benjamin', 'Matt Braithwaite' + major_version = version[0] + '.0' s.source = { :git => 'https://boringssl.googlesource.com/boringssl', - :tag => "version_for_cocoapods_#{version}", + :tag => "version_for_cocoapods_#{major_version}", } name = 'openssl' @@ -186,6 +187,7 @@ Pod::Spec.new do |s| cat > include/openssl/BoringSSL.modulemap < framework module grpc { umbrella header "grpc.h" ${header_lines(grpc_public_headers_no_dir(libs))} + ${textual_header_lines(grpc_public_textual_headers_no_dir(libs))} + export * module * { export * } } From 128d800bb6fc5c010ed2182c4cf9023715b7bb08 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 6 Oct 2017 16:27:47 -0700 Subject: [PATCH 108/142] Add comment --- templates/include/grpc/module.modulemap.template | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/include/grpc/module.modulemap.template b/templates/include/grpc/module.modulemap.template index 9dde240e437..e18bc3de50d 100644 --- a/templates/include/grpc/module.modulemap.template +++ b/templates/include/grpc/module.modulemap.template @@ -27,6 +27,9 @@ out = [hdr.split('/', 2)[2] for hdr in out] return out + # Generate the list of platform-specific headers as textual headers so that + # they are not built when the module is built but only when they are named by + # an #include directive. def grpc_public_textual_headers_no_dir(libs): out = [] for lib in libs: From e6b9c787c0314d31060c0c4547bf12e087fb4e93 Mon Sep 17 00:00:00 2001 From: Adele Zhou Date: Wed, 4 Oct 2017 15:53:03 -0700 Subject: [PATCH 109/142] Exit 1 when there are failures. --- tools/interop_matrix/README.md | 2 +- tools/interop_matrix/create_testcases.sh | 15 +++++----- .../run_interop_matrix_tests.py | 20 +++++++++---- tools/interop_matrix/testcases/cxx__master | 28 +++++++------------ tools/interop_matrix/testcases/go__master | 28 +++++++------------ tools/interop_matrix/testcases/java__master | 28 +++++++------------ 6 files changed, 54 insertions(+), 67 deletions(-) diff --git a/tools/interop_matrix/README.md b/tools/interop_matrix/README.md index c2f354399f0..c0e9a33c5e4 100644 --- a/tools/interop_matrix/README.md +++ b/tools/interop_matrix/README.md @@ -47,7 +47,7 @@ For more details on each step, refer to sections below. ## Instructions for running test cases against GCR images - Run `tools/interop_matrix/run_interop_matrix_tests.py`. Useful options: - - `--release` specifies a git release tag. Defaults to `--release=master`. Make sure the GCR images with the tag have been created using `create_matrix_images.py` above. + - `--release` specifies a git release tag. Defaults to `--release=all`. Make sure the GCR images with the tag have been created using `create_matrix_images.py` above. - `--language` specifies a language. Defaults to `--language=all`. For example, To test all languages for all gRPC releases across all runtimes, do `tools/interop_matrix/run_interop_matrix_test.py --release=all`. - The output for all the test cases is recorded in a junit style xml file (default to 'report.xml'). diff --git a/tools/interop_matrix/create_testcases.sh b/tools/interop_matrix/create_testcases.sh index e89bad93cce..3d34b2ef25a 100755 --- a/tools/interop_matrix/create_testcases.sh +++ b/tools/interop_matrix/create_testcases.sh @@ -33,8 +33,10 @@ echo "Create '$LANG' test cases for gRPC release '${RELEASE:=master}'" echo $client_lang # Invoke run_interop_test in manual mode. +# TODO(adelez): Add cloud_gateways when we figure out how to skip them if not +# running in GCE. ${GRPC_ROOT}/tools/run_tests/run_interop_tests.py -l $LANG --use_docker \ - --cloud_to_prod --cloud_to_prod_auth --prod_servers default cloud_gateway_v4 --manual_run + --cloud_to_prod --prod_servers default gateway_v4 --manual_run # Clean up function cleanup { @@ -53,16 +55,15 @@ function cleanup { [ -e "$CMDS_SH" ] && rm $CMDS_SH } trap cleanup EXIT -# TODO(adelez): skip sanity checks b/c auth tests only work in GCE. Need to be -# able to filter them out and bring back the check. +# TODO(adelez): add test auth tests but do not run if not testing on GCE. # Running the testcases as sanity unless we are asked to skip. -#[ -z "$SKIP_TEST" ] && (echo "Running test cases: $CMDS_SH"; sh $CMDS_SH) +[ -z "$SKIP_TEST" ] && (echo "Running test cases: $CMDS_SH"; sh $CMDS_SH) # Convert c++ to cxx. +if [$LANG == "c++" ]; then +client_lang="cxx" +else client_lang=$LANG -if [ $LANG=="c++" ] - then - client_lang="cxx" fi mkdir -p $TESTCASES_DIR testcase=$TESTCASES_DIR/${client_lang}__$RELEASE diff --git a/tools/interop_matrix/run_interop_matrix_tests.py b/tools/interop_matrix/run_interop_matrix_tests.py index 4315c8277df..510bc7124db 100755 --- a/tools/interop_matrix/run_interop_matrix_tests.py +++ b/tools/interop_matrix/run_interop_matrix_tests.py @@ -48,9 +48,8 @@ argp.add_argument('-j', '--jobs', default=multiprocessing.cpu_count(), type=int) argp.add_argument('--gcr_path', default='gcr.io/grpc-testing', help='Path of docker images in Google Container Registry') - argp.add_argument('--release', - default='master', + default='all', choices=['all', 'master'] + _RELEASES, help='Release tags to test. When testing all ' 'releases defined in client_matrix.py, use "all".') @@ -94,14 +93,15 @@ def find_all_images_for_lang(lang): for runtime in client_matrix.LANG_RUNTIME_MATRIX[lang]: image_path = '%s/grpc_interop_%s' % (args.gcr_path, runtime) output = subprocess.check_output(['gcloud', 'beta', 'container', 'images', - 'list-tags', '--format=json', image_path]) + 'list-tags', '--format=json', image_path]) docker_image_list = json.loads(output) # All images should have a single tag or no tag. + # TODO(adelez): Remove tagless images. tags = [i['tags'][0] for i in docker_image_list if i['tags']] jobset.message('START', 'Found images for %s: %s' % (image_path, tags), do_newline=True) skipped = len(docker_image_list) - len(tags) - jobset.message('START', 'Skipped images (no-tag/unknown-tag): %d' % skipped, + jobset.message('SKIPPED', 'Skipped images (no-tag/unknown-tag): %d' % skipped, do_newline=True) # Filter tags based on the releases. images[runtime] = [(tag,'%s:%s' % (image_path,tag)) for tag in tags if @@ -148,6 +148,7 @@ def run_tests_for_lang(lang, runtime, images): images is a list of (, ) tuple. """ + total_num_failures = 0 for image_tuple in images: release, image = image_tuple jobset.message('START', 'Testing %s' % image, do_newline=True) @@ -161,6 +162,7 @@ def run_tests_for_lang(lang, runtime, images): maxjobs=args.jobs) if num_failures: jobset.message('FAILED', 'Some tests failed', do_newline=True) + total_num_failures += num_failures else: jobset.message('SUCCESS', 'All tests passed', do_newline=True) @@ -170,6 +172,9 @@ def run_tests_for_lang(lang, runtime, images): 'grpc_interop_matrix', '%s__%s %s'%(lang,runtime,release), str(uuid.uuid4())) + + return total_num_failures + _docker_images_cleanup = [] def cleanup(): @@ -180,9 +185,14 @@ def cleanup(): atexit.register(cleanup) languages = args.language if args.language != ['all'] else _LANGUAGES +total_num_failures = 0 for lang in languages: docker_images = find_all_images_for_lang(lang) for runtime in sorted(docker_images.keys()): - run_tests_for_lang(lang, runtime, docker_images[runtime]) + total_num_failures += run_tests_for_lang(lang, runtime, docker_images[runtime]) report_utils.create_xml_report_file(_xml_report_tree, args.report_file) + +if total_num_failures: + sys.exit(1) +sys.exit(0) diff --git a/tools/interop_matrix/testcases/cxx__master b/tools/interop_matrix/testcases/cxx__master index 2f2fc969b1d..e0fed53f088 100755 --- a/tools/interop_matrix/testcases/cxx__master +++ b/tools/interop_matrix/testcases/cxx__master @@ -1,5 +1,5 @@ #!/bin/bash -echo "Testing ${docker_image:=grpc_interop_cxx:ff1e1fd8-fbc5-4499-85eb-565a1f02e7ab}" +echo "Testing ${docker_image:=grpc_interop_cxx:78de6f80-524d-4bc9-bfb2-f00c24ceafed}" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" @@ -9,20 +9,12 @@ docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=compute_engine_creds --oauth_scope=https://www.googleapis.com/auth/xapi.zoo --default_service_account=830293263384-compute@developer.gserviceaccount.com" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=jwt_token_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=oauth2_auth_token --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo --default_service_account=830293263384-compute@developer.gserviceaccount.com" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=per_rpc_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=compute_engine_creds --oauth_scope=https://www.googleapis.com/auth/xapi.zoo --default_service_account=830293263384-compute@developer.gserviceaccount.com" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=jwt_token_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=oauth2_auth_token --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo --default_service_account=830293263384-compute@developer.gserviceaccount.com" -docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=per_rpc_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc --net=host $docker_image bash -c "bins/opt/interop_client --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" diff --git a/tools/interop_matrix/testcases/go__master b/tools/interop_matrix/testcases/go__master index a6bb5ee9d9f..33b25d6a16b 100755 --- a/tools/interop_matrix/testcases/go__master +++ b/tools/interop_matrix/testcases/go__master @@ -1,5 +1,5 @@ #!/bin/bash -echo "Testing ${docker_image:=grpc_interop_go:e7e7cdbd-56bd-490e-b33a-dd27e4cfb9c3}" +echo "Testing ${docker_image:=grpc_interop_go:dd8fbf3a-4964-4387-9997-5dadeea09835}" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" @@ -9,20 +9,12 @@ docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=h docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=compute_engine_creds --oauth_scope=https://www.googleapis.com/auth/xapi.zoo --default_service_account=830293263384-compute@developer.gserviceaccount.com" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=jwt_token_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=oauth2_auth_token --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=per_rpc_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=compute_engine_creds --oauth_scope=https://www.googleapis.com/auth/xapi.zoo --default_service_account=830293263384-compute@developer.gserviceaccount.com" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=jwt_token_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=oauth2_auth_token --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" -docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=per_rpc_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /go/src/google.golang.org/grpc/interop/client --net=host $docker_image bash -c "go run client.go --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" diff --git a/tools/interop_matrix/testcases/java__master b/tools/interop_matrix/testcases/java__master index 9dab1e39d20..dbd87279a6d 100755 --- a/tools/interop_matrix/testcases/java__master +++ b/tools/interop_matrix/testcases/java__master @@ -1,5 +1,5 @@ #!/bin/bash -echo "Testing ${docker_image:=grpc_interop_java:8541e45e-5275-43cb-a017-d4dde2d98f2f}" +echo "Testing ${docker_image:=grpc_interop_java:a764b50c-1788-4387-9b9e-5cfa93927006}" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" @@ -9,20 +9,12 @@ docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_i docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=compute_engine_creds --oauth_scope=https://www.googleapis.com/auth/xapi.zoo --default_service_account=830293263384-compute@developer.gserviceaccount.com" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=jwt_token_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=oauth2_auth_token --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=per_rpc_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=compute_engine_creds --oauth_scope=https://www.googleapis.com/auth/xapi.zoo --default_service_account=830293263384-compute@developer.gserviceaccount.com" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=jwt_token_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=oauth2_auth_token --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" -docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.255 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=per_rpc_creds --service_account_key_file=/root/service_account/GrpcTesting-726eb1347f15.json --oauth_scope=https://www.googleapis.com/auth/xapi.zoo" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=large_unary" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_unary" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=ping_pong" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=empty_stream" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=client_streaming" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=server_streaming" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_begin" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=cancel_after_first_response" +docker run -i --rm=true -w /var/local/git/grpc/../grpc-java --net=host $docker_image bash -c "./run-test-client.sh --server_host=216.239.32.254 --server_host_override=grpc-test4.sandbox.googleapis.com --server_port=443 --use_tls=true --test_case=timeout_on_sleeping_server" From d6712390a6b24732fb1feeced6ad68e9ac54ea5c Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 6 Oct 2017 17:54:16 -0700 Subject: [PATCH 110/142] tcp_client_uv_test changes --- test/core/iomgr/tcp_client_uv_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/core/iomgr/tcp_client_uv_test.c b/test/core/iomgr/tcp_client_uv_test.c index 0f1db4705bb..53061100a26 100644 --- a/test/core/iomgr/tcp_client_uv_test.c +++ b/test/core/iomgr/tcp_client_uv_test.c @@ -110,7 +110,7 @@ void test_succeeds(void) { (int *)&resolved_addr.len) == 0); GRPC_CLOSURE_INIT(&done, must_succeed, NULL, grpc_schedule_on_exec_ctx); grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, NULL, NULL, - &resolved_addr, gpr_inf_future(GPR_CLOCK_REALTIME)); + &resolved_addr, GRPC_MILLIS_INF_FUTURE); gpr_mu_lock(g_mu); @@ -154,7 +154,7 @@ void test_fails(void) { /* connect to a broken address */ GRPC_CLOSURE_INIT(&done, must_fail, NULL, grpc_schedule_on_exec_ctx); grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, NULL, NULL, - &resolved_addr, gpr_inf_future(GPR_CLOCK_REALTIME)); + &resolved_addr, GRPC_MILLIS_INF_FUTURE); gpr_mu_lock(g_mu); From cd58b2dceac4e9caaf299fa9409d6f82e40d8428 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 6 Oct 2017 18:10:05 -0700 Subject: [PATCH 111/142] uv changes for grpc_pollset_work --- test/core/iomgr/tcp_client_uv_test.c | 11 +++++------ test/core/iomgr/tcp_server_uv_test.c | 3 +-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/test/core/iomgr/tcp_client_uv_test.c b/test/core/iomgr/tcp_client_uv_test.c index 53061100a26..f94e589b8d7 100644 --- a/test/core/iomgr/tcp_client_uv_test.c +++ b/test/core/iomgr/tcp_client_uv_test.c @@ -42,8 +42,8 @@ static grpc_pollset *g_pollset; static int g_connections_complete = 0; static grpc_endpoint *g_connecting = NULL; -static gpr_timespec test_deadline(void) { - return grpc_timeout_seconds_to_deadline(10); +static grpc_millis test_deadline(void) { + return grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); } static void finish_connection(grpc_exec_ctx *exec_ctx) { @@ -119,7 +119,6 @@ void test_succeeds(void) { GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), grpc_timeout_seconds_to_deadline(5)))); gpr_mu_unlock(g_mu); grpc_exec_ctx_flush(&exec_ctx); @@ -162,17 +161,17 @@ void test_fails(void) { while (g_connections_complete == connections_complete_before) { grpc_pollset_worker *worker = NULL; gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - gpr_timespec polling_deadline = test_deadline(); + grpc_millis polling_deadline = test_deadline(); switch (grpc_timer_check(&exec_ctx, now, &polling_deadline)) { case GRPC_TIMERS_FIRED: break; case GRPC_TIMERS_NOT_CHECKED: - polling_deadline = now; + polling_deadline = grpc_timespec_to_millis_round_up(now); /* fall through */ case GRPC_TIMERS_CHECKED_AND_EMPTY: GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, - now, polling_deadline))); + polling_deadline))); break; } gpr_mu_unlock(g_mu); diff --git a/test/core/iomgr/tcp_server_uv_test.c b/test/core/iomgr/tcp_server_uv_test.c index bd8ccb4f603..7bf5b868850 100644 --- a/test/core/iomgr/tcp_server_uv_test.c +++ b/test/core/iomgr/tcp_server_uv_test.c @@ -206,8 +206,7 @@ static void tcp_connect(grpc_exec_ctx *exec_ctx, const struct sockaddr *remote, grpc_pollset_worker *worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", - grpc_pollset_work(exec_ctx, g_pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), deadline))); + grpc_pollset_work(exec_ctx, g_pollset, &worker, deadline))); gpr_mu_unlock(g_mu); grpc_exec_ctx_finish(exec_ctx); gpr_mu_lock(g_mu); From 80297d7cd73b3d2101f23136527ece13d2bb55b9 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 6 Oct 2017 18:17:08 -0700 Subject: [PATCH 112/142] uv changes for grpc_pollset_work --- test/core/iomgr/tcp_client_uv_test.c | 5 +++-- test/core/iomgr/tcp_server_uv_test.c | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/test/core/iomgr/tcp_client_uv_test.c b/test/core/iomgr/tcp_client_uv_test.c index f94e589b8d7..edfccbe8678 100644 --- a/test/core/iomgr/tcp_client_uv_test.c +++ b/test/core/iomgr/tcp_client_uv_test.c @@ -119,7 +119,8 @@ void test_succeeds(void) { GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, - grpc_timeout_seconds_to_deadline(5)))); + grpc_timespec_to_millis_round_up( + grpc_timeout_seconds_to_deadline(5))))); gpr_mu_unlock(g_mu); grpc_exec_ctx_flush(&exec_ctx); gpr_mu_lock(g_mu); @@ -162,7 +163,7 @@ void test_fails(void) { grpc_pollset_worker *worker = NULL; gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); grpc_millis polling_deadline = test_deadline(); - switch (grpc_timer_check(&exec_ctx, now, &polling_deadline)) { + switch (grpc_timer_check(&exec_ctx, &polling_deadline)) { case GRPC_TIMERS_FIRED: break; case GRPC_TIMERS_NOT_CHECKED: diff --git a/test/core/iomgr/tcp_server_uv_test.c b/test/core/iomgr/tcp_server_uv_test.c index 7bf5b868850..04aca048ae3 100644 --- a/test/core/iomgr/tcp_server_uv_test.c +++ b/test/core/iomgr/tcp_server_uv_test.c @@ -189,7 +189,8 @@ static void close_cb(uv_handle_t *handle) { gpr_free(handle); } static void tcp_connect(grpc_exec_ctx *exec_ctx, const struct sockaddr *remote, socklen_t remote_len, on_connect_result *result) { - gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10); + grpc_millis deadline = + grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); uv_tcp_t *client_handle = gpr_malloc(sizeof(uv_tcp_t)); uv_connect_t *req = gpr_malloc(sizeof(uv_connect_t)); int nconnects_before; From 84bf2832181fe041e1ec0fe3816f1c9e7eef3eb4 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 6 Oct 2017 20:16:32 -0700 Subject: [PATCH 113/142] tcp_server_uv_test changes --- test/core/iomgr/tcp_server_uv_test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/core/iomgr/tcp_server_uv_test.c b/test/core/iomgr/tcp_server_uv_test.c index 04aca048ae3..9fafd3177a9 100644 --- a/test/core/iomgr/tcp_server_uv_test.c +++ b/test/core/iomgr/tcp_server_uv_test.c @@ -189,8 +189,7 @@ static void close_cb(uv_handle_t *handle) { gpr_free(handle); } static void tcp_connect(grpc_exec_ctx *exec_ctx, const struct sockaddr *remote, socklen_t remote_len, on_connect_result *result) { - grpc_millis deadline = - grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); + gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10); uv_tcp_t *client_handle = gpr_malloc(sizeof(uv_tcp_t)); uv_connect_t *req = gpr_malloc(sizeof(uv_connect_t)); int nconnects_before; @@ -207,7 +206,8 @@ static void tcp_connect(grpc_exec_ctx *exec_ctx, const struct sockaddr *remote, grpc_pollset_worker *worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", - grpc_pollset_work(exec_ctx, g_pollset, &worker, deadline))); + grpc_pollset_work(exec_ctx, g_pollset, &worker, + grpc_timespec_to_millis_round_up(deadline)))); gpr_mu_unlock(g_mu); grpc_exec_ctx_finish(exec_ctx); gpr_mu_lock(g_mu); @@ -246,7 +246,7 @@ static void test_connect(unsigned n) { GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_add_port(s, &resolved_addr, &svr_port)); GPR_ASSERT(svr_port > 0); - GPR_ASSERT(uv_ip6_addr("::", svr_port, (struct sockaddr_in6 *)addr) == 0); + GPR_ASSERT((uv_ip6_addr("::", svr_port, (struct sockaddr_in6 *)addr)) == 0); /* Cannot use wildcard (port==0), because add_port() will try to reuse the same port as a previous add_port(). */ svr1_port = grpc_pick_unused_port_or_die(); From b3b20f671db08c82424f4c9d55cdd82637e64f2f Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Fri, 6 Oct 2017 20:53:14 -0700 Subject: [PATCH 114/142] Adding PR #12879 changes --- src/core/lib/iomgr/timer_uv.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/timer_uv.cc b/src/core/lib/iomgr/timer_uv.cc index bd1e922c7f5..ccbbe357ae9 100644 --- a/src/core/lib/iomgr/timer_uv.cc +++ b/src/core/lib/iomgr/timer_uv.cc @@ -94,7 +94,7 @@ grpc_timer_check_result grpc_timer_check(grpc_exec_ctx *exec_ctx, return GRPC_TIMERS_NOT_CHECKED; } -void grpc_timer_list_init(gpr_timespec now) {} +void grpc_timer_list_init(grpc_exec_ctx *exec_ctx) {} void grpc_timer_list_shutdown(grpc_exec_ctx *exec_ctx) {} void grpc_timer_consume_kick(void) {} From 4e0fe5295e26fbafa7fd4932cd05864132835ea4 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Sun, 8 Oct 2017 18:07:15 -0700 Subject: [PATCH 115/142] Add grpc_posix.h header for grpc_use_signal declaration --- src/core/lib/iomgr/ev_epollsig_linux.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/lib/iomgr/ev_epollsig_linux.cc b/src/core/lib/iomgr/ev_epollsig_linux.cc index 370ea1d50bf..035bdc4cb55 100644 --- a/src/core/lib/iomgr/ev_epollsig_linux.cc +++ b/src/core/lib/iomgr/ev_epollsig_linux.cc @@ -18,6 +18,8 @@ #include "src/core/lib/iomgr/port.h" +#include + /* This polling engine is only relevant on linux kernels supporting epoll() */ #ifdef GRPC_LINUX_EPOLL From 83a2cc0c4452beb70b5cb17a45c2433459b46a20 Mon Sep 17 00:00:00 2001 From: Guilherme Oliveira Date: Mon, 9 Oct 2017 11:53:27 +0200 Subject: [PATCH 116/142] php return the right classes --- src/php/lib/Grpc/BaseStub.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/php/lib/Grpc/BaseStub.php b/src/php/lib/Grpc/BaseStub.php index b62c2c2fa96..67378a34a8a 100644 --- a/src/php/lib/Grpc/BaseStub.php +++ b/src/php/lib/Grpc/BaseStub.php @@ -218,7 +218,7 @@ class BaseStub * (optional) * @param array $options An array of options (optional) * - * @return SimpleSurfaceActiveCall The active call object + * @return UnaryCall The active call object */ protected function _simpleRequest($method, $argument, @@ -253,7 +253,7 @@ class BaseStub * (optional) * @param array $options An array of options (optional) * - * @return ClientStreamingSurfaceActiveCall The active call object + * @return ClientStreamingCall The active call object */ protected function _clientStreamRequest($method, $deserialize, @@ -288,7 +288,7 @@ class BaseStub * (optional) * @param array $options An array of options (optional) * - * @return ServerStreamingSurfaceActiveCall The active call object + * @return ServerStreamingCall The active call object */ protected function _serverStreamRequest($method, $argument, @@ -322,7 +322,7 @@ class BaseStub * (optional) * @param array $options An array of options (optional) * - * @return BidiStreamingSurfaceActiveCall The active call object + * @return BidiStreamingCall The active call object */ protected function _bidiRequest($method, $deserialize, From 97b6e5db9f91f974a9655cbd591046d8c3b61a07 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Mon, 9 Oct 2017 08:31:41 -0700 Subject: [PATCH 117/142] Process updates immediately instead of waiting for a previous one to complete. --- .../client_channel/lb_policy/grpclb/grpclb.cc | 55 +++---------------- 1 file changed, 7 insertions(+), 48 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 53fa0fff049..ffd58129c6e 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -345,9 +345,6 @@ typedef struct glb_lb_policy { /** are we currently updating lb_call? */ bool updating_lb_call; - /** are we currently updating lb_channel? */ - bool updating_lb_channel; - /** are we already watching the LB channel's connectivity? */ bool watching_lb_channel; @@ -360,9 +357,6 @@ typedef struct glb_lb_policy { /** called upon changes to the LB channel's connectivity. */ grpc_closure lb_channel_on_connectivity_changed; - /** args from the latest update received while already updating, or NULL */ - grpc_lb_policy_args *pending_update_args; - /************************************************************/ /* client data associated with the LB server communication */ /************************************************************/ @@ -982,10 +976,6 @@ static void glb_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) { } grpc_fake_resolver_response_generator_unref(glb_policy->response_generator); grpc_subchannel_index_unref(); - if (glb_policy->pending_update_args != NULL) { - grpc_channel_args_destroy(exec_ctx, glb_policy->pending_update_args->args); - gpr_free(glb_policy->pending_update_args); - } gpr_free(glb_policy); } @@ -1752,45 +1742,22 @@ static void glb_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy, } const grpc_lb_addresses *addresses = (const grpc_lb_addresses *)arg->value.pointer.p; - + // If a non-empty serverlist hasn't been received from the balancer, + // propagate the update to fallback_backend_addresses. if (glb_policy->serverlist == NULL) { - // If a non-empty serverlist hasn't been received from the balancer, - // propagate the update to fallback_backend_addresses. fallback_update_locked(exec_ctx, glb_policy, addresses); - } else if (glb_policy->updating_lb_channel) { - // If we have recieved serverlist from the balancer, we need to defer update - // when there is an in-progress one. - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { - gpr_log(GPR_INFO, - "Update already in progress for grpclb %p. Deferring update.", - (void *)glb_policy); - } - if (glb_policy->pending_update_args != NULL) { - grpc_channel_args_destroy(exec_ctx, - glb_policy->pending_update_args->args); - gpr_free(glb_policy->pending_update_args); - } - glb_policy->pending_update_args = (grpc_lb_policy_args *)gpr_zalloc( - sizeof(*glb_policy->pending_update_args)); - glb_policy->pending_update_args->client_channel_factory = - args->client_channel_factory; - glb_policy->pending_update_args->args = grpc_channel_args_copy(args->args); - glb_policy->pending_update_args->combiner = args->combiner; - return; } - - glb_policy->updating_lb_channel = true; GPR_ASSERT(glb_policy->lb_channel != NULL); + // Propagate updates to the LB channel (pick_first) through the fake + // resolver. grpc_channel_args *lb_channel_args = build_lb_channel_args( exec_ctx, addresses, glb_policy->response_generator, args->args); - /* Propagate updates to the LB channel (pick first) through the fake resolver - */ grpc_fake_resolver_response_generator_set_response( exec_ctx, glb_policy->response_generator, lb_channel_args); grpc_channel_args_destroy(exec_ctx, lb_channel_args); - + // Start watching the LB channel connectivity for connection, if not + // already doing so. if (!glb_policy->watching_lb_channel) { - // Watch the LB channel connectivity for connection. glb_policy->lb_channel_connectivity = grpc_channel_check_connectivity_state( glb_policy->lb_channel, true /* try to connect */); grpc_channel_element *client_channel_elem = grpc_channel_stack_last_element( @@ -1842,18 +1809,10 @@ static void glb_lb_channel_on_connectivity_changed_cb(grpc_exec_ctx *exec_ctx, /* fallthrough */ case GRPC_CHANNEL_READY: if (glb_policy->lb_call != NULL) { - glb_policy->updating_lb_channel = false; glb_policy->updating_lb_call = true; grpc_call_cancel(glb_policy->lb_call, NULL); - // lb_on_server_status_received will pick up the cancel and reinit + // lb_on_server_status_received() will pick up the cancel and reinit // lb_call. - if (glb_policy->pending_update_args != NULL) { - grpc_lb_policy_args *args = glb_policy->pending_update_args; - glb_policy->pending_update_args = NULL; - glb_update_locked(exec_ctx, &glb_policy->base, args); - grpc_channel_args_destroy(exec_ctx, args->args); - gpr_free(args); - } } else if (glb_policy->started_picking && !glb_policy->shutting_down) { if (glb_policy->retry_timer_active) { grpc_timer_cancel(exec_ctx, &glb_policy->lb_call_retry_timer); From a5ba0f991b81aefcaa976c4ec2cf6fa3e58160b2 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 9 Oct 2017 19:30:44 +0200 Subject: [PATCH 118/142] improve windows build instructions --- INSTALL.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index ea613f321de..15725bd188e 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -94,6 +94,7 @@ on experience with the tools involved. ### Building using CMake (RECOMMENDED) Builds gRPC C and C++ with boringssl. +- Install Visual Studio 2015 or 2017 (Visual C++ compiler will be used). - Install [CMake](https://cmake.org/download/). - Install [Active State Perl](https://www.activestate.com/activeperl/) (`choco install activeperl`) - Install [Ninja](https://ninja-build.org/) (`choco install ninja`) @@ -101,7 +102,9 @@ Builds gRPC C and C++ with boringssl. - Install [yasm](http://yasm.tortall.net/) and add it to `PATH` (`choco install yasm`) - Run these commands in the repo root directory -Using Ninja (faster build, supports boringssl's assembly optimizations) +#### cmake: Using Ninja (faster build, supports boringssl's assembly optimizations). +Please note that when using Ninja, you'll still need Visual C++ (part of Visual Studio) +installed to be able to compile the C/C++ sources. ``` > md .build > cd .build @@ -110,7 +113,12 @@ Using Ninja (faster build, supports boringssl's assembly optimizations) > cmake --build . ``` -Using Visual Studio 2015 (can only build with OPENSSL_NO_ASM) +#### cmake: Using Visual Studio 2015 (can only build with OPENSSL_NO_ASM). +When using the "Visual Studio" generator, +cmake will generate a solution (`grpc.sln`) that contains a VS project for +every target defined in `CMakeLists.txt` (+ few extra convenience projects +added automatically by cmake). After opening the solution with Visual Studio +you will be able to browse and build the code as usual. ``` > md .build > cd .build From 17acda35b775cb1dea076fe8692bfe7d5c8b2c63 Mon Sep 17 00:00:00 2001 From: Matt Kwong Date: Mon, 9 Oct 2017 11:26:53 -0700 Subject: [PATCH 119/142] Use Ruby 2.3 for Brew --- .../internal_ci/helper_scripts/prepare_build_macos_rc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/internal_ci/helper_scripts/prepare_build_macos_rc b/tools/internal_ci/helper_scripts/prepare_build_macos_rc index b6cc43e0ab0..8f2056096dc 100644 --- a/tools/internal_ci/helper_scripts/prepare_build_macos_rc +++ b/tools/internal_ci/helper_scripts/prepare_build_macos_rc @@ -40,11 +40,12 @@ pip install google-api-python-client --user python export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/GrpcTesting-d0eeee2db331.json # If this is a PR using RUN_TESTS_FLAGS var, then add flags to filter tests -if [ -n "$KOKORO_GITHUB_PULL_REQUEST_NUMBER" ] && [ -n "$RUN_TESTS_FLAGS" ]; then - brew install jq - ghprbTargetBranch=$(curl -s https://api.github.com/repos/grpc/grpc/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER | jq -r .base.ref) - export RUN_TESTS_FLAGS="$RUN_TESTS_FLAGS --filter_pr_tests --base_branch origin/$ghprbTargetBranch" -fi +# TODO(matt-kwong): enable after fixing brew issue +# if [ -n "$KOKORO_GITHUB_PULL_REQUEST_NUMBER" ] && [ -n "$RUN_TESTS_FLAGS" ]; then +# brew install jq +# ghprbTargetBranch=$(curl -s https://api.github.com/repos/grpc/grpc/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER | jq -r .base.ref) +# export RUN_TESTS_FLAGS="$RUN_TESTS_FLAGS --filter_pr_tests --base_branch origin/$ghprbTargetBranch" +# fi set +ex # rvm script is very verbose and exits with errorcode source $HOME/.rvm/scripts/rvm From 156e8bf617be6afa4cb3ba8b770713ead01616b1 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 9 Oct 2017 10:58:28 -0700 Subject: [PATCH 120/142] Make sure to accept expected tags exactly once --- test/cpp/end2end/async_end2end_test.cc | 32 +++++++++++++++----------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index f938aea40eb..a14b4d5295c 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -102,14 +102,23 @@ class Verifier { explicit Verifier(bool spin) : spin_(spin) {} // Expect sets the expected ok value for a specific tag Verifier& Expect(int i, bool expect_ok) { - expectations_[tag(i)] = expect_ok; + return ExpectUnless(i, expect_ok, false); + } + // ExpectUnless sets the expected ok value for a specific tag + // unless the tag was already marked seen (as a result of ExpectMaybe) + Verifier& ExpectUnless(int i, bool expect_ok, bool seen) { + if (!seen) { + expectations_[tag(i)] = expect_ok; + } return *this; } - // AcceptOnce sets the expected ok value for a specific tag, but does not + // ExpectMaybe sets the expected ok value for a specific tag, but does not // require it to appear // If it does, sets *seen to true - Verifier& AcceptOnce(int i, bool expect_ok, bool* seen) { - maybe_expectations_[tag(i)] = MaybeExpect{expect_ok, seen}; + Verifier& ExpectMaybe(int i, bool expect_ok, bool* seen) { + if (!*seen) { + maybe_expectations_[tag(i)] = MaybeExpect{expect_ok, seen}; + } return *this; } @@ -569,13 +578,13 @@ TEST_P(AsyncEnd2endTest, SimpleClientStreamingWithCoalescingApi) { Verifier(GetParam().disable_blocking) .Expect(2, true) - .AcceptOnce(3, true, &seen3) + .ExpectMaybe(3, true, &seen3) .Verify(cq_.get()); srv_stream.Read(&recv_request, tag(4)); Verifier(GetParam().disable_blocking) - .AcceptOnce(3, true, &seen3) + .ExpectUnless(3, true, seen3) .Expect(4, true) .Verify(cq_.get()); @@ -602,7 +611,6 @@ TEST_P(AsyncEnd2endTest, SimpleClientStreamingWithCoalescingApi) { EXPECT_EQ(send_response.message(), recv_response.message()); EXPECT_TRUE(recv_status.ok()); - EXPECT_TRUE(seen3); } // One ping, two pongs. @@ -853,13 +861,13 @@ TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWAF) { Verifier(GetParam().disable_blocking) .Expect(2, true) - .AcceptOnce(3, true, &seen3) + .ExpectMaybe(3, true, &seen3) .Verify(cq_.get()); srv_stream.Read(&recv_request, tag(4)); Verifier(GetParam().disable_blocking) - .AcceptOnce(3, true, &seen3) + .ExpectUnless(3, true, seen3) .Expect(4, true) .Verify(cq_.get()); EXPECT_EQ(send_request.message(), recv_request.message()); @@ -880,7 +888,6 @@ TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWAF) { Verifier(GetParam().disable_blocking).Expect(8, true).Verify(cq_.get()); EXPECT_TRUE(recv_status.ok()); - EXPECT_TRUE(seen3); } // One ping, one pong. Using server:WriteLast api @@ -910,13 +917,13 @@ TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWL) { Verifier(GetParam().disable_blocking) .Expect(2, true) - .AcceptOnce(3, true, &seen3) + .ExpectMaybe(3, true, &seen3) .Verify(cq_.get()); srv_stream.Read(&recv_request, tag(4)); Verifier(GetParam().disable_blocking) - .AcceptOnce(3, true, &seen3) + .ExpectUnless(3, true, seen3) .Expect(4, true) .Verify(cq_.get()); EXPECT_EQ(send_request.message(), recv_request.message()); @@ -939,7 +946,6 @@ TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWL) { Verifier(GetParam().disable_blocking).Expect(9, true).Verify(cq_.get()); EXPECT_TRUE(recv_status.ok()); - EXPECT_TRUE(seen3); } // Metadata tests From d137066be8c9527b5cea36132915619cc61cfc6d Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 9 Oct 2017 10:15:37 -0700 Subject: [PATCH 121/142] Add some details --- doc/core/moving-to-c++.md | 24 +++++++++++++++--------- tools/doxygen/Doxyfile.core | 1 + tools/doxygen/Doxyfile.core.internal | 1 + 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/doc/core/moving-to-c++.md b/doc/core/moving-to-c++.md index 33c3cfa0e66..4c745b38a90 100644 --- a/doc/core/moving-to-c++.md +++ b/doc/core/moving-to-c++.md @@ -6,14 +6,17 @@ ctiller, markdroth, vjpai ## Background and Goal -gRPC core was originally written in C89 for several reasons (possibility of -kernel integration, ease of wrapping, compiler support, etc). Over time, this -was changed to C99 as all relevant compilers in active use came to support C99 -effectively. Now, gRPC core is C++ (although the code is still idiomatically C -code) with C linkage for public functions. Throughout all of these transitions, -the public header files are committed to remain in C89. - -The goal now is to make gRPC core true idiomatic C++ compatible with +gRPC core was originally written in C89 for several reasons +(possibility of kernel integration, ease of wrapping, compiler +support, etc). Over time, this was changed to C99 as all relevant +compilers in active use came to support C99 effectively. +[Now, gRPC core is C++](https://github.com/grpc/proposal/blob/master/L6-allow-c%2B%2B-in-grpc-core.md) +(although the code is still idiomatically C code) with C linkage for +public functions. Throughout all of these transitions, the public +header files are committed to remain in C89. + +The goal now is to make the gRPC core implementation true idiomatic +C++ compatible with [Google's C++ style guide](https://google.github.io/styleguide/cppguide.html). ## Constraints @@ -48,7 +51,10 @@ The goal now is to make gRPC core true idiomatic C++ compatible with ## Implications for C++ API and wrapped languages -- For C++ structs, switch to `using` when possible (e.g., Slice, ByteBuffer, ...) +- For C++ structs, switch to `using` when possible (e.g., Slice, +ByteBuffer, ...) +- The C++ API implementation might directly start using +`grpc_transport_stream_op_batch` rather than the core surface `grpc_op`. - Can we get wrapped languages to a point where we can statically link C++? This will take a year in probability but that would allow the use of `std::` - Are there other environments that don't support std library, like maybe Android NDK? - Probably, that might push things out to 18 months diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index b8514fe3114..c8fd2ee48b2 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -772,6 +772,7 @@ doc/connection-backoff-interop-test-description.md \ doc/connection-backoff.md \ doc/connectivity-semantics-and-api.md \ doc/core/grpc-error.md \ +doc/core/moving-to-c++.md \ doc/core/pending_api_cleanups.md \ doc/cpp-style-guide.md \ doc/environment_variables.md \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index ee593e3ea09..3047778737b 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -772,6 +772,7 @@ doc/connection-backoff-interop-test-description.md \ doc/connection-backoff.md \ doc/connectivity-semantics-and-api.md \ doc/core/grpc-error.md \ +doc/core/moving-to-c++.md \ doc/core/pending_api_cleanups.md \ doc/cpp-style-guide.md \ doc/environment_variables.md \ From f6cd77c48d6d3a9579e8d27b8c140d6d674060f3 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 9 Oct 2017 13:28:00 -0700 Subject: [PATCH 122/142] Stability fixes --- test/cpp/qps/client.h | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index 7fbaf63492e..267a30c9f36 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -299,11 +299,14 @@ class Client { Thread& operator=(const Thread&); void ThreadFunc() { + int wait_loop = 0; while (!gpr_event_wait( &client_->start_requests_, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_seconds(1, GPR_TIMESPAN)))) { - gpr_log(GPR_INFO, "Waiting for benchmark to start"); + gpr_time_from_seconds(20, GPR_TIMESPAN)))) { + gpr_log(GPR_INFO, "%" PRIdPTR ": Waiting for benchmark to start (%d)", + idx_, wait_loop); + wait_loop++; } for (;;) { @@ -380,6 +383,13 @@ class ClientImpl : public Client { config.server_targets(i % config.server_targets_size()), config, create_stub_, i); } + std::vector> connecting_threads; + for (auto& c : channels_) { + connecting_threads.emplace_back(c.WaitForReady()); + } + for (auto& t : connecting_threads) { + t->join(); + } ClientRequestCreator create_req(&request_, config.payload_config()); @@ -414,14 +424,19 @@ class ClientImpl : public Client { !config.security_params().use_test_ca(), std::shared_ptr(), args); gpr_log(GPR_INFO, "Connecting to %s", target.c_str()); - GPR_ASSERT(channel_->WaitForConnected( - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_seconds(300, GPR_TIMESPAN)))); stub_ = create_stub(channel_); } Channel* get_channel() { return channel_.get(); } StubType* get_stub() { return stub_.get(); } + std::unique_ptr WaitForReady() { + return std::unique_ptr(new std::thread([this]() { + GPR_ASSERT(channel_->WaitForConnected( + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_seconds(10, GPR_TIMESPAN)))); + })); + } + private: void set_channel_args(const ClientConfig& config, ChannelArguments* args) { for (auto channel_arg : config.channel_args()) { From c18ad11837f44b3eb2de788306a142b454873d09 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 9 Oct 2017 13:44:10 -0700 Subject: [PATCH 123/142] Wait until all clients connected before starting streams --- test/cpp/qps/client.h | 3 ++ test/cpp/qps/client_async.cc | 1 + test/cpp/qps/client_sync.cc | 56 ++++++++++++++++++------------------ 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index 267a30c9f36..abf755b3935 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -226,6 +226,7 @@ class Client { } virtual void DestroyMultithreading() = 0; + virtual void InitThreadFunc(size_t thread_idx) = 0; virtual bool ThreadFunc(HistogramEntry* histogram, size_t thread_idx) = 0; void SetupLoadTest(const ClientConfig& config, size_t num_threads) { @@ -309,6 +310,8 @@ class Client { wait_loop++; } + client_->InitThreadFunc(idx_); + for (;;) { // run the loop body HistogramEntry entry; diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index f5807da81e3..9ed4e0b3552 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -236,6 +236,7 @@ class AsyncClient : public ClientImpl { this->EndThreads(); // this needed for resolution } + void InitThreadFunc(size_t thread_idx) override final {} bool ThreadFunc(HistogramEntry* entry, size_t thread_idx) override final { void* got_tag; bool ok; diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc index 5d212f1acc0..94554a46b20 100644 --- a/test/cpp/qps/client_sync.cc +++ b/test/cpp/qps/client_sync.cc @@ -103,6 +103,8 @@ class SynchronousUnaryClient final : public SynchronousClient { } ~SynchronousUnaryClient() {} + void InitThreadFunc(size_t thread_idx) override {} + bool ThreadFunc(HistogramEntry* entry, size_t thread_idx) override { if (!WaitToIssue(thread_idx)) { return true; @@ -174,13 +176,7 @@ class SynchronousStreamingPingPongClient final grpc::ClientReaderWriter> { public: SynchronousStreamingPingPongClient(const ClientConfig& config) - : SynchronousStreamingClient(config) { - for (size_t thread_idx = 0; thread_idx < num_threads_; thread_idx++) { - auto* stub = channels_[thread_idx % channels_.size()].get_stub(); - stream_[thread_idx] = stub->StreamingCall(&context_[thread_idx]); - messages_issued_[thread_idx] = 0; - } - } + : SynchronousStreamingClient(config) {} ~SynchronousStreamingPingPongClient() { std::vector cleanup_threads; for (size_t i = 0; i < num_threads_; i++) { @@ -196,6 +192,12 @@ class SynchronousStreamingPingPongClient final } } + void InitThreadFunc(size_t thread_idx) override { + auto* stub = channels_[thread_idx % channels_.size()].get_stub(); + stream_[thread_idx] = stub->StreamingCall(&context_[thread_idx]); + messages_issued_[thread_idx] = 0; + } + bool ThreadFunc(HistogramEntry* entry, size_t thread_idx) override { if (!WaitToIssue(thread_idx)) { return true; @@ -228,14 +230,7 @@ class SynchronousStreamingFromClientClient final : public SynchronousStreamingClient> { public: SynchronousStreamingFromClientClient(const ClientConfig& config) - : SynchronousStreamingClient(config), last_issue_(num_threads_) { - for (size_t thread_idx = 0; thread_idx < num_threads_; thread_idx++) { - auto* stub = channels_[thread_idx % channels_.size()].get_stub(); - stream_[thread_idx] = stub->StreamingFromClient(&context_[thread_idx], - &responses_[thread_idx]); - last_issue_[thread_idx] = UsageTimer::Now(); - } - } + : SynchronousStreamingClient(config), last_issue_(num_threads_) {} ~SynchronousStreamingFromClientClient() { std::vector cleanup_threads; for (size_t i = 0; i < num_threads_; i++) { @@ -251,6 +246,13 @@ class SynchronousStreamingFromClientClient final } } + void InitThreadFunc(size_t thread_idx) override { + auto* stub = channels_[thread_idx % channels_.size()].get_stub(); + stream_[thread_idx] = stub->StreamingFromClient(&context_[thread_idx], + &responses_[thread_idx]); + last_issue_[thread_idx] = UsageTimer::Now(); + } + bool ThreadFunc(HistogramEntry* entry, size_t thread_idx) override { // Figure out how to make histogram sensible if this is rate-paced if (!WaitToIssue(thread_idx)) { @@ -279,13 +281,12 @@ class SynchronousStreamingFromServerClient final : public SynchronousStreamingClient> { public: SynchronousStreamingFromServerClient(const ClientConfig& config) - : SynchronousStreamingClient(config), last_recv_(num_threads_) { - for (size_t thread_idx = 0; thread_idx < num_threads_; thread_idx++) { - auto* stub = channels_[thread_idx % channels_.size()].get_stub(); - stream_[thread_idx] = - stub->StreamingFromServer(&context_[thread_idx], request_); - last_recv_[thread_idx] = UsageTimer::Now(); - } + : SynchronousStreamingClient(config), last_recv_(num_threads_) {} + void InitThreadFunc(size_t thread_idx) override { + auto* stub = channels_[thread_idx % channels_.size()].get_stub(); + stream_[thread_idx] = + stub->StreamingFromServer(&context_[thread_idx], request_); + last_recv_[thread_idx] = UsageTimer::Now(); } bool ThreadFunc(HistogramEntry* entry, size_t thread_idx) override { GPR_TIMER_SCOPE("SynchronousStreamingFromServerClient::ThreadFunc", 0); @@ -311,12 +312,7 @@ class SynchronousStreamingBothWaysClient final grpc::ClientReaderWriter> { public: SynchronousStreamingBothWaysClient(const ClientConfig& config) - : SynchronousStreamingClient(config) { - for (size_t thread_idx = 0; thread_idx < num_threads_; thread_idx++) { - auto* stub = channels_[thread_idx % channels_.size()].get_stub(); - stream_[thread_idx] = stub->StreamingBothWays(&context_[thread_idx]); - } - } + : SynchronousStreamingClient(config) {} ~SynchronousStreamingBothWaysClient() { std::vector cleanup_threads; for (size_t i = 0; i < num_threads_; i++) { @@ -332,6 +328,10 @@ class SynchronousStreamingBothWaysClient final } } + void InitThreadFunc(size_t thread_idx) override { + auto* stub = channels_[thread_idx % channels_.size()].get_stub(); + stream_[thread_idx] = stub->StreamingBothWays(&context_[thread_idx]); + } bool ThreadFunc(HistogramEntry* entry, size_t thread_idx) override { // TODO (vjpai): Do this return true; From c8089f349f9e90b9ba526ae7563ecdaa2cf083f2 Mon Sep 17 00:00:00 2001 From: Matt Kwong Date: Fri, 6 Oct 2017 14:55:40 -0700 Subject: [PATCH 124/142] Clean up and organize interop configs in internal_ci --- .../helper_scripts/prepare_build_linux_rc | 7 ---- .../linux/grpc_interop_badserver_python.sh | 27 -------------- .../linux/grpc_interop_tocloud.cfg | 8 +++- .../internal_ci/linux/grpc_interop_tocloud.sh | 31 ---------------- .../internal_ci/linux/grpc_interop_toprod.cfg | 7 +++- .../internal_ci/linux/grpc_interop_toprod.sh | 37 ------------------- ...rver_java.sh => grpc_run_interop_tests.sh} | 5 +-- .../linux/grpc_run_tests_matrix.sh | 7 ++++ .../grpc_interop_tocloud.cfg} | 12 ++++-- .../grpc_interop_toprod.cfg} | 12 ++++-- 10 files changed, 36 insertions(+), 117 deletions(-) delete mode 100755 tools/internal_ci/linux/grpc_interop_badserver_python.sh delete mode 100755 tools/internal_ci/linux/grpc_interop_tocloud.sh delete mode 100755 tools/internal_ci/linux/grpc_interop_toprod.sh rename tools/internal_ci/linux/{grpc_interop_badserver_java.sh => grpc_run_interop_tests.sh} (88%) rename tools/internal_ci/linux/{grpc_interop_badserver_java.cfg => pull_request/grpc_interop_tocloud.cfg} (76%) rename tools/internal_ci/linux/{grpc_interop_badserver_python.cfg => pull_request/grpc_interop_toprod.cfg} (72%) diff --git a/tools/internal_ci/helper_scripts/prepare_build_linux_rc b/tools/internal_ci/helper_scripts/prepare_build_linux_rc index 2ade8dac51f..ea2a17f2bcf 100644 --- a/tools/internal_ci/helper_scripts/prepare_build_linux_rc +++ b/tools/internal_ci/helper_scripts/prepare_build_linux_rc @@ -32,11 +32,4 @@ PYTHONWARNINGS=ignore XDG_CACHE_HOME=/tmp/xdg-cache-home sudo -E pip install cov # Download Docker images from DockerHub export DOCKERHUB_ORGANIZATION=grpctesting -# If this is a PR using RUN_TESTS_FLAGS var, then add flags to filter tests -if [ -n "$KOKORO_GITHUB_PULL_REQUEST_NUMBER" ] && [ -n "$RUN_TESTS_FLAGS" ]; then - sudo apt-get install -y jq - ghprbTargetBranch=$(curl -s https://api.github.com/repos/grpc/grpc/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER | jq -r .base.ref) - export RUN_TESTS_FLAGS="$RUN_TESTS_FLAGS --filter_pr_tests --base_branch origin/$ghprbTargetBranch" -fi - git submodule update --init diff --git a/tools/internal_ci/linux/grpc_interop_badserver_python.sh b/tools/internal_ci/linux/grpc_interop_badserver_python.sh deleted file mode 100755 index c2bd4e79ac1..00000000000 --- a/tools/internal_ci/linux/grpc_interop_badserver_python.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -ex - -export LANG=en_US.UTF-8 - -# Enter the gRPC repo root -cd $(dirname $0)/../../.. - -source tools/internal_ci/helper_scripts/prepare_build_linux_rc -source tools/internal_ci/helper_scripts/prepare_build_interop_rc - -tools/run_tests/run_interop_tests.py -l python --use_docker --http2_server_interop - diff --git a/tools/internal_ci/linux/grpc_interop_tocloud.cfg b/tools/internal_ci/linux/grpc_interop_tocloud.cfg index 2803616007a..13aec15770b 100644 --- a/tools/internal_ci/linux/grpc_interop_tocloud.cfg +++ b/tools/internal_ci/linux/grpc_interop_tocloud.cfg @@ -15,8 +15,7 @@ # Config file for the internal CI (in protobuf text format) # Location of the continuous shell script in repository. -build_file: "grpc/tools/internal_ci/linux/grpc_interop_tocloud.sh" -# grpc_interop tests can take 6+ hours to complete. +build_file: "grpc/tools/internal_ci/linux/grpc_run_interop_tests.sh" timeout_mins: 60 action { define_artifacts { @@ -24,3 +23,8 @@ action { regex: "github/grpc/reports/**" } } + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-l all -s all --use_docker --http2_interop --internal_ci -t -j 12 --bq_result_table interop_results" +} diff --git a/tools/internal_ci/linux/grpc_interop_tocloud.sh b/tools/internal_ci/linux/grpc_interop_tocloud.sh deleted file mode 100755 index c69c3fbea88..00000000000 --- a/tools/internal_ci/linux/grpc_interop_tocloud.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -ex - -export LANG=en_US.UTF-8 - -# Enter the gRPC repo root -cd $(dirname $0)/../../.. - -source tools/internal_ci/helper_scripts/prepare_build_linux_rc -source tools/internal_ci/helper_scripts/prepare_build_interop_rc - -tools/run_tests/run_interop_tests.py \ - -l all \ - -s all \ - --use_docker \ - --bq_result_table interop_test \ - --http2_interop --internal_ci -t -j 12 $@ diff --git a/tools/internal_ci/linux/grpc_interop_toprod.cfg b/tools/internal_ci/linux/grpc_interop_toprod.cfg index 903480a3d18..8d025c4f60d 100644 --- a/tools/internal_ci/linux/grpc_interop_toprod.cfg +++ b/tools/internal_ci/linux/grpc_interop_toprod.cfg @@ -15,8 +15,7 @@ # Config file for the internal CI (in protobuf text format) # Location of the continuous shell script in repository. -build_file: "grpc/tools/internal_ci/linux/grpc_interop_toprod.sh" -# grpc_interop tests can take 6+ hours to complete. +build_file: "grpc/tools/internal_ci/linux/grpc_run_interop_tests.sh" timeout_mins: 60 action { define_artifacts { @@ -25,3 +24,7 @@ action { } } +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-l all --cloud_to_prod --cloud_to_prod_auth --prod_servers default gateway_v4 --use_docker --internal_ci -t -j 12 --bq_result_table interop_results" +} diff --git a/tools/internal_ci/linux/grpc_interop_toprod.sh b/tools/internal_ci/linux/grpc_interop_toprod.sh deleted file mode 100755 index 4f6fcf87dde..00000000000 --- a/tools/internal_ci/linux/grpc_interop_toprod.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -ex - -export LANG=en_US.UTF-8 - -# Enter the gRPC repo root -cd $(dirname $0)/../../.. - -source tools/internal_ci/helper_scripts/prepare_build_linux_rc -source tools/internal_ci/helper_scripts/prepare_build_interop_rc - -tools/run_tests/run_interop_tests.py \ - -l all \ - --cloud_to_prod \ - --cloud_to_prod_auth \ - --prod_servers default gateway_v4 \ -<<<<<<< HEAD - --use_docker --internal_ci --allow_flakes -t -j 12 $@ -======= - --bq_result_table interop_test \ - --use_docker --internal_ci -t -j 12 $@ ->>>>>>> Add uploading interop result to BQ - diff --git a/tools/internal_ci/linux/grpc_interop_badserver_java.sh b/tools/internal_ci/linux/grpc_run_interop_tests.sh similarity index 88% rename from tools/internal_ci/linux/grpc_interop_badserver_java.sh rename to tools/internal_ci/linux/grpc_run_interop_tests.sh index d25845ca507..1f4eda2d529 100755 --- a/tools/internal_ci/linux/grpc_interop_badserver_java.sh +++ b/tools/internal_ci/linux/grpc_run_interop_tests.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # Copyright 2017 gRPC authors. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,5 +23,4 @@ cd $(dirname $0)/../../.. source tools/internal_ci/helper_scripts/prepare_build_linux_rc source tools/internal_ci/helper_scripts/prepare_build_interop_rc -tools/run_tests/run_interop_tests.py -l java --use_docker --http2_server_interop - +tools/run_tests/run_interop_tests.py $RUN_TESTS_FLAGS diff --git a/tools/internal_ci/linux/grpc_run_tests_matrix.sh b/tools/internal_ci/linux/grpc_run_tests_matrix.sh index bd1430b7415..1018708f967 100755 --- a/tools/internal_ci/linux/grpc_run_tests_matrix.sh +++ b/tools/internal_ci/linux/grpc_run_tests_matrix.sh @@ -20,6 +20,13 @@ cd $(dirname $0)/../../.. source tools/internal_ci/helper_scripts/prepare_build_linux_rc +# If this is a PR using RUN_TESTS_FLAGS var, then add flags to filter tests +if [ -n "$KOKORO_GITHUB_PULL_REQUEST_NUMBER" ] && [ -n "$RUN_TESTS_FLAGS" ]; then + sudo apt-get install -y jq + ghprbTargetBranch=$(curl -s https://api.github.com/repos/grpc/grpc/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER | jq -r .base.ref) + export RUN_TESTS_FLAGS="$RUN_TESTS_FLAGS --filter_pr_tests --base_branch origin/$ghprbTargetBranch" +fi + tools/run_tests/run_tests_matrix.py $RUN_TESTS_FLAGS || FAILED="true" # Reveal leftover processes that might be left behind by the build diff --git a/tools/internal_ci/linux/grpc_interop_badserver_java.cfg b/tools/internal_ci/linux/pull_request/grpc_interop_tocloud.cfg similarity index 76% rename from tools/internal_ci/linux/grpc_interop_badserver_java.cfg rename to tools/internal_ci/linux/pull_request/grpc_interop_tocloud.cfg index dc2114273ea..cb18e8e8682 100644 --- a/tools/internal_ci/linux/grpc_interop_badserver_java.cfg +++ b/tools/internal_ci/linux/pull_request/grpc_interop_tocloud.cfg @@ -15,12 +15,16 @@ # Config file for the internal CI (in protobuf text format) # Location of the continuous shell script in repository. -build_file: "grpc/tools/internal_ci/linux/grpc_interop_badserver_java.sh" -# grpc_interop tests can take 6+ hours to complete. -timeout_mins: 480 +build_file: "grpc/tools/internal_ci/linux/grpc_run_interop_tests.sh" +timeout_mins: 60 action { define_artifacts { - regex: "**/report.xml" + regex: "**/sponge_log.xml" regex: "github/grpc/reports/**" } } + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-l all -s all --use_docker --http2_interop --internal_ci -t -j 12" +} diff --git a/tools/internal_ci/linux/grpc_interop_badserver_python.cfg b/tools/internal_ci/linux/pull_request/grpc_interop_toprod.cfg similarity index 72% rename from tools/internal_ci/linux/grpc_interop_badserver_python.cfg rename to tools/internal_ci/linux/pull_request/grpc_interop_toprod.cfg index ec738fcf74a..e141d9f6486 100644 --- a/tools/internal_ci/linux/grpc_interop_badserver_python.cfg +++ b/tools/internal_ci/linux/pull_request/grpc_interop_toprod.cfg @@ -15,12 +15,16 @@ # Config file for the internal CI (in protobuf text format) # Location of the continuous shell script in repository. -build_file: "grpc/tools/internal_ci/linux/grpc_interop_badserver_python.sh" -# grpc_interop tests can take 6+ hours to complete. -timeout_mins: 480 +build_file: "grpc/tools/internal_ci/linux/grpc_run_interop_tests.sh" +timeout_mins: 60 action { define_artifacts { - regex: "**/report.xml" + regex: "**/sponge_log.xml" regex: "github/grpc/reports/**" } } + +env_vars { + key: "RUN_TESTS_FLAGS" + value: "-l all --allow_flakes --cloud_to_prod --cloud_to_prod_auth --prod_servers default gateway_v4 --use_docker --internal_ci -t -j 12" +} From 12fc6d461e7d8bf37bf0c858164af8b4cad3058c Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 9 Oct 2017 16:43:34 -0700 Subject: [PATCH 125/142] Add newline at the end of src/core headers that did not have it --- src/core/ext/census/base_resources.h | 2 +- src/core/ext/census/census_interface.h | 2 +- src/core/ext/census/census_log.h | 2 +- src/core/ext/census/hash_table.h | 2 +- src/core/ext/census/mlog.h | 2 +- src/core/ext/census/resource.h | 2 +- src/core/ext/census/trace_context.h | 2 +- src/core/ext/census/trace_propagation.h | 2 +- src/core/ext/census/tracing.h | 2 +- src/core/ext/census/window_stats.h | 2 +- src/core/ext/filters/client_channel/client_channel.h | 2 +- src/core/ext/filters/client_channel/client_channel_factory.h | 2 +- src/core/ext/filters/client_channel/connector.h | 2 +- src/core/ext/filters/client_channel/http_connect_handshaker.h | 2 +- src/core/ext/filters/client_channel/http_proxy.h | 2 +- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h | 2 +- src/core/ext/filters/client_channel/lb_policy_factory.h | 2 +- src/core/ext/filters/client_channel/lb_policy_registry.h | 2 +- src/core/ext/filters/client_channel/parse_address.h | 2 +- src/core/ext/filters/client_channel/proxy_mapper.h | 2 +- src/core/ext/filters/client_channel/proxy_mapper_registry.h | 2 +- src/core/ext/filters/client_channel/resolver_factory.h | 2 +- src/core/ext/filters/client_channel/resolver_registry.h | 2 +- src/core/ext/filters/client_channel/retry_throttle.h | 2 +- src/core/ext/filters/client_channel/subchannel_index.h | 2 +- src/core/ext/filters/client_channel/uri_parser.h | 2 +- src/core/ext/filters/deadline/deadline_filter.h | 2 +- src/core/ext/filters/workarounds/workaround_utils.h | 2 +- src/core/ext/transport/chttp2/alpn/alpn.h | 2 +- src/core/ext/transport/chttp2/server/chttp2_server.h | 2 +- src/core/ext/transport/chttp2/transport/bin_decoder.h | 2 +- src/core/ext/transport/chttp2/transport/bin_encoder.h | 2 +- src/core/ext/transport/chttp2/transport/frame_data.h | 2 +- src/core/ext/transport/chttp2/transport/frame_goaway.h | 2 +- src/core/ext/transport/chttp2/transport/frame_ping.h | 2 +- src/core/ext/transport/chttp2/transport/frame_rst_stream.h | 2 +- src/core/ext/transport/chttp2/transport/frame_settings.h | 2 +- src/core/ext/transport/chttp2/transport/frame_window_update.h | 2 +- src/core/ext/transport/chttp2/transport/hpack_encoder.h | 2 +- src/core/ext/transport/chttp2/transport/hpack_parser.h | 2 +- src/core/ext/transport/chttp2/transport/http2_settings.h | 2 +- src/core/ext/transport/chttp2/transport/incoming_metadata.h | 2 +- src/core/ext/transport/chttp2/transport/stream_map.h | 2 +- src/core/lib/channel/channel_args.h | 2 +- src/core/lib/channel/connected_channel.h | 2 +- src/core/lib/channel/handshaker.h | 2 +- src/core/lib/channel/handshaker_factory.h | 2 +- src/core/lib/channel/handshaker_registry.h | 2 +- src/core/lib/compression/algorithm_metadata.h | 2 +- src/core/lib/compression/message_compress.h | 2 +- src/core/lib/http/format_request.h | 2 +- src/core/lib/http/httpcli.h | 2 +- src/core/lib/http/parser.h | 2 +- src/core/lib/iomgr/endpoint.h | 2 +- src/core/lib/iomgr/endpoint_pair.h | 2 +- src/core/lib/iomgr/error_internal.h | 2 +- src/core/lib/iomgr/ev_epoll1_linux.h | 2 +- src/core/lib/iomgr/ev_epollex_linux.h | 2 +- src/core/lib/iomgr/ev_poll_posix.h | 2 +- src/core/lib/iomgr/ev_posix.h | 2 +- src/core/lib/iomgr/executor.h | 2 +- src/core/lib/iomgr/iocp_windows.h | 2 +- src/core/lib/iomgr/iomgr.h | 2 +- src/core/lib/iomgr/iomgr_internal.h | 2 +- src/core/lib/iomgr/is_epollexclusive_available.h | 2 +- src/core/lib/iomgr/lockfree_event.h | 2 +- src/core/lib/iomgr/network_status_tracker.h | 2 +- src/core/lib/iomgr/polling_entity.h | 2 +- src/core/lib/iomgr/pollset_set.h | 2 +- src/core/lib/iomgr/pollset_uv.h | 2 +- src/core/lib/iomgr/pollset_windows.h | 2 +- src/core/lib/iomgr/resolve_address.h | 2 +- src/core/lib/iomgr/resource_quota.h | 2 +- src/core/lib/iomgr/sockaddr_utils.h | 2 +- src/core/lib/iomgr/socket_utils.h | 2 +- src/core/lib/iomgr/socket_utils_posix.h | 2 +- src/core/lib/iomgr/socket_windows.h | 2 +- src/core/lib/iomgr/tcp_client.h | 2 +- src/core/lib/iomgr/tcp_client_posix.h | 2 +- src/core/lib/iomgr/tcp_posix.h | 2 +- src/core/lib/iomgr/tcp_server.h | 2 +- src/core/lib/iomgr/tcp_server_utils_posix.h | 2 +- src/core/lib/iomgr/tcp_uv.h | 2 +- src/core/lib/iomgr/time_averaged_stats.h | 2 +- src/core/lib/iomgr/timer_heap.h | 2 +- src/core/lib/iomgr/timer_manager.h | 2 +- src/core/lib/iomgr/udp_server.h | 2 +- src/core/lib/iomgr/unix_sockets_posix.h | 2 +- src/core/lib/json/json.h | 2 +- src/core/lib/json/json_reader.h | 2 +- src/core/lib/json/json_writer.h | 2 +- src/core/lib/security/credentials/fake/fake_credentials.h | 2 +- src/core/lib/security/credentials/jwt/jwt_credentials.h | 2 +- src/core/lib/security/credentials/oauth2/oauth2_credentials.h | 2 +- src/core/lib/security/transport/lb_targets_info.h | 2 +- src/core/lib/security/transport/secure_endpoint.h | 2 +- src/core/lib/security/transport/security_handshaker.h | 2 +- src/core/lib/security/transport/tsi_error.h | 2 +- src/core/lib/security/util/json_util.h | 2 +- src/core/lib/slice/b64.h | 2 +- src/core/lib/slice/percent_encoding.h | 2 +- src/core/lib/slice/slice_hash_table.h | 2 +- src/core/lib/slice/slice_internal.h | 2 +- src/core/lib/slice/slice_traits.h | 2 +- src/core/lib/surface/channel_stack_type.h | 2 +- src/core/lib/surface/completion_queue_factory.h | 2 +- src/core/lib/surface/event_string.h | 2 +- src/core/lib/surface/init.h | 2 +- src/core/lib/surface/server.h | 2 +- src/core/lib/surface/validate_metadata.h | 2 +- src/core/lib/transport/bdp_estimator.h | 2 +- src/core/lib/transport/byte_stream.h | 2 +- src/core/lib/transport/connectivity_state.h | 2 +- src/core/lib/transport/error_utils.h | 2 +- src/core/lib/transport/pid_controller.h | 2 +- src/core/lib/transport/service_config.h | 2 +- src/core/lib/transport/status_conversion.h | 2 +- src/core/lib/transport/timeout_encoding.h | 2 +- src/core/lib/transport/transport_impl.h | 2 +- src/core/tsi/gts_transport_security.h | 2 +- 120 files changed, 120 insertions(+), 120 deletions(-) diff --git a/src/core/ext/census/base_resources.h b/src/core/ext/census/base_resources.h index 4b1b988e3f7..d24923b5970 100644 --- a/src/core/ext/census/base_resources.h +++ b/src/core/ext/census/base_resources.h @@ -29,4 +29,4 @@ void define_base_resources(); } #endif -#endif /* GRPC_CORE_EXT_CENSUS_BASE_RESOURCES_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_BASE_RESOURCES_H */ diff --git a/src/core/ext/census/census_interface.h b/src/core/ext/census/census_interface.h index 12438e3c0a6..113c2b16efb 100644 --- a/src/core/ext/census/census_interface.h +++ b/src/core/ext/census/census_interface.h @@ -66,4 +66,4 @@ void census_tracing_end_op(census_op_id op_id); } #endif -#endif /* GRPC_CORE_EXT_CENSUS_CENSUS_INTERFACE_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_CENSUS_INTERFACE_H */ diff --git a/src/core/ext/census/census_log.h b/src/core/ext/census/census_log.h index cc9e008907f..ee336ae733d 100644 --- a/src/core/ext/census/census_log.h +++ b/src/core/ext/census/census_log.h @@ -81,4 +81,4 @@ int census_log_out_of_space_count(void); } #endif -#endif /* GRPC_CORE_EXT_CENSUS_CENSUS_LOG_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_CENSUS_LOG_H */ diff --git a/src/core/ext/census/hash_table.h b/src/core/ext/census/hash_table.h index c22ba8df9de..c3ed94ea14c 100644 --- a/src/core/ext/census/hash_table.h +++ b/src/core/ext/census/hash_table.h @@ -121,4 +121,4 @@ uint64_t census_ht_for_all(const census_ht *ht, census_ht_itr_cb); } #endif -#endif /* GRPC_CORE_EXT_CENSUS_HASH_TABLE_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_HASH_TABLE_H */ diff --git a/src/core/ext/census/mlog.h b/src/core/ext/census/mlog.h index 7b4d39272b3..8f74ba231db 100644 --- a/src/core/ext/census/mlog.h +++ b/src/core/ext/census/mlog.h @@ -85,4 +85,4 @@ int64_t census_log_out_of_space_count(void); } #endif -#endif /* GRPC_CORE_EXT_CENSUS_MLOG_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_MLOG_H */ diff --git a/src/core/ext/census/resource.h b/src/core/ext/census/resource.h index 5f7ac2ad27a..56aaaaf750e 100644 --- a/src/core/ext/census/resource.h +++ b/src/core/ext/census/resource.h @@ -53,4 +53,4 @@ int32_t define_resource(const resource *base); } #endif -#endif /* GRPC_CORE_EXT_CENSUS_RESOURCE_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_RESOURCE_H */ diff --git a/src/core/ext/census/trace_context.h b/src/core/ext/census/trace_context.h index c707c632633..2b828ba4da1 100644 --- a/src/core/ext/census/trace_context.h +++ b/src/core/ext/census/trace_context.h @@ -61,4 +61,4 @@ bool decode_trace_context(google_trace_TraceContext *ctxt, uint8_t *buffer, } #endif -#endif /* GRPC_CORE_EXT_CENSUS_TRACE_CONTEXT_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_TRACE_CONTEXT_H */ diff --git a/src/core/ext/census/trace_propagation.h b/src/core/ext/census/trace_propagation.h index 3394e9e0fd3..e05fd23a1fb 100644 --- a/src/core/ext/census/trace_propagation.h +++ b/src/core/ext/census/trace_propagation.h @@ -53,4 +53,4 @@ size_t http_format_to_trace_span_context(const char *buf, size_t buf_size, } #endif -#endif /* GRPC_CORE_EXT_CENSUS_TRACE_PROPAGATION_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_TRACE_PROPAGATION_H */ diff --git a/src/core/ext/census/tracing.h b/src/core/ext/census/tracing.h index 5fcbb1e1f76..0690de8655c 100644 --- a/src/core/ext/census/tracing.h +++ b/src/core/ext/census/tracing.h @@ -114,4 +114,4 @@ void trace_end_span(const trace_status *status, trace_span_context *span_ctxt); } #endif -#endif /* GRPC_CORE_EXT_CENSUS_TRACING_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_TRACING_H */ diff --git a/src/core/ext/census/window_stats.h b/src/core/ext/census/window_stats.h index 3b1d197f76a..2a1d6d0d167 100644 --- a/src/core/ext/census/window_stats.h +++ b/src/core/ext/census/window_stats.h @@ -163,4 +163,4 @@ void census_window_stats_destroy(struct census_window_stats *wstats); } #endif -#endif /* GRPC_CORE_EXT_CENSUS_WINDOW_STATS_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_WINDOW_STATS_H */ diff --git a/src/core/ext/filters/client_channel/client_channel.h b/src/core/ext/filters/client_channel/client_channel.h index b32f378c6ca..152fe2365af 100644 --- a/src/core/ext/filters/client_channel/client_channel.h +++ b/src/core/ext/filters/client_channel/client_channel.h @@ -60,4 +60,4 @@ grpc_subchannel_call *grpc_client_channel_get_subchannel_call( } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CLIENT_CHANNEL_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CLIENT_CHANNEL_H */ diff --git a/src/core/ext/filters/client_channel/client_channel_factory.h b/src/core/ext/filters/client_channel/client_channel_factory.h index bad8b970425..4273c900583 100644 --- a/src/core/ext/filters/client_channel/client_channel_factory.h +++ b/src/core/ext/filters/client_channel/client_channel_factory.h @@ -82,4 +82,4 @@ grpc_arg grpc_client_channel_factory_create_channel_arg( } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CLIENT_CHANNEL_FACTORY_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CLIENT_CHANNEL_FACTORY_H */ diff --git a/src/core/ext/filters/client_channel/connector.h b/src/core/ext/filters/client_channel/connector.h index b91c93e446f..b71e0aab004 100644 --- a/src/core/ext/filters/client_channel/connector.h +++ b/src/core/ext/filters/client_channel/connector.h @@ -78,4 +78,4 @@ void grpc_connector_shutdown(grpc_exec_ctx *exec_ctx, grpc_connector *connector, } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CONNECTOR_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CONNECTOR_H */ diff --git a/src/core/ext/filters/client_channel/http_connect_handshaker.h b/src/core/ext/filters/client_channel/http_connect_handshaker.h index 5042c61becd..05a23cdba34 100644 --- a/src/core/ext/filters/client_channel/http_connect_handshaker.h +++ b/src/core/ext/filters/client_channel/http_connect_handshaker.h @@ -39,4 +39,4 @@ void grpc_http_connect_register_handshaker_factory(); } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_HTTP_CONNECT_HANDSHAKER_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_HTTP_CONNECT_HANDSHAKER_H */ diff --git a/src/core/ext/filters/client_channel/http_proxy.h b/src/core/ext/filters/client_channel/http_proxy.h index 65d52334af2..bdad03def31 100644 --- a/src/core/ext/filters/client_channel/http_proxy.h +++ b/src/core/ext/filters/client_channel/http_proxy.h @@ -29,4 +29,4 @@ void grpc_register_http_proxy_mapper(); } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_HTTP_PROXY_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_HTTP_PROXY_H */ diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h index c67df609fc2..15c8a680b73 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h @@ -34,4 +34,4 @@ grpc_lb_policy_factory *grpc_glb_lb_factory_create(); } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_GRPCLB_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_GRPCLB_H */ diff --git a/src/core/ext/filters/client_channel/lb_policy_factory.h b/src/core/ext/filters/client_channel/lb_policy_factory.h index 69bcba42323..8790ffdda31 100644 --- a/src/core/ext/filters/client_channel/lb_policy_factory.h +++ b/src/core/ext/filters/client_channel/lb_policy_factory.h @@ -138,4 +138,4 @@ grpc_lb_policy *grpc_lb_policy_factory_create_lb_policy( } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_FACTORY_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_FACTORY_H */ diff --git a/src/core/ext/filters/client_channel/lb_policy_registry.h b/src/core/ext/filters/client_channel/lb_policy_registry.h index 0867844c371..55154cb02a1 100644 --- a/src/core/ext/filters/client_channel/lb_policy_registry.h +++ b/src/core/ext/filters/client_channel/lb_policy_registry.h @@ -45,4 +45,4 @@ grpc_lb_policy *grpc_lb_policy_create(grpc_exec_ctx *exec_ctx, const char *name, } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_REGISTRY_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_REGISTRY_H */ diff --git a/src/core/ext/filters/client_channel/parse_address.h b/src/core/ext/filters/client_channel/parse_address.h index 742df380b7e..27d06a1cb3d 100644 --- a/src/core/ext/filters/client_channel/parse_address.h +++ b/src/core/ext/filters/client_channel/parse_address.h @@ -53,4 +53,4 @@ bool grpc_parse_ipv6_hostport(const char *hostport, grpc_resolved_address *addr, } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PARSE_ADDRESS_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PARSE_ADDRESS_H */ diff --git a/src/core/ext/filters/client_channel/proxy_mapper.h b/src/core/ext/filters/client_channel/proxy_mapper.h index 1325a9f1f62..bb8259f8545 100644 --- a/src/core/ext/filters/client_channel/proxy_mapper.h +++ b/src/core/ext/filters/client_channel/proxy_mapper.h @@ -79,4 +79,4 @@ void grpc_proxy_mapper_destroy(grpc_proxy_mapper* mapper); } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_H */ diff --git a/src/core/ext/filters/client_channel/proxy_mapper_registry.h b/src/core/ext/filters/client_channel/proxy_mapper_registry.h index 2d389f1c21d..39c607cefcf 100644 --- a/src/core/ext/filters/client_channel/proxy_mapper_registry.h +++ b/src/core/ext/filters/client_channel/proxy_mapper_registry.h @@ -49,4 +49,4 @@ bool grpc_proxy_mappers_map_address(grpc_exec_ctx* exec_ctx, } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_REGISTRY_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_REGISTRY_H */ diff --git a/src/core/ext/filters/client_channel/resolver_factory.h b/src/core/ext/filters/client_channel/resolver_factory.h index 6e533e32488..c8b2c58db3e 100644 --- a/src/core/ext/filters/client_channel/resolver_factory.h +++ b/src/core/ext/filters/client_channel/resolver_factory.h @@ -75,4 +75,4 @@ char *grpc_resolver_factory_get_default_authority( } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FACTORY_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FACTORY_H */ diff --git a/src/core/ext/filters/client_channel/resolver_registry.h b/src/core/ext/filters/client_channel/resolver_registry.h index eb08d887b18..06d0b99a355 100644 --- a/src/core/ext/filters/client_channel/resolver_registry.h +++ b/src/core/ext/filters/client_channel/resolver_registry.h @@ -74,4 +74,4 @@ char *grpc_resolver_factory_add_default_prefix_if_needed( } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_REGISTRY_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_REGISTRY_H */ diff --git a/src/core/ext/filters/client_channel/retry_throttle.h b/src/core/ext/filters/client_channel/retry_throttle.h index 3b849475b95..399383df78b 100644 --- a/src/core/ext/filters/client_channel/retry_throttle.h +++ b/src/core/ext/filters/client_channel/retry_throttle.h @@ -55,4 +55,4 @@ grpc_server_retry_throttle_data* grpc_retry_throttle_map_get_data_for_server( } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RETRY_THROTTLE_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RETRY_THROTTLE_H */ diff --git a/src/core/ext/filters/client_channel/subchannel_index.h b/src/core/ext/filters/client_channel/subchannel_index.h index 09bac3592ca..05c3878379f 100644 --- a/src/core/ext/filters/client_channel/subchannel_index.h +++ b/src/core/ext/filters/client_channel/subchannel_index.h @@ -86,4 +86,4 @@ void grpc_subchannel_index_test_only_set_force_creation(bool force_creation); } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SUBCHANNEL_INDEX_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SUBCHANNEL_INDEX_H */ diff --git a/src/core/ext/filters/client_channel/uri_parser.h b/src/core/ext/filters/client_channel/uri_parser.h index 43e8ae64e03..e78da5928b6 100644 --- a/src/core/ext/filters/client_channel/uri_parser.h +++ b/src/core/ext/filters/client_channel/uri_parser.h @@ -55,4 +55,4 @@ void grpc_uri_destroy(grpc_uri *uri); } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_URI_PARSER_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_URI_PARSER_H */ diff --git a/src/core/ext/filters/deadline/deadline_filter.h b/src/core/ext/filters/deadline/deadline_filter.h index 4a80535b147..e665dc53ee3 100644 --- a/src/core/ext/filters/deadline/deadline_filter.h +++ b/src/core/ext/filters/deadline/deadline_filter.h @@ -98,4 +98,4 @@ extern const grpc_channel_filter grpc_server_deadline_filter; } #endif -#endif /* GRPC_CORE_EXT_FILTERS_DEADLINE_DEADLINE_FILTER_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_DEADLINE_DEADLINE_FILTER_H */ diff --git a/src/core/ext/filters/workarounds/workaround_utils.h b/src/core/ext/filters/workarounds/workaround_utils.h index afd5291333a..3913cae6b2b 100644 --- a/src/core/ext/filters/workarounds/workaround_utils.h +++ b/src/core/ext/filters/workarounds/workaround_utils.h @@ -42,4 +42,4 @@ void grpc_register_workaround(uint32_t id, user_agent_parser parser); } #endif -#endif /* GRPC_CORE_EXT_FILTERS_WORKAROUNDS_WORKAROUND_UTILS_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_WORKAROUNDS_WORKAROUND_UTILS_H */ diff --git a/src/core/ext/transport/chttp2/alpn/alpn.h b/src/core/ext/transport/chttp2/alpn/alpn.h index 5842204c204..99b928ea591 100644 --- a/src/core/ext/transport/chttp2/alpn/alpn.h +++ b/src/core/ext/transport/chttp2/alpn/alpn.h @@ -39,4 +39,4 @@ const char *grpc_chttp2_get_alpn_version_index(size_t i); } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H */ diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.h b/src/core/ext/transport/chttp2/server/chttp2_server.h index e1df28ed11f..2ac155160fc 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.h +++ b/src/core/ext/transport/chttp2/server/chttp2_server.h @@ -37,4 +37,4 @@ grpc_error *grpc_chttp2_server_add_port(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H */ diff --git a/src/core/ext/transport/chttp2/transport/bin_decoder.h b/src/core/ext/transport/chttp2/transport/bin_decoder.h index f50e0a8ac42..1c0b2b7e97a 100644 --- a/src/core/ext/transport/chttp2/transport/bin_decoder.h +++ b/src/core/ext/transport/chttp2/transport/bin_decoder.h @@ -57,4 +57,4 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H */ diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.h b/src/core/ext/transport/chttp2/transport/bin_encoder.h index ae8219c5ced..0be3633354e 100644 --- a/src/core/ext/transport/chttp2/transport/bin_encoder.h +++ b/src/core/ext/transport/chttp2/transport/bin_encoder.h @@ -44,4 +44,4 @@ grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(grpc_slice input); } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H */ diff --git a/src/core/ext/transport/chttp2/transport/frame_data.h b/src/core/ext/transport/chttp2/transport/frame_data.h index 2df99ccf987..81ec5361a39 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.h +++ b/src/core/ext/transport/chttp2/transport/frame_data.h @@ -88,4 +88,4 @@ grpc_error *grpc_deframe_unprocessed_incoming_frames( } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H */ diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.h b/src/core/ext/transport/chttp2/transport/frame_goaway.h index ce6f18b35c3..7b3aa45f3f2 100644 --- a/src/core/ext/transport/chttp2/transport/frame_goaway.h +++ b/src/core/ext/transport/chttp2/transport/frame_goaway.h @@ -68,4 +68,4 @@ void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code, } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H */ diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.h b/src/core/ext/transport/chttp2/transport/frame_ping.h index 91f16f050fb..ffc2f0cf2ff 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.h +++ b/src/core/ext/transport/chttp2/transport/frame_ping.h @@ -49,4 +49,4 @@ void grpc_set_disable_ping_ack(bool disable_ping_ack); } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H */ diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h index bdca064a917..102ffdb3f36 100644 --- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h @@ -48,4 +48,4 @@ grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H */ diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.h b/src/core/ext/transport/chttp2/transport/frame_settings.h index f0793f0e737..3364da15207 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.h +++ b/src/core/ext/transport/chttp2/transport/frame_settings.h @@ -66,4 +66,4 @@ grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H */ diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.h b/src/core/ext/transport/chttp2/transport/frame_window_update.h index 29cf0cc740a..400f9f53989 100644 --- a/src/core/ext/transport/chttp2/transport/frame_window_update.h +++ b/src/core/ext/transport/chttp2/transport/frame_window_update.h @@ -47,4 +47,4 @@ grpc_error *grpc_chttp2_window_update_parser_parse( } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H */ diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.h b/src/core/ext/transport/chttp2/transport/hpack_encoder.h index dc28b5566a6..16316b63f7c 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.h +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.h @@ -99,4 +99,4 @@ void grpc_chttp2_encode_header(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H */ diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.h b/src/core/ext/transport/chttp2/transport/hpack_parser.h index 6c36ebdf8d1..52014175a06 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.h +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.h @@ -119,4 +119,4 @@ grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H */ diff --git a/src/core/ext/transport/chttp2/transport/http2_settings.h b/src/core/ext/transport/chttp2/transport/http2_settings.h index 01e80b8d014..0f76106dceb 100644 --- a/src/core/ext/transport/chttp2/transport/http2_settings.h +++ b/src/core/ext/transport/chttp2/transport/http2_settings.h @@ -64,4 +64,4 @@ extern const grpc_chttp2_setting_parameters } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H */ diff --git a/src/core/ext/transport/chttp2/transport/incoming_metadata.h b/src/core/ext/transport/chttp2/transport/incoming_metadata.h index 995e8001b13..a0e01f2c4d2 100644 --- a/src/core/ext/transport/chttp2/transport/incoming_metadata.h +++ b/src/core/ext/transport/chttp2/transport/incoming_metadata.h @@ -53,4 +53,4 @@ void grpc_chttp2_incoming_metadata_buffer_set_deadline( } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H */ diff --git a/src/core/ext/transport/chttp2/transport/stream_map.h b/src/core/ext/transport/chttp2/transport/stream_map.h index 364d37c33af..7ab6a4f5ed0 100644 --- a/src/core/ext/transport/chttp2/transport/stream_map.h +++ b/src/core/ext/transport/chttp2/transport/stream_map.h @@ -73,4 +73,4 @@ void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map *map, } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_MAP_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_MAP_H */ diff --git a/src/core/lib/channel/channel_args.h b/src/core/lib/channel/channel_args.h index 2837174f491..1896d35cf45 100644 --- a/src/core/lib/channel/channel_args.h +++ b/src/core/lib/channel/channel_args.h @@ -157,4 +157,4 @@ grpc_arg grpc_channel_arg_pointer_create(char *name, void *value, } #endif -#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_ARGS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_ARGS_H */ diff --git a/src/core/lib/channel/connected_channel.h b/src/core/lib/channel/connected_channel.h index b55a1089a00..4615727baa1 100644 --- a/src/core/lib/channel/connected_channel.h +++ b/src/core/lib/channel/connected_channel.h @@ -38,4 +38,4 @@ grpc_stream *grpc_connected_channel_get_stream(grpc_call_element *elem); } #endif -#endif /* GRPC_CORE_LIB_CHANNEL_CONNECTED_CHANNEL_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_CHANNEL_CONNECTED_CHANNEL_H */ diff --git a/src/core/lib/channel/handshaker.h b/src/core/lib/channel/handshaker.h index 51ee56af437..8ed38c15ba1 100644 --- a/src/core/lib/channel/handshaker.h +++ b/src/core/lib/channel/handshaker.h @@ -172,4 +172,4 @@ void grpc_handshake_manager_pending_list_shutdown_all( } #endif -#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_H */ diff --git a/src/core/lib/channel/handshaker_factory.h b/src/core/lib/channel/handshaker_factory.h index 2a130de252a..59008adf057 100644 --- a/src/core/lib/channel/handshaker_factory.h +++ b/src/core/lib/channel/handshaker_factory.h @@ -56,4 +56,4 @@ void grpc_handshaker_factory_destroy( } #endif -#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_FACTORY_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_FACTORY_H */ diff --git a/src/core/lib/channel/handshaker_registry.h b/src/core/lib/channel/handshaker_registry.h index e96bf06b6af..ddd280bea8a 100644 --- a/src/core/lib/channel/handshaker_registry.h +++ b/src/core/lib/channel/handshaker_registry.h @@ -53,4 +53,4 @@ void grpc_handshakers_add(grpc_exec_ctx* exec_ctx, } #endif -#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_REGISTRY_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_REGISTRY_H */ diff --git a/src/core/lib/compression/algorithm_metadata.h b/src/core/lib/compression/algorithm_metadata.h index 3eb7088230b..17caf58f69c 100644 --- a/src/core/lib/compression/algorithm_metadata.h +++ b/src/core/lib/compression/algorithm_metadata.h @@ -57,4 +57,4 @@ grpc_stream_compression_algorithm grpc_stream_compression_algorithm_from_slice( } #endif -#endif /* GRPC_CORE_LIB_COMPRESSION_ALGORITHM_METADATA_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_COMPRESSION_ALGORITHM_METADATA_H */ diff --git a/src/core/lib/compression/message_compress.h b/src/core/lib/compression/message_compress.h index d2545a02c2e..fffe175fd22 100644 --- a/src/core/lib/compression/message_compress.h +++ b/src/core/lib/compression/message_compress.h @@ -44,4 +44,4 @@ int grpc_msg_decompress(grpc_exec_ctx* exec_ctx, } #endif -#endif /* GRPC_CORE_LIB_COMPRESSION_MESSAGE_COMPRESS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_COMPRESSION_MESSAGE_COMPRESS_H */ diff --git a/src/core/lib/http/format_request.h b/src/core/lib/http/format_request.h index a559aac6603..2e77e8661a7 100644 --- a/src/core/lib/http/format_request.h +++ b/src/core/lib/http/format_request.h @@ -37,4 +37,4 @@ grpc_slice grpc_httpcli_format_connect_request( } #endif -#endif /* GRPC_CORE_LIB_HTTP_FORMAT_REQUEST_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_HTTP_FORMAT_REQUEST_H */ diff --git a/src/core/lib/http/httpcli.h b/src/core/lib/http/httpcli.h index 3e6bdc0e461..76b790fa8ac 100644 --- a/src/core/lib/http/httpcli.h +++ b/src/core/lib/http/httpcli.h @@ -131,4 +131,4 @@ void grpc_httpcli_set_override(grpc_httpcli_get_override get, } #endif -#endif /* GRPC_CORE_LIB_HTTP_HTTPCLI_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_HTTP_HTTPCLI_H */ diff --git a/src/core/lib/http/parser.h b/src/core/lib/http/parser.h index 5484948bea8..d2bda6ae0e4 100644 --- a/src/core/lib/http/parser.h +++ b/src/core/lib/http/parser.h @@ -117,4 +117,4 @@ extern grpc_tracer_flag grpc_http1_trace; } #endif -#endif /* GRPC_CORE_LIB_HTTP_PARSER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_HTTP_PARSER_H */ diff --git a/src/core/lib/iomgr/endpoint.h b/src/core/lib/iomgr/endpoint.h index 16ff0ab733e..21347d90230 100644 --- a/src/core/lib/iomgr/endpoint.h +++ b/src/core/lib/iomgr/endpoint.h @@ -103,4 +103,4 @@ struct grpc_endpoint { } #endif -#endif /* GRPC_CORE_LIB_IOMGR_ENDPOINT_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_ENDPOINT_H */ diff --git a/src/core/lib/iomgr/endpoint_pair.h b/src/core/lib/iomgr/endpoint_pair.h index f8830022f4b..ee91795749b 100644 --- a/src/core/lib/iomgr/endpoint_pair.h +++ b/src/core/lib/iomgr/endpoint_pair.h @@ -37,4 +37,4 @@ grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char *name, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_ENDPOINT_PAIR_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_ENDPOINT_PAIR_H */ diff --git a/src/core/lib/iomgr/error_internal.h b/src/core/lib/iomgr/error_internal.h index f718e06d4e5..8746d5d353f 100644 --- a/src/core/lib/iomgr/error_internal.h +++ b/src/core/lib/iomgr/error_internal.h @@ -65,4 +65,4 @@ bool grpc_error_is_special(grpc_error *err); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_ERROR_INTERNAL_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_ERROR_INTERNAL_H */ diff --git a/src/core/lib/iomgr/ev_epoll1_linux.h b/src/core/lib/iomgr/ev_epoll1_linux.h index 66fd826b495..b437032b368 100644 --- a/src/core/lib/iomgr/ev_epoll1_linux.h +++ b/src/core/lib/iomgr/ev_epoll1_linux.h @@ -34,4 +34,4 @@ const grpc_event_engine_vtable *grpc_init_epoll1_linux(bool explicit_request); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLL1_LINUX_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLL1_LINUX_H */ diff --git a/src/core/lib/iomgr/ev_epollex_linux.h b/src/core/lib/iomgr/ev_epollex_linux.h index 58cc5a24f8f..2849a232835 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.h +++ b/src/core/lib/iomgr/ev_epollex_linux.h @@ -33,4 +33,4 @@ const grpc_event_engine_vtable *grpc_init_epollex_linux( } #endif -#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLLEX_LINUX_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLLEX_LINUX_H */ diff --git a/src/core/lib/iomgr/ev_poll_posix.h b/src/core/lib/iomgr/ev_poll_posix.h index 84b68155b5f..861257204b5 100644 --- a/src/core/lib/iomgr/ev_poll_posix.h +++ b/src/core/lib/iomgr/ev_poll_posix.h @@ -32,4 +32,4 @@ const grpc_event_engine_vtable *grpc_init_poll_cv_posix(bool explicit_request); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H */ diff --git a/src/core/lib/iomgr/ev_posix.h b/src/core/lib/iomgr/ev_posix.h index 955326c5f72..bc4456c2a29 100644 --- a/src/core/lib/iomgr/ev_posix.h +++ b/src/core/lib/iomgr/ev_posix.h @@ -166,4 +166,4 @@ const grpc_event_engine_vtable *grpc_get_event_engine_test_only(); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_EV_POSIX_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_EV_POSIX_H */ diff --git a/src/core/lib/iomgr/executor.h b/src/core/lib/iomgr/executor.h index ab3fc901de2..ef5ac56c832 100644 --- a/src/core/lib/iomgr/executor.h +++ b/src/core/lib/iomgr/executor.h @@ -53,4 +53,4 @@ void grpc_executor_set_threading(grpc_exec_ctx *exec_ctx, bool enable); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_EXECUTOR_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_EXECUTOR_H */ diff --git a/src/core/lib/iomgr/iocp_windows.h b/src/core/lib/iomgr/iocp_windows.h index aefe7a294a2..4efbc94645a 100644 --- a/src/core/lib/iomgr/iocp_windows.h +++ b/src/core/lib/iomgr/iocp_windows.h @@ -45,4 +45,4 @@ void grpc_iocp_add_socket(grpc_winsocket *); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_IOCP_WINDOWS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_IOCP_WINDOWS_H */ diff --git a/src/core/lib/iomgr/iomgr.h b/src/core/lib/iomgr/iomgr.h index fea08496fef..6c0a08b9183 100644 --- a/src/core/lib/iomgr/iomgr.h +++ b/src/core/lib/iomgr/iomgr.h @@ -40,4 +40,4 @@ void grpc_iomgr_shutdown(grpc_exec_ctx *exec_ctx); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_IOMGR_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_IOMGR_H */ diff --git a/src/core/lib/iomgr/iomgr_internal.h b/src/core/lib/iomgr/iomgr_internal.h index 005abbed13e..52db37c89ae 100644 --- a/src/core/lib/iomgr/iomgr_internal.h +++ b/src/core/lib/iomgr/iomgr_internal.h @@ -48,4 +48,4 @@ bool grpc_iomgr_abort_on_leaks(void); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_IOMGR_INTERNAL_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_IOMGR_INTERNAL_H */ diff --git a/src/core/lib/iomgr/is_epollexclusive_available.h b/src/core/lib/iomgr/is_epollexclusive_available.h index 5c3e4830655..9ae9c5c1915 100644 --- a/src/core/lib/iomgr/is_epollexclusive_available.h +++ b/src/core/lib/iomgr/is_epollexclusive_available.h @@ -31,4 +31,4 @@ bool grpc_is_epollexclusive_available(void); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_IS_EPOLLEXCLUSIVE_AVAILABLE_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_IS_EPOLLEXCLUSIVE_AVAILABLE_H */ diff --git a/src/core/lib/iomgr/lockfree_event.h b/src/core/lib/iomgr/lockfree_event.h index 925f0049458..02229e569ef 100644 --- a/src/core/lib/iomgr/lockfree_event.h +++ b/src/core/lib/iomgr/lockfree_event.h @@ -45,4 +45,4 @@ void grpc_lfev_set_ready(grpc_exec_ctx *exec_ctx, gpr_atm *state, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_LOCKFREE_EVENT_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_LOCKFREE_EVENT_H */ diff --git a/src/core/lib/iomgr/network_status_tracker.h b/src/core/lib/iomgr/network_status_tracker.h index af50d51257e..cba38d4530f 100644 --- a/src/core/lib/iomgr/network_status_tracker.h +++ b/src/core/lib/iomgr/network_status_tracker.h @@ -35,4 +35,4 @@ void grpc_network_status_shutdown_all_endpoints(); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_NETWORK_STATUS_TRACKER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_NETWORK_STATUS_TRACKER_H */ diff --git a/src/core/lib/iomgr/polling_entity.h b/src/core/lib/iomgr/polling_entity.h index 4a37acf212f..009f968fac4 100644 --- a/src/core/lib/iomgr/polling_entity.h +++ b/src/core/lib/iomgr/polling_entity.h @@ -72,4 +72,4 @@ void grpc_polling_entity_del_from_pollset_set(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H */ diff --git a/src/core/lib/iomgr/pollset_set.h b/src/core/lib/iomgr/pollset_set.h index 17df86542dd..5455eda02fd 100644 --- a/src/core/lib/iomgr/pollset_set.h +++ b/src/core/lib/iomgr/pollset_set.h @@ -52,4 +52,4 @@ void grpc_pollset_set_del_pollset_set(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_SET_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_SET_H */ diff --git a/src/core/lib/iomgr/pollset_uv.h b/src/core/lib/iomgr/pollset_uv.h index d8f72ff867b..5cc9faf4ff1 100644 --- a/src/core/lib/iomgr/pollset_uv.h +++ b/src/core/lib/iomgr/pollset_uv.h @@ -32,4 +32,4 @@ void grpc_pollset_global_shutdown(void); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_UV_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_UV_H */ diff --git a/src/core/lib/iomgr/pollset_windows.h b/src/core/lib/iomgr/pollset_windows.h index 7733d26471c..2479b25286d 100644 --- a/src/core/lib/iomgr/pollset_windows.h +++ b/src/core/lib/iomgr/pollset_windows.h @@ -68,4 +68,4 @@ void grpc_pollset_global_shutdown(void); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H */ diff --git a/src/core/lib/iomgr/resolve_address.h b/src/core/lib/iomgr/resolve_address.h index 4a6df2cf264..5f0634299e0 100644 --- a/src/core/lib/iomgr/resolve_address.h +++ b/src/core/lib/iomgr/resolve_address.h @@ -60,4 +60,4 @@ extern grpc_error *(*grpc_blocking_resolve_address)( } #endif -#endif /* GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H */ diff --git a/src/core/lib/iomgr/resource_quota.h b/src/core/lib/iomgr/resource_quota.h index 3afb5254349..1d4249b7e29 100644 --- a/src/core/lib/iomgr/resource_quota.h +++ b/src/core/lib/iomgr/resource_quota.h @@ -158,4 +158,4 @@ grpc_slice grpc_resource_user_slice_malloc(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_RESOURCE_QUOTA_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_RESOURCE_QUOTA_H */ diff --git a/src/core/lib/iomgr/sockaddr_utils.h b/src/core/lib/iomgr/sockaddr_utils.h index 129bb54fc9e..1fd552febbb 100644 --- a/src/core/lib/iomgr/sockaddr_utils.h +++ b/src/core/lib/iomgr/sockaddr_utils.h @@ -85,4 +85,4 @@ int grpc_sockaddr_get_family(const grpc_resolved_address *resolved_addr); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_UTILS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_UTILS_H */ diff --git a/src/core/lib/iomgr/socket_utils.h b/src/core/lib/iomgr/socket_utils.h index f319e931b61..d6c538ec6f3 100644 --- a/src/core/lib/iomgr/socket_utils.h +++ b/src/core/lib/iomgr/socket_utils.h @@ -32,4 +32,4 @@ const char *grpc_inet_ntop(int af, const void *src, char *dst, size_t size); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_H */ diff --git a/src/core/lib/iomgr/socket_utils_posix.h b/src/core/lib/iomgr/socket_utils_posix.h index 623b83f08b1..73809b68d30 100644 --- a/src/core/lib/iomgr/socket_utils_posix.h +++ b/src/core/lib/iomgr/socket_utils_posix.h @@ -137,4 +137,4 @@ grpc_error *grpc_create_dualstack_socket_using_factory( } #endif -#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_POSIX_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_POSIX_H */ diff --git a/src/core/lib/iomgr/socket_windows.h b/src/core/lib/iomgr/socket_windows.h index a00a7615a37..84fa071e89a 100644 --- a/src/core/lib/iomgr/socket_windows.h +++ b/src/core/lib/iomgr/socket_windows.h @@ -115,4 +115,4 @@ void grpc_socket_become_ready(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_WINDOWS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_WINDOWS_H */ diff --git a/src/core/lib/iomgr/tcp_client.h b/src/core/lib/iomgr/tcp_client.h index 1b102b5784a..b2f365f2af6 100644 --- a/src/core/lib/iomgr/tcp_client.h +++ b/src/core/lib/iomgr/tcp_client.h @@ -45,4 +45,4 @@ void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *on_connect, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_H */ diff --git a/src/core/lib/iomgr/tcp_client_posix.h b/src/core/lib/iomgr/tcp_client_posix.h index 0b9775504ca..8740511804d 100644 --- a/src/core/lib/iomgr/tcp_client_posix.h +++ b/src/core/lib/iomgr/tcp_client_posix.h @@ -35,4 +35,4 @@ grpc_endpoint *grpc_tcp_client_create_from_fd( } #endif -#endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H */ diff --git a/src/core/lib/iomgr/tcp_posix.h b/src/core/lib/iomgr/tcp_posix.h index dda78b2f8e1..47e78fa67e6 100644 --- a/src/core/lib/iomgr/tcp_posix.h +++ b/src/core/lib/iomgr/tcp_posix.h @@ -61,4 +61,4 @@ void grpc_tcp_destroy_and_release_fd(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_TCP_POSIX_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_TCP_POSIX_H */ diff --git a/src/core/lib/iomgr/tcp_server.h b/src/core/lib/iomgr/tcp_server.h index 3f190ac2853..8f9ce3819e6 100644 --- a/src/core/lib/iomgr/tcp_server.h +++ b/src/core/lib/iomgr/tcp_server.h @@ -106,4 +106,4 @@ void grpc_tcp_server_shutdown_listeners(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_TCP_SERVER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_TCP_SERVER_H */ diff --git a/src/core/lib/iomgr/tcp_server_utils_posix.h b/src/core/lib/iomgr/tcp_server_utils_posix.h index 4bb0660f091..67463339608 100644 --- a/src/core/lib/iomgr/tcp_server_utils_posix.h +++ b/src/core/lib/iomgr/tcp_server_utils_posix.h @@ -125,4 +125,4 @@ bool grpc_tcp_server_have_ifaddrs(void); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_TCP_SERVER_UTILS_POSIX_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_TCP_SERVER_UTILS_POSIX_H */ diff --git a/src/core/lib/iomgr/tcp_uv.h b/src/core/lib/iomgr/tcp_uv.h index ba7db8a0f7f..3399535b421 100644 --- a/src/core/lib/iomgr/tcp_uv.h +++ b/src/core/lib/iomgr/tcp_uv.h @@ -50,4 +50,4 @@ grpc_endpoint *grpc_tcp_create(uv_tcp_t *handle, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_TCP_UV_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_TCP_UV_H */ diff --git a/src/core/lib/iomgr/time_averaged_stats.h b/src/core/lib/iomgr/time_averaged_stats.h index e255b58feeb..d38ed272b6d 100644 --- a/src/core/lib/iomgr/time_averaged_stats.h +++ b/src/core/lib/iomgr/time_averaged_stats.h @@ -78,4 +78,4 @@ double grpc_time_averaged_stats_update_average(grpc_time_averaged_stats* stats); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_TIME_AVERAGED_STATS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_TIME_AVERAGED_STATS_H */ diff --git a/src/core/lib/iomgr/timer_heap.h b/src/core/lib/iomgr/timer_heap.h index f15e8a3abb8..228d038ab38 100644 --- a/src/core/lib/iomgr/timer_heap.h +++ b/src/core/lib/iomgr/timer_heap.h @@ -47,4 +47,4 @@ int grpc_timer_heap_is_empty(grpc_timer_heap *heap); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_TIMER_HEAP_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_TIMER_HEAP_H */ diff --git a/src/core/lib/iomgr/timer_manager.h b/src/core/lib/iomgr/timer_manager.h index d8a59a9477a..72960d6ffc0 100644 --- a/src/core/lib/iomgr/timer_manager.h +++ b/src/core/lib/iomgr/timer_manager.h @@ -42,4 +42,4 @@ void grpc_timer_manager_tick(void); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_TIMER_MANAGER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_TIMER_MANAGER_H */ diff --git a/src/core/lib/iomgr/udp_server.h b/src/core/lib/iomgr/udp_server.h index bcd8572260a..e887cb1bcf4 100644 --- a/src/core/lib/iomgr/udp_server.h +++ b/src/core/lib/iomgr/udp_server.h @@ -81,4 +81,4 @@ void grpc_udp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_udp_server *server, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_UDP_SERVER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_UDP_SERVER_H */ diff --git a/src/core/lib/iomgr/unix_sockets_posix.h b/src/core/lib/iomgr/unix_sockets_posix.h index b96131ae1ce..3e7f9c7d1e3 100644 --- a/src/core/lib/iomgr/unix_sockets_posix.h +++ b/src/core/lib/iomgr/unix_sockets_posix.h @@ -46,4 +46,4 @@ char *grpc_sockaddr_to_uri_unix_if_possible( } #endif -#endif /* GRPC_CORE_LIB_IOMGR_UNIX_SOCKETS_POSIX_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_UNIX_SOCKETS_POSIX_H */ diff --git a/src/core/lib/json/json.h b/src/core/lib/json/json.h index 81b7e0c9da3..c9fdec4ecb7 100644 --- a/src/core/lib/json/json.h +++ b/src/core/lib/json/json.h @@ -78,4 +78,4 @@ void grpc_json_destroy(grpc_json* json); } #endif -#endif /* GRPC_CORE_LIB_JSON_JSON_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_JSON_JSON_H */ diff --git a/src/core/lib/json/json_reader.h b/src/core/lib/json/json_reader.h index ab2384f7a71..7f14a9a9c81 100644 --- a/src/core/lib/json/json_reader.h +++ b/src/core/lib/json/json_reader.h @@ -150,4 +150,4 @@ int grpc_json_reader_is_complete(grpc_json_reader *reader); } #endif -#endif /* GRPC_CORE_LIB_JSON_JSON_READER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_JSON_JSON_READER_H */ diff --git a/src/core/lib/json/json_writer.h b/src/core/lib/json/json_writer.h index 18bd2a80fec..132d1f24e85 100644 --- a/src/core/lib/json/json_writer.h +++ b/src/core/lib/json/json_writer.h @@ -87,4 +87,4 @@ void grpc_json_writer_value_string(grpc_json_writer *writer, } #endif -#endif /* GRPC_CORE_LIB_JSON_JSON_WRITER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_JSON_JSON_WRITER_H */ diff --git a/src/core/lib/security/credentials/fake/fake_credentials.h b/src/core/lib/security/credentials/fake/fake_credentials.h index 64f6f439f0a..ed3f893c58f 100644 --- a/src/core/lib/security/credentials/fake/fake_credentials.h +++ b/src/core/lib/security/credentials/fake/fake_credentials.h @@ -64,4 +64,4 @@ typedef struct { } #endif -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_FAKE_FAKE_CREDENTIALS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_FAKE_FAKE_CREDENTIALS_H */ diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.h b/src/core/lib/security/credentials/jwt/jwt_credentials.h index c09485fd55a..5cee6ed0da6 100644 --- a/src/core/lib/security/credentials/jwt/jwt_credentials.h +++ b/src/core/lib/security/credentials/jwt/jwt_credentials.h @@ -53,4 +53,4 @@ grpc_service_account_jwt_access_credentials_create_from_auth_json_key( } #endif -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_CREDENTIALS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_CREDENTIALS_H */ diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h index 4beaec93e3e..c12db896f33 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h @@ -110,4 +110,4 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response( } #endif -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_OAUTH2_OAUTH2_CREDENTIALS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_OAUTH2_OAUTH2_CREDENTIALS_H */ diff --git a/src/core/lib/security/transport/lb_targets_info.h b/src/core/lib/security/transport/lb_targets_info.h index 705d33b0abe..43f0e645565 100644 --- a/src/core/lib/security/transport/lb_targets_info.h +++ b/src/core/lib/security/transport/lb_targets_info.h @@ -37,4 +37,4 @@ grpc_slice_hash_table *grpc_lb_targets_info_find_in_args( } #endif -#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_LB_TARGETS_INFO_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_LB_TARGETS_INFO_H */ diff --git a/src/core/lib/security/transport/secure_endpoint.h b/src/core/lib/security/transport/secure_endpoint.h index 832cc1c0ce9..980449c03ee 100644 --- a/src/core/lib/security/transport/secure_endpoint.h +++ b/src/core/lib/security/transport/secure_endpoint.h @@ -44,4 +44,4 @@ grpc_endpoint *grpc_secure_endpoint_create( } #endif -#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURE_ENDPOINT_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURE_ENDPOINT_H */ diff --git a/src/core/lib/security/transport/security_handshaker.h b/src/core/lib/security/transport/security_handshaker.h index 345065f26c8..178099bb945 100644 --- a/src/core/lib/security/transport/security_handshaker.h +++ b/src/core/lib/security/transport/security_handshaker.h @@ -39,4 +39,4 @@ void grpc_security_register_handshaker_factories(); } #endif -#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURITY_HANDSHAKER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURITY_HANDSHAKER_H */ diff --git a/src/core/lib/security/transport/tsi_error.h b/src/core/lib/security/transport/tsi_error.h index 4c78b06603d..4e19daf796f 100644 --- a/src/core/lib/security/transport/tsi_error.h +++ b/src/core/lib/security/transport/tsi_error.h @@ -32,4 +32,4 @@ grpc_error *grpc_set_tsi_error_result(grpc_error *error, tsi_result result); } #endif -#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_TSI_ERROR_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_TSI_ERROR_H */ diff --git a/src/core/lib/security/util/json_util.h b/src/core/lib/security/util/json_util.h index 43a2f6b9d18..cdd8a7198a8 100644 --- a/src/core/lib/security/util/json_util.h +++ b/src/core/lib/security/util/json_util.h @@ -45,4 +45,4 @@ bool grpc_copy_json_string_property(const grpc_json *json, } #endif -#endif /* GRPC_CORE_LIB_SECURITY_UTIL_JSON_UTIL_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SECURITY_UTIL_JSON_UTIL_H */ diff --git a/src/core/lib/slice/b64.h b/src/core/lib/slice/b64.h index c01da56575c..9b4dc65dbbb 100644 --- a/src/core/lib/slice/b64.h +++ b/src/core/lib/slice/b64.h @@ -55,4 +55,4 @@ grpc_slice grpc_base64_decode_with_len(grpc_exec_ctx *exec_ctx, const char *b64, } #endif -#endif /* GRPC_CORE_LIB_SLICE_B64_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SLICE_B64_H */ diff --git a/src/core/lib/slice/percent_encoding.h b/src/core/lib/slice/percent_encoding.h index e6f85120c3a..14a4deb44b8 100644 --- a/src/core/lib/slice/percent_encoding.h +++ b/src/core/lib/slice/percent_encoding.h @@ -68,4 +68,4 @@ grpc_slice grpc_permissive_percent_decode_slice(grpc_slice slice_in); } #endif -#endif /* GRPC_CORE_LIB_SLICE_PERCENT_ENCODING_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SLICE_PERCENT_ENCODING_H */ diff --git a/src/core/lib/slice/slice_hash_table.h b/src/core/lib/slice/slice_hash_table.h index 3c3f0e61f3a..41250df7385 100644 --- a/src/core/lib/slice/slice_hash_table.h +++ b/src/core/lib/slice/slice_hash_table.h @@ -75,4 +75,4 @@ int grpc_slice_hash_table_cmp(const grpc_slice_hash_table *a, } #endif -#endif /* GRPC_CORE_LIB_SLICE_SLICE_HASH_TABLE_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SLICE_SLICE_HASH_TABLE_H */ diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index 8591185c53b..fcf70a0e55f 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -54,4 +54,4 @@ int grpc_static_slice_eq(grpc_slice a, grpc_slice b); } #endif -#endif /* GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H */ diff --git a/src/core/lib/slice/slice_traits.h b/src/core/lib/slice/slice_traits.h index 1eda17cf00b..7fdb6752cb4 100644 --- a/src/core/lib/slice/slice_traits.h +++ b/src/core/lib/slice/slice_traits.h @@ -34,4 +34,4 @@ bool grpc_slice_is_bin_suffixed(grpc_slice s); } #endif -#endif /* GRPC_CORE_LIB_SLICE_SLICE_TRAITS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SLICE_SLICE_TRAITS_H */ diff --git a/src/core/lib/surface/channel_stack_type.h b/src/core/lib/surface/channel_stack_type.h index 903b90a0716..c77848794cc 100644 --- a/src/core/lib/surface/channel_stack_type.h +++ b/src/core/lib/surface/channel_stack_type.h @@ -50,4 +50,4 @@ const char *grpc_channel_stack_type_string(grpc_channel_stack_type type); } #endif -#endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_STACK_TYPE_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_STACK_TYPE_H */ diff --git a/src/core/lib/surface/completion_queue_factory.h b/src/core/lib/surface/completion_queue_factory.h index cb0af6f0fb6..af8f3d60c38 100644 --- a/src/core/lib/surface/completion_queue_factory.h +++ b/src/core/lib/surface/completion_queue_factory.h @@ -41,4 +41,4 @@ struct grpc_completion_queue_factory { } #endif -#endif /* GRPC_CORE_LIB_SURFACE_COMPLETION_QUEUE_FACTORY_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SURFACE_COMPLETION_QUEUE_FACTORY_H */ diff --git a/src/core/lib/surface/event_string.h b/src/core/lib/surface/event_string.h index 127609c404f..2d53cf0facf 100644 --- a/src/core/lib/surface/event_string.h +++ b/src/core/lib/surface/event_string.h @@ -32,4 +32,4 @@ char *grpc_event_string(grpc_event *ev); } #endif -#endif /* GRPC_CORE_LIB_SURFACE_EVENT_STRING_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SURFACE_EVENT_STRING_H */ diff --git a/src/core/lib/surface/init.h b/src/core/lib/surface/init.h index b2f48576e50..d429026327f 100644 --- a/src/core/lib/surface/init.h +++ b/src/core/lib/surface/init.h @@ -32,4 +32,4 @@ int grpc_is_initialized(void); } #endif -#endif /* GRPC_CORE_LIB_SURFACE_INIT_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SURFACE_INIT_H */ diff --git a/src/core/lib/surface/server.h b/src/core/lib/surface/server.h index 1114715833b..375eab4a048 100644 --- a/src/core/lib/surface/server.h +++ b/src/core/lib/surface/server.h @@ -62,4 +62,4 @@ void grpc_server_get_pollsets(grpc_server *server, grpc_pollset ***pollsets, } #endif -#endif /* GRPC_CORE_LIB_SURFACE_SERVER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SURFACE_SERVER_H */ diff --git a/src/core/lib/surface/validate_metadata.h b/src/core/lib/surface/validate_metadata.h index aa02419d9f7..afc8be6dfda 100644 --- a/src/core/lib/surface/validate_metadata.h +++ b/src/core/lib/surface/validate_metadata.h @@ -33,4 +33,4 @@ grpc_error *grpc_validate_header_nonbin_value_is_legal(grpc_slice slice); } #endif -#endif /* GRPC_CORE_LIB_SURFACE_VALIDATE_METADATA_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SURFACE_VALIDATE_METADATA_H */ diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h index 480d5237b80..a9d986782ca 100644 --- a/src/core/lib/transport/bdp_estimator.h +++ b/src/core/lib/transport/bdp_estimator.h @@ -82,4 +82,4 @@ void grpc_bdp_estimator_complete_ping(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_LIB_TRANSPORT_BDP_ESTIMATOR_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_TRANSPORT_BDP_ESTIMATOR_H */ diff --git a/src/core/lib/transport/byte_stream.h b/src/core/lib/transport/byte_stream.h index d3e04df5c06..c1d8ee543f5 100644 --- a/src/core/lib/transport/byte_stream.h +++ b/src/core/lib/transport/byte_stream.h @@ -143,4 +143,4 @@ void grpc_caching_byte_stream_reset(grpc_caching_byte_stream *stream); } #endif -#endif /* GRPC_CORE_LIB_TRANSPORT_BYTE_STREAM_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_TRANSPORT_BYTE_STREAM_H */ diff --git a/src/core/lib/transport/connectivity_state.h b/src/core/lib/transport/connectivity_state.h index 1796a540a79..c0ba1881484 100644 --- a/src/core/lib/transport/connectivity_state.h +++ b/src/core/lib/transport/connectivity_state.h @@ -92,4 +92,4 @@ bool grpc_connectivity_state_notify_on_state_change( } #endif -#endif /* GRPC_CORE_LIB_TRANSPORT_CONNECTIVITY_STATE_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_TRANSPORT_CONNECTIVITY_STATE_H */ diff --git a/src/core/lib/transport/error_utils.h b/src/core/lib/transport/error_utils.h index 2c97f9f0bc9..b4f9df4bf1a 100644 --- a/src/core/lib/transport/error_utils.h +++ b/src/core/lib/transport/error_utils.h @@ -48,4 +48,4 @@ bool grpc_error_has_clear_grpc_status(grpc_error *error); } #endif -#endif /* GRPC_CORE_LIB_TRANSPORT_ERROR_UTILS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_TRANSPORT_ERROR_UTILS_H */ diff --git a/src/core/lib/transport/pid_controller.h b/src/core/lib/transport/pid_controller.h index 17feabfd393..80899e9a20f 100644 --- a/src/core/lib/transport/pid_controller.h +++ b/src/core/lib/transport/pid_controller.h @@ -67,4 +67,4 @@ double grpc_pid_controller_last(grpc_pid_controller *pid_controller); } #endif -#endif /* GRPC_CORE_LIB_TRANSPORT_PID_CONTROLLER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_TRANSPORT_PID_CONTROLLER_H */ diff --git a/src/core/lib/transport/service_config.h b/src/core/lib/transport/service_config.h index c485f524723..9c430936274 100644 --- a/src/core/lib/transport/service_config.h +++ b/src/core/lib/transport/service_config.h @@ -67,4 +67,4 @@ void* grpc_method_config_table_get(grpc_exec_ctx* exec_ctx, } #endif -#endif /* GRPC_CORE_LIB_TRANSPORT_SERVICE_CONFIG_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_TRANSPORT_SERVICE_CONFIG_H */ diff --git a/src/core/lib/transport/status_conversion.h b/src/core/lib/transport/status_conversion.h index fd58a82cb74..8ef91aecfea 100644 --- a/src/core/lib/transport/status_conversion.h +++ b/src/core/lib/transport/status_conversion.h @@ -41,4 +41,4 @@ int grpc_status_to_http2_status(grpc_status_code status); } #endif -#endif /* GRPC_CORE_LIB_TRANSPORT_STATUS_CONVERSION_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_TRANSPORT_STATUS_CONVERSION_H */ diff --git a/src/core/lib/transport/timeout_encoding.h b/src/core/lib/transport/timeout_encoding.h index 25cb6639595..91cdf0f728e 100644 --- a/src/core/lib/transport/timeout_encoding.h +++ b/src/core/lib/transport/timeout_encoding.h @@ -40,4 +40,4 @@ int grpc_http2_decode_timeout(grpc_slice text, grpc_millis *timeout); } #endif -#endif /* GRPC_CORE_LIB_TRANSPORT_TIMEOUT_ENCODING_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_TRANSPORT_TIMEOUT_ENCODING_H */ diff --git a/src/core/lib/transport/transport_impl.h b/src/core/lib/transport/transport_impl.h index 41d34d39542..445fb41ab16 100644 --- a/src/core/lib/transport/transport_impl.h +++ b/src/core/lib/transport/transport_impl.h @@ -77,4 +77,4 @@ struct grpc_transport { } #endif -#endif /* GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H */ diff --git a/src/core/tsi/gts_transport_security.h b/src/core/tsi/gts_transport_security.h index b988c3f8616..9590038ed00 100644 --- a/src/core/tsi/gts_transport_security.h +++ b/src/core/tsi/gts_transport_security.h @@ -42,4 +42,4 @@ gts_shared_resource *gts_get_shared_resource(void); } #endif -#endif /* GRPC_CORE_TSI_GTS_TRANSPORT_SECURITY_H */ \ No newline at end of file +#endif /* GRPC_CORE_TSI_GTS_TRANSPORT_SECURITY_H */ From fca7307d0e4f5b29100de13b4de9352aaa07fe14 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 9 Oct 2017 19:09:28 -0700 Subject: [PATCH 126/142] Cleanup suggested by code review --- .../ext/transport/chttp2/transport/writing.cc | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc index 2f9a33d70be..25c1a5ef056 100644 --- a/src/core/ext/transport/chttp2/transport/writing.cc +++ b/src/core/ext/transport/chttp2/transport/writing.cc @@ -372,7 +372,7 @@ class DataSendContext { } } - bool WasLastFrame() const { return is_last_frame_; } + bool is_last_frame() const { return is_last_frame_; } void CallCallbacks(grpc_exec_ctx *exec_ctx) { if (update_list(exec_ctx, t_, s_, @@ -394,21 +394,18 @@ class DataSendContext { class StreamWriteContext { public: StreamWriteContext(WriteContext *write_context, grpc_chttp2_stream *s) - : write_context_(write_context), - t_(write_context->transport()), - s_(s), - sent_initial_metadata_(s->sent_initial_metadata) { + : write_context_(write_context), t_(write_context->transport()), s_(s) { GRPC_CHTTP2_IF_TRACING( gpr_log(GPR_DEBUG, "W:%p %s[%d] im-(sent,send)=(%d,%d) announce=%d", t_, t_->is_client ? "CLIENT" : "SERVER", s->id, - sent_initial_metadata_, s->send_initial_metadata != NULL, + s->sent_initial_metadata, s->send_initial_metadata != NULL, (int)(s->flow_control.local_window_delta - s->flow_control.announced_window_delta))); } void FlushInitialMetadata(grpc_exec_ctx *exec_ctx) { /* send initial metadata if it's available */ - if (sent_initial_metadata_) return; + if (s_->sent_initial_metadata) return; if (s_->send_initial_metadata == nullptr) return; // We skip this on the server side if there is no custom initial @@ -441,7 +438,6 @@ class StreamWriteContext { s_->send_initial_metadata = NULL; s_->sent_initial_metadata = true; - sent_initial_metadata_ = true; write_context_->NoteScheduledResults(); grpc_chttp2_complete_closure_step( exec_ctx, t_, s_, &s_->send_initial_metadata_finished, GRPC_ERROR_NONE, @@ -462,7 +458,7 @@ class StreamWriteContext { } void FlushData(grpc_exec_ctx *exec_ctx) { - if (!sent_initial_metadata_) return; + if (!s_->sent_initial_metadata) return; if (s_->flow_controlled_buffer.length == 0 && s_->compressed_data_buffer.length == 0) { @@ -492,7 +488,7 @@ class StreamWriteContext { } } write_context_->ResetPingRecvClock(); - if (data_send_context.WasLastFrame()) { + if (data_send_context.is_last_frame()) { SentLastFrame(exec_ctx); } data_send_context.CallCallbacks(exec_ctx); @@ -506,7 +502,7 @@ class StreamWriteContext { } void FlushTrailingMetadata(grpc_exec_ctx *exec_ctx) { - if (!sent_initial_metadata_) return; + if (!s_->sent_initial_metadata) return; if (s_->send_trailing_metadata == NULL) return; if (s_->fetching_send_message != NULL) return; @@ -577,7 +573,6 @@ class StreamWriteContext { WriteContext *const write_context_; grpc_chttp2_transport *const t_; grpc_chttp2_stream *const s_; - bool sent_initial_metadata_; bool stream_became_writable_ = false; grpc_mdelem *extra_headers_for_trailing_metadata_[2]; size_t num_extra_headers_for_trailing_metadata_ = 0; From 2fb9859ae2b2146c8b0682ff385fd7635608b065 Mon Sep 17 00:00:00 2001 From: Nicolas Noble Date: Tue, 10 Oct 2017 09:19:02 -0700 Subject: [PATCH 127/142] Properly flushing execution context cache under Windows. --- src/core/lib/iomgr/iocp_windows.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/iocp_windows.cc b/src/core/lib/iomgr/iocp_windows.cc index 336cc86c757..e54584c8fd2 100644 --- a/src/core/lib/iomgr/iocp_windows.cc +++ b/src/core/lib/iomgr/iocp_windows.cc @@ -43,7 +43,6 @@ static HANDLE g_iocp; static DWORD deadline_to_millis_timeout(grpc_exec_ctx *exec_ctx, grpc_millis deadline) { - gpr_timespec timeout; if (deadline == GRPC_MILLIS_INF_FUTURE) { return INFINITE; } @@ -63,6 +62,7 @@ grpc_iocp_work_status grpc_iocp_work(grpc_exec_ctx *exec_ctx, success = GetQueuedCompletionStatus(g_iocp, &bytes, &completion_key, &overlapped, deadline_to_millis_timeout(exec_ctx, deadline)); + grpc_exec_ctx_invalidate_now(exec_ctx); if (success == 0 && overlapped == NULL) { return GRPC_IOCP_WORK_TIMEOUT; } From 3290e49a1d5b896b7ce65d658ffef00bf65d35dd Mon Sep 17 00:00:00 2001 From: Nicolas Noble Date: Tue, 10 Oct 2017 09:49:10 -0700 Subject: [PATCH 128/142] Fixing Windows's memory leak. --- src/core/lib/support/env_windows.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/lib/support/env_windows.cc b/src/core/lib/support/env_windows.cc index 73c643c5600..a0b7846808c 100644 --- a/src/core/lib/support/env_windows.cc +++ b/src/core/lib/support/env_windows.cc @@ -43,7 +43,10 @@ char *gpr_getenv(const char *name) { DWORD ret; ret = GetEnvironmentVariable(tname, NULL, 0); - if (ret == 0) return NULL; + if (ret == 0) { + gpr_free(tname); + return NULL; + } size = ret * (DWORD)sizeof(TCHAR); tresult = (LPTSTR)gpr_malloc(size); ret = GetEnvironmentVariable(tname, tresult, size); From c02dbe57c666e26f40e517b6f940f6cbd4bb43fc Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 10 Oct 2017 19:54:16 +0200 Subject: [PATCH 129/142] clang-format. --- src/core/lib/support/env_windows.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/support/env_windows.cc b/src/core/lib/support/env_windows.cc index a0b7846808c..c5a25dc201d 100644 --- a/src/core/lib/support/env_windows.cc +++ b/src/core/lib/support/env_windows.cc @@ -44,8 +44,8 @@ char *gpr_getenv(const char *name) { ret = GetEnvironmentVariable(tname, NULL, 0); if (ret == 0) { - gpr_free(tname); - return NULL; + gpr_free(tname); + return NULL; } size = ret * (DWORD)sizeof(TCHAR); tresult = (LPTSTR)gpr_malloc(size); From 850568944ae0e5959f939aa539ce6ad8c07c99c9 Mon Sep 17 00:00:00 2001 From: Nicolas Noble Date: Tue, 10 Oct 2017 09:47:50 -0700 Subject: [PATCH 130/142] Fixing init-test timeout. --- src/core/lib/iomgr/iocp_windows.cc | 8 ++++++-- test/core/surface/init_test.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/lib/iomgr/iocp_windows.cc b/src/core/lib/iomgr/iocp_windows.cc index 336cc86c757..7da60c2c14a 100644 --- a/src/core/lib/iomgr/iocp_windows.cc +++ b/src/core/lib/iomgr/iocp_windows.cc @@ -21,6 +21,7 @@ #ifdef GRPC_WINSOCK_SOCKET #include +#include #include #include @@ -43,11 +44,14 @@ static HANDLE g_iocp; static DWORD deadline_to_millis_timeout(grpc_exec_ctx *exec_ctx, grpc_millis deadline) { - gpr_timespec timeout; if (deadline == GRPC_MILLIS_INF_FUTURE) { return INFINITE; } - return (DWORD)GPR_MAX(0, deadline - grpc_exec_ctx_now(exec_ctx)); + grpc_millis now = grpc_exec_ctx_now(exec_ctx); + if (deadline < now) return 0; + grpc_millis timeout = deadline - now; + if (timeout > std::numeric_limits::max()) return INFINITE; + return static_cast(deadline - now); } grpc_iocp_work_status grpc_iocp_work(grpc_exec_ctx *exec_ctx, diff --git a/test/core/surface/init_test.c b/test/core/surface/init_test.c index a9e80575af1..b835a2a8843 100644 --- a/test/core/surface/init_test.c +++ b/test/core/surface/init_test.c @@ -53,7 +53,7 @@ static void test_plugin() { } static void test_repeatedly() { - for (int i = 0; i < 100000; i++) { + for (int i = 0; i < 1000; i++) { grpc_init(); grpc_shutdown(); } From e757adc3520e39a3f8fbaffac66f6bd13efb27ca Mon Sep 17 00:00:00 2001 From: Adele Zhou Date: Mon, 9 Oct 2017 17:40:03 -0700 Subject: [PATCH 131/142] Added allow_flakes flag and set to True by default. --- tools/interop_matrix/run_interop_matrix_tests.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/interop_matrix/run_interop_matrix_tests.py b/tools/interop_matrix/run_interop_matrix_tests.py index 510bc7124db..48c918d25d4 100755 --- a/tools/interop_matrix/run_interop_matrix_tests.py +++ b/tools/interop_matrix/run_interop_matrix_tests.py @@ -68,6 +68,13 @@ argp.add_argument('--report_file', default='report.xml', help='The result file to create.') +argp.add_argument('--allow_flakes', + default=False, + action='store_const', + const=True, + help=('Allow flaky tests to show as passing (re-runs failed ' + 'tests up to five times)')) + args = argp.parse_args() @@ -130,7 +137,8 @@ def find_test_cases(lang, release): spec = jobset.JobSpec(cmdline=line, shortname=shortname, timeout_seconds=_TEST_TIMEOUT, - shell=True) + shell=True, + flake_retries=5 if args.allow_flakes else 0) job_spec_list.append(spec) jobset.message('START', 'Loaded %s tests from %s' % (len(job_spec_list), testcases), From 9f02a27ceb0777951f84b8470a1409b20c9f2d28 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Tue, 10 Oct 2017 12:57:01 -0700 Subject: [PATCH 132/142] Update load-balancing.md --- doc/load-balancing.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/load-balancing.md b/doc/load-balancing.md index 88ff35496f3..401900af883 100644 --- a/doc/load-balancing.md +++ b/doc/load-balancing.md @@ -129,10 +129,9 @@ works: by the resolver. It asks the balancer for the server addresses to use for the server name originally requested by the client (i.e., the same one originally passed to the name resolver). - - Note: The `grpclb` policy currently ignores any non-balancer - addresses returned by the resolver. However, in the future, it - may be changed to use these addresses as a fallback in case no - balancers can be contacted. + - Note: In `grpclb` policy, the non-balancer addresses returned by + the resolver are used as a fallback in case no balancers can be + contacted. 2. The gRPC servers to which the load balancer is directing the client may report load to the load balancers, if that information is needed by the load balancer's configuration. From 9f10a587a9f92ed5750334ad98b00eafc1ae97de Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 10 Oct 2017 11:31:29 -0700 Subject: [PATCH 133/142] Make short deadlines actually expire --- test/cpp/end2end/test_service_impl.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/cpp/end2end/test_service_impl.cc b/test/cpp/end2end/test_service_impl.cc index 4fa98c24f57..156ff8308ef 100644 --- a/test/cpp/end2end/test_service_impl.cc +++ b/test/cpp/end2end/test_service_impl.cc @@ -73,6 +73,10 @@ void CheckServerAuthContext( Status TestServiceImpl::Echo(ServerContext* context, const EchoRequest* request, EchoResponse* response) { + // A bit of sleep to make sure that short deadline tests fail + gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_millis(2, GPR_TIMESPAN))); + if (request->has_param() && request->param().server_die()) { gpr_log(GPR_ERROR, "The request should not reach application handler."); GPR_ASSERT(0); From 1e91362498f0213e7b7b0065ff1390ec2f9be2c4 Mon Sep 17 00:00:00 2001 From: Anna Sapek Date: Tue, 10 Oct 2017 15:23:09 -0700 Subject: [PATCH 134/142] Fix param annotation for AddListeningPort() --- include/grpc++/server_builder.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h index bbf45b3e74c..a948abedb58 100644 --- a/include/grpc++/server_builder.h +++ b/include/grpc++/server_builder.h @@ -140,7 +140,7 @@ class ServerBuilder { /// please use IPv6 any, i.e., [::]:, which also accepts IPv4 /// connections. Valid values include dns:///localhost:1234, / /// 192.168.1.1:31416, dns:///[::1]:27182, etc.). - /// \params creds The credentials associated with the server. + /// \param creds The credentials associated with the server. /// \param selected_port[out] If not `nullptr`, gets populated with the port /// number bound to the \a grpc::Server for the corresponding endpoint after /// it is successfully bound, 0 otherwise. From a6294056c869eb1557f9c5230cd510cad9a3e12e Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 10 Oct 2017 20:47:54 -0700 Subject: [PATCH 135/142] Run ProxyEnd2End tests (without proxy) for inproc transport --- test/cpp/end2end/end2end_test.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 810ee303f2c..9c2be4d57e6 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -1407,6 +1407,10 @@ TEST_P(ProxyEnd2endTest, HugeResponse) { } TEST_P(ProxyEnd2endTest, Peer) { + // Peer is not meaningful for inproc + if (GetParam().inproc) { + return; + } ResetStub(); EchoRequest request; EchoResponse response; @@ -1775,11 +1779,10 @@ std::vector CreateTestScenarios(bool use_proxy, credentials_types.push_back(kInsecureCredentialsType); } GPR_ASSERT(!credentials_types.empty()); - for (auto it = credentials_types.begin(); it != credentials_types.end(); - ++it) { - scenarios.emplace_back(false, false, *it); + for (const auto& cred : credentials_types) { + scenarios.emplace_back(false, false, cred); if (use_proxy) { - scenarios.emplace_back(true, false, *it); + scenarios.emplace_back(true, false, cred); } } if (test_inproc && insec_ok()) { @@ -1798,7 +1801,7 @@ INSTANTIATE_TEST_CASE_P(End2endServerTryCancel, End2endServerTryCancelTest, INSTANTIATE_TEST_CASE_P(ProxyEnd2end, ProxyEnd2endTest, ::testing::ValuesIn(CreateTestScenarios(true, true, - true, false))); + true, true))); INSTANTIATE_TEST_CASE_P(SecureEnd2end, SecureEnd2endTest, ::testing::ValuesIn(CreateTestScenarios(false, false, From 07165cbaf26a2e81710c3f4c0d3cf11bf91c9abb Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 10 Oct 2017 21:00:31 -0700 Subject: [PATCH 136/142] Only put server to sleep when explicitly requested --- src/proto/grpc/testing/echo_messages.proto | 1 + test/cpp/end2end/end2end_test.cc | 2 ++ test/cpp/end2end/test_service_impl.cc | 8 ++++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/proto/grpc/testing/echo_messages.proto b/src/proto/grpc/testing/echo_messages.proto index c5c5fdb3fc4..5396a2fd39a 100644 --- a/src/proto/grpc/testing/echo_messages.proto +++ b/src/proto/grpc/testing/echo_messages.proto @@ -45,6 +45,7 @@ message RequestParams { bool server_die = 12; // Server should not see a request with this set. string binary_error_details = 13; ErrorStatus expected_error = 14; + int32 server_sleep_us = 15; // Amount to sleep when invoking server } message EchoRequest { diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 810ee303f2c..3131faa196c 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -1280,6 +1280,8 @@ TEST_P(ProxyEnd2endTest, RpcDeadlineExpires) { EchoResponse response; request.set_message("Hello"); request.mutable_param()->set_skip_cancelled_check(true); + // Let server sleep for 2 ms first to guarantee expiry + request.mutable_param()->set_server_sleep_us(2 * 1000); ClientContext context; std::chrono::system_clock::time_point deadline = diff --git a/test/cpp/end2end/test_service_impl.cc b/test/cpp/end2end/test_service_impl.cc index 156ff8308ef..e4f7c08f252 100644 --- a/test/cpp/end2end/test_service_impl.cc +++ b/test/cpp/end2end/test_service_impl.cc @@ -74,8 +74,12 @@ void CheckServerAuthContext( Status TestServiceImpl::Echo(ServerContext* context, const EchoRequest* request, EchoResponse* response) { // A bit of sleep to make sure that short deadline tests fail - gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_millis(2, GPR_TIMESPAN))); + if (request->has_param() && request->param().server_sleep_us() > 0) { + gpr_sleep_until( + gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_micros(request->param().server_sleep_us(), + GPR_TIMESPAN))); + } if (request->has_param() && request->param().server_die()) { gpr_log(GPR_ERROR, "The request should not reach application handler."); From fed13916b0f62198992220eefa742e8b3e02cc99 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 11 Oct 2017 00:07:00 -0700 Subject: [PATCH 137/142] Move h2_ssl_cert_test out of end2end fixtures, use gtest --- CMakeLists.txt | 71 +- Makefile | 82 +- build.yaml | 16 + test/core/end2end/gen_build_yaml.py | 1 - test/core/end2end/generate_tests.bzl | 1 - .../h2_ssl_cert.c => h2_ssl_cert_test.cc} | 85 +- .../generated/sources_and_headers.json | 40 +- tools/run_tests/generated/tests.json | 1360 +---------------- 8 files changed, 199 insertions(+), 1457 deletions(-) rename test/core/end2end/{fixtures/h2_ssl_cert.c => h2_ssl_cert_test.cc} (89%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 139d1bd46cb..33e613c42fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -592,7 +592,6 @@ add_dependencies(buildtests_c h2_sockpair_test) add_dependencies(buildtests_c h2_sockpair+trace_test) add_dependencies(buildtests_c h2_sockpair_1byte_test) add_dependencies(buildtests_c h2_ssl_test) -add_dependencies(buildtests_c h2_ssl_cert_test) add_dependencies(buildtests_c h2_ssl_proxy_test) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_c h2_uds_test) @@ -704,6 +703,7 @@ add_dependencies(buildtests_cxx grpc_tool_test) add_dependencies(buildtests_cxx grpclb_api_test) add_dependencies(buildtests_cxx grpclb_end2end_test) add_dependencies(buildtests_cxx grpclb_test) +add_dependencies(buildtests_cxx h2_ssl_cert_test) add_dependencies(buildtests_cxx health_service_end2end_test) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx http2_client) @@ -11163,6 +11163,45 @@ target_link_libraries(grpclb_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) +add_executable(h2_ssl_cert_test + test/core/end2end/h2_ssl_cert_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) + + +target_include_directories(h2_ssl_cert_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${BORINGSSL_ROOT_DIR}/include + PRIVATE ${PROTOBUF_ROOT_DIR}/src + PRIVATE ${BENCHMARK_ROOT_DIR}/include + PRIVATE ${ZLIB_ROOT_DIR} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib + PRIVATE ${CARES_INCLUDE_DIR} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include + PRIVATE third_party/googletest/googletest/include + PRIVATE third_party/googletest/googletest + PRIVATE third_party/googletest/googlemock/include + PRIVATE third_party/googletest/googlemock + PRIVATE ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(h2_ssl_cert_test + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + grpc++ + grpc + gpr_test_util + gpr + ${_gRPC_GFLAGS_LIBRARIES} +) + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + add_executable(health_service_end2end_test test/cpp/end2end/health_service_end2end_test.cc third_party/googletest/googletest/src/gtest-all.cc @@ -13585,36 +13624,6 @@ target_link_libraries(h2_ssl_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) -add_executable(h2_ssl_cert_test - test/core/end2end/fixtures/h2_ssl_cert.c -) - - -target_include_directories(h2_ssl_cert_test - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include - PRIVATE ${BORINGSSL_ROOT_DIR}/include - PRIVATE ${PROTOBUF_ROOT_DIR}/src - PRIVATE ${BENCHMARK_ROOT_DIR}/include - PRIVATE ${ZLIB_ROOT_DIR} - PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib - PRIVATE ${CARES_INCLUDE_DIR} - PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares - PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include -) - -target_link_libraries(h2_ssl_cert_test - ${_gRPC_ALLTARGETS_LIBRARIES} - end2end_tests - grpc_test_util - grpc - gpr_test_util - gpr -) - -endif (gRPC_BUILD_TESTS) -if (gRPC_BUILD_TESTS) - add_executable(h2_ssl_proxy_test test/core/end2end/fixtures/h2_ssl_proxy.c ) diff --git a/Makefile b/Makefile index 382956dc44e..0357f7baac6 100644 --- a/Makefile +++ b/Makefile @@ -1145,6 +1145,7 @@ grpc_tool_test: $(BINDIR)/$(CONFIG)/grpc_tool_test grpclb_api_test: $(BINDIR)/$(CONFIG)/grpclb_api_test grpclb_end2end_test: $(BINDIR)/$(CONFIG)/grpclb_end2end_test grpclb_test: $(BINDIR)/$(CONFIG)/grpclb_test +h2_ssl_cert_test: $(BINDIR)/$(CONFIG)/h2_ssl_cert_test health_service_end2end_test: $(BINDIR)/$(CONFIG)/health_service_end2end_test http2_client: $(BINDIR)/$(CONFIG)/http2_client hybrid_end2end_test: $(BINDIR)/$(CONFIG)/hybrid_end2end_test @@ -1247,7 +1248,6 @@ h2_sockpair_test: $(BINDIR)/$(CONFIG)/h2_sockpair_test h2_sockpair+trace_test: $(BINDIR)/$(CONFIG)/h2_sockpair+trace_test h2_sockpair_1byte_test: $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_test h2_ssl_test: $(BINDIR)/$(CONFIG)/h2_ssl_test -h2_ssl_cert_test: $(BINDIR)/$(CONFIG)/h2_ssl_cert_test h2_ssl_proxy_test: $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test h2_uds_test: $(BINDIR)/$(CONFIG)/h2_uds_test inproc_test: $(BINDIR)/$(CONFIG)/inproc_test @@ -1507,7 +1507,6 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/h2_sockpair+trace_test \ $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_test \ $(BINDIR)/$(CONFIG)/h2_ssl_test \ - $(BINDIR)/$(CONFIG)/h2_ssl_cert_test \ $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test \ $(BINDIR)/$(CONFIG)/h2_uds_test \ $(BINDIR)/$(CONFIG)/inproc_test \ @@ -1583,6 +1582,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/grpclb_api_test \ $(BINDIR)/$(CONFIG)/grpclb_end2end_test \ $(BINDIR)/$(CONFIG)/grpclb_test \ + $(BINDIR)/$(CONFIG)/h2_ssl_cert_test \ $(BINDIR)/$(CONFIG)/health_service_end2end_test \ $(BINDIR)/$(CONFIG)/http2_client \ $(BINDIR)/$(CONFIG)/hybrid_end2end_test \ @@ -1703,6 +1703,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/grpclb_api_test \ $(BINDIR)/$(CONFIG)/grpclb_end2end_test \ $(BINDIR)/$(CONFIG)/grpclb_test \ + $(BINDIR)/$(CONFIG)/h2_ssl_cert_test \ $(BINDIR)/$(CONFIG)/health_service_end2end_test \ $(BINDIR)/$(CONFIG)/http2_client \ $(BINDIR)/$(CONFIG)/hybrid_end2end_test \ @@ -2109,6 +2110,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/grpclb_end2end_test || ( echo test grpclb_end2end_test failed ; exit 1 ) $(E) "[RUN] Testing grpclb_test" $(Q) $(BINDIR)/$(CONFIG)/grpclb_test || ( echo test grpclb_test failed ; exit 1 ) + $(E) "[RUN] Testing h2_ssl_cert_test" + $(Q) $(BINDIR)/$(CONFIG)/h2_ssl_cert_test || ( echo test h2_ssl_cert_test failed ; exit 1 ) $(E) "[RUN] Testing health_service_end2end_test" $(Q) $(BINDIR)/$(CONFIG)/health_service_end2end_test || ( echo test health_service_end2end_test failed ; exit 1 ) $(E) "[RUN] Testing interop_test" @@ -15653,6 +15656,49 @@ endif $(OBJDIR)/$(CONFIG)/test/cpp/grpclb/grpclb_test.o: $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc +H2_SSL_CERT_TEST_SRC = \ + test/core/end2end/h2_ssl_cert_test.cc \ + +H2_SSL_CERT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_SSL_CERT_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/h2_ssl_cert_test: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. + +$(BINDIR)/$(CONFIG)/h2_ssl_cert_test: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/h2_ssl_cert_test: $(PROTOBUF_DEP) $(H2_SSL_CERT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(H2_SSL_CERT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/h2_ssl_cert_test + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/core/end2end/h2_ssl_cert_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_h2_ssl_cert_test: $(H2_SSL_CERT_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(H2_SSL_CERT_TEST_OBJS:.o=.dep) +endif +endif + + HEALTH_SERVICE_END2END_TEST_SRC = \ test/cpp/end2end/health_service_end2end_test.cc \ @@ -19100,38 +19146,6 @@ endif endif -H2_SSL_CERT_TEST_SRC = \ - test/core/end2end/fixtures/h2_ssl_cert.c \ - -H2_SSL_CERT_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_SSL_CERT_TEST_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/h2_ssl_cert_test: openssl_dep_error - -else - - - -$(BINDIR)/$(CONFIG)/h2_ssl_cert_test: $(H2_SSL_CERT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(H2_SSL_CERT_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_ssl_cert_test - -endif - -$(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_ssl_cert.o: $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - -deps_h2_ssl_cert_test: $(H2_SSL_CERT_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(H2_SSL_CERT_TEST_OBJS:.o=.dep) -endif -endif - - H2_SSL_PROXY_TEST_SRC = \ test/core/end2end/fixtures/h2_ssl_proxy.c \ diff --git a/build.yaml b/build.yaml index d23716af2af..25c5760e5e5 100644 --- a/build.yaml +++ b/build.yaml @@ -4158,6 +4158,22 @@ targets: excluded_poll_engines: - poll - poll-cv +- name: h2_ssl_cert_test + gtest: true + build: test + language: c++ + headers: + - test/core/end2end/end2end_tests.h + src: + - test/core/end2end/h2_ssl_cert_test.cc + deps: + - grpc_test_util + - grpc++ + - grpc + - gpr_test_util + - gpr + uses: + - grpc++_test - name: health_service_end2end_test gtest: true build: test diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py index 33fd97f3bd0..e1dc69994c4 100755 --- a/test/core/end2end/gen_build_yaml.py +++ b/test/core/end2end/gen_build_yaml.py @@ -60,7 +60,6 @@ END2END_FIXTURES = { 'h2_sockpair+trace': socketpair_unsecure_fixture_options._replace( ci_mac=False, tracing=True, large_writes=False, exclude_iomgrs=['uv']), 'h2_ssl': default_secure_fixture_options, - 'h2_ssl_cert': default_secure_fixture_options, 'h2_ssl_proxy': default_secure_fixture_options._replace( includes_proxy=True, ci_mac=False, exclude_iomgrs=['uv']), 'h2_uds': uds_fixture_options, diff --git a/test/core/end2end/generate_tests.bzl b/test/core/end2end/generate_tests.bzl index 9bbba26108c..d48ddb46064 100755 --- a/test/core/end2end/generate_tests.bzl +++ b/test/core/end2end/generate_tests.bzl @@ -56,7 +56,6 @@ END2END_FIXTURES = { 'h2_sockpair+trace': fixture_options(fullstack=False, dns_resolver=False, tracing=True), 'h2_ssl': fixture_options(secure=True), - 'h2_ssl_cert': fixture_options(secure=True), 'h2_ssl_proxy': fixture_options(includes_proxy=True, secure=True), 'h2_uds': fixture_options(dns_resolver=False, platforms=['linux', 'mac', 'posix']), diff --git a/test/core/end2end/fixtures/h2_ssl_cert.c b/test/core/end2end/h2_ssl_cert_test.cc similarity index 89% rename from test/core/end2end/fixtures/h2_ssl_cert.c rename to test/core/end2end/h2_ssl_cert_test.cc index f0a2ee5430e..6da5e8396ef 100644 --- a/test/core/end2end/fixtures/h2_ssl_cert.c +++ b/test/core/end2end/h2_ssl_cert_test.cc @@ -16,7 +16,9 @@ * */ +extern "C" { #include "test/core/end2end/end2end_tests.h" +} #include #include @@ -25,6 +27,7 @@ #include #include +extern "C" { #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/support/env.h" @@ -34,8 +37,12 @@ #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" +} -extern void simple_request(grpc_end2end_test_config config); +#include + +namespace grpc { +namespace testing { typedef struct fullstack_secure_fixture_data { char *localaddr; @@ -46,7 +53,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data *ffd = - gpr_malloc(sizeof(fullstack_secure_fixture_data)); + static_cast( + gpr_malloc(sizeof(fullstack_secure_fixture_data))); memset(&f, 0, sizeof(f)); gpr_join_host_port(&ffd->localaddr, "localhost", port); @@ -69,7 +77,8 @@ static void process_auth_failure(void *state, grpc_auth_context *ctx, static void chttp2_init_client_secure_fullstack( grpc_end2end_test_fixture *f, grpc_channel_args *client_args, grpc_channel_credentials *creds) { - fullstack_secure_fixture_data *ffd = f->fixture_data; + fullstack_secure_fixture_data *ffd = + static_cast(f->fixture_data); f->client = grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL); GPR_ASSERT(f->client != NULL); @@ -79,7 +88,8 @@ static void chttp2_init_client_secure_fullstack( static void chttp2_init_server_secure_fullstack( grpc_end2end_test_fixture *f, grpc_channel_args *server_args, grpc_server_credentials *server_creds) { - fullstack_secure_fixture_data *ffd = f->fixture_data; + fullstack_secure_fixture_data *ffd = + static_cast(f->fixture_data); if (f->server) { grpc_server_destroy(f->server); } @@ -92,7 +102,8 @@ static void chttp2_init_server_secure_fullstack( } void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { - fullstack_secure_fixture_data *ffd = f->fixture_data; + fullstack_secure_fixture_data *ffd = + static_cast(f->fixture_data); gpr_free(ffd->localaddr); gpr_free(ffd); } @@ -166,9 +177,10 @@ typedef enum { NONE, SELF_SIGNED, SIGNED, BAD_CERT_PAIR } certtype; } \ ssl_creds = \ grpc_ssl_credentials_create(test_root_cert, key_cert_pair, NULL); \ - grpc_arg ssl_name_override = {GRPC_ARG_STRING, \ - GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, \ - {"foo.test.google.fr"}}; \ + grpc_arg ssl_name_override = { \ + GRPC_ARG_STRING, \ + const_cast(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), \ + {const_cast("foo.test.google.fr")}}; \ grpc_channel_args *new_client_args = \ grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); \ chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds); \ @@ -248,18 +260,6 @@ static grpc_end2end_test_config_wrapper configs[] = { static void *tag(intptr_t t) { return (void *)t; } -static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char *test_name, - grpc_channel_args *client_args, - grpc_channel_args *server_args) { - grpc_end2end_test_fixture f; - gpr_log(GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture(client_args, server_args); - config.init_server(&f, server_args); - config.init_client(&f, client_args); - return f; -} - static gpr_timespec n_seconds_time(int n) { return grpc_timeout_seconds_to_deadline(n); } @@ -332,15 +332,40 @@ static void simple_request_body(grpc_end2end_test_fixture f, cq_verifier_destroy(cqv); } +class H2SslCertTest + : public ::testing::TestWithParam { + protected: + H2SslCertTest() { + gpr_log(GPR_INFO, "SSL_CERT_tests/%s", GetParam().config.name); + } + void SetUp() override { + fixture_ = GetParam().config.create_fixture(nullptr, nullptr); + GetParam().config.init_server(&fixture_, nullptr); + GetParam().config.init_client(&fixture_, nullptr); + } + void TearDown() override { + end_test(&fixture_); + GetParam().config.tear_down_data(&fixture_); + } + + grpc_end2end_test_fixture fixture_; +}; + +TEST_P(H2SslCertTest, SimpleRequestBody) { + simple_request_body(fixture_, GetParam().result); +} + +INSTANTIATE_TEST_CASE_P(H2SslCert, H2SslCertTest, ::testing::ValuesIn(configs)); + +} // namespace testing +} // namespace grpc + int main(int argc, char **argv) { - size_t i; FILE *roots_file; size_t roots_size = strlen(test_root_cert); char *roots_filename; grpc_test_init(argc, argv); - grpc_end2end_tests_pre_init(); - /* Set the SSL roots env var. */ roots_file = gpr_tmpfile("chttp2_simple_ssl_cert_fullstack_test", &roots_filename); @@ -351,21 +376,13 @@ int main(int argc, char **argv) { gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); grpc_init(); - - for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_test_fixture f = - begin_test(configs[i].config, "SSL_CERT_tests", NULL, NULL); - - simple_request_body(f, configs[i].result); - end_test(&f); - configs[i].config.tear_down_data(&f); - } - + ::testing::InitGoogleTest(&argc, argv); + int ret = RUN_ALL_TESTS(); grpc_shutdown(); /* Cleanup. */ remove(roots_filename); gpr_free(roots_filename); - return 0; + return ret; } diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index babdfeb6858..21b3bef691a 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -3489,6 +3489,28 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "gpr_test_util", + "grpc", + "grpc++", + "grpc++_test", + "grpc_test_util" + ], + "headers": [ + "test/core/end2end/end2end_tests.h" + ], + "is_filegroup": false, + "language": "c++", + "name": "h2_ssl_cert_test", + "src": [ + "test/core/end2end/end2end_tests.h", + "test/core/end2end/h2_ssl_cert_test.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", @@ -5287,24 +5309,6 @@ "third_party": false, "type": "target" }, - { - "deps": [ - "end2end_tests", - "gpr", - "gpr_test_util", - "grpc", - "grpc_test_util" - ], - "headers": [], - "is_filegroup": false, - "language": "c", - "name": "h2_ssl_cert_test", - "src": [ - "test/core/end2end/fixtures/h2_ssl_cert.c" - ], - "third_party": false, - "type": "target" - }, { "deps": [ "end2end_tests", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 83418423a20..97631f679ce 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -3627,6 +3627,28 @@ "windows" ] }, + { + "args": [], + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "h2_ssl_cert_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ] + }, { "args": [], "ci_platforms": [ @@ -26393,1344 +26415,6 @@ "posix" ] }, - { - "args": [ - "authority_not_supported" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "bad_hostname" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "bad_ping" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "binary_metadata" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "call_creds" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "cancel_after_accept" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "cancel_after_client_done" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "cancel_after_invoke" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "cancel_after_round_trip" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "cancel_before_invoke" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "cancel_in_a_vacuum" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "cancel_with_status" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "compressed_payload" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "connectivity" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [ - "uv" - ], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "default_host" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "disappearing_server" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": true, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "empty_batch" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "filter_call_init_fails" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "filter_causes_close" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "filter_latency" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "graceful_server_shutdown" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "high_initial_seqno" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "hpack_size" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "idempotent_request" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "invoke_large_request" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "keepalive_timeout" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "large_metadata" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "load_reporting_hook" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "max_concurrent_streams" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "max_connection_age" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "max_connection_idle" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [ - "uv" - ], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "max_message_length" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "negative_deadline" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "network_status_change" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "no_logging" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "no_op" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "payload" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "ping" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "ping_pong_streaming" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "registered_call" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "request_with_flags" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "request_with_payload" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "resource_quota_server" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "server_finishes_request" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "shutdown_finishes_calls" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "shutdown_finishes_tags" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "simple_cacheable_request" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "simple_delayed_request" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "simple_metadata" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "simple_request" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "stream_compression_compressed_payload" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "stream_compression_payload" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "stream_compression_ping_pong_streaming" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "streaming_error_response" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "trailing_metadata" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "workaround_cronet_compression" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "write_buffering" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "write_buffering_at_end" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "h2_ssl_cert_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, { "args": [ "authority_not_supported" From df7583e0b6f715ed06eeeda4a3f2bfc4b6940e22 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Wed, 11 Oct 2017 09:26:12 -0700 Subject: [PATCH 138/142] Update load-balancing.md --- doc/load-balancing.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/load-balancing.md b/doc/load-balancing.md index 401900af883..8ff94075b5f 100644 --- a/doc/load-balancing.md +++ b/doc/load-balancing.md @@ -129,9 +129,9 @@ works: by the resolver. It asks the balancer for the server addresses to use for the server name originally requested by the client (i.e., the same one originally passed to the name resolver). - - Note: In `grpclb` policy, the non-balancer addresses returned by - the resolver are used as a fallback in case no balancers can be - contacted. + - Note: In the `grpclb` policy, the non-balancer addresses returned + by the resolver are used as a fallback in case no balancers can be + contacted when the LB policy is started. 2. The gRPC servers to which the load balancer is directing the client may report load to the load balancers, if that information is needed by the load balancer's configuration. From 1ba537069ca8ac3b97502f66e815f9e84a73acbc Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 11 Oct 2017 10:10:23 -0700 Subject: [PATCH 139/142] Sanity check that tests declared non-polling actually don't poll --- src/core/lib/iomgr/ev_posix.cc | 18 ++++++++++++++++++ tools/run_tests/generated/tests.json | 3 ++- tools/run_tests/run_tests.py | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc index e4033fab1de..369baa621f1 100644 --- a/src/core/lib/iomgr/ev_posix.cc +++ b/src/core/lib/iomgr/ev_posix.cc @@ -61,12 +61,30 @@ typedef struct { event_engine_factory_fn factory; } event_engine_factory; +namespace { +extern "C" { +int dummypoll(struct pollfd fds[], nfds_t nfds, int timeout) { + gpr_log(GPR_ERROR, "Attempted to poll despite declaring non-polling."); + GPR_ASSERT(false); + return -1; +} +} // extern "C" + +const grpc_event_engine_vtable *init_non_polling(bool explicit_request) { + // return the simplest engine as a dummy but also override the poller + auto ret = grpc_init_poll_posix(explicit_request); + grpc_poll_function = dummypoll; + return ret; +} +} // namespace + static const event_engine_factory g_factories[] = { {"epoll1", grpc_init_epoll1_linux}, {"epollsig", grpc_init_epollsig_linux}, {"poll", grpc_init_poll_posix}, {"poll-cv", grpc_init_poll_cv_posix}, {"epollex", grpc_init_epollex_linux}, + {"none", init_non_polling}, }; static void add(const char *beg, const char *end, char ***ss, size_t *ns) { diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 4db823e0039..91c7d4c38e5 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -3811,7 +3811,8 @@ "mac", "posix", "windows" - ] + ], + "uses_polling": true }, { "args": [], diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 7c65067857f..ea21c81875d 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -286,7 +286,7 @@ class CLanguage(object): continue polling_strategies = (_POLLING_STRATEGIES.get(self.platform, ['all']) if target.get('uses_polling', True) - else ['all']) + else ['none']) if self.args.iomgr_platform == 'uv': polling_strategies = ['all'] for polling_strategy in polling_strategies: From 147a45ae8037332b15ec1e9ce9259aa8be6c915a Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 11 Oct 2017 15:19:06 -0700 Subject: [PATCH 140/142] Allow zero-duration polls in non-poller --- src/core/lib/iomgr/ev_posix.cc | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc index 369baa621f1..3a1dd8d30b3 100644 --- a/src/core/lib/iomgr/ev_posix.cc +++ b/src/core/lib/iomgr/ev_posix.cc @@ -62,18 +62,31 @@ typedef struct { } event_engine_factory; namespace { + extern "C" { -int dummypoll(struct pollfd fds[], nfds_t nfds, int timeout) { - gpr_log(GPR_ERROR, "Attempted to poll despite declaring non-polling."); - GPR_ASSERT(false); - return -1; + +grpc_poll_function_type real_poll_function; + +int dummy_poll(struct pollfd fds[], nfds_t nfds, int timeout) { + if (timeout == 0) { + return real_poll_function(fds, nfds, 0); + } else { + gpr_log(GPR_ERROR, "Attempted a blocking poll when declared non-polling."); + GPR_ASSERT(false); + return -1; + } } } // extern "C" const grpc_event_engine_vtable *init_non_polling(bool explicit_request) { + if (!explicit_request) { + return nullptr; + } // return the simplest engine as a dummy but also override the poller auto ret = grpc_init_poll_posix(explicit_request); - grpc_poll_function = dummypoll; + real_poll_function = grpc_poll_function; + grpc_poll_function = dummy_poll; + return ret; } } // namespace From d0703a65f17f34ded3556531ea06cd5c005aa0a9 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 11 Oct 2017 20:55:06 -0700 Subject: [PATCH 141/142] Get latency profiles back up and working --- src/core/lib/profiling/basic_timers.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/lib/profiling/basic_timers.cc b/src/core/lib/profiling/basic_timers.cc index ab9d60481cc..0ae7d7f6002 100644 --- a/src/core/lib/profiling/basic_timers.cc +++ b/src/core/lib/profiling/basic_timers.cc @@ -209,9 +209,9 @@ static void init_output() { static void rotate_log() { /* Using malloc here, as this code could end up being called by gpr_malloc */ - gpr_timer_log *new = malloc(sizeof(*new)); + gpr_timer_log *log = static_cast(malloc(sizeof(*log))); gpr_once_init(&g_once_init, init_output); - new->num_entries = 0; + log->num_entries = 0; pthread_mutex_lock(&g_mu); if (g_thread_log != NULL) { timer_log_remove(&g_in_progress_logs, g_thread_log); @@ -221,9 +221,9 @@ static void rotate_log() { } else { g_thread_id = g_next_thread_id++; } - timer_log_push_back(&g_in_progress_logs, new); + timer_log_push_back(&g_in_progress_logs, log); pthread_mutex_unlock(&g_mu); - g_thread_log = new; + g_thread_log = log; } static void gpr_timers_log_add(const char *tagstr, marker_type type, From 4f0cd0e82c425533bef9f7ab8119cc542bcc9a41 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Fri, 22 Sep 2017 23:34:43 -0700 Subject: [PATCH 142/142] Add flow control to inproc transport so send needs a matching recv; fix some tests that assumed some sends could always go out --- .../ext/transport/inproc/inproc_transport.cc | 669 ++++++++---------- test/core/end2end/gen_build_yaml.py | 19 +- test/core/end2end/generate_tests.bzl | 20 +- .../end2end/tests/streaming_error_response.c | 1 - test/cpp/end2end/async_end2end_test.cc | 182 +++-- tools/run_tests/generated/tests.json | 92 --- 6 files changed, 445 insertions(+), 538 deletions(-) diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc index 1001d74c22c..67a8358927c 100644 --- a/src/core/ext/transport/inproc/inproc_transport.cc +++ b/src/core/ext/transport/inproc/inproc_transport.cc @@ -62,96 +62,22 @@ typedef struct inproc_transport { struct inproc_stream *stream_list; } inproc_transport; -typedef struct sb_list_entry { - grpc_slice_buffer sb; - struct sb_list_entry *next; -} sb_list_entry; - -// Specialize grpc_byte_stream for our use case -typedef struct { - grpc_byte_stream base; - sb_list_entry *le; - grpc_error *shutdown_error; -} inproc_slice_byte_stream; - -typedef struct { - // TODO (vjpai): Add some inlined elements to avoid alloc in simple cases - sb_list_entry *head; - sb_list_entry *tail; -} slice_buffer_list; - -static void slice_buffer_list_init(slice_buffer_list *l) { - l->head = NULL; - l->tail = NULL; -} - -static void sb_list_entry_destroy(grpc_exec_ctx *exec_ctx, sb_list_entry *le) { - grpc_slice_buffer_destroy_internal(exec_ctx, &le->sb); - gpr_free(le); -} - -static void slice_buffer_list_destroy(grpc_exec_ctx *exec_ctx, - slice_buffer_list *l) { - sb_list_entry *curr = l->head; - while (curr != NULL) { - sb_list_entry *le = curr; - curr = curr->next; - sb_list_entry_destroy(exec_ctx, le); - } - l->head = NULL; - l->tail = NULL; -} - -static bool slice_buffer_list_empty(slice_buffer_list *l) { - return l->head == NULL; -} - -static void slice_buffer_list_append_entry(slice_buffer_list *l, - sb_list_entry *next) { - next->next = NULL; - if (l->tail) { - l->tail->next = next; - l->tail = next; - } else { - l->head = next; - l->tail = next; - } -} - -static grpc_slice_buffer *slice_buffer_list_append(slice_buffer_list *l) { - sb_list_entry *next = (sb_list_entry *)gpr_malloc(sizeof(*next)); - grpc_slice_buffer_init(&next->sb); - slice_buffer_list_append_entry(l, next); - return &next->sb; -} - -static sb_list_entry *slice_buffer_list_pophead(slice_buffer_list *l) { - sb_list_entry *ret = l->head; - l->head = l->head->next; - if (l->head == NULL) { - l->tail = NULL; - } - return ret; -} - typedef struct inproc_stream { inproc_transport *t; grpc_metadata_batch to_read_initial_md; uint32_t to_read_initial_md_flags; bool to_read_initial_md_filled; - slice_buffer_list to_read_message; grpc_metadata_batch to_read_trailing_md; bool to_read_trailing_md_filled; - bool reads_needed; - bool read_closure_scheduled; - grpc_closure read_closure; + bool ops_needed; + bool op_closure_scheduled; + grpc_closure op_closure; // Write buffer used only during gap at init time when client-side // stream is set up but server side stream is not yet set up grpc_metadata_batch write_buffer_initial_md; bool write_buffer_initial_md_filled; uint32_t write_buffer_initial_md_flags; grpc_millis write_buffer_deadline; - slice_buffer_list write_buffer_message; grpc_metadata_batch write_buffer_trailing_md; bool write_buffer_trailing_md_filled; grpc_error *write_buffer_cancel_error; @@ -164,11 +90,15 @@ typedef struct inproc_stream { gpr_arena *arena; + grpc_transport_stream_op_batch *send_message_op; + grpc_transport_stream_op_batch *send_trailing_md_op; grpc_transport_stream_op_batch *recv_initial_md_op; grpc_transport_stream_op_batch *recv_message_op; grpc_transport_stream_op_batch *recv_trailing_md_op; - inproc_slice_byte_stream recv_message_stream; + grpc_slice_buffer recv_message; + grpc_slice_buffer_stream recv_stream; + bool recv_inited; bool initial_md_sent; bool trailing_md_sent; @@ -187,54 +117,11 @@ typedef struct inproc_stream { struct inproc_stream *stream_list_next; } inproc_stream; -static bool inproc_slice_byte_stream_next(grpc_exec_ctx *exec_ctx, - grpc_byte_stream *bs, size_t max, - grpc_closure *on_complete) { - // Because inproc transport always provides the entire message atomically, - // the byte stream always has data available when this function is called. - // Thus, this function always returns true (unlike other transports) and - // there is never any need to schedule a closure - return true; -} - -static grpc_error *inproc_slice_byte_stream_pull(grpc_exec_ctx *exec_ctx, - grpc_byte_stream *bs, - grpc_slice *slice) { - inproc_slice_byte_stream *stream = (inproc_slice_byte_stream *)bs; - if (stream->shutdown_error != GRPC_ERROR_NONE) { - return GRPC_ERROR_REF(stream->shutdown_error); - } - *slice = grpc_slice_buffer_take_first(&stream->le->sb); - return GRPC_ERROR_NONE; -} - -static void inproc_slice_byte_stream_shutdown(grpc_exec_ctx *exec_ctx, - grpc_byte_stream *bs, - grpc_error *error) { - inproc_slice_byte_stream *stream = (inproc_slice_byte_stream *)bs; - GRPC_ERROR_UNREF(stream->shutdown_error); - stream->shutdown_error = error; -} - -static void inproc_slice_byte_stream_destroy(grpc_exec_ctx *exec_ctx, - grpc_byte_stream *bs) { - inproc_slice_byte_stream *stream = (inproc_slice_byte_stream *)bs; - sb_list_entry_destroy(exec_ctx, stream->le); - GRPC_ERROR_UNREF(stream->shutdown_error); -} - -static const grpc_byte_stream_vtable inproc_slice_byte_stream_vtable = { - inproc_slice_byte_stream_next, inproc_slice_byte_stream_pull, - inproc_slice_byte_stream_shutdown, inproc_slice_byte_stream_destroy}; - -void inproc_slice_byte_stream_init(inproc_slice_byte_stream *s, - sb_list_entry *le) { - s->base.length = (uint32_t)le->sb.length; - s->base.flags = 0; - s->base.vtable = &inproc_slice_byte_stream_vtable; - s->le = le; - s->shutdown_error = GRPC_ERROR_NONE; -} +static grpc_closure do_nothing_closure; +static bool cancel_stream_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s, + grpc_error *error); +static void op_state_machine(grpc_exec_ctx *exec_ctx, void *arg, + grpc_error *error); static void ref_transport(inproc_transport *t) { INPROC_LOG(GPR_DEBUG, "ref_transport %p", t); @@ -280,12 +167,14 @@ static void unref_stream(grpc_exec_ctx *exec_ctx, inproc_stream *s, static void really_destroy_stream(grpc_exec_ctx *exec_ctx, inproc_stream *s) { INPROC_LOG(GPR_DEBUG, "really_destroy_stream %p", s); - slice_buffer_list_destroy(exec_ctx, &s->to_read_message); - slice_buffer_list_destroy(exec_ctx, &s->write_buffer_message); GRPC_ERROR_UNREF(s->write_buffer_cancel_error); GRPC_ERROR_UNREF(s->cancel_self_error); GRPC_ERROR_UNREF(s->cancel_other_error); + if (s->recv_inited) { + grpc_slice_buffer_destroy_internal(exec_ctx, &s->recv_message); + } + unref_transport(exec_ctx, s->t); if (s->closure_at_destroy) { @@ -293,9 +182,6 @@ static void really_destroy_stream(grpc_exec_ctx *exec_ctx, inproc_stream *s) { } } -static void read_state_machine(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error); - static void log_metadata(const grpc_metadata_batch *md_batch, bool is_client, bool is_initial) { for (grpc_linked_mdelem *md = md_batch->list.head; md != NULL; @@ -359,11 +245,9 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt, s->write_buffer_initial_md_filled = false; grpc_metadata_batch_init(&s->write_buffer_trailing_md); s->write_buffer_trailing_md_filled = false; - slice_buffer_list_init(&s->to_read_message); - slice_buffer_list_init(&s->write_buffer_message); - s->reads_needed = false; - s->read_closure_scheduled = false; - GRPC_CLOSURE_INIT(&s->read_closure, read_state_machine, s, + s->ops_needed = false; + s->op_closure_scheduled = false; + GRPC_CLOSURE_INIT(&s->op_closure, op_state_machine, s, grpc_schedule_on_exec_ctx); s->t = t; s->closure_at_destroy = NULL; @@ -425,11 +309,6 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt, grpc_metadata_batch_clear(exec_ctx, &cs->write_buffer_initial_md); cs->write_buffer_initial_md_filled = false; } - while (!slice_buffer_list_empty(&cs->write_buffer_message)) { - slice_buffer_list_append_entry( - &s->to_read_message, - slice_buffer_list_pophead(&cs->write_buffer_message)); - } if (cs->write_buffer_trailing_md_filled) { fill_in_metadata(exec_ctx, s, &cs->write_buffer_trailing_md, 0, &s->to_read_trailing_md, NULL, @@ -488,9 +367,39 @@ static void close_other_side_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s, } } +// Call the on_complete closure associated with this stream_op_batch if +// this stream_op_batch is only one of the pending operations for this +// stream. This is called when one of the pending operations for the stream +// is done and about to be NULLed out +static void complete_if_batch_end_locked(grpc_exec_ctx *exec_ctx, + inproc_stream *s, grpc_error *error, + grpc_transport_stream_op_batch *op, + const char *msg) { + int is_sm = (int)(op == s->send_message_op); + int is_stm = (int)(op == s->send_trailing_md_op); + int is_rim = (int)(op == s->recv_initial_md_op); + int is_rm = (int)(op == s->recv_message_op); + int is_rtm = (int)(op == s->recv_trailing_md_op); + + if ((is_sm + is_stm + is_rim + is_rm + is_rtm) == 1) { + INPROC_LOG(GPR_DEBUG, "%s %p %p %p", msg, s, op, error); + GRPC_CLOSURE_SCHED(exec_ctx, op->on_complete, GRPC_ERROR_REF(error)); + } +} + +static void maybe_schedule_op_closure_locked(grpc_exec_ctx *exec_ctx, + inproc_stream *s, + grpc_error *error) { + if (s && s->ops_needed && !s->op_closure_scheduled) { + GRPC_CLOSURE_SCHED(exec_ctx, &s->op_closure, GRPC_ERROR_REF(error)); + s->op_closure_scheduled = true; + s->ops_needed = false; + } +} + static void fail_helper_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s, grpc_error *error) { - INPROC_LOG(GPR_DEBUG, "read_state_machine %p fail_helper", s); + INPROC_LOG(GPR_DEBUG, "op_state_machine %p fail_helper", s); // If we're failing this side, we need to make sure that // we also send or have already sent trailing metadata if (!s->trailing_md_sent) { @@ -512,14 +421,7 @@ static void fail_helper_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s, if (other->cancel_other_error == GRPC_ERROR_NONE) { other->cancel_other_error = GRPC_ERROR_REF(error); } - if (other->reads_needed) { - if (!other->read_closure_scheduled) { - GRPC_CLOSURE_SCHED(exec_ctx, &other->read_closure, - GRPC_ERROR_REF(error)); - other->read_closure_scheduled = true; - } - other->reads_needed = false; - } + maybe_schedule_op_closure_locked(exec_ctx, other, error); } else if (s->write_buffer_cancel_error == GRPC_ERROR_NONE) { s->write_buffer_cancel_error = GRPC_ERROR_REF(error); } @@ -564,14 +466,9 @@ static void fail_helper_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s, err); // Last use of err so no need to REF and then UNREF it - if ((s->recv_initial_md_op != s->recv_message_op) && - (s->recv_initial_md_op != s->recv_trailing_md_op)) { - INPROC_LOG(GPR_DEBUG, - "fail_helper %p scheduling initial-metadata-on-complete %p", - error, s); - GRPC_CLOSURE_SCHED(exec_ctx, s->recv_initial_md_op->on_complete, - GRPC_ERROR_REF(error)); - } + complete_if_batch_end_locked( + exec_ctx, s, error, s->recv_initial_md_op, + "fail_helper scheduling recv-initial-metadata-on-complete"); s->recv_initial_md_op = NULL; } if (s->recv_message_op) { @@ -580,20 +477,30 @@ static void fail_helper_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s, GRPC_CLOSURE_SCHED( exec_ctx, s->recv_message_op->payload->recv_message.recv_message_ready, GRPC_ERROR_REF(error)); - if (s->recv_message_op != s->recv_trailing_md_op) { - INPROC_LOG(GPR_DEBUG, "fail_helper %p scheduling message-on-complete %p", - s, error); - GRPC_CLOSURE_SCHED(exec_ctx, s->recv_message_op->on_complete, - GRPC_ERROR_REF(error)); - } + complete_if_batch_end_locked( + exec_ctx, s, error, s->recv_message_op, + "fail_helper scheduling recv-message-on-complete"); s->recv_message_op = NULL; } + if (s->send_message_op) { + complete_if_batch_end_locked( + exec_ctx, s, error, s->send_message_op, + "fail_helper scheduling send-message-on-complete"); + s->send_message_op = NULL; + } + if (s->send_trailing_md_op) { + complete_if_batch_end_locked( + exec_ctx, s, error, s->send_trailing_md_op, + "fail_helper scheduling send-trailng-md-on-complete"); + s->send_trailing_md_op = NULL; + } if (s->recv_trailing_md_op) { INPROC_LOG(GPR_DEBUG, "fail_helper %p scheduling trailing-md-on-complete %p", s, error); - GRPC_CLOSURE_SCHED(exec_ctx, s->recv_trailing_md_op->on_complete, - GRPC_ERROR_REF(error)); + complete_if_batch_end_locked( + exec_ctx, s, error, s->recv_trailing_md_op, + "fail_helper scheduling recv-trailing-metadata-on-complete"); s->recv_trailing_md_op = NULL; } close_other_side_locked(exec_ctx, s, "fail_helper:other_side"); @@ -602,12 +509,61 @@ static void fail_helper_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s, GRPC_ERROR_UNREF(error); } -static void read_state_machine(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void message_transfer_locked(grpc_exec_ctx *exec_ctx, + inproc_stream *sender, + inproc_stream *receiver) { + size_t remaining = + sender->send_message_op->payload->send_message.send_message->length; + if (receiver->recv_inited) { + grpc_slice_buffer_destroy_internal(exec_ctx, &receiver->recv_message); + } + grpc_slice_buffer_init(&receiver->recv_message); + receiver->recv_inited = true; + do { + grpc_slice message_slice; + grpc_closure unused; + GPR_ASSERT(grpc_byte_stream_next( + exec_ctx, sender->send_message_op->payload->send_message.send_message, + SIZE_MAX, &unused)); + grpc_error *error = grpc_byte_stream_pull( + exec_ctx, sender->send_message_op->payload->send_message.send_message, + &message_slice); + if (error != GRPC_ERROR_NONE) { + cancel_stream_locked(exec_ctx, sender, GRPC_ERROR_REF(error)); + break; + } + GPR_ASSERT(error == GRPC_ERROR_NONE); + remaining -= GRPC_SLICE_LENGTH(message_slice); + grpc_slice_buffer_add(&receiver->recv_message, message_slice); + } while (remaining > 0); + + grpc_slice_buffer_stream_init(&receiver->recv_stream, &receiver->recv_message, + 0); + *receiver->recv_message_op->payload->recv_message.recv_message = + &receiver->recv_stream.base; + INPROC_LOG(GPR_DEBUG, "message_transfer_locked %p scheduling message-ready", + receiver); + GRPC_CLOSURE_SCHED( + exec_ctx, + receiver->recv_message_op->payload->recv_message.recv_message_ready, + GRPC_ERROR_NONE); + complete_if_batch_end_locked( + exec_ctx, sender, GRPC_ERROR_NONE, sender->send_message_op, + "message_transfer scheduling sender on_complete"); + complete_if_batch_end_locked( + exec_ctx, receiver, GRPC_ERROR_NONE, receiver->recv_message_op, + "message_transfer scheduling receiver on_complete"); + + receiver->recv_message_op = NULL; + sender->send_message_op = NULL; +} + +static void op_state_machine(grpc_exec_ctx *exec_ctx, void *arg, + grpc_error *error) { // This function gets called when we have contents in the unprocessed reads // Get what we want based on our ops wanted // Schedule our appropriate closures - // and then return to reads_needed state if still needed + // and then return to ops_needed state if still needed // Since this is a closure directly invoked by the combiner, it should not // unref the error parameter explicitly; the combiner will do that implicitly @@ -615,12 +571,14 @@ static void read_state_machine(grpc_exec_ctx *exec_ctx, void *arg, bool needs_close = false; - INPROC_LOG(GPR_DEBUG, "read_state_machine %p", arg); + INPROC_LOG(GPR_DEBUG, "op_state_machine %p", arg); inproc_stream *s = (inproc_stream *)arg; gpr_mu *mu = &s->t->mu->mu; // keep aside in case s gets closed gpr_mu_lock(mu); - s->read_closure_scheduled = false; + s->op_closure_scheduled = false; // cancellation takes precedence + inproc_stream *other = s->other_side; + if (s->cancel_self_error != GRPC_ERROR_NONE) { fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(s->cancel_self_error)); goto done; @@ -632,89 +590,116 @@ static void read_state_machine(grpc_exec_ctx *exec_ctx, void *arg, goto done; } - if (s->recv_initial_md_op) { - if (!s->to_read_initial_md_filled) { - // We entered the state machine on some other kind of read even though - // we still haven't satisfied initial md . That's an error. - new_err = - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unexpected frame sequencing"); - INPROC_LOG(GPR_DEBUG, - "read_state_machine %p scheduling on_complete errors for no " - "initial md %p", - s, new_err); + if (s->send_message_op && other) { + if (other->recv_message_op) { + message_transfer_locked(exec_ctx, s, other); + maybe_schedule_op_closure_locked(exec_ctx, other, GRPC_ERROR_NONE); + } else if (!s->t->is_client && + (s->trailing_md_sent || other->recv_trailing_md_op)) { + // A server send will never be matched if the client is waiting + // for trailing metadata already + complete_if_batch_end_locked( + exec_ctx, s, GRPC_ERROR_NONE, s->send_message_op, + "op_state_machine scheduling send-message-on-complete"); + s->send_message_op = NULL; + } + } + // Pause a send trailing metadata if there is still an outstanding + // send message unless we know that the send message will never get + // matched to a receive. This happens on the client if the server has + // already sent status. + if (s->send_trailing_md_op && + (!s->send_message_op || + (s->t->is_client && + (s->trailing_md_recvd || s->to_read_trailing_md_filled)))) { + grpc_metadata_batch *dest = (other == NULL) ? &s->write_buffer_trailing_md + : &other->to_read_trailing_md; + bool *destfilled = (other == NULL) ? &s->write_buffer_trailing_md_filled + : &other->to_read_trailing_md_filled; + if (*destfilled || s->trailing_md_sent) { + // The buffer is already in use; that's an error! + INPROC_LOG(GPR_DEBUG, "Extra trailing metadata %p", s); + new_err = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Extra trailing metadata"); fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err)); goto done; - } else if (s->initial_md_recvd) { + } else { + if (other && !other->closed) { + fill_in_metadata(exec_ctx, s, + s->send_trailing_md_op->payload->send_trailing_metadata + .send_trailing_metadata, + 0, dest, NULL, destfilled); + } + s->trailing_md_sent = true; + if (!s->t->is_client && s->trailing_md_recvd && s->recv_trailing_md_op) { + INPROC_LOG(GPR_DEBUG, + "op_state_machine %p scheduling trailing-md-on-complete", s); + GRPC_CLOSURE_SCHED(exec_ctx, s->recv_trailing_md_op->on_complete, + GRPC_ERROR_NONE); + s->recv_trailing_md_op = NULL; + needs_close = true; + } + } + maybe_schedule_op_closure_locked(exec_ctx, other, GRPC_ERROR_NONE); + complete_if_batch_end_locked( + exec_ctx, s, GRPC_ERROR_NONE, s->send_trailing_md_op, + "op_state_machine scheduling send-trailing-metadata-on-complete"); + s->send_trailing_md_op = NULL; + } + if (s->recv_initial_md_op) { + if (s->initial_md_recvd) { new_err = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already recvd initial md"); INPROC_LOG( GPR_DEBUG, - "read_state_machine %p scheduling on_complete errors for already " + "op_state_machine %p scheduling on_complete errors for already " "recvd initial md %p", s, new_err); fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err)); goto done; } - s->initial_md_recvd = true; - new_err = fill_in_metadata( - exec_ctx, s, &s->to_read_initial_md, s->to_read_initial_md_flags, - s->recv_initial_md_op->payload->recv_initial_metadata - .recv_initial_metadata, - s->recv_initial_md_op->payload->recv_initial_metadata.recv_flags, NULL); - s->recv_initial_md_op->payload->recv_initial_metadata.recv_initial_metadata - ->deadline = s->deadline; - grpc_metadata_batch_clear(exec_ctx, &s->to_read_initial_md); - s->to_read_initial_md_filled = false; - INPROC_LOG(GPR_DEBUG, - "read_state_machine %p scheduling initial-metadata-ready %p", s, - new_err); - GRPC_CLOSURE_SCHED(exec_ctx, - s->recv_initial_md_op->payload->recv_initial_metadata - .recv_initial_metadata_ready, - GRPC_ERROR_REF(new_err)); - if ((s->recv_initial_md_op != s->recv_message_op) && - (s->recv_initial_md_op != s->recv_trailing_md_op)) { - INPROC_LOG( - GPR_DEBUG, - "read_state_machine %p scheduling initial-metadata-on-complete %p", s, - new_err); - GRPC_CLOSURE_SCHED(exec_ctx, s->recv_initial_md_op->on_complete, - GRPC_ERROR_REF(new_err)); - } - s->recv_initial_md_op = NULL; - - if (new_err != GRPC_ERROR_NONE) { + if (s->to_read_initial_md_filled) { + s->initial_md_recvd = true; + new_err = fill_in_metadata( + exec_ctx, s, &s->to_read_initial_md, s->to_read_initial_md_flags, + s->recv_initial_md_op->payload->recv_initial_metadata + .recv_initial_metadata, + s->recv_initial_md_op->payload->recv_initial_metadata.recv_flags, + NULL); + s->recv_initial_md_op->payload->recv_initial_metadata + .recv_initial_metadata->deadline = s->deadline; + grpc_metadata_batch_clear(exec_ctx, &s->to_read_initial_md); + s->to_read_initial_md_filled = false; INPROC_LOG(GPR_DEBUG, - "read_state_machine %p scheduling on_complete errors2 %p", s, + "op_state_machine %p scheduling initial-metadata-ready %p", s, new_err); - fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err)); - goto done; + GRPC_CLOSURE_SCHED(exec_ctx, + s->recv_initial_md_op->payload->recv_initial_metadata + .recv_initial_metadata_ready, + GRPC_ERROR_REF(new_err)); + complete_if_batch_end_locked( + exec_ctx, s, new_err, s->recv_initial_md_op, + "op_state_machine scheduling recv-initial-metadata-on-complete"); + s->recv_initial_md_op = NULL; + + if (new_err != GRPC_ERROR_NONE) { + INPROC_LOG(GPR_DEBUG, + "op_state_machine %p scheduling on_complete errors2 %p", s, + new_err); + fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err)); + goto done; + } } } - if (s->to_read_initial_md_filled) { - new_err = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unexpected recv frame"); - fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err)); - goto done; - } - if (!slice_buffer_list_empty(&s->to_read_message) && s->recv_message_op) { - inproc_slice_byte_stream_init( - &s->recv_message_stream, - slice_buffer_list_pophead(&s->to_read_message)); - *s->recv_message_op->payload->recv_message.recv_message = - &s->recv_message_stream.base; - INPROC_LOG(GPR_DEBUG, "read_state_machine %p scheduling message-ready", s); - GRPC_CLOSURE_SCHED( - exec_ctx, s->recv_message_op->payload->recv_message.recv_message_ready, - GRPC_ERROR_NONE); - if (s->recv_message_op != s->recv_trailing_md_op) { - INPROC_LOG(GPR_DEBUG, - "read_state_machine %p scheduling message-on-complete %p", s, - new_err); - GRPC_CLOSURE_SCHED(exec_ctx, s->recv_message_op->on_complete, - GRPC_ERROR_REF(new_err)); + if (s->recv_message_op) { + if (other && other->send_message_op) { + message_transfer_locked(exec_ctx, other, s); + maybe_schedule_op_closure_locked(exec_ctx, other, GRPC_ERROR_NONE); } - s->recv_message_op = NULL; + } + if (s->recv_trailing_md_op && s->t->is_client && other && + other->send_message_op) { + maybe_schedule_op_closure_locked(exec_ctx, other, GRPC_ERROR_NONE); } if (s->to_read_trailing_md_filled) { if (s->trailing_md_recvd) { @@ -722,7 +707,7 @@ static void read_state_machine(grpc_exec_ctx *exec_ctx, void *arg, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already recvd trailing md"); INPROC_LOG( GPR_DEBUG, - "read_state_machine %p scheduling on_complete errors for already " + "op_state_machine %p scheduling on_complete errors for already " "recvd trailing md %p", s, new_err); fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err)); @@ -731,21 +716,24 @@ static void read_state_machine(grpc_exec_ctx *exec_ctx, void *arg, if (s->recv_message_op != NULL) { // This message needs to be wrapped up because it will never be // satisfied - INPROC_LOG(GPR_DEBUG, "read_state_machine %p scheduling message-ready", - s); + INPROC_LOG(GPR_DEBUG, "op_state_machine %p scheduling message-ready", s); GRPC_CLOSURE_SCHED( exec_ctx, s->recv_message_op->payload->recv_message.recv_message_ready, GRPC_ERROR_NONE); - if (s->recv_message_op != s->recv_trailing_md_op) { - INPROC_LOG(GPR_DEBUG, - "read_state_machine %p scheduling message-on-complete %p", s, - new_err); - GRPC_CLOSURE_SCHED(exec_ctx, s->recv_message_op->on_complete, - GRPC_ERROR_REF(new_err)); - } + complete_if_batch_end_locked( + exec_ctx, s, new_err, s->recv_message_op, + "op_state_machine scheduling recv-message-on-complete"); s->recv_message_op = NULL; } + if ((s->trailing_md_sent || s->t->is_client) && s->send_message_op) { + // Nothing further will try to receive from this stream, so finish off + // any outstanding send_message op + complete_if_batch_end_locked( + exec_ctx, s, new_err, s->send_message_op, + "op_state_machine scheduling send-message-on-complete"); + s->send_message_op = NULL; + } if (s->recv_trailing_md_op != NULL) { // We wanted trailing metadata and we got it s->trailing_md_recvd = true; @@ -763,61 +751,65 @@ static void read_state_machine(grpc_exec_ctx *exec_ctx, void *arg, // (If the server hasn't already sent its trailing md, it doesn't have // a final status, so don't mark this op complete) if (s->t->is_client || s->trailing_md_sent) { - INPROC_LOG( - GPR_DEBUG, - "read_state_machine %p scheduling trailing-md-on-complete %p", s, - new_err); + INPROC_LOG(GPR_DEBUG, + "op_state_machine %p scheduling trailing-md-on-complete %p", + s, new_err); GRPC_CLOSURE_SCHED(exec_ctx, s->recv_trailing_md_op->on_complete, GRPC_ERROR_REF(new_err)); s->recv_trailing_md_op = NULL; needs_close = true; } else { INPROC_LOG(GPR_DEBUG, - "read_state_machine %p server needs to delay handling " + "op_state_machine %p server needs to delay handling " "trailing-md-on-complete %p", s, new_err); } } else { INPROC_LOG( GPR_DEBUG, - "read_state_machine %p has trailing md but not yet waiting for it", - s); + "op_state_machine %p has trailing md but not yet waiting for it", s); } } if (s->trailing_md_recvd && s->recv_message_op) { // No further message will come on this stream, so finish off the // recv_message_op - INPROC_LOG(GPR_DEBUG, "read_state_machine %p scheduling message-ready", s); + INPROC_LOG(GPR_DEBUG, "op_state_machine %p scheduling message-ready", s); GRPC_CLOSURE_SCHED( exec_ctx, s->recv_message_op->payload->recv_message.recv_message_ready, GRPC_ERROR_NONE); - if (s->recv_message_op != s->recv_trailing_md_op) { - INPROC_LOG(GPR_DEBUG, - "read_state_machine %p scheduling message-on-complete %p", s, - new_err); - GRPC_CLOSURE_SCHED(exec_ctx, s->recv_message_op->on_complete, - GRPC_ERROR_REF(new_err)); - } + complete_if_batch_end_locked( + exec_ctx, s, new_err, s->recv_message_op, + "op_state_machine scheduling recv-message-on-complete"); s->recv_message_op = NULL; } - if (s->recv_message_op || s->recv_trailing_md_op) { + if (s->trailing_md_recvd && (s->trailing_md_sent || s->t->is_client) && + s->send_message_op) { + // Nothing further will try to receive from this stream, so finish off + // any outstanding send_message op + complete_if_batch_end_locked( + exec_ctx, s, new_err, s->send_message_op, + "op_state_machine scheduling send-message-on-complete"); + s->send_message_op = NULL; + } + if (s->send_message_op || s->send_trailing_md_op || s->recv_initial_md_op || + s->recv_message_op || s->recv_trailing_md_op) { // Didn't get the item we wanted so we still need to get // rescheduled - INPROC_LOG(GPR_DEBUG, "read_state_machine %p still needs closure %p %p", s, - s->recv_message_op, s->recv_trailing_md_op); - s->reads_needed = true; + INPROC_LOG( + GPR_DEBUG, "op_state_machine %p still needs closure %p %p %p %p %p", s, + s->send_message_op, s->send_trailing_md_op, s->recv_initial_md_op, + s->recv_message_op, s->recv_trailing_md_op); + s->ops_needed = true; } done: if (needs_close) { - close_other_side_locked(exec_ctx, s, "read_state_machine"); + close_other_side_locked(exec_ctx, s, "op_state_machine"); close_stream_locked(exec_ctx, s); } gpr_mu_unlock(mu); GRPC_ERROR_UNREF(new_err); } -static grpc_closure do_nothing_closure; - static bool cancel_stream_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s, grpc_error *error) { bool ret = false; // was the cancel accepted @@ -826,14 +818,7 @@ static bool cancel_stream_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s, if (s->cancel_self_error == GRPC_ERROR_NONE) { ret = true; s->cancel_self_error = GRPC_ERROR_REF(error); - if (s->reads_needed) { - if (!s->read_closure_scheduled) { - GRPC_CLOSURE_SCHED(exec_ctx, &s->read_closure, - GRPC_ERROR_REF(s->cancel_self_error)); - s->read_closure_scheduled = true; - } - s->reads_needed = false; - } + maybe_schedule_op_closure_locked(exec_ctx, s, s->cancel_self_error); // Send trailing md to the other side indicating cancellation, even if we // already have s->trailing_md_sent = true; @@ -853,14 +838,8 @@ static bool cancel_stream_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s, if (other->cancel_other_error == GRPC_ERROR_NONE) { other->cancel_other_error = GRPC_ERROR_REF(s->cancel_self_error); } - if (other->reads_needed) { - if (!other->read_closure_scheduled) { - GRPC_CLOSURE_SCHED(exec_ctx, &other->read_closure, - GRPC_ERROR_REF(other->cancel_other_error)); - other->read_closure_scheduled = true; - } - other->reads_needed = false; - } + maybe_schedule_op_closure_locked(exec_ctx, other, + other->cancel_other_error); } else if (s->write_buffer_cancel_error == GRPC_ERROR_NONE) { s->write_buffer_cancel_error = GRPC_ERROR_REF(s->cancel_self_error); } @@ -869,11 +848,9 @@ static bool cancel_stream_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s, // couldn't complete that because we hadn't yet sent out trailing // md, now's the chance if (!s->t->is_client && s->trailing_md_recvd && s->recv_trailing_md_op) { - INPROC_LOG(GPR_DEBUG, - "cancel_stream %p scheduling trailing-md-on-complete %p", s, - s->cancel_self_error); - GRPC_CLOSURE_SCHED(exec_ctx, s->recv_trailing_md_op->on_complete, - GRPC_ERROR_REF(s->cancel_self_error)); + complete_if_batch_end_locked( + exec_ctx, s, s->cancel_self_error, s->recv_trailing_md_op, + "cancel_stream scheduling trailing-md-on-complete"); s->recv_trailing_md_op = NULL; } } @@ -918,7 +895,8 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt, // already self-canceled so still give it an error error = GRPC_ERROR_REF(s->cancel_self_error); } else { - INPROC_LOG(GPR_DEBUG, "perform_stream_op %p%s%s%s%s%s%s", s, + INPROC_LOG(GPR_DEBUG, "perform_stream_op %p %s%s%s%s%s%s%s", s, + s->t->is_client ? "client" : "server", op->send_initial_metadata ? " send_initial_metadata" : "", op->send_message ? " send_message" : "", op->send_trailing_metadata ? " send_trailing_metadata" : "", @@ -929,10 +907,9 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt, bool needs_close = false; + inproc_stream *other = s->other_side; if (error == GRPC_ERROR_NONE && - (op->send_initial_metadata || op->send_message || - op->send_trailing_metadata)) { - inproc_stream *other = s->other_side; + (op->send_initial_metadata || op->send_trailing_metadata)) { if (s->t->is_closed) { error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Endpoint already shutdown"); } @@ -963,72 +940,21 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt, s->initial_md_sent = true; } } - } - if (error == GRPC_ERROR_NONE && op->send_message) { - size_t remaining = op->payload->send_message.send_message->length; - grpc_slice_buffer *dest = slice_buffer_list_append( - (other == NULL) ? &s->write_buffer_message : &other->to_read_message); - do { - grpc_slice message_slice; - grpc_closure unused; - GPR_ASSERT(grpc_byte_stream_next(exec_ctx, - op->payload->send_message.send_message, - SIZE_MAX, &unused)); - error = grpc_byte_stream_pull( - exec_ctx, op->payload->send_message.send_message, &message_slice); - if (error != GRPC_ERROR_NONE) { - cancel_stream_locked(exec_ctx, s, GRPC_ERROR_REF(error)); - break; - } - GPR_ASSERT(error == GRPC_ERROR_NONE); - remaining -= GRPC_SLICE_LENGTH(message_slice); - grpc_slice_buffer_add(dest, message_slice); - } while (remaining != 0); - grpc_byte_stream_destroy(exec_ctx, - op->payload->send_message.send_message); - } - if (error == GRPC_ERROR_NONE && op->send_trailing_metadata) { - grpc_metadata_batch *dest = (other == NULL) ? &s->write_buffer_trailing_md - : &other->to_read_trailing_md; - bool *destfilled = (other == NULL) ? &s->write_buffer_trailing_md_filled - : &other->to_read_trailing_md_filled; - if (*destfilled || s->trailing_md_sent) { - // The buffer is already in use; that's an error! - INPROC_LOG(GPR_DEBUG, "Extra trailing metadata %p", s); - error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Extra trailing metadata"); - } else { - if (!other->closed) { - fill_in_metadata( - exec_ctx, s, - op->payload->send_trailing_metadata.send_trailing_metadata, 0, - dest, NULL, destfilled); - } - s->trailing_md_sent = true; - if (!s->t->is_client && s->trailing_md_recvd && - s->recv_trailing_md_op) { - INPROC_LOG(GPR_DEBUG, - "perform_stream_op %p scheduling trailing-md-on-complete", - s); - GRPC_CLOSURE_SCHED(exec_ctx, s->recv_trailing_md_op->on_complete, - GRPC_ERROR_NONE); - s->recv_trailing_md_op = NULL; - needs_close = true; - } - } - } - if (other != NULL && other->reads_needed) { - if (!other->read_closure_scheduled) { - GRPC_CLOSURE_SCHED(exec_ctx, &other->read_closure, error); - other->read_closure_scheduled = true; - } - other->reads_needed = false; + maybe_schedule_op_closure_locked(exec_ctx, other, error); } } + if (error == GRPC_ERROR_NONE && - (op->recv_initial_metadata || op->recv_message || + (op->send_message || op->send_trailing_metadata || + op->recv_initial_metadata || op->recv_message || op->recv_trailing_metadata)) { - // If there are any reads, mark it so that the read closure will react to - // them + // Mark ops that need to be processed by the closure + if (op->send_message) { + s->send_message_op = op; + } + if (op->send_trailing_metadata) { + s->send_trailing_md_op = op; + } if (op->recv_initial_metadata) { s->recv_initial_md_op = op; } @@ -1040,25 +966,28 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt, } // We want to initiate the closure if: - // 1. There is initial metadata and something ready to take that - // 2. There is a message and something ready to take it - // 3. There is trailing metadata, even if nothing specifically wants - // that because that can shut down the message as well - if ((s->to_read_initial_md_filled && op->recv_initial_metadata) || - ((!slice_buffer_list_empty(&s->to_read_message) || - s->trailing_md_recvd) && - op->recv_message) || - (s->to_read_trailing_md_filled)) { - if (!s->read_closure_scheduled) { - GRPC_CLOSURE_SCHED(exec_ctx, &s->read_closure, GRPC_ERROR_NONE); - s->read_closure_scheduled = true; + // 1. We want to send a message and the other side wants to receive or end + // 2. We want to send trailing metadata and there isn't an unmatched send + // 3. We want initial metadata and the other side has sent it + // 4. We want to receive a message and there is a message ready + // 5. There is trailing metadata, even if nothing specifically wants + // that because that can shut down the receive message as well + if ((op->send_message && other && ((other->recv_message_op != NULL) || + (other->recv_trailing_md_op != NULL))) || + (op->send_trailing_metadata && !op->send_message) || + (op->recv_initial_metadata && s->to_read_initial_md_filled) || + (op->recv_message && (other && other->send_message_op != NULL)) || + (s->to_read_trailing_md_filled || s->trailing_md_recvd)) { + if (!s->op_closure_scheduled) { + GRPC_CLOSURE_SCHED(exec_ctx, &s->op_closure, GRPC_ERROR_NONE); + s->op_closure_scheduled = true; } } else { - s->reads_needed = true; + s->ops_needed = true; } } else { if (error != GRPC_ERROR_NONE) { - // Schedule op's read closures that we didn't push to read state machine + // Schedule op's closures that we didn't push to op state machine if (op->recv_initial_metadata) { INPROC_LOG( GPR_DEBUG, diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py index e1dc69994c4..f7f996d5c19 100755 --- a/test/core/end2end/gen_build_yaml.py +++ b/test/core/end2end/gen_build_yaml.py @@ -24,15 +24,15 @@ import hashlib FixtureOptions = collections.namedtuple( 'FixtureOptions', - 'fullstack includes_proxy dns_resolver name_resolution secure platforms ci_mac tracing exclude_configs exclude_iomgrs large_writes enables_compression supports_compression is_inproc is_http2 supports_proxy_auth') + 'fullstack includes_proxy dns_resolver name_resolution secure platforms ci_mac tracing exclude_configs exclude_iomgrs large_writes enables_compression supports_compression is_inproc is_http2 supports_proxy_auth supports_write_buffering') default_unsecure_fixture_options = FixtureOptions( - True, False, True, True, False, ['windows', 'linux', 'mac', 'posix'], True, False, [], [], True, False, True, False, True, False) + True, False, True, True, False, ['windows', 'linux', 'mac', 'posix'], True, False, [], [], True, False, True, False, True, False, True) socketpair_unsecure_fixture_options = default_unsecure_fixture_options._replace(fullstack=False, dns_resolver=False) default_secure_fixture_options = default_unsecure_fixture_options._replace(secure=True) uds_fixture_options = default_unsecure_fixture_options._replace(dns_resolver=False, platforms=['linux', 'mac', 'posix'], exclude_iomgrs=['uv']) fd_unsecure_fixture_options = default_unsecure_fixture_options._replace( dns_resolver=False, fullstack=False, platforms=['linux', 'mac', 'posix'], exclude_iomgrs=['uv']) -inproc_fixture_options = default_unsecure_fixture_options._replace(dns_resolver=False, fullstack=False, name_resolution=False, supports_compression=False, is_inproc=True, is_http2=False) +inproc_fixture_options = default_unsecure_fixture_options._replace(dns_resolver=False, fullstack=False, name_resolution=False, supports_compression=False, is_inproc=True, is_http2=False, supports_write_buffering=False) # maps fixture name to whether it requires the security library END2END_FIXTURES = { @@ -68,8 +68,8 @@ END2END_FIXTURES = { TestOptions = collections.namedtuple( 'TestOptions', - 'needs_fullstack needs_dns needs_names proxyable secure traceable cpu_cost exclude_iomgrs large_writes flaky allows_compression needs_compression exclude_inproc needs_http2 needs_proxy_auth') -default_test_options = TestOptions(False, False, False, True, False, True, 1.0, [], False, False, True, False, False, False, False) + 'needs_fullstack needs_dns needs_names proxyable secure traceable cpu_cost exclude_iomgrs large_writes flaky allows_compression needs_compression exclude_inproc needs_http2 needs_proxy_auth needs_write_buffering') +default_test_options = TestOptions(False, False, False, True, False, True, 1.0, [], False, False, True, False, False, False, False, False) connectivity_test_options = default_test_options._replace(needs_fullstack=True) LOWCPU = 0.1 @@ -146,8 +146,10 @@ END2END_TESTS = { 'streaming_error_response': default_test_options._replace(cpu_cost=LOWCPU), 'trailing_metadata': default_test_options, 'workaround_cronet_compression': default_test_options, - 'write_buffering': default_test_options._replace(cpu_cost=LOWCPU), - 'write_buffering_at_end': default_test_options._replace(cpu_cost=LOWCPU), + 'write_buffering': default_test_options._replace(cpu_cost=LOWCPU, + needs_write_buffering=True), + 'write_buffering_at_end': default_test_options._replace(cpu_cost=LOWCPU, + needs_write_buffering=True), } @@ -185,6 +187,9 @@ def compatible(f, t): if END2END_TESTS[t].needs_proxy_auth: if not END2END_FIXTURES[f].supports_proxy_auth: return False + if END2END_TESTS[t].needs_write_buffering: + if not END2END_FIXTURES[f].supports_write_buffering: + return False return True diff --git a/test/core/end2end/generate_tests.bzl b/test/core/end2end/generate_tests.bzl index d48ddb46064..89a95edfd7b 100755 --- a/test/core/end2end/generate_tests.bzl +++ b/test/core/end2end/generate_tests.bzl @@ -21,7 +21,8 @@ load("//bazel:grpc_build_system.bzl", "grpc_sh_test", "grpc_cc_binary", "grpc_cc def fixture_options(fullstack=True, includes_proxy=False, dns_resolver=True, name_resolution=True, secure=True, tracing=False, platforms=['windows', 'linux', 'mac', 'posix'], - is_inproc=False, is_http2=True, supports_proxy_auth=False): + is_inproc=False, is_http2=True, supports_proxy_auth=False, + supports_write_buffering=True): return struct( fullstack=fullstack, includes_proxy=includes_proxy, @@ -31,7 +32,8 @@ def fixture_options(fullstack=True, includes_proxy=False, dns_resolver=True, tracing=tracing, is_inproc=is_inproc, is_http2=is_http2, - supports_proxy_auth=supports_proxy_auth + supports_proxy_auth=supports_proxy_auth, + supports_write_buffering=supports_write_buffering #platforms=platforms ) @@ -61,14 +63,14 @@ END2END_FIXTURES = { platforms=['linux', 'mac', 'posix']), 'inproc': fixture_options(fullstack=False, dns_resolver=False, name_resolution=False, is_inproc=True, - is_http2=False), + is_http2=False, supports_write_buffering=False), } def test_options(needs_fullstack=False, needs_dns=False, needs_names=False, proxyable=True, secure=False, traceable=False, exclude_inproc=False, needs_http2=False, - needs_proxy_auth=False): + needs_proxy_auth=False, needs_write_buffering=False): return struct( needs_fullstack=needs_fullstack, needs_dns=needs_dns, @@ -78,7 +80,8 @@ def test_options(needs_fullstack=False, needs_dns=False, needs_names=False, traceable=traceable, exclude_inproc=exclude_inproc, needs_http2=needs_http2, - needs_proxy_auth=needs_proxy_auth + needs_proxy_auth=needs_proxy_auth, + needs_write_buffering=needs_write_buffering ) @@ -144,8 +147,8 @@ END2END_TESTS = { 'authority_not_supported': test_options(), 'filter_latency': test_options(), 'workaround_cronet_compression': test_options(), - 'write_buffering': test_options(), - 'write_buffering_at_end': test_options(), + 'write_buffering': test_options(needs_write_buffering=True), + 'write_buffering_at_end': test_options(needs_write_buffering=True), } @@ -174,6 +177,9 @@ def compatible(fopt, topt): if topt.needs_proxy_auth: if not fopt.supports_proxy_auth: return False + if topt.needs_write_buffering: + if not fopt.supports_write_buffering: + return False return True diff --git a/test/core/end2end/tests/streaming_error_response.c b/test/core/end2end/tests/streaming_error_response.c index 9d562b90906..8891b8674ce 100644 --- a/test/core/end2end/tests/streaming_error_response.c +++ b/test/core/end2end/tests/streaming_error_response.c @@ -183,7 +183,6 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { GPR_ASSERT(GRPC_CALL_OK == error); CQ_EXPECT_COMPLETION(cqv, tag(103), 1); - cq_verify(cqv); if (!request_status_early) { memset(ops, 0, sizeof(ops)); diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index a14b4d5295c..2a33e8ae115 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -1304,7 +1304,6 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest { ServerTryCancelRequestPhase server_try_cancel) { ResetStub(); - EchoRequest send_request; EchoRequest recv_request; EchoResponse send_response; EchoResponse recv_response; @@ -1315,31 +1314,24 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest { ServerAsyncReader srv_stream(&srv_ctx); // Initiate the 'RequestStream' call on client + CompletionQueue cli_cq; + std::unique_ptr> cli_stream( - stub_->AsyncRequestStream(&cli_ctx, &recv_response, cq_.get(), tag(1))); - Verifier(GetParam().disable_blocking).Expect(1, true).Verify(cq_.get()); + stub_->AsyncRequestStream(&cli_ctx, &recv_response, &cli_cq, tag(1))); // On the server, request to be notified of 'RequestStream' calls // and receive the 'RequestStream' call just made by the client srv_ctx.AsyncNotifyWhenDone(tag(11)); service_->RequestRequestStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(), tag(2)); + std::thread t1([this, &cli_cq] { + Verifier(GetParam().disable_blocking).Expect(1, true).Verify(&cli_cq); + }); Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get()); - - // Client sends 3 messages (tags 3, 4 and 5) - for (int tag_idx = 3; tag_idx <= 5; tag_idx++) { - send_request.set_message("Ping " + grpc::to_string(tag_idx)); - cli_stream->Write(send_request, tag(tag_idx)); - Verifier(GetParam().disable_blocking) - .Expect(tag_idx, true) - .Verify(cq_.get()); - } - cli_stream->WritesDone(tag(6)); - Verifier(GetParam().disable_blocking).Expect(6, true).Verify(cq_.get()); + t1.join(); bool expected_server_cq_result = true; - bool ignore_cq_result = false; - bool want_done_tag = false; + bool expected_client_cq_result = true; if (server_try_cancel == CANCEL_BEFORE_PROCESSING) { srv_ctx.TryCancel(); @@ -1347,10 +1339,36 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest { EXPECT_TRUE(srv_ctx.IsCancelled()); // Since cancellation is done before server reads any results, we know - // for sure that all cq results will return false from this point forward + // for sure that all server cq results will return false from this + // point forward expected_server_cq_result = false; + expected_client_cq_result = false; } + bool ignore_client_cq_result = + (server_try_cancel == CANCEL_DURING_PROCESSING) || + (server_try_cancel == CANCEL_BEFORE_PROCESSING); + + std::thread cli_thread([&cli_cq, &cli_stream, &expected_client_cq_result, + &ignore_client_cq_result, this] { + EchoRequest send_request; + // Client sends 3 messages (tags 3, 4 and 5) + for (int tag_idx = 3; tag_idx <= 5; tag_idx++) { + send_request.set_message("Ping " + grpc::to_string(tag_idx)); + cli_stream->Write(send_request, tag(tag_idx)); + Verifier(GetParam().disable_blocking) + .Expect(tag_idx, expected_client_cq_result) + .Verify(&cli_cq, ignore_client_cq_result); + } + cli_stream->WritesDone(tag(6)); + // Ignore ok on WritesDone since cancel can affect it + Verifier(GetParam().disable_blocking) + .Expect(6, expected_client_cq_result) + .Verify(&cli_cq, ignore_client_cq_result); + }); + + bool ignore_cq_result = false; + bool want_done_tag = false; std::thread* server_try_cancel_thd = nullptr; auto verif = Verifier(GetParam().disable_blocking); @@ -1387,6 +1405,8 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest { } } + cli_thread.join(); + if (server_try_cancel_thd != nullptr) { server_try_cancel_thd->join(); delete server_try_cancel_thd; @@ -1415,9 +1435,15 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest { // Client will see the cancellation cli_stream->Finish(&recv_status, tag(10)); - Verifier(GetParam().disable_blocking).Expect(10, true).Verify(cq_.get()); + Verifier(GetParam().disable_blocking).Expect(10, true).Verify(&cli_cq); EXPECT_FALSE(recv_status.ok()); EXPECT_EQ(::grpc::StatusCode::CANCELLED, recv_status.error_code()); + + cli_cq.Shutdown(); + void* dummy_tag; + bool dummy_ok; + while (cli_cq.Next(&dummy_tag, &dummy_ok)) { + } } // Helper for testing server-streaming RPCs which are cancelled on the server. @@ -1439,7 +1465,6 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest { EchoRequest send_request; EchoRequest recv_request; EchoResponse send_response; - EchoResponse recv_response; Status recv_status; ClientContext cli_ctx; ServerContext srv_ctx; @@ -1447,20 +1472,29 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest { send_request.set_message("Ping"); // Initiate the 'ResponseStream' call on the client + CompletionQueue cli_cq; std::unique_ptr> cli_stream( - stub_->AsyncResponseStream(&cli_ctx, send_request, cq_.get(), tag(1))); - Verifier(GetParam().disable_blocking).Expect(1, true).Verify(cq_.get()); + stub_->AsyncResponseStream(&cli_ctx, send_request, &cli_cq, tag(1))); // On the server, request to be notified of 'ResponseStream' calls and // receive the call just made by the client srv_ctx.AsyncNotifyWhenDone(tag(11)); service_->RequestResponseStream(&srv_ctx, &recv_request, &srv_stream, cq_.get(), cq_.get(), tag(2)); + + std::thread t1([this, &cli_cq] { + Verifier(GetParam().disable_blocking).Expect(1, true).Verify(&cli_cq); + }); Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get()); + t1.join(); + EXPECT_EQ(send_request.message(), recv_request.message()); bool expected_cq_result = true; bool ignore_cq_result = false; bool want_done_tag = false; + bool expected_client_cq_result = true; + bool ignore_client_cq_result = + (server_try_cancel != CANCEL_BEFORE_PROCESSING); if (server_try_cancel == CANCEL_BEFORE_PROCESSING) { srv_ctx.TryCancel(); @@ -1470,8 +1504,21 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest { // We know for sure that all cq results will be false from this point // since the server cancelled the RPC expected_cq_result = false; + expected_client_cq_result = false; } + std::thread cli_thread([&cli_cq, &cli_stream, &expected_client_cq_result, + &ignore_client_cq_result, this] { + // Client attempts to read the three messages from the server + for (int tag_idx = 6; tag_idx <= 8; tag_idx++) { + EchoResponse recv_response; + cli_stream->Read(&recv_response, tag(tag_idx)); + Verifier(GetParam().disable_blocking) + .Expect(tag_idx, expected_client_cq_result) + .Verify(&cli_cq, ignore_client_cq_result); + } + }); + std::thread* server_try_cancel_thd = nullptr; auto verif = Verifier(GetParam().disable_blocking); @@ -1519,10 +1566,6 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest { srv_ctx.TryCancel(); want_done_tag = true; verif.Expect(11, true); - - // Client reads may fail bacause it is notified that the stream is - // cancelled. - ignore_cq_result = true; } if (want_done_tag) { @@ -1531,13 +1574,7 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest { want_done_tag = false; } - // Client attemts to read the three messages from the server - for (int tag_idx = 6; tag_idx <= 8; tag_idx++) { - cli_stream->Read(&recv_response, tag(tag_idx)); - Verifier(GetParam().disable_blocking) - .Expect(tag_idx, expected_cq_result) - .Verify(cq_.get(), ignore_cq_result); - } + cli_thread.join(); // The RPC has been cancelled at this point for sure (i.e irrespective of // the value of `server_try_cancel` is). So, from this point forward, we @@ -1549,9 +1586,15 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest { // Client will see the cancellation cli_stream->Finish(&recv_status, tag(10)); - Verifier(GetParam().disable_blocking).Expect(10, true).Verify(cq_.get()); + Verifier(GetParam().disable_blocking).Expect(10, true).Verify(&cli_cq); EXPECT_FALSE(recv_status.ok()); EXPECT_EQ(::grpc::StatusCode::CANCELLED, recv_status.error_code()); + + cli_cq.Shutdown(); + void* dummy_tag; + bool dummy_ok; + while (cli_cq.Next(&dummy_tag, &dummy_ok)) { + } } // Helper for testing bidirectinal-streaming RPCs which are cancelled on the @@ -1584,38 +1627,52 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest { // Initiate the call from the client side std::unique_ptr> cli_stream(stub_->AsyncBidiStream(&cli_ctx, cq_.get(), tag(1))); - Verifier(GetParam().disable_blocking).Expect(1, true).Verify(cq_.get()); // On the server, request to be notified of the 'BidiStream' call and // receive the call just made by the client srv_ctx.AsyncNotifyWhenDone(tag(11)); service_->RequestBidiStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(), tag(2)); - Verifier(GetParam().disable_blocking).Expect(2, true).Verify(cq_.get()); + Verifier(GetParam().disable_blocking) + .Expect(1, true) + .Expect(2, true) + .Verify(cq_.get()); + + auto verif = Verifier(GetParam().disable_blocking); // Client sends the first and the only message send_request.set_message("Ping"); cli_stream->Write(send_request, tag(3)); - Verifier(GetParam().disable_blocking).Expect(3, true).Verify(cq_.get()); + verif.Expect(3, true); bool expected_cq_result = true; bool ignore_cq_result = false; bool want_done_tag = false; + int got_tag, got_tag2; + bool tag_3_done = false; + if (server_try_cancel == CANCEL_BEFORE_PROCESSING) { srv_ctx.TryCancel(); - Verifier(GetParam().disable_blocking).Expect(11, true).Verify(cq_.get()); - EXPECT_TRUE(srv_ctx.IsCancelled()); - - // We know for sure that all cq results will be false from this point - // since the server cancelled the RPC + verif.Expect(11, true); + // We know for sure that all server cq results will be false from + // this point since the server cancelled the RPC. However, we can't + // say for sure about the client expected_cq_result = false; + ignore_cq_result = true; + + do { + got_tag = verif.Next(cq_.get(), ignore_cq_result); + GPR_ASSERT(((got_tag == 3) && !tag_3_done) || (got_tag == 11)); + if (got_tag == 3) { + tag_3_done = true; + } + } while (got_tag != 11); + EXPECT_TRUE(srv_ctx.IsCancelled()); } std::thread* server_try_cancel_thd = nullptr; - auto verif = Verifier(GetParam().disable_blocking); - if (server_try_cancel == CANCEL_DURING_PROCESSING) { server_try_cancel_thd = new std::thread(&ServerContext::TryCancel, &srv_ctx); @@ -1630,39 +1687,42 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest { verif.Expect(11, true); } - int got_tag; srv_stream.Read(&recv_request, tag(4)); verif.Expect(4, expected_cq_result); - got_tag = verif.Next(cq_.get(), ignore_cq_result); - GPR_ASSERT((got_tag == 4) || (got_tag == 11 && want_done_tag)); - if (got_tag == 11) { + got_tag = tag_3_done ? 3 : verif.Next(cq_.get(), ignore_cq_result); + got_tag2 = verif.Next(cq_.get(), ignore_cq_result); + GPR_ASSERT((got_tag == 3) || (got_tag == 4) || + (got_tag == 11 && want_done_tag)); + GPR_ASSERT((got_tag2 == 3) || (got_tag2 == 4) || + (got_tag2 == 11 && want_done_tag)); + // If we get 3 and 4, we don't need to wait for 11, but if + // we get 11, we should also clear 3 and 4 + if (got_tag + got_tag2 != 7) { EXPECT_TRUE(srv_ctx.IsCancelled()); want_done_tag = false; - // Now get the other entry that we were waiting on - EXPECT_EQ(verif.Next(cq_.get(), ignore_cq_result), 4); + got_tag = verif.Next(cq_.get(), ignore_cq_result); + GPR_ASSERT((got_tag == 3) || (got_tag == 4)); } send_response.set_message("Pong"); srv_stream.Write(send_response, tag(5)); verif.Expect(5, expected_cq_result); - got_tag = verif.Next(cq_.get(), ignore_cq_result); - GPR_ASSERT((got_tag == 5) || (got_tag == 11 && want_done_tag)); - if (got_tag == 11) { - EXPECT_TRUE(srv_ctx.IsCancelled()); - want_done_tag = false; - // Now get the other entry that we were waiting on - EXPECT_EQ(verif.Next(cq_.get(), ignore_cq_result), 5); - } cli_stream->Read(&recv_response, tag(6)); verif.Expect(6, expected_cq_result); got_tag = verif.Next(cq_.get(), ignore_cq_result); - GPR_ASSERT((got_tag == 6) || (got_tag == 11 && want_done_tag)); - if (got_tag == 11) { + got_tag2 = verif.Next(cq_.get(), ignore_cq_result); + GPR_ASSERT((got_tag == 5) || (got_tag == 6) || + (got_tag == 11 && want_done_tag)); + GPR_ASSERT((got_tag2 == 5) || (got_tag2 == 6) || + (got_tag2 == 11 && want_done_tag)); + // If we get 5 and 6, we don't need to wait for 11, but if + // we get 11, we should also clear 5 and 6 + if (got_tag + got_tag2 != 11) { EXPECT_TRUE(srv_ctx.IsCancelled()); want_done_tag = false; - // Now get the other entry that we were waiting on - EXPECT_EQ(verif.Next(cq_.get(), ignore_cq_result), 6); + got_tag = verif.Next(cq_.get(), ignore_cq_result); + GPR_ASSERT((got_tag == 5) || (got_tag == 6)); } // This is expected to succeed in all cases diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 91c7d4c38e5..a1644dfa097 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -29976,52 +29976,6 @@ "posix" ] }, - { - "args": [ - "write_buffering" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "inproc_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "write_buffering_at_end" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "inproc_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, { "args": [ "authority_not_supported" @@ -48359,52 +48313,6 @@ "posix" ] }, - { - "args": [ - "write_buffering" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "inproc_nosec_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "write_buffering_at_end" - ], - "ci_platforms": [ - "windows", - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "language": "c", - "name": "inproc_nosec_test", - "platforms": [ - "windows", - "linux", - "mac", - "posix" - ] - }, { "args": [ "--scenarios_json",