From 79945419ebcfacf05d3c152c8ca070ca8f75817f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 3 Nov 2019 12:13:51 +0100 Subject: [PATCH] terminal: comments and cleanup --- terminal.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/terminal.c b/terminal.c index a34df466..8fabe81f 100644 --- a/terminal.c +++ b/terminal.c @@ -60,6 +60,11 @@ term_to_slave(struct terminal *term, const void *_data, size_t len) goto enqueue_data; } + /* + * Try a synchronous write first. If we fail to write everything, + * switch to asynchronous. + */ + switch (to_slave(term, _data, len, &(size_t){0})) { case PTMX_WRITE_REMAIN: if (!fdm_event_add(term->fdm, term->ptmx, EPOLLOUT)) @@ -70,6 +75,10 @@ term_to_slave(struct terminal *term, const void *_data, size_t len) case PTMX_WRITE_ERR: return false; } + /* Shouldn't get here */ + assert(false); + return false; + enqueue_data: { void *copy = malloc(len);