[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r19287: {tor} Clients replace entry guards that were chosen more than a fe (in tor/trunk: . src/or)



Author: arma
Date: 2009-04-11 08:00:18 -0400 (Sat, 11 Apr 2009)
New Revision: 19287

Modified:
   tor/trunk/ChangeLog
   tor/trunk/src/or/circuitbuild.c
Log:
Clients replace entry guards that were chosen more than a few months
ago. This change should significantly improve client performance,
especially once more people upgrade, since relays that have been
a guard for a long time are currently overloaded.


Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2009-04-11 06:08:12 UTC (rev 19286)
+++ tor/trunk/ChangeLog	2009-04-11 12:00:18 UTC (rev 19287)
@@ -3,12 +3,18 @@
     - Avoid crashing in the presence of certain malformed descriptors.
       Found by lark, and by automated fuzzing.
 
+  o Major features:
+    - Clients replace entry guards that were chosen more than a few months
+      ago. This change should significantly improve client performance,
+      especially once more people upgrade, since relays that have been
+      a guard for a long time are currently overloaded.
+
   o Major bugfixes:
     - Relays were falling out of the networkstatus consensus for
-      half a day if they changed their local config but the authorities
-      discarded their new descriptor as "not sufficiently different". Now
-      directory authorities accept a descriptor as changed if
-      bandwidthrate or bandwidthburst changed. Partial fix for bug 962;
+      part of a day if they changed their local config but the
+      authorities discarded their new descriptor as "not sufficiently
+      different". Now directory authorities accept a descriptor as changed
+      if bandwidthrate or bandwidthburst changed. Partial fix for bug 962;
       patch by Sebastian.
 
   o Minor features:

Modified: tor/trunk/src/or/circuitbuild.c
===================================================================
--- tor/trunk/src/or/circuitbuild.c	2009-04-11 06:08:12 UTC (rev 19286)
+++ tor/trunk/src/or/circuitbuild.c	2009-04-11 12:00:18 UTC (rev 19287)
@@ -2135,28 +2135,30 @@
 remove_obsolete_entry_guards(void)
 {
   int changed = 0, i;
+  time_t this_month = start_of_month(time(NULL));
+
   for (i = 0; i < smartlist_len(entry_guards); ++i) {
     entry_guard_t *entry = smartlist_get(entry_guards, i);
     const char *ver = entry->chosen_by_version;
     const char *msg = NULL;
     tor_version_t v;
-    int version_is_bad = 0;
     if (!ver) {
       msg = "does not say what version of Tor it was selected by";
-      version_is_bad = 1;
     } else if (tor_version_parse(ver, &v)) {
       msg = "does not seem to be from any recognized version of Tor";
-      version_is_bad = 1;
     } else if ((tor_version_as_new_as(ver, "0.1.0.10-alpha") &&
                 !tor_version_as_new_as(ver, "0.1.2.16-dev")) ||
                (tor_version_as_new_as(ver, "0.2.0.0-alpha") &&
                 !tor_version_as_new_as(ver, "0.2.0.6-alpha"))) {
       msg = "was selected without regard for guard bandwidth";
-      version_is_bad = 1;
+    } else if (entry->chosen_on_date + 3600*24*35 < this_month) {
+      /* It's been more than a month, and probably more like two since
+       * chosen_on_date is clipped to the beginning of its month. */
+      msg = "was selected several months ago";
     }
-    if (version_is_bad) {
+
+    if (msg) { /* we need to drop it */
       char dbuf[HEX_DIGEST_LEN+1];
-      tor_assert(msg);
       base16_encode(dbuf, sizeof(dbuf), entry->identity, DIGEST_LEN);
       log_notice(LD_CIRC, "Entry guard '%s' (%s) %s. (Version=%s.)  "
                  "Replacing it.",
@@ -2730,7 +2732,7 @@
     SMARTLIST_FOREACH(new_entry_guards, entry_guard_t *, e,
                       entry_guard_free(e));
     smartlist_free(new_entry_guards);
-  } else { /* !*err && set */
+  } else { /* !err && set */
     if (entry_guards) {
       SMARTLIST_FOREACH(entry_guards, entry_guard_t *, e,
                         entry_guard_free(e));
@@ -2738,6 +2740,8 @@
     }
     entry_guards = new_entry_guards;
     entry_guards_dirty = 0;
+    /* XXX022 hand new_entry_guards to this func, and move it up a
+     * few lines, so we don't have to re-dirty it */
     if (remove_obsolete_entry_guards())
       entry_guards_dirty = 1;
   }