📄 check_mstate.h~
字号:
void sys_check(){ /* attach parent's shared memory */ ap=(struct area *)shmat(shmid, 0, 0); int flag_A=0,flag_B=0; char start[10]="START"; char stop[10]="STOP";while(1) { /* set semaphore */ buf_sem.sem_op=-1; semop(semid, (struct sembuf *) &buf_sem, 1);//M machine check if(Mstate_check()==0) { ap->Mstate_gl=0; ap->Mhost_name_gl="127.0.0.1"; //change the lpudated_log reboot M //update state_file exit(EXIT_FAILURE); } else { ap->Mstate_gl=1; ap->Mhost_name_gl="192.168.1.1"; }//further check for Main_cpu Main_hub if((ap->Astate_gl==1)&&(ap->Bstate_gl==1)) { ap->flag_sys_check=1; ap->Sys_main_cpu_gl=1; ap->Sys_main_hub_gl=1; } else if((ap->Astate_gl==1)&&(ap->Bstate_gl==0)) { ap->Sys_main_cpu_gl=1; ap->Sys_main_hub_gl=1; ap->flag_sys_check=2; } else if((ap->Astate_gl==0)&&(ap->Bstate_gl==1)) { ap->Sys_main_cpu_gl=2; ap->Sys_main_hub_gl=1; ap->flag_sys_check=3; } else { ap->flag_sys_check=4; ap->Sys_main_cpu_gl=0; //Sys_main_hub_gl=2; }//check the start which machine /* if(ap->Sys_main_cpu_gl==1) { if(flag_B==0) { if(flag_A==0) { sendto_QT("192.168.1.3",start,strlen(start));//Astart 8020,8030 flag_A=1; } } else { sendto_QT("192.168.1.5",stop,strlen(stop));//kill B flag_B=0; sendto_QT("192.168.1.3",start,strlen(start));//Astart flag_A=1; } } else if(ap->Sys_main_cpu_gl==2) { if(flag_A==0) { if(flag_B==0) { sendto_QT("192.168.1.5",start,strlen(start));//Bstart flag_B=1; } } else { //Aalready dead flag_A=0; sendto_QT("192.168.1.5",start,strlen(start));//Bstart flag_B=1; } } else {}*//*//further check for host_name if(Sys_main_hub_gl==2) { Ahost_name_gl="192.168.1.4"; Bhost_name_gl="192.168.1.6"; }*///get the check detail infomation /* clear semaphore */ buf_sem.sem_op=1; semop(semid, (struct sembuf *) &buf_sem, 1); sleep(1); }}//sys_check
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -