1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-16 23:42:43 +01:00

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.
This commit is contained in:
Eelco Dolstra 2012-05-29 22:59:12 -04:00
parent 2c26985835
commit 4bc4da331a
9 changed files with 35 additions and 11 deletions

View file

@ -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);