]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Decouple routerlist_retry_directory_downloads() from the blob
authorNick Mathewson <nickm@torproject.org>
Thu, 13 Aug 2015 13:41:43 +0000 (09:41 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 13 Aug 2015 13:45:30 +0000 (09:45 -0400)
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.

changes/decouple_retry_directory [new file with mode: 0644]
src/or/main.c
src/or/main.h
src/or/routerlist.c

diff --git a/changes/decouple_retry_directory b/changes/decouple_retry_directory
new file mode 100644 (file)
index 0000000..11f901b
--- /dev/null
@@ -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.
+
index a29387c67ac5465bd37b3c2749a7f4a8bb544f73..2e50c5b09029ebe46a54f6e8c72b2cbf7f257cf5 100644 (file)
@@ -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().
  */
index be0bd640574fc686ad0cd1d8563f73ea368b133e..31883d495a00063514f2c40e8349276719d0b94f 100644 (file)
@@ -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));
 
index aebbd480d2b23a81c7d4c79d945c16bd96825a89..8bd80391bc5752f95082f3b175a3276a6c0e8685 100644 (file)
@@ -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.