Skip to content

Commit

Permalink
[core] Refact: moved code to processCtrlDropReq
Browse files Browse the repository at this point in the history
dedicated function
  • Loading branch information
maxsharabayko committed Apr 9, 2021
1 parent 7a2b3a2 commit eb6e029
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 38 deletions.
78 changes: 40 additions & 38 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8360,6 +8360,45 @@ void CUDT::processCtrlHS(const CPacket& ctrlpkt)
}
}

void CUDT::processCtrlDropReq(const CPacket& ctrlpkt)
{
{
const bool using_rexmit_flag = m_bPeerRexmitFlag;
UniqueLock rlock(m_RecvLock);
m_pRcvBuffer->dropMsg(ctrlpkt.getMsgSeq(using_rexmit_flag), using_rexmit_flag);
// When the drop request was received, it means that there are
// packets for which there will never be ACK sent; if the TSBPD thread
// is currently in the ACK-waiting state, it may never exit.
if (m_bTsbPd)
{
HLOGP(inlog.Debug, "DROPREQ: signal TSBPD");
CSync cc(m_RcvTsbPdCond, rlock);
cc.signal_locked(rlock);
}
}

const int32_t* dropdata = (const int32_t*) ctrlpkt.m_pcData;

dropFromLossLists(dropdata[0], dropdata[1]);

// move forward with current recv seq no.
// SYMBOLIC:
// if (dropdata[0] <=% 1 +% m_iRcvCurrSeqNo
// && dropdata[1] >% m_iRcvCurrSeqNo )
if ((CSeqNo::seqcmp(dropdata[0], CSeqNo::incseq(m_iRcvCurrSeqNo)) <= 0)
&& (CSeqNo::seqcmp(dropdata[1], m_iRcvCurrSeqNo) > 0))
{
HLOGC(inlog.Debug, log << CONID() << "DROPREQ: dropping %"
<< dropdata[0] << "-" << dropdata[1] << " <-- set as current seq");
m_iRcvCurrSeqNo = dropdata[1];
}
else
{
HLOGC(inlog.Debug, log << CONID() << "DROPREQ: dropping %"
<< dropdata[0] << "-" << dropdata[1] << " current %" << m_iRcvCurrSeqNo);
}
}

void CUDT::processCtrl(const CPacket &ctrlpkt)
{
// Just heard from the peer, reset the expiration count.
Expand Down Expand Up @@ -8416,44 +8455,7 @@ void CUDT::processCtrl(const CPacket &ctrlpkt)
break;

case UMSG_DROPREQ: // 111 - Msg drop request
{
const bool using_rexmit_flag = m_bPeerRexmitFlag;
UniqueLock rlock(m_RecvLock);
m_pRcvBuffer->dropMsg(ctrlpkt.getMsgSeq(using_rexmit_flag), using_rexmit_flag);
// When the drop request was received, it means that there are
// packets for which there will never be ACK sent; if the TSBPD thread
// is currently in the ACK-waiting state, it may never exit.
if (m_bTsbPd)
{
HLOGP(inlog.Debug, "DROPREQ: signal TSBPD");
CSync cc(m_RcvTsbPdCond, rlock);
cc.signal_locked(rlock);
}
}

{
int32_t* dropdata = (int32_t*)ctrlpkt.m_pcData;

dropFromLossLists(dropdata[0], dropdata[1]);

// move forward with current recv seq no.
// SYMBOLIC:
// if (dropdata[0] <=% 1 +% m_iRcvCurrSeqNo
// && dropdata[1] >% m_iRcvCurrSeqNo )
if ((CSeqNo::seqcmp(dropdata[0], CSeqNo::incseq(m_iRcvCurrSeqNo)) <= 0)
&& (CSeqNo::seqcmp(dropdata[1], m_iRcvCurrSeqNo) > 0))
{
HLOGC(inlog.Debug, log << CONID() << "DROPREQ: dropping %"
<< dropdata[0] << "-" << dropdata[1] << " <-- set as current seq");
m_iRcvCurrSeqNo = dropdata[1];
}
else
{
HLOGC(inlog.Debug, log << CONID() << "DROPREQ: dropping %"
<< dropdata[0] << "-" << dropdata[1] << " current %" << m_iRcvCurrSeqNo);
}
}

processCtrlDropReq(ctrlpkt);
break;

case UMSG_PEERERROR: // 1000 - An error has happened to the peer side
Expand Down
4 changes: 4 additions & 0 deletions srtcore/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,10 @@ class CUDT
/// @param ctrlpkt incoming HS packet
void processCtrlHS(const CPacket& ctrlpkt);

/// @brief Process incoming drop request control packet
/// @param ctrlpkt incoming drop request packet
void processCtrlDropReq(const CPacket& ctrlpkt);

/// @brief Update sender's loss list on an incoming acknowledgement.
/// @param ackdata_seqno sequence number of a data packet being acknowledged
void updateSndLossListOnACK(int32_t ackdata_seqno);
Expand Down

0 comments on commit eb6e029

Please sign in to comment.