summaryrefslogtreecommitdiff
path: root/src/core/hle/service/service.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2022-11-03 21:45:56 -0700
committerGravatar GitHub2022-11-03 21:45:56 -0700
commit37de88040c1999fed639004fb7200cabb8a5f9c0 (patch)
tree561f8439eb8cabd5f254701aaac05f728cdd1ade /src/core/hle/service/service.cpp
parentMerge pull request #9154 from liamwhite/new-fb (diff)
parentsm:: avoid excessive port recreation (diff)
downloadyuzu-37de88040c1999fed639004fb7200cabb8a5f9c0.tar.gz
yuzu-37de88040c1999fed639004fb7200cabb8a5f9c0.tar.xz
yuzu-37de88040c1999fed639004fb7200cabb8a5f9c0.zip
Merge pull request #9135 from liamwhite/service-thread-event
kernel: invert session request handling flow
Diffstat (limited to 'src/core/hle/service/service.cpp')
-rw-r--r--src/core/hle/service/service.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 5db6588e4..5ab41c0c4 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -99,6 +99,12 @@ ServiceFrameworkBase::ServiceFrameworkBase(Core::System& system_, const char* se
99ServiceFrameworkBase::~ServiceFrameworkBase() { 99ServiceFrameworkBase::~ServiceFrameworkBase() {
100 // Wait for other threads to release access before destroying 100 // Wait for other threads to release access before destroying
101 const auto guard = LockService(); 101 const auto guard = LockService();
102
103 if (named_port != nullptr) {
104 named_port->GetClientPort().Close();
105 named_port->GetServerPort().Close();
106 named_port = nullptr;
107 }
102} 108}
103 109
104void ServiceFrameworkBase::InstallAsService(SM::ServiceManager& service_manager) { 110void ServiceFrameworkBase::InstallAsService(SM::ServiceManager& service_manager) {
@@ -113,15 +119,16 @@ void ServiceFrameworkBase::InstallAsService(SM::ServiceManager& service_manager)
113Kernel::KClientPort& ServiceFrameworkBase::CreatePort() { 119Kernel::KClientPort& ServiceFrameworkBase::CreatePort() {
114 const auto guard = LockService(); 120 const auto guard = LockService();
115 121
116 ASSERT(!service_registered); 122 if (named_port == nullptr) {
123 ASSERT(!service_registered);
117 124
118 auto* port = Kernel::KPort::Create(kernel); 125 named_port = Kernel::KPort::Create(kernel);
119 port->Initialize(max_sessions, false, service_name); 126 named_port->Initialize(max_sessions, false, service_name);
120 port->GetServerPort().SetSessionHandler(shared_from_this());
121 127
122 service_registered = true; 128 service_registered = true;
129 }
123 130
124 return port->GetClientPort(); 131 return named_port->GetClientPort();
125} 132}
126 133
127void ServiceFrameworkBase::RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n) { 134void ServiceFrameworkBase::RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n) {
@@ -199,7 +206,6 @@ Result ServiceFrameworkBase::HandleSyncRequest(Kernel::KServerSession& session,
199 switch (ctx.GetCommandType()) { 206 switch (ctx.GetCommandType()) {
200 case IPC::CommandType::Close: 207 case IPC::CommandType::Close:
201 case IPC::CommandType::TIPC_Close: { 208 case IPC::CommandType::TIPC_Close: {
202 session.Close();
203 IPC::ResponseBuilder rb{ctx, 2}; 209 IPC::ResponseBuilder rb{ctx, 2};
204 rb.Push(ResultSuccess); 210 rb.Push(ResultSuccess);
205 result = IPC::ERR_REMOTE_PROCESS_DEAD; 211 result = IPC::ERR_REMOTE_PROCESS_DEAD;
@@ -244,6 +250,7 @@ Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system
244 system.GetFileSystemController().CreateFactories(*system.GetFilesystem(), false); 250 system.GetFileSystemController().CreateFactories(*system.GetFilesystem(), false);
245 251
246 system.Kernel().RegisterNamedService("sm:", SM::ServiceManager::InterfaceFactory); 252 system.Kernel().RegisterNamedService("sm:", SM::ServiceManager::InterfaceFactory);
253 system.Kernel().RegisterInterfaceForNamedService("sm:", SM::ServiceManager::SessionHandler);
247 254
248 Account::InstallInterfaces(system); 255 Account::InstallInterfaces(system);
249 AM::InstallInterfaces(*sm, *nv_flinger, system); 256 AM::InstallInterfaces(*sm, *nv_flinger, system);