extensions refactor to use span and std::shared_ptr (#1005)

extensions refactor to use span. use std::shared_ptr instead of boost::shared_ptr.
This commit is contained in:
Alden Torres 2016-08-17 14:30:24 -04:00 committed by Arvid Norberg
parent 2d84278720
commit 7cee486cf7
33 changed files with 131 additions and 147 deletions

View File

@ -1,3 +1,4 @@
* extensions API changed to use span and std::shared_ptr
* plugin API changed to handle DHT requests using string_view * plugin API changed to handle DHT requests using string_view
* removed support for lt_trackers and metadata_transfer extensions * removed support for lt_trackers and metadata_transfer extensions
(pre-dating ut_metadata) (pre-dating ut_metadata)

View File

@ -343,7 +343,7 @@ namespace libtorrent
// to avoid race conditions. For instance it may be important to have the // to avoid race conditions. For instance it may be important to have the
// plugin catch events that happen very early on after the torrent is // plugin catch events that happen very early on after the torrent is
// created. // created.
std::vector<std::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)>> std::vector<std::function<std::shared_ptr<torrent_plugin>(torrent_handle const&, void*)>>
extensions; extensions;
// the default tracker id to be used when announcing to trackers. By // the default tracker id to be used when announcing to trackers. By

View File

@ -117,7 +117,7 @@ namespace libtorrent {
void set_notify_function(std::function<void()> const& fun); void set_notify_function(std::function<void()> const& fun);
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
void add_extension(boost::shared_ptr<plugin> ext); void add_extension(std::shared_ptr<plugin> ext);
#endif #endif
private: private:
@ -159,7 +159,7 @@ namespace libtorrent {
aux::stack_allocator m_allocations[2]; aux::stack_allocator m_allocations[2];
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
std::list<boost::shared_ptr<plugin>> m_ses_extensions; std::list<std::shared_ptr<plugin>> m_ses_extensions;
#endif #endif
}; };
} }

View File

@ -217,20 +217,20 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
using ext_function_t using ext_function_t
= std::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)>; = std::function<std::shared_ptr<torrent_plugin>(torrent_handle const&, void*)>;
struct session_plugin_wrapper : plugin struct session_plugin_wrapper : plugin
{ {
explicit session_plugin_wrapper(ext_function_t const& f) : m_f(f) {} explicit session_plugin_wrapper(ext_function_t const& f) : m_f(f) {}
boost::shared_ptr<torrent_plugin> new_torrent(torrent_handle const& t, void* user) override std::shared_ptr<torrent_plugin> new_torrent(torrent_handle const& t, void* user) override
{ return m_f(t, user); } { return m_f(t, user); }
ext_function_t m_f; ext_function_t m_f;
}; };
void add_extension(std::function<boost::shared_ptr<torrent_plugin>( void add_extension(std::function<std::shared_ptr<torrent_plugin>(
torrent_handle const&, void*)> ext); torrent_handle const&, void*)> ext);
void add_ses_extension(boost::shared_ptr<plugin> ext); void add_ses_extension(std::shared_ptr<plugin> ext);
#endif #endif
#if TORRENT_USE_ASSERTS #if TORRENT_USE_ASSERTS
bool has_peer(peer_connection const* p) const override; bool has_peer(peer_connection const* p) const override;
@ -1178,7 +1178,7 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
// this is a list to allow extensions to potentially remove themselves. // this is a list to allow extensions to potentially remove themselves.
std::array<std::vector<boost::shared_ptr<plugin>>, 4> m_ses_extensions; std::array<std::vector<std::shared_ptr<plugin>>, 4> m_ses_extensions;
#endif #endif
// if this function is set, it indicates that torrents are allowed // if this function is set, it indicates that torrents are allowed

View File

@ -45,7 +45,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/disable_warnings_push.hpp" #include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/smart_ptr.hpp>
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp" #include "libtorrent/aux_/disable_warnings_pop.hpp"
@ -85,6 +84,8 @@ namespace libtorrent
#endif #endif
bool was_introduced_by(tcp::endpoint const& ep); bool was_introduced_by(tcp::endpoint const& ep);
virtual ~ut_pex_peer_store() {}
}; };
#endif #endif
@ -122,8 +123,8 @@ namespace libtorrent
bool rc4_encrypted() const bool rc4_encrypted() const
{ return m_rc4_encrypted; } { return m_rc4_encrypted; }
void switch_send_crypto(boost::shared_ptr<crypto_plugin> crypto); void switch_send_crypto(std::shared_ptr<crypto_plugin> crypto);
void switch_recv_crypto(boost::shared_ptr<crypto_plugin> crypto); void switch_recv_crypto(std::shared_ptr<crypto_plugin> crypto);
#endif #endif
virtual int type() const override virtual int type() const override
@ -192,10 +193,10 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
bool supports_holepunch() const { return m_holepunch_id != 0; } bool supports_holepunch() const { return m_holepunch_id != 0; }
void set_ut_pex(boost::shared_ptr<ut_pex_peer_store> ut_pex) void set_ut_pex(std::weak_ptr<ut_pex_peer_store> ut_pex)
{ m_ut_pex = ut_pex; } { m_ut_pex = std::move(ut_pex); }
bool was_introduced_by(tcp::endpoint const& ep) const bool was_introduced_by(tcp::endpoint const& ep) const
{ return m_ut_pex && m_ut_pex->was_introduced_by(ep); } { auto p = m_ut_pex.lock(); return p && p->was_introduced_by(ep); }
#endif #endif
bool support_extensions() const { return m_supports_extensions; } bool support_extensions() const { return m_supports_extensions; }
@ -419,7 +420,7 @@ private:
// used during an encrypted handshake then moved // used during an encrypted handshake then moved
// into m_enc_handler if rc4 encryption is negotiated // into m_enc_handler if rc4 encryption is negotiated
// otherwise it is destroyed when the handshake completes // otherwise it is destroyed when the handshake completes
boost::shared_ptr<rc4_handler> m_rc4; std::shared_ptr<rc4_handler> m_rc4;
// if encryption is negotiated, this is used for // if encryption is negotiated, this is used for
// encryption/decryption during the entire session. // encryption/decryption during the entire session.
@ -457,9 +458,9 @@ private:
// 0 if not supported // 0 if not supported
std::uint8_t m_share_mode_id; std::uint8_t m_share_mode_id;
boost::shared_ptr<ut_pex_peer_store> m_ut_pex; std::weak_ptr<ut_pex_peer_store> m_ut_pex;
char m_reserved_bits[8]; std::array<char, 8> m_reserved_bits;
#endif #endif
#if TORRENT_USE_ASSERTS #if TORRENT_USE_ASSERTS

