aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-06-27 15:52:51 +0000
committerNick Mathewson <nickm@torproject.org>2006-06-27 15:52:51 +0000
commitd3784ff1df5f18db00db1d9e2e7d27f8b756507a (patch)
tree9f3c5f761b1040183964b8a302352e97c7f0a721 /src/or
parent3117a41d1b1aac6eaeeebe4c28ecf4e7f158412f (diff)
downloadtor-d3784ff1df5f18db00db1d9e2e7d27f8b756507a.tar
tor-d3784ff1df5f18db00db1d9e2e7d27f8b756507a.tar.gz
Likely fix for bug 309: when we calculate offsets after rebuilding the descriptor cache, do not reset the offset pointer half-way through.
svn:r6693
Diffstat (limited to 'src/or')
-rw-r--r--src/or/routerlist.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 009858054..548103a0c 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -221,6 +221,7 @@ router_rebuild_store(int force)
smartlist_t *chunk_list = NULL;
char *fname = NULL;
int r = -1, i;
+ off_t offset = 0;
if (!force && !router_should_rebuild_store())
return 0;
@@ -230,6 +231,8 @@ router_rebuild_store(int force)
/* Don't save deadweight. */
routerlist_remove_old_routers();
+ log_info(LD_DIR, "Rebuilding router descriptor cache");
+
options = get_options();
fname_len = strlen(options->DataDirectory)+32;
fname = tor_malloc(fname_len);
@@ -279,19 +282,19 @@ router_rebuild_store(int force)
log_warn(LD_FS, "Unable to mmap new descriptor file at '%s'.",fname);
}
+ offset = 0;
for (i = 0; i < 2; ++i) {
smartlist_t *lst = (i == 0) ? routerlist->old_routers :
routerlist->routers;
- off_t offset = 0;
SMARTLIST_FOREACH(lst, void *, ptr,
{
signed_descriptor_t *sd = (i==0) ?
((signed_descriptor_t*)ptr): &((routerinfo_t*)ptr)->cache_info;
sd->saved_location = SAVED_IN_CACHE;
- sd->saved_offset = offset;
- if (routerlist->mmap_descriptors)
- sd->signed_descriptor_body = NULL;
+ if (routerlist->mmap_descriptors) {
+ tor_free(sd->signed_descriptor_body); // sets it to null
+ }
offset += sd->signed_descriptor_len;
});
}