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

[or-cvs] r17642: {tor} Rename or_is_obsolete and move it to or_connection_t where i (in tor/trunk: . src/or)



Author: nickm
Date: 2008-12-17 09:59:19 -0500 (Wed, 17 Dec 2008)
New Revision: 17642

Modified:
   tor/trunk/ChangeLog
   tor/trunk/src/or/circuitbuild.c
   tor/trunk/src/or/circuituse.c
   tor/trunk/src/or/connection_or.c
   tor/trunk/src/or/main.c
   tor/trunk/src/or/or.h
Log:
Rename or_is_obsolete and move it to or_connection_t where it belongs.

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2008-12-17 13:15:00 UTC (rev 17641)
+++ tor/trunk/ChangeLog	2008-12-17 14:59:19 UTC (rev 17642)
@@ -64,7 +64,11 @@
       points thrown away; bugfix on 0.2.1.7-alpha. Spotted by John Brooks.
       Patch by Karsten. Fixes bug 874.
 
+  o Code simplifications and refactoring:
+    - Rename the confusing or_is_obsolete field to the more appropriate
+      is_bad_for_new_circs, and move it to or_connection_t where it belongs.
 
+
 Changes in version 0.2.1.8-alpha - 2008-12-08
   Tor 0.2.1.8-alpha fixes some crash bugs in earlier alpha releases,
   builds better on unusual platforms like Solaris and old OS X, and

Modified: tor/trunk/src/or/circuitbuild.c
===================================================================
--- tor/trunk/src/or/circuitbuild.c	2008-12-17 13:15:00 UTC (rev 17641)
+++ tor/trunk/src/or/circuitbuild.c	2008-12-17 14:59:19 UTC (rev 17642)
@@ -358,7 +358,7 @@
     *state_out = "in progress. Waiting.";
     *launch_out = 0; /* We'll just wait till the connection finishes. */
     return 0;
-  } else if (n_conn->_base.or_is_obsolete) {
+  } else if (n_conn->is_bad_for_new_circs) {
     *state_out = "too old. Launching a new one.";
     *launch_out = 1;
     return 0;

Modified: tor/trunk/src/or/circuituse.c
===================================================================
--- tor/trunk/src/or/circuituse.c	2008-12-17 13:15:00 UTC (rev 17641)
+++ tor/trunk/src/or/circuituse.c	2008-12-17 14:59:19 UTC (rev 17642)
@@ -820,7 +820,7 @@
                "Our circuit failed to get a response from the first hop "
                "(%s:%d). I'm going to try to rotate to a better connection.",
                n_conn->_base.address, n_conn->_base.port);
-      n_conn->_base.or_is_obsolete = 1;
+      n_conn->is_bad_for_new_circs = 1;
       entry_guard_register_connect_status(n_conn->identity_digest, 0,
                                           time(NULL));
     }

Modified: tor/trunk/src/or/connection_or.c
===================================================================
--- tor/trunk/src/or/connection_or.c	2008-12-17 13:15:00 UTC (rev 17641)
+++ tor/trunk/src/or/connection_or.c	2008-12-17 14:59:19 UTC (rev 17642)
@@ -474,14 +474,14 @@
     if (best->is_canonical && !conn->is_canonical)
       continue; /* A canonical connection is best. */
 
