# HG changeset patch # User Guido Berhoerster # Date 1604930764 -3600 # Node ID 8ed91c5e01166e2fb5b7c51e83dda1067744b27d # Parent 4a859595eabd5b1b9d324f00ea8b5f17fe5c799b Explicitly schedule the initial check for updates after a fixed short delay Explicitly schedule the first check after startup to run after a short delay defined in PUI_STARTUP_DELAY. This was always intended but not correctly handled before, the first check could thus take up to the number of seconds defined in PUI_CHECK_UPDATES_INTERVAL. diff -r 4a859595eabd -r 8ed91c5e0116 pui-backend.c --- a/pui-backend.c Thu Nov 05 11:18:16 2020 +0100 +++ b/pui-backend.c Mon Nov 09 15:06:04 2020 +0100 @@ -290,23 +290,33 @@ g_debug("perioidic checks inhibited: low battery"); } } else { - /* schedule periodic checks when no longer inhibited */ - elapsed_time = (g_get_monotonic_time() - self->last_check) / - G_USEC_PER_SEC; - /* - * if more time that the check interval has passed since the - * last check, schedule a check after a short delay, otherwise - * wait until the interval has passed - */ - remaining_time = (elapsed_time < PUI_CHECK_UPDATES_INTERVAL) ? - PUI_CHECK_UPDATES_INTERVAL - elapsed_time : - PUI_STARTUP_DELAY; + if (self->last_check == 0) { + /* first check after startup */ + remaining_time = PUI_STARTUP_DELAY; + + g_debug("scheduled first check in: %ds", + remaining_time); + } else { + /* schedule periodic checks when no longer inhibited */ + elapsed_time = + (g_get_monotonic_time() - self->last_check) / + G_USEC_PER_SEC; + /* + * if more time than the check interval has passed + * since the last check, schedule a check after a short + * delay, otherwise wait until the interval has passed + */ + remaining_time = + (elapsed_time < PUI_CHECK_UPDATES_INTERVAL) ? + PUI_CHECK_UPDATES_INTERVAL - elapsed_time : + PUI_STARTUP_DELAY; + + g_debug("perioidic checks no longer inhibited, " + "time since last check: %ds, next check in: %ds", + elapsed_time, remaining_time); + } self->check_id = g_timeout_add_seconds(remaining_time, periodic_check, self); - - g_debug("perioidic checks no longer inhibited, time since " - "last check: %ds, next check in: %ds", elapsed_time, - remaining_time); } }