forked from ShuriZma/suyu
1
0
Fork 0

hle: service: sm: Remove redundant session reservation, etc.

- We were double-reserving, causing us to run out of sessions in Pokemon Sword & Shield.
This commit is contained in:
bunnei 2021-06-10 11:34:41 -07:00
parent fa8a0065ca
commit 781c85b951
2 changed files with 13 additions and 18 deletions

View File

@ -41,7 +41,10 @@ class ServiceManager;
} }
/// Default number of maximum connections to a server session. /// Default number of maximum connections to a server session.
static constexpr u32 ServerSessionCountMax = 0x10000; static constexpr u32 ServerSessionCountMax = 0x40;
static_assert(ServerSessionCountMax == 0x40,
"ServerSessionCountMax isn't 0x40 somehow, this assert is a reminder that this will "
"break lots of things");
/** /**
* This is an non-templated base of ServiceFramework to reduce code bloat and compilation times, it * This is an non-templated base of ServiceFramework to reduce code bloat and compilation times, it

View File

@ -151,27 +151,19 @@ ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(Kernel::HLERequestContext&
std::string name(PopServiceName(rp)); std::string name(PopServiceName(rp));
// Find the named port. // Find the named port.
auto result = service_manager.GetServicePort(name); auto port_result = service_manager.GetServicePort(name);
if (result.Failed()) { if (port_result.Failed()) {
LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, result.Code().raw); LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, port_result.Code().raw);
return result.Code(); return port_result.Code();
} }
auto* port = result.Unwrap(); auto& port = port_result.Unwrap()->GetClientPort();
// Reserve a new session from the process resource limit.
Kernel::KScopedResourceReservation session_reservation(
kernel.CurrentProcess()->GetResourceLimit(), Kernel::LimitableResource::Sessions);
R_UNLESS(session_reservation.Succeeded(), Kernel::ResultLimitReached);
// Create a new session. // Create a new session.
Kernel::KClientSession* session{}; Kernel::KClientSession* session{};
port->GetClientPort().CreateSession(std::addressof(session)); if (const auto result = port.CreateSession(std::addressof(session)); result.IsError()) {
LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, result.raw);
// Commit the session reservation. return result;
session_reservation.Commit(); }
// Enqueue the session with the named port.
port->EnqueueSession(&session->GetParent()->GetServerSession());
LOG_DEBUG(Service_SM, "called service={} -> session={}", name, session->GetId()); LOG_DEBUG(Service_SM, "called service={} -> session={}", name, session->GetId());