ntdll: Factor filling the IOSB into set_async_direct_result().

This commit is contained in:
Elizabeth Figura 2024-05-28 19:39:23 -05:00 committed by Alexandre Julliard
parent 62df7633e5
commit 5493ff11fa
4 changed files with 15 additions and 29 deletions

View file

@ -1202,15 +1202,13 @@ static NTSTATUS wait_on( HANDLE handle, int fd, HANDLE event, PIO_APC_ROUTINE ap
if (events) if (events)
{ {
status = STATUS_SUCCESS; status = STATUS_SUCCESS;
io->Status = STATUS_SUCCESS;
io->Information = sizeof(events);
*out_buffer = events; *out_buffer = events;
set_async_direct_result( &wait_handle, STATUS_SUCCESS, sizeof(events), FALSE ); set_async_direct_result( &wait_handle, io, STATUS_SUCCESS, sizeof(events), FALSE );
} }
else else
{ {
status = STATUS_PENDING; status = STATUS_PENDING;
set_async_direct_result( &wait_handle, STATUS_PENDING, 0, TRUE ); set_async_direct_result( &wait_handle, io, STATUS_PENDING, 0, TRUE );
} }
} }

View file

@ -875,12 +875,7 @@ static NTSTATUS sock_recv( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, voi
status = try_recv( fd, async, &information ); status = try_recv( fd, async, &information );
if (status == STATUS_DEVICE_NOT_READY && (force_async || !nonblocking)) if (status == STATUS_DEVICE_NOT_READY && (force_async || !nonblocking))
status = STATUS_PENDING; status = STATUS_PENDING;
if (!NT_ERROR(status) && status != STATUS_PENDING) set_async_direct_result( &wait_handle, io, status, information, FALSE );
{
io->Status = status;
io->Information = information;
}
set_async_direct_result( &wait_handle, status, information, FALSE );
} }
if (status != STATUS_PENDING) if (status != STATUS_PENDING)
@ -1125,8 +1120,6 @@ static NTSTATUS sock_send( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, voi
if (status == STATUS_ALERTED) if (status == STATUS_ALERTED)
{ {
ULONG_PTR information;
status = try_send( fd, async ); status = try_send( fd, async );
if (status == STATUS_DEVICE_NOT_READY && (force_async || !nonblocking)) if (status == STATUS_DEVICE_NOT_READY && (force_async || !nonblocking))
status = STATUS_PENDING; status = STATUS_PENDING;
@ -1138,14 +1131,7 @@ static NTSTATUS sock_send( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, voi
if (status == STATUS_DEVICE_NOT_READY && async->sent_len) if (status == STATUS_DEVICE_NOT_READY && async->sent_len)
status = STATUS_SUCCESS; status = STATUS_SUCCESS;
information = async->sent_len; set_async_direct_result( &wait_handle, io, status, async->sent_len, FALSE );
if (!NT_ERROR(status) && status != STATUS_PENDING)
{
io->Status = status;
io->Information = information;
}
set_async_direct_result( &wait_handle, status, information, FALSE );
} }
if (status != STATUS_PENDING) if (status != STATUS_PENDING)
@ -1401,13 +1387,7 @@ static NTSTATUS sock_transmit( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc,
status = STATUS_PENDING; status = STATUS_PENDING;
information = async->head_cursor + async->file_cursor + async->tail_cursor; information = async->head_cursor + async->file_cursor + async->tail_cursor;
if (!NT_ERROR(status) && status != STATUS_PENDING) set_async_direct_result( &wait_handle, io, status, information, TRUE );
{
io->Status = status;
io->Information = information;
}
set_async_direct_result( &wait_handle, status, information, TRUE );
} }
if (status != STATUS_PENDING) if (status != STATUS_PENDING)

View file

@ -2669,13 +2669,20 @@ NTSTATUS WINAPI NtWaitForAlertByThreadId( const void *address, const LARGE_INTEG
/* Notify direct completion of async and close the wait handle if it is no longer needed. /* Notify direct completion of async and close the wait handle if it is no longer needed.
*/ */
void set_async_direct_result( HANDLE *async_handle, NTSTATUS status, ULONG_PTR information, BOOL mark_pending ) void set_async_direct_result( HANDLE *async_handle, IO_STATUS_BLOCK *io,
NTSTATUS status, ULONG_PTR information, BOOL mark_pending )
{ {
unsigned int ret; unsigned int ret;
/* if we got STATUS_ALERTED, we must have a valid async handle */ /* if we got STATUS_ALERTED, we must have a valid async handle */
assert( *async_handle ); assert( *async_handle );
if (!NT_ERROR(status) && status != STATUS_PENDING)
{
io->Status = status;
io->Information = information;
}
SERVER_START_REQ( set_async_direct_result ) SERVER_START_REQ( set_async_direct_result )
{ {
req->handle = wine_server_obj_handle( *async_handle ); req->handle = wine_server_obj_handle( *async_handle );

View file

@ -344,7 +344,8 @@ extern void init_files(void);
extern void init_cpu_info(void); extern void init_cpu_info(void);
extern void file_complete_async( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user, 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 ); 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 void set_async_direct_result( HANDLE *async_handle, IO_STATUS_BLOCK *io,
NTSTATUS status, ULONG_PTR information, BOOL mark_pending );
extern NTSTATUS unixcall_wine_dbg_write( void *args ); extern NTSTATUS unixcall_wine_dbg_write( void *args );
extern NTSTATUS unixcall_wine_server_call( void *args ); extern NTSTATUS unixcall_wine_server_call( void *args );