diff options
author | Patrick Jackson <patrick@jackson.dev> | 2023-03-30 18:05:53 -0700 |
---|---|---|
committer | Patrick Jackson <patrick@jackson.dev> | 2023-03-30 18:06:27 -0700 |
commit | 804180ad52cc855a77bc7901c033e1f441b65cdc (patch) | |
tree | 70d0a7b10f357f8cf4dcc8a4d347945cf2448831 /src/libstore/store-api.cc | |
parent | 309753ebb5f4d1cae64554fac8d4e49c2c28884c (diff) |
Only lock once
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r-- | src/libstore/store-api.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 6233768df..3cf4c801b 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -1103,7 +1103,7 @@ std::map<StorePath, StorePath> copyPaths( }; // total is accessed by each copy, which are each handled in separate threads - Sync<uint64_t> total = 0; + Sync<uint64_t> _total = 0; for (auto & missingPath : sortedMissing) { auto info = srcStore.queryPathInfo(missingPath); @@ -1126,8 +1126,9 @@ std::map<StorePath, StorePath> copyPaths( PushActivity pact(act.id); LambdaSink progressSink([&](std::string_view data) { - *total.lock() += data.size(); - act.progress(*total.lock(), info->narSize); + auto total(_total.lock()); + *total += data.size(); + act.progress(*total, info->narSize); }); TeeSink tee { sink, progressSink }; |