From 8647b933c43eed7d7dd65a7b248e1e679a0f4cf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Sat, 8 Mar 2025 10:31:25 -0500 Subject: [PATCH] DataTransfer: run shutdown on ioPool Change-Id: I3e8ccd71a1b5cb906b66837813bd132cc81f697a --- src/data_transfer.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/data_transfer.cpp b/src/data_transfer.cpp index a30dacaba..09682a29d 100644 --- a/src/data_transfer.cpp +++ b/src/data_transfer.cpp @@ -76,12 +76,16 @@ OutgoingFile::OutgoingFile(const std::shared_ptr<dhtnet::ChannelSocket>& channel { std::filesystem::path fpath(info_.path); if (!std::filesystem::is_regular_file(fpath)) { - channel_->shutdown(); + dht::ThreadPool::io().run([channel = std::move(channel_)] { + channel->shutdown(); + }); return; } stream_.open(fpath, std::ios::binary | std::ios::in); if (!stream_ || !stream_.is_open()) { - channel_->shutdown(); + dht::ThreadPool::io().run([channel = std::move(channel_)] { + channel->shutdown(); + }); return; } } @@ -90,8 +94,11 @@ OutgoingFile::~OutgoingFile() { if (stream_ && stream_.is_open()) stream_.close(); - if (channel_) - channel_->shutdown(); + if (channel_) { + dht::ThreadPool::io().run([channel = std::move(channel_)] { + channel->shutdown(); + }); + } } void @@ -447,7 +454,9 @@ TransferManager::onIncomingFileTransfer(const std::string& fileId, } auto itW = pimpl_->waitingIds_.find(fileId); if (itW == pimpl_->waitingIds_.end()) { - channel->shutdown(); + dht::ThreadPool().io().run([channel] { + channel->shutdown(); + }); return; } -- GitLab