[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Likely fix for bug 309: when we calculate offsets after reb...
Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv2732/src/or
Modified Files:
routerlist.c
Log Message:
Likely fix for bug 309: when we calculate offsets after rebuilding the descriptor cache, do not reset the offset pointer half-way through.
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.524
retrieving revision 1.525
diff -u -p -d -r1.524 -r1.525
--- routerlist.c 22 Jun 2006 07:25:15 -0000 1.524
+++ routerlist.c 27 Jun 2006 15:52:51 -0000 1.525
@@ -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;
});
}