The function hawkbit_pull_cb in hawkbit-client.c handles only one action (download or cancellation) every time it runs.
In cases where a device has many pending actions and has a sensible poll interval, the update is delayed for a significantly long time.
For instance, if a device has 6 updates assigned to it, of which 5 are cancelled and 1 is available for download, and it has been configured to poll the server every 15 minutes, it will take one hour and 15 minutes before it starts downloading the update.
While this isn't a problem for any devices in the field and online, it is a problem for devices that are either offline for a long period, or in our case, devices that have not been deployed yet.
I propose a simple patch for this solution for now: simply set the poll period to a much smaller value until no actions remain. In this patch, I have it set to 10 seconds
diff --git a/src/hawkbit-client.c b/src/hawkbit-client.c
index 75cbd03..9c27194 100644
--- a/src/hawkbit-client.c
+++ b/src/hawkbit-client.c
@@ -1327,6 +1327,10 @@ static gboolean hawkbit_pull_cb(gpointer user_data)
g_autoptr(JsonParser) json_response_parser = NULL;
JsonNode *json_root = NULL;
+ gboolean no_downloads = FALSE;
+ gboolean no_cancellations = FALSE;
+
g_return_val_if_fail(user_data, FALSE);
if (++data->last_run_sec < data->hawkbit_interval_check_sec)
@@ -1379,6 +1383,7 @@ static gboolean hawkbit_pull_cb(gpointer user_data)
}
} else {
g_message("No new software.");
+ no_downloads = TRUE;
}
if (json_contains(json_root, "$._links.cancelAction")) {
res = process_cancel(json_root, &error);
@@ -1386,10 +1391,12 @@ static gboolean hawkbit_pull_cb(gpointer user_data)
g_warning("%s", error->message);
g_clear_error(&error);
}
+ } else {
+ no_cancellations = TRUE;
}
// get hawkbit sleep time (how often should we check for new software)
- data->hawkbit_interval_check_sec = json_get_sleeptime(json_root);
+ data->hawkbit_interval_check_sec = (no_downloads && no_cancellations) ? json_get_sleeptime(json_root) : 10;
out:
if (run_once) {
The function
hawkbit_pull_cbin hawkbit-client.c handles only one action (download or cancellation) every time it runs.In cases where a device has many pending actions and has a sensible poll interval, the update is delayed for a significantly long time.
For instance, if a device has 6 updates assigned to it, of which 5 are cancelled and 1 is available for download, and it has been configured to poll the server every 15 minutes, it will take one hour and 15 minutes before it starts downloading the update.
While this isn't a problem for any devices in the field and online, it is a problem for devices that are either offline for a long period, or in our case, devices that have not been deployed yet.
I propose a simple patch for this solution for now: simply set the poll period to a much smaller value until no actions remain. In this patch, I have it set to 10 seconds