diff --git a/ChangeLog b/ChangeLog index ef6f9ada4..19ad579aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -88,6 +88,7 @@ incoming connection * added more detailed instrumentation of the disk I/O thread + * add reset_piece_deadline function * fix merkle tree torrent assert 0.15.67 release diff --git a/bindings/python/src/torrent_handle.cpp b/bindings/python/src/torrent_handle.cpp index ba93f0447..181d9292f 100644 --- a/bindings/python/src/torrent_handle.cpp +++ b/bindings/python/src/torrent_handle.cpp @@ -329,6 +329,7 @@ void bind_torrent_handle() .def("read_piece", _(&torrent_handle::read_piece)) .def("set_piece_deadline", _(&torrent_handle::set_piece_deadline) , (arg("index"), arg("deadline"), arg("flags") = 0)) + .def("reset_piece_deadline", _(&torrent_handle::reset_piece_deadline), (arg("index")) .def("piece_availability", &piece_availability) .def("piece_priority", _(piece_priority0)) .def("piece_priority", _(piece_priority1)) diff --git a/docs/manual.rst b/docs/manual.rst index c73bf5442..88a6b1fcd 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -2274,6 +2274,7 @@ Its declaration looks like this:: enum deadline_flags { alert_when_available = 1 }; void set_piece_deadline(int index, int deadline, int flags = 0) const; + void reset_piece_deadline(int index) const; void piece_availability(std::vector& avail) const; void piece_priority(int index, int priority) const; @@ -2322,13 +2323,14 @@ it will throw ``invalid_handle``. Since the torrents are processed by a background thread, there is no guarantee that a handle will remain valid between two calls. -set_piece_deadline() --------------------- +set_piece_deadline() reset_piece_deadline() +------------------------------------------- :: enum deadline_flags { alert_when_available = 1 }; void set_piece_deadline(int index, int deadline, int flags = 0) const; + void reset_piece_deadline(int index) const; This function sets or resets the deadline associated with a specific piece index (``index``). libtorrent will attempt to download this entire piece before @@ -2347,6 +2349,8 @@ as calling `read_piece()`_ for ``index``. ``deadline`` is the number of milliseconds until this piece should be completed. +``reset_piece_deadline`` removes the deadline from the piece. If it hasn't already +been downloaded, it will no longer be considered a priority. piece_availability() -------------------- diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index c007ea2b3..277c4f21e 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -298,6 +298,7 @@ namespace libtorrent void file_priorities(std::vector*) const; void set_piece_deadline(int piece, int t, int flags); + void reset_piece_deadline(int piece); void update_piece_priorities(); void status(torrent_status* st, boost::uint32_t flags); diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 4c9a087fc..171598d83 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -179,6 +179,7 @@ namespace libtorrent enum deadline_flags { alert_when_available = 1 }; void set_piece_deadline(int index, int deadline, int flags = 0) const; + void reset_piece_deadline(int index) const; void set_priority(int prio) const; diff --git a/src/torrent.cpp b/src/torrent.cpp index 246a956f7..da1532dfd 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -3299,6 +3299,11 @@ namespace libtorrent m_time_critical_pieces.insert(i, p); } + void torrent::reset_piece_deadline(int piece) + { + remove_time_critical_piece(piece); + } + void torrent::remove_time_critical_piece(int piece, bool finished) { for (std::list::iterator i = m_time_critical_pieces.begin() diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index c910f8bed..1e86d557e 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -869,5 +869,11 @@ namespace libtorrent TORRENT_ASYNC_CALL3(set_piece_deadline, index, deadline, flags); } + void torrent_handle::reset_piece_deadline(int index) const + { + INVARIANT_CHECK; + TORRENT_ASYNC_CALL1(reset_piece_deadline, index); + } + }