Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
13ea775c
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
13ea775c
编写于
9月 10, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-5992}<fix>:optimize
上级
6028c919
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
13 deletion
+35
-13
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+15
-11
src/client/tests/setConfigTest.cpp
src/client/tests/setConfigTest.cpp
+7
-0
src/inc/taos.h
src/inc/taos.h
+13
-2
未找到文件。
src/client/src/tscSystem.c
浏览文件 @
13ea775c
...
@@ -440,30 +440,30 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
...
@@ -440,30 +440,30 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
#include "cJSON.h"
#include "cJSON.h"
static
setConfRet
taos_set_config_imp
(
const
char
*
config
){
static
setConfRet
taos_set_config_imp
(
const
char
*
config
){
setConfRet
ret
;
setConfRet
ret
=
{
SET_CONF_RET_SUCC
,
{
0
}}
;
static
bool
setConfFlag
=
false
;
static
bool
setConfFlag
=
false
;
if
(
setConfFlag
)
{
if
(
setConfFlag
)
{
ret
.
retCode
=
-
5
;
ret
.
retCode
=
SET_CONF_RET_ERR_ONLY_ONCE
;
strcpy
(
ret
.
retMsg
,
"configuration can only set once"
);
strcpy
(
ret
.
retMsg
,
"configuration can only set once"
);
return
ret
;
return
ret
;
}
}
taosInitGlobalCfg
();
taosInitGlobalCfg
();
cJSON
*
root
=
cJSON_Parse
(
config
);
cJSON
*
root
=
cJSON_Parse
(
config
);
if
(
root
==
NULL
){
if
(
root
==
NULL
){
ret
.
retCode
=
-
4
;
ret
.
retCode
=
SET_CONF_RET_ERR_JSON_PARSE
;
strcpy
(
ret
.
retMsg
,
"parse json error"
);
strcpy
(
ret
.
retMsg
,
"parse json error"
);
return
ret
;
return
ret
;
}
}
int
size
=
cJSON_GetArraySize
(
root
);
int
size
=
cJSON_GetArraySize
(
root
);
if
(
!
cJSON_IsObject
(
root
)
||
size
==
0
)
{
if
(
!
cJSON_IsObject
(
root
)
||
size
==
0
)
{
ret
.
retCode
=
-
3
;
ret
.
retCode
=
SET_CONF_RET_ERR_JSON_INVALID
;
strcpy
(
ret
.
retMsg
,
"json content is invalid, must be not empty object"
);
strcpy
(
ret
.
retMsg
,
"json content is invalid, must be not empty object"
);
return
ret
;
return
ret
;
}
}
if
(
size
>=
1000
)
{
if
(
size
>=
1000
)
{
ret
.
retCode
=
-
6
;
ret
.
retCode
=
SET_CONF_RET_ERR_TOO_LONG
;
strcpy
(
ret
.
retMsg
,
"json object size is too long"
);
strcpy
(
ret
.
retMsg
,
"json object size is too long"
);
return
ret
;
return
ret
;
}
}
...
@@ -471,21 +471,25 @@ static setConfRet taos_set_config_imp(const char *config){
...
@@ -471,21 +471,25 @@ static setConfRet 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
)
{
ret
.
retCode
=
-
2
;
ret
.
retCode
=
SET_CONF_RET_ERR_INNER
;
strcpy
(
ret
.
retMsg
,
"inner error"
);
strcpy
(
ret
.
retMsg
,
"inner error"
);
return
ret
;
return
ret
;
}
}
if
(
!
taosReadConfigOption
(
item
->
string
,
item
->
valuestring
,
NULL
,
NULL
,
TAOS_CFG_CSTATUS_OPTION
,
TSDB_CFG_CTYPE_B_CLIENT
)){
if
(
!
taosReadConfigOption
(
item
->
string
,
item
->
valuestring
,
NULL
,
NULL
,
TAOS_CFG_CSTATUS_OPTION
,
TSDB_CFG_CTYPE_B_CLIENT
)){
ret
.
retCode
=
-
1
;
ret
.
retCode
=
SET_CONF_RET_ERR_PART
;
if
(
strlen
(
ret
.
retMsg
)
==
0
){
if
(
strlen
(
ret
.
retMsg
)
==
0
){
snprintf
(
ret
.
retMsg
,
1024
,
"part error|%s"
,
item
->
string
);
snprintf
(
ret
.
retMsg
,
RET_MSG_LENGTH
-
1
,
"part error|%s"
,
item
->
string
);
}
else
{
}
else
{
char
tmp
[
1000
]
=
{
0
};
int
leftSize
=
RET_MSG_LENGTH
-
1
-
strlen
(
ret
.
retMsg
);
strncpy
(
tmp
,
ret
.
retMsg
,
1000
);
leftSize
=
leftSize
>=
0
?
leftSize
:
0
;
snprintf
(
ret
.
retMsg
,
1024
,
"%s|%s"
,
tmp
,
item
->
string
);
strncat
(
ret
.
retMsg
,
"|"
,
leftSize
);
leftSize
=
RET_MSG_LENGTH
-
1
-
strlen
(
ret
.
retMsg
);
leftSize
=
leftSize
>=
0
?
leftSize
:
0
;
strncat
(
ret
.
retMsg
,
item
->
string
,
leftSize
);
}
}
}
}
}
}
cJSON_Delete
(
root
);
setConfFlag
=
true
;
setConfFlag
=
true
;
return
ret
;
return
ret
;
}
}
...
...
src/client/tests/setConfigTest.cpp
浏览文件 @
13ea775c
...
@@ -62,3 +62,10 @@ TEST(testCase, set_config_test5) {
...
@@ -62,3 +62,10 @@ TEST(testCase, set_config_test5) {
ASSERT_EQ
(
ret
.
retCode
,
-
3
);
ASSERT_EQ
(
ret
.
retCode
,
-
3
);
printf
(
"msg:%d->%s"
,
ret
.
retCode
,
ret
.
retMsg
);
printf
(
"msg:%d->%s"
,
ret
.
retCode
,
ret
.
retMsg
);
}
}
TEST
(
testCase
,
set_config_test6
)
{
const
char
*
config
=
"{
\"
numOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitThreadsnumOfCoitT3333dd
\"
:
\"
10
\"
,
\"
esdfa
\"
:
\"
10
\"
}"
;
setConfRet
ret
=
taos_set_config
(
config
);
ASSERT_EQ
(
ret
.
retCode
,
-
1
);
printf
(
"msg:%d->%s"
,
ret
.
retCode
,
ret
.
retMsg
);
}
src/inc/taos.h
浏览文件 @
13ea775c
...
@@ -62,9 +62,20 @@ typedef struct taosField {
...
@@ -62,9 +62,20 @@ typedef struct taosField {
int16_t
bytes
;
int16_t
bytes
;
}
TAOS_FIELD
;
}
TAOS_FIELD
;
typedef
enum
{
SET_CONF_RET_SUCC
=
0
,
SET_CONF_RET_ERR_PART
=
-
1
,
SET_CONF_RET_ERR_INNER
=
-
2
,
SET_CONF_RET_ERR_JSON_INVALID
=
-
3
,
SET_CONF_RET_ERR_JSON_PARSE
=
-
4
,
SET_CONF_RET_ERR_ONLY_ONCE
=
-
5
,
SET_CONF_RET_ERR_TOO_LONG
=
-
6
}
SET_CONF_RET_CODE
;
#define RET_MSG_LENGTH 1024
typedef
struct
setConfRet
{
typedef
struct
setConfRet
{
char
retMsg
[
1024
]
;
SET_CONF_RET_CODE
retCode
;
int8_t
retCode
;
char
retMsg
[
RET_MSG_LENGTH
]
;
}
setConfRet
;
}
setConfRet
;
#ifdef _TD_GO_DLL_
#ifdef _TD_GO_DLL_
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录