Skip to content

Commit

Permalink
[core] Fixed build with the old RCV buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko committed Dec 27, 2021
1 parent 1111cbd commit 3d26644
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
49 changes: 25 additions & 24 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5302,6 +5302,31 @@ void * srt::CUDT::tsbpd(void* param)
HLOGC(tslog.Debug, log << self->CONID() << "tsbpd: EXITING");
return NULL;
}

int srt::CUDT::dropTooLateUpTo(int seqno)
{
const int seq_gap_len = CSeqNo::seqoff(m_iRcvLastSkipAck, seqno);

// seq_gap_len can be <= 0 if a packet has been dropped by the sender.
if (seq_gap_len > 0)
{
// Remove [from,to-inclusive]
dropFromLossLists(m_iRcvLastSkipAck, CSeqNo::decseq(seqno));
m_iRcvLastSkipAck = seqno;
}

const int iDropCnt = m_pRcvBuffer->dropUpTo(seqno);
if (iDropCnt > 0)
{
enterCS(m_StatsLock);
// Estimate dropped bytes from average payload size.
const uint64_t avgpayloadsz = m_pRcvBuffer->getRcvAvgPayloadSize();
m_stats.rcvr.dropped.count(stats::BytesPackets(iDropCnt * avgpayloadsz, (size_t)iDropCnt));
leaveCS(m_StatsLock);
}
return iDropCnt;
}

#else
void * srt::CUDT::tsbpd(void *param)
{
Expand Down Expand Up @@ -5521,30 +5546,6 @@ void * srt::CUDT::tsbpd(void *param)
}
#endif // ENABLE_NEW_RCVBUFFER

int srt::CUDT::dropTooLateUpTo(int seqno)
{
const int seq_gap_len = CSeqNo::seqoff(m_iRcvLastSkipAck, seqno);

// seq_gap_len can be <= 0 if a packet has been dropped by the sender.
if (seq_gap_len > 0)
{
// Remove [from,to-inclusive]
dropFromLossLists(m_iRcvLastSkipAck, CSeqNo::decseq(seqno));
m_iRcvLastSkipAck = seqno;
}

const int iDropCnt = m_pRcvBuffer->dropUpTo(seqno);
if (iDropCnt > 0)
{
enterCS(m_StatsLock);
// Estimate dropped bytes from average payload size.
const uint64_t avgpayloadsz = m_pRcvBuffer->getRcvAvgPayloadSize();
m_stats.rcvr.dropped.count(stats::BytesPackets(iDropCnt * avgpayloadsz, (size_t) iDropCnt));
leaveCS(m_StatsLock);
}
return iDropCnt;
}

void srt::CUDT::updateForgotten(int seqlen, int32_t lastack, int32_t skiptoseqno)
{
enterCS(m_StatsLock);
Expand Down
2 changes: 2 additions & 0 deletions srtcore/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,13 @@ class CUDT
// TSBPD thread main function.
static void* tsbpd(void* param);

#if ENABLE_NEW_RCVBUFFER
/// Drop too late packets. Updaet loss lists and ACK positions.
/// The @a seqno packet itself is not dropped.
/// @param seqno [in] The sequence number of the first packets following those to be dropped.
/// @return The number of packets dropped.
int dropTooLateUpTo(int seqno);
#endif

void updateForgotten(int seqlen, int32_t lastack, int32_t skiptoseqno);

Expand Down

0 comments on commit 3d26644

Please sign in to comment.