Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1d8ffd95
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看板
提交
1d8ffd95
编写于
3月 16, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
handle except
上级
3d4280c7
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
70 addition
and
9 deletion
+70
-9
include/libs/transport/trpc.h
include/libs/transport/trpc.h
+1
-0
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+27
-3
source/libs/transport/src/transSrv.c
source/libs/transport/src/transSrv.c
+12
-5
source/libs/transport/test/transUT.cc
source/libs/transport/test/transUT.cc
+30
-1
未找到文件。
include/libs/transport/trpc.h
浏览文件 @
1d8ffd95
...
...
@@ -43,6 +43,7 @@ typedef struct SRpcMsg {
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 indicate resp);
}
SRpcMsg
;
typedef
struct
SRpcInit
{
...
...
source/libs/transport/src/transCli.c
浏览文件 @
1d8ffd95
...
...
@@ -158,9 +158,11 @@ static void destroyThrdObj(SCliThrdObj* pThrd);
} while (0)
#define CONN_NO_PERSIST_BY_APP(conn) ((conn)->persist == false)
#define REQUEST_NO_RESP(msg) ((msg)->noResp == 1)
static
void
*
cliWorkThread
(
void
*
arg
);
bool
cliMay
ContinueSen
dMsg
(
SCliConn
*
conn
)
{
bool
cliMay
SendCache
dMsg
(
SCliConn
*
conn
)
{
if
(
taosArrayGetSize
(
conn
->
cliMsgs
)
>
0
)
{
cliSend
(
conn
);
return
true
;
...
...
@@ -226,7 +228,7 @@ void cliHandleResp(SCliConn* conn) {
}
destroyCmsg
(
pMsg
);
if
(
cliMay
ContinueSen
dMsg
(
conn
)
==
true
)
{
if
(
cliMay
SendCache
dMsg
(
conn
)
==
true
)
{
return
;
}
...
...
@@ -441,7 +443,24 @@ static void cliDestroy(uv_handle_t* handle) {
tTrace
(
"%s cli conn %p destroy successfully"
,
CONN_GET_INST_LABEL
(
conn
),
conn
);
free
(
conn
);
}
static
bool
cliHandleNoResp
(
SCliConn
*
conn
)
{
bool
res
=
false
;
SArray
*
msgs
=
conn
->
cliMsgs
;
if
(
taosArrayGetSize
(
msgs
)
>
0
)
{
SCliMsg
*
pMsg
=
taosArrayGetP
(
msgs
,
0
);
if
(
REQUEST_NO_RESP
(
&
pMsg
->
msg
))
{
taosArrayRemove
(
msgs
,
0
);
destroyCmsg
(
pMsg
);
res
=
true
;
}
if
(
res
==
true
)
{
if
(
cliMaySendCachedMsg
(
conn
)
==
false
)
{
addConnToPool
(
conn
->
hostThrd
,
conn
);
}
}
}
return
res
;
}
static
void
cliSendCb
(
uv_write_t
*
req
,
int
status
)
{
SCliConn
*
pConn
=
req
->
data
;
...
...
@@ -452,6 +471,10 @@ static void cliSendCb(uv_write_t* req, int status) {
cliHandleExcept
(
pConn
);
return
;
}
if
(
cliHandleNoResp
(
pConn
)
==
true
)
{
tTrace
(
"%s cli conn %p no resp required"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
);
return
;
}
uv_read_start
((
uv_stream_t
*
)
pConn
->
stream
,
cliAllocRecvBufferCb
,
cliRecvCb
);
}
...
...
@@ -489,6 +512,7 @@ void cliSend(SCliConn* pConn) {
msgLen
+=
sizeof
(
STransUserMsg
);
}
pHead
->
resflag
=
REQUEST_NO_RESP
(
pMsg
)
?
1
:
0
;
pHead
->
msgType
=
pMsg
->
msgType
;
pHead
->
msgLen
=
(
int32_t
)
htonl
((
uint32_t
)
msgLen
);
...
...
source/libs/transport/src/transSrv.c
浏览文件 @
1d8ffd95
...
...
@@ -226,15 +226,22 @@ static void uvHandleReq(SSrvConn* pConn) {
transMsg
.
msgType
=
pHead
->
msgType
;
transMsg
.
code
=
pHead
->
code
;
transMsg
.
ahandle
=
NULL
;
transMsg
.
handle
=
pConn
;
transMsg
.
handle
=
NULL
;
transClearBuffer
(
&
pConn
->
readBuf
);
pConn
->
inType
=
pHead
->
msgType
;
transRefSrvHandle
(
pConn
);
if
(
pHead
->
resflag
==
0
)
{
transRefSrvHandle
(
pConn
);
transMsg
.
handle
=
pConn
;
tDebug
(
"server conn %p %s received from %s:%d, local info: %s:%d, msg size: %d"
,
pConn
,
TMSG_INFO
(
transMsg
.
msgType
),
inet_ntoa
(
pConn
->
addr
.
sin_addr
),
ntohs
(
pConn
->
addr
.
sin_port
),
inet_ntoa
(
pConn
->
locaddr
.
sin_addr
),
ntohs
(
pConn
->
locaddr
.
sin_port
),
transMsg
.
contLen
);
}
else
{
tDebug
(
"server conn %p %s received from %s:%d, local info: %s:%d, msg size: %d, no resp "
,
pConn
,
TMSG_INFO
(
transMsg
.
msgType
),
inet_ntoa
(
pConn
->
addr
.
sin_addr
),
ntohs
(
pConn
->
addr
.
sin_port
),
inet_ntoa
(
pConn
->
locaddr
.
sin_addr
),
ntohs
(
pConn
->
locaddr
.
sin_port
),
transMsg
.
contLen
);
}
STrans
*
pTransInst
=
(
STrans
*
)
p
->
shandle
;
(
*
pTransInst
->
cfp
)(
pTransInst
->
parent
,
&
transMsg
,
NULL
);
...
...
source/libs/transport/test/transUT.cc
浏览文件 @
1d8ffd95
...
...
@@ -361,7 +361,7 @@ TEST_F(TransEnv, cliPersistHandle) {
tr
->
SetCliPersistFp
(
cliPersistHandle
);
SRpcMsg
resp
=
{
0
};
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
SRpcMsg
req
=
{.
handle
=
resp
.
handle
};
SRpcMsg
req
=
{.
handle
=
resp
.
handle
,
.
noResp
=
0
};
req
.
msgType
=
1
;
req
.
pCont
=
rpcMallocCont
(
10
);
req
.
contLen
=
10
;
...
...
@@ -448,6 +448,25 @@ TEST_F(TransEnv, srvPersistHandleExcept) {
// conn broken
//
}
TEST_F
(
TransEnv
,
cliPersistHandleExcept
)
{
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
->
StopSrv
();
break
;
}
}
taosMsleep
(
2000
);
// conn broken
//
}
TEST_F
(
TransEnv
,
multiCliPersistHandleExcept
)
{
// conn broken
...
...
@@ -458,5 +477,15 @@ TEST_F(TransEnv, queryExcept) {
// query and conn is broken
}
TEST_F
(
TransEnv
,
noResp
)
{
SRpcMsg
resp
=
{
0
};
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
SRpcMsg
req
=
{.
noResp
=
1
};
req
.
msgType
=
1
;
req
.
pCont
=
rpcMallocCont
(
10
);
req
.
contLen
=
10
;
tr
->
cliSendAndRecv
(
&
req
,
&
resp
);
}
taosMsleep
(
2000
);
// no resp
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录