Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
73cd9da8
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
73cd9da8
编写于
9月 23, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
9月 23, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17032 from taosdata/fix/fixInvalidFree
fix(tsc): fix invalid free
上级
17d7ec98
c2c7e7a6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
51 addition
and
17 deletion
+51
-17
include/common/tmsg.h
include/common/tmsg.h
+1
-0
source/client/src/clientHb.c
source/client/src/clientHb.c
+17
-11
source/libs/transport/src/thttp.c
source/libs/transport/src/thttp.c
+33
-6
未找到文件。
include/common/tmsg.h
浏览文件 @
73cd9da8
...
...
@@ -2337,6 +2337,7 @@ int32_t tSerializeSClientHbBatchReq(void* buf, int32_t bufLen, const SClientHbBa
int32_t
tDeserializeSClientHbBatchReq
(
void
*
buf
,
int32_t
bufLen
,
SClientHbBatchReq
*
pReq
);
static
FORCE_INLINE
void
tFreeClientHbBatchReq
(
void
*
pReq
)
{
if
(
pReq
==
NULL
)
return
;
SClientHbBatchReq
*
req
=
(
SClientHbBatchReq
*
)
pReq
;
taosArrayDestroyEx
(
req
->
reqs
,
tFreeClientHbReq
);
taosMemoryFree
(
pReq
);
...
...
source/client/src/clientHb.c
浏览文件 @
73cd9da8
...
...
@@ -606,28 +606,34 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
int32_t
connKeyCnt
=
atomic_load_32
(
&
pAppHbMgr
->
connKeyCnt
);
pBatchReq
->
reqs
=
taosArrayInit
(
connKeyCnt
,
sizeof
(
SClientHbReq
));
int64_t
rid
=
-
1
;
int32_t
code
=
0
;
void
*
pIter
=
taosHashIterate
(
pAppHbMgr
->
activeInfo
,
NULL
);
while
(
pIter
!=
NULL
)
{
SClientHbReq
*
pOneReq
=
pIter
;
pOneReq
=
taosArrayPush
(
pBatchReq
->
reqs
,
pOneReq
);
void
*
pIter
=
taosHashIterate
(
pAppHbMgr
->
activeInfo
,
NULL
);
SClientHbReq
*
pOneReq
=
pIter
;
SClientHbKey
*
connKey
=
pOneReq
?
&
pOneReq
->
connKey
:
NULL
;
if
(
connKey
!=
NULL
)
rid
=
connKey
->
tscRid
;
STscObj
*
pTscObj
=
(
STscObj
*
)
acquireTscObj
(
rid
);
if
(
pTscObj
==
NULL
)
{
tFreeClientHbBatchReq
(
pBatchReq
);
return
NULL
;
}
while
(
pIter
!=
NULL
)
{
pOneReq
=
taosArrayPush
(
pBatchReq
->
reqs
,
pOneReq
);
code
=
(
*
clientHbMgr
.
reqHandle
[
pOneReq
->
connKey
.
connType
])(
&
pOneReq
->
connKey
,
&
pOneReq
->
clusterId
,
pOneReq
);
if
(
code
)
{
pIter
=
taosHashIterate
(
pAppHbMgr
->
activeInfo
,
pIter
);
pOneReq
=
pIter
;
continue
;
}
// hbClearClientHbReq(pOneReq);
pIter
=
taosHashIterate
(
pAppHbMgr
->
activeInfo
,
pIter
);
pOneReq
=
pIter
;
}
// if (code) {
// taosArrayDestroyEx(pBatchReq->reqs, hbFreeReq);
// taosMemoryFreeClear(pBatchReq);
// }
releaseTscObj
(
rid
);
return
pBatchReq
;
}
...
...
source/libs/transport/src/thttp.c
浏览文件 @
73cd9da8
...
...
@@ -146,7 +146,7 @@ static FORCE_INLINE void clientRecvCb(uv_stream_t* handle, ssize_t nread, const
if
(
nread
<
0
)
{
uError
(
"http-report recv error:%s"
,
uv_err_name
(
nread
));
}
else
{
uTrace
(
"http-report succ to recv %d bytes
, just ignore it
"
,
nread
);
uTrace
(
"http-report succ to recv %d bytes"
,
nread
);
}
uv_close
((
uv_handle_t
*
)
&
cli
->
tcp
,
clientCloseCb
);
}
...
...
@@ -160,7 +160,16 @@ static void clientSentCb(uv_write_t* req, int32_t status) {
}
else
{
uTrace
(
"http-report succ to send data"
);
}
uv_read_start
((
uv_stream_t
*
)
&
cli
->
tcp
,
clientAllocBuffCb
,
clientRecvCb
);
status
=
uv_read_start
((
uv_stream_t
*
)
&
cli
->
tcp
,
clientAllocBuffCb
,
clientRecvCb
);
if
(
status
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
status
);
uError
(
"http-report failed to recv data,reason:%s, dst:%s:%d"
,
uv_strerror
(
status
),
cli
->
addr
,
cli
->
port
);
if
(
!
uv_is_closing
((
uv_handle_t
*
)
&
cli
->
tcp
))
{
uv_close
((
uv_handle_t
*
)
&
cli
->
tcp
,
clientCloseCb
);
}
else
{
destroyHttpClient
(
cli
);
}
}
}
static
void
clientConnCb
(
uv_connect_t
*
req
,
int32_t
status
)
{
SHttpClient
*
cli
=
req
->
data
;
...
...
@@ -170,7 +179,16 @@ static void clientConnCb(uv_connect_t* req, int32_t status) {
uv_close
((
uv_handle_t
*
)
&
cli
->
tcp
,
clientCloseCb
);
return
;
}
uv_write
(
&
cli
->
req
,
(
uv_stream_t
*
)
&
cli
->
tcp
,
cli
->
wbuf
,
2
,
clientSentCb
);
status
=
uv_write
(
&
cli
->
req
,
(
uv_stream_t
*
)
&
cli
->
tcp
,
cli
->
wbuf
,
2
,
clientSentCb
);
if
(
0
!=
status
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
status
);
uError
(
"http-report failed to send data,reason:%s, dst:%s:%d"
,
uv_strerror
(
status
),
cli
->
addr
,
cli
->
port
);
if
(
!
uv_is_closing
((
uv_handle_t
*
)
&
cli
->
tcp
))
{
uv_close
((
uv_handle_t
*
)
&
cli
->
tcp
,
clientCloseCb
);
}
else
{
destroyHttpClient
(
cli
);
}
}
}
static
FORCE_INLINE
int32_t
taosBuildDstAddr
(
const
char
*
server
,
uint16_t
port
,
struct
sockaddr_in
*
dest
)
{
...
...
@@ -220,13 +238,22 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, char* pCont, int32
uv_tcp_init
(
loop
,
&
cli
->
tcp
);
// set up timeout to avoid stuck;
int32_t
fd
=
taosCreateSocketWithTimeout
(
5
);
uv_tcp_open
((
uv_tcp_t
*
)
&
cli
->
tcp
,
fd
);
int
32_t
ret
=
uv_tcp_connect
(
&
cli
->
conn
,
&
cli
->
tcp
,
(
const
struct
sockaddr
*
)
&
dest
,
clientConnCb
);
int
ret
=
uv_tcp_open
((
uv_tcp_t
*
)
&
cli
->
tcp
,
fd
);
if
(
ret
!=
0
)
{
uError
(
"http-report failed to
connect to server
, reason:%s, dst:%s:%d"
,
uv_strerror
(
ret
),
cli
->
addr
,
cli
->
port
);
uError
(
"http-report failed to
open socket
, reason:%s, dst:%s:%d"
,
uv_strerror
(
ret
),
cli
->
addr
,
cli
->
port
);
destroyHttpClient
(
cli
);
uv_stop
(
loop
);
terrno
=
TAOS_SYSTEM_ERROR
(
ret
);
}
else
{
ret
=
uv_tcp_connect
(
&
cli
->
conn
,
&
cli
->
tcp
,
(
const
struct
sockaddr
*
)
&
dest
,
clientConnCb
);
if
(
ret
!=
0
)
{
uError
(
"http-report failed to connect to http-server, reason:%s, dst:%s:%d"
,
uv_strerror
(
ret
),
cli
->
addr
,
cli
->
port
);
destroyHttpClient
(
cli
);
uv_stop
(
loop
);
terrno
=
TAOS_SYSTEM_ERROR
(
ret
);
}
}
uv_run
(
loop
,
UV_RUN_DEFAULT
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录