设置MAAT配置监听线程名称,便于debug。
This commit is contained in:
@@ -143,8 +143,9 @@ enum MAAT_INIT_OPT
|
|||||||
MAAT_OPT_STAT_ON, //VALUE is indifferent,SIZE is indifferent.MAAT_OPT_STAT_FILE_PATH must be set.Default: stat OFF.
|
MAAT_OPT_STAT_ON, //VALUE is indifferent,SIZE is indifferent.MAAT_OPT_STAT_FILE_PATH must be set.Default: stat OFF.
|
||||||
MAAT_OPT_PERF_ON, //VALUE is indifferent,SIZE is indifferent.MAAT_OPT_STAT_FILE_PATH must be set.Default: stat OFF.
|
MAAT_OPT_PERF_ON, //VALUE is indifferent,SIZE is indifferent.MAAT_OPT_STAT_FILE_PATH must be set.Default: stat OFF.
|
||||||
MAAT_OPT_STAT_FILE_PATH, //VALUE is a const char*,MUST end with '\0',SIZE= strlen(string+'\0')+1.DEFAULT: no default.
|
MAAT_OPT_STAT_FILE_PATH, //VALUE is a const char*,MUST end with '\0',SIZE= strlen(string+'\0')+1.DEFAULT: no default.
|
||||||
MAAT_OPT_SCAN_DETAIL //VALUE is interger,SIZE=sizeof(int). 0: not return any detail;1: return hit pos, not include regex grouping;
|
MAAT_OPT_SCAN_DETAIL, //VALUE is interger,SIZE=sizeof(int). 0: not return any detail;1: return hit pos, not include regex grouping;
|
||||||
// 2 return hit pos and regex grouping pos;DEFAULT:0
|
// 2 return hit pos and regex grouping pos;DEFAULT:0
|
||||||
|
MAAT_OPT_INSTANCE_NAME //VALUE is a const char*,MUST end with '\0',SIZE= strlen(string+'\0')+1,no more than 11 bytes.DEFAULT: MAAT_$tableinfo_path$.
|
||||||
};
|
};
|
||||||
//return -1 if failed, return 0 on success;
|
//return -1 if failed, return 0 on success;
|
||||||
int Maat_set_feather_opt(Maat_feather_t feather,enum MAAT_INIT_OPT type,const void* value,int size);
|
int Maat_set_feather_opt(Maat_feather_t feather,enum MAAT_INIT_OPT type,const void* value,int size);
|
||||||
|
|||||||
@@ -454,6 +454,7 @@ Maat_feather_t Maat_feather(int max_thread_num,const char* table_info_path,void*
|
|||||||
feather->hit_cnt=aligment_int64_array_alloc(max_thread_num);
|
feather->hit_cnt=aligment_int64_array_alloc(max_thread_num);
|
||||||
feather->maat_version=0;
|
feather->maat_version=0;
|
||||||
feather->last_full_version=0;
|
feather->last_full_version=0;
|
||||||
|
snprintf(feather->table_info_fn,sizeof(feather->table_info_fn),"%s",table_info_path);
|
||||||
return feather;
|
return feather;
|
||||||
}
|
}
|
||||||
int Maat_set_feather_opt(Maat_feather_t feather,enum MAAT_INIT_OPT type,const void* value,int size)
|
int Maat_set_feather_opt(Maat_feather_t feather,enum MAAT_INIT_OPT type,const void* value,int size)
|
||||||
@@ -530,6 +531,12 @@ int Maat_set_feather_opt(Maat_feather_t feather,enum MAAT_INIT_OPT type,const vo
|
|||||||
intval=*(const int*)value;
|
intval=*(const int*)value;
|
||||||
_feather->rule_scan_type=intval;
|
_feather->rule_scan_type=intval;
|
||||||
break;
|
break;
|
||||||
|
case MAAT_OPT_INSTANCE_NAME:
|
||||||
|
snprintf(_feather->instance_name
|
||||||
|
,sizeof(_feather->instance_name)
|
||||||
|
,"%s",
|
||||||
|
(const char*)value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <sys/prctl.h>
|
||||||
#include <MESA/MESA_htable.h>
|
#include <MESA/MESA_htable.h>
|
||||||
#include <MESA/MESA_list_queue.h>
|
#include <MESA/MESA_list_queue.h>
|
||||||
#include <MESA/MESA_handle_logger.h>
|
#include <MESA/MESA_handle_logger.h>
|
||||||
@@ -2949,7 +2950,20 @@ void *thread_rule_monitor(void *arg)
|
|||||||
const char* inc_cfg_dir=(const char*)feather->inc_dir;
|
const char* inc_cfg_dir=(const char*)feather->inc_dir;
|
||||||
struct _Maat_scanner_t* old_scanner=NULL;
|
struct _Maat_scanner_t* old_scanner=NULL;
|
||||||
long expr_wait_q_cnt=0;
|
long expr_wait_q_cnt=0;
|
||||||
int scan_dir_cnt=0;
|
int scan_dir_cnt=0,ret=0;
|
||||||
|
char maat_name[16];//Defined by prctl: The name can be up to 16 bytes long,and should
|
||||||
|
// be null terminated if it contains fewer bytes.
|
||||||
|
if(strlen(feather->instance_name)>0)
|
||||||
|
{
|
||||||
|
snprintf(maat_name,sizeof(maat_name),"MAAT_%s",feather->instance_name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
snprintf(maat_name,sizeof(maat_name),"MAAT");
|
||||||
|
}
|
||||||
|
//ret=prctl(PR_SET_NAME,(unsigned long long)maat_name,NULL,NULL,NULL);
|
||||||
|
ret=pthread_setname_np(pthread_self(),maat_name);
|
||||||
|
assert(ret>=0);
|
||||||
while(feather->still_working)
|
while(feather->still_working)
|
||||||
{
|
{
|
||||||
usleep(feather->scan_interval_ms*1000);
|
usleep(feather->scan_interval_ms*1000);
|
||||||
|
|||||||
@@ -369,6 +369,8 @@ struct _Maat_feather_t
|
|||||||
char inc_dir[MAX_TABLE_NAME_LEN];
|
char inc_dir[MAX_TABLE_NAME_LEN];
|
||||||
char full_dir[MAX_TABLE_NAME_LEN];
|
char full_dir[MAX_TABLE_NAME_LEN];
|
||||||
char stat_file[MAX_TABLE_NAME_LEN];
|
char stat_file[MAX_TABLE_NAME_LEN];
|
||||||
|
char instance_name[MAX_TABLE_NAME_LEN];
|
||||||
|
char table_info_fn[MAX_TABLE_NAME_LEN];
|
||||||
//for stat>>>>
|
//for stat>>>>
|
||||||
screen_stat_handle_t stat_handle;
|
screen_stat_handle_t stat_handle;
|
||||||
int total_stat_id;
|
int total_stat_id;
|
||||||
|
|||||||
Reference in New Issue
Block a user