[tor-commits] [tor/master] Create new periodic event for pruning old info about Tor routers

nickm at torproject.org nickm at torproject.org
Mon Nov 26 22:19:37 UTC 2018


commit 100136ca8624151605601d80b63746cfaeb6df47
Author: rl1987 <rl1987 at sdf.lonestar.org>
Date:   Sun Nov 11 20:24:07 2018 +0200

    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(-)

diff --git a/changes/bug27929 b/changes/bug27929
new file mode 100644
index 000000000..a97d18f20
--- /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 a9f142978..be1913613 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;





More information about the tor-commits mailing list