From fe1c0176c13af6b61ee59a2bc471af5c98e4993b Mon Sep 17 00:00:00 2001 From: Marc Hoersken Date: Sun, 20 Apr 2014 18:26:24 +0200 Subject: [PATCH] sockfilt.c: ignore non-key-events and continue waiting for input --- tests/server/sockfilt.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c index a15baeb7f..7328ca495 100644 --- a/tests/server/sockfilt.c +++ b/tests/server/sockfilt.c @@ -515,15 +515,24 @@ static void lograw(unsigned char *buffer, ssize_t len) */ static DWORD WINAPI select_ws_stdin_wait_thread(LPVOID lpParameter) { + INPUT_RECORD inputrecord; HANDLE handle; - DWORD mode; + DWORD length; handle = (HANDLE) lpParameter; - if(GetConsoleMode(handle, &mode)) - WaitForSingleObjectEx(handle, INFINITE, FALSE); + if(GetConsoleMode(handle, &length)) { + while(WaitForSingleObjectEx(handle, INFINITE, FALSE) == WAIT_OBJECT_0) { + if(PeekConsoleInput(handle, &inputrecord, 1, &length)) { + if(length == 1 && inputrecord.EventType != KEY_EVENT) + ReadConsoleInput(handle, &inputrecord, 1, &length); + else + break; + } + } + } else - ReadFile(handle, NULL, 0, &mode, NULL); + ReadFile(handle, NULL, 0, &length, NULL); return 0; }