From: Jacek Caban Subject: [PATCH 04/16] server: Use queue list in default_fd_cancel_async. Message-Id: <7a02a9fa-b8ce-f19d-4da6-0625094a18df@codeweavers.com> Date: Wed, 5 Oct 2016 21:27:50 +0200 Signed-off-by: Jacek Caban --- server/async.c | 24 ++++++++++++++---------- server/fd.c | 7 +------ server/file.h | 2 +- server/sock.c | 16 +--------------- 4 files changed, 17 insertions(+), 32 deletions(-) diff --git a/server/async.c b/server/async.c index a707c32..e9a46a3 100644 --- a/server/async.c +++ b/server/async.c @@ -356,23 +356,27 @@ int async_waiting( struct async_queue *queue ) return async->status == STATUS_PENDING; } -int async_wake_up_by( struct async_queue *queue, struct process *process, - struct thread *thread, client_ptr_t iosb, unsigned int status ) +int async_wake_up_by( struct list *queues, struct process *process, struct thread *thread, + client_ptr_t iosb, unsigned int status ) { + struct async_queue *queue; struct list *ptr, *next; int woken = 0; - if (!queue || (!process && !thread && !iosb)) return 0; + if (!process && !thread && !iosb) return 0; - LIST_FOR_EACH_SAFE( ptr, next, &queue->queue ) + LIST_FOR_EACH_ENTRY( queue, queues, struct async_queue, fd_entry ) { - struct async *async = LIST_ENTRY( ptr, struct async, queue_entry ); - if ( (!process || async->thread->process == process) && - (!thread || async->thread == thread) && - (!iosb || async->data.iosb == iosb) ) + LIST_FOR_EACH_SAFE( ptr, next, &queue->queue ) { - async_terminate( async, status ); - woken++; + struct async *async = LIST_ENTRY( ptr, struct async, queue_entry ); + if ( (!process || async->thread->process == process) && + (!thread || async->thread == thread) && + (!iosb || async->data.iosb == iosb) ) + { + async_terminate( async, status ); + woken++; + } } } return woken; diff --git a/server/fd.c b/server/fd.c index 09b8d65..6491e87 100644 --- a/server/fd.c +++ b/server/fd.c @@ -2119,12 +2119,7 @@ void default_fd_reselect_async( struct fd *fd, struct async_queue *queue ) /* default cancel_async() fd routine */ int default_fd_cancel_async( struct fd *fd, struct process *process, struct thread *thread, client_ptr_t iosb ) { - int n = 0; - - n += async_wake_up_by( fd->read_q, process, thread, iosb, STATUS_CANCELLED ); - n += async_wake_up_by( fd->write_q, process, thread, iosb, STATUS_CANCELLED ); - n += async_wake_up_by( fd->wait_q, process, thread, iosb, STATUS_CANCELLED ); - return n; + return async_wake_up_by( &fd->async_queues, process, thread, iosb, STATUS_CANCELLED ); } /* add async queue to queue list */ diff --git a/server/file.h b/server/file.h index fa08553..638ad5e 100644 --- a/server/file.h +++ b/server/file.h @@ -177,7 +177,7 @@ extern void async_set_result( struct object *obj, unsigned int status, extern int async_queued( struct async_queue *queue ); extern int async_waiting( struct async_queue *queue ); extern void async_terminate( struct async *async, unsigned int status ); -extern int async_wake_up_by( struct async_queue *queue, struct process *process, +extern int async_wake_up_by( struct list *queues, struct process *process, struct thread *thread, client_ptr_t iosb, unsigned int status ); extern void async_wake_up( struct async_queue *queue, unsigned int status ); extern struct completion *fd_get_completion( struct fd *fd, apc_param_t *p_key ); diff --git a/server/sock.c b/server/sock.c index 89049e0..e580412 100644 --- a/server/sock.c +++ b/server/sock.c @@ -132,7 +132,6 @@ 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_reselect_async( struct fd *fd, struct async_queue *queue ); -static int sock_cancel_async( struct fd *fd, struct process *process, struct thread *thread, client_ptr_t iosb ); static int sock_get_ntstatus( int err ); static int sock_get_error( int err ); @@ -171,7 +170,7 @@ static const struct fd_ops sock_fd_ops = sock_ioctl, /* ioctl */ sock_queue_async, /* queue_async */ sock_reselect_async, /* reselect_async */ - sock_cancel_async /* cancel_async */ + default_fd_cancel_async /* cancel_async */ }; @@ -609,19 +608,6 @@ static void sock_reselect_async( struct fd *fd, struct async_queue *queue ) sock_reselect( sock ); } -static int sock_cancel_async( struct fd *fd, struct process *process, struct thread *thread, client_ptr_t iosb ) -{ - struct sock *sock = get_fd_user( fd ); - int n = 0; - - assert( sock->obj.ops == &sock_ops ); - - n += async_wake_up_by( sock->read_q, process, thread, iosb, STATUS_CANCELLED ); - n += async_wake_up_by( sock->write_q, process, thread, iosb, STATUS_CANCELLED ); - n += async_wake_up_by( sock->ifchange_q, process, thread, iosb, STATUS_CANCELLED ); - return n; -} - static struct fd *sock_get_fd( struct object *obj ) { struct sock *sock = (struct sock *)obj;