thread: Release resource limit in Thread::Stop

This commit is contained in:
GPUCode
2024-01-06 00:18:33 +02:00
parent 12880e9170
commit 0e4e8aa45a
2 changed files with 5 additions and 6 deletions

View File

@@ -60,12 +60,7 @@ void Thread::Acquire(Thread* thread) {
Thread::Thread(KernelSystem& kernel, u32 core_id) Thread::Thread(KernelSystem& kernel, u32 core_id)
: WaitObject(kernel), core_id(core_id), thread_manager(kernel.GetThreadManager(core_id)) {} : WaitObject(kernel), core_id(core_id), thread_manager(kernel.GetThreadManager(core_id)) {}
Thread::~Thread() { Thread::~Thread() = default;
auto process = owner_process.lock();
if (process) {
process->resource_limit->Release(ResourceLimitType::Thread, 1);
}
}
Thread* ThreadManager::GetCurrentThread() const { Thread* ThreadManager::GetCurrentThread() const {
return current_thread.get(); return current_thread.get();
@@ -101,6 +96,7 @@ void Thread::Stop() {
((tls_address - Memory::TLS_AREA_VADDR) % Memory::CITRA_PAGE_SIZE) / Memory::TLS_ENTRY_SIZE; ((tls_address - Memory::TLS_AREA_VADDR) % Memory::CITRA_PAGE_SIZE) / Memory::TLS_ENTRY_SIZE;
if (auto process = owner_process.lock()) { if (auto process = owner_process.lock()) {
process->tls_slots[tls_page].reset(tls_slot); process->tls_slots[tls_page].reset(tls_slot);
process->resource_limit->Release(ResourceLimitType::Thread, 1);
} }
} }

View File

@@ -288,6 +288,9 @@ void PLG_LDR::GetPluginPath(Kernel::HLERequestContext& ctx) {
} }
std::shared_ptr<PLG_LDR> GetService(Core::System& system) { std::shared_ptr<PLG_LDR> GetService(Core::System& system) {
if (!system.IsPoweredOn()) {
return nullptr;
}
return system.ServiceManager().GetService<PLG_LDR>("plg:ldr"); return system.ServiceManager().GetService<PLG_LDR>("plg:ldr");
} }