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