提交 65b358d4 编写于 作者: Z zyyang

Merge branch 'feature/TD-5992' of github.com:taosdata/TDengine into feature/TD-5992

......@@ -18,9 +18,9 @@ IF (TD_LINUX)
# generate dynamic library (*.so)
ADD_LIBRARY(taos SHARED ${SRC})
TARGET_LINK_LIBRARIES(taos common query trpc tutil pthread m rt)
TARGET_LINK_LIBRARIES(taos common query trpc cJson tutil pthread m rt)
IF (TD_LINUX_64)
TARGET_LINK_LIBRARIES(taos lua)
TARGET_LINK_LIBRARIES(taos lua cJson)
ENDIF ()
SET_TARGET_PROPERTIES(taos PROPERTIES CLEAN_DIRECT_OUTPUT 1)
......@@ -39,13 +39,13 @@ ELSEIF (TD_DARWIN)
# set the static lib name
ADD_LIBRARY(taos_static STATIC ${SRC})
TARGET_LINK_LIBRARIES(taos_static common query trpc tutil pthread m lua cJson)
TARGET_LINK_LIBRARIES(taos_static common query trpc cJson tutil pthread m lua cJson)
SET_TARGET_PROPERTIES(taos_static PROPERTIES OUTPUT_NAME "taos_static")
SET_TARGET_PROPERTIES(taos_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
# generate dynamic library (*.dylib)
ADD_LIBRARY(taos SHARED ${SRC})
TARGET_LINK_LIBRARIES(taos common query trpc tutil pthread m lua)
TARGET_LINK_LIBRARIES(taos common query cJson trpc tutil pthread m lua)
SET_TARGET_PROPERTIES(taos PROPERTIES CLEAN_DIRECT_OUTPUT 1)
#set version of .dylib
......@@ -64,14 +64,14 @@ ELSEIF (TD_WINDOWS)
CONFIGURE_FILE("${TD_COMMUNITY_DIR}/src/client/src/taos.rc.in" "${TD_COMMUNITY_DIR}/src/client/src/taos.rc")
ADD_LIBRARY(taos_static STATIC ${SRC})
TARGET_LINK_LIBRARIES(taos_static trpc tutil cJson query)
TARGET_LINK_LIBRARIES(taos_static trpc cJson tutil cJson query)
# generate dynamic library (*.dll)
ADD_LIBRARY(taos SHARED ${SRC} ${TD_COMMUNITY_DIR}/src/client/src/taos.rc)
IF (NOT TD_GODLL)
SET_TARGET_PROPERTIES(taos PROPERTIES LINK_FLAGS /DEF:${TD_COMMUNITY_DIR}/src/client/src/taos.def)
ENDIF ()
TARGET_LINK_LIBRARIES(taos trpc tutil query lua)
TARGET_LINK_LIBRARIES(taos trpc cJson tutil query lua)
ELSEIF (TD_DARWIN)
SET(CMAKE_MACOSX_RPATH 1)
......@@ -79,12 +79,12 @@ ELSEIF (TD_DARWIN)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc)
ADD_LIBRARY(taos_static STATIC ${SRC})
TARGET_LINK_LIBRARIES(taos_static query trpc tutil pthread cJson m lua)
TARGET_LINK_LIBRARIES(taos_static query trpc cJson tutil pthread cJson m lua)
SET_TARGET_PROPERTIES(taos_static PROPERTIES OUTPUT_NAME "taos_static")
# generate dynamic library (*.dylib)
ADD_LIBRARY(taos SHARED ${SRC})
TARGET_LINK_LIBRARIES(taos query trpc tutil pthread m lua)
TARGET_LINK_LIBRARIES(taos query trpc cJson tutil pthread m lua)
SET_TARGET_PROPERTIES(taos PROPERTIES CLEAN_DIRECT_OUTPUT 1)
......
......@@ -442,12 +442,13 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
static int taos_set_config_imp(const char *config){
static bool setConfFlag = false;
if (setConfFlag) {
tscError("already set config");
printf("already set config");
return 0;
}
taosInitGlobalCfg();
cJSON *root = cJSON_Parse(config);
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;
}
......@@ -456,30 +457,25 @@ static int taos_set_config_imp(const char *config){
for(int i = 0; i < size; i++){
cJSON *item = cJSON_GetArrayItem(root, i);
if (!item) {
tscError("failed to read index:%d", i);
printf("failed to read index:%d", i);
ret = -2;
continue;
}
if(!taosReadConfigOption(item->string, item->valuestring, NULL, NULL)){
if(!taosReadConfigOption(item->string, item->valuestring, NULL, NULL, TAOS_CFG_CSTATUS_OPTION)){
printf("set failed:%s->%s", item->string, item->valuestring);
ret = -2;
}
}
taosPrintGlobalCfg();
setConfFlag = true;
return ret;
}
int taos_set_config(const char *config){
if(taos_init()){
tscError("failed to call taos_init");
return -1;
}
static int32_t lock = 0;
for (int i = 1; atomic_val_compare_exchange_32(&lock, 0, 1) != 0; ++i) {
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();
}
}
......
......@@ -89,7 +89,7 @@ void taosDumpGlobalCfg();
void taosInitConfigOption(SGlobalCfg cfg);
SGlobalCfg * taosGetConfigOption(const char *option);
bool taosReadConfigOption(const char *option, char *value, char *value2, char *value3);
bool taosReadConfigOption(const char *option, char *value, char *value2, char *value3, int8_t cfgStatus);
#ifdef __cplusplus
}
......
......@@ -293,7 +293,9 @@ SGlobalCfg *taosGetConfigOption(const char *option) {
return NULL;
}
bool taosReadConfigOption(const char *option, char *value, char *value2, char *value3) {
bool taosReadConfigOption(const char *option, char *value, char *value2, char *value3,
int8_t cfgStatus) {
bool ret = false;
for (int i = 0; i < tsGlobalConfigNum; ++i) {
SGlobalCfg *cfg = tsGlobalConfig + i;
if (!(cfg->cfgType & TSDB_CFG_CTYPE_B_CONFIG)) continue;
......@@ -301,35 +303,48 @@ bool taosReadConfigOption(const char *option, char *value, char *value2, char *v
switch (cfg->valType) {
case TAOS_CFG_VTYPE_INT8:
return taosReadInt8Config(cfg, value);
ret = taosReadInt8Config(cfg, value);
break;
case TAOS_CFG_VTYPE_INT16:
return taosReadInt16Config(cfg, value);
ret = taosReadInt16Config(cfg, value);
break;
case TAOS_CFG_VTYPE_INT32:
return taosReadInt32Config(cfg, value);
ret = taosReadInt32Config(cfg, value);
break;
case TAOS_CFG_VTYPE_UINT16:
return taosReadUInt16Config(cfg, value);
ret = taosReadUInt16Config(cfg, value);
break;
case TAOS_CFG_VTYPE_FLOAT:
return taosReadFloatConfig(cfg, value);
ret = taosReadFloatConfig(cfg, value);
break;
case TAOS_CFG_VTYPE_DOUBLE:
return taosReadDoubleConfig(cfg, value);
ret = taosReadDoubleConfig(cfg, value);
break;
case TAOS_CFG_VTYPE_STRING:
return taosReadStringConfig(cfg, value);
ret = taosReadStringConfig(cfg, value);
break;
case TAOS_CFG_VTYPE_IPSTR:
return taosReadIpStrConfig(cfg, value);
ret = taosReadIpStrConfig(cfg, value);
break;
case TAOS_CFG_VTYPE_DIRECTORY:
return taosReadDirectoryConfig(cfg, value);
ret = taosReadDirectoryConfig(cfg, value);
break;
case TAOS_CFG_VTYPE_DATA_DIRCTORY:
if (taosReadDirectoryConfig(cfg, value)) {
taosReadDataDirCfg(value, value2, value3);
return true;
ret = true;
}
return false;
ret = false;
break;
default:
uError("config option:%s, input value:%s, can't be recognized", option, value);
return false;
ret = false;
}
if(ret && cfgStatus == TAOS_CFG_CSTATUS_OPTION){
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
}
}
return false;
return ret;
}
void taosInitConfigOption(SGlobalCfg cfg) {
......@@ -464,7 +479,7 @@ bool taosReadGlobalCfg() {
if (vlen3 != 0) value3[vlen3] = 0;
}
taosReadConfigOption(option, value, value2, value3);
taosReadConfigOption(option, value, value2, value3, TAOS_CFG_CSTATUS_FILE);
}
fclose(fp);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册