postpone recalculate auto-managed torrents when changing many torrents state

This commit is contained in:
Arvid Norberg 2011-12-23 17:16:14 +00:00
parent d7103ab5b0
commit 231fc30e13
2 changed files with 11 additions and 20 deletions

View File

@ -4510,7 +4510,7 @@ namespace aux {
// a boat load of torrents, we postpone the recalculation until
// we're done adding them all (since it's kind of an expensive operation)
if (params.flags & add_torrent_params::flag_auto_managed)
m_auto_manage_time_scaler = 1;
m_auto_manage_time_scaler = 2;
return torrent_handle(torrent_ptr);
}

View File

@ -5908,8 +5908,8 @@ ctx->set_verify_callback(verify_function, ec);
// this torrent just completed downloads, which means it will fall
// under a different limit with the auto-manager. Make sure we
// update auto-manage torrents in that case
if (m_auto_managed && m_ses.m_auto_manage_time_scaler > 1)
m_ses.m_auto_manage_time_scaler = 1;
if (m_auto_managed)
m_ses.m_auto_manage_time_scaler = 2;
}
// this is called when we were finished, but some files were
@ -6015,19 +6015,14 @@ ctx->set_verify_callback(verify_function, ec);
// if this is an auto managed torrent, force a recalculation
// of which torrents to have active
if (m_auto_managed && m_ses.m_auto_manage_time_scaler > 1)
m_ses.m_auto_manage_time_scaler = 1;
if (m_auto_managed)
m_ses.m_auto_manage_time_scaler = 2;
if (!is_seed())
{
// turn off super seeding if we're not a seed
if (m_super_seeding) m_super_seeding = false;
// if we just finished checking and we're not a seed, we are
// likely to be unpaused
if (m_ses.m_auto_manage_time_scaler > 1)
m_ses.m_auto_manage_time_scaler = 1;
if (is_finished() && m_state != torrent_status::finished)
finished();
}
@ -6410,8 +6405,7 @@ ctx->set_verify_callback(verify_function, ec);
m_sequence_number = (std::min)(max_seq, p);
}
if (m_ses.m_auto_manage_time_scaler > 2)
m_ses.m_auto_manage_time_scaler = 2;
m_ses.m_auto_manage_time_scaler = 2;
}
void torrent::set_max_uploads(int limit)
@ -6536,8 +6530,7 @@ ctx->set_verify_callback(verify_function, ec);
TORRENT_ASSERT(m_ses.is_network_thread());
if (!m_error) return;
bool checking_files = should_check_files();
if (m_ses.m_auto_manage_time_scaler > 2)
m_ses.m_auto_manage_time_scaler = 2;
m_ses.m_auto_manage_time_scaler = 2;
m_error = error_code();
m_error_file.clear();
@ -6602,7 +6595,7 @@ ctx->set_verify_callback(verify_function, ec);
// recalculate which torrents should be
// paused
m_ses.m_auto_manage_time_scaler = 0;
m_ses.m_auto_manage_time_scaler = 2;
if (!checking_files && should_check_files())
{
@ -6618,9 +6611,8 @@ ctx->set_verify_callback(verify_function, ec);
// if this torrent is running and just became auto-managed
// we might want to pause it in favor of some other torrent
if (m_auto_managed && !is_paused()
&& m_ses.m_auto_manage_time_scaler > 1)
m_ses.m_auto_manage_time_scaler = 1;
if (m_auto_managed && !is_paused())
m_ses.m_auto_manage_time_scaler = 2;
}
// the higher seed rank, the more important to seed
@ -6884,8 +6876,7 @@ ctx->set_verify_callback(verify_function, ec);
// if this torrent was just paused
// we might have to resume some other auto-managed torrent
if (m_ses.m_auto_manage_time_scaler > 1)
m_ses.m_auto_manage_time_scaler = 1;
m_ses.m_auto_manage_time_scaler = 2;
}
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING || defined TORRENT_LOGGING