diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc index 8ed65d4f5..9e93cdaa9 100644 --- a/src/libstore/gc.cc +++ b/src/libstore/gc.cc @@ -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("Can’t 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("Can’t 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> UncheckedRoots; diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh index 833e3f1bd..81b3b5137 100644 --- a/src/libstore/local-store.hh +++ b/src/libstore/local-store.hh @@ -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();