Merge pull request #145 from arvidn/super-seeding-fix2

fix super seeding assert (forward port from RC_1_0)
This commit is contained in:
Arvid Norberg 2015-09-10 20:13:14 -04:00
commit 4fd56fd220
3 changed files with 34 additions and 16 deletions

@ -1 +1 @@
Subproject commit 5924e3b17eb0bdd710027187ccd2952422b25a39
Subproject commit a1985197c925d7668922b9066c378c232ebc06c4

View File

@ -292,7 +292,8 @@ namespace libtorrent
{
INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
TORRENT_ASSERT(m_sent_handshake);
TORRENT_ASSERT(m_sent_bitfield);
#ifndef TORRENT_DISABLE_LOGGING
peer_log(peer_log_alert::outgoing_message, "DHT_PORT", "%d", listen_port);
@ -345,7 +346,8 @@ namespace libtorrent
peer_log(peer_log_alert::outgoing_message, "REJECT_PIECE"
, "piece: %d | s: %d | l: %d", r.piece, r.start, r.length);
#endif
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
TORRENT_ASSERT(m_sent_handshake);
TORRENT_ASSERT(m_sent_bitfield);
TORRENT_ASSERT(associated_torrent().lock()->valid_metadata());
char msg[] = {0,0,0,13, msg_reject_request,0,0,0,0, 0,0,0,0, 0,0,0,0};
@ -364,7 +366,8 @@ namespace libtorrent
if (!m_supports_fast) return;
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
TORRENT_ASSERT(m_sent_handshake);
TORRENT_ASSERT(m_sent_bitfield);
TORRENT_ASSERT(associated_torrent().lock()->valid_metadata());
char msg[] = {0,0,0,5, msg_allowed_fast, 0, 0, 0, 0};
@ -381,7 +384,8 @@ namespace libtorrent
if (!m_supports_fast) return;
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
TORRENT_ASSERT(m_sent_handshake);
TORRENT_ASSERT(m_sent_bitfield);
boost::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t);
@ -2069,7 +2073,8 @@ namespace libtorrent
{
INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
TORRENT_ASSERT(m_sent_handshake);
TORRENT_ASSERT(m_sent_bitfield);
TORRENT_ASSERT(associated_torrent().lock()->valid_metadata());
char msg[17] = {0,0,0,13, msg_cancel};
@ -2089,7 +2094,8 @@ namespace libtorrent
{
INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
TORRENT_ASSERT(m_sent_handshake);
TORRENT_ASSERT(m_sent_bitfield);
TORRENT_ASSERT(associated_torrent().lock()->valid_metadata());
char msg[17] = {0,0,0,13, msg_request};
@ -2380,7 +2386,8 @@ namespace libtorrent
{
INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
TORRENT_ASSERT(m_sent_handshake);
TORRENT_ASSERT(m_sent_bitfield);
if (is_choked()) return;
char msg[] = {0,0,0,1,msg_choke};
@ -2393,7 +2400,8 @@ namespace libtorrent
{
INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
TORRENT_ASSERT(m_sent_handshake);
TORRENT_ASSERT(m_sent_bitfield);
char msg[] = {0,0,0,1,msg_unchoke};
send_buffer(msg, sizeof(msg));
@ -2413,7 +2421,8 @@ namespace libtorrent
{
INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
TORRENT_ASSERT(m_sent_handshake);
TORRENT_ASSERT(m_sent_bitfield);
char msg[] = {0,0,0,1,msg_interested};
send_buffer(msg, sizeof(msg));
@ -2425,7 +2434,8 @@ namespace libtorrent
{
INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
TORRENT_ASSERT(m_sent_handshake);
TORRENT_ASSERT(m_sent_bitfield);
char msg[] = {0,0,0,1,msg_not_interested};
send_buffer(msg, sizeof(msg));
@ -2439,7 +2449,8 @@ namespace libtorrent
TORRENT_ASSERT(associated_torrent().lock()->valid_metadata());
TORRENT_ASSERT(index >= 0);
TORRENT_ASSERT(index < associated_torrent().lock()->torrent_file().num_pieces());
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
TORRENT_ASSERT(m_sent_handshake);
TORRENT_ASSERT(m_sent_bitfield);
char msg[] = {0,0,0,5,msg_have,0,0,0,0};
char* ptr = msg + 5;
@ -2459,7 +2470,8 @@ namespace libtorrent
if (in_handshake()) return;
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
TORRENT_ASSERT(m_sent_handshake);
TORRENT_ASSERT(m_sent_bitfield);
if (!m_supports_extensions || m_dont_have_id == 0) return;
@ -2496,7 +2508,8 @@ namespace libtorrent
{
INVARIANT_CHECK;
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
TORRENT_ASSERT(m_sent_handshake);
TORRENT_ASSERT(m_sent_bitfield);
boost::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t);

View File

@ -4522,6 +4522,10 @@ namespace libtorrent
void peer_connection::superseed_piece(int replace_piece, int new_piece)
{
TORRENT_ASSERT(is_single_thread());
if (is_connecting()) return;
if (in_handshake()) return;
if (new_piece == -1)
{
if (m_superseed_piece[0] == -1) return;
@ -4689,6 +4693,7 @@ namespace libtorrent
}
if (t->super_seeding()
&& t->ready_for_connections()
&& !m_peer_interested
&& m_became_uninterested + seconds(10) < now)
{