From da26bb646e4ae6c571dedc29e9b68837e9cb238f Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 7 Jan 2015 10:37:33 -0500 Subject: [PATCH 1/2] Turn entry_guards_changed constants into symbolic constants --- src/or/entrynodes.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c index 9eb0efd670..05ed56072d 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 3600 +/** 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 600 + /** 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); } From fb68f507618ab5479471384cc4a1fa8b4bfa99fe Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 7 Jan 2015 10:39:44 -0500 Subject: [PATCH 2/2] Lower the delay before saving guard status to disk "Maybe this time should be reduced, since we are considering guard-related changes as quite important? It would be a pity to settle on a guard node, then close the Tor client fast and lose that information." Closes 12485. --- changes/bug12485 | 4 ++++ src/or/entrynodes.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 changes/bug12485 diff --git a/changes/bug12485 b/changes/bug12485 new file mode 100644 index 0000000000..53ce33ef7b --- /dev/null +++ b/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. diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c index 05ed56072d..116f047074 100644 --- a/src/or/entrynodes.c +++ b/src/or/entrynodes.c @@ -1525,10 +1525,10 @@ entry_guards_parse_state(or_state_t *state, int set, char **msg) /** 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 3600 +#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 600 +#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