0
程序运行良好几分钟,然后ReadFile开始失败,错误代码为ERROR_WORKING_SET_QUOTA。调用ReadFile返回ERROR_WORKING_SET_QUOTA
我使用的ReadFile重叠的I/O,像这样:
while (continueReading)
{
BOOL bSuccess = ReadFile(deviceHandle, pReadBuf, length,
&bytesRead, readOverlappedPtr);
waitVal = WaitForMultipleObjects(
(sizeof(eventsToWaitFor)/sizeof(eventsToWaitFor[0])),
eventsToWaitFor, FALSE, INFINITE);
if (waitVal == WAIT_OBJECT_0) {
// do stuff
} else if (waitVal == WAIT_OBJECT_0 + 1) {
// do stuff
} else if (waitVal == WAIT_OBJECT_0 + 2) {
// complete the read
bSuccess = GetOverlappedResult(deviceHandle, &readOverlapped,
&bytesRead, FALSE);
if (!bSuccess) {
errorCode = GetLastError();
printf("ReadFile error=%d\n", errorCode);
}
}
}
为什么会出现这个错误?
更接近。但实际上验证ReadFile返回FALSE并且GetLastError()返回ERROR_IO_PENDING *非常重要。当数据从文件系统缓存中传出时,读取文件通常会立即完成。 – 2010-08-09 18:20:02
谢谢,更新以纳入您的建议。 – 2010-08-10 13:01:08