[tor-commits] [tor/master] If we do underflow the know usage of a storage, recalculate it
nickm at torproject.org
nickm at torproject.org
Tue May 30 12:51:29 UTC 2017
commit 79725289e1f0ed86e2afb37748c83571118d465b
Author: teor <teor2345 at gmail.com>
Date: Sun May 28 22:28:56 2017 +1000
If we do underflow the know usage of a storage, recalculate it
Fixes bug #22424 on 0.3.1.1-alpha.
---
src/common/storagedir.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/common/storagedir.c b/src/common/storagedir.c
index cc2230d..befcfe6 100644
--- a/src/common/storagedir.c
+++ b/src/common/storagedir.c
@@ -418,6 +418,16 @@ storage_dir_reduce_usage(storage_dir_t *d, uint64_t removed_file_size)
* actual usage (rather than relaying on cached usage), and the call to
* this function. */
d->usage -= removed_file_size;
+ } else {
+ /* If we underflowed the cached directory size, re-check the sizes of all
+ * the files in the directory. This makes storage_dir_shrink() quadratic,
+ * but only if a process is continually changing file sizes in the
+ * storage directory (in which case, we have bigger issues).
+ *
+ * We can't just reset usage_known, because storage_dir_shrink() relies
+ * on knowing the usage. */
+ storage_dir_rescan(d);
+ (void)storage_dir_get_usage(d);
}
}
}
More information about the tor-commits
mailing list