diff options
author | Feng Chen <vonchenplus@gmail.com> | 2021-10-25 12:55:20 +0200 |
---|---|---|
committer | Feng Chen <vonchenplus@gmail.com> | 2021-10-27 03:06:22 +0200 |
commit | a8b01049235bffa13d18a010311c16c8b9c316b4 (patch) | |
tree | 3e8f433c3da629b09a4b3e000047ceb6f8ac3ec0 /src/core/hle/kernel/kernel.cpp | |
parent | Merge pull request #7218 from bylaws/aswdqdsam (diff) | |
download | yuzu-a8b01049235bffa13d18a010311c16c8b9c316b4.tar yuzu-a8b01049235bffa13d18a010311c16c8b9c316b4.tar.gz yuzu-a8b01049235bffa13d18a010311c16c8b9c316b4.tar.bz2 yuzu-a8b01049235bffa13d18a010311c16c8b9c316b4.tar.lz yuzu-a8b01049235bffa13d18a010311c16c8b9c316b4.tar.xz yuzu-a8b01049235bffa13d18a010311c16c8b9c316b4.tar.zst yuzu-a8b01049235bffa13d18a010311c16c8b9c316b4.zip |
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
-rw-r--r-- | src/core/hle/kernel/kernel.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index bea945301..d054a7925 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -170,6 +170,17 @@ struct KernelCore::Impl { // Next host thead ID to use, 0-3 IDs represent core threads, >3 represent others next_host_thread_id = Core::Hardware::NUM_CPU_CORES; + // Close kernel objects that were not freed on shutdown + { + std::lock_guard lk(registered_in_use_objects_lock); + if (registered_in_use_objects.size()) { + for (auto thread : registered_in_use_objects) { + thread->Close(); + } + registered_in_use_objects.clear(); + } + } + // Track kernel objects that were not freed on shutdown { std::lock_guard lk(registered_objects_lock); @@ -714,9 +725,11 @@ struct KernelCore::Impl { std::unordered_set<KServerPort*> server_ports; std::unordered_set<KServerSession*> server_sessions; std::unordered_set<KAutoObject*> registered_objects; + std::unordered_set<KAutoObject*> registered_in_use_objects; std::mutex server_ports_lock; std::mutex server_sessions_lock; std::mutex registered_objects_lock; + std::mutex registered_in_use_objects_lock; std::unique_ptr<Core::ExclusiveMonitor> exclusive_monitor; std::vector<Kernel::PhysicalCore> cores; @@ -928,6 +941,16 @@ void KernelCore::UnregisterKernelObject(KAutoObject* object) { impl->registered_objects.erase(object); } +void KernelCore::RegisterInUseObject(KAutoObject* object) { + std::lock_guard lk(impl->registered_in_use_objects_lock); + impl->registered_in_use_objects.insert(object); +} + +void KernelCore::UnregisterInUseObject(KAutoObject* object) { + std::lock_guard lk(impl->registered_in_use_objects_lock); + impl->registered_in_use_objects.erase(object); +} + bool KernelCore::IsValidNamedPort(NamedPortTable::const_iterator port) const { return port != impl->named_ports.cend(); } |