瀏覽代碼

r16032@catbus: nickm | 2007-10-22 11:56:53 -0400
When our directory status or our v3 authority status changes, reschedule operations as appropriate. (Fixes some xxxx020 items)


svn:r12102

Nick Mathewson 18 年之前
父節點
當前提交
c47eb2c8d9
共有 5 個文件被更改,包括 15 次插入3 次删除
  1. 2 0
      ChangeLog
  2. 11 0
      src/or/config.c
  3. 1 2
      src/or/networkstatus.c
  4. 1 0
      src/or/or.h
  5. 0 1
      src/or/routerlist.c

+ 2 - 0
ChangeLog

@@ -31,6 +31,8 @@ Changes in version 0.2.0.9-alpha - 2007-10-??
     - Allow tor-gencert to generate a new certificate without replacing the
       signing key.
     - Allow certificates to include an address.
+    - When we change our directory-cache settings, reschedule all voting
+      and download operations.
 
   o Minor features (router descriptor cache):
     - If we find a cached-routers file that's been sitting around for more

+ 11 - 0
src/or/config.c

@@ -1119,6 +1119,17 @@ options_act(or_options_t *old_options)
       options_transition_affects_descriptor(old_options, options))
     mark_my_descriptor_dirty();
 
+  /* We may need to reschedule some directory stuff if our status changed. */
+  if (authdir_mode_v3(options) && !authdir_mode_v3(old_options))
+    dirvote_recalculate_timing(options, time(NULL));
+  if (!bool_eq(dirserver_mode(options), dirserver_mode(old_options))) {
+    /* Make sure update_router_have_min_dir_info gets called. */
+    router_dir_info_changed();
+    /* We might need to download a new consensus status later or sooner than
+     * we had expected. */
+    update_consensus_networkstatus_fetch_time(time(NULL));
+  }
+
   return 0;
 }
 

+ 1 - 2
src/or/networkstatus.c

@@ -776,11 +776,10 @@ networkstatus_consensus_download_failed(int status_code)
 
 /** Update the time at which we'll consider replacing the current
  * consensus. */
-static void
+void
 update_consensus_networkstatus_fetch_time(time_t now)
 {
   or_options_t *options = get_options();
-  /* XXXX020 call this when DirPort switches on or off. NMNM */
   networkstatus_vote_t *c = networkstatus_get_live_consensus(now);
   if (c) {
     long dl_interval;

+ 1 - 0
src/or/or.h

@@ -3103,6 +3103,7 @@ routerstatus_t *router_get_consensus_status_by_nickname(const char *nickname,
 const char *networkstatus_get_router_digest_by_nickname(const char *nickname);
 int networkstatus_nickname_is_unnamed(const char *nickname);
 void networkstatus_consensus_download_failed(int status_code);
+void update_consensus_networkstatus_fetch_time(time_t now);
 int should_delay_dir_fetches(or_options_t *options);
 void update_networkstatus_downloads(time_t now);
 networkstatus_v2_t *networkstatus_v2_get_by_digest(const char *digest);

+ 0 - 1
src/or/routerlist.c

@@ -3863,7 +3863,6 @@ router_dir_info_changed(void)
 static void
 update_router_have_minimum_dir_info(void)
 {
-  /*XXX020 call when dirserver_mode() changes. */
   int num_present = 0, num_usable=0;
   time_t now = time(NULL);
   int res;