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] Made offset consistent with avail_bufsize. #2465

Merged
merged 2 commits into from
Oct 12, 2022
Merged
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
26 changes: 12 additions & 14 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9890,34 +9890,32 @@ int srt::CUDT::processData(CUnit* in_unit)
CUnit * u = *unitIt;
CPacket &rpkt = u->m_Packet;

// m_iRcvLastSkipAck is the base sequence number for the receiver buffer.
// This is the offset in the buffer; if this is negative, it means that
// this sequence is already in the past and the buffer is not interested.
// If negative, the seqno is already behind the dropped/acknowledged position.
// Meaning, this packet will be rejected, even if it could potentially be
// one of missing packets in the transmission.
int32_t offset = CSeqNo::seqoff(m_iRcvLastSkipAck, rpkt.m_iSeqNo);

IF_HEAVY_LOGGING(const char *exc_type = "EXPECTED");

if (offset < 0)
if (CSeqNo::seqcmp(rpkt.m_iSeqNo, m_iRcvLastSkipAck) < 0)
{
IF_HEAVY_LOGGING(exc_type = "BELATED");
steady_clock::time_point tsbpdtime = m_pRcvBuffer->getPktTsbPdTime(rpkt.getMsgTimeStamp());
const double bltime = (double) CountIIR<uint64_t>(
uint64_t(m_stats.traceBelatedTime) * 1000,
count_microseconds(steady_clock::now() - tsbpdtime), 0.2);

const double bltime = (double)CountIIR<uint64_t>(uint64_t(m_stats.traceBelatedTime) * 1000,
count_microseconds(steady_clock::now() - tsbpdtime),
0.2);
enterCS(m_StatsLock);
m_stats.traceBelatedTime = bltime / 1000.0;
m_stats.rcvr.recvdBelated.count(rpkt.getLength());
leaveCS(m_StatsLock);
HLOGC(qrlog.Debug,
log << CONID() << "RECEIVED: seq=" << packet.m_iSeqNo << " offset=" << offset << " (BELATED/"
log << CONID() << "RECEIVED: seq=" << packet.m_iSeqNo
<< " offset=" << CSeqNo::seqoff(m_iRcvLastSkipAck, rpkt.m_iSeqNo) << " (BELATED/"
<< rexmitstat[pktrexmitflag] << rexmit_reason << ") FLAGS: " << packet.MessageFlagStr());
continue;
}

IF_HEAVY_LOGGING(const char *exc_type = "EXPECTED");

// m_iRcvLastAck is the base sequence number for the receiver buffer.
const int32_t offset = CSeqNo::seqoff(m_iRcvLastAck, rpkt.m_iSeqNo);
const int avail_bufsize = (int) getAvailRcvBufferSizeNoLock();

if (offset >= avail_bufsize)
{
// This is already a sequence discrepancy. Probably there could be found
Expand Down