fix potential overflow in stats averaging

This commit is contained in:
Arvid Norberg 2011-04-22 08:12:19 +00:00
parent 7bd0573927
commit a5c0fd7210
1 changed files with 2 additions and 2 deletions

View File

@ -43,8 +43,8 @@ void stat_channel::second_tick(int tick_interval_ms)
{
int sample = int(size_type(m_counter) * 1000 / tick_interval_ms);
TORRENT_ASSERT(sample >= 0);
m_5_sec_average = m_5_sec_average * 4 / 5 + sample / 5;
m_30_sec_average = m_30_sec_average * 29 / 30 + sample / 30;
m_5_sec_average = size_type(m_5_sec_average) * 4 / 5 + sample / 5;
m_30_sec_average = size_type(m_30_sec_average) * 29 / 30 + sample / 30;
m_counter = 0;
}