diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-08-29 13:03:36 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-08-29 13:03:36 -0400 |
commit | da159c45e2447c729601a1393e93de908ba27c16 (patch) | |
tree | 8c3e518856fff0645bd858d7e227b418c94915a4 /src/or/conscache.c | |
parent | 5e97b34daa27f6e0ca1c233e31d00ab8620284f0 (diff) | |
download | tor-da159c45e2447c729601a1393e93de908ba27c16.tar.gz tor-da159c45e2447c729601a1393e93de908ba27c16.zip |
On windows, allow many entries in conscache directories
Since we can't be sure that we can unlink enough files on windows
here, let's let the number of permitted entries grow huge if it
really must.
We do this by letting the storagedir hold lots of entries, but still
trying to keep the number of entries under the configured limit. We
also have to tell consdiffmgr not to freak out if it can't actually
remove enough entries.
Part of a fix for bug 22752
Diffstat (limited to 'src/or/conscache.c')
-rw-r--r-- | src/or/conscache.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/or/conscache.c b/src/or/conscache.c index c30d1998c6..350a05b0f2 100644 --- a/src/or/conscache.c +++ b/src/or/conscache.c @@ -54,6 +54,11 @@ struct consensus_cache_t { storage_dir_t *dir; /** List of all the entries in the directory. */ smartlist_t *entries; + + /** The maximum number of entries that we'd like to allow in this cache. + * This is the same as the storagedir limit when MUST_UNMAP_TO_UNLINK is + * not defined. */ + unsigned max_entries; }; static void consensus_cache_clear(consensus_cache_t *cache); @@ -71,6 +76,10 @@ consensus_cache_open(const char *subdir, int max_entries) { consensus_cache_t *cache = tor_malloc_zero(sizeof(consensus_cache_t)); char *directory = get_datadir_fname(subdir); + cache->max_entries = max_entries; +#ifdef MUST_UNMAP_TO_UNLINK + max_entries = 1000000; +#endif cache->dir = storage_dir_new(directory, max_entries); tor_free(directory); if (!cache->dir) { @@ -82,6 +91,19 @@ consensus_cache_open(const char *subdir, int max_entries) return cache; } +/** Return true if it's okay to put more entries in this cache than + * its official file limit. */ +int +consensus_cache_may_overallocate(consensus_cache_t *cache) +{ + (void) cache; +#ifdef MUST_UNMAP_TO_UNLINK + return 1; +#else + return 0; +#endif +} + /** * Tell the sandbox (if any) configured by <b>cfg</b> to allow the * operations that <b>cache</b> will need. @@ -90,6 +112,11 @@ int consensus_cache_register_with_sandbox(consensus_cache_t *cache, struct sandbox_cfg_elem **cfg) { +#ifdef MUST_UNMAP_TO_UNLINK + /* Our sandbox doesn't support huge limits like we use here. + */ + tor_assert_nonfatal_unreached(); +#endif return storage_dir_register_with_sandbox(cache->dir, cfg); } |