瀏覽代碼

Make DirPostPeriod config option obsolete.
Force new descriptor upload every 18 hours, not 24, to avoid races.
Change rate-limiting on new descriptors due to bandwidth changes, from
45 minutes to 20 minutes.


svn:r4814

Roger Dingledine 20 年之前
父節點
當前提交
676b330eb2
共有 3 個文件被更改,包括 6 次插入25 次删除
  1. 1 11
      src/or/config.c
  2. 4 13
      src/or/main.c
  3. 1 1
      src/or/router.c

+ 1 - 11
src/or/config.c

@@ -115,7 +115,7 @@ static config_var_t _option_vars[] = {
   VAR("DirFetchPeriod",      INTERVAL, DirFetchPeriod,       "0 seconds"),  /** DOCDOC **/
   VAR("DirPolicy",           LINELIST, DirPolicy,            NULL),
   VAR("DirPort",             UINT,     DirPort,              "0"),
-  VAR("DirPostPeriod",       INTERVAL, DirPostPeriod,        "20 minutes"),
+  OBSOLETE("DirPostPeriod"),
   VAR("DirServer",           LINELIST, DirServers,           NULL),
   VAR("EntryNodes",          STRING,   EntryNodes,           NULL),
   VAR("ExcludeNodes",        STRING,   ExcludeNodes,         NULL),
@@ -1728,7 +1728,6 @@ options_validate(or_options_t *options)
   }
 
 #define MIN_DIR_FETCH_PERIOD 600
-#define MIN_DIR_POST_PERIOD 300
 #define MIN_REND_POST_PERIOD 300
 #define MIN_STATUS_FETCH_PERIOD 60
 
@@ -1746,11 +1745,6 @@ options_validate(or_options_t *options)
     log(LOG_WARN, "StatusFetchPeriod option must be at least %d seconds. Clipping.", MIN_STATUS_FETCH_PERIOD);
     options->StatusFetchPeriod = MIN_STATUS_FETCH_PERIOD;
   }
-  if (options->DirPostPeriod < MIN_DIR_POST_PERIOD) {
-    log(LOG_WARN, "DirPostPeriod option must be at least %d seconds. Clipping.",
-        MIN_DIR_POST_PERIOD);
-    options->DirPostPeriod = MIN_DIR_POST_PERIOD;
-  }
   if (options->RendPostPeriod < MIN_REND_POST_PERIOD) {
     log(LOG_WARN,"RendPostPeriod option must be at least %d seconds. Clipping.",
         MIN_REND_POST_PERIOD);
@@ -1772,10 +1766,6 @@ options_validate(or_options_t *options)
     log(LOG_WARN, "DirFetchPeriod is too large; clipping to %ds.", MAX_DIR_PERIOD);
     options->DirFetchPeriod = MAX_DIR_PERIOD;
   }
-  if (options->DirPostPeriod > MAX_DIR_PERIOD) {
-    log(LOG_WARN, "DirPostPeriod is too large; clipping to %ds.", MAX_DIR_PERIOD);
-    options->DirPostPeriod = MAX_DIR_PERIOD;
-  }
   if (options->StatusFetchPeriod > MAX_DIR_PERIOD) {
     log(LOG_WARN, "StatusFetchPeriod is too large; clipping to %ds.", MAX_DIR_PERIOD);
     options->StatusFetchPeriod = MAX_DIR_PERIOD;

+ 4 - 13
src/or/main.c

@@ -46,8 +46,6 @@ long time_of_process_start = 0;
 long stats_n_seconds_working = 0;
 /** When do we next download a directory? */
 static time_t time_to_fetch_directory = 0;
-/** When do we next upload our descriptor? */
-static time_t time_to_force_upload_descriptor = 0;
 /** When do we next download a running-routers summary? */
 static time_t time_to_fetch_running_routers = 0;
 
@@ -94,7 +92,7 @@ static char* nt_strerror(uint32_t errnum);
 #define nt_service_is_stopped() (0)
 #endif
 
-#define FORCE_REGENERATE_DESCRIPTOR_INTERVAL 24*60*60 /* 1 day. */
+#define FORCE_REGENERATE_DESCRIPTOR_INTERVAL 18*60*60 /* 18 hours */
 #define CHECK_DESCRIPTOR_INTERVAL 60 /* one minute */
 #define BUF_SHRINK_INTERVAL 60 /* one minute */
 #define TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT (20*60) /* 20 minutes */
@@ -545,9 +543,6 @@ directory_has_arrived(time_t now, char *identity_digest)
   if (!time_to_fetch_directory)
     time_to_fetch_directory = now + get_dir_fetch_period(options);
 
-  if (!time_to_force_upload_descriptor)
-    time_to_force_upload_descriptor = now + options->DirPostPeriod;
-
   if (!time_to_fetch_running_routers)
     time_to_fetch_running_routers = now + get_status_fetch_period(options);
 
@@ -709,8 +704,10 @@ run_scheduled_events(time_t now)
       time_to_fetch_running_routers = next_status_fetch;
     }
 
-    /* Also, take this chance to remove old information from rephist. */
+    /* Also, take this chance to remove old information from rephist
+     * and the rend cache. */
     rep_history_clean(now - options->RephistTrackTime);
+    rend_cache_clean();
   }
 
   if (time_to_fetch_running_routers < now) {
@@ -720,12 +717,6 @@ run_scheduled_events(time_t now)
     time_to_fetch_running_routers = now + get_status_fetch_period(options);
   }
 
-  if (time_to_force_upload_descriptor < now) {
-    /*XXXX this should go elsewhere. */
-    rend_cache_clean(); /* this should go elsewhere? */
-    time_to_force_upload_descriptor = now + options->DirPostPeriod;
-  }
-
   /* 2b. Once per minute, regenerate and upload the descriptor if the old
    * one is inaccurate. */
   if (time_to_check_descriptor < now) {

+ 1 - 1
src/or/router.c

@@ -792,7 +792,7 @@ mark_my_descriptor_dirty(void)
   desc_clean_since = 0;
 }
 
-#define MAX_BANDWIDTH_CHANGE_FREQ 45*60
+#define MAX_BANDWIDTH_CHANGE_FREQ 20*60
 /** Check whether bandwidth has changed a lot since the last time we announced
  * bandwidth.  If so, mark our descriptor dirty.*/
 void