diff --git a/include/libtorrent/alert.hpp b/include/libtorrent/alert.hpp index e86df8f3a..985256339 100644 --- a/include/libtorrent/alert.hpp +++ b/include/libtorrent/alert.hpp @@ -287,8 +287,12 @@ namespace libtorrent { time_point m_timestamp; }; -// When you get an alert, you can use ``alert_cast<>`` to attempt to cast the pointer to a -// more specific alert type, in order to query it for more information. +// When you get an alert, you can use ``alert_cast<>`` to attempt to cast the +// pointer to a specific alert type, in order to query it for more +// information. +// +// .. note:: +// ``alert_cast<>`` can only cast to an exact alert type, not a base class template T* alert_cast(alert* a) { if (a == nullptr) return nullptr; diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 3a100dff5..99b26d959 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -2522,8 +2522,12 @@ namespace aux { { // now, disconnect a random peer torrent_map::iterator i = std::max_element(m_torrents.begin() - , m_torrents.end(), boost::bind(&torrent::num_peers - , boost::bind(&torrent_map::value_type::second, _1))); + , m_torrents.end() + , boost::bind(&torrent::num_peers + , boost::bind(&torrent_map::value_type::second, _1)) + < boost::bind(&torrent::num_peers + , boost::bind(&torrent_map::value_type::second, _2)) + ); if (m_alerts.should_post()) m_alerts.emplace_alert( diff --git a/src/torrent.cpp b/src/torrent.cpp index 737765203..e8944d5de 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -9243,7 +9243,11 @@ namespace libtorrent void torrent::do_resume() { TORRENT_ASSERT(is_single_thread()); - if (is_paused()) return; + if (is_paused()) + { + update_want_tick(); + return; + } #ifndef TORRENT_DISABLE_EXTENSIONS for (auto& ext : m_extensions) diff --git a/test/Jamfile b/test/Jamfile index 3117aaf49..d849881d4 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -75,11 +75,9 @@ lib libtorrent_test darwin:-Wno-unused-command-line-argument # disable warning C4275: non DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' msvc:/wd4275 - on : # default build shared - on : # user-requirements shared:TORRENT_LINK_TEST_SHARED @@ -103,6 +101,8 @@ project full shared on + on + on ; feature launcher : none valgrind : composite ; diff --git a/test/test_session.cpp b/test/test_session.cpp index 3abf0d13e..7fb5eb880 100644 --- a/test/test_session.cpp +++ b/test/test_session.cpp @@ -31,7 +31,13 @@ POSSIBILITY OF SUCH DAMAGE. */ #include "libtorrent/session.hpp" + +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include +#include + +#include "libtorrent/aux_/disable_warnings_pop.hpp" #include "test.hpp" #include "setup_transfer.hpp" @@ -42,6 +48,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/bencode.hpp" #include "libtorrent/torrent_info.hpp" +#include + using namespace libtorrent; namespace lt = libtorrent; @@ -151,7 +159,7 @@ TORRENT_TEST(load_empty_file) add_torrent_params atp; error_code ignore_errors; - atp.ti = boost::make_shared("", 0, ignore_errors); + atp.ti = boost::make_shared("", 0, boost::ref(ignore_errors)); atp.save_path = "."; error_code ec; torrent_handle h = ses.add_torrent(atp, ec); @@ -175,6 +183,26 @@ TORRENT_TEST(session_stats) } } +TORRENT_TEST(paused_session) +{ + lt::session s; + s.pause(); + + lt::add_torrent_params ps; + std::ofstream file("temporary"); + ps.ti = ::create_torrent(&file, "temporary", 16 * 1024, 13, false); + ps.flags = lt::add_torrent_params::flag_paused; + ps.save_path = "."; + + torrent_handle h = s.add_torrent(ps); + + test_sleep(2000); + h.resume(); + test_sleep(1000); + + TEST_CHECK(!h.status().paused); +} + template void test_save_restore(Set setup, Save s, Default d, Load l) { diff --git a/test/test_torrent_info.cpp b/test/test_torrent_info.cpp index 1a3214eeb..ac8189777 100644 --- a/test/test_torrent_info.cpp +++ b/test/test_torrent_info.cpp @@ -36,7 +36,13 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/create_torrent.hpp" #include "libtorrent/announce_entry.hpp" #include "libtorrent/aux_/escape_string.hpp" // for convert_path_to_posix + +#include "libtorrent/aux_/disable_warnings_push.hpp" + #include +#include + +#include "libtorrent/aux_/disable_warnings_pop.hpp" #if TORRENT_USE_IOSTREAM #include