提交 a133bfbe 编写于 作者: wmmhello's avatar wmmhello

[TD-5992] make config take effect

上级 ad767f6d
...@@ -442,13 +442,13 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) { ...@@ -442,13 +442,13 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
static int taos_set_config_imp(const char *config){ static int taos_set_config_imp(const char *config){
static bool setConfFlag = false; static bool setConfFlag = false;
if (setConfFlag) { if (setConfFlag) {
tscError("already set config"); printf("already set config");
return 0; return 0;
} }
taosInitGlobalCfg(); taosInitGlobalCfg();
cJSON *root = cJSON_Parse(config); cJSON *root = cJSON_Parse(config);
if (root == NULL) { if (root == NULL) {
tscError("failed to set config, invalid json format: %s", config); printf("failed to set config, invalid json format: %s", config);
return -1; return -1;
} }
...@@ -457,11 +457,12 @@ static int taos_set_config_imp(const char *config){ ...@@ -457,11 +457,12 @@ static int taos_set_config_imp(const char *config){
for(int i = 0; i < size; i++){ for(int i = 0; i < size; i++){
cJSON *item = cJSON_GetArrayItem(root, i); cJSON *item = cJSON_GetArrayItem(root, i);
if (!item) { if (!item) {
tscError("failed to read index:%d", i); printf("failed to read index:%d", i);
ret = -2; ret = -2;
continue; continue;
} }
if(!taosReadConfigOption(item->string, item->valuestring, NULL, NULL, TAOS_CFG_CSTATUS_OPTION)){ if(!taosReadConfigOption(item->string, item->valuestring, NULL, NULL, TAOS_CFG_CSTATUS_OPTION)){
printf("set failed:%s->%s", item->string, item->valuestring);
ret = -2; ret = -2;
} }
} }
...@@ -474,7 +475,7 @@ int taos_set_config(const char *config){ ...@@ -474,7 +475,7 @@ int taos_set_config(const char *config){
for (int i = 1; atomic_val_compare_exchange_32(&lock, 0, 1) != 0; ++i) { for (int i = 1; atomic_val_compare_exchange_32(&lock, 0, 1) != 0; ++i) {
if (i % 1000 == 0) { if (i % 1000 == 0) {
tscInfo("haven't acquire lock after spin %d times.", i); printf("haven't acquire lock after spin %d times.", i);
sched_yield(); sched_yield();
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册