Fix memory leaks in PROTO_AGENT
This commit is contained in:
@@ -131,6 +131,11 @@ error:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void proto_agent_stop(mod_id_t mod_id)
|
||||||
|
{
|
||||||
|
proto_agent_destroy_channel(proto_agent[mod_id].channel->channel_id);
|
||||||
|
}
|
||||||
|
|
||||||
//void
|
//void
|
||||||
//proto_agent_send_hello(void)
|
//proto_agent_send_hello(void)
|
||||||
//{
|
//{
|
||||||
@@ -164,24 +169,21 @@ proto_agent_send_rlc_data_req(const protocol_ctxt_t* const ctxt_pP,
|
|||||||
int msg_flag = 0;
|
int msg_flag = 0;
|
||||||
int msgsize = 0;
|
int msgsize = 0;
|
||||||
mod_id_t mod_id = ctxt_pP->module_id;
|
mod_id_t mod_id = ctxt_pP->module_id;
|
||||||
|
data_req_args args;
|
||||||
|
|
||||||
DevAssert(proto_agent[mod_id].channel);
|
DevAssert(proto_agent[mod_id].channel);
|
||||||
DevAssert(proto_agent[mod_id].channel->channel_info);
|
DevAssert(proto_agent[mod_id].channel->channel_info);
|
||||||
|
|
||||||
data_req_args *args = malloc(sizeof(data_req_args));
|
args.ctxt = ctxt_pP;
|
||||||
|
args.srb_flag = srb_flagP;
|
||||||
args->ctxt = malloc(sizeof(protocol_ctxt_t));
|
args.MBMS_flag = MBMS_flagP;
|
||||||
memcpy(args->ctxt, ctxt_pP, sizeof(protocol_ctxt_t));
|
args.rb_id = rb_idP;
|
||||||
args->srb_flag = srb_flagP;
|
args.mui = muiP;
|
||||||
args->MBMS_flag = MBMS_flagP;
|
args.confirm = confirmP;
|
||||||
args->rb_id = rb_idP;
|
args.sdu_size = sdu_sizeP;
|
||||||
args->mui = muiP;
|
args.sdu_p = sdu_pP;
|
||||||
args->confirm = confirmP;
|
|
||||||
args->sdu_size = sdu_sizeP;
|
|
||||||
args->sdu_p = malloc(sdu_sizeP);
|
|
||||||
memcpy(args->sdu_p, sdu_pP->data, sdu_sizeP);
|
|
||||||
|
|
||||||
msg_flag = proto_agent_pdcp_data_req(mod_id, (void *) args, &init_msg);
|
msg_flag = proto_agent_pdcp_data_req(mod_id, (void *) &args, &init_msg);
|
||||||
if (msg_flag != 0 || !init_msg) goto error;
|
if (msg_flag != 0 || !init_msg) goto error;
|
||||||
|
|
||||||
msg = proto_agent_pack_message(init_msg, &msgsize);
|
msg = proto_agent_pack_message(init_msg, &msgsize);
|
||||||
@@ -206,22 +208,19 @@ proto_agent_send_pdcp_data_ind(const protocol_ctxt_t* const ctxt_pP, const srb_f
|
|||||||
int msg_flag = 0;
|
int msg_flag = 0;
|
||||||
int msgsize = 0;
|
int msgsize = 0;
|
||||||
mod_id_t mod_id = ctxt_pP->module_id;
|
mod_id_t mod_id = ctxt_pP->module_id;
|
||||||
|
data_req_args args;
|
||||||
|
|
||||||
DevAssert(proto_agent[mod_id].channel);
|
DevAssert(proto_agent[mod_id].channel);
|
||||||
DevAssert(proto_agent[mod_id].channel->channel_info);
|
DevAssert(proto_agent[mod_id].channel->channel_info);
|
||||||
|
|
||||||
data_req_args *args = malloc(sizeof(data_req_args));
|
args.ctxt = ctxt_pP;
|
||||||
|
args.srb_flag = srb_flagP;
|
||||||
args->ctxt = malloc(sizeof(protocol_ctxt_t));
|
args.MBMS_flag = MBMS_flagP;
|
||||||
memcpy(args->ctxt, ctxt_pP, sizeof(protocol_ctxt_t));
|
args.rb_id = rb_idP;
|
||||||
args->srb_flag = srb_flagP;
|
args.sdu_size = sdu_sizeP;
|
||||||
args->MBMS_flag = MBMS_flagP;
|
args.sdu_p = sdu_pP;
|
||||||
args->rb_id = rb_idP;
|
|
||||||
args->sdu_size = sdu_sizeP;
|
|
||||||
args->sdu_p = malloc(sdu_sizeP);
|
|
||||||
memcpy(args->sdu_p, sdu_pP->data, sdu_sizeP);
|
|
||||||
|
|
||||||
msg_flag = proto_agent_pdcp_data_ind(mod_id, (void *) args, &init_msg);
|
msg_flag = proto_agent_pdcp_data_ind(mod_id, (void *) &args, &init_msg);
|
||||||
if (msg_flag != 0 || !init_msg) goto error;
|
if (msg_flag != 0 || !init_msg) goto error;
|
||||||
|
|
||||||
msg = proto_agent_pack_message(init_msg, &msgsize);
|
msg = proto_agent_pack_message(init_msg, &msgsize);
|
||||||
@@ -232,7 +231,7 @@ proto_agent_send_pdcp_data_ind(const protocol_ctxt_t* const ctxt_pP, const srb_f
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
LOG_E(PROTO_AGENT, "there was an error\n");
|
LOG_E(PROTO_AGENT, "there was an error in %s\n", __func__);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
void * proto_agent_receive(void *args);
|
void * proto_agent_receive(void *args);
|
||||||
|
|
||||||
int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p);
|
int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p);
|
||||||
|
void proto_agent_stop(mod_id_t mod_id);
|
||||||
|
|
||||||
void proto_agent_send_rlc_data_req( const protocol_ctxt_t* const ctxt_pP,
|
void proto_agent_send_rlc_data_req( const protocol_ctxt_t* const ctxt_pP,
|
||||||
const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP,
|
const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP,
|
||||||
|
|||||||
@@ -68,7 +68,8 @@ proto_agent_async_channel_info(mod_id_t mod_id, const char *bind_ip, uint16_t bi
|
|||||||
return channel;
|
return channel;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
LOG_E(PROTO_AGENT,"there was an error\n");
|
if (channel)
|
||||||
|
free(channel);
|
||||||
fprintf(stderr, "error creating proto_agent_async_channel_t\n");
|
fprintf(stderr, "error creating proto_agent_async_channel_t\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -87,8 +88,7 @@ int proto_agent_async_msg_recv(void **data, int *size, int *priority, void *chan
|
|||||||
|
|
||||||
void proto_agent_async_release(proto_agent_channel_t *channel)
|
void proto_agent_async_release(proto_agent_channel_t *channel)
|
||||||
{
|
{
|
||||||
proto_agent_async_channel_t *channel_info;
|
proto_agent_async_channel_t *channel_info = channel->channel_info;
|
||||||
channel_info = (proto_agent_async_channel_t *) channel->channel_info;
|
|
||||||
|
|
||||||
destroy_link_manager(channel_info->manager);
|
destroy_link_manager(channel_info->manager);
|
||||||
|
|
||||||
|
|||||||
@@ -453,8 +453,12 @@ int proto_agent_destroy_pdcp_data_ind(Protocol__FlexsplitMessage *msg)
|
|||||||
if(msg->msg_case != PROTOCOL__FLEXSPLIT_MESSAGE__MSG_DATA_IND_MSG)
|
if(msg->msg_case != PROTOCOL__FLEXSPLIT_MESSAGE__MSG_DATA_IND_MSG)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
free(msg->data_req_ack->header);
|
free(msg->data_ind_msg->header);
|
||||||
free(msg->data_req_ack);
|
free(msg->data_ind_msg->rlc_data->fsp_pdu->fsp_pdu_data.data);
|
||||||
|
free(msg->data_ind_msg->rlc_data->fsp_pdu);
|
||||||
|
free(msg->data_ind_msg->rlc_data->fsp_ctxt);
|
||||||
|
free(msg->data_ind_msg->rlc_data);
|
||||||
|
free(msg->data_ind_msg);
|
||||||
free(msg);
|
free(msg);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|||||||
@@ -104,10 +104,8 @@ Protocol__FlexsplitMessage* proto_agent_handle_message (mod_id_t mod_id,
|
|||||||
LOG_I(PROTO_AGENT, "decoded_message case : %d, direction : %d \n", decoded_message->msg_case-1, decoded_message->msg_dir-1);
|
LOG_I(PROTO_AGENT, "decoded_message case : %d, direction : %d \n", decoded_message->msg_case-1, decoded_message->msg_dir-1);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
else if (err_code == 1)
|
|
||||||
{
|
protocol__flexsplit_message__free_unpacked(decoded_message, NULL);
|
||||||
protocol__flexsplit_message__free_unpacked(decoded_message, NULL);
|
|
||||||
}
|
|
||||||
LOG_D(PROTO_AGENT,"Returning REPLY message after the callback\n");
|
LOG_D(PROTO_AGENT,"Returning REPLY message after the callback\n");
|
||||||
return reply_message;
|
return reply_message;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user