diff options
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/kernel/client_port.cpp | 11 | ||||
-rw-r--r-- | src/core/hle/kernel/client_port.h | 4 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/core/hle/kernel/client_port.cpp b/src/core/hle/kernel/client_port.cpp index b6a4cab26..120ce554d 100644 --- a/src/core/hle/kernel/client_port.cpp +++ b/src/core/hle/kernel/client_port.cpp @@ -14,7 +14,14 @@ namespace Kernel { ClientPort::ClientPort() {} ClientPort::~ClientPort() {} -SharedPtr<ClientSession> ClientPort::Connect() { +ResultVal<SharedPtr<ClientSession>> ClientPort::Connect() { + if (active_sessions >= max_sessions) { + return ResultCode(ErrorDescription::MaxConnectionsReached, + ErrorModule::OS, ErrorSummary::WouldBlock, + ErrorLevel::Temporary); + } + active_sessions++; + // Create a new session pair, let the created sessions inherit the parent port's HLE handler. auto sessions = ServerSession::CreateSessionPair(server_port->GetName(), server_port->hle_handler); auto client_session = std::get<SharedPtr<ClientSession>>(sessions); @@ -25,7 +32,7 @@ SharedPtr<ClientSession> ClientPort::Connect() { // Wake the threads waiting on the ServerPort server_port->WakeupAllWaitingThreads(); - return std::move(client_session); + return MakeResult<SharedPtr<ClientSession>>(std::move(client_session)); } } // namespace diff --git a/src/core/hle/kernel/client_port.h b/src/core/hle/kernel/client_port.h index d217c6649..0039cf028 100644 --- a/src/core/hle/kernel/client_port.h +++ b/src/core/hle/kernel/client_port.h @@ -31,9 +31,9 @@ public: /** * Creates a new Session pair, adds the created ServerSession to the associated ServerPort's list of pending sessions, * and signals the ServerPort, causing any threads waiting on it to awake. - * @returns ClientSession The client endpoint of the created Session pair. + * @returns ClientSession The client endpoint of the created Session pair, or error code. */ - SharedPtr<ClientSession> Connect(); + ResultVal<SharedPtr<ClientSession>> Connect(); SharedPtr<ServerPort> server_port; ///< ServerPort associated with this client port. u32 max_sessions; ///< Maximum number of simultaneous sessions the port can have |