From 41b3628b53becbeef60a8fca0794c8ec1dd46e2f Mon Sep 17 00:00:00 2001 From: zhengchao Date: Mon, 6 Jul 2020 16:46:41 +0800 Subject: [PATCH] =?UTF-8?q?region=5Frule=5Finner=E4=B8=AD=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0magic=5Fnum=EF=BC=8C=E4=BB=A5=E8=AF=8A=E6=96=ADregion?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=88=A0=E9=99=A4=E6=97=B6=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E5=8F=91=E7=94=9F=E7=9A=84=E9=87=8E=E6=8C=87=E9=92=88=E8=AE=BF?= =?UTF-8?q?=E9=97=AE=EF=BC=9B=E5=90=8C=E6=97=B6hierarchy=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=AF=B9region=5Fid=E6=9F=A5=E6=89=BE=E7=9A=84=E5=88=A4?= =?UTF-8?q?=E7=A9=BA=EF=BC=8C=E4=BB=A5=E9=81=BF=E5=85=8D=E5=9C=A8=E4=B8=80?= =?UTF-8?q?=E4=B8=AAregion=E6=89=AB=E6=8F=8F=E5=91=BD=E4=B8=AD=E5=90=8E?= =?UTF-8?q?=EF=BC=8Chierarchy=E4=B8=AD=E8=AF=A5region=E5=8F=88=E8=A2=AB?= =?UTF-8?q?=E5=88=A0=E9=99=A4=EF=BC=8C=E4=BA=A7=E7=94=9F=E7=9A=84=E7=A9=BA?= =?UTF-8?q?=E6=8C=87=E9=92=88=E8=AE=BF=E9=97=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entry/Maat_api.cpp | 1 + src/entry/Maat_hierarchy.cpp | 6 ++++++ src/entry/Maat_rule.cpp | 5 ++++- src/inc_internal/Maat_rule_internal.h | 3 ++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/entry/Maat_api.cpp b/src/entry/Maat_api.cpp index 2ae109d..fdff783 100644 --- a/src/entry/Maat_api.cpp +++ b/src/entry/Maat_api.cpp @@ -235,6 +235,7 @@ int region_compile(_Maat_feather_t*feather, struct Maat_hierarchy_compile_mid* c for(i=0; (size_t)imagic_num==REGION_RULE_MAGIC); if(region_hit_wraper->virtual_table_ids) { virtual_table_id=region_hit_wraper->virtual_table_ids[i]; diff --git a/src/entry/Maat_hierarchy.cpp b/src/entry/Maat_hierarchy.cpp index ca14f55..b97f50f 100644 --- a/src/entry/Maat_hierarchy.cpp +++ b/src/entry/Maat_hierarchy.cpp @@ -1052,6 +1052,12 @@ void Maat_hierarchy_compile_mid_udpate(struct Maat_hierarchy_compile_mid* mid, i mid->this_scan_region_hit_cnt++; pthread_rwlock_rdlock(&hier->rwlock); HASH_FIND_INT(hier->hash_region_by_id, ®ion_id, region); + if(!region) + { + pthread_rwlock_unlock(&hier->rwlock); + return; + } + group=region->ref_parent_group; if(group->top_group_cnt==0) diff --git a/src/entry/Maat_rule.cpp b/src/entry/Maat_rule.cpp index 413f89e..6a944fc 100644 --- a/src/entry/Maat_rule.cpp +++ b/src/entry/Maat_rule.cpp @@ -34,7 +34,7 @@ #include "stream_fuzzy_hash.h" #include "gram_index_engine.h" -int MAAT_FRAME_VERSION_3_0_20200703=1; +int MAAT_FRAME_VERSION_3_0_20200706=1; int is_valid_table_name(const char* str) { @@ -715,6 +715,8 @@ void op_expr_add_rule(struct op_expr_t* op_expr,scan_rule_t* p_rule) } void Maat_region_inner_free(struct Maat_region_inner* region) { + assert(region->magic_num==REGION_RULE_MAGIC); + region->magic_num=0; free(region); } @@ -1031,6 +1033,7 @@ int get_district_id(Maat_scanner *scanner,const char* district_str) struct Maat_region_inner* Maat_region_inner_new(int group_id, int region_id, int table_id, int district_id) { struct Maat_region_inner* region=ALLOC(struct Maat_region_inner, 1); + region->magic_num=REGION_RULE_MAGIC; region->region_id=region_id; region->group_id=group_id; region->table_id=table_id; diff --git a/src/inc_internal/Maat_rule_internal.h b/src/inc_internal/Maat_rule_internal.h index 74c3690..c016ff0 100644 --- a/src/inc_internal/Maat_rule_internal.h +++ b/src/inc_internal/Maat_rule_internal.h @@ -136,9 +136,10 @@ struct op_expr_t int table_id; int rule_type; }; - +#define REGION_RULE_MAGIC 0x4d3c2b1a struct Maat_region_inner { + long long magic_num; int region_id; int group_id; int district_id;