]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
sched: BUG() on event_add() and log_warn next_run
authorDavid Goulet <dgoulet@torproject.org>
Mon, 18 Sep 2017 14:58:38 +0000 (10:58 -0400)
committerDavid Goulet <dgoulet@torproject.org>
Mon, 18 Sep 2017 14:58:38 +0000 (10:58 -0400)
It is highly unlikely to happen but if so, we need to know and why. The
warning with the next_run values could help.

Signed-off-by: David Goulet <dgoulet@torproject.org>
src/or/scheduler.c

index 2d6f7fc4bd1847068dd66f3159b2f8cc0326780d..43fff2bf2b44a34605e531beaacf9e42f6ab445b 100644 (file)
@@ -506,7 +506,11 @@ scheduler_ev_add(const struct timeval *next_run)
 {
   tor_assert(run_sched_ev);
   tor_assert(next_run);
-  event_add(run_sched_ev, next_run);
+  if (BUG(event_add(run_sched_ev, next_run) < 0)) {
+    log_warn(LD_SCHED, "Adding to libevent failed. Next run time was set to: "
+                       "%ld.%06ld", next_run->tv_sec, next_run->tv_usec);
+    return;
+  }
 }
 
 /* Make the scheduler event active with the given flags. */