diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-11-23 07:06:36 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-11-23 07:06:36 +0000 |
commit | 36109fea334deee546a43bd8c7e22bba36f21f98 (patch) | |
tree | cd348eefde4b219103adaeaa55ed06f15b8c4504 /src/or | |
parent | fbf8a8c25f0ec63ca64b3e9de51dc75484eb0aeb (diff) | |
download | tor-36109fea334deee546a43bd8c7e22bba36f21f98.tar tor-36109fea334deee546a43bd8c7e22bba36f21f98.tar.gz |
e more aggressive about calling routerlist_remove_old_routers()
svn:r5444
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/routerlist.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 1100821b7..f3e3ff372 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -34,6 +34,8 @@ static int routerdesc_digest_is_recognized(const char *identity, const char *digest); static void routerlist_assert_ok(routerlist_t *rl); +#define MAX_DESCRIPTORS_PER_ROUTER 5 + /****************************************************************************/ /** Global list of a trusted_dir_server_t object for each trusted directory @@ -1137,7 +1139,7 @@ dump_routerlist_mem_usage(int severity) SMARTLIST_FOREACH(routerlist->routers, routerinfo_t *, r, livedescs += r->cache_info.signed_descriptor_len); SMARTLIST_FOREACH(routerlist->old_routers, signed_descriptor_t *, sd, - livedescs += sd->signed_descriptor_len); + olddescs += sd->signed_descriptor_len); log(severity, LD_GENERAL, "In %d live descriptors: "U64_FORMAT" bytes. " @@ -1147,6 +1149,13 @@ dump_routerlist_mem_usage(int severity) } static INLINE int +routerlist_is_overfull(routerlist_t *rl) +{ + return smartlist_len(rl->old_routers) > + smartlist_len(rl->routers)*(MAX_DESCRIPTORS_PER_ROUTER+1); +} + +static INLINE int _routerlist_find_elt(smartlist_t *sl, void *ri, int idx) { if (idx < 0 || smartlist_get(sl, idx) != ri) { @@ -1431,6 +1440,9 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg, return -1; } + if (routerlist_is_overfull(routerlist)) + routerlist_remove_old_routers(); + if (authdir) { if (authdir_wants_to_reject_router(router, msg)) { routerinfo_free(router); @@ -1537,8 +1549,6 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg, return 0; } -#define MAX_DESCRIPTORS_PER_ROUTER 5 - static int _compare_old_routers_by_identity(const void **_a, const void **_b) { @@ -3267,7 +3277,6 @@ routerlist_assert_ok(routerlist_t *rl) digestmap_iter_t *iter; routerinfo_t *r2; signed_descriptor_t *sd2; - uint32_t bytes = 0; if (!routerlist) return; SMARTLIST_FOREACH(rl->routers, routerinfo_t *, r, |