2018-11-11 21:53:15 +00:00
|
|
|
#include <mesosphere/processes/KLightServerSession.hpp>
|
2018-11-12 08:54:22 +00:00
|
|
|
#include <mesosphere/processes/KLightSession.hpp>
|
|
|
|
#include <mesosphere/threading/KScopedCriticalSection.hpp>
|
2018-11-11 21:53:15 +00:00
|
|
|
|
|
|
|
namespace mesosphere
|
|
|
|
{
|
|
|
|
|
|
|
|
KLightServerSession::~KLightServerSession()
|
|
|
|
{
|
2018-11-12 08:54:22 +00:00
|
|
|
Terminate(true);
|
2018-11-11 21:53:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool KLightServerSession::IsSignaled() const
|
|
|
|
{
|
|
|
|
return false; // TODO
|
|
|
|
}
|
|
|
|
|
2018-11-12 08:54:22 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2018-11-11 21:53:15 +00:00
|
|
|
|
|
|
|
}
|