summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2016-12-08 21:01:10 +0100
committerSubv <subv2112@gmail.com>2016-12-08 21:01:10 +0100
commit386112da3265d111595329508b860800e5cf14e8 (patch)
tree7cb27e289abd255ff7f371eff0f9d1ddd07b5d11 /src/core/hle/kernel
parentUse std::move where appropriate. (diff)
downloadyuzu-386112da3265d111595329508b860800e5cf14e8.tar
yuzu-386112da3265d111595329508b860800e5cf14e8.tar.gz
yuzu-386112da3265d111595329508b860800e5cf14e8.tar.bz2
yuzu-386112da3265d111595329508b860800e5cf14e8.tar.lz
yuzu-386112da3265d111595329508b860800e5cf14e8.tar.xz
yuzu-386112da3265d111595329508b860800e5cf14e8.tar.zst
yuzu-386112da3265d111595329508b860800e5cf14e8.zip
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/client_port.cpp8
-rw-r--r--src/core/hle/kernel/client_session.cpp15
-rw-r--r--src/core/hle/kernel/client_session.h11
-rw-r--r--src/core/hle/kernel/server_session.cpp10
4 files changed, 35 insertions, 9 deletions
diff --git a/src/core/hle/kernel/client_port.cpp b/src/core/hle/kernel/client_port.cpp
index 20179e546..bd8ef055d 100644
--- a/src/core/hle/kernel/client_port.cpp
+++ b/src/core/hle/kernel/client_port.cpp
@@ -19,9 +19,10 @@ ResultVal<SharedPtr<ClientSession>> ClientPort::Connect() {
// AcceptSession before returning from this call.
if (active_sessions >= max_sessions) {
- return ResultCode(ErrorDescription::MaxConnectionsReached,
+ // TODO(Subv): Return an error code in this situation after session disconnection is implemented.
+ /*return ResultCode(ErrorDescription::MaxConnectionsReached,
ErrorModule::OS, ErrorSummary::WouldBlock,
- ErrorLevel::Temporary);
+ ErrorLevel::Temporary);*/
}
active_sessions++;
@@ -30,6 +31,9 @@ ResultVal<SharedPtr<ClientSession>> ClientPort::Connect() {
auto client_session = std::get<SharedPtr<ClientSession>>(sessions);
auto server_session = std::get<SharedPtr<ServerSession>>(sessions);
+ if (server_port->hle_handler)
+ server_port->hle_handler->ClientConnected(server_session);
+
server_port->pending_sessions.push_back(std::move(server_session));
// Wake the threads waiting on the ServerPort
diff --git a/src/core/hle/kernel/client_session.cpp b/src/core/hle/kernel/client_session.cpp
index 30ef10764..17302baca 100644
--- a/src/core/hle/kernel/client_session.cpp
+++ b/src/core/hle/kernel/client_session.cpp
@@ -10,13 +10,22 @@
namespace Kernel {
ClientSession::ClientSession() = default;
-ClientSession::~ClientSession() = default;
+ClientSession::~ClientSession() {
+ // This destructor will be called automatically when the last ClientSession handle is closed by the emulated application.
-ResultVal<SharedPtr<ClientSession>> ClientSession::Create(SharedPtr<ServerSession> server_session, std::string name) {
+ if (server_session->hle_handler)
+ server_session->hle_handler->ClientDisconnected(server_session);
+
+ // TODO(Subv): If the session is still open, set the connection status to 2 (Closed by client),
+ // wake up all the ServerSession's waiting threads and set the WaitSynchronization result to 0xC920181A.
+}
+
+ResultVal<SharedPtr<ClientSession>> ClientSession::Create(ServerSession* server_session, std::string name) {
SharedPtr<ClientSession> client_session(new ClientSession);
client_session->name = std::move(name);
- client_session->server_session = std::move(server_session);
+ client_session->server_session = server_session;
+ client_session->session_status = SessionStatus::Open;
return MakeResult<SharedPtr<ClientSession>>(std::move(client_session));
}
diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h
index 45f479901..fedbd0625 100644
--- a/src/core/hle/kernel/client_session.h
+++ b/src/core/hle/kernel/client_session.h
@@ -15,6 +15,12 @@ namespace Kernel {
class ServerSession;
+enum class SessionStatus {
+ Open = 1,
+ ClosedByClient = 2,
+ ClosedBYServer = 3,
+};
+
class ClientSession final : public Object {
public:
friend class ServerSession;
@@ -39,7 +45,8 @@ public:
ResultCode SendSyncRequest();
std::string name; ///< Name of client port (optional)
- SharedPtr<ServerSession> server_session; ///< The server session associated with this client session.
+ ServerSession* server_session; ///< The server session associated with this client session.
+ SessionStatus session_status; ///< The session's current status.
private:
ClientSession();
@@ -51,7 +58,7 @@ private:
* @param name Optional name of client session
* @return The created client session
*/
- static ResultVal<SharedPtr<ClientSession>> Create(SharedPtr<ServerSession> server_session, std::string name = "Unknown");
+ static ResultVal<SharedPtr<ClientSession>> Create(ServerSession* server_session, std::string name = "Unknown");
};
} // namespace
diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp
index f8bccadfd..3fac6b934 100644
--- a/src/core/hle/kernel/server_session.cpp
+++ b/src/core/hle/kernel/server_session.cpp
@@ -11,7 +11,11 @@
namespace Kernel {
ServerSession::ServerSession() = default;
-ServerSession::~ServerSession() = default;
+ServerSession::~ServerSession() {
+ // This destructor will be called automatically when the last ServerSession handle is closed by the emulated application.
+ // TODO(Subv): Reduce the ClientPort's connection count,
+ // if the session is still open, set the connection status to 3 (Closed by server),
+}
ResultVal<SharedPtr<ServerSession>> ServerSession::Create(std::string name, std::shared_ptr<Service::SessionRequestHandler> hle_handler) {
SharedPtr<ServerSession> server_session(new ServerSession);
@@ -49,7 +53,9 @@ ResultCode ServerSession::HandleSyncRequest() {
ServerSession::SessionPair ServerSession::CreateSessionPair(const std::string& name,
std::shared_ptr<Service::SessionRequestHandler> hle_handler) {
auto server_session = ServerSession::Create(name + "_Server", std::move(hle_handler)).MoveFrom();
- auto client_session = ClientSession::Create(server_session, name + "_Client").MoveFrom();
+ // We keep a non-owning pointer to the ServerSession in the ClientSession because we don't want to prevent the
+ // ServerSession's destructor from being called when the emulated application closes the last ServerSession handle.
+ auto client_session = ClientSession::Create(server_session.get(), name + "_Client").MoveFrom();
return std::make_tuple(std::move(server_session), std::move(client_session));
}