change APIs slightly to make #1944 easier

This commit is contained in:
Roger Dingledine
2011-02-07 06:39:21 -05:00
parent 69f7c0385b
commit d3836b02cc
3 changed files with 8 additions and 9 deletions
+2 -2
View File
@@ -1254,8 +1254,8 @@ run_scheduled_events(time_t now)
/* Remove old information from rephist and the rend cache. */
if (time_to_clean_caches < now) {
rep_history_clean(now - options->RephistTrackTime);
rend_cache_clean();
rend_cache_clean_v2_descs_as_dir();
rend_cache_clean(now);
rend_cache_clean_v2_descs_as_dir(now);
#define CLEAN_CACHES_INTERVAL (30*60)
time_to_clean_caches = now + CLEAN_CACHES_INTERVAL;
}
+4 -5
View File
@@ -814,14 +814,13 @@ rend_cache_free_all(void)
/** Removes all old entries from the service descriptor cache.
*/
void
rend_cache_clean(void)
rend_cache_clean(time_t now)
{
strmap_iter_t *iter;
const char *key;
void *val;
rend_cache_entry_t *ent;
time_t cutoff;
cutoff = time(NULL) - REND_CACHE_MAX_AGE - REND_CACHE_MAX_SKEW;
time_t cutoff = now - REND_CACHE_MAX_AGE - REND_CACHE_MAX_SKEW;
for (iter = strmap_iter_init(rend_cache); !strmap_iter_done(iter); ) {
strmap_iter_get(iter, &key, &val);
ent = (rend_cache_entry_t*)val;
@@ -837,10 +836,10 @@ rend_cache_clean(void)
/** Remove all old v2 descriptors and those for which this hidden service
* directory is not responsible for any more. */
void
rend_cache_clean_v2_descs_as_dir(void)
rend_cache_clean_v2_descs_as_dir(time_t now)
{
digestmap_iter_t *iter;
time_t cutoff = time(NULL) - REND_CACHE_MAX_AGE - REND_CACHE_MAX_SKEW;
time_t cutoff = now - REND_CACHE_MAX_AGE - REND_CACHE_MAX_SKEW;
for (iter = digestmap_iter_init(rend_cache_v2_dir);
!digestmap_iter_done(iter); ) {
const char *key;
+2 -2
View File
@@ -34,8 +34,8 @@ void rend_encoded_v2_service_descriptor_free(
void rend_intro_point_free(rend_intro_point_t *intro);
void rend_cache_init(void);
void rend_cache_clean(void);
void rend_cache_clean_v2_descs_as_dir(void);
void rend_cache_clean(time_t now);
void rend_cache_clean_v2_descs_as_dir(time_t now);
void rend_cache_free_all(void);
int rend_valid_service_id(const char *query);
int rend_cache_lookup_desc(const char *query, int version, const char **desc,