kernel: Release thread resource limit in Thread::Stop (#7318)

* core: Config plg_ldr after its creation

* Also use service manager to retrieve the service

* thread: Release resource limit in Thread::Stop

* service: Undo plgldr change
This commit is contained in:
GPUCode 2024-01-06 02:12:00 +02:00 committed by GitHub
parent 0df72f3873
commit 62409f8139
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View File

@ -449,6 +449,12 @@ System::ResultStatus System::Init(Frontend::EmuWindow& emu_window,
gpu->SetInterruptHandler( gpu->SetInterruptHandler(
[gsp](Service::GSP::InterruptId interrupt_id) { gsp->SignalInterrupt(interrupt_id); }); [gsp](Service::GSP::InterruptId interrupt_id) { gsp->SignalInterrupt(interrupt_id); });
auto plg_ldr = Service::PLGLDR::GetService(*this);
if (plg_ldr) {
plg_ldr->SetEnabled(Settings::values.plugin_loader_enabled.GetValue());
plg_ldr->SetAllowGameChangeState(Settings::values.allow_plugin_loader.GetValue());
}
LOG_DEBUG(Core, "Initialized OK"); LOG_DEBUG(Core, "Initialized OK");
is_powered_on = true; is_powered_on = true;

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

@ -26,12 +26,10 @@
#include "common/settings.h" #include "common/settings.h"
#include "core/core.h" #include "core/core.h"
#include "core/file_sys/plugin_3gx.h" #include "core/file_sys/plugin_3gx.h"
#include "core/hle/ipc.h"
#include "core/hle/ipc_helpers.h" #include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/event.h" #include "core/hle/kernel/event.h"
#include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/handle_table.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/shared_memory.h"
#include "core/hle/service/plgldr/plgldr.h" #include "core/hle/service/plgldr/plgldr.h"
#include "core/loader/loader.h" #include "core/loader/loader.h"