diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/filetransfer.cc | 21 | ||||
-rw-r--r-- | src/nix/repl.cc | 2 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc index 2cf35ec83..758862e60 100644 --- a/src/libstore/filetransfer.cc +++ b/src/libstore/filetransfer.cc @@ -716,15 +716,32 @@ struct curlFileTransfer : public FileTransfer } }; +ref<curlFileTransfer> makeCurlFileTransfer() +{ + return make_ref<curlFileTransfer>(); +} + ref<FileTransfer> getFileTransfer() { - static ref<FileTransfer> fileTransfer = makeFileTransfer(); + static ref<curlFileTransfer> fileTransfer = makeCurlFileTransfer(); + + // this has to be done in its own scope to make sure that the lock is released + // before creating a new fileTransfer instance. + auto needsRecreation = [&]() -> bool { + auto state = fileTransfer->state_.lock(); + return state->quit; + }; + + if (needsRecreation()) { + fileTransfer = makeCurlFileTransfer(); + } + return fileTransfer; } ref<FileTransfer> makeFileTransfer() { - return make_ref<curlFileTransfer>(); + return makeCurlFileTransfer(); } std::future<FileTransferResult> FileTransfer::enqueueFileTransfer(const FileTransferRequest & request) diff --git a/src/nix/repl.cc b/src/nix/repl.cc index c1233ab46..4b2efa293 100644 --- a/src/nix/repl.cc +++ b/src/nix/repl.cc @@ -396,6 +396,8 @@ bool NixRepl::processLine(string line) { if (line == "") return true; + _isInterrupted = false; + string command, arg; if (line[0] == ':') { |