diff --git a/repos/gems/src/app/depot_download_manager/main.cc b/repos/gems/src/app/depot_download_manager/main.cc index 7dc2e6a814..6aa4a2d4d2 100644 --- a/repos/gems/src/app/depot_download_manager/main.cc +++ b/repos/gems/src/app/depot_download_manager/main.cc @@ -240,22 +240,28 @@ struct Depot_download_manager::Main : Import::Download_progress uint64_t _observed_downloaded_bytes = _main._downloaded_bytes; + uint64_t _started_ms = _timer.elapsed_ms(); + + enum { PERIOD_SECONDS = 5UL }; + void _handle() { - if (_main._downloaded_bytes != _observed_downloaded_bytes) { - _observed_downloaded_bytes = _main._downloaded_bytes; + uint64_t const now_ms = _timer.elapsed_ms(); + + bool starting_up = (now_ms - _started_ms < PERIOD_SECONDS*1000); + bool made_progress = (_main._downloaded_bytes != _observed_downloaded_bytes); + + if (starting_up || made_progress) return; - } warning("fetchurl got stuck, respawning"); /* downloads got stuck, try replacing fetchurl with new instance */ _main._fetchurl_count.value++; _main._generate_init_config(); + _started_ms = now_ms; } - enum { PERIOD_SECONDS = 5UL }; - Fetchurl_watchdog(Main &main) : _main(main) { _timer.sigh(_handler);