diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/channel/client_setup.c | 6 | ||||
-rw-r--r-- | src/core/iomgr/alarm.h | 3 | ||||
-rw-r--r-- | src/core/iomgr/iomgr_libevent.c | 5 | ||||
-rw-r--r-- | src/core/surface/call.c | 2 |
4 files changed, 9 insertions, 7 deletions
diff --git a/src/core/channel/client_setup.c b/src/core/channel/client_setup.c index 562f284928..fa946b0f1b 100644 --- a/src/core/channel/client_setup.c +++ b/src/core/channel/client_setup.c @@ -212,11 +212,11 @@ void grpc_client_setup_request_finish(grpc_client_setup_request *r, /* TODO(klempner): Replace these values with further consideration. 2x is probably too aggressive of a backoff. */ gpr_timespec max_backoff = gpr_time_from_minutes(2); - gpr_timespec deadline = - gpr_time_add(s->current_backoff_interval, gpr_now()); + gpr_timespec now = gpr_now(); + gpr_timespec deadline = gpr_time_add(s->current_backoff_interval, now); GPR_ASSERT(!s->in_alarm); s->in_alarm = 1; - grpc_alarm_init(&s->backoff_alarm, deadline, backoff_alarm_done, s); + grpc_alarm_init(&s->backoff_alarm, deadline, backoff_alarm_done, s, now); s->current_backoff_interval = gpr_time_add(s->current_backoff_interval, s->current_backoff_interval); if (gpr_time_cmp(s->current_backoff_interval, max_backoff) > 0) { diff --git a/src/core/iomgr/alarm.h b/src/core/iomgr/alarm.h index e09f165bcf..2bb5bf7022 100644 --- a/src/core/iomgr/alarm.h +++ b/src/core/iomgr/alarm.h @@ -53,7 +53,8 @@ typedef struct grpc_alarm grpc_alarm; information about when to free up any user-level state. Returns 1 on success, 0 on failure. */ int grpc_alarm_init(grpc_alarm *alarm, gpr_timespec deadline, - grpc_iomgr_cb_func alarm_cb, void *alarm_cb_arg); + grpc_iomgr_cb_func alarm_cb, void *alarm_cb_arg, + gpr_timespec now); /* Note that there is no alarm destroy function. This is because the alarm is a one-time occurrence with a guarantee that the callback will diff --git a/src/core/iomgr/iomgr_libevent.c b/src/core/iomgr/iomgr_libevent.c index 35a1764fa3..3c94d35a38 100644 --- a/src/core/iomgr/iomgr_libevent.c +++ b/src/core/iomgr/iomgr_libevent.c @@ -363,10 +363,11 @@ static void libevent_alarm_cb(int fd, short what, void *arg /*=alarm*/) { } int grpc_alarm_init(grpc_alarm *alarm, gpr_timespec deadline, - grpc_iomgr_cb_func alarm_cb, void *alarm_cb_arg) { + grpc_iomgr_cb_func alarm_cb, void *alarm_cb_arg, + gpr_timespec now) { grpc_libevent_activation_data *adata = &alarm->task.activation[GRPC_EM_TA_ONLY]; - gpr_timespec delay_timespec = gpr_time_sub(deadline, gpr_now()); + gpr_timespec delay_timespec = gpr_time_sub(deadline, now); struct timeval delay = gpr_timeval_from_timespec(delay_timespec); alarm->task.type = GRPC_EM_TASK_ALARM; gpr_atm_rel_store(&alarm->triggered, ALARM_TRIGGER_INIT); diff --git a/src/core/surface/call.c b/src/core/surface/call.c index 6b4e8962de..ba4c806602 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -877,5 +877,5 @@ void grpc_call_set_deadline(grpc_call_element *elem, gpr_timespec deadline) { } grpc_call_internal_ref(call); call->have_alarm = 1; - grpc_alarm_init(&call->alarm, deadline, call_alarm, call); + grpc_alarm_init(&call->alarm, deadline, call_alarm, call, gpr_now()); } |