Merge "libstore: fix queryValidPaths concurrency" into main

This commit is contained in:
jade 2024-06-20 05:55:08 +00:00 committed by Gerrit Code Review
commit 6c29a2a6fc

View file

@ -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)