Thanks to visit codestin.com
Credit goes to Github.com

Skip to content
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
sam-mccall:poll
Open

Simplify IO loop by buffering output, and select->poll#21
sam-mccall wants to merge 2 commits intogoogle:masterfrom
sam-mccall:poll

Conversation

@sam-mccall
Copy link
Contributor

@sam-mccall sam-mccall commented Oct 6, 2017

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 ttyread is 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)

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.
@sam-mccall
Copy link
Contributor Author

Wow, I just realized this is totally broken, ttysend(AB); ttysend(CD) coalesce into CDAB.
I'll fix it, but looking forward nervously to being in a better shape to write tests.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant