minor cleanups

This commit is contained in:
arvidn 2018-07-24 12:16:43 +02:00 committed by Arvid Norberg
parent c2ebae7dbb
commit 730ef15b08
5 changed files with 19 additions and 10 deletions

View File

@ -516,9 +516,9 @@ namespace aux {
int est_reciprocation_rate() const { return m_est_reciprocation_rate; }
#ifndef TORRENT_DISABLE_LOGGING
bool should_log(peer_log_alert::direction_t direction) const override final;
bool should_log(peer_log_alert::direction_t direction) const final;
void peer_log(peer_log_alert::direction_t direction
, char const* event, char const* fmt, ...) const noexcept override final TORRENT_FORMAT(4,5);
, char const* event, char const* fmt, ...) const noexcept final TORRENT_FORMAT(4,5);
void peer_log(peer_log_alert::direction_t direction
, char const* event) const noexcept;

View File

@ -2422,10 +2422,12 @@ namespace aux {
// socket
bool handled = false;
#ifndef TORRENT_DISABLE_DHT
if (m_dht && buf.size() > 20 && buf.front() == 'd' && buf.back() == 'e')
if (m_dht && buf.size() > 20
&& buf.front() == 'd'
&& buf.back() == 'e'
&& listen_socket)
{
if (listen_socket)
handled = m_dht->incoming_packet(listen_socket, packet.from, buf);
handled = m_dht->incoming_packet(listen_socket, packet.from, buf);
}
#endif

View File

@ -10785,12 +10785,12 @@ bool is_downloading_state(int const st)
if (st->state == torrent_status::finished
|| st->state == torrent_status::seeding)
{
// it may be tempting to assume that st->is_finished == true here, but
// this assumption does not always hold. We transition to "finished"
// when we receive the last block of the last piece, which is before
// the hash check comes back. "is_finished" is set to true once all the
// pieces have been hash checked. So, there's a short window where it
// doesn't hold.
// TORRENT_ASSERT(st->is_finished);
}
#endif

View File

@ -52,6 +52,12 @@ namespace libtorrent {
using namespace std::placeholders;
// used to build SOCKS messages in
std::size_t const tmp_buffer_size = 270;
// used for SOCKS5 UDP wrapper header
std::size_t const max_header_size = 25;
// this class hold the state of the SOCKS5 connection to maintain the UDP
// ASSOCIATE tunnel. It's instantiated on the heap for two reasons:
//
@ -97,7 +103,7 @@ private:
tcp::resolver m_resolver;
deadline_timer m_timer;
deadline_timer m_retry_timer;
std::array<char, 270> m_tmp_buf;
std::array<char, tmp_buffer_size> m_tmp_buf;
aux::proxy_settings m_proxy_settings;
@ -312,7 +318,7 @@ void udp_socket::wrap(udp::endpoint const& ep, span<char const> p
TORRENT_UNUSED(flags);
using namespace libtorrent::detail;
std::array<char, 25> header;
std::array<char, max_header_size> header;
char* h = header.data();
write_uint16(0, h); // reserved
@ -336,7 +342,7 @@ void udp_socket::wrap(char const* hostname, int const port, span<char const> p
{
using namespace libtorrent::detail;
std::array<char, 270> header;
std::array<char, max_header_size> header;
char* h = header.data();
write_uint16(0, h); // reserved

View File

@ -513,7 +513,8 @@ namespace libtorrent {
return;
}
std::array<char, 16> buf;
std::size_t const connect_packet_size = 16;
std::array<char, connect_packet_size> buf;
span<char> view = buf;
TORRENT_ASSERT(m_transaction_id != 0);