merged post_torrent_updates assert from libtorrent_aio

This commit is contained in:
Arvid Norberg 2012-10-06 14:31:14 +00:00
parent 84ccb31a6d
commit 83754b3427
3 changed files with 20 additions and 1 deletions

View File

@ -237,6 +237,9 @@ namespace libtorrent
, boost::bind(&boost::intrusive_ptr<peer_connection>::get, _1) == p) , boost::bind(&boost::intrusive_ptr<peer_connection>::get, _1) == p)
!= m_connections.end(); != m_connections.end();
} }
// this is set while the session is building the
// torrent status update message
bool m_posting_torrent_updates;
#endif #endif
void main_thread(); void main_thread();

View File

@ -672,6 +672,10 @@ namespace aux {
, m_network_thread(0) , m_network_thread(0)
#endif #endif
{ {
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
m_posting_torrent_updates = false;
#endif
memset(m_redundant_bytes, 0, sizeof(m_redundant_bytes)); memset(m_redundant_bytes, 0, sizeof(m_redundant_bytes));
m_udp_socket.set_rate_limit(m_settings.dht_upload_rate_limit); m_udp_socket.set_rate_limit(m_settings.dht_upload_rate_limit);
@ -4792,6 +4796,10 @@ namespace aux {
std::auto_ptr<state_update_alert> alert(new state_update_alert()); std::auto_ptr<state_update_alert> alert(new state_update_alert());
alert->status.reserve(m_state_updates.size()); alert->status.reserve(m_state_updates.size());
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
m_posting_torrent_updates = true;
#endif
for (std::vector<boost::weak_ptr<torrent> >::iterator i = m_state_updates.begin() for (std::vector<boost::weak_ptr<torrent> >::iterator i = m_state_updates.begin()
, end(m_state_updates.end()); i != end; ++i) , end(m_state_updates.end()); i != end; ++i)
{ {
@ -4803,6 +4811,10 @@ namespace aux {
} }
m_state_updates.clear(); m_state_updates.clear();
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
m_posting_torrent_updates = false;
#endif
m_alerts.post_alert_ptr(alert.release()); m_alerts.post_alert_ptr(alert.release());
} }

View File

@ -2923,7 +2923,7 @@ namespace libtorrent
TORRENT_ASSERT(st.total_wanted >= st.total_wanted_done); TORRENT_ASSERT(st.total_wanted >= st.total_wanted_done);
// subtract padding files // subtract padding files
if (m_padding > 0) if (m_padding > 0 && accurate)
{ {
file_storage const& files = m_torrent_file->files(); file_storage const& files = m_torrent_file->files();
int fileno = 0; int fileno = 0;
@ -8398,6 +8398,10 @@ namespace libtorrent
// this should probably be moved to torrent::start() // this should probably be moved to torrent::start()
TORRENT_ASSERT(shared_from_this()); TORRENT_ASSERT(shared_from_this());
// we can't call state_updated() while the session
// is building the status update alert
TORRENT_ASSERT(!m_ses.m_posting_torrent_updates);
// we're either not subscribing to this torrent, or // we're either not subscribing to this torrent, or
// it has already been updated this round, no need to // it has already been updated this round, no need to
// add it to the list twice // add it to the list twice