History

protect against unexpected rollover

Brad Hefta-Gaub committed 10 years ago

Commit fe31be71 parent 541c1e51 file · +4 −2Browse files

Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all

Unified · Split

interface/src/Application.cpp+4−2
@@ -271,8 +271,10 @@ public: · 270 unmodified lines
271271 while (!_quit) {
272272 QThread::sleep(HEARTBEAT_UPDATE_INTERVAL_SECS);
273273 auto now = usecTimestampNow();
274− auto lastHeartbeatAge = now - _heartbeat;
275− auto sinceLastReport = now - _lastReport;
274+
275+ // in the unlikely event that now is less than _heartbeat, don't rollover and confuse ourselves
276+ auto lastHeartbeatAge = (now > _heartbeat) ? now - _heartbeat : 0;
277+ auto sinceLastReport = (now > _lastReport) ? now - _lastReport : 0;
276278 auto elapsedMovingAverage = _movingAverage.getAverage();
277279
278280 if (elapsedMovingAverage > _maxElapsedAverage) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t