添加错误映射文件的处理防止崩溃,优化mq处理topic前缀,添加空指针预防
This commit is contained in:
@@ -132,10 +132,25 @@ void CloseIECReports(chnl_usr_t *chnl_usr)
|
||||
ied_usr = GET_IEDEXT_ADDR(ied);
|
||||
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++) {
|
||||
char rpt_inst_name[65];
|
||||
rptinfo = LD_info->rptinfo[rpt_no];
|
||||
if ( ! rptinfo->rpt_registered )
|
||||
|
||||
//添加保护lnk20260602
|
||||
if (rptinfo == NULL)
|
||||
continue;
|
||||
|
||||
if ( !rptinfo->rpt_registered )
|
||||
continue;
|
||||
if ( rptinfo->chnl_id != chnl_usr->chnl_id)
|
||||
continue;
|
||||
@@ -260,6 +275,18 @@ void IECReport_tryGI(chnl_usr_t *chnl_usr,rptinfo_t *rptinfo)
|
||||
//增加处理根据稳态,或暂态功能等,决定 报告是否需要注册、取消注册或 不做任何处理
|
||||
int judge_rpt_next_should_do(rptinfo_t *rptinfo)
|
||||
{
|
||||
|
||||
if (rptinfo == NULL) {
|
||||
printf("[RPT][ERROR] rptinfo is NULL\n");
|
||||
return SHOULD_DO_NOTHING;
|
||||
}
|
||||
|
||||
if (rptinfo->LD_info == NULL) {
|
||||
printf("[RPT][ERROR] rptinfo->LD_info is NULL, rptID=%s\n",
|
||||
rptinfo->rptID ? rptinfo->rptID : "NULL");
|
||||
return SHOULD_DO_NOTHING;
|
||||
}
|
||||
|
||||
int should_register_state = 1; //各功能默认注册
|
||||
int is_real_report = (rptinfo->report_PQ_type & REPORT_TYPE_REAL);//报告控制中包含的类型
|
||||
int is_soe_report = (rptinfo->report_PQ_type & REPORT_TYPE_SOE);
|
||||
@@ -302,7 +329,23 @@ void ChannelCheckIECReports(chnl_usr_t *chnl_usr)
|
||||
{
|
||||
LD_info = &(ied_usr->LD_info[cpuno]); //遍历监测点
|
||||
|
||||
if (LD_info->cpuno==0){
|
||||
//添加保护,防止台账中测点号不连续导致的崩溃
|
||||
if (LD_info->cpuno == 0 ||
|
||||
LD_info->LD_name == NULL ||
|
||||
LD_info->rptcount <= 0 ||
|
||||
LD_info->rptinfo == NULL)
|
||||
{
|
||||
printf("[RPT][SKIP] invalid LD_info cpu=%d cpuno=%d LD_name=%p rptcount=%d rptinfo=%p\n",
|
||||
cpuno,
|
||||
LD_info->cpuno,
|
||||
LD_info->LD_name,
|
||||
LD_info->rptcount,
|
||||
LD_info->rptinfo);
|
||||
continue;
|
||||
}
|
||||
|
||||
//未初始化的测点告警没有意义,直接访问id还可能崩溃
|
||||
/*if (LD_info->cpuno==0){
|
||||
// 仅在还没达到5次上限时打印
|
||||
if (!LD_info->has_logged_regist) {
|
||||
LD_info->registcount++;
|
||||
@@ -319,13 +362,39 @@ void ChannelCheckIECReports(chnl_usr_t *chnl_usr)
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
for(rpt_no=0 ; rpt_no<LD_info->rptcount; rpt_no++) { //遍历报告(映射文件中读取的报告控制)
|
||||
|
||||
rptinfo = LD_info->rptinfo[rpt_no] ;
|
||||
|
||||
//检查是否需要注册或取消注册报告,或不做任何处理
|
||||
printf("[RPT][CHECK] ip=%s cpu=%d rpt_no=%d rptcount=%d LD_name=%s rptinfo=%p\n",
|
||||
chnl_usr->ip_str,
|
||||
cpuno,
|
||||
rpt_no,
|
||||
LD_info->rptcount,
|
||||
LD_info->LD_name ? LD_info->LD_name : "NULL",
|
||||
rptinfo);
|
||||
|
||||
if (rptinfo == NULL) {
|
||||
printf("[RPT][ERROR] rptinfo NULL, skip\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rptinfo->LD_info == NULL) {
|
||||
printf("[RPT][ERROR] rptinfo->LD_info NULL, rptID=%s, skip\n",
|
||||
rptinfo->rptID ? rptinfo->rptID : "NULL");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rptinfo->rptID == NULL || rptinfo->rptID[0] == '\0') {
|
||||
printf("[RPT][ERROR] rptID empty, skip\n");
|
||||
continue;
|
||||
}
|
||||
//添加保护
|
||||
|
||||
if (judge_rpt_next_should_do(rptinfo)==SHOULD_DO_NOTHING)//检查是否触发
|
||||
{
|
||||
//DIY_DEBUGLOG_CODE(LD_info->mp_id,2,LOG_CODE_REPORT,"【DEBUG】监测点:%s - id:%s不注册报告", LD_info->name,LD_info->mp_id);
|
||||
@@ -496,8 +565,17 @@ void ChannelCheckIECLogs(chnl_usr_t *chnl_usr)
|
||||
for(cpuno=0 ; cpuno<ied->cpucount; cpuno++) {
|
||||
LD_info = &(ied_usr->LD_info[cpuno]);
|
||||
|
||||
//添加保护,防止台账中测点号不连续导致的崩溃
|
||||
if (LD_info->cpuno == 0 ||
|
||||
LD_info->LD_name == NULL ||
|
||||
LD_info->logcount <= 0 ||
|
||||
LD_info->loginfo == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//日志控制块缺失
|
||||
if (LD_info->logcount<=0){
|
||||
/*if (LD_info->logcount<=0){
|
||||
// 仅在还没达到5次上限时打印
|
||||
if (!LD_info->has_logged_regist) {
|
||||
LD_info->registcount++;
|
||||
@@ -515,10 +593,14 @@ void ChannelCheckIECLogs(chnl_usr_t *chnl_usr)
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}*/
|
||||
|
||||
loginfo = LD_info->loginfo[0] ;
|
||||
|
||||
//添加保护,防止台账中测点号不连续导致的崩溃
|
||||
if (loginfo == NULL || loginfo->LD_info == NULL)
|
||||
continue;
|
||||
|
||||
apr_sleep(apr_time_from_sec(1) / 10);
|
||||
|
||||
Check_Recall_Config(LD_info->mp_id);//尝试获取xml结构
|
||||
|
||||
@@ -135,6 +135,15 @@ int fill_rptctrl_by_cfg(LD_info_t* LD_info,int rptno,char *buf)
|
||||
|
||||
assert( (rptno+1) <= LD_info->rptcount ) ;
|
||||
rptinfo = LD_info->rptinfo[rptno];
|
||||
|
||||
|
||||
if (rptinfo == NULL) {
|
||||
printf("[RPT_INIT][ERROR] rptinfo NULL, rptno=%d\n", rptno);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rptinfo->LD_info = LD_info;
|
||||
|
||||
if(!(str = strtok(buf,",")))
|
||||
return 1;
|
||||
|
||||
@@ -262,6 +271,13 @@ int fill_logctrl_by_cfg(LD_info_t* LD_info,int logno,char *buf,char* devtype)
|
||||
assert( (logno+1) <= LD_info->logcount ) ;
|
||||
loginfo = LD_info->loginfo[logno];
|
||||
|
||||
if (loginfo == NULL) {
|
||||
printf("[LOG_INIT][ERROR] loginfo NULL, logno=%d\n", logno);
|
||||
return 1;
|
||||
}
|
||||
|
||||
loginfo->LD_info = LD_info;
|
||||
|
||||
if(!(str = strtok(buf,",")))
|
||||
return 1;
|
||||
tmp_str = apr_pstrdup(g_init_pool,str);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user