View File

@ -92,19 +92,19 @@ POSSIBILITY OF SUCH DAMAGE.
// //
// The signature of the function is:: // The signature of the function is::
// //
// boost::shared_ptr<torrent_plugin> (*)(torrent_handle const&, void*); // std::shared_ptr<torrent_plugin> (*)(torrent_handle const&, void*);
// //
// The second argument is the userdata passed to ``session::add_torrent()`` or // The second argument is the userdata passed to ``session::add_torrent()`` or
// ``torrent_handle::add_extension()``. // ``torrent_handle::add_extension()``.
// //
// The function should return a ``boost::shared_ptr<torrent_plugin>`` which // The function should return a ``std::shared_ptr<torrent_plugin>`` which
// may or may not be 0. If it is a nullptr, the extension is simply ignored // may or may not be 0. If it is a nullptr, the extension is simply ignored
// for this torrent. If it is a valid pointer (to a class inheriting // for this torrent. If it is a valid pointer (to a class inheriting
// ``torrent_plugin``), it will be associated with this torrent and callbacks // ``torrent_plugin``), it will be associated with this torrent and callbacks
// will be made on torrent events. // will be made on torrent events.
// //
// For more elaborate plugins which require session wide state, you would // For more elaborate plugins which require session wide state, you would
// implement ``plugin``, construct an object (in a ``boost::shared_ptr``) and pass // implement ``plugin``, construct an object (in a ``std::shared_ptr``) and pass
// it in to ``session::add_extension()``. // it in to ``session::add_extension()``.
// //
// custom alerts // custom alerts
@ -158,12 +158,11 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
#include <vector> #include <vector>
#include "libtorrent/config.hpp" #include "libtorrent/config.hpp"
#include "libtorrent/sha1_hash.hpp" // for sha1_hash
#include "libtorrent/session_handle.hpp"
#include "libtorrent/peer_connection_handle.hpp"
#include "libtorrent/span.hpp" #include "libtorrent/span.hpp"
#include "libtorrent/string_view.hpp" #include "libtorrent/string_view.hpp"
#include "libtorrent/socket.hpp"
namespace libtorrent namespace libtorrent
{ {
@ -176,6 +175,9 @@ namespace libtorrent
struct torrent_plugin; struct torrent_plugin;
struct add_torrent_params; struct add_torrent_params;
struct torrent_handle; struct torrent_handle;
class sha1_hash;
struct session_handle;
struct peer_connection_handle;
// this is the base class for a session plugin. One primary feature // this is the base class for a session plugin. One primary feature
// is that it is notified of all torrents that are added to the session, // is that it is notified of all torrents that are added to the session,
@ -222,11 +224,11 @@ namespace libtorrent
// If the plugin returns a torrent_plugin instance, it will be added // If the plugin returns a torrent_plugin instance, it will be added
// to the new torrent. Otherwise, return an empty shared_ptr to a // to the new torrent. Otherwise, return an empty shared_ptr to a
// torrent_plugin (the default). // torrent_plugin (the default).
virtual boost::shared_ptr<torrent_plugin> new_torrent(torrent_handle const&, void*) virtual std::shared_ptr<torrent_plugin> new_torrent(torrent_handle const&, void*)
{ return boost::shared_ptr<torrent_plugin>(); } { return std::shared_ptr<torrent_plugin>(); }
// called when plugin is added to a session // called when plugin is added to a session
virtual void added(session_handle) {} virtual void added(session_handle const&) {}
// called when a dht request is received. // called when a dht request is received.
// If your plugin expects this to be called, make sure to include the flag // If your plugin expects this to be called, make sure to include the flag
@ -292,8 +294,8 @@ namespace libtorrent
// to it, use ``weak_ptr``. // to it, use ``weak_ptr``.
// //
// If this function throws an exception, the connection will be closed. // If this function throws an exception, the connection will be closed.
virtual boost::shared_ptr<peer_plugin> new_connection(peer_connection_handle const&) virtual std::shared_ptr<peer_plugin> new_connection(peer_connection_handle const&)
{ return boost::shared_ptr<peer_plugin>(); } { return std::shared_ptr<peer_plugin>(); }
// These hooks are called when a piece passes the hash check or fails the hash // These hooks are called when a piece passes the hash check or fails the hash
// check, respectively. The ``index`` is the piece index that was downloaded. // check, respectively. The ``index`` is the piece index that was downloaded.
@ -394,7 +396,7 @@ namespace libtorrent
// means that the other end doesn't support this extension and will remove // means that the other end doesn't support this extension and will remove
// it from the list of plugins. // it from the list of plugins.
// this is not called for web seeds // this is not called for web seeds
virtual bool on_handshake(char const* /*reserved_bits*/) { return true; } virtual bool on_handshake(span<char const> /*reserved_bits*/) { return true; }
// called when the extension handshake from the other end is received // called when the extension handshake from the other end is received
// if this returns false, it means that this extension isn't // if this returns false, it means that this extension isn't
@ -427,7 +429,7 @@ namespace libtorrent
// returns true to indicate that the piece is handled and the // returns true to indicate that the piece is handled and the
// rest of the logic should be ignored. // rest of the logic should be ignored.
virtual bool on_piece(peer_request const& /*piece*/ virtual bool on_piece(peer_request const& /*piece*/
, char const* /*buf*/) { return false; } , span<char const> /*buf*/) { return false; }
virtual bool on_cancel(peer_request const&) { return false; } virtual bool on_cancel(peer_request const&) { return false; }
virtual bool on_reject(peer_request const&) { return false; } virtual bool on_reject(peer_request const&) { return false; }

View File

@ -37,11 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp" #include "libtorrent/config.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp" #include <memory>
#include <boost/shared_ptr.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
namespace libtorrent namespace libtorrent
{ {
@ -54,7 +50,7 @@ namespace libtorrent
// out to have sent corrupt data. // out to have sent corrupt data.
// This function can either be passed in the add_torrent_params::extensions // This function can either be passed in the add_torrent_params::extensions
// field, or via torrent_handle::add_extension(). // field, or via torrent_handle::add_extension().
TORRENT_EXPORT boost::shared_ptr<torrent_plugin> create_smart_ban_plugin(torrent_handle const&, void*); TORRENT_EXPORT std::shared_ptr<torrent_plugin> create_smart_ban_plugin(torrent_handle const&, void*);
} }
#endif // TORRENT_DISABLE_EXTENSIONS #endif // TORRENT_DISABLE_EXTENSIONS

View File

@ -37,11 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp" #include "libtorrent/config.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp" #include <memory>
#include <boost/shared_ptr.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
namespace libtorrent namespace libtorrent
{ {
@ -57,7 +53,7 @@ namespace libtorrent
// //
// This can either be passed in the add_torrent_params::extensions field, or // This can either be passed in the add_torrent_params::extensions field, or
// via torrent_handle::add_extension(). // via torrent_handle::add_extension().
TORRENT_EXPORT boost::shared_ptr<torrent_plugin> create_ut_metadata_plugin(torrent_handle const&, void*); TORRENT_EXPORT std::shared_ptr<torrent_plugin> create_ut_metadata_plugin(torrent_handle const&, void*);
} }
#endif // TORRENT_DISABLE_EXTENSIONS #endif // TORRENT_DISABLE_EXTENSIONS

View File

@ -36,14 +36,8 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
#include "libtorrent/config.hpp" #include "libtorrent/config.hpp"
#include "libtorrent/socket.hpp" // for endpoint
#include "libtorrent/address.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp" #include <memory>
#include <boost/shared_ptr.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
namespace libtorrent namespace libtorrent
{ {
@ -58,7 +52,7 @@ namespace libtorrent
// //
// This can either be passed in the add_torrent_params::extensions field, or // This can either be passed in the add_torrent_params::extensions field, or
// via torrent_handle::add_extension(). // via torrent_handle::add_extension().
TORRENT_EXPORT boost::shared_ptr<torrent_plugin> create_ut_pex_plugin(torrent_handle const&, void*); TORRENT_EXPORT std::shared_ptr<torrent_plugin> create_ut_pex_plugin(torrent_handle const&, void*);
} }
#endif // TORRENT_DISABLE_EXTENSIONS #endif // TORRENT_DISABLE_EXTENSIONS

View File

@ -104,10 +104,10 @@ namespace libtorrent
int decrypt(crypto_receive_buffer& recv_buffer int decrypt(crypto_receive_buffer& recv_buffer
, std::size_t& bytes_transferred); , std::size_t& bytes_transferred);
bool switch_send_crypto(boost::shared_ptr<crypto_plugin> crypto bool switch_send_crypto(std::shared_ptr<crypto_plugin> crypto
, int pending_encryption); , int pending_encryption);
void switch_recv_crypto(boost::shared_ptr<crypto_plugin> crypto void switch_recv_crypto(std::shared_ptr<crypto_plugin> crypto
, crypto_receive_buffer& recv_buffer); , crypto_receive_buffer& recv_buffer);
bool is_send_plaintext() const bool is_send_plaintext() const
@ -123,14 +123,14 @@ namespace libtorrent
private: private:
struct barrier struct barrier
{ {
barrier(boost::shared_ptr<crypto_plugin> plugin, int n) barrier(std::shared_ptr<crypto_plugin> plugin, int n)
: enc_handler(plugin), next(n) {} : enc_handler(plugin), next(n) {}
boost::shared_ptr<crypto_plugin> enc_handler; std::shared_ptr<crypto_plugin> enc_handler;
// number of bytes to next barrier // number of bytes to next barrier
int next; int next;
}; };
std::list<barrier> m_send_barriers; std::list<barrier> m_send_barriers;
boost::shared_ptr<crypto_plugin> m_dec_handler; std::shared_ptr<crypto_plugin> m_dec_handler;
}; };
struct TORRENT_EXTRA_EXPORT rc4_handler : crypto_plugin struct TORRENT_EXTRA_EXPORT rc4_handler : crypto_plugin

