refactor(connlib): only buffer 1 unsent packet if socket is busy#6563
Merged
thomaseizinger merged 4 commits intomainfrom Sep 4, 2024
Merged
refactor(connlib): only buffer 1 unsent packet if socket is busy#6563thomaseizinger merged 4 commits intomainfrom
thomaseizinger merged 4 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
9a84480 to
7124dc1
Compare
jamilbk
pushed a commit
that referenced
this pull request
Sep 4, 2024
Currently, we buffer UDP packets whenever the socket is busy and try to flush them out at a later point. This requires allocations and is tricky to get right. In order to solve both of these problems, we refactor `snownet` to return us an `EncryptedPacket` instead of a `Transmit`. An `EncryptedPacket` is an indirection-abstraction that can be turned into a `Transmit` given an `EncryptBuffer`. This combination of types allows us to hold on to the `EncryptedPacket` (which does not contain any references itself) in the `io` component whilst we are waiting for the socket to be ready to send again. This means we will immediately suspend the event loop in case the socket is no longer ready for sending and resend the datagram in the `EncryptBuffer` once we get re-polled.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Currently, we buffer UDP packets whenever the socket is busy and try to flush them out at a later point. This requires allocations and is tricky to get right.
In order to solve both of these problems, we refactor
snownetto return us anEncryptedPacketinstead of aTransmit. AnEncryptedPacketis an indirection-abstraction that can be turned into aTransmitgiven anEncryptBuffer. This combination of types allows us to hold on to theEncryptedPacket(which does not contain any references itself) in theiocomponent whilst we are waiting for the socket to be ready to send again.This means we will immediately suspend the event loop in case the socket is no longer ready for sending and resend the datagram in the
EncryptBufferonce we get re-polled.