diff options
author | jade <lix@jade.fyi> | 2024-06-20 05:55:08 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@localhost> | 2024-06-20 05:55:08 +0000 |
commit | 6c29a2a6fc1043f2a0c17a6304a1624070ded2ed (patch) | |
tree | 8eb912e2a1f237555613fe7ed104ff8f56a2f623 /src | |
parent | fb7d3154115cb5cf211c5ddbc124e17ee519bb64 (diff) | |
parent | 66a9fbb7ffa781f46e246de08700739fa775650c (diff) |
Merge "libstore: fix queryValidPaths concurrency" into main
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/store-api.cc | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index e954acff3..244ecf256 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -803,17 +803,31 @@ StorePathSet Store::queryValidPaths(const StorePathSet & paths, SubstituteFlag m auto doQuery = [&](const StorePath & path) { checkInterrupt(); - auto state(state_.lock()); + + bool exists = false; + std::exception_ptr newExc{}; + try { - auto info = queryPathInfo(path); - state->valid.insert(path); + queryPathInfo(path); + exists = true; } catch (InvalidPath &) { } catch (...) { - state->exc = std::current_exception(); + newExc = std::current_exception(); + } + + { + auto state(state_.lock()); + + if (exists) { + state->valid.insert(path); + } + if (newExc != nullptr) { + state->exc = newExc; + } + assert(state->left); + if (!--state->left) + wakeup.notify_one(); } - assert(state->left); - if (!--state->left) - wakeup.notify_one(); }; for (auto & path : paths) |