Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] make sure data to be inserted into CRcvLossList are monotonic #2195

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion srtcore/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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)
{
Expand Down Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions srtcore/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -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&);
Expand Down