term: asynchronous writes to slave

Make ptmx non-blocking. Then, when writing data to the slave would
have blocked, use the FDM to asynchronously write the remaining data.

This is done by enabling EPOLLOUT on ptmx, and enqueueing all outgoing
data. The FDM handler will go through the enqueued data, and once all
of it has been written, we turn off EPOLLOUT again (thus switching
back to synchronous writes)
This commit is contained in:
Daniel Eklöf 2019-11-03 01:03:52 +01:00
parent 777d851282
commit f00c5fdac6
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 106 additions and 21 deletions

View file

@ -145,6 +145,12 @@ enum mouse_reporting {
enum cursor_style { CURSOR_BLOCK, CURSOR_UNDERLINE, CURSOR_BAR };
struct ptmx_buffer {
void *data;
size_t len;
size_t idx;
};
struct terminal {
struct fdm *fdm;
@ -152,6 +158,8 @@ struct terminal {
int ptmx;
bool quit;
tll(struct ptmx_buffer) ptmx_buffer;
enum cursor_keys cursor_keys_mode;
enum keypad_keys keypad_keys_mode;
bool reverse;