aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-05-12 11:19:52 -0400
committerNick Mathewson <nickm@torproject.org>2011-05-12 11:19:52 -0400
commitbdff7e3299d78cd2f7aa4a31e5f57c1aeef5ffa1 (patch)
tree8524d0f9a976f9dfccbaba8e48359ddc178c3e33
parentb47f574c1e27b8665e9e2658409645a3831e7aa4 (diff)
downloadtor-bdff7e3299d78cd2f7aa4a31e5f57c1aeef5ffa1.tar
tor-bdff7e3299d78cd2f7aa4a31e5f57c1aeef5ffa1.tar.gz
Unmap microdesc cache before replacing it.
If we do a replace-then-munmap, windows will never actually rewrite the microdesc cache. Found by wanoskarnet; bugfix on 0.2.2.6-alpha.
-rw-r--r--changes/md_cache_replace6
-rw-r--r--src/or/microdesc.c5
2 files changed, 9 insertions, 2 deletions
diff --git a/changes/md_cache_replace b/changes/md_cache_replace
new file mode 100644
index 000000000..88e029c00
--- /dev/null
+++ b/changes/md_cache_replace
@@ -0,0 +1,6 @@
+ o Minor bugfixes
+ - Avoid a bug that would keep us from replacing a microdescriptor
+ cache on Windows. (We would try to replace the file while still
+ holding it open. That's fine on Unix, but Windows doesn't let us
+ do that.) Bugfix on 0.2.2.6-alpha; bug found by wanoskarnet.
+
diff --git a/src/or/microdesc.c b/src/or/microdesc.c
index 5740c40d5..1554aca91 100644
--- a/src/or/microdesc.c
+++ b/src/or/microdesc.c
@@ -399,10 +399,11 @@ microdesc_cache_rebuild(microdesc_cache_t *cache, int force)
smartlist_add(wrote, md);
}
- finish_writing_to_file(open_file); /*XXX Check me.*/
-
if (cache->cache_content)
tor_munmap_file(cache->cache_content);
+
+ finish_writing_to_file(open_file); /*XXX Check me.*/
+
cache->cache_content = tor_mmap_file(cache->cache_fname);
if (!cache->cache_content && smartlist_len(wrote)) {