forked from premiere/premiere-libtorrent
require tracker_request objects be moved into queue_manager. also replace non-const reference parameter with rvalue reference
This commit is contained in:
parent
00987475f4
commit
0c76a3a0c5
|
@ -476,7 +476,7 @@ namespace aux {
|
||||||
port_filter const& get_port_filter() const override;
|
port_filter const& get_port_filter() const override;
|
||||||
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
|
||||||
, std::weak_ptr<request_callback> c) override;
|
, std::weak_ptr<request_callback> c) override;
|
||||||
|
|
||||||
// ==== peer class operations ====
|
// ==== peer class operations ====
|
||||||
|
|
|
@ -233,8 +233,11 @@ namespace aux {
|
||||||
virtual void apply_settings_pack(std::shared_ptr<settings_pack> pack) = 0;
|
virtual void apply_settings_pack(std::shared_ptr<settings_pack> pack) = 0;
|
||||||
virtual session_settings const& settings() const = 0;
|
virtual session_settings const& settings() const = 0;
|
||||||
|
|
||||||
virtual void queue_tracker_request(tracker_request& req
|
// the tracker request object must be moved in
|
||||||
|
virtual void queue_tracker_request(tracker_request&& req
|
||||||
, std::weak_ptr<request_callback> c) = 0;
|
, std::weak_ptr<request_callback> c) = 0;
|
||||||
|
void queue_tracker_request(tracker_request const& req
|
||||||
|
, std::weak_ptr<request_callback> c) = delete;
|
||||||
|
|
||||||
// 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;
|
||||||
|
|
|
@ -357,9 +357,14 @@ namespace libtorrent {
|
||||||
|
|
||||||
void queue_request(
|
void queue_request(
|
||||||
io_service& ios
|
io_service& ios
|
||||||
, tracker_request r
|
, tracker_request&& r
|
||||||
, std::weak_ptr<request_callback> c
|
, std::weak_ptr<request_callback> c
|
||||||
= std::weak_ptr<request_callback>());
|
= std::weak_ptr<request_callback>());
|
||||||
|
void queue_request(
|
||||||
|
io_service& ios
|
||||||
|
, tracker_request const& r
|
||||||
|
, std::weak_ptr<request_callback> c
|
||||||
|
= std::weak_ptr<request_callback>()) = delete;
|
||||||
void abort_all_requests(bool all = false);
|
void abort_all_requests(bool all = false);
|
||||||
|
|
||||||
void remove_request(http_tracker_connection const* c);
|
void remove_request(http_tracker_connection const* c);
|
||||||
|
|
|
@ -1035,7 +1035,7 @@ namespace aux {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_impl::queue_tracker_request(tracker_request& req
|
void session_impl::queue_tracker_request(tracker_request&& req
|
||||||
, std::weak_ptr<request_callback> c)
|
, std::weak_ptr<request_callback> c)
|
||||||
{
|
{
|
||||||
#if TORRENT_USE_I2P
|
#if TORRENT_USE_I2P
|
||||||
|
@ -1062,7 +1062,7 @@ namespace aux {
|
||||||
use_ssl ? ssl_listen_port(ls) :
|
use_ssl ? ssl_listen_port(ls) :
|
||||||
#endif
|
#endif
|
||||||
listen_port(ls);
|
listen_port(ls);
|
||||||
m_tracker_manager.queue_request(get_io_service(), req, c);
|
m_tracker_manager.queue_request(get_io_service(), std::move(req), c);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1071,7 +1071,8 @@ namespace aux {
|
||||||
#ifdef TORRENT_USE_OPENSSL
|
#ifdef TORRENT_USE_OPENSSL
|
||||||
if ((ls->ssl == transport::ssl) != use_ssl) continue;
|
if ((ls->ssl == transport::ssl) != use_ssl) continue;
|
||||||
#endif
|
#endif
|
||||||
req.listen_port =
|
tracker_request socket_req(req);
|
||||||
|
socket_req.listen_port =
|
||||||
#ifdef TORRENT_USE_OPENSSL
|
#ifdef TORRENT_USE_OPENSSL
|
||||||
// SSL torrents use the SSL listen port
|
// SSL torrents use the SSL listen port
|
||||||
use_ssl ? ssl_listen_port(ls.get()) :
|
use_ssl ? ssl_listen_port(ls.get()) :
|
||||||
|
@ -1080,9 +1081,9 @@ namespace aux {
|
||||||
|
|
||||||
// we combine the per-torrent key with the per-interface key to make
|
// we combine the per-torrent key with the per-interface key to make
|
||||||
// them consistent and unique per torrent and interface
|
// them consistent and unique per torrent and interface
|
||||||
req.key ^= ls->tracker_key;
|
socket_req.key ^= ls->tracker_key;
|
||||||
req.outgoing_socket = ls;
|
socket_req.outgoing_socket = ls;
|
||||||
m_tracker_manager.queue_request(get_io_service(), req, c);
|
m_tracker_manager.queue_request(get_io_service(), std::move(socket_req), c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2919,12 +2919,12 @@ bool is_downloading_state(int const st)
|
||||||
if (m_abort && m_ses.should_log())
|
if (m_abort && m_ses.should_log())
|
||||||
{
|
{
|
||||||
auto tl = std::make_shared<aux::tracker_logger>(m_ses);
|
auto tl = std::make_shared<aux::tracker_logger>(m_ses);
|
||||||
m_ses.queue_tracker_request(req, tl);
|
m_ses.queue_tracker_request(tracker_request(req), tl);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
m_ses.queue_tracker_request(req, shared_from_this());
|
m_ses.queue_tracker_request(tracker_request(req), shared_from_this());
|
||||||
}
|
}
|
||||||
|
|
||||||
aep.updating = true;
|
aep.updating = true;
|
||||||
|
@ -2979,7 +2979,7 @@ bool is_downloading_state(int const st)
|
||||||
#endif
|
#endif
|
||||||
req.key = tracker_key();
|
req.key = tracker_key();
|
||||||
req.triggered_manually = user_triggered;
|
req.triggered_manually = user_triggered;
|
||||||
m_ses.queue_tracker_request(req, shared_from_this());
|
m_ses.queue_tracker_request(std::move(req), shared_from_this());
|
||||||
}
|
}
|
||||||
|
|
||||||
void torrent::tracker_warning(tracker_request const& req, std::string const& msg)
|
void torrent::tracker_warning(tracker_request const& req, std::string const& msg)
|
||||||
|
|
|
@ -256,7 +256,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
|
||||||
, std::weak_ptr<request_callback> c)
|
, std::weak_ptr<request_callback> c)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
|
@ -278,14 +278,14 @@ namespace libtorrent {
|
||||||
if (protocol == "http")
|
if (protocol == "http")
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
auto con = std::make_shared<http_tracker_connection>(ios, *this, req, c);
|
auto con = std::make_shared<http_tracker_connection>(ios, *this, std::move(req), c);
|
||||||
m_http_conns.push_back(con);
|
m_http_conns.push_back(con);
|
||||||
con->start();
|
con->start();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (protocol == "udp")
|
else if (protocol == "udp")
|
||||||
{
|
{
|
||||||
auto con = std::make_shared<udp_tracker_connection>(ios, *this, req, c);
|
auto con = std::make_shared<udp_tracker_connection>(ios, *this, std::move(req), c);
|
||||||
m_udp_conns[con->transaction_id()] = con;
|
m_udp_conns[con->transaction_id()] = con;
|
||||||
con->start();
|
con->start();
|
||||||
return;
|
return;
|
||||||
|
@ -293,7 +293,7 @@ namespace libtorrent {
|
||||||
|
|
||||||
// we need to post the error to avoid deadlock
|
// we need to post the error to avoid deadlock
|
||||||
if (std::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, std::move(req)
|
||||||
, error_code(errors::unsupported_url_protocol)
|
, error_code(errors::unsupported_url_protocol)
|
||||||
, "", seconds32(0)));
|
, "", seconds32(0)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue