[*] Fix IO Processor regression, circa WorkerPId_t behaviour change.

[*] Fix minor Linux SOCK_CLOEXEC issue
This commit is contained in:
Reece Wilson 2023-09-18 19:04:09 +01:00
parent 7357764cfc
commit 5ef6e0cd23
3 changed files with 30 additions and 15 deletions

View File

@ -19,7 +19,7 @@ namespace Aurora::IO
{
IOProcessor::IOProcessor(AuUInt threadId,
bool bTickOnly,
AuAsync::WorkerPId_t worker,
AuOptionalEx<AuAsync::WorkerPId_t> worker,
const AuSPtr<AuLoop::ILoopQueue> &pLoopQueue,
bool bIsNoQueue) :
mutliplexIOAndTimer(!bTickOnly),
@ -39,7 +39,9 @@ namespace Aurora::IO
bool IOProcessor::Init()
{
if (!this->ToQueue())
auto pQueue = this->ToQueue();
if (!pQueue)
{
return {};
}
@ -50,13 +52,25 @@ namespace Aurora::IO
return false;
}
if (!this->timers.Init(this, AuLoop::NewLSTimer(0)))
auto pTimer = AuLoop::NewLSTimer(0);
if (!pTimer)
{
SysPushErrorNested();
return false;
}
if (!this->timers.Init(this, pTimer))
{
SysPushErrorNested();
return false;
}
if (!pQueue->SourceAdd(this->items.cvEvent))
{
SysPushErrorNested();
return false;
}
this->ToQueue()->SourceAdd(this->items.cvEvent);
if (!this->bIsNoQueue)
{
auto pAS = AuMakeShared<AuLoop::ILoopSourceSubscriberFunctional>([pThat = AuSharedFromThis()](const AuSPtr<AuLoop::ILoopSource> &pSource) -> bool
@ -65,13 +79,13 @@ namespace Aurora::IO
return false;
});
if (!this->ToQueue()->AddCallback(this->items.cvEvent, pAS))
if (!pQueue->AddCallback(this->items.cvEvent, pAS))
{
return {};
return false;
}
}
}
this->ToQueue()->Commit();
(void)pQueue->Commit();
if (asyncWorker)
{
@ -931,7 +945,7 @@ namespace Aurora::IO
static AuSPtr<IIOProcessor> NewIOProcessorEx(bool tickOnly, const AuSPtr<AuLoop::ILoopQueue> &queue, bool bIsNoQueue)
{
auto processor = AuMakeShared<IOProcessor>(0, tickOnly, AuAsync::WorkerPId_t {}, queue, bIsNoQueue);
auto processor = AuMakeShared<IOProcessor>(0, tickOnly, AuOptionalEx<AuAsync::WorkerPId_t> {}, queue, bIsNoQueue);
if (!processor)
{
SysPushErrorMem();
@ -949,7 +963,7 @@ namespace Aurora::IO
AUKN_SYM AuSPtr<IIOProcessor> NewIOProcessor(bool tickOnly, const AuSPtr<AuLoop::ILoopQueue> &queue)
{
auto processor = AuMakeShared<IOProcessor>(0, tickOnly, AuAsync::WorkerPId_t {}, queue, false);
auto processor = AuMakeShared<IOProcessor>(0, tickOnly, AuOptionalEx<AuAsync::WorkerPId_t> {}, queue, false);
if (!processor)
{
SysPushErrorMem();
@ -969,6 +983,7 @@ namespace Aurora::IO
{
if (!id.pool)
{
SysPushErrorArg();
return {};
}

View File

@ -16,7 +16,7 @@ namespace Aurora::IO
struct IOProcessor : IIOProcessor, AuEnableSharedFromThis<IOProcessor>, AuAsync::IWorkItemHandler
{
~IOProcessor();
IOProcessor(AuUInt threadId, bool tickOnly, AuAsync::WorkerPId_t worker, const AuSPtr<AuLoop::ILoopQueue> &loop, bool bIsNoQueue);
IOProcessor(AuUInt threadId, bool tickOnly, AuOptionalEx<AuAsync::WorkerPId_t> worker, const AuSPtr<AuLoop::ILoopQueue> &loop, bool bIsNoQueue);
bool Init();

View File

@ -88,8 +88,8 @@ namespace Aurora::IO::Net
this->osHandle_ = ::socket(
IPToDomain(this->remoteEndpoint_) | SOCK_CLOEXEC,
TransportToPlatformType(this->remoteEndpoint_),
IPToDomain(this->remoteEndpoint_),
TransportToPlatformType(this->remoteEndpoint_) | SOCK_CLOEXEC,
0
);
@ -137,8 +137,8 @@ namespace Aurora::IO::Net
}
this->osHandle_ = ::socket(
IPToDomain(this->remoteEndpoint_) | SOCK_CLOEXEC,
TransportToPlatformType(this->remoteEndpoint_),
IPToDomain(this->remoteEndpoint_),
TransportToPlatformType(this->remoteEndpoint_) | SOCK_CLOEXEC,
0
);