View File

@ -330,7 +330,7 @@ namespace libtorrent
void send_allowed_set(); void send_allowed_set();
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
void add_extension(boost::shared_ptr<peer_plugin>); void add_extension(std::shared_ptr<peer_plugin>);
#endif #endif
// this function is called once the torrent associated // this function is called once the torrent associated
@ -865,9 +865,9 @@ namespace libtorrent
// io service // io service
io_service& m_ios; io_service& m_ios;
public: protected:
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
typedef std::list<boost::shared_ptr<peer_plugin>> extension_list_t; typedef std::list<std::shared_ptr<peer_plugin>> extension_list_t;
extension_list_t m_extensions; extension_list_t m_extensions;
#endif #endif
private: private:

View File

@ -59,7 +59,7 @@ struct TORRENT_EXPORT peer_connection_handle
int type() const; int type() const;
void add_extension(boost::shared_ptr<peer_plugin>); void add_extension(std::shared_ptr<peer_plugin>);
bool is_seed() const; bool is_seed() const;
@ -139,8 +139,8 @@ struct TORRENT_EXPORT bt_peer_connection_handle : public peer_connection_handle
bool supports_encryption() const; bool supports_encryption() const;
void switch_send_crypto(boost::shared_ptr<crypto_plugin> crypto); void switch_send_crypto(std::shared_ptr<crypto_plugin> crypto);
void switch_recv_crypto(boost::shared_ptr<crypto_plugin> crypto); void switch_recv_crypto(std::shared_ptr<crypto_plugin> crypto);
boost::shared_ptr<bt_peer_connection> native_handle() const; boost::shared_ptr<bt_peer_connection> native_handle() const;
}; };

