fix potential overflow in stats averaging
This commit is contained in:
parent
7bd0573927
commit
a5c0fd7210
|
@ -43,8 +43,8 @@ void stat_channel::second_tick(int tick_interval_ms)
|
||||||
{
|
{
|
||||||
int sample = int(size_type(m_counter) * 1000 / tick_interval_ms);
|
int sample = int(size_type(m_counter) * 1000 / tick_interval_ms);
|
||||||
TORRENT_ASSERT(sample >= 0);
|
TORRENT_ASSERT(sample >= 0);
|
||||||
m_5_sec_average = m_5_sec_average * 4 / 5 + sample / 5;
|
m_5_sec_average = size_type(m_5_sec_average) * 4 / 5 + sample / 5;
|
||||||
m_30_sec_average = m_30_sec_average * 29 / 30 + sample / 30;
|
m_30_sec_average = size_type(m_30_sec_average) * 29 / 30 + sample / 30;
|
||||||
m_counter = 0;
|
m_counter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue