-
Notifications
You must be signed in to change notification settings - Fork 851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core] Slightly optimize the RCV drop by message number. #2686
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,9 @@ 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; | ||
} | ||
|
||
|
@@ -319,13 +322,15 @@ int CRcvBuffer::dropMessage(int32_t seqnolo, int32_t seqnohi, int32_t msgno, Dro | |
|
||
if (bDropByMsgNo) | ||
{ | ||
// First try to drop by message number in case the message starts earlier thtan @a seqnolo. | ||
// The sender should have the last packet of the message it is requesting to be dropped, | ||
// therefore we don't search forward. | ||
// If msgno is specified, potentially not the whole message was dropped using seqno range. | ||
// The sender might have removed the first packets of the message, and thus @a seqnolo may point to a packet in the middle. | ||
// The sender should have the last packet of the message it is requesting to be dropped. | ||
// Therefore we don't search forward, but need to check earlier packets in the RCV buffer. | ||
// Try to drop by the message number in case the message starts earlier than @a seqnolo. | ||
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,21 +341,19 @@ 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 %" | ||
<< packetAt(i).getSeqNo() << "."); | ||
LOGC(rbuflog.Debug, | ||
log << "CRcvBuffer::dropMessage(): Skipped dropping an existing SOLO message packet %" | ||
<< packetAt(i).getSeqNo() << "."); | ||
break; | ||
} | ||
|
||
++iDropCnt; | ||
dropUnitInPos(i); | ||
m_entries[i].status = EntryState_Drop; | ||
// As the search goes backward, i is always earlier than minDroppedOffset. | ||
minDroppedOffset = offPos(m_iStartPos, i); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As said in #2661 (comment)
gou4shi1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (minDroppedOffset == -1) | ||
minDroppedOffset = offPos(m_iStartPos, i); | ||
else | ||
minDroppedOffset = min(offPos(m_iStartPos, i), minDroppedOffset); | ||
|
||
// Break the loop if the start of message has been found. No need to search further. | ||
// Break the loop if the start of the message has been found. No need to search further. | ||
if (bnd == PB_FIRST) | ||
break; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed typo: exising