fix performance issue when receiving UDP packets (the udp tracker would not reject DHT packets immediately)

This commit is contained in:
arvidn 2015-07-17 18:48:20 -04:00
parent f85d62b601
commit 51dd174303
1 changed files with 6 additions and 1 deletions

View File

@ -328,7 +328,12 @@ namespace libtorrent
return false; return false;
} }
const char* ptr = buf + 4; // the first word is the action, if it's not [0, 3]
// it's not a valid udp tracker response
const char* ptr = buf;
boost::uint32_t action = detail::read_uint32(ptr);
if (action > 3) return false;
boost::uint32_t transaction = detail::read_uint32(ptr); boost::uint32_t transaction = detail::read_uint32(ptr);
udp_conns_t::iterator i = m_udp_conns.find(transaction); udp_conns_t::iterator i = m_udp_conns.find(transaction);