Browse Source

bugfix: if a circuit if borderline too old, then count it as too old.

bugfix: we were retrying the same circuit after getting a resolve
failure. so of course the next two tries would fail too. now we try
a new circuit each time (at most three times).


svn:r1867
Roger Dingledine 21 years ago
parent
commit
04bb8c8046
3 changed files with 11 additions and 4 deletions
  1. 1 1
      src/or/circuituse.c
  2. 0 2
      src/or/or.h
  3. 10 1
      src/or/relay.c

+ 1 - 1
src/or/circuituse.c

@@ -56,7 +56,7 @@ static int circuit_is_acceptable(circuit_t *circ,
 
   if(purpose == CIRCUIT_PURPOSE_C_GENERAL)
     if(circ->timestamp_dirty &&
-       circ->timestamp_dirty+options.NewCircuitPeriod < now)
+       circ->timestamp_dirty+options.NewCircuitPeriod <= now)
       return 0;
 
   if(conn) {

+ 0 - 2
src/or/or.h

@@ -1149,8 +1149,6 @@ extern unsigned long stats_n_relay_cells_delivered;
 
 int circuit_receive_relay_cell(cell_t *cell, circuit_t *circ,
                                int cell_direction);
-int circuit_package_relay_cell(cell_t *cell, circuit_t *circ,
-                               int cell_direction, crypt_path_t *layer_hint);
 
 void relay_header_pack(char *dest, const relay_header_t *src);
 void relay_header_unpack(relay_header_t *dest, const char *src);

+ 10 - 1
src/or/relay.c

@@ -10,6 +10,8 @@
 
 #include "or.h"
 
+extern or_options_t options; /* command-line and config-file options */
+
 static int relay_crypt(circuit_t *circ, cell_t *cell, int cell_direction,
                 crypt_path_t **layer_hint, char *recognized);
 static connection_t *relay_lookup_conn(circuit_t *circ, cell_t *cell, int cell_direction);
@@ -281,7 +283,7 @@ static int relay_crypt(circuit_t *circ, cell_t *cell, int cell_direction,
  *  - Encrypt it to the right layer
  *  - connection_or_write_cell_to_buf to the right conn
  */
-int
+static int
 circuit_package_relay_cell(cell_t *cell, circuit_t *circ,
                            int cell_direction,
                            crypt_path_t *layer_hint)
@@ -509,8 +511,15 @@ connection_edge_process_relay_cell_not_open(
       if (client_dns_incr_failures(conn->socks_request->address)
           < MAX_RESOLVE_FAILURES) {
         /* We haven't retried too many times; reattach the connection. */
+        log_fn(LOG_INFO,"Resolve of '%s' failed, trying again.",
+               conn->socks_request->address);
+        circuit_log_path(LOG_INFO,circ);
         conn->state = AP_CONN_STATE_CIRCUIT_WAIT;
         circuit_detach_stream(circ,conn);
+        tor_assert(circ->timestamp_dirty);
+        circ->timestamp_dirty -= options.NewCircuitPeriod;
+        /* make sure not to expire/retry the stream quite yet */
+        conn->timestamp_lastread = time(NULL);
         if(connection_ap_handshake_attach_circuit(conn) >= 0)
           return 0;
         /* else, conn will get closed below */