no more extension_list_t type and uncommented call to torrent_plugin::on_load (#1042)
This commit is contained in:
parent
2ac45d17ef
commit
cfd2caeb74
|
@ -868,8 +868,7 @@ namespace libtorrent
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
typedef std::list<std::shared_ptr<peer_plugin>> extension_list_t;
|
std::list<std::shared_ptr<peer_plugin>> m_extensions;
|
||||||
extension_list_t m_extensions;
|
|
||||||
#endif
|
#endif
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -1771,7 +1771,7 @@ namespace libtorrent
|
||||||
, "%s", print_entry(root).c_str());
|
, "%s", print_entry(root).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (extension_list_t::iterator i = m_extensions.begin();
|
for (auto i = m_extensions.begin();
|
||||||
!m_extensions.empty() && i != m_extensions.end();)
|
!m_extensions.empty() && i != m_extensions.end();)
|
||||||
{
|
{
|
||||||
// a false return value means that the extension
|
// a false return value means that the extension
|
||||||
|
@ -1911,10 +1911,9 @@ namespace libtorrent
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (extension_list_t::iterator i = m_extensions.begin()
|
for (auto const& e : m_extensions)
|
||||||
, end(m_extensions.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
if ((*i)->on_unknown_message(m_recv_buffer.packet_size(), packet_type
|
if (e->on_unknown_message(m_recv_buffer.packet_size(), packet_type
|
||||||
, recv_buffer.subspan(1)))
|
, recv_buffer.subspan(1)))
|
||||||
return m_recv_buffer.packet_finished();
|
return m_recv_buffer.packet_finished();
|
||||||
}
|
}
|
||||||
|
@ -2238,10 +2237,9 @@ namespace libtorrent
|
||||||
|
|
||||||
// loop backwards, to make the first extension be the last
|
// loop backwards, to make the first extension be the last
|
||||||
// to fill in the handshake (i.e. give the first extensions priority)
|
// to fill in the handshake (i.e. give the first extensions priority)
|
||||||
for (extension_list_t::reverse_iterator i = m_extensions.rbegin()
|
for (auto const& e : m_extensions)
|
||||||
, end(m_extensions.rend()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
(*i)->add_handshake(handshake);
|
e->add_handshake(handshake);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
@ -2307,10 +2305,9 @@ namespace libtorrent
|
||||||
stats_counters().inc_stats_counter(counters::num_outgoing_unchoke);
|
stats_counters().inc_stats_counter(counters::num_outgoing_unchoke);
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (extension_list_t::iterator i = m_extensions.begin()
|
for (auto const& e : m_extensions)
|
||||||
, end(m_extensions.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
(*i)->sent_unchoke();
|
e->sent_unchoke();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -3339,7 +3336,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (extension_list_t::iterator i = m_extensions.begin()
|
for (auto i = m_extensions.begin()
|
||||||
, end(m_extensions.end()); i != end;)
|
, end(m_extensions.end()); i != end;)
|
||||||
{
|
{
|
||||||
if (!(*i)->on_handshake(m_reserved_bits))
|
if (!(*i)->on_handshake(m_reserved_bits))
|
||||||
|
|
|
@ -1049,11 +1049,10 @@ namespace libtorrent
|
||||||
// INVARIANT_CHECK;
|
// INVARIANT_CHECK;
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (extension_list_t::iterator i = m_extensions.begin()
|
for (auto const& e : m_extensions)
|
||||||
, end(m_extensions.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
TORRENT_TRY {
|
TORRENT_TRY {
|
||||||
(*i)->on_piece_pass(index);
|
e->on_piece_pass(index);
|
||||||
} TORRENT_CATCH(std::exception&) {}
|
} TORRENT_CATCH(std::exception&) {}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -1070,11 +1069,10 @@ namespace libtorrent
|
||||||
TORRENT_UNUSED(single_peer);
|
TORRENT_UNUSED(single_peer);
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (extension_list_t::iterator i = m_extensions.begin()
|
for (auto const& e : m_extensions)
|
||||||
, end(m_extensions.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
TORRENT_TRY {
|
TORRENT_TRY {
|
||||||
(*i)->on_piece_failed(index);
|
e->on_piece_failed(index);
|
||||||
} TORRENT_CATCH(std::exception&) {}
|
} TORRENT_CATCH(std::exception&) {}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -1461,10 +1459,9 @@ namespace libtorrent
|
||||||
if (!t) return;
|
if (!t) return;
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (extension_list_t::iterator i = m_extensions.begin()
|
for (auto const& e : m_extensions)
|
||||||
, end(m_extensions.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
if ((*i)->on_suggest(index)) return;
|
if (e->on_suggest(index)) return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1529,10 +1526,9 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (extension_list_t::iterator i = m_extensions.begin()
|
for (auto const& e : m_extensions)
|
||||||
, end(m_extensions.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
if ((*i)->on_unchoke()) return;
|
if (e->on_unchoke()) return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1567,10 +1563,9 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(t);
|
TORRENT_ASSERT(t);
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (extension_list_t::iterator i = m_extensions.begin()
|
for (auto const& e : m_extensions)
|
||||||
, end(m_extensions.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
if ((*i)->on_interested()) return;
|
if (e->on_interested()) return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1660,10 +1655,9 @@ namespace libtorrent
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (extension_list_t::iterator i = m_extensions.begin()
|
for (auto const& e : m_extensions)
|
||||||
, end(m_extensions.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
if ((*i)->on_not_interested()) return;
|
if (e->on_not_interested()) return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1720,10 +1714,9 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(t);
|
TORRENT_ASSERT(t);
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (extension_list_t::iterator i = m_extensions.begin()
|
for (auto const& e : m_extensions)
|
||||||
, end(m_extensions.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
if ((*i)->on_have(index)) return;
|
if (e->on_have(index)) return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1952,10 +1945,9 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(t);
|
TORRENT_ASSERT(t);
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (extension_list_t::iterator i = m_extensions.begin()
|
for (auto const& e : m_extensions)
|
||||||
, end(m_extensions.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
if ((*i)->on_bitfield(bits)) return;
|
if (e->on_bitfield(bits)) return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2119,10 +2111,9 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (extension_list_t::const_iterator i = m_extensions.begin()
|
for (auto const& e : m_extensions)
|
||||||
, end(m_extensions.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
if (!(*i)->can_disconnect(ec)) return false;
|
if (!e->can_disconnect(ec)) return false;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
TORRENT_UNUSED(ec);
|
TORRENT_UNUSED(ec);
|
||||||
|
@ -2189,10 +2180,9 @@ namespace libtorrent
|
||||||
if (is_disconnecting()) return;
|
if (is_disconnecting()) return;
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (extension_list_t::iterator i = m_extensions.begin()
|
for (auto const& e : m_extensions)
|
||||||
, end(m_extensions.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
if ((*i)->on_request(r)) return;
|
if (e->on_request(r)) return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (is_disconnecting()) return;
|
if (is_disconnecting()) return;
|
||||||
|
@ -3094,10 +3084,9 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (extension_list_t::iterator i = m_extensions.begin()
|
for (auto const& e : m_extensions)
|
||||||
, end(m_extensions.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
if ((*i)->on_have_all()) return;
|
if (e->on_have_all()) return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (is_disconnecting()) return;
|
if (is_disconnecting()) return;
|
||||||
|
@ -3176,10 +3165,9 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(t);
|
TORRENT_ASSERT(t);
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (extension_list_t::iterator i = m_extensions.begin()
|
for (auto const& e : m_extensions)
|
||||||
, end(m_extensions.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
if ((*i)->on_have_none()) return;
|
if (e->on_have_none()) return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (is_disconnecting()) return;
|
if (is_disconnecting()) return;
|
||||||
|
@ -3233,10 +3221,9 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (extension_list_t::iterator i = m_extensions.begin()
|
for (auto const& e : m_extensions)
|
||||||
, end(m_extensions.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
if ((*i)->on_allowed_fast(index)) return;
|
if (e->on_allowed_fast(index)) return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (is_disconnecting()) return;
|
if (is_disconnecting()) return;
|
||||||
|
@ -4151,10 +4138,9 @@ namespace libtorrent
|
||||||
if (t) handle = t->get_handle();
|
if (t) handle = t->get_handle();
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (extension_list_t::iterator i = m_extensions.begin()
|
for (auto const& e : m_extensions)
|
||||||
, end(m_extensions.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
(*i)->on_disconnect(ec);
|
e->on_disconnect(ec);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -2492,7 +2492,7 @@ namespace aux {
|
||||||
// for SSL connections, incoming_connection() is called
|
// for SSL connections, incoming_connection() is called
|
||||||
// after the handshake is done
|
// after the handshake is done
|
||||||
ADD_OUTSTANDING_ASYNC("session_impl::ssl_handshake");
|
ADD_OUTSTANDING_ASYNC("session_impl::ssl_handshake");
|
||||||
s->get<ssl_stream<tcp::socket> >()->async_accept_handshake(
|
s->get<ssl_stream<tcp::socket>>()->async_accept_handshake(
|
||||||
std::bind(&session_impl::ssl_handshake, this, _1, s));
|
std::bind(&session_impl::ssl_handshake, this, _1, s));
|
||||||
m_incoming_sockets.insert(s);
|
m_incoming_sockets.insert(s);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2034,24 +2034,22 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
state_updated();
|
state_updated();
|
||||||
/*
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
// create the extensions again
|
// create the extensions again
|
||||||
|
|
||||||
// TOOD: should we store add_torrent_params::userdata
|
// TODO: should we store add_torrent_params::userdata
|
||||||
// in torrent just to have it available here?
|
// in torrent just to have it available here?
|
||||||
m_ses.add_extensions_to_torrent(shared_from_this(), nullptr);
|
//m_ses.add_extensions_to_torrent(shared_from_this(), nullptr);
|
||||||
|
|
||||||
// and call on_load() on them
|
// and call on_load() on them
|
||||||
for (extension_list_t::iterator i = m_extensions.begin()
|
for (auto const& e : m_extensions)
|
||||||
, end(m_extensions.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
TORRENT_TRY {
|
TORRENT_TRY {
|
||||||
(*i)->on_load();
|
e->on_load();
|
||||||
} TORRENT_CATCH (std::exception&) {}
|
} TORRENT_CATCH (std::exception&) {}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
*/
|
|
||||||
|
|
||||||
inc_stats_counter(counters::num_loaded_torrents);
|
inc_stats_counter(counters::num_loaded_torrents);
|
||||||
|
|
||||||
|
@ -2076,10 +2074,10 @@ namespace libtorrent
|
||||||
|
|
||||||
// call on_unload() on extensions
|
// call on_unload() on extensions
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (auto& ext : m_extensions)
|
for (auto const& e : m_extensions)
|
||||||
{
|
{
|
||||||
TORRENT_TRY {
|
TORRENT_TRY {
|
||||||
ext->on_unload();
|
e->on_unload();
|
||||||
} TORRENT_CATCH (std::exception&) {}
|
} TORRENT_CATCH (std::exception&) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -279,7 +279,7 @@ namespace libtorrent { namespace
|
||||||
if (!m_tp.need_loaded()) return;
|
if (!m_tp.need_loaded()) return;
|
||||||
metadata = m_tp.metadata().data() + offset;
|
metadata = m_tp.metadata().data() + offset;
|
||||||
metadata_piece_size = (std::min)(
|
metadata_piece_size = (std::min)(
|
||||||
int(m_tp.get_metadata_size() - offset), 16 * 1024);
|
m_tp.get_metadata_size() - offset, 16 * 1024);
|
||||||
TORRENT_ASSERT(metadata_piece_size > 0);
|
TORRENT_ASSERT(metadata_piece_size > 0);
|
||||||
TORRENT_ASSERT(offset >= 0);
|
TORRENT_ASSERT(offset >= 0);
|
||||||
TORRENT_ASSERT(offset + metadata_piece_size <= int(m_tp.get_metadata_size()));
|
TORRENT_ASSERT(offset + metadata_piece_size <= int(m_tp.get_metadata_size()));
|
||||||
|
|
Loading…
Reference in New Issue