From cb5d83434ce2e186ef87957377e8dc0e9749bce6 Mon Sep 17 00:00:00 2001 From: Guangqing Chen Date: Sat, 11 Mar 2023 17:41:29 +0800 Subject: [PATCH] [core] some minor improvements on logs and comments --- srtcore/buffer_rcv.cpp | 17 +++++++---------- srtcore/core.cpp | 8 ++++---- srtcore/group.cpp | 10 ++++------ 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/srtcore/buffer_rcv.cpp b/srtcore/buffer_rcv.cpp index 3098407a6d..598c53fc8f 100644 --- a/srtcore/buffer_rcv.cpp +++ b/srtcore/buffer_rcv.cpp @@ -257,8 +257,9 @@ int CRcvBuffer::dropAll() int CRcvBuffer::dropMessage(int32_t seqnolo, int32_t seqnohi, int32_t msgno, DropActionIfExists actionOnExisting) { IF_RCVBUF_DEBUG(ScopedLog scoped_log); - IF_RCVBUF_DEBUG(scoped_log.ss << "CRcvBuffer::dropMessage: seqnolo " << seqnolo << " seqnohi " << seqnohi - << ", msgno " << msgno << " m_iStartSeqNo " << m_iStartSeqNo); + IF_RCVBUF_DEBUG(scoped_log.ss << "CRcvBuffer::dropMessage(): %(" << seqnolo << "-" << seqnohi << ")" + << " #" << msgno << " actionOnExisting=" << actionOnExisting << " m_iStartSeqNo=%" + << m_iStartSeqNo); // Drop by packet seqno range to also wipe those packets that do not exist in the buffer. const int offset_a = CSeqNo::seqoff(m_iStartSeqNo, seqnolo); @@ -293,7 +294,7 @@ int CRcvBuffer::dropMessage(int32_t seqnolo, int32_t seqnohi, int32_t msgno, Dro if (bKeepExisting && bnd == PB_SOLO) { bDropByMsgNo = false; // Solo packet, don't search for the rest of the message. - LOGC(rbuflog.Debug, log << "CRcvBuffer.dropMessage(): Skipped dropping an exising SOLO packet %" << packetAt(i).getSeqNo() << "."); + LOGC(rbuflog.Debug, log << "CRcvBuffer.dropMessage(): Skipped dropping an existing SOLO packet %" << packetAt(i).getSeqNo() << "."); continue; } @@ -325,7 +326,7 @@ int CRcvBuffer::dropMessage(int32_t seqnolo, int32_t seqnohi, int32_t msgno, Dro const int stop_pos = decPos(m_iStartPos); for (int i = start_pos; i != stop_pos; i = decPos(i)) { - // Can't drop is message number is not known. + // Can't drop if message number is not known. if (!m_entries[i].pUnit) // also dropped earlier. continue; @@ -336,7 +337,7 @@ int CRcvBuffer::dropMessage(int32_t seqnolo, int32_t seqnohi, int32_t msgno, Dro if (bKeepExisting && bnd == PB_SOLO) { - LOGC(rbuflog.Debug, log << "CRcvBuffer.dropMessage(): Skipped dropping an exising SOLO message packet %" + LOGC(rbuflog.Debug, log << "CRcvBuffer.dropMessage(): Skipped dropping an existing SOLO message packet %" << packetAt(i).getSeqNo() << "."); break; } @@ -344,11 +345,7 @@ int CRcvBuffer::dropMessage(int32_t seqnolo, int32_t seqnohi, int32_t msgno, Dro ++iDropCnt; dropUnitInPos(i); m_entries[i].status = EntryState_Drop; - - if (minDroppedOffset == -1) - minDroppedOffset = offPos(m_iStartPos, i); - else - minDroppedOffset = min(offPos(m_iStartPos, i), minDroppedOffset); + minDroppedOffset = offPos(m_iStartPos, i); // Break the loop if the start of message has been found. No need to search further. if (bnd == PB_FIRST) diff --git a/srtcore/core.cpp b/srtcore/core.cpp index e6da157a55..adbf608e58 100644 --- a/srtcore/core.cpp +++ b/srtcore/core.cpp @@ -9728,7 +9728,7 @@ void srt::CUDT::sendLossReport(const std::vector > & bool srt::CUDT::overrideSndSeqNo(int32_t seq) { // This function is intended to be called from the socket - // group managmenet functions to synchronize the sequnece in + // group management functions to synchronize the sequnece in // all sockes in the bonding group. THIS sequence given // here is the sequence TO BE STAMPED AT THE EXACTLY NEXT // sent payload. Therefore, screw up the ISN to exactly this @@ -9770,9 +9770,9 @@ bool srt::CUDT::overrideSndSeqNo(int32_t seq) // the latter is ahead with the number of packets already scheduled, but // not yet sent. - HLOGC(gslog.Debug, log << CONID() << "overrideSndSeqNo: sched-seq=" << m_iSndNextSeqNo << " send-seq=" << m_iSndCurrSeqNo - << " (unchanged)" - ); + HLOGC(gslog.Debug, + log << CONID() << "overrideSndSeqNo: sched-seq=" << m_iSndNextSeqNo << " send-seq=" << m_iSndCurrSeqNo + << " (unchanged)"); return true; } diff --git a/srtcore/group.cpp b/srtcore/group.cpp index f4dfba1ba4..dad9d9a4d1 100644 --- a/srtcore/group.cpp +++ b/srtcore/group.cpp @@ -1223,12 +1223,10 @@ int CUDTGroup::sendBroadcast(const char* buf, int len, SRT_MSGCTRL& w_mc) // and therefore take over the leading role in setting the ISN. If the // second one fails, too, then the only remaining idle link will simply // go with its own original sequence. - // - // On the opposite side the reader should know that the link is inactive - // so the first received payload activates it. Activation of an idle link - // means that the very first packet arriving is TAKEN AS A GOOD DEAL, that is, - // no LOSSREPORT is sent even if the sequence looks like a "jumped over". - // Only for activated links is the LOSSREPORT sent upon seqhole detection. + + // On the opposite side, if the first packet arriving looks like a jump over, + // the corresponding LOSSREPORT is sent. For packets that are truly lost, + // the sender retransmits them, for packets that before ISN, DROPREQ is sent. // Now we can go to the idle links and attempt to send the payload // also over them.