Message ID | 20220126081112.14960-1-christian.storm@siemens.com |
---|---|
State | Accepted |
Headers | show |
Series | server_general: short-circuit on update already installed | expand |
On 26.01.22 09:11, Christian Storm wrote: > If there's an already installed update pending testing, there is > no sense in communicating with the General Purpose HTTP Server just > to rediscover this fact, hence abort server_has_pending_action() > early in this case. > > Signed-off-by: Christian Storm <christian.storm@siemens.com> > --- > suricatta/server_general.c | 24 ++++++------------------ > 1 file changed, 6 insertions(+), 18 deletions(-) > > diff --git a/suricatta/server_general.c b/suricatta/server_general.c > index 59d0089..e674441 100644 > --- a/suricatta/server_general.c > +++ b/suricatta/server_general.c > @@ -485,28 +485,16 @@ static server_op_res_t server_get_deployment_info(channel_t *channel, channel_da > > server_op_res_t server_has_pending_action(int *action_id) > { > - > - channel_data_t channel_data = channel_data_defaults; > - server_op_res_t result = > - server_get_deployment_info(server_general.channel, > - &channel_data); > - > - /* > - * action_id is not used by this server > - * There is no memory between one call and the next one > - */ > *action_id = 0; > > - if ((result == SERVER_UPDATE_AVAILABLE) && > - (get_state() == STATE_INSTALLED)) { > - WARN("An already installed update is pending testing, " > - "ignoring available update action."); > - INFO("Please restart SWUpdate to report the test results " > - "upstream."); > - result = SERVER_NO_UPDATE_AVAILABLE; > + if (get_state() == STATE_INSTALLED) { > + WARN("An already installed update is pending testing."); > + return SERVER_NO_UPDATE_AVAILABLE; > } > > - return result; > + channel_data_t channel_data = channel_data_defaults; > + return server_get_deployment_info(server_general.channel, > + &channel_data); > } > > server_op_res_t server_send_target_data(void) Applied to -master, thanks ! Best regards, Stefano Babic
diff --git a/suricatta/server_general.c b/suricatta/server_general.c index 59d0089..e674441 100644 --- a/suricatta/server_general.c +++ b/suricatta/server_general.c @@ -485,28 +485,16 @@ static server_op_res_t server_get_deployment_info(channel_t *channel, channel_da server_op_res_t server_has_pending_action(int *action_id) { - - channel_data_t channel_data = channel_data_defaults; - server_op_res_t result = - server_get_deployment_info(server_general.channel, - &channel_data); - - /* - * action_id is not used by this server - * There is no memory between one call and the next one - */ *action_id = 0; - if ((result == SERVER_UPDATE_AVAILABLE) && - (get_state() == STATE_INSTALLED)) { - WARN("An already installed update is pending testing, " - "ignoring available update action."); - INFO("Please restart SWUpdate to report the test results " - "upstream."); - result = SERVER_NO_UPDATE_AVAILABLE; + if (get_state() == STATE_INSTALLED) { + WARN("An already installed update is pending testing."); + return SERVER_NO_UPDATE_AVAILABLE; } - return result; + channel_data_t channel_data = channel_data_defaults; + return server_get_deployment_info(server_general.channel, + &channel_data); } server_op_res_t server_send_target_data(void)
If there's an already installed update pending testing, there is no sense in communicating with the General Purpose HTTP Server just to rediscover this fact, hence abort server_has_pending_action() early in this case. Signed-off-by: Christian Storm <christian.storm@siemens.com> --- suricatta/server_general.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)