Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b2996fe1
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
未验证
提交
b2996fe1
编写于
6月 09, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
6月 09, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2199 from taosdata/hotfix/crash
[TD_543] fix coverity scan, cid:267845 267846
上级
4e4520ee
04956442
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
18 addition
and
77 deletion
+18
-77
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+1
-1
src/os/linux/src/linuxSysPara.c
src/os/linux/src/linuxSysPara.c
+17
-76
未找到文件。
src/client/src/tscSystem.c
浏览文件 @
b2996fe1
...
...
@@ -201,7 +201,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) {
tscPrint
(
"set shellActivityTimer:%d"
,
tsShellActivityTimer
);
}
else
{
tscWarn
(
"config option:%s, input value:%s, is configured by %s, use %d"
,
cfg
->
option
,
pStr
,
tsCfgStatusStr
[
cfg
->
cfgStatus
],
(
int32_t
*
)
cfg
->
ptr
);
tsCfgStatusStr
[
cfg
->
cfgStatus
],
*
(
int32_t
*
)
cfg
->
ptr
);
}
break
;
...
...
src/os/linux/src/linuxSysPara.c
浏览文件 @
b2996fe1
...
...
@@ -331,66 +331,7 @@ bool taosGetDisk() {
return
true
;
}
static
bool
taosGetCardName
(
char
*
ip
,
char
*
name
)
{
struct
ifaddrs
*
ifaddr
,
*
ifa
;
int
family
,
s
;
char
host
[
NI_MAXHOST
];
bool
ret
=
false
;
if
(
getifaddrs
(
&
ifaddr
)
==
-
1
)
{
return
false
;
}
/* Walk through linked list, maintaining head pointer so we can free list
* later */
for
(
ifa
=
ifaddr
;
ifa
!=
NULL
;
ifa
=
ifa
->
ifa_next
)
{
if
(
ifa
->
ifa_addr
==
NULL
)
continue
;
family
=
ifa
->
ifa_addr
->
sa_family
;
if
(
family
!=
AF_INET
)
{
continue
;
}
s
=
getnameinfo
(
ifa
->
ifa_addr
,
(
family
==
AF_INET
)
?
sizeof
(
struct
sockaddr_in
)
:
sizeof
(
struct
sockaddr_in6
),
host
,
NI_MAXHOST
,
NULL
,
0
,
NI_NUMERICHOST
);
if
(
s
!=
0
)
{
break
;
}
if
(
strcmp
(
host
,
"127.0.0.1"
)
==
0
)
{
continue
;
}
// TODO: the ip not config
// if (strcmp(host, ip) == 0) {
strcpy
(
name
,
ifa
->
ifa_name
);
ret
=
true
;
// }
}
freeifaddrs
(
ifaddr
);
return
ret
;
}
static
bool
taosGetCardInfo
(
int64_t
*
bytes
)
{
static
char
tsPublicCard
[
1000
]
=
{
0
};
static
char
tsPrivateIp
[
40
];
if
(
tsPublicCard
[
0
]
==
0
)
{
if
(
!
taosGetCardName
(
tsPrivateIp
,
tsPublicCard
))
{
uError
(
"can't get card name from ip:%s"
,
tsPrivateIp
);
return
false
;
}
int
cardNameLen
=
(
int
)
strlen
(
tsPublicCard
);
for
(
int
i
=
0
;
i
<
cardNameLen
;
++
i
)
{
if
(
tsPublicCard
[
i
]
==
':'
)
{
tsPublicCard
[
i
]
=
0
;
break
;
}
}
// uTrace("card name of public ip:%s is %s", tsPublicIp, tsPublicCard);
}
FILE
*
fp
=
fopen
(
tsSysNetFile
,
"r"
);
if
(
fp
==
NULL
)
{
uError
(
"open file:%s failed"
,
tsSysNetFile
);
...
...
@@ -403,6 +344,7 @@ static bool taosGetCardInfo(int64_t *bytes) {
size_t
len
;
char
*
line
=
NULL
;
*
bytes
=
0
;
while
(
!
feof
(
fp
))
{
tfree
(
line
);
...
...
@@ -411,23 +353,20 @@ static bool taosGetCardInfo(int64_t *bytes) {
if
(
line
==
NULL
)
{
break
;
}
if
(
strstr
(
line
,
tsPublicCard
)
!=
NULL
)
{
break
;
if
(
strstr
(
line
,
"lo:"
)
!=
NULL
)
{
continue
;
}
sscanf
(
line
,
"%s %"
PRId64
" %"
PRId64
" %"
PRId64
" %"
PRId64
" %"
PRId64
" %"
PRId64
" %"
PRId64
" %"
PRId64
" %"
PRId64
" %"
PRId64
,
nouse0
,
&
rbytes
,
&
rpackts
,
&
nouse1
,
&
nouse2
,
&
nouse3
,
&
nouse4
,
&
nouse5
,
&
nouse6
,
&
tbytes
,
&
tpackets
);
*
bytes
+=
(
rbytes
+
tbytes
);
}
if
(
line
!=
NULL
)
{
sscanf
(
line
,
"%s %"
PRId64
" %"
PRId64
" %"
PRId64
" %"
PRId64
" %"
PRId64
" %"
PRId64
" %"
PRId64
" %"
PRId64
" %"
PRId64
" %"
PRId64
,
nouse0
,
&
rbytes
,
&
rpackts
,
&
nouse1
,
&
nouse2
,
&
nouse3
,
&
nouse4
,
&
nouse5
,
&
nouse6
,
&
tbytes
,
&
tpackets
);
*
bytes
=
rbytes
+
tbytes
;
tfree
(
line
);
fclose
(
fp
);
return
true
;
}
else
{
uWarn
(
"can't get card:%s info from device:%s"
,
tsPublicCard
,
tsSysNetFile
);
*
bytes
=
0
;
fclose
(
fp
);
return
false
;
}
tfree
(
line
);
fclose
(
fp
);
return
true
;
}
bool
taosGetBandSpeed
(
float
*
bandSpeedKb
)
{
...
...
@@ -443,13 +382,15 @@ bool taosGetBandSpeed(float *bandSpeedKb) {
if
(
lastTime
==
0
||
lastBytes
==
0
)
{
lastTime
=
curTime
;
lastBytes
=
curBytes
;
return
false
;
*
bandSpeedKb
=
0
;
return
true
;
}
if
(
lastTime
>=
curTime
||
lastBytes
>
curBytes
)
{
lastTime
=
curTime
;
lastBytes
=
curBytes
;
return
false
;
*
bandSpeedKb
=
0
;
return
true
;
}
double
totalBytes
=
(
double
)(
curBytes
-
lastBytes
)
/
1024
*
8
;
// Kb
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录