Process CDC timeouts in a timely manner

This commit is contained in:
Francesco Mazzoli
2024-01-29 15:08:06 +00:00
parent 1145ea10a3
commit 0a6a0c8f24
5 changed files with 10 additions and 7 deletions
+2 -1
View File
@@ -272,7 +272,8 @@ public:
}
LOG_DEBUG(_env, "Blocking to wait for readable sockets");
if (unlikely(poll(_socks.data(), _socks.size()) < 0)) {
// Only timeout if there are outstanding shard requests
if (unlikely(poll(_socks.data(), _socks.size(), (_inFlightShardReqs.size() > 0) ? _shardTimeout : -1) < 0)) {
if (errno == EINTR) { return; }
throw SYSCALL_EXCEPTION("poll");
}
+3 -2
View File
@@ -73,8 +73,9 @@ void Loop::run() {
while (!stopLoop.load()) { step(); }
}
int Loop::poll(struct pollfd* fds, nfds_t nfds) {
return ppoll(fds, nfds, nullptr, &blockingSigset);
int Loop::poll(struct pollfd* fds, nfds_t nfds, Duration timeout) {
struct timespec spec = timeout.timespec();
return ppoll(fds, nfds, &spec, &blockingSigset);
}
void Loop::stop() {
+3 -2
View File
@@ -46,8 +46,9 @@ public:
void run();
// Polls forever with SIGINT/SIGTERM unmasked.
int poll(struct pollfd* fds, nfds_t nfds);
// Polls forever with SIGINT/SIGTERM unmasked. If timeout < 0, waits forever.
// If timeout == 0, returns immediately. If timeout > 0, it'll wait.
int poll(struct pollfd* fds, nfds_t nfds, Duration timeout);
// Sleeps with SIGINT/SIGTERM unmasked.
int sleep(Duration d);
+1 -1
View File
@@ -251,7 +251,7 @@ EggsTime Xmon::_stepNextWakeup() {
nextWakeup = std::min(nextWakeup, eggsNow() + HEARTBEAT_INTERVAL*2);
}
if (poll(_fds, NUM_FDS) < 0) {
if (poll(_fds, NUM_FDS, -1) < 0) {
if (errno == EINTR) { return nextWakeup; }
throw SYSCALL_EXCEPTION("poll");
}
+1 -1
View File
@@ -379,7 +379,7 @@ public:
_sendVecs[i].clear();
}
if (unlikely(poll(_shared.socks.data(), 1 + (_shared.socks[1].fd != 0)) < 0)) {
if (unlikely(poll(_shared.socks.data(), 1 + (_shared.socks[1].fd != 0), -1) < 0)) {
if (errno == EINTR) { return; }
throw SYSCALL_EXCEPTION("poll");
}