...
This commit is contained in:
@@ -11,6 +11,7 @@ ABSTRACT DEVICE COMPONENTS LIBRARY
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#if __has_include(<unistd.h>) // POSIX
|
||||
#define FORK_EXISTS 1
|
||||
@@ -138,7 +139,7 @@ protected:
|
||||
|
||||
// started sessions weak pointers
|
||||
template <interfaces::adc_netsession_c SessionT>
|
||||
static std::unordered_map<const AdcNetSessionManager*, std::set<std::weak_ptr<SessionT>>> _serverSessions;
|
||||
static std::unordered_map<const AdcNetSessionManager*, std::unordered_set<std::weak_ptr<SessionT>>> _serverSessions;
|
||||
std::vector<std::function<bool()>> _stopSessionFunc;
|
||||
std::vector<std::function<void(const AdcNetSessionManager*)>> _moveCtorFunc;
|
||||
|
||||
@@ -147,11 +148,11 @@ protected:
|
||||
{
|
||||
auto res = _serverSessions<SessionT>[this].emplace(sess_ptr);
|
||||
if (res.second) {
|
||||
sess_ptr.start();
|
||||
sess_ptr->start();
|
||||
|
||||
_stopSessionFunc.emplace_back([res, this]() {
|
||||
if (!res.first.expired()) { // session is still existing
|
||||
auto sess = res.first.lock();
|
||||
if (!res.first->expired()) { // session is still existing
|
||||
auto sess = res.first->lock();
|
||||
sess->stop();
|
||||
_serverSessions<SessionT>[this].erase(res.first);
|
||||
return true;
|
||||
@@ -308,9 +309,9 @@ public:
|
||||
|
||||
// only once per SessionT
|
||||
if (_isListening<SessionT>[this].size() == 1) {
|
||||
_moveCtorFunc = [this](const AdcGenericNetServer* new_instance) {
|
||||
_moveCtorFunc.emplace_back([this](const AdcGenericNetServer* new_instance) {
|
||||
_isListening<SessionT>[new_instance] = std::move(_isListening<SessionT>[this]);
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -358,7 +359,7 @@ protected:
|
||||
startSession(sess);
|
||||
|
||||
_isListening<SessionT>[this][id] = true;
|
||||
doAccept(acceptor, id, sess_ctx);
|
||||
doAccept<SessionT>(acceptor, id, sess_ctx);
|
||||
} else {
|
||||
_isListening<SessionT>[this][id] = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user