From 8948bb5e010b55bf1f4b196b2ed21e77ee2f1af5 Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 27 Jul 2026 21:52:44 -0400 Subject: [PATCH] defer moving stream to destination's thread --- libi2pd_client/AddressBook.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libi2pd_client/AddressBook.cpp b/libi2pd_client/AddressBook.cpp index 5215751b..4ff93a7e 100644 --- a/libi2pd_client/AddressBook.cpp +++ b/libi2pd_client/AddressBook.cpp @@ -980,6 +980,11 @@ namespace client LogPrint (eLogError, "Addressbook: LeaseSet for address ", url.host, " not found"); return false; } + i2p::util::Defer ([stream]() + { + // destroy stream in destination's thread on exit + boost::asio::post (i2p::client::context.GetSharedLocalDestination ()->GetService (), [s = std::move (stream)](){}); + }); if (m_Etag.empty() && m_LastModified.empty()) { m_Book.GetEtag (m_Ident, m_Etag, m_LastModified); @@ -1030,8 +1035,6 @@ namespace client LogPrint(eLogError, "Addressbook: Receive HTTP response exception: ", ex.what ()); return false; } - // destroy stream in destination's thread - boost::asio::post (i2p::client::context.GetSharedLocalDestination ()->GetService (), [s = std::move (stream)](){}); // check result if (res.result () != boost::beast::http::status::ok) {