Browse Source

Decouple routerlist_retry_directory_downloads() from the blob

Instead of having it call update_all_descriptor_downloads and
update_networkstatus_downloads directly, we can have it cause them to
get rescheduled and called from run_scheduled_events.

Closes ticket 16789.
Nick Mathewson 8 years ago
parent
commit
e62518865b
4 changed files with 20 additions and 4 deletions
  1. 6 0
      changes/decouple_retry_directory
  2. 11 0
      src/or/main.c
  3. 1 0
      src/or/main.h
  4. 2 4
      src/or/routerlist.c

+ 6 - 0
changes/decouple_retry_directory

@@ -0,0 +1,6 @@
+  o Code simplification and refactoring:
+    - Change the function that's called when we need to retry all downloads
+      so that it only reschedules the downloads to happen immediately, rather
+      than launching them all at once itself.  This further simplifies
+      Tor's callgraph.
+

+ 11 - 0
src/or/main.c

@@ -1280,6 +1280,17 @@ reschedule_descriptor_update_check(void)
   time_to.check_descriptor = 0;
 }
 
+/**
+ * Update our schedule so that we'll check whether we need to fetch directory
+ * info immediately.
+ */
+void
+reschedule_directory_downloads(void)
+{
+  time_to.download_networkstatus = 0;
+  time_to.try_getting_descriptors = 0;
+}
+
 /** Perform regular maintenance tasks.  This function gets run once per
  * second by second_elapsed_callback().
  */

+ 1 - 0
src/or/main.h

@@ -54,6 +54,7 @@ void ip_address_changed(int at_interface);
 void dns_servers_relaunch_checks(void);
 void reset_all_main_loop_timers(void);
 void reschedule_descriptor_update_check(void);
+void reschedule_directory_downloads(void);
 
 MOCK_DECL(long,get_uptime,(void));
 

+ 2 - 4
src/or/routerlist.c

@@ -4013,12 +4013,10 @@ update_all_descriptor_downloads(time_t now)
 void
 routerlist_retry_directory_downloads(time_t now)
 {
+  (void)now;
   router_reset_status_download_failures();
   router_reset_descriptor_download_failures();
-  if (get_options()->DisableNetwork)
-    return;
-  update_networkstatus_downloads(now);
-  update_all_descriptor_downloads(now);
+  reschedule_directory_downloads();
 }
 
 /** Return true iff <b>router</b> does not permit exit streams.