[PATCH 4/5] [Kernel32, Server]: fixed a couple of bugs when reading bare console input with overlapped operations
Eric Pouech
eric.pouech at orange.fr
Sun Nov 28 15:10:58 CST 2010
A+
---
dlls/kernel32/console.c | 6 +++++-
server/console.c | 3 +--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index f3d029d..f4ec5c3 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -1117,6 +1117,7 @@ static enum read_console_input_return bare_console_fetch_input(HANDLE handle, DW
OVERLAPPED ov;
enum read_console_input_return ret;
char ch;
+ DWORD bytesread;
/* get the real handle to the console object */
handle = wine_server_ptr_handle(console_handle_unmap(handle));
@@ -1127,13 +1128,15 @@ static enum read_console_input_return bare_console_fetch_input(HANDLE handle, DW
if (ReadFile(handle, &ch, 1, NULL, &ov) ||
(GetLastError() == ERROR_IO_PENDING &&
WaitForSingleObject(ov.hEvent, timeout) == WAIT_OBJECT_0 &&
- GetOverlappedResult(handle, &ov, NULL, FALSE)))
+ GetOverlappedResult(handle, &ov, &bytesread, FALSE) &&
+ bytesread > 0))
{
ret = handle_simple_char(handle, ch) ? rci_gotone : rci_error;
}
else
{
WARN("Failed read %x\n", GetLastError());
+ CancelIo(handle);
ret = rci_error;
}
CloseHandle(ov.hEvent);
@@ -3011,6 +3014,7 @@ BOOL CONSOLE_Init(RTL_USER_PROCESS_PARAMETERS *params)
/* reply->event shouldn't be created by server */
}
SERVER_END_REQ;
+ fcntl( 0, F_SETFL, O_NONBLOCK );
if (!params->hStdInput)
params->hStdInput = conin;
diff --git a/server/console.c b/server/console.c
index b49aed7..0010630 100644
--- a/server/console.c
+++ b/server/console.c
@@ -327,8 +327,7 @@ static struct object *create_console_input( struct thread* renderer, int fd )
}
if (fd != -1) /* bare console */
{
- if (!(console_input->fd = create_anonymous_fd( &console_fd_ops, fd, &console_input->obj,
- FILE_SYNCHRONOUS_IO_NONALERT )))
+ if (!(console_input->fd = create_anonymous_fd( &console_fd_ops, fd, &console_input->obj, 0 )))
{
release_object( console_input );
return NULL;
More information about the wine-patches
mailing list