From cad9604695271861027267123c253fa7d308f2ef Mon Sep 17 00:00:00 2001 From: zhengchao Date: Sun, 31 May 2020 10:20:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8glibc=E4=B8=AD=E7=9A=84remove?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E6=9B=BF=E4=BB=A3rm=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=EF=BC=9B=E6=B8=85=E7=90=86=E6=97=A0=E7=94=A8=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E5=9E=83=E5=9C=BE=E5=9B=9E=E6=94=B6=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=96=E9=94=AE=E6=96=87=E4=BB=B6=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E5=9C=A8=E4=B8=8D=E6=94=AF=E6=8C=81MAAT=5FOP?= =?UTF-8?q?T=5FFOREIGN=5FCONT=5FLINGER=E9=80=89=E9=A1=B9=E5=90=8E=E5=B7=B2?= =?UTF-8?q?=E4=B8=8D=E4=BD=BF=E7=94=A8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entry/Maat_api.cpp | 28 +++++++++---------- src/entry/Maat_command.cpp | 3 +- src/entry/Maat_rule.cpp | 40 ++++++++------------------- src/inc_internal/Maat_rule_internal.h | 9 +++--- 4 files changed, 31 insertions(+), 49 deletions(-) diff --git a/src/entry/Maat_api.cpp b/src/entry/Maat_api.cpp index 5c623fb..dbe1916 100644 --- a/src/entry/Maat_api.cpp +++ b/src/entry/Maat_api.cpp @@ -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_cntmagic_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)); } } diff --git a/src/entry/Maat_command.cpp b/src/entry/Maat_command.cpp index 1801e90..e1a458b 100644 --- a/src/entry/Maat_command.cpp +++ b/src/entry/Maat_command.cpp @@ -1741,7 +1741,8 @@ void _get_foreign_conts(redisContext *ctx, struct serial_rule_t* rule_list, int { for(j=0; jmagic_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; diff --git a/src/inc_internal/Maat_rule_internal.h b/src/inc_internal/Maat_rule_internal.h index 2db3142..b0138f5 100644 --- a/src/inc_internal/Maat_rule_internal.h +++ b/src/inc_internal/Maat_rule_internal.h @@ -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