mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-03 17:13:33 +01:00
Track how many bytes we have in signed descriptors. Try to make sure we are tracking this right. Somebody should valgrind a dirserver on an example net. There should be code to dump this value.
svn:r5442
This commit is contained in:
parent
a39269572f
commit
7d7bb95f36
@ -875,7 +875,7 @@ typedef struct networkstatus_t {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
/** Map from server identity digest to a member of routers. */
|
/** Map from server identity digest to a member of routers. */
|
||||||
digestmap_t *identity_map;
|
digestmap_t *identity_map;
|
||||||
/** Map from server descriptor digest to a signed_descritptor_t from
|
/** Map from server descriptor digest to a signed_descriptor_t from
|
||||||
* routers or old_routers. */
|
* routers or old_routers. */
|
||||||
digestmap_t *desc_digest_map;
|
digestmap_t *desc_digest_map;
|
||||||
/** List of routerinfo_t for all currently live routers we know. */
|
/** List of routerinfo_t for all currently live routers we know. */
|
||||||
@ -883,6 +883,8 @@ typedef struct {
|
|||||||
/** List of signed_descriptor_t for older router descriptors we're
|
/** List of signed_descriptor_t for older router descriptors we're
|
||||||
* caching. */
|
* caching. */
|
||||||
smartlist_t *old_routers;
|
smartlist_t *old_routers;
|
||||||
|
/** For debugging: tracks RAM usage in signed descriptors. */
|
||||||
|
uint32_t signed_descriptor_bytes;
|
||||||
} routerlist_t;
|
} routerlist_t;
|
||||||
|
|
||||||
/** Information on router used when extending a circuit. (We don't need a
|
/** Information on router used when extending a circuit. (We don't need a
|
||||||
|
@ -1150,6 +1150,7 @@ routerlist_insert(routerlist_t *rl, routerinfo_t *ri)
|
|||||||
digestmap_set(rl->desc_digest_map, ri->cache_info.signed_descriptor_digest,
|
digestmap_set(rl->desc_digest_map, ri->cache_info.signed_descriptor_digest,
|
||||||
&(ri->cache_info));
|
&(ri->cache_info));
|
||||||
smartlist_add(rl->routers, ri);
|
smartlist_add(rl->routers, ri);
|
||||||
|
rl->signed_descriptor_bytes += ri->cache_info.signed_descriptor_len;
|
||||||
// routerlist_assert_ok(rl);
|
// routerlist_assert_ok(rl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1160,6 +1161,7 @@ routerlist_insert_old(routerlist_t *rl, routerinfo_t *ri)
|
|||||||
signed_descriptor_t *sd = signed_descriptor_from_routerinfo(ri);
|
signed_descriptor_t *sd = signed_descriptor_from_routerinfo(ri);
|
||||||
digestmap_set(rl->desc_digest_map, sd->signed_descriptor_digest, sd);
|
digestmap_set(rl->desc_digest_map, sd->signed_descriptor_digest, sd);
|
||||||
smartlist_add(rl->old_routers, sd);
|
smartlist_add(rl->old_routers, sd);
|
||||||
|
rl->signed_descriptor_bytes += sd->signed_descriptor_len;
|
||||||
} else {
|
} else {
|
||||||
routerinfo_free(ri);
|
routerinfo_free(ri);
|
||||||
}
|
}
|
||||||
@ -1188,6 +1190,7 @@ routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int idx, int make_old)
|
|||||||
} else {
|
} else {
|
||||||
ri_tmp = digestmap_remove(rl->desc_digest_map,
|
ri_tmp = digestmap_remove(rl->desc_digest_map,
|
||||||
ri->cache_info.signed_descriptor_digest);
|
ri->cache_info.signed_descriptor_digest);
|
||||||
|
rl->signed_descriptor_bytes -= ri->cache_info.signed_descriptor_len;
|
||||||
tor_assert(ri_tmp == ri);
|
tor_assert(ri_tmp == ri);
|
||||||
routerinfo_free(ri);
|
routerinfo_free(ri);
|
||||||
}
|
}
|
||||||
@ -1204,6 +1207,7 @@ routerlist_remove_old(routerlist_t *rl, signed_descriptor_t *sd, int idx)
|
|||||||
smartlist_del(rl->old_routers, idx);
|
smartlist_del(rl->old_routers, idx);
|
||||||
sd_tmp = digestmap_remove(rl->desc_digest_map,
|
sd_tmp = digestmap_remove(rl->desc_digest_map,
|
||||||
sd->signed_descriptor_digest);
|
sd->signed_descriptor_digest);
|
||||||
|
rl->signed_descriptor_bytes -= sd->signed_descriptor_len;
|
||||||
tor_assert(sd_tmp == sd);
|
tor_assert(sd_tmp == sd);
|
||||||
signed_descriptor_free(sd);
|
signed_descriptor_free(sd);
|
||||||
routerlist_assert_ok(rl);
|
routerlist_assert_ok(rl);
|
||||||
@ -1225,6 +1229,7 @@ routerlist_replace(routerlist_t *rl, routerinfo_t *ri_old,
|
|||||||
} else {
|
} else {
|
||||||
warn(LD_BUG, "Appending entry from routerlist_replace.");
|
warn(LD_BUG, "Appending entry from routerlist_replace.");
|
||||||
routerlist_insert(rl, ri_new);
|
routerlist_insert(rl, ri_new);
|
||||||
|
rl->signed_descriptor_bytes += ri_new->cache_info.signed_descriptor_len;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (memcmp(ri_old->cache_info.identity_digest, ri_new->cache_info.identity_digest, DIGEST_LEN)) {
|
if (memcmp(ri_old->cache_info.identity_digest, ri_new->cache_info.identity_digest, DIGEST_LEN)) {
|
||||||
@ -1233,6 +1238,7 @@ routerlist_replace(routerlist_t *rl, routerinfo_t *ri_old,
|
|||||||
}
|
}
|
||||||
digestmap_set(rl->identity_map, ri_new->cache_info.identity_digest, ri_new);
|
digestmap_set(rl->identity_map, ri_new->cache_info.identity_digest, ri_new);
|
||||||
digestmap_set(rl->desc_digest_map, ri_new->cache_info.signed_descriptor_digest, &(ri_new->cache_info));
|
digestmap_set(rl->desc_digest_map, ri_new->cache_info.signed_descriptor_digest, &(ri_new->cache_info));
|
||||||
|
rl->signed_descriptor_bytes += ri_new->cache_info.signed_descriptor_len;
|
||||||
|
|
||||||
if (make_old && get_options()->DirPort) {
|
if (make_old && get_options()->DirPort) {
|
||||||
signed_descriptor_t *sd = signed_descriptor_from_routerinfo(ri_old);
|
signed_descriptor_t *sd = signed_descriptor_from_routerinfo(ri_old);
|
||||||
@ -1245,6 +1251,7 @@ routerlist_replace(routerlist_t *rl, routerinfo_t *ri_old,
|
|||||||
/* digests don't match; digestmap_set didn't replace */
|
/* digests don't match; digestmap_set didn't replace */
|
||||||
digestmap_remove(rl->desc_digest_map, ri_old->cache_info.signed_descriptor_digest);
|
digestmap_remove(rl->desc_digest_map, ri_old->cache_info.signed_descriptor_digest);
|
||||||
}
|
}
|
||||||
|
rl->signed_descriptor_bytes -= ri_old->cache_info.signed_descriptor_len;
|
||||||
routerinfo_free(ri_old);
|
routerinfo_free(ri_old);
|
||||||
}
|
}
|
||||||
// routerlist_assert_ok(rl);
|
// routerlist_assert_ok(rl);
|
||||||
@ -3248,6 +3255,7 @@ 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,
|
||||||
@ -3256,6 +3264,7 @@ routerlist_assert_ok(routerlist_t *rl)
|
|||||||
tor_assert(r == r2);
|
tor_assert(r == r2);
|
||||||
sd2 = digestmap_get(rl->desc_digest_map, r->cache_info.signed_descriptor_digest);
|
sd2 = digestmap_get(rl->desc_digest_map, r->cache_info.signed_descriptor_digest);
|
||||||
tor_assert(&(r->cache_info) == sd2);
|
tor_assert(&(r->cache_info) == sd2);
|
||||||
|
bytes += r->cache_info.signed_descriptor_len;
|
||||||
});
|
});
|
||||||
SMARTLIST_FOREACH(rl->old_routers, signed_descriptor_t *, sd,
|
SMARTLIST_FOREACH(rl->old_routers, signed_descriptor_t *, sd,
|
||||||
{
|
{
|
||||||
@ -3263,7 +3272,9 @@ routerlist_assert_ok(routerlist_t *rl)
|
|||||||
tor_assert(sd != &(r2->cache_info));
|
tor_assert(sd != &(r2->cache_info));
|
||||||
sd2 = digestmap_get(rl->desc_digest_map, sd->signed_descriptor_digest);
|
sd2 = digestmap_get(rl->desc_digest_map, sd->signed_descriptor_digest);
|
||||||
tor_assert(sd == sd2);
|
tor_assert(sd == sd2);
|
||||||
|
bytes += sd->signed_descriptor_len;
|
||||||
});
|
});
|
||||||
|
tor_assert(bytes == rl->signed_descriptor_bytes);
|
||||||
iter = digestmap_iter_init(rl->identity_map);
|
iter = digestmap_iter_init(rl->identity_map);
|
||||||
while (!digestmap_iter_done(iter)) {
|
while (!digestmap_iter_done(iter)) {
|
||||||
const char *d;
|
const char *d;
|
||||||
|
Loading…
Reference in New Issue
Block a user