Module: wine Branch: master Commit: c09a903bfac4153b3061c0da95de58387a278cb7 URL: https://source.winehq.org/git/wine.git/?a=commit;h=c09a903bfac4153b3061c0da9...
Author: Jacek Caban jacek@codeweavers.com Date: Thu May 23 19:35:51 2019 +0200
ntdll: Introduce wait_async helper.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ntdll/file.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c index 3dafdcf..1f93c52 100644 --- a/dlls/ntdll/file.c +++ b/dlls/ntdll/file.c @@ -425,6 +425,12 @@ static async_data_t server_async( HANDLE handle, struct async_fileio *user, HAND return async; }
+static NTSTATUS wait_async( HANDLE handle, BOOL alertable, IO_STATUS_BLOCK *io ) +{ + NtWaitForSingleObject( handle, alertable, NULL ); + return io->u.Status; +} + /* callback for irp async I/O completion */ static NTSTATUS irp_completion( void *user, IO_STATUS_BLOCK *io, NTSTATUS status ) { @@ -588,12 +594,7 @@ static NTSTATUS server_read_file( HANDLE handle, HANDLE event, PIO_APC_ROUTINE a
if (status != STATUS_PENDING) RtlFreeHeap( GetProcessHeap(), 0, async );
- if (wait_handle) - { - NtWaitForSingleObject( wait_handle, (options & FILE_SYNCHRONOUS_IO_ALERT), NULL ); - status = io->u.Status; - } - + if (wait_handle) status = wait_async( wait_handle, (options & FILE_SYNCHRONOUS_IO_ALERT), io ); return status; }
@@ -631,12 +632,7 @@ static NTSTATUS server_write_file( HANDLE handle, HANDLE event, PIO_APC_ROUTINE
if (status != STATUS_PENDING) RtlFreeHeap( GetProcessHeap(), 0, async );
- if (wait_handle) - { - NtWaitForSingleObject( wait_handle, (options & FILE_SYNCHRONOUS_IO_ALERT), NULL ); - status = io->u.Status; - } - + if (wait_handle) status = wait_async( wait_handle, (options & FILE_SYNCHRONOUS_IO_ALERT), io ); return status; }
@@ -1550,12 +1546,7 @@ static NTSTATUS server_ioctl_file( HANDLE handle, HANDLE event,
if (status != STATUS_PENDING) RtlFreeHeap( GetProcessHeap(), 0, async );
- if (wait_handle) - { - NtWaitForSingleObject( wait_handle, (options & FILE_SYNCHRONOUS_IO_ALERT), NULL ); - status = io->u.Status; - } - + if (wait_handle) status = wait_async( wait_handle, (options & FILE_SYNCHRONOUS_IO_ALERT), io ); return status; }
@@ -3350,11 +3341,7 @@ NTSTATUS WINAPI NtFlushBuffersFile( HANDLE hFile, IO_STATUS_BLOCK *io )
if (ret != STATUS_PENDING) RtlFreeHeap( GetProcessHeap(), 0, async );
- if (wait_handle) - { - NtWaitForSingleObject( wait_handle, FALSE, NULL ); - ret = io->u.Status; - } + if (wait_handle) ret = wait_async( wait_handle, FALSE, io ); }
if (needs_close) close( fd );