diff options
author | 2017-10-02 14:42:49 -0700 | |
---|---|---|
committer | 2017-10-02 14:42:49 -0700 | |
commit | 43c1b5f4377d3f1640b7bdae099cd3300a624bc0 (patch) | |
tree | acab7723bf4a6a5d64c87559a55920c956753b24 /src/core | |
parent | ced7653a1cf171c0ed59b09cc36e80f86b2e6101 (diff) |
Fixes
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/ext/transport/chttp2/transport/chttp2_transport.c | 2 | ||||
-rw-r--r-- | src/core/ext/transport/chttp2/transport/flow_control.c | 3 | ||||
-rw-r--r-- | src/core/lib/iomgr/iocp_windows.c | 6 | ||||
-rw-r--r-- | src/core/lib/transport/bdp_estimator.c | 14 | ||||
-rw-r--r-- | src/core/lib/transport/bdp_estimator.h | 13 |
5 files changed, 22 insertions, 16 deletions
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 1c575badb8..452651af90 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 a95b4b3d05..a8ac80cf43 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 3c38105ef9..a6e064c8c0 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 2a3ffbbd01..2bf1d0b5e5 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 670e38dd4b..c74de5a6bb 100644 --- a/src/core/lib/transport/bdp_estimator.h +++ b/src/core/lib/transport/bdp_estimator.h @@ -23,6 +23,7 @@ #include <stdbool.h> #include <stdint.h> #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 */ |