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