Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Cherenkov effect
TDengine
提交
adbf4c22
T
TDengine
项目概览
Cherenkov effect
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
adbf4c22
编写于
11月 13, 2019
作者:
S
slguan
提交者:
GitHub
11月 13, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #713 from taosdata/feature/tbase-306
TBASE-306
上级
4decb7b8
21427af3
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
60 addition
and
46 deletion
+60
-46
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+51
-40
src/inc/tglobalcfg.h
src/inc/tglobalcfg.h
+1
-1
src/util/src/tglobalcfg.c
src/util/src/tglobalcfg.c
+8
-5
未找到文件。
src/client/src/tscSystem.c
浏览文件 @
adbf4c22
...
@@ -182,51 +182,45 @@ void taos_init_imp() {
...
@@ -182,51 +182,45 @@ void taos_init_imp() {
void
taos_init
()
{
pthread_once
(
&
tscinit
,
taos_init_imp
);
}
void
taos_init
()
{
pthread_once
(
&
tscinit
,
taos_init_imp
);
}
int
taos_options
(
TSDB_OPTION
option
,
const
void
*
arg
,
...)
{
static
int
taos_options_imp
(
TSDB_OPTION
option
,
const
char
*
pStr
)
{
char
*
pStr
=
NULL
;
SGlobalConfig
*
cfg
=
NULL
;
SGlobalConfig
*
cfg_configDir
=
tsGetConfigOption
(
"configDir"
);
SGlobalConfig
*
cfg_activetimer
=
tsGetConfigOption
(
"shellActivityTimer"
);
SGlobalConfig
*
cfg_locale
=
tsGetConfigOption
(
"locale"
);
SGlobalConfig
*
cfg_charset
=
tsGetConfigOption
(
"charset"
);
SGlobalConfig
*
cfg_timezone
=
tsGetConfigOption
(
"timezone"
);
SGlobalConfig
*
cfg_socket
=
tsGetConfigOption
(
"sockettype"
);
switch
(
option
)
{
switch
(
option
)
{
case
TSDB_OPTION_CONFIGDIR
:
case
TSDB_OPTION_CONFIGDIR
:
pStr
=
(
char
*
)
arg
;
cfg
=
tsGetConfigOption
(
"configDir"
)
;
if
(
cfg
_configDir
&&
cfg_configDir
->
cfgStatus
<=
TSDB_CFG_CSTATUS_OPTION
)
{
if
(
cfg
&&
cfg
->
cfgStatus
<=
TSDB_CFG_CSTATUS_OPTION
)
{
strncpy
(
configDir
,
pStr
,
TSDB_FILENAME_LEN
);
strncpy
(
configDir
,
pStr
,
TSDB_FILENAME_LEN
);
cfg
_configDir
->
cfgStatus
=
TSDB_CFG_CSTATUS_OPTION
;
cfg
->
cfgStatus
=
TSDB_CFG_CSTATUS_OPTION
;
tscPrint
(
"set config file directory:%s"
,
pStr
);
tscPrint
(
"set config file directory:%s"
,
pStr
);
}
else
{
}
else
{
tscWarn
(
"config option:%s, input value:%s, is configured by %s, use %s"
,
cfg
_configDir
->
option
,
pStr
,
tscWarn
(
"config option:%s, input value:%s, is configured by %s, use %s"
,
cfg
->
option
,
pStr
,
tsCfgStatusStr
[
cfg
_configDir
->
cfgStatus
],
(
char
*
)
cfg_configDir
->
ptr
);
tsCfgStatusStr
[
cfg
->
cfgStatus
],
(
char
*
)
cfg
->
ptr
);
}
}
break
;
break
;
case
TSDB_OPTION_SHELL_ACTIVITY_TIMER
:
case
TSDB_OPTION_SHELL_ACTIVITY_TIMER
:
if
(
cfg_activetimer
&&
cfg_activetimer
->
cfgStatus
<=
TSDB_CFG_CSTATUS_OPTION
)
{
cfg
=
tsGetConfigOption
(
"shellActivityTimer"
);
tsShellActivityTimer
=
atoi
((
char
*
)
arg
);
if
(
cfg
&&
cfg
->
cfgStatus
<=
TSDB_CFG_CSTATUS_OPTION
)
{
tsShellActivityTimer
=
atoi
(
pStr
);
if
(
tsShellActivityTimer
<
1
)
tsShellActivityTimer
=
1
;
if
(
tsShellActivityTimer
<
1
)
tsShellActivityTimer
=
1
;
if
(
tsShellActivityTimer
>
3600
)
tsShellActivityTimer
=
3600
;
if
(
tsShellActivityTimer
>
3600
)
tsShellActivityTimer
=
3600
;
cfg
_activetimer
->
cfgStatus
=
TSDB_CFG_CSTATUS_OPTION
;
cfg
->
cfgStatus
=
TSDB_CFG_CSTATUS_OPTION
;
tscPrint
(
"set shellActivityTimer:%d"
,
tsShellActivityTimer
);
tscPrint
(
"set shellActivityTimer:%d"
,
tsShellActivityTimer
);
}
else
{
}
else
{
tscWarn
(
"config option:%s, input value:%s, is configured by %s, use %d"
,
cfg
_activetimer
->
option
,
pStr
,
tscWarn
(
"config option:%s, input value:%s, is configured by %s, use %d"
,
cfg
->
option
,
pStr
,
tsCfgStatusStr
[
cfg
_activetimer
->
cfgStatus
],
(
int32_t
*
)
cfg_activetimer
->
ptr
);
tsCfgStatusStr
[
cfg
->
cfgStatus
],
(
int32_t
*
)
cfg
->
ptr
);
}
}
break
;
break
;
case
TSDB_OPTION_LOCALE
:
{
// set locale
case
TSDB_OPTION_LOCALE
:
{
// set locale
pStr
=
(
char
*
)
arg
;
cfg
=
tsGetConfigOption
(
"locale"
);
size_t
len
=
strlen
(
pStr
);
size_t
len
=
strlen
(
pStr
);
if
(
len
==
0
||
len
>
TSDB_LOCALE_LEN
)
{
if
(
len
==
0
||
len
>
TSDB_LOCALE_LEN
)
{
tscPrint
(
"Invalid locale:%s, use default"
,
pStr
);
tscPrint
(
"Invalid locale:%s, use default"
,
pStr
);
return
-
1
;
return
-
1
;
}
}
if
(
cfg
_locale
&&
cfg_charset
&&
cfg_locale
->
cfgStatus
<=
TSDB_CFG_CSTATUS_OPTION
)
{
if
(
cfg
&&
cfg
&&
cfg
->
cfgStatus
<=
TSDB_CFG_CSTATUS_OPTION
)
{
char
sep
=
'.'
;
char
sep
=
'.'
;
if
(
strlen
(
tsLocale
)
==
0
)
{
// locale does not set yet
if
(
strlen
(
tsLocale
)
==
0
)
{
// locale does not set yet
...
@@ -239,7 +233,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
...
@@ -239,7 +233,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
if
(
locale
!=
NULL
)
{
if
(
locale
!=
NULL
)
{
tscPrint
(
"locale set, prev locale:%s, new locale:%s"
,
tsLocale
,
locale
);
tscPrint
(
"locale set, prev locale:%s, new locale:%s"
,
tsLocale
,
locale
);
cfg
_locale
->
cfgStatus
=
TSDB_CFG_CSTATUS_OPTION
;
cfg
->
cfgStatus
=
TSDB_CFG_CSTATUS_OPTION
;
}
else
{
// set the user-specified localed failed, use default LC_CTYPE as current locale
}
else
{
// set the user-specified localed failed, use default LC_CTYPE as current locale
locale
=
setlocale
(
LC_CTYPE
,
tsLocale
);
locale
=
setlocale
(
LC_CTYPE
,
tsLocale
);
tscPrint
(
"failed to set locale:%s, current locale:%s"
,
pStr
,
tsLocale
);
tscPrint
(
"failed to set locale:%s, current locale:%s"
,
pStr
,
tsLocale
);
...
@@ -261,7 +255,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
...
@@ -261,7 +255,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
}
}
strncpy
(
tsCharset
,
charset
,
tListLen
(
tsCharset
));
strncpy
(
tsCharset
,
charset
,
tListLen
(
tsCharset
));
cfg
_charset
->
cfgStatus
=
TSDB_CFG_CSTATUS_OPTION
;
cfg
->
cfgStatus
=
TSDB_CFG_CSTATUS_OPTION
;
}
else
{
}
else
{
tscPrint
(
"charset:%s is not valid in locale, charset remains:%s"
,
charset
,
tsCharset
);
tscPrint
(
"charset:%s is not valid in locale, charset remains:%s"
,
charset
,
tsCharset
);
...
@@ -272,23 +266,22 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
...
@@ -272,23 +266,22 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
tscPrint
(
"charset remains:%s"
,
tsCharset
);
tscPrint
(
"charset remains:%s"
,
tsCharset
);
}
}
}
else
{
}
else
{
tscWarn
(
"config option:%s, input value:%s, is configured by %s, use %s"
,
cfg
_locale
->
option
,
pStr
,
tscWarn
(
"config option:%s, input value:%s, is configured by %s, use %s"
,
cfg
->
option
,
pStr
,
tsCfgStatusStr
[
cfg
_locale
->
cfgStatus
],
(
char
*
)
cfg_locale
->
ptr
);
tsCfgStatusStr
[
cfg
->
cfgStatus
],
(
char
*
)
cfg
->
ptr
);
}
}
break
;
break
;
}
}
case
TSDB_OPTION_CHARSET
:
{
case
TSDB_OPTION_CHARSET
:
{
/* set charset will override the value of charset, assigned during system locale changed */
/* set charset will override the value of charset, assigned during system locale changed */
pStr
=
(
char
*
)
arg
;
cfg
=
tsGetConfigOption
(
"charset"
);
size_t
len
=
strlen
(
pStr
);
size_t
len
=
strlen
(
pStr
);
if
(
len
==
0
||
len
>
TSDB_LOCALE_LEN
)
{
if
(
len
==
0
||
len
>
TSDB_LOCALE_LEN
)
{
tscPrint
(
"failed to set charset:%s"
,
pStr
);
tscPrint
(
"failed to set charset:%s"
,
pStr
);
return
-
1
;
return
-
1
;
}
}
if
(
cfg
_charset
&&
cfg_charset
->
cfgStatus
<=
TSDB_CFG_CSTATUS_OPTION
)
{
if
(
cfg
&&
cfg
->
cfgStatus
<=
TSDB_CFG_CSTATUS_OPTION
)
{
if
(
taosValidateEncodec
(
pStr
))
{
if
(
taosValidateEncodec
(
pStr
))
{
if
(
strlen
(
tsCharset
)
==
0
)
{
if
(
strlen
(
tsCharset
)
==
0
)
{
tscPrint
(
"charset is set:%s"
,
pStr
);
tscPrint
(
"charset is set:%s"
,
pStr
);
...
@@ -297,40 +290,41 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
...
@@ -297,40 +290,41 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
}
}
strncpy
(
tsCharset
,
pStr
,
tListLen
(
tsCharset
));
strncpy
(
tsCharset
,
pStr
,
tListLen
(
tsCharset
));
cfg
_charset
->
cfgStatus
=
TSDB_CFG_CSTATUS_OPTION
;
cfg
->
cfgStatus
=
TSDB_CFG_CSTATUS_OPTION
;
}
else
{
}
else
{
tscPrint
(
"charset:%s not valid"
,
pStr
);
tscPrint
(
"charset:%s not valid"
,
pStr
);
}
}
}
else
{
}
else
{
tscWarn
(
"config option:%s, input value:%s, is configured by %s, use %s"
,
cfg
_charset
->
option
,
pStr
,
tscWarn
(
"config option:%s, input value:%s, is configured by %s, use %s"
,
cfg
->
option
,
pStr
,
tsCfgStatusStr
[
cfg
_charset
->
cfgStatus
],
(
char
*
)
cfg_charset
->
ptr
);
tsCfgStatusStr
[
cfg
->
cfgStatus
],
(
char
*
)
cfg
->
ptr
);
}
}
break
;
break
;
}
}
case
TSDB_OPTION_TIMEZONE
:
case
TSDB_OPTION_TIMEZONE
:
pStr
=
(
char
*
)
arg
;
cfg
=
tsGetConfigOption
(
"timezone"
)
;
if
(
cfg
_timezone
&&
cfg_timezone
->
cfgStatus
<=
TSDB_CFG_CSTATUS_OPTION
)
{
if
(
cfg
&&
cfg
->
cfgStatus
<=
TSDB_CFG_CSTATUS_OPTION
)
{
strcpy
(
tsTimezone
,
pStr
);
strcpy
(
tsTimezone
,
pStr
);
tsSetTimeZone
();
tsSetTimeZone
();
cfg
_timezone
->
cfgStatus
=
TSDB_CFG_CSTATUS_OPTION
;
cfg
->
cfgStatus
=
TSDB_CFG_CSTATUS_OPTION
;
tscTrace
(
"timezone set:%s, input:%s by taos_options"
,
tsTimezone
,
pStr
);
tscTrace
(
"timezone set:%s, input:%s by taos_options"
,
tsTimezone
,
pStr
);
}
else
{
}
else
{
tscWarn
(
"config option:%s, input value:%s, is configured by %s, use %s"
,
cfg
_timezone
->
option
,
pStr
,
tscWarn
(
"config option:%s, input value:%s, is configured by %s, use %s"
,
cfg
->
option
,
pStr
,
tsCfgStatusStr
[
cfg
_timezone
->
cfgStatus
],
(
char
*
)
cfg_timezone
->
ptr
);
tsCfgStatusStr
[
cfg
->
cfgStatus
],
(
char
*
)
cfg
->
ptr
);
}
}
break
;
break
;
case
TSDB_OPTION_SOCKET_TYPE
:
case
TSDB_OPTION_SOCKET_TYPE
:
if
(
cfg_socket
&&
cfg_socket
->
cfgStatus
<=
TSDB_CFG_CSTATUS_OPTION
)
{
cfg
=
tsGetConfigOption
(
"sockettype"
);
if
(
strcasecmp
(
arg
,
TAOS_SOCKET_TYPE_NAME_UDP
)
!=
0
&&
strcasecmp
(
arg
,
TAOS_SOCKET_TYPE_NAME_TCP
)
!=
0
)
{
if
(
cfg
&&
cfg
->
cfgStatus
<=
TSDB_CFG_CSTATUS_OPTION
)
{
if
(
strcasecmp
(
pStr
,
TAOS_SOCKET_TYPE_NAME_UDP
)
!=
0
&&
strcasecmp
(
pStr
,
TAOS_SOCKET_TYPE_NAME_TCP
)
!=
0
)
{
tscError
(
"only 'tcp' or 'udp' allowed for configuring the socket type"
);
tscError
(
"only 'tcp' or 'udp' allowed for configuring the socket type"
);
return
-
1
;
return
-
1
;
}
}
strncpy
(
tsSocketType
,
arg
,
tListLen
(
tsSocketType
));
strncpy
(
tsSocketType
,
pStr
,
tListLen
(
tsSocketType
));
cfg
_socket
->
cfgStatus
=
TSDB_CFG_CSTATUS_OPTION
;
cfg
->
cfgStatus
=
TSDB_CFG_CSTATUS_OPTION
;
tscPrint
(
"socket type is set:%s"
,
tsSocketType
);
tscPrint
(
"socket type is set:%s"
,
tsSocketType
);
}
}
break
;
break
;
...
@@ -342,3 +336,20 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
...
@@ -342,3 +336,20 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
return
0
;
return
0
;
}
}
int
taos_options
(
TSDB_OPTION
option
,
const
void
*
arg
,
...)
{
static
int32_t
lock
=
0
;
for
(
int
i
=
1
;
atomic_val_compare_exchange_32
(
&
lock
,
0
,
1
)
!=
0
;
++
i
)
{
if
(
i
%
1000
==
0
)
{
tscPrint
(
"haven't acquire lock after spin %d times."
,
i
);
sched_yield
();
}
}
int
ret
=
taos_options_imp
(
option
,
(
const
char
*
)
arg
);
atomic_store_32
(
&
lock
,
0
);
return
ret
;
}
\ No newline at end of file
src/inc/tglobalcfg.h
浏览文件 @
adbf4c22
...
@@ -247,7 +247,7 @@ typedef struct {
...
@@ -247,7 +247,7 @@ typedef struct {
extern
SGlobalConfig
*
tsGlobalConfig
;
extern
SGlobalConfig
*
tsGlobalConfig
;
extern
int
tsGlobalConfigNum
;
extern
int
tsGlobalConfigNum
;
extern
char
*
tsCfgStatusStr
[];
extern
char
*
tsCfgStatusStr
[];
SGlobalConfig
*
tsGetConfigOption
(
char
*
option
);
SGlobalConfig
*
tsGetConfigOption
(
c
onst
c
har
*
option
);
#define TSDB_CFG_MAX_NUM 110
#define TSDB_CFG_MAX_NUM 110
#define TSDB_CFG_PRINT_LEN 23
#define TSDB_CFG_PRINT_LEN 23
...
...
src/util/src/tglobalcfg.c
浏览文件 @
adbf4c22
...
@@ -364,7 +364,7 @@ void tsReadLogOption(char *option, char *value) {
...
@@ -364,7 +364,7 @@ void tsReadLogOption(char *option, char *value) {
}
}
}
}
SGlobalConfig
*
tsGetConfigOption
(
char
*
option
)
{
SGlobalConfig
*
tsGetConfigOption
(
c
onst
c
har
*
option
)
{
tsInitGlobalConfig
();
tsInitGlobalConfig
();
for
(
int
i
=
0
;
i
<
tsGlobalConfigNum
;
++
i
)
{
for
(
int
i
=
0
;
i
<
tsGlobalConfigNum
;
++
i
)
{
SGlobalConfig
*
cfg
=
tsGlobalConfig
+
i
;
SGlobalConfig
*
cfg
=
tsGlobalConfig
+
i
;
...
@@ -374,7 +374,7 @@ SGlobalConfig *tsGetConfigOption(char *option) {
...
@@ -374,7 +374,7 @@ SGlobalConfig *tsGetConfigOption(char *option) {
return
NULL
;
return
NULL
;
}
}
void
tsReadConfigOption
(
char
*
option
,
char
*
value
)
{
void
tsReadConfigOption
(
c
onst
c
har
*
option
,
char
*
value
)
{
for
(
int
i
=
0
;
i
<
tsGlobalConfigNum
;
++
i
)
{
for
(
int
i
=
0
;
i
<
tsGlobalConfigNum
;
++
i
)
{
SGlobalConfig
*
cfg
=
tsGlobalConfig
+
i
;
SGlobalConfig
*
cfg
=
tsGlobalConfig
+
i
;
if
(
!
(
cfg
->
cfgType
&
TSDB_CFG_CTYPE_B_CONFIG
))
continue
;
if
(
!
(
cfg
->
cfgType
&
TSDB_CFG_CTYPE_B_CONFIG
))
continue
;
...
@@ -423,9 +423,7 @@ void tsInitConfigOption(SGlobalConfig *cfg, char *name, void *ptr, int8_t valTyp
...
@@ -423,9 +423,7 @@ void tsInitConfigOption(SGlobalConfig *cfg, char *name, void *ptr, int8_t valTyp
cfg
->
cfgStatus
=
TSDB_CFG_CSTATUS_NONE
;
cfg
->
cfgStatus
=
TSDB_CFG_CSTATUS_NONE
;
}
}
void
tsInitGlobalConfig
()
{
static
void
doInitGlobalConfig
()
{
if
(
tsGlobalConfig
!=
NULL
)
return
;
tsGlobalConfig
=
(
SGlobalConfig
*
)
malloc
(
sizeof
(
SGlobalConfig
)
*
TSDB_CFG_MAX_NUM
);
tsGlobalConfig
=
(
SGlobalConfig
*
)
malloc
(
sizeof
(
SGlobalConfig
)
*
TSDB_CFG_MAX_NUM
);
memset
(
tsGlobalConfig
,
0
,
sizeof
(
SGlobalConfig
)
*
TSDB_CFG_MAX_NUM
);
memset
(
tsGlobalConfig
,
0
,
sizeof
(
SGlobalConfig
)
*
TSDB_CFG_MAX_NUM
);
...
@@ -783,6 +781,11 @@ void tsInitGlobalConfig() {
...
@@ -783,6 +781,11 @@ void tsInitGlobalConfig() {
tsGlobalConfigNum
=
(
int
)(
cfg
-
tsGlobalConfig
);
tsGlobalConfigNum
=
(
int
)(
cfg
-
tsGlobalConfig
);
}
}
static
pthread_once_t
initGlobalConfig
=
PTHREAD_ONCE_INIT
;
void
tsInitGlobalConfig
()
{
pthread_once
(
&
initGlobalConfig
,
doInitGlobalConfig
);
}
void
tsReadGlobalLogConfig
()
{
void
tsReadGlobalLogConfig
()
{
tsInitGlobalConfig
();
tsInitGlobalConfig
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录