From 253ed1cc05ff75703e36504244f210bc8af8e560 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Wed, 22 Oct 2025 19:05:25 +0200 Subject: [PATCH] libstore: abort all transfers when shutting down curl thread waiting for them to finish leaves us prone to deadlocking, e.g. if some active transfers is blocked and hasn't been destroyed before our thread was asked to exit. aborting transfers is the safer option here; even if we cause use after frees we'll at least have a crash, not hang forever. Change-Id: I333dcced810e8a85e2ded1f377962a0176798098 --- lix/libstore/filetransfer.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lix/libstore/filetransfer.cc b/lix/libstore/filetransfer.cc index 584a19a95..07f202644 100644 --- a/lix/libstore/filetransfer.cc +++ b/lix/libstore/filetransfer.cc @@ -654,9 +654,10 @@ 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) { + // exit immediately and abort all running transfers. waiting for transfers to finish + // before exiting this loop may hang the shutdown procedure forever, e.g. if blocked + // transfers would be destroyed (thus aborted) after the curl thread for any reason. + if (quit) { break; }