summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/entry/Maat_api.cpp11
-rw-r--r--src/entry/Maat_rule.cpp2
-rw-r--r--src/inc_internal/Maat_rule_internal.h2
-rw-r--r--test/test_maatframe.cpp13
4 files changed, 17 insertions, 11 deletions
diff --git a/src/entry/Maat_api.cpp b/src/entry/Maat_api.cpp
index 587a228..a797fc5 100644
--- a/src/entry/Maat_api.cpp
+++ b/src/entry/Maat_api.cpp
@@ -536,7 +536,10 @@ int load_maat_json_file(_Maat_feather_t* feather, const char* maat_json_fn, char
{
return -1;
}
- strncpy(feather->json_ctx.json_file, maat_json_fn, sizeof(feather->json_ctx.json_file));
+ if(!feather->is_running)
+ {
+ strncpy(feather->json_ctx.json_file, maat_json_fn, sizeof(feather->json_ctx.json_file));
+ }
ret=stat(maat_json_fn, &fstat_buf);
feather->json_ctx.last_md5_time=fstat_buf.st_ctim;
@@ -638,7 +641,7 @@ int Maat_set_feather_opt(Maat_feather_t feather,enum MAAT_INIT_OPT type,const vo
default:
break;
}
- if(_feather->still_working==1)//The following options are not allowed to set after initiation;
+ if(_feather->is_running==1)//The following options are not allowed to set after initiation;
{
return -2;
}
@@ -887,7 +890,7 @@ void maat_read_full_config(_Maat_feather_t* _feather)
}
_feather->scanner=_feather->update_tmp_scanner;
_feather->update_tmp_scanner=NULL;
- _feather->still_working=1;
+ _feather->is_running=1;
if(_feather->scanner!=NULL)
{
_feather->maat_version=_feather->scanner->version;
@@ -1009,7 +1012,7 @@ error_out:
void Maat_burn_feather(Maat_feather_t feather)
{
struct _Maat_feather_t* _feather=(_Maat_feather_t*)feather;
- _feather->still_working=0;//destroy will proceed in thread_rule_monitor
+ _feather->is_running=0;//destroy will proceed in thread_rule_monitor
void* ret=NULL;
pthread_join(_feather->cfg_mon_t, &ret);
return;
diff --git a/src/entry/Maat_rule.cpp b/src/entry/Maat_rule.cpp
index f0879f1..fc36607 100644
--- a/src/entry/Maat_rule.cpp
+++ b/src/entry/Maat_rule.cpp
@@ -2599,7 +2599,7 @@ void *thread_rule_monitor(void *arg)
maat_read_full_config(feather);
}
pthread_mutex_unlock(&(feather->background_update_mutex));
- while(feather->still_working)
+ while(feather->is_running)
{
usleep(feather->rule_update_checking_interval_ms*1000);
scan_dir_cnt++;
diff --git a/src/inc_internal/Maat_rule_internal.h b/src/inc_internal/Maat_rule_internal.h
index 839165c..72a1597 100644
--- a/src/inc_internal/Maat_rule_internal.h
+++ b/src/inc_internal/Maat_rule_internal.h
@@ -290,7 +290,7 @@ struct _Maat_feather_t
struct source_json_ctx json_ctx;
struct source_redis_ctx mr_ctx;
};
- int still_working;
+ int is_running;
int rule_update_checking_interval_ms;
int rule_effect_interval_ms;
int garbage_collection_timeout_ms;
diff --git a/test/test_maatframe.cpp b/test/test_maatframe.cpp
index 31f06d7..b6f8fac 100644
--- a/test/test_maatframe.cpp
+++ b/test/test_maatframe.cpp
@@ -2302,6 +2302,13 @@ protected:
const char* foregin_dir="./foreign_files/";
Maat_set_feather_opt(_shared_feather, MAAT_OPT_FOREIGN_CONT_DIR,foregin_dir, strlen(foregin_dir)+1);
+ const char* stat_file="./maat_cmd_test.fs2";
+ Maat_set_feather_opt(_shared_feather, MAAT_OPT_STAT_FILE_PATH, stat_file, strlen(stat_file)+1);
+ Maat_set_feather_opt(_shared_feather, MAAT_OPT_STAT_ON, NULL, 0);
+ Maat_set_feather_opt(_shared_feather, MAAT_OPT_PERF_ON, NULL, 0);
+ //Set a short intevral for testing.
+ int tmp=0;
+ Maat_set_feather_opt(_shared_feather, MAAT_OPT_GARBAGE_COLLECTION_TIMEOUT_MS, &tmp, sizeof(tmp));
Maat_cmd_flushDB(_shared_feather);
Maat_initiate_feather(_shared_feather);
@@ -4485,7 +4492,7 @@ int main(int argc, char ** argv)
{
const char* log_file="./test.log";
- const char* stat_file="./scan_staus.log";
+ const char* stat_file="./maat_stat.fs2";
const char* decrypt_key="mesa2017wy";
const char* accept_tags="{\"tags\":[{\"tag\":\"location\",\"value\":\"北京/朝阳/华严北里/甲22号\"},{\"tag\":\"isp\",\"value\":\"移动\"},{\"tag\":\"location\",\"value\":\"Astana\"}]}";
// const char* subsitute_acc_tags="{\"tags\":[{\"tag\":\"location\",\"value\":\"Astana\"}]}";
@@ -4503,10 +4510,6 @@ int main(int argc, char ** argv)
//Set a short intevral for testing.
Maat_set_feather_opt(g_feather, MAAT_OPT_EFFECT_INVERVAL_MS, &effective_interval_ms, sizeof(effective_interval_ms));
- //Set a short intevral for testing.
- int tmp=0;
- Maat_set_feather_opt(g_feather, MAAT_OPT_GARBAGE_COLLECTION_TIMEOUT_MS, &tmp, sizeof(tmp));
-
Maat_set_feather_opt(g_feather, MAAT_OPT_STAT_FILE_PATH, stat_file, strlen(stat_file)+1);
Maat_set_feather_opt(g_feather, MAAT_OPT_STAT_ON, NULL, 0);