fix peer class leak in torrent and widen peer_class_t to allow for mo… (#707)

fix peer class leak in torrent and widen peer_class_t to allow for more instances
This commit is contained in:
Arvid Norberg 2016-05-07 14:52:10 -04:00
parent 29943ab0f0
commit 8922990fc7
3 changed files with 9 additions and 2 deletions

View File

@ -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
{

View File

@ -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<peer_class>());
}

View File

@ -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);