[or-cvs] attempted patch for bug 220: don"t assert when we"ve tried ...

arma at seul.org arma at seul.org
Tue Jan 17 04:17:01 UTC 2006


Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv9237

Modified Files:
	connection.c connection_edge.c rendclient.c 
Log Message:
attempted patch for bug 220: don't assert when we've tried all the
intro points for a hidden service and we try fetching the service
descriptor again.


Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.433
retrieving revision 1.434
diff -u -p -d -r1.433 -r1.434
--- connection.c	10 Jan 2006 22:42:44 -0000	1.433
+++ connection.c	17 Jan 2006 04:16:59 -0000	1.434
@@ -337,6 +337,7 @@ connection_about_to_close_connection(con
         /* It's a directory connection and connecting or fetching
          * failed: forget about this router, and maybe try again. */
         connection_dir_request_failed(conn);
+        // XXX if it's rend desc we may want to retry -RD
       }
       if (conn->purpose == DIR_PURPOSE_FETCH_RENDDESC)
         rend_client_desc_here(conn->rend_query); /* give it a try */

Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection_edge.c,v
retrieving revision 1.377
retrieving revision 1.378
diff -u -p -d -r1.377 -r1.378
--- connection_edge.c	5 Jan 2006 21:23:03 -0000	1.377
+++ connection_edge.c	17 Jan 2006 04:16:59 -0000	1.378
@@ -1133,7 +1133,7 @@ connection_ap_handshake_process_socks(co
     /* see if we already have it cached */
     r = rend_cache_lookup_entry(conn->rend_query, -1, &entry);
     if (r<0) {
-      warn(LD_REND,"Invalid service descriptor %s",
+      warn(LD_BUG,"Bug: Invalid service name '%s'",
            safe_str(conn->rend_query));
       connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);
       return -1;

Index: rendclient.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/rendclient.c,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -p -d -r1.102 -r1.103
--- rendclient.c	5 Jan 2006 21:23:03 -0000	1.102
+++ rendclient.c	17 Jan 2006 04:16:59 -0000	1.103
@@ -258,7 +258,7 @@ rend_client_refetch_renddesc(const char 
   }
 }
 
-/** remove failed_intro from ent. if ent now has no intro points, or
+/** Remove failed_intro from ent. If ent now has no intro points, or
  * service is unrecognized, then launch a new renddesc fetch.
  *
  * Return -1 if error, 0 if no intro points remain or service
@@ -423,9 +423,18 @@ rend_client_desc_here(const char *query)
   connection_t *conn;
   rend_cache_entry_t *entry;
   time_t now = time(NULL);
+  int i, n_conns;
+  connection_t **carray;
 
-  while ((conn = connection_get_by_type_state_rendquery(CONN_TYPE_AP,
-                                 AP_CONN_STATE_RENDDESC_WAIT, query))) {
+  get_connection_array(&carray, &n_conns);
+
+  for (i = 0; i < n_conns; ++i) {
+    conn = carray[i];
+    if (conn->type != CONN_TYPE_AP ||
+        conn->state != AP_CONN_STATE_RENDDESC_WAIT ||
+        conn->marked_for_close ||
+        rend_cmp_service_ids(query, conn->rend_query))
+      continue;
     assert_connection_ok(conn, now);
     if (rend_cache_lookup_entry(conn->rend_query, -1, &entry) == 1 &&
         entry->parsed->n_intro_points > 0) {
@@ -445,7 +454,6 @@ rend_client_desc_here(const char *query)
         warn(LD_REND,"Rendezvous attempt failed. Closing.");
         connection_mark_unattached_ap(conn, END_STREAM_REASON_CANT_ATTACH);
       }
-      tor_assert(conn->state != AP_CONN_STATE_RENDDESC_WAIT); /* avoid loop */
     } else { /* 404, or fetch didn't get that far */
       notice(LD_REND,"Closing stream for '%s.onion': hidden service is "
              "unavailable (try again later).", safe_str(query));



More information about the tor-commits mailing list