Commit d055d3d1 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

server: Use async object to transfer IRP result to client.

parent 64dc8f5c
......@@ -420,9 +420,8 @@ static NTSTATUS irp_completion( void *user, IO_STATUS_BLOCK *io, NTSTATUS status
if (status == STATUS_ALERTED)
{
SERVER_START_REQ( get_irp_result )
SERVER_START_REQ( get_async_result )
{
req->handle = wine_server_obj_handle( async->io.handle );
req->user_arg = wine_server_client_ptr( async );
wine_server_set_reply( req, async->buffer, async->size );
status = wine_server_call( req );
......
......@@ -3223,6 +3223,22 @@ struct cancel_async_reply
struct get_async_result_request
{
struct request_header __header;
char __pad_12[4];
client_ptr_t user_arg;
};
struct get_async_result_reply
{
struct reply_header __header;
data_size_t size;
/* VARARG(out_data,bytes); */
char __pad_12[4];
};
struct read_request
{
struct request_header __header;
......@@ -3294,22 +3310,6 @@ struct set_irp_result_reply
struct get_irp_result_request
{
struct request_header __header;
obj_handle_t handle;
client_ptr_t user_arg;
};
struct get_irp_result_reply
{
struct reply_header __header;
data_size_t size;
/* VARARG(out_data,bytes); */
char __pad_12[4];
};
struct create_named_pipe_request
{
struct request_header __header;
......@@ -5693,11 +5693,11 @@ enum request
REQ_set_serial_info,
REQ_register_async,
REQ_cancel_async,
REQ_get_async_result,
REQ_read,
REQ_write,
REQ_ioctl,
REQ_set_irp_result,
REQ_get_irp_result,
REQ_create_named_pipe,
REQ_get_named_pipe_info,
REQ_set_named_pipe_info,
......@@ -5983,11 +5983,11 @@ union generic_request
struct set_serial_info_request set_serial_info_request;
struct register_async_request register_async_request;
struct cancel_async_request cancel_async_request;
struct get_async_result_request get_async_result_request;
struct read_request read_request;
struct write_request write_request;
struct ioctl_request ioctl_request;
struct set_irp_result_request set_irp_result_request;
struct get_irp_result_request get_irp_result_request;
struct create_named_pipe_request create_named_pipe_request;
struct get_named_pipe_info_request get_named_pipe_info_request;
struct set_named_pipe_info_request set_named_pipe_info_request;
......@@ -6271,11 +6271,11 @@ union generic_reply
struct set_serial_info_reply set_serial_info_reply;
struct register_async_reply register_async_reply;
struct cancel_async_reply cancel_async_reply;
struct get_async_result_reply get_async_result_reply;
struct read_reply read_reply;
struct write_reply write_reply;
struct ioctl_reply ioctl_reply;
struct set_irp_result_reply set_irp_result_reply;
struct get_irp_result_reply get_irp_result_reply;
struct create_named_pipe_reply create_named_pipe_reply;
struct get_named_pipe_info_reply get_named_pipe_info_reply;
struct set_named_pipe_info_reply set_named_pipe_info_reply;
......@@ -6412,6 +6412,6 @@ union generic_reply
struct terminate_job_reply terminate_job_reply;
};
#define SERVER_PROTOCOL_VERSION 523
#define SERVER_PROTOCOL_VERSION 524
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
......@@ -471,3 +471,35 @@ DECL_HANDLER(cancel_async)
release_object( obj );
}
}
/* get async result from associated iosb */
DECL_HANDLER(get_async_result)
{
struct iosb *iosb = NULL;
struct async *async;
LIST_FOR_EACH_ENTRY( async, &current->process->asyncs, struct async, process_entry )
if (async->data.arg == req->user_arg)
{
iosb = async->iosb;
break;
}
if (!iosb)
{
set_error( STATUS_INVALID_PARAMETER );
return;
}
if (iosb->out_data)
{
data_size_t size = min( iosb->out_size, get_reply_max_size() );
if (size)
{
set_reply_data_ptr( iosb->out_data, size );
iosb->out_data = NULL;
}
}
reply->size = iosb->result;
set_error( iosb->status );
}
......@@ -297,13 +297,9 @@ static void set_irp_result( struct irp_call *irp, unsigned int status,
}
wake_up( &irp->obj, 0 );
if (status != STATUS_ALERTED)
{
/* remove it from the device queue */
/* (for STATUS_ALERTED this will be done in get_irp_result) */
list_remove( &irp->dev_entry );
release_object( irp ); /* no longer on the device queue */
}
/* remove it from the device queue */
list_remove( &irp->dev_entry );
release_object( irp ); /* no longer on the device queue */
release_object( file );
}
......@@ -445,18 +441,6 @@ static void device_file_destroy( struct object *obj )
release_object( file->device );
}
static struct irp_call *find_irp_call( struct device_file *file, struct thread *thread,
client_ptr_t user_arg )
{
struct irp_call *irp;
LIST_FOR_EACH_ENTRY( irp, &file->requests, struct irp_call, dev_entry )
if (irp->thread == thread && irp->user_arg == user_arg) return irp;
set_error( STATUS_INVALID_PARAMETER );
return NULL;
}
static void set_file_user_ptr( struct device_file *file, client_ptr_t ptr )
{
struct irp_call *irp;
......@@ -810,34 +794,3 @@ DECL_HANDLER(set_irp_result)
release_object( irp );
}
}
/* retrieve results of an async irp */
DECL_HANDLER(get_irp_result)
{
struct device_file *file;
struct irp_call *irp;
if (!(file = (struct device_file *)get_handle_obj( current->process, req->handle,
0, &device_file_ops )))
return;
if ((irp = find_irp_call( file, current, req->user_arg )))
{
struct iosb *iosb = irp->iosb;
if (iosb->out_data)
{
data_size_t size = min( iosb->out_size, get_reply_max_size() );
if (size)
{
set_reply_data_ptr( iosb->out_data, size );
iosb->out_data = NULL;
}
}
reply->size = iosb->result;
set_error( iosb->status );
list_remove( &irp->dev_entry );
release_object( irp ); /* no longer on the device queue */
}
release_object( file );
}
......@@ -2350,6 +2350,15 @@ enum message_type
@END
/* Retrieve results of an async */
@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
/* Perform a read on a file object */
@REQ(read)
int blocking; /* whether it's a blocking read */
......@@ -2398,16 +2407,6 @@ enum message_type
@END
/* Retrieve results of an async irp */
@REQ(get_irp_result)
obj_handle_t handle; /* handle to the device */
client_ptr_t user_arg; /* user arg used to identify the request */
@REPLY
data_size_t size; /* result size (input or output depending on the operation) */
VARARG(out_data,bytes); /* irp output data */
@END
/* Create a named pipe */
@REQ(create_named_pipe)
unsigned int access;
......
......@@ -256,11 +256,11 @@ DECL_HANDLER(get_serial_info);
DECL_HANDLER(set_serial_info);
DECL_HANDLER(register_async);
DECL_HANDLER(cancel_async);
DECL_HANDLER(get_async_result);
DECL_HANDLER(read);
DECL_HANDLER(write);
DECL_HANDLER(ioctl);
DECL_HANDLER(set_irp_result);
DECL_HANDLER(get_irp_result);
DECL_HANDLER(create_named_pipe);
DECL_HANDLER(get_named_pipe_info);
DECL_HANDLER(set_named_pipe_info);
......@@ -545,11 +545,11 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] =
(req_handler)req_set_serial_info,
(req_handler)req_register_async,
(req_handler)req_cancel_async,
(req_handler)req_get_async_result,
(req_handler)req_read,
(req_handler)req_write,
(req_handler)req_ioctl,
(req_handler)req_set_irp_result,
(req_handler)req_get_irp_result,
(req_handler)req_create_named_pipe,
(req_handler)req_get_named_pipe_info,
(req_handler)req_set_named_pipe_info,
......@@ -1580,6 +1580,10 @@ C_ASSERT( FIELD_OFFSET(struct cancel_async_request, handle) == 12 );
C_ASSERT( FIELD_OFFSET(struct cancel_async_request, iosb) == 16 );
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( FIELD_OFFSET(struct read_request, blocking) == 12 );
C_ASSERT( FIELD_OFFSET(struct read_request, async) == 16 );
C_ASSERT( FIELD_OFFSET(struct read_request, pos) == 56 );
......@@ -1607,11 +1611,6 @@ C_ASSERT( FIELD_OFFSET(struct set_irp_result_request, status) == 16 );
C_ASSERT( FIELD_OFFSET(struct set_irp_result_request, size) == 20 );
C_ASSERT( FIELD_OFFSET(struct set_irp_result_request, file_ptr) == 24 );
C_ASSERT( sizeof(struct set_irp_result_request) == 32 );
C_ASSERT( FIELD_OFFSET(struct get_irp_result_request, handle) == 12 );
C_ASSERT( FIELD_OFFSET(struct get_irp_result_request, user_arg) == 16 );
C_ASSERT( sizeof(struct get_irp_result_request) == 24 );
C_ASSERT( FIELD_OFFSET(struct get_irp_result_reply, size) == 8 );
C_ASSERT( sizeof(struct get_irp_result_reply) == 16 );
C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, access) == 12 );
C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, options) == 16 );
C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, sharing) == 20 );
......
......@@ -2870,6 +2870,17 @@ static void dump_cancel_async_request( const struct cancel_async_request *req )
fprintf( stderr, ", only_thread=%d", req->only_thread );
}
static void dump_get_async_result_request( const struct get_async_result_request *req )
{
dump_uint64( " user_arg=", &req->user_arg );
}
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 );
}
static void dump_read_request( const struct read_request *req )
{
fprintf( stderr, " blocking=%d", req->blocking );
......@@ -2923,18 +2934,6 @@ static void dump_set_irp_result_request( const struct set_irp_result_request *re
dump_varargs_bytes( ", data=", cur_size );
}
static void dump_get_irp_result_request( const struct get_irp_result_request *req )
{
fprintf( stderr, " handle=%04x", req->handle );
dump_uint64( ", user_arg=", &req->user_arg );
}
static void dump_get_irp_result_reply( const struct get_irp_result_reply *req )
{
fprintf( stderr, " size=%u", req->size );
dump_varargs_bytes( ", out_data=", cur_size );
}
static void dump_create_named_pipe_request( const struct create_named_pipe_request *req )
{
fprintf( stderr, " access=%08x", req->access );
......@@ -4605,11 +4604,11 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_set_serial_info_request,
(dump_func)dump_register_async_request,
(dump_func)dump_cancel_async_request,
(dump_func)dump_get_async_result_request,
(dump_func)dump_read_request,
(dump_func)dump_write_request,
(dump_func)dump_ioctl_request,
(dump_func)dump_set_irp_result_request,
(dump_func)dump_get_irp_result_request,
(dump_func)dump_create_named_pipe_request,
(dump_func)dump_get_named_pipe_info_request,
(dump_func)dump_set_named_pipe_info_request,
......@@ -4891,11 +4890,11 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
NULL,
NULL,
NULL,
(dump_func)dump_get_async_result_reply,
(dump_func)dump_read_reply,
(dump_func)dump_write_reply,
(dump_func)dump_ioctl_reply,
NULL,
(dump_func)dump_get_irp_result_reply,
(dump_func)dump_create_named_pipe_reply,
(dump_func)dump_get_named_pipe_info_reply,
NULL,
......@@ -5177,11 +5176,11 @@ static const char * const req_names[REQ_NB_REQUESTS] = {
"set_serial_info",
"register_async",
"cancel_async",
"get_async_result",
"read",
"write",
"ioctl",
"set_irp_result",
"get_irp_result",
"create_named_pipe",
"get_named_pipe_info",
"set_named_pipe_info",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment