From 33c8e492a0014a8173487f89205aab82067ca4b2 Mon Sep 17 00:00:00 2001 From: Maxim Sharabayko Date: Mon, 25 Oct 2021 15:27:54 +0200 Subject: [PATCH] [core] checkNeedDrop returns the congestion state --- srtcore/core.cpp | 14 +++++++------- srtcore/core.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/srtcore/core.cpp b/srtcore/core.cpp index 9aa2c5eb2..1833b25d8 100644 --- a/srtcore/core.cpp +++ b/srtcore/core.cpp @@ -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) { @@ -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 @@ -6447,7 +6448,7 @@ void srt::CUDT::checkNeedDrop(bool& w_bCongestion) } #endif } - w_bCongestion = true; + bCongestion = true; leaveCS(m_RecvAckLock); } else if (timespan_ms > (m_iPeerTsbPdDelay_ms / 2)) @@ -6455,8 +6456,9 @@ void srt::CUDT::checkNeedDrop(bool& w_bCongestion) 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) @@ -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); @@ -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) diff --git a/srtcore/core.h b/srtcore/core.h index 9f957d040..54c3927e2 100644 --- a/srtcore/core.h +++ b/srtcore/core.h @@ -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,