Skip to content
Snippets Groups Projects
Commit 60b653bf authored by yang-g's avatar yang-g
Browse files

Use MONOTONIC instead of REALTIME

parent 88b77c64
No related branches found
No related tags found
No related merge requests found
...@@ -273,7 +273,7 @@ void grpc_subchannel_del_interested_party(grpc_subchannel *c, ...@@ -273,7 +273,7 @@ void grpc_subchannel_del_interested_party(grpc_subchannel *c,
} }
static gpr_int32 random_seed() { static gpr_int32 random_seed() {
return gpr_time_to_millis(gpr_now(GPR_CLOCK_REALTIME)); return gpr_time_to_millis(gpr_now(GPR_CLOCK_MONOTONIC));
} }
grpc_subchannel *grpc_subchannel_create(grpc_connector *connector, grpc_subchannel *grpc_subchannel_create(grpc_connector *connector,
...@@ -608,7 +608,8 @@ static void update_reconnect_parameters(grpc_subchannel *c) { ...@@ -608,7 +608,8 @@ static void update_reconnect_parameters(grpc_subchannel *c) {
backoff_delta_millis = max_backoff_millis; backoff_delta_millis = max_backoff_millis;
} }
c->backoff_delta = gpr_time_from_millis(backoff_delta_millis, GPR_TIMESPAN); c->backoff_delta = gpr_time_from_millis(backoff_delta_millis, GPR_TIMESPAN);
c->next_attempt = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), c->backoff_delta); c->next_attempt =
gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), c->backoff_delta);
jitter_range = GRPC_SUBCHANNEL_RECONNECT_JITTER * backoff_delta_millis; jitter_range = GRPC_SUBCHANNEL_RECONNECT_JITTER * backoff_delta_millis;
jitter = jitter =
...@@ -654,7 +655,7 @@ static gpr_timespec compute_connect_deadline(grpc_subchannel *c) { ...@@ -654,7 +655,7 @@ static gpr_timespec compute_connect_deadline(grpc_subchannel *c) {
gpr_timespec current_deadline = gpr_timespec current_deadline =
gpr_time_add(c->next_attempt, c->backoff_delta); gpr_time_add(c->next_attempt, c->backoff_delta);
gpr_timespec min_deadline = gpr_time_add( gpr_timespec min_deadline = gpr_time_add(
gpr_now(GPR_CLOCK_REALTIME), gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_seconds(GRPC_SUBCHANNEL_MIN_CONNECT_TIMEOUT_SECONDS, gpr_time_from_seconds(GRPC_SUBCHANNEL_MIN_CONNECT_TIMEOUT_SECONDS,
GPR_TIMESPAN)); GPR_TIMESPAN));
return gpr_time_cmp(current_deadline, min_deadline) > 0 ? current_deadline return gpr_time_cmp(current_deadline, min_deadline) > 0 ? current_deadline
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment