refactor to use std::shared_ptr with torrent (#1048)

This commit is contained in:
Alden Torres 2016-08-31 08:27:36 -04:00 committed by Arvid Norberg
parent 44a761e5c8
commit cdb15ba886
28 changed files with 269 additions and 271 deletions

View File

@ -203,8 +203,8 @@ namespace libtorrent
#if TORRENT_USE_INVARIANT_CHECKS #if TORRENT_USE_INVARIANT_CHECKS
friend class libtorrent::invariant_access; friend class libtorrent::invariant_access;
#endif #endif
typedef std::set<boost::shared_ptr<peer_connection> > connection_map; typedef std::set<boost::shared_ptr<peer_connection>> connection_map;
typedef std::unordered_map<sha1_hash, boost::shared_ptr<torrent> > torrent_map; typedef std::unordered_map<sha1_hash, std::shared_ptr<torrent>> torrent_map;
session_impl(io_service& ios); session_impl(io_service& ios);
virtual ~session_impl(); virtual ~session_impl();
@ -264,7 +264,7 @@ namespace libtorrent
// attempts, because this torrent needs more peers. // attempts, because this torrent needs more peers.
// this is typically done when a torrent starts out and // this is typically done when a torrent starts out and
// need the initial push to connect peers // need the initial push to connect peers
void prioritize_connections(boost::weak_ptr<torrent> t) override; void prioritize_connections(std::weak_ptr<torrent> t) override;
tcp::endpoint get_ipv6_interface() const override; tcp::endpoint get_ipv6_interface() const override;
tcp::endpoint get_ipv4_interface() const override; tcp::endpoint get_ipv4_interface() const override;
@ -279,26 +279,26 @@ namespace libtorrent
void incoming_connection(boost::shared_ptr<socket_type> const& s); void incoming_connection(boost::shared_ptr<socket_type> const& s);
boost::weak_ptr<torrent> find_torrent(sha1_hash const& info_hash) const override; std::weak_ptr<torrent> find_torrent(sha1_hash const& info_hash) const override;
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
//deprecated in 1.2 //deprecated in 1.2
boost::weak_ptr<torrent> find_torrent(std::string const& uuid) const; std::weak_ptr<torrent> find_torrent(std::string const& uuid) const;
#endif #endif
#ifndef TORRENT_DISABLE_MUTABLE_TORRENTS #ifndef TORRENT_DISABLE_MUTABLE_TORRENTS
std::vector<boost::shared_ptr<torrent> > find_collection( std::vector<std::shared_ptr<torrent>> find_collection(
std::string const& collection) const override; std::string const& collection) const override;
#endif #endif
boost::weak_ptr<torrent> find_disconnect_candidate_torrent() const override; std::weak_ptr<torrent> find_disconnect_candidate_torrent() const override;
int num_torrents() const override { return int(m_torrents.size()); } int num_torrents() const override { return int(m_torrents.size()); }
void insert_torrent(sha1_hash const& ih, boost::shared_ptr<torrent> const& t void insert_torrent(sha1_hash const& ih, std::shared_ptr<torrent> const& t
, std::string uuid) override; , std::string uuid) override;
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
//deprecated in 1.2 //deprecated in 1.2
void insert_uuid_torrent(std::string uuid, boost::shared_ptr<torrent> const& t) override void insert_uuid_torrent(std::string uuid, std::shared_ptr<torrent> const& t) override
{ m_uuids.insert(std::make_pair(uuid, t)); } { m_uuids.insert(std::make_pair(uuid, t)); }
#endif #endif
boost::shared_ptr<torrent> delay_load_torrent(sha1_hash const& info_hash std::shared_ptr<torrent> delay_load_torrent(sha1_hash const& info_hash
, peer_connection* pc) override; , peer_connection* pc) override;
void set_queue_position(torrent* t, int p) override; void set_queue_position(torrent* t, int p) override;
@ -335,7 +335,7 @@ namespace libtorrent
// this is called for torrents when they are started // this is called for torrents when they are started
// it will prioritize them for announcing to // it will prioritize them for announcing to
// the DHT, to get the initial peers quickly // the DHT, to get the initial peers quickly
void prioritize_dht(boost::weak_ptr<torrent> t) override; void prioritize_dht(std::weak_ptr<torrent> t) override;
void get_immutable_callback(sha1_hash target void get_immutable_callback(sha1_hash target
, dht::item const& i); , dht::item const& i);
@ -374,7 +374,7 @@ namespace libtorrent
torrent const* find_encrypted_torrent( torrent const* find_encrypted_torrent(
sha1_hash const& info_hash, sha1_hash const& xor_mask) override; sha1_hash const& info_hash, sha1_hash const& xor_mask) override;
void add_obfuscated_hash(sha1_hash const& obfuscated, boost::weak_ptr<torrent> const& t) override; void add_obfuscated_hash(sha1_hash const& obfuscated, std::weak_ptr<torrent> const& t) override;
#endif #endif
void on_port_map_log(char const* msg, int map_transport); void on_port_map_log(char const* msg, int map_transport);
@ -403,7 +403,7 @@ namespace libtorrent
void ban_ip(address addr) override; void ban_ip(address addr) override;
void queue_tracker_request(tracker_request& req void queue_tracker_request(tracker_request& req
, boost::weak_ptr<request_callback> c) override; , std::weak_ptr<request_callback> c) override;
// ==== peer class operations ==== // ==== peer class operations ====
@ -432,19 +432,19 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
void add_extensions_to_torrent( void add_extensions_to_torrent(
boost::shared_ptr<torrent> const& torrent_ptr, void* userdata); std::shared_ptr<torrent> const& torrent_ptr, void* userdata);
#endif #endif
torrent_handle add_torrent(add_torrent_params const&, error_code& ec); torrent_handle add_torrent(add_torrent_params const&, error_code& ec);
// second return value is true if the torrent was added and false if an // second return value is true if the torrent was added and false if an
// existing one was found. // existing one was found.
std::pair<boost::shared_ptr<torrent>, bool> std::pair<std::shared_ptr<torrent>, bool>
add_torrent_impl(add_torrent_params& p, error_code& ec); add_torrent_impl(add_torrent_params& p, error_code& ec);
void async_add_torrent(add_torrent_params* params); void async_add_torrent(add_torrent_params* params);
void on_async_load_torrent(disk_io_job const* j); void on_async_load_torrent(disk_io_job const* j);
void remove_torrent(torrent_handle const& h, int options) override; void remove_torrent(torrent_handle const& h, int options) override;
void remove_torrent_impl(boost::shared_ptr<torrent> tptr, int options) override; void remove_torrent_impl(std::shared_ptr<torrent> tptr, int options) override;
void get_torrent_status(std::vector<torrent_status>* ret void get_torrent_status(std::vector<torrent_status>* ret
, std::function<bool(torrent_status const&)> const& pred , std::function<bool(torrent_status const&)> const& pred
@ -818,7 +818,7 @@ namespace libtorrent
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
//deprecated in 1.2 //deprecated in 1.2
std::map<std::string, boost::shared_ptr<torrent> > m_uuids; std::map<std::string, std::shared_ptr<torrent>> m_uuids;
#endif #endif
// peer connections are put here when disconnected to avoid // peer connections are put here when disconnected to avoid
@ -827,7 +827,7 @@ namespace libtorrent
// once a peer is disconnected, it's put in this list and // once a peer is disconnected, it's put in this list and
// every second their refcount is checked, and if it's 1, // every second their refcount is checked, and if it's 1,
// they are deleted (from the network thread) // they are deleted (from the network thread)
std::vector<boost::shared_ptr<peer_connection> > m_undead_peers; std::vector<boost::shared_ptr<peer_connection>> m_undead_peers;
// keep the io_service alive until we have posted the job // keep the io_service alive until we have posted the job
// to clear the undead peers // to clear the undead peers
@ -1115,11 +1115,11 @@ namespace libtorrent
// in this queue and get announced the next time // in this queue and get announced the next time
// the timer fires, instead of the next one in // the timer fires, instead of the next one in
// the round-robin sequence. // the round-robin sequence.
std::deque<boost::weak_ptr<torrent> > m_dht_torrents; std::deque<std::weak_ptr<torrent>> m_dht_torrents;
#endif #endif
// torrents prioritized to get connection attempts // torrents prioritized to get connection attempts
std::deque<std::pair<boost::weak_ptr<torrent>, int> > m_prio_torrents; std::deque<std::pair<std::weak_ptr<torrent>, int>> m_prio_torrents;
// this announce timer is used // this announce timer is used
// by Local service discovery // by Local service discovery

View File

@ -169,7 +169,7 @@ namespace libtorrent { namespace aux
virtual void evict_torrent(torrent* t) = 0; virtual void evict_torrent(torrent* t) = 0;
virtual void remove_torrent(torrent_handle const& h, int options = 0) = 0; virtual void remove_torrent(torrent_handle const& h, int options = 0) = 0;
virtual void remove_torrent_impl(boost::shared_ptr<torrent> tptr, int options) = 0; virtual void remove_torrent_impl(std::shared_ptr<torrent> tptr, int options) = 0;
// port filter // port filter
virtual port_filter const& get_port_filter() const = 0; virtual port_filter const& get_port_filter() const = 0;
@ -183,15 +183,15 @@ namespace libtorrent { namespace aux
virtual void trigger_optimistic_unchoke() = 0; virtual void trigger_optimistic_unchoke() = 0;
virtual void trigger_unchoke() = 0; virtual void trigger_unchoke() = 0;
virtual boost::weak_ptr<torrent> find_torrent(sha1_hash const& info_hash) const = 0; virtual std::weak_ptr<torrent> find_torrent(sha1_hash const& info_hash) const = 0;
virtual boost::weak_ptr<torrent> find_disconnect_candidate_torrent() const = 0; virtual std::weak_ptr<torrent> find_disconnect_candidate_torrent() const = 0;
virtual boost::shared_ptr<torrent> delay_load_torrent(sha1_hash const& info_hash virtual std::shared_ptr<torrent> delay_load_torrent(sha1_hash const& info_hash
, peer_connection* pc) = 0; , peer_connection* pc) = 0;
virtual void insert_torrent(sha1_hash const& ih, boost::shared_ptr<torrent> const& t virtual void insert_torrent(sha1_hash const& ih, std::shared_ptr<torrent> const& t
, std::string uuid) = 0; , std::string uuid) = 0;
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
//deprecated in 1.2 //deprecated in 1.2
virtual void insert_uuid_torrent(std::string uuid, boost::shared_ptr<torrent> const& t) = 0; virtual void insert_uuid_torrent(std::string uuid, std::shared_ptr<torrent> const& t) = 0;
#endif #endif
virtual void set_queue_position(torrent* t, int p) = 0; virtual void set_queue_position(torrent* t, int p) = 0;
virtual int num_torrents() const = 0; virtual int num_torrents() const = 0;
@ -229,7 +229,7 @@ namespace libtorrent { namespace aux
, error_code& ec) = 0; , error_code& ec) = 0;
#ifndef TORRENT_DISABLE_MUTABLE_TORRENTS #ifndef TORRENT_DISABLE_MUTABLE_TORRENTS
virtual std::vector<boost::shared_ptr<torrent> > find_collection( virtual std::vector<std::shared_ptr<torrent>> find_collection(
std::string const& collection) const = 0; std::string const& collection) const = 0;
#endif #endif
@ -241,7 +241,7 @@ namespace libtorrent { namespace aux
virtual char const* i2p_session() const = 0; virtual char const* i2p_session() const = 0;
#endif #endif
virtual void prioritize_connections(boost::weak_ptr<torrent> t) = 0; virtual void prioritize_connections(std::weak_ptr<torrent> t) = 0;
virtual tcp::endpoint get_ipv4_interface() const = 0; virtual tcp::endpoint get_ipv4_interface() const = 0;
virtual tcp::endpoint get_ipv6_interface() const = 0; virtual tcp::endpoint get_ipv6_interface() const = 0;
@ -252,7 +252,7 @@ namespace libtorrent { namespace aux
virtual session_settings const& settings() const = 0; virtual session_settings const& settings() const = 0;
virtual void queue_tracker_request(tracker_request& req virtual void queue_tracker_request(tracker_request& req
, boost::weak_ptr<request_callback> c) = 0; , std::weak_ptr<request_callback> c) = 0;
// peer-classes // peer-classes
virtual void set_peer_classes(peer_class_set* s, address const& a, int st) = 0; virtual void set_peer_classes(peer_class_set* s, address const& a, int st) = 0;
@ -323,7 +323,7 @@ namespace libtorrent { namespace aux
virtual torrent const* find_encrypted_torrent( virtual torrent const* find_encrypted_torrent(
sha1_hash const& info_hash, sha1_hash const& xor_mask) = 0; sha1_hash const& info_hash, sha1_hash const& xor_mask) = 0;
virtual void add_obfuscated_hash(sha1_hash const& obfuscated virtual void add_obfuscated_hash(sha1_hash const& obfuscated
, boost::weak_ptr<torrent> const& t) = 0; , std::weak_ptr<torrent> const& t) = 0;
#endif #endif
#ifndef TORRENT_DISABLE_DHT #ifndef TORRENT_DISABLE_DHT
@ -332,7 +332,7 @@ namespace libtorrent { namespace aux
virtual bool has_dht() const = 0; virtual bool has_dht() const = 0;
virtual int external_udp_port() const = 0; virtual int external_udp_port() const = 0;
virtual dht::dht_tracker* dht() = 0; virtual dht::dht_tracker* dht() = 0;
virtual void prioritize_dht(boost::weak_ptr<torrent> t) = 0; virtual void prioritize_dht(std::weak_ptr<torrent> t) = 0;
#endif #endif
virtual counters& stats_counters() = 0; virtual counters& stats_counters() = 0;

View File

@ -70,7 +70,7 @@ namespace libtorrent
io_service& ios io_service& ios
, tracker_manager& man , tracker_manager& man
, tracker_request const& req , tracker_request const& req
, boost::weak_ptr<request_callback> c); , std::weak_ptr<request_callback> c);
void start(); void start();
void close(); void close();

View File

@ -163,7 +163,7 @@ namespace libtorrent
buffer_allocator_interface* allocator; buffer_allocator_interface* allocator;
disk_interface* disk_thread; disk_interface* disk_thread;
io_service* ios; io_service* ios;
boost::weak_ptr<torrent> tor; std::weak_ptr<torrent> tor;
boost::shared_ptr<socket_type> s; boost::shared_ptr<socket_type> s;
tcp::endpoint endp; tcp::endpoint endp;
torrent_peer* peerinfo; torrent_peer* peerinfo;
@ -176,7 +176,7 @@ namespace libtorrent
{ {
// if tor is set, this is an outgoing connection // if tor is set, this is an outgoing connection
peer_connection_hot_members( peer_connection_hot_members(
boost::weak_ptr<torrent> t std::weak_ptr<torrent> t
, aux::session_interface& ses , aux::session_interface& ses
, aux::session_settings const& sett) , aux::session_settings const& sett)
: m_torrent(t) : m_torrent(t)
@ -207,7 +207,7 @@ namespace libtorrent
// the first cache line) and make the constructor // the first cache line) and make the constructor
// take a raw pointer. torrent objects should always // take a raw pointer. torrent objects should always
// outlive their peers // outlive their peers
boost::weak_ptr<torrent> m_torrent; std::weak_ptr<torrent> m_torrent;
public: public:
@ -451,7 +451,7 @@ namespace libtorrent
// may be zero if the connection is an incoming connection // may be zero if the connection is an incoming connection
// and it hasn't received enough information to determine // and it hasn't received enough information to determine
// which torrent it should be associated with // which torrent it should be associated with
boost::weak_ptr<torrent> associated_torrent() const std::weak_ptr<torrent> associated_torrent() const
{ return m_torrent; } { return m_torrent; }
stat const& statistics() const { return m_statistics; } stat const& statistics() const { return m_statistics; }
@ -790,7 +790,7 @@ namespace libtorrent
void on_disk_read_complete(disk_io_job const* j, peer_request r void on_disk_read_complete(disk_io_job const* j, peer_request r
, time_point issue_time); , time_point issue_time);
void on_disk_write_complete(disk_io_job const* j void on_disk_write_complete(disk_io_job const* j
, peer_request r, boost::shared_ptr<torrent> t); , peer_request r, std::shared_ptr<torrent> t);
void on_seed_mode_hashed(disk_io_job const* j); void on_seed_mode_hashed(disk_io_job const* j);
int request_timeout() const; int request_timeout() const;
void check_graceful_pause(); void check_graceful_pause();

View File

@ -561,7 +561,7 @@ namespace libtorrent
piece_manager( piece_manager(
storage_interface* storage_impl storage_interface* storage_impl
, boost::shared_ptr<void> const& torrent , std::shared_ptr<void> const& torrent
, file_storage* files); , file_storage* files);
~piece_manager(); ~piece_manager();
@ -610,7 +610,7 @@ namespace libtorrent
// to keep the torrent object alive until // to keep the torrent object alive until
// the piece_manager destructs. This is because // the piece_manager destructs. This is because
// the torrent_info object is owned by the torrent. // the torrent_info object is owned by the torrent.
boost::shared_ptr<void> m_torrent; std::shared_ptr<void> m_torrent;
}; };
// this identifies a read or write operation so that readwritev() knows // this identifies a read or write operation so that readwritev() knows

View File

@ -266,7 +266,7 @@ namespace libtorrent
, private torrent_hot_members , private torrent_hot_members
, public request_callback , public request_callback
, public peer_class_set , public peer_class_set
, public boost::enable_shared_from_this<torrent> , public std::enable_shared_from_this<torrent>
, public list_node<torrent> // used for torrent activity LRU , public list_node<torrent> // used for torrent activity LRU
{ {
public: public:
@ -1125,13 +1125,13 @@ namespace libtorrent
void update_tracker_timer(time_point now); void update_tracker_timer(time_point now);
static void on_tracker_announce_disp(boost::weak_ptr<torrent> p static void on_tracker_announce_disp(std::weak_ptr<torrent> p
, error_code const& e); , error_code const& e);
void on_tracker_announce(); void on_tracker_announce();
#ifndef TORRENT_DISABLE_DHT #ifndef TORRENT_DISABLE_DHT
static void on_dht_announce_response_disp(boost::weak_ptr<torrent> t static void on_dht_announce_response_disp(std::weak_ptr<torrent> t
, std::vector<tcp::endpoint> const& peers); , std::vector<tcp::endpoint> const& peers);
void on_dht_announce_response(std::vector<tcp::endpoint> const& peers); void on_dht_announce_response(std::vector<tcp::endpoint> const& peers);
bool should_announce_dht() const; bool should_announce_dht() const;

View File

@ -1285,7 +1285,7 @@ namespace libtorrent
// This function is intended only for use by plugins and the alert // This function is intended only for use by plugins and the alert
// dispatch function. This type does not have a stable API and should // dispatch function. This type does not have a stable API and should
// be relied on as little as possible. // be relied on as little as possible.
boost::shared_ptr<torrent> native_handle() const; std::shared_ptr<torrent> native_handle() const;
private: private:
@ -1298,10 +1298,10 @@ namespace libtorrent
template<typename Ret, typename Fun, typename... Args> template<typename Ret, typename Fun, typename... Args>
Ret sync_call_ret(Ret def, Fun f, Args&&... a) const; Ret sync_call_ret(Ret def, Fun f, Args&&... a) const;
torrent_handle(boost::weak_ptr<torrent> const& t) torrent_handle(std::weak_ptr<torrent> const& t)
{ if (!t.expired()) m_torrent = t; } { if (!t.expired()) m_torrent = t; }
boost::weak_ptr<torrent> m_torrent; std::weak_ptr<torrent> m_torrent;
}; };

View File

@ -297,12 +297,12 @@ namespace libtorrent
tracker_connection(tracker_manager& man tracker_connection(tracker_manager& man
, tracker_request const& req , tracker_request const& req
, io_service& ios , io_service& ios
, boost::weak_ptr<request_callback> r); , std::weak_ptr<request_callback> r);
void update_transaction_id(boost::shared_ptr<udp_tracker_connection> c void update_transaction_id(boost::shared_ptr<udp_tracker_connection> c
, std::uint64_t tid); , std::uint64_t tid);
boost::shared_ptr<request_callback> requester() const; std::shared_ptr<request_callback> requester() const;
virtual ~tracker_connection() {} virtual ~tracker_connection() {}
tracker_request const& tracker_req() const { return m_req; } tracker_request const& tracker_req() const { return m_req; }
@ -330,7 +330,7 @@ namespace libtorrent
void fail_impl(error_code const& ec, int code = -1, std::string msg = std::string() void fail_impl(error_code const& ec, int code = -1, std::string msg = std::string()
, int interval = 0, int min_interval = 0); , int interval = 0, int min_interval = 0);
boost::weak_ptr<request_callback> m_requester; std::weak_ptr<request_callback> m_requester;
tracker_manager& m_man; tracker_manager& m_man;
}; };
@ -362,8 +362,8 @@ namespace libtorrent
void queue_request( void queue_request(
io_service& ios io_service& ios
, tracker_request r , tracker_request r
, boost::weak_ptr<request_callback> c , std::weak_ptr<request_callback> c
= boost::weak_ptr<request_callback>()); = std::weak_ptr<request_callback>());
void abort_all_requests(bool all = false); void abort_all_requests(bool all = false);
void remove_request(tracker_connection const*); void remove_request(tracker_connection const*);

View File

@ -63,7 +63,7 @@ namespace libtorrent
io_service& ios io_service& ios
, tracker_manager& man , tracker_manager& man
, tracker_request const& req , tracker_request const& req
, boost::weak_ptr<request_callback> c); , std::weak_ptr<request_callback> c);
void start(); void start();
void close(); void close();

View File

@ -60,7 +60,7 @@ namespace libtorrent {
: handle(h) : handle(h)
, m_alloc(alloc) , m_alloc(alloc)
{ {
boost::shared_ptr<torrent> t = h.native_handle(); std::shared_ptr<torrent> t = h.native_handle();
if (t) if (t)
{ {
std::string name_str = t->name(); std::string name_str = t->name();

View File

@ -210,7 +210,7 @@ namespace libtorrent
{ {
if (is_disconnecting()) return; if (is_disconnecting()) return;
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
if (t->graceful_pause()) if (t->graceful_pause())
@ -324,7 +324,7 @@ namespace libtorrent
if (m_sent_bitfield) return; if (m_sent_bitfield) return;
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
write_bitfield(); write_bitfield();
TORRENT_ASSERT(m_sent_bitfield); TORRENT_ASSERT(m_sent_bitfield);
@ -437,7 +437,7 @@ namespace libtorrent
TORRENT_ASSERT(m_sent_handshake); TORRENT_ASSERT(m_sent_handshake);
TORRENT_ASSERT(m_sent_bitfield); TORRENT_ASSERT(m_sent_bitfield);
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
TORRENT_ASSERT(t->valid_metadata()); TORRENT_ASSERT(t->valid_metadata());
@ -551,7 +551,7 @@ namespace libtorrent
TORRENT_ASSERT(is_outgoing()); TORRENT_ASSERT(is_outgoing());
TORRENT_ASSERT(!m_sent_handshake); TORRENT_ASSERT(!m_sent_handshake);
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
hasher h; hasher h;
@ -758,7 +758,7 @@ namespace libtorrent
TORRENT_ASSERT(!m_sent_handshake); TORRENT_ASSERT(!m_sent_handshake);
m_sent_handshake = true; m_sent_handshake = true;
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
// add handshake to the send buffer // add handshake to the send buffer
@ -843,7 +843,7 @@ namespace libtorrent
boost::optional<piece_block_progress> bt_peer_connection::downloading_piece_progress() const boost::optional<piece_block_progress> bt_peer_connection::downloading_piece_progress() const
{ {
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
span<char const> recv_buffer = m_recv_buffer.get(); span<char const> recv_buffer = m_recv_buffer.get();
@ -916,7 +916,7 @@ namespace libtorrent
// assume that the choke message implies that all // assume that the choke message implies that all
// of our requests are rejected. Go through them and // of our requests are rejected. Go through them and
// pretend that we received reject request messages // pretend that we received reject request messages
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
while (!download_queue().empty()) while (!download_queue().empty())
{ {
@ -1044,7 +1044,7 @@ namespace libtorrent
TORRENT_ASSERT(received >= 0); TORRENT_ASSERT(received >= 0);
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
received_bytes(0, received); received_bytes(0, received);
@ -1109,7 +1109,7 @@ namespace libtorrent
span<char const> recv_buffer = m_recv_buffer.get(); span<char const> recv_buffer = m_recv_buffer.get();
int recv_pos = m_recv_buffer.pos(); // recv_buffer.end - recv_buffer.begin; int recv_pos = m_recv_buffer.pos(); // recv_buffer.end - recv_buffer.begin;
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
bool const merkle = static_cast<std::uint8_t>(recv_buffer.front()) == 250; bool const merkle = static_cast<std::uint8_t>(recv_buffer.front()) == 250;
if (merkle) if (merkle)
@ -1483,7 +1483,7 @@ namespace libtorrent
return; // unknown address type return; // unknown address type
} }
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
if (!t) return; if (!t) return;
switch (msg_type) switch (msg_type)
@ -1747,7 +1747,7 @@ namespace libtorrent
{ {
if (!m_recv_buffer.packet_finished()) return; if (!m_recv_buffer.packet_finished()) return;
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
span<char const> recv_buffer = m_recv_buffer.get(); span<char const> recv_buffer = m_recv_buffer.get();
@ -1955,7 +1955,7 @@ namespace libtorrent
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
if (m_upload_only_id == 0) return; if (m_upload_only_id == 0) return;
if (t->share_mode()) return; if (t->share_mode()) return;
@ -1987,7 +1987,7 @@ namespace libtorrent
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
if (m_share_mode_id == 0) return; if (m_share_mode_id == 0) return;
char msg[7] = {0, 0, 0, 3, msg_extended}; char msg[7] = {0, 0, 0, 3, msg_extended};
@ -2064,7 +2064,7 @@ namespace libtorrent
// know whether to send a have-all or have-none? // know whether to send a have-all or have-none?
TORRENT_ASSERT(m_state >= state_t::read_peer_id); TORRENT_ASSERT(m_state >= state_t::read_peer_id);
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
TORRENT_ASSERT(m_sent_handshake); TORRENT_ASSERT(m_sent_handshake);
TORRENT_ASSERT(t->valid_metadata()); TORRENT_ASSERT(t->valid_metadata());
@ -2201,7 +2201,7 @@ namespace libtorrent
#endif #endif
handshake["yourip"] = remote_address; handshake["yourip"] = remote_address;
handshake["reqq"] = m_settings.get_int(settings_pack::max_allowed_in_request_queue); handshake["reqq"] = m_settings.get_int(settings_pack::max_allowed_in_request_queue);
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
m["upload_only"] = upload_only_msg; m["upload_only"] = upload_only_msg;
@ -2409,7 +2409,7 @@ namespace libtorrent
TORRENT_ASSERT(m_sent_handshake); TORRENT_ASSERT(m_sent_handshake);
TORRENT_ASSERT(m_sent_bitfield); TORRENT_ASSERT(m_sent_bitfield);
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
bool merkle = t->torrent_file().is_merkle_torrent() && r.start == 0; bool merkle = t->torrent_file().is_merkle_torrent() && r.start == 0;
@ -2553,7 +2553,7 @@ namespace libtorrent
void bt_peer_connection::on_receive_impl(std::size_t bytes_transferred) void bt_peer_connection::on_receive_impl(std::size_t bytes_transferred)
{ {
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
span<char const> recv_buffer = m_recv_buffer.get(); span<char const> recv_buffer = m_recv_buffer.get();
@ -3561,7 +3561,7 @@ namespace libtorrent
if (amount_payload > 0) if (amount_payload > 0)
{ {
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
if (t) t->update_last_upload(); if (t) t->update_last_upload();
} }
@ -3570,7 +3570,7 @@ namespace libtorrent
#if TORRENT_USE_INVARIANT_CHECKS #if TORRENT_USE_INVARIANT_CHECKS
void bt_peer_connection::check_invariant() const void bt_peer_connection::check_invariant() const
{ {
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
TORRENT_ASSERT( (bool(m_state != state_t::read_pe_dhkey) || m_dh_key_exchange.get()) TORRENT_ASSERT( (bool(m_state != state_t::read_pe_dhkey) || m_dh_key_exchange.get())

View File

@ -50,9 +50,9 @@ namespace libtorrent
{ {
// if one peer belongs to a higher priority torrent than the other one // if one peer belongs to a higher priority torrent than the other one
// that one should be unchoked. // that one should be unchoked.
boost::shared_ptr<torrent> t1 = lhs->associated_torrent().lock(); std::shared_ptr<torrent> t1 = lhs->associated_torrent().lock();
TORRENT_ASSERT(t1); TORRENT_ASSERT(t1);
boost::shared_ptr<torrent> t2 = rhs->associated_torrent().lock(); std::shared_ptr<torrent> t2 = rhs->associated_torrent().lock();
TORRENT_ASSERT(t2); TORRENT_ASSERT(t2);
int prio1 = lhs->get_priority(peer_connection::upload_channel); int prio1 = lhs->get_priority(peer_connection::upload_channel);
@ -113,9 +113,9 @@ namespace libtorrent
{ {
// if one peer belongs to a higher priority torrent than the other one // if one peer belongs to a higher priority torrent than the other one
// that one should be unchoked. // that one should be unchoked.
boost::shared_ptr<torrent> t1 = lhs->associated_torrent().lock(); std::shared_ptr<torrent> t1 = lhs->associated_torrent().lock();
TORRENT_ASSERT(t1); TORRENT_ASSERT(t1);
boost::shared_ptr<torrent> t2 = rhs->associated_torrent().lock(); std::shared_ptr<torrent> t2 = rhs->associated_torrent().lock();
TORRENT_ASSERT(t2); TORRENT_ASSERT(t2);
int prio1 = lhs->get_priority(peer_connection::upload_channel); int prio1 = lhs->get_priority(peer_connection::upload_channel);
@ -155,9 +155,9 @@ namespace libtorrent
{ {
// if one peer belongs to a higher priority torrent than the other one // if one peer belongs to a higher priority torrent than the other one
// that one should be unchoked. // that one should be unchoked.
boost::shared_ptr<torrent> t1 = lhs->associated_torrent().lock(); std::shared_ptr<torrent> t1 = lhs->associated_torrent().lock();
TORRENT_ASSERT(t1); TORRENT_ASSERT(t1);
boost::shared_ptr<torrent> t2 = rhs->associated_torrent().lock(); std::shared_ptr<torrent> t2 = rhs->associated_torrent().lock();
TORRENT_ASSERT(t2); TORRENT_ASSERT(t2);
int prio1 = lhs->get_priority(peer_connection::upload_channel); int prio1 = lhs->get_priority(peer_connection::upload_channel);

View File

@ -268,7 +268,7 @@ namespace libtorrent
} }
// dummy torrent object pointer // dummy torrent object pointer
boost::shared_ptr<char> dummy; std::shared_ptr<char> dummy;
counters cnt; counters cnt;
disk_io_thread disk_thread(ios, cnt, nullptr); disk_io_thread disk_thread(ios, cnt, nullptr);
disk_thread.set_num_threads(1); disk_thread.set_num_threads(1);

View File

@ -57,7 +57,7 @@ namespace libtorrent
if (!m_settings.get_bool(settings_pack::report_web_seed_downloads)) if (!m_settings.get_bool(settings_pack::report_web_seed_downloads))
ignore_stats(true); ignore_stats(true);
shared_ptr<torrent> tor = pack.tor.lock(); std::shared_ptr<torrent> tor = pack.tor.lock();
TORRENT_ASSERT(tor); TORRENT_ASSERT(tor);
int blocks_per_piece = tor->torrent_file().piece_length() / tor->block_size(); int blocks_per_piece = tor->torrent_file().piece_length() / tor->block_size();
@ -85,7 +85,7 @@ namespace libtorrent
m_web->endpoints.erase(m_web->endpoints.begin()); m_web->endpoints.erase(m_web->endpoints.begin());
} }
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
peer_connection::disconnect(ec, op, error); peer_connection::disconnect(ec, op, error);
if (t) t->disconnect_web_seed(this); if (t) t->disconnect_web_seed(this);
} }
@ -96,7 +96,7 @@ namespace libtorrent
if (m_requests.empty()) if (m_requests.empty())
return boost::optional<piece_block_progress>(); return boost::optional<piece_block_progress>();
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
piece_block_progress ret; piece_block_progress ret;
@ -132,7 +132,7 @@ namespace libtorrent
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
TORRENT_ASSERT(t->valid_metadata()); TORRENT_ASSERT(t->valid_metadata());
@ -210,7 +210,7 @@ namespace libtorrent
return; return;
} }
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
for (;;) for (;;)

View File

@ -65,7 +65,7 @@ namespace libtorrent
io_service& ios io_service& ios
, tracker_manager& man , tracker_manager& man
, tracker_request const& req , tracker_request const& req
, boost::weak_ptr<request_callback> c) , std::weak_ptr<request_callback> c)
: tracker_connection(man, req, ios, c) : tracker_connection(man, req, ios, c)
, m_man(man) , m_man(man)
#if TORRENT_USE_I2P #if TORRENT_USE_I2P
@ -239,7 +239,7 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> cb = requester(); std::shared_ptr<request_callback> cb = requester();
if (cb) if (cb)
{ {
cb->debug_log("==> TRACKER_REQUEST [ url: %s ]", url.c_str()); cb->debug_log("==> TRACKER_REQUEST [ url: %s ]", url.c_str());
@ -275,7 +275,7 @@ namespace libtorrent
} }
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> cb = requester(); std::shared_ptr<request_callback> cb = requester();
if (cb) if (cb)
{ {
cb->debug_log("*** TRACKER_FILTER"); cb->debug_log("*** TRACKER_FILTER");
@ -290,7 +290,7 @@ namespace libtorrent
error_code ec; error_code ec;
tcp::endpoint ep = c.socket().remote_endpoint(ec); tcp::endpoint ep = c.socket().remote_endpoint(ec);
m_tracker_ip = ep.address(); m_tracker_ip = ep.address();
boost::shared_ptr<request_callback> cb = requester(); std::shared_ptr<request_callback> cb = requester();
} }
void http_tracker_connection::on_response(error_code const& ec void http_tracker_connection::on_response(error_code const& ec
@ -329,7 +329,7 @@ namespace libtorrent
// handle tracker response // handle tracker response
error_code ecode; error_code ecode;
boost::shared_ptr<request_callback> cb = requester(); std::shared_ptr<request_callback> cb = requester();
if (!cb) if (!cb)
{ {
close(); close();

View File

@ -104,7 +104,7 @@ namespace libtorrent
#if TORRENT_USE_ASSERTS #if TORRENT_USE_ASSERTS
bool peer_connection::is_single_thread() const bool peer_connection::is_single_thread() const
{ {
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (!t) return true; if (!t) return true;
return t->is_single_thread(); return t->is_single_thread();
} }
@ -149,7 +149,7 @@ namespace libtorrent
else if (m_connecting) else if (m_connecting)
m_counters.inc_stats_counter(counters::num_peers_half_open); m_counters.inc_stats_counter(counters::num_peers_half_open);
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
// if t is nullptr, we better not be connecting, since // if t is nullptr, we better not be connecting, since
// we can't decrement the connecting counter // we can't decrement the connecting counter
TORRENT_ASSERT(t || !m_connecting); TORRENT_ASSERT(t || !m_connecting);
@ -221,7 +221,7 @@ namespace libtorrent
if (prio < class_prio) prio = class_prio; if (prio < class_prio) prio = class_prio;
} }
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
if (t) if (t)
{ {
@ -245,7 +245,7 @@ namespace libtorrent
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
TORRENT_ASSERT(m_peer_info == nullptr || m_peer_info->connection == this); TORRENT_ASSERT(m_peer_info == nullptr || m_peer_info->connection == this);
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (!m_outgoing) if (!m_outgoing)
{ {
@ -386,7 +386,7 @@ namespace libtorrent
TORRENT_ASSERT(m_need_interest_update); TORRENT_ASSERT(m_need_interest_update);
m_need_interest_update = false; m_need_interest_update = false;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (!t) return; if (!t) return;
// if m_have_piece is 0, it means the connections // if m_have_piece is 0, it means the connections
@ -460,7 +460,7 @@ namespace libtorrent
va_start(v, fmt); va_start(v, fmt);
torrent_handle h; torrent_handle h;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (t) h = t->get_handle(); if (t) h = t->get_handle();
m_ses.alerts().emplace_alert<peer_log_alert>( m_ses.alerts().emplace_alert<peer_log_alert>(
@ -484,7 +484,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
if (t->super_seeding()) if (t->super_seeding())
@ -589,7 +589,7 @@ namespace libtorrent
void peer_connection::on_metadata_impl() void peer_connection::on_metadata_impl()
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
m_have_piece.resize(t->torrent_file().num_pieces(), m_have_all); m_have_piece.resize(t->torrent_file().num_pieces(), m_have_all);
m_num_pieces = m_have_piece.count(); m_num_pieces = m_have_piece.count();
@ -623,7 +623,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
TORRENT_ASSERT(t->valid_metadata()); TORRENT_ASSERT(t->valid_metadata());
TORRENT_ASSERT(t->ready_for_connections()); TORRENT_ASSERT(t->ready_for_connections());
@ -730,7 +730,7 @@ namespace libtorrent
m_counters.inc_stats_counter(counters::num_peers_down_requests, -1); m_counters.inc_stats_counter(counters::num_peers_down_requests, -1);
// defensive // defensive
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
// if t is nullptr, we better not be connecting, since // if t is nullptr, we better not be connecting, since
// we can't decrement the connecting counter // we can't decrement the connecting counter
TORRENT_ASSERT(t || !m_connecting); TORRENT_ASSERT(t || !m_connecting);
@ -768,7 +768,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
int ret = m_picker_options; int ret = m_picker_options;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
if (!t) return 0; if (!t) return 0;
@ -863,7 +863,7 @@ namespace libtorrent
if (disconnect_if_redundant()) return; if (disconnect_if_redundant()) return;
#if TORRENT_USE_ASSERTS #if TORRENT_USE_ASSERTS
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
#endif #endif
} }
@ -892,7 +892,7 @@ namespace libtorrent
#endif #endif
write_have(index); write_have(index);
#if TORRENT_USE_ASSERTS #if TORRENT_USE_ASSERTS
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
#endif #endif
} }
@ -900,7 +900,7 @@ namespace libtorrent
bool peer_connection::has_piece(int i) const bool peer_connection::has_piece(int i) const
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
TORRENT_ASSERT(t->valid_metadata()); TORRENT_ASSERT(t->valid_metadata());
TORRENT_ASSERT(i >= 0); TORRENT_ASSERT(i >= 0);
@ -929,7 +929,7 @@ namespace libtorrent
time_duration peer_connection::download_queue_time(int extra_bytes) const time_duration peer_connection::download_queue_time(int extra_bytes) const
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
int rate = 0; int rate = 0;
@ -981,7 +981,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
m_statistics.received_bytes(bytes_payload, bytes_protocol); m_statistics.received_bytes(bytes_payload, bytes_protocol);
if (m_ignore_stats) return; if (m_ignore_stats) return;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (!t) return; if (!t) return;
t->received_bytes(bytes_payload, bytes_protocol); t->received_bytes(bytes_payload, bytes_protocol);
} }
@ -1000,7 +1000,7 @@ namespace libtorrent
} }
#endif #endif
if (m_ignore_stats) return; if (m_ignore_stats) return;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (!t) return; if (!t) return;
t->sent_bytes(bytes_payload, bytes_protocol); t->sent_bytes(bytes_payload, bytes_protocol);
} }
@ -1010,7 +1010,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
m_statistics.trancieve_ip_packet(bytes, ipv6); m_statistics.trancieve_ip_packet(bytes, ipv6);
if (m_ignore_stats) return; if (m_ignore_stats) return;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (!t) return; if (!t) return;
t->trancieve_ip_packet(bytes, ipv6); t->trancieve_ip_packet(bytes, ipv6);
} }
@ -1020,7 +1020,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
m_statistics.sent_syn(ipv6); m_statistics.sent_syn(ipv6);
if (m_ignore_stats) return; if (m_ignore_stats) return;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (!t) return; if (!t) return;
t->sent_syn(ipv6); t->sent_syn(ipv6);
} }
@ -1030,7 +1030,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
m_statistics.received_synack(ipv6); m_statistics.received_synack(ipv6);
if (m_ignore_stats) return; if (m_ignore_stats) return;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (!t) return; if (!t) return;
t->received_synack(ipv6); t->received_synack(ipv6);
} }
@ -1086,7 +1086,7 @@ namespace libtorrent
bool peer_connection::verify_piece(const peer_request& p) const bool peer_connection::verify_piece(const peer_request& p) const
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
TORRENT_ASSERT(t->valid_metadata()); TORRENT_ASSERT(t->valid_metadata());
@ -1111,8 +1111,8 @@ namespace libtorrent
TORRENT_ASSERT(!m_disconnecting); TORRENT_ASSERT(!m_disconnecting);
TORRENT_ASSERT(m_torrent.expired()); TORRENT_ASSERT(m_torrent.expired());
boost::weak_ptr<torrent> wpt = m_ses.find_torrent(ih); std::weak_ptr<torrent> wpt = m_ses.find_torrent(ih);
boost::shared_ptr<torrent> t = wpt.lock(); std::shared_ptr<torrent> t = wpt.lock();
if (t && t->is_aborted()) if (t && t->is_aborted())
{ {
@ -1208,8 +1208,8 @@ namespace libtorrent
{ {
// find a peer in some torrent (presumably the one with most peers) // find a peer in some torrent (presumably the one with most peers)
// and disconnect the lowest ranking peer // and disconnect the lowest ranking peer
boost::weak_ptr<torrent> torr = m_ses.find_disconnect_candidate_torrent(); std::weak_ptr<torrent> torr = m_ses.find_disconnect_candidate_torrent();
boost::shared_ptr<torrent> other_t = torr.lock(); std::shared_ptr<torrent> other_t = torr.lock();
if (other_t) if (other_t)
{ {
@ -1313,7 +1313,7 @@ namespace libtorrent
void peer_connection::clear_request_queue() void peer_connection::clear_request_queue()
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
if (!t->has_picker()) if (!t->has_picker())
{ {
@ -1357,7 +1357,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
@ -1455,7 +1455,7 @@ namespace libtorrent
peer_log(peer_log_alert::incoming_message, "SUGGEST_PIECE" peer_log(peer_log_alert::incoming_message, "SUGGEST_PIECE"
, "piece: %d", index); , "piece: %d", index);
#endif #endif
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (!t) return; if (!t) return;
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
@ -1516,7 +1516,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
@ -1559,7 +1559,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
@ -1630,7 +1630,7 @@ namespace libtorrent
// if the peer is choked and we have upload slots left, // if the peer is choked and we have upload slots left,
// then unchoke it. // then unchoke it.
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
t->unchoke_peer(*this); t->unchoke_peer(*this);
@ -1672,7 +1672,7 @@ namespace libtorrent
m_peer_interested = false; m_peer_interested = false;
if (is_disconnecting()) return; if (is_disconnecting()) return;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
choke_this_peer(); choke_this_peer();
@ -1688,7 +1688,7 @@ namespace libtorrent
return; return;
} }
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
if (m_peer_info && m_peer_info->optimistically_unchoked) if (m_peer_info && m_peer_info->optimistically_unchoked)
@ -1710,7 +1710,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
@ -1883,7 +1883,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
@ -1941,7 +1941,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
@ -2069,7 +2069,7 @@ namespace libtorrent
TORRENT_ASSERT(m_in_constructor == false); TORRENT_ASSERT(m_in_constructor == false);
if (!m_settings.get_bool(settings_pack::close_redundant_connections)) return false; if (!m_settings.get_bool(settings_pack::close_redundant_connections)) return false;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (!t) return false; if (!t) return false;
// if we don't have the metadata yet, don't disconnect // if we don't have the metadata yet, don't disconnect
@ -2130,7 +2130,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
m_counters.inc_stats_counter(counters::piece_requests); m_counters.inc_stats_counter(counters::piece_requests);
@ -2399,7 +2399,7 @@ namespace libtorrent
TORRENT_ASSERT(m_outstanding_bytes >= bytes); TORRENT_ASSERT(m_outstanding_bytes >= bytes);
m_outstanding_bytes -= bytes; m_outstanding_bytes -= bytes;
if (m_outstanding_bytes < 0) m_outstanding_bytes = 0; if (m_outstanding_bytes < 0) m_outstanding_bytes = 0;
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
#if TORRENT_USE_ASSERTS #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(m_received_in_piece + bytes <= t->block_size()); TORRENT_ASSERT(m_received_in_piece + bytes <= t->block_size());
m_received_in_piece += bytes; m_received_in_piece += bytes;
@ -2425,7 +2425,7 @@ namespace libtorrent
TORRENT_ASSERT(recv_pos >= 9); TORRENT_ASSERT(recv_pos >= 9);
#endif #endif
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
if (!verify_piece(r)) if (!verify_piece(r))
@ -2491,7 +2491,7 @@ namespace libtorrent
#if TORRENT_USE_INVARIANT_CHECKS #if TORRENT_USE_INVARIANT_CHECKS
struct check_postcondition struct check_postcondition
{ {
explicit check_postcondition(boost::shared_ptr<torrent> const& t_ explicit check_postcondition(std::shared_ptr<torrent> const& t_
, bool init_check = true): t(t_) { if (init_check) check(); } , bool init_check = true): t(t_) { if (init_check) check(); }
~check_postcondition() { check(); } ~check_postcondition() { check(); }
@ -2514,7 +2514,7 @@ namespace libtorrent
} }
} }
shared_ptr<torrent> t; std::shared_ptr<torrent> t;
}; };
#endif #endif
@ -2561,7 +2561,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
// we're not receiving any block right now // we're not receiving any block right now
@ -2881,7 +2881,7 @@ namespace libtorrent
// should update them when it enters graceful pause). When a peer enters // should update them when it enters graceful pause). When a peer enters
// graceful pause mode, it should cancel all outstanding requests and // graceful pause mode, it should cancel all outstanding requests and
// clear its request queue. // clear its request queue.
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (!t || !t->graceful_pause()) return; if (!t || !t->graceful_pause()) return;
if (m_outstanding_bytes > 0) return; if (m_outstanding_bytes > 0) return;
@ -2893,7 +2893,7 @@ namespace libtorrent
} }
void peer_connection::on_disk_write_complete(disk_io_job const* j void peer_connection::on_disk_write_complete(disk_io_job const* j
, peer_request p, boost::shared_ptr<torrent> t) , peer_request p, std::shared_ptr<torrent> t)
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
torrent_ref_holder h(t.get(), "async_write"); torrent_ref_holder h(t.get(), "async_write");
@ -3072,7 +3072,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
// we cannot disconnect in a constructor, and // we cannot disconnect in a constructor, and
@ -3161,7 +3161,7 @@ namespace libtorrent
peer_log(peer_log_alert::incoming_message, "HAVE_NONE"); peer_log(peer_log_alert::incoming_message, "HAVE_NONE");
#endif #endif
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
@ -3206,7 +3206,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
@ -3274,7 +3274,7 @@ namespace libtorrent
std::vector<int> const& peer_connection::allowed_fast() std::vector<int> const& peer_connection::allowed_fast()
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
// TODO: sort the allowed fast set in priority order // TODO: sort the allowed fast set in priority order
@ -3289,7 +3289,7 @@ namespace libtorrent
> m_desired_queue_size * 2) return false; > m_desired_queue_size * 2) return false;
if (on_parole()) return false; if (on_parole()) return false;
if (m_disconnecting) return false; if (m_disconnecting) return false;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
if (t->upload_mode()) return false; if (t->upload_mode()) return false;
@ -3306,7 +3306,7 @@ namespace libtorrent
, m_request_queue.end(), has_block(block)); , m_request_queue.end(), has_block(block));
if (rit == m_request_queue.end()) return false; if (rit == m_request_queue.end()) return false;
#if TORRENT_USE_ASSERTS #if TORRENT_USE_ASSERTS
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
TORRENT_ASSERT(t->has_picker()); TORRENT_ASSERT(t->has_picker());
TORRENT_ASSERT(t->picker().is_requested(block)); TORRENT_ASSERT(t->picker().is_requested(block));
@ -3325,7 +3325,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
TORRENT_ASSERT(!m_disconnecting); TORRENT_ASSERT(!m_disconnecting);
@ -3435,7 +3435,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
// this peer might be disconnecting // this peer might be disconnecting
if (!t) return; if (!t) return;
@ -3491,7 +3491,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
// this peer might be disconnecting // this peer might be disconnecting
if (!t) return; if (!t) return;
@ -3621,7 +3621,7 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
if (!m_choked) return false; if (!m_choked) return false;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (!t->ready_for_connections()) return false; if (!t->ready_for_connections()) return false;
if (m_settings.get_int(settings_pack::suggest_mode) if (m_settings.get_int(settings_pack::suggest_mode)
@ -3651,7 +3651,7 @@ namespace libtorrent
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
if (m_interesting) return; if (m_interesting) return;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (!t->ready_for_connections()) return; if (!t->ready_for_connections()) return;
m_interesting = true; m_interesting = true;
m_counters.inc_stats_counter(counters::num_peers_down_interested); m_counters.inc_stats_counter(counters::num_peers_down_interested);
@ -3675,7 +3675,7 @@ namespace libtorrent
return; return;
} }
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (!t->ready_for_connections()) return; if (!t->ready_for_connections()) return;
m_interesting = false; m_interesting = false;
m_slow_start = false; m_slow_start = false;
@ -3695,7 +3695,7 @@ namespace libtorrent
void peer_connection::send_piece_suggestions(int const num) void peer_connection::send_piece_suggestions(int const num)
{ {
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
int const new_suggestions = t->get_suggest_pieces(m_suggest_pieces int const new_suggestions = t->get_suggest_pieces(m_suggest_pieces
@ -3729,7 +3729,7 @@ namespace libtorrent
// we cannot suggest a piece we don't have! // we cannot suggest a piece we don't have!
#if TORRENT_USE_ASSERTS #if TORRENT_USE_ASSERTS
{ {
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
TORRENT_ASSERT(t->has_piece_passed(piece)); TORRENT_ASSERT(t->has_piece_passed(piece));
TORRENT_ASSERT(piece >= 0 && piece < t->torrent_file().num_pieces()); TORRENT_ASSERT(piece >= 0 && piece < t->torrent_file().num_pieces());
@ -3744,7 +3744,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
if (m_disconnecting) return; if (m_disconnecting) return;
@ -3911,7 +3911,7 @@ namespace libtorrent
m_counters.inc_stats_counter(counters::connect_timeouts); m_counters.inc_stats_counter(counters::connect_timeouts);
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(!m_connecting || t); TORRENT_ASSERT(!m_connecting || t);
if (m_connecting) if (m_connecting)
{ {
@ -4126,7 +4126,7 @@ namespace libtorrent
m_channel_state[download_channel] &= ~peer_info::bw_disk; m_channel_state[download_channel] &= ~peer_info::bw_disk;
} }
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (m_connecting) if (m_connecting)
{ {
m_counters.inc_stats_counter(counters::num_peers_half_open, -1); m_counters.inc_stats_counter(counters::num_peers_half_open, -1);
@ -4244,7 +4244,7 @@ namespace libtorrent
if (num_classes() == 0) return true; if (num_classes() == 0) return true;
if (m_ses.ignore_unchoke_slots_set(*this)) return true; if (m_ses.ignore_unchoke_slots_set(*this)) return true;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (t && m_ses.ignore_unchoke_slots_set(*t)) return true; if (t && m_ses.ignore_unchoke_slots_set(*t)) return true;
return false; return false;
} }
@ -4429,7 +4429,7 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
peer_log(peer_log_alert::info, "SUPER_SEEDING", "ending"); peer_log(peer_log_alert::info, "SUPER_SEEDING", "ending");
#endif #endif
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
assert(t); assert(t);
// this will either send a full bitfield or // this will either send a full bitfield or
@ -4502,7 +4502,7 @@ namespace libtorrent
// the minimum number of requests is 2 and the maximum is 48 // the minimum number of requests is 2 and the maximum is 48
// the block size doesn't have to be 16. So we first query the // the block size doesn't have to be 16. So we first query the
// torrent for it // torrent for it
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
int const block_size = t->block_size(); int const block_size = t->block_size();
TORRENT_ASSERT(block_size > 0); TORRENT_ASSERT(block_size > 0);
@ -4536,7 +4536,7 @@ namespace libtorrent
// in case the peer got disconnected // in case the peer got disconnected
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
int warning = 0; int warning = 0;
// drain the IP overhead from the bandwidth limiters // drain the IP overhead from the bandwidth limiters
@ -4838,7 +4838,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
if (!m_snubbed) if (!m_snubbed)
@ -4938,7 +4938,7 @@ namespace libtorrent
#endif #endif
bool sent_a_piece = false; bool sent_a_piece = false;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (!t || t->is_aborted() || m_requests.empty()) return; if (!t || t->is_aborted() || m_requests.empty()) return;
// only add new piece-chunks if the send buffer is small enough // only add new piece-chunks if the send buffer is small enough
@ -5078,7 +5078,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
torrent_ref_holder h(t.get(), "async_seed_hash"); torrent_ref_holder h(t.get(), "async_seed_hash");
if (t) t->dec_refcount("async_seed_hash"); if (t) t->dec_refcount("async_seed_hash");
@ -5149,7 +5149,7 @@ namespace libtorrent
m_reading_bytes -= r.length; m_reading_bytes -= r.length;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
torrent_ref_holder h(t.get(), "async_read"); torrent_ref_holder h(t.get(), "async_read");
if (t) t->dec_refcount("async_read"); if (t) t->dec_refcount("async_read");
@ -5267,7 +5267,7 @@ namespace libtorrent
int peer_connection::wanted_transfer(int channel) int peer_connection::wanted_transfer(int channel)
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
const int tick_interval = (std::max)(1, m_settings.get_int(settings_pack::tick_interval)); const int tick_interval = (std::max)(1, m_settings.get_int(settings_pack::tick_interval));
@ -5295,7 +5295,7 @@ namespace libtorrent
// we can only have one outstanding bandwidth request at a time // we can only have one outstanding bandwidth request at a time
if (m_channel_state[channel] & peer_info::bw_limit) return 0; if (m_channel_state[channel] & peer_info::bw_limit) return 0;
shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
bytes = (std::max)(wanted_transfer(channel), bytes); bytes = (std::max)(wanted_transfer(channel), bytes);
@ -5423,7 +5423,7 @@ namespace libtorrent
&& !m_requests.empty() && !m_requests.empty()
&& m_reading_bytes > m_settings.get_int(settings_pack::send_buffer_watermark) - 0x4000) && m_reading_bytes > m_settings.get_int(settings_pack::send_buffer_watermark) - 0x4000)
{ {
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
// we're stalled on the disk. We want to write and we can write // we're stalled on the disk. We want to write and we can write
// but our send buffer is empty, waiting to be refilled from the disk // but our send buffer is empty, waiting to be refilled from the disk
@ -5849,7 +5849,7 @@ namespace libtorrent
if (is_seed()) if (is_seed())
{ {
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (t) t->seen_complete(); if (t) t->seen_complete();
} }
@ -5876,7 +5876,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
bool bw_limit = m_quota[download_channel] > 0; bool bw_limit = m_quota[download_channel] > 0;
@ -5907,7 +5907,7 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
{ {
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (t) t->debug_log("END connect [%p]", static_cast<void*>(this)); if (t) t->debug_log("END connect [%p]", static_cast<void*>(this));
m_connect_time = completed; m_connect_time = completed;
} }
@ -5922,7 +5922,7 @@ namespace libtorrent
// if t is nullptr, we better not be connecting, since // if t is nullptr, we better not be connecting, since
// we can't decrement the connecting counter // we can't decrement the connecting counter
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t || !m_connecting); TORRENT_ASSERT(t || !m_connecting);
if (m_connecting) if (m_connecting)
{ {
@ -6177,7 +6177,7 @@ namespace libtorrent
} }
} }
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
#if TORRENT_USE_INVARIANT_CHECKS \ #if TORRENT_USE_INVARIANT_CHECKS \
&& !defined TORRENT_NO_EXPENSIVE_INVARIANT_CHECK && !defined TORRENT_NO_EXPENSIVE_INVARIANT_CHECK
@ -6448,7 +6448,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
// if m_num_pieces == 0, we probably don't have the // if m_num_pieces == 0, we probably don't have the
// metadata yet. // metadata yet.
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
return m_num_pieces == int(m_have_piece.size()) return m_num_pieces == int(m_have_piece.size())
&& m_num_pieces > 0 && t && t->valid_metadata(); && m_num_pieces > 0 && t && t->valid_metadata();
} }
@ -6470,7 +6470,7 @@ namespace libtorrent
if (m_upload_only || is_seed()) return; if (m_upload_only || is_seed()) return;
m_upload_only = u; m_upload_only = u;
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
t->set_seed(m_peer_info, u); t->set_seed(m_peer_info, u);
disconnect_if_redundant(); disconnect_if_redundant();
} }

View File

@ -140,7 +140,7 @@ torrent_handle peer_connection_handle::associated_torrent() const
{ {
boost::shared_ptr<peer_connection> pc = native_handle(); boost::shared_ptr<peer_connection> pc = native_handle();
if (!pc) return torrent_handle(); if (!pc) return torrent_handle();
boost::shared_ptr<torrent> t = pc->associated_torrent().lock(); std::shared_ptr<torrent> t = pc->associated_torrent().lock();
if (!t) return torrent_handle(); if (!t) return torrent_handle();
return t->get_handle(); return t->get_handle();
} }

View File

@ -419,7 +419,7 @@ namespace libtorrent
, torrent_handle h, int flags) const , torrent_handle h, int flags) const
{ {
piece_manager* st = nullptr; piece_manager* st = nullptr;
boost::shared_ptr<torrent> t = h.m_torrent.lock(); std::shared_ptr<torrent> t = h.m_torrent.lock();
if (t) if (t)
{ {
if (t->has_storage()) if (t->has_storage())

View File

@ -281,7 +281,7 @@ namespace aux {
return SSL_TLSEXT_ERR_ALERT_FATAL; return SSL_TLSEXT_ERR_ALERT_FATAL;
// see if there is a torrent with this info-hash // see if there is a torrent with this info-hash
boost::shared_ptr<torrent> t = ses->find_torrent(info_hash).lock(); std::shared_ptr<torrent> t = ses->find_torrent(info_hash).lock();
// if there isn't, fail // if there isn't, fail
if (!t) return SSL_TLSEXT_ERR_ALERT_FATAL; if (!t) return SSL_TLSEXT_ERR_ALERT_FATAL;
@ -1059,7 +1059,7 @@ namespace aux {
} }
void session_impl::queue_tracker_request(tracker_request& req void session_impl::queue_tracker_request(tracker_request& req
, boost::weak_ptr<request_callback> c) , std::weak_ptr<request_callback> c)
{ {
req.listen_port = listen_port(); req.listen_port = listen_port();
if (m_key) req.key = m_key; if (m_key) req.key = m_key;
@ -2764,7 +2764,7 @@ namespace aux {
pack.allocator = this; pack.allocator = this;
pack.disk_thread = &m_disk_thread; pack.disk_thread = &m_disk_thread;
pack.ios = &m_io_service; pack.ios = &m_io_service;
pack.tor = boost::weak_ptr<torrent>(); pack.tor = std::weak_ptr<torrent>();
pack.s = s; pack.s = s;
pack.endp = endp; pack.endp = endp;
pack.peerinfo = nullptr; pack.peerinfo = nullptr;
@ -3314,7 +3314,7 @@ namespace aux {
for (torrent_map::iterator i = m_torrents.begin() for (torrent_map::iterator i = m_torrents.begin()
, end(m_torrents.end()); i != end; ++i) , end(m_torrents.end()); i != end; ++i)
{ {
boost::shared_ptr<torrent> t = i->second; std::shared_ptr<torrent> t = i->second;
// ths disconnect logic is disabled for torrents with // ths disconnect logic is disabled for torrents with
// too low connection limit // too low connection limit
@ -3371,7 +3371,7 @@ namespace aux {
m_stats_counters.inc_stats_counter(counters::socket_send_size3 + index); m_stats_counters.inc_stats_counter(counters::socket_send_size3 + index);
} }
void session_impl::prioritize_connections(boost::weak_ptr<torrent> t) void session_impl::prioritize_connections(std::weak_ptr<torrent> t)
{ {
m_prio_torrents.push_back(std::make_pair(t, 10)); m_prio_torrents.push_back(std::make_pair(t, 10));
} }
@ -3391,7 +3391,7 @@ namespace aux {
return m_dht.get() != nullptr; return m_dht.get() != nullptr;
} }
void session_impl::prioritize_dht(boost::weak_ptr<torrent> t) void session_impl::prioritize_dht(std::weak_ptr<torrent> t)
{ {
TORRENT_ASSERT(!m_abort); TORRENT_ASSERT(!m_abort);
if (m_abort) return; if (m_abort) return;
@ -3399,7 +3399,7 @@ namespace aux {
TORRENT_ASSERT(m_dht); TORRENT_ASSERT(m_dht);
m_dht_torrents.push_back(t); m_dht_torrents.push_back(t);
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<torrent> tor = t.lock(); std::shared_ptr<torrent> tor = t.lock();
if (tor) if (tor)
session_log("prioritizing DHT announce: \"%s\"", tor->name().c_str()); session_log("prioritizing DHT announce: \"%s\"", tor->name().c_str());
#endif #endif
@ -3466,7 +3466,7 @@ namespace aux {
if (!m_dht_torrents.empty()) if (!m_dht_torrents.empty())
{ {
boost::shared_ptr<torrent> t; std::shared_ptr<torrent> t;
do do
{ {
t = m_dht_torrents.front().lock(); t = m_dht_torrents.front().lock();
@ -3843,7 +3843,7 @@ namespace aux {
else else
{ {
TORRENT_ASSERT(p->is_choked()); TORRENT_ASSERT(p->is_choked());
boost::shared_ptr<torrent> t = p->associated_torrent().lock(); std::shared_ptr<torrent> t = p->associated_torrent().lock();
bool ret = t->unchoke_peer(*p, true); bool ret = t->unchoke_peer(*p, true);
TORRENT_ASSERT(ret); TORRENT_ASSERT(ret);
if (ret) if (ret)
@ -3864,7 +3864,7 @@ namespace aux {
{ {
TORRENT_ASSERT(pi->optimistically_unchoked); TORRENT_ASSERT(pi->optimistically_unchoked);
peer_connection* p = static_cast<peer_connection*>(pi->connection); peer_connection* p = static_cast<peer_connection*>(pi->connection);
boost::shared_ptr<torrent> t = p->associated_torrent().lock(); std::shared_ptr<torrent> t = p->associated_torrent().lock();
pi->optimistically_unchoked = false; pi->optimistically_unchoked = false;
m_stats_counters.inc_stats_counter(counters::num_peers_up_unchoked_optimistic, -1); m_stats_counters.inc_stats_counter(counters::num_peers_up_unchoked_optimistic, -1);
t->choke_peer(*p); t->choke_peer(*p);
@ -4184,7 +4184,7 @@ namespace aux {
m_delayed_uncorks.clear(); m_delayed_uncorks.clear();
} }
boost::shared_ptr<torrent> session_impl::delay_load_torrent(sha1_hash const& info_hash std::shared_ptr<torrent> session_impl::delay_load_torrent(sha1_hash const& info_hash
, peer_connection* pc) , peer_connection* pc)
{ {
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
@ -4203,12 +4203,12 @@ namespace aux {
TORRENT_UNUSED(pc); TORRENT_UNUSED(pc);
TORRENT_UNUSED(info_hash); TORRENT_UNUSED(info_hash);
#endif #endif
return boost::shared_ptr<torrent>(); return std::shared_ptr<torrent>();
} }
// the return value from this function is valid only as long as the // the return value from this function is valid only as long as the
// session is locked! // session is locked!
boost::weak_ptr<torrent> session_impl::find_torrent(sha1_hash const& info_hash) const std::weak_ptr<torrent> session_impl::find_torrent(sha1_hash const& info_hash) const
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
@ -4222,10 +4222,10 @@ namespace aux {
} }
#endif #endif
if (i != m_torrents.end()) return i->second; if (i != m_torrents.end()) return i->second;
return boost::weak_ptr<torrent>(); return std::weak_ptr<torrent>();
} }
void session_impl::insert_torrent(sha1_hash const& ih, boost::shared_ptr<torrent> const& t void session_impl::insert_torrent(sha1_hash const& ih, std::shared_ptr<torrent> const& t
, std::string uuid) , std::string uuid)
{ {
m_torrents.insert(std::make_pair(ih, t)); m_torrents.insert(std::make_pair(ih, t));
@ -4333,26 +4333,26 @@ namespace aux {
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
//deprecated in 1.2 //deprecated in 1.2
boost::weak_ptr<torrent> session_impl::find_torrent(std::string const& uuid) const std::weak_ptr<torrent> session_impl::find_torrent(std::string const& uuid) const
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
std::map<std::string, boost::shared_ptr<torrent> >::const_iterator i std::map<std::string, std::shared_ptr<torrent> >::const_iterator i
= m_uuids.find(uuid); = m_uuids.find(uuid);
if (i != m_uuids.end()) return i->second; if (i != m_uuids.end()) return i->second;
return boost::weak_ptr<torrent>(); return std::weak_ptr<torrent>();
} }
#endif #endif
#ifndef TORRENT_DISABLE_MUTABLE_TORRENTS #ifndef TORRENT_DISABLE_MUTABLE_TORRENTS
std::vector<boost::shared_ptr<torrent> > session_impl::find_collection( std::vector<std::shared_ptr<torrent> > session_impl::find_collection(
std::string const& collection) const std::string const& collection) const
{ {
std::vector<boost::shared_ptr<torrent> > ret; std::vector<std::shared_ptr<torrent> > ret;
for (session_impl::torrent_map::const_iterator i = m_torrents.begin() for (session_impl::torrent_map::const_iterator i = m_torrents.begin()
, end(m_torrents.end()); i != end; ++i) , end(m_torrents.end()); i != end; ++i)
{ {
boost::shared_ptr<torrent> t = i->second; std::shared_ptr<torrent> t = i->second;
if (!t) continue; if (!t) continue;
std::vector<std::string> const& c = t->torrent_file().collections(); std::vector<std::string> const& c = t->torrent_file().collections();
if (std::count(c.begin(), c.end(), collection) == 0) continue; if (std::count(c.begin(), c.end(), collection) == 0) continue;
@ -4383,13 +4383,13 @@ namespace aux {
} // anonymous namespace } // anonymous namespace
boost::weak_ptr<torrent> session_impl::find_disconnect_candidate_torrent() const std::weak_ptr<torrent> session_impl::find_disconnect_candidate_torrent() const
{ {
aux::session_impl::torrent_map::const_iterator i = std::min_element(m_torrents.begin(), m_torrents.end() aux::session_impl::torrent_map::const_iterator i = std::min_element(m_torrents.begin(), m_torrents.end()
, &compare_disconnect_torrent); , &compare_disconnect_torrent);
TORRENT_ASSERT(i != m_torrents.end()); TORRENT_ASSERT(i != m_torrents.end());
if (i == m_torrents.end()) return boost::shared_ptr<torrent>(); if (i == m_torrents.end()) return std::shared_ptr<torrent>();
return i->second; return i->second;
} }
@ -4436,7 +4436,7 @@ namespace aux {
for (std::vector<torrent_status>::iterator i for (std::vector<torrent_status>::iterator i
= ret->begin(), end(ret->end()); i != end; ++i) = ret->begin(), end(ret->end()); i != end; ++i)
{ {
boost::shared_ptr<torrent> t = i->handle.m_torrent.lock(); std::shared_ptr<torrent> t = i->handle.m_torrent.lock();
if (!t) continue; if (!t) continue;
t->status(&*i, flags); t->status(&*i, flags);
} }
@ -4582,7 +4582,7 @@ namespace aux {
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
void session_impl::add_extensions_to_torrent( void session_impl::add_extensions_to_torrent(
boost::shared_ptr<torrent> const& torrent_ptr, void* userdata) std::shared_ptr<torrent> const& torrent_ptr, void* userdata)
{ {
for (auto& e : m_ses_extensions[plugins_all_idx]) for (auto& e : m_ses_extensions[plugins_all_idx])
{ {
@ -4598,7 +4598,7 @@ namespace aux {
{ {
// params is updated by add_torrent_impl() // params is updated by add_torrent_impl()
add_torrent_params params = p; add_torrent_params params = p;
boost::shared_ptr<torrent> torrent_ptr; std::shared_ptr<torrent> torrent_ptr;
bool added; bool added;
boost::tie(torrent_ptr, added) = add_torrent_impl(params, ec); boost::tie(torrent_ptr, added) = add_torrent_impl(params, ec);
@ -4718,14 +4718,14 @@ namespace aux {
return handle; return handle;
} }
std::pair<boost::shared_ptr<torrent>, bool> std::pair<std::shared_ptr<torrent>, bool>
session_impl::add_torrent_impl( session_impl::add_torrent_impl(
add_torrent_params& params add_torrent_params& params
, error_code& ec) , error_code& ec)
{ {
TORRENT_ASSERT(!params.save_path.empty()); TORRENT_ASSERT(!params.save_path.empty());
using ptr_t = boost::shared_ptr<torrent>; using ptr_t = std::shared_ptr<torrent>;
if (string_begins_no_case("magnet:", params.url.c_str())) if (string_begins_no_case("magnet:", params.url.c_str()))
{ {
@ -4798,7 +4798,7 @@ namespace aux {
} }
// is the torrent already active? // is the torrent already active?
boost::shared_ptr<torrent> torrent_ptr = find_torrent(params.info_hash).lock(); std::shared_ptr<torrent> torrent_ptr = find_torrent(params.info_hash).lock();
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
//deprecated in 1.2 //deprecated in 1.2
if (!torrent_ptr && !params.uuid.empty()) torrent_ptr = find_torrent(params.uuid).lock(); if (!torrent_ptr && !params.uuid.empty()) torrent_ptr = find_torrent(params.uuid).lock();
@ -4833,7 +4833,7 @@ namespace aux {
int queue_pos = ++m_max_queue_pos; int queue_pos = ++m_max_queue_pos;
torrent_ptr = boost::make_shared<torrent>(std::ref(*this) torrent_ptr = std::make_shared<torrent>(std::ref(*this)
, 16 * 1024, queue_pos, m_paused , 16 * 1024, queue_pos, m_paused
, boost::cref(params), boost::cref(params.info_hash)); , boost::cref(params), boost::cref(params.info_hash));
@ -4946,7 +4946,7 @@ namespace aux {
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> tptr = h.m_torrent.lock(); std::shared_ptr<torrent> tptr = h.m_torrent.lock();
if (!tptr) return; if (!tptr) return;
m_alerts.emplace_alert<torrent_removed_alert>(tptr->get_handle() m_alerts.emplace_alert<torrent_removed_alert>(tptr->get_handle()
@ -4958,7 +4958,7 @@ namespace aux {
tptr->set_queue_position(-1); tptr->set_queue_position(-1);
} }
void session_impl::remove_torrent_impl(boost::shared_ptr<torrent> tptr void session_impl::remove_torrent_impl(std::shared_ptr<torrent> tptr
, int options) , int options)
{ {
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
@ -4966,7 +4966,7 @@ namespace aux {
// remove from uuid list // remove from uuid list
if (!tptr->uuid().empty()) if (!tptr->uuid().empty())
{ {
std::map<std::string, boost::shared_ptr<torrent> >::iterator j std::map<std::string, std::shared_ptr<torrent> >::iterator j
= m_uuids.find(tptr->uuid()); = m_uuids.find(tptr->uuid());
if (j != m_uuids.end()) m_uuids.erase(j); if (j != m_uuids.end()) m_uuids.erase(j);
} }
@ -5276,7 +5276,7 @@ namespace aux {
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = find_torrent(ih).lock(); std::shared_ptr<torrent> t = find_torrent(ih).lock();
if (!t) return; if (!t) return;
// don't add peers from lsd to private torrents // don't add peers from lsd to private torrents
if (t->torrent_file().priv() || (t->torrent_file().is_i2p() if (t->torrent_file().priv() || (t->torrent_file().is_i2p()
@ -5523,23 +5523,21 @@ namespace aux {
m_dht_storage = m_dht_storage_constructor(m_dht_settings); m_dht_storage = m_dht_storage_constructor(m_dht_settings);
m_dht = std::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) , 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)
, std::cref(m_dht_settings) , m_dht_settings
, std::ref(m_stats_counters) , m_stats_counters
, *m_dht_storage , *m_dht_storage
, startup_state); , startup_state);
for (std::vector<udp::endpoint>::iterator i = m_dht_router_nodes.begin() for (auto const& n : m_dht_router_nodes)
, end(m_dht_router_nodes.end()); i != end; ++i)
{ {
m_dht->add_router_node(*i); m_dht->add_router_node(n);
} }
for (std::vector<udp::endpoint>::iterator i = m_dht_nodes.begin() for (auto const& n : m_dht_nodes)
, end(m_dht_nodes.end()); i != end; ++i)
{ {
m_dht->add_node(*i); m_dht->add_node(n);
} }
m_dht_nodes.clear(); m_dht_nodes.clear();
@ -5775,7 +5773,7 @@ namespace aux {
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
void session_impl::add_obfuscated_hash(sha1_hash const& obfuscated void session_impl::add_obfuscated_hash(sha1_hash const& obfuscated
, boost::weak_ptr<torrent> const& t) , std::weak_ptr<torrent> const& t)
{ {
m_obfuscated_torrents.insert(std::make_pair(obfuscated, t.lock())); m_obfuscated_torrents.insert(std::make_pair(obfuscated, t.lock()));
} }
@ -6726,7 +6724,7 @@ namespace aux {
for (torrent_map::const_iterator i = m_torrents.begin() for (torrent_map::const_iterator i = m_torrents.begin()
, end(m_torrents.end()); i != end; ++i) , end(m_torrents.end()); i != end; ++i)
{ {
boost::shared_ptr<torrent> t = i->second; std::shared_ptr<torrent> t = i->second;
if (t->want_peers_download()) ++num_active_downloading; if (t->want_peers_download()) ++num_active_downloading;
if (t->want_peers_finished()) ++num_active_finished; if (t->want_peers_finished()) ++num_active_finished;
TORRENT_ASSERT(!(t->want_peers_download() && t->want_peers_finished())); TORRENT_ASSERT(!(t->want_peers_download() && t->want_peers_finished()));
@ -6769,7 +6767,7 @@ namespace aux {
i != m_connections.end(); ++i) i != m_connections.end(); ++i)
{ {
TORRENT_ASSERT(*i); TORRENT_ASSERT(*i);
boost::shared_ptr<torrent> t = (*i)->associated_torrent().lock(); std::shared_ptr<torrent> t = (*i)->associated_torrent().lock();
TORRENT_ASSERT(unique_peers.find(i->get()) == unique_peers.end()); TORRENT_ASSERT(unique_peers.find(i->get()) == unique_peers.end());
unique_peers.insert(i->get()); unique_peers.insert(i->get());

View File

@ -1477,7 +1477,7 @@ namespace libtorrent
piece_manager::piece_manager( piece_manager::piece_manager(
storage_interface* storage_impl storage_interface* storage_impl
, boost::shared_ptr<void> const& torrent , std::shared_ptr<void> const& torrent
, file_storage* files) , file_storage* files)
: m_files(*files) : m_files(*files)
, m_storage(storage_impl) , m_storage(storage_impl)

View File

@ -441,7 +441,7 @@ namespace libtorrent
// as we replace the torrent_info object // as we replace the torrent_info object
// we're about to erase the session's reference to this // we're about to erase the session's reference to this
// torrent, create another reference // torrent, create another reference
boost::shared_ptr<torrent> me(shared_from_this()); std::shared_ptr<torrent> me(shared_from_this());
m_ses.remove_torrent_impl(me, 0); m_ses.remove_torrent_impl(me, 0);
@ -452,7 +452,7 @@ namespace libtorrent
m_info_hash = tf->info_hash(); m_info_hash = tf->info_hash();
// now, we might already have this torrent in the session. // now, we might already have this torrent in the session.
boost::shared_ptr<torrent> t = m_ses.find_torrent(m_torrent_file->info_hash()).lock(); std::shared_ptr<torrent> t = m_ses.find_torrent(m_torrent_file->info_hash()).lock();
if (t) if (t)
{ {
if (!m_uuid.empty() && t->uuid().empty()) if (!m_uuid.empty() && t->uuid().empty())
@ -1896,7 +1896,7 @@ namespace libtorrent
for (std::vector<sha1_hash>::iterator i = s.begin(), end(s.end()); for (std::vector<sha1_hash>::iterator i = s.begin(), end(s.end());
i != end; ++i) i != end; ++i)
{ {
boost::shared_ptr<torrent> t = m_ses.find_torrent(*i).lock(); std::shared_ptr<torrent> t = m_ses.find_torrent(*i).lock();
if (!t) continue; if (!t) continue;
// Only attempt to reuse files from torrents that are seeding. // Only attempt to reuse files from torrents that are seeding.
@ -1910,9 +1910,9 @@ namespace libtorrent
for (std::vector<std::string>::iterator i = c.begin(), end(c.end()); for (std::vector<std::string>::iterator i = c.begin(), end(c.end());
i != end; ++i) i != end; ++i)
{ {
std::vector<boost::shared_ptr<torrent> > ts = m_ses.find_collection(*i); std::vector<std::shared_ptr<torrent> > ts = m_ses.find_collection(*i);
for (std::vector<boost::shared_ptr<torrent> >::iterator k = ts.begin() for (std::vector<std::shared_ptr<torrent> >::iterator k = ts.begin()
, end2(ts.end()); k != end2; ++k) , end2(ts.end()); k != end2; ++k)
{ {
// Only attempt to reuse files from torrents that are seeding. // Only attempt to reuse files from torrents that are seeding.
@ -2667,11 +2667,11 @@ namespace libtorrent
} }
#endif #endif
void torrent::on_tracker_announce_disp(boost::weak_ptr<torrent> p void torrent::on_tracker_announce_disp(std::weak_ptr<torrent> p
, error_code const& e) , error_code const& e)
{ {
COMPLETE_ASYNC("tracker::on_tracker_announce_disp"); COMPLETE_ASYNC("tracker::on_tracker_announce_disp");
boost::shared_ptr<torrent> t = p.lock(); std::shared_ptr<torrent> t = p.lock();
if (!t) return; if (!t) return;
t->m_waiting_tracker = false; t->m_waiting_tracker = false;
@ -2797,16 +2797,16 @@ namespace libtorrent
if (settings().get_bool(settings_pack::enable_incoming_utp)) if (settings().get_bool(settings_pack::enable_incoming_utp))
flags |= dht::dht_tracker::flag_implied_port; flags |= dht::dht_tracker::flag_implied_port;
boost::weak_ptr<torrent> self(shared_from_this()); std::weak_ptr<torrent> self(shared_from_this());
m_ses.dht()->announce(m_torrent_file->info_hash() m_ses.dht()->announce(m_torrent_file->info_hash()
, port, flags , port, flags
, std::bind(&torrent::on_dht_announce_response_disp, self, _1)); , std::bind(&torrent::on_dht_announce_response_disp, self, _1));
} }
void torrent::on_dht_announce_response_disp(boost::weak_ptr<libtorrent::torrent> t void torrent::on_dht_announce_response_disp(std::weak_ptr<torrent> t
, std::vector<tcp::endpoint> const& peers) , std::vector<tcp::endpoint> const& peers)
{ {
boost::shared_ptr<libtorrent::torrent> tor = t.lock(); std::shared_ptr<torrent> tor = t.lock();
if (!tor) return; if (!tor) return;
tor->on_dht_announce_response(peers); tor->on_dht_announce_response(peers);
} }
@ -3044,7 +3044,7 @@ namespace libtorrent
// observer object just for logging // observer object just for logging
if (m_abort && alerts().should_post<log_alert>()) if (m_abort && alerts().should_post<log_alert>())
{ {
boost::shared_ptr<aux::tracker_logger> tl(new aux::tracker_logger(m_ses)); std::shared_ptr<aux::tracker_logger> tl(new aux::tracker_logger(m_ses));
m_ses.queue_tracker_request(req, tl); m_ses.queue_tracker_request(req, tl);
} }
else else
@ -9153,7 +9153,7 @@ namespace libtorrent
m_waiting_tracker = true; m_waiting_tracker = true;
error_code ec; error_code ec;
boost::weak_ptr<torrent> self(shared_from_this()); std::weak_ptr<torrent> self(shared_from_this());
ADD_OUTSTANDING_ASYNC("tracker::on_tracker_announce_disp"); ADD_OUTSTANDING_ASYNC("tracker::on_tracker_announce_disp");
m_tracker_timer.expires_at(next_announce, ec); m_tracker_timer.expires_at(next_announce, ec);
@ -9276,10 +9276,10 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
INVARIANT_CHECK; INVARIANT_CHECK;
boost::weak_ptr<torrent> self(shared_from_this()); std::weak_ptr<torrent> self(shared_from_this());
#ifndef TORRENT_DISABLE_EXTENSIONS #ifndef TORRENT_DISABLE_EXTENSIONS
for (auto& ext : m_extensions) for (auto const& ext : m_extensions)
{ {
TORRENT_TRY { TORRENT_TRY {
ext->tick(); ext->tick();

View File

@ -69,7 +69,7 @@ namespace libtorrent
template<typename Fun, typename... Args> template<typename Fun, typename... Args>
void torrent_handle::async_call(Fun f, Args&&... a) const void torrent_handle::async_call(Fun f, Args&&... a) const
{ {
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT_PRECOND(t); TORRENT_ASSERT_PRECOND(t);
if (!t) return; if (!t) return;
session_impl& ses = static_cast<session_impl&>(t->session()); session_impl& ses = static_cast<session_impl&>(t->session());
@ -79,7 +79,7 @@ namespace libtorrent
template<typename Fun, typename... Args> template<typename Fun, typename... Args>
void torrent_handle::sync_call(Fun f, Args&&... a) const void torrent_handle::sync_call(Fun f, Args&&... a) const
{ {
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT_PRECOND(t); TORRENT_ASSERT_PRECOND(t);
if (!t) return; if (!t) return;
session_impl& ses = static_cast<session_impl&>(t->session()); session_impl& ses = static_cast<session_impl&>(t->session());
@ -101,7 +101,7 @@ namespace libtorrent
template<typename Ret, typename Fun, typename... Args> template<typename Ret, typename Fun, typename... Args>
Ret torrent_handle::sync_call_ret(Ret def, Fun f, Args&&... a) const Ret torrent_handle::sync_call_ret(Ret def, Fun f, Args&&... a) const
{ {
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT_PRECOND(t); TORRENT_ASSERT_PRECOND(t);
Ret r = def; Ret r = def;
if (!t) return r; if (!t) return r;
@ -125,7 +125,7 @@ namespace libtorrent
sha1_hash torrent_handle::info_hash() const sha1_hash torrent_handle::info_hash() const
{ {
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
static const sha1_hash empty; static const sha1_hash empty;
if (!t) return empty; if (!t) return empty;
return t->info_hash(); return t->info_hash();
@ -650,7 +650,7 @@ namespace libtorrent
{ {
status.clear(); status.clear();
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (!t || !t->has_storage()) return; if (!t || !t->has_storage()) return;
session_impl& ses = static_cast<session_impl&>(t->session()); session_impl& ses = static_cast<session_impl&>(t->session());
status = ses.disk_thread().files().get_status(&t->storage()); status = ses.disk_thread().files().get_status(&t->storage());
@ -671,7 +671,7 @@ namespace libtorrent
std::vector<pool_file_status> torrent_handle::file_status() const std::vector<pool_file_status> torrent_handle::file_status() const
{ {
boost::shared_ptr<torrent> t = m_torrent.lock(); std::shared_ptr<torrent> t = m_torrent.lock();
if (!t || !t->has_storage()) return {}; if (!t || !t->has_storage()) return {};
session_impl& ses = static_cast<session_impl&>(t->session()); session_impl& ses = static_cast<session_impl&>(t->session());
return ses.disk_thread().files().get_status(&t->storage()); return ses.disk_thread().files().get_status(&t->storage());
@ -722,7 +722,7 @@ namespace libtorrent
async_call(&torrent::clear_time_critical); async_call(&torrent::clear_time_critical);
} }
boost::shared_ptr<torrent> torrent_handle::native_handle() const std::shared_ptr<torrent> torrent_handle::native_handle() const
{ {
return m_torrent.lock(); return m_torrent.lock();
} }

View File

@ -151,14 +151,14 @@ namespace libtorrent
tracker_manager& man tracker_manager& man
, tracker_request const& req , tracker_request const& req
, io_service& ios , io_service& ios
, boost::weak_ptr<request_callback> r) , std::weak_ptr<request_callback> r)
: timeout_handler(ios) : timeout_handler(ios)
, m_req(req) , m_req(req)
, m_requester(std::move(r)) , m_requester(std::move(r))
, m_man(man) , m_man(man)
{} {}
boost::shared_ptr<request_callback> tracker_connection::requester() const std::shared_ptr<request_callback> tracker_connection::requester() const
{ {
return m_requester.lock(); return m_requester.lock();
} }
@ -174,7 +174,7 @@ namespace libtorrent
void tracker_connection::fail_impl(error_code const& ec, int code void tracker_connection::fail_impl(error_code const& ec, int code
, std::string msg, int interval, int min_interval) , std::string msg, int interval, int min_interval)
{ {
boost::shared_ptr<request_callback> cb = requester(); std::shared_ptr<request_callback> cb = requester();
if (cb) cb->tracker_request_error(m_req, code, ec, msg.c_str() if (cb) cb->tracker_request_error(m_req, code, ec, msg.c_str()
, interval == 0 ? min_interval : interval); , interval == 0 ? min_interval : interval);
close(); close();
@ -266,7 +266,7 @@ namespace libtorrent
void tracker_manager::queue_request( void tracker_manager::queue_request(
io_service& ios io_service& ios
, tracker_request req , tracker_request req
, boost::weak_ptr<request_callback> c) , std::weak_ptr<request_callback> c)
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
TORRENT_ASSERT(req.num_want >= 0); TORRENT_ASSERT(req.num_want >= 0);
@ -305,7 +305,7 @@ namespace libtorrent
} }
// we need to post the error to avoid deadlock // we need to post the error to avoid deadlock
if (boost::shared_ptr<request_callback> r = c.lock()) if (std::shared_ptr<request_callback> r = c.lock())
ios.post(std::bind(&request_callback::tracker_request_error, r, req ios.post(std::bind(&request_callback::tracker_request_error, r, req
, -1, error_code(errors::unsupported_url_protocol) , -1, error_code(errors::unsupported_url_protocol)
, "", 0)); , "", 0));
@ -425,7 +425,7 @@ namespace libtorrent
close_http_connections.push_back(*i); close_http_connections.push_back(*i);
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> rc = c->requester(); std::shared_ptr<request_callback> rc = c->requester();
if (rc) rc->debug_log("aborting: %s", req.url.c_str()); if (rc) rc->debug_log("aborting: %s", req.url.c_str());
#endif #endif
} }
@ -440,7 +440,7 @@ namespace libtorrent
close_udp_connections.push_back(c); close_udp_connections.push_back(c);
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> rc = c->requester(); std::shared_ptr<request_callback> rc = c->requester();
if (rc) rc->debug_log("aborting: %s", req.url.c_str()); if (rc) rc->debug_log("aborting: %s", req.url.c_str());
#endif #endif
} }

View File

@ -73,7 +73,7 @@ namespace libtorrent
io_service& ios io_service& ios
, tracker_manager& man , tracker_manager& man
, tracker_request const& req , tracker_request const& req
, boost::weak_ptr<request_callback> c) , std::weak_ptr<request_callback> c)
: tracker_connection(man, req, ios, c) : tracker_connection(man, req, ios, c)
, m_transaction_id(0) , m_transaction_id(0)
, m_attempts(0) , m_attempts(0)
@ -126,7 +126,7 @@ namespace libtorrent
, shared_from_this(), _1, _2, port)); , shared_from_this(), _1, _2, port));
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> cb = requester(); std::shared_ptr<request_callback> cb = requester();
if (cb) cb->debug_log("*** UDP_TRACKER [ initiating name lookup: \"%s\" ]" if (cb) cb->debug_log("*** UDP_TRACKER [ initiating name lookup: \"%s\" ]"
, hostname.c_str()); , hostname.c_str());
#endif #endif
@ -155,7 +155,7 @@ namespace libtorrent
} }
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> cb = requester(); std::shared_ptr<request_callback> cb = requester();
if (cb) cb->debug_log("*** UDP_TRACKER [ host: \"%s\" ip: \"%s\" | error: \"%s\" ]" if (cb) cb->debug_log("*** UDP_TRACKER [ host: \"%s\" ip: \"%s\" | error: \"%s\" ]"
, m_hostname.c_str(), print_endpoint(m_target).c_str(), ec.message().c_str()); , m_hostname.c_str(), print_endpoint(m_target).c_str(), ec.message().c_str());
#endif #endif
@ -189,7 +189,7 @@ namespace libtorrent
return; return;
} }
boost::shared_ptr<request_callback> cb = requester(); std::shared_ptr<request_callback> cb = requester();
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (cb) cb->debug_log("*** UDP_TRACKER [ name lookup successful ]"); if (cb) cb->debug_log("*** UDP_TRACKER [ name lookup successful ]");
#endif #endif
@ -254,7 +254,7 @@ namespace libtorrent
if (iter == m_endpoints.end()) if (iter == m_endpoints.end())
{ {
TORRENT_ASSERT(target.address().is_v4() != bind_interface().is_v4()); TORRENT_ASSERT(target.address().is_v4() != bind_interface().is_v4());
boost::shared_ptr<request_callback> cb = requester(); std::shared_ptr<request_callback> cb = requester();
if (cb) if (cb)
{ {
char const* tracker_address_type = target.address().is_v4() ? "IPv4" : "IPv6"; char const* tracker_address_type = target.address().is_v4() ? "IPv4" : "IPv6";
@ -312,7 +312,7 @@ namespace libtorrent
} }
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> cb = requester(); std::shared_ptr<request_callback> cb = requester();
if (cb) cb->debug_log("*** UDP_TRACKER [ timed out url: %s ]", tracker_req().url.c_str()); if (cb) cb->debug_log("*** UDP_TRACKER [ timed out url: %s ]", tracker_req().url.c_str());
#endif #endif
fail(error_code(errors::timed_out)); fail(error_code(errors::timed_out));
@ -339,7 +339,7 @@ namespace libtorrent
, span<char const> const buf) , span<char const> const buf)
{ {
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> cb = requester(); std::shared_ptr<request_callback> cb = requester();
#endif #endif
// ignore resposes before we've sent any requests // ignore resposes before we've sent any requests
@ -479,7 +479,7 @@ namespace libtorrent
void udp_tracker_connection::send_udp_connect() void udp_tracker_connection::send_udp_connect()
{ {
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> cb = requester(); std::shared_ptr<request_callback> cb = requester();
#endif #endif
if (m_abort) if (m_abort)
@ -606,7 +606,7 @@ namespace libtorrent
return false; return false;
} }
boost::shared_ptr<request_callback> cb = requester(); std::shared_ptr<request_callback> cb = requester();
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (cb) if (cb)
{ {
@ -682,7 +682,7 @@ namespace libtorrent
int const downloaded = aux::read_int32(buf); int const downloaded = aux::read_int32(buf);
int const incomplete = aux::read_int32(buf); int const incomplete = aux::read_int32(buf);
boost::shared_ptr<request_callback> cb = requester(); std::shared_ptr<request_callback> cb = requester();
if (!cb) if (!cb)
{ {
close(); close();
@ -757,7 +757,7 @@ namespace libtorrent
} }
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> cb = requester(); std::shared_ptr<request_callback> cb = requester();
if (cb) if (cb)
{ {
char hex_ih[41]; char hex_ih[41];

View File

@ -109,7 +109,7 @@ namespace libtorrent
void web_connection_base::on_connected() void web_connection_base::on_connected()
{ {
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
// this is always a seed // this is always a seed

View File

@ -85,7 +85,7 @@ web_peer_connection::web_peer_connection(peer_connection_args const& pack
if (!m_settings.get_bool(settings_pack::report_web_seed_downloads)) if (!m_settings.get_bool(settings_pack::report_web_seed_downloads))
ignore_stats(true); ignore_stats(true);
shared_ptr<torrent> tor = pack.tor.lock(); std::shared_ptr<torrent> tor = pack.tor.lock();
TORRENT_ASSERT(tor); TORRENT_ASSERT(tor);
// we always prefer downloading 1 MiB chunks // we always prefer downloading 1 MiB chunks
@ -99,7 +99,7 @@ web_peer_connection::web_peer_connection(peer_connection_args const& pack
prefer_contiguous_blocks((std::max)(preferred_size / tor->block_size(), 1)); prefer_contiguous_blocks((std::max)(preferred_size / tor->block_size(), 1));
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
bool const single_file_request = t->torrent_file().num_files() == 1; bool const single_file_request = t->torrent_file().num_files() == 1;
if (!single_file_request) if (!single_file_request)
@ -186,7 +186,7 @@ void web_peer_connection::disconnect(error_code const& ec
m_web->endpoints.erase(m_web->endpoints.begin()); m_web->endpoints.erase(m_web->endpoints.begin());
} }
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
if (!m_requests.empty() && !m_file_requests.empty() if (!m_requests.empty() && !m_file_requests.empty()
&& !m_piece.empty() && m_web) && !m_piece.empty() && m_web)
@ -230,7 +230,7 @@ web_peer_connection::downloading_piece_progress() const
if (m_requests.empty()) if (m_requests.empty())
return boost::optional<piece_block_progress>(); return boost::optional<piece_block_progress>();
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
piece_block_progress ret; piece_block_progress ret;
@ -257,7 +257,7 @@ void web_peer_connection::write_request(peer_request const& r)
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
TORRENT_ASSERT(t->valid_metadata()); TORRENT_ASSERT(t->valid_metadata());
@ -504,7 +504,7 @@ bool web_peer_connection::received_invalid_data(int index, bool single_peer)
// 3. if it's a single file torrent, just ban it right away // 3. if it's a single file torrent, just ban it right away
// this handles the case where web seeds may have some files updated but not other // this handles the case where web seeds may have some files updated but not other
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
file_storage const& fs = t->torrent_file().files(); file_storage const& fs = t->torrent_file().files();
// single file torrent // single file torrent
@ -544,7 +544,7 @@ void web_peer_connection::on_receive_padfile()
void web_peer_connection::handle_error(int bytes_left) void web_peer_connection::handle_error(int bytes_left)
{ {
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
// TODO: 2 just make this peer not have the pieces // TODO: 2 just make this peer not have the pieces
@ -573,7 +573,7 @@ void web_peer_connection::handle_redirect(int bytes_left)
std::string location = m_parser.header("location"); std::string location = m_parser.header("location");
received_bytes(0, bytes_left); received_bytes(0, bytes_left);
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
if (location.empty()) if (location.empty())
@ -648,7 +648,7 @@ void web_peer_connection::on_receive(error_code const& error
return; return;
} }
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
// in case the first file on this series of requests is a padfile // in case the first file on this series of requests is a padfile
@ -967,7 +967,7 @@ void web_peer_connection::incoming_payload(char const* buf, int len)
TORRENT_ASSERT(front_request.length >= piece_size); TORRENT_ASSERT(front_request.length >= piece_size);
if (int(m_piece.size()) == front_request.length) if (int(m_piece.size()) == front_request.length)
{ {
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
@ -1019,7 +1019,7 @@ void web_peer_connection::maybe_harvest_piece()
TORRENT_ASSERT(front_request.length >= int(m_piece.size())); TORRENT_ASSERT(front_request.length >= int(m_piece.size()));
if (int(m_piece.size()) != front_request.length) return; if (int(m_piece.size()) != front_request.length) return;
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
@ -1045,7 +1045,7 @@ void web_peer_connection::handle_padfile()
if (m_file_requests.empty()) return; if (m_file_requests.empty()) return;
if (m_requests.empty()) return; if (m_requests.empty()) return;
boost::shared_ptr<torrent> t = associated_torrent().lock(); std::shared_ptr<torrent> t = associated_torrent().lock();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
torrent_info const& info = t->torrent_file(); torrent_info const& info = t->torrent_file();

View File

@ -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; \
std::shared_ptr<piece_manager> pm = std::make_shared<piece_manager>(st, boost::shared_ptr<int>(new int), &fs); \ std::shared_ptr<piece_manager> pm = std::make_shared<piece_manager>(st, std::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; \

View File

@ -462,7 +462,7 @@ void test_check_files(std::string const& test_path
p.pool = &fp; p.pool = &fp;
p.mode = storage_mode; p.mode = storage_mode;
boost::shared_ptr<void> dummy; std::shared_ptr<void> dummy;
std::shared_ptr<piece_manager> pm = std::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;