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] Improved group readiness updating in sendCtrlAck() #2245

Merged
merged 1 commit into from
Feb 8, 2022
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
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