Loading src/or/routers.c +30 −13 Original line number Diff line number Diff line Loading @@ -50,9 +50,10 @@ void router_retry_connections(void) { } routerinfo_t *router_pick_directory_server(void) { /* pick the first running router with a positive dir_port */ int i; /* pick a random running router with a positive dir_port */ int i,j; routerinfo_t *router, *dirserver=NULL; int num_dirservers=0; if(!directory) return NULL; Loading @@ -60,9 +61,10 @@ routerinfo_t *router_pick_directory_server(void) { for(i=0;i<directory->n_routers;i++) { router = directory->routers[i]; if(router->dir_port > 0 && router->is_running) return router; num_dirservers++; } if(!num_dirservers) { log_fn(LOG_INFO,"No dirservers are reachable. Trying them all again."); /* no running dir servers found? go through and mark them all as up, * and we'll cycle through the list again. */ Loading @@ -73,10 +75,25 @@ routerinfo_t *router_pick_directory_server(void) { dirserver = router; } } return dirserver; } j = crypto_pseudo_rand_int(num_dirservers); for (i=0;i<directory->n_routers;i++) { router = directory->routers[i]; if (router->dir_port > 0 && router->is_running) { if (j) --j; else { log_fn(LOG_DEBUG, "Chose server '%s'", router->nickname); return router; } } } assert(0); return NULL; } routerinfo_t *router_pick_randomly_from_running(void) { int i,j; int num_running=0; Loading Loading
src/or/routers.c +30 −13 Original line number Diff line number Diff line Loading @@ -50,9 +50,10 @@ void router_retry_connections(void) { } routerinfo_t *router_pick_directory_server(void) { /* pick the first running router with a positive dir_port */ int i; /* pick a random running router with a positive dir_port */ int i,j; routerinfo_t *router, *dirserver=NULL; int num_dirservers=0; if(!directory) return NULL; Loading @@ -60,9 +61,10 @@ routerinfo_t *router_pick_directory_server(void) { for(i=0;i<directory->n_routers;i++) { router = directory->routers[i]; if(router->dir_port > 0 && router->is_running) return router; num_dirservers++; } if(!num_dirservers) { log_fn(LOG_INFO,"No dirservers are reachable. Trying them all again."); /* no running dir servers found? go through and mark them all as up, * and we'll cycle through the list again. */ Loading @@ -73,10 +75,25 @@ routerinfo_t *router_pick_directory_server(void) { dirserver = router; } } return dirserver; } j = crypto_pseudo_rand_int(num_dirservers); for (i=0;i<directory->n_routers;i++) { router = directory->routers[i]; if (router->dir_port > 0 && router->is_running) { if (j) --j; else { log_fn(LOG_DEBUG, "Chose server '%s'", router->nickname); return router; } } } assert(0); return NULL; } routerinfo_t *router_pick_randomly_from_running(void) { int i,j; int num_running=0; Loading