Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f49524da
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看板
未验证
提交
f49524da
编写于
5月 05, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
5月 05, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12119 from taosdata/fix/tsim
fix: forbid the startup of illegal fqdn
上级
2198001b
ae905656
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
34 addition
and
13 deletion
+34
-13
source/common/src/tglobal.c
source/common/src/tglobal.c
+34
-13
未找到文件。
source/common/src/tglobal.c
浏览文件 @
f49524da
...
@@ -224,7 +224,8 @@ struct SConfig *taosGetCfg() {
...
@@ -224,7 +224,8 @@ struct SConfig *taosGetCfg() {
return
tsCfg
;
return
tsCfg
;
}
}
static
int32_t
taosLoadCfg
(
SConfig
*
pCfg
,
const
char
**
envCmd
,
const
char
*
inputCfgDir
,
const
char
*
envFile
,
char
*
apolloUrl
)
{
static
int32_t
taosLoadCfg
(
SConfig
*
pCfg
,
const
char
**
envCmd
,
const
char
*
inputCfgDir
,
const
char
*
envFile
,
char
*
apolloUrl
)
{
char
cfgDir
[
PATH_MAX
]
=
{
0
};
char
cfgDir
[
PATH_MAX
]
=
{
0
};
char
cfgFile
[
PATH_MAX
+
100
]
=
{
0
};
char
cfgFile
[
PATH_MAX
+
100
]
=
{
0
};
...
@@ -300,15 +301,10 @@ static int32_t taosAddServerLogCfg(SConfig *pCfg) {
...
@@ -300,15 +301,10 @@ static int32_t taosAddServerLogCfg(SConfig *pCfg) {
static
int32_t
taosAddClientCfg
(
SConfig
*
pCfg
)
{
static
int32_t
taosAddClientCfg
(
SConfig
*
pCfg
)
{
char
defaultFqdn
[
TSDB_FQDN_LEN
]
=
{
0
};
char
defaultFqdn
[
TSDB_FQDN_LEN
]
=
{
0
};
int32_t
defaultServerPort
=
6030
;
int32_t
defaultServerPort
=
6030
;
char
defaultFirstEp
[
TSDB_EP_LEN
]
=
{
0
};
char
defaultSecondEp
[
TSDB_EP_LEN
]
=
{
0
};
if
(
taosGetFqdn
(
defaultFqdn
)
!=
0
)
return
-
1
;
if
(
taosGetFqdn
(
defaultFqdn
)
!=
0
)
return
-
1
;
snprintf
(
defaultFirstEp
,
TSDB_EP_LEN
,
"%s:%d"
,
defaultFqdn
,
defaultServerPort
);
snprintf
(
defaultSecondEp
,
TSDB_EP_LEN
,
"%s:%d"
,
defaultFqdn
,
defaultServerPort
);
if
(
cfgAddString
(
pCfg
,
"firstEp"
,
defaultFirstEp
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"firstEp"
,
""
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"secondEp"
,
defaultSecondEp
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"secondEp"
,
""
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"fqdn"
,
defaultFqdn
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"fqdn"
,
defaultFqdn
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"serverPort"
,
defaultServerPort
,
1
,
65056
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"serverPort"
,
defaultServerPort
,
1
,
65056
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddDir
(
pCfg
,
"tempDir"
,
tsTempDir
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddDir
(
pCfg
,
"tempDir"
,
tsTempDir
,
1
)
!=
0
)
return
-
1
;
...
@@ -478,15 +474,18 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
...
@@ -478,15 +474,18 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
tsServerPort
=
(
uint16_t
)
cfgGetItem
(
pCfg
,
"serverPort"
)
->
i32
;
tsServerPort
=
(
uint16_t
)
cfgGetItem
(
pCfg
,
"serverPort"
)
->
i32
;
snprintf
(
tsLocalEp
,
sizeof
(
tsLocalEp
),
"%s:%u"
,
tsLocalFqdn
,
tsServerPort
);
snprintf
(
tsLocalEp
,
sizeof
(
tsLocalEp
),
"%s:%u"
,
tsLocalFqdn
,
tsServerPort
);
char
defaultFirstEp
[
TSDB_EP_LEN
]
=
{
0
};
snprintf
(
defaultFirstEp
,
TSDB_EP_LEN
,
"%s:%u"
,
tsLocalFqdn
,
tsServerPort
);
SConfigItem
*
pFirstEpItem
=
cfgGetItem
(
pCfg
,
"firstEp"
);
SConfigItem
*
pFirstEpItem
=
cfgGetItem
(
pCfg
,
"firstEp"
);
SEp
firstEp
=
{
0
};
SEp
firstEp
=
{
0
};
taosGetFqdnPortFromEp
(
pFirstEpItem
->
str
,
&
firstEp
);
taosGetFqdnPortFromEp
(
strlen
(
pFirstEpItem
->
str
)
==
0
?
defaultFirstEp
:
pFirstEpItem
->
str
,
&
firstEp
);
snprintf
(
tsFirst
,
sizeof
(
tsFirst
),
"%s:%u"
,
firstEp
.
fqdn
,
firstEp
.
port
);
snprintf
(
tsFirst
,
sizeof
(
tsFirst
),
"%s:%u"
,
firstEp
.
fqdn
,
firstEp
.
port
);
cfgSetItem
(
pCfg
,
"firstEp"
,
tsFirst
,
pFirstEpItem
->
stype
);
cfgSetItem
(
pCfg
,
"firstEp"
,
tsFirst
,
pFirstEpItem
->
stype
);
SConfigItem
*
pSecondpItem
=
cfgGetItem
(
pCfg
,
"secondEp"
);
SConfigItem
*
pSecondpItem
=
cfgGetItem
(
pCfg
,
"secondEp"
);
SEp
secondEp
=
{
0
};
SEp
secondEp
=
{
0
};
taosGetFqdnPortFromEp
(
pSecondpItem
->
str
,
&
secondEp
);
taosGetFqdnPortFromEp
(
strlen
(
pSecondpItem
->
str
)
==
0
?
defaultFirstEp
:
pSecondpItem
->
str
,
&
secondEp
);
snprintf
(
tsSecond
,
sizeof
(
tsSecond
),
"%s:%u"
,
secondEp
.
fqdn
,
secondEp
.
port
);
snprintf
(
tsSecond
,
sizeof
(
tsSecond
),
"%s:%u"
,
secondEp
.
fqdn
,
secondEp
.
port
);
cfgSetItem
(
pCfg
,
"secondEp"
,
tsSecond
,
pSecondpItem
->
stype
);
cfgSetItem
(
pCfg
,
"secondEp"
,
tsSecond
,
pSecondpItem
->
stype
);
...
@@ -583,8 +582,8 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
...
@@ -583,8 +582,8 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
return
0
;
return
0
;
}
}
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
**
envCmd
,
const
char
*
envFile
,
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
**
envCmd
,
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
c
onst
char
*
envFile
,
c
har
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
osDefaultInit
();
osDefaultInit
();
SConfig
*
pCfg
=
cfgInit
();
SConfig
*
pCfg
=
cfgInit
();
...
@@ -636,7 +635,24 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
...
@@ -636,7 +635,24 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
return
0
;
return
0
;
}
}
int32_t
taosInitCfg
(
const
char
*
cfgDir
,
const
char
**
envCmd
,
const
char
*
envFile
,
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
static
int32_t
taosCheckGlobalCfg
()
{
uint32_t
ipv4
=
taosGetIpv4FromFqdn
(
tsLocalFqdn
);
if
(
ipv4
==
0xffffffff
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
uError
(
"failed to get ip from fqdn:%s since %s, dnode can not be initialized"
,
tsLocalFqdn
,
terrstr
());
return
-
1
;
}
if
(
tsServerPort
<=
0
)
{
uError
(
"invalid server port:%u, dnode can not be initialized"
,
tsServerPort
);
return
-
1
;
}
return
0
;
}
int32_t
taosInitCfg
(
const
char
*
cfgDir
,
const
char
**
envCmd
,
const
char
*
envFile
,
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
if
(
tsCfg
!=
NULL
)
return
0
;
if
(
tsCfg
!=
NULL
)
return
0
;
tsCfg
=
cfgInit
();
tsCfg
=
cfgInit
();
...
@@ -674,6 +690,11 @@ int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile
...
@@ -674,6 +690,11 @@ int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile
taosSetSystemCfg
(
tsCfg
);
taosSetSystemCfg
(
tsCfg
);
cfgDumpCfg
(
tsCfg
,
tsc
,
false
);
cfgDumpCfg
(
tsCfg
,
tsc
,
false
);
if
(
taosCheckGlobalCfg
()
!=
0
)
{
return
-
1
;
}
return
0
;
return
0
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录