Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2bd441bb
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2bd441bb
编写于
8月 23, 2021
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature/TD-5992' of github.com:taosdata/TDengine into feature/TD-5992
上级
1b69e315
2cf005ca
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
66 addition
and
35 deletion
+66
-35
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+7
-3
src/util/inc/tconfig.h
src/util/inc/tconfig.h
+1
-1
src/util/src/tconfig.c
src/util/src/tconfig.c
+58
-31
未找到文件。
src/client/src/tscSystem.c
浏览文件 @
2bd441bb
...
...
@@ -443,7 +443,7 @@ static int taos_set_config_imp(const char *config){
static
bool
setConfFlag
=
false
;
if
(
setConfFlag
)
{
tscError
(
"already set config"
);
return
-
1
;
return
0
;
}
cJSON
*
root
=
cJSON_Parse
(
config
);
if
(
root
==
NULL
)
{
...
...
@@ -451,18 +451,22 @@ static int taos_set_config_imp(const char *config){
return
-
1
;
}
int
ret
=
0
;
int
size
=
cJSON_GetArraySize
(
root
);
for
(
int
i
=
0
;
i
<
size
;
i
++
){
cJSON
*
item
=
cJSON_GetArrayItem
(
root
,
i
);
if
(
!
item
)
{
tscError
(
"failed to read index:%d"
,
i
);
ret
=
-
2
;
continue
;
}
taosReadConfigOption
(
item
->
string
,
item
->
valuestring
,
NULL
,
NULL
);
if
(
!
taosReadConfigOption
(
item
->
string
,
item
->
valuestring
,
NULL
,
NULL
)){
ret
=
-
2
;
}
}
taosPrintGlobalCfg
();
setConfFlag
=
true
;
return
0
;
return
ret
;
}
int
taos_set_config
(
const
char
*
config
){
...
...
src/util/inc/tconfig.h
浏览文件 @
2bd441bb
...
...
@@ -89,7 +89,7 @@ void taosDumpGlobalCfg();
void
taosInitConfigOption
(
SGlobalCfg
cfg
);
SGlobalCfg
*
taosGetConfigOption
(
const
char
*
option
);
void
taosReadConfigOption
(
const
char
*
option
,
char
*
value
,
char
*
value2
,
char
*
value3
);
bool
taosReadConfigOption
(
const
char
*
option
,
char
*
value
,
char
*
value2
,
char
*
value3
);
#ifdef __cplusplus
}
...
...
src/util/src/tconfig.c
浏览文件 @
2bd441bb
...
...
@@ -26,6 +26,11 @@
SGlobalCfg
tsGlobalConfig
[
TSDB_CFG_MAX_NUM
]
=
{{
0
}};
int32_t
tsGlobalConfigNum
=
0
;
#define ATOI_JUDGE if ( !value && strcmp(input_value, "0") != 0) { \
uError("atoi error, input value:%s",input_value); \
return false; \
}
static
char
*
tsGlobalUnit
[]
=
{
" "
,
"(%)"
,
...
...
@@ -44,12 +49,14 @@ char *tsCfgStatusStr[] = {
"program argument list"
};
static
void
taosReadFloatConfig
(
SGlobalCfg
*
cfg
,
char
*
input_value
)
{
static
bool
taosReadFloatConfig
(
SGlobalCfg
*
cfg
,
char
*
input_value
)
{
float
value
=
(
float
)
atof
(
input_value
);
ATOI_JUDGE
float
*
option
=
(
float
*
)
cfg
->
ptr
;
if
(
value
<
cfg
->
minValue
||
value
>
cfg
->
maxValue
)
{
uError
(
"config option:%s, input value:%s, out of range[%f, %f], use default value:%f"
,
cfg
->
option
,
input_value
,
cfg
->
minValue
,
cfg
->
maxValue
,
*
option
);
return
false
;
}
else
{
if
(
cfg
->
cfgStatus
<=
TAOS_CFG_CSTATUS_FILE
)
{
*
option
=
value
;
...
...
@@ -57,16 +64,20 @@ static void taosReadFloatConfig(SGlobalCfg *cfg, char *input_value) {
}
else
{
uWarn
(
"config option:%s, input value:%s, is configured by %s, use %f"
,
cfg
->
option
,
input_value
,
tsCfgStatusStr
[
cfg
->
cfgStatus
],
*
option
);
return
false
;
}
}
return
true
;
}
static
void
taosReadDoubleConfig
(
SGlobalCfg
*
cfg
,
char
*
input_value
)
{
static
bool
taosReadDoubleConfig
(
SGlobalCfg
*
cfg
,
char
*
input_value
)
{
double
value
=
atof
(
input_value
);
ATOI_JUDGE
double
*
option
=
(
double
*
)
cfg
->
ptr
;
if
(
value
<
cfg
->
minValue
||
value
>
cfg
->
maxValue
)
{
uError
(
"config option:%s, input value:%s, out of range[%f, %f], use default value:%f"
,
cfg
->
option
,
input_value
,
cfg
->
minValue
,
cfg
->
maxValue
,
*
option
);
return
false
;
}
else
{
if
(
cfg
->
cfgStatus
<=
TAOS_CFG_CSTATUS_FILE
)
{
*
option
=
value
;
...
...
@@ -74,17 +85,21 @@ static void taosReadDoubleConfig(SGlobalCfg *cfg, char *input_value) {
}
else
{
uWarn
(
"config option:%s, input value:%s, is configured by %s, use %f"
,
cfg
->
option
,
input_value
,
tsCfgStatusStr
[
cfg
->
cfgStatus
],
*
option
);
return
false
;
}
}
return
true
;
}
static
void
taosReadInt32Config
(
SGlobalCfg
*
cfg
,
char
*
input_value
)
{
static
bool
taosReadInt32Config
(
SGlobalCfg
*
cfg
,
char
*
input_value
)
{
int32_t
value
=
atoi
(
input_value
);
ATOI_JUDGE
int32_t
*
option
=
(
int32_t
*
)
cfg
->
ptr
;
if
(
value
<
cfg
->
minValue
||
value
>
cfg
->
maxValue
)
{
uError
(
"config option:%s, input value:%s, out of range[%f, %f], use default value:%d"
,
cfg
->
option
,
input_value
,
cfg
->
minValue
,
cfg
->
maxValue
,
*
option
);
return
false
;
}
else
{
if
(
cfg
->
cfgStatus
<=
TAOS_CFG_CSTATUS_FILE
)
{
*
option
=
value
;
...
...
@@ -92,16 +107,20 @@ static void taosReadInt32Config(SGlobalCfg *cfg, char *input_value) {
}
else
{
uWarn
(
"config option:%s, input value:%s, is configured by %s, use %d"
,
cfg
->
option
,
input_value
,
tsCfgStatusStr
[
cfg
->
cfgStatus
],
*
option
);
return
false
;
}
}
return
true
;
}
static
void
taosReadInt16Config
(
SGlobalCfg
*
cfg
,
char
*
input_value
)
{
static
bool
taosReadInt16Config
(
SGlobalCfg
*
cfg
,
char
*
input_value
)
{
int32_t
value
=
atoi
(
input_value
);
ATOI_JUDGE
int16_t
*
option
=
(
int16_t
*
)
cfg
->
ptr
;
if
(
value
<
cfg
->
minValue
||
value
>
cfg
->
maxValue
)
{
uError
(
"config option:%s, input value:%s, out of range[%f, %f], use default value:%d"
,
cfg
->
option
,
input_value
,
cfg
->
minValue
,
cfg
->
maxValue
,
*
option
);
return
false
;
}
else
{
if
(
cfg
->
cfgStatus
<=
TAOS_CFG_CSTATUS_FILE
)
{
*
option
=
(
int16_t
)
value
;
...
...
@@ -109,16 +128,20 @@ static void taosReadInt16Config(SGlobalCfg *cfg, char *input_value) {
}
else
{
uWarn
(
"config option:%s, input value:%s, is configured by %s, use %d"
,
cfg
->
option
,
input_value
,
tsCfgStatusStr
[
cfg
->
cfgStatus
],
*
option
);
return
false
;
}
}
return
true
;
}
static
void
taosReadUInt16Config
(
SGlobalCfg
*
cfg
,
char
*
input_value
)
{
static
bool
taosReadUInt16Config
(
SGlobalCfg
*
cfg
,
char
*
input_value
)
{
int32_t
value
=
atoi
(
input_value
);
ATOI_JUDGE
uint16_t
*
option
=
(
uint16_t
*
)
cfg
->
ptr
;
if
(
value
<
cfg
->
minValue
||
value
>
cfg
->
maxValue
)
{
uError
(
"config option:%s, input value:%s, out of range[%f, %f], use default value:%d"
,
cfg
->
option
,
input_value
,
cfg
->
minValue
,
cfg
->
maxValue
,
*
option
);
return
false
;
}
else
{
if
(
cfg
->
cfgStatus
<=
TAOS_CFG_CSTATUS_FILE
)
{
*
option
=
(
uint16_t
)
value
;
...
...
@@ -126,16 +149,20 @@ static void taosReadUInt16Config(SGlobalCfg *cfg, char *input_value) {
}
else
{
uWarn
(
"config option:%s, input value:%s, is configured by %s, use %d"
,
cfg
->
option
,
input_value
,
tsCfgStatusStr
[
cfg
->
cfgStatus
],
*
option
);
return
false
;
}
}
return
true
;
}
static
void
taosReadInt8Config
(
SGlobalCfg
*
cfg
,
char
*
input_value
)
{
static
bool
taosReadInt8Config
(
SGlobalCfg
*
cfg
,
char
*
input_value
)
{
int32_t
value
=
atoi
(
input_value
);
ATOI_JUDGE
int8_t
*
option
=
(
int8_t
*
)
cfg
->
ptr
;
if
(
value
<
cfg
->
minValue
||
value
>
cfg
->
maxValue
)
{
uError
(
"config option:%s, input value:%s, out of range[%f, %f], use default value:%d"
,
cfg
->
option
,
input_value
,
cfg
->
minValue
,
cfg
->
maxValue
,
*
option
);
return
false
;
}
else
{
if
(
cfg
->
cfgStatus
<=
TAOS_CFG_CSTATUS_FILE
)
{
*
option
=
(
int8_t
)
value
;
...
...
@@ -143,8 +170,10 @@ static void taosReadInt8Config(SGlobalCfg *cfg, char *input_value) {
}
else
{
uWarn
(
"config option:%s, input value:%s, is configured by %s, use %d"
,
cfg
->
option
,
input_value
,
tsCfgStatusStr
[
cfg
->
cfgStatus
],
*
option
);
return
false
;
}
}
return
true
;
}
static
bool
taosReadDirectoryConfig
(
SGlobalCfg
*
cfg
,
char
*
input_value
)
{
...
...
@@ -191,12 +220,13 @@ static bool taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) {
return
true
;
}
static
void
taosReadIpStrConfig
(
SGlobalCfg
*
cfg
,
char
*
input_value
)
{
static
bool
taosReadIpStrConfig
(
SGlobalCfg
*
cfg
,
char
*
input_value
)
{
uint32_t
value
=
taosInetAddr
(
input_value
);
char
*
option
=
(
char
*
)
cfg
->
ptr
;
if
(
value
==
INADDR_NONE
)
{
uError
(
"config option:%s, input value:%s, is not a valid ip address, use default value:%s"
,
cfg
->
option
,
input_value
,
option
);
return
false
;
}
else
{
if
(
cfg
->
cfgStatus
<=
TAOS_CFG_CSTATUS_FILE
)
{
strncpy
(
option
,
input_value
,
cfg
->
ptrLength
);
...
...
@@ -204,16 +234,19 @@ static void taosReadIpStrConfig(SGlobalCfg *cfg, char *input_value) {
}
else
{
uWarn
(
"config option:%s, input value:%s, is configured by %s, use %s"
,
cfg
->
option
,
input_value
,
tsCfgStatusStr
[
cfg
->
cfgStatus
],
option
);
return
false
;
}
}
return
true
;
}
static
void
taosReadStringConfig
(
SGlobalCfg
*
cfg
,
char
*
input_value
)
{
static
bool
taosReadStringConfig
(
SGlobalCfg
*
cfg
,
char
*
input_value
)
{
int
length
=
(
int
)
strlen
(
input_value
);
char
*
option
=
(
char
*
)
cfg
->
ptr
;
if
(
length
<=
0
||
length
>
cfg
->
ptrLength
)
{
uError
(
"config option:%s, input value:%s, length out of range[0, %d], use default value:%s"
,
cfg
->
option
,
input_value
,
cfg
->
ptrLength
,
option
);
return
false
;
}
else
{
if
(
cfg
->
cfgStatus
<=
TAOS_CFG_CSTATUS_FILE
)
{
strncpy
(
option
,
input_value
,
cfg
->
ptrLength
);
...
...
@@ -221,8 +254,10 @@ static void taosReadStringConfig(SGlobalCfg *cfg, char *input_value) {
}
else
{
uWarn
(
"config option:%s, input value:%s, is configured by %s, use %s"
,
cfg
->
option
,
input_value
,
tsCfgStatusStr
[
cfg
->
cfgStatus
],
option
);
return
false
;
}
}
return
true
;
}
static
void
taosReadLogOption
(
char
*
option
,
char
*
value
)
{
...
...
@@ -258,7 +293,7 @@ SGlobalCfg *taosGetConfigOption(const char *option) {
return
NULL
;
}
void
taosReadConfigOption
(
const
char
*
option
,
char
*
value
,
char
*
value2
,
char
*
value3
)
{
bool
taosReadConfigOption
(
const
char
*
option
,
char
*
value
,
char
*
value2
,
char
*
value3
)
{
for
(
int
i
=
0
;
i
<
tsGlobalConfigNum
;
++
i
)
{
SGlobalCfg
*
cfg
=
tsGlobalConfig
+
i
;
if
(
!
(
cfg
->
cfgType
&
TSDB_CFG_CTYPE_B_CONFIG
))
continue
;
...
...
@@ -266,43 +301,35 @@ void taosReadConfigOption(const char *option, char *value, char *value2, char *v
switch
(
cfg
->
valType
)
{
case
TAOS_CFG_VTYPE_INT8
:
taosReadInt8Config
(
cfg
,
value
);
break
;
return
taosReadInt8Config
(
cfg
,
value
);
case
TAOS_CFG_VTYPE_INT16
:
taosReadInt16Config
(
cfg
,
value
);
break
;
return
taosReadInt16Config
(
cfg
,
value
);
case
TAOS_CFG_VTYPE_INT32
:
taosReadInt32Config
(
cfg
,
value
);
break
;
return
taosReadInt32Config
(
cfg
,
value
);
case
TAOS_CFG_VTYPE_UINT16
:
taosReadUInt16Config
(
cfg
,
value
);
break
;
return
taosReadUInt16Config
(
cfg
,
value
);
case
TAOS_CFG_VTYPE_FLOAT
:
taosReadFloatConfig
(
cfg
,
value
);
break
;
return
taosReadFloatConfig
(
cfg
,
value
);
case
TAOS_CFG_VTYPE_DOUBLE
:
taosReadDoubleConfig
(
cfg
,
value
);
break
;
return
taosReadDoubleConfig
(
cfg
,
value
);
case
TAOS_CFG_VTYPE_STRING
:
taosReadStringConfig
(
cfg
,
value
);
break
;
return
taosReadStringConfig
(
cfg
,
value
);
case
TAOS_CFG_VTYPE_IPSTR
:
taosReadIpStrConfig
(
cfg
,
value
);
break
;
return
taosReadIpStrConfig
(
cfg
,
value
);
case
TAOS_CFG_VTYPE_DIRECTORY
:
taosReadDirectoryConfig
(
cfg
,
value
);
break
;
return
taosReadDirectoryConfig
(
cfg
,
value
);
case
TAOS_CFG_VTYPE_DATA_DIRCTORY
:
if
(
taosReadDirectoryConfig
(
cfg
,
value
))
{
taosReadDataDirCfg
(
value
,
value2
,
value3
);
taosReadDataDirCfg
(
value
,
value2
,
value3
);
return
true
;
}
break
;
return
false
;
default:
uError
(
"config option:%s, input value:%s, can't be recognized"
,
option
,
value
);
break
;
return
false
;
}
break
;
}
return
false
;
}
void
taosInitConfigOption
(
SGlobalCfg
cfg
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录