diff --git a/include/libtorrent/peer_class.hpp b/include/libtorrent/peer_class.hpp index a7bc61cc1..a1ca3322a 100644 --- a/include/libtorrent/peer_class.hpp +++ b/include/libtorrent/peer_class.hpp @@ -47,7 +47,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - typedef boost::uint8_t peer_class_t; + typedef boost::uint16_t peer_class_t; struct peer_class_info { diff --git a/src/peer_class.cpp b/src/peer_class.cpp index ce8c810b7..34af2c84e 100644 --- a/src/peer_class.cpp +++ b/src/peer_class.cpp @@ -87,7 +87,7 @@ namespace libtorrent } else { - TORRENT_ASSERT(m_peer_classes.size() < 0x100); + TORRENT_ASSERT(m_peer_classes.size() < 0x10000); ret = peer_class_t(m_peer_classes.size()); m_peer_classes.push_back(boost::shared_ptr()); } diff --git a/src/torrent.cpp b/src/torrent.cpp index f8bbdcb03..e2b4470b6 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -876,6 +876,7 @@ namespace libtorrent // this means that the invariant check that this is called from the // network thread cannot be maintained + TORRENT_ASSERT(m_peer_class == 0); TORRENT_ASSERT(m_abort); TORRENT_ASSERT(m_connections.empty()); if (!m_connections.empty()) @@ -4719,6 +4720,12 @@ namespace libtorrent update_gauge(); stop_announcing(); + if (m_peer_class > 0) + { + m_ses.peer_classes().decref(m_peer_class); + m_peer_class = 0; + } + error_code ec; m_inactivity_timer.cancel(ec);