summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2018-04-26 15:00:19 -0400
committerNick Mathewson <nickm@torproject.org>2018-04-27 09:28:00 -0400
commitd6903e9e87ffd39846b7cacebcfc8bae71f3ca5f (patch)
tree213ebb454298652b5c0bf452754c9da578a5a0d3 /src
parent05d314f888dd96840d92fbcc513974487485f4cb (diff)
downloadtor-d6903e9e87ffd39846b7cacebcfc8bae71f3ca5f.tar.gz
tor-d6903e9e87ffd39846b7cacebcfc8bae71f3ca5f.zip
hibernation: Rescan the event list on state change
When we change the hibernation state, rescan the main loop event list because the new state might affect the events. Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src')
-rw-r--r--src/or/hibernate.c10
-rw-r--r--src/or/main.c3
-rw-r--r--src/or/main.h1
3 files changed, 11 insertions, 3 deletions
diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index 9fed338555..c4ae63acc4 100644
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@ -1111,10 +1111,18 @@ getinfo_helper_accounting(control_connection_t *conn,
static void
on_hibernate_state_change(hibernate_state_t prev_state)
{
- (void)prev_state; /* Should we do something with this? */
control_event_server_status(LOG_NOTICE,
"HIBERNATION_STATUS STATUS=%s",
hibernate_state_to_string(hibernate_state));
+
+ /* We are changing hibernation state, this can affect the main loop event
+ * list. Rescan it to update the events state. We do this whatever the new
+ * hibernation state because they can each possibly affect an event. The
+ * initial state means we are booting up so we shouldn't scan here because
+ * at this point the events in the list haven't been initialized. */
+ if (prev_state != HIBERNATE_STATE_INITIAL) {
+ rescan_periodic_events(get_options());
+ }
}
#ifdef TOR_UNIT_TESTS
diff --git a/src/or/main.c b/src/or/main.c
index c7bd720ccf..b5a7017135 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -150,7 +150,6 @@ static int run_main_loop_until_done(void);
static void process_signal(int sig);
static void shutdown_did_not_work_callback(evutil_socket_t fd, short event,
void *arg) ATTR_NORETURN;
-static void rescan_periodic_events(const or_options_t *options);
/********* START VARIABLES **********/
@@ -1549,7 +1548,7 @@ teardown_periodic_events(void)
/** Do a pass at all our periodic events, disable those we don't need anymore
* and enable those we need now using the given options. */
-static void
+void
rescan_periodic_events(const or_options_t *options)
{
tor_assert(options);
diff --git a/src/or/main.h b/src/or/main.h
index 33ef40ce40..2447339fb5 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 mainloop_schedule_postloop_cleanup(void);
+void rescan_periodic_events(const or_options_t *options);
MOCK_DECL(long,get_uptime,(void));
MOCK_DECL(void,reset_uptime,(void));