There are several issues with the timeout argument in DiscoverSched::getNetnames:
Mixed units. The docstring and the usage indicates that the timeout is expressed in milliseconds, but then its compared in min() against seconds
/* Wait at least two seconds to give all schedulers a chance to answer
(unless that'd be longer than the timeout).*/
time_t timeout_time = time(nullptr) + min(2 + 1, timeout); // <-- timeout is in ms, time() is in seconds
The timeout of the do/while loop is based on a wall clock instead of a monotonic clock. It's susceptible to wall clock changes (ntpdate).
The granularity of the do/while loop has a 1 second precision because it's based on time(). The timeout is an integer, divided by 1000. The only case where this method is called, it's called with timeout 200, meaning that the timeout is effectively 0 seconds. This means that this do/while loop always runs exactly once.
There are several issues with the timeout argument in
DiscoverSched::getNetnames
:min()
against secondsntpdate
).time()
. Thetimeout
is an integer, divided by 1000. The only case where this method is called, it's called withtimeout
200, meaning that the timeout is effectively 0 seconds. This means that this do/while loop always runs exactly once.