From b2971b48ed8f86857878f0fc0e1a744c4bc9d766 Mon Sep 17 00:00:00 2001 From: bunnei Date: Wed, 9 Jun 2021 21:37:11 -0700 Subject: hle: kernel: KServerSession: Fix client disconnected. - Prevents a cloned session's handler from being overwritten by another disconnected session. - Fixes session handler nullptr asserts with Pokemon Sword & Shield. --- src/core/hle/kernel/hle_ipc.cpp | 4 ++-- src/core/hle/kernel/k_server_session.h | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src/core/hle/kernel') diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 45aced99f..28ed6265a 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -57,11 +57,11 @@ bool SessionRequestManager::HasSessionRequestHandler(const HLERequestContext& co } void SessionRequestHandler::ClientConnected(KServerSession* session) { - session->SetSessionHandler(shared_from_this()); + session->ClientConnected(shared_from_this()); } void SessionRequestHandler::ClientDisconnected(KServerSession* session) { - session->SetSessionHandler(nullptr); + session->ClientDisconnected(); } HLERequestContext::HLERequestContext(KernelCore& kernel_, Core::Memory::Memory& memory_, diff --git a/src/core/hle/kernel/k_server_session.h b/src/core/hle/kernel/k_server_session.h index 9efd400bc..d44bc9d4f 100644 --- a/src/core/hle/kernel/k_server_session.h +++ b/src/core/hle/kernel/k_server_session.h @@ -62,15 +62,14 @@ public: void OnClientClosed(); - /** - * Sets the HLE handler for the session. This handler will be called to service IPC requests - * instead of the regular IPC machinery. (The regular IPC machinery is currently not - * implemented.) - */ - void SetSessionHandler(SessionRequestHandlerPtr handler) { + void ClientConnected(SessionRequestHandlerPtr handler) { manager->SetSessionHandler(std::move(handler)); } + void ClientDisconnected() { + manager = nullptr; + } + /** * Handle a sync request from the emulated application. * -- cgit v1.2.3