[*] protocol stack: hardening of buffer flags

This commit is contained in:
Reece Wilson 2023-10-23 11:30:25 +01:00
parent 08c37454fe
commit dfe6b468ec
2 changed files with 16 additions and 4 deletions

View File

@ -77,7 +77,13 @@ namespace Aurora::IO::Protocol
} }
} }
return this->outputBuffer.Resize(uOutputLength); this->outputBuffer.flagNoFree = false;
auto bRet = this->outputBuffer.Resize(uOutputLength);
if (!this->uMax.has_value())
{
this->outputBuffer.flagNoFree = true;
}
return bRet;
} }
void ProtocolPiece::Remove() void ProtocolPiece::Remove()

View File

@ -120,6 +120,8 @@ namespace Aurora::IO::Protocol
return {}; return {};
} }
pNew->outputBuffer.flagNoFree = true;
// Circular ref // Circular ref
pNew->pOuputWriter = AuMakeShared<AuIO::Buffered::BlobWriter>(AuSPtr<Memory::ByteBuffer>(pNew, &pNew->outputBuffer)); pNew->pOuputWriter = AuMakeShared<AuIO::Buffered::BlobWriter>(AuSPtr<Memory::ByteBuffer>(pNew, &pNew->outputBuffer));
@ -136,7 +138,7 @@ namespace Aurora::IO::Protocol
EStreamError Write(const Memory::MemoryViewStreamRead &parameters) override EStreamError Write(const Memory::MemoryViewStreamRead &parameters) override
{ {
return pStack.lock()->DoTick(AuMakeShared<AuByteBuffer>(parameters), pParent.lock()) ? return pStack.lock()->DoTick(AuMakeSharedThrow<AuByteBuffer>(parameters), pParent.lock()) ?
EStreamError::eErrorNone : EStreamError::eErrorNone :
EStreamError::eErrorStreamInterrupted; EStreamError::eErrorStreamInterrupted;
} }
@ -254,6 +256,10 @@ namespace Aurora::IO::Protocol
pNew->uMax = uMax; pNew->uMax = uMax;
pNew->outputBuffer.flagAlwaysExpandable = pNew->outputBuffer.flagExpandable = 1; pNew->outputBuffer.flagAlwaysExpandable = pNew->outputBuffer.flagExpandable = 1;
} }
else
{
pNew->outputBuffer.flagNoFree = true;
}
pNew->uStartingSize = uOutputBufferSize; pNew->uStartingSize = uOutputBufferSize;
@ -273,7 +279,7 @@ namespace Aurora::IO::Protocol
EStreamError Write(const Memory::MemoryViewStreamRead &parameters) override EStreamError Write(const Memory::MemoryViewStreamRead &parameters) override
{ {
return pStack.lock()->DoTick(AuMakeShared<AuByteBuffer>(parameters), pParent.lock()) ? return pStack.lock()->DoTick(AuMakeSharedThrow<AuByteBuffer>(parameters), pParent.lock()) ?
EStreamError::eErrorNone : EStreamError::eErrorNone :
EStreamError::eErrorStreamInterrupted; EStreamError::eErrorStreamInterrupted;
} }
@ -384,7 +390,7 @@ namespace Aurora::IO::Protocol
EStreamError Write(const Memory::MemoryViewStreamRead &parameters) override EStreamError Write(const Memory::MemoryViewStreamRead &parameters) override
{ {
return pStack.lock()->DoTick(AuMakeShared<AuByteBuffer>(parameters), pParent.lock()) ? return pStack.lock()->DoTick(AuMakeSharedThrow<AuByteBuffer>(parameters), pParent.lock()) ?
EStreamError::eErrorNone : EStreamError::eErrorNone :
EStreamError::eErrorStreamInterrupted; EStreamError::eErrorStreamInterrupted;
} }