Dear Genodians,
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.
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.
Best regards, Timo
--
Timo Nicolai
Operating Systems Engineer
Gapfruit AG
Baarerstrasse 135
6300 Zug - Switzerland
timo.nico...@gapfruit.com
https://gapfruit.com
From a0a9c8c9a38a2f7bad26d414f45e5c1b694e0c16 Mon Sep 17 00:00:00 2001
From: Timo Nicolai <timo.nico...@gapfruit.com>
Date: Tue, 21 Mar 2023 19:25:18 +0100
Subject: [PATCH 1/1] fetchurl: avoid needless restarts
Fixes an issue with the fetchurl watchdog which would restart it
immediately on some platforms due to an early first return of
`Timer::trigger_once`.
---
.../src/app/depot_download_manager/main.cc | 20 ++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/repos/gems/src/app/depot_download_manager/main.cc b/repos/gems/src/app/depot_download_manager/main.cc
index d2786e9047..7e120713ea 100644
--- a/repos/gems/src/app/depot_download_manager/main.cc
+++ b/repos/gems/src/app/depot_download_manager/main.cc
@@ -250,24 +250,26 @@ struct Depot_download_manager::Main : Import::Download_progress
void _handle()
{
- if (_main._downloaded_bytes != _observed_downloaded_bytes) {
+ if (_main._downloaded_bytes == _observed_downloaded_bytes) {
+ warning("fetchurl got stuck, respawning");
+
+ /* downloads got stuck, try replacing fetchurl with new instance */
+ _main._fetchurl_count.value++;
+ _main._generate_init_config();
+
+ } else {
_observed_downloaded_bytes = _main._downloaded_bytes;
- return;
}
- warning("fetchurl got stuck, respawning");
-
- /* downloads got stuck, try replacing fetchurl with new instance */
- _main._fetchurl_count.value++;
- _main._generate_init_config();
+ _timer.trigger_once(PERIOD_US);
}
- enum { PERIOD_SECONDS = 10UL };
+ enum : Genode::uint64_t { PERIOD_US = 10 * 1000 * 1000 };
Fetchurl_watchdog(Main &main) : _main(main)
{
_timer.sigh(_handler);
- _timer.trigger_periodic((Genode::uint64_t)PERIOD_SECONDS*1000*1000);
+ _timer.trigger_once(PERIOD_US);
}
};
--
2.34.1
_______________________________________________
Genode users mailing list
users@lists.genode.org
https://lists.genode.org/listinfo/users