Browse Source

change APIs slightly to make #1944 easier

Roger Dingledine 13 years ago
parent
commit
d3836b02cc
3 changed files with 8 additions and 9 deletions
  1. 2 2
      src/or/main.c
  2. 4 5
      src/or/rendcommon.c
  3. 2 2
      src/or/rendcommon.h

+ 2 - 2
src/or/main.c

@@ -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
src/or/rendcommon.c

@@ -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
src/or/rendcommon.h

@@ -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,