mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
SendQueue uses LossList
This commit is contained in:
parent
5d1c0f6935
commit
b5b7fa8504
2 changed files with 10 additions and 22 deletions
|
@ -91,36 +91,24 @@ void SendQueue::ack(SequenceNumber ack) {
|
|||
return;
|
||||
}
|
||||
|
||||
{
|
||||
// remove any ACKed packets from the map of sent packets
|
||||
{ // remove any ACKed packets from the map of sent packets
|
||||
QWriteLocker locker(&_sentLock);
|
||||
for (auto seq = _lastAck; seq <= ack; ++seq) {
|
||||
_sentPackets.erase(seq);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// remove any sequence numbers equal to or lower than this ACK in the loss list
|
||||
{ // remove any sequence numbers equal to or lower than this ACK in the loss list
|
||||
QWriteLocker nakLocker(&_naksLock);
|
||||
|
||||
auto it = _naks.begin();
|
||||
|
||||
while (it != _naks.end()) {
|
||||
if (*it <= ack) {
|
||||
it = _naks.erase(it);
|
||||
} else {
|
||||
// the NAKs in the NAK list must be in order, so we can break if we hit one > ack
|
||||
break;
|
||||
}
|
||||
}
|
||||
_naks.remove(_naks.getFirstSequenceNumber(), ack);
|
||||
}
|
||||
|
||||
_lastAck = ack;
|
||||
}
|
||||
|
||||
void SendQueue::nak(std::list<SequenceNumber> naks) {
|
||||
void SendQueue::nak(SequenceNumber start, SequenceNumber end) {
|
||||
QWriteLocker locker(&_naksLock);
|
||||
_naks.splice(_naks.end(), naks); // Add naks at the end
|
||||
_naks.insert(start, end);
|
||||
}
|
||||
|
||||
SequenceNumber SendQueue::getNextSequenceNumber() {
|
||||
|
@ -154,10 +142,9 @@ void SendQueue::sendNextPacket() {
|
|||
{
|
||||
// Check nak list for packet to resend
|
||||
QWriteLocker locker(&_naksLock);
|
||||
if (!_naks.empty()) {
|
||||
if (_naks.getLength() > 0) {
|
||||
hasResend = true;
|
||||
seqNum = _naks.front();
|
||||
_naks.pop_front();
|
||||
seqNum = _naks.popFirstSequenceNumber();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "../HifiSockAddr.h"
|
||||
|
||||
#include "SequenceNumber.h"
|
||||
#include "LossList.h"
|
||||
|
||||
namespace udt {
|
||||
|
||||
|
@ -55,7 +56,7 @@ public slots:
|
|||
void stop();
|
||||
|
||||
void ack(SequenceNumber ack);
|
||||
void nak(std::list<SequenceNumber> naks);
|
||||
void nak(SequenceNumber start, SequenceNumber end);
|
||||
|
||||
private slots:
|
||||
void sendNextPacket();
|
||||
|
@ -88,7 +89,7 @@ private:
|
|||
std::atomic<bool> _running { false };
|
||||
|
||||
mutable QReadWriteLock _naksLock; // Protects the naks list.
|
||||
std::list<SequenceNumber> _naks; // Sequence numbers of packets to resend
|
||||
LossList _naks; // Sequence numbers of packets to resend
|
||||
|
||||
mutable QReadWriteLock _sentLock; // Protects the sent packet list
|
||||
std::unordered_map<SequenceNumber, std::unique_ptr<Packet>> _sentPackets; // Packets waiting for ACK.
|
||||
|
|
Loading…
Reference in a new issue