From ab03c745a8038da47abf08d3921b471d3ac44c2f Mon Sep 17 00:00:00 2001 From: orignal Date: Sun, 9 Aug 2026 11:27:27 -0400 Subject: [PATCH] release requested piece if connection got closed --- libi2pd_client/Torrents.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libi2pd_client/Torrents.cpp b/libi2pd_client/Torrents.cpp index a73299d6..645e4896 100644 --- a/libi2pd_client/Torrents.cpp +++ b/libi2pd_client/Torrents.cpp @@ -524,6 +524,12 @@ namespace torrents void PeerConnection::Terminate () { if (Kill()) return; + if (m_Torrent && m_LastRequestedPieceIndex >= 0) // pending requests by us + { + auto& piece = m_Torrent->GetPiece (m_LastRequestedPieceIndex); + if (piece.IsRequested ()) + piece.Reset (); // piece can be requested by other connections + } if (m_Stream) { m_Stream->Close ();