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) { auto doQuery = [&](const StorePath & path) {
checkInterrupt(); checkInterrupt();
auto state(state_.lock());
bool exists = false;
std::exception_ptr newExc{};
try { try {
auto info = queryPathInfo(path); queryPathInfo(path);
state->valid.insert(path); exists = true;
} catch (InvalidPath &) { } catch (InvalidPath &) {
} catch (...) { } 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); assert(state->left);
if (!--state->left) if (!--state->left)
wakeup.notify_one(); wakeup.notify_one();
}
}; };
for (auto & path : paths) for (auto & path : paths)