[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Fix paul gardner"s assert bug. Turns out when circuit_launc...
- To: or-cvs@freehaven.net
- Subject: [or-cvs] Fix paul gardner"s assert bug. Turns out when circuit_launc...
- From: arma@seul.org (Roger Dingledine)
- Date: Sat, 30 Oct 2004 01:04:54 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Sat, 30 Oct 2004 01:05:17 -0400
- Reply-to: or-dev@freehaven.net
- Sender: owner-or-cvs@freehaven.net
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
circuitbuild.c rendservice.c
Log Message:
Fix paul gardner's assert bug. Turns out when circuit_launch_by_nickname()
failed at the first hop, it would try to relaunch another circ right
then, even though the first circuit hadn't been populated yet with its
pending_final_cpath.
Index: circuitbuild.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuitbuild.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- circuitbuild.c 27 Oct 2004 21:14:10 -0000 1.45
+++ circuitbuild.c 30 Oct 2004 05:04:52 -0000 1.46
@@ -1167,7 +1167,7 @@
}
log_fn(LOG_DEBUG,"Chose router %s for hop %d (exit is %s)",
- choice->nickname, cur_len, state->chosen_exit_name);
+ choice->nickname, cur_len+1, state->chosen_exit_name);
hop = tor_malloc_zero(sizeof(crypt_path_t));
@@ -1184,7 +1184,7 @@
hop->deliver_window = CIRCWINDOW_START;
log_fn(LOG_DEBUG, "Extended circuit path with %s for hop %d",
- choice->nickname, cur_len);
+ choice->nickname, cur_len+1);
*router_out = choice;
return 0;
Index: rendservice.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendservice.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -d -r1.97 -r1.98
--- rendservice.c 27 Oct 2004 06:48:16 -0000 1.97
+++ rendservice.c 30 Oct 2004 05:04:52 -0000 1.98
@@ -30,6 +30,9 @@
/** Don't try to build more than this many circuits before giving up
* for a while.*/
#define MAX_INTRO_CIRCS_PER_PERIOD 10
+/** How many times will a hidden service operator attempt to connect to
+ * a requested rendezvous point before giving up? */
+#define MAX_REND_FAILURES 3
/** Represents a single hidden service running at this OP. */
typedef struct rend_service_t {
@@ -341,7 +344,7 @@
char buf[RELAY_PAYLOAD_SIZE];
char keys[DIGEST_LEN+CPATH_KEY_MATERIAL_LEN]; /* Holds KH, Df, Db, Kf, Kb */
rend_service_t *service;
- int r;
+ int r, i;
size_t len, keylen;
crypto_dh_env_t *dh = NULL;
circuit_t *launched = NULL;
@@ -444,16 +447,19 @@
/* Launch a circuit to alice's chosen rendezvous point.
*/
- launched = circuit_launch_by_nickname(CIRCUIT_PURPOSE_S_CONNECT_REND, rp_nickname);
- log_fn(LOG_INFO,
- "Accepted intro; launching circuit to '%s' (cookie %s) for service %s",
- rp_nickname, hexcookie, serviceid);
- if (!launched) {
- log_fn(LOG_WARN,
- "Can't launch circuit to rendezvous point '%s' for service %s",
+ for(i=0;i<MAX_REND_FAILURES;i++) {
+ launched = circuit_launch_by_nickname(CIRCUIT_PURPOSE_S_CONNECT_REND, rp_nickname);
+ if (launched)
+ break;
+ }
+ if(!launched) { /* give up */
+ log_fn(LOG_WARN,"Giving up launching first hop of circuit to rendezvous point '%s' for service %s",
rp_nickname, serviceid);
goto err;
}
+ log_fn(LOG_INFO,
+ "Accepted intro; launching circuit to '%s' (cookie %s) for service %s",
+ rp_nickname, hexcookie, serviceid);
tor_assert(launched->build_state);
/* Fill in the circuit's state. */
memcpy(launched->rend_pk_digest, circuit->rend_pk_digest,
@@ -477,10 +483,6 @@
return -1;
}
-/** How many times will a hidden service operator attempt to connect to
- * a requested rendezvous point before giving up? */
-#define MAX_REND_FAILURES 3
-
/** Called when we fail building a rendezvous circuit at some point other
* than the last hop: launches a new circuit to the same rendezvous point.
*/
@@ -499,20 +501,26 @@
return;
}
+ oldstate = oldcirc->build_state;
+ tor_assert(oldstate);
+
+ if(oldstate->pending_final_cpath == NULL) {
+ log_fn(LOG_INFO,"Skipping relaunch of circ that failed on its first hop. Initiator will retry.");
+ return;
+ }
+
log_fn(LOG_INFO,"Reattempting rendezvous circuit to %s",
- oldcirc->build_state->chosen_exit_name);
+ oldstate->chosen_exit_name);
newcirc = circuit_launch_by_nickname(CIRCUIT_PURPOSE_S_CONNECT_REND,
- oldcirc->build_state->chosen_exit_name);
+ oldstate->chosen_exit_name);
if (!newcirc) {
log_fn(LOG_WARN,"Couldn't relaunch rendezvous circuit to %s",
- oldcirc->build_state->chosen_exit_name);
+ oldstate->chosen_exit_name);
return;
}
- oldstate = oldcirc->build_state;
newstate = newcirc->build_state;
tor_assert(newstate);
- tor_assert(oldstate);
newstate->failure_count = oldstate->failure_count+1;
newstate->pending_final_cpath = oldstate->pending_final_cpath;
oldstate->pending_final_cpath = NULL;