Commit 9e1fc626 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Do overlapped reads if and only if the file was opened with

FILE_FLAG_OVERLAPPED.
parent 0136b813
...@@ -1434,6 +1434,7 @@ BOOL WINAPI ReadFile( HANDLE hFile, LPVOID buffer, DWORD bytesToRead, ...@@ -1434,6 +1434,7 @@ BOOL WINAPI ReadFile( HANDLE hFile, LPVOID buffer, DWORD bytesToRead,
LPDWORD bytesRead, LPOVERLAPPED overlapped ) LPDWORD bytesRead, LPOVERLAPPED overlapped )
{ {
int unix_handle, result; int unix_handle, result;
DWORD type;
TRACE("%d %p %ld %p %p\n", hFile, buffer, bytesToRead, TRACE("%d %p %ld %p %p\n", hFile, buffer, bytesToRead,
bytesRead, overlapped ); bytesRead, overlapped );
...@@ -1441,13 +1442,21 @@ BOOL WINAPI ReadFile( HANDLE hFile, LPVOID buffer, DWORD bytesToRead, ...@@ -1441,13 +1442,21 @@ BOOL WINAPI ReadFile( HANDLE hFile, LPVOID buffer, DWORD bytesToRead,
if (bytesRead) *bytesRead = 0; /* Do this before anything else */ if (bytesRead) *bytesRead = 0; /* Do this before anything else */
if (!bytesToRead) return TRUE; if (!bytesToRead) return TRUE;
/* this will only have impact if the overlapped structure is specified */ unix_handle = FILE_GetUnixHandleType( hFile, GENERIC_READ, &type );
if ( overlapped )
{
/* see if we can read some data already (this shouldn't block) */
unix_handle = FILE_GetUnixHandle( hFile, GENERIC_READ );
if (unix_handle == -1) if (unix_handle == -1)
return FALSE; return FALSE;
switch(type)
{
case FD_TYPE_OVERLAPPED:
if(!overlapped)
{
close(unix_handle);
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
/* see if we can read some data already (this shouldn't block) */
result = read( unix_handle, buffer, bytesToRead ); result = read( unix_handle, buffer, bytesToRead );
close(unix_handle); close(unix_handle);
...@@ -1474,10 +1483,16 @@ BOOL WINAPI ReadFile( HANDLE hFile, LPVOID buffer, DWORD bytesToRead, ...@@ -1474,10 +1483,16 @@ BOOL WINAPI ReadFile( HANDLE hFile, LPVOID buffer, DWORD bytesToRead,
/* fail on return, with ERROR_IO_PENDING */ /* fail on return, with ERROR_IO_PENDING */
SetLastError(ERROR_IO_PENDING); SetLastError(ERROR_IO_PENDING);
return FALSE; return FALSE;
}
unix_handle = FILE_GetUnixHandle( hFile, GENERIC_READ ); default:
if (unix_handle == -1) return FALSE; if(overlapped)
{
close(unix_handle);
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
break;
}
/* code for synchronous reads */ /* code for synchronous reads */
while ((result = read( unix_handle, buffer, bytesToRead )) == -1) while ((result = read( unix_handle, buffer, bytesToRead )) == -1)
......
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