summaryrefslogtreecommitdiff
path: root/src/or/conscache.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-04-26 10:42:11 -0400
committerNick Mathewson <nickm@torproject.org>2017-04-27 21:40:13 -0400
commit7a0964279fafc9912ed5cc4b82abfb81328f5150 (patch)
tree2ee8670626a483744736b6128b81daaea2753af3 /src/or/conscache.c
parent920475f293a8a69dd846cd06249b4b699857a3d4 (diff)
downloadtor-7a0964279fafc9912ed5cc4b82abfb81328f5150.tar.gz
tor-7a0964279fafc9912ed5cc4b82abfb81328f5150.zip
Functionality to ensure there is space to add files to cache.
Diffstat (limited to 'src/or/conscache.c')
-rw-r--r--src/or/conscache.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/or/conscache.c b/src/or/conscache.c
index 7760d1315b..5ffa129bbe 100644
--- a/src/or/conscache.c
+++ b/src/or/conscache.c
@@ -400,6 +400,19 @@ consensus_cache_unmap_lazy(consensus_cache_t *cache, time_t cutoff)
}
/**
+ * Return the number of currently unused filenames available in this cache.
+ */
+int
+consensus_cache_get_n_filenames_available(consensus_cache_t *cache)
+{
+ tor_assert(cache);
+ int max = storage_dir_get_max_files(cache->dir);
+ int used = smartlist_len(storage_dir_list(cache->dir));
+ tor_assert_nonfatal(max >= used);
+ return max - used;
+}
+
+/**
* Delete every element of <b>cache</b> has been marked with
* consensus_cache_entry_mark_for_removal. If <b>force</b> is false,
* retain those entries which are not in use except by the cache.