[*] Refine Linux threads... They were still problematic :(

This commit is contained in:
Reece Wilson 2022-08-15 03:31:35 +01:00
parent 2e5742dd2f
commit cdb10eb3c6
2 changed files with 26 additions and 25 deletions

View File

@ -141,7 +141,10 @@ namespace Aurora::Grug
void DeinitGrug()
{
gGrugsBigWorld.reset();
if (bool(gGrugsBigWorld) && gGrugsBigWorld.get() != AuThreads::GetThread())
{
gGrugsBigWorld.reset();
}
GrugFlushWrites();
GrugFlushFlushs();

View File

@ -55,7 +55,6 @@ namespace Aurora::Threading::Threads
static void HandleSigAbortThread(int a)
{
((OSThread *)HandleCurrent())->InternalKill(true);
((OSThread *)HandleCurrent())->InternalKillForceNtfy();
SysPanic("Couldn't terminate thread context");
}
@ -98,13 +97,6 @@ namespace Aurora::Threading::Threads
bool bDetached {};
bool bDetachedSuccess {};
#if defined(AURORA_IS_POSIX_DERIVED)
if (getpid() == gettid())
{
RuntimeLateClean();
}
#endif
if (this->bNotOwned)
{
return;
@ -135,11 +127,19 @@ namespace Aurora::Threading::Threads
}
else if (gRuntimeRunLevel >= 5)
{
// Application is dead
}
else
{
if (this->terminated_)
{
this->exiting_ = true;
if (WaitFor(this->terminated_.get(), 5000))
{
return;
}
}
// Kill the current OS thread instance
TeminateOSContext(false);
@ -458,6 +458,7 @@ namespace Aurora::Threading::Threads
if (setjmp(env) != 0)
{
Exit(true);
return;
}
#endif
@ -493,6 +494,7 @@ namespace Aurora::Threading::Threads
// "Safer" update
this->HookOnExit();
if (this->terminated_)
{
if (this->exitOnlyOnce_)
@ -1039,7 +1041,10 @@ namespace Aurora::Threading::Threads
{
if (this->terminated_)
{
this->exitOnlyOnce_->Unlock();
if (this->exitOnlyOnce_)
{
this->exitOnlyOnce_->Unlock();
}
this->terminated_->Set();
}
@ -1050,15 +1055,15 @@ namespace Aurora::Threading::Threads
// Great C++ ABI guys...
#if defined(AURORA_HAS_PTHREADS)
if (!AuExchange(bLongJmpOnce, true))
{
if (gettid() == getpid())
{
AuProcess::Exit(0);
return true;
}
::longjmp(env, 1);
}
else
{
}
//::pthread_exit(nullptr);
::pthread_exit(nullptr);
#endif
return true;
@ -1086,14 +1091,7 @@ namespace Aurora::Threading::Threads
if (calledFromThis)
{
if (!AuExchange(bLongJmpOnce, true))
{
::longjmp(env, 1);
}
else
{
}
::longjmp(env, 1);
::pthread_exit(nullptr);
}
else