diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-09-28 23:57:49 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-09-28 23:57:49 +0000 |
commit | d3a06684bc626f17872a59a375cd6fbe1635baa4 (patch) | |
tree | e77c1f1b94870e70e163c370246ec299d7177deb /src/or | |
parent | 9988112c87bc5e4ad39880ffd2aa898e0e62e82f (diff) | |
download | tor-d3a06684bc626f17872a59a375cd6fbe1635baa4.tar tor-d3a06684bc626f17872a59a375cd6fbe1635baa4.tar.gz |
r8974@Kushana: nickm | 2006-09-28 17:05:59 -0400
Improvement to last entry guards patch: track when we last attempted to connect to a node in our state file along with how long it has been unreachable. Also clarify behavior of parse_iso_time() when it gets extra characters.
svn:r8520
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/circuitbuild.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index ed9ce5a76..6e36e1dab 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -2275,6 +2275,7 @@ entry_guards_parse_state(or_state_t *state, int set, char **msg) break; } else { time_t when; + time_t last_try = 0; if (!node) { *msg = tor_strdup("Unable to parse entry nodes: " "EntryGuardDownSince/UnlistedSince without EntryGuard"); @@ -2285,10 +2286,16 @@ entry_guards_parse_state(or_state_t *state, int set, char **msg) "Bad time in EntryGuardDownSince/UnlistedSince"); break; } - if (!strcasecmp(line->key, "EntryGuardDownSince")) + if (strlen(line->value) >= ISO_TIME_LEN+ISO_TIME_LEN+1) { + /* ignore failure */ + parse_iso_time(line->value+ISO_TIME_LEN+1, &last_try); + } + if (!strcasecmp(line->key, "EntryGuardDownSince")) { node->unreachable_since = when; - else + node->last_attempted = last_try; + } else { node->bad_since = when; + } } } @@ -2348,8 +2355,12 @@ entry_guards_update_state(or_state_t *state) if (e->unreachable_since) { *next = line = tor_malloc_zero(sizeof(config_line_t)); line->key = tor_strdup("EntryGuardDownSince"); - line->value = tor_malloc(ISO_TIME_LEN+1); + line->value = tor_malloc(ISO_TIME_LEN+1+ISO_TIME_LEN+1); format_iso_time(line->value, e->unreachable_since); + if (e->last_attempted) { + line->value[ISO_TIME_LEN] = ' '; + format_iso_time(line->value+ISO_TIME_LEN+1, e->last_attempted); + } next = &(line->next); } if (e->bad_since) { |