diff options
author | George Kadianakis <desnacked@riseup.net> | 2014-06-24 14:12:51 -0400 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2014-06-24 14:19:07 -0400 |
commit | 4245662b28d04f2c7d51b8175031007a80f1c3e5 (patch) | |
tree | cd3f53c3336709f73d3464f4eb7c5ed46ae4837f /src/or/routerlist.c | |
parent | 727ed5448a8e63fb8116bb691d55c99bc1ca03f6 (diff) | |
download | tor-4245662b28d04f2c7d51b8175031007a80f1c3e5.tar.gz tor-4245662b28d04f2c7d51b8175031007a80f1c3e5.zip |
Functionify the descriptor age check so that we can NOP it in tests.
Diffstat (limited to 'src/or/routerlist.c')
-rw-r--r-- | src/or/routerlist.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 8f3477a4a4..bf4aff3b55 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -3292,6 +3292,14 @@ routerlist_reset_warnings(void) networkstatus_reset_warnings(); } +/** Return 1 if the signed descriptor of this router is too old to be used. + * Otherwise return 0. */ +MOCK_IMPL(int, +router_descriptor_is_too_old,(const routerinfo_t *router)) +{ + return router->cache_info.published_on < time(NULL)-OLD_ROUTER_DESC_MAX_AGE; +} + /** Add <b>router</b> to the routerlist, if we don't already have it. Replace * older entries (if any) with the same key. Note: Callers should not hold * their pointers to <b>router</b> if this function fails; <b>router</b> @@ -3460,8 +3468,7 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg, } } - if (!in_consensus && from_cache && - router->cache_info.published_on < time(NULL) - OLD_ROUTER_DESC_MAX_AGE) { + if (!in_consensus && from_cache && router_descriptor_is_too_old(router)) { *msg = "Router descriptor was really old."; routerinfo_free(router); return ROUTER_WAS_NOT_NEW; |