From: Timo Sirainen Date: Tue, 28 Jul 2026 23:44:01 +0000 (+0000) Subject: lib: test-iostream-pump - Fix flakiness on stalled machines X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1d89da5e1bbf38fcc4486c7c0f5dc00a1a14e7ef;p=thirdparty%2Fdovecot%2Fcore.git lib: test-iostream-pump - Fix flakiness on stalled machines The tests used a 3000 ms ioloop timeout as a watchdog for the pump to finish. The ioloop compensates for time moving forwards only while it is waiting, not while timeout and IO callbacks are running. When the wall clock jumps forwards during that window, or the process doesn't get scheduled, every timeout that became due is called in the same run, so the watchdog fires before the pump has had the chance to make any progress. Use a 30 second watchdog instead, so that only a machine that is stalled that long can trigger it. Keep alarm() a bit above the watchdog, so that it still only triggers when the ioloop itself is stuck. --- diff --git a/src/lib/test-iostream-pump.c b/src/lib/test-iostream-pump.c index 4f56f925a5..4e1f6714f4 100644 --- a/src/lib/test-iostream-pump.c +++ b/src/lib/test-iostream-pump.c @@ -14,6 +14,12 @@ #include #include +/* Timeout for waiting for the pump to finish. Reaching this timeout means the + test failed, so it just needs to be long enough that a heavily loaded or + stalled machine doesn't reach it before the pump has had the chance to + finish. */ +#define PUMP_TIMEOUT_MSECS (30*1000) + struct nonblock_ctx { struct istream *in; struct ostream *out; @@ -95,8 +101,8 @@ run_pump(struct istream *in, struct ostream *out, int *counter, iostream_pump_set_completion_callback(pump, completed, counter); iostream_pump_start(pump); - alarm(5); - struct timeout *to = timeout_add(3000, failed, counter); + alarm(PUMP_TIMEOUT_MSECS/1000 + 5); + struct timeout *to = timeout_add(PUMP_TIMEOUT_MSECS, failed, counter); io_loop_run(current_ioloop);