-    if (!best->_base.or_is_obsolete && conn->_base.or_is_obsolete)
+    if (!best->is_bad_for_new_circs && conn->is_bad_for_new_circs)
       continue; /* We never prefer obsolete over non-obsolete connections. */
 
     if (
       /* We prefer canonical connections: */
         (!best->is_canonical && conn->is_canonical) ||
       /* We prefer non-obsolete connections: */
-        (best->_base.or_is_obsolete && !conn->_base.or_is_obsolete) ||
+        (best->is_bad_for_new_circs && !conn->is_bad_for_new_circs) ||
       /* If both have circuits we prefer the newer: */
         (best->n_circuits && conn->n_circuits && newer) ||
       /* If neither has circuits we prefer the newer: */

Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2008-12-17 13:15:00 UTC (rev 17641)
+++ tor/trunk/src/or/main.c	2008-12-17 14:59:19 UTC (rev 17642)
@@ -99,8 +99,8 @@
 #define DIR_CONN_MAX_STALL (5*60)
 
 /** How old do we let a connection to an OR get before deciding it's
- * obsolete? */
-#define TIME_BEFORE_OR_CONN_IS_OBSOLETE (60*60*24*7)
+ * too old for new circuits? */
+#define TIME_BEFORE_OR_CONN_IS_TOO_OLD (60*60*24*7)
 /** How long do we let OR connections handshake before we decide that
  * they are obsolete? */
 #define TLS_HANDSHAKE_TIMEOUT (60)
@@ -714,13 +714,14 @@
 
   or_conn = TO_OR_CONN(conn);
 
-  if (!conn->or_is_obsolete) {
-    if (conn->timestamp_created + TIME_BEFORE_OR_CONN_IS_OBSOLETE < now) {
+  if (!or_conn->is_bad_for_new_circs) {
+    if (conn->timestamp_created + TIME_BEFORE_OR_CONN_IS_TOO_OLD < now) {
       log_info(LD_OR,
-               "Marking OR conn to %s:%d obsolete (fd %d, %d secs old).",
+               "Marking OR conn to %s:%d as too old for new circuits "
+               "(fd %d, %d secs old).",
                conn->address, conn->port, conn->s,
                (int)(now - conn->timestamp_created));
-      conn->or_is_obsolete = 1;
+      or_conn->is_bad_for_new_circs = 1;
     } else {
       or_connection_t *best =
         connection_or_get_by_identity_digest(or_conn->identity_digest);
@@ -735,19 +736,19 @@
            * early for router->last_reachable to be updated.
            */
         log_info(LD_OR,
-                 "Marking duplicate conn to %s:%d obsolete "
+                 "Marking duplicate conn to %s:%d as too old for new circuits "
                  "(fd %d, %d secs old).",
                  conn->address, conn->port, conn->s,
                  (int)(now - conn->timestamp_created));
-        conn->or_is_obsolete = 1;
+        or_conn->is_bad_for_new_circs = 1;
       }
     }
   }
 
-  if (conn->or_is_obsolete && !or_conn->n_circuits) {
+  if (or_conn->is_bad_for_new_circs && !or_conn->n_circuits) {
     /* no unmarked circs -- mark it now */
     log_info(LD_OR,
-             "Expiring non-used OR connection to fd %d (%s:%d) [Obsolete].",
+             "Expiring non-used OR connection to fd %d (%s:%d) [Too old].",
              conn->s, conn->address, conn->port);
     if (conn->state == OR_CONN_STATE_CONNECTING)
       connection_or_connect_failed(TO_OR_CONN(conn),
@@ -905,7 +906,7 @@
     }
     last_rotated_x509_certificate = now;
     /* We also make sure to rotate the TLS connections themselves if they've
-     * been up for too long -- but that's done via or_is_obsolete in
+     * been up for too long -- but that's done via is_bad_for_new_circs in
      * connection_run_housekeeping() above. */
   }
 

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2008-12-17 13:15:00 UTC (rev 17641)
+++ tor/trunk/src/or/or.h	2008-12-17 14:59:19 UTC (rev 17642)
@@ -904,10 +904,6 @@
   /** Edge connections only: true if we've blocked reading until the
    * circuit has fewer queued cells. */
   unsigned int edge_blocked_on_circ:1;
-  /** Used for OR conns that shouldn't get any new circs attached to them,
-   * because the connection is too old. */
-  /* XXXX "obsolete" isn't really a good name here. */
-  unsigned int or_is_obsolete:1;
   /** For AP connections only. If 1, and we fail to reach the chosen exit,
    * stop requiring it. */
   unsigned int chosen_exit_optional:1;
@@ -1020,6 +1016,10 @@
    * address listed in a server descriptor, or because an authenticated
    * NETINFO cell listed the address we're connected to as recognized. */
   unsigned int is_canonical:1;
+  /** True iff this connection shouldn't get any new circs attached to it,
+   * because the connection is too old, or because there's a better one, etc.
+   */
+  unsigned int is_bad_for_new_circs:1;
   uint8_t link_proto; /**< What protocol version are we using? 0 for
                        * "none negotiated yet." */
   circid_t next_circ_id; /**< Which circ_id do we try to use next on