fix invariant when setting the piece deadline of a piece with priority 0
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
* fix bug in set_piece_deadline() when set in a zero-priority piece
|
||||
* fix issue in URL parser, causing issues with certain tracker URLs
|
||||
* use a different error code than host-unreachable, when skipping tracker announces
|
||||
|
||||
|
@ -4782,9 +4782,14 @@ bool is_downloading_state(int const st)
|
||||
--i;
|
||||
}
|
||||
// just in case this piece had priority 0
|
||||
download_priority_t prev_prio = m_picker->piece_priority(piece);
|
||||
m_picker->set_piece_priority(piece, top_priority);
|
||||
if (prev_prio == dont_download) update_gauge();
|
||||
download_priority_t const prev_prio = m_picker->piece_priority(piece);
|
||||
bool const was_finished = is_finished();
|
||||
bool const filter_updated = m_picker->set_piece_priority(piece, top_priority);
|
||||
if (prev_prio == dont_download)
|
||||
{
|
||||
update_gauge();
|
||||
if (filter_updated) update_peer_interest(was_finished);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -4802,9 +4807,14 @@ bool is_downloading_state(int const st)
|
||||
m_time_critical_pieces.insert(critical_piece_it, p);
|
||||
|
||||
// just in case this piece had priority 0
|
||||
download_priority_t prev_prio = m_picker->piece_priority(piece);
|
||||
m_picker->set_piece_priority(piece, top_priority);
|
||||
if (prev_prio == dont_download) update_gauge();
|
||||
download_priority_t const prev_prio = m_picker->piece_priority(piece);
|
||||
bool const was_finished = is_finished();
|
||||
bool const filter_updated = m_picker->set_piece_priority(piece, top_priority);
|
||||
if (prev_prio == dont_download)
|
||||
{
|
||||
update_gauge();
|
||||
if (filter_updated) update_peer_interest(was_finished);
|
||||
}
|
||||
|
||||
piece_picker::downloading_piece pi;
|
||||
m_picker->piece_info(piece, pi);
|
||||
|
@ -31,11 +31,30 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "swarm_suite.hpp"
|
||||
#include "setup_transfer.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "libtorrent/download_priority.hpp"
|
||||
#include "libtorrent/torrent_info.hpp"
|
||||
|
||||
TORRENT_TEST(time_crititcal)
|
||||
{
|
||||
// with time critical pieces
|
||||
test_swarm(test_flags::time_critical);
|
||||
}
|
||||
|
||||
TORRENT_TEST(time_crititcal_zero_prio)
|
||||
{
|
||||
auto ti = generate_torrent();
|
||||
|
||||
lt::session ses(settings());
|
||||
|
||||
lt::add_torrent_params atp;
|
||||
atp.ti = ti;
|
||||
atp.piece_priorities.resize(std::size_t(ti->num_pieces()), lt::dont_download);
|
||||
atp.save_path = ".";
|
||||
auto h = ses.add_torrent(atp);
|
||||
|
||||
wait_for_downloading(ses, "");
|
||||
|
||||
h.set_piece_deadline(lt::piece_index_t{0}, 0, lt::torrent_handle::alert_when_available);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user