[*] Passive crinkling of today : Async.NT.cpp can now be aborted. Will port identical behavior to Linux.
This commit is contained in:
parent
bf6f13095c
commit
250d3fd11e
@ -293,11 +293,23 @@ namespace Aurora::IO::FS
|
||||
|
||||
bool NtAsyncFileTransaction::StartRead(AuUInt64 offset, const AuSPtr<AuMemoryViewWrite> &memoryView)
|
||||
{
|
||||
if (this->isIrredeemable_)
|
||||
{
|
||||
SysPushErrorIO("Transaction was signaled to be destroyed to reset mid synchronizable operation. You can no longer use this stream object");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IDontWannaUsePorts())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!memoryView)
|
||||
{
|
||||
SysPushErrorArg();
|
||||
return {};
|
||||
}
|
||||
|
||||
this->latch_ = false;
|
||||
::ResetEvent(this->event_);
|
||||
|
||||
@ -316,11 +328,23 @@ namespace Aurora::IO::FS
|
||||
|
||||
bool NtAsyncFileTransaction::StartWrite(AuUInt64 offset, const AuSPtr<AuMemoryViewRead> &memoryView)
|
||||
{
|
||||
if (this->isIrredeemable_)
|
||||
{
|
||||
SysPushErrorIO("Transaction was signaled to be destroyed to reset mid synchronizable operation. You can no longer use this stream object");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IDontWannaUsePorts())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!memoryView)
|
||||
{
|
||||
SysPushErrorArg();
|
||||
return {};
|
||||
}
|
||||
|
||||
this->latch_ = false;
|
||||
::ResetEvent(this->event_);
|
||||
|
||||
@ -345,24 +369,38 @@ namespace Aurora::IO::FS
|
||||
}
|
||||
|
||||
auto memoryHold = this->memoryHold_;
|
||||
this->memoryHold_.reset();
|
||||
|
||||
if (this->sub_)
|
||||
{
|
||||
this->sub_->OnAsyncFileOpFinished(this->lastAbstractOffset_, read);
|
||||
}
|
||||
|
||||
this->memoryHold_.reset();
|
||||
}
|
||||
|
||||
void NtAsyncFileTransaction::Reset()
|
||||
{
|
||||
::ResetEvent(this->event_);
|
||||
this->hasFailed = false;
|
||||
this->lastAbstractStat_ = 0; // do not use latch
|
||||
if (this->memoryHold_)
|
||||
{
|
||||
this->isIrredeemable_ = true;
|
||||
this->hasFailed = true;
|
||||
::CancelIoEx(this->handle_->handle, &this->overlap_);
|
||||
::SetEvent(this->event_);
|
||||
this->osErrorCode = ERROR_ABANDONED_WAIT_0;
|
||||
}
|
||||
else
|
||||
{
|
||||
::ResetEvent(this->event_);
|
||||
this->hasFailed = false;
|
||||
}
|
||||
|
||||
this->memoryHold_.reset();
|
||||
this->lastAbstractStat_ = 0;
|
||||
}
|
||||
|
||||
bool NtAsyncFileTransaction::Failed()
|
||||
{
|
||||
return this->hasFailed && GetOSErrorCode() != ERROR_BROKEN_PIPE;
|
||||
return this->hasFailed && this->osErrorCode != ERROR_BROKEN_PIPE;
|
||||
}
|
||||
|
||||
AuUInt NtAsyncFileTransaction::GetOSErrorCode()
|
||||
@ -374,6 +412,12 @@ namespace Aurora::IO::FS
|
||||
{
|
||||
DWORD read {};
|
||||
|
||||
if (this->isIrredeemable_)
|
||||
{
|
||||
::ResetEvent(this->event_);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (GetOSErrorCode() == ERROR_BROKEN_PIPE)
|
||||
{
|
||||
if (!completeRoutine)
|
||||
@ -396,11 +440,6 @@ namespace Aurora::IO::FS
|
||||
return false;
|
||||
}
|
||||
|
||||
//if (this->latch_)
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
|
||||
if ((this->hasFailed) ||
|
||||
::GetOverlappedResult(this->handle_->handle, &this->overlap_, &read, false))
|
||||
{
|
||||
|
@ -52,6 +52,8 @@ namespace Aurora::IO::FS
|
||||
bool StartRead(AuUInt64 offset, const AuSPtr<AuMemoryViewWrite> &memoryView) override;
|
||||
bool StartWrite(AuUInt64 offset, const AuSPtr<AuMemoryViewRead> &memoryView) override;
|
||||
|
||||
bool isIrredeemable_ {};
|
||||
|
||||
bool Complete() override;
|
||||
|
||||
bool CompleteEx(bool completeRoutine);
|
||||
|
Loading…
Reference in New Issue
Block a user