Commit c1e680dd authored by Robert Schmidt's avatar Robert Schmidt

FlexRAN: free memory of statistics reports

parent 836f6c63
......@@ -646,14 +646,9 @@ int flexran_agent_mac_stats_reply(mid_t mod_id,
return -1;
}
int flexran_agent_mac_destroy_stats_reply(Protocol__FlexranMessage *msg) {
//TODO: Need to deallocate memory for the stats reply message
if(msg->msg_case != PROTOCOL__FLEXRAN_MESSAGE__MSG_STATS_REPLY_MSG)
goto error;
free(msg->stats_reply_msg->header);
int flexran_agent_mac_destroy_stats_reply(Protocol__FlexStatsReply *reply) {
int i, j, k;
Protocol__FlexStatsReply *reply = msg->stats_reply_msg;
Protocol__FlexDlCqiReport *dl_report;
Protocol__FlexUlCqiReport *ul_report;
Protocol__FlexPagingBufferReport *paging_report;
......@@ -744,20 +739,23 @@ int flexran_agent_mac_destroy_stats_reply(Protocol__FlexranMessage *msg) {
free(ul_report->pucch_dbm[j]);
}
free(ul_report->pucch_dbm);
free(ul_report);
}
if (reply->ue_report[i]->flags & PROTOCOL__FLEX_UE_STATS_TYPE__FLUST_MAC_STATS) {
for (j = 0; j < reply->ue_report[i]->mac_stats->n_mac_sdus_dl; j++)
free(reply->ue_report[i]->mac_stats->mac_sdus_dl[j]);
free(reply->ue_report[i]->mac_stats->mac_sdus_dl);
free(reply->ue_report[i]->mac_stats);
}
free(reply->ue_report[i]);
}
free(reply->ue_report);
// Free memory for all Cell reports
for (i = 0; i < reply->n_cell_report; i++) {
if (reply->cell_report[i]->flags & PROTOCOL__FLEX_CELL_STATS_TYPE__FLCST_NOISE_INTERFERENCE) {
free(reply->cell_report[i]->noise_inter_report);
free(reply->cell_report[i]);
}
free(reply->cell_report);
}
free(reply);
free(msg);
return 0;
error:
......
......@@ -53,7 +53,7 @@ int flexran_agent_mac_destroy_sf_trigger(Protocol__FlexranMessage *msg);
/* Statistics reply protocol message constructor and destructor */
int flexran_agent_mac_stats_reply(mid_t mod_id, const report_config_t *report_config, Protocol__FlexUeStatsReport **ue_report, Protocol__FlexCellStatsReport **cell_report);
int flexran_agent_mac_destroy_stats_reply(Protocol__FlexranMessage *msg);
int flexran_agent_mac_destroy_stats_reply(Protocol__FlexStatsReply *reply);
/* DL MAC scheduling decision protocol message constructor (empty command) and destructor */
int flexran_agent_mac_create_empty_dl_config(mid_t mod_id, Protocol__FlexranMessage **msg);
......
......@@ -136,6 +136,14 @@ int flexran_agent_pdcp_stats_reply(mid_t mod_id,
return -1;
}
int flexran_agent_pdcp_destroy_stats_reply(Protocol__FlexStatsReply *reply)
{
for (int i = 0; i < reply->n_ue_report; ++i) {
if (reply->ue_report[i]->pdcp_stats)
free(reply->ue_report[i]->pdcp_stats);
}
return 0;
}
int flexran_agent_register_pdcp_xface(mid_t mod_id)
......
......@@ -51,6 +51,7 @@ int flexran_agent_pdcp_stats_reply(mid_t mod_id,
const report_config_t *report_config,
Protocol__FlexUeStatsReport **ue_report,
Protocol__FlexCellStatsReport **cell_report);
int flexran_agent_pdcp_destroy_stats_reply(Protocol__FlexStatsReply *reply);
/* Get the stats from RAN API and aggregate them per USER*/
void flexran_agent_pdcp_aggregate_stats(const mid_t mod_id,
......
......@@ -493,7 +493,7 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id,
for (int i = 0; i < report_config->nr_ue; i++){
if (ue_report[i]->rrc_measurements->neigh_meas != NULL){
if (ue_report[i]->rrc_measurements && ue_report[i]->rrc_measurements->neigh_meas != NULL){
for (int j = 0; j < ue_report[i]->rrc_measurements->neigh_meas->n_eutra_meas; j++){
free(ue_report[i]->rrc_measurements->neigh_meas->eutra_meas[j]);
......@@ -510,6 +510,22 @@ int flexran_agent_rrc_stats_reply(mid_t mod_id,
return -1;
}
int flexran_agent_rrc_destroy_stats_reply(Protocol__FlexStatsReply *reply)
{
for (int i = 0; i < reply->n_ue_report; i++){
if (reply->ue_report[i]->rrc_measurements && reply->ue_report[i]->rrc_measurements->neigh_meas){
for (int j = 0; j < reply->ue_report[i]->rrc_measurements->neigh_meas->n_eutra_meas; j++){
free(reply->ue_report[i]->rrc_measurements->neigh_meas->eutra_meas[j]->meas_result);
free(reply->ue_report[i]->rrc_measurements->neigh_meas->eutra_meas[j]);
}
free(reply->ue_report[i]->rrc_measurements->neigh_meas->eutra_meas);
free(reply->ue_report[i]->rrc_measurements->neigh_meas);
free(reply->ue_report[i]->rrc_measurements);
}
}
return 0;
}
void flexran_agent_fill_rrc_ue_config(mid_t mod_id, rnti_t rnti,
Protocol__FlexUeConfig *ue_conf)
{
......
......@@ -58,7 +58,7 @@ void flexran_trigger_rrc_measurements (mid_t mod_id, MeasResults_t *);
/* Statistics reply protocol message constructor and destructor */
int flexran_agent_rrc_stats_reply(mid_t mod_id, const report_config_t *report_config, Protocol__FlexUeStatsReport **ue_report, Protocol__FlexCellStatsReport **cell_report);
int flexran_agent_rrc_destroy_stats_reply(Protocol__FlexranMessage *msg);
int flexran_agent_rrc_destroy_stats_reply(Protocol__FlexStatsReply *reply);
/* Fill the RRC part of a ue_config message */
void flexran_agent_fill_rrc_ue_config(mid_t mod_id, rnti_t rnti,
......
......@@ -113,7 +113,7 @@ Protocol__FlexranMessage* flexran_agent_handle_message (mid_t mod_id,
err_code = ((*agent_messages_callback[decoded_message->msg_case-1][decoded_message->msg_dir-1])(mod_id, (void *) decoded_message, &reply_message));
if ( err_code < 0 ){
goto error;
} else if (err_code == 1) { //If err_code > 1, we do not want to dispose the message yet
} else if (err_code == 0) { //If err_code > 1, we do not want to dispose the message yet
protocol__flexran_message__free_unpacked(decoded_message, NULL);
}
return reply_message;
......@@ -653,14 +653,16 @@ int flexran_agent_destroy_stats_reply(Protocol__FlexranMessage *msg)
return -1;
}
flexran_agent_mac_destroy_stats_reply((Protocol__FlexranMessage *)msg->stats_reply_msg);
// TODO implement rrc_destroy_stats_reply()
//flexran_agent_rrc_destroy_stats_reply(msg->stats_reply_msg);
// TODO implement pdcp_destroy_stats_reply()
//flexran_agent_pdcp_destroy_stats_reply(msg->stats_reply_msg);
free(msg->stats_reply_msg->header);
flexran_agent_mac_destroy_stats_reply(msg->stats_reply_msg);
flexran_agent_rrc_destroy_stats_reply(msg->stats_reply_msg);
flexran_agent_pdcp_destroy_stats_reply(msg->stats_reply_msg);
for (int i = 0; i < msg->stats_reply_msg->n_cell_report; ++i)
free(msg->stats_reply_msg->cell_report[i]);
for (int i = 0; i < msg->stats_reply_msg->n_ue_report; ++i)
free(msg->stats_reply_msg->ue_report[i]);
free(msg->stats_reply_msg->cell_report);
free(msg->stats_reply_msg->ue_report);
free(msg->stats_reply_msg->header);
free(msg->stats_reply_msg);
free(msg);
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment