使用glibc中的remove函数替代rm命令;清理无用代码,垃圾回收方式删除外键文件功能,在不支持MAAT_OPT_FOREIGN_CONT_LINGER选项后已不使用。
This commit is contained in:
@@ -410,8 +410,8 @@ int region_compile(_Maat_feather_t*feather, struct scan_hit_status *_mid, const
|
||||
size_t r_in_c_cnt=0;
|
||||
struct bool_matcher* bm=feather->scanner->bool_matcher_expr_compiler;
|
||||
struct Maat_group_inner* group_rule=NULL;
|
||||
struct Maat_compile_inner* relation_array[MAX_SCANNER_HIT_NUM];
|
||||
struct Maat_compile_inner* relation=NULL;
|
||||
struct Maat_compile_inner* compile_inner_array[MAX_SCANNER_HIT_NUM];
|
||||
struct Maat_compile_inner* compile_inner=NULL;
|
||||
int virtual_table_id=0;
|
||||
const unsigned long long* hit_group_ids=NULL;
|
||||
size_t hit_group_id_cnt=0;
|
||||
@@ -444,7 +444,7 @@ int region_compile(_Maat_feather_t*feather, struct scan_hit_status *_mid, const
|
||||
hit_group_id_cnt=scan_hit_status_read_group_ids(_mid, &hit_group_ids);
|
||||
scan_ret=bool_matcher_match(bm, thread_num,
|
||||
hit_group_ids, hit_group_id_cnt,
|
||||
(void **)relation_array, MAX_SCANNER_HIT_NUM);
|
||||
(void **)compile_inner_array, MAX_SCANNER_HIT_NUM);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -452,38 +452,38 @@ int region_compile(_Maat_feather_t*feather, struct scan_hit_status *_mid, const
|
||||
}
|
||||
if(scan_ret>1)
|
||||
{
|
||||
qsort(relation_array, scan_ret, sizeof(struct Maat_compile_inner*),
|
||||
qsort(compile_inner_array, scan_ret, sizeof(struct Maat_compile_inner*),
|
||||
compare_compile_inner);
|
||||
}
|
||||
for(i=0; i<(unsigned int)scan_ret&&result_cnt<size; i++)
|
||||
{
|
||||
relation=relation_array[i];
|
||||
if(relation==NULL)
|
||||
compile_inner=compile_inner_array[i];
|
||||
if(compile_inner==NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
assert(relation->magic_num==COMPILE_RELATION_MAGIC);
|
||||
if(0==pthread_rwlock_tryrdlock(&(relation->rwlock)))
|
||||
assert(compile_inner->magic_num==COMPILE_INNER_MAGIC);
|
||||
if(0==pthread_rwlock_tryrdlock(&(compile_inner->rwlock)))
|
||||
{
|
||||
if(relation->compile)
|
||||
if(compile_inner->compile)
|
||||
{
|
||||
if(relation->not_group_cnt>0 && !is_last_region)
|
||||
if(compile_inner->not_group_cnt>0 && !is_last_region)
|
||||
{
|
||||
_mid->not_grp_compile_hitted_flag=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
r_in_c_cnt=scan_hit_status_update_by_compile(_mid, relation, region_hit_wraper->Nth_scan);
|
||||
r_in_c_cnt=scan_hit_status_update_by_compile(_mid, compile_inner, region_hit_wraper->Nth_scan);
|
||||
if(r_in_c_cnt>0 || //compile hitted becasue of new reigon
|
||||
region_hit_num==0) //or hit a compile that refer a NOT-logic group in previous scan.
|
||||
{
|
||||
fill_maat_rule(&(result[result_cnt]), &(relation->compile->head),
|
||||
relation->compile->service_defined, relation->compile->head.serv_def_len);
|
||||
fill_maat_rule(&(result[result_cnt]), &(compile_inner->compile->head),
|
||||
compile_inner->compile->service_defined, compile_inner->compile->head.serv_def_len);
|
||||
result_cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
pthread_rwlock_unlock(&(relation->rwlock));
|
||||
pthread_rwlock_unlock(&(compile_inner->rwlock));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1741,7 +1741,8 @@ void _get_foreign_conts(redisContext *ctx, struct serial_rule_t* rule_list, int
|
||||
{
|
||||
for(j=0; j<rule_list[i].n_foreign; j++)
|
||||
{
|
||||
ret=system_cmd_rm(rule_list[i].f_keys[j].filename);
|
||||
//ret=system_cmd_rm(rule_list[i].f_keys[j].filename);
|
||||
ret=remove(rule_list[i].f_keys[j].filename);
|
||||
if(ret==-1)
|
||||
{
|
||||
MESA_handle_runtime_log(logger, RLOG_LV_INFO, maat_module,
|
||||
|
||||
@@ -792,7 +792,7 @@ struct Maat_compile_inner * create_compile_group_relation(int compile_id, struct
|
||||
{
|
||||
int ret=0;
|
||||
struct Maat_compile_inner* p=ALLOC(struct Maat_compile_inner, 1);
|
||||
p->magic_num=COMPILE_RELATION_MAGIC;
|
||||
p->magic_num=COMPILE_INNER_MAGIC;
|
||||
p->compile_id=compile_id;
|
||||
p->group_cnt=0;
|
||||
p->group_boundary=1;
|
||||
@@ -803,9 +803,9 @@ struct Maat_compile_inner * create_compile_group_relation(int compile_id, struct
|
||||
return p;
|
||||
}
|
||||
|
||||
void _destroy_compile_group_relation(struct Maat_compile_inner * cg_relation)
|
||||
void _destroy_compile_inner(struct Maat_compile_inner * cg_relation)
|
||||
{
|
||||
assert(cg_relation->magic_num==COMPILE_RELATION_MAGIC);
|
||||
assert(cg_relation->magic_num==COMPILE_INNER_MAGIC);
|
||||
pthread_rwlock_wrlock(&(cg_relation->rwlock));
|
||||
cg_relation->compile_id=-1;
|
||||
dynamic_array_destroy(cg_relation->groups, NULL);
|
||||
@@ -815,7 +815,7 @@ void _destroy_compile_group_relation(struct Maat_compile_inner * cg_relation)
|
||||
|
||||
free(cg_relation);
|
||||
}
|
||||
void destroy_compile_group_relation(struct Maat_compile_inner * p, struct Maat_scanner *scanner)
|
||||
void destroy_compile_inner(struct Maat_compile_inner * p, struct Maat_scanner *scanner)
|
||||
{
|
||||
int i=0;
|
||||
UNUSED struct Maat_group_inner* p_group=NULL;
|
||||
@@ -826,9 +826,9 @@ void destroy_compile_group_relation(struct Maat_compile_inner * p, struct Maat_s
|
||||
p_group=(struct Maat_group_inner*)dynamic_array_read(p->groups, i);
|
||||
assert(p_group==NULL);
|
||||
}
|
||||
assert(p->magic_num==COMPILE_RELATION_MAGIC);
|
||||
assert(p->magic_num==COMPILE_INNER_MAGIC);
|
||||
HASH_delete_by_id(scanner->compile_hash, p->compile_id);
|
||||
garbage_bagging(GARBAGE_COMPILE_GOURP_RELATION, p, scanner->tomb_ref);
|
||||
garbage_bagging(GARBAGE_COMPILE_INNER, p, scanner->tomb_ref);
|
||||
}
|
||||
scan_rule_t* create_rs_str_rule(unsigned int sub_type,enum MAAT_MATCH_METHOD match_method,int is_case_sensitive,const char* string,int len,int l_offset,int r_offset)
|
||||
{
|
||||
@@ -1049,7 +1049,7 @@ void destroy_maat_scanner(struct Maat_scanner*scanner)
|
||||
return;
|
||||
}
|
||||
rulescan_destroy(scanner->region);
|
||||
MESA_htable_destroy(scanner->compile_hash,(void (*)(void*))_destroy_compile_group_relation);
|
||||
MESA_htable_destroy(scanner->compile_hash,(void (*)(void*))_destroy_compile_inner);
|
||||
MESA_htable_destroy(scanner->group_hash, (void (*)(void*))_destroy_group_rule);
|
||||
MESA_htable_destroy(scanner->exprid_hash, NULL);
|
||||
MESA_htable_destroy(scanner->region_hash, NULL);
|
||||
@@ -2109,7 +2109,7 @@ int del_group_rule(struct Maat_table_schema* table, struct db_group_rule_t* db_g
|
||||
}
|
||||
if(relation->group_cnt==0 && relation->compile==NULL)
|
||||
{
|
||||
destroy_compile_group_relation(relation, scanner);
|
||||
destroy_compile_inner(relation, scanner);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2159,7 +2159,7 @@ int del_compile_rule(struct Maat_table_schema* table, int compile_id, struct Maa
|
||||
|
||||
if(cg_relation->group_cnt==0&&cg_relation->compile==NULL)
|
||||
{
|
||||
destroy_compile_group_relation(cg_relation, scanner);
|
||||
destroy_compile_inner(cg_relation, scanner);
|
||||
}
|
||||
scanner->to_update_compile_cnt++;
|
||||
return 1;
|
||||
@@ -2932,8 +2932,8 @@ void garbage_bury(MESA_lqueue_head garbage_q, int timeout, void *logger)
|
||||
case GARBAGE_COMPILE_RULE:
|
||||
destroy_compile_rule(bag->compile_rule);
|
||||
break;
|
||||
case GARBAGE_COMPILE_GOURP_RELATION:
|
||||
_destroy_compile_group_relation(bag->compile_group_relation);
|
||||
case GARBAGE_COMPILE_INNER:
|
||||
_destroy_compile_inner(bag->compile_group_relation);
|
||||
break;
|
||||
case GARBAGE_GROUP_RULE:
|
||||
_destroy_group_rule(bag->group_rule);
|
||||
@@ -2959,24 +2959,6 @@ void garbage_bury(MESA_lqueue_head garbage_q, int timeout, void *logger)
|
||||
case GARBAGE_MAP_STR2INT:
|
||||
map_destroy(bag->str2int_map);
|
||||
break;
|
||||
case GARBAGE_FOREIGN_FILE:
|
||||
ret=system_cmd_rm(bag->filename);
|
||||
if(ret==-1)
|
||||
{
|
||||
MESA_handle_runtime_log(logger,RLOG_LV_INFO,maat_module,
|
||||
"Foreign content file %s remove failed.",
|
||||
bag->filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
MESA_handle_runtime_log(logger,RLOG_LV_DEBUG,maat_module,
|
||||
"Foreign content file %s remove success.",
|
||||
bag->filename);
|
||||
}
|
||||
free(bag->filename);
|
||||
bag->filename=NULL;
|
||||
break;
|
||||
case GARBAGE_IP_MATCHER:
|
||||
ip_matcher_free(bag->a_ip_matcher);
|
||||
bag->a_ip_matcher=NULL;
|
||||
|
||||
@@ -153,14 +153,14 @@ struct Maat_group_inner
|
||||
dynamic_array_t *regions;
|
||||
pthread_mutex_t mutex;
|
||||
};
|
||||
|
||||
#define COMPILE_RELATION_MAGIC 0x1a2b3c4d
|
||||
#define COMPILE_INNER_MAGIC 0x1a2b3c4d
|
||||
struct Maat_group_reference
|
||||
{
|
||||
struct Maat_group_inner* ref_group;
|
||||
char not_flag;
|
||||
int virtual_table_id;
|
||||
int clause_id;
|
||||
int local_clause_id;
|
||||
int global_clause_id;
|
||||
TAILQ_ENTRY(Maat_group_reference) entries;
|
||||
};
|
||||
TAILQ_HEAD(ref_group_q, Maat_group_reference);
|
||||
@@ -223,10 +223,9 @@ enum maat_garbage_type
|
||||
GARBAGE_SCANNER=0,
|
||||
GARBAGE_GROUP_RULE,
|
||||
GARBAGE_COMPILE_RULE,
|
||||
GARBAGE_COMPILE_GOURP_RELATION,
|
||||
GARBAGE_COMPILE_INNER,
|
||||
GARBAGE_BOOL_MATCHER,
|
||||
GARBAGE_MAP_STR2INT,
|
||||
GARBAGE_FOREIGN_FILE,
|
||||
GARBAGE_IP_MATCHER
|
||||
};
|
||||
struct iconv_handle_t
|
||||
|
||||
Reference in New Issue
Block a user