diff --git a/ChangeLog b/ChangeLog index 1455dc3c9..36a3f8df3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -107,6 +107,7 @@ * improved LSD performance and made the interval configurable * improved UDP tracker support by caching connect tokens * fast piece optimization + * fixed udp tracker race condition * added support for torrents with odd piece sizes * fixed issue with disk read cache not being cleared when removing torrents * made the DHT socket bind to the same interface as the session diff --git a/include/libtorrent/tracker_manager.hpp b/include/libtorrent/tracker_manager.hpp index 15f23aede..62da5f34c 100644 --- a/include/libtorrent/tracker_manager.hpp +++ b/include/libtorrent/tracker_manager.hpp @@ -160,6 +160,7 @@ namespace libtorrent void set_timeout(int completion_timeout, int read_timeout); void restart_read_timeout(); void cancel(); + bool cancelled() const { return m_abort; } virtual void on_timeout() = 0; virtual ~timeout_handler() {} diff --git a/src/udp_tracker_connection.cpp b/src/udp_tracker_connection.cpp index 4e35bf16c..2edf5e37d 100644 --- a/src/udp_tracker_connection.cpp +++ b/src/udp_tracker_connection.cpp @@ -131,6 +131,12 @@ namespace libtorrent #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING if (cb) cb->debug_log("*** UDP_TRACKER [ name lookup successful ]"); #endif + if (cancelled()) + { + fail(-1, "aborted"); + return; + } + restart_read_timeout(); // look for an address that has the same kind as the one