From 993cc99f0d27d7c45271a1deffa18a904ee616a5 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Tue, 11 Feb 2025 01:06:15 +0100 Subject: [PATCH] libstore: asyncify drvOutputReferences Change-Id: I68bc77eadb1ddf3d0e257e773f8b9b29289ea2bc --- lix/libstore/build/derivation-goal.cc | 8 +++++--- lix/libstore/misc.cc | 18 ++++++++++++------ lix/libstore/store-api.hh | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lix/libstore/build/derivation-goal.cc b/lix/libstore/build/derivation-goal.cc index bd5bd9461..2fcfb36d1 100644 --- a/lix/libstore/build/derivation-goal.cc +++ b/lix/libstore/build/derivation-goal.cc @@ -1159,7 +1159,9 @@ try { auto & drvStore = worker.evalStore.isValidPath(drvPath) ? worker.evalStore : worker.store; - newRealisation.dependentRealisations = drvOutputReferences(worker.store, *drv, realisation.outPath, &drvStore); + newRealisation.dependentRealisations = TRY_AWAIT( + drvOutputReferences(worker.store, *drv, realisation.outPath, &drvStore) + ); } signRealisation(newRealisation); worker.store.registerDrvOutput(newRealisation); @@ -1180,9 +1182,9 @@ try { if (status == BuildResult::AlreadyValid) status = BuildResult::ResolvesToAlreadyValid; - return {done(status, std::move(builtOutputs))}; + co_return done(status, std::move(builtOutputs)); } catch (...) { - return {result::current_exception()}; + co_return result::current_exception(); } HookReply DerivationGoal::tryBuildHook() diff --git a/lix/libstore/misc.cc b/lix/libstore/misc.cc index 368d3d106..627bba0e6 100644 --- a/lix/libstore/misc.cc +++ b/lix/libstore/misc.cc @@ -352,10 +352,10 @@ StorePaths Store::topoSortPaths(const StorePathSet & paths) }}); } -std::map drvOutputReferences( +static kj::Promise>> drvOutputReferences( const std::set & inputRealisations, const StorePathSet & pathReferences) -{ +try { std::map res; for (const auto & input : inputRealisations) { @@ -364,15 +364,17 @@ std::map drvOutputReferences( } } - return res; + co_return res; +} catch (...) { + co_return result::current_exception(); } -std::map drvOutputReferences( +kj::Promise>> drvOutputReferences( Store & store, const Derivation & drv, const StorePath & outputPath, Store * evalStore_) -{ +try { auto & evalStore = evalStore_ ? *evalStore_ : store; std::set inputRealisations; @@ -415,7 +417,11 @@ std::map drvOutputReferences( auto info = store.queryPathInfo(outputPath); - return drvOutputReferences(Realisation::closure(store, inputRealisations), info->references); + co_return TRY_AWAIT( + drvOutputReferences(Realisation::closure(store, inputRealisations), info->references) + ); +} catch (...) { + co_return result::current_exception(); } OutputPathMap resolveDerivedPath(Store & store, const DerivedPath::Built & bfd, Store * evalStore_) diff --git a/lix/libstore/store-api.hh b/lix/libstore/store-api.hh index 14b7bb98c..363735ae7 100644 --- a/lix/libstore/store-api.hh +++ b/lix/libstore/store-api.hh @@ -1074,7 +1074,7 @@ std::pair splitUriAndParams(const std::string const ContentAddress * getDerivationCA(const BasicDerivation & drv); -std::map drvOutputReferences( +kj::Promise>> drvOutputReferences( Store & store, const Derivation & drv, const StorePath & outputPath,