From 698fa0fc67118bea2ea7720455ebbdee705c8c1a Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 3 May 2011 16:22:31 -0400 Subject: [PATCH 1/2] Add missing code to set cache->journal_len when reading microdesc journal This could be one reason that authorities' journals would grow without bound; related to bug 2230. Bugfix on 0.2.2.6-alpha. Fix by "cypherpunks". --- changes/bug2230_part1 | 7 +++++++ src/or/microdesc.c | 1 + 2 files changed, 8 insertions(+) create mode 100644 changes/bug2230_part1 diff --git a/changes/bug2230_part1 b/changes/bug2230_part1 new file mode 100644 index 0000000000..79f725410d --- /dev/null +++ b/changes/bug2230_part1 @@ -0,0 +1,7 @@ + o Minor bugfixes + - When loading the microdesc journal, remember its current size. + In 0.2.2, this helps prevent the microdesc journal from growing + without limit on authorities (who are the only ones to use it in + 0.2.2). Fixes a part of bug 2230; bugfix on 0.2.2.6-alpha. + Fix posted by "cypherpunks." + diff --git a/src/or/microdesc.c b/src/or/microdesc.c index 2c4b3435f7..356627700d 100644 --- a/src/or/microdesc.c +++ b/src/or/microdesc.c @@ -261,6 +261,7 @@ microdesc_cache_reload(microdesc_cache_t *cache) journal_content = read_file_to_str(cache->journal_fname, RFTS_IGNORE_MISSING, &st); if (journal_content) { + cache->journal_len = (size_t) st.st_size; added = microdescs_add_to_cache(cache, journal_content, journal_content+st.st_size, SAVED_IN_JOURNAL, 0); From 970715dd8f52a79bbaddfcfa5af1f11608ddacf9 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 3 May 2011 16:29:39 -0400 Subject: [PATCH 2/2] Fix a check for when to rebuild the microdesc cache. (Backport from 0.2.3. --- changes/bug2230_part2 | 5 +++++ src/or/microdesc.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changes/bug2230_part2 diff --git a/changes/bug2230_part2 b/changes/bug2230_part2 new file mode 100644 index 0000000000..2664ecc1a0 --- /dev/null +++ b/changes/bug2230_part2 @@ -0,0 +1,5 @@ + o Minor bugfixes + - The microdesc journal is supposed to get rebuilt only if it is + at least _half_ the length of the store, not _twice_ the length + of the store. Bugfix on 0.2.2.6-alpha; fixes part of bug 2230. + diff --git a/src/or/microdesc.c b/src/or/microdesc.c index 356627700d..0ceb134a61 100644 --- a/src/or/microdesc.c +++ b/src/or/microdesc.c @@ -208,7 +208,7 @@ microdescs_add_list_to_cache(microdesc_cache_t *cache, size_t old_content_len = cache->cache_content ? cache->cache_content->size : 0; if (cache->journal_len > 16384 + old_content_len && - cache->journal_len > old_content_len * 2) { + cache->journal_len > old_content_len / 2) { microdesc_cache_rebuild(cache); } }