Переглянути джерело

r12842@catbus: nickm | 2007-05-21 21:51:45 -0400
Partial backport candidate. Fix issue noted in r10241: stores were rebuilt too often. Also notes dropped bytes better.


svn:r10244

Nick Mathewson 17 роки тому
батько
коміт
32c8d94c12
2 змінених файлів з 10 додано та 3 видалено
  1. 2 0
      ChangeLog
  2. 8 3
      src/or/routerlist.c

+ 2 - 0
ChangeLog

@@ -159,6 +159,8 @@ Changes in version 0.2.0.1-alpha - 2007-??-??
     - When choosing an entry guard for our circuit, avoid using guards
       that are in the same family as the chosen exit -- not just guards
       that are exactly the chosen exit. (Reported by lodger.)
+    - Don't rebuild the entire router store just because we got 32K of
+      routers.
 
   o Minor bugfixes (controller):
     - Make 'getinfo fingerprint' return a 551 error if we're not a

+ 8 - 3
src/or/routerlist.c

@@ -271,7 +271,6 @@ _compare_signed_descriptors_by_age(const void **_a, const void **_b)
 static int
 router_rebuild_store(int force, int extrainfo)
 {
-  size_t len = 0; /* XXX020 never used */
   or_options_t *options;
   size_t fname_len;
   smartlist_t *chunk_list = NULL;
@@ -394,7 +393,8 @@ router_rebuild_store(int force, int extrainfo)
   write_str_to_file(fname, "", 1);
 
   r = 0;
-  stats->store_len = len; /* XXX020 always 0 */
+  tor_assert(offset > 0);
+  stats->store_len = (size_t) offset;
   stats->journal_len = 0;
   stats->bytes_dropped = 0;
  done:
@@ -1827,8 +1827,11 @@ extrainfo_insert(routerlist_t *rl, extrainfo_t *ei)
                          ei->cache_info.signed_descriptor_digest,
                          ei);
   r = 1;
-  if (ei_tmp)
+  if (ei_tmp) {
+    extrainfo_store_stats.bytes_dropped +=
+      ei_tmp->cache_info.signed_descriptor_len;
     extrainfo_free(ei_tmp);
+  }
 
  done:
   if (r == 0)
@@ -2035,6 +2038,8 @@ routerlist_replace(routerlist_t *rl, routerinfo_t *ri_old,
     if (!tor_digest_is_zero(ri_old->cache_info.extra_info_digest))
       digestmap_remove(rl->desc_by_eid_map,
                        ri_old->cache_info.extra_info_digest);
+    router_store_stats.bytes_ropped +=
+      ri_old->cache_info.signed_descriptor_len;
     routerinfo_free(ri_old);
   }
 #ifdef DEBUG_ROUTERLIST