summaryrefslogtreecommitdiff
path: root/src/or/dirauth
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-04-26 17:42:43 -0400
committerNick Mathewson <nickm@torproject.org>2018-05-01 10:52:16 -0400
commit9870497f9df909c6a48a6f6c1e82171e99aa33a4 (patch)
tree457406679925e826c61acb7b4857ce21323cbcb5 /src/or/dirauth
parent4f184415cc462214427627df0edfa897e555d5e8 (diff)
downloadtor-9870497f9df909c6a48a6f6c1e82171e99aa33a4.tar.gz
tor-9870497f9df909c6a48a6f6c1e82171e99aa33a4.zip
Update dirvote_act() to return the time of its next action.
This is remarkably simple, given the macros in the last commit.
Diffstat (limited to 'src/or/dirauth')
-rw-r--r--src/or/dirauth/dirvote.c19
-rw-r--r--src/or/dirauth/dirvote.h5
2 files changed, 18 insertions, 6 deletions
diff --git a/src/or/dirauth/dirvote.c b/src/or/dirauth/dirvote.c
index 90f8d22272..36f328d6c5 100644
--- a/src/or/dirauth/dirvote.c
+++ b/src/or/dirauth/dirvote.c
@@ -2731,12 +2731,14 @@ get_detached_signatures_from_pending_consensuses(pending_consensus_t *pending,
/**
* Entry point: Take whatever voting actions are pending as of <b>now</b>.
+ *
+ * Return the time at which the next action should be taken.
*/
-void
+time_t
dirvote_act(const or_options_t *options, time_t now)
{
if (!authdir_mode_v3(options))
- return;
+ return TIME_MAX;
tor_assert_nonfatal(voting_schedule.voting_starts);
/* If we haven't initialized this object through this codeflow, we need to
* recalculate the timings to match our vote. The reason to do that is if we
@@ -2754,8 +2756,13 @@ dirvote_act(const or_options_t *options, time_t now)
}
#define IF_TIME_FOR_NEXT_ACTION(when_field, done_field) \
- if (voting_schedule.when_field < now && !voting_schedule.done_field) do {
-#define ENDIF } while(0);
+ if (! voting_schedule.done_field) { \
+ if (voting_schedule.when_field > now) { \
+ return voting_schedule.when_field; \
+ } else {
+#define ENDIF \
+ } \
+ }
IF_TIME_FOR_NEXT_ACTION(voting_starts, have_voted) {
log_notice(LD_DIR, "Time to vote.");
@@ -2792,8 +2799,12 @@ dirvote_act(const or_options_t *options, time_t now)
/* XXXX We will want to try again later if we haven't got enough
* signatures yet. Implement this if it turns out to ever happen. */
dirvote_recalculate_timing(options, now);
+ return voting_schedule.voting_starts;
} ENDIF
+ tor_assert_nonfatal_unreached();
+ return now + 1;
+
#undef ENDIF
#undef IF_TIME_FOR_NEXT_ACTION
}
diff --git a/src/or/dirauth/dirvote.h b/src/or/dirauth/dirvote.h
index f69e872c8e..7294962925 100644
--- a/src/or/dirauth/dirvote.h
+++ b/src/or/dirauth/dirvote.h
@@ -96,7 +96,7 @@
*/
#ifdef HAVE_MODULE_DIRAUTH
-void dirvote_act(const or_options_t *options, time_t now);
+time_t dirvote_act(const or_options_t *options, time_t now);
void dirvote_free_all(void);
void dirvote_parse_sr_commits(networkstatus_t *ns, smartlist_t *tokens);
@@ -114,11 +114,12 @@ int dirvote_add_signatures(const char *detached_signatures_body,
#else /* HAVE_MODULE_DIRAUTH */
-static inline void
+static inline time_t
dirvote_act(const or_options_t *options, time_t now)
{
(void) options;
(void) now;
+ return TIME_MAX;
}
static inline void