diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-12-29 01:47:28 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-12-29 01:47:28 +0000 |
commit | 870fd18b8fe880c6194415f6744b08a3989a0166 (patch) | |
tree | e277a75238db8b402462b1bbd0bd578e6247c6f1 /src/or/routerlist.c | |
parent | 94507f1b6d563d301ef5ad284141105ebb3e9d2f (diff) | |
download | tor-870fd18b8fe880c6194415f6744b08a3989a0166.tar.gz tor-870fd18b8fe880c6194415f6744b08a3989a0166.zip |
Refactor some exit-policy-related functions that showed up in oprofile.
Specifically, split compare_tor_addr_to_addr_policy() from a loop with a bunch
of complicated ifs inside into some ifs, each with a simple loop. Rearrange
router_find_exact_exit_enclave() to run a little faster. Bizarrely,
router_policy_rejects_all() shows up on oprofile, so precalculate it per
routerinfo.
svn:r17802
Diffstat (limited to 'src/or/routerlist.c')
-rw-r--r-- | src/or/routerlist.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 71baf6ea8d..c4de128666 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -1449,16 +1449,19 @@ router_find_exact_exit_enclave(const char *address, uint16_t port) { uint32_t addr; struct in_addr in; + tor_addr_t a; if (!tor_inet_aton(address, &in)) return NULL; /* it's not an IP already */ addr = ntohl(in.s_addr); + tor_addr_from_ipv4h(&a, addr); + SMARTLIST_FOREACH(routerlist->routers, routerinfo_t *, router, { - if (router->is_running && - router->addr == addr && - compare_addr_to_addr_policy(addr, port, router->exit_policy) == + if (router->addr == addr && + router->is_running && + compare_tor_addr_to_addr_policy(&a, port, router->exit_policy) == ADDR_POLICY_ACCEPTED) return router; }); @@ -3645,8 +3648,7 @@ router_exit_policy_all_routers_reject(uint32_t addr, uint16_t port, int router_exit_policy_rejects_all(routerinfo_t *router) { - return compare_addr_to_addr_policy(0, 0, router->exit_policy) - == ADDR_POLICY_REJECTED; + return router->policy_is_reject_star; } /** Add to the list of authorized directory servers one at |