cloud inspecting ...

This commit is contained in:
2024-03-15 19:49:37 +03:00
parent 2b738f6f43
commit 3fa5d9d9df
5 changed files with 29 additions and 15 deletions

View File

@@ -54,9 +54,8 @@ void CloudServer::removeClient(DispatcherClient * c) {
PIVector<DispatcherClient *> CloudServer::getClients() {
mutex_clients.lock();
PIMutexLocker locker(mutex_clients);
PIVector<DispatcherClient *> cl = clients;
mutex_clients.unlock();
return cl;
}
@@ -67,11 +66,10 @@ double CloudServer::lastPing() {
void CloudServer::printStatus() {
mutex_clients.lock();
PIMutexLocker locker(mutex_clients);
piCout << " "
<< "Clients for" << server->address() << server_uuid.toHex() << ":";
for (auto c: clients) {
piCout << " " << c->address() << c->clientId();
}
mutex_clients.unlock();
}

View File

@@ -22,7 +22,7 @@ void DispatcherClient::start() {
DispatcherClient::~DispatcherClient() {
delete eth;
piDeleteSafety(eth);
}

View File

@@ -61,6 +61,7 @@ void DispatcherServer::cleanClients() {
piCout << "remove Server by ping timeout" << c->getConnection()->clientId();
PIVector<DispatcherClient *> cscv = c->getClients();
for (auto csc: cscv) {
if (!csc->isPIObject()) piCout << "ACHTUNG! Non-piobject DispatcherClient!";
clients.removeAll(csc);
index_c_clients.remove(csc);
c->removeClient(csc);
@@ -183,12 +184,12 @@ void DispatcherServer::setMaxConnections(uint max_count) {
void DispatcherServer::disconnectClient(DispatcherClient * client) {
PIMutexLocker locker(map_mutex);
if (!clients.contains(client)) {
// piCoutObj << "INVALID client" << client;
return;
}
piCoutObj << "remove ..." << client->clientId();
PIMutexLocker locker(map_mutex);
clients.removeAll(client);
rm_clients.removeAll(client);
CloudServer * cs = index_c_servers.value(client, nullptr);
@@ -219,6 +220,7 @@ void DispatcherServer::disconnectClient(DispatcherClient * client) {
void DispatcherServer::newConnection(PIEthernet * cl) {
PIMutexLocker locker(map_mutex);
if (clients.size() >= max_connections) {
delete cl;
return;
@@ -253,7 +255,6 @@ void DispatcherServer::newConnection(PIEthernet * cl) {
}
});
// piCoutObj << "add client" << client;
PIMutexLocker locker(map_mutex);
clients.push_back(client);
client->start();
}