mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-23 04:41:12 +00:00
meso: impl AddServerSession
This commit is contained in:
parent
173bde2eca
commit
efe7325af3
5 changed files with 40 additions and 3 deletions
|
@ -27,6 +27,7 @@ class KClientPort final :
|
||||||
private:
|
private:
|
||||||
friend class KPort;
|
friend class KPort;
|
||||||
|
|
||||||
|
std::atomic<int> numSessions{0}, currentCapacity{0}, maxSessions{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(ClientPort);
|
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(ClientPort);
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <mesosphere/interfaces/ISetAllocated.hpp>
|
#include <mesosphere/interfaces/ISetAllocated.hpp>
|
||||||
#include <mesosphere/processes/KClientPort.hpp>
|
#include <mesosphere/processes/KClientPort.hpp>
|
||||||
#include <mesosphere/processes/KServerPort.hpp>
|
#include <mesosphere/processes/KServerPort.hpp>
|
||||||
|
#include <mesosphere/processes/KLightServerSession.hpp>
|
||||||
|
|
||||||
namespace mesosphere
|
namespace mesosphere
|
||||||
{
|
{
|
||||||
|
@ -20,12 +21,14 @@ class KPort final :
|
||||||
|
|
||||||
virtual ~KPort();
|
virtual ~KPort();
|
||||||
|
|
||||||
Result Initialize();
|
Result Initialize(int maxSessions, bool isLight);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class KClientPort;
|
friend class KClientPort;
|
||||||
friend class KServerPort;
|
friend class KServerPort;
|
||||||
|
|
||||||
|
Result AddServerSession(KLightServerSession &lightServerSession);
|
||||||
|
|
||||||
bool isClientAlive = false;
|
bool isClientAlive = false;
|
||||||
bool isServerAlive = false;
|
bool isServerAlive = false;
|
||||||
bool isLight = false;
|
bool isLight = false;
|
||||||
|
|
|
@ -23,7 +23,9 @@ class KServerPort final :
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class KPort;
|
friend class KPort;
|
||||||
|
Result AddServerSession(KLightServerSession &lightServerSession);
|
||||||
|
|
||||||
|
KLightServerSession::List lightServerSessions{};
|
||||||
};
|
};
|
||||||
|
|
||||||
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(ServerPort);
|
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(ServerPort);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <mesosphere/processes/KPort.hpp>
|
#include <mesosphere/processes/KPort.hpp>
|
||||||
#include <mesosphere/core/KCoreContext.hpp>
|
#include <mesosphere/core/KCoreContext.hpp>
|
||||||
|
#include <mesosphere/threading/KScopedCriticalSection.hpp>
|
||||||
|
|
||||||
namespace mesosphere
|
namespace mesosphere
|
||||||
{
|
{
|
||||||
|
@ -8,13 +9,27 @@ KPort::~KPort()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Result KPort::Initialize()
|
Result KPort::Initialize(int maxSessions, bool isLight)
|
||||||
{
|
{
|
||||||
SetClientServerParent();
|
SetClientServerParent();
|
||||||
isClientAlive = true;
|
isClientAlive = true;
|
||||||
isServerAlive = true;
|
isServerAlive = true;
|
||||||
|
|
||||||
|
client.maxSessions = maxSessions;
|
||||||
|
this->isLight = isLight;
|
||||||
|
|
||||||
return ResultSuccess();
|
return ResultSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result KPort::AddServerSession(KLightServerSession &lightServerSession)
|
||||||
|
{
|
||||||
|
KScopedCriticalSection critsec{};
|
||||||
|
if (isClientAlive || isServerAlive) {
|
||||||
|
return ResultKernelConnectionRefused();
|
||||||
|
} else {
|
||||||
|
return server.AddServerSession(lightServerSession);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,23 @@ KServerPort::~KServerPort()
|
||||||
|
|
||||||
bool KServerPort::IsSignaled() const
|
bool KServerPort::IsSignaled() const
|
||||||
{
|
{
|
||||||
return false; // TODO
|
if (!parent->isLight) {
|
||||||
|
return false; // TODO
|
||||||
|
} else {
|
||||||
|
return !lightServerSessions.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Result KServerPort::AddServerSession(KLightServerSession &lightServerSession)
|
||||||
|
{
|
||||||
|
KScopedCriticalSection critsec{};
|
||||||
|
bool wasEmpty = lightServerSessions.empty();
|
||||||
|
lightServerSessions.push_back(lightServerSession);
|
||||||
|
if (wasEmpty && !lightServerSessions.empty()) {
|
||||||
|
NotifyWaiters();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResultSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue