[PATCH] server: Use default_fd_get_poll_events() for file objects.

Zebediah Figura z.figura12 at gmail.com
Thu Jan 21 18:16:41 CST 2021


This avoids sending the server into a busy-loop when trying to perform an
asynchronous read from a non-regular file (say, a FIFO).

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
I can provide a simple test program which reproduces that behaviour if desired.

 server/file.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/server/file.c b/server/file.c
index 2cc4a9d978c..fd8e3f96033 100644
--- a/server/file.c
+++ b/server/file.c
@@ -75,7 +75,6 @@ static struct object *file_open_file( struct object *obj, unsigned int access,
 static struct list *file_get_kernel_obj_list( struct object *obj );
 static void file_destroy( struct object *obj );
 
-static int file_get_poll_events( struct fd *fd );
 static enum server_fd_type file_get_fd_type( struct fd *fd );
 
 static const struct object_ops file_ops =
@@ -104,7 +103,7 @@ static const struct object_ops file_ops =
 
 static const struct fd_ops file_fd_ops =
 {
-    file_get_poll_events,         /* get_poll_events */
+    default_fd_get_poll_events,   /* get_poll_events */
     default_poll_event,           /* poll_event */
     file_get_fd_type,             /* get_fd_type */
     no_fd_read,                   /* read */
@@ -287,16 +286,6 @@ struct object_type *file_get_type( struct object *obj )
     return get_object_type( &str );
 }
 
-static int file_get_poll_events( struct fd *fd )
-{
-    struct file *file = get_fd_user( fd );
-    int events = 0;
-    assert( file->obj.ops == &file_ops );
-    if (file->access & FILE_UNIX_READ_ACCESS) events |= POLLIN;
-    if (file->access & FILE_UNIX_WRITE_ACCESS) events |= POLLOUT;
-    return events;
-}
-
 static enum server_fd_type file_get_fd_type( struct fd *fd )
 {
     struct file *file = get_fd_user( fd );
-- 
2.29.2




More information about the wine-devel mailing list