summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-08-17 12:09:37 +0000
committerRoger Dingledine <arma@torproject.org>2004-08-17 12:09:37 +0000
commit2c002b1533b82299694598ab565923a05b3de574 (patch)
treee62a6cedc0a59be556209f30a166d17dfacf099a
parent4c47e07a11dfbd99d1549c9f737224455b751e30 (diff)
downloadtor-2c002b1533b82299694598ab565923a05b3de574.tar.gz
tor-2c002b1533b82299694598ab565923a05b3de574.zip
deal better if we don't have enough available nodes to choose a path
svn:r2262
-rw-r--r--src/or/circuitbuild.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 51ee835e49..2dac67d811 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -211,8 +211,8 @@ circuit_t *circuit_establish_circuit(uint8_t purpose,
return NULL;
}
- onion_extend_cpath(&circ->cpath, circ->build_state, &firsthop);
- if(!CIRCUIT_IS_ORIGIN(circ)) {
+ if(onion_extend_cpath(&circ->cpath, circ->build_state, &firsthop)<0 ||
+ !CIRCUIT_IS_ORIGIN(circ)) {
log_fn(LOG_INFO,"Generating first cpath hop failed.");
circuit_mark_for_close(circ);
return NULL;
@@ -220,6 +220,7 @@ circuit_t *circuit_establish_circuit(uint8_t purpose,
/* now see if we're already connected to the first OR in 'route' */
+ tor_assert(firsthop);
log_fn(LOG_DEBUG,"Looking for firsthop '%s:%u'",
firsthop->address,firsthop->or_port);
/* imprint the circuit with its future n_conn->id */
@@ -980,7 +981,7 @@ onion_new_cpath_build_state(uint8_t purpose, const char *exit_digest)
routerinfo_t *exit;
router_get_routerlist(&rl);
r = new_route_len(options.PathlenCoinWeight, purpose, rl->routers);
- if (r < 0)
+ if (r < 1) /* must be at least 1 */
return NULL;
info = tor_malloc_zero(sizeof(cpath_build_state_t));
info->desired_path_len = r;