diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-04-26 13:52:16 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-04-26 13:52:16 -0400 |
commit | 857e210b7d4939cf32d7d519b8b4d739d0b23f43 (patch) | |
tree | 8faff86c7152c38f9ff582ac08d5ce54bee90e10 /src | |
parent | 96c5ac338a7df986d2419e14801df42421debd06 (diff) | |
parent | 8a81a70878bb0f77ebdf1e6fda436b4b6af14f9a (diff) | |
download | tor-857e210b7d4939cf32d7d519b8b4d739d0b23f43.tar.gz tor-857e210b7d4939cf32d7d519b8b4d739d0b23f43.zip |
Merge branch 'ticket25931'
Diffstat (limited to 'src')
-rw-r--r-- | src/or/consdiffmgr.c | 33 | ||||
-rw-r--r-- | src/or/main.c | 6 |
2 files changed, 31 insertions, 8 deletions
diff --git a/src/or/consdiffmgr.c b/src/or/consdiffmgr.c index 02b905a520..323f4f9ca0 100644 --- a/src/or/consdiffmgr.c +++ b/src/or/consdiffmgr.c @@ -99,6 +99,14 @@ static const compress_method_t compress_diffs_with[] = { #endif }; +/** + * Event for rescanning the cache. + */ +static mainloop_event_t *consdiffmgr_rescan_ev = NULL; + +static void consdiffmgr_rescan_cb(mainloop_event_t *ev, void *arg); +static void mark_cdm_cache_dirty(void); + /** How many different methods will we try to use for diff compression? */ STATIC unsigned n_diff_compression_methods(void) @@ -372,7 +380,9 @@ cdm_cache_init(void) } else { consdiffmgr_set_cache_flags(); } - cdm_cache_dirty = 1; + consdiffmgr_rescan_ev = + mainloop_event_postloop_new(consdiffmgr_rescan_cb, NULL); + mark_cdm_cache_dirty(); cdm_cache_loaded = 0; } @@ -1095,6 +1105,24 @@ consdiffmgr_rescan(void) cdm_cache_dirty = 0; } +/** Callback wrapper for consdiffmgr_rescan */ +static void +consdiffmgr_rescan_cb(mainloop_event_t *ev, void *arg) +{ + (void)ev; + (void)arg; + consdiffmgr_rescan(); +} + +/** Mark the cache as dirty, and schedule a rescan event. */ +static void +mark_cdm_cache_dirty(void) +{ + cdm_cache_dirty = 1; + tor_assert(consdiffmgr_rescan_ev); + mainloop_event_activate(consdiffmgr_rescan_ev); +} + /** * Helper: compare two files by their from-valid-after and valid-after labels, * trying to sort in ascending order by from-valid-after (when present) and @@ -1219,6 +1247,7 @@ consdiffmgr_free_all(void) memset(latest_consensus, 0, sizeof(latest_consensus)); consensus_cache_free(cons_diff_cache); cons_diff_cache = NULL; + mainloop_event_free(consdiffmgr_rescan_ev); } /* ===== @@ -1750,7 +1779,7 @@ consensus_compress_worker_replyfn(void *work_) compress_consensus_with, job->out, "consensus"); - cdm_cache_dirty = 1; + mark_cdm_cache_dirty(); unsigned u; consensus_flavor_t f = job->flavor; diff --git a/src/or/main.c b/src/or/main.c index 18b9b780d1..83d1e6a41a 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -1742,12 +1742,6 @@ run_scheduled_events(time_t now) /* 11b. check pending unconfigured managed proxies */ if (!net_is_disabled() && pt_proxies_configuration_pending()) pt_configure_remaining_proxies(); - - /* 12. launch diff computations. (This is free if there are none to - * launch.) */ - if (dir_server_mode(options)) { - consdiffmgr_rescan(); - } } /* Periodic callback: rotate the onion keys after the period defined by the |