fix coredump because of no compile/group2compile/group2group field in maat_json.json file

This commit is contained in:
liuwentan
2023-03-30 20:49:59 +08:00
parent 4bbd0ebdc4
commit 18881c5bc3
8 changed files with 726 additions and 19 deletions

View File

@@ -1094,17 +1094,32 @@ int json2iris(const char *json_buff, const char *json_filename,
tmp_obj = cJSON_GetObjectItem(json, "compile_table");
if (tmp_obj) {
compile_tbl_name = tmp_obj->valuestring;
}
} else {
log_error(logger, MODULE_JSON2IRIS,
"[%s:%d] json file:%s has no [compile_table] field",
__FUNCTION__, __LINE__, json_filename);
goto error_out;
}
tmp_obj = cJSON_GetObjectItem(json, "group2compile_table");
if (tmp_obj) {
group2compile_tbl_name = tmp_obj->valuestring;
}
} else {
log_error(logger, MODULE_JSON2IRIS,
"[%s:%d] json file:%s has no [group2compile_table] field",
__FUNCTION__, __LINE__, json_filename);
goto error_out;
}
tmp_obj = cJSON_GetObjectItem(json, "group2group_table");
if (tmp_obj) {
group2group_tbl_name = tmp_obj->valuestring;
}
} else {
log_error(logger, MODULE_JSON2IRIS,
"[%s:%d] json file:%s has no [group2group_table] field",
__FUNCTION__, __LINE__, json_filename);
goto error_out;
}
ret = set_iris_descriptor(json_filename, json, encrypt_key, encrypt_algo,
compile_tbl_name, group2compile_tbl_name,

View File

@@ -1185,13 +1185,17 @@ size_t group_to_compile(struct maat *maat_instance, long long *results, size_t n
{
int compile_table_id = -1;
if (state->compile_table_id != 0) {
if (state->compile_table_id > 0) {
compile_table_id = state->compile_table_id;
} else {
compile_table_id = maat_instance->default_compile_table_id;
}
void *compile_rt = table_manager_get_runtime(maat_instance->tbl_mgr, compile_table_id);
if (NULL == compile_rt) {
return 0;
}
size_t n_hit_compile = hit_group_to_compile(compile_rt, results, n_result, state);
assert(state->is_last_scan < LAST_SCAN_FINISHED);
@@ -1800,20 +1804,21 @@ int maat_state_get_hit_paths(struct maat_state *state, struct maat_hit_path *pat
}
int compile_table_id = -1;
if (state->compile_table_id != 0) {
if (state->compile_table_id > 0) {
compile_table_id = state->compile_table_id;
} else {
compile_table_id = maat_instance->default_compile_table_id;
}
void *g2g_runtime = table_manager_get_runtime(maat_instance->tbl_mgr, maat_instance->g2g_table_id);
assert(g2g_runtime != NULL);
size_t internal_hit_path_cnt = maat_compile_state_get_internal_hit_paths(state->compile_state,
(struct group2group_runtime *)g2g_runtime,
paths, n_path);
void *compile_rt = table_manager_get_runtime(maat_instance->tbl_mgr, compile_table_id);
assert(NULL != compile_rt);
if (NULL == compile_rt) {
return internal_hit_path_cnt;
}
return compile_runtime_get_hit_paths((struct compile_runtime *)compile_rt,
state->compile_state, paths, n_path,

View File

@@ -1244,10 +1244,6 @@ static inline int compare_clause_id(const void *a, const void *b)
struct maat_compile_state *maat_compile_state_new(int thread_id)
{
if (thread_id < 0) {
return NULL;
}
struct maat_compile_state *compile_state = ALLOC(struct maat_compile_state, 1);
compile_state->thread_id = thread_id;
@@ -1858,7 +1854,7 @@ int maat_compile_state_update(struct rcu_hash_table *item_htable, int vtable_id,
/* update hit clause */
int compile_table_id = -1;
if (state->compile_table_id != 0) {
if (state->compile_table_id > 0) {
compile_table_id = state->compile_table_id;
} else {
compile_table_id = state->maat_instance->default_compile_table_id;
@@ -1866,7 +1862,9 @@ int maat_compile_state_update(struct rcu_hash_table *item_htable, int vtable_id,
void *compile_rt = table_manager_get_runtime(state->maat_instance->tbl_mgr,
compile_table_id);
assert(compile_rt != NULL);
if (NULL == compile_rt) {
return 0;
}
long long top_group_ids[MAX_SCANNER_HIT_GROUP_NUM];
memset(top_group_ids, -1, sizeof(top_group_ids));

View File

@@ -488,8 +488,8 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
}
}
int default_compile_table_id = MAX_TABLE_NUM;
int g2g_table_id = MAX_TABLE_NUM;
int default_compile_table_id = -1;
int g2g_table_id = -1;
struct maat_kv_store *reserved_word_map = maat_kv_store_new();
register_reserved_word(reserved_word_map);
@@ -516,12 +516,14 @@ table_manager_create(const char *table_info_path, const char *accept_tags,
maat_tbl->table_name, maat_tbl->table_id);
if (maat_tbl->table_type == TABLE_TYPE_COMPILE) {
if (maat_tbl->table_id < default_compile_table_id) {
if (default_compile_table_id < 0) {
default_compile_table_id = maat_tbl->table_id;
} else if (maat_tbl->table_id < default_compile_table_id) {
default_compile_table_id = maat_tbl->table_id;
}
}
if (maat_tbl->table_type == TABLE_TYPE_GROUP2GROUP) {
if (maat_tbl->table_type == TABLE_TYPE_GROUP2GROUP) {
g2g_table_id = maat_tbl->table_id;
}