From 673872f632473b2134e1f0c9342433df4ca1227f Mon Sep 17 00:00:00 2001 From: Reece Wilson Date: Tue, 8 Nov 2022 21:25:43 +0000 Subject: [PATCH] [*] Fix critical bug in rwlock (few commits ago. still havent updated submodules so its ok) [*] IAsyncTransaction::uStartOffset should be u64 --- Include/Aurora/IO/IOAdapterAsyncStream.hpp | 10 ++++---- Include/Aurora/IO/IOPipeRequestAIO.hpp | 2 +- Source/IO/IOAdapterAsyncStream.cpp | 28 +++++++++++----------- Source/Threading/Primitives/RWLock.cpp | 4 +--- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/Include/Aurora/IO/IOAdapterAsyncStream.hpp b/Include/Aurora/IO/IOAdapterAsyncStream.hpp index c81cdeec..bcd53680 100644 --- a/Include/Aurora/IO/IOAdapterAsyncStream.hpp +++ b/Include/Aurora/IO/IOAdapterAsyncStream.hpp @@ -30,13 +30,13 @@ namespace Aurora::IO { virtual bool SetFlushOnWrite(bool value) = 0; - virtual void ReserveBuffer(AuUInt length) = 0; + virtual void ReserveBuffer(AuUInt64 length) = 0; - virtual AuUInt GetReadOffset() = 0; - virtual AuUInt SetReadOffset(AuUInt offset) = 0; + virtual AuUInt64 GetReadOffset() = 0; + virtual AuUInt64 SetReadOffset(AuUInt64 offset) = 0; - virtual AuUInt GetWriteOffset() = 0; - virtual AuUInt SetWriteOffset(AuUInt offset) = 0; + virtual AuUInt64 GetWriteOffset() = 0; + virtual AuUInt64 SetWriteOffset(AuUInt64 offset) = 0; virtual AuSPtr ToStreamReader() = 0; virtual AuSPtr ToStreamWriter() = 0; diff --git a/Include/Aurora/IO/IOPipeRequestAIO.hpp b/Include/Aurora/IO/IOPipeRequestAIO.hpp index b95aed62..f7b988e8 100644 --- a/Include/Aurora/IO/IOPipeRequestAIO.hpp +++ b/Include/Aurora/IO/IOPipeRequestAIO.hpp @@ -14,7 +14,7 @@ namespace Aurora::IO struct IOPipeRequestAIO : IOPipeRequest { AuSPtr pAsyncTransaction; - AuUInt32 uStartOffset {}; + AuUInt64 uStartOffset {}; IOPipeCallback output; }; diff --git a/Source/IO/IOAdapterAsyncStream.cpp b/Source/IO/IOAdapterAsyncStream.cpp index 824fd694..a7c978b2 100644 --- a/Source/IO/IOAdapterAsyncStream.cpp +++ b/Source/IO/IOAdapterAsyncStream.cpp @@ -62,7 +62,7 @@ namespace Aurora::IO { AsyncStreamAdapter(); - AuSPtr AllocateNextPageCached(AuUInt length); + AuSPtr AllocateNextPageCached(AuUInt64 length); virtual AuSPtr ToStreamReader() override; virtual AuSPtr ToStreamWriter() override; @@ -78,17 +78,17 @@ namespace Aurora::IO bool SetFlushOnWrite(bool value) override; - void ReserveBuffer(AuUInt length) override; + void ReserveBuffer(AuUInt64 length) override; - AuUInt GetReadOffset() override; - AuUInt SetReadOffset(AuUInt offset) override; + AuUInt64 GetReadOffset() override; + AuUInt64 SetReadOffset(AuUInt64 offset) override; - AuUInt GetWriteOffset() override; - AuUInt SetWriteOffset(AuUInt offset) override; + AuUInt64 GetWriteOffset() override; + AuUInt64 SetWriteOffset(AuUInt64 offset) override; bool asyncActive {}; - AuUInt readOffset {}; - AuUInt writeOffset {}; + AuUInt64 readOffset {}; + AuUInt64 writeOffset {}; bool isStream {}; bool flushOnWrite {true}; @@ -139,12 +139,12 @@ namespace Aurora::IO return AuExchange(this->flushOnWrite, value); } - AuUInt AsyncStreamAdapter::GetReadOffset() + AuUInt64 AsyncStreamAdapter::GetReadOffset() { return this->readOffset; } - AuUInt AsyncStreamAdapter::SetReadOffset(AuUInt offset) + AuUInt64 AsyncStreamAdapter::SetReadOffset(AuUInt64 offset) { if (this->locked == 1) { @@ -153,7 +153,7 @@ namespace Aurora::IO return AuExchange(this->readOffset, offset); } - AuUInt AsyncStreamAdapter::GetWriteOffset() + AuUInt64 AsyncStreamAdapter::GetWriteOffset() { if (this->locked == 1) { @@ -162,7 +162,7 @@ namespace Aurora::IO return this->writeOffset; } - AuUInt AsyncStreamAdapter::SetWriteOffset(AuUInt offset) + AuUInt64 AsyncStreamAdapter::SetWriteOffset(AuUInt64 offset) { return AuExchange(this->writeOffset, offset); } @@ -183,7 +183,7 @@ namespace Aurora::IO } - AuSPtr AsyncStreamAdapter::AllocateNextPageCached(AuUInt length) + AuSPtr AsyncStreamAdapter::AllocateNextPageCached(AuUInt64 length) { if (this->lastAllocation) { @@ -637,7 +637,7 @@ namespace Aurora::IO return AuSPtr(AuSharedFromThis(), &this->source); } - void AsyncStreamAdapter::ReserveBuffer(AuUInt length) + void AsyncStreamAdapter::ReserveBuffer(AuUInt64 length) { if (!this->lastAllocation || !this->asyncActive) { diff --git a/Source/Threading/Primitives/RWLock.cpp b/Source/Threading/Primitives/RWLock.cpp index 47dce5b8..5b476d21 100644 --- a/Source/Threading/Primitives/RWLock.cpp +++ b/Source/Threading/Primitives/RWLock.cpp @@ -132,8 +132,6 @@ namespace Aurora::Threading::Primitives this->condition_->Broadcast(); continue; } - - return true; } } } @@ -177,7 +175,7 @@ namespace Aurora::Threading::Primitives return this->reentrantWriteLockHandle_ == AuThreads::GetThreadId(); } - return AuAtomicCompareExchange(&this->state_, iCurState + 1, iCurState) != iCurState; + return AuAtomicCompareExchange(&this->state_, iCurState + 1, iCurState) == iCurState; } bool RWLockImpl::TryLockWrite()