Skip to content

Commit

Permalink
Remove unfinished packets after timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
AWann2 committed Nov 6, 2024
1 parent 3350a93 commit a0aa443
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/extension/network/NUClearNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,15 @@ namespace extension {
// We have completed this packet, discard the data
assemblers.erase(assemblers.find(packet.packet_id));
}

// Check for and delete any timed out packets
for (auto it = assemblers.begin(); it != assemblers.end();) {
const auto now = std::chrono::steady_clock::now();
const auto timeout = remote->round_trip_time * 10.0;
const auto& last_chunk_time = it->second.first;

it = now > last_chunk_time + timeout ? assemblers.erase(it) : std::next(it);
}
}
}
} break;
Expand Down

0 comments on commit a0aa443

Please sign in to comment.