From 100136ca8624151605601d80b63746cfaeb6df47 Mon Sep 17 00:00:00 2001 From: rl1987 Date: Sun, 11 Nov 2018 20:24:07 +0200 Subject: [PATCH 1/3] Create new periodic event for pruning old info about Tor routers --- changes/bug27929 | 5 +++++ src/core/mainloop/mainloop.c | 32 ++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 changes/bug27929 diff --git a/changes/bug27929 b/changes/bug27929 new file mode 100644 index 0000000000..a97d18f202 --- /dev/null +++ b/changes/bug27929 @@ -0,0 +1,5 @@ + o Minor bugfixes (periodic events): + - Refrain from calling routerlist_remove_old_routers() from + check_descriptor_callback(). Instead, create a new periodic + event that will run every minute even if Tor is not configured + as onion router. Fixes bug 27929; bugfix on 0.2.8.1-alpha. diff --git a/src/core/mainloop/mainloop.c b/src/core/mainloop/mainloop.c index a9f1429787..be19136130 100644 --- a/src/core/mainloop/mainloop.c +++ b/src/core/mainloop/mainloop.c @@ -1359,6 +1359,7 @@ CALLBACK(heartbeat); CALLBACK(hs_service); CALLBACK(launch_descriptor_fetches); CALLBACK(launch_reachability_tests); +CALLBACK(prune_old_routers); CALLBACK(reachability_warnings); CALLBACK(record_bridge_stats); CALLBACK(rend_cache_failure_clean); @@ -1391,6 +1392,8 @@ STATIC periodic_event_item_t periodic_events[] = { CALLBACK(retry_listeners, PERIODIC_EVENT_ROLE_ALL, PERIODIC_EVENT_FLAG_NEED_NET), CALLBACK(save_state, PERIODIC_EVENT_ROLE_ALL, 0), + CALLBACK(prune_old_routers, PERIODIC_EVENT_ROLE_ALL, + PERIODIC_EVENT_FLAG_NEED_NET), CALLBACK(rotate_x509_certificate, PERIODIC_EVENT_ROLE_ALL, 0), CALLBACK(write_stats_file, PERIODIC_EVENT_ROLE_ALL, 0), @@ -1454,6 +1457,7 @@ static periodic_event_item_t *fetch_networkstatus_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 *save_state_event=NULL; +static periodic_event_item_t *prune_old_routers_event=NULL; /** Reset all the periodic events so we'll do all our actions again as if we * just started up. @@ -1556,6 +1560,7 @@ initialize_periodic_events(void) STMT_BEGIN name ## _event = find_periodic_event( #name ); STMT_END NAMED_CALLBACK(check_descriptor); + NAMED_CALLBACK(prune_old_routers); NAMED_CALLBACK(dirvote); NAMED_CALLBACK(fetch_networkstatus); NAMED_CALLBACK(launch_descriptor_fetches); @@ -2220,6 +2225,27 @@ retry_dns_callback(time_t now, const or_options_t *options) return RETRY_DNS_INTERVAL; } +/** + * Periodic callback: prune routerlist of old information about Tor network. + */ +static int +prune_old_routers_callback(time_t now, const or_options_t *options) +{ +#define ROUTERLIST_PRUNING_INTERVAL (60) // 1 minute. + (void)now; + (void)options; + + if (!net_is_disabled()) { + /* If any networkstatus documents are no longer recent, we need to + * update all the descriptors' running status. */ + /* Remove dead routers. */ + log_debug(LD_GENERAL, "Pruning routerlist..."); + routerlist_remove_old_routers(); + } + + return ROUTERLIST_PRUNING_INTERVAL; +} + /** Periodic callback: consider rebuilding or and re-uploading our descriptor * (if we've passed our internal checks). */ static int @@ -2239,12 +2265,6 @@ check_descriptor_callback(time_t now, const or_options_t *options) check_descriptor_ipaddress_changed(now); mark_my_descriptor_dirty_if_too_old(now); consider_publishable_server(0); - /* If any networkstatus documents are no longer recent, we need to - * update all the descriptors' running status. */ - /* Remove dead routers. */ - /* XXXX This doesn't belong here, but it was here in the pre- - * XXXX refactoring code. */ - routerlist_remove_old_routers(); } return CHECK_DESCRIPTOR_INTERVAL; From 411780d563e4d08e12d8aef0bbe8915f48011cca Mon Sep 17 00:00:00 2001 From: rl1987 Date: Sat, 17 Nov 2018 10:19:25 +0200 Subject: [PATCH 2/3] Make ROUTERLIST_PRUNING_INTERVAL 1 hr. --- src/core/mainloop/mainloop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/mainloop/mainloop.c b/src/core/mainloop/mainloop.c index be19136130..0b9d4e0889 100644 --- a/src/core/mainloop/mainloop.c +++ b/src/core/mainloop/mainloop.c @@ -2231,7 +2231,7 @@ retry_dns_callback(time_t now, const or_options_t *options) static int prune_old_routers_callback(time_t now, const or_options_t *options) { -#define ROUTERLIST_PRUNING_INTERVAL (60) // 1 minute. +#define ROUTERLIST_PRUNING_INTERVAL (60*60) // 1 hour. (void)now; (void)options; From c8c4c3dffa71b4bbc9e7cabfee2124fb5e19ad39 Mon Sep 17 00:00:00 2001 From: rl1987 Date: Sat, 17 Nov 2018 10:27:10 +0200 Subject: [PATCH 3/3] fixup! Make ROUTERLIST_PRUNING_INTERVAL 1 hr. --- changes/bug27929 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes/bug27929 b/changes/bug27929 index a97d18f202..dab57a2eca 100644 --- a/changes/bug27929 +++ b/changes/bug27929 @@ -1,5 +1,5 @@ o Minor bugfixes (periodic events): - Refrain from calling routerlist_remove_old_routers() from check_descriptor_callback(). Instead, create a new periodic - event that will run every minute even if Tor is not configured + event that will run once every hour even if Tor is not configured as onion router. Fixes bug 27929; bugfix on 0.2.8.1-alpha.