aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/iomgr
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-04-13 20:26:07 -0700
committerGravatar Craig Tiller <ctiller@google.com>2016-04-13 20:26:07 -0700
commit3f72df99993a4905e280c7a5ad86da5fcd8a40d5 (patch)
tree2b582a5209dda8159bf5a838e45e1851a4c34990 /src/core/lib/iomgr
parent849155d03a8f45236a812d3492dfea98b4ca8571 (diff)
Report sooner
Diffstat (limited to 'src/core/lib/iomgr')
-rw-r--r--src/core/lib/iomgr/timer.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core/lib/iomgr/timer.c b/src/core/lib/iomgr/timer.c
index 713f15b69e..c4dfc09c9d 100644
--- a/src/core/lib/iomgr/timer.c
+++ b/src/core/lib/iomgr/timer.c
@@ -83,6 +83,7 @@ static gpr_timespec compute_min_deadline(shard_type *shard) {
void grpc_timer_list_init(gpr_timespec now) {
uint32_t i;
+ g_initialized = true;
gpr_mu_init(&g_mu);
gpr_mu_init(&g_checker_mu);
g_clock_type = now.clock_type;
@@ -111,6 +112,7 @@ void grpc_timer_list_shutdown(grpc_exec_ctx *exec_ctx) {
}
gpr_mu_destroy(&g_mu);
gpr_mu_destroy(&g_checker_mu);
+ g_initialized = false;
}
/* This is a cheap, but good enough, pointer hash for sharding the tasks: */
@@ -180,6 +182,16 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer,
timer->deadline = deadline;
timer->triggered = 0;
+ if (!g_initialized) {
+ grpc_exec_ctx_enqueue(exec_ctx, &timer->closure, false);
+ return;
+ }
+
+ if (gpr_time_cmp(deadline, now) <= 0) {
+ grpc_exec_ctx_enqueue(exec_ctx, &timer->closure, true);
+ return;
+ }
+
/* TODO(ctiller): check deadline expired */
gpr_mu_lock(&shard->mu);