[*] Harden 1920f5a8
against deadlocks under neverending pipe conditions
This commit is contained in:
parent
1920f5a8d5
commit
1f143ae981
@ -13,5 +13,9 @@ namespace Aurora::IO::CompletionGroup
|
||||
{
|
||||
virtual bool HasCompletedForGCWI() = 0;
|
||||
virtual void CleanupForGCWI() = 0;
|
||||
inline virtual bool HasNonTrivialCleanup()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
@ -47,12 +47,17 @@ namespace Aurora::IO::Async
|
||||
|
||||
bool APCLessWaitable::HasCompletedForGCWI()
|
||||
{
|
||||
this->CheckLocal();
|
||||
return this->bHasFinished;
|
||||
}
|
||||
|
||||
bool APCLessWaitable::HasNonTrivialCleanup()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void APCLessWaitable::CleanupForGCWI()
|
||||
{
|
||||
this->CheckLocal();
|
||||
AuResetMember(this->pCompletionGroup);
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ namespace Aurora::IO::Async
|
||||
|
||||
virtual bool HasCompletedForGCWI() override;
|
||||
virtual void CleanupForGCWI() override;
|
||||
virtual bool HasNonTrivialCleanup() override;
|
||||
|
||||
bool HasBeenSignaled();
|
||||
|
||||
|
@ -65,7 +65,7 @@ namespace Aurora::IO::CompletionGroup
|
||||
|
||||
void CompletionGroup::DoIOTick(bool bManual)
|
||||
{
|
||||
AuList<AuSPtr<ICompletionGroupWorkItem>> removedItems;
|
||||
AuList<AuPair<AuSPtr<ICompletionGroupWorkItem>, bool>> removedItems;
|
||||
|
||||
{
|
||||
AU_DEBUG_MEMCRUNCH;
|
||||
@ -82,11 +82,19 @@ namespace Aurora::IO::CompletionGroup
|
||||
|
||||
this->uTriggered++;
|
||||
|
||||
that->CleanupForGCWI();
|
||||
|
||||
if (this->pCallbacks)
|
||||
if (that->HasNonTrivialCleanup())
|
||||
{
|
||||
removedItems.push_back(that);
|
||||
removedItems.push_back(AuMakePair(that, true));
|
||||
}
|
||||
else if (this->pCallbacks)
|
||||
{
|
||||
removedItems.push_back(AuMakePair(that, false));
|
||||
that->CleanupForGCWI();
|
||||
}
|
||||
else
|
||||
{
|
||||
that->CleanupForGCWI();
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -95,10 +103,10 @@ namespace Aurora::IO::CompletionGroup
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (auto pCallbacks = this->pCallbacks)
|
||||
|
||||
for (const auto &[pRemoved, bNonTrivial] : removedItems)
|
||||
{
|
||||
for (const auto &pRemoved : removedItems)
|
||||
if (auto pCallbacks = this->pCallbacks)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -109,6 +117,11 @@ namespace Aurora::IO::CompletionGroup
|
||||
SysPushErrorCatch();
|
||||
}
|
||||
}
|
||||
|
||||
if (bNonTrivial)
|
||||
{
|
||||
pRemoved->CleanupForGCWI();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user