diff --git a/simulation/libsimulator b/simulation/libsimulator index 5924e3b17..a1985197c 160000 --- a/simulation/libsimulator +++ b/simulation/libsimulator @@ -1 +1 @@ -Subproject commit 5924e3b17eb0bdd710027187ccd2952422b25a39 +Subproject commit a1985197c925d7668922b9066c378c232ebc06c4 diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index e60f61661..be7ceac77 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -292,8 +292,9 @@ 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); #endif @@ -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 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 t = associated_torrent().lock(); TORRENT_ASSERT(t); diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index a98b03af5..c605ab7d3 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -4522,12 +4522,16 @@ 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; m_superseed_piece[0] = -1; m_superseed_piece[1] = -1; - + #ifndef TORRENT_DISABLE_LOGGING peer_log(peer_log_alert::info, "SUPER_SEEDING", "ending"); #endif @@ -4689,6 +4693,7 @@ namespace libtorrent } if (t->super_seeding() + && t->ready_for_connections() && !m_peer_interested && m_became_uninterested + seconds(10) < now) {