[or-cvs] [tor/master] change APIs slightly to make #1944 easier

arma at torproject.org arma at torproject.org
Mon Feb 7 12:12:25 UTC 2011


commit d3836b02cc579cd1c63d1b3fca57521c5a63beb2
Author: Roger Dingledine <arma at torproject.org>
Date:   Mon Feb 7 06:39:21 2011 -0500

    change APIs slightly to make #1944 easier
---
 src/or/main.c       |    4 ++--
 src/or/rendcommon.c |    9 ++++-----
 src/or/rendcommon.h |    4 ++--
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/or/main.c b/src/or/main.c
index 3a77f62..c6fd2c0 100644
--- a/src/or/main.c
+++ b/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;
   }
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c
index 290e8f8..aac660a 100644
--- a/src/or/rendcommon.c
+++ b/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;
diff --git a/src/or/rendcommon.h b/src/or/rendcommon.h
index 5014957..36d7e4a 100644
--- a/src/or/rendcommon.h
+++ b/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,



More information about the tor-commits mailing list