Skip to content

Commit

Permalink
[core] Fixed the inconsistency between getFirstLostSeq() and ackDataU…
Browse files Browse the repository at this point in the history
…pTo() (#2488)
  • Loading branch information
gou4shi1 authored Nov 1, 2022
1 parent ea86302 commit 0f6e7c7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7822,6 +7822,10 @@ int srt::CUDT::sendCtrlAck(CPacket& ctrlpkt, int size)
dropToGroupRecvBase();
#endif

// The TSBPD thread may change the first lost sequence record (TLPKTDROP).
// To avoid it the m_RcvBufferLock has to be acquired.
UniqueLock bufflock(m_RcvBufferLock);

{
// If there is no loss, the ACK is the current largest sequence number plus 1;
// Otherwise it is the smallest sequence number in the receiver loss list.
Expand Down Expand Up @@ -7850,18 +7854,16 @@ int srt::CUDT::sendCtrlAck(CPacket& ctrlpkt, int size)
// to save time on buffer processing and bandwidth/AS measurement, a lite ACK only feeds back an ACK number
if (size == SEND_LITE_ACK)
{
bufflock.unlock();
ctrlpkt.pack(UMSG_ACK, NULL, &ack, size);
ctrlpkt.m_iID = m_PeerID;
nbsent = m_pSndQueue->sendto(m_PeerAddr, ctrlpkt);
DebugAck(CONID() + "sendCtrl(lite): ", local_prevack, ack);
return nbsent;
}

// There are new received packets to acknowledge, update related information.
/* tsbpd thread may also call ackData when skipping packet so protect code */
UniqueLock bufflock(m_RcvBufferLock);

// IF ack %> m_iRcvLastAck
// There are new received packets to acknowledge, update related information.
if (CSeqNo::seqcmp(ack, m_iRcvLastAck) > 0)
{
ackDataUpTo(ack);
Expand Down

0 comments on commit 0f6e7c7

Please sign in to comment.