aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2017-09-29 14:07:55 -0400
committerDavid Goulet <dgoulet@torproject.org>2017-09-29 14:07:55 -0400
commit070064de899901daaf98aefc3335bc9f21acb5c6 (patch)
tree46ef31eae8f190a0b183ae11d6cf835d8764d849
parentfc6c0b46fb2741d58e4c8afc22800c76c304b0dc (diff)
downloadtor-070064de899901daaf98aefc3335bc9f21acb5c6.tar.gz
tor-070064de899901daaf98aefc3335bc9f21acb5c6.zip
sched: Always initialize scheduler_last_run to now
Because our monotonic time interface doesn't play well with value set to 0, always initialize to now() the scheduler_last_run at init() of the KIST scheduler. Fixes #23696 Signed-off-by: David Goulet <dgoulet@torproject.org>
-rw-r--r--changes/bug236963
-rw-r--r--src/or/scheduler_kist.c10
2 files changed, 13 insertions, 0 deletions
diff --git a/changes/bug23696 b/changes/bug23696
new file mode 100644
index 0000000000..d447815c84
--- /dev/null
+++ b/changes/bug23696
@@ -0,0 +1,3 @@
+ o Minor bugfixes (scheduler, kist):
+ - Properly initialize the scheduler last run time counter so it is not 0
+ at the first tick. Fixes bug 23696; bugfix on 0.3.2.1-alpha.
diff --git a/src/or/scheduler_kist.c b/src/or/scheduler_kist.c
index 9e960cdef9..5856cbea45 100644
--- a/src/or/scheduler_kist.c
+++ b/src/or/scheduler_kist.c
@@ -490,6 +490,16 @@ kist_scheduler_on_new_options(void)
static void
kist_scheduler_init(void)
{
+ /* When initializing the scheduler, the last run could be 0 because it is
+ * declared static or a value in the past that was set when it was last
+ * used. In both cases, we want to initialize it to now so we don't risk
+ * using the value 0 which doesn't play well with our monotonic time
+ * interface.
+ *
+ * One side effect is that the first scheduler run will be at the next tick
+ * that is in now + 10 msec (KIST_SCHED_RUN_INTERVAL_DEFAULT) by default. */
+ monotime_get(&scheduler_last_run);
+
kist_scheduler_on_new_options();
IF_BUG_ONCE(sched_run_interval == 0) {
log_warn(LD_SCHED, "We are initing the KIST scheduler and noticed the "