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>
This commit is contained in:
parent
05d314f888
commit
d6903e9e87
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue