[or-cvs] Resolve problem found by weasel: the v1 directory was inclu...

arma at seul.org arma at seul.org
Wed Mar 22 21:32:45 UTC 2006


Update of /home2/or/cvsroot/tor/src/or
In directory moria:/home/arma/work/onion/cvs/tor/src/or

Modified Files:
	dirserv.c 
Log Message:
Resolve problem found by weasel: the v1 directory was including
servers as much as 48 hours old, because that's how the new
routerlist->routers works. Now only include them if they're
20 hours old or less.


Index: dirserv.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/dirserv.c,v
retrieving revision 1.313
retrieving revision 1.314
diff -u -p -d -r1.313 -r1.314
--- dirserv.c	22 Mar 2006 11:23:00 -0000	1.313
+++ dirserv.c	22 Mar 2006 21:32:42 -0000	1.314
@@ -799,11 +799,12 @@ dirserv_dump_directory_to_string(char **
   char *recommended_versions;
   char digest[DIGEST_LEN];
   char published[ISO_TIME_LEN+1];
-  time_t published_on;
   char *buf = NULL;
   size_t buf_len;
   size_t identity_pkey_len;
   routerlist_t *rl = router_get_routerlist();
+  time_t now = time(NULL);
+  time_t cutoff = now - ROUTER_MAX_AGE_TO_PUBLISH;
 
   tor_assert(dir_out);
   *dir_out = NULL;
@@ -820,13 +821,13 @@ dirserv_dump_directory_to_string(char **
   recommended_versions =
     format_versions_list(get_options()->RecommendedVersions);
 
-  published_on = time(NULL);
-  format_iso_time(published, published_on);
+  format_iso_time(published, now);
 
   buf_len = 2048+strlen(recommended_versions)+
     strlen(router_status);
   SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri,
-                    buf_len += ri->cache_info.signed_descriptor_len+1);
+                    if (ri->cache_info.published_on >= cutoff)
+                      buf_len += ri->cache_info.signed_descriptor_len+1);
   buf = tor_malloc(buf_len);
   /* We'll be comparing against buf_len throughout the rest of the
      function, though strictly speaking we shouldn't be able to exceed
@@ -851,6 +852,8 @@ dirserv_dump_directory_to_string(char **
     {
       size_t len = ri->cache_info.signed_descriptor_len;
       const char *body;
+      if (ri->cache_info.published_on < cutoff)
+        continue;
       if (cp+len+1 >= buf+buf_len)
         goto truncated;
       body = signed_descriptor_get_body(&ri->cache_info);



More information about the tor-commits mailing list