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

Fallback to the old mechanism if the gc socket isn’t found

This commit is contained in:
Théophane Hufschmitt 2022-04-11 10:20:36 +02:00
parent 26c802d18c
commit 4d9ca6d09e
2 changed files with 16 additions and 2 deletions

View file

@ -293,9 +293,19 @@ void LocalStore::findRootsNoTemp(Roots & roots, bool censor)
} }
Roots LocalStore::findRoots(bool censor) Roots LocalStore::findRootsNoExternalDaemon(bool censor)
{ {
Roots roots; Roots roots;
findRootsNoTemp(roots, censor);
FDs fds;
findTempRoots(fds, roots, censor);
return roots;
}
Roots LocalStore::findRoots(bool censor)
{
auto fd = AutoCloseFD(socket(PF_UNIX, SOCK_STREAM auto fd = AutoCloseFD(socket(PF_UNIX, SOCK_STREAM
#ifdef SOCK_CLOEXEC #ifdef SOCK_CLOEXEC
@ -317,7 +327,9 @@ Roots LocalStore::findRoots(bool censor)
strcpy(addr.sun_path, socketPath.c_str()); strcpy(addr.sun_path, socketPath.c_str());
if (::connect(fd.get(), (struct sockaddr *) &addr, sizeof(addr)) == -1) if (::connect(fd.get(), (struct sockaddr *) &addr, sizeof(addr)) == -1)
throw SysError("cannot connect to the gc daemon at '%1%'", socketPath); return findRootsNoExternalDaemon(censor);
Roots roots;
try { try {
while (true) { while (true) {

View file

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