Retry GPN and GPV calls twice on failure to ensure path validity

This commit is contained in:
Amin Ben Romdhane 2024-05-24 10:26:56 +02:00
parent d2041138fc
commit 80f8f26836
3 changed files with 39 additions and 6 deletions

View file

@ -882,6 +882,23 @@ int cwmp_handle_rpc_cpe_get_parameter_names(struct rpc *rpc)
}
char *err = cwmp_get_parameter_names(parameter_name ? parameter_name : "", next_level, &parameters_list, &err_msg);
if (err) {
// If an error occurs, try up to two more times to ensure the path is invalid
for (int i = 0; i < 2; i++) {
CWMP_LOG(ERROR, "Failed to get parameter name for '%s', error: %s. Retrying in 1 second...", parameter_name ? parameter_name : "", err);
// Wait for 1 second before retrying
sleep(1);
// Retry to get the parameter name
err = cwmp_get_parameter_names(parameter_name ? parameter_name : "", next_level, &parameters_list, &err_msg);
// If the operation is successful, exit the loop
if (err == NULL)
break;
}
}
if (err) {
fault_code = cwmp_get_fault_code_by_string(err);
FREE(parameter_name);

View file

@ -613,9 +613,25 @@ int build_parameter_structure(mxml_node_t *param_list, struct xml_data_struct *x
if (xml_attrs->parameter_name == NULL)
return CWMP_OK;
if (xml_attrs->rpc_enum == SOAP_PARAM_STRUCT)
if (xml_attrs->rpc_enum == SOAP_PARAM_STRUCT) {
err = cwmp_get_parameter_values(*(xml_attrs->parameter_name), &parameters_list);
else if (xml_attrs->rpc_enum == SOAP_GPA_STRUCT)
if (err) {
// If an error occurs, try up to two more times to ensure the path is invalid
for (int i = 0; i < 2; i++) {
CWMP_LOG(ERROR, "Failed to get parameter value for '%s', error: %s. Retrying in 1 second...", *(xml_attrs->parameter_name), err);
// Wait for 1 second before retrying
sleep(1);
// Retry to get the parameter value
err = cwmp_get_parameter_values(*(xml_attrs->parameter_name), &parameters_list);
// If the operation is successful, exit the loop
if (err == NULL)
break;
}
}
} else if (xml_attrs->rpc_enum == SOAP_GPA_STRUCT)
err = cwmp_get_parameter_attributes(*(xml_attrs->parameter_name), &parameters_list);
else
return FAULT_CPE_INTERNAL_ERROR;

View file

@ -99,8 +99,8 @@ if [[ $res != *"9009"* ]]; then
fi
log "ADD METHOD: Correct Path"
res=$(./icwmpd -c add Device.DHCPv4.Relay.Forwarding. 2>&1)
if [[ $res != *"Device.DHCPv4.Relay.Forwarding."* ]]; then
res=$(./icwmpd -c add Device.X_IOPSYS_EU_Dropbear. 2>&1)
if [[ $res != *"Device.X_IOPSYS_EU_Dropbear."* ]]; then
log "Error: Add Method with correct path doesn't work correctly"
exit 1
fi
@ -129,8 +129,8 @@ if [[ $res != *"Deleted ${del_path}"* ]]; then
fi
log "DELETE METHOD: Correct Path && all instance"
res=$(./icwmpd -c del Device.DHCPv4.Relay.Forwarding. 2>&1)
if [[ $res != *"Deleted Device.DHCPv4.Relay.Forwarding."* ]]; then
res=$(./icwmpd -c del Device.X_IOPSYS_EU_Dropbear. 2>&1)
if [[ $res != *"Deleted Device.X_IOPSYS_EU_Dropbear."* ]]; then
log "Error: Delete Method with correct path && all instances doesn't work correctly"
exit 1
fi