about summary refs log tree commit diff
path: root/src/libutil/util.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2011-12-22T15·55+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2011-12-22T15·55+0000
commitb33da599c5c1b06a32a3eeac58f95481d10f821d (patch)
treeb3f33d5a7a86becd1485ae0de06d88b6eed7729c /src/libutil/util.cc
parent58d974336c733416756e5b396928602ea8ed8df2 (diff)
* In the garbage collector, delete invalid paths before deleting
  unreachable paths.  This matters when using --max-freed etc.:
  unreachable paths could become reachable again, so it's nicer to
  keep them if there is "real" garbage to be deleted.  Also, don't use
  readDirectory() but read the Nix store and delete invalid paths in
  parallel.  This reduces GC latency on very large Nix stores.

Diffstat (limited to 'src/libutil/util.cc')
-rw-r--r--src/libutil/util.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 9adaac40d5..0352754f59 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -701,7 +701,7 @@ AutoCloseDir::AutoCloseDir(DIR * dir)
 
 AutoCloseDir::~AutoCloseDir()
 {
-    if (dir) closedir(dir);
+    close();
 }
 
 
@@ -717,6 +717,14 @@ AutoCloseDir::operator DIR *()
 }
 
 
+void AutoCloseDir::close()
+{
+    if (dir) {
+	closedir(dir);
+	dir = 0;
+    }
+}
+
 
 //////////////////////////////////////////////////////////////////////