summaryrefslogtreecommitdiffstats
path: root/src/core/hle
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2016-12-05 19:59:57 +0100
committerSubv <subv2112@gmail.com>2016-12-05 19:59:57 +0100
commitc93c5a72bb46796e898f54a7c13dfb8d941ddd4d (patch)
tree1e5bded69840948daaa8b27bcba05a14b38dcb75 /src/core/hle
parentHLE: Use a member variable instead of a virtual function to retrieve the max number of sessions that can be connected to an HLE service at the same time. (diff)
downloadyuzu-c93c5a72bb46796e898f54a7c13dfb8d941ddd4d.tar
yuzu-c93c5a72bb46796e898f54a7c13dfb8d941ddd4d.tar.gz
yuzu-c93c5a72bb46796e898f54a7c13dfb8d941ddd4d.tar.bz2
yuzu-c93c5a72bb46796e898f54a7c13dfb8d941ddd4d.tar.lz
yuzu-c93c5a72bb46796e898f54a7c13dfb8d941ddd4d.tar.xz
yuzu-c93c5a72bb46796e898f54a7c13dfb8d941ddd4d.tar.zst
yuzu-c93c5a72bb46796e898f54a7c13dfb8d941ddd4d.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/client_port.cpp11
-rw-r--r--src/core/hle/kernel/client_port.h4
-rw-r--r--src/core/hle/result.h1
-rw-r--r--src/core/hle/service/srv.cpp8
-rw-r--r--src/core/hle/svc.cpp3
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 {
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
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 {
Success = 0,
WrongPermission = 46,
OS_InvalidBufferDescriptor = 48,
+ MaxConnectionsReached = 52,
WrongAddress = 53,
FS_ArchiveNotMounted = 101,
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) {
// Connect to the port and retrieve the client endpoint of the connection Session.
auto client_session = client_port->Connect();
- // Return the client session
- cmd_buff[3] = Kernel::g_handle_table.Create(client_session).MoveFrom();
+ res = client_session.Code();
+
+ if (client_session.Succeeded()) {
+ // Return the client session
+ cmd_buff[3] = Kernel::g_handle_table.Create(*client_session).MoveFrom();
+ }
LOG_TRACE(Service_SRV, "called port=%s, handle=0x%08X", port_name.c_str(), cmd_buff[3]);
} else {
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) {
auto client_port = it->second;
// Connect to the port and retrieve the client endpoint of the connection Session.
- auto client_session = client_port->Connect();
+ SharedPtr<Kernel::ClientSession> client_session;
+ CASCADE_RESULT(client_session, client_port->Connect());
// Note: Threads do not wait for the server endpoint to call
// AcceptSession before returning from this call.