*** empty log message ***
This commit is contained in:
parent
b55a1a6766
commit
5a25be2825
|
@ -105,7 +105,8 @@ namespace libtorrent
|
|||
// thread that initialize pieces
|
||||
struct piece_checker_data
|
||||
{
|
||||
piece_checker_data(): progress(0.f), abort(false) {}
|
||||
piece_checker_data()
|
||||
: progress(0.f), abort(false), processing(false) {}
|
||||
|
||||
boost::shared_ptr<torrent> torrent_ptr;
|
||||
boost::filesystem::path save_path;
|
||||
|
@ -121,6 +122,12 @@ namespace libtorrent
|
|||
std::vector<address> peers;
|
||||
entry resume_data;
|
||||
|
||||
// this is true if this torrent is being processed (checked)
|
||||
// if it is not being processed, then it can be removed from
|
||||
// the queue without problems, otherwise the abort flag has
|
||||
// to be set.
|
||||
volatile bool processing;
|
||||
|
||||
// is filled in by storage::initialize_pieces()
|
||||
// and represents the progress. It should be a
|
||||
// value in the range [0, 1]
|
||||
|
@ -137,6 +144,7 @@ namespace libtorrent
|
|||
checker_impl(session_impl& s): m_ses(s), m_abort(false) {}
|
||||
void operator()();
|
||||
piece_checker_data* find_torrent(const sha1_hash& info_hash);
|
||||
void remove_torrent(sha1_hash const& info_hash);
|
||||
|
||||
// when the files has been checked
|
||||
// the torrent is added to the session
|
||||
|
@ -315,6 +323,7 @@ namespace libtorrent
|
|||
void disable_extensions();
|
||||
|
||||
void set_peer_id(peer_id const& id);
|
||||
void set_key(int key);
|
||||
|
||||
bool is_listening() const;
|
||||
|
||||
|
|
|
@ -114,6 +114,7 @@ namespace libtorrent { namespace detail
|
|||
m_torrents.pop_front();
|
||||
continue;
|
||||
}
|
||||
t->processing = true;
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -176,7 +177,7 @@ namespace libtorrent { namespace detail
|
|||
}
|
||||
}
|
||||
|
||||
detail::piece_checker_data* checker_impl::find_torrent(const sha1_hash& info_hash)
|
||||
detail::piece_checker_data* checker_impl::find_torrent(sha1_hash const& info_hash)
|
||||
{
|
||||
for (std::deque<piece_checker_data>::iterator i
|
||||
= m_torrents.begin();
|
||||
|
@ -188,6 +189,21 @@ namespace libtorrent { namespace detail
|
|||
return 0;
|
||||
}
|
||||
|
||||
void checker_impl::remove_torrent(sha1_hash const& info_hash)
|
||||
{
|
||||
for (std::deque<piece_checker_data>::iterator i
|
||||
= m_torrents.begin();
|
||||
i != m_torrents.end();
|
||||
++i)
|
||||
{
|
||||
if (i->info_hash == info_hash)
|
||||
{
|
||||
m_torrents.erase(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
session_impl::session_impl(
|
||||
std::pair<int, int> listen_port_range
|
||||
, const fingerprint& cl_fprint
|
||||
|
@ -876,6 +892,12 @@ namespace libtorrent
|
|||
m_impl.m_peer_id = id;
|
||||
}
|
||||
|
||||
void session::set_key(int key)
|
||||
{
|
||||
boost::mutex::scoped_lock l(m_impl.m_mutex);
|
||||
m_impl.m_key = key;
|
||||
}
|
||||
|
||||
void session::enable_extension(peer_connection::extension_index i)
|
||||
{
|
||||
assert(i >= 0);
|
||||
|
@ -1022,7 +1044,8 @@ namespace libtorrent
|
|||
detail::piece_checker_data* d = m_checker_impl.find_torrent(h.m_info_hash);
|
||||
if (d != 0)
|
||||
{
|
||||
d->abort = true;
|
||||
if (d->processing) d->abort = true;
|
||||
else m_checker_impl.remove_torrent(h.m_info_hash);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue