[*] Linux IPC reliability: finally got around to closing #48
This commit is contained in:
parent
f2339bb0a9
commit
a4f6db7ec9
@ -60,7 +60,40 @@ namespace Aurora::IO::IPC
|
|||||||
|
|
||||||
void IPCPipeImpl::DrainOtherFd()
|
void IPCPipeImpl::DrainOtherFd()
|
||||||
{
|
{
|
||||||
// TODO (Reece): urgent
|
#if defined(FIONREAD)
|
||||||
|
|
||||||
|
int available {};
|
||||||
|
if (::ioctl(fds[1], FIONREAD, &available) < 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!available)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuByteBuffer temp(available);
|
||||||
|
SysAssert(temp);
|
||||||
|
|
||||||
|
AuUInt uCounter {};
|
||||||
|
while (this->ReadEx({temp, uCounter}, true, false))
|
||||||
|
{
|
||||||
|
temp.writePtr = temp.readPtr = temp.base;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
AuByteBuffer temp(4096 * 10);
|
||||||
|
SysAssert(temp);
|
||||||
|
|
||||||
|
AuUInt uCounter {};
|
||||||
|
while (this->ReadEx({temp, uCounter}, true, false))
|
||||||
|
{
|
||||||
|
temp.writePtr = temp.readPtr = temp.base;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
AuUInt IPCPipeImpl::GetPreemptFd()
|
AuUInt IPCPipeImpl::GetPreemptFd()
|
||||||
@ -77,8 +110,7 @@ namespace Aurora::IO::IPC
|
|||||||
|
|
||||||
#if defined(FIONREAD)
|
#if defined(FIONREAD)
|
||||||
int available {};
|
int available {};
|
||||||
int res = ::ioctl(fds[0], FIONREAD, &available) ;
|
if (::ioctl(fds[0], FIONREAD, &available) < 0)
|
||||||
if (res< 0)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -162,7 +194,12 @@ namespace Aurora::IO::IPC
|
|||||||
|
|
||||||
bool IPCPipeImpl::Read(const Memory::MemoryViewStreamWrite &write, bool nonblock)
|
bool IPCPipeImpl::Read(const Memory::MemoryViewStreamWrite &write, bool nonblock)
|
||||||
{
|
{
|
||||||
auto handle = fds[0];
|
return this->ReadEx(write, nonblock, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IPCPipeImpl::ReadEx(const Memory::MemoryViewStreamWrite &write, bool nonblock, bool bSide)
|
||||||
|
{
|
||||||
|
auto handle = bSide ? fds[0] : fds[1];
|
||||||
auto control = ::fcntl(handle, F_GETFL);
|
auto control = ::fcntl(handle, F_GETFL);
|
||||||
auto ref = control;
|
auto ref = control;
|
||||||
|
|
||||||
|
@ -62,6 +62,8 @@ namespace Aurora::IO::IPC
|
|||||||
virtual bool Write(const Memory::MemoryViewStreamRead &read) override;
|
virtual bool Write(const Memory::MemoryViewStreamRead &read) override;
|
||||||
virtual AuString ExportToString() override;
|
virtual AuString ExportToString() override;
|
||||||
|
|
||||||
|
bool ReadEx(const Memory::MemoryViewStreamWrite &write, bool nonblock, bool bSide);
|
||||||
|
|
||||||
bool IsSignaled() override;
|
bool IsSignaled() override;
|
||||||
bool WaitOn(AuUInt32 timeout) override;
|
bool WaitOn(AuUInt32 timeout) override;
|
||||||
Loop::ELoopSource GetType() override;
|
Loop::ELoopSource GetType() override;
|
||||||
|
Loading…
Reference in New Issue
Block a user