This repository was archived by the owner on Jun 1, 2022. It is now read-only.
Simplify IO loop by buffering output, and select->poll#21
Open
sam-mccall wants to merge 2 commits intogoogle:masterfrom
Open
Simplify IO loop by buffering output, and select->poll#21sam-mccall wants to merge 2 commits intogoogle:masterfrom
sam-mccall wants to merge 2 commits intogoogle:masterfrom
Conversation
The existing code has two event loops: one with terminal reads and writes, and one with terminal and X reads. Instead, make the terminal expose its write buffer and make a single event loop handle everything. While here, switch from select to the more elegant poll API.
Contributor
Author
|
Wow, I just realized this is totally broken, ttysend(AB); ttysend(CD) coalesce into CDAB. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
The existing code has two event loops: one with terminal reads and writes, and one with terminal and X reads.
Instead, make the terminal expose its write buffer and make a single event loop handle everything. While here, switch from select to the more elegant poll API.
Note that this means if we're writing faster than the pty can consume data, the buffer will grow without bound. But we no longer support serial lines, and ptys can do tens of MB/sec, so I think this will only happen when pasting huge text (which we put in memory anyway).
This naive buffering seems more likely to be correct than the current code where
ttyreadis reentrant, e.g.ttyread->tputc->csihandle->ttywrite->ttyread. I suspect bugs are lurking there.(The timeout logic could certainly use more cleanup. Honestly I wonder whether blinking text is worth the complexity, this could be so simple)