[*] Mucho Sanchez
This commit is contained in:
parent
3d859a319e
commit
f5a8d875d8
@ -183,7 +183,7 @@ namespace Aurora::IO::FS
|
||||
|
||||
bool NtAsyncFileTransaction::StartRead(AuUInt64 offset, void *buffer, AuUInt32 length)
|
||||
{
|
||||
if (std::exchange(this->latch_, {}))
|
||||
if (std::exchange(this->pin_, AuSharedFromThis()))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
@ -191,14 +191,13 @@ namespace Aurora::IO::FS
|
||||
this->lastAbstractOffset_ = offset;
|
||||
this->overlap_.Offset = offset & 0xFFFFFFFF;
|
||||
this->overlap_.OffsetHigh = (offset >> 32) & 0xFFFFFFFF;
|
||||
this->pin_ = AU_SHARED_FROM_THIS;
|
||||
auto ret = ::ReadFileEx(this->handle_->handle, buffer, length, &overlap_, GenericCompletionRoutine);
|
||||
return TranslateNtStatus(this, ret);
|
||||
}
|
||||
|
||||
bool NtAsyncFileTransaction::StartWrite(AuUInt64 offset, const void *buffer, AuUInt32 length)
|
||||
{
|
||||
if (std::exchange(this->latch_, {}))
|
||||
if (std::exchange(this->pin_, AuSharedFromThis()))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
@ -206,7 +205,6 @@ namespace Aurora::IO::FS
|
||||
this->lastAbstractOffset_ = offset;
|
||||
this->overlap_.Offset = offset & 0xFFFFFFFF;
|
||||
this->overlap_.OffsetHigh = (offset >> 32) & 0xFFFFFFFF;
|
||||
this->pin_ = AU_SHARED_FROM_THIS;
|
||||
auto ret = ::WriteFileEx(this->handle_->handle, buffer, length, &overlap_, GenericCompletionRoutine);
|
||||
return TranslateNtStatus(this, ret);
|
||||
}
|
||||
@ -217,16 +215,15 @@ namespace Aurora::IO::FS
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto hold = std::exchange(this->pin_, {}); // this has side effects
|
||||
|
||||
if (this->sub_)
|
||||
if (hold->sub_)
|
||||
{
|
||||
DWORD read {};
|
||||
GetOverlappedResult(this->handle_->handle, &this->overlap_, &read, false);
|
||||
this->sub_->OnAsyncFileOpFinished(this->lastAbstractOffset_, read);
|
||||
GetOverlappedResult(hold->handle_->handle, &hold->overlap_, &read, false);
|
||||
hold->sub_->OnAsyncFileOpFinished(hold->lastAbstractOffset_, read);
|
||||
}
|
||||
|
||||
// TODO: test for write after free
|
||||
std::exchange(this->pin_, {});
|
||||
}
|
||||
|
||||
bool NtAsyncFileTransaction::Complete()
|
||||
|
Loading…
Reference in New Issue
Block a user