fix to avoid connecting web seeds when not a seed but finished

This commit is contained in:
Arvid Norberg 2007-04-11 22:27:58 +00:00
parent 3bc8d093c2
commit 87b1cdc341
3 changed files with 13 additions and 2 deletions

View File

@ -208,6 +208,7 @@ namespace libtorrent
// the number of filtered pieces we already have
int num_have_filtered() const { return m_num_have_filtered; }
#ifndef NDEBUG
// used in debug mode
void check_invariant(const torrent* t = 0) const;

View File

@ -411,12 +411,22 @@ namespace libtorrent
void received_redundant_data(int num_bytes)
{ assert(num_bytes > 0); m_total_redundant_bytes += num_bytes; }
// this is true if we have all the pieces
bool is_seed() const
{
return valid_metadata()
&& m_num_pieces == m_torrent_file.num_pieces();
}
// this is true if we have all the pieces that we want
bool is_finished() const
{
if (is_seed()) return true;
return valid_metadata() && m_torrent_file.num_pieces()
- m_num_pieces - m_picker->num_filtered()
+ m_picker->num_have_filtered() == 0;
}
boost::filesystem::path save_path() const;
alert_manager& alerts() const;
piece_picker& picker()

View File

@ -2519,8 +2519,8 @@ namespace libtorrent
// ---- WEB SEEDS ----
// if we're a seed, we don't need to connect to any web-seed
if (!is_seed() && !m_web_seeds.empty())
// if we have everything we want we don't need to connect to any web-seed
if (!is_finished() && !m_web_seeds.empty())
{
// keep trying web-seeds if there are any
// first find out which web seeds we are connected to