Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
哥们要飞
TDengine
提交
173f1948
T
TDengine
项目概览
哥们要飞
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
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,发现更多精彩内容 >>
未验证
提交
173f1948
编写于
8月 18, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
8月 18, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3126 from taosdata/hotfix/os
fix coverity defects
上级
4e1de7fb
152867cb
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
23 addition
and
6 deletion
+23
-6
src/balance/src/balance.c
src/balance/src/balance.c
+1
-1
src/plugins/mqtt/src/mqttSystem.c
src/plugins/mqtt/src/mqttSystem.c
+15
-1
src/util/src/tsocket.c
src/util/src/tsocket.c
+7
-4
未找到文件。
src/balance/src/balance.c
浏览文件 @
173f1948
...
@@ -165,7 +165,7 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) {
...
@@ -165,7 +165,7 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) {
balanceSwapVnodeGid
(
pVgroup
->
vnodeGid
,
pVgroup
->
vnodeGid
+
1
);
balanceSwapVnodeGid
(
pVgroup
->
vnodeGid
,
pVgroup
->
vnodeGid
+
1
);
}
}
}
else
{
}
else
{
int32_t
randVal
=
rand
()
%
6
;
int32_t
randVal
=
rand
Index
++
%
6
;
if
(
randVal
==
1
)
{
// 1, 0, 2
if
(
randVal
==
1
)
{
// 1, 0, 2
balanceSwapVnodeGid
(
pVgroup
->
vnodeGid
+
0
,
pVgroup
->
vnodeGid
+
1
);
balanceSwapVnodeGid
(
pVgroup
->
vnodeGid
+
0
,
pVgroup
->
vnodeGid
+
1
);
}
else
if
(
randVal
==
2
)
{
// 1, 2, 0
}
else
if
(
randVal
==
2
)
{
// 1, 2, 0
...
...
src/plugins/mqtt/src/mqttSystem.c
浏览文件 @
173f1948
...
@@ -39,6 +39,7 @@ int mttIsRuning = 1;
...
@@ -39,6 +39,7 @@ int mttIsRuning = 1;
int32_t
mqttInitSystem
()
{
int32_t
mqttInitSystem
()
{
int
rc
=
0
;
int
rc
=
0
;
#if 0
uint8_t sendbuf[2048];
uint8_t sendbuf[2048];
uint8_t recvbuf[1024];
uint8_t recvbuf[1024];
recntStatus.sendbuf = sendbuf;
recntStatus.sendbuf = sendbuf;
...
@@ -47,7 +48,11 @@ int32_t mqttInitSystem() {
...
@@ -47,7 +48,11 @@ int32_t mqttInitSystem() {
recntStatus.recvbufsz = sizeof(recvbuf);
recntStatus.recvbufsz = sizeof(recvbuf);
char* url = tsMqttBrokerAddress;
char* url = tsMqttBrokerAddress;
recntStatus.user_name = strstr(url, "@") != NULL ? strbetween(url, "//", ":") : NULL;
recntStatus.user_name = strstr(url, "@") != NULL ? strbetween(url, "//", ":") : NULL;
recntStatus
.
password
=
strstr
(
url
,
"@"
)
!=
NULL
?
strbetween
(
strstr
(
url
,
recntStatus
.
user_name
),
":"
,
"@"
)
:
NULL
;
char * passStr = strstr(url, recntStatus.user_name);
if (passStr != NULL) {
recntStatus.password = strstr(url, "@") != NULL ? strbetween(passStr, ":", "@") : NULL;
}
if (strlen(url) == 0) {
if (strlen(url) == 0) {
mqttDebug("mqtt module not init, url is null");
mqttDebug("mqtt module not init, url is null");
...
@@ -91,11 +96,13 @@ int32_t mqttInitSystem() {
...
@@ -91,11 +96,13 @@ int32_t mqttInitSystem() {
topicPath = NULL;
topicPath = NULL;
}
}
#endif
return
rc
;
return
rc
;
}
}
int32_t
mqttStartSystem
()
{
int32_t
mqttStartSystem
()
{
int
rc
=
0
;
int
rc
=
0
;
#if 0
if (recntStatus.user_name != NULL && recntStatus.password != NULL) {
if (recntStatus.user_name != NULL && recntStatus.password != NULL) {
mqttInfo("connecting to mqtt://%s:%s@%s:%s/%s/", recntStatus.user_name, recntStatus.password,
mqttInfo("connecting to mqtt://%s:%s@%s:%s/%s/", recntStatus.user_name, recntStatus.password,
recntStatus.hostname, recntStatus.port, topicPath);
recntStatus.hostname, recntStatus.port, topicPath);
...
@@ -112,18 +119,22 @@ int32_t mqttStartSystem() {
...
@@ -112,18 +119,22 @@ int32_t mqttStartSystem() {
} else {
} else {
mqttInfo("listening for '%s' messages.", recntStatus.topic);
mqttInfo("listening for '%s' messages.", recntStatus.topic);
}
}
#endif
return
rc
;
return
rc
;
}
}
void
mqttStopSystem
()
{
void
mqttStopSystem
()
{
#if 0
mqttClient.error = MQTT_ERROR_SOCKET_ERROR;
mqttClient.error = MQTT_ERROR_SOCKET_ERROR;
mttIsRuning = 0;
mttIsRuning = 0;
usleep(300000U);
usleep(300000U);
mqttCleanup(EXIT_SUCCESS, mqttClient.socketfd, &clientDaemonThread);
mqttCleanup(EXIT_SUCCESS, mqttClient.socketfd, &clientDaemonThread);
mqttInfo("mqtt is stoped");
mqttInfo("mqtt is stoped");
#endif
}
}
void
mqttCleanUpSystem
()
{
void
mqttCleanUpSystem
()
{
#if 0
mqttInfo("starting to cleanup mqtt");
mqttInfo("starting to cleanup mqtt");
free(recntStatus.user_name);
free(recntStatus.user_name);
free(recntStatus.password);
free(recntStatus.password);
...
@@ -132,6 +143,7 @@ void mqttCleanUpSystem() {
...
@@ -132,6 +143,7 @@ void mqttCleanUpSystem() {
free(recntStatus.topic);
free(recntStatus.topic);
free(topicPath);
free(topicPath);
mqttInfo("mqtt is cleaned up");
mqttInfo("mqtt is cleaned up");
#endif
}
}
void
mqtt_PublishCallback
(
void
**
unused
,
struct
mqtt_response_publish
*
published
)
{
void
mqtt_PublishCallback
(
void
**
unused
,
struct
mqtt_response_publish
*
published
)
{
...
@@ -183,9 +195,11 @@ void* mqttClientRefresher(void* client) {
...
@@ -183,9 +195,11 @@ void* mqttClientRefresher(void* client) {
}
}
void
mqttCleanup
(
int
status
,
int
sockfd
,
pthread_t
*
client_daemon
)
{
void
mqttCleanup
(
int
status
,
int
sockfd
,
pthread_t
*
client_daemon
)
{
#if 0
mqttInfo("clean up mqtt module");
mqttInfo("clean up mqtt module");
if (sockfd != -1) close(sockfd);
if (sockfd != -1) close(sockfd);
if (client_daemon != NULL) pthread_cancel(*client_daemon);
if (client_daemon != NULL) pthread_cancel(*client_daemon);
#endif
}
}
void
mqttInitConnCb
(
void
*
param
,
TAOS_RES
*
result
,
int32_t
code
)
{
void
mqttInitConnCb
(
void
*
param
,
TAOS_RES
*
result
,
int32_t
code
)
{
...
...
src/util/src/tsocket.c
浏览文件 @
173f1948
...
@@ -231,8 +231,9 @@ SOCKET taosOpenUdpSocket(uint32_t ip, uint16_t port) {
...
@@ -231,8 +231,9 @@ SOCKET taosOpenUdpSocket(uint32_t ip, uint16_t port) {
localAddr
.
sin_addr
.
s_addr
=
ip
;
localAddr
.
sin_addr
.
s_addr
=
ip
;
localAddr
.
sin_port
=
(
uint16_t
)
htons
(
port
);
localAddr
.
sin_port
=
(
uint16_t
)
htons
(
port
);
if
((
sockFd
=
(
int
)
socket
(
AF_INET
,
SOCK_DGRAM
,
0
))
<
0
)
{
if
((
sockFd
=
(
int
)
socket
(
AF_INET
,
SOCK_DGRAM
,
0
))
<
=
2
)
{
uError
(
"failed to open udp socket: %d (%s)"
,
errno
,
strerror
(
errno
));
uError
(
"failed to open udp socket: %d (%s)"
,
errno
,
strerror
(
errno
));
close
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
...
@@ -265,8 +266,9 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie
...
@@ -265,8 +266,9 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie
sockFd
=
socket
(
PF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
sockFd
=
socket
(
PF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
if
(
sockFd
<
0
)
{
if
(
sockFd
<
=
2
)
{
uError
(
"failed to open the socket: %d (%s)"
,
errno
,
strerror
(
errno
));
uError
(
"failed to open the socket: %d (%s)"
,
errno
,
strerror
(
errno
));
close
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
...
@@ -276,7 +278,7 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie
...
@@ -276,7 +278,7 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie
uError
(
"setsockopt SO_REUSEADDR failed: %d (%s)"
,
errno
,
strerror
(
errno
));
uError
(
"setsockopt SO_REUSEADDR failed: %d (%s)"
,
errno
,
strerror
(
errno
));
taosCloseSocket
(
sockFd
);
taosCloseSocket
(
sockFd
);
return
-
1
;
return
-
1
;
}
;
}
if
(
clientIp
!=
0
)
{
if
(
clientIp
!=
0
)
{
memset
((
char
*
)
&
clientAddr
,
0
,
sizeof
(
clientAddr
));
memset
((
char
*
)
&
clientAddr
,
0
,
sizeof
(
clientAddr
));
...
@@ -371,8 +373,9 @@ SOCKET taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
...
@@ -371,8 +373,9 @@ SOCKET taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
serverAdd
.
sin_addr
.
s_addr
=
ip
;
serverAdd
.
sin_addr
.
s_addr
=
ip
;
serverAdd
.
sin_port
=
(
uint16_t
)
htons
(
port
);
serverAdd
.
sin_port
=
(
uint16_t
)
htons
(
port
);
if
((
sockFd
=
(
int
)
socket
(
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
))
<
2
)
{
if
((
sockFd
=
(
int
)
socket
(
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
))
<
=
2
)
{
uError
(
"failed to open TCP socket: %d (%s)"
,
errno
,
strerror
(
errno
));
uError
(
"failed to open TCP socket: %d (%s)"
,
errno
,
strerror
(
errno
));
close
(
sockFd
);
return
-
1
;
return
-
1
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录