Skip to content

Commit

Permalink
[core] checkNeedDrop returns the congestion state
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko committed Nov 24, 2021
1 parent 5f3cd06 commit 33c8e49
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6362,10 +6362,10 @@ int srt::CUDT::receiveBuffer(char *data, int len)

// [[using maybe_locked(CUDTGroup::m_GroupLock, m_parent->m_GroupOf != NULL)]];
// [[using locked(m_SendLock)]];
void srt::CUDT::checkNeedDrop(bool& w_bCongestion)
bool srt::CUDT::checkNeedDrop()
{
if (!m_bPeerTLPktDrop)
return;
return false;

if (!m_config.bMessageAPI)
{
Expand All @@ -6390,6 +6390,7 @@ void srt::CUDT::checkNeedDrop(bool& w_bCongestion)
(2 * COMM_SYN_INTERVAL_US / 1000);
}

bool bCongestion = false;
if (threshold_ms && timespan_ms > threshold_ms)
{
// protect packet retransmission
Expand Down Expand Up @@ -6447,16 +6448,17 @@ void srt::CUDT::checkNeedDrop(bool& w_bCongestion)
}
#endif
}
w_bCongestion = true;
bCongestion = true;
leaveCS(m_RecvAckLock);
}
else if (timespan_ms > (m_iPeerTsbPdDelay_ms / 2))
{
HLOGC(aslog.Debug,
log << "cong, BYTES " << bytes << ", TMSPAN " << timespan_ms << "ms");

w_bCongestion = true;
bCongestion = true;
}
return bCongestion;
}

int srt::CUDT::sendmsg(const char *data, int len, int msttl, bool inorder, int64_t srctime)
Expand All @@ -6473,8 +6475,6 @@ int srt::CUDT::sendmsg(const char *data, int len, int msttl, bool inorder, int64
// which is the only case when the m_parent->m_GroupOf is not NULL.
int srt::CUDT::sendmsg2(const char *data, int len, SRT_MSGCTRL& w_mctrl)
{
bool bCongestion = false;

// throw an exception if not connected
if (m_bBroken || m_bClosing)
throw CUDTException(MJ_CONNECTION, MN_CONNLOST, 0);
Expand Down Expand Up @@ -6563,7 +6563,7 @@ int srt::CUDT::sendmsg2(const char *data, int len, SRT_MSGCTRL& w_mctrl)

// checkNeedDrop(...) may lock m_RecvAckLock
// to modify m_pSndBuffer and m_pSndLossList
checkNeedDrop((bCongestion));
const bool bCongestion = checkNeedDrop();

int minlen = 1; // Minimum sender buffer space required for STREAM API
if (m_config.bMessageAPI)
Expand Down
2 changes: 1 addition & 1 deletion srtcore/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ class CUDT

void updateIdleLinkFrom(CUDT* source);

void checkNeedDrop(bool& bCongestion);
bool checkNeedDrop();

/// Connect to a UDT entity as per hs request. This will update
/// required data in the entity, then update them also in the hs structure,
Expand Down

0 comments on commit 33c8e49

Please sign in to comment.