From 95ba4b553ca2a20bca8b5c055033ab505ceec86f Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 2 Apr 2007 12:47:52 +0200 Subject: [PATCH] server: Add a generic wait queue to the file descriptor object. --- server/fd.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ server/file.h | 2 ++ 2 files changed, 46 insertions(+) diff --git a/server/fd.c b/server/fd.c index 6fe4ace38f..d353acab98 100644 --- a/server/fd.c +++ b/server/fd.c @@ -173,6 +173,7 @@ struct fd int poll_index; /* index of fd in poll array */ struct list read_q; /* async readers of this fd */ struct list write_q; /* async writers of this fd */ + struct list wait_q; /* other async waiters of this fd */ }; static void fd_dump( struct object *obj, int verbose ); @@ -1287,6 +1288,7 @@ static void fd_destroy( struct object *obj ) async_terminate_queue( &fd->read_q, STATUS_CANCELLED ); async_terminate_queue( &fd->write_q, STATUS_CANCELLED ); + async_terminate_queue( &fd->wait_q, STATUS_CANCELLED ); remove_fd_locks( fd ); list_remove( &fd->inode_entry ); @@ -1365,6 +1367,7 @@ static struct fd *alloc_fd_object(void) list_init( &fd->locks ); list_init( &fd->read_q ); list_init( &fd->write_q ); + list_init( &fd->wait_q ); if ((fd->poll_index = add_poll_user( fd )) == -1) { @@ -1395,6 +1398,7 @@ struct fd *alloc_pseudo_fd( const struct fd_ops *fd_user_ops, struct object *use list_init( &fd->locks ); list_init( &fd->read_q ); list_init( &fd->write_q ); + list_init( &fd->wait_q ); return fd; } @@ -1736,6 +1740,9 @@ void fd_queue_async_timeout( struct fd *fd, const async_data_t *data, int type, case ASYNC_TYPE_WRITE: queue = &fd->write_q; break; + case ASYNC_TYPE_WAIT: + queue = &fd->wait_q; + break; default: set_error( STATUS_INVALID_PARAMETER ); return; @@ -1751,6 +1758,42 @@ void fd_queue_async_timeout( struct fd *fd, const async_data_t *data, int type, set_fd_events( fd, fd->fd_ops->get_poll_events( fd ) ); } +void fd_async_terminate_head( struct fd *fd, int type, unsigned int status ) +{ + switch (type) + { + case ASYNC_TYPE_READ: + async_terminate_head( &fd->read_q, status ); + break; + case ASYNC_TYPE_WRITE: + async_terminate_head( &fd->write_q, status ); + break; + case ASYNC_TYPE_WAIT: + async_terminate_head( &fd->wait_q, status ); + break; + default: + assert(0); + } +} + +void fd_async_terminate_queue( struct fd *fd, int type, unsigned int status ) +{ + switch (type) + { + case ASYNC_TYPE_READ: + async_terminate_queue( &fd->read_q, status ); + break; + case ASYNC_TYPE_WRITE: + async_terminate_queue( &fd->write_q, status ); + break; + case ASYNC_TYPE_WAIT: + async_terminate_queue( &fd->wait_q, status ); + break; + default: + assert(0); + } +} + void default_fd_queue_async( struct fd *fd, const async_data_t *data, int type, int count ) { fd_queue_async_timeout( fd, data, type, count, NULL ); @@ -1760,6 +1803,7 @@ void default_fd_cancel_async( struct fd *fd ) { async_terminate_queue( &fd->read_q, STATUS_CANCELLED ); async_terminate_queue( &fd->write_q, STATUS_CANCELLED ); + async_terminate_queue( &fd->wait_q, STATUS_CANCELLED ); } /* default flush() routine */ diff --git a/server/file.h b/server/file.h index c43352a1cd..507d14c19c 100644 --- a/server/file.h +++ b/server/file.h @@ -70,6 +70,8 @@ extern int default_fd_get_poll_events( struct fd *fd ); extern void default_poll_event( struct fd *fd, int event ); extern void fd_queue_async_timeout( struct fd *fd, const async_data_t *data, int type, int count, const struct timeval *timeout ); +extern void fd_async_terminate_head( struct fd *fd, int type, unsigned int status ); +extern void fd_async_terminate_queue( struct fd *fd, int type, unsigned int status ); extern void default_fd_queue_async( struct fd *fd, const async_data_t *data, int type, int count ); extern void default_fd_cancel_async( struct fd *fd ); extern void no_flush( struct fd *fd, struct event **event ); -- 2.32.0.93.g670b81a890