summaryrefslogtreecommitdiff
path: root/src/or/conscache.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-04-26 10:13:25 -0400
committerNick Mathewson <nickm@torproject.org>2017-04-27 21:40:13 -0400
commit920475f293a8a69dd846cd06249b4b699857a3d4 (patch)
tree724e3cab92a42745f36af074a839e33183557a47 /src/or/conscache.c
parent466e9140888f0a6a504dc642a0426bd2352f0490 (diff)
downloadtor-920475f293a8a69dd846cd06249b4b699857a3d4.tar.gz
tor-920475f293a8a69dd846cd06249b4b699857a3d4.zip
New force-delete option on consensus_cache_delete_pending()
If we're out of file space in the storage directory, we'll need to get rid of old files fast.
Diffstat (limited to 'src/or/conscache.c')
-rw-r--r--src/or/conscache.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/or/conscache.c b/src/or/conscache.c
index 2544f56313..7760d1315b 100644
--- a/src/or/conscache.c
+++ b/src/or/conscache.c
@@ -95,7 +95,7 @@ consensus_cache_register_with_sandbox(consensus_cache_t *cache,
static void
consensus_cache_clear(consensus_cache_t *cache)
{
- consensus_cache_delete_pending(cache);
+ consensus_cache_delete_pending(cache, 0);
SMARTLIST_FOREACH_BEGIN(cache->entries, consensus_cache_entry_t *, ent) {
ent->in_cache = NULL;
@@ -401,17 +401,19 @@ consensus_cache_unmap_lazy(consensus_cache_t *cache, time_t cutoff)
/**
* Delete every element of <b>cache</b> has been marked with
- * consensus_cache_entry_mark_for_removal, and which is not in use except by
- * the cache.
+ * consensus_cache_entry_mark_for_removal. If <b>force</b> is false,
+ * retain those entries which are not in use except by the cache.
*/
void
-consensus_cache_delete_pending(consensus_cache_t *cache)
+consensus_cache_delete_pending(consensus_cache_t *cache, int force)
{
SMARTLIST_FOREACH_BEGIN(cache->entries, consensus_cache_entry_t *, ent) {
tor_assert_nonfatal(ent->in_cache == cache);
- if (ent->refcnt > 1 || BUG(ent->in_cache == NULL)) {
- /* Somebody is using this entry right now */
- continue;
+ if (! force) {
+ if (ent->refcnt > 1 || BUG(ent->in_cache == NULL)) {
+ /* Somebody is using this entry right now */
+ continue;
+ }
}
if (ent->can_remove == 0) {
/* Don't want to delete this. */