meso: Implement KLightServerSession dtor

This commit is contained in:
TuxSH
2018-11-12 09:54:22 +01:00
committed by Michael Scire
parent 9c8f818c29
commit be3550d382
8 changed files with 60 additions and 10 deletions

View File

@@ -1,11 +1,13 @@
#include <mesosphere/processes/KLightServerSession.hpp>
#include <mesosphere/processes/KLightSession.hpp>
#include <mesosphere/threading/KScopedCriticalSection.hpp>
namespace mesosphere
{
KLightServerSession::~KLightServerSession()
{
//TODO
Terminate(true);
}
bool KLightServerSession::IsSignaled() const
@@ -13,5 +15,30 @@ bool KLightServerSession::IsSignaled() const
return false; // TODO
}
void KLightServerSession::Terminate(bool fromServer)
{
SharedPtr<KThread> curSender{std::move(currentSender)};
{
KScopedCriticalSection critsec{};
if (fromServer) {
parent->isServerAlive = false; // buggy in official kernel -- where it sets it outside of critical section
} else {
parent->isClientAlive = false;
}
if (curSender != nullptr) {
kassert(curSender->GetSchedulingStatus() == KThread::SchedulingStatus::Paused && curSender->IsInKernelSync());
curSender->CancelKernelSync(ResultKernelConnectionClosed()); //TODO check
currentSender = nullptr;
currentReceiver = nullptr;
}
for (auto &&sender : senderThreads) {
kassert(sender.GetSchedulingStatus() == KThread::SchedulingStatus::Paused && sender.IsInKernelSync());
sender.CancelKernelSync(ResultKernelConnectionClosed()); //TODO check
}
KThread::ResumeAllFromKernelSync(receiverThreads);
}
}
}