From 13b107b7b15e6d4823627ea4707a12108fd5a1c7 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 21 Jun 2024 10:24:35 +0200 Subject: [PATCH] Fix #407: extend initctl poll timeout Signed-off-by: Joachim Wiberg --- ChangeLog.md | 4 ++++ src/client.c | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 7abf7874..e8bbe19e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -19,6 +19,10 @@ All relevant changes are documented in this file. - Add `runparts -b` (batch mode) support, disables escape sequences - New configure `--without-rc-local`, disables `/etc/rc.local` support - New configure `--disable-cgroup` option, disables cgroup v2 detection + - Extend `initctl` timeout connecting and waiting for Finit reply. The + previous 2 + 2 second poll timeout has proved to be too short on more + complex systems. Now a 15 + 15 second timeout is applied which should + be more resistant to temporary overload scenarios, issue #407 ### Fixes - Fix #397: system shutdown/reboot can block on console input if action diff --git a/src/client.c b/src/client.c index c3fd3aef..a8c06ac4 100644 --- a/src/client.c +++ b/src/client.c @@ -29,6 +29,8 @@ #include "client.h" #include "log.h" +#define REQUEST_TIMEOUT 15000 + static int sd = -1; int client_connect(void) @@ -85,7 +87,7 @@ int client_request(struct init_request *rq, ssize_t len) pfd.fd = sd; pfd.events = POLLOUT; - if (poll(&pfd, 1, 2000) <= 0) { + if (poll(&pfd, 1, REQUEST_TIMEOUT) <= 0) { warn("Timed out waiting for Finit, errno %d", errno); return -1; } @@ -107,7 +109,7 @@ int client_request(struct init_request *rq, ssize_t len) pfd.fd = sd; pfd.events = POLLIN | POLLERR | POLLHUP; - if ((rc = poll(&pfd, 1, 2000)) <= 0) { + if ((rc = poll(&pfd, 1, REQUEST_TIMEOUT)) <= 0) { if (rc) { if (errno == EINTR) /* shutdown/reboot */ return -1;