From cbfa812cae7665d9cf949fe63179ffeccab37d40 Mon Sep 17 00:00:00 2001 From: Sektor van Skijlen Date: Fri, 11 Nov 2022 09:37:37 +0100 Subject: [PATCH] [core] Refax/postfix: further fixes after last refax changes (#2528) --- srtcore/core.cpp | 17 +++++++---------- srtcore/core.h | 2 +- srtcore/packet.cpp | 22 ++++++++++++++++++---- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/srtcore/core.cpp b/srtcore/core.cpp index 5ca239995..e1b4b9e49 100644 --- a/srtcore/core.cpp +++ b/srtcore/core.cpp @@ -9669,7 +9669,7 @@ bool srt::CUDT::overrideSndSeqNo(int32_t seq) return true; } -int srt::CUDT::checkLazySpawnLatencyThread() +int srt::CUDT::checkLazySpawnTsbPdThread() { const bool need_tsbpd = m_bTsbPd || m_bGroupTsbPd; @@ -9709,6 +9709,8 @@ int srt::CUDT::handleSocketPacketReception(const vector& incoming, bool& { bool excessive SRT_ATR_UNUSED = true; // stays true unless it was successfully added + w_new_inserted = false; + // Loop over all incoming packets that were filtered out. // In case when there is no filter, there's just one packet in 'incoming', // the one that came in the input of this function. @@ -9719,7 +9721,6 @@ int srt::CUDT::handleSocketPacketReception(const vector& incoming, bool& const int pktrexmitflag = m_bPeerRexmitFlag ? (rpkt.getRexmitFlag() ? 1 : 0) : 2; const bool retransmitted = pktrexmitflag == 1; - int buffer_add_result; bool adding_successful = true; // m_iRcvLastSkipAck is the base sequence number for the receiver buffer. @@ -9750,9 +9751,6 @@ int srt::CUDT::handleSocketPacketReception(const vector& incoming, bool& continue; } - // This is executed only when bonding is enabled and only - // with the new buffer (in which case the buffer is in the group). - const int avail_bufsize = (int) getAvailRcvBufferSizeNoLock(); if (offset >= avail_bufsize) @@ -9791,10 +9789,11 @@ int srt::CUDT::handleSocketPacketReception(const vector& incoming, bool& } } - buffer_add_result = m_pRcvBuffer->insert(u); + int buffer_add_result = m_pRcvBuffer->insert(u); if (buffer_add_result < 0) { - // addData returns -1 if at the m_iLastAckPos+offset position there already is a packet. + // The insert() result is -1 if at the position evaluated from this packet's + // sequence number there already is a packet. // So this packet is "redundant". IF_HEAVY_LOGGING(exc_type = "UNACKED"); adding_successful = false; @@ -9924,7 +9923,7 @@ int srt::CUDT::processData(CUnit* in_unit) // We are receiving data, start tsbpd thread if TsbPd is enabled - if (-1 == checkLazySpawnLatencyThread()) + if (-1 == checkLazySpawnTsbPdThread()) { return -1; } @@ -10081,8 +10080,6 @@ int srt::CUDT::processData(CUnit* in_unit) } #endif - // NULL time by default - time_point next_tsbpd_avail; bool new_inserted = false; if (m_PacketFilter) diff --git a/srtcore/core.h b/srtcore/core.h index e0c5e1243..825259db3 100644 --- a/srtcore/core.h +++ b/srtcore/core.h @@ -1077,7 +1077,7 @@ class CUDT time_point getPktTsbPdTime(void* grp, const CPacket& packet); /// Checks and spawns the TSBPD thread if required. - int checkLazySpawnLatencyThread(); + int checkLazySpawnTsbPdThread(); void processClose(); /// Process the request after receiving the handshake from caller. diff --git a/srtcore/packet.cpp b/srtcore/packet.cpp index cbe4dd90d..e7ddb9db1 100644 --- a/srtcore/packet.cpp +++ b/srtcore/packet.cpp @@ -263,7 +263,7 @@ void CPacket::setLength(size_t len, size_t cap) #if ENABLE_HEAVY_LOGGING // Debug only -static std::string FormatNumbers(UDTMessageType pkttype, const int32_t* lparam, void* rparam, size_t size) +static std::string FormatNumbers(UDTMessageType pkttype, const int32_t* lparam, void* rparam, const size_t size) { // This may be changed over time, so use special interpretation // only for certain types, and still display all data, no matter @@ -288,9 +288,15 @@ static std::string FormatNumbers(UDTMessageType pkttype, const int32_t* lparam, } bool interp_as_seq = (pkttype == UMSG_LOSSREPORT || pkttype == UMSG_DROPREQ); + bool display_dec = (pkttype == UMSG_ACK || pkttype == UMSG_ACKACK || pkttype == UMSG_DROPREQ); out << " [ "; - for (size_t i = 0; i < size; ++i) + + // Will be effective only for hex/oct. + out << std::showbase; + + const size_t size32 = size/4; + for (size_t i = 0; i < size32; ++i) { int32_t val = ((int32_t*)rparam)[i]; if (interp_as_seq) @@ -302,8 +308,16 @@ static std::string FormatNumbers(UDTMessageType pkttype, const int32_t* lparam, } else { - out << std::showpos << std::hex << val << "/" << std::dec << val; + if (!display_dec) + { + out << std::hex; + out << val << "/"; + out << std::dec; + } + out << val; + } + out << " "; } out << "]"; @@ -315,7 +329,7 @@ void CPacket::pack(UDTMessageType pkttype, const int32_t* lparam, void* rparam, { // Set (bit-0 = 1) and (bit-1~15 = type) setControl(pkttype); - HLOGC(inlog.Debug, log << "pack: type=" << MessageTypeStr(pkttype) << FormatNumbers(pkttype, lparam, rparam, size)); + HLOGC(inlog.Debug, log << "pack: type=" << MessageTypeStr(pkttype) << " " << FormatNumbers(pkttype, lparam, rparam, size)); // Set additional information and control information field switch (pkttype)