mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
e more aggressive about calling routerlist_remove_old_routers()
svn:r5444
This commit is contained in:
parent
fbf8a8c25f
commit
36109fea33
@ -34,6 +34,8 @@ static int routerdesc_digest_is_recognized(const char *identity,
|
|||||||
const char *digest);
|
const char *digest);
|
||||||
static void routerlist_assert_ok(routerlist_t *rl);
|
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
|
/** 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,
|
SMARTLIST_FOREACH(routerlist->routers, routerinfo_t *, r,
|
||||||
livedescs += r->cache_info.signed_descriptor_len);
|
livedescs += r->cache_info.signed_descriptor_len);
|
||||||
SMARTLIST_FOREACH(routerlist->old_routers, signed_descriptor_t *, sd,
|
SMARTLIST_FOREACH(routerlist->old_routers, signed_descriptor_t *, sd,
|
||||||
livedescs += sd->signed_descriptor_len);
|
olddescs += sd->signed_descriptor_len);
|
||||||
|
|
||||||
log(severity, LD_GENERAL,
|
log(severity, LD_GENERAL,
|
||||||
"In %d live descriptors: "U64_FORMAT" bytes. "
|
"In %d live descriptors: "U64_FORMAT" bytes. "
|
||||||
@ -1146,6 +1148,13 @@ dump_routerlist_mem_usage(int severity)
|
|||||||
smartlist_len(routerlist->old_routers), U64_PRINTF_ARG(olddescs));
|
smartlist_len(routerlist->old_routers), U64_PRINTF_ARG(olddescs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static INLINE int
|
||||||
_routerlist_find_elt(smartlist_t *sl, void *ri, int idx)
|
_routerlist_find_elt(smartlist_t *sl, void *ri, int idx)
|
||||||
{
|
{
|
||||||
@ -1431,6 +1440,9 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (routerlist_is_overfull(routerlist))
|
||||||
|
routerlist_remove_old_routers();
|
||||||
|
|
||||||
if (authdir) {
|
if (authdir) {
|
||||||
if (authdir_wants_to_reject_router(router, msg)) {
|
if (authdir_wants_to_reject_router(router, msg)) {
|
||||||
routerinfo_free(router);
|
routerinfo_free(router);
|
||||||
@ -1537,8 +1549,6 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_DESCRIPTORS_PER_ROUTER 5
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_compare_old_routers_by_identity(const void **_a, const void **_b)
|
_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;
|
digestmap_iter_t *iter;
|
||||||
routerinfo_t *r2;
|
routerinfo_t *r2;
|
||||||
signed_descriptor_t *sd2;
|
signed_descriptor_t *sd2;
|
||||||
uint32_t bytes = 0;
|
|
||||||
if (!routerlist)
|
if (!routerlist)
|
||||||
return;
|
return;
|
||||||
SMARTLIST_FOREACH(rl->routers, routerinfo_t *, r,
|
SMARTLIST_FOREACH(rl->routers, routerinfo_t *, r,
|
||||||
|
Loading…
Reference in New Issue
Block a user