mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-20 19:44:52 +00:00
lt sync 2438
This commit is contained in:
parent
5bc3906863
commit
888b57cd6f
7 changed files with 43 additions and 53 deletions
|
@ -99,11 +99,6 @@ namespace libtorrent
|
|||
// the peer has got at least one interesting piece
|
||||
void peer_is_interesting(peer_connection& c);
|
||||
|
||||
void piece_finished(int index, bool successfully_verified);
|
||||
|
||||
// the peer choked us
|
||||
void choked(peer_connection& c);
|
||||
|
||||
int count_choked() const;
|
||||
|
||||
// the peer unchoked us
|
||||
|
|
|
@ -796,7 +796,6 @@ namespace libtorrent
|
|||
(*m_logger) << time_now_string() << " <== CHOKE\n";
|
||||
#endif
|
||||
m_peer_choked = true;
|
||||
t->get_policy().choked(*this);
|
||||
|
||||
if (peer_info_struct() == 0 || !peer_info_struct()->on_parole)
|
||||
{
|
||||
|
|
|
@ -1775,7 +1775,13 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(block.piece_index < (int)m_piece_map.size());
|
||||
TORRENT_ASSERT(block.block_index < blocks_in_piece(block.piece_index));
|
||||
|
||||
TORRENT_ASSERT(m_piece_map[block.piece_index].downloading);
|
||||
// this might be the case if a piece fails, is restored, and then
|
||||
// completed from a different peer (from which the piece was requested
|
||||
// before it failed the hash check)
|
||||
if (m_piece_map[block.piece_index].downloading == 0)
|
||||
mark_as_downloading(block, peer, piece_picker::none);
|
||||
|
||||
TORRENT_ASSERT(m_piece_map[block.piece_index].downloaing);
|
||||
|
||||
std::vector<downloading_piece>::iterator i
|
||||
= std::find_if(m_downloads.begin(), m_downloads.end(), has_index(block.piece_index));
|
||||
|
|
|
@ -881,35 +881,6 @@ namespace libtorrent
|
|||
return &i->second;
|
||||
}
|
||||
|
||||
// this is called when we are choked by a peer
|
||||
// i.e. a peer lets us know that we will not receive
|
||||
// anything for a while
|
||||
void policy::choked(peer_connection&)
|
||||
{
|
||||
}
|
||||
|
||||
void policy::piece_finished(int index, bool successfully_verified)
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
TORRENT_ASSERT(index >= 0 && index < m_torrent->torrent_file().num_pieces());
|
||||
|
||||
if (successfully_verified)
|
||||
{
|
||||
// have all peers update their interested-flag
|
||||
for (iterator i = m_peers.begin();
|
||||
i != m_peers.end(); ++i)
|
||||
{
|
||||
if (i->second.connection == 0) continue;
|
||||
// if we're not interested, we will not become interested
|
||||
if (!i->second.connection->is_interesting()) continue;
|
||||
if (!i->second.connection->has_piece(index)) continue;
|
||||
|
||||
i->second.connection->update_interest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this is called when we are unchoked by a peer
|
||||
// i.e. a peer lets us know that we will receive
|
||||
// data from now on
|
||||
|
|
|
@ -527,7 +527,8 @@ namespace aux {
|
|||
// if queuing settings were changed, recalculate
|
||||
// queued torrents sooner
|
||||
if ((m_settings.active_downloads != s.active_downloads
|
||||
|| m_settings.active_seeds != s.active_seeds)
|
||||
|| m_settings.active_seeds != s.active_seeds
|
||||
|| m_settings.active_limit != s.active_limit)
|
||||
&& m_auto_manage_time_scaler > 2)
|
||||
m_auto_manage_time_scaler = 2;
|
||||
m_settings = s;
|
||||
|
@ -1323,6 +1324,8 @@ namespace aux {
|
|||
num_downloaders = (std::numeric_limits<int>::max)();
|
||||
if (num_seeds == -1)
|
||||
num_seeds = (std::numeric_limits<int>::max)();
|
||||
if (hard_limit == -1)
|
||||
hard_limit = (std::numeric_limits<int>::max)();
|
||||
|
||||
for (torrent_map::iterator i = m_torrents.begin()
|
||||
, end(m_torrents.end()); i != end; ++i)
|
||||
|
|
|
@ -127,6 +127,10 @@ namespace libtorrent { namespace
|
|||
// The piece failed the hash check. Record
|
||||
// the CRC and origin peer of every block
|
||||
|
||||
// if the torrent is aborted, no point in starting
|
||||
// a bunch of read operations on it
|
||||
if (m_torrent.is_aborted()) return;
|
||||
|
||||
std::vector<void*> downloaders;
|
||||
m_torrent.picker().get_downloaders(downloaders, p);
|
||||
|
||||
|
|
|
@ -1254,9 +1254,35 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(valid_metadata());
|
||||
// if we just became a seed, picker is now invalid, since it
|
||||
// is deallocated by the torrent once it starts seeding
|
||||
|
||||
// since this piece just passed, we might have
|
||||
// become uninterested in some peers where this
|
||||
// was the last piece we were interested in
|
||||
for (peer_iterator i = m_connections.begin()
|
||||
, end(m_connections.end()); i != end; ++i)
|
||||
{
|
||||
peer_connection* p = *i;
|
||||
// if we're not interested already, no need to check
|
||||
if (!p->is_interesting()) continue;
|
||||
// if the peer doesn't have the piece we just got, it
|
||||
// wouldn't affect our interest
|
||||
if (!p->has_piece(index)) continue;
|
||||
p->update_interest();
|
||||
}
|
||||
|
||||
if (!was_finished&& is_finished())
|
||||
{
|
||||
TORRENT_ASSERT(passed_hash_check == 0);
|
||||
// torrent finished
|
||||
// i.e. all the pieces we're interested in have
|
||||
// been downloaded. Release the files (they will open
|
||||
// in read only mode if needed)
|
||||
finished();
|
||||
}
|
||||
}
|
||||
else if (passed_hash_check == -2)
|
||||
{
|
||||
// piece_failed() will restore the piece
|
||||
piece_failed(index);
|
||||
}
|
||||
else
|
||||
|
@ -1264,21 +1290,6 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(passed_hash_check == -1);
|
||||
m_picker->restore_piece(index);
|
||||
}
|
||||
|
||||
m_policy.piece_finished(index, passed_hash_check == 0);
|
||||
|
||||
if (!was_finished
|
||||
&& (is_seed()
|
||||
|| m_picker->num_filtered() + num_have()
|
||||
== torrent_file().num_pieces()))
|
||||
{
|
||||
TORRENT_ASSERT(passed_hash_check == 0);
|
||||
// torrent finished
|
||||
// i.e. all the pieces we're interested in have
|
||||
// been downloaded. Release the files (they will open
|
||||
// in read only mode if needed)
|
||||
finished();
|
||||
}
|
||||
}
|
||||
|
||||
void torrent::piece_failed(int index)
|
||||
|
@ -3271,7 +3282,8 @@ namespace libtorrent
|
|||
piece_manager& torrent::filesystem()
|
||||
{
|
||||
TORRENT_ASSERT(m_owning_storage.get());
|
||||
return *m_owning_storage;
|
||||
TORRENT_ASSERT(m_storage);
|
||||
return *m_storage;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue