Merge remote-tracking branch 'origin/maint-0.2.2'

Conflicts:
	src/or/main.c
	src/or/microdesc.c
This commit is contained in:
Nick Mathewson 2011-05-03 17:30:58 -04:00
commit 599d1b62b4
3 changed files with 15 additions and 3 deletions

6
changes/bug2230_part4 Normal file
View File

@ -0,0 +1,6 @@
o Minor bugfixes:
- Authorities now clean their microdesc cache periodically and when
reading from disk initially, not only when adding new descriptors.
This prevents a bug where we could lose microdescriptors. Bugfix
on 0.2.2.6-alpha.

View File

@ -1269,6 +1269,7 @@ run_scheduled_events(time_t now)
rep_history_clean(now - options->RephistTrackTime); rep_history_clean(now - options->RephistTrackTime);
rend_cache_clean(now); rend_cache_clean(now);
rend_cache_clean_v2_descs_as_dir(now); rend_cache_clean_v2_descs_as_dir(now);
microdesc_cache_rebuild(NULL, 0);
#define CLEAN_CACHES_INTERVAL (30*60) #define CLEAN_CACHES_INTERVAL (30*60)
time_to_clean_caches = now + CLEAN_CACHES_INTERVAL; time_to_clean_caches = now + CLEAN_CACHES_INTERVAL;
} }

View File

@ -245,8 +245,6 @@ microdescs_add_list_to_cache(microdesc_cache_t *cache,
if (f) if (f)
finish_writing_to_file(open_file); /*XXX Check me.*/ finish_writing_to_file(open_file); /*XXX Check me.*/
microdesc_cache_rebuild(cache, 0/* only as needed */);
{ {
networkstatus_t *ns = networkstatus_get_latest_consensus(); networkstatus_t *ns = networkstatus_get_latest_consensus();
if (ns && ns->flavor == FLAV_MICRODESC) if (ns && ns->flavor == FLAV_MICRODESC)
@ -273,6 +271,7 @@ microdesc_cache_clear(microdesc_cache_t *cache)
} }
cache->total_len_seen = 0; cache->total_len_seen = 0;
cache->n_seen = 0; cache->n_seen = 0;
cache->bytes_dropped = 0;
} }
/** Reload the contents of <b>cache</b> from disk. If it is empty, load it /** Reload the contents of <b>cache</b> from disk. If it is empty, load it
@ -314,7 +313,7 @@ microdesc_cache_reload(microdesc_cache_t *cache)
log_notice(LD_DIR, "Reloaded microdescriptor cache. Found %d descriptors.", log_notice(LD_DIR, "Reloaded microdescriptor cache. Found %d descriptors.",
total); total);
microdesc_cache_clean(cache, 0, 0); microdesc_cache_rebuild(cache, 0 /* don't force */);
return 0; return 0;
} }
@ -399,6 +398,12 @@ microdesc_cache_rebuild(microdesc_cache_t *cache, int force)
off_t off = 0; off_t off = 0;
int orig_size, new_size; int orig_size, new_size;
if (cache == NULL) {
cache = the_microdesc_cache;
if (cache == NULL)
return 0;
}
/* Remove dead descriptors */ /* Remove dead descriptors */
microdesc_cache_clean(cache, 0/*cutoff*/, 0/*force*/); microdesc_cache_clean(cache, 0/*cutoff*/, 0/*force*/);