[*] Fixup Linux io timeouts (mixed ms/ns)

This commit is contained in:
Reece Wilson 2024-01-02 07:41:23 +00:00
parent d199b52c0f
commit 81093fa2cd

View File

@ -506,14 +506,14 @@ namespace Aurora::IO::UNIX
return false;
}
AuInt64 iStartTime {};
AuInt64 iTargetTime {};
AuUInt64 uStartTime {};
AuUInt64 uTargetTime {};
if (timeout)
{
iStartTime = AuTime::SteadyClockMS();
iTargetTime = iStartTime + timeout;
uStartTime = AuTime::SteadyClockNS();
uTargetTime = uStartTime + AuMSToNS<AuUInt64>(timeout);
}
if (!LinuxOverlappedTrySubmitWork())
{
SysPushErrorIO();
@ -526,13 +526,13 @@ namespace Aurora::IO::UNIX
{
if (timeout)
{
auto delta = iTargetTime - AuTime::SteadyClockMS();
if (delta <= 0)
AuUInt64 uTimeNow = AuTime::SteadyClockNS();
if (uTargetTime <= uTimeNow)
{
return dwApcsSent;
return bool(dwApcsSent);
}
AuTime::ns2ts(&targetTime, delta);
AuTime::ns2ts(&targetTime, uTimeNow - uTargetTime);
}
temp = io_getevents(io->context, 1, 512, ioEvents, timeout ? &targetTime : nullptr);
@ -616,12 +616,12 @@ namespace Aurora::IO::UNIX
return epoll_wait(epfd, events, maxevents, timeout);
}
AuInt64 iStartTime {};
AuInt64 iTargetTime {};
AuUInt64 uStartTime {};
AuUInt64 uTargetTime {};
if (timeout)
{
iStartTime = AuTime::SteadyClockMS();
iTargetTime = iStartTime + timeout;
uStartTime = AuTime::SteadyClockNS();
uTargetTime = uStartTime + AuMSToNS<AuUInt64>(timeout);
}
if (!LinuxOverlappedTrySubmitWork())
@ -662,14 +662,14 @@ namespace Aurora::IO::UNIX
{
if (timeout)
{
auto delta = iTargetTime - AuTime::SteadyClockMS();
if (delta <= 0)
AuUInt64 uTimeNow = AuTime::SteadyClockNS();
if (uTargetTime <= uTimeNow)
{
errno = EINTR;
return -1;
}
AuTime::ns2ts(&targetTime, delta);
AuTime::ns2ts(&targetTime, uTimeNow - uTargetTime);
}
temp = io_getevents(io->context, 1, 512, ioEvents, timeout ? &targetTime : nullptr);
@ -777,12 +777,12 @@ namespace Aurora::IO::UNIX
return false;
}
AuInt64 iStartTime {};
AuInt64 iTargetTime {};
AuUInt64 uStartTime {};
AuUInt64 uTargetTime {};
if (timeout)
{
iStartTime = AuTime::SteadyClockMS();
iTargetTime = iStartTime + timeout;
uStartTime = AuTime::SteadyClockNS();
uTargetTime = uStartTime + AuMSToNS<AuUInt64>(timeout);
}
if (!LinuxOverlappedTrySubmitWork())
@ -837,13 +837,14 @@ namespace Aurora::IO::UNIX
{
if (timeout)
{
auto delta = iTargetTime - AuTime::SteadyClockMS();
if (delta <= 0)
AuUInt64 uTimeNow = AuTime::SteadyClockNS();
if (uTargetTime <= uTimeNow)
{
errno = EINTR;
return false;
}
AuTime::ns2ts(&targetTime, delta);
AuTime::ns2ts(&targetTime, uTimeNow - uTargetTime);
}
temp = io_getevents(io->context, 1, 512, ioEvents, timeout ? &targetTime : nullptr);