diff options
author | Roger Dingledine <arma@torproject.org> | 2002-09-26 13:17:14 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2002-09-26 13:17:14 +0000 |
commit | f033442be292f9f573794913ca99fca83d622535 (patch) | |
tree | 9164a722f93e24b532af6b5e7387842b9f272a0a /src/or/routers.c | |
parent | 01f6727306c784f790fcf50077007a8b958c4e03 (diff) | |
download | tor-f033442be292f9f573794913ca99fca83d622535.tar.gz tor-f033442be292f9f573794913ca99fca83d622535.zip |
dirserver should include itself in the directory
if connecting to a dirserver fails, remove it from the router array
svn:r113
Diffstat (limited to 'src/or/routers.c')
-rw-r--r-- | src/or/routers.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/or/routers.c b/src/or/routers.c index b7984fe593..a0e4da6d84 100644 --- a/src/or/routers.c +++ b/src/or/routers.c @@ -21,6 +21,7 @@ static int rarray_len = 0; extern int global_role; /* from main.c */ extern or_options_t options; /* command-line and config-file options */ +extern routerinfo_t *my_routerinfo; /* from main.c */ /****************************************************************************/ @@ -175,6 +176,27 @@ void rarray_free(routerinfo_t **list) { free(list); } +void router_forget_router(uint32_t addr, uint16_t port) { + int i; + routerinfo_t *router; + + router = router_get_by_addr_port(addr,port); + if(!router) /* we don't seem to know about him in the first place */ + return; + + /* now walk down router_array until we get to router */ + for(i=0;i<rarray_len;i++) + if(router_array[i] == router) + break; + + assert(i != rarray_len); /* if so then router_get_by_addr_port should have returned null */ + + free(router); +// log(LOG_DEBUG,"router_forget_router(): Forgot about router %d:%d",addr,port); + for(; i<rarray_len-1;i++) + router_array[i] = router_array[i+1]; +} + /* create a NULL-terminated array of pointers pointing to elements of a router list */ /* this is done in two passes through the list - inefficient but irrelevant as this is * only done once when op/or start up */ @@ -289,6 +311,9 @@ int router_get_list_from_string(char *s, uint16_t or_listenport) { if(!router_is_me(router->addr, router->or_port, or_listenport)) { router->next = routerlist; routerlist = router; + } else { + if(!my_routerinfo) /* save it, so we can use it for directories */ + my_routerinfo = router; } s = eat_whitespace(s); } |