Create new periodic event for pruning old info about Tor routers

This commit is contained in:
rl1987 2018-11-11 20:24:07 +02:00
parent e27dff08a3
commit 100136ca86
2 changed files with 31 additions and 6 deletions

5
changes/bug27929 Normal file
View file

@ -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.

View file

@ -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;