diff options
Diffstat (limited to 'src/core/hle/kernel/k_server_port.cpp')
-rw-r--r-- | src/core/hle/kernel/k_server_port.cpp | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/src/core/hle/kernel/k_server_port.cpp b/src/core/hle/kernel/k_server_port.cpp index a29d34bc1..bb6632f58 100644 --- a/src/core/hle/kernel/k_server_port.cpp +++ b/src/core/hle/kernel/k_server_port.cpp @@ -27,12 +27,14 @@ bool KServerPort::IsLight() const { void KServerPort::CleanupSessions() { // Ensure our preconditions are met. if (this->IsLight()) { - UNIMPLEMENTED(); + ASSERT(m_session_list.empty()); + } else { + ASSERT(m_light_session_list.empty()); } // Cleanup the session list. while (true) { - // Get the last session in the list + // Get the last session in the list. KServerSession* session = nullptr; { KScopedSchedulerLock sl{m_kernel}; @@ -49,6 +51,26 @@ void KServerPort::CleanupSessions() { break; } } + + // Cleanup the light session list. + while (true) { + // Get the last session in the list. + KLightServerSession* session = nullptr; + { + KScopedSchedulerLock sl{m_kernel}; + if (!m_light_session_list.empty()) { + session = std::addressof(m_light_session_list.front()); + m_light_session_list.pop_front(); + } + } + + // Close the session. + if (session != nullptr) { + session->Close(); + } else { + break; + } + } } void KServerPort::Destroy() { @@ -64,8 +86,7 @@ void KServerPort::Destroy() { bool KServerPort::IsSignaled() const { if (this->IsLight()) { - UNIMPLEMENTED(); - return false; + return !m_light_session_list.empty(); } else { return !m_session_list.empty(); } @@ -83,6 +104,18 @@ void KServerPort::EnqueueSession(KServerSession* session) { } } +void KServerPort::EnqueueSession(KLightServerSession* session) { + ASSERT(this->IsLight()); + + KScopedSchedulerLock sl{m_kernel}; + + // Add the session to our queue. + m_light_session_list.push_back(*session); + if (m_light_session_list.size() == 1) { + this->NotifyAvailable(); + } +} + KServerSession* KServerPort::AcceptSession() { ASSERT(!this->IsLight()); @@ -98,4 +131,19 @@ KServerSession* KServerPort::AcceptSession() { return session; } +KLightServerSession* KServerPort::AcceptLightSession() { + ASSERT(this->IsLight()); + + KScopedSchedulerLock sl{m_kernel}; + + // Return the first session in the list. + if (m_light_session_list.empty()) { + return nullptr; + } + + KLightServerSession* session = std::addressof(m_light_session_list.front()); + m_light_session_list.pop_front(); + return session; +} + } // namespace Kernel |