diff options
| author | 2016-12-05 13:59:57 -0500 | |
|---|---|---|
| committer | 2016-12-05 13:59:57 -0500 | |
| commit | c93c5a72bb46796e898f54a7c13dfb8d941ddd4d (patch) | |
| tree | 1e5bded69840948daaa8b27bcba05a14b38dcb75 /src | |
| 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')
| -rw-r--r-- | src/core/hle/kernel/client_port.cpp | 11 | ||||
| -rw-r--r-- | src/core/hle/kernel/client_port.h | 4 | ||||
| -rw-r--r-- | src/core/hle/result.h | 1 | ||||
| -rw-r--r-- | src/core/hle/service/srv.cpp | 8 | ||||
| -rw-r--r-- | src/core/hle/svc.cpp | 3 |
5 files changed, 20 insertions, 7 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 |
diff --git a/src/core/hle/result.h b/src/core/hle/result.h index f7356f9d8..20562aed6 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h | |||
| @@ -18,6 +18,7 @@ enum class ErrorDescription : u32 { | |||
| 18 | Success = 0, | 18 | Success = 0, |
| 19 | WrongPermission = 46, | 19 | WrongPermission = 46, |
| 20 | OS_InvalidBufferDescriptor = 48, | 20 | OS_InvalidBufferDescriptor = 48, |
| 21 | MaxConnectionsReached = 52, | ||
| 21 | WrongAddress = 53, | 22 | WrongAddress = 53, |
| 22 | FS_ArchiveNotMounted = 101, | 23 | FS_ArchiveNotMounted = 101, |
| 23 | FS_FileNotFound = 112, | 24 | FS_FileNotFound = 112, |
diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cpp index bb2c8fcc4..ff7a84347 100644 --- a/src/core/hle/service/srv.cpp +++ b/src/core/hle/service/srv.cpp | |||
| @@ -93,8 +93,12 @@ static void GetServiceHandle(Service::Interface* self) { | |||
| 93 | // Connect to the port and retrieve the client endpoint of the connection Session. | 93 | // Connect to the port and retrieve the client endpoint of the connection Session. |
| 94 | auto client_session = client_port->Connect(); | 94 | auto client_session = client_port->Connect(); |
| 95 | 95 | ||
| 96 | // Return the client session | 96 | res = client_session.Code(); |
| 97 | cmd_buff[3] = Kernel::g_handle_table.Create(client_session).MoveFrom(); | 97 | |
| 98 | if (client_session.Succeeded()) { | ||
| 99 | // Return the client session | ||
| 100 | cmd_buff[3] = Kernel::g_handle_table.Create(*client_session).MoveFrom(); | ||
| 101 | } | ||
| 98 | LOG_TRACE(Service_SRV, "called port=%s, handle=0x%08X", port_name.c_str(), cmd_buff[3]); | 102 | LOG_TRACE(Service_SRV, "called port=%s, handle=0x%08X", port_name.c_str(), cmd_buff[3]); |
| 99 | } else { | 103 | } else { |
| 100 | LOG_ERROR(Service_SRV, "(UNIMPLEMENTED) called port=%s", port_name.c_str()); | 104 | LOG_ERROR(Service_SRV, "(UNIMPLEMENTED) called port=%s", port_name.c_str()); |
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 4189d75ac..0a2b474ee 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -227,7 +227,8 @@ static ResultCode ConnectToPort(Handle* out_handle, const char* port_name) { | |||
| 227 | auto client_port = it->second; | 227 | auto client_port = it->second; |
| 228 | 228 | ||
| 229 | // Connect to the port and retrieve the client endpoint of the connection Session. | 229 | // Connect to the port and retrieve the client endpoint of the connection Session. |
| 230 | auto client_session = client_port->Connect(); | 230 | SharedPtr<Kernel::ClientSession> client_session; |
| 231 | CASCADE_RESULT(client_session, client_port->Connect()); | ||
| 231 | 232 | ||
| 232 | // Note: Threads do not wait for the server endpoint to call | 233 | // Note: Threads do not wait for the server endpoint to call |
| 233 | // AcceptSession before returning from this call. | 234 | // AcceptSession before returning from this call. |