|
|
|
@ -152,10 +152,10 @@ static void send_ping_locked( |
|
|
|
|
static void retry_initiate_ping_locked(grpc_exec_ctx *exec_ctx, void *tp, |
|
|
|
|
grpc_error *error); |
|
|
|
|
|
|
|
|
|
#define DEFAULT_MIN_TIME_BETWEEN_PINGS_MS 0 |
|
|
|
|
#define DEFAULT_MAX_PINGS_BETWEEN_DATA 3 |
|
|
|
|
#define DEFAULT_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS 300000 /* 5 minutes */ |
|
|
|
|
#define DEFAULT_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS 300000 /* 5 minutes */ |
|
|
|
|
#define DEFAULT_MAX_PINGS_BETWEEN_DATA 2 |
|
|
|
|
#define DEFAULT_MAX_PING_STRIKES 2 |
|
|
|
|
#define DEFAULT_MIN_PING_INTERVAL_WITHOUT_DATA_MS 300000 /* 5 minutes */ |
|
|
|
|
|
|
|
|
|
/** keepalive-relevant functions */ |
|
|
|
|
static void init_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg, |
|
|
|
@ -364,11 +364,11 @@ 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_sent_ping_interval_without_data = gpr_time_from_millis( |
|
|
|
|
DEFAULT_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS, GPR_TIMESPAN), |
|
|
|
|
.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_recv_ping_interval_without_data = gpr_time_from_millis( |
|
|
|
|
DEFAULT_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS, GPR_TIMESPAN), |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
/* Keepalive setting */ |
|
|
|
@ -434,23 +434,30 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, |
|
|
|
|
t->ping_policy.max_ping_strikes = grpc_channel_arg_get_integer( |
|
|
|
|
&channel_args->args[i], |
|
|
|
|
(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); |
|
|
|
|
} 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( |
|
|
|
|
grpc_channel_arg_get_integer( |
|
|
|
|
&channel_args->args[i], |
|
|
|
|
(grpc_integer_options){ |
|
|
|
|
DEFAULT_MIN_PING_INTERVAL_WITHOUT_DATA_MS, 0, INT_MAX}), |
|
|
|
|
GPR_TIMESPAN); |
|
|
|
|
strcmp( |
|
|
|
|
channel_args->args[i].key, |
|
|
|
|
GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS)) { |
|
|
|
|
t->ping_policy.min_sent_ping_interval_without_data = |
|
|
|
|
gpr_time_from_millis( |
|
|
|
|
grpc_channel_arg_get_integer( |
|
|
|
|
&channel_args->args[i], |
|
|
|
|
(grpc_integer_options){ |
|
|
|
|
DEFAULT_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS, 0, |
|
|
|
|
INT_MAX}), |
|
|
|
|
GPR_TIMESPAN); |
|
|
|
|
} else if (0 == |
|
|
|
|
strcmp( |
|
|
|
|
channel_args->args[i].key, |
|
|
|
|
GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS)) { |
|
|
|
|
t->ping_policy.min_recv_ping_interval_without_data = |
|
|
|
|
gpr_time_from_millis( |
|
|
|
|
grpc_channel_arg_get_integer( |
|
|
|
|
&channel_args->args[i], |
|
|
|
|
(grpc_integer_options){ |
|
|
|
|
DEFAULT_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS, 0, |
|
|
|
|
INT_MAX}), |
|
|
|
|
GPR_TIMESPAN); |
|
|
|
|
} 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( |
|
|
|
@ -625,6 +632,9 @@ static void close_transport_locked(grpc_exec_ctx *exec_ctx, |
|
|
|
|
connectivity_state_set(exec_ctx, t, GRPC_CHANNEL_SHUTDOWN, |
|
|
|
|
GRPC_ERROR_REF(error), "close_transport"); |
|
|
|
|
grpc_endpoint_shutdown(exec_ctx, t->ep, GRPC_ERROR_REF(error)); |
|
|
|
|
if (t->ping_state.is_delayed_ping_timer_set) { |
|
|
|
|
grpc_timer_cancel(exec_ctx, &t->ping_state.delayed_ping_timer); |
|
|
|
|
} |
|
|
|
|
switch (t->keepalive_state) { |
|
|
|
|
case GRPC_CHTTP2_KEEPALIVE_STATE_WAITING: |
|
|
|
|
grpc_timer_cancel(exec_ctx, &t->keepalive_ping_timer); |
|
|
|
@ -1729,8 +1739,10 @@ static void retry_initiate_ping_locked(grpc_exec_ctx *exec_ctx, void *tp, |
|
|
|
|
grpc_error *error) { |
|
|
|
|
grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp; |
|
|
|
|
t->ping_state.is_delayed_ping_timer_set = false; |
|
|
|
|
grpc_chttp2_initiate_write(exec_ctx, t, |
|
|
|
|
GRPC_CHTTP2_INITIATE_WRITE_RETRY_SEND_PING); |
|
|
|
|
if (error == GRPC_ERROR_NONE) { |
|
|
|
|
grpc_chttp2_initiate_write(exec_ctx, t, |
|
|
|
|
GRPC_CHTTP2_INITIATE_WRITE_RETRY_SEND_PING); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, |
|
|
|
|