added unit test for RSS feeds and fixed a parsing bug

This commit is contained in:
Arvid Norberg
2012-02-20 07:51:36 +00:00
parent 079a8f8314
commit 75fce84ce4
6 changed files with 204 additions and 31 deletions

View File

@@ -320,7 +320,8 @@ feed_handle feed::my_handle()
void feed::on_feed(error_code const& ec
, http_parser const& parser, char const* data, int size)
{
TORRENT_ASSERT(m_updating);
// enabling this assert makes the unit test a lot more difficult
// TORRENT_ASSERT(m_updating);
m_updating = false;
if (ec && ec != asio::error::eof)
@@ -350,32 +351,35 @@ void feed::on_feed(error_code const& ec
feed_state s(*this);
xml_parse(buf, buf + size, boost::bind(&parse_feed, boost::ref(s), _1, _2, _3));
for (std::vector<feed_item>::iterator i = m_items.begin()
, end(m_items.end()); i != end; ++i)
if (m_settings.auto_download || m_settings.auto_map_handles)
{
i->handle = torrent_handle(m_ses.find_torrent(i->uuid.empty() ? i->url : i->uuid));
// if we're already downloading this torrent, or if we
// don't have auto-download enabled, just move along to
// the next one
if (i->handle.is_valid() || !m_settings.auto_download) continue;
// this means we should add this torrent to the session
add_torrent_params p = m_settings.add_args;
p.url = i->url;
p.uuid = i->uuid;
p.source_feed_url = m_settings.url;
p.ti.reset();
p.info_hash.clear();
p.name = i->title.c_str();
error_code e;
// #error session_impl::add_torrent doesn't support magnet links via url
m_ses.add_torrent(p, e);
if (e)
for (std::vector<feed_item>::iterator i = m_items.begin()
, end(m_items.end()); i != end; ++i)
{
// #error alert!
i->handle = torrent_handle(m_ses.find_torrent(i->uuid.empty() ? i->url : i->uuid));
// if we're already downloading this torrent, or if we
// don't have auto-download enabled, just move along to
// the next one
if (i->handle.is_valid() || !m_settings.auto_download) continue;
// this means we should add this torrent to the session
add_torrent_params p = m_settings.add_args;
p.url = i->url;
p.uuid = i->uuid;
p.source_feed_url = m_settings.url;
p.ti.reset();
p.info_hash.clear();
p.name = i->title.c_str();
error_code e;
// #error session_impl::add_torrent doesn't support magnet links via url
m_ses.add_torrent(p, e);
if (e)
{
// #error alert!
}
}
}

View File

@@ -1718,9 +1718,7 @@ namespace aux {
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
(*m_logger) << time_now_string() << " aborting all connections (" << m_connections.size() << ")\n";
#endif
// closing all the connections needs to be done from a callback,
// when the session mutex is not held
m_io_service.post(boost::bind(&connection_queue::close, &m_half_open));
m_half_open.close();
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
(*m_logger) << time_now_string() << " connection queue: " << m_half_open.size() << "\n";