fix(Core/Warden): Fix buffer not being handled during interrupt. (#15258)

This commit is contained in:
AnchyDev
2023-03-10 01:31:13 +11:00
committed by GitHub
parent 4dca18652d
commit 67bbeb7d6f
3 changed files with 157 additions and 143 deletions
+5
View File
@@ -154,6 +154,11 @@ bool Warden::IsValidCheckSum(uint32 checksum, const uint8* data, const uint16 le
}
}
bool Warden::IsInitialized()
{
return _initialized;
}
union keyData
{
std::array<uint8, 20> bytes;
+1
View File
@@ -115,6 +115,7 @@ public:
virtual void RequestHash() = 0;
virtual void HandleHashResult(ByteBuffer &buff) = 0;
virtual bool IsCheckInProgress() = 0;
virtual bool IsInitialized();
virtual void ForceChecks() = 0;
virtual void RequestChecks() = 0;
virtual void HandleData(ByteBuffer &buff) = 0;
+13 -5
View File
@@ -560,8 +560,6 @@ void WardenWin::RequestChecks()
}
void WardenWin::HandleData(ByteBuffer& buff)
{
if (!_interrupted)
{
LOG_DEBUG("warden", "Handle data");
@@ -576,7 +574,12 @@ void WardenWin::HandleData(ByteBuffer& buff)
if (Length != (buff.size() - buff.rpos()))
{
buff.rfinish();
if (!_interrupted)
{
ApplyPenalty(0, "Failed size checks in HandleData");
}
return;
}
@@ -584,7 +587,12 @@ void WardenWin::HandleData(ByteBuffer& buff)
{
buff.rpos(buff.wpos());
LOG_DEBUG("warden", "CHECKSUM FAIL");
if (!_interrupted)
{
ApplyPenalty(0, "Failed checksum in HandleData");
}
return;
}
@@ -738,12 +746,12 @@ void WardenWin::HandleData(ByteBuffer& buff)
}
}
if (checkFailed > 0)
if (checkFailed > 0 && !_interrupted)
{
ApplyPenalty(checkFailed, "");
}
}
else
if (_interrupted)
{
LOG_DEBUG("warden", "Warden was interrupted by ForceChecks, ignoring results.");