From 7b33613fc4d74a5d13629f20e4b818fc8000a115 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 4 Jul 2017 15:26:35 +0200 Subject: [PATCH] server: Make fd_queue_async infallible. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- server/change.c | 4 ++-- server/device.c | 2 +- server/fd.c | 6 +++--- server/file.h | 2 +- server/mailslot.c | 10 ++++------ server/named_pipe.c | 16 ++++++---------- server/serial.c | 8 +++----- 7 files changed, 20 insertions(+), 28 deletions(-) diff --git a/server/change.c b/server/change.c index 88423feb55a..4dd7933f3ee 100644 --- a/server/change.c +++ b/server/change.c @@ -1247,7 +1247,7 @@ DECL_HANDLER(read_directory_changes) /* requests don't timeout */ if (!(async = create_async( dir->fd, current, &req->async, NULL ))) goto end; - if (!fd_queue_async( dir->fd, async, ASYNC_TYPE_WAIT )) goto end; + fd_queue_async( dir->fd, async, ASYNC_TYPE_WAIT ); /* assign it once */ if (!dir->filter) @@ -1269,8 +1269,8 @@ DECL_HANDLER(read_directory_changes) set_error(STATUS_PENDING); + release_object( async ); end: - if (async) release_object( async ); release_object( dir ); } diff --git a/server/device.c b/server/device.c index fc5bcbec115..0443185778a 100644 --- a/server/device.c +++ b/server/device.c @@ -464,7 +464,7 @@ static void set_file_user_ptr( struct device_file *file, client_ptr_t ptr ) /* queue an irp to the device */ static int queue_irp( struct device_file *file, struct irp_call *irp, struct async *async ) { - if (!fd_queue_async( file->fd, async, ASYNC_TYPE_WAIT )) return 0; + fd_queue_async( file->fd, async, ASYNC_TYPE_WAIT ); irp->async = (struct async *)grab_object( async ); add_irp_to_queue( file, irp, current ); diff --git a/server/fd.c b/server/fd.c index 4a746c95a91..9322e2c1c15 100644 --- a/server/fd.c +++ b/server/fd.c @@ -2030,7 +2030,7 @@ void default_poll_event( struct fd *fd, int event ) else if (!fd->inode) set_fd_events( fd, fd->fd_ops->get_poll_events( fd ) ); } -int fd_queue_async( struct fd *fd, struct async *async, int type ) +void fd_queue_async( struct fd *fd, struct async *async, int type ) { struct async_queue *queue; @@ -2059,7 +2059,6 @@ int fd_queue_async( struct fd *fd, struct async *async, int type ) else /* regular files are always ready for read and write */ async_wake_up( queue, STATUS_ALERTED ); } - return 1; } void fd_async_wake_up( struct fd *fd, int type, unsigned int status ) @@ -2092,7 +2091,8 @@ 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 ) { - if (fd_queue_async( fd, async, type )) set_error( STATUS_PENDING ); + fd_queue_async( fd, async, type ); + set_error( STATUS_PENDING ); } /* default reselect_async() fd routine */ diff --git a/server/file.h b/server/file.h index 0633b879980..fa41654e6b6 100644 --- a/server/file.h +++ b/server/file.h @@ -102,7 +102,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 int default_fd_get_poll_events( struct fd *fd ); extern void default_poll_event( struct fd *fd, int event ); -extern int fd_queue_async( struct fd *fd, struct async *async, int type ); +extern void 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_reselect_async( struct fd *fd, struct async_queue *queue ); extern int no_fd_read( struct fd *fd, struct async *async, file_pos_t pos ); diff --git a/server/mailslot.c b/server/mailslot.c index 643577cd72c..d7affa514bf 100644 --- a/server/mailslot.c +++ b/server/mailslot.c @@ -331,12 +331,10 @@ static void mailslot_queue_async( struct fd *fd, struct async *async, int type, assert(mailslot->obj.ops == &mailslot_ops); - if (fd_queue_async( fd, async, type )) - { - async_set_timeout( async, mailslot->read_timeout ? mailslot->read_timeout : -1, - STATUS_IO_TIMEOUT ); - set_error( STATUS_PENDING ); - } + fd_queue_async( fd, async, type ); + async_set_timeout( async, mailslot->read_timeout ? mailslot->read_timeout : -1, + STATUS_IO_TIMEOUT ); + set_error( STATUS_PENDING ); } static void mailslot_device_dump( struct object *obj, int verbose ) diff --git a/server/named_pipe.c b/server/named_pipe.c index 0be0fcbeb1b..80363cb971a 100644 --- a/server/named_pipe.c +++ b/server/named_pipe.c @@ -653,8 +653,7 @@ static int pipe_end_flush( struct pipe_end *pipe_end, struct async *async ) if (use_server_io( pipe_end ) && (!pipe_end->connection || list_empty( &pipe_end->connection->message_queue ))) return 1; - if (!fd_queue_async( pipe_end->fd, async, ASYNC_TYPE_WAIT )) return 0; - + fd_queue_async( pipe_end->fd, async, ASYNC_TYPE_WAIT ); set_error( STATUS_PENDING ); return 1; } @@ -933,14 +932,11 @@ static int pipe_server_ioctl( struct fd *fd, ioctl_code_t code, struct async *as { case ps_idle_server: case ps_wait_connect: - if (fd_queue_async( server->ioctl_fd, async, ASYNC_TYPE_WAIT )) - { - set_server_state( server, ps_wait_open ); - async_wake_up( &server->pipe->waiters, STATUS_SUCCESS ); - set_error( STATUS_PENDING ); - return 1; - } - break; + fd_queue_async( server->ioctl_fd, async, ASYNC_TYPE_WAIT ); + set_server_state( server, ps_wait_open ); + async_wake_up( &server->pipe->waiters, STATUS_SUCCESS ); + set_error( STATUS_PENDING ); + return 1; case ps_connected_server: set_error( STATUS_PIPE_CONNECTED ); break; diff --git a/server/serial.c b/server/serial.c index 396ca22a2cb..85dd104bc68 100644 --- a/server/serial.c +++ b/server/serial.c @@ -244,11 +244,9 @@ static void serial_queue_async( struct fd *fd, struct async *async, int type, in break; } - if (fd_queue_async( fd, async, type )) - { - if (timeout) async_set_timeout( async, timeout * -10000, STATUS_TIMEOUT ); - set_error( STATUS_PENDING ); - } + fd_queue_async( fd, async, type ); + if (timeout) async_set_timeout( async, timeout * -10000, STATUS_TIMEOUT ); + set_error( STATUS_PENDING ); } static void serial_read_timeout( void *arg )