diff options
author | Liam <byteslice@airmail.cc> | 2022-10-31 03:22:14 +0100 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2022-10-31 22:47:39 +0100 |
commit | 77b74f5d95626422f59b508cd2b355135ed256ca (patch) | |
tree | cde636e3e2241941d13e66964d2fd3154e0002fa /src/core/hle/service/sm/sm.cpp | |
parent | kernel: fix single core for service threads (diff) | |
download | yuzu-77b74f5d95626422f59b508cd2b355135ed256ca.tar yuzu-77b74f5d95626422f59b508cd2b355135ed256ca.tar.gz yuzu-77b74f5d95626422f59b508cd2b355135ed256ca.tar.bz2 yuzu-77b74f5d95626422f59b508cd2b355135ed256ca.tar.lz yuzu-77b74f5d95626422f59b508cd2b355135ed256ca.tar.xz yuzu-77b74f5d95626422f59b508cd2b355135ed256ca.tar.zst yuzu-77b74f5d95626422f59b508cd2b355135ed256ca.zip |
Diffstat (limited to 'src/core/hle/service/sm/sm.cpp')
-rw-r--r-- | src/core/hle/service/sm/sm.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index c1f535d71..84720094f 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -23,7 +23,13 @@ constexpr Result ERR_INVALID_NAME(ErrorModule::SM, 6); constexpr Result ERR_SERVICE_NOT_REGISTERED(ErrorModule::SM, 7); ServiceManager::ServiceManager(Kernel::KernelCore& kernel_) : kernel{kernel_} {} -ServiceManager::~ServiceManager() = default; + +ServiceManager::~ServiceManager() { + for (auto& [name, port] : service_ports) { + port->GetClientPort().Close(); + port->GetServerPort().Close(); + } +} void ServiceManager::InvokeControlRequest(Kernel::HLERequestContext& context) { controller_interface->InvokeRequest(context); @@ -57,7 +63,11 @@ Result ServiceManager::RegisterService(std::string name, u32 max_sessions, return ERR_ALREADY_REGISTERED; } - registered_services.emplace(std::move(name), handler); + auto* port = Kernel::KPort::Create(kernel); + port->Initialize(ServerSessionCountMax, false, name); + + service_ports.emplace(name, port); + registered_services.emplace(name, handler); return ResultSuccess; } @@ -72,23 +82,20 @@ Result ServiceManager::UnregisterService(const std::string& name) { } registered_services.erase(iter); + service_ports.erase(name); + return ResultSuccess; } ResultVal<Kernel::KPort*> ServiceManager::GetServicePort(const std::string& name) { CASCADE_CODE(ValidateServiceName(name)); - auto it = registered_services.find(name); - if (it == registered_services.end()) { + auto it = service_ports.find(name); + if (it == service_ports.end()) { LOG_ERROR(Service_SM, "Server is not registered! service={}", name); return ERR_SERVICE_NOT_REGISTERED; } - auto* port = Kernel::KPort::Create(kernel); - - port->Initialize(ServerSessionCountMax, false, name); - auto handler = it->second; - - return port; + return it->second; } /** @@ -153,10 +160,6 @@ ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(Kernel::HLERequestContext& return port_result.Code(); } auto& port = port_result.Unwrap(); - SCOPE_EXIT({ - port->GetClientPort().Close(); - port->GetServerPort().Close(); - }); // Create a new session. Kernel::KClientSession* session{}; |