From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/ntdll/unix/file.c | 27 ++++++++++++++++----------- dlls/ntdll/unix/socket.c | 28 ++++++++-------------------- dlls/ntdll/unix/unix_private.h | 3 ++- 3 files changed, 26 insertions(+), 32 deletions(-)
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c index c128e8aa369..c9a0b023d23 100644 --- a/dlls/ntdll/unix/file.c +++ b/dlls/ntdll/unix/file.c @@ -5470,7 +5470,7 @@ static unsigned int register_async_file_read( HANDLE handle, HANDLE event, return status; }
-void add_completion( HANDLE handle, ULONG_PTR value, NTSTATUS status, ULONG info, BOOL async ) +static void add_completion( HANDLE handle, ULONG_PTR value, NTSTATUS status, ULONG info, BOOL async ) { SERVER_START_REQ( add_fd_completion ) { @@ -5484,6 +5484,20 @@ void add_completion( HANDLE handle, ULONG_PTR value, NTSTATUS status, ULONG info SERVER_END_REQ; }
+/* complete async file I/O, signaling completion in all ways necessary */ +void file_complete_async( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user, + IO_STATUS_BLOCK *io, NTSTATUS status, ULONG_PTR information ) +{ + ULONG_PTR iosb_ptr = iosb_client_ptr(io); + + io->Status = status; + io->Information = information; + if (event) NtSetEvent( event, NULL ); + if (apc) NtQueueApcThread( GetCurrentThread(), (PNTAPCFUNC)apc, (ULONG_PTR)apc_user, iosb_ptr, 0 ); + else if (apc_user) add_completion( handle, (ULONG_PTR)apc_user, status, information, FALSE ); +} + + static unsigned int set_pending_write( HANDLE device ) { unsigned int status; @@ -6019,10 +6033,7 @@ NTSTATUS WINAPI NtWriteFileGather( HANDLE file, HANDLE event, PIO_APC_ROUTINE ap int result, unix_handle, needs_close; unsigned int options, status; UINT pos = 0, total = 0; - client_ptr_t iosb_ptr = iosb_client_ptr(io); enum server_fd_type type; - ULONG_PTR cvalue = apc ? 0 : (ULONG_PTR)apc_user; - BOOL send_completion = FALSE;
TRACE( "(%p,%p,%p,%p,%p,%p,0x%08x,%p,%p),partial stub!\n", file, event, apc, apc_user, io, segments, (int)length, offset, key ); @@ -6074,24 +6085,18 @@ NTSTATUS WINAPI NtWriteFileGather( HANDLE file, HANDLE event, PIO_APC_ROUTINE ap } }
- send_completion = cvalue != 0; - done: if (needs_close) close( unix_handle ); if (status == STATUS_SUCCESS) { - io->Status = status; - io->Information = total; + file_complete_async( file, event, apc, apc_user, io, status, total ); TRACE("= SUCCESS (%u)\n", total); - if (event) NtSetEvent( event, NULL ); - if (apc) NtQueueApcThread( GetCurrentThread(), (PNTAPCFUNC)apc, (ULONG_PTR)apc_user, iosb_ptr, 0 ); } else { TRACE("= 0x%08x\n", status); if (status != STATUS_PENDING && event) NtResetEvent( event, NULL ); } - if (send_completion) add_completion( file, cvalue, status, total, FALSE ); return status; }
diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c index 123e318058b..587faf51ccf 100644 --- a/dlls/ntdll/unix/socket.c +++ b/dlls/ntdll/unix/socket.c @@ -1425,18 +1425,6 @@ static NTSTATUS sock_transmit( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, return status; }
-static void complete_async( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user, - IO_STATUS_BLOCK *io, NTSTATUS status, ULONG_PTR information ) -{ - ULONG_PTR iosb_ptr = iosb_client_ptr(io); - - io->Status = status; - io->Information = information; - if (event) NtSetEvent( event, NULL ); - if (apc) NtQueueApcThread( GetCurrentThread(), (PNTAPCFUNC)apc, (ULONG_PTR)apc_user, iosb_ptr, 0 ); - else if (apc_user) add_completion( handle, (ULONG_PTR)apc_user, status, information, FALSE ); -} -
static NTSTATUS do_getsockopt( HANDLE handle, IO_STATUS_BLOCK *io, int level, int option, void *out_buffer, ULONG out_size ) @@ -1563,7 +1551,7 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc } SERVER_END_REQ;
- complete_async( handle, event, apc, apc_user, io, status, 0 ); + file_complete_async( handle, event, apc, apc_user, io, status, 0 ); return status; }
@@ -1710,7 +1698,7 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc return STATUS_BUFFER_TOO_SMALL;
status = *(NTSTATUS *)in_buffer; - complete_async( handle, event, apc, apc_user, io, status, 0 ); + file_complete_async( handle, event, apc, apc_user, io, status, 0 ); return status; }
@@ -1736,7 +1724,7 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc { *(int *)out_buffer = 0; if (needs_close) close( fd ); - complete_async( handle, event, apc, apc_user, io, STATUS_SUCCESS, 0 ); + file_complete_async( handle, event, apc, apc_user, io, STATUS_SUCCESS, 0 ); return STATUS_SUCCESS; } } @@ -1749,7 +1737,7 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc } *(int *)out_buffer = value; if (needs_close) close( fd ); - complete_async( handle, event, apc, apc_user, io, STATUS_SUCCESS, 0 ); + file_complete_async( handle, event, apc, apc_user, io, STATUS_SUCCESS, 0 ); return STATUS_SUCCESS; }
@@ -1788,7 +1776,7 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc *(int *)out_buffer = !value; } if (needs_close) close( fd ); - complete_async( handle, event, apc, apc_user, io, STATUS_SUCCESS, 0 ); + file_complete_async( handle, event, apc, apc_user, io, STATUS_SUCCESS, 0 ); return STATUS_SUCCESS; }
@@ -1815,7 +1803,7 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc if (out_size < ret_size) { freeifaddrs( ifaddrs ); - complete_async( handle, event, apc, apc_user, io, STATUS_BUFFER_TOO_SMALL, 0 ); + file_complete_async( handle, event, apc, apc_user, io, STATUS_BUFFER_TOO_SMALL, 0 ); return STATUS_PENDING; }
@@ -1865,7 +1853,7 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc }
freeifaddrs( ifaddrs ); - complete_async( handle, event, apc, apc_user, io, STATUS_SUCCESS, ret_size ); + file_complete_async( handle, event, apc, apc_user, io, STATUS_SUCCESS, ret_size ); return STATUS_PENDING; #else FIXME( "Interface list queries are currently not supported on this platform.\n" ); @@ -1920,7 +1908,7 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc }
if (needs_close) close( fd ); - complete_async( handle, event, apc, apc_user, io, STATUS_SUCCESS, 0 ); + file_complete_async( handle, event, apc, apc_user, io, STATUS_SUCCESS, 0 ); return STATUS_SUCCESS; }
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index b278ab8df84..fcb3de83a29 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -342,7 +342,8 @@ extern NTSTATUS open_unix_file( HANDLE *handle, const char *unix_name, ACCESS_MA extern NTSTATUS get_device_info( int fd, struct _FILE_FS_DEVICE_INFORMATION *info ); extern void init_files(void); extern void init_cpu_info(void); -extern void add_completion( HANDLE handle, ULONG_PTR value, NTSTATUS status, ULONG info, BOOL async ); +extern void file_complete_async( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user, + IO_STATUS_BLOCK *io, NTSTATUS status, ULONG_PTR information ); extern void set_async_direct_result( HANDLE *async_handle, NTSTATUS status, ULONG_PTR information, BOOL mark_pending );
extern NTSTATUS unixcall_wine_dbg_write( void *args );