diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-05-09 12:47:59 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-05-10 09:02:44 -0400 |
commit | 8b4cf7771e869bea4550452ad2cf5634278e0e87 (patch) | |
tree | 03659e6c5818c10d248ba54b72fc6fb12f1eabca /src/or | |
parent | e722bba263e6c4648fff4259a14677993697337c (diff) | |
download | tor-8b4cf7771e869bea4550452ad2cf5634278e0e87.tar.gz tor-8b4cf7771e869bea4550452ad2cf5634278e0e87.zip |
Enable/disable per-second callback as needed.
There are three cases where this can happen: changes in our
controller events, changes in our DisableNetwork setting, and
changes in our hibernation state.
Closes ticket 26063.
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/config.c | 3 | ||||
-rw-r--r-- | src/or/control.c | 5 | ||||
-rw-r--r-- | src/or/hibernate.c | 2 |
3 files changed, 10 insertions, 0 deletions
diff --git a/src/or/config.c b/src/or/config.c index e695947f07..2cc28b6d76 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -2001,6 +2001,9 @@ options_act(const or_options_t *old_options) finish_daemon(options->DataDirectory); } + /* See whether we need to enable/disable our once-a-second timer. */ + reschedule_per_second_timer(); + /* We want to reinit keys as needed before we do much of anything else: keys are important, and other things can depend on them. */ if (transition_affects_workers || diff --git a/src/or/control.c b/src/or/control.c index 44439b6d5f..237a8572d4 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -277,6 +277,7 @@ control_update_global_event_mask(void) smartlist_t *conns = get_connection_array(); event_mask_t old_mask, new_mask; old_mask = global_event_mask; + int any_old_per_sec_events = control_any_per_second_event_enabled(); global_event_mask = 0; SMARTLIST_FOREACH(conns, connection_t *, _conn, @@ -316,6 +317,10 @@ control_update_global_event_mask(void) uint64_t r, w; control_get_bytes_rw_last_sec(&r, &w); } + if (any_old_per_sec_events != control_any_per_second_event_enabled()) { + reschedule_per_second_timer(); + } + #undef NEWLY_ENABLED } diff --git a/src/or/hibernate.c b/src/or/hibernate.c index f73b0420d3..24479cff9e 100644 --- a/src/or/hibernate.c +++ b/src/or/hibernate.c @@ -1137,6 +1137,8 @@ on_hibernate_state_change(hibernate_state_t prev_state) if (prev_state != HIBERNATE_STATE_INITIAL) { rescan_periodic_events(get_options()); } + + reschedule_per_second_timer(); } #ifdef TOR_UNIT_TESTS |