mirror of
https://github.com/overte-org/overte.git
synced 2025-08-18 08:06:47 +02:00
Added ACKs removal from sent list
This commit is contained in:
parent
e330727e36
commit
f06d21691d
2 changed files with 15 additions and 1 deletions
|
@ -81,7 +81,16 @@ void SendQueue::sendPacket(const Packet& packet) {
|
|||
}
|
||||
|
||||
void SendQueue::ack(SeqNum ack) {
|
||||
// TODO Remove acked packet from sent list
|
||||
if (_lastAck == ack) {
|
||||
return;
|
||||
}
|
||||
|
||||
QWriteLocker locker(&_sentLock);
|
||||
for (auto seq = _lastAck; seq != ack; ++seq) {
|
||||
_sentPackets.erase(seq);
|
||||
}
|
||||
|
||||
_lastAck = ack;
|
||||
}
|
||||
|
||||
void SendQueue::nak(std::list<SeqNum> naks) {
|
||||
|
@ -103,6 +112,7 @@ void SendQueue::sendNextPacket() {
|
|||
sendPacket(*_nextPacket);
|
||||
|
||||
// Insert the packet we have just sent in the sent list
|
||||
QWriteLocker locker(&_sentLock);
|
||||
_sentPackets[_nextPacket->getSequenceNumber()].swap(_nextPacket);
|
||||
Q_ASSERT_X(!_nextPacket,
|
||||
"SendQueue::sendNextPacket()", "Overriden packet in sent list");
|
||||
|
@ -122,6 +132,7 @@ void SendQueue::sendNextPacket() {
|
|||
|
||||
// Find packet in sent list using SeqNum
|
||||
if (hasResend) {
|
||||
QWriteLocker locker(&_sentLock);
|
||||
auto it = _sentPackets.find(seqNum);
|
||||
Q_ASSERT_X(it != _sentPackets.end(),
|
||||
"SendQueue::sendNextPacket()", "Couldn't find NAKed packet to resend");
|
||||
|
|
|
@ -68,6 +68,7 @@ private:
|
|||
Socket* _socket { nullptr }; // Socket to send packet on
|
||||
HifiSockAddr _destination; // Destination addr
|
||||
SeqNum _currentSeqNum; // Last sequence number sent out
|
||||
SeqNum _lastAck; // ACKed sequence number
|
||||
|
||||
std::unique_ptr<QTimer> _sendTimer; // Send timer
|
||||
std::atomic<int> _packetSendPeriod { 0 }; // Interval between two packet send envent in msec
|
||||
|
@ -76,6 +77,8 @@ private:
|
|||
|
||||
QReadWriteLock _naksLock; // Protects the naks list.
|
||||
std::list<SeqNum> _naks; // Sequence numbers of packets to resend
|
||||
|
||||
QReadWriteLock _sentLock; // Protects the sent packet list
|
||||
std::unordered_map<SeqNum, std::unique_ptr<Packet>> _sentPackets; // Packets waiting for ACK.
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue