Skip to content

Commit

Permalink
[core] Group::updateReadState() support out-of-order messages
Browse files Browse the repository at this point in the history
  • Loading branch information
gou4shi1 authored and maxsharabayko committed Feb 8, 2022
1 parent 650dbe6 commit c885ed1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
27 changes: 13 additions & 14 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7663,7 +7663,7 @@ void srt::CUDT::releaseSynch()
}

// [[using locked(m_RcvBufferLock)]];
int32_t srt::CUDT::ackDataUpTo(int32_t ack)
void srt::CUDT::ackDataUpTo(int32_t ack)
{
const int acksize SRT_ATR_UNUSED = CSeqNo::seqoff(m_iRcvLastSkipAck, ack);

Expand All @@ -7673,24 +7673,14 @@ int32_t srt::CUDT::ackDataUpTo(int32_t ack)
m_iRcvLastAck = ack;
m_iRcvLastSkipAck = ack;

#if ENABLE_NEW_RCVBUFFER
const std::pair<int, int> range = m_pRcvBuffer->getAvailablePacketsRange();
// Some packets acknowledged are not available in the buffer.
if (CSeqNo::seqcmp(range.second, ack) < 0)
{
LOGC(xtlog.Error, log << "IPE: Acknowledged seqno %" << ack << " outruns the RCV buffer state %" << range.first
<< " - %" << range.second);
}
return CSeqNo::decseq(range.second);
#else
#if !ENABLE_NEW_RCVBUFFER
// NOTE: This is new towards UDT and prevents spurious
// wakeup of select/epoll functions when no new packets
// were signed off for extraction.
if (acksize > 0)
{
m_pRcvBuffer->ackData(acksize);
}
return ack;
#endif
}

Expand Down Expand Up @@ -7930,7 +7920,16 @@ int srt::CUDT::sendCtrlAck(CPacket& ctrlpkt, int size)
// IF ack %> m_iRcvLastAck
if (CSeqNo::seqcmp(ack, m_iRcvLastAck) > 0)
{
const int32_t group_read_seq SRT_ATR_UNUSED = ackDataUpTo(ack);
ackDataUpTo(ack);

#if ENABLE_EXPERIMENTAL_BONDING
#if ENABLE_NEW_RCVBUFFER
const int32_t group_read_seq = m_pRcvBuffer->getFirstReadablePacketInfo(steady_clock::now()).seqno;
#else
const int32_t group_read_seq = CSeqNo::decseq(ack);
#endif
#endif

InvertedLock un_bufflock (m_RcvBufferLock);

#if ENABLE_EXPERIMENTAL_BONDING
Expand Down Expand Up @@ -8015,7 +8014,7 @@ int srt::CUDT::sendCtrlAck(CPacket& ctrlpkt, int size)
}
}
#if ENABLE_EXPERIMENTAL_BONDING
if (m_parent->m_GroupOf)
if (group_read_seq != SRT_SEQNO_NONE && m_parent->m_GroupOf)
{
// See above explanation for double-checking
ScopedLock glock (uglobal().m_GlobControlLock);
Expand Down
3 changes: 1 addition & 2 deletions srtcore/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1075,8 +1075,7 @@ class CUDT
/// @brief Acknowledge reading position up to the @p seq.
/// Updates m_iRcvLastAck and m_iRcvLastSkipAck to @p seq.
/// @param seq first unacknowledged packet sequence number.
/// @return
int32_t ackDataUpTo(int32_t seq);
void ackDataUpTo(int32_t seq);

void handleKeepalive(const char* data, size_t lenghth);

Expand Down

0 comments on commit c885ed1

Please sign in to comment.