changed path selection so it's actually random again

svn:r78
This commit is contained in:
Roger Dingledine 2002-08-23 05:27:50 +00:00
parent 08adaa4b46
commit 5414786cf1

View File

@ -156,15 +156,15 @@ unsigned int *new_route(double cw, routerinfo_t **rarray, size_t rarray_len, siz
choice = choice % (rarray_len); choice = choice % (rarray_len);
log(LOG_DEBUG,"new_route(): Contemplating router %u.",choice); log(LOG_DEBUG,"new_route(): Contemplating router %u.",choice);
while(choice == oldchoice || if(choice == oldchoice ||
(oldchoice < rarray_len && !pkey_cmp(rarray[choice]->pkey, rarray[oldchoice]->pkey)) || (oldchoice < rarray_len && !pkey_cmp(rarray[choice]->pkey, rarray[oldchoice]->pkey)) ||
!connection_twin_get_by_addr_port(rarray[choice]->addr, rarray[choice]->or_port)) { !connection_twin_get_by_addr_port(rarray[choice]->addr, rarray[choice]->or_port)) {
/* Same router as last choice, or router twin, /* Same router as last choice, or router twin,
* or no routers with that key are connected to us. * or no routers with that key are connected to us.
* Try again. */ * Try again. */
log(LOG_DEBUG,"new_route(): Picked a router %d that won't work as next hop.",choice); log(LOG_DEBUG,"new_route(): Picked a router %d that won't work as next hop.",choice);
choice++; i--;
choice = choice % (rarray_len); continue;
} }
log(LOG_DEBUG,"new_route(): Chosen router %u for hop %u.",choice,i); log(LOG_DEBUG,"new_route(): Chosen router %u for hop %u.",choice,i);
oldchoice = choice; oldchoice = choice;