server: Pass the async result size as part of apc_call_t.

Only really an optimization (plus it makes the code a little conceptually simpler).

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-09-14 01:02:43 -05:00 committed by Alexandre Julliard
parent 554a4a111a
commit 1ee382c706
8 changed files with 15 additions and 27 deletions

View File

@ -4690,7 +4690,6 @@ static NTSTATUS irp_completion( void *user, ULONG_PTR *info, NTSTATUS status )
req->user_arg = wine_server_client_ptr( async );
wine_server_set_reply( req, async->buffer, async->size );
status = virtual_locked_server_call( req );
*info = reply->size;
}
SERVER_END_REQ;
}

View File

@ -378,7 +378,7 @@ static void invoke_system_apc( const apc_call_t *call, apc_result_t *result, BOO
case APC_ASYNC_IO:
{
struct async_fileio *user = wine_server_get_ptr( call->async_io.user );
ULONG_PTR info = 0;
ULONG_PTR info = call->async_io.result;
result->type = call->type;
result->async_io.status = user->callback( user, &info, call->async_io.status );

View File

@ -565,7 +565,6 @@ static NTSTATUS try_recv( int fd, struct async_recv_ioctl *async, ULONG_PTR *siz
static NTSTATUS async_recv_proc( void *user, ULONG_PTR *info, NTSTATUS status )
{
struct async_recv_ioctl *async = user;
ULONG_PTR information = 0;
int fd, needs_close;
TRACE( "%#x\n", status );
@ -575,19 +574,15 @@ static NTSTATUS async_recv_proc( void *user, ULONG_PTR *info, NTSTATUS status )
if ((status = server_get_unix_fd( async->io.handle, 0, &fd, &needs_close, NULL, NULL )))
return status;
status = try_recv( fd, async, &information );
TRACE( "got status %#x, %#lx bytes read\n", status, information );
status = try_recv( fd, async, info );
TRACE( "got status %#x, %#lx bytes read\n", status, *info );
if (status == STATUS_DEVICE_NOT_READY)
status = STATUS_PENDING;
if (needs_close) close( fd );
}
if (status != STATUS_PENDING)
{
*info = information;
release_fileio( &async->io );
}
if (status != STATUS_PENDING) release_fileio( &async->io );
return status;
}
@ -704,7 +699,6 @@ static ULONG_PTR fill_poll_output( struct async_poll_ioctl *async, NTSTATUS stat
static NTSTATUS async_poll_proc( void *user, ULONG_PTR *info, NTSTATUS status )
{
struct async_poll_ioctl *async = user;
ULONG_PTR information = 0;
if (status == STATUS_ALERTED)
{
@ -716,12 +710,11 @@ static NTSTATUS async_poll_proc( void *user, ULONG_PTR *info, NTSTATUS status )
}
SERVER_END_REQ;
information = fill_poll_output( async, status );
*info = fill_poll_output( async, status );
}
if (status != STATUS_PENDING)
{
*info = information;
free( async->input );
release_fileio( &async->io );
}

View File

@ -492,6 +492,7 @@ typedef union
unsigned int status;
client_ptr_t user;
client_ptr_t sb;
data_size_t result;
} async_io;
struct
{
@ -2896,9 +2897,7 @@ struct get_async_result_request
struct get_async_result_reply
{
struct reply_header __header;
data_size_t size;
/* VARARG(out_data,bytes); */
char __pad_12[4];
};
@ -6257,7 +6256,7 @@ union generic_reply
/* ### protocol_version begin ### */
#define SERVER_PROTOCOL_VERSION 729
#define SERVER_PROTOCOL_VERSION 730
/* ### protocol_version end ### */

View File

@ -185,11 +185,11 @@ void async_terminate( struct async *async, unsigned int status )
data.type = APC_ASYNC_IO;
data.async_io.user = async->data.user;
data.async_io.sb = async->data.iosb;
data.async_io.result = iosb ? iosb->result : 0;
/* if the result is nonzero or there is output data, the client needs to
* make an extra request to retrieve them; use STATUS_ALERTED to signal
* this case */
if (iosb && (iosb->result || iosb->out_data))
/* if there is output data, the client needs to make an extra request
* to retrieve it; use STATUS_ALERTED to signal this case */
if (iosb && iosb->out_data)
data.async_io.status = STATUS_ALERTED;
else
data.async_io.status = status;
@ -719,6 +719,5 @@ DECL_HANDLER(get_async_result)
iosb->out_data = NULL;
}
}
reply->size = iosb->result;
set_error( iosb->status );
}

View File

@ -508,6 +508,7 @@ typedef union
unsigned int status; /* I/O status */
client_ptr_t user; /* user pointer */
client_ptr_t sb; /* status block */
data_size_t result; /* result size */
} async_io;
struct
{
@ -2156,7 +2157,6 @@ enum message_type
@REQ(get_async_result)
client_ptr_t user_arg; /* user arg used to identify async */
@REPLY
data_size_t size; /* result size (input or output depending on the operation) */
VARARG(out_data,bytes); /* iosb output data */
@END

View File

@ -1396,8 +1396,7 @@ C_ASSERT( FIELD_OFFSET(struct cancel_async_request, only_thread) == 24 );
C_ASSERT( sizeof(struct cancel_async_request) == 32 );
C_ASSERT( FIELD_OFFSET(struct get_async_result_request, user_arg) == 16 );
C_ASSERT( sizeof(struct get_async_result_request) == 24 );
C_ASSERT( FIELD_OFFSET(struct get_async_result_reply, size) == 8 );
C_ASSERT( sizeof(struct get_async_result_reply) == 16 );
C_ASSERT( sizeof(struct get_async_result_reply) == 8 );
C_ASSERT( FIELD_OFFSET(struct read_request, async) == 16 );
C_ASSERT( FIELD_OFFSET(struct read_request, pos) == 56 );
C_ASSERT( sizeof(struct read_request) == 64 );

View File

@ -181,7 +181,7 @@ static void dump_apc_call( const char *prefix, const apc_call_t *call )
case APC_ASYNC_IO:
dump_uint64( "APC_ASYNC_IO,user=", &call->async_io.user );
dump_uint64( ",sb=", &call->async_io.sb );
fprintf( stderr, ",status=%s", get_status_name(call->async_io.status) );
fprintf( stderr, ",status=%s,result=%u", get_status_name(call->async_io.status), call->async_io.result );
break;
case APC_VIRTUAL_ALLOC:
dump_uint64( "APC_VIRTUAL_ALLOC,addr==", &call->virtual_alloc.addr );
@ -2845,8 +2845,7 @@ static void dump_get_async_result_request( const struct get_async_result_request
static void dump_get_async_result_reply( const struct get_async_result_reply *req )
{
fprintf( stderr, " size=%u", req->size );
dump_varargs_bytes( ", out_data=", cur_size );
dump_varargs_bytes( " out_data=", cur_size );
}
static void dump_read_request( const struct read_request *req )