修正在记录日志中检查目录时(在函数create_dir中),由于采用线程进行日志记录,>多次调用get_nic_info可能会导致的将日志文件路径名变错的问题。在get_nic_info中>判断log_path是否被初始化过,如过未初始化,则到共享内存中读取。否则,为初始化>过,直接使用该值,并在create_dir中使用局部变量保存该值,在create_dir中使用操作
该局部变量,而不去改变该全局变量的值。
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
--V1.12 --
|
||||
--V1.13 --
|
||||
2015-12-23
|
||||
修正在记录日志中检查目录时(在函数create_dir中),由于采用线程进行日志记录,多次调用get_nic_info可能会导致的将日志文件路径名变错的问题。在get_nic_info中判断log_path是否被初始化过,如过未初始化,则到共享内存中读取。否则,为初始化过,直接使用该值,并在create_dir中使用局部变量保存该值,在create_dir中使用操作该局部变量,而不去改变该全局变量的值。
|
||||
|
||||
-V1.12 --
|
||||
2015-12-23
|
||||
修正在程序开始时对IPC变量删除的错误函数调用。
|
||||
添加配置项crazyping,当其不为零时,会在每次取网卡信息时进行ping操作。
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
--V1.12 --
|
||||
--V1.13 --
|
||||
2015-12-23
|
||||
修正在记录日志中检查目录时(在函数create_dir中),由于采用线程进行日志记录,多次调用get_nic_info可能会导致的将日志文件路径名变错的问题。在get_nic_info中判断log_path是否被初始化过,如过未初始化,则到共享内存中读取。否则,为初始化过,直接使用该值,并在create_dir中使用局部变量保存该值,在create_dir中使用操作该局部变量,而不去改变该全局变量的值。
|
||||
|
||||
-V1.12 --
|
||||
2015-12-23
|
||||
修正在程序开始时对IPC变量删除的错误函数调用。
|
||||
添加配置项crazyping,当其不为零时,会在每次取网卡信息时进行ping操作。
|
||||
|
||||
@@ -16,21 +16,25 @@ static int log_idx = 0;
|
||||
|
||||
void create_dir(char *create_path)
|
||||
{
|
||||
int i,len = strlen(create_path);
|
||||
char tmp_path[256];
|
||||
|
||||
strcpy(tmp_path,create_path);
|
||||
|
||||
int i,len = strlen(tmp_path);
|
||||
|
||||
for(i=1; i<len; i++)
|
||||
{
|
||||
if(create_path[i]=='/')
|
||||
if(tmp_path[i]=='/')
|
||||
{
|
||||
create_path[i] = 0;
|
||||
if( access(create_path, F_OK)!=0 )
|
||||
tmp[i] = 0;
|
||||
if( access(tmp_path, F_OK)!=0 )
|
||||
{
|
||||
if(mkdir(create_path, 0755)==-1)
|
||||
if(mkdir(tmp_path, 0755)==-1)
|
||||
{
|
||||
perror("mkdir error");
|
||||
}
|
||||
}
|
||||
create_path[i] = '/';
|
||||
tmp_path[i] = '/';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ typedef struct net_info{
|
||||
}SHM;
|
||||
|
||||
static int semid = 0;
|
||||
static char log_path[1024];
|
||||
static char shm_path[1024];
|
||||
static char sem_path[1024];
|
||||
char log_path[1024];
|
||||
char shm_path[1024];
|
||||
char sem_path[1024];
|
||||
SHM *ptr = NULL;
|
||||
static char process_name[32] = "get_nic_info";
|
||||
|
||||
@@ -304,21 +304,20 @@ int get_nic_info(char *nic_name, NETCARD_INFO *net_info)
|
||||
#endif
|
||||
tamp = time(NULL);
|
||||
localtime_r(&tamp, &tmptr);
|
||||
|
||||
shm_id = shmget(shm_key,128,0666);
|
||||
if(shm_id < 0) return -1;
|
||||
shm_buf = (char *)shmat(shm_id,NULL,0);
|
||||
if(shm_buf == (void *) -1) return -1;
|
||||
|
||||
sprintf(log_path,"%s",shm_buf);
|
||||
sprintf(shm_path,"%s",shm_buf);
|
||||
sprintf(sem_path,"%s",shm_buf);
|
||||
|
||||
shmdt(shm_buf);
|
||||
|
||||
strcat(log_path,LOG_PATH);
|
||||
strcat(shm_path,SHM_PATH);
|
||||
strcat(sem_path,SEM_PATH);
|
||||
if(log_path[0]==0){
|
||||
shm_id = shmget(shm_key,128,0666);
|
||||
if(shm_id < 0) return -1;
|
||||
shm_buf = (char *)shmat(shm_id,NULL,0);
|
||||
if(shm_buf == (void *) -1) return -1;
|
||||
sprintf(log_path,"%s",shm_buf);
|
||||
sprintf(shm_path,"%s",shm_buf);
|
||||
sprintf(sem_path,"%s",shm_buf);
|
||||
shmdt(shm_buf);
|
||||
strcat(log_path,LOG_PATH);
|
||||
strcat(shm_path,SHM_PATH);
|
||||
strcat(sem_path,SEM_PATH);
|
||||
}
|
||||
#if 0
|
||||
//remove
|
||||
if((dir = opendir(log_path)) == NULL){
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// version=1.12
|
||||
// version=1.13
|
||||
#ifndef MNIC_VERSION
|
||||
#define MNIC_VERSION "1.12"
|
||||
#define MNIC_VERSION "1.13"
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user