Skip to content
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

feat: MConnection prioritizes received messages based on their channel ID priority #1228

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

staheri14
Copy link
Contributor

@staheri14 staheri14 commented Feb 14, 2024

Closes #1192

@staheri14 staheri14 self-assigned this Feb 14, 2024
p2p/conn/connection.go Outdated Show resolved Hide resolved
@@ -869,7 +984,10 @@ func (ch *Channel) recvPacketMsg(packet tmp2p.PacketMsg) ([]byte, error) {
// suggests this could be a memory leak, but we might as well keep the memory for the channel until it closes,
// at which point the recving slice stops being used and should be garbage collected
ch.recving = ch.recving[:0] // make([]byte, 0, ch.desc.RecvBufferCapacity)
return msgBytes, nil

msgCopy := make([]byte, len(msgBytes))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[To reviewers] Without creating a new copy, the original output of this function msgBytes and the ch.recving slice would reference the same memory address. Consequently, if msgBytes is passed to another goroutine, it can lead to a race condition [and it does]. Therefore, it's necessary to create a fresh copy to prevent this issue.

@staheri14 staheri14 changed the title feat: async processing of incoming messages feat: MConnection prioritizes received messages based on their channel ID priority Feb 16, 2024
@staheri14
Copy link
Contributor Author

The TestReactorConcurrency has become flaky, so investigating it.

@staheri14
Copy link
Contributor Author

This PR is ready for review. I am currently waiting for the results from testground to confirm our plan to merge this new logic. Once confirmed, I will mark it as ready for review. In the meantime, please feel free to leave any comments or feedback you may have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lack of channel ID prioritization in MConnection's message receiving process
2 participants