mirror of
https://github.com/NixOS/nix.git
synced 2025-11-18 00:12:43 +01:00
* Fix and simplify the garbage collector (it's still not concurrent,
though). In particular it's now much easier to register a GC root. Just place a symlink to whatever store path it is that you want to keep in /nix/var/nix/gcroots.
This commit is contained in:
parent
59682e6188
commit
c505702265
10 changed files with 124 additions and 109 deletions
|
|
@ -573,7 +573,7 @@ static void opQuery(Globals & globals,
|
|||
Strings columns;
|
||||
|
||||
if (printStatus) {
|
||||
Substitutes subs = querySubstitutes(i->drvPath);
|
||||
Substitutes subs = querySubstitutes(noTxn, i->drvPath);
|
||||
columns.push_back(
|
||||
(string) (installedPaths.find(i->outPath)
|
||||
!= installedPaths.end() ? "I" : "-")
|
||||
|
|
|
|||
|
|
@ -62,11 +62,11 @@ Generations findGenerations(Path profile, int & curGen)
|
|||
|
||||
|
||||
static void makeNames(const Path & profile, unsigned int num,
|
||||
Path & generation, Path & gcrootDrv)
|
||||
Path & outLink, Path & drvLink)
|
||||
{
|
||||
Path prefix = (format("%1%-%2%") % profile % num).str();
|
||||
generation = prefix + "-link";
|
||||
gcrootDrv = prefix + "-drv.gcroot";
|
||||
outLink = prefix + "-output";
|
||||
drvLink = prefix + "-drv";
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -79,20 +79,21 @@ Path createGeneration(Path profile, Path outPath, Path drvPath)
|
|||
unsigned int num = gens.size() > 0 ? gens.front().number : 0;
|
||||
|
||||
/* Create the new generation. */
|
||||
Path generation, gcrootDrv;
|
||||
Path outLink, drvLink;
|
||||
|
||||
while (1) {
|
||||
makeNames(profile, num, generation, gcrootDrv);
|
||||
if (symlink(outPath.c_str(), generation.c_str()) == 0) break;
|
||||
makeNames(profile, num, outLink, drvLink);
|
||||
if (symlink(outPath.c_str(), outLink.c_str()) == 0) break;
|
||||
if (errno != EEXIST)
|
||||
throw SysError(format("creating symlink `%1%'") % generation);
|
||||
throw SysError(format("creating symlink `%1%'") % outLink);
|
||||
/* Somebody beat us to it, retry with a higher number. */
|
||||
num++;
|
||||
}
|
||||
|
||||
writeStringToFile(gcrootDrv, drvPath);
|
||||
if (symlink(drvPath.c_str(), drvLink.c_str()) != 0)
|
||||
throw SysError(format("creating symlink `%1%'") % drvLink);
|
||||
|
||||
return generation;
|
||||
return outLink;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue