forked from premiere/premiere-libtorrent
more use of std::shared_ptr refactor (#1043)
This commit is contained in:
commit
33ec20f7b6
|
@ -1009,7 +1009,7 @@ namespace libtorrent
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
std::unique_ptr<dht::dht_storage_interface> m_dht_storage;
|
std::unique_ptr<dht::dht_storage_interface> m_dht_storage;
|
||||||
boost::shared_ptr<dht::dht_tracker> m_dht;
|
std::shared_ptr<dht::dht_tracker> m_dht;
|
||||||
dht_settings m_dht_settings;
|
dht_settings m_dht_settings;
|
||||||
dht::dht_storage_constructor_type m_dht_storage_constructor
|
dht::dht_storage_constructor_type m_dht_storage_constructor
|
||||||
= dht::dht_default_storage_constructor;
|
= dht::dht_default_storage_constructor;
|
||||||
|
@ -1068,9 +1068,9 @@ namespace libtorrent
|
||||||
// this is deducted from the connect speed
|
// this is deducted from the connect speed
|
||||||
int m_boost_connections = 0;
|
int m_boost_connections = 0;
|
||||||
|
|
||||||
boost::shared_ptr<natpmp> m_natpmp;
|
std::shared_ptr<natpmp> m_natpmp;
|
||||||
boost::shared_ptr<upnp> m_upnp;
|
std::shared_ptr<upnp> m_upnp;
|
||||||
boost::shared_ptr<lsd> m_lsd;
|
std::shared_ptr<lsd> m_lsd;
|
||||||
|
|
||||||
// mask is a bitmask of which protocols to remap on:
|
// mask is a bitmask of which protocols to remap on:
|
||||||
// 1: NAT-PMP
|
// 1: NAT-PMP
|
||||||
|
|
|
@ -36,14 +36,14 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||||
|
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <cstdint>
|
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
#include <boost/shared_array.hpp>
|
#include <boost/shared_array.hpp>
|
||||||
#include <list>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <list>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "libtorrent/time.hpp"
|
#include "libtorrent/time.hpp"
|
||||||
#include "libtorrent/error_code.hpp"
|
#include "libtorrent/error_code.hpp"
|
||||||
#include "libtorrent/io_service_fwd.hpp"
|
#include "libtorrent/io_service_fwd.hpp"
|
||||||
|
@ -187,7 +187,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
// storage this piece belongs to
|
// storage this piece belongs to
|
||||||
boost::shared_ptr<piece_manager> storage;
|
std::shared_ptr<piece_manager> storage;
|
||||||
|
|
||||||
// write jobs hanging off of this piece
|
// write jobs hanging off of this piece
|
||||||
tailqueue<disk_io_job> jobs;
|
tailqueue<disk_io_job> jobs;
|
||||||
|
|
|
@ -33,26 +33,18 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef TORRENT_DISK_IO_JOB_HPP
|
#ifndef TORRENT_DISK_IO_JOB_HPP
|
||||||
#define TORRENT_DISK_IO_JOB_HPP
|
#define TORRENT_DISK_IO_JOB_HPP
|
||||||
|
|
||||||
#include "libtorrent/time.hpp"
|
|
||||||
#include "libtorrent/error_code.hpp"
|
#include "libtorrent/error_code.hpp"
|
||||||
#include "libtorrent/tailqueue.hpp"
|
#include "libtorrent/tailqueue.hpp"
|
||||||
#include "libtorrent/peer_id.hpp"
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
#include <memory>
|
||||||
|
#include <functional>
|
||||||
#include <boost/function/function1.hpp>
|
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
class entry;
|
|
||||||
class piece_manager;
|
class piece_manager;
|
||||||
struct cached_piece_entry;
|
struct cached_piece_entry;
|
||||||
struct bdecode_node;
|
|
||||||
class torrent_info;
|
class torrent_info;
|
||||||
struct add_torrent_params;
|
struct add_torrent_params;
|
||||||
|
|
||||||
|
@ -161,7 +153,7 @@ namespace libtorrent
|
||||||
} buffer;
|
} buffer;
|
||||||
|
|
||||||
// the disk storage this job applies to (if applicable)
|
// the disk storage this job applies to (if applicable)
|
||||||
boost::shared_ptr<piece_manager> storage;
|
std::shared_ptr<piece_manager> storage;
|
||||||
|
|
||||||
// this is called when operation completes
|
// this is called when operation completes
|
||||||
std::function<void(disk_io_job const*)> callback;
|
std::function<void(disk_io_job const*)> callback;
|
||||||
|
|
|
@ -77,9 +77,9 @@ namespace libtorrent
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
boost::shared_ptr<http_tracker_connection> shared_from_this()
|
std::shared_ptr<http_tracker_connection> shared_from_this()
|
||||||
{
|
{
|
||||||
return boost::static_pointer_cast<http_tracker_connection>(
|
return std::static_pointer_cast<http_tracker_connection>(
|
||||||
tracker_connection::shared_from_this());
|
tracker_connection::shared_from_this());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define TORRENT_DHT_TRACKER
|
#define TORRENT_DHT_TRACKER
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <boost/smart_ptr/enable_shared_from_this.hpp>
|
|
||||||
|
|
||||||
#include "libtorrent/kademlia/node.hpp"
|
#include "libtorrent/kademlia/node.hpp"
|
||||||
#include "libtorrent/kademlia/node_id.hpp"
|
#include "libtorrent/kademlia/node_id.hpp"
|
||||||
|
@ -63,7 +62,7 @@ namespace libtorrent { namespace dht
|
||||||
|
|
||||||
struct TORRENT_EXTRA_EXPORT dht_tracker final
|
struct TORRENT_EXTRA_EXPORT dht_tracker final
|
||||||
: udp_socket_interface
|
: udp_socket_interface
|
||||||
, boost::enable_shared_from_this<dht_tracker>
|
, std::enable_shared_from_this<dht_tracker>
|
||||||
{
|
{
|
||||||
typedef std::function<void(udp::endpoint const&
|
typedef std::function<void(udp::endpoint const&
|
||||||
, span<char const>, error_code&, int)> send_fun_t;
|
, span<char const>, error_code&, int)> send_fun_t;
|
||||||
|
@ -134,7 +133,7 @@ namespace libtorrent { namespace dht
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
boost::shared_ptr<dht_tracker> self()
|
std::shared_ptr<dht_tracker> self()
|
||||||
{ return shared_from_this(); }
|
{ return shared_from_this(); }
|
||||||
|
|
||||||
void connection_timeout(node& n, error_code const& e);
|
void connection_timeout(node& n, error_code const& e);
|
||||||
|
|
|
@ -38,19 +38,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/broadcast_socket.hpp"
|
#include "libtorrent/broadcast_socket.hpp"
|
||||||
#include "libtorrent/deadline_timer.hpp"
|
#include "libtorrent/deadline_timer.hpp"
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
|
||||||
|
|
||||||
#include <boost/function/function2.hpp>
|
|
||||||
#include <boost/noncopyable.hpp>
|
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
#include <boost/enable_shared_from_this.hpp>
|
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
|
||||||
#include <boost/function/function1.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -59,7 +46,7 @@ typedef std::function<void(tcp::endpoint, sha1_hash)> peer_callback_t;
|
||||||
typedef std::function<void(char const*)> log_callback_t;
|
typedef std::function<void(char const*)> log_callback_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class lsd : public boost::enable_shared_from_this<lsd>
|
class lsd : public std::enable_shared_from_this<lsd>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
lsd(io_service& ios, peer_callback_t const& cb
|
lsd(io_service& ios, peer_callback_t const& cb
|
||||||
|
@ -76,7 +63,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
boost::shared_ptr<lsd> self() { return shared_from_this(); }
|
std::shared_ptr<lsd> self() { return shared_from_this(); }
|
||||||
|
|
||||||
void announce_impl(sha1_hash const& ih, int listen_port
|
void announce_impl(sha1_hash const& ih, int listen_port
|
||||||
, bool broadcast, int retry_count);
|
, bool broadcast, int retry_count);
|
||||||
|
@ -117,6 +104,4 @@ private:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -41,14 +41,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/time.hpp"
|
#include "libtorrent/time.hpp"
|
||||||
#include "libtorrent/debug.hpp"
|
#include "libtorrent/debug.hpp"
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
|
||||||
|
|
||||||
#include <boost/function/function1.hpp>
|
|
||||||
#include <boost/function/function5.hpp>
|
|
||||||
#include <boost/enable_shared_from_this.hpp>
|
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -59,7 +51,7 @@ typedef std::function<void(int, address, int, int, error_code const&)> portmap_c
|
||||||
typedef std::function<void(char const*)> log_callback_t;
|
typedef std::function<void(char const*)> log_callback_t;
|
||||||
|
|
||||||
struct TORRENT_EXTRA_EXPORT natpmp
|
struct TORRENT_EXTRA_EXPORT natpmp
|
||||||
: boost::enable_shared_from_this<natpmp>
|
: std::enable_shared_from_this<natpmp>
|
||||||
, single_threaded
|
, single_threaded
|
||||||
{
|
{
|
||||||
natpmp(io_service& ios, portmap_callback_t const& cb
|
natpmp(io_service& ios, portmap_callback_t const& cb
|
||||||
|
@ -78,7 +70,7 @@ struct TORRENT_EXTRA_EXPORT natpmp
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
boost::shared_ptr<natpmp> self() { return shared_from_this(); }
|
std::shared_ptr<natpmp> self() { return shared_from_this(); }
|
||||||
|
|
||||||
void update_mapping(int i);
|
void update_mapping(int i);
|
||||||
void send_map_request(int i);
|
void send_map_request(int i);
|
||||||
|
@ -182,6 +174,4 @@ private:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <libtorrent/disk_buffer_holder.hpp>
|
#include <libtorrent/disk_buffer_holder.hpp>
|
||||||
#include <libtorrent/sliding_average.hpp>
|
#include <libtorrent/sliding_average.hpp>
|
||||||
|
|
||||||
|
#include <climits>
|
||||||
|
|
||||||
namespace libtorrent {
|
namespace libtorrent {
|
||||||
|
|
||||||
struct TORRENT_EXTRA_EXPORT receive_buffer
|
struct TORRENT_EXTRA_EXPORT receive_buffer
|
||||||
|
|
|
@ -43,10 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <boost/function/function2.hpp>
|
|
||||||
#include <boost/function/function0.hpp>
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/enable_shared_from_this.hpp>
|
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||||
|
|
||||||
|
@ -554,7 +551,7 @@ namespace libtorrent
|
||||||
};
|
};
|
||||||
|
|
||||||
class TORRENT_EXTRA_EXPORT piece_manager
|
class TORRENT_EXTRA_EXPORT piece_manager
|
||||||
: public boost::enable_shared_from_this<piece_manager>
|
: public std::enable_shared_from_this<piece_manager>
|
||||||
, public disk_job_fence
|
, public disk_job_fence
|
||||||
, public storage_piece_set
|
, public storage_piece_set
|
||||||
, boost::noncopyable
|
, boost::noncopyable
|
||||||
|
|
|
@ -1167,7 +1167,7 @@ namespace libtorrent
|
||||||
// the piece_manager, and stored in the
|
// the piece_manager, and stored in the
|
||||||
// torrent, so the torrent cannot destruct
|
// torrent, so the torrent cannot destruct
|
||||||
// before the piece_manager.
|
// before the piece_manager.
|
||||||
boost::shared_ptr<piece_manager> m_storage;
|
std::shared_ptr<piece_manager> m_storage;
|
||||||
|
|
||||||
#ifdef TORRENT_USE_OPENSSL
|
#ifdef TORRENT_USE_OPENSSL
|
||||||
boost::shared_ptr<boost::asio::ssl::context> m_ssl_ctx;
|
boost::shared_ptr<boost::asio::ssl::context> m_ssl_ctx;
|
||||||
|
|
|
@ -219,7 +219,7 @@ namespace libtorrent
|
||||||
int incomplete;
|
int incomplete;
|
||||||
|
|
||||||
// if supported by the tracker, the number of actively downloading peers.
|
// if supported by the tracker, the number of actively downloading peers.
|
||||||
// i.e. partial seeds. If not suppored, -1
|
// i.e. partial seeds. If not supported, -1
|
||||||
int downloaders;
|
int downloaders;
|
||||||
|
|
||||||
// the number of times the torrent has been downloaded
|
// the number of times the torrent has been downloaded
|
||||||
|
@ -254,7 +254,7 @@ namespace libtorrent
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TORRENT_EXTRA_EXPORT timeout_handler
|
struct TORRENT_EXTRA_EXPORT timeout_handler
|
||||||
: boost::enable_shared_from_this<timeout_handler>
|
: std::enable_shared_from_this<timeout_handler>
|
||||||
, boost::noncopyable
|
, boost::noncopyable
|
||||||
{
|
{
|
||||||
timeout_handler(io_service& str);
|
timeout_handler(io_service& str);
|
||||||
|
@ -315,9 +315,9 @@ namespace libtorrent
|
||||||
void sent_bytes(int bytes);
|
void sent_bytes(int bytes);
|
||||||
void received_bytes(int bytes);
|
void received_bytes(int bytes);
|
||||||
|
|
||||||
boost::shared_ptr<tracker_connection> shared_from_this()
|
std::shared_ptr<tracker_connection> shared_from_this()
|
||||||
{
|
{
|
||||||
return boost::static_pointer_cast<tracker_connection>(
|
return std::static_pointer_cast<tracker_connection>(
|
||||||
timeout_handler::shared_from_this());
|
timeout_handler::shared_from_this());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,7 +383,7 @@ namespace libtorrent
|
||||||
bool incoming_packet(char const* hostname, span<char const> buf);
|
bool incoming_packet(char const* hostname, span<char const> buf);
|
||||||
|
|
||||||
void update_transaction_id(
|
void update_transaction_id(
|
||||||
boost::shared_ptr<udp_tracker_connection> c
|
std::shared_ptr<udp_tracker_connection> c
|
||||||
, std::uint64_t tid);
|
, std::uint64_t tid);
|
||||||
|
|
||||||
aux::session_settings const& settings() const { return m_settings; }
|
aux::session_settings const& settings() const { return m_settings; }
|
||||||
|
@ -401,10 +401,10 @@ namespace libtorrent
|
||||||
// These must use shared_ptr to avoid a dangling reference
|
// These must use shared_ptr to avoid a dangling reference
|
||||||
// if a connection is erased while a timeout event is in the queue
|
// if a connection is erased while a timeout event is in the queue
|
||||||
typedef boost::unordered_map<std::uint32_t
|
typedef boost::unordered_map<std::uint32_t
|
||||||
, boost::shared_ptr<udp_tracker_connection> > udp_conns_t;
|
, std::shared_ptr<udp_tracker_connection>> udp_conns_t;
|
||||||
udp_conns_t m_udp_conns;
|
udp_conns_t m_udp_conns;
|
||||||
|
|
||||||
typedef std::vector<boost::shared_ptr<http_tracker_connection> > http_conns_t;
|
typedef std::vector<std::shared_ptr<http_tracker_connection>> http_conns_t;
|
||||||
http_conns_t m_http_conns;
|
http_conns_t m_http_conns;
|
||||||
|
|
||||||
send_fun_t m_send_fun;
|
send_fun_t m_send_fun;
|
||||||
|
@ -421,4 +421,3 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TORRENT_TRACKER_MANAGER_HPP_INCLUDED
|
#endif // TORRENT_TRACKER_MANAGER_HPP_INCLUDED
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ namespace libtorrent
|
||||||
|
|
||||||
aux::proxy_settings m_proxy_settings;
|
aux::proxy_settings m_proxy_settings;
|
||||||
|
|
||||||
boost::shared_ptr<socks5> m_socks5_connection;
|
std::shared_ptr<socks5> m_socks5_connection;
|
||||||
|
|
||||||
// TODO: 3 add a unit test for force-proxy
|
// TODO: 3 add a unit test for force-proxy
|
||||||
bool m_force_proxy:1;
|
bool m_force_proxy:1;
|
||||||
|
@ -155,4 +155,3 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -80,9 +80,9 @@ namespace libtorrent
|
||||||
action_error
|
action_error
|
||||||
};
|
};
|
||||||
|
|
||||||
boost::shared_ptr<udp_tracker_connection> shared_from_this()
|
std::shared_ptr<udp_tracker_connection> shared_from_this()
|
||||||
{
|
{
|
||||||
return boost::static_pointer_cast<udp_tracker_connection>(
|
return std::static_pointer_cast<udp_tracker_connection>(
|
||||||
tracker_connection::shared_from_this());
|
tracker_connection::shared_from_this());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/enable_shared_from_this.hpp>
|
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
@ -131,7 +130,7 @@ TORRENT_EXTRA_EXPORT void find_control_url(int type, char const* string
|
||||||
|
|
||||||
// TODO: support using the windows API for UPnP operations as well
|
// TODO: support using the windows API for UPnP operations as well
|
||||||
struct TORRENT_EXTRA_EXPORT upnp final
|
struct TORRENT_EXTRA_EXPORT upnp final
|
||||||
: boost::enable_shared_from_this<upnp>
|
: std::enable_shared_from_this<upnp>
|
||||||
, single_threaded
|
, single_threaded
|
||||||
{
|
{
|
||||||
upnp(io_service& ios
|
upnp(io_service& ios
|
||||||
|
@ -182,7 +181,7 @@ struct TORRENT_EXTRA_EXPORT upnp final
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
boost::shared_ptr<upnp> self() { return shared_from_this(); }
|
std::shared_ptr<upnp> self() { return shared_from_this(); }
|
||||||
|
|
||||||
void map_timer(error_code const& ec);
|
void map_timer(error_code const& ec);
|
||||||
void try_map_upnp(bool timer = false);
|
void try_map_upnp(bool timer = false);
|
||||||
|
|
|
@ -161,7 +161,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_hash(disk_io_job const* j, create_torrent* t
|
void on_hash(disk_io_job const* j, create_torrent* t
|
||||||
, boost::shared_ptr<piece_manager> storage, disk_io_thread* iothread
|
, std::shared_ptr<piece_manager> storage, disk_io_thread* iothread
|
||||||
, int* piece_counter, int* completed_piece
|
, int* piece_counter, int* completed_piece
|
||||||
, std::function<void(int)> const* f, error_code* ec)
|
, std::function<void(int)> const* f, error_code* ec)
|
||||||
{
|
{
|
||||||
|
@ -282,7 +282,7 @@ namespace libtorrent
|
||||||
|
|
||||||
storage_interface* storage_impl = default_storage_constructor(params);
|
storage_interface* storage_impl = default_storage_constructor(params);
|
||||||
|
|
||||||
boost::shared_ptr<piece_manager> storage = boost::make_shared<piece_manager>(
|
std::shared_ptr<piece_manager> storage = std::make_shared<piece_manager>(
|
||||||
storage_impl, dummy, const_cast<file_storage*>(&t.files()));
|
storage_impl, dummy, const_cast<file_storage*>(&t.files()));
|
||||||
|
|
||||||
settings_pack sett;
|
settings_pack sett;
|
||||||
|
|
|
@ -31,9 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libtorrent/disk_io_job.hpp"
|
#include "libtorrent/disk_io_job.hpp"
|
||||||
#include "libtorrent/storage.hpp"
|
|
||||||
#include "libtorrent/block_cache.hpp" // for cached_piece_entry
|
#include "libtorrent/block_cache.hpp" // for cached_piece_entry
|
||||||
#include "libtorrent/entry.hpp"
|
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
@ -68,7 +66,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
if (action != write) return false;
|
if (action != write) return false;
|
||||||
|
|
||||||
int block_offset = d.io.offset & (block_size-1);
|
int block_offset = d.io.offset & (block_size - 1);
|
||||||
int size = d.io.buffer_size;
|
int size = d.io.buffer_size;
|
||||||
int start = d.io.offset / block_size;
|
int start = d.io.offset / block_size;
|
||||||
int end = block_offset > 0 && (size > block_size - block_offset) ? start + 2 : start + 1;
|
int end = block_offset > 0 && (size > block_size - block_offset) ? start + 2 : start + 1;
|
||||||
|
@ -81,4 +79,3 @@ namespace libtorrent
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1074,7 +1074,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
boost::shared_ptr<piece_manager> storage = j->storage;
|
std::shared_ptr<piece_manager> storage = j->storage;
|
||||||
|
|
||||||
// TODO: instead of doing this. pass in the settings to each storage_interface
|
// TODO: instead of doing this. pass in the settings to each storage_interface
|
||||||
// call. Each disk thread could hold its most recent understanding of the settings
|
// call. Each disk thread could hold its most recent understanding of the settings
|
||||||
|
|
|
@ -297,7 +297,7 @@ namespace libtorrent
|
||||||
, http_parser const& parser, char const* data, int size)
|
, http_parser const& parser, char const* data, int size)
|
||||||
{
|
{
|
||||||
// keep this alive
|
// keep this alive
|
||||||
boost::shared_ptr<http_tracker_connection> me(shared_from_this());
|
std::shared_ptr<http_tracker_connection> me(shared_from_this());
|
||||||
|
|
||||||
if (ec && ec != boost::asio::error::eof)
|
if (ec && ec != boost::asio::error::eof)
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,14 +56,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/hex.hpp" // to_hex
|
#include "libtorrent/hex.hpp" // to_hex
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <boost/function/function0.hpp>
|
|
||||||
#include <boost/ref.hpp>
|
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
|
||||||
|
|
||||||
using libtorrent::dht::node;
|
using libtorrent::dht::node;
|
||||||
using libtorrent::dht::node_id;
|
using libtorrent::dht::node_id;
|
||||||
using libtorrent::dht::packet_t;
|
using libtorrent::dht::packet_t;
|
||||||
|
@ -363,7 +355,7 @@ namespace libtorrent { namespace dht
|
||||||
|
|
||||||
// these functions provide a slightly higher level
|
// these functions provide a slightly higher level
|
||||||
// interface to the get/put functionality in the DHT
|
// interface to the get/put functionality in the DHT
|
||||||
void get_immutable_item_callback(item const& it, boost::shared_ptr<get_immutable_item_ctx> ctx
|
void get_immutable_item_callback(item const& it, std::shared_ptr<get_immutable_item_ctx> ctx
|
||||||
, std::function<void(item const&)> f)
|
, std::function<void(item const&)> f)
|
||||||
{
|
{
|
||||||
// the reason to wrap here is to control the return value
|
// the reason to wrap here is to control the return value
|
||||||
|
@ -385,7 +377,7 @@ namespace libtorrent { namespace dht
|
||||||
};
|
};
|
||||||
|
|
||||||
void get_mutable_item_callback(item const& it, bool authoritative
|
void get_mutable_item_callback(item const& it, bool authoritative
|
||||||
, boost::shared_ptr<get_mutable_item_ctx> ctx
|
, std::shared_ptr<get_mutable_item_ctx> ctx
|
||||||
, std::function<void(item const&, bool)> f)
|
, std::function<void(item const&, bool)> f)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(it.is_mutable());
|
TORRENT_ASSERT(it.is_mutable());
|
||||||
|
@ -411,7 +403,7 @@ namespace libtorrent { namespace dht
|
||||||
int response_count;
|
int response_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
void put_immutable_item_callback(int responses, boost::shared_ptr<put_item_ctx> ctx
|
void put_immutable_item_callback(int responses, std::shared_ptr<put_item_ctx> ctx
|
||||||
, std::function<void(int)> f)
|
, std::function<void(int)> f)
|
||||||
{
|
{
|
||||||
ctx->response_count += responses;
|
ctx->response_count += responses;
|
||||||
|
@ -419,7 +411,7 @@ namespace libtorrent { namespace dht
|
||||||
f(ctx->response_count);
|
f(ctx->response_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void put_mutable_item_callback(item const& it, int responses, boost::shared_ptr<put_item_ctx> ctx
|
void put_mutable_item_callback(item const& it, int responses, std::shared_ptr<put_item_ctx> ctx
|
||||||
, std::function<void(item const&, int)> cb)
|
, std::function<void(item const&, int)> cb)
|
||||||
{
|
{
|
||||||
ctx->response_count += responses;
|
ctx->response_count += responses;
|
||||||
|
@ -432,8 +424,8 @@ namespace libtorrent { namespace dht
|
||||||
void dht_tracker::get_item(sha1_hash const& target
|
void dht_tracker::get_item(sha1_hash const& target
|
||||||
, std::function<void(item const&)> cb)
|
, std::function<void(item const&)> cb)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<get_immutable_item_ctx>
|
std::shared_ptr<get_immutable_item_ctx>
|
||||||
ctx = boost::make_shared<get_immutable_item_ctx>((TORRENT_USE_IPV6) ? 2 : 1);
|
ctx = std::make_shared<get_immutable_item_ctx>((TORRENT_USE_IPV6) ? 2 : 1);
|
||||||
m_dht.get_item(target, std::bind(&get_immutable_item_callback, _1, ctx, cb));
|
m_dht.get_item(target, std::bind(&get_immutable_item_callback, _1, ctx, cb));
|
||||||
#if TORRENT_USE_IPV6
|
#if TORRENT_USE_IPV6
|
||||||
m_dht6.get_item(target, std::bind(&get_immutable_item_callback, _1, ctx, cb));
|
m_dht6.get_item(target, std::bind(&get_immutable_item_callback, _1, ctx, cb));
|
||||||
|
@ -446,8 +438,8 @@ namespace libtorrent { namespace dht
|
||||||
, std::function<void(item const&, bool)> cb
|
, std::function<void(item const&, bool)> cb
|
||||||
, std::string salt)
|
, std::string salt)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<get_mutable_item_ctx>
|
std::shared_ptr<get_mutable_item_ctx>
|
||||||
ctx = boost::make_shared<get_mutable_item_ctx>((TORRENT_USE_IPV6) ? 2 : 1);
|
ctx = std::make_shared<get_mutable_item_ctx>((TORRENT_USE_IPV6) ? 2 : 1);
|
||||||
m_dht.get_item(key, salt, std::bind(&get_mutable_item_callback, _1, _2, ctx, cb));
|
m_dht.get_item(key, salt, std::bind(&get_mutable_item_callback, _1, _2, ctx, cb));
|
||||||
#if TORRENT_USE_IPV6
|
#if TORRENT_USE_IPV6
|
||||||
m_dht6.get_item(key, salt, std::bind(&get_mutable_item_callback, _1, _2, ctx, cb));
|
m_dht6.get_item(key, salt, std::bind(&get_mutable_item_callback, _1, _2, ctx, cb));
|
||||||
|
@ -461,8 +453,8 @@ namespace libtorrent { namespace dht
|
||||||
bencode(std::back_inserter(flat_data), data);
|
bencode(std::back_inserter(flat_data), data);
|
||||||
sha1_hash const target = item_target_id(flat_data);
|
sha1_hash const target = item_target_id(flat_data);
|
||||||
|
|
||||||
boost::shared_ptr<put_item_ctx>
|
std::shared_ptr<put_item_ctx>
|
||||||
ctx = boost::make_shared<put_item_ctx>((TORRENT_USE_IPV6) ? 2 : 1);
|
ctx = std::make_shared<put_item_ctx>((TORRENT_USE_IPV6) ? 2 : 1);
|
||||||
m_dht.put_item(target, data, std::bind(&put_immutable_item_callback
|
m_dht.put_item(target, data, std::bind(&put_immutable_item_callback
|
||||||
, _1, ctx, cb));
|
, _1, ctx, cb));
|
||||||
#if TORRENT_USE_IPV6
|
#if TORRENT_USE_IPV6
|
||||||
|
@ -475,8 +467,8 @@ namespace libtorrent { namespace dht
|
||||||
, std::function<void(item const&, int)> cb
|
, std::function<void(item const&, int)> cb
|
||||||
, std::function<void(item&)> data_cb, std::string salt)
|
, std::function<void(item&)> data_cb, std::string salt)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<put_item_ctx>
|
std::shared_ptr<put_item_ctx>
|
||||||
ctx = boost::make_shared<put_item_ctx>((TORRENT_USE_IPV6) ? 2 : 1);
|
ctx = std::make_shared<put_item_ctx>((TORRENT_USE_IPV6) ? 2 : 1);
|
||||||
|
|
||||||
m_dht.put_item(key, salt, std::bind(&put_mutable_item_callback
|
m_dht.put_item(key, salt, std::bind(&put_mutable_item_callback
|
||||||
, _1, _2, ctx, cb), data_cb);
|
, _1, _2, ctx, cb), data_cb);
|
||||||
|
|
|
@ -311,5 +311,3 @@ void lsd::close()
|
||||||
}
|
}
|
||||||
|
|
||||||
} // libtorrent namespace
|
} // libtorrent namespace
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/version.hpp>
|
|
||||||
#include <boost/asio/ip/host_name.hpp>
|
#include <boost/asio/ip/host_name.hpp>
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||||
|
@ -657,4 +656,3 @@ void natpmp::close_impl()
|
||||||
m_currently_mapping = -1;
|
m_currently_mapping = -1;
|
||||||
update_mapping(0);
|
update_mapping(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5521,11 +5521,11 @@ namespace aux {
|
||||||
if (m_outstanding_router_lookups > 0) return;
|
if (m_outstanding_router_lookups > 0) return;
|
||||||
|
|
||||||
m_dht_storage = m_dht_storage_constructor(m_dht_settings);
|
m_dht_storage = m_dht_storage_constructor(m_dht_settings);
|
||||||
m_dht = boost::make_shared<dht::dht_tracker>(
|
m_dht = std::make_shared<dht::dht_tracker>(
|
||||||
static_cast<dht_observer*>(this)
|
static_cast<dht_observer*>(this)
|
||||||
, std::ref(m_io_service)
|
, std::ref(m_io_service)
|
||||||
, std::bind(&session_impl::send_udp_packet, this, false, _1, _2, _3, _4)
|
, std::bind(&session_impl::send_udp_packet, this, false, _1, _2, _3, _4)
|
||||||
, boost::cref(m_dht_settings)
|
, std::cref(m_dht_settings)
|
||||||
, std::ref(m_stats_counters)
|
, std::ref(m_stats_counters)
|
||||||
, *m_dht_storage
|
, *m_dht_storage
|
||||||
, startup_state);
|
, startup_state);
|
||||||
|
@ -6390,7 +6390,7 @@ namespace aux {
|
||||||
|
|
||||||
if (m_lsd) return;
|
if (m_lsd) return;
|
||||||
|
|
||||||
m_lsd = boost::make_shared<lsd>(std::ref(m_io_service)
|
m_lsd = std::make_shared<lsd>(std::ref(m_io_service)
|
||||||
, std::bind(&session_impl::on_lsd_peer, this, _1, _2)
|
, std::bind(&session_impl::on_lsd_peer, this, _1, _2)
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
, std::bind(&session_impl::on_lsd_log, this, _1)
|
, std::bind(&session_impl::on_lsd_log, this, _1)
|
||||||
|
@ -6418,7 +6418,7 @@ namespace aux {
|
||||||
|
|
||||||
// the natpmp constructor may fail and call the callbacks
|
// the natpmp constructor may fail and call the callbacks
|
||||||
// into the session_impl.
|
// into the session_impl.
|
||||||
m_natpmp = boost::make_shared<natpmp>(std::ref(m_io_service)
|
m_natpmp = std::make_shared<natpmp>(std::ref(m_io_service)
|
||||||
, std::bind(&session_impl::on_port_mapping
|
, std::bind(&session_impl::on_port_mapping
|
||||||
, this, _1, _2, _3, _4, _5, 0)
|
, this, _1, _2, _3, _4, _5, 0)
|
||||||
, std::bind(&session_impl::on_port_map_log
|
, std::bind(&session_impl::on_port_map_log
|
||||||
|
@ -6440,7 +6440,7 @@ namespace aux {
|
||||||
if (m_upnp) return m_upnp.get();
|
if (m_upnp) return m_upnp.get();
|
||||||
|
|
||||||
// the upnp constructor may fail and call the callbacks
|
// the upnp constructor may fail and call the callbacks
|
||||||
m_upnp = boost::make_shared<upnp>(std::ref(m_io_service)
|
m_upnp = std::make_shared<upnp>(std::ref(m_io_service)
|
||||||
, m_settings.get_str(settings_pack::user_agent)
|
, m_settings.get_str(settings_pack::user_agent)
|
||||||
, std::bind(&session_impl::on_port_mapping
|
, std::bind(&session_impl::on_port_mapping
|
||||||
, this, _1, _2, _3, _4, _5, 1)
|
, this, _1, _2, _3, _4, _5, 1)
|
||||||
|
|
|
@ -1675,7 +1675,7 @@ namespace libtorrent
|
||||||
|
|
||||||
// the shared_from_this() will create an intentional
|
// the shared_from_this() will create an intentional
|
||||||
// cycle of ownership, se the hpp file for description.
|
// cycle of ownership, se the hpp file for description.
|
||||||
m_storage = boost::make_shared<piece_manager>(
|
m_storage = std::make_shared<piece_manager>(
|
||||||
storage_impl, shared_from_this()
|
storage_impl, shared_from_this()
|
||||||
, const_cast<file_storage*>(&m_torrent_file->files()));
|
, const_cast<file_storage*>(&m_torrent_file->files()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,7 +238,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
http_conns_t::iterator i = std::find_if(m_http_conns.begin(), m_http_conns.end()
|
http_conns_t::iterator i = std::find_if(m_http_conns.begin(), m_http_conns.end()
|
||||||
, [c] (boost::shared_ptr<http_tracker_connection> const& ptr) { return ptr.get() == c; });
|
, [c] (std::shared_ptr<http_tracker_connection> const& ptr) { return ptr.get() == c; });
|
||||||
if (i != m_http_conns.end())
|
if (i != m_http_conns.end())
|
||||||
{
|
{
|
||||||
m_http_conns.erase(i);
|
m_http_conns.erase(i);
|
||||||
|
@ -255,7 +255,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
void tracker_manager::update_transaction_id(
|
void tracker_manager::update_transaction_id(
|
||||||
boost::shared_ptr<udp_tracker_connection> c
|
std::shared_ptr<udp_tracker_connection> c
|
||||||
, std::uint64_t tid)
|
, std::uint64_t tid)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
|
@ -287,18 +287,18 @@ namespace libtorrent
|
||||||
if (protocol == "http")
|
if (protocol == "http")
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
boost::shared_ptr<http_tracker_connection> con
|
std::shared_ptr<http_tracker_connection> con
|
||||||
= boost::make_shared<http_tracker_connection>(
|
= std::make_shared<http_tracker_connection>(
|
||||||
std::ref(ios), std::ref(*this), boost::cref(req), c);
|
std::ref(ios), std::ref(*this), std::cref(req), c);
|
||||||
m_http_conns.push_back(con);
|
m_http_conns.push_back(con);
|
||||||
con->start();
|
con->start();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (protocol == "udp")
|
else if (protocol == "udp")
|
||||||
{
|
{
|
||||||
boost::shared_ptr<udp_tracker_connection> con
|
std::shared_ptr<udp_tracker_connection> con
|
||||||
= boost::make_shared<udp_tracker_connection>(
|
= std::make_shared<udp_tracker_connection>(
|
||||||
std::ref(ios), std::ref(*this), boost::cref(req) , c);
|
std::ref(ios), std::ref(*this), std::cref(req) , c);
|
||||||
m_udp_conns[con->transaction_id()] = con;
|
m_udp_conns[con->transaction_id()] = con;
|
||||||
con->start();
|
con->start();
|
||||||
return;
|
return;
|
||||||
|
@ -344,7 +344,7 @@ namespace libtorrent
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<udp_tracker_connection> const p = i->second;
|
std::shared_ptr<udp_tracker_connection> const p = i->second;
|
||||||
// on_receive() may remove the tracker connection from the list
|
// on_receive() may remove the tracker connection from the list
|
||||||
return p->on_receive(ep, buf);
|
return p->on_receive(ep, buf);
|
||||||
}
|
}
|
||||||
|
@ -383,7 +383,7 @@ namespace libtorrent
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<udp_tracker_connection> const p = i->second;
|
std::shared_ptr<udp_tracker_connection> const p = i->second;
|
||||||
// on_receive() may remove the tracker connection from the list
|
// on_receive() may remove the tracker connection from the list
|
||||||
return p->on_receive_hostname(hostname, buf);
|
return p->on_receive_hostname(hostname, buf);
|
||||||
}
|
}
|
||||||
|
@ -412,7 +412,7 @@ namespace libtorrent
|
||||||
|
|
||||||
m_abort = true;
|
m_abort = true;
|
||||||
http_conns_t close_http_connections;
|
http_conns_t close_http_connections;
|
||||||
std::vector<boost::shared_ptr<udp_tracker_connection> > close_udp_connections;
|
std::vector<std::shared_ptr<udp_tracker_connection>> close_udp_connections;
|
||||||
|
|
||||||
for (http_conns_t::iterator i = m_http_conns.begin()
|
for (http_conns_t::iterator i = m_http_conns.begin()
|
||||||
, end(m_http_conns.end()); i != end; ++i)
|
, end(m_http_conns.end()); i != end; ++i)
|
||||||
|
@ -432,7 +432,7 @@ namespace libtorrent
|
||||||
for (udp_conns_t::iterator i = m_udp_conns.begin()
|
for (udp_conns_t::iterator i = m_udp_conns.begin()
|
||||||
, end(m_udp_conns.end()); i != end; ++i)
|
, end(m_udp_conns.end()); i != end; ++i)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<udp_tracker_connection> c = i->second;
|
std::shared_ptr<udp_tracker_connection> c = i->second;
|
||||||
tracker_request const& req = c->tracker_req();
|
tracker_request const& req = c->tracker_req();
|
||||||
if (req.event == tracker_request::stopped && !all)
|
if (req.event == tracker_request::stopped && !all)
|
||||||
continue;
|
continue;
|
||||||
|
@ -451,11 +451,9 @@ namespace libtorrent
|
||||||
(*i)->close();
|
(*i)->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::vector<boost::shared_ptr<udp_tracker_connection> >::iterator i
|
for (auto const& c : close_udp_connections)
|
||||||
= close_udp_connections.begin()
|
|
||||||
, end(close_udp_connections.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
(*i)->close();
|
c->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,12 +41,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/debug.hpp"
|
#include "libtorrent/debug.hpp"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <functional>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <array>
|
|
||||||
#include <boost/function/function3.hpp>
|
|
||||||
#include <boost/system/system_error.hpp>
|
#include <boost/system/system_error.hpp>
|
||||||
#include <boost/system/error_code.hpp>
|
#include <boost/system/error_code.hpp>
|
||||||
#include <boost/asio/read.hpp>
|
#include <boost/asio/read.hpp>
|
||||||
|
@ -66,7 +65,7 @@ using namespace std::placeholders;
|
||||||
// been destructed, it needs to be held by a shared_ptr
|
// been destructed, it needs to be held by a shared_ptr
|
||||||
// 2. since using a socks proxy is assumed to be a less common case, it makes
|
// 2. since using a socks proxy is assumed to be a less common case, it makes
|
||||||
// the common case cheaper by not allocating this space unconditionally
|
// the common case cheaper by not allocating this space unconditionally
|
||||||
struct socks5 : boost::enable_shared_from_this<socks5>
|
struct socks5 : std::enable_shared_from_this<socks5>
|
||||||
{
|
{
|
||||||
explicit socks5(io_service& ios)
|
explicit socks5(io_service& ios)
|
||||||
: m_socks5_sock(ios)
|
: m_socks5_sock(ios)
|
||||||
|
@ -75,7 +74,7 @@ struct socks5 : boost::enable_shared_from_this<socks5>
|
||||||
, m_abort(false)
|
, m_abort(false)
|
||||||
, m_active(false)
|
, m_active(false)
|
||||||
{
|
{
|
||||||
memset(m_tmp_buf, 0, sizeof(m_tmp_buf));
|
std::memset(m_tmp_buf, 0, sizeof(m_tmp_buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
void start(aux::proxy_settings const& ps);
|
void start(aux::proxy_settings const& ps);
|
||||||
|
@ -86,7 +85,7 @@ struct socks5 : boost::enable_shared_from_this<socks5>
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
boost::shared_ptr<socks5> self() { return shared_from_this(); }
|
std::shared_ptr<socks5> self() { return shared_from_this(); }
|
||||||
|
|
||||||
void on_name_lookup(error_code const& e, tcp::resolver::iterator i);
|
void on_name_lookup(error_code const& e, tcp::resolver::iterator i);
|
||||||
void on_connect_timeout(error_code const& ec);
|
void on_connect_timeout(error_code const& ec);
|
||||||
|
@ -478,7 +477,7 @@ void udp_socket::set_proxy_settings(aux::proxy_settings const& ps)
|
||||||
{
|
{
|
||||||
// connect to socks5 server and open up the UDP tunnel
|
// connect to socks5 server and open up the UDP tunnel
|
||||||
|
|
||||||
m_socks5_connection = boost::make_shared<socks5>(std::ref(m_socket.get_io_service()));
|
m_socks5_connection = std::make_shared<socks5>(std::ref(m_socket.get_io_service()));
|
||||||
m_socks5_connection->start(ps);
|
m_socks5_connection->start(ps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
16
src/upnp.cpp
16
src/upnp.cpp
|
@ -43,7 +43,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/debug.hpp"
|
#include "libtorrent/debug.hpp"
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||||
#include <boost/ref.hpp>
|
|
||||||
#include <boost/asio/ip/host_name.hpp>
|
#include <boost/asio/ip/host_name.hpp>
|
||||||
#include <boost/asio/ip/multicast.hpp>
|
#include <boost/asio/ip/multicast.hpp>
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||||
|
@ -274,7 +273,7 @@ void upnp::resend_request(error_code const& ec)
|
||||||
COMPLETE_ASYNC("upnp::resend_request");
|
COMPLETE_ASYNC("upnp::resend_request");
|
||||||
if (ec) return;
|
if (ec) return;
|
||||||
|
|
||||||
boost::shared_ptr<upnp> me(self());
|
std::shared_ptr<upnp> me(self());
|
||||||
|
|
||||||
if (m_closing) return;
|
if (m_closing) return;
|
||||||
|
|
||||||
|
@ -332,7 +331,7 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
|
||||||
, std::size_t bytes_transferred)
|
, std::size_t bytes_transferred)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
boost::shared_ptr<upnp> me(self());
|
std::shared_ptr<upnp> me(self());
|
||||||
|
|
||||||
using namespace libtorrent::detail;
|
using namespace libtorrent::detail;
|
||||||
|
|
||||||
|
@ -739,7 +738,7 @@ void upnp::update_map(rootdevice& d, int i)
|
||||||
|
|
||||||
if (d.upnp_connection) return;
|
if (d.upnp_connection) return;
|
||||||
|
|
||||||
boost::shared_ptr<upnp> me(self());
|
std::shared_ptr<upnp> me(self());
|
||||||
|
|
||||||
mapping_t& m = d.mapping[i];
|
mapping_t& m = d.mapping[i];
|
||||||
|
|
||||||
|
@ -900,7 +899,7 @@ void upnp::on_upnp_xml(error_code const& e
|
||||||
, http_connection& c)
|
, http_connection& c)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
boost::shared_ptr<upnp> me(self());
|
std::shared_ptr<upnp> me(self());
|
||||||
|
|
||||||
TORRENT_ASSERT(d.magic == 1337);
|
TORRENT_ASSERT(d.magic == 1337);
|
||||||
if (d.upnp_connection && d.upnp_connection.get() == &c)
|
if (d.upnp_connection && d.upnp_connection.get() == &c)
|
||||||
|
@ -1181,7 +1180,7 @@ void upnp::on_upnp_get_ip_address_response(error_code const& e
|
||||||
, http_connection& c)
|
, http_connection& c)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
boost::shared_ptr<upnp> me(self());
|
std::shared_ptr<upnp> me(self());
|
||||||
|
|
||||||
TORRENT_ASSERT(d.magic == 1337);
|
TORRENT_ASSERT(d.magic == 1337);
|
||||||
if (d.upnp_connection && d.upnp_connection.get() == &c)
|
if (d.upnp_connection && d.upnp_connection.get() == &c)
|
||||||
|
@ -1267,7 +1266,7 @@ void upnp::on_upnp_map_response(error_code const& e
|
||||||
, http_connection& c)
|
, http_connection& c)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
boost::shared_ptr<upnp> me(self());
|
std::shared_ptr<upnp> me(self());
|
||||||
|
|
||||||
TORRENT_ASSERT(d.magic == 1337);
|
TORRENT_ASSERT(d.magic == 1337);
|
||||||
if (d.upnp_connection && d.upnp_connection.get() == &c)
|
if (d.upnp_connection && d.upnp_connection.get() == &c)
|
||||||
|
@ -1434,7 +1433,7 @@ void upnp::on_upnp_unmap_response(error_code const& e
|
||||||
, http_connection& c)
|
, http_connection& c)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
boost::shared_ptr<upnp> me(self());
|
std::shared_ptr<upnp> me(self());
|
||||||
|
|
||||||
TORRENT_ASSERT(d.magic == 1337);
|
TORRENT_ASSERT(d.magic == 1337);
|
||||||
if (d.upnp_connection && d.upnp_connection.get() == &c)
|
if (d.upnp_connection && d.upnp_connection.get() == &c)
|
||||||
|
@ -1562,4 +1561,3 @@ void upnp::close()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/enable_shared_from_this.hpp>
|
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
@ -117,7 +116,7 @@ void peer_connection::start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef std::vector<boost::shared_ptr<peer_connection> > connections_t;
|
typedef std::vector<boost::shared_ptr<peer_connection>> connections_t;
|
||||||
|
|
||||||
void do_change_rate(bandwidth_channel& t1, bandwidth_channel& t2, int limit)
|
void do_change_rate(bandwidth_channel& t1, bandwidth_channel& t2, int limit)
|
||||||
{
|
{
|
||||||
|
@ -184,7 +183,7 @@ void spawn_connections(connections_t& v, bandwidth_manager& bwm
|
||||||
{
|
{
|
||||||
char name[200];
|
char name[200];
|
||||||
std::snprintf(name, sizeof(name), "%s%d", prefix, i);
|
std::snprintf(name, sizeof(name), "%s%d", prefix, i);
|
||||||
v.push_back(boost::shared_ptr<peer_connection>(new peer_connection(bwm, bwc, 200, false, name)));
|
v.push_back(boost::make_shared<peer_connection>(bwm, bwc, 200, false, name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,8 +403,8 @@ void test_peer_priority(int limit, bool torrent_limit)
|
||||||
spawn_connections(v1, manager, t1, 10, "p");
|
spawn_connections(v1, manager, t1, 10, "p");
|
||||||
connections_t v;
|
connections_t v;
|
||||||
std::copy(v1.begin(), v1.end(), std::back_inserter(v));
|
std::copy(v1.begin(), v1.end(), std::back_inserter(v));
|
||||||
boost::shared_ptr<peer_connection> p(
|
boost::shared_ptr<peer_connection> p =
|
||||||
new peer_connection(manager, t1, 1, false, "no-priority"));
|
boost::make_shared<peer_connection>(manager, t1, 1, false, "no-priority");
|
||||||
v.push_back(p);
|
v.push_back(p);
|
||||||
run_test(v, manager);
|
run_test(v, manager);
|
||||||
|
|
||||||
|
@ -440,8 +439,8 @@ void test_no_starvation(int limit)
|
||||||
spawn_connections(v1, manager, t1, num_peers, "p");
|
spawn_connections(v1, manager, t1, num_peers, "p");
|
||||||
connections_t v;
|
connections_t v;
|
||||||
std::copy(v1.begin(), v1.end(), std::back_inserter(v));
|
std::copy(v1.begin(), v1.end(), std::back_inserter(v));
|
||||||
boost::shared_ptr<peer_connection> p(
|
boost::shared_ptr<peer_connection> p =
|
||||||
new peer_connection(manager, t2, 1, false, "no-priority"));
|
boost::make_shared<peer_connection>(manager, t2, 1, false, "no-priority");
|
||||||
v.push_back(p);
|
v.push_back(p);
|
||||||
run_test(v, manager);
|
run_test(v, manager);
|
||||||
|
|
||||||
|
@ -517,5 +516,3 @@ TORRENT_TEST(no_starvation)
|
||||||
{
|
{
|
||||||
test_no_starvation(40000);
|
test_no_starvation(40000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ static void nop() {}
|
||||||
fs.set_piece_length(0x8000); \
|
fs.set_piece_length(0x8000); \
|
||||||
fs.set_num_pieces(5); \
|
fs.set_num_pieces(5); \
|
||||||
test_storage_impl* st = new test_storage_impl; \
|
test_storage_impl* st = new test_storage_impl; \
|
||||||
boost::shared_ptr<piece_manager> pm(boost::make_shared<piece_manager>(st, boost::shared_ptr<int>(new int), &fs)); \
|
std::shared_ptr<piece_manager> pm = std::make_shared<piece_manager>(st, boost::shared_ptr<int>(new int), &fs); \
|
||||||
error_code ec; \
|
error_code ec; \
|
||||||
bc.set_settings(sett, ec); \
|
bc.set_settings(sett, ec); \
|
||||||
st->m_settings = &sett; \
|
st->m_settings = &sett; \
|
||||||
|
|
|
@ -463,7 +463,7 @@ void test_check_files(std::string const& test_path
|
||||||
p.mode = storage_mode;
|
p.mode = storage_mode;
|
||||||
|
|
||||||
boost::shared_ptr<void> dummy;
|
boost::shared_ptr<void> dummy;
|
||||||
boost::shared_ptr<piece_manager> pm = boost::make_shared<piece_manager>(new default_storage(p), dummy, &fs);
|
std::shared_ptr<piece_manager> pm = std::make_shared<piece_manager>(new default_storage(p), dummy, &fs);
|
||||||
std::mutex lock;
|
std::mutex lock;
|
||||||
|
|
||||||
bool done = false;
|
bool done = false;
|
||||||
|
@ -1377,4 +1377,3 @@ TORRENT_TEST(dont_move_intermingled_files)
|
||||||
TEST_CHECK(!exists(combine_path(test_path, combine_path("temp_storage"
|
TEST_CHECK(!exists(combine_path(test_path, combine_path("temp_storage"
|
||||||
, combine_path("_folder3", "alien_folder1")))));
|
, combine_path("_folder3", "alien_folder1")))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,8 +161,8 @@ void run_upnp_test(char const* root_filename, char const* router_model, char con
|
||||||
|
|
||||||
std::string user_agent = "test agent";
|
std::string user_agent = "test agent";
|
||||||
|
|
||||||
boost::shared_ptr<upnp> upnp_handler(new upnp(std::ref(ios)
|
std::shared_ptr<upnp> upnp_handler = std::make_shared<upnp>(std::ref(ios)
|
||||||
, user_agent, &callback, &log_callback, false));
|
, user_agent, &callback, &log_callback, false);
|
||||||
upnp_handler->start();
|
upnp_handler->start();
|
||||||
upnp_handler->discover_device();
|
upnp_handler->discover_device();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue