[or-cvs] [tor/master 3/4] Send control port events for timeouts.

arma at torproject.org arma at torproject.org
Wed Sep 29 21:22:02 UTC 2010


Author: Mike Perry <mikeperry-git at fscked.org>
Date: Sat, 24 Jul 2010 18:19:20 +0200
Subject: Send control port events for timeouts.
Commit: c5b5643965f57520842756e16d7ca7e8ea1cb2f8

We now differentiate between timeouts and cutoffs by the REASON string and
the PURPOSE string.
---
 doc/spec/control-spec.txt |    3 ++-
 src/or/circuitlist.c      |    2 +-
 src/or/circuituse.c       |    8 +++++++-
 src/or/or.h               |    4 ++++
 src/or/reasons.c          |    2 ++
 5 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/doc/spec/control-spec.txt b/doc/spec/control-spec.txt
index 31ce350..1864666 100644
--- a/doc/spec/control-spec.txt
+++ b/doc/spec/control-spec.txt
@@ -1005,7 +1005,8 @@
       Reason = "NONE" / "TORPROTOCOL" / "INTERNAL" / "REQUESTED" /
                "HIBERNATING" / "RESOURCELIMIT" / "CONNECTFAILED" /
                "OR_IDENTITY" / "OR_CONN_CLOSED" / "TIMEOUT" /
-               "FINISHED" / "DESTROYED" / "NOPATH" / "NOSUCHSERVICE"
+               "FINISHED" / "DESTROYED" / "NOPATH" / "NOSUCHSERVICE" /
+               "MEASUREMENT_EXPIRED"
 
    The path is provided only when the circuit has been extended at least one
    hop.
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index fa800db..fb4b69b 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -368,7 +368,7 @@ circuit_purpose_to_controller_string(uint8_t purpose)
     case CIRCUIT_PURPOSE_TESTING:
       return "TESTING";
     case CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT:
-      return "EXPIRED";
+      return "MEASURE_TIMEOUT";
     case CIRCUIT_PURPOSE_CONTROLLER:
       return "CONTROLLER";
 
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index d9c16c1..ce03500 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -389,6 +389,9 @@ circuit_expire_building(time_t now)
         /* Circuits are allowed to last longer for measurement.
          * Switch their purpose and wait. */
         if (victim->purpose != CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT) {
+          control_event_circuit_status(TO_ORIGIN_CIRCUIT(victim),
+                                       CIRC_EVENT_FAILED,
+                                       END_CIRC_REASON_TIMEOUT);
           victim->purpose = CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT;
           /* Record this failure to check for too many timeouts
            * in a row. This function does not record a time value yet
@@ -430,7 +433,10 @@ circuit_expire_building(time_t now)
                circuit_state_to_string(victim->state), victim->purpose);
 
     circuit_log_path(LOG_INFO,LD_CIRC,TO_ORIGIN_CIRCUIT(victim));
-    circuit_mark_for_close(victim, END_CIRC_REASON_TIMEOUT);
+    if (victim->purpose == CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT)
+      circuit_mark_for_close(victim, END_CIRC_REASON_MEASUREMENT_EXPIRED);
+    else
+      circuit_mark_for_close(victim, END_CIRC_REASON_TIMEOUT);
   }
 }
 
diff --git a/src/or/or.h b/src/or/or.h
index 2399ecf..6c398b7 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -614,6 +614,10 @@ typedef enum {
 
 /* Negative reasons are internal: we never send them in a DESTROY or TRUNCATE
  * call; they only go to the controller for tracking  */
+/** Our post-timeout circuit time measurement period expired.
+ * We must give up now */
+#define END_CIRC_REASON_MEASUREMENT_EXPIRED -3
+
 /** We couldn't build a path for this circuit. */
 #define END_CIRC_REASON_NOPATH          -2
 /** Catch-all "other" reason for closing origin circuits. */
diff --git a/src/or/reasons.c b/src/or/reasons.c
index ade9a3a..aa7972b 100644
--- a/src/or/reasons.c
+++ b/src/or/reasons.c
@@ -334,6 +334,8 @@ circuit_end_reason_to_control_string(int reason)
       return "NOPATH";
     case END_CIRC_REASON_NOSUCHSERVICE:
       return "NOSUCHSERVICE";
+    case END_CIRC_REASON_MEASUREMENT_EXPIRED:
+      return "MEASUREMENT_EXPIRED";
     default:
       log_warn(LD_BUG, "Unrecognized reason code %d", (int)reason);
       return NULL;
-- 
1.7.1




More information about the tor-commits mailing list