Fix TransferComplete RPC missed after reboot

This commit is contained in:
Suvendhu Hansa 2024-10-24 17:31:22 +05:30 committed by Vivek Kumar Dutta
parent 0d99484a9a
commit a1e77afd6f
6 changed files with 44 additions and 15 deletions

View file

@ -103,13 +103,6 @@ int cwmp_session_rpc_destructor(struct rpc *rpc)
return CWMP_OK; 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) static int cwmp_rpc_cpe_handle_message(struct rpc *rpc_cpe)
{ {
if (xml_prepare_msg_out()) if (xml_prepare_msg_out())
@ -312,6 +305,29 @@ void rpc_exit()
FREE(cwmp_ctx.session->rpc_cpe); FREE(cwmp_ctx.session->rpc_cpe);
} }
void remove_inform_getrpc()
{
if (cwmp_ctx.session == NULL)
return;
if (!list_empty(&(cwmp_ctx.session->head_rpc_acs))) {
struct list_head *ilist, *q;
list_for_each_safe (ilist, q, &(cwmp_ctx.session->head_rpc_acs)) {
struct rpc *rpc = list_entry(ilist, 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_ctx.session->rpc_cpe);
}
static void schedule_session_retry(void) static void schedule_session_retry(void)
{ {
cwmp_ctx.retry_count_session++; cwmp_ctx.retry_count_session++;
@ -347,8 +363,12 @@ void start_cwmp_session(void)
if (is_ipv6_status_changed()) { if (is_ipv6_status_changed()) {
if (icwmp_check_http_connection() != CWMP_OK || cwmp_stop) { if (icwmp_check_http_connection() != CWMP_OK || cwmp_stop) {
CWMP_LOG(INFO, "Failed to check http connection"); 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(); schedule_session_retry();
}
return; return;
} }
} }
@ -394,12 +414,15 @@ void start_cwmp_session(void)
if (cwmp_stop) { if (cwmp_stop) {
cwmp_remove_all_session_events(); cwmp_remove_all_session_events();
run_session_end_func(); run_session_end_func();
cwmp_session_exit(); rpc_exit();
icwmp_cleanmem();
return; return;
} }
if (cwmp_ctx.session->error == CWMP_RETRY_SESSION && (!list_empty(&(cwmp_ctx.session->events)) || (list_empty(&(cwmp_ctx.session->events)) && cwmp_ctx.cwmp_cr_event == 0))) { //CWMP Retry session if (cwmp_ctx.session->error == CWMP_RETRY_SESSION && (!list_empty(&(cwmp_ctx.session->events)) || (list_empty(&(cwmp_ctx.session->events)) && cwmp_ctx.cwmp_cr_event == 0))) { //CWMP Retry session
// clear inform and getrpc method from rpc list. These will be added in next session init
remove_inform_getrpc();
schedule_session_retry(); schedule_session_retry();
} else { } else {
save_acs_bkp_config(); save_acs_bkp_config();
@ -409,6 +432,8 @@ void start_cwmp_session(void)
remove_single_event(EVENT_IDX_14HEARTBEAT); remove_single_event(EVENT_IDX_14HEARTBEAT);
} }
// clear all rpc from lists if exist any
rpc_exit();
cwmp_ctx.retry_count_session = 0; cwmp_ctx.retry_count_session = 0;
set_cwmp_session_status(SESSION_SUCCESS, 0); set_cwmp_session_status(SESSION_SUCCESS, 0);
@ -431,7 +456,7 @@ void start_cwmp_session(void)
} }
} }
run_session_end_func(); run_session_end_func();
cwmp_session_exit(); icwmp_cleanmem();
if (cwmp_ctx.acs_changed) { if (cwmp_ctx.acs_changed) {
CWMP_LOG(INFO, "%s: Schedule session with new ACS since URL changed", __func__); CWMP_LOG(INFO, "%s: Schedule session with new ACS since URL changed", __func__);

View file

@ -103,8 +103,8 @@ void start_cwmp_session();
int create_cwmp_session_structure(); int create_cwmp_session_structure();
int clean_cwmp_session_structure(); int clean_cwmp_session_structure();
int cwmp_session_init(); int cwmp_session_init();
int cwmp_session_exit();
int cwmp_apply_acs_changes(void); int cwmp_apply_acs_changes(void);
void rpc_exit(); void rpc_exit();
void remove_inform_getrpc();
void trigger_cwmp_restart_timer(void); void trigger_cwmp_restart_timer(void);
#endif /* SRC_INC_SESSION_H_ */ #endif /* SRC_INC_SESSION_H_ */

View file

@ -56,7 +56,8 @@ static int cwmp_cli_unit_tests_init(void **state)
static int cwmp_cli_unit_tests_clean(void **state) static int cwmp_cli_unit_tests_clean(void **state)
{ {
cwmp_session_exit(); rpc_exit();
icwmp_cleanmem();
FREE(cwmp_ctx.session); FREE(cwmp_ctx.session);
FREE(add_instance); FREE(add_instance);
return 0; return 0;

View file

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

View file

@ -38,7 +38,8 @@ static int cwmp_notifications_unit_tests_clean(void **state)
clean_list_param_notify(); clean_list_param_notify();
clean_list_value_change(); clean_list_value_change();
cwmp_free_all_dm_parameter_list(&parameters_list); cwmp_free_all_dm_parameter_list(&parameters_list);
cwmp_session_exit(); rpc_exit();
icwmp_cleanmem();
FREE(cwmp_ctx.session); FREE(cwmp_ctx.session);
return 0; return 0;
} }

View file

@ -84,7 +84,8 @@ static int soap_unit_tests_init(void **state)
static int soap_unit_tests_clean(void **state) static int soap_unit_tests_clean(void **state)
{ {
clean_name_space(); clean_name_space();
cwmp_session_exit(); rpc_exit();
icwmp_cleanmem();
clean_force_inform_list(); clean_force_inform_list();
FREE(cwmp_ctx.session); FREE(cwmp_ctx.session);
return 0; return 0;