From 9924a4c78de61b1f790899607b50d8787feefd1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=9F=E5=AE=89?= Date: Wed, 23 Dec 2015 11:54:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=9C=A8=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E5=BC=80=E5=A7=8B=E6=97=B6=E5=AF=B9IPC=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=9A=84=E9=94=99=E8=AF=AF=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E3=80=82=20=E6=B7=BB=E5=8A=A0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=A1=B9crazyping,=E5=BD=93=E5=85=B6=E4=B8=8D?= =?UTF-8?q?=E4=B8=BA=E9=9B=B6=E6=97=B6=EF=BC=8C=E4=BC=9A=E5=9C=A8=E6=AF=8F?= =?UTF-8?q?=E6=AC=A1=E5=8F=96=E7=BD=91=E5=8D=A1=E4=BF=A1=E6=81=AF=E6=97=B6?= =?UTF-8?q?=E8=BF=9B=E8=A1=8Cping=E6=93=8D=E4=BD=9C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/README | 6 ++++++ src/sys_nicmonitor/README | 6 ++++++ src/sys_nicmonitor/mnic.c | 22 +++++++++++++++------- src/sys_nicmonitor/version.h | 4 ++-- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/README b/src/README index 6d74ce1..84360b2 100644 --- a/src/README +++ b/src/README @@ -1,3 +1,9 @@ +--V1.12 -- +2015-12-23 +修正在程序开始时对IPC变量删除的错误函数调用。 +添加配置项crazyping,当其不为零时,会在每次取网卡信息时进行ping操作。 + + --V1.11 -- 2015-12-18 添加在程序开始时对IPC变量是否已存在的判断,如果已存在,则将其删除。 diff --git a/src/sys_nicmonitor/README b/src/sys_nicmonitor/README index 6d74ce1..84360b2 100644 --- a/src/sys_nicmonitor/README +++ b/src/sys_nicmonitor/README @@ -1,3 +1,9 @@ +--V1.12 -- +2015-12-23 +修正在程序开始时对IPC变量删除的错误函数调用。 +添加配置项crazyping,当其不为零时,会在每次取网卡信息时进行ping操作。 + + --V1.11 -- 2015-12-18 添加在程序开始时对IPC变量是否已存在的判断,如果已存在,则将其删除。 diff --git a/src/sys_nicmonitor/mnic.c b/src/sys_nicmonitor/mnic.c index dd1457f..ba6ace7 100644 --- a/src/sys_nicmonitor/mnic.c +++ b/src/sys_nicmonitor/mnic.c @@ -52,6 +52,7 @@ typedef struct __config_file_st{ char ip[IPSIZE]; int pingnum; //OPTIONAL!! How many times for once ping check? Default is 2. int pinglap; //OPTIONAL!! How many seconds does ping wait for reply package? Default is 1. + int crazyping; }CONFIG_FILE_ST; typedef struct inc_name_node{ @@ -133,6 +134,7 @@ char myconf[][64] = { "ping", // 13 "pingnum", // 14 "pinglap", // 15 + "crazyping", // 16 "" }; @@ -153,6 +155,7 @@ static const configoption_t options[] = { {myconf[13], ARG_STR, cb_str, NULL, CTX_ALL}, {myconf[14], ARG_INT, cb_int, NULL, CTX_ALL}, {myconf[15], ARG_INT, cb_int, NULL, CTX_ALL}, + {myconf[16], ARG_INT, cb_int, NULL, CTX_ALL}, LAST_OPTION }; @@ -1189,6 +1192,10 @@ DOTCONF_CB(cb_int) if(strcmp(cmd ->name, myconf[15]) == 0){ conf.pinglap = cmd->data.value; } + if(strcmp(cmd ->name, myconf[16]) == 0){ + conf.crazyping = cmd->data.value; + } + return NULL; } @@ -1413,7 +1420,7 @@ int get_netcard_status(NETCARD_INFO_ST *listp) return NIC_UNRUNNING; //20100510 - if(elapsed_ping_time == total_ping_time){ + if(conf.crazyping || (elapsed_ping_time == total_ping_time)){ if(ping_gw(listp->info.charname) != 0) return NIC_UNLINKABLE; } @@ -1475,14 +1482,14 @@ int do_alarm(NETCARD_INFO_ST *listp, int nic_status, D5000_NIC_ALARM *Malarm) int main(int argc, char ** argv) { int id = -1; - if((id = semget(0x1d5200, 1, 0666)) == -1) + if((id = semget(0x1d5200, 1, 0666)) != -1) semctl(id,0,IPC_RMID,0); id = -1; - if((id = shmget(0x1d5010,sizeof(SHM) + 16 , 0666)) == -1) - semctl(id,0,IPC_RMID,0); + if((id = shmget(0x1d5010,sizeof(SHM) + 16 , 0666)) != -1) + shmctl(id,IPC_RMID,0); id = -1; - if((id = shmget(0x1d6010, 128, 0666)) == -1) - semctl(id,0,IPC_RMID,0); + if((id = shmget(0x1d6010, 128, 0666)) != -1) + shmctl(id,IPC_RMID,0); int ret = 0, proc_stat = 0; unsigned int i = 0; @@ -1725,7 +1732,8 @@ int main(int argc, char ** argv) total_ping_time = 1000 / conf.monitor_interval; if(total_ping_time == 0) total_ping_time = 1; - elapsed_ping_time = 1; + //elapsed_ping_time = 1; + elapsed_ping_time = total_ping_time; while(1){ i = 0; diff --git a/src/sys_nicmonitor/version.h b/src/sys_nicmonitor/version.h index f849540..bcb3351 100644 --- a/src/sys_nicmonitor/version.h +++ b/src/sys_nicmonitor/version.h @@ -1,5 +1,5 @@ -// version=1.11 +// version=1.12 #ifndef MNIC_VERSION - #define MNIC_VERSION "1.11" + #define MNIC_VERSION "1.12" #endif