-
Notifications
You must be signed in to change notification settings - Fork 126
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
Throttle reads from standard input if output queue is full #74
Comments
What's the way to reproduce that issue of discarding chars? On TX terminal, were I paste the text data into:
|
Practically, only by setting a limit on the queue size (i.e. But DO NOT try to fix it, as this (dropping input chars) is probably the CORRECT behavior... That's why I marked this as "needs more thought". I opened the issue more as a note to self... |
At least, it is the correct behavior, when the input is from a terminal, that is... Plus, the fact that the output queue can grow as much as needed, makes the problem very hard to practically matter (unless you are using really huge files as input)... |
If picocom stops reading stdin to apply backpressure because its output queue is full, then C-a sequences would be unavailable, making user recovery hard. e.g. when the back tty device is malfunctioning and not draining, stuck cts, etc. Idea: If you really want to apply backpressure to stdin (by entering a state where you just don't read stdin), maybe enable a restricted ISIG termios mode on stdin, with the escape char C-a mapped to VINTR/SIGINT. Then some (complicated) logic to "wake up" a single stdin read on the signal. You'd accompany this with a command to dump the output queue, eg C-a C-o. |
When standard input is a terminal, there is no real reason for picocom to throttle its reads from it, in order to apply back-pressure. In a huge copy-paste, for example, (the only case I can think of where it would be practically applicable), it normally shouldn't matter at which end of the pipe you buffer the data (yes, conceivably the two ends could be on different hosts, but let's not get into that). After all, copy-paste is not expected to be a fully reliable transfer method for huge amounts of data. Not being able to "see" the escape / command characters in time (as you say) is another very good reason not to do so. So when stdin is a tty you should always read from it, and either buffer or discard what you read. Anything else (like the complicated signaling dance you describe 😆 ) lies on the path to insanity! EDIT If you ever get it to work reliably, after great effort, it will be at a big loss of maintainability and possibly portability, and for very little practical gain. When reading from a file,though, or if you have the escape character disabled, throttling your reads could be useful and practicable---and that's the real reason for this note / issue. It hasn't come up, in practice, especially since I've put in the resize-able output buffer, but conceivably it could be useful. |
I think the auto-sizing Another crazy idea/workaround while I'm here, inspired by the vi trick of |
Yes the grow-able output buffer is good enough, at least for the present |
Currently picocom never stops / delays reading from the standard input (terminal) if data are available. If the output queue is full, data read are discarded. Maybe it would be better if we could delay reading from stdin until the output queue partially drains. This could be useful particularly when the standard input is not a terminal and, possibly, it should be done only in this case...
The text was updated successfully, but these errors were encountered: