VERY experimental Nintendo Switch 2 emulator
C++
kernel/server_port: Make data members private
Lioncash9c8de2ee40ac
diff --git a/src/core/hle/kernel/client_port.cpp b/src/core/hle/kernel/client_port.cppindex d4c91d529c..aa432658e8 100644--- a/src/core/hle/kernel/client_port.cpp+++ b/src/core/hle/kernel/client_port.cpp@@ -33,10 +33,11 @@ ResultVal<SharedPtr<ClientSession>> ClientPort::Connect() {// Create a new session pair, let the created sessions inherit the parent port's HLE handler.auto sessions = ServerSession::CreateSessionPair(kernel, server_port->GetName(), this);- if (server_port->hle_handler)- server_port->hle_handler->ClientConnected(std::get<SharedPtr<ServerSession>>(sessions));- else- server_port->pending_sessions.push_back(std::get<SharedPtr<ServerSession>>(sessions));+ if (server_port->HasHLEHandler()) {+ server_port->GetHLEHandler()->ClientConnected(std::get<SharedPtr<ServerSession>>(sessions));+ } else {+ server_port->AppendPendingSession(std::get<SharedPtr<ServerSession>>(sessions));+ }// Wake the threads waiting on the ServerPortserver_port->WakeupAllWaitingThreads();diff --git a/src/core/hle/kernel/server_port.cpp b/src/core/hle/kernel/server_port.cppindex d6ceeb2da8..0e1515c890 100644--- a/src/core/hle/kernel/server_port.cpp+++ b/src/core/hle/kernel/server_port.cpp@@ -26,6 +26,10 @@ ResultVal<SharedPtr<ServerSession>> ServerPort::Accept() {return MakeResult(std::move(session));}+void ServerPort::AppendPendingSession(SharedPtr<ServerSession> pending_session) {+ pending_sessions.push_back(std::move(pending_session));+}+bool ServerPort::ShouldWait(Thread* thread) const {// If there are no pending sessions, we wait until a new one is added.return pending_sessions.empty();diff --git a/src/core/hle/kernel/server_port.h b/src/core/hle/kernel/server_port.hindex e52f8245f1..9bc667cf2c 100644--- a/src/core/hle/kernel/server_port.h+++ b/src/core/hle/kernel/server_port.h@@ -22,6 +22,8 @@ class SessionRequestHandler;class ServerPort final : public WaitObject {public:+ using HLEHandler = std::shared_ptr<SessionRequestHandler>;+/*** Creates a pair of ServerPort and an associated ClientPort.*@@ -51,22 +53,27 @@ public:*/ResultVal<SharedPtr<ServerSession>> Accept();+ /// Whether or not this server port has an HLE handler available.+ bool HasHLEHandler() const {+ return hle_handler != nullptr;+ }++ /// Gets the HLE handler for this port.+ HLEHandler GetHLEHandler() const {+ return hle_handler;+ }+/*** Sets the HLE handler template for the port. ServerSessions crated by connecting to this port* will inherit a reference to this handler.*/- void SetHleHandler(std::shared_ptr<SessionRequestHandler> hle_handler_) {+ void SetHleHandler(HLEHandler hle_handler_) {hle_handler = std::move(hle_handler_);}- std::string name; ///< Name of port (optional)-- /// ServerSessions waiting to be accepted by the port- std::vector<SharedPtr<ServerSession>> pending_sessions;-- /// This session's HLE request handler template (optional)- /// ServerSessions created from this port inherit a reference to this handler.- std::shared_ptr<SessionRequestHandler> hle_handler;+ /// Appends a ServerSession to the collection of ServerSessions+ /// waiting to be accepted by this port.+ void AppendPendingSession(SharedPtr<ServerSession> pending_session);bool ShouldWait(Thread* thread) const override;void Acquire(Thread* thread) override;@@ -74,6 +81,16 @@ public:private:explicit ServerPort(KernelCore& kernel);~ServerPort() override;++ /// ServerSessions waiting to be accepted by the port+ std::vector<SharedPtr<ServerSession>> pending_sessions;++ /// This session's HLE request handler template (optional)+ /// ServerSessions created from this port inherit a reference to this handler.+ HLEHandler hle_handler;++ /// Name of the port (optional)+ std::string name;};} // namespace Kerneldiff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.hindex bef25433e7..b9d6381b4d 100644--- a/src/core/hle/service/sm/sm.h+++ b/src/core/hle/service/sm/sm.h@@ -67,7 +67,7 @@ public:if (port == nullptr) {return nullptr;}- return std::static_pointer_cast<T>(port->hle_handler);+ return std::static_pointer_cast<T>(port->GetHLEHandler());}void InvokeControlRequest(Kernel::HLERequestContext& context);