aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
Diffstat (limited to 'src/or')
-rw-r--r--src/or/microdesc.c15
-rw-r--r--src/or/microdesc.h2
2 files changed, 8 insertions, 9 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;
diff --git a/src/or/microdesc.h b/src/or/microdesc.h
index 1dfe3ae826..eda7008b91 100644
--- a/src/or/microdesc.h
+++ b/src/or/microdesc.h
@@ -22,7 +22,7 @@ smartlist_t *microdescs_add_list_to_cache(microdesc_cache_t *cache,
smartlist_t *descriptors, saved_location_t where,
int no_save);
-void microdesc_cache_clean(microdesc_cache_t *cache);
+void microdesc_cache_clean(microdesc_cache_t *cache, time_t cutoff, int force);
int microdesc_cache_rebuild(microdesc_cache_t *cache);
int microdesc_cache_reload(microdesc_cache_t *cache);
void microdesc_cache_clear(microdesc_cache_t *cache);