mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-09 15:50:26 +03:00
don't recalculate badwidth if clock was adjusted too much
This commit is contained in:
parent
04adc14b76
commit
d04b19d77c
@ -152,8 +152,16 @@ namespace transport
|
||||
|
||||
void UpdateBandwidth ()
|
||||
{
|
||||
uint64_t interval = m_LastActivityTimestamp - m_LastBandwidthUpdateTimestamp;
|
||||
if (interval > TRANSPORT_SESSION_BANDWIDTH_UPDATE_MIN_INTERVAL)
|
||||
int64_t interval = m_LastActivityTimestamp - m_LastBandwidthUpdateTimestamp;
|
||||
if (interval < 0 || interval > 60*10) // 10 minutes
|
||||
{
|
||||
// clock was adjusted, copy new values
|
||||
m_LastBandWidthUpdateNumSentBytes = m_NumSentBytes;
|
||||
m_LastBandWidthUpdateNumReceivedBytes = m_NumReceivedBytes;
|
||||
m_LastBandwidthUpdateTimestamp = m_LastActivityTimestamp;
|
||||
return;
|
||||
}
|
||||
if ((uint64_t)interval > TRANSPORT_SESSION_BANDWIDTH_UPDATE_MIN_INTERVAL)
|
||||
{
|
||||
m_OutBandwidth = (m_NumSentBytes - m_LastBandWidthUpdateNumSentBytes)/interval;
|
||||
m_LastBandWidthUpdateNumSentBytes = m_NumSentBytes;
|
||||
|
Loading…
Reference in New Issue
Block a user