merged RC_1_1 into master

This commit is contained in:
arvidn 2018-11-14 15:48:37 +01:00
commit 29cddaa23e
8 changed files with 58 additions and 39 deletions

View File

@ -117,6 +117,7 @@ EXTRA_DIST = \
Jamfile \ Jamfile \
Jamroot.jam \ Jamroot.jam \
CMakeLists.txt \ CMakeLists.txt \
LibtorrentRasterbarConfig.cmake.in \
cmake/Modules/FindLibGcrypt.cmake \ cmake/Modules/FindLibGcrypt.cmake \
cmake/Modules/GeneratePkgConfig.cmake \ cmake/Modules/GeneratePkgConfig.cmake \
cmake/Modules/ucm_flags.cmake \ cmake/Modules/ucm_flags.cmake \

View File

@ -91,19 +91,19 @@ list dht_stats_routing_table(dht_stats_alert const& a)
dict dht_immutable_item(dht_immutable_item_alert const& alert) dict dht_immutable_item(dht_immutable_item_alert const& alert)
{ {
dict d; dict d;
d["key"] = alert.target.to_string(); d["key"] = alert.target;
d["value"] = alert.item.to_string(); d["value"] = bytes(alert.item.to_string());
return d; return d;
} }
dict dht_mutable_item(dht_mutable_item_alert const& alert) dict dht_mutable_item(dht_mutable_item_alert const& alert)
{ {
dict d; dict d;
d["key"] = std::string(alert.key.data(), alert.key.size()); d["key"] = bytes(alert.key.data(), alert.key.size());
d["value"] = alert.item.to_string(); d["value"] = bytes(alert.item.to_string());
d["signature"] = std::string(alert.signature.data(), alert.signature.size()); d["signature"] = bytes(alert.signature.data(), alert.signature.size());
d["seq"] = alert.seq; d["seq"] = alert.seq;
d["salt"] = alert.salt; d["salt"] = bytes(alert.salt);
d["authoritative"] = alert.authoritative; d["authoritative"] = alert.authoritative;
return d; return d;
} }
@ -112,12 +112,12 @@ dict dht_put_item(dht_put_alert const& alert)
{ {
dict d; dict d;
if (alert.target.is_all_zeros()) { if (alert.target.is_all_zeros()) {
d["public_key"] = std::string(alert.public_key.data(), alert.public_key.size()); d["public_key"] = bytes(alert.public_key.data(), alert.public_key.size());
d["signature"] = std::string(alert.signature.data(), alert.signature.size()); d["signature"] = bytes(alert.signature.data(), alert.signature.size());
d["seq"] = alert.seq; d["seq"] = alert.seq;
d["salt"] = alert.salt; d["salt"] = bytes(alert.salt);
} else { } else {
d["target"] = alert.target.to_string(); d["target"] = alert.target;
} }
return d; return d;
} }

View File

@ -9,7 +9,7 @@
struct bytes struct bytes
{ {
bytes(char const* s, int len): arr(s, len) {} bytes(char const* s, std::size_t len): arr(s, len) {}
bytes(std::string const& s): arr(s) {} bytes(std::string const& s): arr(s) {}
bytes(std::string&& s): arr(std::move(s)) {} bytes(std::string&& s): arr(std::move(s)) {}
bytes(bytes const&) = default; bytes(bytes const&) = default;

View File

@ -34,6 +34,8 @@ overviews = {}
# maps names -> URL # maps names -> URL
symbols = {} symbols = {}
global orphaned_export
# some files that need pre-processing to turn symbols into # some files that need pre-processing to turn symbols into
# links into the reference documentation # links into the reference documentation
preprocess_rst = \ preprocess_rst = \
@ -283,6 +285,9 @@ def parse_function(lno, lines, filename):
end_paren = 0 end_paren = 0
signature = '' signature = ''
global orphaned_export
orphaned_export = False
while lno < len(lines): while lno < len(lines):
line = lines[lno].strip() line = lines[lno].strip()
lno += 1 lno += 1
@ -358,6 +363,9 @@ def parse_class(lno, lines, filename):
name = decl.split(':')[0].replace('class ', '').replace('struct ', '').replace('final', '').strip() name = decl.split(':')[0].replace('class ', '').replace('struct ', '').replace('final', '').strip()
global orphaned_export
orphaned_export = False
while lno < len(lines): while lno < len(lines):
line = lines[lno].strip() line = lines[lno].strip()
lno += 1 lno += 1
@ -695,8 +703,16 @@ for filename in files:
blanks = 0 blanks = 0
lno = 0 lno = 0
global orphaned_export
orphaned_export = False
while lno < len(lines): while lno < len(lines):
line = lines[lno].strip() line = lines[lno].strip()
if orphaned_export:
print('ERROR: TORRENT_EXPORT without function or class!\n%s:%d\n%s' % (filename, lno, line))
sys.exit(1)
lno += 1 lno += 1
if line == '': if line == '':
@ -704,6 +720,18 @@ for filename in files:
context = '' context = ''
continue continue
if 'TORRENT_EXPORT' in line.split() \
and 'ifndef TORRENT_EXPORT' not in line \
and 'define TORRENT_DEPRECATED_EXPORT TORRENT_EXPORT' not in line \
and 'define TORRENT_EXPORT' not in line \
and 'for TORRENT_EXPORT' not in line \
and 'TORRENT_EXPORT TORRENT_CFG' not in line \
and 'extern TORRENT_EXPORT ' not in line \
and 'struct TORRENT_EXPORT ' not in line:
orphaned_export = True
if verbose:
print('maybe orphaned: %s\n' % line)
if line.startswith('//') and line[2:].strip() == 'OVERVIEW': if line.startswith('//') and line[2:].strip() == 'OVERVIEW':
# this is a section overview # this is a section overview
current_overview = '' current_overview = ''

View File

@ -497,7 +497,7 @@ POSSIBILITY OF SUCH DAMAGE.
#endif #endif
#if !defined(TORRENT_READ_HANDLER_MAX_SIZE) #if !defined(TORRENT_READ_HANDLER_MAX_SIZE)
# ifdef _GLIBCXX_DEBUG # if defined _GLIBCXX_DEBUG || !defined NDEBUG
constexpr std::size_t TORRENT_READ_HANDLER_MAX_SIZE = 400; constexpr std::size_t TORRENT_READ_HANDLER_MAX_SIZE = 400;
# else # else
// if this is not divisible by 8, we're wasting space // if this is not divisible by 8, we're wasting space
@ -506,7 +506,7 @@ constexpr std::size_t TORRENT_READ_HANDLER_MAX_SIZE = 342;
#endif #endif
#if !defined(TORRENT_WRITE_HANDLER_MAX_SIZE) #if !defined(TORRENT_WRITE_HANDLER_MAX_SIZE)
# ifdef _GLIBCXX_DEBUG # if defined _GLIBCXX_DEBUG || !defined NDEBUG
constexpr std::size_t TORRENT_WRITE_HANDLER_MAX_SIZE = 400; constexpr std::size_t TORRENT_WRITE_HANDLER_MAX_SIZE = 400;
# else # else
// if this is not divisible by 8, we're wasting space // if this is not divisible by 8, we're wasting space

View File

@ -236,8 +236,8 @@ namespace libtorrent { namespace dht {
using dht_storage_constructor_type using dht_storage_constructor_type
= std::function<std::unique_ptr<dht_storage_interface>(dht_settings const& settings)>; = std::function<std::unique_ptr<dht_storage_interface>(dht_settings const& settings)>;
TORRENT_EXPORT std::unique_ptr<dht_storage_interface> TORRENT_EXPORT std::unique_ptr<dht_storage_interface> dht_default_storage_constructor(
dht_default_storage_constructor(dht_settings const& settings); dht_settings const& settings);
} } // namespace libtorrent::dht } } // namespace libtorrent::dht

View File

@ -1046,7 +1046,7 @@ namespace aux {
#endif #endif
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
bool const use_ssl = req.ssl_ctx != nullptr; bool const use_ssl = req.ssl_ctx != nullptr && req.ssl_ctx != &m_ssl_ctx;
if (!use_ssl) req.ssl_ctx = &m_ssl_ctx; if (!use_ssl) req.ssl_ctx = &m_ssl_ctx;
#endif #endif

View File

@ -139,16 +139,7 @@ enum
// if a packet receives more than this number of // if a packet receives more than this number of
// duplicate acks, we'll trigger a fast re-send // duplicate acks, we'll trigger a fast re-send
dup_ack_limit = 3, dup_ack_limit = 3
// the max number of packets to fast-resend per
// selective ack message
// only re-sending a single packet per sack
// appears to improve performance by making it
// less likely to loose the re-sent packet. Because
// when that happens, we must time-out in order
// to continue, which takes a long time.
sack_resend_limit = 1
}; };
// compare if lhs is less than rhs, taking wrapping // compare if lhs is less than rhs, taking wrapping
@ -1543,15 +1534,21 @@ std::pair<std::uint32_t, int> utp_socket_impl::parse_sack(std::uint16_t const pa
{ {
experienced_loss(m_fast_resend_seq_nr); experienced_loss(m_fast_resend_seq_nr);
int num_resent = 0; int num_resent = 0;
while (m_fast_resend_seq_nr != last_ack)
// only re-sending a single packet per sack
// appears to improve performance by making it
// less likely to loose the re-sent packet. Because
// when that happens, we must time-out in order
// to continue, which takes a long time.
if (m_fast_resend_seq_nr != last_ack)
{ {
packet* p = m_outbuf.at(m_fast_resend_seq_nr); packet* p = m_outbuf.at(m_fast_resend_seq_nr);
m_fast_resend_seq_nr = (m_fast_resend_seq_nr + 1) & ACK_MASK; m_fast_resend_seq_nr = (m_fast_resend_seq_nr + 1) & ACK_MASK;
if (!p) continue; if (p)
++num_resent; {
if (!resend_packet(p, true)) break; ++num_resent;
m_duplicate_acks = 0; if (resend_packet(p, true)) m_duplicate_acks = 0;
if (num_resent >= sack_resend_limit) break; }
} }
} }
@ -2876,13 +2873,6 @@ bool utp_socket_impl::incoming_packet(span<std::uint8_t const> buf
} }
std::uint8_t const next_extension = *ptr++; std::uint8_t const next_extension = *ptr++;
int const len = *ptr++; int const len = *ptr++;
if (len < 0)
{
UTP_LOGV("%8p: invalid extension length:%d packet:%d\n"
, static_cast<void*>(this), len, int(ptr - buf.data()));
m_sm.inc_stats_counter(counters::utp_invalid_pkts_in);
return true;
}
if (ptr - buf.data() + len > size) if (ptr - buf.data() + len > size)
{ {
UTP_LOG("%8p: ERROR: invalid extension header size:%d packet:%d\n" UTP_LOG("%8p: ERROR: invalid extension header size:%d packet:%d\n"