when we try to exclude our routerinfo from being picked in the

path, it fails because we're using a pointer to the routerinfo we
generate, not a pointer to the routerinfo in the routerlist. so look
up the right one and use that.


svn:r2286
This commit is contained in:
Roger Dingledine 2004-08-18 10:32:50 +00:00
parent 20b8819023
commit 3937ecfaae
3 changed files with 19 additions and 2 deletions

View file

@ -1098,7 +1098,7 @@ static routerinfo_t *choose_good_middle_server(cpath_build_state_t *state,
excluded = smartlist_create();
if((r = router_get_by_digest(state->chosen_exit_digest)))
smartlist_add(excluded, r);
if((r = router_get_my_routerinfo()))
if((r = routerlist_find_my_routerinfo()))
smartlist_add(excluded, r);
for (i = 0, cpath = head; i < cur_len; ++i, cpath=cpath->next) {
r = router_get_by_digest(cpath->identity_digest);
@ -1119,7 +1119,7 @@ static routerinfo_t *choose_good_entry_server(cpath_build_state_t *state)
if((r = router_get_by_digest(state->chosen_exit_digest)))
smartlist_add(excluded, r);
if((r = router_get_my_routerinfo()))
if((r = routerlist_find_my_routerinfo()))
smartlist_add(excluded, r);
if(options.FascistFirewall) {
/* exclude all ORs that listen on the wrong port */

View file

@ -1395,6 +1395,7 @@ routerinfo_t *router_pick_directory_server(int requireauth, int requireothers);
int all_directory_servers_down(void);
struct smartlist_t;
void add_nickname_list_to_smartlist(struct smartlist_t *sl, const char *list);
routerinfo_t *routerlist_find_my_routerinfo(void);
int router_nickname_matches(routerinfo_t *router, const char *nickname);
routerinfo_t *routerlist_sl_choose_by_bandwidth(smartlist_t *sl);
routerinfo_t *router_choose_random_node(char *preferred, char *excluded,

View file

@ -207,6 +207,22 @@ router_add_running_routers_to_smartlist(smartlist_t *sl, int allow_unverified)
}
}
routerinfo_t *
routerlist_find_my_routerinfo(void) {
routerinfo_t *router;
int i;
if(!routerlist)
return NULL;
for(i=0;i<smartlist_len(routerlist->routers);i++) {
router = smartlist_get(routerlist->routers, i);
if(router_is_me(router))
return router;
}
return NULL;
}
/** How many seconds a router must be up before we'll use it for
* reliability-critical node positions.
*/