wine and asyncronous file i/o

Martin Wilck Martin.Wilck at
Tue Nov 26 04:52:11 CST 2002

Am Die, 2002-11-26 um 10.46 schrieb martin-fuchs at
> Hi Martin,
> > Is it correct to say, then, that it is broken behavior by your app to
> > not handle ERROR_HANDLE_EOF correctly, and that it "runs on Windows"
> > only if the files you're accessing are on a local disk?
> > 
> > I'm asking because this seems to be one of the rare cases where fixing
> > the app rather than fixing Wine may be the right thing to do.
> No, my library handles both cases very well. It does this, because in the
> case of network files the file has been read already completely before the last
> ReadFileEx() call returns the error code. So there's no problem. My get()
> function returns EOF and so the application leaves it read loop.

OK. So you're saying that EOF is only passed to the completion function
when there is nothing more to read. 

Would the patch below satisfy your needs? It will call the completion
function with SUCCESS if any data was read (case (b)) and with EOF
otherwise. Thinking about it, this is also consistent with the EOF
conditions I've seen elsewhere (and my previous attempt wasn't:-().

This does still not fix the fact that ReadFileEx() doesn't detect EOF
right away. I hope that is ok - I would really like to postpone the
error handling of ReadFileEx() to the async handler unless it really
breaks stuff. Inserting such code in ReadFileEx (andf ReadFile()?) would
be a lot of hassle and possibly break IO on non-regular files.


diff -u -r1.170 file.c
--- files/file.c	21 Nov 2002 03:45:03 -0000	1.170
+++ files/file.c	26 Nov 2002 10:34:21 -0000
@@ -152,7 +152,7 @@
     async_fileio *ovp = (async_fileio*) data;
     TRACE ("data: %p\n", ovp);
-    ovp->completion_func( ovp->lpOverlapped->Internal,
+    ovp->completion_func( RtlNtStatusToDosError ( ovp->lpOverlapped->Internal ),
                           ovp->lpOverlapped );
@@ -1697,6 +1705,11 @@
         r = FILE_GetNtStatus ();
         goto async_end;
+    else if ( result == 0 )
+    {
+        r = ( lpOverlapped->InternalHigh ? STATUS_SUCCESS : 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);

Martin Wilck                Phone: +49 5251 8 15113
Fujitsu Siemens Computers   Fax:   +49 5251 8 20409
Heinz-Nixdorf-Ring 1	    mailto:Martin.Wilck at
D-33106 Paderborn 

More information about the wine-devel mailing list