mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-24 22:58:50 +01:00
Ensure that voting is rescheduled whenever the schedule changes.
This commit is contained in:
parent
6868398b69
commit
234e317ef1
4 changed files with 18 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
/* Copyright (c) 2001 Matej Pfajfar.
|
/* Copyright (c) 2001 Matej Pfajfar.
|
||||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
* 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. */
|
/* We may need to reschedule some directory stuff if our status changed. */
|
||||||
if (old_options) {
|
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));
|
dirvote_recalculate_timing(options, time(NULL));
|
||||||
|
reschedule_dirvote(options);
|
||||||
|
}
|
||||||
if (!bool_eq(directory_fetches_dir_info_early(options),
|
if (!bool_eq(directory_fetches_dir_info_early(options),
|
||||||
directory_fetches_dir_info_early(old_options)) ||
|
directory_fetches_dir_info_early(old_options)) ||
|
||||||
!bool_eq(directory_fetches_dir_info_later(options),
|
!bool_eq(directory_fetches_dir_info_later(options),
|
||||||
|
|
|
@ -1436,6 +1436,7 @@ STATIC periodic_event_item_t periodic_events[] = {
|
||||||
* can access them by name. We also keep them inside 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. */
|
* 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 *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 *fetch_networkstatus_event=NULL;
|
||||||
static periodic_event_item_t *launch_descriptor_fetches_event=NULL;
|
static periodic_event_item_t *launch_descriptor_fetches_event=NULL;
|
||||||
static periodic_event_item_t *check_dns_honesty_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
|
STMT_BEGIN name ## _event = find_periodic_event( #name ); STMT_END
|
||||||
|
|
||||||
NAMED_CALLBACK(check_descriptor);
|
NAMED_CALLBACK(check_descriptor);
|
||||||
|
NAMED_CALLBACK(dirvote);
|
||||||
NAMED_CALLBACK(fetch_networkstatus);
|
NAMED_CALLBACK(fetch_networkstatus);
|
||||||
NAMED_CALLBACK(launch_descriptor_fetches);
|
NAMED_CALLBACK(launch_descriptor_fetches);
|
||||||
NAMED_CALLBACK(check_dns_honesty);
|
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
|
* Periodic callback: If our consensus is too old, recalculate whether
|
||||||
* we can actually use it.
|
* we can actually use it.
|
||||||
|
|
|
@ -62,6 +62,7 @@ void reset_all_main_loop_timers(void);
|
||||||
void reschedule_descriptor_update_check(void);
|
void reschedule_descriptor_update_check(void);
|
||||||
void reschedule_directory_downloads(void);
|
void reschedule_directory_downloads(void);
|
||||||
void reschedule_or_state_save(void);
|
void reschedule_or_state_save(void);
|
||||||
|
void reschedule_dirvote(const or_options_t *options);
|
||||||
void mainloop_schedule_postloop_cleanup(void);
|
void mainloop_schedule_postloop_cleanup(void);
|
||||||
void rescan_periodic_events(const or_options_t *options);
|
void rescan_periodic_events(const or_options_t *options);
|
||||||
|
|
||||||
|
|
|
@ -2001,6 +2001,7 @@ networkstatus_set_current_consensus(const char *consensus,
|
||||||
* object so we can use the timings in there needed by some subsystems
|
* object so we can use the timings in there needed by some subsystems
|
||||||
* such as hidden service and shared random. */
|
* such as hidden service and shared random. */
|
||||||
dirvote_recalculate_timing(options, now);
|
dirvote_recalculate_timing(options, now);
|
||||||
|
reschedule_dirvote(options);
|
||||||
|
|
||||||
nodelist_set_consensus(c);
|
nodelist_set_consensus(c);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue