mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
lt sync 2896
This commit is contained in:
parent
0661c70594
commit
e89251b545
7 changed files with 39 additions and 29 deletions
|
@ -118,7 +118,7 @@ namespace libtorrent
|
||||||
, use_dht_as_fallback(false)
|
, use_dht_as_fallback(false)
|
||||||
#endif
|
#endif
|
||||||
, free_torrent_hashes(true)
|
, free_torrent_hashes(true)
|
||||||
, upnp_ignore_nonrouters(true)
|
, upnp_ignore_nonrouters(false)
|
||||||
, send_buffer_watermark(80 * 1024)
|
, send_buffer_watermark(80 * 1024)
|
||||||
, auto_upload_slots(true)
|
, auto_upload_slots(true)
|
||||||
, use_parole_mode(true)
|
, use_parole_mode(true)
|
||||||
|
|
|
@ -1288,6 +1288,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
t->get_policy().update_peer_port(listen_port
|
t->get_policy().update_peer_port(listen_port
|
||||||
, peer_info_struct(), peer_info::incoming);
|
, peer_info_struct(), peer_info::incoming);
|
||||||
|
if (is_disconnecting()) return;
|
||||||
}
|
}
|
||||||
// there should be a version too
|
// there should be a version too
|
||||||
// but where do we put that info?
|
// but where do we put that info?
|
||||||
|
|
|
@ -119,19 +119,16 @@ namespace libtorrent
|
||||||
m_timer.cancel(ec);
|
m_timer.cancel(ec);
|
||||||
m_abort = true;
|
m_abort = true;
|
||||||
|
|
||||||
// make a copy of the list to go through, so
|
while (!m_queue.empty())
|
||||||
// that connections removing themseleves won't
|
|
||||||
// interfere with the iteration
|
|
||||||
std::list<entry> closing_entries = m_queue;
|
|
||||||
|
|
||||||
// we don't want to call the timeout callback while we're locked
|
|
||||||
// since that is a recepie for dead-locks
|
|
||||||
l.unlock();
|
|
||||||
|
|
||||||
for (std::list<entry>::iterator i = closing_entries.begin()
|
|
||||||
, end(closing_entries.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
try { i->on_timeout(); } catch (std::exception&) {}
|
// we don't want to call the timeout callback while we're locked
|
||||||
|
// since that is a recepie for dead-locks
|
||||||
|
entry e = m_queue.front();
|
||||||
|
m_queue.pop_front();
|
||||||
|
if (e.connecting) --m_num_connecting;
|
||||||
|
l.unlock();
|
||||||
|
try { e.on_timeout(); } catch (std::exception&) {}
|
||||||
|
l.lock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,6 @@ void http_connection::start(std::string const& hostname, std::string const& port
|
||||||
|
|
||||||
void http_connection::on_connect_timeout()
|
void http_connection::on_connect_timeout()
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(m_connection_ticket >= 0);
|
|
||||||
if (m_connection_ticket > -1) m_cc.done(m_connection_ticket);
|
if (m_connection_ticket > -1) m_cc.done(m_connection_ticket);
|
||||||
m_connection_ticket = -1;
|
m_connection_ticket = -1;
|
||||||
|
|
||||||
|
|
|
@ -1397,13 +1397,19 @@ namespace libtorrent
|
||||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||||
TORRENT_ASSERT(t);
|
TORRENT_ASSERT(t);
|
||||||
if (m_upload_only && t->is_finished())
|
if (m_upload_only && t->is_finished())
|
||||||
|
{
|
||||||
disconnect("seed to seed");
|
disconnect("seed to seed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_upload_only
|
if (m_upload_only
|
||||||
&& !m_interesting
|
&& !m_interesting
|
||||||
&& m_bitfield_received
|
&& m_bitfield_received
|
||||||
&& t->are_files_checked())
|
&& t->are_files_checked())
|
||||||
|
{
|
||||||
disconnect("uninteresting upload-only peer");
|
disconnect("uninteresting upload-only peer");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
|
@ -2531,7 +2537,7 @@ namespace libtorrent
|
||||||
m_torrent.reset();
|
m_torrent.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#if !defined NDEBUG && defined TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
||||||
// since this connection doesn't have a torrent reference
|
// since this connection doesn't have a torrent reference
|
||||||
// no torrent should have a reference to this connection either
|
// no torrent should have a reference to this connection either
|
||||||
for (aux::session_impl::torrent_map::const_iterator i = m_ses.m_torrents.begin()
|
for (aux::session_impl::torrent_map::const_iterator i = m_ses.m_torrents.begin()
|
||||||
|
|
|
@ -498,7 +498,7 @@ namespace aux {
|
||||||
m_half_open.close();
|
m_half_open.close();
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||||
(*m_logger) << time_now_string() << " connection queue: " << m_half_open.size() << std::endl;
|
(*m_logger) << time_now_string() << " connection queue: " << m_half_open.size() << "\n";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// abort all connections
|
// abort all connections
|
||||||
|
@ -512,7 +512,7 @@ namespace aux {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||||
(*m_logger) << time_now_string() << " connection queue: " << m_half_open.size() << std::endl;
|
(*m_logger) << time_now_string() << " connection queue: " << m_half_open.size() << "\n";
|
||||||
#endif
|
#endif
|
||||||
TORRENT_ASSERT(m_half_open.size() == 0);
|
TORRENT_ASSERT(m_half_open.size() == 0);
|
||||||
|
|
||||||
|
|
|
@ -753,14 +753,17 @@ namespace
|
||||||
|
|
||||||
struct parse_state
|
struct parse_state
|
||||||
{
|
{
|
||||||
parse_state(): found_service(false) {}
|
parse_state(): in_service(false) {}
|
||||||
void reset(char const* st)
|
void reset(char const* st)
|
||||||
{
|
{
|
||||||
found_service = false;
|
in_service = false;
|
||||||
service_type = st;
|
service_type = st;
|
||||||
tag_stack.clear();
|
tag_stack.clear();
|
||||||
|
control_url.clear();
|
||||||
|
model.clear();
|
||||||
|
url_base.clear();
|
||||||
}
|
}
|
||||||
bool found_service;
|
bool in_service;
|
||||||
std::list<std::string> tag_stack;
|
std::list<std::string> tag_stack;
|
||||||
std::string control_url;
|
std::string control_url;
|
||||||
char const* service_type;
|
char const* service_type;
|
||||||
|
@ -791,22 +794,26 @@ void find_control_url(int type, char const* string, parse_state& state)
|
||||||
else if (type == xml_end_tag)
|
else if (type == xml_end_tag)
|
||||||
{
|
{
|
||||||
if (!state.tag_stack.empty())
|
if (!state.tag_stack.empty())
|
||||||
|
{
|
||||||
|
if (state.in_service && state.tag_stack.back() == "service")
|
||||||
|
state.in_service = false;
|
||||||
state.tag_stack.pop_back();
|
state.tag_stack.pop_back();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (type == xml_string)
|
else if (type == xml_string)
|
||||||
{
|
{
|
||||||
if (state.tag_stack.empty()) return;
|
if (state.tag_stack.empty()) return;
|
||||||
// std::cout << " " << string << std::endl;
|
// std::cout << " " << string << std::endl;
|
||||||
if (!state.found_service && state.top_tags("service", "servicetype"))
|
if (!state.in_service && state.top_tags("service", "servicetype"))
|
||||||
{
|
{
|
||||||
if (string_equal_nocase(string, state.service_type))
|
if (string_equal_nocase(string, state.service_type))
|
||||||
state.found_service = true;
|
state.in_service = true;
|
||||||
}
|
}
|
||||||
else if (state.found_service && state.top_tags("service", "controlurl"))
|
else if (state.in_service && state.top_tags("service", "controlurl"))
|
||||||
{
|
{
|
||||||
state.control_url = string;
|
state.control_url = string;
|
||||||
}
|
}
|
||||||
else if (state.tag_stack.back() == "modelname")
|
else if (state.model.empty() && state.top_tags("device", "modelname"))
|
||||||
{
|
{
|
||||||
state.model = string;
|
state.model = string;
|
||||||
}
|
}
|
||||||
|
@ -865,7 +872,7 @@ void upnp::on_upnp_xml(error_code const& e
|
||||||
s.reset("urn:schemas-upnp-org:service:WANIPConnection:1");
|
s.reset("urn:schemas-upnp-org:service:WANIPConnection:1");
|
||||||
xml_parse((char*)p.get_body().begin, (char*)p.get_body().end
|
xml_parse((char*)p.get_body().begin, (char*)p.get_body().end
|
||||||
, bind(&find_control_url, _1, _2, boost::ref(s)));
|
, bind(&find_control_url, _1, _2, boost::ref(s)));
|
||||||
if (s.found_service)
|
if (!s.control_url.empty())
|
||||||
{
|
{
|
||||||
d.service_namespace = s.service_type;
|
d.service_namespace = s.service_type;
|
||||||
if (!s.model.empty()) m_model = s.model;
|
if (!s.model.empty()) m_model = s.model;
|
||||||
|
@ -877,7 +884,7 @@ void upnp::on_upnp_xml(error_code const& e
|
||||||
s.reset("urn:schemas-upnp-org:service:WANPPPConnection:1");
|
s.reset("urn:schemas-upnp-org:service:WANPPPConnection:1");
|
||||||
xml_parse((char*)p.get_body().begin, (char*)p.get_body().end
|
xml_parse((char*)p.get_body().begin, (char*)p.get_body().end
|
||||||
, bind(&find_control_url, _1, _2, boost::ref(s)));
|
, bind(&find_control_url, _1, _2, boost::ref(s)));
|
||||||
if (s.found_service)
|
if (!s.control_url.empty())
|
||||||
{
|
{
|
||||||
d.service_namespace = s.service_type;
|
d.service_namespace = s.service_type;
|
||||||
if (!s.model.empty()) m_model = s.model;
|
if (!s.model.empty()) m_model = s.model;
|
||||||
|
@ -894,6 +901,9 @@ void upnp::on_upnp_xml(error_code const& e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (s.url_base.empty()) d.control_url = s.control_url;
|
||||||
|
else d.control_url = s.url_base + s.control_url;
|
||||||
|
|
||||||
std::string protocol;
|
std::string protocol;
|
||||||
std::string auth;
|
std::string auth;
|
||||||
char const* error;
|
char const* error;
|
||||||
|
@ -911,9 +921,6 @@ void upnp::on_upnp_xml(error_code const& e
|
||||||
<< " urlbase: " << s.url_base << " namespace: " << d.service_namespace << std::endl;
|
<< " urlbase: " << s.url_base << " namespace: " << d.service_namespace << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (s.url_base.empty()) d.control_url = s.control_url;
|
|
||||||
else d.control_url = s.url_base + s.control_url;
|
|
||||||
|
|
||||||
boost::tie(protocol, auth, d.hostname, d.port, d.path, error)
|
boost::tie(protocol, auth, d.hostname, d.port, d.path, error)
|
||||||
= parse_url_components(d.control_url);
|
= parse_url_components(d.control_url);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue