diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-03-11 14:50:41 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-03-11 14:51:18 -0400 |
commit | 6905c1f60d2d0e658481df70fdcaa73251becacc (patch) | |
tree | 495b7abdf7e103aa66da592504893174fac098a1 /src | |
parent | d54ccbe9fd5c9ca6ff53ad7d0efc4d0e837062ab (diff) | |
download | tor-6905c1f60d2d0e658481df70fdcaa73251becacc.tar tor-6905c1f60d2d0e658481df70fdcaa73251becacc.tar.gz |
Check more error codes when writing microdescriptors.
Possible partial fix, or diagnosis tool, for bug 8031.
Diffstat (limited to 'src')
-rw-r--r-- | src/or/microdesc.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/or/microdesc.c b/src/or/microdesc.c index 0a9724fda..7d3f631a3 100644 --- a/src/or/microdesc.c +++ b/src/or/microdesc.c @@ -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)) { |