Fix timeout handling

slirp_pollfds_fill() expects *timeout to be set to the minimum timeout value
(i.e., the soonest timeout) the calling function currently has to fulfill.
The value `0` really is a timeout of zero (i.e., expires immediately).
There is no explicit value for no timeout (i.e., an infinite timeout) in
libslirp but UINT32_MAX (u32::MAX) can be used instead as libslirp will only
decrease *timeout if libslirp needs a smaller (i.e., sooner) timeout.

The same technique (set *timeout = UINT32_MAX, check for UINT32_MAX after
calling slirp_pollfds_fill()) is also used by QEMU in

Note that currently, slirp_pollfds_fill() will never set *timeout to a
larger value than 1000 (i.e., the timeout will never be later than in 1 second)
in <>.
This means that, currently, `timeout == u32::MAX` will always be false but
later version of libslirp might change this behavior.

Signed-off-by: Rafael Gieschke <>
1 job for fix-timeout in 1 minute and 38 seconds (queued for 25 seconds)
Status Name Job ID Coverage
failed test:cargo #16207442


Name Stage Failure
test:cargo Test
OSError: [Errno 101] Network is unreachable

Ran 17 tests in 0.917s

FAILED (errors=3)
sys:1: ResourceWarning: unclosed file <_io.BufferedReader name='/proc/self/ns/net'>
make: *** [Makefile:11: test] Error 1
Cleaning up file based variables
ERROR: Job failed: exit code 1