[*] Linux: possible regressions in 57c5515173. Fixes read while transaction is signaled loops

This commit is contained in:
Reece Wilson 2024-08-06 03:22:00 +01:00
parent 1b240143c4
commit b73c20d616
2 changed files with 55 additions and 30 deletions

View File

@ -85,6 +85,14 @@ namespace Aurora::IO::FS
return lock->Complete();
}
UNIX::LinuxOverlappedYield();
if (LSEvent::IsSignaled())
{
auto lock = caller_.lock();
return lock->Complete();
}
return false;
}

View File

@ -645,7 +645,8 @@ namespace Aurora::IO::UNIX
(void)LinuxOverlappedTrySubmitWork();
}
} while (timeout || AuExchange(bAgain, false));
}
while (timeout || AuExchange(bAgain, false));
return dwApcsSent;
}
@ -698,9 +699,18 @@ namespace Aurora::IO::UNIX
iocb * ptr = &pollSubmit;
iocb ** ptrArray = &ptr;
errno = 0;
bool bEpollTriggered {};
io_event ioEvents[1024];
AuTuple<ASubmittable *, AuUInt, bool, int> toProcess[1024] {};
int toProcessDone {};
int temp {};
bool bAgain {};
int error;
redo:
toProcessDone = 0;
bEpollTriggered = false;
do
{
error = io_submit(io->context, 1, ptrArray);
@ -715,18 +725,11 @@ namespace Aurora::IO::UNIX
{
SysPushErrorIO();
return -1;
}
bool bEpollTriggered {};
io_event ioEvents[1024];
AuTuple<ASubmittable *, AuUInt, bool, int> toProcess[1024] {};
int toProcessDone {};
int temp {};
bool bAgain {};
};
do
{
if (timeout)
if (timeout && !bAgain)
{
AuUInt64 uTimeNow = AuTime::SteadyClockNS();
if (uTargetTime <= uTimeNow)
@ -800,16 +803,12 @@ namespace Aurora::IO::UNIX
SysPanic("io_getevents() is not implemented on this architecture.");
}
}
bAgain = AuExchange(io->bPollHit, false);
if (bAgain)
{
(void)LinuxOverlappedTrySubmitWork();
}
} while ((timeout ? !bEpollTriggered : false) || AuExchange(bAgain, false));
while ((timeout ? !bEpollTriggered : false));
exit:
bAgain = false;
io_event finalEpollEvent {};
if (!bEpollTriggered)
{
@ -838,6 +837,12 @@ namespace Aurora::IO::UNIX
handle->LIOS_SendProcess(bytesTransacted, bError, errNo);
}
if ((bAgain = AuExchange(io->bPollHit, false)))
{
(void)LinuxOverlappedTrySubmitWork();
goto redo;
}
if (bEpollTriggered)
{
return epoll_wait(epfd, events, maxevents, 0);
@ -855,7 +860,16 @@ namespace Aurora::IO::UNIX
bool LinuxOverlappedWaitForOne(AuUInt32 timeout, AuUInt read, AuUInt write, bool &bReadTriggered, bool &bWriteTriggered)
{
timespec targetTime;
iocb submit {};
iocb readSubmit {};
iocb writeSubmit {};
bool bRet { true };
io_event ioEvents[1024];
AuTuple<ASubmittable *, AuUInt, bool, int> toProcess[1024] {};
int toProcessDone {};
int temp;
bool bTryAgain {};
auto io = GetTls();
bWriteTriggered = false;
@ -886,9 +900,6 @@ namespace Aurora::IO::UNIX
return false;
}
iocb submit {};
iocb readSubmit {};
iocb writeSubmit {};
AuMemset(&readSubmit, 0, sizeof(readSubmit));
AuMemset(&writeSubmit, 0, sizeof(readSubmit));
AuMemset(&submit, 0, sizeof(submit));
@ -915,6 +926,8 @@ namespace Aurora::IO::UNIX
ptrArray[iocbIdx++] = &writeSubmit;
}
redo:
toProcessDone = 0;
int error;
do
{
@ -933,14 +946,9 @@ namespace Aurora::IO::UNIX
return -1;
}
io_event ioEvents[1024];
AuTuple<ASubmittable *, AuUInt, bool, int> toProcess[1024] {};
int toProcessDone {};
int temp;
do
{
if (timeout)
if (timeout && !bTryAgain)
{
AuUInt64 uTimeNow = AuTime::SteadyClockNS();
if (uTargetTime <= uTimeNow)
@ -1025,9 +1033,12 @@ namespace Aurora::IO::UNIX
}
}
} while (timeout ? (!bReadTriggered && !bWriteTriggered) : false);
}
while (timeout ? (!bReadTriggered && !bWriteTriggered) : false);
exit:
bTryAgain = false;
for (int i = 0; i < iocbIdx; i++)
{
io_event finalEpollEvent {};
@ -1071,6 +1082,12 @@ namespace Aurora::IO::UNIX
handle->LIOS_SendProcess(bytesTransacted, bError, errNo);
}
if ((bTryAgain = AuExchange(io->bPollHit, false)))
{
(void)LinuxOverlappedTrySubmitWork();
goto redo;
}
return bRet;
}