Skip to content

Commit

Permalink
[core] Fixed data race: TLPKTDROP while checking loss list for ACK ca…
Browse files Browse the repository at this point in the history
…ndidate (#1668)
  • Loading branch information
ethouris authored Nov 24, 2020
1 parent 3bc810b commit b7eb2d2
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8056,25 +8056,23 @@ int CUDT::sendCtrlAck(CPacket& ctrlpkt, int size)

local_prevack = m_iDebugPrevLastAck;

string reason; // just for "a reason" of giving particular % for ACK
string reason = "first lost"; // just for "a reason" of giving particular % for ACK
#endif

// 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.
if (m_pRcvLossList->getLossLength() == 0)
{
ack = CSeqNo::incseq(m_iRcvCurrSeqNo);
#if ENABLE_HEAVY_LOGGING
reason = "expected next";
#endif
}
else
{
// 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.
ScopedLock lock(m_RcvLossLock);
ack = m_pRcvLossList->getFirstLostSeq();
#if ENABLE_HEAVY_LOGGING
reason = "first lost";
#endif
}

// We don't need to check the length prematurely,
// if length is 0, this will return SRT_SEQNO_NONE.
// If so happened, simply use the latest received pkt + 1.
if (ack == SRT_SEQNO_NONE)
{
ack = CSeqNo::incseq(m_iRcvCurrSeqNo);
IF_HEAVY_LOGGING(reason = "expected next");
}

if (m_iRcvLastAckAck == ack)
Expand Down

0 comments on commit b7eb2d2

Please sign in to comment.