wineserver: don't add files that are ready to the pollfd array

Mike McCormack mike at codeweavers.com
Tue Nov 23 21:41:41 CST 2004


Currently, the wineserver can get into a busy loop if we do overlapped 
I/O on standard files.  This patch fixes the problem by only adding fds 
that are not ready (eg. select doesn't return POLLIN) to the pollfd array.

Mike


ChangeLog:
* don't add files that are ready to the pollfd array
-------------- next part --------------
Index: server/file.c
===================================================================
RCS file: /home/wine/wine/server/file.c,v
retrieving revision 1.88
diff -u -r1.88 file.c
--- server/file.c	18 Aug 2004 00:04:58 -0000	1.88
+++ server/file.c	24 Nov 2004 04:29:52 -0000
@@ -225,8 +225,17 @@
     struct file *file = get_fd_user( fd );
     int events = 0;
     assert( file->obj.ops == &file_ops );
-    if (file->access & GENERIC_READ) events |= POLLIN;
-    if (file->access & GENERIC_WRITE) events |= POLLOUT;
+    if (is_overlapped( file ))
+    {
+        if (IS_READY(file->read_q) && (file->access & GENERIC_READ)) events |= POLLIN;
+        if (IS_READY(file->write_q) && (file->access & GENERIC_WRITE)) events |= POLLOUT;
+    }
+    else
+    {
+        if (file->access & GENERIC_READ) events |= POLLIN;
+        if (file->access & GENERIC_WRITE) events |= POLLOUT;
+    }
+
     return events;
 }
 
@@ -271,6 +280,7 @@
     struct file *file = get_fd_user( fd );
     struct async *async;
     struct async_queue *q;
+    int old_events, new_events;
 
     assert( file->obj.ops == &file_ops );
 
@@ -293,6 +303,7 @@
         return;
     }
 
+    old_events = file_get_poll_events( fd );
     async = find_async ( q, current, ptr );
 
     if ( status == STATUS_PENDING )
@@ -315,7 +326,9 @@
     else if ( async ) destroy_async ( async );
     else set_error ( STATUS_INVALID_PARAMETER );
 
-    set_fd_events( fd, file_get_poll_events( fd ));
+    new_events = file_get_poll_events( fd );
+    if (old_events != new_events)
+        set_fd_events( fd, new_events);
 }
 
 static struct fd *file_get_fd( struct object *obj )


More information about the wine-patches mailing list