[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Ensure that voting is rescheduled whenever the schedule changes.
commit 234e317ef17de111a48c8bb6dba9e84d346afe25
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Fri Apr 27 09:55:05 2018 -0400
Ensure that voting is rescheduled whenever the schedule changes.
---
src/or/config.c | 5 ++++-
src/or/main.c | 12 ++++++++++++
src/or/main.h | 1 +
src/or/networkstatus.c | 1 +
4 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/or/config.c b/src/or/config.c
index 3719ac884..1c2b4cf10 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1,3 +1,4 @@
+
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
@@ -2329,8 +2330,10 @@ options_act(const or_options_t *old_options)
/* We may need to reschedule some directory stuff if our status changed. */
if (old_options) {
- if (authdir_mode_v3(options) && !authdir_mode_v3(old_options))
+ if (authdir_mode_v3(options) && !authdir_mode_v3(old_options)) {
dirvote_recalculate_timing(options, time(NULL));
+ reschedule_dirvote(options);
+ }
if (!bool_eq(directory_fetches_dir_info_early(options),
directory_fetches_dir_info_early(old_options)) ||
!bool_eq(directory_fetches_dir_info_later(options),
diff --git a/src/or/main.c b/src/or/main.c
index 8bc89817a..0708e647f 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1436,6 +1436,7 @@ STATIC periodic_event_item_t periodic_events[] = {
* can access them by name. We also keep them inside periodic_events[]
* so that we can implement "reset all timers" in a reasonable way. */
static periodic_event_item_t *check_descriptor_event=NULL;
+static periodic_event_item_t *dirvote_event=NULL;
static periodic_event_item_t *fetch_networkstatus_event=NULL;
static periodic_event_item_t *launch_descriptor_fetches_event=NULL;
static periodic_event_item_t *check_dns_honesty_event=NULL;
@@ -1535,6 +1536,7 @@ initialize_periodic_events(void)
STMT_BEGIN name ## _event = find_periodic_event( #name ); STMT_END
NAMED_CALLBACK(check_descriptor);
+ NAMED_CALLBACK(dirvote);
NAMED_CALLBACK(fetch_networkstatus);
NAMED_CALLBACK(launch_descriptor_fetches);
NAMED_CALLBACK(check_dns_honesty);
@@ -2001,6 +2003,16 @@ dirvote_callback(time_t now, const or_options_t *options)
}
}
+/** Reschedule the directory-authority voting event. Run this whenever the
+ * schedule has changed. */
+void
+reschedule_dirvote(const or_options_t *options)
+{
+ if (periodic_events_initialized && authdir_mode_v3(options)) {
+ periodic_event_reschedule(dirvote_event);
+ }
+}
+
/**
* Periodic callback: If our consensus is too old, recalculate whether
* we can actually use it.
diff --git a/src/or/main.h b/src/or/main.h
index 836dbf1ca..a312b51e0 100644
--- a/src/or/main.h
+++ b/src/or/main.h
@@ -62,6 +62,7 @@ void reset_all_main_loop_timers(void);
void reschedule_descriptor_update_check(void);
void reschedule_directory_downloads(void);
void reschedule_or_state_save(void);
+void reschedule_dirvote(const or_options_t *options);
void mainloop_schedule_postloop_cleanup(void);
void rescan_periodic_events(const or_options_t *options);
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 5ca320d28..1267d9d6b 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -2001,6 +2001,7 @@ networkstatus_set_current_consensus(const char *consensus,
* object so we can use the timings in there needed by some subsystems
* such as hidden service and shared random. */
dirvote_recalculate_timing(options, now);
+ reschedule_dirvote(options);
nodelist_set_consensus(c);
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits