diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-08-18 13:36:09 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-08-18 13:36:09 -0400 |
commit | 5926d9cfccccfca19895522ed7a445626be8cc79 (patch) | |
tree | d6fbbb0ecc5e632f38132543e38de4cf7a24c406 /src/or/routerlist.c | |
parent | 23fdf0b30fd9fdfe1f82e5aa1b8a196c3ca68575 (diff) | |
download | tor-5926d9cfccccfca19895522ed7a445626be8cc79.tar tor-5926d9cfccccfca19895522ed7a445626be8cc79.tar.gz |
Move code for launching tests out of router_add_to_routerlist()
router_add_to_routerlist() is supposed to be a nice minimal function
that only touches the routerlist structures, but it included a call to
dirserv_single_reachability_test().
We have a function that gets called _after_ adding descriptors
successfully: routerlist_descriptors_added. This patch moves the
responsibility for testing there.
Because the decision of whether to test or not depends on whether
there was an old routerinfo for this router or not, we have to first
detect whether we _will_ want to run the tests if the router is added.
We make this the job of
routers_update_status_from_consensus_networkstatus().
Finally, this patch makes the code notice if a router is going from
hibernating to non-hibernating, and if so causes a reachability test
to get launched.
Diffstat (limited to 'src/or/routerlist.c')
-rw-r--r-- | src/or/routerlist.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 5f98abe01..968d5a104 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -3276,11 +3276,6 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg, * the list. */ routerlist_insert(routerlist, router); if (!from_cache) { - if (authdir) { - /* launch an immediate reachability test, so we will have an opinion - * soon in case we're generating a consensus soon */ - dirserv_single_reachability_test(time(NULL), router); - } signed_desc_append_to_journal(&router->cache_info, &routerlist->desc_store); } @@ -3600,15 +3595,19 @@ routerlist_remove_old_routers(void) /** We just added a new set of descriptors. Take whatever extra steps * we need. */ -static void +void routerlist_descriptors_added(smartlist_t *sl, int from_cache) { tor_assert(sl); control_event_descriptors_changed(sl); - SMARTLIST_FOREACH(sl, routerinfo_t *, ri, + SMARTLIST_FOREACH_BEGIN(sl, routerinfo_t *, ri) { if (ri->purpose == ROUTER_PURPOSE_BRIDGE) learned_bridge_descriptor(ri, from_cache); - ); + if (ri->needs_retest_if_added) { + ri->needs_retest_if_added = 0; + dirserv_single_reachability_test(approx_time(), ri); + } + } SMARTLIST_FOREACH_END(ri); } /** |