picloud add "-w" option for watchdog

This commit is contained in:
2024-10-15 15:04:39 +03:00
parent cd7e053fc5
commit 92a87a0c64
3 changed files with 30 additions and 6 deletions

View File

@@ -45,6 +45,7 @@ void DispatcherServer::picoutStatus() {
void DispatcherServer::cleanClients() {
wd_cnt++;
PIMutexLocker locker(map_mutex);
for (auto s: rmrf_servers)
s->close();
@@ -194,6 +195,23 @@ void DispatcherServer::setMaxConnections(uint max_count) {
}
void DispatcherServer::startWatchdog() {
wd_cnt++;
PIThread * thread = new PIThread(
[this]() {
if (wd_cnt == 0) {
piCout << "Deadlock detected, abort";
std::abort();
return;
}
wd_cnt = 0;
},
true,
10_s);
NO_UNUSED(thread);
}
void DispatcherServer::disconnectClient(DispatcherClient * client) {
PIMutexLocker locker(map_mutex);
if (!clients.contains(client)) {