add incremental interval backoff

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2025-07-17 09:48:25 +02:00
parent 4a5cf875d9
commit 89ac58b48f

View File

@@ -26,6 +26,7 @@ let timeouts = {
'offline': 4 * 60 * 60,
'validate': 120,
'orphan': 2 * 60 * 60,
interval: 10000,
};
ulog_open(ULOG_SYSLOG | ULOG_STDIO, LOG_DAEMON, "cloud_discover");
@@ -196,6 +197,19 @@ function time_is_valid() {
function interval_handler() {
printf(`State ${state}\n`);
switch(state) {
case DISCOVER:
if (timeouts.interval < 60000)
timeouts.interval += 10000;
break;
default:
timeouts.interval = 10000;
break;
}
printf('setting interval to %d\n', timeouts.interval);
interval.set(timeouts.interval);
switch(state) {
case ORPHAN:
if (time() - orphan_time <= timeouts.orphan_skew)
@@ -329,7 +343,7 @@ if (gateway_available()) {
timeouts_load();
interval = uloop.interval(10000, interval_handler);
interval = uloop.interval(timeouts.interval, interval_handler);
ubus.publish('cloud', ubus_methods);