1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-13 14:02:42 +01:00

Properly get the temp roots when using the external gc daemon

This commit is contained in:
Théophane Hufschmitt 2022-04-11 10:20:36 +02:00
parent 2575dd4f19
commit 80bb58b186
2 changed files with 9 additions and 10 deletions

View file

@ -280,8 +280,10 @@ void LocalStore::findRoots(const Path & path, unsigned char type, Roots & roots)
}
void LocalStore::findRootsNoTemp(Roots & roots, bool censor)
void LocalStore::findRootsNoTempNoExternalDaemon(Roots & roots, bool censor)
{
debug("Cant connect to the tracing daemon socket, fallback to the internal trace");
/* Process direct roots in {gcroots,profiles}. */
findRoots(stateDir + "/" + gcRootsDir, DT_UNKNOWN, roots);
findRoots(stateDir + "/profiles", DT_UNKNOWN, roots);
@ -293,9 +295,8 @@ void LocalStore::findRootsNoTemp(Roots & roots, bool censor)
}
Roots LocalStore::findRootsNoExternalDaemon(bool censor)
Roots LocalStore::findRoots(bool censor)
{
debug("Cant connect to the tracing daemon socket, fallback to the internal trace");
Roots roots;
findRootsNoTemp(roots, censor);
@ -305,7 +306,7 @@ Roots LocalStore::findRootsNoExternalDaemon(bool censor)
return roots;
}
Roots LocalStore::findRoots(bool censor)
void LocalStore::findRootsNoTemp(Roots & roots, bool censor)
{
auto fd = AutoCloseFD(socket(PF_UNIX, SOCK_STREAM
@ -328,9 +329,7 @@ Roots LocalStore::findRoots(bool censor)
strcpy(addr.sun_path, socketPath.c_str());
if (::connect(fd.get(), (struct sockaddr *) &addr, sizeof(addr)) == -1)
return findRootsNoExternalDaemon(censor);
Roots roots;
return findRootsNoTempNoExternalDaemon(roots, censor);
try {
while (true) {
@ -353,7 +352,7 @@ Roots LocalStore::findRoots(bool censor)
} catch (EndOfFile &) {
}
return roots;
findRuntimeRoots(roots, censor);
}
typedef std::unordered_map<Path, std::unordered_set<std::string>> UncheckedRoots;

View file

@ -250,12 +250,12 @@ private:
PathSet queryValidPathsOld();
ValidPathInfo queryPathInfoOld(const Path & path);
Roots findRootsNoExternalDaemon(bool censor);
void findRoots(const Path & path, unsigned char type, Roots & roots);
void findRootsNoTemp(Roots & roots, bool censor);
void findRootsNoTempNoExternalDaemon(Roots & roots, bool censor);
void findRuntimeRoots(Roots & roots, bool censor);
Path createTempDirInStore();