Rewrite RecvStart error checking as suggested by shuffle2

This commit is contained in:
zeroZshadow 2015-08-15 16:45:44 +02:00
parent 8925b828aa
commit 84764db3b2
1 changed files with 13 additions and 9 deletions

View File

@ -304,21 +304,25 @@ bool CEXIETHERNET::RecvStart()
DWORD res = ReadFile(mHAdapter, mRecvBuffer, BBA_RECV_SIZE,
(LPDWORD)&mRecvBufferLength, &mReadOverlapped);
DWORD err = GetLastError();
if (!res && err != ERROR_IO_PENDING)
{
// error occurred
ERROR_LOG(SP1, "Failed to recieve packet with error 0x%X", err);
return false;
}
if (res)
{
// Since the read is synchronous here, complete immediately
RecvHandlePacket();
return true;
}
else
{
DWORD err = GetLastError();
if (err == ERROR_IO_PENDING)
{
return true;
}
// Unexpected error
ERROR_LOG(SP1, "Failed to recieve packet with error 0x%X", err);
return false;
}
return true;
}
void CEXIETHERNET::RecvStop()