diff --git a/lix/libstore/gc.cc b/lix/libstore/gc.cc index 3c0eea944..5590f446c 100644 --- a/lix/libstore/gc.cc +++ b/lix/libstore/gc.cc @@ -359,8 +359,8 @@ try { co_return result::current_exception(); } -void LocalStore::findPlatformRoots(UncheckedRoots & unchecked) -{ +kj::Promise> LocalStore::findPlatformRoots(UncheckedRoots & unchecked) +try { // N.B. This is (read: undertested!) fallback code only used for // non-Darwin, non-Linux platforms. Both major platforms have // platform-specific code in lix/libstore/platform/ @@ -376,13 +376,17 @@ void LocalStore::findPlatformRoots(UncheckedRoots & unchecked) } catch (ExecError & e) { /* lsof not installed, lsof failed */ } + + co_return result::success(); +} catch (...) { + co_return result::current_exception(); } kj::Promise> LocalStore::findRuntimeRoots(Roots & roots, bool censor) try { UncheckedRoots unchecked; - findPlatformRoots(unchecked); + TRY_AWAIT(findPlatformRoots(unchecked)); for (auto & [target, links] : unchecked) { if (!isInStore(target)) continue; diff --git a/lix/libstore/local-store.hh b/lix/libstore/local-store.hh index c16bb9e21..36fa9570d 100644 --- a/lix/libstore/local-store.hh +++ b/lix/libstore/local-store.hh @@ -393,7 +393,7 @@ private: * Find possible garbage collector roots in a platform-specific manner, * e.g. by looking in `/proc` or using `lsof` */ - virtual void findPlatformRoots(UncheckedRoots & unchecked); + virtual kj::Promise> findPlatformRoots(UncheckedRoots & unchecked); kj::Promise> findRuntimeRoots(Roots & roots, bool censor); diff --git a/lix/libstore/platform/darwin.cc b/lix/libstore/platform/darwin.cc index ac540e286..054132694 100644 --- a/lix/libstore/platform/darwin.cc +++ b/lix/libstore/platform/darwin.cc @@ -1,4 +1,5 @@ #include "lix/libstore/gc-store.hh" +#include "lix/libutil/result.hh" #include "lix/libutil/signals.hh" #include "lix/libstore/platform/darwin.hh" #include "lix/libutil/regex.hh" @@ -14,8 +15,8 @@ namespace nix { -void DarwinLocalStore::findPlatformRoots(UncheckedRoots & unchecked) -{ +kj::Promise> DarwinLocalStore::findPlatformRoots(UncheckedRoots & unchecked) +try { auto storePathRegex = regex::storePathRegex(config().storeDir); std::vector pids; @@ -240,6 +241,10 @@ void DarwinLocalStore::findPlatformRoots(UncheckedRoots & unchecked) throw; } } + + co_return result::success(); +} catch (...) { + co_return result::current_exception(); } void DarwinLocalDerivationGoal::execBuilder(std::string builder, Strings args, Strings envStrs) diff --git a/lix/libstore/platform/darwin.hh b/lix/libstore/platform/darwin.hh index db44fe632..7a2682c37 100644 --- a/lix/libstore/platform/darwin.hh +++ b/lix/libstore/platform/darwin.hh @@ -25,7 +25,7 @@ public: private: - void findPlatformRoots(UncheckedRoots & unchecked) override; + kj::Promise> findPlatformRoots(UncheckedRoots & unchecked) override; }; /** diff --git a/lix/libstore/platform/linux.cc b/lix/libstore/platform/linux.cc index caf5ea29b..5b29558c7 100644 --- a/lix/libstore/platform/linux.cc +++ b/lix/libstore/platform/linux.cc @@ -5,6 +5,7 @@ #include "lix/libutil/finally.hh" #include "lix/libstore/gc-store.hh" #include "lix/libutil/processes.hh" +#include "lix/libutil/result.hh" #include "lix/libutil/signals.hh" #include "lix/libstore/platform/linux.hh" #include "lix/libutil/regex.hh" @@ -79,8 +80,8 @@ LinuxLocalDerivationGoal::~LinuxLocalDerivationGoal() } } -void LinuxLocalStore::findPlatformRoots(UncheckedRoots & unchecked) -{ +kj::Promise> LinuxLocalStore::findPlatformRoots(UncheckedRoots & unchecked) +try { auto procDir = AutoCloseDir{opendir("/proc")}; if (procDir) { struct dirent * ent; @@ -154,6 +155,10 @@ void LinuxLocalStore::findPlatformRoots(UncheckedRoots & unchecked) readFileRoots("/proc/sys/kernel/modprobe", unchecked); readFileRoots("/proc/sys/kernel/fbsplash", unchecked); readFileRoots("/proc/sys/kernel/poweroff_cmd", unchecked); + + co_return result::success(); +} catch (...) { + co_return result::current_exception(); } #if HAVE_SECCOMP diff --git a/lix/libstore/platform/linux.hh b/lix/libstore/platform/linux.hh index 79c222356..e9e19f237 100644 --- a/lix/libstore/platform/linux.hh +++ b/lix/libstore/platform/linux.hh @@ -23,7 +23,7 @@ public: private: - void findPlatformRoots(UncheckedRoots & unchecked) override; + kj::Promise> findPlatformRoots(UncheckedRoots & unchecked) override; }; /**