diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-10-07 15:28:54 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-10-07 15:28:54 -0400 |
commit | 3061a036c81cfa49a35ee06aadf525fba44ff761 (patch) | |
tree | 71ff465de7715024eb10608f4dfbeda7a3d6c921 /src/or/microdesc.c | |
parent | 4c71be65d83c961571db4ca460250503957cbe84 (diff) | |
download | tor-3061a036c81cfa49a35ee06aadf525fba44ff761.tar.gz tor-3061a036c81cfa49a35ee06aadf525fba44ff761.zip |
Unit tests for microdescriptor cache
May help with tracking down bug #2022
Diffstat (limited to 'src/or/microdesc.c')
-rw-r--r-- | src/or/microdesc.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/or/microdesc.c b/src/or/microdesc.c index 2752d15c8c..97d30ff655 100644 --- a/src/or/microdesc.c +++ b/src/or/microdesc.c @@ -316,21 +316,20 @@ microdesc_cache_reload(microdesc_cache_t *cache) /** DOCDOC */ void -microdesc_cache_clean(microdesc_cache_t *cache) +microdesc_cache_clean(microdesc_cache_t *cache, time_t cutoff, int force) { - networkstatus_t *consensus; - time_t cutoff; microdesc_t **mdp, *victim; int dropped=0, kept=0; size_t bytes_dropped = 0; time_t now = time(NULL); /* If we don't know a consensus, never believe last_listed values */ - consensus = networkstatus_get_reasonably_live_consensus(now, FLAV_MICRODESC); - if (consensus == NULL) - return; + if (! force && + ! networkstatus_get_reasonably_live_consensus(now, FLAV_MICRODESC)) + return; - cutoff = now - TOLERATE_MICRODESC_AGE; + if (cutoff <= 0) + cutoff = now - TOLERATE_MICRODESC_AGE; for (mdp = HT_START(microdesc_map, &cache->map); mdp != NULL; ) { if ((*mdp)->last_listed < cutoff) { @@ -368,7 +367,7 @@ microdesc_cache_rebuild(microdesc_cache_t *cache) log_info(LD_DIR, "Rebuilding the microdescriptor cache..."); - microdesc_cache_clean(cache); + microdesc_cache_clean(cache, 0/*cutoff*/, 0/*force*/); orig_size = (int)(cache->cache_content ? cache->cache_content->size : 0); orig_size += (int)cache->journal_len; |