]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Check more error codes when writing microdescriptors.
authorNick Mathewson <nickm@torproject.org>
Mon, 11 Mar 2013 18:50:41 +0000 (14:50 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 11 Mar 2013 18:51:18 +0000 (14:51 -0400)
Possible partial fix, or diagnosis tool, for bug 8031.

changes/bug8031 [new file with mode: 0644]
src/or/microdesc.c

diff --git a/changes/bug8031 b/changes/bug8031
new file mode 100644 (file)
index 0000000..17329ec
--- /dev/null
@@ -0,0 +1,7 @@
+  o Minor bugfixes:
+    - Use direct writes rather than stdio when building microdescriptor
+      caches, in an attempt to mitigate bug 8031, or at least make it
+      less common.
+    - Warn more aggressively when flushing microdescriptors to a
+      microdescriptor cache fails, in an attempt to mitegate bug 8031,
+      or at least make it more diagnosable.
index 0a9724fda930ca38a3c33dca3acfd73662a48bd9..7d3f631a3280b694c8a91de6d7f041d6cf68b056 100644 (file)
@@ -251,8 +251,14 @@ microdescs_add_list_to_cache(microdesc_cache_t *cache,
     cache->total_len_seen += md->bodylen;
   } SMARTLIST_FOREACH_END(md);
 
-  if (fd >= 0)
-    finish_writing_to_file(open_file); /*XXX Check me.*/
+  if (fd >= 0) {
+    if (finish_writing_to_file(open_file) < 0) {
+      log_warn(LD_DIR, "Error appending to microdescriptor file: %s",
+               strerror(errno));
+      smartlist_clear(added);
+      return added;
+    }
+  }
 
   {
     networkstatus_t *ns = networkstatus_get_latest_consensus();
@@ -459,11 +465,15 @@ microdesc_cache_rebuild(microdesc_cache_t *cache, int force)
     smartlist_add(wrote, md);
   }
 
+  if (finish_writing_to_file(open_file) < 0) {
+    log_warn(LD_DIR, "Error rebuilding microdescriptor cache: %s",
+             strerror(errno));
+    return -1;
+  }
+
   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)) {