From 78fea899e0ea79447f64bfd2804cae84bba3b2f8 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Thu, 9 Feb 2023 13:56:50 +0100 Subject: [PATCH] Check interupts even when download stalled --- src/libstore/filetransfer.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc index 756bd4423..2818043e8 100644 --- a/src/libstore/filetransfer.cc +++ b/src/libstore/filetransfer.cc @@ -828,16 +828,15 @@ void FileTransfer::download(FileTransferRequest && request, Sink & sink) { auto state(_state->lock()); - while (state->data.empty()) { - - if (state->quit) { - if (state->exc) std::rethrow_exception(state->exc); - return; - } - - state.wait(state->avail); + if (state->quit) { + if (state->exc) std::rethrow_exception(state->exc); + return; } + state.wait(state->avail); + + if (state->data.empty()) continue; + chunk = std::move(state->data); state->request.notify_one();