View File

@ -135,7 +135,7 @@ namespace libtorrent
// This constructor helps to configure the set of initial plugins // This constructor helps to configure the set of initial plugins
// to be added to the session before it's started. // to be added to the session before it's started.
session_params(settings_pack sp session_params(settings_pack sp
, std::vector<boost::shared_ptr<plugin>> exts); , std::vector<std::shared_ptr<plugin>> exts);
session_params(session_params const&) = default; session_params(session_params const&) = default;
session_params(session_params&&) = default; session_params(session_params&&) = default;
@ -144,7 +144,7 @@ namespace libtorrent
settings_pack settings; settings_pack settings;
std::vector<boost::shared_ptr<plugin>> extensions; std::vector<std::shared_ptr<plugin>> extensions;
libtorrent::dht_settings dht_settings; libtorrent::dht_settings dht_settings;

View File

@ -479,9 +479,9 @@ namespace libtorrent
// //
// //
// .. _`libtorrent plugins`: libtorrent_plugins.html // .. _`libtorrent plugins`: libtorrent_plugins.html
void add_extension(std::function<boost::shared_ptr<torrent_plugin>( void add_extension(std::function<std::shared_ptr<torrent_plugin>(
torrent_handle const&, void*)> ext); torrent_handle const&, void*)> ext);
void add_extension(boost::shared_ptr<plugin> ext); void add_extension(std::shared_ptr<plugin> ext);
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
// GeoIP support has been removed from libtorrent internals. If you // GeoIP support has been removed from libtorrent internals. If you

View File

@ -298,9 +298,9 @@ namespace libtorrent
int current_stats_state() const; int current_stats_state() const;
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
void add_extension(boost::shared_ptr<torrent_plugin>); void add_extension(std::shared_ptr<torrent_plugin>);
void remove_extension(boost::shared_ptr<torrent_plugin>); void remove_extension(std::shared_ptr<torrent_plugin>);
void add_extension_fun(std::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext void add_extension_fun(std::function<std::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
, void* userdata); , void* userdata);
void notify_extension_add_peer(tcp::endpoint const& ip, int src, int flags); void notify_extension_add_peer(tcp::endpoint const& ip, int src, int flags);
#endif #endif
@ -1205,7 +1205,7 @@ namespace libtorrent
std::list<web_seed_t> m_web_seeds; std::list<web_seed_t> m_web_seeds;
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
std::list<boost::shared_ptr<torrent_plugin>> m_extensions; std::list<std::shared_ptr<torrent_plugin>> m_extensions;
#endif #endif
// used for tracker announces // used for tracker announces

View File

@ -511,7 +511,7 @@ namespace libtorrent
// pointer. The function is expected to return a shared pointer to // pointer. The function is expected to return a shared pointer to
// a torrent_plugin instance. // a torrent_plugin instance.
void add_extension( void add_extension(
std::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext std::function<std::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
, void* userdata = 0); , void* userdata = 0);
// ``set_metadata`` expects the *info* section of metadata. i.e. The // ``set_metadata`` expects the *info* section of metadata. i.e. The

View File

@ -106,7 +106,7 @@ namespace libtorrent
} }
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
void alert_manager::add_extension(boost::shared_ptr<plugin> ext) void alert_manager::add_extension(std::shared_ptr<plugin> ext)
{ {
m_ses_extensions.push_back(ext); m_ses_extensions.push_back(ext);
} }

View File

@ -91,7 +91,7 @@ namespace libtorrent
// stream key (info hash of attached torrent) // stream key (info hash of attached torrent)
// secret is the DH shared secret // secret is the DH shared secret
// initializes m_enc_handler // initializes m_enc_handler
boost::shared_ptr<rc4_handler> init_pe_rc4_handler(key_t const& secret std::shared_ptr<rc4_handler> init_pe_rc4_handler(key_t const& secret
, sha1_hash const& stream_key, bool const outgoing) , sha1_hash const& stream_key, bool const outgoing)
{ {
hasher h; hasher h;
@ -120,7 +120,7 @@ namespace libtorrent
h.update(stream_key); h.update(stream_key);
sha1_hash const remote_key = h.final(); sha1_hash const remote_key = h.final();
boost::shared_ptr<rc4_handler> ret = boost::make_shared<rc4_handler>(); auto ret = std::make_shared<rc4_handler>();
ret->set_incoming_key(remote_key); ret->set_incoming_key(remote_key);
ret->set_outgoing_key(local_key); ret->set_outgoing_key(local_key);
@ -192,7 +192,7 @@ namespace libtorrent
m_in_constructor = false; m_in_constructor = false;
#endif #endif
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
memset(m_reserved_bits, 0, sizeof(m_reserved_bits)); m_reserved_bits.fill(0);
#endif #endif
} }
@ -209,13 +209,13 @@ namespace libtorrent
bt_peer_connection::~bt_peer_connection() = default; bt_peer_connection::~bt_peer_connection() = default;
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
void bt_peer_connection::switch_send_crypto(boost::shared_ptr<crypto_plugin> crypto) void bt_peer_connection::switch_send_crypto(std::shared_ptr<crypto_plugin> crypto)
{ {
if (m_enc_handler.switch_send_crypto(crypto, send_buffer_size() - get_send_barrier())) if (m_enc_handler.switch_send_crypto(crypto, send_buffer_size() - get_send_barrier()))
set_send_barrier(send_buffer_size()); set_send_barrier(send_buffer_size());
} }
void bt_peer_connection::switch_recv_crypto(boost::shared_ptr<crypto_plugin> crypto) void bt_peer_connection::switch_recv_crypto(std::shared_ptr<crypto_plugin> crypto)
{ {
m_enc_handler.switch_recv_crypto(crypto, m_recv_buffer); m_enc_handler.switch_recv_crypto(crypto, m_recv_buffer);
} }
@ -2618,7 +2618,7 @@ namespace libtorrent
// again according to peer selection. // again according to peer selection.
switch_send_crypto(m_rc4); switch_send_crypto(m_rc4);
write_handshake(); write_handshake();
switch_send_crypto(boost::shared_ptr<crypto_plugin>()); switch_send_crypto(std::shared_ptr<crypto_plugin>());
// vc,crypto_select,len(pad),pad, encrypt(handshake) // vc,crypto_select,len(pad),pad, encrypt(handshake)
// 8+4+2+0+handshake_len // 8+4+2+0+handshake_len
@ -3212,7 +3212,7 @@ namespace libtorrent
#endif #endif
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
std::memcpy(m_reserved_bits, recv_buffer.begin(), 8); std::memcpy(m_reserved_bits.data(), recv_buffer.begin(), 8);
if ((recv_buffer[5] & 0x10)) if ((recv_buffer[5] & 0x10))
m_supports_extensions = true; m_supports_extensions = true;
#endif #endif

