fixed/improved GetOverlappedResult

svn path=/trunk/; revision=6806
This commit is contained in:
Gunnar Dalsnes 2003-11-27 00:57:57 +00:00
parent ebdb1b6328
commit 05dd288048

View file

@ -1,4 +1,4 @@
/* $Id: deviceio.c,v 1.12 2003/07/10 18:50:51 chorns Exp $ /* $Id: deviceio.c,v 1.13 2003/11/27 00:57:57 gdalsnes Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -139,54 +139,46 @@ DeviceIoControl(
WINBOOL WINBOOL
STDCALL STDCALL
GetOverlappedResult ( GetOverlappedResult (
HANDLE hFile, IN HANDLE hFile,
LPOVERLAPPED lpOverlapped, IN LPOVERLAPPED lpOverlapped,
LPDWORD lpNumberOfBytesTransferred, OUT LPDWORD lpNumberOfBytesTransferred,
WINBOOL bWait IN WINBOOL bWait
) )
{ {
DWORD WaitStatus; DWORD WaitStatus;
HANDLE hObject;
if (lpOverlapped == NULL) if (lpOverlapped->Internal == STATUS_PENDING)
{ {
SetLastErrorByStatus(STATUS_INVALID_PARAMETER); if (!bWait)
return FALSE; {
} /* can't use SetLastErrorByStatus(STATUS_PENDING) here,
since STATUS_PENDING translates to ERROR_IO_PENDING */
SetLastError(ERROR_IO_INCOMPLETE);
return FALSE;
}
hObject = lpOverlapped->hEvent ? lpOverlapped->hEvent : hFile;
if (lpOverlapped ->Internal == STATUS_PENDING) /* Wine delivers pending APC's while waiting, but Windows does
{ not, nor do we... */
if (lpNumberOfBytesTransferred == 0) WaitStatus = WaitForSingleObject(hObject, INFINITE);
{
SetLastErrorByStatus (STATUS_PENDING); if (WaitStatus == WAIT_FAILED)
return FALSE; {
} DPRINT("Wait failed!\n");
else if (bWait == TRUE) /* WaitForSingleObjectEx sets the last error */
{ return FALSE;
if (lpOverlapped->hEvent != NULL) }
{ }
WaitStatus = WaitForSingleObject (lpOverlapped->hEvent,
-1);
if (WaitStatus == STATUS_TIMEOUT)
{
SetLastError (ERROR_IO_INCOMPLETE);
return FALSE;
}
else
return GetOverlappedResult (hFile,
lpOverlapped,
lpNumberOfBytesTransferred,
FALSE);
}
}
}
*lpNumberOfBytesTransferred = lpOverlapped->InternalHigh; *lpNumberOfBytesTransferred = lpOverlapped->InternalHigh;
if (lpOverlapped->Internal < 0) if (!NT_SUCCESS(lpOverlapped->Internal))
{ {
SetLastErrorByStatus (lpOverlapped->Internal); SetLastErrorByStatus(lpOverlapped->Internal);
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }