diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc index c29132d9c..8a566f441 100644 --- a/src/libstore/filetransfer.cc +++ b/src/libstore/filetransfer.cc @@ -506,13 +506,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(); } } @@ -536,6 +535,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)