[or-cvs] r9622: Fix an XXXX012: make entry guards _really_ get retried when (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Fri Feb 23 18:34:37 UTC 2007


Author: nickm
Date: 2007-02-23 13:34:35 -0500 (Fri, 23 Feb 2007)
New Revision: 9622

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/circuitbuild.c
Log:
 r11885 at catbus:  nickm | 2007-02-23 13:34:24 -0500
 Fix an XXXX012: make entry guards _really_ get retried when the network comes back online.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r11885] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-02-23 17:56:31 UTC (rev 9621)
+++ tor/trunk/ChangeLog	2007-02-23 18:34:35 UTC (rev 9622)
@@ -48,6 +48,8 @@
       wants (because it has received fresh networkstatuses in the meantime),
       do not warn the user.  Cache the descriptor if we're a cache; drop it
       if we aren't.
+    - Make earlier entry guards _really_ get retried when the network comes
+      back online.
 
   o Minor features (controller):
     - Warn the user when an application uses the obsolete binary v0

Modified: tor/trunk/src/or/circuitbuild.c
===================================================================
--- tor/trunk/src/or/circuitbuild.c	2007-02-23 17:56:31 UTC (rev 9621)
+++ tor/trunk/src/or/circuitbuild.c	2007-02-23 18:34:35 UTC (rev 9622)
@@ -25,8 +25,10 @@
 typedef struct {
   char nickname[MAX_NICKNAME_LEN+1];
   char identity[DIGEST_LEN];
-  uint8_t made_contact; /**< 0 if we have never connected to this router,
-                         * 1 if we have. */
+  unsigned int made_contact : 1; /**< 0 if we have never connected to this
+                                  * router, 1 if we have. */
+  unsigned int can_retry : 1; /**< Should we retry connecting to this entry,
+                               * in spite of having it marked as unreachable?*/
   time_t bad_since; /**< 0 if this guard is currently usable, or the time at
                       * which it was observed to become (according to the
                       * directory or the user configuration) unusable. */
@@ -1881,7 +1883,8 @@
   routerinfo_t *r;
   if (e->bad_since)
     return NULL;
-  if (!assume_reachable &&
+  /* no good if it's unreachable, unless assume_unreachable or can_retry. */
+  if ((!assume_reachable && !e->can_retry) &&
       e->unreachable_since && !entry_is_time_to_retry(e, time(NULL)))
     return NULL;
   r = router_get_by_digest(e->identity);
@@ -2162,6 +2165,7 @@
     if (entry->unreachable_since) {
       log_info(LD_CIRC, "Entry guard '%s' (%s) is now reachable again. Good.",
                entry->nickname, buf);
+      entry->can_retry = 0;
       entry->unreachable_since = 0;
       entry->last_attempted = now;
       control_event_guard(entry->nickname, entry->identity, "UP");
@@ -2197,6 +2201,7 @@
                 entry->nickname, buf, tbuf);
       entry->last_attempted = now;
     }
+    entry->can_retry = 0; /* We gave it an early chance; no good. */
   }
 
   if (first_contact) {
@@ -2205,19 +2210,13 @@
      * and close this connection so we don't use it before we've given
      * the others a shot. */
     SMARTLIST_FOREACH(entry_guards, entry_guard_t *, e, {
-        routerinfo_t *r;
         if (e == entry)
           break;
         if (e->made_contact) {
-          r = entry_is_live(e, 0, 1, 1);
-          if (r && !r->is_running) {
+          routerinfo_t *r = entry_is_live(e, 0, 1, 1);
+          if (r && e->unreachable_since) {
             refuse_conn = 1;
-            /* XXXX012 I think this might be broken; when picking entry nodes,
-             * we only look at unreachable_since and is_time_to_retry, and we
-             * pay no attention to is_running. If this is indeed the case, we
-             * can fix the bug by adding a retry_as_entry flag to
-             * routerinfo_t. -NM */
-            r->is_running = 1;
+            e->can_retry = 1;
           }
         }
       });



More information about the tor-commits mailing list