about summary refs log tree commit diff
path: root/src/libstore/remote-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-05-30T02·59-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-05-30T02·59-0400
commit4bc4da331aae13be8a39e768524a854597addd8a (patch)
tree5fccb805c1d27bd82c935f87a97f1a6cd3b29176 /src/libstore/remote-store.cc
parent2c26985835cf82ed5d2979c3a400f72f6aeba32f (diff)
Reserve some disk space for the garbage collector
We can't open a SQLite database if the disk is full.  Since this
prevents the garbage collector from running when it's most needed, we
reserve some dummy space that we can free just before doing a garbage
collection.  This actually revives some old code from the Berkeley DB
days.

Fixes #27.
Diffstat (limited to 'src/libstore/remote-store.cc')
-rw-r--r--src/libstore/remote-store.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index 0fd759b07b4b..cbcf860543e2 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -43,7 +43,7 @@ RemoteStore::RemoteStore()
 }
 
 
-void RemoteStore::openConnection()
+void RemoteStore::openConnection(bool reserveSpace)
 {
     if (initialised) return;
     initialised = true;
@@ -75,6 +75,8 @@ void RemoteStore::openConnection()
         if (GET_PROTOCOL_MAJOR(daemonVersion) != GET_PROTOCOL_MAJOR(PROTOCOL_VERSION))
             throw Error("Nix daemon protocol version not supported");
         writeInt(PROTOCOL_VERSION, to);
+        if (GET_PROTOCOL_MINOR(daemonVersion) >= 11)
+            writeInt(reserveSpace, to);
         processStderr();
     }
     catch (Error & e) {
@@ -462,7 +464,7 @@ Roots RemoteStore::findRoots()
 
 void RemoteStore::collectGarbage(const GCOptions & options, GCResults & results)
 {
-    openConnection();
+    openConnection(false);
     
     writeInt(wopCollectGarbage, to);
     writeInt(options.action, to);