summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-10-24 15:45:45 +0000
committerNick Mathewson <nickm@torproject.org>2007-10-24 15:45:45 +0000
commit5b65103bb9ba78caf3712d85d10f12bb1801ccd4 (patch)
tree912f446914ba9aba29773a8ebfd58a3c3ca461f8
parent99d72f7295eca20d721482928712fc6d34983a5d (diff)
downloadtor-5b65103bb9ba78caf3712d85d10f12bb1801ccd4.tar.gz
tor-5b65103bb9ba78caf3712d85d10f12bb1801ccd4.zip
r16101@catbus: nickm | 2007-10-24 11:44:40 -0400
Detect mmap failures from empty descriptor files, and only warn if the file was not supposed to be empty. Fixes bug 533 svn:r12154
-rw-r--r--ChangeLog3
-rw-r--r--src/or/routerlist.c28
2 files changed, 28 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 68757c42c3..7549cc01cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -119,6 +119,9 @@ Changes in version 0.2.0.9-alpha - 2007-10-24
ports are reachable" if we haven't been able to build any circuits
yet. Bug found by spending four hours without a v3 consensus. Bugfix
on 0.1.2.x.
+ - Detect the reason for failing to mmap a descriptor file we just
+ wrote, and give a more useful log message. Fixes bug 533. Bugfix
+ on 0.1.2.x.
o Code simplifications and refactoring:
- Remove support for the old bw_accounting file: we've been storing
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index c25a25adbb..fe8efae477 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -459,13 +459,19 @@ router_rebuild_store(int force, desc_store_t *store)
off_t offset = 0;
smartlist_t *signed_descriptors = NULL;
int nocache=0;
+ size_t total_expected_len = 0;
+ int had_any;
if (!force && !router_should_rebuild_store(store))
return 0;
if (!routerlist)
return 0;
- //routerlist_assert_ok(routerlist);
+ if (store->type == EXTRAINFO_STORE)
+ had_any = !eimap_isempty(routerlist->extra_info_map);
+ else
+ had_any = (smartlist_len(routerlist->routers)+
+ smartlist_len(routerlist->old_routers))>0;
/* Don't save deadweight. */
routerlist_remove_old_routers();
@@ -516,6 +522,7 @@ router_rebuild_store(int force, desc_store_t *store)
c = tor_malloc(sizeof(sized_chunk_t));
c->bytes = body;
c->len = sd->signed_descriptor_len + sd->annotations_len;
+ total_expected_len += c->len;
smartlist_add(chunk_list, c);
});
@@ -535,10 +542,23 @@ router_rebuild_store(int force, desc_store_t *store)
goto done;
}
+ errno = 0;
store->mmap = tor_mmap_file(fname);
if (! store->mmap) {
- log_warn(LD_FS, "Unable to mmap new descriptor file at '%s'.",fname);
- //tor_assert(0);
+ if (errno == ERANGE) {
+ /* empty store.*/
+ if (total_expected_len) {
+ log_warn(LD_FS, "We wrote some bytes to a new descriptor file at '%s',"
+ " but when we went to mmap it, it was empty!", fname);
+ } else if (had_any) {
+ log_notice(LD_FS, "We just removed every descriptor in '%s'. This is "
+ "okay if we're just starting up after a long time. "
+ "Otherwise, it's a bug.",
+ fname);
+ }
+ } else {
+ log_warn(LD_FS, "Unable to mmap new descriptor file at '%s'.",fname);
+ }
}
log_info(LD_DIR, "Reconstructing pointers into cache");
@@ -694,6 +714,8 @@ router_get_trusted_dir_servers(void)
* (that is, a trusted dirserver, or one running 0.0.9rc5-cvs or later).
* Don't pick an authority if any non-authority is viable.
* Other args are as in router_pick_directory_server_impl().
+ *
+ * DOCDOC arguments are pretty screwed up.
*/
routerstatus_t *
router_pick_directory_server(int requireother,