[*] Improved disconnect reason reporting: HasErrorCode under the NT network async stream object

This commit is contained in:
Reece Wilson 2023-04-26 20:32:25 +01:00
parent 4b79aa902b
commit efadd964be
3 changed files with 21 additions and 2 deletions

View File

@ -451,13 +451,25 @@ namespace Aurora::IO::Net
{
if (this->error_.netError == ENetworkError::kEnumInvalid)
{
// Note: some interfaces will now have a `HasErrorCode` that reports non-fatal errors
// This should be useful for reporting the disconnect reason when otherwise filtered as not-an-error
if (this->socketChannel_.inputChannel.pNetReadTransaction &&
this->socketChannel_.inputChannel.pNetReadTransaction->Failed())
#if defined(AURORA_IS_MODERNNT_DERIVED)
AuStaticCast<NtAsyncNetworkTransaction>(this->socketChannel_.inputChannel.pNetReadTransaction)->HasErrorCode()
#else
this->socketChannel_.inputChannel.pNetReadTransaction->Failed()
#endif
)
{
NetError_SetOsError(this->error_, this->socketChannel_.inputChannel.pNetReadTransaction->GetOSErrorCode());
}
else if (this->socketChannel_.outputChannel.pNetWriteTransaction_ &&
this->socketChannel_.outputChannel.pNetWriteTransaction_->Failed())
#if defined(AURORA_IS_MODERNNT_DERIVED)
AuStaticCast<NtAsyncNetworkTransaction>(this->socketChannel_.outputChannel.pNetWriteTransaction_)->HasErrorCode()
#else
this->socketChannel_.outputChannel.pNetWriteTransaction_->Failed()
#endif
)
{
NetError_SetOsError(this->error_, this->socketChannel_.outputChannel.pNetWriteTransaction_->GetOSErrorCode());
}

View File

@ -343,6 +343,12 @@ namespace Aurora::IO::Net
this->dwOsErrorCode != WSAEDISCON;
}
bool NtAsyncNetworkTransaction::HasErrorCode()
{
return this->bHasFailed &&
this->dwOsErrorCode != ERROR_HANDLE_EOF;
}
AuUInt NtAsyncNetworkTransaction::GetOSErrorCode()
{
return this->dwOsErrorCode;

View File

@ -29,6 +29,7 @@ namespace Aurora::IO::Net
bool CompleteEx(AuUInt completeRoutine);
bool Failed() override;
bool HasErrorCode();
AuUInt GetOSErrorCode() override;
AuUInt32 GetLastPacketLength() override;