修正在程序开始时对IPC变量删除的错误函数调用。

添加配置项crazyping,当其不为零时,会在每次取网卡信息时进行ping操作。
This commit is contained in:
钟安
2015-12-23 11:54:46 +08:00
parent 137dd511f1
commit 9924a4c78d
4 changed files with 29 additions and 9 deletions

View File

@@ -1,3 +1,9 @@
--V1.12 --
20151223
修正在程序开始时对IPC变量删除的错误函数调用。
添加配置项crazyping,当其不为零时会在每次取网卡信息时进行ping操作。
--V1.11 --
20151218
添加在程序开始时对IPC变量是否已存在的判断如果已存在则将其删除。

View File

@@ -1,3 +1,9 @@
--V1.12 --
20151223
修正在程序开始时对IPC变量删除的错误函数调用。
添加配置项crazyping,当其不为零时会在每次取网卡信息时进行ping操作。
--V1.11 --
20151218
添加在程序开始时对IPC变量是否已存在的判断如果已存在则将其删除。

View File

@@ -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;

View File

@@ -1,5 +1,5 @@
// version=1.11
// version=1.12
#ifndef MNIC_VERSION
#define MNIC_VERSION "1.11"
#define MNIC_VERSION "1.12"
#endif