forked from premiere/premiere-libtorrent
fixed crashing bug when removing torrents while checking
This commit is contained in:
parent
1bde539d67
commit
80dc56d388
|
@ -1,3 +1,4 @@
|
||||||
|
* fixed crasing bug when closing while checking a torrent
|
||||||
* fixed bug causing a crash with a torrent with piece length 0
|
* fixed bug causing a crash with a torrent with piece length 0
|
||||||
* added an extension to the DHT network protocol to support the
|
* added an extension to the DHT network protocol to support the
|
||||||
exchange of nodes with IPv6 addresses.
|
exchange of nodes with IPv6 addresses.
|
||||||
|
|
|
@ -163,6 +163,10 @@ namespace libtorrent
|
||||||
piece_checker_data* find_torrent(const sha1_hash& info_hash);
|
piece_checker_data* find_torrent(const sha1_hash& info_hash);
|
||||||
void remove_torrent(sha1_hash const& info_hash);
|
void remove_torrent(sha1_hash const& info_hash);
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
void check_invariant() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
// when the files has been checked
|
// when the files has been checked
|
||||||
// the torrent is added to the session
|
// the torrent is added to the session
|
||||||
session_impl& m_ses;
|
session_impl& m_ses;
|
||||||
|
|
|
@ -112,6 +112,8 @@ namespace libtorrent { namespace detail
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock l(m_mutex);
|
boost::mutex::scoped_lock l(m_mutex);
|
||||||
|
|
||||||
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
// if the job queue is empty and
|
// if the job queue is empty and
|
||||||
// we shouldn't abort
|
// we shouldn't abort
|
||||||
// wait for a signal
|
// wait for a signal
|
||||||
|
@ -160,7 +162,8 @@ namespace libtorrent { namespace detail
|
||||||
if (t)
|
if (t)
|
||||||
{
|
{
|
||||||
std::string error_msg;
|
std::string error_msg;
|
||||||
t->parse_resume_data(t->resume_data, t->torrent_ptr->torrent_file(), error_msg);
|
t->parse_resume_data(t->resume_data, t->torrent_ptr->torrent_file()
|
||||||
|
, error_msg);
|
||||||
|
|
||||||
if (!error_msg.empty() && m_ses.m_alerts.should_post(alert::warning))
|
if (!error_msg.empty() && m_ses.m_alerts.should_post(alert::warning))
|
||||||
{
|
{
|
||||||
|
@ -185,6 +188,7 @@ namespace libtorrent { namespace detail
|
||||||
// lock the session to add the new torrent
|
// lock the session to add the new torrent
|
||||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||||
mutex::scoped_lock l2(m_mutex);
|
mutex::scoped_lock l2(m_mutex);
|
||||||
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
assert(m_torrents.front() == t);
|
assert(m_torrents.front() == t);
|
||||||
|
|
||||||
|
@ -276,6 +280,9 @@ namespace libtorrent { namespace detail
|
||||||
|
|
||||||
{
|
{
|
||||||
mutex::scoped_lock l(m_mutex);
|
mutex::scoped_lock l(m_mutex);
|
||||||
|
|
||||||
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
processing->progress = progress;
|
processing->progress = progress;
|
||||||
if (processing->abort)
|
if (processing->abort)
|
||||||
{
|
{
|
||||||
|
@ -300,6 +307,8 @@ namespace libtorrent { namespace detail
|
||||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||||
mutex::scoped_lock l2(m_mutex);
|
mutex::scoped_lock l2(m_mutex);
|
||||||
|
|
||||||
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
assert(!m_processing.empty());
|
assert(!m_processing.empty());
|
||||||
assert(m_processing.front() == processing);
|
assert(m_processing.front() == processing);
|
||||||
|
|
||||||
|
@ -388,6 +397,7 @@ namespace libtorrent { namespace detail
|
||||||
|
|
||||||
detail::piece_checker_data* checker_impl::find_torrent(sha1_hash const& info_hash)
|
detail::piece_checker_data* checker_impl::find_torrent(sha1_hash const& info_hash)
|
||||||
{
|
{
|
||||||
|
INVARIANT_CHECK;
|
||||||
for (std::deque<boost::shared_ptr<piece_checker_data> >::iterator i
|
for (std::deque<boost::shared_ptr<piece_checker_data> >::iterator i
|
||||||
= m_torrents.begin(); i != m_torrents.end(); ++i)
|
= m_torrents.begin(); i != m_torrents.end(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -405,6 +415,7 @@ namespace libtorrent { namespace detail
|
||||||
|
|
||||||
void checker_impl::remove_torrent(sha1_hash const& info_hash)
|
void checker_impl::remove_torrent(sha1_hash const& info_hash)
|
||||||
{
|
{
|
||||||
|
INVARIANT_CHECK;
|
||||||
for (std::deque<boost::shared_ptr<piece_checker_data> >::iterator i
|
for (std::deque<boost::shared_ptr<piece_checker_data> >::iterator i
|
||||||
= m_torrents.begin(); i != m_torrents.end(); ++i)
|
= m_torrents.begin(); i != m_torrents.end(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -421,7 +432,7 @@ namespace libtorrent { namespace detail
|
||||||
if ((*i)->info_hash == info_hash)
|
if ((*i)->info_hash == info_hash)
|
||||||
{
|
{
|
||||||
assert((*i)->processing == false);
|
assert((*i)->processing == false);
|
||||||
m_torrents.erase(i);
|
m_processing.erase(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -429,6 +440,24 @@ namespace libtorrent { namespace detail
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
void checker_impl::check_invariant() const
|
||||||
|
{
|
||||||
|
for (std::deque<boost::shared_ptr<piece_checker_data> >::const_iterator i
|
||||||
|
= m_torrents.begin(); i != m_torrents.end(); ++i)
|
||||||
|
{
|
||||||
|
assert(*i);
|
||||||
|
assert((*i)->torrent_ptr);
|
||||||
|
}
|
||||||
|
for (std::deque<boost::shared_ptr<piece_checker_data> >::const_iterator i
|
||||||
|
= m_processing.begin(); i != m_processing.end(); ++i)
|
||||||
|
{
|
||||||
|
assert(*i);
|
||||||
|
assert((*i)->torrent_ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
session_impl::session_impl(
|
session_impl::session_impl(
|
||||||
std::pair<int, int> listen_port_range
|
std::pair<int, int> listen_port_range
|
||||||
, fingerprint const& cl_fprint
|
, fingerprint const& cl_fprint
|
||||||
|
|
|
@ -957,7 +957,7 @@ namespace libtorrent
|
||||||
req.downloaded = m_stat.total_payload_download();
|
req.downloaded = m_stat.total_payload_download();
|
||||||
req.uploaded = m_stat.total_payload_upload();
|
req.uploaded = m_stat.total_payload_upload();
|
||||||
req.left = bytes_left();
|
req.left = bytes_left();
|
||||||
if (req.left == -1) req.left = 1000;
|
if (req.left == -1) req.left = 16*1024;
|
||||||
req.event = m_event;
|
req.event = m_event;
|
||||||
|
|
||||||
if (m_event != tracker_request::stopped)
|
if (m_event != tracker_request::stopped)
|
||||||
|
|
Loading…
Reference in New Issue