View File

@ -233,7 +233,7 @@ namespace libtorrent
return consume; return consume;
} }
bool encryption_handler::switch_send_crypto(boost::shared_ptr<crypto_plugin> crypto bool encryption_handler::switch_send_crypto(std::shared_ptr<crypto_plugin> crypto
, int pending_encryption) , int pending_encryption)
{ {
bool place_barrier = false; bool place_barrier = false;
@ -255,7 +255,7 @@ namespace libtorrent
return place_barrier; return place_barrier;
} }
void encryption_handler::switch_recv_crypto(boost::shared_ptr<crypto_plugin> crypto void encryption_handler::switch_recv_crypto(std::shared_ptr<crypto_plugin> crypto
, crypto_receive_buffer& recv_buffer) , crypto_receive_buffer& recv_buffer)
{ {
m_dec_handler = crypto; m_dec_handler = crypto;

View File

@ -523,7 +523,7 @@ namespace libtorrent
#endif #endif
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
void peer_connection::add_extension(boost::shared_ptr<peer_plugin> ext) void peer_connection::add_extension(std::shared_ptr<peer_plugin> ext)
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
m_extensions.push_back(ext); m_extensions.push_back(ext);
@ -2654,10 +2654,9 @@ namespace libtorrent
update_desired_queue_size(); update_desired_queue_size();
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
for (extension_list_t::iterator i = m_extensions.begin() for (auto& e : m_extensions)
, end(m_extensions.end()); i != end; ++i)
{ {
if ((*i)->on_piece(p, data.get())) if (e->on_piece(p, {data.get(), size_t(p.length)}))
{ {
#if TORRENT_USE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_received_in_piece == p.length); TORRENT_ASSERT(m_received_in_piece == p.length);

View File

@ -48,7 +48,7 @@ int peer_connection_handle::type() const
return pc->type(); return pc->type();
} }
void peer_connection_handle::add_extension(boost::shared_ptr<peer_plugin> ext) void peer_connection_handle::add_extension(std::shared_ptr<peer_plugin> ext)
{ {
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
boost::shared_ptr<peer_connection> pc = native_handle(); boost::shared_ptr<peer_connection> pc = native_handle();
@ -299,7 +299,7 @@ bool bt_peer_connection_handle::supports_encryption() const
#endif #endif
} }
void bt_peer_connection_handle::switch_send_crypto(boost::shared_ptr<crypto_plugin> crypto) void bt_peer_connection_handle::switch_send_crypto(std::shared_ptr<crypto_plugin> crypto)
{ {
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
boost::shared_ptr<bt_peer_connection> pc = native_handle(); boost::shared_ptr<bt_peer_connection> pc = native_handle();
@ -310,7 +310,7 @@ void bt_peer_connection_handle::switch_send_crypto(boost::shared_ptr<crypto_plug
#endif #endif
} }
void bt_peer_connection_handle::switch_recv_crypto(boost::shared_ptr<crypto_plugin> crypto) void bt_peer_connection_handle::switch_recv_crypto(std::shared_ptr<crypto_plugin> crypto)
{ {
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
boost::shared_ptr<bt_peer_connection> pc = native_handle(); boost::shared_ptr<bt_peer_connection> pc = native_handle();

View File

@ -325,16 +325,16 @@ namespace libtorrent
namespace namespace
{ {
std::vector<boost::shared_ptr<plugin>> default_plugins( std::vector<std::shared_ptr<plugin>> default_plugins(
bool empty = false) bool empty = false)
{ {
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
if (empty) return {}; if (empty) return {};
using wrapper = session_impl::session_plugin_wrapper; using wrapper = session_impl::session_plugin_wrapper;
return { return {
boost::make_shared<wrapper>(create_ut_pex_plugin), std::make_shared<wrapper>(create_ut_pex_plugin),
boost::make_shared<wrapper>(create_ut_metadata_plugin), std::make_shared<wrapper>(create_ut_metadata_plugin),
boost::make_shared<wrapper>(create_smart_ban_plugin) std::make_shared<wrapper>(create_smart_ban_plugin)
}; };
#else #else
TORRENT_UNUSED(empty); TORRENT_UNUSED(empty);
@ -411,7 +411,7 @@ namespace libtorrent
{} {}
session_params::session_params(settings_pack sp session_params::session_params(settings_pack sp
, std::vector<boost::shared_ptr<plugin>> exts) , std::vector<std::shared_ptr<plugin>> exts)
: settings(std::move(sp)) : settings(std::move(sp))
, extensions(std::move(exts)) , extensions(std::move(exts))
#ifndef TORRENT_DISABLE_DHT #ifndef TORRENT_DISABLE_DHT

View File

@ -601,7 +601,7 @@ namespace libtorrent
} }
#endif // TORRENT_NO_DEPRECATE #endif // TORRENT_NO_DEPRECATE
void session_handle::add_extension(std::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> ext) void session_handle::add_extension(std::function<std::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> ext)
{ {
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
async_call(&session_impl::add_extension, ext); async_call(&session_impl::add_extension, ext);
@ -610,7 +610,7 @@ namespace libtorrent
#endif #endif
} }
void session_handle::add_extension(boost::shared_ptr<plugin> ext) void session_handle::add_extension(std::shared_ptr<plugin> ext)
{ {
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
async_call(&session_impl::add_ses_extension, ext); async_call(&session_impl::add_ses_extension, ext);

View File

@ -776,10 +776,10 @@ namespace aux {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
TORRENT_ASSERT(ext); TORRENT_ASSERT(ext);
add_ses_extension(boost::make_shared<session_plugin_wrapper>(ext)); add_ses_extension(std::make_shared<session_plugin_wrapper>(ext));
} }
void session_impl::add_ses_extension(boost::shared_ptr<plugin> ext) void session_impl::add_ses_extension(std::shared_ptr<plugin> ext)
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
TORRENT_ASSERT_VAL(ext, ext); TORRENT_ASSERT_VAL(ext, ext);
@ -796,7 +796,8 @@ namespace aux {
m_ses_extensions[plugins_dht_request_idx].push_back(ext); m_ses_extensions[plugins_dht_request_idx].push_back(ext);
if (features & plugin::alert_feature) if (features & plugin::alert_feature)
m_alerts.add_extension(ext); m_alerts.add_extension(ext);
ext->added(session_handle(this)); session_handle h(this);
ext->added(h);
} }
#endif // TORRENT_DISABLE_EXTENSIONS #endif // TORRENT_DISABLE_EXTENSIONS
@ -3739,11 +3740,11 @@ namespace aux {
struct last_optimistic_unchoke_cmp struct last_optimistic_unchoke_cmp
{ {
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
explicit last_optimistic_unchoke_cmp(std::vector<boost::shared_ptr<plugin>>& ps) explicit last_optimistic_unchoke_cmp(std::vector<std::shared_ptr<plugin>>& ps)
: plugins(ps) : plugins(ps)
{} {}
std::vector<boost::shared_ptr<plugin>>& plugins; std::vector<std::shared_ptr<plugin>>& plugins;
#endif #endif
uint64_t get_ext_priority(opt_unchoke_candidate const& peer) const uint64_t get_ext_priority(opt_unchoke_candidate const& peer) const
@ -4627,7 +4628,7 @@ namespace aux {
{ {
for (auto& e : m_ses_extensions[plugins_all_idx]) for (auto& e : m_ses_extensions[plugins_all_idx])
{ {
boost::shared_ptr<torrent_plugin> tp(e->new_torrent( std::shared_ptr<torrent_plugin> tp(e->new_torrent(
torrent_ptr->get_handle(), userdata)); torrent_ptr->get_handle(), userdata));
if (tp) torrent_ptr->add_extension(std::move(tp)); if (tp) torrent_ptr->add_extension(std::move(tp));
} }
@ -4676,7 +4677,7 @@ namespace aux {
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
for (auto& ext : params.extensions) for (auto& ext : params.extensions)
{ {
boost::shared_ptr<torrent_plugin> tp(ext(handle, params.userdata)); std::shared_ptr<torrent_plugin> tp(ext(handle, params.userdata));
if (tp) torrent_ptr->add_extension(std::move(tp)); if (tp) torrent_ptr->add_extension(std::move(tp));
} }

View File

@ -74,7 +74,7 @@ namespace
struct smart_ban_plugin final struct smart_ban_plugin final
: torrent_plugin : torrent_plugin
, boost::enable_shared_from_this<smart_ban_plugin> , std::enable_shared_from_this<smart_ban_plugin>
{ {
explicit smart_ban_plugin(torrent& t) explicit smart_ban_plugin(torrent& t)
: m_torrent(t) : m_torrent(t)
@ -327,14 +327,11 @@ namespace
namespace libtorrent namespace libtorrent
{ {
std::shared_ptr<torrent_plugin> create_smart_ban_plugin(torrent_handle const& th, void*)
boost::shared_ptr<torrent_plugin> create_smart_ban_plugin(torrent_handle const& th, void*)
{ {
torrent* t = th.native_handle().get(); torrent* t = th.native_handle().get();
return boost::shared_ptr<torrent_plugin>(new smart_ban_plugin(*t)); return std::make_shared<smart_ban_plugin>(*t);
} }
} }
#endif #endif

View File

@ -1445,29 +1445,29 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
void torrent::add_extension(boost::shared_ptr<torrent_plugin> ext) void torrent::add_extension(std::shared_ptr<torrent_plugin> ext)
{ {
m_extensions.push_back(ext); m_extensions.push_back(ext);
} }
void torrent::remove_extension(boost::shared_ptr<torrent_plugin> ext) void torrent::remove_extension(std::shared_ptr<torrent_plugin> ext)
{ {
auto i = std::find(m_extensions.begin(), m_extensions.end(), ext); auto i = std::find(m_extensions.begin(), m_extensions.end(), ext);
if (i == m_extensions.end()) return; if (i == m_extensions.end()) return;
m_extensions.erase(i); m_extensions.erase(i);
} }
void torrent::add_extension_fun(std::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext void torrent::add_extension_fun(std::function<std::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
, void* userdata) , void* userdata)
{ {
boost::shared_ptr<torrent_plugin> tp(ext(get_handle(), userdata)); std::shared_ptr<torrent_plugin> tp(ext(get_handle(), userdata));
if (!tp) return; if (!tp) return;
add_extension(std::move(tp)); add_extension(std::move(tp));
for (auto p : m_connections) for (auto p : m_connections)
{ {
boost::shared_ptr<peer_plugin> pp(tp->new_connection(peer_connection_handle(p->self()))); std::shared_ptr<peer_plugin> pp(tp->new_connection(peer_connection_handle(p->self())));
if (pp) p->add_extension(std::move(pp)); if (pp) p->add_extension(std::move(pp));
} }
@ -6260,7 +6260,7 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
for (auto& ext : m_extensions) for (auto& ext : m_extensions)
{ {
boost::shared_ptr<peer_plugin> std::shared_ptr<peer_plugin>
pp(ext->new_connection(peer_connection_handle(c->self()))); pp(ext->new_connection(peer_connection_handle(c->self())));
if (pp) c->add_extension(pp); if (pp) c->add_extension(pp);
} }
@ -6960,7 +6960,7 @@ namespace libtorrent
for (auto& ext : m_extensions) for (auto& ext : m_extensions)
{ {
TORRENT_TRY { TORRENT_TRY {
boost::shared_ptr<peer_plugin> pp(ext->new_connection( std::shared_ptr<peer_plugin> pp(ext->new_connection(
peer_connection_handle(c->self()))); peer_connection_handle(c->self())));
if (pp) c->add_extension(pp); if (pp) c->add_extension(pp);
} TORRENT_CATCH (std::exception&) {} } TORRENT_CATCH (std::exception&) {}
@ -7254,7 +7254,7 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
for (auto& ext : m_extensions) for (auto& ext : m_extensions)
{ {
boost::shared_ptr<peer_plugin> pp(ext->new_connection( std::shared_ptr<peer_plugin> pp(ext->new_connection(
peer_connection_handle(p->self()))); peer_connection_handle(p->self())));
if (pp) p->add_extension(pp); if (pp) p->add_extension(pp);
} }

View File

@ -206,7 +206,7 @@ namespace libtorrent
} }
void torrent_handle::add_extension( void torrent_handle::add_extension(
std::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext std::function<std::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
, void* userdata) , void* userdata)
{ {
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS

View File

@ -57,6 +57,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/random.hpp" #include "libtorrent/random.hpp"
#include "libtorrent/io.hpp" #include "libtorrent/io.hpp"
#include "libtorrent/performance_counters.hpp" // for counters #include "libtorrent/performance_counters.hpp" // for counters
#include "libtorrent/aux_/time.hpp"
using namespace std::placeholders; using namespace std::placeholders;
@ -125,7 +126,7 @@ namespace libtorrent { namespace
metadata(); metadata();
} }
boost::shared_ptr<peer_plugin> new_connection( std::shared_ptr<peer_plugin> new_connection(
peer_connection_handle const& pc) override; peer_connection_handle const& pc) override;
int get_metadata_size() const int get_metadata_size() const
@ -188,7 +189,7 @@ namespace libtorrent { namespace
metadata_piece(): num_requests(0), last_request(min_time()) {} metadata_piece(): num_requests(0), last_request(min_time()) {}
int num_requests; int num_requests;
time_point last_request; time_point last_request;
boost::weak_ptr<ut_metadata_peer_plugin> source; std::weak_ptr<ut_metadata_peer_plugin> source;
bool operator<(metadata_piece const& rhs) const bool operator<(metadata_piece const& rhs) const
{ return num_requests < rhs.num_requests; } { return num_requests < rhs.num_requests; }
}; };
@ -204,7 +205,7 @@ namespace libtorrent { namespace
struct ut_metadata_peer_plugin final struct ut_metadata_peer_plugin final
: peer_plugin, boost::enable_shared_from_this<ut_metadata_peer_plugin> : peer_plugin, std::enable_shared_from_this<ut_metadata_peer_plugin>
{ {
friend struct ut_metadata_plugin; friend struct ut_metadata_plugin;
@ -496,14 +497,14 @@ namespace libtorrent { namespace
ut_metadata_peer_plugin& operator=(ut_metadata_peer_plugin const&); ut_metadata_peer_plugin& operator=(ut_metadata_peer_plugin const&);
}; };
boost::shared_ptr<peer_plugin> ut_metadata_plugin::new_connection( std::shared_ptr<peer_plugin> ut_metadata_plugin::new_connection(
peer_connection_handle const& pc) peer_connection_handle const& pc)
{ {
if (pc.type() != peer_connection::bittorrent_connection) if (pc.type() != peer_connection::bittorrent_connection)
return boost::shared_ptr<peer_plugin>(); return std::shared_ptr<peer_plugin>();
bt_peer_connection* c = static_cast<bt_peer_connection*>(pc.native_handle().get()); bt_peer_connection* c = static_cast<bt_peer_connection*>(pc.native_handle().get());
return boost::shared_ptr<peer_plugin>(new ut_metadata_peer_plugin(m_torrent, *c, *this)); return std::make_shared<ut_metadata_peer_plugin>(m_torrent, *c, *this);
} }
// has_metadata is false if the peer making the request has not announced // has_metadata is false if the peer making the request has not announced
@ -624,7 +625,7 @@ namespace libtorrent { namespace
for (int i = 0; i < int(m_requested_metadata.size()); ++i) for (int i = 0; i < int(m_requested_metadata.size()); ++i)
{ {
m_requested_metadata[i].num_requests = 0; m_requested_metadata[i].num_requests = 0;
boost::shared_ptr<ut_metadata_peer_plugin> peer std::shared_ptr<ut_metadata_peer_plugin> peer
= m_requested_metadata[i].source.lock(); = m_requested_metadata[i].source.lock();
if (!peer) continue; if (!peer) continue;
@ -650,15 +651,13 @@ namespace libtorrent { namespace
namespace libtorrent namespace libtorrent
{ {
std::shared_ptr<torrent_plugin> create_ut_metadata_plugin(torrent_handle const& th, void*)
boost::shared_ptr<torrent_plugin> create_ut_metadata_plugin(torrent_handle const& th, void*)
{ {
torrent* t = th.native_handle().get(); torrent* t = th.native_handle().get();
// don't add this extension if the torrent is private // don't add this extension if the torrent is private
if (t->valid_metadata() && t->torrent_file().priv()) return boost::shared_ptr<torrent_plugin>(); if (t->valid_metadata() && t->torrent_file().priv()) return std::shared_ptr<torrent_plugin>();
return boost::shared_ptr<torrent_plugin>(new ut_metadata_plugin(*t)); return std::make_shared<ut_metadata_plugin>(*t);
} }
} }
#endif #endif

View File

@ -42,6 +42,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket_type.hpp" // for is_utp #include "libtorrent/socket_type.hpp" // for is_utp
#include "libtorrent/performance_counters.hpp" // for counters #include "libtorrent/performance_counters.hpp" // for counters
#include "libtorrent/extensions/ut_pex.hpp" #include "libtorrent/extensions/ut_pex.hpp"
#include "libtorrent/aux_/time.hpp"
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
@ -79,7 +80,7 @@ namespace libtorrent { namespace
, m_last_msg(min_time()) , m_last_msg(min_time())
, m_peers_in_message(0) {} , m_peers_in_message(0) {}
boost::shared_ptr<peer_plugin> new_connection( std::shared_ptr<peer_plugin> new_connection(
peer_connection_handle const& pc) override; peer_connection_handle const& pc) override;
std::vector<char>& get_ut_pex_msg() std::vector<char>& get_ut_pex_msg()
@ -633,13 +634,13 @@ namespace libtorrent { namespace
ut_pex_peer_plugin& operator=(ut_pex_peer_plugin const&); ut_pex_peer_plugin& operator=(ut_pex_peer_plugin const&);
}; };
boost::shared_ptr<peer_plugin> ut_pex_plugin::new_connection(peer_connection_handle const& pc) std::shared_ptr<peer_plugin> ut_pex_plugin::new_connection(peer_connection_handle const& pc)
{ {
if (pc.type() != peer_connection::bittorrent_connection) if (pc.type() != peer_connection::bittorrent_connection)
return boost::shared_ptr<peer_plugin>(); return std::shared_ptr<peer_plugin>();
bt_peer_connection* c = static_cast<bt_peer_connection*>(pc.native_handle().get()); bt_peer_connection* c = static_cast<bt_peer_connection*>(pc.native_handle().get());
auto p = boost::make_shared<ut_pex_peer_plugin>(m_torrent, *c, *this); auto p = std::make_shared<ut_pex_peer_plugin>(m_torrent, *c, *this);
c->set_ut_pex(p); c->set_ut_pex(p);
return p; return p;
} }
@ -647,15 +648,15 @@ namespace libtorrent { namespace
namespace libtorrent namespace libtorrent
{ {
boost::shared_ptr<torrent_plugin> create_ut_pex_plugin(torrent_handle const& th, void*) std::shared_ptr<torrent_plugin> create_ut_pex_plugin(torrent_handle const& th, void*)
{ {
torrent* t = th.native_handle().get(); torrent* t = th.native_handle().get();
if (t->torrent_file().priv() || (t->torrent_file().is_i2p() if (t->torrent_file().priv() || (t->torrent_file().is_i2p()
&& !t->settings().get_bool(settings_pack::allow_i2p_mixed))) && !t->settings().get_bool(settings_pack::allow_i2p_mixed)))
{ {
return boost::shared_ptr<torrent_plugin>(); return std::shared_ptr<torrent_plugin>();
} }
return boost::make_shared<ut_pex_plugin>(*t); return std::make_shared<ut_pex_plugin>(*t);
} }
} }

View File

@ -38,9 +38,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "setup_transfer.hpp" #include "setup_transfer.hpp"
#include <functional> #include <functional>
#include <boost/make_shared.hpp>
#include <boost/shared_ptr.hpp>
#include <thread> #include <thread>
namespace lt = libtorrent; namespace lt = libtorrent;
@ -172,9 +169,9 @@ TORRENT_TEST(extensions)
memset(plugin_alerts, 0, sizeof(plugin_alerts)); memset(plugin_alerts, 0, sizeof(plugin_alerts));
alert_manager mgr(100, 0xffffffff); alert_manager mgr(100, 0xffffffff);
mgr.add_extension(boost::make_shared<test_plugin>(0)); mgr.add_extension(std::make_shared<test_plugin>(0));
mgr.add_extension(boost::make_shared<test_plugin>(1)); mgr.add_extension(std::make_shared<test_plugin>(1));
mgr.add_extension(boost::make_shared<test_plugin>(2)); mgr.add_extension(std::make_shared<test_plugin>(2));
for (int i = 0; i < 53; ++i) for (int i = 0; i < 53; ++i)
mgr.emplace_alert<torrent_added_alert>(torrent_handle()); mgr.emplace_alert<torrent_added_alert>(torrent_handle());

View File

@ -101,7 +101,7 @@ TORRENT_TEST(direct_dht_request)
sp.set_str(settings_pack::listen_interfaces, "127.0.0.1:45434"); sp.set_str(settings_pack::listen_interfaces, "127.0.0.1:45434");
lt::session requester(sp, 0); lt::session requester(sp, 0);
responder.add_extension(boost::static_pointer_cast<plugin>(boost::make_shared<test_plugin>())); responder.add_extension(std::make_shared<test_plugin>());
// successful request // successful request

View File

@ -58,7 +58,7 @@ namespace
struct custom_plugin : plugin struct custom_plugin : plugin
{ {
void added(session_handle h) override void added(session_handle const& h) override
{ {
TORRENT_UNUSED(h); TORRENT_UNUSED(h);
g_plugin_added_invoked = true; g_plugin_added_invoked = true;
@ -76,7 +76,7 @@ TORRENT_TEST(default_plugins)
TEST_EQUAL(int(p1.extensions.size()), 0); TEST_EQUAL(int(p1.extensions.size()), 0);
#endif #endif
std::vector<boost::shared_ptr<plugin>> exts; std::vector<std::shared_ptr<plugin>> exts;
session_params p2(settings_pack(), exts); session_params p2(settings_pack(), exts);
TEST_EQUAL(int(p2.extensions.size()), 0); TEST_EQUAL(int(p2.extensions.size()), 0);
} }
@ -100,7 +100,7 @@ TORRENT_TEST(add_plugin)
{ {
g_plugin_added_invoked = false; g_plugin_added_invoked = false;
session_params params; session_params params;
params.extensions.push_back(boost::make_shared<custom_plugin>()); params.extensions.push_back(std::make_shared<custom_plugin>());
lt::session ses(params); lt::session ses(params);
TEST_EQUAL(g_plugin_added_invoked, true); TEST_EQUAL(g_plugin_added_invoked, true);

View File

@ -314,11 +314,11 @@ struct plugin_creator
{ {
explicit plugin_creator(int& c) : m_called(c) {} explicit plugin_creator(int& c) : m_called(c) {}
boost::shared_ptr<libtorrent::torrent_plugin> std::shared_ptr<libtorrent::torrent_plugin>
operator()(torrent_handle const&, void*) operator()(torrent_handle const&, void*)
{ {
++m_called; ++m_called;
return boost::make_shared<test_plugin>(); return std::make_shared<test_plugin>();
} }
int& m_called; int& m_called;