Browse Source

Merge remote-tracking branch 'public/bug12485'

Nick Mathewson 9 years ago
parent
commit
79e12da861
2 changed files with 16 additions and 1 deletions
  1. 4 0
      changes/bug12485
  2. 12 1
      src/or/entrynodes.c

+ 4 - 0
changes/bug12485

@@ -0,0 +1,4 @@
+  o Minor features (Guard nodes):
+    - Reduce the time delay before saving guard status to disk from 10
+      minute to 30 seconds (or from one hour to 10 minutes if
+      AvoidDiskWrites is set).  Closes ticket 12485.

+ 12 - 1
src/or/entrynodes.c

@@ -1523,6 +1523,13 @@ entry_guards_parse_state(or_state_t *state, int set, char **msg)
   return *msg ? -1 : 0;
 }
 
+/** How long will we let a change in our guard nodes stay un-saved
+ * when we are trying to avoid disk writes? */
+#define SLOW_GUARD_STATE_FLUSH_TIME 600
+/** How long will we let a change in our guard nodes stay un-saved
+ * when we are not trying to avoid disk writes? */
+#define FAST_GUARD_STATE_FLUSH_TIME 30
+
 /** Our list of entry guards has changed, or some element of one
  * of our entry guards has changed. Write the changes to disk within
  * the next few minutes.
@@ -1533,8 +1540,12 @@ entry_guards_changed(void)
   time_t when;
   entry_guards_dirty = 1;
 
+  if (get_options()->AvoidDiskWrites)
+    when = time(NULL) + SLOW_GUARD_STATE_FLUSH_TIME;
+  else
+    when = time(NULL) + FAST_GUARD_STATE_FLUSH_TIME;
+
   /* or_state_save() will call entry_guards_update_state(). */
-  when = get_options()->AvoidDiskWrites ? time(NULL) + 3600 : time(NULL)+600;
   or_state_mark_dirty(get_or_state(), when);
 }