diff --git a/inc/Maat_rule.h b/inc/Maat_rule.h index d9f1d49..81d5419 100644 --- a/inc/Maat_rule.h +++ b/inc/Maat_rule.h @@ -155,6 +155,13 @@ enum MAAT_INIT_OPT }; //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); +enum MAAT_STATE_OPT +{ + MAAT_STATE_VERSION=1, //Get current maat version. VALUE is interger, SIZE=sizeof(int). + MAAT_STATE_LAST_UPDATING_TABLE //Query at Maat_finish_callback_t to determine whether this table is the last one to update. VALUE is interger, SIZE=sizeof(int), 1:yes, 0: no +}; +int Maat_read_feather_state(Maat_feather_t feather,enum MAAT_STATE_OPT type,const void* value,int size); + void Maat_burn_feather(Maat_feather_t feather); //return table_id(>=0) if success,otherwise return -1; diff --git a/src/entry/Maat_command.cpp b/src/entry/Maat_command.cpp index 9b056cd..a9e0dc3 100644 --- a/src/entry/Maat_command.cpp +++ b/src/entry/Maat_command.cpp @@ -1251,17 +1251,20 @@ int Maat_cmd_set_lines(Maat_feather_t feather,const struct Maat_line_t** line_ru ret=-1; goto error_out; } - ret=get_valid_flag_offset(line_rule[i]->table_line - , _feather->p_table_info[table_id]->table_type - , _feather->p_table_info[table_id]->valid_flag_column); - if(ret<0|| - (op==MAAT_OP_ADD&&line_rule[i]->table_line[ret]!='1')) + if(op==MAAT_OP_ADD) { - MESA_handle_runtime_log(_feather->logger,RLOG_LV_FATAL,maat_command - ,"Command set line id %d failed: illegal valid flag." - , line_rule[i]->rule_id); - ret=-1; - goto error_out; + ret=get_valid_flag_offset(line_rule[i]->table_line + , _feather->p_table_info[table_id]->table_type + , _feather->p_table_info[table_id]->valid_flag_column); + if(ret<0|| + (op==MAAT_OP_ADD&&line_rule[i]->table_line[ret]!='1')) + { + MESA_handle_runtime_log(_feather->logger,RLOG_LV_FATAL,maat_command + ,"Command set line id %d failed: illegal valid flag." + , line_rule[i]->rule_id); + ret=-1; + goto error_out; + } } if(line_rule[i]->expire_after>0) { diff --git a/src/entry/Maat_rule.cpp b/src/entry/Maat_rule.cpp index c6c94b7..e1f6a56 100644 --- a/src/entry/Maat_rule.cpp +++ b/src/entry/Maat_rule.cpp @@ -2980,6 +2980,7 @@ void maat_start_cb(unsigned int new_version,int update_type,void*u_para) struct _Maat_table_info_t* p_table=NULL; struct _plugin_table_info* p_table_cb=NULL; int i=0,j=0; + feather->new_version=new_version; if(update_type==CM_UPDATE_TYPE_FULL) { feather->update_tmp_scanner=create_maat_scanner(new_version,feather); @@ -3017,6 +3018,7 @@ void maat_start_cb(unsigned int new_version,int update_type,void*u_para) { continue; } + feather->active_plugin_table_num++; p_table_cb=p_table->cb_info; for(j=0;jcb_plug_cnt;j++) { @@ -3052,6 +3054,10 @@ void maat_finish_cb(void* u_para) continue; } p_table_cb=p_table->cb_info; + if(i==feather->active_plugin_table_num) + { + feather->is_last_plugin_table_updating=1; + } for(j=0;jcb_plug_cnt;j++) { if(p_table_cb->cb_plug[j].finish!=NULL) @@ -3059,6 +3065,7 @@ void maat_finish_cb(void* u_para) p_table_cb->cb_plug[j].finish(p_table_cb->cb_plug[j].u_para); } } + feather->is_last_plugin_table_updating=0; } if(feather->update_tmp_scanner!=NULL) { @@ -3101,6 +3108,8 @@ void maat_finish_cb(void* u_para) "Version %d have no valid scan rules, plugin callback complete.", feather->maat_version); } + feather->new_version=-1; + feather->active_plugin_table_num=0; return; } int maat_update_cb(const char* table_name,const char* line,void *u_para) diff --git a/src/entry/Maat_rule_internal.h b/src/entry/Maat_rule_internal.h index 4839c2e..dc78dfd 100644 --- a/src/entry/Maat_rule_internal.h +++ b/src/entry/Maat_rule_internal.h @@ -392,6 +392,11 @@ struct _Maat_feather_t struct _Maat_cmd_inner_t* cmd_qhead, *cmd_qtail; pthread_mutex_t redis_write_lock; //protect redis_write_ctx long long base_rgn_seq,base_grp_seq,server_time; +//internal states + int new_version; + int active_plugin_table_num; + int is_last_plugin_table_updating; + //for stat>>>> screen_stat_handle_t stat_handle; int total_stat_id;