mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 10:19:06 +02:00
protect against unexpected rollover
This commit is contained in:
parent
541c1e5c6f
commit
fe31be71eb
1 changed files with 4 additions and 2 deletions
|
@ -271,8 +271,10 @@ public:
|
||||||
while (!_quit) {
|
while (!_quit) {
|
||||||
QThread::sleep(HEARTBEAT_UPDATE_INTERVAL_SECS);
|
QThread::sleep(HEARTBEAT_UPDATE_INTERVAL_SECS);
|
||||||
auto now = usecTimestampNow();
|
auto now = usecTimestampNow();
|
||||||
auto lastHeartbeatAge = now - _heartbeat;
|
|
||||||
auto sinceLastReport = now - _lastReport;
|
// in the unlikely event that now is less than _heartbeat, don't rollover and confuse ourselves
|
||||||
|
auto lastHeartbeatAge = (now > _heartbeat) ? now - _heartbeat : 0;
|
||||||
|
auto sinceLastReport = (now > _lastReport) ? now - _lastReport : 0;
|
||||||
auto elapsedMovingAverage = _movingAverage.getAverage();
|
auto elapsedMovingAverage = _movingAverage.getAverage();
|
||||||
|
|
||||||
if (elapsedMovingAverage > _maxElapsedAverage) {
|
if (elapsedMovingAverage > _maxElapsedAverage) {
|
||||||
|
|
Loading…
Reference in a new issue