From 88c733ef2dade1b515b80dbcd59150e53689c106 Mon Sep 17 00:00:00 2001 From: arvidn Date: Tue, 27 Nov 2018 01:45:25 +0100 Subject: [PATCH] attempt to fix an assert for a newly connected peer that disconnects just as we receive the metadata. disconnecting peers don't have their bitfield properly initialized, so we can't use it --- src/peer_connection.cpp | 2 +- src/torrent.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index e48c036eb..7a8140713 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -1867,7 +1867,7 @@ namespace libtorrent { if (!t->valid_metadata() && index >= m_have_piece.end_index()) { // TODO: 3 replace this magic number with something that makes sense - if (index < piece_index_t(131072)) + if (index < piece_index_t(524288)) { // if we don't have metadata // and we might not have received a bitfield diff --git a/src/torrent.cpp b/src/torrent.cpp index 80aca9f51..3cf340188 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -1259,6 +1259,7 @@ bool is_downloading_state(int const st) for (auto const p : m_connections) { TORRENT_INCREMENT(m_iterating_connections); + if (p->is_disconnecting()) continue; peer_has(p->get_bitfield(), p); } }