diff options
author | Liam <[email protected]> | 2022-10-16 01:53:56 -0400 |
---|---|---|
committer | Liam <[email protected]> | 2022-10-31 17:44:06 -0400 |
commit | 983f2b70741f17f30fe2321451f10cabecc013d2 (patch) | |
tree | c1ac3c1033fdeefaabe76590ca204c4c1b2a98cd /src/core/hle/service/sm/sm.cpp | |
parent | 7f0d0dd17773f1f6c865907bc6c95e0630e3b886 (diff) | |
download | yuzu-android-983f2b70741f17f30fe2321451f10cabecc013d2.tar.gz yuzu-android-983f2b70741f17f30fe2321451f10cabecc013d2.zip |
kernel: invert session request handling flow
Diffstat (limited to 'src/core/hle/service/sm/sm.cpp')
-rw-r--r-- | src/core/hle/service/sm/sm.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index cb6c0e96f..c1f535d71 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -43,6 +43,10 @@ Kernel::KClientPort& ServiceManager::InterfaceFactory(ServiceManager& self, Core return self.sm_interface->CreatePort(); } +void ServiceManager::SessionHandler(ServiceManager& self, Kernel::KServerPort* server_port) { + self.sm_interface->AcceptSession(server_port); +} + Result ServiceManager::RegisterService(std::string name, u32 max_sessions, Kernel::SessionRequestHandlerPtr handler) { @@ -83,7 +87,6 @@ ResultVal<Kernel::KPort*> ServiceManager::GetServicePort(const std::string& name port->Initialize(ServerSessionCountMax, false, name); auto handler = it->second; - port->GetServerPort().SetSessionHandler(std::move(handler)); return port; } @@ -144,7 +147,8 @@ ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(Kernel::HLERequestContext& // Find the named port. auto port_result = service_manager.GetServicePort(name); - if (port_result.Failed()) { + auto service = service_manager.GetService<Kernel::SessionRequestHandler>(name); + if (port_result.Failed() || !service) { LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, port_result.Code().raw); return port_result.Code(); } @@ -156,12 +160,11 @@ ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(Kernel::HLERequestContext& // Create a new session. Kernel::KClientSession* session{}; - if (const auto result = port->GetClientPort().CreateSession( - std::addressof(session), std::make_shared<Kernel::SessionRequestManager>(kernel)); - result.IsError()) { + if (const auto result = port->GetClientPort().CreateSession(&session); result.IsError()) { LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, result.raw); return result; } + service->AcceptSession(&port->GetServerPort()); LOG_DEBUG(Service_SM, "called service={} -> session={}", name, session->GetId()); |