Hi again!  ;-)

After investigating the problem a bit more, I found a better solution:
The completition function should NOT be called with STATUS_END_OF_FILE.
Instead ReadFileEx() should report the error, if there's no more to read.

This patch works better for me, although I don't think, it is a really clean 
solution, do you? And i'm not sure, if it will work with something other than 
regular files.


Index: file.c
===================================================================
RCS file: /home/wine/wine/files/file.c,v
retrieving revision 1.170
diff -u -r1.170 file.c
--- file.c      21 Nov 2002 03:45:03 -0000      1.170
+++ file.c      23 Nov 2002 10:49:24 -0000
@@ -152,9 +152,15 @@
     async_fileio *ovp = (async_fileio*) data;
     TRACE ("data: %p\n", ovp);
 
-    ovp->completion_func( ovp->lpOverlapped->Internal,
-                          ovp->lpOverlapped->InternalHigh,
-                          ovp->lpOverlapped );
+       if (ovp->lpOverlapped->Internal == STATUS_END_OF_FILE) {
+        ovp->completion_func( 0,
+                              ovp->lpOverlapped->InternalHigh,
+                              ovp->lpOverlapped );
+       } else {
+        ovp->completion_func( ovp->lpOverlapped->Internal,
+                              ovp->lpOverlapped->InternalHigh,
+                              ovp->lpOverlapped );
+    }
 
     fileio_async_cleanup ( &ovp->async );
 }
@@ -1697,6 +1703,11 @@
         r = FILE_GetNtStatus ();
         goto async_end;
     }
+       else if (result == 0)
+       {
+               r = STATUS_END_OF_FILE;
+               goto async_end;
+       }
 
     lpOverlapped->InternalHigh += result;
     TRACE("read %d more bytes %ld/%d so 
far\n",result,lpOverlapped->InternalHigh,fileio->count);
@@ -1731,6 +1742,12 @@
     {
         SetLastError(ERROR_INVALID_PARAMETER);
         return FALSE;
+    }
+
+    if (overlapped->Internal == STATUS_END_OF_FILE)
+    {
+               SetLastError(overlapped->Internal);
+               return FALSE;
     }
 
     fd = FILE_GetUnixHandleType ( hFile, GENERIC_READ, &type, &flags);


-- 
Martin Fuchs
[EMAIL PROTECTED]

Reply via email to