[*] Check for null handle under LSHandle bc win32 apis are inconsistent as shit
[*] _beginthreadex returns null, nonex returns -1, and it doesnt fucking work with affinity but seems to work with name updates. i dont care to fix this yet. fuck microsoft. [*] NT: preempt process watch thread of leaders instead of syncing to the process under a watch guard on free (evil, we should use a builtin nt threadpool. also cant be arsed to resolve)
This commit is contained in:
parent
11e5c04bac
commit
433898709e
@ -78,7 +78,7 @@ namespace Aurora::IO::Loop
|
||||
#if defined(AURORA_IS_POSIX_DERIVED)
|
||||
return this->handle != kInvalidHandle || this->handleWr != kInvalidHandle;
|
||||
#elif defined(AURORA_IS_MODERNNT_DERIVED)
|
||||
return this->handle != kInvalidHandle;
|
||||
return this->handle != kInvalidHandle && this->handle;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ namespace Aurora::IO::Loop
|
||||
AuSPtr<ILSMutex> ret;
|
||||
|
||||
auto mutex = ::CreateMutexW(NULL, false, NULL);
|
||||
if (mutex == INVALID_HANDLE_VALUE)
|
||||
if (!mutex)
|
||||
{
|
||||
SysPushErrorGen("Out of OS resources?");
|
||||
return {};
|
||||
|
@ -45,13 +45,13 @@ namespace Aurora::IO::Loop
|
||||
{
|
||||
AuSPtr<LSSemaphore> ret;
|
||||
|
||||
auto mutex = ::CreateSemaphoreA(NULL, initialCount, AuNumericLimits<LONG>::max(), NULL);
|
||||
if (mutex == INVALID_HANDLE_VALUE)
|
||||
auto semaphore = ::CreateSemaphoreA(NULL, initialCount, AuNumericLimits<LONG>::max(), NULL);
|
||||
if (!semaphore)
|
||||
{
|
||||
SysPushErrorGen("Out of OS resources?");
|
||||
return {};
|
||||
}
|
||||
|
||||
return AuMakeShared<LSSemaphore>(mutex);
|
||||
return AuMakeShared<LSSemaphore>(semaphore);
|
||||
}
|
||||
}
|
@ -77,11 +77,14 @@ namespace Aurora::Processes
|
||||
Terminate();
|
||||
}
|
||||
|
||||
SetEvent(this->poke_);
|
||||
|
||||
if (this->thread_)
|
||||
{
|
||||
this->thread_.reset();
|
||||
}
|
||||
|
||||
AuWin32CloseHandle(this->poke_);
|
||||
AuWin32CloseHandle(this->process_);
|
||||
AuWin32CloseHandle(this->hthread_);
|
||||
|
||||
@ -240,6 +243,12 @@ namespace Aurora::Processes
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this->poke_ = CreateEventW(NULL, TRUE, FALSE, NULL);
|
||||
if (!this->poke_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this->exitCode_ = 0x10110100;
|
||||
if (this->startup_.fwdOut == EStreamForward::eAsyncPipe)
|
||||
@ -475,13 +484,22 @@ namespace Aurora::Processes
|
||||
// TODO: delegate to a singular worker thread / SetThreadPoolWait
|
||||
auto a = [=]()
|
||||
{
|
||||
WaitForSingleObject(processInfo.hProcess, INFINITE);
|
||||
HANDLE b[] =
|
||||
{
|
||||
this->poke_, processInfo.hProcess
|
||||
};
|
||||
|
||||
WaitForMultipleObjects(2, b, FALSE, INFINITE);
|
||||
|
||||
DWORD exitCode;
|
||||
auto result = GetExitCodeProcess(processInfo.hProcess, &exitCode);
|
||||
this->exitCode_ = exitCode;
|
||||
if (result)
|
||||
{
|
||||
this->exitCode_ = exitCode;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this->thread_ = AuThreads::ThreadUnique(AuThreads::ThreadInfo(
|
||||
AuMakeShared<AuThreads::IThreadVectorsFunctional>(AuThreads::IThreadVectorsFunctional::OnEntry_t(std::bind(a)),
|
||||
AuThreads::IThreadVectorsFunctional::OnExit_t{})
|
||||
|
@ -72,6 +72,7 @@ namespace Aurora::Processes
|
||||
AuString windowsCli_;
|
||||
|
||||
AuThreads::ThreadUnique_t thread_;
|
||||
HANDLE poke_ {INVALID_HANDLE_VALUE};
|
||||
HANDLE process_ {INVALID_HANDLE_VALUE};
|
||||
HANDLE hthread_ {INVALID_HANDLE_VALUE};
|
||||
AuSInt exitCode_;
|
||||
|
@ -82,7 +82,8 @@ namespace Aurora::Threading::Threads
|
||||
#endif
|
||||
|
||||
auto ok = _beginthreadex(nullptr, staskSize, OSEP_f, callbackClone, 0, 0);
|
||||
if (ok == -1L)
|
||||
if ((ok == -1L) ||
|
||||
(ok == 0))
|
||||
{
|
||||
SysPushErrorGen("Couldn't initialize thread: {}", debugString);
|
||||
return {false, 0};
|
||||
|
Loading…
Reference in New Issue
Block a user