From d3784ff1df5f18db00db1d9e2e7d27f8b756507a Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 27 Jun 2006 15:52:51 +0000 Subject: 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 --- src/or/routerlist.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 0098580543..548103a0cf 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; }); } -- cgit v1.2.3-54-g00ecf