Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
79963b9c
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看板
提交
79963b9c
编写于
4月 06, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename node type
上级
c5348920
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
78 addition
and
67 deletion
+78
-67
source/dnode/mgmt/dm/dmHandle.c
source/dnode/mgmt/dm/dmHandle.c
+2
-2
source/dnode/mgmt/exe/dndMain.c
source/dnode/mgmt/exe/dndMain.c
+9
-9
source/dnode/mgmt/inc/dndInt.h
source/dnode/mgmt/inc/dndInt.h
+6
-6
source/dnode/mgmt/main/dndEnv.c
source/dnode/mgmt/main/dndEnv.c
+2
-2
source/dnode/mgmt/main/dndExec.c
source/dnode/mgmt/main/dndExec.c
+8
-8
source/dnode/mgmt/main/dndFile.c
source/dnode/mgmt/main/dndFile.c
+3
-3
source/dnode/mgmt/main/dndInt.c
source/dnode/mgmt/main/dndInt.c
+4
-4
source/dnode/mgmt/main/dndTransport.c
source/dnode/mgmt/main/dndTransport.c
+1
-1
source/util/src/tprocess.c
source/util/src/tprocess.c
+2
-1
source/util/test/procTest.cpp
source/util/test/procTest.cpp
+41
-31
未找到文件。
source/dnode/mgmt/dm/dmHandle.c
浏览文件 @
79963b9c
...
...
@@ -118,7 +118,7 @@ int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
}
static
int32_t
dmProcessCreateNodeMsg
(
SDnode
*
pDnode
,
E
Node
Type
ntype
,
SNodeMsg
*
pMsg
)
{
static
int32_t
dmProcessCreateNodeMsg
(
SDnode
*
pDnode
,
E
Dnd
Type
ntype
,
SNodeMsg
*
pMsg
)
{
SMgmtWrapper
*
pWrapper
=
dndAcquireWrapper
(
pDnode
,
ntype
);
if
(
pWrapper
!=
NULL
)
{
dndReleaseWrapper
(
pWrapper
);
...
...
@@ -146,7 +146,7 @@ static int32_t dmProcessCreateNodeMsg(SDnode *pDnode, ENodeType ntype, SNodeMsg
return
code
;
}
static
int32_t
dmProcessDropNodeMsg
(
SDnode
*
pDnode
,
E
Node
Type
ntype
,
SNodeMsg
*
pMsg
)
{
static
int32_t
dmProcessDropNodeMsg
(
SDnode
*
pDnode
,
E
Dnd
Type
ntype
,
SNodeMsg
*
pMsg
)
{
SMgmtWrapper
*
pWrapper
=
dndAcquireWrapper
(
pDnode
,
ntype
);
if
(
pWrapper
==
NULL
)
{
terrno
=
TSDB_CODE_NODE_NOT_DEPLOYED
;
...
...
source/dnode/mgmt/exe/dndMain.c
浏览文件 @
79963b9c
...
...
@@ -18,15 +18,15 @@
#include "tconfig.h"
static
struct
{
bool
dumpConfig
;
bool
generateGrant
;
bool
printAuth
;
bool
printVersion
;
char
envFile
[
PATH_MAX
];
char
apolloUrl
[
PATH_MAX
];
SArray
*
pArgs
;
// SConfigPair
SDnode
*
pDnode
;
E
Node
Type
ntype
;
bool
dumpConfig
;
bool
generateGrant
;
bool
printAuth
;
bool
printVersion
;
char
envFile
[
PATH_MAX
];
char
apolloUrl
[
PATH_MAX
];
SArray
*
pArgs
;
// SConfigPair
SDnode
*
pDnode
;
E
Dnd
Type
ntype
;
}
global
=
{
0
};
static
void
dndStopDnode
(
int
signum
,
void
*
info
,
void
*
ctx
)
{
...
...
source/dnode/mgmt/inc/dndInt.h
浏览文件 @
79963b9c
...
...
@@ -49,7 +49,7 @@ extern "C" {
#define dDebug(...) { if (dDebugFlag & DEBUG_DEBUG) { taosPrintLog("DND ", DEBUG_DEBUG, dDebugFlag, __VA_ARGS__); }}
#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", DEBUG_TRACE, dDebugFlag, __VA_ARGS__); }}
typedef
enum
{
DNODE
,
VNODES
,
QNODE
,
SNODE
,
MNODE
,
BNODE
,
NODE_MAX
}
E
Node
Type
;
typedef
enum
{
DNODE
,
VNODES
,
QNODE
,
SNODE
,
MNODE
,
BNODE
,
NODE_MAX
}
E
Dnd
Type
;
typedef
enum
{
DND_STAT_INIT
,
DND_STAT_RUNNING
,
DND_STAT_STOPPED
}
EDndStatus
;
typedef
enum
{
DND_ENV_INIT
,
DND_ENV_READY
,
DND_ENV_CLEANUP
}
EEnvStatus
;
typedef
enum
{
PROC_SINGLE
,
PROC_CHILD
,
PROC_PARENT
}
EProcType
;
...
...
@@ -92,7 +92,7 @@ typedef struct SMgmtWrapper {
char
*
path
;
int32_t
refCount
;
SRWLatch
latch
;
E
NodeType
ntype
;
E
DndType
ntype
;
bool
deployed
;
bool
required
;
EProcType
procType
;
...
...
@@ -126,7 +126,7 @@ typedef struct SDnode {
int32_t
numOfDisks
;
uint16_t
serverPort
;
bool
dropped
;
E
NodeType
ntype
;
E
DndType
ntype
;
EDndStatus
status
;
EDndEvent
event
;
SStartupReq
startup
;
...
...
@@ -137,8 +137,8 @@ typedef struct SDnode {
// dndEnv.c
const
char
*
dndStatStr
(
EDndStatus
stat
);
const
char
*
dndNodeLogStr
(
E
Node
Type
ntype
);
const
char
*
dndNodeProcStr
(
E
Node
Type
ntype
);
const
char
*
dndNodeLogStr
(
E
Dnd
Type
ntype
);
const
char
*
dndNodeProcStr
(
E
Dnd
Type
ntype
);
const
char
*
dndEventStr
(
EDndEvent
ev
);
// dndExec.c
...
...
@@ -156,7 +156,7 @@ int32_t dndWriteShmFile(SDnode *pDnode);
EDndStatus
dndGetStatus
(
SDnode
*
pDnode
);
void
dndSetStatus
(
SDnode
*
pDnode
,
EDndStatus
stat
);
void
dndSetMsgHandle
(
SMgmtWrapper
*
pWrapper
,
tmsg_t
msgType
,
NodeMsgFp
nodeMsgFp
,
int8_t
vgId
);
SMgmtWrapper
*
dndAcquireWrapper
(
SDnode
*
pDnode
,
E
NodeType
node
Type
);
SMgmtWrapper
*
dndAcquireWrapper
(
SDnode
*
pDnode
,
E
DndType
n
Type
);
int32_t
dndMarkWrapper
(
SMgmtWrapper
*
pWrapper
);
void
dndReleaseWrapper
(
SMgmtWrapper
*
pWrapper
);
void
dndHandleEvent
(
SDnode
*
pDnode
,
EDndEvent
event
);
...
...
source/dnode/mgmt/main/dndEnv.c
浏览文件 @
79963b9c
...
...
@@ -71,7 +71,7 @@ const char *dndStatStr(EDndStatus status) {
}
}
const
char
*
dndNodeLogStr
(
E
Node
Type
ntype
)
{
const
char
*
dndNodeLogStr
(
E
Dnd
Type
ntype
)
{
switch
(
ntype
)
{
case
VNODES
:
return
"vnode"
;
...
...
@@ -88,7 +88,7 @@ const char *dndNodeLogStr(ENodeType ntype) {
}
}
const
char
*
dndNodeProcStr
(
E
Node
Type
ntype
)
{
const
char
*
dndNodeProcStr
(
E
Dnd
Type
ntype
)
{
switch
(
ntype
)
{
case
VNODES
:
return
"taosv"
;
...
...
source/dnode/mgmt/main/dndExec.c
浏览文件 @
79963b9c
...
...
@@ -66,7 +66,7 @@ void dndCloseNode(SMgmtWrapper *pWrapper) {
}
static
int32_t
dndNewProc
(
SMgmtWrapper
*
pWrapper
,
E
Node
Type
n
)
{
static
int32_t
dndNewProc
(
SMgmtWrapper
*
pWrapper
,
E
Dnd
Type
n
)
{
char
tstr
[
8
]
=
{
0
};
char
*
args
[
6
]
=
{
0
};
snprintf
(
tstr
,
sizeof
(
tstr
),
"%d"
,
n
);
...
...
@@ -97,7 +97,7 @@ static void dndProcessProcHandle(void *handle) {
static
int32_t
dndRunInSingleProcess
(
SDnode
*
pDnode
)
{
dInfo
(
"dnode run in single process"
);
for
(
E
Node
Type
n
=
DNODE
;
n
<
NODE_MAX
;
++
n
)
{
for
(
E
Dnd
Type
n
=
DNODE
;
n
<
NODE_MAX
;
++
n
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
pWrapper
->
required
=
dndRequireNode
(
pWrapper
);
if
(
!
pWrapper
->
required
)
continue
;
...
...
@@ -110,7 +110,7 @@ static int32_t dndRunInSingleProcess(SDnode *pDnode) {
dndSetStatus
(
pDnode
,
DND_STAT_RUNNING
);
for
(
E
Node
Type
n
=
0
;
n
<
NODE_MAX
;
++
n
)
{
for
(
E
Dnd
Type
n
=
0
;
n
<
NODE_MAX
;
++
n
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
if
(
!
pWrapper
->
required
)
continue
;
if
(
pWrapper
->
fp
.
startFp
==
NULL
)
continue
;
...
...
@@ -142,7 +142,7 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
return
-
1
;
}
for
(
E
Node
Type
n
=
DNODE
+
1
;
n
<
NODE_MAX
;
++
n
)
{
for
(
E
Dnd
Type
n
=
DNODE
+
1
;
n
<
NODE_MAX
;
++
n
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
pWrapper
->
required
=
dndRequireNode
(
pWrapper
);
if
(
!
pWrapper
->
required
)
continue
;
...
...
@@ -170,7 +170,7 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
return
-
1
;
}
for
(
E
Node
Type
n
=
DNODE
+
1
;
n
<
NODE_MAX
;
++
n
)
{
for
(
E
Dnd
Type
n
=
DNODE
+
1
;
n
<
NODE_MAX
;
++
n
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
if
(
!
pWrapper
->
required
)
continue
;
...
...
@@ -203,7 +203,7 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
dInfo
(
"dnode is about to stop"
);
dndSetStatus
(
pDnode
,
DND_STAT_STOPPED
);
for
(
E
Node
Type
n
=
DNODE
+
1
;
n
<
NODE_MAX
;
++
n
)
{
for
(
E
Dnd
Type
n
=
DNODE
+
1
;
n
<
NODE_MAX
;
++
n
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
if
(
!
pWrapper
->
required
)
continue
;
if
(
pDnode
->
ntype
==
NODE_MAX
)
continue
;
...
...
@@ -218,13 +218,13 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
}
break
;
}
else
{
for
(
E
Node
Type
n
=
DNODE
+
1
;
n
<
NODE_MAX
;
++
n
)
{
for
(
E
Dnd
Type
n
=
DNODE
+
1
;
n
<
NODE_MAX
;
++
n
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
if
(
!
pWrapper
->
required
)
continue
;
if
(
pDnode
->
ntype
==
NODE_MAX
)
continue
;
if
(
pWrapper
->
procId
<=
0
||
!
taosProcExist
(
pWrapper
->
procId
))
{
d
Info
(
"node:%s, process:%d is killed and needs to be restarted"
,
pWrapper
->
name
,
pWrapper
->
procId
);
d
Warn
(
"node:%s, process:%d is killed and needs to be restarted"
,
pWrapper
->
name
,
pWrapper
->
procId
);
taosProcCloseHandles
(
pWrapper
->
pProc
,
dndProcessProcHandle
);
dndNewProc
(
pWrapper
,
n
);
}
...
...
source/dnode/mgmt/main/dndFile.c
浏览文件 @
79963b9c
...
...
@@ -164,7 +164,7 @@ int32_t dndReadShmFile(SDnode *pDnode) {
goto
_OVER
;
}
for
(
E
Node
Type
ntype
=
DNODE
+
1
;
ntype
<
NODE_MAX
;
++
ntype
)
{
for
(
E
Dnd
Type
ntype
=
DNODE
+
1
;
ntype
<
NODE_MAX
;
++
ntype
)
{
snprintf
(
itemName
,
sizeof
(
itemName
),
"%s_shmid"
,
dndNodeProcStr
(
ntype
));
cJSON
*
shmid
=
cJSON_GetObjectItem
(
root
,
itemName
);
if
(
shmid
&&
shmid
->
type
==
cJSON_Number
)
{
...
...
@@ -180,7 +180,7 @@ int32_t dndReadShmFile(SDnode *pDnode) {
}
if
(
!
tsMultiProcess
||
pDnode
->
ntype
==
DNODE
||
pDnode
->
ntype
==
NODE_MAX
)
{
for
(
E
Node
Type
ntype
=
DNODE
;
ntype
<
NODE_MAX
;
++
ntype
)
{
for
(
E
Dnd
Type
ntype
=
DNODE
;
ntype
<
NODE_MAX
;
++
ntype
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
ntype
];
if
(
pWrapper
->
shm
.
id
>=
0
)
{
dDebug
(
"shmid:%d, is closed, size:%d"
,
pWrapper
->
shm
.
id
,
pWrapper
->
shm
.
size
);
...
...
@@ -226,7 +226,7 @@ int32_t dndWriteShmFile(SDnode *pDnode) {
}
len
+=
snprintf
(
content
+
len
,
MAXLEN
-
len
,
"{
\n
"
);
for
(
E
Node
Type
ntype
=
DNODE
+
1
;
ntype
<
NODE_MAX
;
++
ntype
)
{
for
(
E
Dnd
Type
ntype
=
DNODE
+
1
;
ntype
<
NODE_MAX
;
++
ntype
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
ntype
];
len
+=
snprintf
(
content
+
len
,
MAXLEN
-
len
,
"
\"
%s_shmid
\"
:%d,
\n
"
,
dndNodeProcStr
(
ntype
),
pWrapper
->
shm
.
id
);
if
(
ntype
==
NODE_MAX
-
1
)
{
...
...
source/dnode/mgmt/main/dndInt.c
浏览文件 @
79963b9c
...
...
@@ -46,7 +46,7 @@ static int32_t dndInitVars(SDnode *pDnode, const SDnodeOpt *pOption) {
}
static
void
dndClearVars
(
SDnode
*
pDnode
)
{
for
(
E
Node
Type
n
=
0
;
n
<
NODE_MAX
;
++
n
)
{
for
(
E
Dnd
Type
n
=
0
;
n
<
NODE_MAX
;
++
n
)
{
SMgmtWrapper
*
pMgmt
=
&
pDnode
->
wrappers
[
n
];
taosMemoryFreeClear
(
pMgmt
->
path
);
}
...
...
@@ -89,7 +89,7 @@ SDnode *dndCreate(const SDnodeOpt *pOption) {
smSetMgmtFp
(
&
pDnode
->
wrappers
[
SNODE
]);
bmSetMgmtFp
(
&
pDnode
->
wrappers
[
BNODE
]);
for
(
E
Node
Type
n
=
0
;
n
<
NODE_MAX
;
++
n
)
{
for
(
E
Dnd
Type
n
=
0
;
n
<
NODE_MAX
;
++
n
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
snprintf
(
path
,
sizeof
(
path
),
"%s%s%s"
,
pDnode
->
dataDir
,
TD_DIRSEP
,
pWrapper
->
name
);
pWrapper
->
path
=
strdup
(
path
);
...
...
@@ -134,7 +134,7 @@ _OVER:
void
dndClose
(
SDnode
*
pDnode
)
{
if
(
pDnode
==
NULL
)
return
;
for
(
E
Node
Type
n
=
0
;
n
<
NODE_MAX
;
++
n
)
{
for
(
E
Dnd
Type
n
=
0
;
n
<
NODE_MAX
;
++
n
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
dndCloseNode
(
pWrapper
);
}
...
...
@@ -149,7 +149,7 @@ void dndHandleEvent(SDnode *pDnode, EDndEvent event) {
}
}
SMgmtWrapper
*
dndAcquireWrapper
(
SDnode
*
pDnode
,
E
Node
Type
ntype
)
{
SMgmtWrapper
*
dndAcquireWrapper
(
SDnode
*
pDnode
,
E
Dnd
Type
ntype
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
ntype
];
SMgmtWrapper
*
pRetWrapper
=
pWrapper
;
...
...
source/dnode/mgmt/main/dndTransport.c
浏览文件 @
79963b9c
...
...
@@ -307,7 +307,7 @@ void dndCleanupTrans(SDnode *pDnode) {
int32_t
dndInitMsgHandle
(
SDnode
*
pDnode
)
{
STransMgmt
*
pMgmt
=
&
pDnode
->
trans
;
for
(
E
Node
Type
n
=
0
;
n
<
NODE_MAX
;
++
n
)
{
for
(
E
Dnd
Type
n
=
0
;
n
<
NODE_MAX
;
++
n
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
for
(
int32_t
msgIndex
=
0
;
msgIndex
<
TDMT_MAX
;
++
msgIndex
)
{
...
...
source/util/src/tprocess.c
浏览文件 @
79963b9c
...
...
@@ -478,6 +478,7 @@ void taosProcCloseHandles(SProcObj *pProc, void (*HandleFp)(void *handle)) {
(
*
HandleFp
)(
handle
);
h
=
taosHashIterate
(
pProc
->
hash
,
h
);
}
taosHashClear
(
pProc
->
hash
);
taosThreadMutexUnlock
(
&
pProc
->
pChildQueue
->
mutex
);
}
...
...
@@ -485,7 +486,7 @@ void taosProcPutToParentQ(SProcObj *pProc, const void *pHead, int16_t headLen, c
ProcFuncType
ftype
)
{
int32_t
retry
=
0
;
while
(
taosProcQueuePush
(
pProc
,
pProc
->
pParentQueue
,
pHead
,
headLen
,
pBody
,
bodyLen
,
0
,
ftype
)
!=
0
)
{
u
Info
(
"proc:%s, failed to put to queue:%p since %s, retry:%d"
,
pProc
->
name
,
pProc
->
pParentQueue
,
terrstr
(),
retry
);
u
Warn
(
"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
浏览文件 @
79963b9c
...
...
@@ -10,10 +10,20 @@
*/
#include <gtest/gtest.h>
#include "tlog.h"
#include "tprocess.h"
#include "tqueue.h"
#include "trpc.h"
#include "tlog.h"
typedef
struct
STestMsg
{
uint16_t
msgType
;
void
*
pCont
;
int
contLen
;
int32_t
code
;
void
*
handle
;
// rpc handle returned to app
void
*
ahandle
;
// app handle set by client
int
noResp
;
// has response or not(default 0, 0: resp, 1: no resp);
int
persistHandle
;
// persist handle or not
}
STestMsg
;
class
UtilTesProc
:
public
::
testing
::
Test
{
public:
...
...
@@ -38,7 +48,7 @@ class UtilTesProc : public ::testing::Test {
void
TearDown
()
override
{
taosDropShm
(
&
shm
);
}
public:
static
S
RpcMsg
head
;
static
S
TestMsg
head
;
static
char
body
[
4000
];
static
SShm
shm
;
static
void
SetUpTestSuite
()
{}
...
...
@@ -47,7 +57,7 @@ class UtilTesProc : public ::testing::Test {
SShm
UtilTesProc
::
shm
;
char
UtilTesProc
::
body
[
4000
];
S
RpcMsg
UtilTesProc
::
head
;
S
TestMsg
UtilTesProc
::
head
;
TEST_F
(
UtilTesProc
,
00
_Init_Cleanup
)
{
ASSERT_EQ
(
taosCreateShm
(
&
shm
,
1234
,
1024
*
1024
*
2
),
0
);
...
...
@@ -56,13 +66,13 @@ TEST_F(UtilTesProc, 00_Init_Cleanup) {
SProcCfg
cfg
=
{.
childConsumeFp
=
(
ProcConsumeFp
)
NULL
,
.
childMallocHeadFp
=
(
ProcMallocFp
)
taosAllocateQitem
,
.
childFreeHeadFp
=
(
ProcFreeFp
)
taosFreeQitem
,
.
childMallocBodyFp
=
(
ProcMallocFp
)
rpcMallocCont
,
.
childFreeBodyFp
=
(
ProcFreeFp
)
rpcFreeCont
,
.
childMallocBodyFp
=
(
ProcMallocFp
)
taosMemoryMalloc
,
.
childFreeBodyFp
=
(
ProcFreeFp
)
taosMemoryMalloc
,
.
parentConsumeFp
=
(
ProcConsumeFp
)
NULL
,
.
parentMallocHeadFp
=
(
ProcMallocFp
)
taosMemoryMalloc
,
.
parentFreeHeadFp
=
(
ProcFreeFp
)
taosMemoryFree
,
.
parentMallocBodyFp
=
(
ProcMallocFp
)
rpcMallocCont
,
.
parentFreeBodyFp
=
(
ProcFreeFp
)
rpcFreeCont
,
.
parentMallocBodyFp
=
(
ProcMallocFp
)
taosMemoryMalloc
,
.
parentFreeBodyFp
=
(
ProcFreeFp
)
taosMemoryMalloc
,
.
shm
=
shm
,
.
parent
=
&
shm
,
.
name
=
"1234"
};
...
...
@@ -80,14 +90,14 @@ TEST_F(UtilTesProc, 00_Init_Cleanup) {
}
void
ConsumeChild1
(
void
*
parent
,
void
*
pHead
,
int16_t
headLen
,
void
*
pBody
,
int32_t
bodyLen
,
ProcFuncType
ftype
)
{
S
Rpc
Msg
msg
;
S
Test
Msg
msg
;
memcpy
(
&
msg
,
pHead
,
headLen
);
char
body
[
2000
]
=
{
0
};
memcpy
(
body
,
pBody
,
bodyLen
);
uDebug
(
"====> parent:%"
PRId64
" ftype:%d, headLen:%d bodyLen:%d head:%d:%d:%d:%d body:%s <===="
,
(
int64_t
)
parent
,
ftype
,
headLen
,
bodyLen
,
msg
.
code
,
msg
.
msgType
,
msg
.
noResp
,
msg
.
persistHandle
,
body
);
rpcFreeCont
(
pBody
);
taosMemoryFree
(
pBody
);
taosFreeQitem
(
pHead
);
}
...
...
@@ -97,13 +107,13 @@ TEST_F(UtilTesProc, 01_Push_Pop_Child) {
SProcCfg
cfg
=
{.
childConsumeFp
=
(
ProcConsumeFp
)
ConsumeChild1
,
.
childMallocHeadFp
=
(
ProcMallocFp
)
taosAllocateQitem
,
.
childFreeHeadFp
=
(
ProcFreeFp
)
taosFreeQitem
,
.
childMallocBodyFp
=
(
ProcMallocFp
)
rpcMallocCont
,
.
childFreeBodyFp
=
(
ProcFreeFp
)
rpcFreeCont
,
.
childMallocBodyFp
=
(
ProcMallocFp
)
taosMemoryMalloc
,
.
childFreeBodyFp
=
(
ProcFreeFp
)
taosMemoryFree
,
.
parentConsumeFp
=
(
ProcConsumeFp
)
NULL
,
.
parentMallocHeadFp
=
(
ProcMallocFp
)
taosMemoryMalloc
,
.
parentFreeHeadFp
=
(
ProcFreeFp
)
taosMemoryFree
,
.
parentMallocBodyFp
=
(
ProcMallocFp
)
rpcMallocCont
,
.
parentFreeBodyFp
=
(
ProcFreeFp
)
rpcFreeCont
,
.
parentMallocBodyFp
=
(
ProcMallocFp
)
taosMemoryMalloc
,
.
parentFreeBodyFp
=
(
ProcFreeFp
)
taosMemoryFree
,
.
shm
=
shm
,
.
parent
=
(
void
*
)((
int64_t
)
1235
),
.
name
=
"1235_c"
};
...
...
@@ -116,14 +126,14 @@ TEST_F(UtilTesProc, 01_Push_Pop_Child) {
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
NULL
,
12
,
body
,
0
,
0
,
PROC_REQ
),
0
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
0
,
body
,
0
,
0
,
PROC_REQ
),
0
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
shm
.
size
,
body
,
0
,
0
,
PROC_REQ
),
0
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
sizeof
(
S
Rpc
Msg
),
body
,
shm
.
size
,
0
,
PROC_REQ
),
0
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
sizeof
(
S
Test
Msg
),
body
,
shm
.
size
,
0
,
PROC_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
(
S
Rpc
Msg
),
body
,
i
,
0
,
PROC_REQ
),
0
);
ASSERT_EQ
(
taosProcPutToChildQ
(
cproc
,
&
head
,
sizeof
(
S
Test
Msg
),
body
,
i
,
0
,
PROC_REQ
),
0
);
}
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
sizeof
(
S
Rpc
Msg
),
body
,
i
,
0
,
PROC_REQ
),
0
);
ASSERT_NE
(
taosProcPutToChildQ
(
cproc
,
&
head
,
sizeof
(
S
Test
Msg
),
body
,
i
,
0
,
PROC_REQ
),
0
);
cfg
.
isChild
=
true
;
cfg
.
name
=
"1235_p"
;
...
...
@@ -138,14 +148,14 @@ TEST_F(UtilTesProc, 01_Push_Pop_Child) {
}
void
ConsumeParent1
(
void
*
parent
,
void
*
pHead
,
int16_t
headLen
,
void
*
pBody
,
int32_t
bodyLen
,
ProcFuncType
ftype
)
{
S
Rpc
Msg
msg
;
S
Test
Msg
msg
;
memcpy
(
&
msg
,
pHead
,
headLen
);
char
body
[
2000
]
=
{
0
};
memcpy
(
body
,
pBody
,
bodyLen
);
uDebug
(
"----> parent:%"
PRId64
" ftype:%d, headLen:%d bodyLen:%d head:%d:%d:%d:%d body:%s <----"
,
(
int64_t
)
parent
,
ftype
,
headLen
,
bodyLen
,
msg
.
code
,
msg
.
msgType
,
msg
.
noResp
,
msg
.
persistHandle
,
body
);
rpcFreeCont
(
pBody
);
taosMemoryFree
(
pBody
);
taosMemoryFree
(
pHead
);
}
...
...
@@ -155,13 +165,13 @@ TEST_F(UtilTesProc, 02_Push_Pop_Parent) {
SProcCfg
cfg
=
{.
childConsumeFp
=
(
ProcConsumeFp
)
NULL
,
.
childMallocHeadFp
=
(
ProcMallocFp
)
taosAllocateQitem
,
.
childFreeHeadFp
=
(
ProcFreeFp
)
taosFreeQitem
,
.
childMallocBodyFp
=
(
ProcMallocFp
)
rpcMallocCont
,
.
childFreeBodyFp
=
(
ProcFreeFp
)
rpcFreeCont
,
.
childMallocBodyFp
=
(
ProcMallocFp
)
taosMemoryMalloc
,
.
childFreeBodyFp
=
(
ProcFreeFp
)
taosMemoryFree
,
.
parentConsumeFp
=
(
ProcConsumeFp
)
ConsumeParent1
,
.
parentMallocHeadFp
=
(
ProcMallocFp
)
taosMemoryMalloc
,
.
parentFreeHeadFp
=
(
ProcFreeFp
)
taosMemoryFree
,
.
parentMallocBodyFp
=
(
ProcMallocFp
)
rpcMallocCont
,
.
parentFreeBodyFp
=
(
ProcFreeFp
)
rpcFreeCont
,
.
parentMallocBodyFp
=
(
ProcMallocFp
)
taosMemoryMalloc
,
.
parentFreeBodyFp
=
(
ProcFreeFp
)
taosMemoryFree
,
.
shm
=
shm
,
.
parent
=
(
void
*
)((
int64_t
)
1236
),
.
name
=
"1236_c"
};
...
...
@@ -176,7 +186,7 @@ TEST_F(UtilTesProc, 02_Push_Pop_Parent) {
for
(
int32_t
j
=
0
;
j
<
1000
;
j
++
)
{
int32_t
i
=
0
;
for
(
i
=
0
;
i
<
20
;
++
i
)
{
taosProcPutToParentQ
(
pproc
,
&
head
,
sizeof
(
S
Rpc
Msg
),
body
,
i
,
PROC_REQ
);
taosProcPutToParentQ
(
pproc
,
&
head
,
sizeof
(
S
Test
Msg
),
body
,
i
,
PROC_REQ
);
}
taosProcRun
(
cproc
);
...
...
@@ -189,14 +199,14 @@ TEST_F(UtilTesProc, 02_Push_Pop_Parent) {
}
void
ConsumeChild3
(
void
*
parent
,
void
*
pHead
,
int16_t
headLen
,
void
*
pBody
,
int32_t
bodyLen
,
ProcFuncType
ftype
)
{
S
Rpc
Msg
msg
;
S
Test
Msg
msg
;
memcpy
(
&
msg
,
pHead
,
headLen
);
char
body
[
2000
]
=
{
0
};
memcpy
(
body
,
pBody
,
bodyLen
);
uDebug
(
"====> parent:%"
PRId64
" ftype:%d, headLen:%d bodyLen:%d handle:%"
PRId64
" body:%s <===="
,
(
int64_t
)
parent
,
ftype
,
headLen
,
bodyLen
,
(
int64_t
)
msg
.
handle
,
body
);
rpcFreeCont
(
pBody
);
taosMemoryFree
(
pBody
);
taosFreeQitem
(
pHead
);
}
...
...
@@ -209,13 +219,13 @@ TEST_F(UtilTesProc, 03_Handle) {
SProcCfg
cfg
=
{.
childConsumeFp
=
(
ProcConsumeFp
)
ConsumeChild3
,
.
childMallocHeadFp
=
(
ProcMallocFp
)
taosAllocateQitem
,
.
childFreeHeadFp
=
(
ProcFreeFp
)
taosFreeQitem
,
.
childMallocBodyFp
=
(
ProcMallocFp
)
rpcMallocCont
,
.
childFreeBodyFp
=
(
ProcFreeFp
)
rpcFreeCont
,
.
childMallocBodyFp
=
(
ProcMallocFp
)
taosMemoryMalloc
,
.
childFreeBodyFp
=
(
ProcFreeFp
)
taosMemoryFree
,
.
parentConsumeFp
=
(
ProcConsumeFp
)
NULL
,
.
parentMallocHeadFp
=
(
ProcMallocFp
)
taosMemoryMalloc
,
.
parentFreeHeadFp
=
(
ProcFreeFp
)
taosMemoryFree
,
.
parentMallocBodyFp
=
(
ProcMallocFp
)
rpcMallocCont
,
.
parentFreeBodyFp
=
(
ProcFreeFp
)
rpcFreeCont
,
.
parentMallocBodyFp
=
(
ProcMallocFp
)
taosMemoryMalloc
,
.
parentFreeBodyFp
=
(
ProcFreeFp
)
taosMemoryFree
,
.
shm
=
shm
,
.
parent
=
(
void
*
)((
int64_t
)
1235
),
.
name
=
"1237_p"
};
...
...
@@ -226,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
(
S
Rpc
Msg
),
body
,
i
,
(
void
*
)((
int64_t
)
i
),
PROC_REQ
),
0
);
ASSERT_EQ
(
taosProcPutToChildQ
(
cproc
,
&
head
,
sizeof
(
S
Test
Msg
),
body
,
i
,
(
void
*
)((
int64_t
)
i
),
PROC_REQ
),
0
);
}
cfg
.
isChild
=
true
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录