diff options
author | Roger Dingledine <arma@torproject.org> | 2003-11-18 09:53:03 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2003-11-18 09:53:03 +0000 |
commit | f0cccc567ecfd318305c4b6bab05091a50532e2a (patch) | |
tree | 8665d2934579eca13cb6510c3e25bd8024dd6f67 /src/or/onion.c | |
parent | ac56486bf64df4eb3264e87538ac415ce42eefd9 (diff) | |
download | tor-f0cccc567ecfd318305c4b6bab05091a50532e2a.tar tor-f0cccc567ecfd318305c4b6bab05091a50532e2a.tar.gz |
bugfix: don't ask for ->next of an expired circuit
bugfix: keep going when a circ fails in circuit_n_conn_open
(make circuit_enumerate_by_naddr_nport obsolete)
bugfix: make circuit_n_conn_open only look at circ's that start at us
bugfix: only try circuit_n_conn_open if we're an OP. Otherwise we
expect connections to always already be up.
bugfix: when choosing path length, pay attention to whether the directory
says a router is down.
bugfix: when picking good exit, skip routers which are known to be down
(more work needs to be done on this one)
svn:r838
Diffstat (limited to 'src/or/onion.c')
-rw-r--r-- | src/or/onion.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/or/onion.c b/src/or/onion.c index b50dd2bdc..84f43e9e8 100644 --- a/src/or/onion.c +++ b/src/or/onion.c @@ -254,15 +254,17 @@ static routerinfo_t *choose_good_exit_server(directory_t *dir) n_maybe_supported = tor_malloc(sizeof(int)*dir->n_routers); for (i = 0; i < dir->n_routers; ++i) { /* iterate over routers */ n_supported[i] = n_maybe_supported[i] = 0; + if(!dir->routers[i]->is_running) + continue; /* skip routers which are known to be down */ for (j = 0; j < n_connections; ++j) { /* iterate over connections */ if (carray[j]->type != CONN_TYPE_AP || carray[j]->state == AP_CONN_STATE_CIRCUIT_WAIT || carray[j]->marked_for_close) - continue; /* Skip everything by open APs in CIRCUIT_WAIT */ + continue; /* Skip everything but APs in CIRCUIT_WAIT */ switch (connection_ap_can_use_exit(carray[j], dir->routers[i])) { case -1: - break; + break; /* would be rejected; try next connection */ case 0: ++n_supported[i]; ; /* Fall through: If it is supported, it is also maybe supported. */ @@ -308,6 +310,7 @@ static routerinfo_t *choose_good_exit_server(directory_t *dir) } } /* This point should never be reached. */ + assert(0); } /* If any routers _maybe_ support pending connections, choose one at * random, as above. */ @@ -324,9 +327,11 @@ static routerinfo_t *choose_good_exit_server(directory_t *dir) } } /* This point should never be reached. */ + assert(0); } /* Either there are no pending connections, or no routers even seem to * possibly support any of them. Choose a router at random. */ + /* XXX should change to not choose non-running routers */ tor_free(n_supported); tor_free(n_maybe_supported); i = crypto_pseudo_rand_int(dir->n_routers); log_fn(LOG_DEBUG, "Chose exit server '%s'", dir->routers[i]->nickname); @@ -355,6 +360,10 @@ static int count_acceptable_routers(routerinfo_t **rarray, int rarray_len) { for(i=0;i<rarray_len;i++) { log_fn(LOG_DEBUG,"Contemplating whether router %d is a new option...",i); + if(rarray[i]->is_running == 0) { + log_fn(LOG_DEBUG,"Nope, the directory says %d is not running.",i); + goto next_i_loop; + } if(options.OnionRouter) { conn = connection_exact_get_by_addr_port(rarray[i]->addr, rarray[i]->or_port); if(!conn || conn->type != CONN_TYPE_OR || conn->state != OR_CONN_STATE_OPEN) { |