[or-cvs] r10612: if we already have a bridge in our state file, it won't be i (tor/trunk/src/or)

arma at seul.org arma at seul.org
Fri Jun 15 18:32:28 UTC 2007


Author: arma
Date: 2007-06-15 14:32:27 -0400 (Fri, 15 Jun 2007)
New Revision: 10612

Modified:
   tor/trunk/src/or/circuitbuild.c
Log:
if we already have a bridge in our state file, it won't be
in the networkstatuses, so we'll mark it unusable when we
load it, and then when we get a new routerinfo for it, we'll
still think it's unusable. fix that.


Modified: tor/trunk/src/or/circuitbuild.c
===================================================================
--- tor/trunk/src/or/circuitbuild.c	2007-06-15 16:21:40 UTC (rev 10611)
+++ tor/trunk/src/or/circuitbuild.c	2007-06-15 18:32:27 UTC (rev 10612)
@@ -1958,16 +1958,16 @@
   return n;
 }
 
-/** Return 1 if <b>digest</b> matches the identity of any node
- * in the entry_guards list. Else return 0. */
-static INLINE int
+/** If <b>digest</b> matches the identity of any node in the
+ * entry_guards list, return that node. Else return NULL. */
+static INLINE entry_guard_t *
 is_an_entry_guard(const char *digest)
 {
   SMARTLIST_FOREACH(entry_guards, entry_guard_t *, entry,
                     if (!memcmp(digest, entry->identity, DIGEST_LEN))
-                      return 1;
+                      return entry;
                    );
-  return 0;
+  return NULL;
 }
 
 /** Dump a description of our list of entry guards to the log at level
@@ -2032,15 +2032,19 @@
  * already in our entry_guards list, put it at the *beginning*.
  * Else, put the one we pick at the end of the list. */
 static routerinfo_t *
-add_an_entry_guard(routerinfo_t *chosen)
+add_an_entry_guard(routerinfo_t *chosen, int reset_status)
 {
   routerinfo_t *router;
   entry_guard_t *entry;
 
   if (chosen) {
     router = chosen;
-    if (is_an_entry_guard(router->cache_info.identity_digest))
+    entry = is_an_entry_guard(router->cache_info.identity_digest);
+    if (entry) {
+      if (reset_status)
+        entry->bad_since = 0;
       return NULL;
+    }
   } else {
     router = choose_good_entry_server(CIRCUIT_PURPOSE_C_GENERAL, NULL);
     if (!router)
@@ -2071,7 +2075,7 @@
   tor_assert(entry_guards);
 
   while (num_live_entry_guards() < options->NumEntryGuards) {
-    if (!add_an_entry_guard(NULL))
+    if (!add_an_entry_guard(NULL, 0))
       break;
     changed = 1;
   }
@@ -2346,7 +2350,7 @@
   smartlist_add_all(entry_guards, old_entry_guards_on_list);
   /* Next, the rest of EntryNodes */
   SMARTLIST_FOREACH(entry_routers, routerinfo_t *, ri, {
-    add_an_entry_guard(ri);
+    add_an_entry_guard(ri, 0);
   });
   /* Finally, the remaining EntryNodes, unless we're strict */
   if (options->StrictEntryNodes) {
@@ -2429,7 +2433,7 @@
       /* XXX if guard doesn't imply fast and stable, then we need
        * to tell add_an_entry_guard below what we want, or it might
        * be a long time til we get it. -RD */
-      r = add_an_entry_guard(NULL);
+      r = add_an_entry_guard(NULL, 0);
       if (r) {
         smartlist_add(live_entry_guards, r);
         entry_guards_changed();
@@ -2780,7 +2784,7 @@
   if (get_options()->UseBridges) {
     int first = !any_bridge_descriptors_known();
     ri->is_running = 1;
-    add_an_entry_guard(ri);
+    add_an_entry_guard(ri, 1);
     log_notice(LD_DIR, "new bridge descriptor '%s'", ri->nickname);
     if (first)
       routerlist_retry_directory_downloads(time(NULL));



More information about the tor-commits mailing list