summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhengchao <[email protected]>2021-04-01 14:37:31 +0800
committerzhengchao <[email protected]>2021-04-19 10:27:11 +0800
commit0f6eccbb47d3902b59a62a7703e841a22cd7b6dc (patch)
tree3220882b9a4d7b642625009bed50836f30b10c0e
parente3b3288dc12b7f8dace9bdb8a9dc7133d712e186 (diff)
增加hierarachy中为每个线程分配expr_buff,以修复使用用户设置的缓冲区大小,导致不命中的bug。
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/entry/Maat_hierarchy.cpp24
-rw-r--r--src/entry/Maat_rule.cpp2
-rw-r--r--src/entry/bool_matcher.cpp4
4 files changed, 18 insertions, 14 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a9ba7a2..223bf10 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.5)
set(MAAT_FRAME_MAJOR_VERSION 3)
set(MAAT_FRAME_MINOR_VERSION 1)
-set(MAAT_FRAME_PATCH_VERSION 4)
+set(MAAT_FRAME_PATCH_VERSION 17)
set(MAAT_FRAME_VERSION ${MAAT_FRAME_MAJOR_VERSION}.${MAAT_FRAME_MINOR_VERSION}.${MAAT_FRAME_PATCH_VERSION})
message(STATUS "Maat Frame, Version: ${MAAT_FRAME_VERSION}")
diff --git a/src/entry/Maat_hierarchy.cpp b/src/entry/Maat_hierarchy.cpp
index ae40428..1db7500 100644
--- a/src/entry/Maat_hierarchy.cpp
+++ b/src/entry/Maat_hierarchy.cpp
@@ -110,6 +110,7 @@ struct Maat_hierarchy
int thread_num;
struct Maat_garbage_bin* garbage_bin;
void* logger;
+ struct bool_expr_match *expr_match_buff;
};
int compare_literal_id(const void *pa, const void *pb)
@@ -296,6 +297,7 @@ struct Maat_hierarchy* Maat_hierarchy_new(int thread_num, void* mesa_handle_logg
hier->hash_literal_by_id=NULL;
hier->hash_region_by_id=NULL;
+ hier->expr_match_buff=ALLOC(struct bool_expr_match, thread_num*MAX_SCANNER_HIT_NUM);
ret=igraph_empty(&hier->group_graph, 0, IGRAPH_DIRECTED);
assert(ret==IGRAPH_SUCCESS);
@@ -345,6 +347,8 @@ void Maat_hierarchy_free(struct Maat_hierarchy* hier)
bool_matcher_free(hier->bm);
hier->bm=NULL;
pthread_rwlock_unlock(&hier->rwlock);
+ free(hier->expr_match_buff);
+ hier->expr_match_buff=NULL;
free(hier);
}
@@ -1338,8 +1342,8 @@ int Maat_hierarchy_region_compile(struct Maat_hierarchy_compile_mid* mid, int is
{
int bool_match_ret=0, i=0;
struct Maat_hierarchy* hier=mid->ref_hier;
- struct Maat_hierarchy_compile* compile_array[ud_array_sz];
- struct bool_expr_match expr_match[ud_array_sz];
+ struct Maat_hierarchy_compile* compile_array=NULL;
+ struct bool_expr_match *expr_match=hier->expr_match_buff+mid->thread_num*MAX_SCANNER_HIT_NUM;
size_t r_in_c_cnt=0, this_scan_region_hits=mid->this_scan_region_hit_cnt;
size_t ud_result_cnt=0;
@@ -1351,22 +1355,22 @@ int Maat_hierarchy_region_compile(struct Maat_hierarchy_compile_mid* mid, int is
pthread_rwlock_rdlock(&hier->rwlock);
bool_match_ret=bool_matcher_match(hier->bm, mid->thread_num,
(unsigned long long*)utarray_eltptr(mid->_all_hit_clause_array, 0), utarray_len(mid->_all_hit_clause_array),
- expr_match, ud_array_sz);
- for(i=0; i<bool_match_ret; i++)
+ expr_match, MAX_SCANNER_HIT_NUM);
+ for(i=0; i<bool_match_ret && ud_result_cnt<ud_array_sz; i++)
{
- compile_array[i]=(struct Maat_hierarchy_compile*)expr_match[i].user_tag;
- assert((unsigned long long)compile_array[i]->compile_id==expr_match[i].expr_id);
- r_in_c_cnt=Maat_hierarchy_compile_mid_update_by_compile(mid, compile_array[i]);
- if(compile_array[i]->not_clause_cnt>0 && !is_last_compile)
+ compile_array=(struct Maat_hierarchy_compile*)expr_match[i].user_tag;
+ assert((unsigned long long)compile_array->compile_id==expr_match[i].expr_id);
+ r_in_c_cnt=Maat_hierarchy_compile_mid_update_by_compile(mid, compile_array);
+ if(compile_array->not_clause_cnt>0 && !is_last_compile)
{
mid->not_clause_hitted_flag=1;
}
- else if(compile_array[i]->user_data)//For compile may be dettached by Maat_hierarchy_compile_dettach_user_data, only return non-NULL userdata.
+ else if(compile_array->user_data)//For compile may be dettached by Maat_hierarchy_compile_dettach_user_data, only return non-NULL userdata.
{
if(r_in_c_cnt>0 || //compile hitted becasue of new reigon
this_scan_region_hits==0) //or hit a compile that refer a NOT-logic group in previous scan.
{
- user_data_array[ud_result_cnt]=compile_array[i]->user_data;
+ user_data_array[ud_result_cnt]=compile_array->user_data;
ud_result_cnt++;
}
}
diff --git a/src/entry/Maat_rule.cpp b/src/entry/Maat_rule.cpp
index 0aeff39..2aa53e9 100644
--- a/src/entry/Maat_rule.cpp
+++ b/src/entry/Maat_rule.cpp
@@ -57,7 +57,7 @@ extern "C"
}
#endif
-int MAAT_FRAME_VERSION_3_1_16_20210320=1;
+int MAAT_FRAME_VERSION_3_1_17_20210323=1;
int is_valid_table_name(const char* str)
{
diff --git a/src/entry/bool_matcher.cpp b/src/entry/bool_matcher.cpp
index c391d5d..f868d3f 100644
--- a/src/entry/bool_matcher.cpp
+++ b/src/entry/bool_matcher.cpp
@@ -194,7 +194,7 @@ int bool_matcher_match(struct bool_matcher * matcher, unsigned int thread_id, co
for(unsigned int j=matcher->mapped_ptr[h]; j<matcher->mapped_ptr[h+1]; j++)
{
- if(ids_num==MAX_ARRAY_SIZE) return -1;
+ if(ids_num==MAX_ARRAY_SIZE) continue;
mapped_ids[ids_num++]=matcher->mapped_ids[j];
}
}
@@ -203,7 +203,7 @@ int bool_matcher_match(struct bool_matcher * matcher, unsigned int thread_id, co
unsigned int used_num=0;
for(unsigned int i=0; i<ids_num; i++)
{
- if(used_num==MAX_ARRAY_SIZE) return -1;
+ if(used_num==MAX_ARRAY_SIZE) continue;
used_cells[used_num++]=(mapped_ids[i]>>3);
}