添加错误映射文件的处理防止崩溃,优化mq处理topic前缀,添加空指针预防

This commit is contained in:
lnk
2026-06-02 16:23:23 +08:00
parent c388bd04fe
commit 465e304085
7 changed files with 367 additions and 73 deletions

View File

@@ -145,12 +145,26 @@ RCB_INFO* FindRcbInfo(MVL_NET_INFO *net_info,ST_CHAR *dom_name, ST_CHAR *rcb_nam
for(cpuno=0 ; cpuno<ied->cpucount; cpuno++) {
LD_info = &(ied_usr->LD_info[cpuno]);
if (!LD_info->LD_name)
continue;
//if (!LD_info->LD_name)
// continue;
//添加保护lnk20260602
if (LD_info->cpuno == 0 ||
LD_info->LD_name == NULL ||
LD_info->rptcount <= 0 ||
LD_info->rptinfo == NULL)
{
continue;
}
if ( strcmp(LD_info->LD_name,dom_name)!=0 )
continue;
for(rpt_no=0 ; rpt_no<LD_info->rptcount; rpt_no++) {
rptinfo = LD_info->rptinfo[rpt_no];
//添加保护lnk20260602
if (rptinfo == NULL || rptinfo->rptID == NULL)
continue;
get_rpt_inst_name(rptinfo,rpt_inst_name);
if ( strcmp(rpt_inst_name,rcb_name)==0 ) {
if (rptinfo->rpt_registered)
@@ -181,8 +195,22 @@ rptinfo_t* find_rptinfo_from_net_rpt_info_name(MVL_NET_INFO *net_info, RCB_INFO
for(cpuno=0 ; cpuno<ied->cpucount; cpuno++) {
LD_info = &(ied_usr->LD_info[cpuno]);
//添加保护lnk20260602
if (LD_info->cpuno == 0 ||
LD_info->LD_name == NULL ||
LD_info->rptcount <= 0 ||
LD_info->rptinfo == NULL)
{
continue;
}
for(rpt_no=0 ; rpt_no<LD_info->rptcount; rpt_no++) {
rptinfo = LD_info->rptinfo[rpt_no];
//添加保护lnk20260602
if (rptinfo == NULL || rptinfo->rptID == NULL || rcb_info == NULL || rcb_info->RptID == NULL)
continue;
printf("%d rptinfo %s,rcbinfo %s ", rpt_no, rptinfo->rptID, rcb_info->RptID);
if (strcmp(rcb_info->RptID,rptinfo->rptID)==0)//WW 修改为匹配字符串
return rptinfo;
@@ -211,8 +239,21 @@ rptinfo_t* find_rptinfo_from_net_rcb_info(MVL_NET_INFO *net_info,RCB_INFO *rcb_i
for(cpuno=0 ; cpuno<ied->cpucount; cpuno++) {
LD_info = &(ied_usr->LD_info[cpuno]);
//添加保护lnk20260602
if (LD_info->cpuno == 0 ||
LD_info->LD_name == NULL ||
LD_info->rptcount <= 0 ||
LD_info->rptinfo == NULL)
{
continue;
}
for(rpt_no=0 ; rpt_no<LD_info->rptcount; rpt_no++) {
rptinfo = LD_info->rptinfo[rpt_no];
if (rptinfo == NULL)
continue;
if (rcb_info==rptinfo->m_rcb_info)
return rptinfo;
}
@@ -221,7 +262,7 @@ rptinfo_t* find_rptinfo_from_net_rcb_info(MVL_NET_INFO *net_info,RCB_INFO *rcb_i
}
////////////////////////////////////////
//WW 2023-08-29 注释 end
void get_rpt_inst_name(rptinfo_t *rptinfo, char * rpt_inst_name )
/*void get_rpt_inst_name(rptinfo_t *rptinfo, char * rpt_inst_name )
{
strcpy(rpt_inst_name,rptinfo->rptID);
if (rptinfo->instanceNeedSuffix) {
@@ -229,7 +270,56 @@ void get_rpt_inst_name(rptinfo_t *rptinfo, char * rpt_inst_name )
apr_snprintf(rpt_suffix_str,sizeof(rpt_suffix_str),"%02d",rptinfo->m_curRptSuffix);
strcat(rpt_inst_name,rpt_suffix_str);
}
}
} */
void get_rpt_inst_name(rptinfo_t *rptinfo, char *rpt_inst_name)
{
if (rpt_inst_name == NULL)
{
printf("get_rpt_inst_name: rpt_inst_name is NULL\n");
return;
}
rpt_inst_name[0] = '\0';
if (rptinfo == NULL)
{
printf("get_rpt_inst_name: rptinfo is NULL\n");
strcpy(rpt_inst_name, "NULL_RPT");
return;
}
if (rptinfo->rptID == NULL)
{
printf("get_rpt_inst_name: rptID is NULL\n");
strcpy(rpt_inst_name, "NULL_RPT");
return;
}
printf("[RPT] rptinfo=%p rptID=%s suffix=%d needSuffix=%d\n",
rptinfo,
rptinfo->rptID,
rptinfo->m_curRptSuffix,
rptinfo->instanceNeedSuffix);
// 原代码
strncpy(rpt_inst_name, rptinfo->rptID, 64);
rpt_inst_name[64] = '\0';
if (rptinfo->instanceNeedSuffix)
{
char rpt_suffix_str[8] = {0};
apr_snprintf(rpt_suffix_str,
sizeof(rpt_suffix_str),
"%02d",
rptinfo->m_curRptSuffix);
// 防止越界
strncat(rpt_inst_name,
rpt_suffix_str,
64 - strlen(rpt_inst_name));
}
}
void strip_file_name_tail_to_ms(char *fileName)
@@ -359,12 +449,20 @@ LD_info_t* find_LD_info_only_from_line_id(int line_id)
LD_info_t* find_LD_info_from_mp_id(ied_t* ied, char* mp_id)
{
if (mp_id == NULL)
return NULL;
LD_info_t* LD_info = NULL;
ied_usr_t* ied_usr = GET_IEDEXT_ADDR(ied);
int cpuno;
for (cpuno = 0; cpuno < ied->cpucount; cpuno++) {
LD_info = &(ied_usr->LD_info[cpuno]);
if (LD_info->cpuno == 0 || LD_info->LD_name == NULL)
continue;
if (LD_info && strcmp(LD_info->mp_id, mp_id) == 0)
return LD_info;
}