[*] More IO bug fixes; a double free, statement that should be uncommented, and wrong IO handle under Async.NT.cpp read

This commit is contained in:
Reece Wilson 2022-07-04 23:41:29 +01:00
parent ee07505952
commit c0ee48435c
3 changed files with 16 additions and 8 deletions

View File

@ -18,7 +18,7 @@ namespace Aurora::IO::FS
{
struct NtAsyncFileTransactionLoopSource : AuLoop::LSHandle
{
NtAsyncFileTransactionLoopSource(AuSPtr<NtAsyncFileTransaction> that) : caller_(that), Loop::LSHandle(AuUInt(that->GetFileHandle()->handle))
NtAsyncFileTransactionLoopSource(AuSPtr<NtAsyncFileTransaction> that) : caller_(that), Loop::LSHandle(AuUInt(that->event_))
{}
virtual bool IsSignaled() override;
@ -273,6 +273,7 @@ namespace Aurora::IO::FS
hold->lastAbstractStat_ = 0;
hold->CompleteEx(dwNumberOfBytesTransfered);
hold->memoryHold_.reset();
}
bool NtAsyncFileTransaction::IDontWannaUsePorts()
@ -379,14 +380,11 @@ namespace Aurora::IO::FS
this->lastBytes = read;
auto memoryHold = this->memoryHold_;
if (this->sub_)
{
this->sub_->OnAsyncFileOpFinished(this->lastAbstractOffset_, read);
}
this->memoryHold_.reset();
}
void NtAsyncFileTransaction::Reset()
@ -411,7 +409,7 @@ namespace Aurora::IO::FS
bool NtAsyncFileTransaction::Failed()
{
return this->hasFailed && this->osErrorCode != ERROR_BROKEN_PIPE;
return this->hasFailed;
}
AuUInt NtAsyncFileTransaction::GetOSErrorCode()

View File

@ -34,6 +34,7 @@ namespace Aurora::IO
~AsyncStreamMemory();
bool IsValid();
bool owned {};
AuSPtr<AuMemoryViewWrite> pin;
AuUInt streamIndex {};
// todo shared
@ -116,12 +117,12 @@ namespace Aurora::IO
AsyncStreamMemory::AsyncStreamMemory(AuUInt length) : AuMemoryViewWrite(AuMemory::ZAlloc<AuUInt8*>(length), length)
{
this->owned = true;
}
AsyncStreamMemory::~AsyncStreamMemory()
{
if (this->ptr)
if (this->ptr && this->owned)
{
AuMemory::Free(this->ptr);
this->ptr = nullptr;

View File

@ -328,7 +328,7 @@ namespace Aurora::IO
try
{
AuUInt canBuffer = this->buffer_.RemainingWrite();
//canBuffer = AuMin(canBuffer, AuUInt((this->buffer_.length + this->buffer_.base) - this->buffer_.writePtr));
canBuffer = AuMin(canBuffer, AuUInt((this->buffer_.length + this->buffer_.base) - this->buffer_.writePtr));
this->nextWriteAsync_ = AuMemoryViewWrite(this->buffer_.writePtr, canBuffer);
@ -373,7 +373,16 @@ namespace Aurora::IO
do
{
AuUInt canRead = this->buffer_.RemainingBytes();
if (!canRead)
{
break;
}
canRead = AuMin<AuUInt>(canRead, (this->buffer_.length + this->buffer_.base) - this->buffer_.readPtr);
if (!canRead)
{
continue;
}
try
{