Add memory leak fixes && delete some script output

This commit is contained in:
Omar Kallel 2020-12-21 11:24:05 +01:00
parent 1dffd92c0a
commit edb34e1e8d
3 changed files with 21 additions and 16 deletions

View file

@ -14,6 +14,8 @@
bool transaction_started = false;
int transaction_id = 0;
json_object *old_global_json_obj = NULL;
json_object *actual_global_json_obj = NULL;
json_object *old_list_notify = NULL;
json_object *actual_list_notify = NULL;
@ -381,18 +383,28 @@ char* cwmp_set_parameter_attributes(char* parameter_name, char* notification)
int cwmp_update_enabled_list_notify(int instance_mode, int notify_type)
{
int e;
json_object *list_notif_obj = NULL;
e = cwmp_ubus_call("usp.raw", "list_notify", CWMP_UBUS_ARGS{{"instance_mode", {.int_val=instance_mode}, UBUS_Integer}}, 1, &list_notif_obj);
if (e)
return e;
CWMP_LOG (INFO,"Get List Notify for %s paramters values", notify_type == OLD_LIST_NOTIFY ? "old": "actual");
if (notify_type == OLD_LIST_NOTIFY) {
CWMP_LOG (INFO,"%s line %d", __FILE__, __LINE__);
FREE_JSON(old_list_notify)
json_object_object_get_ex(list_notif_obj, "parameters", &old_list_notify);
FREE_JSON(old_global_json_obj)
CWMP_LOG (INFO,"%s:%s line %d", __FILE__, __FUNCTION__, __LINE__);
e = cwmp_ubus_call("usp.raw", "list_notify", CWMP_UBUS_ARGS{{"instance_mode", {.int_val=instance_mode}, UBUS_Integer}}, 1, &old_global_json_obj);
if (e)
return e;
json_object_object_get_ex(old_global_json_obj, "parameters", &old_list_notify);
CWMP_LOG (INFO,"%s line %d", __FILE__, __LINE__);
}
else {
CWMP_LOG (INFO,"%s line %d", __FILE__, __LINE__);
FREE_JSON(actual_list_notify)
json_object_object_get_ex(list_notif_obj, "parameters", &actual_list_notify);
FREE_JSON(actual_global_json_obj)
CWMP_LOG (INFO,"%s line %d", __FILE__, __FUNCTION__, __LINE__);
e = cwmp_ubus_call("usp.raw", "list_notify", CWMP_UBUS_ARGS{{"instance_mode", {.int_val=instance_mode}, UBUS_Integer}}, 1, &actual_global_json_obj);
if (e)
return e;
json_object_object_get_ex(actual_global_json_obj, "parameters", &actual_list_notify);
CWMP_LOG (INFO,"%s line %d", __FILE__, __FUNCTION__, __LINE__);
}
//FREE_JSON(list_notif_obj)
return 0;
}

View file

@ -9,6 +9,8 @@
#define DM_ROOT_OBJ "Device."
extern bool transaction_started;
extern int transaction_id;
extern json_object *old_global_json_obj;
extern json_object *actual_global_json_obj;
extern json_object *old_list_notify;
extern json_object *actual_list_notify;

View file

@ -195,13 +195,10 @@ handle_action() {
if [ -z `echo $set_res | jsonfilter -e @.fault` ]; then
if [ `echo $set_res | jsonfilter -e @.status` = true ]; then
ubus call usp.raw transaction_commit "{'transaction_id':$transaction_id}" &> /dev/null
echo "Parameter is successfully set"
else
echo "Not able to set parameter"
ubus call usp.raw transaction_abort "{'transaction_id':$transaction_id}" &> /dev/null
fi
else
echo "Not able to set parameter"
ubus call usp.raw transaction_abort "{'transaction_id':$transaction_id}" &> /dev/null
fi
echo $set_res
@ -219,13 +216,10 @@ handle_action() {
if [ -z `echo $set_notif | jsonfilter -e @.fault` ]; then
if [ -z `echo $set_notif | jsonfilter -e @.parameters[0].fault` ]; then
ubus call usp.raw transaction_commit "{'transaction_id':$transaction_id}" &> /dev/null
echo "Parameter notification is successfully set"
else
echo "Not able to set parameter notification"
ubus call usp.raw transaction_abort "{'transaction_id':$transaction_id}" &> /dev/null
fi
else
echo "Not able to set parameter"
ubus call usp.raw transaction_abort "{'transaction_id':$transaction_id}" &> /dev/null
fi
echo $set_notif
@ -243,13 +237,10 @@ handle_action() {
if [ -z `echo $adddel_obj_res | jsonfilter -e @.fault` ]; then
if [ -z `echo $adddel_obj_res | jsonfilter -e @.parameters[0].fault` ]; then
ubus call usp.raw transaction_commit "{'transaction_id':$transaction_id}" &> /dev/null
echo "Add/Delete operation successfully done"
else
echo "Add/Delete operation failed"
ubus call usp.raw transaction_abort "{'transaction_id':$transaction_id}" &> /dev/null
fi
else
echo "Not able to set parameter"
ubus call usp.raw transaction_abort "{'transaction_id':$transaction_id}" &> /dev/null
fi
echo $adddel_obj_res