2018-11-12 13:52:57 +00:00
|
|
|
#include <mesosphere/processes/KPort.hpp>
|
|
|
|
#include <mesosphere/threading/KScopedCriticalSection.hpp>
|
|
|
|
#include <mesosphere/threading/KThread.hpp>
|
|
|
|
#include <mesosphere/core/KCoreContext.hpp>
|
|
|
|
|
|
|
|
namespace mesosphere
|
|
|
|
{
|
|
|
|
|
|
|
|
KServerPort::~KServerPort()
|
|
|
|
{
|
2018-11-13 10:01:46 +00:00
|
|
|
KCriticalSection &critsec = KScheduler::GetCriticalSection();
|
|
|
|
critsec.lock();
|
2018-11-12 13:52:57 +00:00
|
|
|
parent->isServerAlive = false;
|
2018-11-13 10:01:46 +00:00
|
|
|
// TODO: normal sessions
|
|
|
|
lightServerSessions.clear_and_dispose(
|
|
|
|
[&critsec](KLightServerSession *s) {
|
|
|
|
critsec.unlock();
|
|
|
|
intrusive_ptr_release(s);
|
|
|
|
critsec.lock();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
critsec.unlock();
|
2018-11-12 13:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool KServerPort::IsSignaled() const
|
|
|
|
{
|
2018-11-12 14:48:03 +00:00
|
|
|
if (!parent->isLight) {
|
|
|
|
return false; // TODO
|
|
|
|
} else {
|
|
|
|
return !lightServerSessions.empty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-13 00:14:55 +00:00
|
|
|
Result KServerPort::AddLightServerSession(KLightServerSession &lightServerSession)
|
2018-11-12 14:48:03 +00:00
|
|
|
{
|
|
|
|
KScopedCriticalSection critsec{};
|
|
|
|
bool wasEmpty = lightServerSessions.empty();
|
|
|
|
lightServerSessions.push_back(lightServerSession);
|
|
|
|
if (wasEmpty && !lightServerSessions.empty()) {
|
|
|
|
NotifyWaiters();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ResultSuccess();
|
2018-11-12 13:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|