Skip to content

Commit

Permalink
Merge pull request #11424 from kjeremy/lix-1462
Browse files Browse the repository at this point in the history
Pull fut.get() out of the lock
  • Loading branch information
edolstra authored Sep 4, 2024
2 parents 357cec9 + 8152c5c commit 668d63d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/libstore/store-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -822,14 +822,25 @@ StorePathSet Store::queryValidPaths(const StorePathSet & paths, SubstituteFlag m
auto doQuery = [&](const StorePath & path) {
checkInterrupt();
queryPathInfo(path, {[path, &state_, &wakeup](std::future<ref<const ValidPathInfo>> fut) {
auto state(state_.lock());
bool exists = false;
std::exception_ptr newExc{};

try {
auto info = fut.get();
state->valid.insert(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)
state->exc = newExc;

assert(state->left);
if (!--state->left)
wakeup.notify_one();
Expand Down

0 comments on commit 668d63d

Please sign in to comment.