Skip to content

Commit

Permalink
Fix issue #1 (#2)
Browse files Browse the repository at this point in the history
Makes the iteration to clean old ack data in ClockServer::updateEntry
dependent on previous entry deletion.

Co-authored-by: Fabian Dreer <[email protected]>
  • Loading branch information
Infrasonics and Fabian Dreer authored Nov 17, 2020
1 parent 9bc7454 commit ab395fd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ClockKit/ClockServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,14 @@ void ClockServer::updateEntry(string addr, int offset, int rtt)
map<string, Entry>::iterator it;

// purge old entries
for(it = ackData_.begin(); it != ackData_.end(); it++)
for(it = ackData_.begin(); it != ackData_.end();)
{
timestamp_t entryTime = (it->second).time;
if (now - entryTime > SYSTEM_STATE_PURGE_TIME)
ackData_.erase(it);
if (now - entryTime > SYSTEM_STATE_PURGE_TIME) {
it = ackData_.erase(it);
} else {
++it;
}
}

// calculate maximum offset
Expand Down

0 comments on commit ab395fd

Please sign in to comment.