summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-05-01 10:56:11 -0400
committerNick Mathewson <nickm@torproject.org>2018-05-01 10:56:56 -0400
commit4a559e996055d4ad8aeb1be7aece036fad94a4e9 (patch)
treedbb420b09f129c5a664fb216e5a7ab670feff050 /src/or
parenta73603653a5b54260705b40c7d71bc38faaf6436 (diff)
downloadtor-4a559e996055d4ad8aeb1be7aece036fad94a4e9.tar.gz
tor-4a559e996055d4ad8aeb1be7aece036fad94a4e9.zip
Refactor to use safe_timer_diff.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/main.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/src/or/main.c b/src/or/main.c
index 0708e647f1..c03e80dc03 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1994,13 +1994,7 @@ dirvote_callback(time_t now, const or_options_t *options)
* fix itself in an hour or so? */
return 3600;
}
- if (BUG(next <= now)) {
- /* This case shouldn't be possible, since "next" is computed by
- * dirvote_act() based on the value of "now" we give it. */
- return 1;
- } else {
- return next - now;
- }
+ return safe_timer_diff(now, next);
}
/** Reschedule the directory-authority voting event. Run this whenever the
@@ -2046,14 +2040,8 @@ save_state_callback(time_t now, const or_options_t *options)
const time_t next_write = get_or_state()->next_write;
if (next_write == TIME_MAX) {
return 86400;
- } else if (BUG(next_write <= now)) {
- /* This can't happen due to clock jumps, since the value of next_write
- * is based on the same "now" that we passed to or_state_save().
- */
- return PERIODIC_EVENT_NO_UPDATE;
- } else {
- return (int)(next_write - now);
}
+ return safe_timer_diff(now, next_write);
}
/** Reschedule the event for saving the state file.