diff --git a/Include/Aurora/IO/Protocol/IProtocolStack.hpp b/Include/Aurora/IO/Protocol/IProtocolStack.hpp index db9e1b15..d4b38d0b 100644 --- a/Include/Aurora/IO/Protocol/IProtocolStack.hpp +++ b/Include/Aurora/IO/Protocol/IProtocolStack.hpp @@ -80,8 +80,9 @@ namespace Aurora::IO::Protocol /** * @brief Sends one tick down the protocol stack, regardless of how much data is written into the * next piece/interceptor, and regardless of if another read tick is required. + * @return The error state of the top-most interceptor */ - virtual void DoTick() = 0; + virtual bool DoTick() = 0; /** * @brief @@ -101,5 +102,5 @@ namespace Aurora::IO::Protocol * @param pWork * @return */ - AUKN_SYM AuSPtr NewProtocolStackFromPipe(const AuSPtr &pWork, bool bAutoTick = true); + AUKN_SYM AuSPtr NewProtocolStackFromPipe(const AuSPtr &pWork, bool bAutoTick = true, bool bKillPipeOnFirstRootLevelFalse = true); } \ No newline at end of file diff --git a/Source/IO/Protocol/AuProtocolStack.cpp b/Source/IO/Protocol/AuProtocolStack.cpp index 7e52dc6f..d4186331 100644 --- a/Source/IO/Protocol/AuProtocolStack.cpp +++ b/Source/IO/Protocol/AuProtocolStack.cpp @@ -441,19 +441,29 @@ namespace Aurora::IO::Protocol return AuSPtr(this->pTopPiece, &this->pTopPiece->outputBuffer); } - void ProtocolStack::DoTick() + bool ProtocolStack::DoTick() { if (!this->pSourceBufer) { - return; + return false; } if (!this->pBottomPiece) { - return; + return false; } - this->DoTick(this->pSourceBufer, {}); + if (!this->DoTick(this->pSourceBufer, {})) + { + if (auto pStack = AuTryLockMemoryType(this->pPipeWork)) + { + pStack->TerminateOnThread(true); + } + + return false; + } + + return true; } bool ProtocolStack::DoTick(const AuSPtr &pRead, const AuSPtr &pPiece) @@ -585,7 +595,7 @@ namespace Aurora::IO::Protocol return pStack; } - AUKN_SYM AuSPtr NewProtocolStackFromPipe(const AuSPtr &pWork, bool bAutoTick) + AUKN_SYM AuSPtr NewProtocolStackFromPipe(const AuSPtr &pWork, bool bAutoTick, bool bKillPipeOnFirstRootLevelFalse) { if (!pWork) { @@ -602,6 +612,8 @@ namespace Aurora::IO::Protocol auto pWorkEx = AuStaticCast(pWork); + pStack->pPipeWork = pWorkEx; + if (bAutoTick) { if (pWorkEx->pProtocolStack) diff --git a/Source/IO/Protocol/AuProtocolStack.hpp b/Source/IO/Protocol/AuProtocolStack.hpp index 14cce095..96153ca7 100644 --- a/Source/IO/Protocol/AuProtocolStack.hpp +++ b/Source/IO/Protocol/AuProtocolStack.hpp @@ -7,6 +7,8 @@ ***/ #pragma once +#include "../AuIOPipeProcessor.hpp" + namespace Aurora::IO::Protocol { struct ProtocolPiece; @@ -15,7 +17,7 @@ namespace Aurora::IO::Protocol { ~ProtocolStack(); - void DoTick() override; + bool DoTick() override; bool DoTick(const AuSPtr &read, const AuSPtr &pPiece); AuSPtr AppendInterceptor(const AuSPtr &pInterceptor, AuUInt uOutputBufferSize) override; @@ -46,5 +48,7 @@ namespace Aurora::IO::Protocol AuSPtr pTopPiece; bool bWrittenEnd {}; + + AuWPtr pPipeWork; }; } \ No newline at end of file