Sync libtorrent to 0.13RC
Update python bindings to support wait_for_alert() and scrape_tracker() plus associated alerts. This modifies lt's wait_for_alert() to return a std::auto_ptr.
This commit is contained in:
parent
dae1472f61
commit
a7e6ec4b06
2
TODO
2
TODO
|
@ -23,4 +23,6 @@
|
|||
* Add filtering to torrentview to use with the sidebar
|
||||
* Fix up preferences for when using a remote host.. the download folders, etc..
|
||||
* Add decay items to statusbar.. items that will disappear after X seconds
|
||||
* Do not update UI when minimized or hidden
|
||||
* Add command line option to change config dir.. --config
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@ extern char const* portmap_error_alert_doc;
|
|||
extern char const* portmap_alert_doc;
|
||||
extern char const* fastresume_rejected_alert_doc;
|
||||
extern char const* peer_blocked_alert_doc;
|
||||
extern char const* scrape_reply_alert_doc;
|
||||
extern char const* scrape_failed_alert_doc;
|
||||
|
||||
void bind_alert()
|
||||
{
|
||||
|
@ -210,4 +212,15 @@ void bind_alert()
|
|||
)
|
||||
.def_readonly("ip", &peer_blocked_alert::ip)
|
||||
;
|
||||
|
||||
class_<scrape_reply_alert, bases<torrent_alert>, noncopyable>(
|
||||
"scrape_reply_alert", scrape_reply_alert_doc, no_init
|
||||
)
|
||||
.def_readonly("incomplete", &scrape_reply_alert::incomplete)
|
||||
.def_readonly("complete", &scrape_reply_alert::complete)
|
||||
;
|
||||
|
||||
class_<scrape_failed_alert, bases<torrent_alert>, noncopyable>(
|
||||
"scrape_failed_alert", scrape_failed_alert_doc, no_init
|
||||
);
|
||||
}
|
||||
|
|
|
@ -177,6 +177,9 @@ char const* session_start_natpmp_doc =
|
|||
"";
|
||||
char const* session_stop_natpmp_doc =
|
||||
"";
|
||||
char const* session_wait_for_alert_doc =
|
||||
"";
|
||||
|
||||
// -- alert -----------------------------------------------------------------
|
||||
|
||||
char const* alert_doc =
|
||||
|
@ -321,3 +324,13 @@ char const* fastresume_rejected_alert_doc =
|
|||
|
||||
char const* peer_blocked_alert_doc =
|
||||
"";
|
||||
|
||||
char const* scrape_reply_alert_doc =
|
||||
"This alert is generated when a scrape request succeeds.\n"
|
||||
"incomplete and complete is the data returned in the scrape\n"
|
||||
"response. These numbers may be -1 if the reponse was malformed.";
|
||||
|
||||
char const* scrape_failed_alert_doc =
|
||||
"If a scrape request fails, this alert is generated. This might\n"
|
||||
"be due to the tracker timing out, refusing connection or returning\n"
|
||||
"an http response code indicating an error.";
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <libtorrent/session.hpp>
|
||||
#include <libtorrent/torrent.hpp>
|
||||
#include <libtorrent/storage.hpp>
|
||||
#include <libtorrent/time.hpp>
|
||||
#include <boost/python.hpp>
|
||||
#include "gil.hpp"
|
||||
|
||||
|
@ -56,6 +57,7 @@ extern char const* session_stop_lsd_doc;
|
|||
extern char const* session_stop_upnp_doc;
|
||||
extern char const* session_start_natpmp_doc;
|
||||
extern char const* session_stop_natpmp_doc;
|
||||
extern char const* session_wait_for_alert_doc;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -248,6 +250,7 @@ void bind_session()
|
|||
.def("stop_lsd", allow_threads(&session::stop_lsd), session_stop_lsd_doc)
|
||||
.def("start_natpmp", allow_threads(&session::start_natpmp), session_start_natpmp_doc)
|
||||
.def("stop_natpmp", allow_threads(&session::stop_natpmp), session_stop_natpmp_doc)
|
||||
.def("wait_for_alert", allow_threads(&session::wait_for_alert), session_wait_for_alert_doc)
|
||||
;
|
||||
|
||||
register_ptr_to_python<std::auto_ptr<alert> >();
|
||||
|
|
|
@ -190,6 +190,7 @@ void bind_torrent_handle()
|
|||
.def("prioritize_files", prioritize_files)
|
||||
.def("get_peer_info", get_peer_info)
|
||||
.def("get_download_queue", get_download_queue)
|
||||
.def("scrape_tracker", (&torrent_handle::scrape_tracker))
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace libtorrent {
|
|||
void set_severity(alert::severity_t severity);
|
||||
bool should_post(alert::severity_t severity) const;
|
||||
|
||||
alert const* wait_for_alert(time_duration max_wait);
|
||||
std::auto_ptr<alert> wait_for_alert(time_duration max_wait);
|
||||
|
||||
private:
|
||||
std::queue<alert*> m_alerts;
|
||||
|
|
|
@ -280,7 +280,7 @@ namespace libtorrent
|
|||
void set_severity_level(alert::severity_t s);
|
||||
std::auto_ptr<alert> pop_alert();
|
||||
|
||||
alert const* wait_for_alert(time_duration max_wait);
|
||||
std::auto_ptr<alert> wait_for_alert(time_duration max_wait);
|
||||
|
||||
int upload_rate_limit() const;
|
||||
int download_rate_limit() const;
|
||||
|
|
|
@ -265,7 +265,7 @@ namespace libtorrent
|
|||
std::auto_ptr<alert> pop_alert();
|
||||
void set_severity_level(alert::severity_t s);
|
||||
|
||||
alert const* wait_for_alert(time_duration max_wait);
|
||||
std::auto_ptr<alert> wait_for_alert(time_duration max_wait);
|
||||
|
||||
connection_queue& get_connection_queue();
|
||||
|
||||
|
|
|
@ -78,11 +78,11 @@ namespace libtorrent {
|
|||
}
|
||||
}
|
||||
|
||||
alert const* alert_manager::wait_for_alert(time_duration max_wait)
|
||||
std::auto_ptr<alert> alert_manager::wait_for_alert(time_duration max_wait)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
|
||||
if (!m_alerts.empty()) return m_alerts.front();
|
||||
if (!m_alerts.empty()) return std::auto_ptr<alert>(m_alerts.front());
|
||||
|
||||
int secs = total_seconds(max_wait);
|
||||
max_wait -= seconds(secs);
|
||||
|
@ -96,10 +96,10 @@ namespace libtorrent {
|
|||
xt.sec += 1;
|
||||
}
|
||||
xt.nsec = nsec;
|
||||
if (!m_condition.timed_wait(lock, xt)) return 0;
|
||||
if (!m_condition.timed_wait(lock, xt)) return std::auto_ptr<alert>(NULL);
|
||||
TORRENT_ASSERT(!m_alerts.empty());
|
||||
if (m_alerts.empty()) return 0;
|
||||
return m_alerts.front();
|
||||
if (m_alerts.empty()) return std::auto_ptr<alert>(NULL);
|
||||
return std::auto_ptr<alert>(m_alerts.front());
|
||||
}
|
||||
|
||||
void alert_manager::post_alert(const alert& alert_)
|
||||
|
|
|
@ -422,7 +422,7 @@ namespace libtorrent
|
|||
return m_impl->pop_alert();
|
||||
}
|
||||
|
||||
alert const* session::wait_for_alert(time_duration max_wait)
|
||||
std::auto_ptr<alert> session::wait_for_alert(time_duration max_wait)
|
||||
{
|
||||
return m_impl->wait_for_alert(max_wait);
|
||||
}
|
||||
|
|
|
@ -766,6 +766,8 @@ namespace detail
|
|||
mutex::scoped_lock l2(m_checker_impl.m_mutex);
|
||||
// abort the checker thread
|
||||
m_checker_impl.m_abort = true;
|
||||
|
||||
m_io_service.stop();
|
||||
}
|
||||
|
||||
void session_impl::set_port_filter(port_filter const& f)
|
||||
|
@ -1572,6 +1574,24 @@ namespace detail
|
|||
}
|
||||
while (!m_abort);
|
||||
|
||||
ptime end = time_now() + seconds(m_settings.stop_tracker_timeout);
|
||||
while (time_now() < end && !m_tracker_manager.empty())
|
||||
{
|
||||
m_io_service.reset();
|
||||
m_io_service.poll();
|
||||
// sleep 200 milliseconds
|
||||
boost::xtime xt;
|
||||
boost::xtime_get(&xt, boost::TIME_UTC);
|
||||
boost::int64_t nsec = xt.nsec + 200 * 1000000;
|
||||
if (nsec > 1000000000)
|
||||
{
|
||||
nsec -= 1000000000;
|
||||
xt.sec += 1;
|
||||
}
|
||||
xt.nsec = nsec;
|
||||
boost::thread::sleep(xt);
|
||||
}
|
||||
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
(*m_logger) << time_now_string() << " locking mutex\n";
|
||||
#endif
|
||||
|
@ -2252,7 +2272,7 @@ namespace detail
|
|||
return std::auto_ptr<alert>(0);
|
||||
}
|
||||
|
||||
alert const* session_impl::wait_for_alert(time_duration max_wait)
|
||||
std::auto_ptr<alert> session_impl::wait_for_alert(time_duration max_wait)
|
||||
{
|
||||
return m_alerts.wait_for_alert(max_wait);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue