[+] Added Linux signal configuration and separate LinuxConfig type (LinuxConfig)
[*] Fix Linux regressions in previous NT commit
This commit is contained in:
parent
ac0981ac1b
commit
3503d0ec68
@ -389,6 +389,14 @@ namespace Aurora
|
||||
|
||||
};
|
||||
|
||||
struct LinuxConfig
|
||||
{
|
||||
bool bFIODisableBatching { false };
|
||||
bool bIOLinuxHasProcIpcPerms { false };
|
||||
AuUInt8 uSignalTerminate { 27 };
|
||||
AuUInt8 uSignalGAIOWorkerThreadDone { 28 };
|
||||
};
|
||||
|
||||
struct RuntimeStartInfo
|
||||
{
|
||||
ConsoleConfig console;
|
||||
@ -398,9 +406,8 @@ namespace Aurora
|
||||
AuAlignTo<32, FIOConfig> fio;
|
||||
AuAlignTo<64, DebugConfig> debug;
|
||||
AuAlignTo<32, ThreadingConfig> threadingConfig;
|
||||
AuAlignTo<32, LinuxConfig> linuxConfig;
|
||||
AuAlignTo<32, DummyConfig> padding;
|
||||
bool bFIODisableBatching { true };
|
||||
bool bIOLinuxHasProcIpcPerms { false };
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -51,10 +51,6 @@ namespace Aurora::IO
|
||||
struct UnixIOHandle final : AFileHandle
|
||||
{
|
||||
bool InitFromPath(HandleCreate create) override;
|
||||
|
||||
bool IsFile() override;
|
||||
bool IsTTY() override;
|
||||
bool IsPipe() override;
|
||||
};
|
||||
|
||||
bool UnixIOHandle::InitFromPath(HandleCreate create)
|
||||
@ -176,7 +172,7 @@ namespace Aurora::IO
|
||||
|
||||
AUKN_SYM bool IsHandleTTY(AuUInt uHandle)
|
||||
{
|
||||
if ((AuInt)uHandle < 0)
|
||||
if ((AuSInt)uHandle < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -188,7 +184,7 @@ namespace Aurora::IO
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if ((AuInt)uHandle < 0)
|
||||
if ((AuSInt)uHandle < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -206,7 +202,7 @@ namespace Aurora::IO
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if ((AuInt)uHandle < 0)
|
||||
if ((AuSInt)uHandle < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ namespace Aurora::IO::FS
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gRuntimeConfig.bFIODisableBatching)
|
||||
if (gRuntimeConfig.linuxConfig.bFIODisableBatching)
|
||||
{
|
||||
UNIX::SendIOBuffers();
|
||||
}
|
||||
@ -329,7 +329,7 @@ namespace Aurora::IO::FS
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gRuntimeConfig.bFIODisableBatching)
|
||||
if (gRuntimeConfig.linuxConfig.bFIODisableBatching)
|
||||
{
|
||||
UNIX::SendIOBuffers();
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
namespace Aurora::IO::Net
|
||||
{
|
||||
static const auto kMagicSignal = SIGRTMIN + 10 - 6 + 9;
|
||||
static AuList<AuWPtr<NetResolver>> tlsResolvers;
|
||||
|
||||
struct ThreadLocalCaughtCompletion : Loop::LSSignalCatcher
|
||||
@ -35,8 +34,15 @@ namespace Aurora::IO::Net
|
||||
NetResolver *pParent_;
|
||||
};
|
||||
|
||||
// this is beyond dumb and inefficient. i think glibc just creates a singular worker thread and resolves each request in a blocking manner with no mutliplexing
|
||||
// TODO: we really need to make a general purpose AuAsync IO pool and generic resolver replacer/hooking interface for net services.
|
||||
static auto GetGAIAsyncIOSignal()
|
||||
{
|
||||
return SIGUSR1 + gRuntimeConfig.linuxConfig.uSignalGAIOWorkerThreadDone;
|
||||
}
|
||||
|
||||
ThreadLocalCaughtCompletion::ThreadLocalCaughtCompletion(NetResolver *pParent) :
|
||||
LSSignalCatcher({kMagicSignal}),
|
||||
LSSignalCatcher({GetGAIAsyncIOSignal()}),
|
||||
pParent_(pParent)
|
||||
{
|
||||
handles_ = {this->handle, AuStaticCast<AuLoop::LSEvent>(this->pParent_->pEvent)->GetHandle()};
|
||||
@ -132,7 +138,7 @@ namespace Aurora::IO::Net
|
||||
|
||||
sigevent event {0};
|
||||
event.sigev_notify = SIGEV_SIGNAL;
|
||||
event.sigev_signo = kMagicSignal;
|
||||
event.sigev_signo = GetGAIAsyncIOSignal();
|
||||
//event._sigev_un._tid = gettid();
|
||||
|
||||
auto pQueue = AuMakeShared<ThreadLocalCaughtCompletion>(this);
|
||||
@ -353,6 +359,6 @@ namespace Aurora::IO::Net
|
||||
};
|
||||
|
||||
::sigemptyset(&action.sa_mask);
|
||||
::sigaction(kMagicSignal, &action, nullptr);
|
||||
::sigaction(GetGAIAsyncIOSignal(), &action, nullptr);
|
||||
}
|
||||
}
|
@ -82,7 +82,7 @@ namespace Aurora::IO::Net
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gRuntimeConfig.bFIODisableBatching)
|
||||
if (gRuntimeConfig.linuxConfig.bFIODisableBatching)
|
||||
{
|
||||
UNIX::SendIOBuffers();
|
||||
}
|
||||
@ -150,7 +150,7 @@ namespace Aurora::IO::Net
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gRuntimeConfig.bFIODisableBatching)
|
||||
if (gRuntimeConfig.linuxConfig.bFIODisableBatching)
|
||||
{
|
||||
UNIX::SendIOBuffers();
|
||||
}
|
||||
|
@ -459,7 +459,7 @@ namespace Aurora::IO::UNIX
|
||||
if ((platform.uKernelMajor > 5) ||
|
||||
((platform.uKernelMajor == 5) && (platform.uKernelMinor >= 6)))
|
||||
{
|
||||
gHasProcSyscall = gRuntimeConfig.bIOLinuxHasProcIpcPerms;
|
||||
gHasProcSyscall = gRuntimeConfig.linuxConfig.bIOLinuxHasProcIpcPerms;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -68,7 +68,6 @@ namespace Aurora::Threading::Threads
|
||||
static ThreadInfo gDummyThreadInfo;
|
||||
|
||||
#if defined(AURORA_IS_POSIX_DERIVED)
|
||||
static const auto kSignalAbort = SIGUSR1 + 69;
|
||||
|
||||
static void HandleSigAbortThread(int a)
|
||||
{
|
||||
@ -566,7 +565,7 @@ namespace Aurora::Threading::Threads
|
||||
Exit(true);
|
||||
return;
|
||||
}
|
||||
AttachSignalKiller();
|
||||
|
||||
this->bSupportsAltKill = true;
|
||||
#endif
|
||||
|
||||
@ -747,11 +746,11 @@ namespace Aurora::Threading::Threads
|
||||
#if defined(AURORA_IS_POSIX_DERIVED)
|
||||
struct sigaction action =
|
||||
{
|
||||
.sa_handler = HandleSigAbortThread
|
||||
|
||||
.sa_handler = HandleSigAbortThread,
|
||||
.sa_flags = 0
|
||||
};
|
||||
::sigemptyset(&action.sa_mask);
|
||||
::sigaction(kSignalAbort, &action, nullptr);
|
||||
::sigaction(SIGRTMIN + gRuntimeConfig.linuxConfig.uSignalTerminate, &action, nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -796,11 +795,6 @@ namespace Aurora::Threading::Threads
|
||||
SetAffinity(this->mask_);
|
||||
AffinityPrioThrottleTickAmendECores();
|
||||
UpdateName();
|
||||
|
||||
if (!this->bNotOwned)
|
||||
{
|
||||
AttachSignalKiller();
|
||||
}
|
||||
}
|
||||
|
||||
static AuHashMap<EThreadPriority, int> kNiceMap
|
||||
@ -1282,12 +1276,13 @@ namespace Aurora::Threading::Threads
|
||||
void OSThread::OSDeatach()
|
||||
{
|
||||
#if defined(AURORA_IS_POSIX_DERIVED)
|
||||
struct sigaction action =
|
||||
{
|
||||
.sa_handler = SIG_DFL
|
||||
};
|
||||
::sigemptyset(&action.sa_mask);
|
||||
::sigaction(kSignalAbort, &action, nullptr);
|
||||
this->bSupportsAltKill = false;
|
||||
//struct sigaction action =
|
||||
//{
|
||||
// .sa_handler = SIG_DFL
|
||||
//};
|
||||
//::sigemptyset(&action.sa_mask);
|
||||
//::sigaction(SIGRTMIN + gRuntimeConfig.linuxConfig.uSignalTerminate, &action, nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1417,7 +1412,7 @@ namespace Aurora::Threading::Threads
|
||||
|
||||
if (this->bSupportsAltKill)
|
||||
{
|
||||
::pthread_kill(this->handle_, kSignalAbort);
|
||||
::pthread_kill(this->handle_, SIGRTMIN + gRuntimeConfig.linuxConfig.uSignalTerminate);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1464,6 +1459,8 @@ namespace Aurora::Threading::Threads
|
||||
AuxUlibInitialize();
|
||||
#endif
|
||||
|
||||
AttachSignalKiller();
|
||||
|
||||
if (auto pThread = GetThread())
|
||||
{
|
||||
AuStaticCast<OSThread>(pThread)->MakeMain();
|
||||
|
Loading…
Reference in New Issue
Block a user