Without this patch conhost would attempt to process non-existent input, spewing stdout with various cursor moves and incorrectly returning the ReadConsole call early. Fix that by only attempting input processing if there are actually input records to be processed and properly returning STATUS_PENDING if the input processing is not yet complete.
Signed-off-by: Keno Fischer keno@juliacomputing.com --- programs/conhost/conhost.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c index 78f6e345170..64a77e52b43 100644 --- a/programs/conhost/conhost.c +++ b/programs/conhost/conhost.c @@ -1385,7 +1385,14 @@ static NTSTATUS read_console( struct console *console, unsigned int ioctl, size_ if (edit_line_grow( console, 1 )) console->edit_line.buf[0] = 0;
console->pending_read = out_size; - return process_console_input( console ); + + /* If there are any pending input records, cook them now. */ + if (console->record_count) + { + process_console_input( console ); + } + + return console->edit_line.status; }
/* add input events to a console input queue */
Hi Keno,
On 12/29/21 16:10, Keno Fischer wrote:
diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c index 78f6e345170..64a77e52b43 100644 --- a/programs/conhost/conhost.c +++ b/programs/conhost/conhost.c @@ -1385,7 +1385,14 @@ static NTSTATUS read_console( struct console *console, unsigned int ioctl, size_ if (edit_line_grow( console, 1 )) console->edit_line.buf[0] = 0;
console->pending_read = out_size;
- return process_console_input( console );
- /* If there are any pending input records, cook them now. */
- if (console->record_count)
- {
process_console_input( console );
- }
- return console->edit_line.status;
process_console_input() generally handles 0 record_count, what's exactly wrong there? Does the attached patch help?
Thanks,
Jacek
Hi Jacek,
On Wed, Dec 29, 2021 at 11:13 AM Jacek Caban jacek@codeweavers.com wrote:
process_console_input() generally handles 0 record_count, what's exactly wrong there? Does the attached patch help?
Yes, that patch would have a similar effect, except that I believe it would still return STATUS_SUCCESS rather than STATUS_PENDING. Unfortunately, I can't reproduce the exact issue I saw that caused this right now (I upgraded my local tree from rc1 to master yesterday, so that's likely the difference), but basically what I was seeing is that conhost spammed about 100 or so unnecessary cursor moves from inside `update_read_output`. That caused lots of blinking in the terminal. This patch fixed that for me.
Keno