Flush buffers if too many lost packets.

merge-requests/4/head
Phil Taylor 2021-05-18 15:41:27 +01:00
rodzic 2b8cc4c849
commit ff3eecdfed
1 zmienionych plików z 33 dodań i 23 usunięć

Wyświetl plik

@ -1197,8 +1197,18 @@ void udpBase::sendRetransmitRequest()
rxBufferMutex.lock();
if (!rxSeqBuf.empty() && rxSeqBuf.size() <= rxSeqBuf.lastKey() - rxSeqBuf.firstKey())
{
if ((rxSeqBuf.lastKey() - rxSeqBuf.firstKey() - rxSeqBuf.size()) > 20)
{
// Too many packets to process, flush buffers and start again!
qDebug(logUdp()) << "Too many missing packets, flushing buffer: " << rxSeqBuf.lastKey() << "missing=" << rxSeqBuf.lastKey() - rxSeqBuf.firstKey() - rxSeqBuf.size() + 1;
rxMissing.clear();
missingMutex.lock();
rxSeqBuf.clear();
missingMutex.unlock();
}
else {
// We have at least 1 missing packet!
qDebug(logUdp()) << "Missing Seq: size=" << rxSeqBuf.size() << "firstKey=" << rxSeqBuf.firstKey() << "lastKey=" << rxSeqBuf.lastKey() << "missing=" << rxSeqBuf.lastKey()-rxSeqBuf.firstKey()- rxSeqBuf.size()+1;
qDebug(logUdp()) << "Missing Seq: size=" << rxSeqBuf.size() << "firstKey=" << rxSeqBuf.firstKey() << "lastKey=" << rxSeqBuf.lastKey() << "missing=" << rxSeqBuf.lastKey() - rxSeqBuf.firstKey() - rxSeqBuf.size() + 1;
// We are missing packets so iterate through the buffer and add the missing ones to missing packet list
for (int i = 0; i < rxSeqBuf.keys().length() - 1; i++) {
missingMutex.lock();
@ -1223,7 +1233,7 @@ void udpBase::sendRetransmitRequest()
}
missingMutex.unlock();
}
}
}
rxBufferMutex.unlock();