diff --git a/include/libtorrent/add_torrent_params.hpp b/include/libtorrent/add_torrent_params.hpp index e47ff6620..27cd0467b 100644 --- a/include/libtorrent/add_torrent_params.hpp +++ b/include/libtorrent/add_torrent_params.hpp @@ -44,8 +44,8 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { class torrent_info; - class torrent; struct torrent_plugin; + struct torrent_handle; // The add_torrent_params is a parameter pack for adding torrents to a // session. The key fields when adding a torrent are: @@ -331,7 +331,7 @@ namespace libtorrent // 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 // created. - std::vector(torrent*, void*)> > + std::vector(torrent_handle const&, void*)> > extensions; // the default tracker id to be used when announcing to trackers. By diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 1c50a9887..a55e6208c 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -62,7 +62,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/session.hpp" // for user_load_function_t #include "libtorrent/ip_voter.hpp" -#include "libtorrent/torrent_handle.hpp" #include "libtorrent/entry.hpp" #include "libtorrent/socket.hpp" #include "libtorrent/peer_id.hpp" @@ -111,6 +110,7 @@ namespace libtorrent class torrent; class alert; struct cache_info; + struct torrent_handle; namespace dht { @@ -193,7 +193,7 @@ namespace libtorrent #ifndef TORRENT_DISABLE_EXTENSIONS void add_extension(boost::function( - torrent*, void*)> ext); + torrent_handle const&, void*)> ext); void add_ses_extension(boost::shared_ptr ext); #endif #if TORRENT_USE_ASSERTS diff --git a/include/libtorrent/extensions.hpp b/include/libtorrent/extensions.hpp index 9fc02b6f5..275540241 100644 --- a/include/libtorrent/extensions.hpp +++ b/include/libtorrent/extensions.hpp @@ -96,10 +96,9 @@ POSSIBILITY OF SUCH DAMAGE. // // The signature of the function is:: // -// boost::shared_ptr (*)(torrent*, void*); +// boost::shared_ptr (*)(torrent_handle const&, void*); // -// The first argument is the internal torrent object, 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()``. // // The function should return a ``boost::shared_ptr`` which @@ -177,12 +176,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/socket.hpp" #include "libtorrent/sha1_hash.hpp" // for sha1_hash #include "libtorrent/error_code.hpp" -#include "libtorrent/peer_connection_handle.hpp" +#include "libtorrent/session_handle.hpp" namespace libtorrent { - namespace aux { struct session_impl; } - struct peer_plugin; struct peer_request; class entry; @@ -191,9 +188,9 @@ namespace libtorrent struct bitfield; class alert; struct torrent_plugin; - class torrent; - struct torrent_peer; struct add_torrent_params; + struct peer_connection_handle; + struct torrent_handle; // 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, @@ -211,18 +208,18 @@ namespace libtorrent // If the plugin returns a torrent_plugin instance, it will be added // to the new torrent. Otherwise, return an empty shared_ptr to a // torrent_plugin (the default). - virtual boost::shared_ptr new_torrent(torrent*, void*) + virtual boost::shared_ptr new_torrent(torrent_handle const&, void*) { return boost::shared_ptr(); } // called when plugin is added to a session - virtual void added(aux::session_impl*) {} + virtual void added(session_handle) {} // called when an alert is posted alerts that are filtered are not posted virtual void on_alert(alert const*) {} // return true if the add_torrent_params should be added virtual bool on_unknown_torrent(sha1_hash const& /* info_hash */ - , peer_connection_handle /* pc */, add_torrent_params& /* p */) + , peer_connection_handle const& /* pc */, add_torrent_params& /* p */) { return false; } // called once per second @@ -234,7 +231,7 @@ namespace libtorrent // optimistically unchoked. // if the plugin returns true then the ordering provided will be // used and no other plugin will be allowed to change it. - virtual bool on_optimistic_unchoke(std::vector& /* peers */) + virtual bool on_optimistic_unchoke(std::vector& /* peers */) { return false; } // called when saving settings state @@ -267,7 +264,7 @@ namespace libtorrent // to it, use ``weak_ptr``. // // If this function throws an exception, the connection will be closed. - virtual boost::shared_ptr new_connection(peer_connection_handle) + virtual boost::shared_ptr new_connection(peer_connection_handle const&) { return boost::shared_ptr(); } // These hooks are called when a piece passes the hash check or fails the hash diff --git a/include/libtorrent/extensions/lt_trackers.hpp b/include/libtorrent/extensions/lt_trackers.hpp index 4f0dec652..963fff8d8 100644 --- a/include/libtorrent/extensions/lt_trackers.hpp +++ b/include/libtorrent/extensions/lt_trackers.hpp @@ -35,22 +35,23 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS +#include "libtorrent/config.hpp" + #include "libtorrent/aux_/disable_warnings_push.hpp" #include -#include "libtorrent/config.hpp" #include "libtorrent/aux_/disable_warnings_pop.hpp" namespace libtorrent { struct torrent_plugin; - class torrent; + struct torrent_handle; // constructor function for the trackers exchange extension. This can // either be passed in the add_torrent_params::extensions field, or // via torrent_handle::add_extension(). - boost::shared_ptr TORRENT_EXPORT create_lt_trackers_plugin(torrent*, void*); + boost::shared_ptr TORRENT_EXPORT create_lt_trackers_plugin(torrent_handle const&, void*); } #endif // TORRENT_DISABLE_EXTENSIONS diff --git a/include/libtorrent/extensions/metadata_transfer.hpp b/include/libtorrent/extensions/metadata_transfer.hpp index f06185888..72681b3ab 100644 --- a/include/libtorrent/extensions/metadata_transfer.hpp +++ b/include/libtorrent/extensions/metadata_transfer.hpp @@ -48,7 +48,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { struct torrent_plugin; - class torrent; + struct torrent_handle; #ifndef TORRENT_NO_DEPRECATE // constructor function for the metadata transfer extension. This @@ -58,7 +58,7 @@ namespace libtorrent // via torrent_handle::add_extension(). TORRENT_DEPRECATED TORRENT_EXPORT boost::shared_ptr - create_metadata_plugin(torrent*, void*); + create_metadata_plugin(torrent_handle const&, void*); #endif } #endif diff --git a/include/libtorrent/extensions/smart_ban.hpp b/include/libtorrent/extensions/smart_ban.hpp index a21b99233..a2a5e35c9 100644 --- a/include/libtorrent/extensions/smart_ban.hpp +++ b/include/libtorrent/extensions/smart_ban.hpp @@ -45,7 +45,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { struct torrent_plugin; - class torrent; + struct torrent_handle; // constructor function for the smart ban extension. The extension keeps // track of the data peers have sent us for failing pieces and once the @@ -53,7 +53,7 @@ namespace libtorrent // out to have sent corrupt data. // This function can either be passed in the add_torrent_params::extensions // field, or via torrent_handle::add_extension(). - TORRENT_EXPORT boost::shared_ptr create_smart_ban_plugin(torrent*, void*); + TORRENT_EXPORT boost::shared_ptr create_smart_ban_plugin(torrent_handle const&, void*); } #endif // TORRENT_DISABLE_EXTENSIONS diff --git a/include/libtorrent/extensions/ut_metadata.hpp b/include/libtorrent/extensions/ut_metadata.hpp index e74d9a10e..7080ee76a 100644 --- a/include/libtorrent/extensions/ut_metadata.hpp +++ b/include/libtorrent/extensions/ut_metadata.hpp @@ -35,17 +35,18 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS +#include "libtorrent/config.hpp" + #include "libtorrent/aux_/disable_warnings_push.hpp" #include -#include "libtorrent/config.hpp" #include "libtorrent/aux_/disable_warnings_pop.hpp" namespace libtorrent { struct torrent_plugin; - class torrent; + struct torrent_handle; // constructor function for the ut_metadata extension. The ut_metadata // extension allows peers to request the .torrent file (or more @@ -56,7 +57,7 @@ namespace libtorrent // // This can either be passed in the add_torrent_params::extensions field, or // via torrent_handle::add_extension(). - TORRENT_EXPORT boost::shared_ptr create_ut_metadata_plugin(torrent*, void*); + TORRENT_EXPORT boost::shared_ptr create_ut_metadata_plugin(torrent_handle const&, void*); } #endif // TORRENT_DISABLE_EXTENSIONS diff --git a/include/libtorrent/extensions/ut_pex.hpp b/include/libtorrent/extensions/ut_pex.hpp index 64b5941e4..00da8c1f9 100644 --- a/include/libtorrent/extensions/ut_pex.hpp +++ b/include/libtorrent/extensions/ut_pex.hpp @@ -49,7 +49,7 @@ namespace libtorrent { struct torrent_plugin; struct peer_plugin; - class torrent; + struct torrent_handle; // constructor function for the ut_pex extension. The ut_pex // extension allows peers to gossip about their connections, allowing @@ -59,7 +59,7 @@ namespace libtorrent // // This can either be passed in the add_torrent_params::extensions field, or // via torrent_handle::add_extension(). - TORRENT_EXPORT boost::shared_ptr create_ut_pex_plugin(torrent*, void*); + TORRENT_EXPORT boost::shared_ptr create_ut_pex_plugin(torrent_handle const&, void*); bool was_introduced_by(peer_plugin const* pp, tcp::endpoint const& ep); } diff --git a/include/libtorrent/session_handle.hpp b/include/libtorrent/session_handle.hpp index a0c848405..e2bbd9376 100644 --- a/include/libtorrent/session_handle.hpp +++ b/include/libtorrent/session_handle.hpp @@ -437,7 +437,7 @@ namespace libtorrent #endif // This function adds an extension to this session. The argument is a - // function object that is called with a ``torrent*`` and which should + // function object that is called with a ``torrent_handle`` and which should // return a ``boost::shared_ptr``. To write custom // plugins, see `libtorrent plugins`_. For the typical bittorrent client // all of these extensions should be added. The main plugins implemented @@ -482,7 +482,7 @@ namespace libtorrent // // .. _`libtorrent plugins`: libtorrent_plugins.html void add_extension(boost::function( - torrent*, void*)> ext); + torrent_handle const&, void*)> ext); void add_extension(boost::shared_ptr ext); #ifndef TORRENT_NO_DEPRECATE diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index e5096b65b..bdb1a625b 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -301,7 +301,7 @@ namespace libtorrent #ifndef TORRENT_DISABLE_EXTENSIONS void add_extension(boost::shared_ptr); void remove_extension(boost::shared_ptr); - void add_extension(boost::function(torrent*, void*)> const& ext + void add_extension(boost::function(torrent_handle const&, void*)> const& ext , void* userdata); void notify_extension_add_peer(tcp::endpoint const& ip, int src, int flags); #endif diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 0b5cdb3c5..84d27df6a 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -501,7 +501,7 @@ namespace libtorrent // pointer. The function is expected to return a shared pointer to // a torrent_plugin instance. void add_extension( - boost::function(torrent*, void*)> const& ext + boost::function(torrent_handle const&, void*)> const& ext , void* userdata = 0); // ``set_metadata`` expects the *info* section of metadata. i.e. The diff --git a/src/lt_trackers.cpp b/src/lt_trackers.cpp index fd135b240..c333173f3 100644 --- a/src/lt_trackers.cpp +++ b/src/lt_trackers.cpp @@ -46,6 +46,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_connection.hpp" #include "libtorrent/bt_peer_connection.hpp" +#include "libtorrent/peer_connection_handle.hpp" #include "libtorrent/hasher.hpp" #include "libtorrent/bencode.hpp" #include "libtorrent/torrent.hpp" @@ -54,6 +55,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/alert_types.hpp" #include "libtorrent/io.hpp" #include "libtorrent/parse_url.hpp" +#include "libtorrent/torrent_handle.hpp" namespace libtorrent { namespace { @@ -79,7 +81,7 @@ namespace libtorrent { namespace } virtual boost::shared_ptr new_connection( - peer_connection_handle pc); + peer_connection_handle const& pc); virtual void tick() { @@ -360,7 +362,7 @@ namespace libtorrent { namespace }; boost::shared_ptr lt_tracker_plugin::new_connection( - peer_connection_handle pc) + peer_connection_handle const& pc) { if (pc.type() != peer_connection::bittorrent_connection) return boost::shared_ptr(); @@ -377,8 +379,9 @@ namespace libtorrent { namespace namespace libtorrent { - boost::shared_ptr TORRENT_EXPORT create_lt_trackers_plugin(torrent* t, void*) + boost::shared_ptr TORRENT_EXPORT create_lt_trackers_plugin(torrent_handle const& th, void*) { + torrent* t = th.native_handle().get(); if (t->valid_metadata() && t->torrent_file().priv()) return boost::shared_ptr(); return boost::shared_ptr(new lt_tracker_plugin(*t)); } diff --git a/src/metadata_transfer.cpp b/src/metadata_transfer.cpp index c36096c8f..fd59ee273 100644 --- a/src/metadata_transfer.cpp +++ b/src/metadata_transfer.cpp @@ -47,9 +47,11 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_connection.hpp" #include "libtorrent/bt_peer_connection.hpp" +#include "libtorrent/peer_connection_handle.hpp" #include "libtorrent/hasher.hpp" #include "libtorrent/bencode.hpp" #include "libtorrent/torrent.hpp" +#include "libtorrent/torrent_handle.hpp" #include "libtorrent/extensions.hpp" #include "libtorrent/extensions/metadata_transfer.hpp" #include "libtorrent/alert_types.hpp" @@ -128,7 +130,7 @@ namespace libtorrent { namespace } virtual boost::shared_ptr new_connection( - peer_connection_handle pc); + peer_connection_handle const& pc); buffer::const_interval metadata() const { @@ -543,7 +545,7 @@ namespace libtorrent { namespace }; boost::shared_ptr metadata_plugin::new_connection( - peer_connection_handle pc) + peer_connection_handle const& pc) { if (pc.type() != peer_connection::bittorrent_connection) return boost::shared_ptr(); @@ -590,8 +592,9 @@ namespace libtorrent { namespace namespace libtorrent { - boost::shared_ptr create_metadata_plugin(torrent* t, void*) + boost::shared_ptr create_metadata_plugin(torrent_handle const& th, void*) { + torrent* t = th.native_handle().get(); // don't add this extension if the torrent is private if (t->valid_metadata() && t->torrent_file().priv()) return boost::shared_ptr(); return boost::shared_ptr(new metadata_plugin(*t)); diff --git a/src/session_handle.cpp b/src/session_handle.cpp index 7b81e095a..b06ff13a5 100644 --- a/src/session_handle.cpp +++ b/src/session_handle.cpp @@ -414,7 +414,7 @@ namespace libtorrent } #endif // TORRENT_NO_DEPRECATE - void session_handle::add_extension(boost::function(torrent*, void*)> ext) + void session_handle::add_extension(boost::function(torrent_handle const&, void*)> ext) { #ifndef TORRENT_DISABLE_EXTENSIONS TORRENT_ASYNC_CALL1(add_extension, ext); diff --git a/src/session_impl.cpp b/src/session_impl.cpp index ebf84634f..75cd01ca7 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -75,6 +75,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/invariant_check.hpp" #include "libtorrent/file.hpp" #include "libtorrent/bt_peer_connection.hpp" +#include "libtorrent/peer_connection_handle.hpp" #include "libtorrent/ip_filter.hpp" #include "libtorrent/socket.hpp" #include "libtorrent/aux_/session_impl.hpp" @@ -95,6 +96,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/magnet_uri.hpp" #include "libtorrent/aux_/session_settings.hpp" #include "libtorrent/torrent_peer.hpp" +#include "libtorrent/torrent_handle.hpp" #include "libtorrent/choker.hpp" #include "libtorrent/error.hpp" @@ -867,13 +869,13 @@ namespace aux { #ifndef TORRENT_DISABLE_EXTENSIONS - typedef boost::function(torrent*, void*)> ext_function_t; + typedef boost::function(torrent_handle const&, void*)> ext_function_t; struct session_plugin_wrapper : plugin { session_plugin_wrapper(ext_function_t const& f) : m_f(f) {} - virtual boost::shared_ptr new_torrent(torrent* t, void* user) + virtual boost::shared_ptr new_torrent(torrent_handle const& t, void* user) { return m_f(t, user); } ext_function_t m_f; }; @@ -895,7 +897,7 @@ namespace aux { m_ses_extensions.push_back(ext); m_alerts.add_extension(ext); - ext->added(this); + ext->added(session_handle(this)); } #endif // TORRENT_DISABLE_EXTENSIONS @@ -3638,12 +3640,24 @@ retry: } } + namespace { + struct last_optimistic_unchoke_cmp + { + bool operator()(peer_connection_handle const& l + , peer_connection_handle const& r) + { + return l.native_handle()->peer_info_struct()->last_optimistically_unchoked + < r.native_handle()->peer_info_struct()->last_optimistically_unchoked; + } + }; + } + void session_impl::recalculate_optimistic_unchoke_slots() { TORRENT_ASSERT(is_single_thread()); if (m_stats_counters[counters::num_unchoke_slots] == 0) return; - std::vector opt_unchoke; + std::vector opt_unchoke; for (connection_map::iterator i = m_connections.begin() , end(m_connections.end()); i != end; ++i) @@ -3660,7 +3674,7 @@ retry: if (pi->optimistically_unchoked) { TORRENT_ASSERT(!p->is_choked()); - opt_unchoke.push_back(pi); + opt_unchoke.push_back(peer_connection_handle(*i)); } if (!p->is_connecting() @@ -3671,7 +3685,7 @@ retry: && !p->ignore_unchoke_slots() && t->valid_metadata()) { - opt_unchoke.push_back(pi); + opt_unchoke.push_back(peer_connection_handle(*i)); } } @@ -3683,9 +3697,7 @@ retry: // sort all candidates based on when they were last optimistically // unchoked. - std::sort(opt_unchoke.begin(), opt_unchoke.end() - , boost::bind(&torrent_peer::last_optimistically_unchoked, _1) - < boost::bind(&torrent_peer::last_optimistically_unchoked, _2)); + std::sort(opt_unchoke.begin(), opt_unchoke.end(), last_optimistic_unchoke_cmp()); #ifndef TORRENT_DISABLE_EXTENSIONS for (ses_extension_list_t::iterator i = m_ses_extensions.begin() @@ -3702,10 +3714,10 @@ retry: // unchoke the first num_opt_unchoke peers in the candidate set // and make sure that the others are choked - for (std::vector::iterator i = opt_unchoke.begin() + for (std::vector::iterator i = opt_unchoke.begin() , end(opt_unchoke.end()); i != end; ++i) { - torrent_peer* pi = *i; + torrent_peer* pi = i->native_handle()->peer_info_struct(); if (num_opt_unchoke > 0) { --num_opt_unchoke; @@ -4433,7 +4445,7 @@ retry: for (ses_extension_list_t::iterator i = m_ses_extensions.begin() , end(m_ses_extensions.end()); i != end; ++i) { - boost::shared_ptr tp((*i)->new_torrent(torrent_ptr.get(), userdata)); + boost::shared_ptr tp((*i)->new_torrent(torrent_ptr->get_handle(), userdata)); if (tp) torrent_ptr->add_extension(tp); } } @@ -4623,13 +4635,13 @@ retry: #ifndef TORRENT_DISABLE_EXTENSIONS typedef std::vector(torrent*, void*)> > + boost::shared_ptr(torrent_handle const&, void*)> > torrent_plugins_t; for (torrent_plugins_t::const_iterator i = params.extensions.begin() , end(params.extensions.end()); i != end; ++i) { - torrent_ptr->add_extension((*i)(torrent_ptr.get(), + torrent_ptr->add_extension((*i)(torrent_ptr->get_handle(), params.userdata)); } diff --git a/src/smart_ban.cpp b/src/smart_ban.cpp index 43fd6fc20..77356a96e 100644 --- a/src/smart_ban.cpp +++ b/src/smart_ban.cpp @@ -47,6 +47,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/hasher.hpp" #include "libtorrent/torrent.hpp" +#include "libtorrent/torrent_handle.hpp" #include "libtorrent/extensions.hpp" #include "libtorrent/extensions/smart_ban.hpp" #include "libtorrent/disk_io_thread.hpp" @@ -389,8 +390,9 @@ namespace namespace libtorrent { - boost::shared_ptr create_smart_ban_plugin(torrent* t, void*) + boost::shared_ptr create_smart_ban_plugin(torrent_handle const& th, void*) { + torrent* t = th.native_handle().get(); return boost::shared_ptr(new smart_ban_plugin(*t)); } diff --git a/src/torrent.cpp b/src/torrent.cpp index 7db59252a..19e1f7532 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -70,6 +70,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/bt_peer_connection.hpp" #include "libtorrent/web_peer_connection.hpp" #include "libtorrent/http_seed_connection.hpp" +#include "libtorrent/peer_connection_handle.hpp" #include "libtorrent/peer_id.hpp" #include "libtorrent/identify_client.hpp" #include "libtorrent/alert_types.hpp" @@ -1497,10 +1498,10 @@ namespace libtorrent m_extensions.erase(i); } - void torrent::add_extension(boost::function(torrent*, void*)> const& ext + void torrent::add_extension(boost::function(torrent_handle const&, void*)> const& ext , void* userdata) { - boost::shared_ptr tp(ext(this, userdata)); + boost::shared_ptr tp(ext(get_handle(), userdata)); if (!tp) return; add_extension(tp); diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index bb31e6524..5e7ea29de 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -296,7 +296,7 @@ namespace libtorrent } void torrent_handle::add_extension( - boost::function(torrent*, void*)> const& ext + boost::function(torrent_handle const&, void*)> const& ext , void* userdata) { #ifndef TORRENT_DISABLE_EXTENSIONS diff --git a/src/ut_metadata.cpp b/src/ut_metadata.cpp index 6b6808cf5..8adde205f 100644 --- a/src/ut_metadata.cpp +++ b/src/ut_metadata.cpp @@ -46,9 +46,11 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_connection.hpp" #include "libtorrent/bt_peer_connection.hpp" +#include "libtorrent/peer_connection_handle.hpp" #include "libtorrent/hasher.hpp" #include "libtorrent/bencode.hpp" #include "libtorrent/torrent.hpp" +#include "libtorrent/torrent_handle.hpp" #include "libtorrent/extensions.hpp" #include "libtorrent/extensions/ut_metadata.hpp" #include "libtorrent/alert_types.hpp" @@ -124,7 +126,7 @@ namespace libtorrent { namespace } virtual boost::shared_ptr new_connection( - peer_connection_handle pc); + peer_connection_handle const& pc); int get_metadata_size() const { @@ -500,7 +502,7 @@ namespace libtorrent { namespace }; boost::shared_ptr ut_metadata_plugin::new_connection( - peer_connection_handle pc) + peer_connection_handle const& pc) { if (pc.type() != peer_connection::bittorrent_connection) return boost::shared_ptr(); @@ -655,8 +657,9 @@ namespace libtorrent { namespace namespace libtorrent { - boost::shared_ptr create_ut_metadata_plugin(torrent* t, void*) + boost::shared_ptr create_ut_metadata_plugin(torrent_handle const& th, void*) { + torrent* t = th.native_handle().get(); // don't add this extension if the torrent is private if (t->valid_metadata() && t->torrent_file().priv()) return boost::shared_ptr(); return boost::shared_ptr(new ut_metadata_plugin(*t)); diff --git a/src/ut_pex.cpp b/src/ut_pex.cpp index 98753daab..16a6bd59b 100644 --- a/src/ut_pex.cpp +++ b/src/ut_pex.cpp @@ -33,8 +33,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/peer_connection.hpp" #include "libtorrent/bt_peer_connection.hpp" +#include "libtorrent/peer_connection_handle.hpp" #include "libtorrent/bencode.hpp" #include "libtorrent/torrent.hpp" +#include "libtorrent/torrent_handle.hpp" #include "libtorrent/extensions.hpp" #include "libtorrent/broadcast_socket.hpp" #include "libtorrent/socket_io.hpp" @@ -90,7 +92,7 @@ namespace libtorrent { namespace , m_last_msg(min_time()) , m_peers_in_message(0) {} - virtual boost::shared_ptr new_connection(peer_connection_handle pc); + virtual boost::shared_ptr new_connection(peer_connection_handle const& pc); std::vector& get_ut_pex_msg() { @@ -646,7 +648,7 @@ namespace libtorrent { namespace bool m_first_time; }; - boost::shared_ptr ut_pex_plugin::new_connection(peer_connection_handle pc) + boost::shared_ptr ut_pex_plugin::new_connection(peer_connection_handle const& pc) { if (pc.type() != peer_connection::bittorrent_connection) return boost::shared_ptr(); @@ -658,8 +660,9 @@ namespace libtorrent { namespace namespace libtorrent { - boost::shared_ptr create_ut_pex_plugin(torrent* t, void*) + boost::shared_ptr create_ut_pex_plugin(torrent_handle const& th, void*) { + torrent* t = th.native_handle().get(); if (t->torrent_file().priv() || (t->torrent_file().is_i2p() && !t->settings().get_bool(settings_pack::allow_i2p_mixed))) { diff --git a/test/test_metadata_extension.cpp b/test/test_metadata_extension.cpp index 6fff18956..58c7a9e8b 100644 --- a/test/test_metadata_extension.cpp +++ b/test/test_metadata_extension.cpp @@ -69,7 +69,7 @@ enum flags_t }; void test_transfer(int flags - , boost::shared_ptr (*constructor)(libtorrent::torrent*, void*) + , boost::shared_ptr (*constructor)(libtorrent::torrent_handle const&, void*) , int timeout) { using namespace libtorrent;