Module: wine Branch: master Commit: e92f85474f8c81f40437c97fa630eb0326cef749 URL: http://source.winehq.org/git/wine.git/?a=commit;h=e92f85474f8c81f40437c97fa6...
Author: Alexandre Julliard julliard@winehq.org Date: Mon Apr 2 12:48:13 2007 +0200
server: Avoid redundant polling in fd_queue_async_timeout.
Moved the file overlapped flag check to default_fd_queue_async.
---
server/fd.c | 33 +++++++++++++++++---------------- server/file.h | 4 ++-- server/mailslot.c | 2 +- 3 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/server/fd.c b/server/fd.c index d353aca..baab135 100644 --- a/server/fd.c +++ b/server/fd.c @@ -1719,18 +1719,10 @@ void default_poll_event( struct fd *fd, int event ) wake_up( fd->user, 0 ); }
-void fd_queue_async_timeout( struct fd *fd, const async_data_t *data, int type, int count, - const struct timeval *timeout ) +int fd_queue_async_timeout( struct fd *fd, const async_data_t *data, int type, int count, + const struct timeval *timeout ) { struct list *queue; - int events, flags; - - fd->fd_ops->get_file_info( fd, &flags ); - if (!(flags & (FD_FLAG_OVERLAPPED|FD_FLAG_TIMEOUT))) - { - set_error( STATUS_INVALID_HANDLE ); - return; - }
switch (type) { @@ -1745,17 +1737,18 @@ void fd_queue_async_timeout( struct fd *fd, const async_data_t *data, int type, break; default: set_error( STATUS_INVALID_PARAMETER ); - return; + return 0; }
- if (!create_async( current, timeout, queue, data )) return; + if (!create_async( current, timeout, queue, data )) return 0; set_error( STATUS_PENDING );
- /* Check if the new pending request can be served immediately */ - events = check_fd_events( fd, fd->fd_ops->get_poll_events( fd ) ); - if (events) fd->fd_ops->poll_event( fd, events ); + if (!fd->inode) + set_fd_events( fd, fd->fd_ops->get_poll_events( fd ) ); + else /* regular files are always ready for read and write */ + if (type != ASYNC_TYPE_WAIT) async_terminate_head( queue, STATUS_ALERTED );
- set_fd_events( fd, fd->fd_ops->get_poll_events( fd ) ); + return 1; }
void fd_async_terminate_head( struct fd *fd, int type, unsigned int status ) @@ -1796,6 +1789,14 @@ void fd_async_terminate_queue( struct fd *fd, int type, unsigned int status )
void default_fd_queue_async( struct fd *fd, const async_data_t *data, int type, int count ) { + int flags; + + fd->fd_ops->get_file_info( fd, &flags ); + if (!(flags & (FD_FLAG_OVERLAPPED|FD_FLAG_TIMEOUT))) + { + set_error( STATUS_INVALID_HANDLE ); + return; + } fd_queue_async_timeout( fd, data, type, count, NULL ); }
diff --git a/server/file.h b/server/file.h index 507d14c..f0f3a6b 100644 --- a/server/file.h +++ b/server/file.h @@ -68,8 +68,8 @@ extern void default_fd_remove_queue( struct object *obj, struct wait_queue_entry extern int default_fd_signaled( struct object *obj, struct thread *thread ); 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 int 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 ); diff --git a/server/mailslot.c b/server/mailslot.c index cf0950d..bd637f2 100644 --- a/server/mailslot.c +++ b/server/mailslot.c @@ -302,7 +302,7 @@ static void mailslot_queue_async( struct fd *fd, const async_data_t *data, int t if (mailslot->read_timeout != -1) { struct timeval when = current_time; - add_timeout( &when, mailslot->read_timeout ); + add_timeout( &when, max(1,mailslot->read_timeout) ); fd_queue_async_timeout( fd, data, type, count, &when ); } else fd_queue_async_timeout( fd, data, type, count, NULL );