Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
43124401
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看板
提交
43124401
编写于
2月 28, 2023
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: invalid read memory issue
上级
0c730ec4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
13 deletion
+24
-13
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+2
-1
source/client/src/clientHb.c
source/client/src/clientHb.c
+22
-12
未找到文件。
source/client/inc/clientInt.h
浏览文件 @
43124401
...
...
@@ -66,7 +66,8 @@ enum {
typedef
struct
SAppInstInfo
SAppInstInfo
;
typedef
struct
{
char
*
key
;
char
*
key
;
int32_t
idx
;
// statistics
int32_t
reportCnt
;
int32_t
connKeyCnt
;
...
...
source/client/src/clientHb.c
浏览文件 @
43124401
...
...
@@ -303,8 +303,12 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
}
static
int32_t
hbAsyncCallBack
(
void
*
param
,
SDataBuf
*
pMsg
,
int32_t
code
)
{
if
(
0
==
atomic_load_8
(
&
clientHbMgr
.
inited
))
{
goto
_return
;
}
static
int32_t
emptyRspNum
=
0
;
char
*
key
=
(
char
*
)
param
;
int32_t
idx
=
*
(
int32_t
*
)
param
;
SClientHbBatchRsp
pRsp
=
{
0
};
if
(
TSDB_CODE_SUCCESS
==
code
)
{
tDeserializeSClientHbBatchRsp
(
pMsg
->
pData
,
pMsg
->
len
,
&
pRsp
);
...
...
@@ -319,22 +323,24 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
int32_t
rspNum
=
taosArrayGetSize
(
pRsp
.
rsps
);
taosThreadMutexLock
(
&
appInfo
.
mutex
);
taosThreadMutexLock
(
&
clientHbMgr
.
lock
);
SApp
InstInfo
**
pInst
=
taosHashGet
(
appInfo
.
pInstMap
,
key
,
strlen
(
key
)
);
if
(
p
Inst
==
NULL
||
NULL
==
*
pInst
)
{
taosThreadMutexUnlock
(
&
appInfo
.
mutex
);
tscError
(
"
cluster not exist, key:%s"
,
key
);
SApp
HbMgr
*
pAppHbMgr
=
taosArrayGetP
(
clientHbMgr
.
appHbMgrs
,
idx
);
if
(
p
AppHbMgr
==
NULL
)
{
taosThreadMutexUnlock
(
&
clientHbMgr
.
lock
);
tscError
(
"
appHbMgr not exist, idx:%d"
,
idx
);
taosMemoryFree
(
pMsg
->
pData
);
taosMemoryFree
(
pMsg
->
pEpSet
);
tFreeClientHbBatchRsp
(
&
pRsp
);
return
-
1
;
}
SAppInstInfo
*
pInst
=
pAppHbMgr
->
pAppInstInfo
;
if
(
code
!=
0
)
{
(
*
pInst
)
->
onlineDnodes
=
((
*
pInst
)
->
totalDnodes
?
0
:
-
1
)
;
tscDebug
(
"hb rsp error %s, update server status %d/%d"
,
tstrerror
(
code
),
(
*
pInst
)
->
onlineDnodes
,
(
*
pInst
)
->
totalDnodes
);
pInst
->
onlineDnodes
=
pInst
->
totalDnodes
?
0
:
-
1
;
tscDebug
(
"hb rsp error %s, update server status %d/%d"
,
tstrerror
(
code
),
pInst
->
onlineDnodes
,
pInst
->
totalDnodes
);
}
if
(
rspNum
)
{
...
...
@@ -346,15 +352,17 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
for
(
int32_t
i
=
0
;
i
<
rspNum
;
++
i
)
{
SClientHbRsp
*
rsp
=
taosArrayGet
(
pRsp
.
rsps
,
i
);
code
=
(
*
clientHbMgr
.
rspHandle
[
rsp
->
connKey
.
connType
])(
(
*
pInst
)
->
pAppHbMgr
,
rsp
);
code
=
(
*
clientHbMgr
.
rspHandle
[
rsp
->
connKey
.
connType
])(
pAppHbMgr
,
rsp
);
if
(
code
)
{
break
;
}
}
taosThreadMutexUnlock
(
&
appInfo
.
mutex
);
taosThreadMutexUnlock
(
&
clientHbMgr
.
lock
);
tFreeClientHbBatchRsp
(
&
pRsp
);
_return:
taosMemoryFree
(
pMsg
->
pData
);
taosMemoryFree
(
pMsg
->
pEpSet
);
return
code
;
...
...
@@ -788,7 +796,8 @@ static void *hbThreadFunc(void *param) {
pInfo
->
msgInfo
.
pData
=
buf
;
pInfo
->
msgInfo
.
len
=
tlen
;
pInfo
->
msgType
=
TDMT_MND_HEARTBEAT
;
pInfo
->
param
=
taosStrdup
(
pAppHbMgr
->
key
);
pInfo
->
param
=
taosMemoryMalloc
(
sizeof
(
int32_t
));
*
(
int32_t
*
)
pInfo
->
param
=
i
;
pInfo
->
paramFreeFp
=
taosMemoryFree
;
pInfo
->
requestId
=
generateRequestId
();
pInfo
->
requestObjRefId
=
0
;
...
...
@@ -874,6 +883,7 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) {
taosThreadMutexLock
(
&
clientHbMgr
.
lock
);
taosArrayPush
(
clientHbMgr
.
appHbMgrs
,
&
pAppHbMgr
);
pAppHbMgr
->
idx
=
taosArrayGetSize
(
clientHbMgr
.
appHbMgrs
)
-
1
;
taosThreadMutexUnlock
(
&
clientHbMgr
.
lock
);
return
pAppHbMgr
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录