lt sync 3240 + patch
This commit is contained in:
parent
1394c52a80
commit
8df39bbcef
|
@ -265,7 +265,6 @@ namespace libtorrent
|
|||
// and the write cache. This is not supposed to
|
||||
// exceed m_cache_size
|
||||
cache_status m_cache_stats;
|
||||
int m_num_cached_blocks;
|
||||
|
||||
// in (16kB) blocks
|
||||
int m_cache_size;
|
||||
|
|
|
@ -663,6 +663,9 @@ namespace libtorrent
|
|||
|
||||
void update_peer_interest(bool was_finished);
|
||||
|
||||
void queue_torrent_check();
|
||||
void dequeue_torrent_check();
|
||||
|
||||
policy m_policy;
|
||||
|
||||
// total time we've been available on this torrent
|
||||
|
@ -975,6 +978,10 @@ namespace libtorrent
|
|||
// connect to peers
|
||||
bool m_files_checked:1;
|
||||
|
||||
// this is true if the torrent has been added to
|
||||
// checking queue in the session
|
||||
bool m_queued_for_checking:1;
|
||||
|
||||
// this is true while tracker announcing is enabled
|
||||
// is is disabled while paused and checking files
|
||||
bool m_announcing:1;
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace libtorrent
|
|||
struct TORRENT_EXPORT torrent_status
|
||||
{
|
||||
torrent_status()
|
||||
: state(queued_for_checking)
|
||||
: state(checking_resume_data)
|
||||
, paused(false)
|
||||
, progress(0.f)
|
||||
, total_download(0)
|
||||
|
@ -130,7 +130,8 @@ namespace libtorrent
|
|||
downloading,
|
||||
finished,
|
||||
seeding,
|
||||
allocating
|
||||
allocating,
|
||||
checking_resume_data
|
||||
};
|
||||
|
||||
state_t state;
|
||||
|
|
|
@ -170,7 +170,7 @@ namespace libtorrent
|
|||
, m_net_interface(net_interface.address(), 0)
|
||||
, m_save_path(complete(save_path))
|
||||
, m_storage_mode(storage_mode)
|
||||
, m_state(torrent_status::queued_for_checking)
|
||||
, m_state(torrent_status::checking_resume_data)
|
||||
, m_settings(ses.settings())
|
||||
, m_storage_constructor(sc)
|
||||
, m_progress(0.f)
|
||||
|
@ -200,6 +200,7 @@ namespace libtorrent
|
|||
, m_connections_initialized(true)
|
||||
, m_has_incoming(false)
|
||||
, m_files_checked(false)
|
||||
, m_queued_for_checking(false)
|
||||
, m_announcing(false)
|
||||
, m_start_sent(false)
|
||||
, m_complete_sent(false)
|
||||
|
@ -251,7 +252,7 @@ namespace libtorrent
|
|||
, m_net_interface(net_interface.address(), 0)
|
||||
, m_save_path(complete(save_path))
|
||||
, m_storage_mode(storage_mode)
|
||||
, m_state(torrent_status::queued_for_checking)
|
||||
, m_state(torrent_status::checking_resume_data)
|
||||
, m_settings(ses.settings())
|
||||
, m_storage_constructor(sc)
|
||||
, m_progress(0.f)
|
||||
|
@ -281,6 +282,7 @@ namespace libtorrent
|
|||
, m_connections_initialized(false)
|
||||
, m_has_incoming(false)
|
||||
, m_files_checked(false)
|
||||
, m_queued_for_checking(false)
|
||||
, m_announcing(false)
|
||||
, m_start_sent(false)
|
||||
, m_complete_sent(false)
|
||||
|
@ -469,7 +471,7 @@ namespace libtorrent
|
|||
std::copy(url_seeds.begin(), url_seeds.end(), std::inserter(m_web_seeds
|
||||
, m_web_seeds.begin()));
|
||||
|
||||
set_state(torrent_status::queued_for_checking);
|
||||
set_state(torrent_status::checking_resume_data);
|
||||
|
||||
if (m_resume_entry.type() == lazy_entry::dict_t)
|
||||
{
|
||||
|
@ -656,17 +658,35 @@ namespace libtorrent
|
|||
{
|
||||
// either the fastresume data was rejected or there are
|
||||
// some files
|
||||
m_ses.check_torrent(shared_from_this());
|
||||
set_state(torrent_status::queued_for_checking);
|
||||
if (should_check_files())
|
||||
queue_torrent_check();
|
||||
}
|
||||
|
||||
std::vector<char>().swap(m_resume_data);
|
||||
lazy_entry().swap(m_resume_entry);
|
||||
}
|
||||
|
||||
void torrent::queue_torrent_check()
|
||||
{
|
||||
if (m_queued_for_checking) return;
|
||||
m_queued_for_checking = true;
|
||||
m_ses.check_torrent(shared_from_this());
|
||||
}
|
||||
|
||||
void torrent::dequeue_torrent_check()
|
||||
{
|
||||
if (!m_queued_for_checking) return;
|
||||
m_queued_for_checking = false;
|
||||
m_ses.done_checking(shared_from_this());
|
||||
}
|
||||
|
||||
void torrent::force_recheck()
|
||||
{
|
||||
if (m_state == torrent_status::checking_files
|
||||
|| m_state == torrent_status::queued_for_checking)
|
||||
// if the torrent is already queued to check its files
|
||||
// don't do anything
|
||||
if (should_check_files()
|
||||
|| m_state == torrent_status::checking_resume_data)
|
||||
return;
|
||||
|
||||
disconnect_all();
|
||||
|
@ -681,7 +701,7 @@ namespace libtorrent
|
|||
, int((m_torrent_file->total_size()+m_block_size-1)/m_block_size));
|
||||
// assume that we don't have anything
|
||||
m_files_checked = false;
|
||||
set_state(torrent_status::queued_for_checking);
|
||||
set_state(torrent_status::checking_resume_data);
|
||||
|
||||
if (m_auto_managed)
|
||||
set_queue_position((std::numeric_limits<int>::max)());
|
||||
|
@ -713,7 +733,9 @@ namespace libtorrent
|
|||
pause();
|
||||
return;
|
||||
}
|
||||
m_ses.check_torrent(shared_from_this());
|
||||
set_state(torrent_status::queued_for_checking);
|
||||
if (should_check_files())
|
||||
queue_torrent_check();
|
||||
}
|
||||
|
||||
void torrent::start_checking()
|
||||
|
@ -764,7 +786,7 @@ namespace libtorrent
|
|||
// we're done, or encounter a failure
|
||||
if (ret == piece_manager::need_full_check) return;
|
||||
|
||||
if (!m_abort) m_ses.done_checking(shared_from_this());
|
||||
dequeue_torrent_check();
|
||||
files_checked();
|
||||
}
|
||||
|
||||
|
@ -1585,6 +1607,8 @@ namespace libtorrent
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (m_abort) return;
|
||||
|
||||
m_abort = true;
|
||||
// if the torrent is paused, it doesn't need
|
||||
// to announce with even=stopped again.
|
||||
|
@ -1611,8 +1635,7 @@ namespace libtorrent
|
|||
m_storage->abort_disk_io();
|
||||
}
|
||||
|
||||
if (m_state == torrent_status::checking_files)
|
||||
m_ses.done_checking(shared_from_this());
|
||||
dequeue_torrent_check();
|
||||
|
||||
m_owning_storage = 0;
|
||||
m_host_resolver.cancel();
|
||||
|
@ -3020,7 +3043,8 @@ namespace libtorrent
|
|||
m_has_incoming = true;
|
||||
|
||||
if ((m_state == torrent_status::queued_for_checking
|
||||
|| m_state == torrent_status::checking_files)
|
||||
|| m_state == torrent_status::checking_files
|
||||
|| m_state == torrent_status::checking_resume_data)
|
||||
&& valid_metadata())
|
||||
{
|
||||
p->disconnect("torrent is not ready to accept peers");
|
||||
|
@ -3089,6 +3113,7 @@ namespace libtorrent
|
|||
return int(m_connections.size()) < m_max_connections
|
||||
&& !is_paused()
|
||||
&& m_state != torrent_status::checking_files
|
||||
&& m_state != torrent_status::checking_resume_data
|
||||
&& (m_state != torrent_status::queued_for_checking
|
||||
|| !valid_metadata())
|
||||
&& m_policy.num_connect_candidates() > 0
|
||||
|
@ -3418,7 +3443,6 @@ namespace libtorrent
|
|||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||
|
||||
TORRENT_ASSERT(m_torrent_file->is_valid());
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (m_abort) return;
|
||||
|
||||
|
@ -3427,6 +3451,8 @@ namespace libtorrent
|
|||
if (m_state != torrent_status::finished)
|
||||
set_state(torrent_status::downloading);
|
||||
|
||||
INVARIANT_CHECK;
|
||||
|
||||
if (m_ses.m_alerts.should_post<torrent_checked_alert>())
|
||||
{
|
||||
m_ses.m_alerts.post_alert(torrent_checked_alert(
|
||||
|
@ -3559,18 +3585,30 @@ namespace libtorrent
|
|||
|
||||
if (is_paused()) TORRENT_ASSERT(num_peers() == 0);
|
||||
|
||||
if (!should_check_files())
|
||||
TORRENT_ASSERT(m_state != torrent_status::checking_files);
|
||||
else
|
||||
TORRENT_ASSERT(m_queued_for_checking);
|
||||
|
||||
if (!m_ses.m_queued_for_checking.empty())
|
||||
{
|
||||
// if there are torrents waiting to be checked
|
||||
// assert that there's a torrent that is being
|
||||
// processed right now
|
||||
int found = 0;
|
||||
int found_active = 0;
|
||||
for (aux::session_impl::torrent_map::iterator i = m_ses.m_torrents.begin()
|
||||
, end(m_ses.m_torrents.end()); i != end; ++i)
|
||||
if (i->second->m_state == torrent_status::checking_files) ++found;
|
||||
if (i->second->m_state == torrent_status::checking_files)
|
||||
{
|
||||
++found;
|
||||
if (i->second->should_check_files()) ++found_active;
|
||||
}
|
||||
// the case of 2 is in the special case where one switches over from
|
||||
// checking to complete
|
||||
TORRENT_ASSERT(found == 1 || found == 2);
|
||||
TORRENT_ASSERT(found_active >= 1);
|
||||
TORRENT_ASSERT(found_active <= 2);
|
||||
TORRENT_ASSERT(found >= 1);
|
||||
}
|
||||
|
||||
TORRENT_ASSERT(m_resume_entry.type() == lazy_entry::dict_t
|
||||
|
@ -3849,7 +3887,7 @@ namespace libtorrent
|
|||
m_ses.m_auto_manage_time_scaler = 2;
|
||||
m_error.clear();
|
||||
if (!checking_files && should_check_files())
|
||||
m_ses.check_torrent(shared_from_this());
|
||||
queue_torrent_check();
|
||||
}
|
||||
|
||||
void torrent::set_error(std::string const& msg)
|
||||
|
@ -3860,7 +3898,7 @@ namespace libtorrent
|
|||
{
|
||||
// stop checking
|
||||
m_storage->abort_disk_io();
|
||||
m_ses.done_checking(shared_from_this());
|
||||
dequeue_torrent_check();
|
||||
set_state(torrent_status::queued_for_checking);
|
||||
}
|
||||
}
|
||||
|
@ -3877,12 +3915,14 @@ namespace libtorrent
|
|||
m_ses.m_auto_manage_time_scaler = 0;
|
||||
|
||||
if (!checking_files && should_check_files())
|
||||
m_ses.check_torrent(shared_from_this());
|
||||
{
|
||||
queue_torrent_check();
|
||||
}
|
||||
else if (checking_files && !should_check_files())
|
||||
{
|
||||
// stop checking
|
||||
m_storage->abort_disk_io();
|
||||
m_ses.done_checking(shared_from_this());
|
||||
dequeue_torrent_check();
|
||||
set_state(torrent_status::queued_for_checking);
|
||||
}
|
||||
}
|
||||
|
@ -3955,7 +3995,8 @@ namespace libtorrent
|
|||
{
|
||||
TORRENT_ASSERT(m_storage);
|
||||
if (m_state == torrent_status::queued_for_checking
|
||||
|| m_state == torrent_status::checking_files)
|
||||
|| m_state == torrent_status::checking_files
|
||||
|| m_state == torrent_status::checking_resume_data)
|
||||
{
|
||||
if (alerts().should_post<save_resume_data_failed_alert>())
|
||||
{
|
||||
|
@ -3983,8 +4024,9 @@ namespace libtorrent
|
|||
{
|
||||
return (m_state == torrent_status::checking_files
|
||||
|| m_state == torrent_status::queued_for_checking)
|
||||
&& (!is_paused() || m_auto_managed)
|
||||
&& m_error.empty();
|
||||
&& (!m_paused || m_auto_managed)
|
||||
&& m_error.empty()
|
||||
&& !m_abort;
|
||||
}
|
||||
|
||||
bool torrent::is_paused() const
|
||||
|
@ -3999,13 +4041,13 @@ namespace libtorrent
|
|||
if (m_paused) return;
|
||||
bool checking_files = should_check_files();
|
||||
m_paused = true;
|
||||
if (m_ses.is_paused()) return;
|
||||
if (!m_ses.is_paused())
|
||||
do_pause();
|
||||
if (checking_files && !should_check_files())
|
||||
{
|
||||
// stop checking
|
||||
m_storage->abort_disk_io();
|
||||
m_ses.done_checking(shared_from_this());
|
||||
dequeue_torrent_check();
|
||||
set_state(torrent_status::queued_for_checking);
|
||||
}
|
||||
}
|
||||
|
@ -4064,7 +4106,7 @@ namespace libtorrent
|
|||
m_paused = false;
|
||||
do_resume();
|
||||
if (!checking_files && should_check_files())
|
||||
m_ses.check_torrent(shared_from_this());
|
||||
queue_torrent_check();
|
||||
}
|
||||
|
||||
void torrent::do_resume()
|
||||
|
@ -4487,6 +4529,9 @@ namespace libtorrent
|
|||
void torrent::set_state(torrent_status::state_t s)
|
||||
{
|
||||
#ifdef TORRENT_DEBUG
|
||||
if (s != torrent_status::checking_files
|
||||
&& s != torrent_status::queued_for_checking)
|
||||
TORRENT_ASSERT(!m_queued_for_checking);
|
||||
if (s == torrent_status::seeding)
|
||||
TORRENT_ASSERT(is_seed());
|
||||
if (s == torrent_status::finished)
|
||||
|
@ -4586,6 +4631,9 @@ namespace libtorrent
|
|||
// if we don't have any metadata, stop here
|
||||
|
||||
st.state = m_state;
|
||||
// for backwards compatibility
|
||||
if (st.state == torrent_status::checking_resume_data)
|
||||
st.state = torrent_status::queued_for_checking;
|
||||
|
||||
if (!valid_metadata())
|
||||
{
|
||||
|
@ -4739,4 +4787,3 @@ namespace libtorrent
|
|||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue