merged RC_1_1 into master
This commit is contained in:
commit
b1e22e6183
|
@ -42,6 +42,7 @@
|
|||
* resume data no longer has timestamps of files
|
||||
* require C++11 to build libtorrent
|
||||
|
||||
* fix bug in last-seen-complete
|
||||
* remove file size limit in torrent_info filename constructor
|
||||
* fix tail-padding for last file in create_torrent
|
||||
* don't send user-agent in metadata http downloads or UPnP requests when
|
||||
|
|
|
@ -66,6 +66,14 @@ class test_torrent_handle(unittest.TestCase):
|
|||
print(a.message())
|
||||
time.sleep(0.1)
|
||||
|
||||
def test_scrape(self):
|
||||
ses = lt.session({'alert_mask': lt.alert.category_t.all_categories, 'enable_dht': False})
|
||||
ti = lt.torrent_info('url_seed_multi.torrent');
|
||||
h = ses.add_torrent({'ti': ti, 'save_path': os.getcwd()})
|
||||
# this is just to make sure this function can be called like this
|
||||
# from python
|
||||
h.scrape_tracker()
|
||||
|
||||
class test_torrent_info(unittest.TestCase):
|
||||
|
||||
def test_bencoded_constructor(self):
|
||||
|
|
|
@ -280,7 +280,7 @@ private:
|
|||
// the url to the WANIP or WANPPP interface
|
||||
std::string control_url;
|
||||
// either the WANIP namespace or the WANPPP namespace
|
||||
char const* service_namespace = nullptr;
|
||||
std::string service_namespace;
|
||||
|
||||
std::vector<mapping_t> mapping;
|
||||
|
||||
|
|
|
@ -1841,7 +1841,7 @@ namespace libtorrent
|
|||
// there should be a version too
|
||||
// but where do we put that info?
|
||||
|
||||
int last_seen_complete = std::uint8_t(root.dict_find_int_value("complete_ago", -1));
|
||||
int const last_seen_complete = root.dict_find_int_value("complete_ago", -1);
|
||||
if (last_seen_complete >= 0) set_last_seen_complete(last_seen_complete);
|
||||
|
||||
auto client_info = root.dict_find_string_value("v");
|
||||
|
|
|
@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/choker.hpp"
|
||||
#include "libtorrent/peer_connection.hpp"
|
||||
#include "libtorrent/aux_/session_settings.hpp"
|
||||
#include "libtorrent/aux_/time.hpp"
|
||||
#include "libtorrent/torrent.hpp"
|
||||
|
||||
#include <functional>
|
||||
|
@ -81,24 +82,33 @@ namespace libtorrent
|
|||
// peers that are unchoked, but have sent more than one quota
|
||||
// since they were unchoked, they get de-prioritized.
|
||||
|
||||
// if a peer is already unchoked, and the number of bytes sent since it was unchoked
|
||||
// is greater than the send quanta, then it's done with it' upload slot, and we
|
||||
// can de-prioritize it
|
||||
bool c1_quota_complete = !lhs->is_choked() && c1
|
||||
> (std::max)(t1->torrent_file().piece_length() * pieces, 256 * 1024);
|
||||
bool c2_quota_complete = !rhs->is_choked() && c2
|
||||
> (std::max)(t2->torrent_file().piece_length() * pieces, 256 * 1024);
|
||||
// if a peer is already unchoked, the number of bytes sent since it was unchoked
|
||||
// is greater than the send quanta, and it has been unchoked for at least one minute
|
||||
// then it's done with its upload slot, and we can de-prioritize it
|
||||
bool c1_quota_complete = !lhs->is_choked()
|
||||
&& c1 > t1->torrent_file().piece_length() * pieces
|
||||
&& aux::time_now() - lhs->time_of_last_unchoke() > minutes(1);
|
||||
bool c2_quota_complete = !rhs->is_choked()
|
||||
&& c2 > t2->torrent_file().piece_length() * pieces
|
||||
&& aux::time_now() - rhs->time_of_last_unchoke() > minutes(1);
|
||||
|
||||
// if c2 has completed a quanta, it should be de-prioritized
|
||||
// and vice versa
|
||||
if (c1_quota_complete < c2_quota_complete) return true;
|
||||
if (c1_quota_complete > c2_quota_complete) return false;
|
||||
|
||||
// if both peers have either completed a quanta, or not.
|
||||
// keep unchoked peers prioritized over choked ones, to let
|
||||
// peers keep working on uploading a full quanta
|
||||
if (lhs->is_choked() < rhs->is_choked()) return true;
|
||||
if (lhs->is_choked() > rhs->is_choked()) return false;
|
||||
// when seeding, prefer the peer we're uploading the fastest to
|
||||
|
||||
// force the upload rate to zero for choked peers because
|
||||
// if the peers just got choked the previous round
|
||||
// there may have been a residual transfer which was already
|
||||
// in-flight at the time and we don't want that to cause the peer
|
||||
// to be ranked at the top of the choked peers
|
||||
c1 = lhs->is_choked() ? 0 : lhs->uploaded_in_last_round();
|
||||
c2 = rhs->is_choked() ? 0 : rhs->uploaded_in_last_round();
|
||||
|
||||
if (c1 > c2) return true;
|
||||
if (c2 > c1) return false;
|
||||
|
||||
// if the peers are still identical (say, they're both waiting to be unchoked)
|
||||
// prioritize the one that has waited the longest to be unchoked
|
||||
|
@ -136,10 +146,6 @@ namespace libtorrent
|
|||
c1 = lhs->uploaded_in_last_round();
|
||||
c2 = rhs->uploaded_in_last_round();
|
||||
|
||||
// take torrent priority into account
|
||||
c1 *= prio1;
|
||||
c2 *= prio2;
|
||||
|
||||
if (c1 > c2) return true;
|
||||
if (c2 > c1) return false;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5480,6 +5480,8 @@ namespace aux {
|
|||
// postpone starting the DHT if we're still resolving the DHT router
|
||||
if (m_outstanding_router_lookups > 0) return;
|
||||
|
||||
if (m_abort) return;
|
||||
|
||||
// TODO: refactor, move the storage to dht_tracker
|
||||
m_dht_storage = m_dht_storage_constructor(m_dht_settings);
|
||||
m_dht = std::make_shared<dht::dht_tracker>(
|
||||
|
|
23
src/upnp.cpp
23
src/upnp.cpp
|
@ -225,7 +225,7 @@ int upnp::add_mapping(portmap_protocol const p, int const external_port
|
|||
m.external_port = external_port;
|
||||
m.local_port = local_port;
|
||||
|
||||
if (d.service_namespace) update_map(d, mapping_index);
|
||||
if (!d.service_namespace.empty()) update_map(d, mapping_index);
|
||||
}
|
||||
|
||||
return mapping_index;
|
||||
|
@ -255,7 +255,7 @@ void upnp::delete_mapping(int mapping)
|
|||
TORRENT_ASSERT(mapping < int(d.mapping.size()));
|
||||
d.mapping[mapping].act = mapping_t::action::del;
|
||||
|
||||
if (d.service_namespace) update_map(d, mapping);
|
||||
if (!d.service_namespace.empty()) update_map(d, mapping);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -699,7 +699,7 @@ void upnp::post(upnp::rootdevice const& d, char const* soap
|
|||
"Soapaction: \"%s#%s\"\r\n\r\n"
|
||||
"%s"
|
||||
, d.path.c_str(), d.hostname.c_str(), d.port
|
||||
, int(strlen(soap)), d.service_namespace, soap_action
|
||||
, int(strlen(soap)), d.service_namespace.c_str(), soap_action
|
||||
, soap);
|
||||
|
||||
d.upnp_connection->m_sendbuffer = header;
|
||||
|
@ -743,7 +743,7 @@ void upnp::create_port_mapping(http_connection& c, rootdevice& d, int i)
|
|||
"<NewPortMappingDescription>%s at %s:%d</NewPortMappingDescription>"
|
||||
"<NewLeaseDuration>%u</NewLeaseDuration>"
|
||||
"</u:%s></s:Body></s:Envelope>"
|
||||
, soap_action, d.service_namespace, d.mapping[i].external_port
|
||||
, soap_action, d.service_namespace.c_str(), d.mapping[i].external_port
|
||||
, (d.mapping[i].protocol == portmap_protocol::udp ? "UDP" : "TCP")
|
||||
, d.mapping[i].local_port
|
||||
, local_endpoint.c_str()
|
||||
|
@ -795,7 +795,7 @@ void upnp::update_map(rootdevice& d, int i)
|
|||
}
|
||||
|
||||
TORRENT_ASSERT(!d.upnp_connection);
|
||||
TORRENT_ASSERT(d.service_namespace);
|
||||
TORRENT_ASSERT(!d.service_namespace.empty());
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
log("connecting to %s", d.hostname.c_str());
|
||||
|
@ -862,7 +862,7 @@ void upnp::delete_port_mapping(rootdevice& d, int i)
|
|||
"<NewExternalPort>%u</NewExternalPort>"
|
||||
"<NewProtocol>%s</NewProtocol>"
|
||||
"</u:%s></s:Body></s:Envelope>"
|
||||
, soap_action, d.service_namespace
|
||||
, soap_action, d.service_namespace.c_str()
|
||||
, d.mapping[i].external_port
|
||||
, (d.mapping[i].protocol == portmap_protocol::udp ? "UDP" : "TCP")
|
||||
, soap_action);
|
||||
|
@ -996,9 +996,10 @@ void upnp::on_upnp_xml(error_code const& e
|
|||
d.disabled = true;
|
||||
return;
|
||||
}
|
||||
static std::string service_type;
|
||||
service_type.swap(s.service_type);
|
||||
d.service_namespace = service_type.c_str();
|
||||
d.service_namespace = s.service_type;
|
||||
|
||||
TORRENT_ASSERT(!d.service_namespace.empty());
|
||||
|
||||
if (!s.model.empty()) m_model = s.model;
|
||||
|
||||
if (!s.url_base.empty() && s.control_url.substr(0, 7) != "http://")
|
||||
|
@ -1029,7 +1030,7 @@ void upnp::on_upnp_xml(error_code const& e
|
|||
{
|
||||
log("found control URL: %s namespace %s "
|
||||
"urlbase: %s in response from %s"
|
||||
, d.control_url.c_str(), d.service_namespace
|
||||
, d.control_url.c_str(), d.service_namespace.c_str()
|
||||
, s.url_base.c_str(), d.url.c_str());
|
||||
}
|
||||
#endif
|
||||
|
@ -1084,7 +1085,7 @@ void upnp::get_ip_address(rootdevice& d)
|
|||
"s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
|
||||
"<s:Body><u:%s xmlns:u=\"%s\">"
|
||||
"</u:%s></s:Body></s:Envelope>"
|
||||
, soap_action, d.service_namespace
|
||||
, soap_action, d.service_namespace.c_str()
|
||||
, soap_action);
|
||||
|
||||
post(d, soap, soap_action);
|
||||
|
|
|
@ -299,3 +299,9 @@ TORRENT_TEST(save_restore_state_load_filter)
|
|||
});
|
||||
}
|
||||
|
||||
TORRENT_TEST(session_shutdown)
|
||||
{
|
||||
lt::settings_pack pack;
|
||||
lt::session ses(pack);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue