summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorGravatar Subv2016-12-05 13:59:57 -0500
committerGravatar Subv2016-12-05 13:59:57 -0500
commitc93c5a72bb46796e898f54a7c13dfb8d941ddd4d (patch)
tree1e5bded69840948daaa8b27bcba05a14b38dcb75 /src/core/hle/kernel
parentHLE: Use a member variable instead of a virtual function to retrieve the max ... (diff)
downloadyuzu-c93c5a72bb46796e898f54a7c13dfb8d941ddd4d.tar.gz
yuzu-c93c5a72bb46796e898f54a7c13dfb8d941ddd4d.tar.xz
yuzu-c93c5a72bb46796e898f54a7c13dfb8d941ddd4d.zip
Return an error code when connecting to a saturated port.
The error code was taken from the 3DS kernel.
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/client_port.cpp11
-rw-r--r--src/core/hle/kernel/client_port.h4
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 {
14ClientPort::ClientPort() {} 14ClientPort::ClientPort() {}
15ClientPort::~ClientPort() {} 15ClientPort::~ClientPort() {}
16 16
17SharedPtr<ClientSession> ClientPort::Connect() { 17ResultVal<SharedPtr<ClientSession>> ClientPort::Connect() {
18 if (active_sessions >= max_sessions) {
19 return ResultCode(ErrorDescription::MaxConnectionsReached,
20 ErrorModule::OS, ErrorSummary::WouldBlock,
21 ErrorLevel::Temporary);
22 }
23 active_sessions++;
24
18 // Create a new session pair, let the created sessions inherit the parent port's HLE handler. 25 // Create a new session pair, let the created sessions inherit the parent port's HLE handler.
19 auto sessions = ServerSession::CreateSessionPair(server_port->GetName(), server_port->hle_handler); 26 auto sessions = ServerSession::CreateSessionPair(server_port->GetName(), server_port->hle_handler);
20 auto client_session = std::get<SharedPtr<ClientSession>>(sessions); 27 auto client_session = std::get<SharedPtr<ClientSession>>(sessions);
@@ -25,7 +32,7 @@ SharedPtr<ClientSession> ClientPort::Connect() {
25 // Wake the threads waiting on the ServerPort 32 // Wake the threads waiting on the ServerPort
26 server_port->WakeupAllWaitingThreads(); 33 server_port->WakeupAllWaitingThreads();
27 34
28 return std::move(client_session); 35 return MakeResult<SharedPtr<ClientSession>>(std::move(client_session));
29} 36}
30 37
31} // namespace 38} // 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:
31 /** 31 /**
32 * Creates a new Session pair, adds the created ServerSession to the associated ServerPort's list of pending sessions, 32 * Creates a new Session pair, adds the created ServerSession to the associated ServerPort's list of pending sessions,
33 * and signals the ServerPort, causing any threads waiting on it to awake. 33 * and signals the ServerPort, causing any threads waiting on it to awake.
34 * @returns ClientSession The client endpoint of the created Session pair. 34 * @returns ClientSession The client endpoint of the created Session pair, or error code.
35 */ 35 */
36 SharedPtr<ClientSession> Connect(); 36 ResultVal<SharedPtr<ClientSession>> Connect();
37 37
38 SharedPtr<ServerPort> server_port; ///< ServerPort associated with this client port. 38 SharedPtr<ServerPort> server_port; ///< ServerPort associated with this client port.
39 u32 max_sessions; ///< Maximum number of simultaneous sessions the port can have 39 u32 max_sessions; ///< Maximum number of simultaneous sessions the port can have