Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5e7da351
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看板
提交
5e7da351
编写于
4月 24, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(cluster): add refid in rpc, and handle it in multi-process mode
上级
fcd0d272
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
37 addition
and
25 deletion
+37
-25
include/util/tprocess.h
include/util/tprocess.h
+2
-2
source/dnode/mgmt/implement/src/dmTransport.c
source/dnode/mgmt/implement/src/dmTransport.c
+2
-2
source/util/src/tprocess.c
source/util/src/tprocess.c
+15
-8
source/util/test/procTest.cpp
source/util/test/procTest.cpp
+18
-13
未找到文件。
include/util/tprocess.h
浏览文件 @
5e7da351
...
...
@@ -53,8 +53,8 @@ int32_t taosProcRun(SProcObj *pProc);
void
taosProcStop
(
SProcObj
*
pProc
);
int32_t
taosProcPutToChildQ
(
SProcObj
*
pProc
,
const
void
*
pHead
,
int16_t
headLen
,
const
void
*
pBody
,
int32_t
bodyLen
,
void
*
handle
,
EProcFuncType
ftype
);
void
taosProcRemoveHandle
(
SProcObj
*
pProc
,
void
*
handle
);
void
*
handle
,
int64_t
handleRef
,
EProcFuncType
ftype
);
int64_t
taosProcRemoveHandle
(
SProcObj
*
pProc
,
void
*
handle
);
void
taosProcCloseHandles
(
SProcObj
*
pProc
,
void
(
*
HandleFp
)(
void
*
handle
));
void
taosProcPutToParentQ
(
SProcObj
*
pProc
,
const
void
*
pHead
,
int16_t
headLen
,
const
void
*
pBody
,
int32_t
bodyLen
,
EProcFuncType
ftype
);
...
...
source/dnode/mgmt/implement/src/dmTransport.c
浏览文件 @
5e7da351
...
...
@@ -88,7 +88,7 @@ static void dmProcessRpcMsg(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, SEpSet *pEpSe
dTrace
(
"msg:%p, is created and put into child queue, type:%s handle:%p user:%s"
,
pMsg
,
TMSG_INFO
(
msgType
),
pRpc
->
handle
,
pMsg
->
user
);
code
=
taosProcPutToChildQ
(
pWrapper
->
procObj
,
pMsg
,
sizeof
(
SNodeMsg
),
pRpc
->
pCont
,
pRpc
->
contLen
,
pRpc
->
handle
,
PROC_FUNC_REQ
);
pRpc
->
refId
,
PROC_FUNC_REQ
);
}
else
{
dTrace
(
"msg:%p, should not processed in child process, handle:%p user:%s"
,
pMsg
,
pRpc
->
handle
,
pMsg
->
user
);
ASSERT
(
1
);
...
...
@@ -356,7 +356,7 @@ static void dmConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t
dmSendRpcReq
(
pWrapper
->
pDnode
,
(
SEpSet
*
)((
char
*
)
pMsg
+
sizeof
(
SRpcMsg
)),
pMsg
);
break
;
case
PROC_FUNC_RSP
:
taosProcRemoveHandle
(
pWrapper
->
procObj
,
pMsg
->
handle
);
pMsg
->
refId
=
taosProcRemoveHandle
(
pWrapper
->
procObj
,
pMsg
->
handle
);
dmSendRpcRsp
(
pWrapper
->
pDnode
,
pMsg
);
break
;
default:
...
...
source/util/src/tprocess.c
浏览文件 @
5e7da351
...
...
@@ -154,7 +154,8 @@ static void taosProcCleanupQueue(SProcQueue *pQueue) {
}
static
int32_t
taosProcQueuePush
(
SProcObj
*
pProc
,
SProcQueue
*
pQueue
,
const
char
*
pHead
,
int16_t
rawHeadLen
,
const
char
*
pBody
,
int32_t
rawBodyLen
,
int64_t
handle
,
EProcFuncType
ftype
)
{
const
char
*
pBody
,
int32_t
rawBodyLen
,
int64_t
handle
,
int64_t
handleRef
,
EProcFuncType
ftype
)
{
if
(
rawHeadLen
==
0
||
pHead
==
NULL
)
{
terrno
=
TSDB_CODE_INVALID_PARA
;
return
-
1
;
...
...
@@ -172,7 +173,7 @@ static int32_t taosProcQueuePush(SProcObj *pProc, SProcQueue *pQueue, const char
}
if
(
handle
!=
0
&&
ftype
==
PROC_FUNC_REQ
)
{
if
(
taosHashPut
(
pProc
->
hash
,
&
handle
,
sizeof
(
int64_t
),
&
handle
,
sizeof
(
int64_t
))
!=
0
)
{
if
(
taosHashPut
(
pProc
->
hash
,
&
handle
,
sizeof
(
int64_t
),
&
handle
Ref
,
sizeof
(
int64_t
))
!=
0
)
{
taosThreadMutexUnlock
(
&
pQueue
->
mutex
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
...
...
@@ -286,13 +287,13 @@ static int32_t taosProcQueuePop(SProcQueue *pQueue, void **ppHead, int16_t *pHea
pQueue
->
head
=
headLen
+
bodyLen
;
}
else
if
(
remain
<
8
+
headLen
)
{
memcpy
(
pHead
,
pQueue
->
pBuffer
+
pQueue
->
head
+
8
,
remain
-
8
);
memcpy
((
char
*
)
pHead
+
remain
-
8
,
pQueue
->
pBuffer
,
headLen
-
(
remain
-
8
));
memcpy
((
char
*
)
pHead
+
remain
-
8
,
pQueue
->
pBuffer
,
headLen
-
(
remain
-
8
));
memcpy
(
pBody
,
pQueue
->
pBuffer
+
headLen
-
(
remain
-
8
),
bodyLen
);
pQueue
->
head
=
headLen
-
(
remain
-
8
)
+
bodyLen
;
}
else
if
(
remain
<
8
+
headLen
+
bodyLen
)
{
memcpy
(
pHead
,
pQueue
->
pBuffer
+
pQueue
->
head
+
8
,
headLen
);
memcpy
(
pBody
,
pQueue
->
pBuffer
+
pQueue
->
head
+
8
+
headLen
,
remain
-
8
-
headLen
);
memcpy
((
char
*
)
pBody
+
remain
-
8
-
headLen
,
pQueue
->
pBuffer
,
bodyLen
-
(
remain
-
8
-
headLen
));
memcpy
((
char
*
)
pBody
+
remain
-
8
-
headLen
,
pQueue
->
pBuffer
,
bodyLen
-
(
remain
-
8
-
headLen
));
pQueue
->
head
=
bodyLen
-
(
remain
-
8
-
headLen
);
}
else
{
memcpy
(
pHead
,
pQueue
->
pBuffer
+
pQueue
->
head
+
8
,
headLen
);
...
...
@@ -454,19 +455,25 @@ void taosProcCleanup(SProcObj *pProc) {
}
int32_t
taosProcPutToChildQ
(
SProcObj
*
pProc
,
const
void
*
pHead
,
int16_t
headLen
,
const
void
*
pBody
,
int32_t
bodyLen
,
void
*
handle
,
EProcFuncType
ftype
)
{
void
*
handle
,
int64_t
handleRef
,
EProcFuncType
ftype
)
{
if
(
ftype
!=
PROC_FUNC_REQ
)
{
terrno
=
TSDB_CODE_INVALID_PARA
;
return
-
1
;
}
return
taosProcQueuePush
(
pProc
,
pProc
->
pChildQueue
,
pHead
,
headLen
,
pBody
,
bodyLen
,
(
int64_t
)
handle
,
ftype
);
return
taosProcQueuePush
(
pProc
,
pProc
->
pChildQueue
,
pHead
,
headLen
,
pBody
,
bodyLen
,
(
int64_t
)
handle
,
handleRef
,
ftype
);
}
void
taosProcRemoveHandle
(
SProcObj
*
pProc
,
void
*
handle
)
{
int64_t
taosProcRemoveHandle
(
SProcObj
*
pProc
,
void
*
handle
)
{
int64_t
h
=
(
int64_t
)
handle
;
taosThreadMutexLock
(
&
pProc
->
pChildQueue
->
mutex
);
int64_t
*
handleRef
=
taosHashGet
(
pProc
->
hash
,
&
h
,
sizeof
(
int64_t
));
taosHashRemove
(
pProc
->
hash
,
&
h
,
sizeof
(
int64_t
));
taosThreadMutexUnlock
(
&
pProc
->
pChildQueue
->
mutex
);
if
(
handleRef
==
NULL
)
return
0
;
return
*
handleRef
;
}
void
taosProcCloseHandles
(
SProcObj
*
pProc
,
void
(
*
HandleFp
)(
void
*
handle
))
{
...
...
@@ -484,7 +491,7 @@ void taosProcCloseHandles(SProcObj *pProc, void (*HandleFp)(void *handle)) {
void
taosProcPutToParentQ
(
SProcObj
*
pProc
,
const
void
*
pHead
,
int16_t
headLen
,
const
void
*
pBody
,
int32_t
bodyLen
,
EProcFuncType
ftype
)
{
int32_t
retry
=
0
;
while
(
taosProcQueuePush
(
pProc
,
pProc
->
pParentQueue
,
pHead
,
headLen
,
pBody
,
bodyLen
,
0
,
ftype
)
!=
0
)
{
while
(
taosProcQueuePush
(
pProc
,
pProc
->
pParentQueue
,
pHead
,
headLen
,
pBody
,
bodyLen
,
0
,
0
,
ftype
)
!=
0
)
{
uWarn
(
"proc:%s, failed to put to queue:%p since %s, retry:%d"
,
pProc
->
name
,
pProc
->
pParentQueue
,
terrstr
(),
retry
);
retry
++
;
taosMsleep
(
retry
);
...
...
source/util/test/procTest.cpp
浏览文件 @
5e7da351
...
...
@@ -120,20 +120,20 @@ TEST_F(UtilTesProc, 01_Push_Pop_Child) {
SProcObj
*
cproc
=
taosProcInit
(
&
cfg
);
ASSERT_NE
(
cproc
,
nullptr
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
0
,
body
,
0
,
0
,
PROC_FUNC_RSP
),
0
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
0
,
body
,
0
,
0
,
PROC_FUNC_REGIST
),
0
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
0
,
body
,
0
,
0
,
PROC_FUNC_RELEASE
),
0
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
NULL
,
12
,
body
,
0
,
0
,
PROC_FUNC_REQ
),
0
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
0
,
body
,
0
,
0
,
PROC_FUNC_REQ
),
0
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
shm
.
size
,
body
,
0
,
0
,
PROC_FUNC_REQ
),
0
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
sizeof
(
STestMsg
),
body
,
shm
.
size
,
0
,
PROC_FUNC_REQ
),
0
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
0
,
body
,
0
,
0
,
0
,
PROC_FUNC_RSP
),
0
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
0
,
body
,
0
,
0
,
0
,
PROC_FUNC_REGIST
),
0
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
0
,
body
,
0
,
0
,
0
,
PROC_FUNC_RELEASE
),
0
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
NULL
,
12
,
body
,
0
,
0
,
0
,
PROC_FUNC_REQ
),
0
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
0
,
body
,
0
,
0
,
0
,
PROC_FUNC_REQ
),
0
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
shm
.
size
,
body
,
0
,
0
,
0
,
PROC_FUNC_REQ
),
0
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
sizeof
(
STestMsg
),
body
,
shm
.
size
,
0
,
0
,
PROC_FUNC_REQ
),
0
);
for
(
int32_t
j
=
0
;
j
<
1000
;
j
++
)
{
int32_t
i
=
0
;
for
(
i
=
0
;
i
<
20
;
++
i
)
{
ASSERT_EQ
(
taosProcPutToChildQ
(
cproc
,
&
head
,
sizeof
(
STestMsg
),
body
,
i
,
0
,
PROC_FUNC_REQ
),
0
);
ASSERT_EQ
(
taosProcPutToChildQ
(
cproc
,
&
head
,
sizeof
(
STestMsg
),
body
,
i
,
0
,
0
,
PROC_FUNC_REQ
),
0
);
}
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
sizeof
(
STestMsg
),
body
,
i
,
0
,
PROC_FUNC_REQ
),
0
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
sizeof
(
STestMsg
),
body
,
i
,
0
,
0
,
PROC_FUNC_REQ
),
0
);
cfg
.
isChild
=
true
;
cfg
.
name
=
"1235_p"
;
...
...
@@ -236,7 +236,7 @@ TEST_F(UtilTesProc, 03_Handle) {
int32_t
i
=
0
;
for
(
i
=
0
;
i
<
20
;
++
i
)
{
head
.
handle
=
(
void
*
)((
int64_t
)
i
);
ASSERT_EQ
(
taosProcPutToChildQ
(
cproc
,
&
head
,
sizeof
(
STestMsg
),
body
,
i
,
(
void
*
)((
int64_t
)
i
),
PROC_FUNC_REQ
),
0
);
ASSERT_EQ
(
taosProcPutToChildQ
(
cproc
,
&
head
,
sizeof
(
STestMsg
),
body
,
i
,
(
void
*
)((
int64_t
)
i
),
i
,
PROC_FUNC_REQ
),
0
);
}
cfg
.
isChild
=
true
;
...
...
@@ -246,9 +246,14 @@ TEST_F(UtilTesProc, 03_Handle) {
taosProcRun
(
pproc
);
taosProcCleanup
(
pproc
);
taosProcRemoveHandle
(
cproc
,
(
void
*
)((
int64_t
)
3
));
taosProcRemoveHandle
(
cproc
,
(
void
*
)((
int64_t
)
5
));
taosProcRemoveHandle
(
cproc
,
(
void
*
)((
int64_t
)
6
));
int64_t
ref
=
0
;
ref
=
taosProcRemoveHandle
(
cproc
,
(
void
*
)((
int64_t
)
3
));
EXPECT_EQ
(
ref
,
3
);
ref
=
taosProcRemoveHandle
(
cproc
,
(
void
*
)((
int64_t
)
5
));
EXPECT_EQ
(
ref
,
5
);
ref
=
taosProcRemoveHandle
(
cproc
,
(
void
*
)((
int64_t
)
6
));
EXPECT_EQ
(
ref
,
6
);
taosProcCloseHandles
(
cproc
,
processHandle
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录