summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2021-06-10 11:34:41 -0700
committerGravatar bunnei2021-06-10 11:34:41 -0700
commit781c85b951a8ac8de8f876429a56ae5c375e4149 (patch)
treecb1c3905b5cbcc47aa31100e4bc484bb79252213
parenthle: service: Increase arbitrary max sessions limit. (diff)
downloadyuzu-781c85b951a8ac8de8f876429a56ae5c375e4149.tar.gz
yuzu-781c85b951a8ac8de8f876429a56ae5c375e4149.tar.xz
yuzu-781c85b951a8ac8de8f876429a56ae5c375e4149.zip
hle: service: sm: Remove redundant session reservation, etc.
- We were double-reserving, causing us to run out of sessions in Pokemon Sword & Shield.
-rw-r--r--src/core/hle/service/service.h5
-rw-r--r--src/core/hle/service/sm/sm.cpp26
2 files changed, 13 insertions, 18 deletions
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index 6c5bf3a95..e078ac176 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -41,7 +41,10 @@ class ServiceManager;
41} 41}
42 42
43/// Default number of maximum connections to a server session. 43/// Default number of maximum connections to a server session.
44static constexpr u32 ServerSessionCountMax = 0x10000; 44static constexpr u32 ServerSessionCountMax = 0x40;
45static_assert(ServerSessionCountMax == 0x40,
46 "ServerSessionCountMax isn't 0x40 somehow, this assert is a reminder that this will "
47 "break lots of things");
45 48
46/** 49/**
47 * This is an non-templated base of ServiceFramework to reduce code bloat and compilation times, it 50 * This is an non-templated base of ServiceFramework to reduce code bloat and compilation times, it
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp
index a1e1a7d76..c7828c3bd 100644
--- a/src/core/hle/service/sm/sm.cpp
+++ b/src/core/hle/service/sm/sm.cpp
@@ -151,27 +151,19 @@ ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(Kernel::HLERequestContext&
151 std::string name(PopServiceName(rp)); 151 std::string name(PopServiceName(rp));
152 152
153 // Find the named port. 153 // Find the named port.
154 auto result = service_manager.GetServicePort(name); 154 auto port_result = service_manager.GetServicePort(name);
155 if (result.Failed()) { 155 if (port_result.Failed()) {
156 LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, result.Code().raw); 156 LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, port_result.Code().raw);
157 return result.Code(); 157 return port_result.Code();
158 } 158 }
159 auto* port = result.Unwrap(); 159 auto& port = port_result.Unwrap()->GetClientPort();
160
161 // Reserve a new session from the process resource limit.
162 Kernel::KScopedResourceReservation session_reservation(
163 kernel.CurrentProcess()->GetResourceLimit(), Kernel::LimitableResource::Sessions);
164 R_UNLESS(session_reservation.Succeeded(), Kernel::ResultLimitReached);
165 160
166 // Create a new session. 161 // Create a new session.
167 Kernel::KClientSession* session{}; 162 Kernel::KClientSession* session{};
168 port->GetClientPort().CreateSession(std::addressof(session)); 163 if (const auto result = port.CreateSession(std::addressof(session)); result.IsError()) {
169 164 LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, result.raw);
170 // Commit the session reservation. 165 return result;
171 session_reservation.Commit(); 166 }
172
173 // Enqueue the session with the named port.
174 port->EnqueueSession(&session->GetParent()->GetServerSession());
175 167
176 LOG_DEBUG(Service_SM, "called service={} -> session={}", name, session->GetId()); 168 LOG_DEBUG(Service_SM, "called service={} -> session={}", name, session->GetId());
177 169