Fix TransferComplete RPC missed after reboot

This commit is contained in:
Suvendhu Hansa 2024-10-24 16:36:50 +05:30
parent 29298b70ad
commit 492e8a720c
7 changed files with 42 additions and 20 deletions

View file

@ -151,8 +151,6 @@ int cwmp_root_cause_transfer_complete(struct transfer_complete *p)
return CWMP_MEM_ERR;
}
CWMP_LOG(INFO, "%s: Added TransferComplete rpc for %d", __func__, p->type);
switch (p->type) {
case TYPE_DOWNLOAD:
event_container = cwmp_add_event_container(EVENT_IDX_M_Download, p->command_key ? p->command_key : "");

View file

@ -98,13 +98,6 @@ int cwmp_session_rpc_destructor(struct rpc *rpc)
return CWMP_OK;
}
int cwmp_session_exit()
{
rpc_exit();
icwmp_cleanmem();
return CWMP_OK;
}
static int cwmp_rpc_cpe_handle_message(struct rpc *rpc_cpe)
{
if (xml_prepare_msg_out())
@ -305,8 +298,6 @@ void rpc_exit()
if (!rpc)
break;
CWMP_LOG(INFO, "%s: Removed rpc %d", __func__, rpc->type);
if (rpc_acs_methods[rpc->type].extra_clean != NULL)
rpc_acs_methods[rpc->type].extra_clean(rpc);
cwmp_session_rpc_destructor(rpc);
@ -315,6 +306,27 @@ void rpc_exit()
FREE(cwmp_main->session->rpc_cpe);
}
void remove_inform_getrpc()
{
if (cwmp_main == NULL || cwmp_main->session == NULL)
return;
if (!list_empty(&(cwmp_main->session->head_rpc_acs))) {
while (cwmp_main->session->head_rpc_acs.next != &(cwmp_main->session->head_rpc_acs)) {
struct rpc *rpc = list_entry(cwmp_main->session->head_rpc_acs.next, struct rpc, list);
if (!rpc)
break;
if (rpc->type == RPC_ACS_GET_RPC_METHODS || rpc->type == RPC_ACS_INFORM) {
if (rpc_acs_methods[rpc->type].extra_clean != NULL)
rpc_acs_methods[rpc->type].extra_clean(rpc);
cwmp_session_rpc_destructor(rpc);
}
}
}
FREE(cwmp_main->session->rpc_cpe);
}
static void schedule_session_retry(void)
{
cwmp_main->retry_count_session++;
@ -350,8 +362,12 @@ void start_cwmp_session(void)
if (is_ipv6_status_changed()) {
if (icwmp_check_http_connection() != CWMP_OK || cwmp_stop) {
CWMP_LOG(INFO, "Failed to check http connection");
if (!cwmp_stop)
if (!cwmp_stop) {
/* clear inform and getrpc method from rpc list.
* These will be added in next session init */
remove_inform_getrpc();
schedule_session_retry();
}
return;
}
}
@ -397,13 +413,15 @@ void start_cwmp_session(void)
if (cwmp_stop) {
cwmp_remove_all_session_events();
run_session_end_func();
cwmp_session_exit();
rpc_exit();
icwmp_cleanmem();
return;
}
if (cwmp_main->session->error == CWMP_RETRY_SESSION && (!list_empty(&(cwmp_main->session->events)) || (list_empty(&(cwmp_main->session->events)) && cwmp_main->cwmp_cr_event == 0))) { //CWMP Retry session
CWMP_LOG(ERROR, "%s: Session will be retried soon", __func__);
// clear inform and getrpc method from rpc list. These will be added in next session init
remove_inform_getrpc();
schedule_session_retry();
} else {
save_acs_bkp_config();
@ -413,6 +431,8 @@ void start_cwmp_session(void)
remove_single_event(EVENT_IDX_14HEARTBEAT);
}
// clear all rpc from lists if exist any
rpc_exit();
cwmp_main->retry_count_session = 0;
set_cwmp_session_status(SESSION_SUCCESS, 0);
if (cwmp_main->throttle_session_triggered == true) {
@ -425,7 +445,7 @@ void start_cwmp_session(void)
}
}
run_session_end_func();
cwmp_session_exit();
icwmp_cleanmem();
if (cwmp_main->acs_changed) {
CWMP_LOG(INFO, "%s: Schedule session with new ACS since URL changed", __func__);

View file

@ -110,9 +110,9 @@ int create_cwmp_session_structure();
int clean_cwmp_session_structure();
void set_cwmp_session_status(int status, int retry_time);
int cwmp_session_init();
int cwmp_session_exit();
int cwmp_schedule_rpc();
int cwmp_apply_acs_changes(void);
void rpc_exit();
void remove_inform_getrpc();
void trigger_cwmp_restart_timer(void);
#endif /* SRC_INC_SESSION_H_ */

View file

@ -59,7 +59,8 @@ static int cwmp_cli_unit_tests_init(void **state)
static int cwmp_cli_unit_tests_clean(void **state)
{
icwmp_free_list_services();
cwmp_session_exit();
rpc_exit();
icwmp_cleanmem();
FREE(cwmp_main->session);
FREE(cwmp_main);
FREE(add_instance);

View file

@ -42,7 +42,8 @@ static int dm_iface_unit_tests_clean(void **state)
icwmp_free_list_services();
cwmp_free_all_list_param_fault(&faults_array);
cwmp_free_all_dm_parameter_list(&list_set_param_value);
cwmp_session_exit();
rpc_exit();
icwmp_cleanmem();
clean_cwmp_session_structure();
FREE(cwmp_main);
return 0;

View file

@ -40,7 +40,8 @@ static int cwmp_notifications_unit_tests_clean(void **state)
clean_list_param_notify();
clean_list_value_change();
cwmp_free_all_dm_parameter_list(&parameters_list);
cwmp_session_exit();
rpc_exit();
icwmp_cleanmem();
FREE(cwmp_main->session);
FREE(cwmp_main);
return 0;

View file

@ -87,7 +87,8 @@ static int soap_unit_tests_clean(void **state)
{
icwmp_free_list_services();
clean_name_space();
cwmp_session_exit();
rpc_exit();
icwmp_cleanmem();
clean_force_inform_list();
FREE(cwmp_main->session);
FREE(cwmp_main);