|
|
|
@ -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: |
|
|
|
|