FirmwareImage: Fix race condition

This commit is contained in:
Vivek Kumar Dutta 2023-09-06 15:57:11 +00:00 committed by Amin Ben Romdhane
parent d0d3480ef6
commit 686c4a9fd6

View file

@ -461,10 +461,6 @@ int bbf_fw_image_download(const char *url, const char *auto_activate, const char
long res_code = download_file(fw_image_path, url, username, password); long res_code = download_file(fw_image_path, url, username, password);
time_t complete_time = time(NULL); time_t complete_time = time(NULL);
// Send Transfer Complete Event
// TODO according to tr069 standard TransferComplete should be sent after applying the downloaded image
send_transfer_complete_event(command, obj_path, url, res_code, start_time, complete_time,commandKey, "Download");
// Check if the download operation was successful // Check if the download operation was successful
if (!get_response_code_status(url, res_code)) { if (!get_response_code_status(url, res_code)) {
res = -1; res = -1;
@ -488,8 +484,12 @@ int bbf_fw_image_download(const char *url, const char *auto_activate, const char
} }
sleep(30); // Wait for the image to become available sleep(30); // Wait for the image to become available
// Send the transfer complete after image applied
send_transfer_complete_event(command, obj_path, url, res_code, start_time, complete_time, commandKey, "Download");
// Reboot the device if auto activation is true // Reboot the device if auto activation is true
if (activate) { if (activate) {
sleep(5); // added additional buffer for TransferComplete! event
if (dmubus_call_set("system", "reboot", UBUS_ARGS{0}, 0) != 0) if (dmubus_call_set("system", "reboot", UBUS_ARGS{0}, 0) != 0)
res = -1; res = -1;
sleep(10); // Wait for reboot to take action sleep(10); // Wait for reboot to take action