diff --git a/srtcore/list.cpp b/srtcore/list.cpp index e295fb8c8..c6a54a691 100644 --- a/srtcore/list.cpp +++ b/srtcore/list.cpp @@ -487,6 +487,7 @@ CRcvLossList::CRcvLossList(int size) , m_iTail(-1) , m_iLength(0) , m_iSize(size) + , m_iLargestSeq(SRT_SEQNO_NONE) { m_caSeq = new Seq[m_iSize]; @@ -506,7 +507,25 @@ CRcvLossList::~CRcvLossList() void CRcvLossList::insert(int32_t seqno1, int32_t seqno2) { // Data to be inserted must be larger than all those in the list - // guaranteed by the UDT receiver + if (m_iLargestSeq != SRT_SEQNO_NONE && CSeqNo::seqcmp(seqno1, m_iLargestSeq) <= 0) + { + if (CSeqNo::seqcmp(seqno2, m_iLargestSeq) > 0) + { + LOGC(qrlog.Warn, + log << "RCV-LOSS/insert: seqno1=" << seqno1 << " too small, adjust to " + << CSeqNo::incseq(m_iLargestSeq)); + seqno1 = CSeqNo::incseq(m_iLargestSeq); + } + else + { + LOGC(qrlog.Warn, + log << "RCV-LOSS/insert: (" << seqno1 << "," << seqno2 + << ") to be inserted is too small: m_iLargestSeq=" << m_iLargestSeq << ", m_iLength=" << m_iLength + << ", m_iHead=" << m_iHead << ", m_iTail=" << m_iTail << " -- REJECTING"); + return; + } + } + m_iLargestSeq = seqno2; if (0 == m_iLength) { @@ -561,6 +580,9 @@ void CRcvLossList::insert(int32_t seqno1, int32_t seqno2) bool CRcvLossList::remove(int32_t seqno) { + if (m_iLargestSeq == SRT_SEQNO_NONE || CSeqNo::seqcmp(seqno, m_iLargestSeq) > 0) + m_iLargestSeq = seqno; + if (0 == m_iLength) return false; diff --git a/srtcore/list.h b/srtcore/list.h index 19b300f30..d79349aa7 100644 --- a/srtcore/list.h +++ b/srtcore/list.h @@ -185,6 +185,7 @@ class CRcvLossList int m_iTail; // last node in the list; int m_iLength; // loss length int m_iSize; // size of the static array + int m_iLargestSeq; // largest seq ever seen private: CRcvLossList(const CRcvLossList&);