History

one more crack at fixing false deadlock

Brad Hefta-Gaub committed 10 years ago

Commit f7e6f601 parent bb42d841 file · +4 −4Browse files

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

Unified · Split

interface/src/Application.cpp+4−4
@@ -270,10 +270,10 @@ public: · 269 unmodified lines
270270 void run() override {
271271 while (!_quit) {
272272 QThread::sleep(HEARTBEAT_UPDATE_INTERVAL_SECS);
273− auto now = usecTimestampNow();
274273
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;
274+ uint64_t lastHeartbeat = _heartbeat; // sample atomic _heartbeat, because we could context switch away and have it updated on us
275+ uint64_t now = usecTimestampNow();
276+ auto lastHeartbeatAge = (now > lastHeartbeat) ? now - lastHeartbeat : 0;
277277 auto sinceLastReport = (now > _lastReport) ? now - _lastReport : 0;
278278 auto elapsedMovingAverage = _movingAverage.getAverage();
279279
@@ -310,7 +310,7 @@ public: · 30 unmodified lines
310310 if (lastHeartbeatAge > MAX_HEARTBEAT_AGE_USECS) {
311311 qDebug() << "DEADLOCK DETECTED -- "
312312 << "lastHeartbeatAge:" << lastHeartbeatAge
313− << "[ _heartbeat:" << _heartbeat
313+ << "[ lastHeartbeat :" << lastHeartbeat
314314 << "now:" << now << " ]"
315315 << "elapsedMovingAverage:" << elapsedMovingAverage
316316 << "maxElapsed:" << _maxElapsed

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