暴露内部状态

This commit is contained in:
zhengchao
2017-12-06 14:41:08 +08:00
parent 1d3c2f8f2c
commit 6e7e8214cc
4 changed files with 34 additions and 10 deletions

View File

@@ -155,6 +155,13 @@ enum MAAT_INIT_OPT
}; };
//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);
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); void Maat_burn_feather(Maat_feather_t feather);
//return table_id(>=0) if success,otherwise return -1; //return table_id(>=0) if success,otherwise return -1;

View File

@@ -1251,6 +1251,8 @@ int Maat_cmd_set_lines(Maat_feather_t feather,const struct Maat_line_t** line_ru
ret=-1; ret=-1;
goto error_out; goto error_out;
} }
if(op==MAAT_OP_ADD)
{
ret=get_valid_flag_offset(line_rule[i]->table_line ret=get_valid_flag_offset(line_rule[i]->table_line
, _feather->p_table_info[table_id]->table_type , _feather->p_table_info[table_id]->table_type
, _feather->p_table_info[table_id]->valid_flag_column); , _feather->p_table_info[table_id]->valid_flag_column);
@@ -1263,6 +1265,7 @@ int Maat_cmd_set_lines(Maat_feather_t feather,const struct Maat_line_t** line_ru
ret=-1; ret=-1;
goto error_out; goto error_out;
} }
}
if(line_rule[i]->expire_after>0) if(line_rule[i]->expire_after>0)
{ {
absolute_expire_time=server_time+line_rule[i]->expire_after; absolute_expire_time=server_time+line_rule[i]->expire_after;

View File

@@ -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 _Maat_table_info_t* p_table=NULL;
struct _plugin_table_info* p_table_cb=NULL; struct _plugin_table_info* p_table_cb=NULL;
int i=0,j=0; int i=0,j=0;
feather->new_version=new_version;
if(update_type==CM_UPDATE_TYPE_FULL) if(update_type==CM_UPDATE_TYPE_FULL)
{ {
feather->update_tmp_scanner=create_maat_scanner(new_version,feather); 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; continue;
} }
feather->active_plugin_table_num++;
p_table_cb=p_table->cb_info; p_table_cb=p_table->cb_info;
for(j=0;j<p_table_cb->cb_plug_cnt;j++) for(j=0;j<p_table_cb->cb_plug_cnt;j++)
{ {
@@ -3052,6 +3054,10 @@ void maat_finish_cb(void* u_para)
continue; continue;
} }
p_table_cb=p_table->cb_info; p_table_cb=p_table->cb_info;
if(i==feather->active_plugin_table_num)
{
feather->is_last_plugin_table_updating=1;
}
for(j=0;j<p_table_cb->cb_plug_cnt;j++) for(j=0;j<p_table_cb->cb_plug_cnt;j++)
{ {
if(p_table_cb->cb_plug[j].finish!=NULL) 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); 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) 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.", "Version %d have no valid scan rules, plugin callback complete.",
feather->maat_version); feather->maat_version);
} }
feather->new_version=-1;
feather->active_plugin_table_num=0;
return; return;
} }
int maat_update_cb(const char* table_name,const char* line,void *u_para) int maat_update_cb(const char* table_name,const char* line,void *u_para)

View File

@@ -392,6 +392,11 @@ struct _Maat_feather_t
struct _Maat_cmd_inner_t* cmd_qhead, *cmd_qtail; struct _Maat_cmd_inner_t* cmd_qhead, *cmd_qtail;
pthread_mutex_t redis_write_lock; //protect redis_write_ctx pthread_mutex_t redis_write_lock; //protect redis_write_ctx
long long base_rgn_seq,base_grp_seq,server_time; 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>>>> //for stat>>>>
screen_stat_handle_t stat_handle; screen_stat_handle_t stat_handle;
int total_stat_id; int total_stat_id;