diff --git a/src/entry/Maat_api.cpp b/src/entry/Maat_api.cpp index f1ce27a..67b23fe 100644 --- a/src/entry/Maat_api.cpp +++ b/src/entry/Maat_api.cpp @@ -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->maat_version=0; feather->last_full_version=0; + pthread_mutex_init(&(feather->plugin_table_reg_mutex),NULL); snprintf(feather->table_info_fn,sizeof(feather->table_info_fn),"%s",table_info_path); return feather; } @@ -699,11 +700,11 @@ int Maat_table_callback_register(Maat_feather_t feather,short table_id, { return -1; } - pthread_mutex_lock(&(p_table->cb_info->plugin_mutex)); + pthread_mutex_lock(&(_feather->plugin_table_reg_mutex)); idx=p_table->cb_info->cb_plug_cnt; if(idx==MAX_PLUGING_NUM) { - pthread_mutex_unlock(&(p_table->cb_info->plugin_mutex)); + pthread_mutex_unlock(&(_feather->plugin_table_reg_mutex)); return -1; } p_table->cb_info->cb_plug_cnt++; @@ -731,7 +732,7 @@ int Maat_table_callback_register(Maat_feather_t feather,short table_id, finish(u_para); } } - pthread_mutex_unlock(&(p_table->cb_info->plugin_mutex)); + pthread_mutex_unlock(&(_feather->plugin_table_reg_mutex)); return 1; } int Maat_full_scan_string_detail(Maat_feather_t feather,int table_id diff --git a/src/entry/Maat_rule.cpp b/src/entry/Maat_rule.cpp index 299b520..cb61027 100644 --- a/src/entry/Maat_rule.cpp +++ b/src/entry/Maat_rule.cpp @@ -609,7 +609,6 @@ int read_table_info(struct _Maat_table_info_t** p_table_info,int num,const char* { p->cb_info=(struct _plugin_table_info*)calloc(sizeof(struct _plugin_table_info),1); p->cb_info->cache_lines=dynamic_array_create(1024,1024); - pthread_mutex_init(&(p->cb_info->plugin_mutex),NULL); } p_table_info[p->table_id]=p; table_cnt++; @@ -2681,7 +2680,6 @@ void plugin_table_callback(struct _Maat_table_info_t* table,const char* table_li unsigned int len=strlen(table_line)+1; struct _plugin_table_info* p_table_cb=table->cb_info; char *p=NULL; - pthread_mutex_lock(&(p_table_cb->plugin_mutex)); p_table_cb->acc_line_num++; if(p_table_cb->cb_plug_cnt>0) { @@ -2698,7 +2696,6 @@ void plugin_table_callback(struct _Maat_table_info_t* table,const char* table_li dynamic_array_write(p_table_cb->cache_lines,p_table_cb->cache_line_num,p); p_table_cb->cache_line_num++; } - pthread_mutex_unlock(&(p_table_cb->plugin_mutex)); } void do_scanner_update(struct _Maat_scanner_t* scanner,MESA_lqueue_head garbage_q,int scan_thread_num,void* logger) { @@ -2766,7 +2763,6 @@ void clear_plugin_table_info(struct _plugin_table_info *cb_info) { int i=0; void *line=NULL; - pthread_mutex_lock(&(cb_info->plugin_mutex)); for(i=0;icache_line_num;i++) { line=dynamic_array_read(cb_info->cache_lines,i); @@ -2776,7 +2772,6 @@ void clear_plugin_table_info(struct _plugin_table_info *cb_info) cb_info->cache_line_num=0; cb_info->cache_size=0; cb_info->acc_line_num=0; - pthread_mutex_unlock(&(cb_info->plugin_mutex)); return; } void maat_start_cb(unsigned int new_version,int update_type,void*u_para) @@ -2988,6 +2983,8 @@ void *thread_rule_monitor(void *arg) { usleep(feather->scan_interval_ms*1000); scan_dir_cnt++; + //plugin table register is not allowed during update; + pthread_mutex_lock(&(feather->plugin_table_reg_mutex)); config_monitor_traverse(feather->maat_version, inc_cfg_dir, maat_start_cb, @@ -2995,6 +2992,7 @@ void *thread_rule_monitor(void *arg) maat_finish_cb, feather, feather->logger); + pthread_mutex_unlock(&(feather->plugin_table_reg_mutex)); if(feather->update_tmp_scanner!=NULL) { old_scanner=feather->scanner; diff --git a/src/entry/Maat_rule_internal.h b/src/entry/Maat_rule_internal.h index 5944436..147a4a8 100644 --- a/src/entry/Maat_rule_internal.h +++ b/src/entry/Maat_rule_internal.h @@ -221,7 +221,6 @@ struct _plugin_table_info int acc_line_num; int update_type; long cache_size; - pthread_mutex_t plugin_mutex; }; struct _region_stat_t { @@ -372,6 +371,7 @@ struct _Maat_feather_t char stat_file[MAX_TABLE_NAME_LEN]; char instance_name[MAX_TABLE_NAME_LEN]; char table_info_fn[MAX_TABLE_NAME_LEN]; + pthread_mutex_t plugin_table_reg_mutex; //for stat>>>> screen_stat_handle_t stat_handle; int total_stat_id;