Hello Nicolai,
On Wed, Apr 12, 2023 at 09:05:21 CEST, Timo Nicolai wrote:
I have noticed that at least when running on Linux, the fetchurl component started by depot_download_manager will always restart immediately after it is first executed (before anything has been downloaded). After that the download proceeds as normal.
This is because Fetchurl_watchdog uses trigger_periodic to trigger the timer handler which checks the current download progress. As a consequence, this handler /might/ be called immediately, before fetchurl has had the chance to do any work.
Your investigation nails it: the first periodic timeout triggers (almost) immediately. I stumbled upon this undocumented behavior of periodic timeouts in a different context myself recently [1].
I believe this is a bug, but one that might not manifest on all platforms due to the uncertain timing introduced by trigger_periodic.
I have attached a potential patch, if this sounds okay to you I will open an Issue on GitHub.
AFAICS your patch fixes the issue for fetchurl. Nevertheless, I favor the use of periodic timeouts in proper contexts over oneshot timeouts. How about keeping the periodic timeout and handling the _initial_ state in Fetchurl_watchdog::_handle()?
[1] https://github.com/genodelabs/genode/commit/7feea78991285c6c3b3c0f83659b80c6...
Regards