]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: test-iostream-pump - Fix flakiness on stalled machines
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 28 Jul 2026 23:44:01 +0000 (23:44 +0000)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Tue, 28 Jul 2026 12:13:20 +0000 (12:13 +0000)
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.

src/lib/test-iostream-pump.c

index 4f56f925a544263e55e06d533685f507d87a7408..4e1f6714f4a8eb732c8b288524d573e6f4093558 100644 (file)
 #include <sys/types.h>
 #include <sys/socket.h>
 
+/* 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);