Skip to content
Snippets Groups Projects
Commit 44264d59 authored by Yuchen Zeng's avatar Yuchen Zeng
Browse files

Add client_ prefix for keepalive args

parent 3d43da7b
Branches
Tags
No related merge requests found
...@@ -198,10 +198,10 @@ typedef struct { ...@@ -198,10 +198,10 @@ typedef struct {
#define GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE "grpc.http2.write_buffer_size" #define GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE "grpc.http2.write_buffer_size"
/** After a duration of this time the client pings the server to see if the /** After a duration of this time the client pings the server to see if the
transport is still alive. Int valued, seconds. */ transport is still alive. Int valued, seconds. */
#define GRPC_ARG_KEEPALIVE_TIME_S "grpc.keepalive_time" #define GRPC_ARG_CLIENT_KEEPALIVE_TIME_S "grpc.client_keepalive_time"
/** After waiting for a duration of this time, if the client does not receive /** After waiting for a duration of this time, if the client does not receive
the ping ack, it will close the transport. Int valued, seconds. */ the ping ack, it will close the transport. Int valued, seconds. */
#define GRPC_ARG_KEEPALIVE_TIMEOUT_S "grpc.keepalive_timeout" #define GRPC_ARG_CLIENT_KEEPALIVE_TIMEOUT_S "grpc.client_keepalive_timeout"
/** Is it permissible to send keepalive pings without any outstanding streams. /** Is it permissible to send keepalive pings without any outstanding streams.
Int valued, 0(false)/1(true). */ Int valued, 0(false)/1(true). */
#define GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS \ #define GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS \
......
...@@ -69,12 +69,13 @@ ...@@ -69,12 +69,13 @@
#define MAX_WRITE_BUFFER_SIZE (64 * 1024 * 1024) #define MAX_WRITE_BUFFER_SIZE (64 * 1024 * 1024)
#define DEFAULT_MAX_HEADER_LIST_SIZE (16 * 1024) #define DEFAULT_MAX_HEADER_LIST_SIZE (16 * 1024)
#define DEFAULT_KEEPALIVE_TIME_S INT_MAX #define DEFAULT_CLIENT_KEEPALIVE_TIME_S INT_MAX
#define DEFAULT_KEEPALIVE_TIMEOUT_S 20 #define DEFAULT_CLIENT_KEEPALIVE_TIMEOUT_S 20
#define DEFAULT_KEEPALIVE_PERMIT_WITHOUT_CALLS false #define DEFAULT_KEEPALIVE_PERMIT_WITHOUT_CALLS false
static int g_default_keepalive_time_s = DEFAULT_KEEPALIVE_TIME_S; static int g_default_client_keepalive_time_s = DEFAULT_CLIENT_KEEPALIVE_TIME_S;
static int g_default_keepalive_timeout_s = DEFAULT_KEEPALIVE_TIMEOUT_S; static int g_default_client_keepalive_timeout_s =
DEFAULT_CLIENT_KEEPALIVE_TIMEOUT_S;
static bool g_default_keepalive_permit_without_calls = static bool g_default_keepalive_permit_without_calls =
DEFAULT_KEEPALIVE_PERMIT_WITHOUT_CALLS; DEFAULT_KEEPALIVE_PERMIT_WITHOUT_CALLS;
...@@ -350,13 +351,15 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, ...@@ -350,13 +351,15 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
/* client-side keepalive setting */ /* client-side keepalive setting */
t->keepalive_time = t->keepalive_time =
g_default_keepalive_time_s == INT_MAX g_default_client_keepalive_time_s == INT_MAX
? gpr_inf_future(GPR_TIMESPAN) ? gpr_inf_future(GPR_TIMESPAN)
: gpr_time_from_seconds(g_default_keepalive_time_s, GPR_TIMESPAN); : gpr_time_from_seconds(g_default_client_keepalive_time_s,
GPR_TIMESPAN);
t->keepalive_timeout = t->keepalive_timeout =
g_default_keepalive_timeout_s == INT_MAX g_default_client_keepalive_timeout_s == INT_MAX
? gpr_inf_future(GPR_TIMESPAN) ? gpr_inf_future(GPR_TIMESPAN)
: gpr_time_from_seconds(g_default_keepalive_timeout_s, GPR_TIMESPAN); : gpr_time_from_seconds(g_default_client_keepalive_timeout_s,
GPR_TIMESPAN);
t->keepalive_permit_without_calls = g_default_keepalive_permit_without_calls; t->keepalive_permit_without_calls = g_default_keepalive_permit_without_calls;
if (channel_args) { if (channel_args) {
...@@ -406,19 +409,21 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, ...@@ -406,19 +409,21 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
strcmp(channel_args->args[i].key, GRPC_ARG_HTTP2_BDP_PROBE)) { strcmp(channel_args->args[i].key, GRPC_ARG_HTTP2_BDP_PROBE)) {
t->enable_bdp_probe = grpc_channel_arg_get_integer( t->enable_bdp_probe = grpc_channel_arg_get_integer(
&channel_args->args[i], (grpc_integer_options){1, 0, 1}); &channel_args->args[i], (grpc_integer_options){1, 0, 1});
} else if (0 == } else if (0 == strcmp(channel_args->args[i].key,
strcmp(channel_args->args[i].key, GRPC_ARG_KEEPALIVE_TIME_S)) { GRPC_ARG_CLIENT_KEEPALIVE_TIME_S)) {
const int value = grpc_channel_arg_get_integer( const int value = grpc_channel_arg_get_integer(
&channel_args->args[i], &channel_args->args[i],
(grpc_integer_options){g_default_keepalive_time_s, 1, INT_MAX}); (grpc_integer_options){g_default_client_keepalive_time_s, 1,
INT_MAX});
t->keepalive_time = value == INT_MAX t->keepalive_time = value == INT_MAX
? gpr_inf_future(GPR_TIMESPAN) ? gpr_inf_future(GPR_TIMESPAN)
: gpr_time_from_seconds(value, GPR_TIMESPAN); : gpr_time_from_seconds(value, GPR_TIMESPAN);
} else if (0 == strcmp(channel_args->args[i].key, } else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_KEEPALIVE_TIMEOUT_S)) { GRPC_ARG_CLIENT_KEEPALIVE_TIMEOUT_S)) {
const int value = grpc_channel_arg_get_integer( const int value = grpc_channel_arg_get_integer(
&channel_args->args[i], &channel_args->args[i],
(grpc_integer_options){g_default_keepalive_timeout_s, 0, INT_MAX}); (grpc_integer_options){g_default_client_keepalive_timeout_s, 0,
INT_MAX});
t->keepalive_timeout = value == INT_MAX t->keepalive_timeout = value == INT_MAX
? gpr_inf_future(GPR_TIMESPAN) ? gpr_inf_future(GPR_TIMESPAN)
: gpr_time_from_seconds(value, GPR_TIMESPAN); : gpr_time_from_seconds(value, GPR_TIMESPAN);
...@@ -2110,14 +2115,16 @@ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args) { ...@@ -2110,14 +2115,16 @@ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args) {
size_t i; size_t i;
if (args) { if (args) {
for (i = 0; i < args->num_args; i++) { for (i = 0; i < args->num_args; i++) {
if (0 == strcmp(args->args[i].key, GRPC_ARG_KEEPALIVE_TIME_S)) { if (0 == strcmp(args->args[i].key, GRPC_ARG_CLIENT_KEEPALIVE_TIME_S)) {
g_default_keepalive_time_s = grpc_channel_arg_get_integer( g_default_client_keepalive_time_s = grpc_channel_arg_get_integer(
&args->args[i], &args->args[i], (grpc_integer_options){
(grpc_integer_options){g_default_keepalive_time_s, 1, INT_MAX}); g_default_client_keepalive_time_s, 1, INT_MAX});
} else if (0 == strcmp(args->args[i].key, GRPC_ARG_KEEPALIVE_TIMEOUT_S)) { } else if (0 == strcmp(args->args[i].key,
g_default_keepalive_timeout_s = grpc_channel_arg_get_integer( GRPC_ARG_CLIENT_KEEPALIVE_TIMEOUT_S)) {
g_default_client_keepalive_timeout_s = grpc_channel_arg_get_integer(
&args->args[i], &args->args[i],
(grpc_integer_options){g_default_keepalive_timeout_s, 0, INT_MAX}); (grpc_integer_options){g_default_client_keepalive_timeout_s, 0,
INT_MAX});
; ;
} else if (0 == strcmp(args->args[i].key, } else if (0 == strcmp(args->args[i].key,
GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS)) { GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS)) {
......
...@@ -111,10 +111,10 @@ static void test_keepalive_timeout(grpc_end2end_test_config config) { ...@@ -111,10 +111,10 @@ static void test_keepalive_timeout(grpc_end2end_test_config config) {
gpr_timespec deadline = five_seconds_time(); gpr_timespec deadline = five_seconds_time();
grpc_arg keepalive_args[] = {{.type = GRPC_ARG_INTEGER, grpc_arg keepalive_args[] = {{.type = GRPC_ARG_INTEGER,
.key = GRPC_ARG_KEEPALIVE_TIME_S, .key = GRPC_ARG_CLIENT_KEEPALIVE_TIME_S,
.value.integer = 2}, .value.integer = 2},
{.type = GRPC_ARG_INTEGER, {.type = GRPC_ARG_INTEGER,
.key = GRPC_ARG_KEEPALIVE_TIMEOUT_S, .key = GRPC_ARG_CLIENT_KEEPALIVE_TIMEOUT_S,
.value.integer = 0}, .value.integer = 0},
{.type = GRPC_ARG_INTEGER, {.type = GRPC_ARG_INTEGER,
.key = GRPC_ARG_HTTP2_BDP_PROBE, .key = GRPC_ARG_HTTP2_BDP_PROBE,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment