From 9050b58f0769fca75c4cebed7be3cce51989814e Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 30 Oct 2018 16:08:48 +0100 Subject: [PATCH] ntdll: Correctly return result of blocking NtFlushBuffersFile. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/kernel32/tests/pipe.c | 2 +- dlls/ntdll/file.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/tests/pipe.c b/dlls/kernel32/tests/pipe.c index 7f77df1d0b3..05e23bfb6a4 100644 --- a/dlls/kernel32/tests/pipe.c +++ b/dlls/kernel32/tests/pipe.c @@ -2852,7 +2852,7 @@ static DWORD CALLBACK flush_proc(HANDLE pipe) if (expected_flush_error == ERROR_SUCCESS) ok(res, "FlushFileBuffers failed: %u\n", GetLastError()); else - todo_wine ok(!res && GetLastError() == expected_flush_error, "FlushFileBuffers failed: %u\n", GetLastError()); + ok(!res && GetLastError() == expected_flush_error, "FlushFileBuffers failed: %u\n", GetLastError()); return 0; } diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c index d3b3698b1ab..870ad06b534 100644 --- a/dlls/ntdll/file.c +++ b/dlls/ntdll/file.c @@ -3317,9 +3317,17 @@ NTSTATUS WINAPI NtFlushBuffersFile( HANDLE hFile, IO_STATUS_BLOCK *io ) } else if (ret != STATUS_ACCESS_DENIED) { + struct async_irp *async; + + if (!(async = (struct async_irp *)alloc_fileio( sizeof(*async), irp_completion, hFile ))) + return STATUS_NO_MEMORY; + async->event = NULL; + async->buffer = NULL; + async->size = 0; + SERVER_START_REQ( flush ) { - req->async = server_async( hFile, NULL, NULL, NULL, NULL, io ); + req->async = server_async( hFile, &async->io, NULL, NULL, NULL, io ); ret = wine_server_call( req ); wait_handle = wine_server_ptr_handle( reply->event ); if (wait_handle && ret != STATUS_PENDING) @@ -3330,6 +3338,8 @@ NTSTATUS WINAPI NtFlushBuffersFile( HANDLE hFile, IO_STATUS_BLOCK *io ) } SERVER_END_REQ; + if (ret != STATUS_PENDING) RtlFreeHeap( GetProcessHeap(), 0, async ); + if (wait_handle) { NtWaitForSingleObject( wait_handle, FALSE, NULL );