aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2015-01-18 13:49:30 -0500
committerNick Mathewson <nickm@torproject.org>2015-01-18 13:49:30 -0500
commit79e12da86199fbfcf44aa7e569ea2d938156108b (patch)
tree9619ebecd7744308f904df9252b37d2db8f538bf /src
parentdcf8cddab25e5b189eaebf473423c2b31acb4525 (diff)
parentfb68f507618ab5479471384cc4a1fa8b4bfa99fe (diff)
downloadtor-79e12da86199fbfcf44aa7e569ea2d938156108b.tar.gz
tor-79e12da86199fbfcf44aa7e569ea2d938156108b.zip
Merge remote-tracking branch 'public/bug12485'
Diffstat (limited to 'src')
-rw-r--r--src/or/entrynodes.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 968a993999..5b0e342662 100644
--- a/src/or/entrynodes.c
+++ b/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);
}