Commit e92f8547 authored by Alexandre Julliard's avatar Alexandre Julliard

server: Avoid redundant polling in fd_queue_async_timeout.

Moved the file overlapped flag check to default_fd_queue_async.
parent 95ba4b55
...@@ -1719,18 +1719,10 @@ void default_poll_event( struct fd *fd, int event ) ...@@ -1719,18 +1719,10 @@ void default_poll_event( struct fd *fd, int event )
wake_up( fd->user, 0 ); wake_up( fd->user, 0 );
} }
void fd_queue_async_timeout( struct fd *fd, const async_data_t *data, int type, int count, int fd_queue_async_timeout( struct fd *fd, const async_data_t *data, int type, int count,
const struct timeval *timeout ) const struct timeval *timeout )
{ {
struct list *queue; 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) switch (type)
{ {
...@@ -1745,17 +1737,18 @@ void fd_queue_async_timeout( struct fd *fd, const async_data_t *data, int type, ...@@ -1745,17 +1737,18 @@ void fd_queue_async_timeout( struct fd *fd, const async_data_t *data, int type,
break; break;
default: default:
set_error( STATUS_INVALID_PARAMETER ); 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 ); set_error( STATUS_PENDING );
/* Check if the new pending request can be served immediately */ if (!fd->inode)
events = check_fd_events( fd, fd->fd_ops->get_poll_events( fd ) ); set_fd_events( fd, fd->fd_ops->get_poll_events( fd ) );
if (events) fd->fd_ops->poll_event( fd, events ); 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 ) 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 ) ...@@ -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 ) 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 ); fd_queue_async_timeout( fd, data, type, count, NULL );
} }
......
...@@ -68,8 +68,8 @@ extern void default_fd_remove_queue( struct object *obj, struct wait_queue_entry ...@@ -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_signaled( struct object *obj, struct thread *thread );
extern int default_fd_get_poll_events( struct fd *fd ); extern int default_fd_get_poll_events( struct fd *fd );
extern void default_poll_event( struct fd *fd, int event ); 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, extern int fd_queue_async_timeout( struct fd *fd, const async_data_t *data, int type,
int count, const struct timeval *timeout ); 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_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 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_queue_async( struct fd *fd, const async_data_t *data, int type, int count );
......
...@@ -302,7 +302,7 @@ static void mailslot_queue_async( struct fd *fd, const async_data_t *data, int t ...@@ -302,7 +302,7 @@ static void mailslot_queue_async( struct fd *fd, const async_data_t *data, int t
if (mailslot->read_timeout != -1) if (mailslot->read_timeout != -1)
{ {
struct timeval when = current_time; 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 ); fd_queue_async_timeout( fd, data, type, count, &when );
} }
else fd_queue_async_timeout( fd, data, type, count, NULL ); else fd_queue_async_timeout( fd, data, type, count, NULL );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment