refactor(connlib): don't re-implement waker for TUN thread#7944
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
jamilbk
approved these changes
Jan 29, 2025
Member
There was a problem hiding this comment.
Anything to remove complexity LGTM. I think the hunch about not reading network packets because we can't write to the TUN device makes sense.
I guess the key question is why can't we write to the TUN device. If it's due to an OS error or something outside of our control, I guess we'd have to consider adding logic that detects a "stuck" channel and rolls over the file descriptor?
That wouldn't be an option on Apple though...
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.
Within
connlib- on UNIX platforms - we have dedicated threads that read from and write to the TUN device. These threads are connected withconnlib's main thread via bounded channels: one in each direction. When these channels are full,connlib's main thread will suspend and not read any network packets from the sockets in order to maintain back-pressure. Reading more packets from the socket would mean most likely sending more packets out the TUN device.When debugging #7763, it became apparent that something must be wrong with these threads and that somehow, we either consider them as full or aren't emptying them and as a result, we don't read any network packets from our sockets.
To maintain back-pressure here, we currently use our own
AtomicWakerconstruct that is shared with the TUN thread(s). This is unnecessary. We can also directly convert theflume::Senderinto aflume::async::SendSinkand therefore directly access apollinterface.