[PATCH]check for same table_name but different table_id in table_info
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
#include "maat_utils.h"
|
#include "maat_utils.h"
|
||||||
#include "../bool_matcher/bool_matcher.h"
|
#include "../bool_matcher/bool_matcher.h"
|
||||||
|
|
||||||
#define MAX_OFFSET_NUM 1024
|
#define MAX_OFFSET_NUM 1024
|
||||||
#define MAX_HIT_PATTERN_NUM 512
|
#define MAX_HIT_PATTERN_NUM 512
|
||||||
|
|
||||||
pid_t hs_gettid()
|
pid_t hs_gettid()
|
||||||
|
|||||||
@@ -592,6 +592,7 @@ static int register_tablename2id(cJSON *json, struct maat_kv_store *tablename2id
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
long long tmp_table_id = 0;
|
long long tmp_table_id = 0;
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
int n_table_name = cJSON_GetArraySize(item);
|
int n_table_name = cJSON_GetArraySize(item);
|
||||||
@@ -607,17 +608,20 @@ static int register_tablename2id(cJSON *json, struct maat_kv_store *tablename2id
|
|||||||
|
|
||||||
if (strlen(tmp_item->valuestring) >= NAME_MAX) {
|
if (strlen(tmp_item->valuestring) >= NAME_MAX) {
|
||||||
log_error(logger, MODULE_TABLE,
|
log_error(logger, MODULE_TABLE,
|
||||||
"[%s:%d] table(table_id:%d) db_tables string %s length exceed maxium:%d",
|
"[%s:%d] table(table_id:%d) db_tables string %s length "
|
||||||
__FUNCTION__, __LINE__, table_id, tmp_item->valuestring, NAME_MAX);
|
"exceed maxium:%d", __FUNCTION__, __LINE__, table_id,
|
||||||
|
tmp_item->valuestring, NAME_MAX);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (maat_kv_read(tablename2id_map, tmp_item->valuestring, &tmp_table_id) > 0) {
|
ret = maat_kv_read(tablename2id_map, tmp_item->valuestring, &tmp_table_id);
|
||||||
// log_error(logger, MODULE_TABLE,
|
if (ret > 0 && tmp_table_id != table_id) {
|
||||||
// "[%s:%d] table:<%s>(table_id:%lld) has already been registered, can't register again",
|
log_error(logger, MODULE_TABLE,
|
||||||
// __FUNCTION__, __LINE__, tmp_item->valuestring, tmp_table_id);
|
"[%s:%d] table:<%s>(table_id:%lld) has already been registered"
|
||||||
// return -1;
|
", can't register again", __FUNCTION__, __LINE__,
|
||||||
// }
|
tmp_item->valuestring, tmp_table_id);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
maat_kv_register(tablename2id_map, tmp_item->valuestring, table_id);
|
maat_kv_register(tablename2id_map, tmp_item->valuestring, table_id);
|
||||||
}
|
}
|
||||||
@@ -638,12 +642,14 @@ static int register_tablename2id(cJSON *json, struct maat_kv_store *tablename2id
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (maat_kv_read(tablename2id_map, item->valuestring, &tmp_table_id) > 0) {
|
ret = maat_kv_read(tablename2id_map, item->valuestring, &tmp_table_id);
|
||||||
// log_error(logger, MODULE_TABLE,
|
if (ret > 0 && tmp_table_id != table_id) {
|
||||||
// "[%s:%d] table:<%s>(table_id:%lld) has already been registered, can't register again",
|
log_error(logger, MODULE_TABLE,
|
||||||
// __FUNCTION__, __LINE__, item->valuestring, tmp_table_id);
|
"[%s:%d] table:<%s>(table_id:%lld) has already been registered,"
|
||||||
// return -1;
|
" can't register again", __FUNCTION__, __LINE__, item->valuestring,
|
||||||
// }
|
tmp_table_id);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
maat_kv_register(tablename2id_map, item->valuestring, table_id);
|
maat_kv_register(tablename2id_map, item->valuestring, table_id);
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#define ARRAY_SIZE 10
|
#define ARRAY_SIZE 10
|
||||||
#define WAIT_FOR_EFFECTIVE_S 2
|
#define WAIT_FOR_EFFECTIVE_S 2
|
||||||
#define PERF_THREAD_NUM 5
|
#define PERF_THREAD_NUM 5
|
||||||
|
#define PERF_SCAN_COUNT 1000 * 1000
|
||||||
|
|
||||||
const char *table_info_path = "./table_info.conf";
|
const char *table_info_path = "./table_info.conf";
|
||||||
const char *json_filename = "maat_json.json";
|
const char *json_filename = "maat_json.json";
|
||||||
@@ -475,7 +476,7 @@ TEST_F(MaatPerfStringScan, MultiThread) {
|
|||||||
thread_params[i].maat_instance = maat_instance;
|
thread_params[i].maat_instance = maat_instance;
|
||||||
thread_params[i].thread_id = i;
|
thread_params[i].thread_id = i;
|
||||||
thread_params[i].table_name = table_name;
|
thread_params[i].table_name = table_name;
|
||||||
thread_params[i].test_count = 1 * 1000 * 1000;
|
thread_params[i].test_count = PERF_SCAN_COUNT;
|
||||||
thread_params[i].time_elapse_ms = 0;
|
thread_params[i].time_elapse_ms = 0;
|
||||||
thread_params[i].logger = logger;
|
thread_params[i].logger = logger;
|
||||||
|
|
||||||
@@ -629,7 +630,7 @@ TEST_F(MaatPerfStreamScan, MultiThread) {
|
|||||||
thread_params[i].maat_instance = maat_instance;
|
thread_params[i].maat_instance = maat_instance;
|
||||||
thread_params[i].thread_id = i;
|
thread_params[i].thread_id = i;
|
||||||
thread_params[i].table_name = table_name;
|
thread_params[i].table_name = table_name;
|
||||||
thread_params[i].test_count = 100 * 1000;
|
thread_params[i].test_count = PERF_SCAN_COUNT / 10;
|
||||||
thread_params[i].time_elapse_ms = 0;
|
thread_params[i].time_elapse_ms = 0;
|
||||||
thread_params[i].logger = logger;
|
thread_params[i].logger = logger;
|
||||||
|
|
||||||
@@ -723,7 +724,7 @@ TEST_F(MaatPerfIPScan, MultiThread)
|
|||||||
thread_params[i].maat_instance = maat_instance;
|
thread_params[i].maat_instance = maat_instance;
|
||||||
thread_params[i].thread_id = i;
|
thread_params[i].thread_id = i;
|
||||||
thread_params[i].table_name = table_name;
|
thread_params[i].table_name = table_name;
|
||||||
thread_params[i].test_count = 10 * 1000 * 1000;
|
thread_params[i].test_count = PERF_SCAN_COUNT;
|
||||||
thread_params[i].time_elapse_ms = 0;
|
thread_params[i].time_elapse_ms = 0;
|
||||||
thread_params[i].logger = logger;
|
thread_params[i].logger = logger;
|
||||||
|
|
||||||
@@ -953,7 +954,7 @@ TEST_F(MaatPerfFQDNPluginScan, MultiThread) {
|
|||||||
thread_params[i].maat_instance = maat_instance;
|
thread_params[i].maat_instance = maat_instance;
|
||||||
thread_params[i].thread_id = i;
|
thread_params[i].thread_id = i;
|
||||||
thread_params[i].table_name = table_name;
|
thread_params[i].table_name = table_name;
|
||||||
thread_params[i].test_count = 1 * 1000 * 1000;
|
thread_params[i].test_count = PERF_SCAN_COUNT;
|
||||||
thread_params[i].time_elapse_ms = 0;
|
thread_params[i].time_elapse_ms = 0;
|
||||||
thread_params[i].logger = logger;
|
thread_params[i].logger = logger;
|
||||||
|
|
||||||
@@ -1161,7 +1162,7 @@ TEST_F(MaatPerfBoolPluginScan, MultiThread) {
|
|||||||
thread_params[i].maat_instance = maat_instance;
|
thread_params[i].maat_instance = maat_instance;
|
||||||
thread_params[i].thread_id = i;
|
thread_params[i].thread_id = i;
|
||||||
thread_params[i].table_name = table_name;
|
thread_params[i].table_name = table_name;
|
||||||
thread_params[i].test_count = 1 * 1000 * 1000;
|
thread_params[i].test_count = PERF_SCAN_COUNT;
|
||||||
thread_params[i].time_elapse_ms = 0;
|
thread_params[i].time_elapse_ms = 0;
|
||||||
thread_params[i].logger = logger;
|
thread_params[i].logger = logger;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user