fix for torrent announcing bug introduced when supporting fine grained control over sources torrents are announced to

This commit is contained in:
Arvid Norberg 2010-03-31 02:40:00 +00:00
parent 3ae927abb4
commit 4c4c7f832a
3 changed files with 30 additions and 8 deletions

View File

@ -252,6 +252,7 @@ namespace libtorrent
void flush_cache(); void flush_cache();
void pause(); void pause();
void resume(); void resume();
void set_allow_peers(bool b);
void set_announce_to_dht(bool b) { m_announce_to_dht = b; } void set_announce_to_dht(bool b) { m_announce_to_dht = b; }
void set_announce_to_trackers(bool b) { m_announce_to_trackers = b; } void set_announce_to_trackers(bool b) { m_announce_to_trackers = b; }
void set_announce_to_lsd(bool b) { m_announce_to_lsd = b; } void set_announce_to_lsd(bool b) { m_announce_to_lsd = b; }

View File

@ -2377,11 +2377,11 @@ namespace aux {
--tracker_limit; --tracker_limit;
t->set_announce_to_dht(dht_limit >= 0); t->set_announce_to_dht(dht_limit >= 0);
t->set_announce_to_trackers(tracker_limit >= 0); t->set_announce_to_trackers(tracker_limit >= 0);
if (t->is_paused()) t->resume(); t->set_allow_peers(true);
} }
else else
{ {
if (!t->is_paused()) t->pause(); t->set_allow_peers(false);
} }
} }
} }

View File

@ -5335,6 +5335,30 @@ namespace libtorrent
stop_announcing(); stop_announcing();
} }
void torrent::set_allow_peers(bool b)
{
if (m_allow_peers == b) return;
bool checking_files = should_check_files();
m_allow_peers = b;
if (!b)
{
m_announce_to_dht = false;
m_announce_to_trackers = false;
m_announce_to_lsd = false;
do_pause();
}
else
{
do_resume();
}
if (!checking_files && should_check_files())
queue_torrent_check();
}
void torrent::resume() void torrent::resume()
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
@ -5345,12 +5369,9 @@ namespace libtorrent
&& m_announce_to_lsd) return; && m_announce_to_lsd) return;
bool checking_files = should_check_files(); bool checking_files = should_check_files();
m_allow_peers = true; m_allow_peers = true;
if (!m_auto_managed)
{
m_announce_to_dht = true; m_announce_to_dht = true;
m_announce_to_trackers = true; m_announce_to_trackers = true;
m_announce_to_lsd = true; m_announce_to_lsd = true;
}
do_resume(); do_resume();
if (!checking_files && should_check_files()) if (!checking_files && should_check_files())
queue_torrent_check(); queue_torrent_check();