Hi Stefan,
On 29.04.21 20:14, Stefan Herbrechtsmeier wrote:
> Hi Stefano,
>
> why does the swupdate-progress restarts the system after SUCCESS and not
> after DONE?
>
>> case SUCCESS:
>> case FAILURE:
>
> [snip]
>
>> if ((msg.status == SUCCESS) && (msg.cur_step > 0) && opt_r) {
>> sleep(5);
>> if (system("reboot") < 0) { /* It should never happen */
>> fprintf(stdout, "Please reset the board.\n");
>> }
>> }
>> wait_update = true;
>> break;
>> case DONE:
>> fprintf(stdout, "\nDONE.\n\n");
>> break;
>
> The function postupdate in the source file installer.c sends a DONE
> before the post update command
I just think it was not checked in code that the behavior is exactly the
same, and there is no special reason to do in different way. I looked in
code all occurrences of postupdate. The switch to perform an action
remains the result of an update should check SUCCESS or FAILURE. For the
Webserver:
226 if (msg.status == SUCCESS && msg.source ==
SOURCE_WEBSERVER && run_postupdate) {
227 ipc_message ipc = {};
228
229 ipc_postupdate(&ipc);
230 }
So at least swupdate-progress and Webserver seem in sync (or do you mean
they are not ?).
Another actor is swupdate-client, but it looks to me consistent, too:
106
107 if (status == SUCCESS && run_postupdate) {
108 fprintf(stdout, "Executing post-update actions.\n");
109 ipc_message msg;
110 if (ipc_postupdate(&msg) != 0)
111 fprintf(stderr, "Running post-update
failed!\n");
112 }
So action when SUCCESS or FAILURE is received.
In core/install_from_file.c, there is another use case:
50 static int endupdate(RECOVERY_STATUS status)
51 {
52 end_status = (status == SUCCESS) ? EXIT_SUCCESS :
EXIT_FAILURE;
53
54 INFO("Swupdate %s\n",
55 status == FAILURE ? "*failed* !" :
56 "was successful !");
57
58 if (status == SUCCESS) {
59 ipc_message msg;
60 msg.data.procmsg.len = 0;
61 if (ipc_postupdate(&msg) != 0 || msg.type != ACK) {
All of them are waiting for SUCCESS or FAILURE. IMHO this is the value
to be parsed, even if the state machine goes further and it will reach
the DONE and then back to IDLE.
Nevertheless, if there is some discrepancy, it is now mitigated by the
delay before executing the command, and drawbacks are maybe hidden. Do
you have seen a concrete problem ? Can you show it ?
>
>>
>> int postupdate(struct swupdate_cfg *swcfg, const char *info)
>> {
>> swupdate_progress_done(info);
>>
>> if (swcfg) {
>> if (swcfg->parms.dry_run) {
>> DEBUG("Dry run, skipping Post-update command");
>> } else {
>> DEBUG("Running Post-update command");
>> return run_system_cmd(swcfg->postupdatecmd);
>> }
>>
>> }
>>
>> return 0;
>> }
>
> This leads to a different behavior between "swupdate-progress -r" and
> "swupdate -p reboot" if somebody like the web-app triggers a reboot via
> ipc_postupdate.
I am not sure, it looks to me that Webserver is looking for SUCCESS as well.
Best regards,
Stefano
--
=====================================================================
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone:
+49-8142-66989-53 Fax:
+49-8142-66989-80 Email:
sba...@denx.de
=====================================================================