diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc index 6be5080c9..19ccef2bb 100644 --- a/src/libstore/filetransfer.cc +++ b/src/libstore/filetransfer.cc @@ -515,13 +515,12 @@ struct curlFileTransfer : public FileTransfer // loop with kj. until then curl will handle its timeouts internally. int64_t timeoutMs = INT64_MAX; - while (!quit) { - checkInterrupt(); - + while (true) { { auto cancel = [&] { return std::move(state_.lock()->cancel); }(); for (auto & [item, promise] : cancel) { curl_multi_remove_handle(curlm.get(), item->req.get()); + items.erase(item->req.get()); promise.set_value(); } } @@ -545,6 +544,12 @@ struct curlFileTransfer : public FileTransfer } } + // only exit when all transfers are done (which will happen through the + // progress callback issuing an abort in the case of user interruption) + if (items.empty() && quit) { + break; + } + /* Wait for activity, including wakeup events. */ mc = curl_multi_poll(curlm.get(), nullptr, 0, std::min(timeoutMs, INT_MAX), nullptr); if (mc != CURLM_OK)