Skip to content

Commit

Permalink
[core] Fixed the RCV buff nonread position update
Browse files Browse the repository at this point in the history
condition in case of dropping upto a sequence number.
  • Loading branch information
maxsharabayko committed Feb 12, 2024
1 parent 3dba3f4 commit a9a92af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion srtcore/buffer_rcv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ int CRcvBuffer::dropUpTo(int32_t seqno)

// If the nonread position is now behind the starting position, set it to the starting position and update.
// Preceding packets were likely missing, and the non read position can probably be moved further now.
if (CSeqNo::seqcmp(m_iFirstNonreadPos, m_iStartPos) < 0)
if (cmpPos(m_iFirstNonreadPos, m_iStartPos) < 0)
{
m_iFirstNonreadPos = m_iStartPos;
updateNonreadPos();
Expand Down
5 changes: 5 additions & 0 deletions srtcore/buffer_rcv.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ class CRcvBuffer
inline int incPos(int pos, int inc = 1) const { return (pos + inc) % m_szSize; }
inline int decPos(int pos) const { return (pos - 1) >= 0 ? (pos - 1) : int(m_szSize - 1); }
inline int offPos(int pos1, int pos2) const { return (pos2 >= pos1) ? (pos2 - pos1) : int(m_szSize + pos2 - pos1); }

/// @brief Compares the two positions in the receiver buffer.
/// @param pos2 a position in the receiver buffer.
/// @param pos1 a position in the receiver buffer.
/// @return a positive value if pos2 is ahead of pos1; a negative value, if pos2 is behind pos1; otherwise returns 0.
inline int cmpPos(int pos2, int pos1) const
{
// XXX maybe not the best implementation, but this keeps up to the rule
Expand Down

0 comments on commit a9a92af

Please sign in to comment.