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

Refax: removed m_iRcvLastSkipAck and its dependencies #2546

Merged
merged 13 commits into from
Nov 29, 2022
Prev Previous commit
Next Next commit
Restored the old dropping proc for the sake of DROPREQ. Changed remov…
…eUpTo convention for including given seqno. Removed unused updateForgotten.
  • Loading branch information
Mikołaj Małecki committed Nov 22, 2022
commit 0b6515844aa771943415df74a28db43f0a6e53e2
43 changes: 23 additions & 20 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
@@ -5421,7 +5421,7 @@ int srt::CUDT::rcvDropTooLateUpTo(int seqno)
seqno = CSeqNo::incseq(m_iRcvCurrSeqNo);
}

dropFromLossLists(CSeqNo::decseq(seqno));
dropFromLossLists(SRT_SEQNO_NONE, CSeqNo::decseq(seqno));

const int iDropCnt = m_pRcvBuffer->dropUpTo(seqno);
if (iDropCnt > 0)
@@ -5460,17 +5460,6 @@ void srt::CUDT::setInitialRcvSeq(int32_t isn)
}
}

void srt::CUDT::updateForgotten(int seqlen, int32_t skiptoseqno)
{
enterCS(m_StatsLock);
// Estimate dropped bytes from average payload size.
const uint64_t avgpayloadsz = m_pRcvBuffer->getRcvAvgPayloadSize();
m_stats.rcvr.dropped.count(stats::BytesPackets(seqlen * avgpayloadsz, (uint32_t) seqlen));
leaveCS(m_StatsLock);

dropFromLossLists(CSeqNo::decseq(skiptoseqno)); //remove(from,to-inclusive)
}

bool srt::CUDT::prepareConnectionObjects(const CHandShake &hs, HandshakeSide hsd, CUDTException *eout)
{
// This will be lazily created due to being the common
@@ -8778,8 +8767,7 @@ void srt::CUDT::processCtrlDropReq(const CPacket& ctrlpkt)
rcvtscc.notify_one();
}
}
// XXX Add some sanity check on dropdata[0]?
dropFromLossLists(dropdata[1]);
dropFromLossLists(dropdata[0], dropdata[1]);

// If dropping ahead of the current largest sequence number,
// move the recv seq number forward.
@@ -10571,20 +10559,32 @@ breakbreak:;
}
}

void srt::CUDT::dropFromLossLists(int32_t to)
void srt::CUDT::dropFromLossLists(int32_t from, int32_t to)
{
ScopedLock lg(m_RcvLossLock);
int32_t from SRT_ATR_UNUSED = m_pRcvLossList->removeUpTo(CSeqNo::incseq(to));

IF_HEAVY_LOGGING(bool autodetected = false);
int32_t begin SRT_ATR_UNUSED;
if (from == SRT_SEQNO_NONE)
{
begin = m_pRcvLossList->removeUpTo(to);
IF_HEAVY_LOGGING(autodetected = true);
}
else
{
begin = from;
m_pRcvLossList->remove(from, to);
}

#if ENABLE_HEAVY_LOGGING
ostringstream range;
if (from == SRT_SEQNO_NONE)
if (begin == SRT_SEQNO_NONE)
{
range << "no";
}
else
{
int off = CSeqNo::seqoff(from, to);
int off = CSeqNo::seqoff(begin, to);
if (off < 0)
{
range << "WEIRD NUMBER OF";
@@ -10595,7 +10595,10 @@ void srt::CUDT::dropFromLossLists(int32_t to)
}
}

HLOGC(qrlog.Debug, log << CONID() << "TLPKTDROP %" << from << "-" << to << " ("
static const char* const beginwhere[2] = {"explicit", "detected"};

HLOGC(qrlog.Debug, log << CONID() << "TLPKTDROP %" << begin
<< "[" << beginwhere[1*autodetected] << "]-" << to << " ("
<< range.str() << " packets)");
#endif

@@ -10613,7 +10616,7 @@ void srt::CUDT::dropFromLossLists(int32_t to)
size_t delete_index = 0;
for (size_t i = 0; i < m_FreshLoss.size(); ++i)
{
CRcvFreshLoss::Emod result = m_FreshLoss[i].revoke(SRT_SEQNO_NONE, to);
CRcvFreshLoss::Emod result = m_FreshLoss[i].revoke(from, to);
switch (result)
{
case CRcvFreshLoss::DELETE:
4 changes: 1 addition & 3 deletions srtcore/core.h
Original file line number Diff line number Diff line change
@@ -662,7 +662,7 @@ class CUDT
/// removes the loss record from both current receiver loss list and
/// the receiver fresh loss list.
void unlose(const CPacket& oldpacket);
void dropFromLossLists(int32_t to);
void dropFromLossLists(int32_t from, int32_t to);
bool getFirstNoncontSequence(int32_t& w_seq, std::string& w_log_reason);

void checkSndTimers();
@@ -723,8 +723,6 @@ class CUDT
/// @return The number of packets dropped.
int rcvDropTooLateUpTo(int seqno);

void updateForgotten(int seqlen, int32_t skiptoseqno);

static loss_seqs_t defaultPacketArrival(void* vself, CPacket& pkt);
static loss_seqs_t groupPacketArrival(void* vself, CPacket& pkt);

18 changes: 9 additions & 9 deletions srtcore/list.cpp
Original file line number Diff line number Diff line change
@@ -730,28 +730,28 @@ bool srt::CRcvLossList::remove(int32_t seqno1, int32_t seqno2)
return true;
}

int32_t srt::CRcvLossList::removeUpTo(int32_t seqno_end)
int32_t srt::CRcvLossList::removeUpTo(int32_t seqno_last)
{
int32_t first = getFirstLostSeq();
if (first == SRT_SEQNO_NONE)
{
//HLOGC(tslog.Debug, log << "rcv-loss: DROP to %" << seqno_end << " - empty list");
HLOGC(tslog.Debug, log << "rcv-loss: DROP to %" << seqno_last << " - empty list");
return first; // empty, so nothing to remove
}

if (CSeqNo::seqcmp(seqno_end, first) <= 0)
if (CSeqNo::seqcmp(seqno_last, first) < 0)
{
//HLOGC(tslog.Debug, log << "rcv-loss: DROP to %" << seqno_end << " - first %" << first << " is newer, exitting");
return first; // seqno_end older than first - nothing to remove
HLOGC(tslog.Debug, log << "rcv-loss: DROP to %" << seqno_last << " - first %" << first << " is newer, exitting");
return first; // seqno_last older than first - nothing to remove
}

//HLOGC(tslog.Debug, log << "rcv-loss: DROP to %" << seqno_end << " ...");
HLOGC(tslog.Debug, log << "rcv-loss: DROP to %" << seqno_last << " ...");

// NOTE: seqno_end is past-the-end here. Removed are only seqs
// NOTE: seqno_last is past-the-end here. Removed are only seqs
// that are earlier than this.
for (int32_t i = first; CSeqNo::seqcmp(i, seqno_end) < 0; i = CSeqNo::incseq(i))
for (int32_t i = first; CSeqNo::seqcmp(i, seqno_last) <= 0; i = CSeqNo::incseq(i))
{
//HLOGC(tslog.Debug, log << "... removing %" << i);
HLOGC(tslog.Debug, log << "... removing %" << i);
remove(i);
}