From a604db12612afccd789e4c09884c3c35dc8f1562 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 15 Feb 2017 22:12:45 +0100 Subject: [PATCH] server: Create async object in register_async handler. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- server/fd.c | 15 +++++++++------ server/file.h | 6 +++--- server/mailslot.c | 7 +++---- server/serial.c | 7 +++---- server/sock.c | 8 ++------ 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/server/fd.c b/server/fd.c index 202bd56a7cb..4aa1b1ddf89 100644 --- a/server/fd.c +++ b/server/fd.c @@ -2091,16 +2091,14 @@ void fd_reselect_async( struct fd *fd, struct async_queue *queue ) fd->fd_ops->reselect_async( fd, queue ); } -void no_fd_queue_async( struct fd *fd, const async_data_t *data, int type, int count ) +void no_fd_queue_async( struct fd *fd, struct async *async, int type, int count ) { set_error( STATUS_OBJECT_TYPE_MISMATCH ); } -void default_fd_queue_async( struct fd *fd, const async_data_t *data, int type, int count ) +void default_fd_queue_async( struct fd *fd, struct async *async, int type, int count ) { - struct async *async; - - if ((async = fd_queue_async( fd, data, NULL, type ))) + if ((async = fd_queue_async( fd, async_get_data( async ), NULL, type ))) { release_object( async ); set_error( STATUS_PENDING ); @@ -2509,6 +2507,7 @@ DECL_HANDLER(ioctl) DECL_HANDLER(register_async) { unsigned int access; + struct async *async; struct fd *fd; switch(req->type) @@ -2526,7 +2525,11 @@ DECL_HANDLER(register_async) if ((fd = get_handle_fd_obj( current->process, req->async.handle, access ))) { - if (get_unix_fd( fd ) != -1) fd->fd_ops->queue_async( fd, &req->async, req->type, req->count ); + if (get_unix_fd( fd ) != -1 && (async = create_async( current, &req->async, NULL ))) + { + fd->fd_ops->queue_async( fd, async, req->type, req->count ); + release_object( async ); + } release_object( fd ); } } diff --git a/server/file.h b/server/file.h index 3605053d8af..98a1e84253e 100644 --- a/server/file.h +++ b/server/file.h @@ -60,7 +60,7 @@ struct fd_ops /* perform an ioctl on the file */ obj_handle_t (*ioctl)(struct fd *fd, ioctl_code_t code, const async_data_t *async, int blocking ); /* queue an async operation */ - void (*queue_async)(struct fd *, const async_data_t *data, int type, int count); + void (*queue_async)(struct fd *, struct async *async, int type, int count); /* selected events for async i/o need an update */ void (*reselect_async)( struct fd *, struct async_queue *queue ); }; @@ -105,8 +105,8 @@ extern obj_handle_t no_fd_write( struct fd *fd, struct async *async, int blockin extern obj_handle_t no_fd_flush( struct fd *fd, const async_data_t *async, int blocking ); extern obj_handle_t no_fd_ioctl( struct fd *fd, ioctl_code_t code, const async_data_t *async, int blocking ); extern obj_handle_t default_fd_ioctl( struct fd *fd, ioctl_code_t code, const async_data_t *async, int blocking ); -extern void no_fd_queue_async( struct fd *fd, const async_data_t *data, int type, int count ); -extern void default_fd_queue_async( struct fd *fd, const async_data_t *data, int type, int count ); +extern void no_fd_queue_async( struct fd *fd, struct async *async, int type, int count ); +extern void default_fd_queue_async( struct fd *fd, struct async *async, int type, int count ); extern void default_fd_reselect_async( struct fd *fd, struct async_queue *queue ); extern void main_loop(void); extern void remove_process_locks( struct process *process ); diff --git a/server/mailslot.c b/server/mailslot.c index 783b28b72e8..20bf99cc5b0 100644 --- a/server/mailslot.c +++ b/server/mailslot.c @@ -94,7 +94,7 @@ static const struct object_ops mailslot_ops = }; static enum server_fd_type mailslot_get_fd_type( struct fd *fd ); -static void mailslot_queue_async( struct fd *fd, const async_data_t *data, int type, int count ); +static void mailslot_queue_async( struct fd *fd, struct async *async, int type, int count ); static const struct fd_ops mailslot_fd_ops = { @@ -325,14 +325,13 @@ static struct object *mailslot_open_file( struct object *obj, unsigned int acces return &writer->obj; } -static void mailslot_queue_async( struct fd *fd, const async_data_t *data, int type, int count ) +static void mailslot_queue_async( struct fd *fd, struct async *async, int type, int count ) { struct mailslot *mailslot = get_fd_user( fd ); - struct async *async; assert(mailslot->obj.ops == &mailslot_ops); - if ((async = fd_queue_async( fd, data, NULL, type ))) + if ((async = fd_queue_async( fd, async_get_data( async ), NULL, type ))) { async_set_timeout( async, mailslot->read_timeout ? mailslot->read_timeout : -1, STATUS_IO_TIMEOUT ); diff --git a/server/serial.c b/server/serial.c index 6f9cc2444f7..58170cd1134 100644 --- a/server/serial.c +++ b/server/serial.c @@ -61,7 +61,7 @@ static struct fd *serial_get_fd( struct object *obj ); static void serial_destroy(struct object *obj); static enum server_fd_type serial_get_fd_type( struct fd *fd ); -static void serial_queue_async( struct fd *fd, const async_data_t *data, int type, int count ); +static void serial_queue_async( struct fd *fd, struct async *async, int type, int count ); static void serial_reselect_async( struct fd *fd, struct async_queue *queue ); struct serial @@ -183,11 +183,10 @@ static enum server_fd_type serial_get_fd_type( struct fd *fd ) return FD_TYPE_SERIAL; } -static void serial_queue_async( struct fd *fd, const async_data_t *data, int type, int count ) +static void serial_queue_async( struct fd *fd, struct async *async, int type, int count ) { struct serial *serial = get_fd_user( fd ); timeout_t timeout = 0; - struct async *async; assert(serial->obj.ops == &serial_ops); @@ -201,7 +200,7 @@ static void serial_queue_async( struct fd *fd, const async_data_t *data, int typ break; } - if ((async = fd_queue_async( fd, data, NULL, type ))) + if ((async = fd_queue_async( fd, async_get_data( async ), NULL, type ))) { if (timeout) async_set_timeout( async, timeout * -10000, STATUS_TIMEOUT ); release_object( async ); diff --git a/server/sock.c b/server/sock.c index e9369e5e4df..c997bf33e5f 100644 --- a/server/sock.c +++ b/server/sock.c @@ -130,7 +130,7 @@ static int sock_get_poll_events( struct fd *fd ); static void sock_poll_event( struct fd *fd, int event ); static enum server_fd_type sock_get_fd_type( struct fd *fd ); static obj_handle_t sock_ioctl( struct fd *fd, ioctl_code_t code, const async_data_t *async, int blocking ); -static void sock_queue_async( struct fd *fd, const async_data_t *data, int type, int count ); +static void sock_queue_async( struct fd *fd, struct async *async, int type, int count ); static void sock_reselect_async( struct fd *fd, struct async_queue *queue ); static int sock_get_ntstatus( int err ); @@ -564,10 +564,9 @@ obj_handle_t sock_ioctl( struct fd *fd, ioctl_code_t code, const async_data_t *a } } -static void sock_queue_async( struct fd *fd, const async_data_t *data, int type, int count ) +static void sock_queue_async( struct fd *fd, struct async *async, int type, int count ) { struct sock *sock = get_fd_user( fd ); - struct async *async; struct async_queue *queue; assert( sock->obj.ops == &sock_ops ); @@ -594,10 +593,7 @@ static void sock_queue_async( struct fd *fd, const async_data_t *data, int type, return; } - if (!(async = create_async( current, data, NULL ))) return; queue_async( queue, async ); - release_object( async ); - sock_reselect( sock ); set_error( STATUS_PENDING );