Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f43efb9f
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看板
提交
f43efb9f
编写于
3月 16, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
handle except and update UT
上级
6e9bc0cb
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
55 addition
and
20 deletion
+55
-20
include/libs/transport/trpc.h
include/libs/transport/trpc.h
+1
-1
source/libs/transport/inc/transportInt.h
source/libs/transport/inc/transportInt.h
+1
-1
source/libs/transport/src/transSrv.c
source/libs/transport/src/transSrv.c
+18
-6
source/libs/transport/test/transUT.cc
source/libs/transport/test/transUT.cc
+35
-12
未找到文件。
include/libs/transport/trpc.h
浏览文件 @
f43efb9f
...
...
@@ -73,7 +73,7 @@ typedef struct SRpcInit {
void
*
(
*
mfp
)(
void
*
parent
,
tmsg_t
msgType
);
// call back to handle except when query/fetch in progress
void
(
*
efp
)(
void
*
parent
,
tmsg_t
msgType
);
bool
(
*
efp
)(
void
*
parent
,
tmsg_t
msgType
);
void
*
parent
;
}
SRpcInit
;
...
...
source/libs/transport/inc/transportInt.h
浏览文件 @
f43efb9f
...
...
@@ -65,7 +65,7 @@ typedef struct {
int
(
*
afp
)(
void
*
parent
,
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
bool
(
*
pfp
)(
void
*
parent
,
tmsg_t
msgType
);
void
*
(
*
mfp
)(
void
*
parent
,
tmsg_t
msgType
);
void
(
*
efp
)(
void
*
parent
,
tmsg_t
msgType
);
bool
(
*
efp
)(
void
*
parent
,
tmsg_t
msgType
);
int32_t
refCount
;
void
*
parent
;
...
...
source/libs/transport/src/transSrv.c
浏览文件 @
f43efb9f
...
...
@@ -106,6 +106,8 @@ static void uvStartSendRespInternal(SSrvMsg* smsg);
static
void
uvPrepareSendData
(
SSrvMsg
*
msg
,
uv_buf_t
*
wb
);
static
void
uvStartSendResp
(
SSrvMsg
*
msg
);
static
void
uvNotifyLinkBrokenToApp
(
SSrvConn
*
conn
);
static
void
destroySmsg
(
SSrvMsg
*
smsg
);
// check whether already read complete packet
static
SSrvConn
*
createConn
(
void
*
hThrd
);
...
...
@@ -233,7 +235,7 @@ static void uvHandleReq(SSrvConn* pConn) {
ntohs
(
pConn
->
locaddr
.
sin_port
),
transMsg
.
contLen
);
STrans
*
pTransInst
=
(
STrans
*
)
p
->
shandle
;
(
*
((
STrans
*
)
p
->
shandle
)
->
cfp
)(
pTransInst
->
parent
,
&
transMsg
,
NULL
);
(
*
pTransInst
->
cfp
)(
pTransInst
->
parent
,
&
transMsg
,
NULL
);
// uv_timer_start(&pConn->pTimer, uvHandleActivityTimeout, pRpc->idleTime * 10000, 0);
// auth
// validate msg type
...
...
@@ -261,13 +263,12 @@ void uvOnRecvCb(uv_stream_t* cli, ssize_t nread, const uv_buf_t* buf) {
tError
(
"server conn %p read error: %s"
,
conn
,
uv_err_name
(
nread
));
if
(
nread
<
0
)
{
conn
->
broken
=
true
;
transUnrefSrvHandle
(
conn
);
uvNotifyLinkBrokenToApp
(
conn
);
//
if (conn->ref > 1) {
//
conn->ref++; // ref > 1 signed that write is in progress
//
STrans* pTransInst = conn->pTransInst;
//
if (pTransInst->efp != NULL && (pTransInst->efp)(NULL, conn->inType)) {
//}
// tError("server conn %p read error: %s", conn, uv_err_name(nread));
// destroyConn(conn, true);
transUnrefSrvHandle
(
conn
);
}
}
void
uvAllocConnBufferCb
(
uv_handle_t
*
handle
,
size_t
suggested_size
,
uv_buf_t
*
buf
)
{
...
...
@@ -373,6 +374,17 @@ static void uvStartSendResp(SSrvMsg* smsg) {
uvStartSendRespInternal
(
smsg
);
return
;
}
static
void
uvNotifyLinkBrokenToApp
(
SSrvConn
*
conn
)
{
STrans
*
pTransInst
=
conn
->
pTransInst
;
if
(
pTransInst
->
efp
!=
NULL
&&
(
*
pTransInst
->
efp
)(
NULL
,
conn
->
inType
)
&&
T_REF_VAL_GET
(
conn
)
>=
2
)
{
STransMsg
transMsg
=
{
0
};
transMsg
.
msgType
=
conn
->
inType
;
transMsg
.
code
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
// transRefSrvHandle(conn);
(
*
pTransInst
->
cfp
)(
pTransInst
->
parent
,
&
transMsg
,
0
);
}
}
static
void
destroySmsg
(
SSrvMsg
*
smsg
)
{
if
(
smsg
==
NULL
)
{
return
;
...
...
source/libs/transport/test/transUT.cc
浏览文件 @
f43efb9f
...
...
@@ -15,6 +15,7 @@
#include <gtest/gtest.h>
#include <cstdio>
#include <cstring>
#include "rpcLog.h"
#include "tdatablock.h"
#include "tglobal.h"
#include "tlog.h"
...
...
@@ -48,7 +49,9 @@ static void *ConstructArgForSpecificMsgType(void *parent, tmsg_t msgType) {
return
NULL
;
}
// server except
static
void
NotifyAppLinkBroken
(
void
*
parent
,
tmsg_t
msgType
)
{}
static
bool
handleExcept
(
void
*
parent
,
tmsg_t
msgType
)
{
return
msgType
==
TDMT_VND_QUERY
||
msgType
==
TDMT_VND_FETCH_RSP
||
msgType
==
TDMT_VND_RES_READY_RSP
;
}
typedef
void
(
*
CB
)(
void
*
parent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
static
void
processContinueSend
(
void
*
parent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
...
...
@@ -83,6 +86,10 @@ class Client {
rpcInit_
.
cfp
=
cb
;
this
->
transCli
=
rpcOpen
(
&
rpcInit_
);
}
void
Stop
()
{
rpcClose
(
this
->
transCli
);
this
->
transCli
=
NULL
;
}
void
SetPersistFP
(
bool
(
*
pfp
)(
void
*
parent
,
tmsg_t
msgType
))
{
rpcClose
(
this
->
transCli
);
rpcInit_
.
pfp
=
pfp
;
...
...
@@ -157,7 +164,7 @@ class Server {
rpcClose
(
this
->
transSrv
);
this
->
transSrv
=
NULL
;
}
void
SetExceptFp
(
void
(
*
efp
)(
void
*
parent
,
tmsg_t
msgType
))
{
void
SetExceptFp
(
bool
(
*
efp
)(
void
*
parent
,
tmsg_t
msgType
))
{
this
->
Stop
();
rpcInit_
.
efp
=
efp
;
this
->
Start
();
...
...
@@ -207,6 +214,7 @@ static void processResp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
Client
*
client
=
(
Client
*
)
parent
;
client
->
SetResp
(
pMsg
);
client
->
SemPost
();
tDebug
(
"received resp"
);
}
static
void
initEnv
()
{
...
...
@@ -266,7 +274,7 @@ class TransObj {
cli
->
SetPAndMFp
(
pfp
,
mfp
);
}
// call when link broken, and notify query or fetch stop
void
SetSrvExceptFp
(
void
(
*
efp
)(
void
*
parent
,
tmsg_t
msgType
))
{
void
SetSrvExceptFp
(
bool
(
*
efp
)(
void
*
parent
,
tmsg_t
msgType
))
{
////////
srv
->
SetExceptFp
(
efp
);
}
...
...
@@ -275,6 +283,10 @@ class TransObj {
srv
->
SetSrvContinueSend
(
cfp
);
}
void
RestartSrv
()
{
srv
->
Restart
();
}
void
cliStop
()
{
///////
cli
->
Stop
();
}
void
cliSendAndRecv
(
SRpcMsg
*
req
,
SRpcMsg
*
resp
)
{
cli
->
SendAndRecv
(
req
,
resp
);
}
void
cliSendAndRecvNoHandle
(
SRpcMsg
*
req
,
SRpcMsg
*
resp
)
{
cli
->
SendAndRecvNoHandle
(
req
,
resp
);
}
...
...
@@ -417,20 +429,31 @@ TEST_F(TransEnv, srvContinueSend) {
}
TEST_F
(
TransEnv
,
srvPersistHandleExcept
)
{
// conn breken
tr
->
SetSrvContinueSend
(
processContinueSend
);
tr
->
SetCliPersistFp
(
cliPersistHandle
);
SRpcMsg
resp
=
{
0
};
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
SRpcMsg
req
=
{.
handle
=
resp
.
handle
};
req
.
msgType
=
1
;
req
.
pCont
=
rpcMallocCont
(
10
);
req
.
contLen
=
10
;
tr
->
cliSendAndRecv
(
&
req
,
&
resp
);
if
(
i
>
2
)
{
tr
->
cliStop
();
break
;
}
}
taosMsleep
(
2000
);
// conn broken
//
}
TEST_F
(
TransEnv
,
cliPersistHandleExcept
)
{
// conn breken
}
TEST_F
(
TransEnv
,
multiCliPersisHandleExcept
)
{
// conn breken
}
TEST_F
(
TransEnv
,
multiSrvPersisHandleExcept
)
{
// conn breken
TEST_F
(
TransEnv
,
multiCliPersistHandleExcept
)
{
// conn broken
}
TEST_F
(
TransEnv
,
queryExcept
)
{
tr
->
SetSrvExceptFp
(
handleExcept
);
// query and conn is broken
}
TEST_F
(
TransEnv
,
noResp
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录