[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] e more aggressive about calling routerlist_remove_old_route...
Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv14562/src/or
Modified Files:
routerlist.c
Log Message:
e more aggressive about calling routerlist_remove_old_routers()
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.377
retrieving revision 1.378
diff -u -d -r1.377 -r1.378
--- routerlist.c 23 Nov 2005 06:00:58 -0000 1.377
+++ routerlist.c 23 Nov 2005 07:06:36 -0000 1.378
@@ -34,6 +34,8 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
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,