minor fixes in utp_socket_impl

This commit is contained in:
arvidn 2018-02-05 01:29:14 +01:00 committed by Arvid Norberg
parent 137baa6c04
commit 09bf97b79e
1 changed files with 20 additions and 3 deletions

View File

@ -315,6 +315,8 @@ struct utp_socket_impl
, m_stalled(false)
, m_confirmed(false)
{
TORRENT_ASSERT((m_recv_id == ((m_send_id + 1) & 0xffff))
|| (m_send_id == ((m_recv_id + 1) & 0xffff)));
m_sm->inc_stats_counter(counters::num_utp_idle);
TORRENT_ASSERT(m_userdata);
for (int i = 0; i != num_delay_hist; ++i)
@ -2712,10 +2714,18 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
{
INVARIANT_CHECK;
utp_header const* ph = reinterpret_cast<utp_header const*>(buf);
m_sm->inc_stats_counter(counters::utp_packets_in);
if (size < sizeof(utp_header))
{
UTP_LOG("%8p: ERROR: incoming packet size too small:%d (ignored)\n"
, static_cast<void*>(this), size);
m_sm->inc_stats_counter(counters::utp_invalid_pkts_in);
return false;
}
utp_header const* ph = reinterpret_cast<utp_header const*>(buf);
if (ph->get_version() != 1)
{
UTP_LOG("%8p: ERROR: incoming packet version:%d (ignored)\n"
@ -3105,7 +3115,14 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size
UTP_LOGV("%8p: received ST_SYN state:%s seq_nr:%d ack_nr:%d\n"
, static_cast<void*>(this), socket_state_names[m_state], m_seq_nr, m_ack_nr);
#endif
TORRENT_ASSERT(m_send_id == ph->connection_id);
if (m_send_id != ph->connection_id)
{
#if TORRENT_UTP_LOG
UTP_LOGV("%8p: received invalid connection_id:%d expected: %d\n"
, static_cast<void*>(this), int(ph->connection_id), int(m_send_id));
#endif
return false;
}
TORRENT_ASSERT(m_recv_id == ((m_send_id + 1) & 0xffff));
defer_ack();