[+] IAsyncTransaction::SetBaseOffset

This commit is contained in:
Reece Wilson 2023-08-09 00:02:35 +01:00
parent aaeca44fb0
commit df6f29bf38
9 changed files with 49 additions and 6 deletions

View File

@ -71,6 +71,8 @@ namespace Aurora::IO
*/ */
virtual void Reset() = 0; virtual void Reset() = 0;
virtual void SetBaseOffset(AuUInt64 uBaseOffset) = 0;
AURT_ADD_USR_DATA; AURT_ADD_USR_DATA;
}; };
} }

View File

@ -249,6 +249,11 @@ namespace Aurora::IO::FS
return bool(this->loopSource_); return bool(this->loopSource_);
} }
void LinuxAsyncFileTransaction::SetBaseOffset(AuUInt64 uBaseOffset)
{
this->uBaseOffset = uBaseOffset;
}
bool LinuxAsyncFileTransaction::StartRead(AuUInt64 offset, const AuSPtr<AuMemoryViewWrite> &memoryView) bool LinuxAsyncFileTransaction::StartRead(AuUInt64 offset, const AuSPtr<AuMemoryViewWrite> &memoryView)
{ {
if (HasState()) if (HasState())
@ -296,6 +301,8 @@ namespace Aurora::IO::FS
return true; return true;
} }
} }
offset += this->uBaseOffset;
if (!UNIX::LinuxOverlappedSubmitRead(fd, offset, this, this->loopSource_.get(), bool(this->handle_->pIPCPipe))) if (!UNIX::LinuxOverlappedSubmitRead(fd, offset, this, this->loopSource_.get(), bool(this->handle_->pIPCPipe)))
{ {
@ -351,6 +358,8 @@ namespace Aurora::IO::FS
LIOS_Init(AuSharedFromThis()); LIOS_Init(AuSharedFromThis());
SetMemory(memoryView); SetMemory(memoryView);
offset += this->uBaseOffset;
if (!UNIX::LinuxOverlappedSubmitWrite(fd, offset, this, this->loopSource_.get())) if (!UNIX::LinuxOverlappedSubmitWrite(fd, offset, this, this->loopSource_.get()))
{ {
LIOS_SendProcess(0, true, errno); LIOS_SendProcess(0, true, errno);

View File

@ -77,11 +77,15 @@ namespace Aurora::IO::FS
void DispatchCb(); void DispatchCb();
AuSPtr<FileHandle> GetFileHandle(); AuSPtr<FileHandle> GetFileHandle();
void SetBaseOffset(AuUInt64 uBaseOffset) override;
virtual void LIOS_Process(AuUInt32 read, bool failure, int err, bool mark) override; virtual void LIOS_Process(AuUInt32 read, bool failure, int err, bool mark) override;
private: private:
AuSPtr<FileHandle> handle_; AuSPtr<FileHandle> handle_;
AuUInt32 lastAbstractOffset_ {}, lastFinishedStat_{}; AuUInt64 lastAbstractOffset_ {};
AuUInt32 lastFinishedStat_ {};
AuUInt64 uBaseOffset {};
bool latch_ {}; bool latch_ {};
bool bTxFinished_ {}; bool bTxFinished_ {};
AuSPtr<IAsyncFinishedSubscriber> sub_; AuSPtr<IAsyncFinishedSubscriber> sub_;

View File

@ -345,10 +345,13 @@ namespace Aurora::IO::FS
this->bHasFailed = false; this->bHasFailed = false;
this->dwLastAbstractStat = memoryView->length; this->dwLastAbstractStat = memoryView->length;
this->dwLastAbstractOffset = offset; this->qwLastAbstractOffset = offset;
this->dwLastBytes = 0; this->dwLastBytes = 0;
this->ResetAIO(); this->ResetAIO();
offset += this->uBaseOffset;
this->overlap.Offset = AuBitsToLower(offset); this->overlap.Offset = AuBitsToLower(offset);
this->overlap.OffsetHigh = AuBitsToHigher(offset); this->overlap.OffsetHigh = AuBitsToHigher(offset);
@ -398,9 +401,12 @@ namespace Aurora::IO::FS
this->pMemoryHold = memoryView; this->pMemoryHold = memoryView;
this->dwLastBytes = 0; this->dwLastBytes = 0;
this->dwLastAbstractStat = memoryView->length; this->dwLastAbstractStat = memoryView->length;
this->dwLastAbstractOffset = offset; this->qwLastAbstractOffset = offset;
this->ResetAIO(); this->ResetAIO();
offset += this->uBaseOffset;
this->overlap.Offset = AuBitsToLower(offset); this->overlap.Offset = AuBitsToLower(offset);
this->overlap.OffsetHigh = AuBitsToHigher(offset); this->overlap.OffsetHigh = AuBitsToHigher(offset);
auto ret = ::WriteFileEx((HANDLE)optWrite.value(), memoryView->ptr, memoryView->length, &this->overlap, FileOperationCompletion); auto ret = ::WriteFileEx((HANDLE)optWrite.value(), memoryView->ptr, memoryView->length, &this->overlap, FileOperationCompletion);
@ -421,7 +427,7 @@ namespace Aurora::IO::FS
if (this->pSub_) if (this->pSub_)
{ {
this->pSub_->OnAsyncFileOpFinished(this->dwLastAbstractOffset, read); this->pSub_->OnAsyncFileOpFinished(this->qwLastAbstractOffset, read);
} }
} }
@ -543,6 +549,11 @@ namespace Aurora::IO::FS
this->pSub_ = sub; this->pSub_ = sub;
} }
void NtAsyncFileTransaction::SetBaseOffset(AuUInt64 uBaseOffset)
{
this->uBaseOffset = uBaseOffset;
}
bool NtAsyncFileTransaction::Wait(AuUInt32 timeout) bool NtAsyncFileTransaction::Wait(AuUInt32 timeout)
{ {
if (this->bLatch) if (this->bLatch)

View File

@ -54,6 +54,8 @@ namespace Aurora::IO::FS
void SetCallback(const AuSPtr<IAsyncFinishedSubscriber> &sub) override; void SetCallback(const AuSPtr<IAsyncFinishedSubscriber> &sub) override;
void SetBaseOffset(AuUInt64 uBaseOffset) override;
bool Wait(AuUInt32 timeout) override; bool Wait(AuUInt32 timeout) override;
AuSPtr<AuLoop::ILoopSource> NewLoopSource() override; AuSPtr<AuLoop::ILoopSource> NewLoopSource() override;
@ -68,12 +70,13 @@ namespace Aurora::IO::FS
OVERLAPPED overlap {}; OVERLAPPED overlap {};
HANDLE event = INVALID_HANDLE_VALUE; HANDLE event = INVALID_HANDLE_VALUE;
AuSPtr<NtAsyncFileTransaction> pPin; AuSPtr<NtAsyncFileTransaction> pPin;
AuUInt32 dwLastAbstractStat {}, AuUInt32 dwLastAbstractStat {};
dwLastAbstractOffset {}; AuUInt64 qwLastAbstractOffset {};
bool bLatch {}; bool bLatch {};
AuUInt32 dwLastBytes {}; AuUInt32 dwLastBytes {};
AuUInt32 dwOsErrorCode {}; AuUInt32 dwOsErrorCode {};
bool bHasFailed {}; bool bHasFailed {};
AuUInt64 uBaseOffset {};
AuWPtr<Aurora::IO::IPC::IPCPipeImpl> pNtIpcPipeImpl; AuWPtr<Aurora::IO::IPC::IPCPipeImpl> pNtIpcPipeImpl;
AuSPtr<void> pMemoryHold; AuSPtr<void> pMemoryHold;

View File

@ -206,6 +206,11 @@ namespace Aurora::IO::Net
return false; return false;
} }
void LinuxAsyncNetworkTransaction::SetBaseOffset(AuUInt64 uBaseOffset)
{
}
bool LinuxAsyncNetworkTransaction::Complete() bool LinuxAsyncNetworkTransaction::Complete()
{ {
return this->bLatch; return this->bLatch;

View File

@ -42,6 +42,8 @@ namespace Aurora::IO::Net
void Reset() override; void Reset() override;
void SetBaseOffset(AuUInt64 uBaseOffset) override;
virtual void LIOS_Process(AuUInt32 read, bool failure, int err, bool mark) override; virtual void LIOS_Process(AuUInt32 read, bool failure, int err, bool mark) override;
void MakeSyncable(); void MakeSyncable();

View File

@ -387,6 +387,11 @@ namespace Aurora::IO::Net
return this->pWaitable; return this->pWaitable;
} }
void NtAsyncNetworkTransaction::SetBaseOffset(AuUInt64 uBaseOffset)
{
}
void NtAsyncNetworkTransaction::Reset() void NtAsyncNetworkTransaction::Reset()
{ {
if (this->dwLastAbstractStat) if (this->dwLastAbstractStat)

View File

@ -39,6 +39,8 @@ namespace Aurora::IO::Net
bool Wait(AuUInt32 timeout) override; bool Wait(AuUInt32 timeout) override;
AuSPtr<AuLoop::ILoopSource> NewLoopSource() override; AuSPtr<AuLoop::ILoopSource> NewLoopSource() override;
void SetBaseOffset(AuUInt64 uBaseOffset) override;
void Reset(); void Reset();
void MakeSyncable(); void MakeSyncable();