1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
From 34fb22b162cf78d97c39804da1e647297121b7e4 Mon Sep 17 00:00:00 2001
From: Vaxry <vaxry@vaxry.net>
Date: Thu, 23 Jul 2026 19:23:26 +0200
Subject: [PATCH] core: fix loop hangup detection
---
src/core/PortalManager.cpp | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/core/PortalManager.cpp b/src/core/PortalManager.cpp
index fe5a27d..5dc98d4 100644
--- a/src/core/PortalManager.cpp
+++ b/src/core/PortalManager.cpp
@@ -349,13 +349,16 @@ void CPortalManager::startEventLoop() {
if (ret < 0) {
Debug::log(CRIT, "[core] Polling fds failed with {}", strerror(errno));
g_pPortalManager->terminate();
+ break;
}
- for (size_t i = 0; i < 3; ++i) {
- if (m_sEventLoopInternals.pollFds.data()->revents & POLLHUP) {
- Debug::log(CRIT, "[core] Disconnected from pollfd id {}", i);
- g_pPortalManager->terminate();
- }
+ for (size_t i = 0; i < m_sEventLoopInternals.pollFds.size(); ++i) {
+ if (!(m_sEventLoopInternals.pollFds[i].revents & (POLLHUP | POLLERR | POLLNVAL)))
+ continue;
+
+ Debug::log(CRIT, "[core] Disconnected from pollfd id {}", i);
+ g_pPortalManager->terminate();
+ break;
}
if (m_bTerminate)
@@ -557,7 +560,7 @@ void CPortalManager::addTimer(const CTimer& timer) {
}
void CPortalManager::addFdToEventLoop(int fd, short events, std::function<void()> callback) {
- m_sEventLoopInternals.pollFds.emplace_back(pollfd{.fd = fd, .events = POLLIN});
+ m_sEventLoopInternals.pollFds.emplace_back(pollfd{.fd = fd, .events = events});
if (callback == nullptr)
return;
|