diff options
| author | 2016-12-05 13:59:57 -0500 | |
|---|---|---|
| committer | 2016-12-05 13:59:57 -0500 | |
| commit | c93c5a72bb46796e898f54a7c13dfb8d941ddd4d (patch) | |
| tree | 1e5bded69840948daaa8b27bcba05a14b38dcb75 /src/core/hle/kernel | |
| parent | HLE: Use a member variable instead of a virtual function to retrieve the max ... (diff) | |
| download | yuzu-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.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 { | |||
| 14 | ClientPort::ClientPort() {} | 14 | ClientPort::ClientPort() {} |
| 15 | ClientPort::~ClientPort() {} | 15 | ClientPort::~ClientPort() {} |
| 16 | 16 | ||
| 17 | SharedPtr<ClientSession> ClientPort::Connect() { | 17 | ResultVal<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 |