server: Pass existing async object to fd_queue_async.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
1f1efea0d3
commit
a3acdf117f
|
@ -474,11 +474,6 @@ struct iosb *async_get_iosb( struct async *async )
|
||||||
return async->iosb ? (struct iosb *)grab_object( async->iosb ) : NULL;
|
return async->iosb ? (struct iosb *)grab_object( async->iosb ) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const async_data_t *async_get_data( struct async *async )
|
|
||||||
{
|
|
||||||
return &async->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* cancels all async I/O */
|
/* cancels all async I/O */
|
||||||
DECL_HANDLER(cancel_async)
|
DECL_HANDLER(cancel_async)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1246,7 +1246,8 @@ DECL_HANDLER(read_directory_changes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* requests don't timeout */
|
/* requests don't timeout */
|
||||||
if (!(async = fd_queue_async( dir->fd, &req->async, NULL, ASYNC_TYPE_WAIT ))) goto end;
|
if (!(async = create_async( current, &req->async, NULL ))) goto end;
|
||||||
|
if (!fd_queue_async( dir->fd, async, ASYNC_TYPE_WAIT )) goto end;
|
||||||
|
|
||||||
/* assign it once */
|
/* assign it once */
|
||||||
if (!dir->filter)
|
if (!dir->filter)
|
||||||
|
@ -1266,10 +1267,10 @@ DECL_HANDLER(read_directory_changes)
|
||||||
if (!inotify_adjust_changes( dir ))
|
if (!inotify_adjust_changes( dir ))
|
||||||
dnotify_adjust_changes( dir );
|
dnotify_adjust_changes( dir );
|
||||||
|
|
||||||
release_object( async );
|
|
||||||
set_error(STATUS_PENDING);
|
set_error(STATUS_PENDING);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
if (async) release_object( async );
|
||||||
release_object( dir );
|
release_object( dir );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ static void irp_call_destroy( struct object *obj )
|
||||||
if (irp->thread) release_object( irp->thread );
|
if (irp->thread) release_object( irp->thread );
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct irp_call *create_irp( struct device_file *file, const irp_params_t *params, struct iosb *iosb )
|
static struct irp_call *create_irp( struct device_file *file, const irp_params_t *params, struct async *async )
|
||||||
{
|
{
|
||||||
struct irp_call *irp;
|
struct irp_call *irp;
|
||||||
|
|
||||||
|
@ -258,12 +258,10 @@ static struct irp_call *create_irp( struct device_file *file, const irp_params_t
|
||||||
irp->thread = NULL;
|
irp->thread = NULL;
|
||||||
irp->async = NULL;
|
irp->async = NULL;
|
||||||
irp->params = *params;
|
irp->params = *params;
|
||||||
|
irp->iosb = NULL;
|
||||||
|
|
||||||
if (iosb)
|
if (async) irp->iosb = async_get_iosb( async );
|
||||||
{
|
if (!irp->iosb && !(irp->iosb = create_iosb( NULL, 0, 0 )))
|
||||||
irp->iosb = (struct iosb *)grab_object( iosb );
|
|
||||||
}
|
|
||||||
else if (!(irp->iosb = create_iosb( NULL, 0, 0 )))
|
|
||||||
{
|
{
|
||||||
release_object( irp );
|
release_object( irp );
|
||||||
irp = NULL;
|
irp = NULL;
|
||||||
|
@ -471,11 +469,12 @@ static obj_handle_t queue_irp( struct device_file *file, struct irp_call *irp,
|
||||||
|
|
||||||
if (blocking && !(handle = alloc_handle( current->process, irp, SYNCHRONIZE, 0 ))) return 0;
|
if (blocking && !(handle = alloc_handle( current->process, irp, SYNCHRONIZE, 0 ))) return 0;
|
||||||
|
|
||||||
if (!(irp->async = fd_queue_async( file->fd, async_get_data( async ), irp->iosb, ASYNC_TYPE_WAIT )))
|
if (!fd_queue_async( file->fd, async, ASYNC_TYPE_WAIT ))
|
||||||
{
|
{
|
||||||
if (handle) close_handle( current->process, handle );
|
if (handle) close_handle( current->process, handle );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
irp->async = (struct async *)grab_object( async );
|
||||||
add_irp_to_queue( file, irp, current );
|
add_irp_to_queue( file, irp, current );
|
||||||
set_error( STATUS_PENDING );
|
set_error( STATUS_PENDING );
|
||||||
return handle;
|
return handle;
|
||||||
|
@ -492,7 +491,6 @@ static obj_handle_t device_file_read( struct fd *fd, struct async *async, int bl
|
||||||
struct irp_call *irp;
|
struct irp_call *irp;
|
||||||
obj_handle_t handle;
|
obj_handle_t handle;
|
||||||
irp_params_t params;
|
irp_params_t params;
|
||||||
struct iosb *iosb;
|
|
||||||
|
|
||||||
memset( ¶ms, 0, sizeof(params) );
|
memset( ¶ms, 0, sizeof(params) );
|
||||||
params.read.major = IRP_MJ_READ;
|
params.read.major = IRP_MJ_READ;
|
||||||
|
@ -500,9 +498,7 @@ static obj_handle_t device_file_read( struct fd *fd, struct async *async, int bl
|
||||||
params.read.pos = pos;
|
params.read.pos = pos;
|
||||||
params.read.file = file->user_ptr;
|
params.read.file = file->user_ptr;
|
||||||
|
|
||||||
iosb = async_get_iosb( async );
|
irp = create_irp( file, ¶ms, async );
|
||||||
irp = create_irp( file, ¶ms, iosb );
|
|
||||||
release_object( iosb );
|
|
||||||
if (!irp) return 0;
|
if (!irp) return 0;
|
||||||
|
|
||||||
handle = queue_irp( file, irp, async, blocking );
|
handle = queue_irp( file, irp, async, blocking );
|
||||||
|
@ -516,7 +512,6 @@ static obj_handle_t device_file_write( struct fd *fd, struct async *async, int b
|
||||||
struct irp_call *irp;
|
struct irp_call *irp;
|
||||||
obj_handle_t handle;
|
obj_handle_t handle;
|
||||||
irp_params_t params;
|
irp_params_t params;
|
||||||
struct iosb *iosb;
|
|
||||||
|
|
||||||
memset( ¶ms, 0, sizeof(params) );
|
memset( ¶ms, 0, sizeof(params) );
|
||||||
params.write.major = IRP_MJ_WRITE;
|
params.write.major = IRP_MJ_WRITE;
|
||||||
|
@ -524,9 +519,7 @@ static obj_handle_t device_file_write( struct fd *fd, struct async *async, int b
|
||||||
params.write.pos = pos;
|
params.write.pos = pos;
|
||||||
params.write.file = file->user_ptr;
|
params.write.file = file->user_ptr;
|
||||||
|
|
||||||
iosb = async_get_iosb( async );
|
irp = create_irp( file, ¶ms, async );
|
||||||
irp = create_irp( file, ¶ms, iosb );
|
|
||||||
release_object( iosb );
|
|
||||||
if (!irp) return 0;
|
if (!irp) return 0;
|
||||||
|
|
||||||
handle = queue_irp( file, irp, async, blocking );
|
handle = queue_irp( file, irp, async, blocking );
|
||||||
|
@ -560,17 +553,13 @@ static obj_handle_t device_file_ioctl( struct fd *fd, ioctl_code_t code, struct
|
||||||
struct irp_call *irp;
|
struct irp_call *irp;
|
||||||
obj_handle_t handle;
|
obj_handle_t handle;
|
||||||
irp_params_t params;
|
irp_params_t params;
|
||||||
struct iosb *iosb;
|
|
||||||
|
|
||||||
memset( ¶ms, 0, sizeof(params) );
|
memset( ¶ms, 0, sizeof(params) );
|
||||||
params.ioctl.major = IRP_MJ_DEVICE_CONTROL;
|
params.ioctl.major = IRP_MJ_DEVICE_CONTROL;
|
||||||
params.ioctl.code = code;
|
params.ioctl.code = code;
|
||||||
params.ioctl.file = file->user_ptr;
|
params.ioctl.file = file->user_ptr;
|
||||||
|
|
||||||
iosb = create_iosb( get_req_data(), get_req_data_size(), get_reply_max_size() );
|
irp = create_irp( file, ¶ms, async );
|
||||||
if (!iosb) return 0;
|
|
||||||
irp = create_irp( file, ¶ms, iosb );
|
|
||||||
release_object(iosb);
|
|
||||||
if (!irp) return 0;
|
if (!irp) return 0;
|
||||||
|
|
||||||
handle = queue_irp( file, irp, async, blocking );
|
handle = queue_irp( file, irp, async, blocking );
|
||||||
|
|
21
server/fd.c
21
server/fd.c
|
@ -2030,23 +2030,22 @@ void default_poll_event( struct fd *fd, int event )
|
||||||
else if (!fd->inode) set_fd_events( fd, fd->fd_ops->get_poll_events( fd ) );
|
else if (!fd->inode) set_fd_events( fd, fd->fd_ops->get_poll_events( fd ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
struct async *fd_queue_async( struct fd *fd, const async_data_t *data, struct iosb *iosb, int type )
|
int fd_queue_async( struct fd *fd, struct async *async, int type )
|
||||||
{
|
{
|
||||||
struct async_queue *queue;
|
struct async_queue *queue;
|
||||||
struct async *async;
|
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case ASYNC_TYPE_READ:
|
case ASYNC_TYPE_READ:
|
||||||
if (!fd->read_q && !(fd->read_q = create_async_queue( fd ))) return NULL;
|
if (!fd->read_q && !(fd->read_q = create_async_queue( fd ))) return 0;
|
||||||
queue = fd->read_q;
|
queue = fd->read_q;
|
||||||
break;
|
break;
|
||||||
case ASYNC_TYPE_WRITE:
|
case ASYNC_TYPE_WRITE:
|
||||||
if (!fd->write_q && !(fd->write_q = create_async_queue( fd ))) return NULL;
|
if (!fd->write_q && !(fd->write_q = create_async_queue( fd ))) return 0;
|
||||||
queue = fd->write_q;
|
queue = fd->write_q;
|
||||||
break;
|
break;
|
||||||
case ASYNC_TYPE_WAIT:
|
case ASYNC_TYPE_WAIT:
|
||||||
if (!fd->wait_q && !(fd->wait_q = create_async_queue( fd ))) return NULL;
|
if (!fd->wait_q && !(fd->wait_q = create_async_queue( fd ))) return 0;
|
||||||
queue = fd->wait_q;
|
queue = fd->wait_q;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -2054,9 +2053,8 @@ struct async *fd_queue_async( struct fd *fd, const async_data_t *data, struct io
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((async = create_async( current, data, iosb )))
|
|
||||||
{
|
|
||||||
queue_async( queue, async );
|
queue_async( queue, async );
|
||||||
|
|
||||||
if (type != ASYNC_TYPE_WAIT)
|
if (type != ASYNC_TYPE_WAIT)
|
||||||
{
|
{
|
||||||
if (!fd->inode)
|
if (!fd->inode)
|
||||||
|
@ -2064,8 +2062,7 @@ struct async *fd_queue_async( struct fd *fd, const async_data_t *data, struct io
|
||||||
else /* regular files are always ready for read and write */
|
else /* regular files are always ready for read and write */
|
||||||
async_wake_up( queue, STATUS_ALERTED );
|
async_wake_up( queue, STATUS_ALERTED );
|
||||||
}
|
}
|
||||||
}
|
return 1;
|
||||||
return async;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void fd_async_wake_up( struct fd *fd, int type, unsigned int status )
|
void fd_async_wake_up( struct fd *fd, int type, unsigned int status )
|
||||||
|
@ -2098,11 +2095,7 @@ void no_fd_queue_async( struct fd *fd, struct async *async, int type, int count
|
||||||
|
|
||||||
void default_fd_queue_async( struct fd *fd, struct async *async, int type, int count )
|
void default_fd_queue_async( struct fd *fd, struct async *async, int type, int count )
|
||||||
{
|
{
|
||||||
if ((async = fd_queue_async( fd, async_get_data( async ), NULL, type )))
|
if (fd_queue_async( fd, async, type )) set_error( STATUS_PENDING );
|
||||||
{
|
|
||||||
release_object( async );
|
|
||||||
set_error( STATUS_PENDING );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* default reselect_async() fd routine */
|
/* default reselect_async() fd routine */
|
||||||
|
|
|
@ -97,7 +97,7 @@ extern int default_fd_signaled( struct object *obj, struct wait_queue_entry *ent
|
||||||
extern unsigned int default_fd_map_access( struct object *obj, unsigned int access );
|
extern unsigned int default_fd_map_access( struct object *obj, unsigned int access );
|
||||||
extern int default_fd_get_poll_events( struct fd *fd );
|
extern int default_fd_get_poll_events( struct fd *fd );
|
||||||
extern void default_poll_event( struct fd *fd, int event );
|
extern void default_poll_event( struct fd *fd, int event );
|
||||||
extern struct async *fd_queue_async( struct fd *fd, const async_data_t *data, struct iosb *iosb, int type );
|
extern int fd_queue_async( struct fd *fd, struct async *async, int type );
|
||||||
extern void fd_async_wake_up( struct fd *fd, int type, unsigned int status );
|
extern void fd_async_wake_up( struct fd *fd, int type, unsigned int status );
|
||||||
extern void fd_reselect_async( struct fd *fd, struct async_queue *queue );
|
extern void fd_reselect_async( struct fd *fd, struct async_queue *queue );
|
||||||
extern obj_handle_t no_fd_read( struct fd *fd, struct async *async, int blocking, file_pos_t pos );
|
extern obj_handle_t no_fd_read( struct fd *fd, struct async *async, int blocking, file_pos_t pos );
|
||||||
|
@ -188,7 +188,6 @@ extern struct completion *fd_get_completion( struct fd *fd, apc_param_t *p_key )
|
||||||
extern void fd_copy_completion( struct fd *src, struct fd *dst );
|
extern void fd_copy_completion( struct fd *src, struct fd *dst );
|
||||||
extern struct iosb *create_iosb( const void *in_data, data_size_t in_size, data_size_t out_size );
|
extern struct iosb *create_iosb( const void *in_data, data_size_t in_size, data_size_t out_size );
|
||||||
extern struct iosb *async_get_iosb( struct async *async );
|
extern struct iosb *async_get_iosb( struct async *async );
|
||||||
extern const async_data_t *async_get_data( struct async *async );
|
|
||||||
extern void cancel_process_asyncs( struct process *process );
|
extern void cancel_process_asyncs( struct process *process );
|
||||||
|
|
||||||
/* access rights that require Unix read permission */
|
/* access rights that require Unix read permission */
|
||||||
|
|
|
@ -331,11 +331,10 @@ static void mailslot_queue_async( struct fd *fd, struct async *async, int type,
|
||||||
|
|
||||||
assert(mailslot->obj.ops == &mailslot_ops);
|
assert(mailslot->obj.ops == &mailslot_ops);
|
||||||
|
|
||||||
if ((async = fd_queue_async( fd, async_get_data( async ), NULL, type )))
|
if (fd_queue_async( fd, async, type ))
|
||||||
{
|
{
|
||||||
async_set_timeout( async, mailslot->read_timeout ? mailslot->read_timeout : -1,
|
async_set_timeout( async, mailslot->read_timeout ? mailslot->read_timeout : -1,
|
||||||
STATUS_IO_TIMEOUT );
|
STATUS_IO_TIMEOUT );
|
||||||
release_object( async );
|
|
||||||
set_error( STATUS_PENDING );
|
set_error( STATUS_PENDING );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -554,13 +554,12 @@ static obj_handle_t pipe_server_flush( struct fd *fd, struct async *async, int b
|
||||||
|
|
||||||
if (!pipe_data_remaining( server )) return 0;
|
if (!pipe_data_remaining( server )) return 0;
|
||||||
|
|
||||||
if ((async = fd_queue_async( server->fd, async_get_data( async ), NULL, ASYNC_TYPE_WAIT )))
|
if (fd_queue_async( server->fd, async, ASYNC_TYPE_WAIT ))
|
||||||
{
|
{
|
||||||
/* there's no unix way to be alerted when a pipe becomes empty, so resort to polling */
|
/* there's no unix way to be alerted when a pipe becomes empty, so resort to polling */
|
||||||
if (!server->flush_poll)
|
if (!server->flush_poll)
|
||||||
server->flush_poll = add_timeout_user( -TICKS_PER_SEC / 10, check_flushed, server );
|
server->flush_poll = add_timeout_user( -TICKS_PER_SEC / 10, check_flushed, server );
|
||||||
if (blocking) handle = alloc_handle( current->process, async, SYNCHRONIZE, 0 );
|
if (blocking) handle = alloc_handle( current->process, async, SYNCHRONIZE, 0 );
|
||||||
release_object( async );
|
|
||||||
set_error( STATUS_PENDING );
|
set_error( STATUS_PENDING );
|
||||||
}
|
}
|
||||||
return handle;
|
return handle;
|
||||||
|
@ -600,12 +599,11 @@ static obj_handle_t pipe_server_ioctl( struct fd *fd, ioctl_code_t code, struct
|
||||||
{
|
{
|
||||||
case ps_idle_server:
|
case ps_idle_server:
|
||||||
case ps_wait_connect:
|
case ps_wait_connect:
|
||||||
if ((async = fd_queue_async( server->ioctl_fd, async_get_data( async ), NULL, ASYNC_TYPE_WAIT )))
|
if (fd_queue_async( server->ioctl_fd, async, ASYNC_TYPE_WAIT ))
|
||||||
{
|
{
|
||||||
if (blocking) wait_handle = alloc_handle( current->process, async, SYNCHRONIZE, 0 );
|
if (blocking) wait_handle = alloc_handle( current->process, async, SYNCHRONIZE, 0 );
|
||||||
set_server_state( server, ps_wait_open );
|
set_server_state( server, ps_wait_open );
|
||||||
if (server->pipe->waiters) async_wake_up( server->pipe->waiters, STATUS_SUCCESS );
|
if (server->pipe->waiters) async_wake_up( server->pipe->waiters, STATUS_SUCCESS );
|
||||||
release_object( async );
|
|
||||||
set_error( STATUS_PENDING );
|
set_error( STATUS_PENDING );
|
||||||
return wait_handle;
|
return wait_handle;
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,10 +200,9 @@ static void serial_queue_async( struct fd *fd, struct async *async, int type, in
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((async = fd_queue_async( fd, async_get_data( async ), NULL, type )))
|
if (fd_queue_async( fd, async, type ))
|
||||||
{
|
{
|
||||||
if (timeout) async_set_timeout( async, timeout * -10000, STATUS_TIMEOUT );
|
if (timeout) async_set_timeout( async, timeout * -10000, STATUS_TIMEOUT );
|
||||||
release_object( async );
|
|
||||||
set_error( STATUS_PENDING );
|
set_error( STATUS_PENDING );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue