Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
916dbe79
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
916dbe79
编写于
3月 18, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
handle except
上级
a9b712ab
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
69 addition
and
25 deletion
+69
-25
include/libs/transport/trpc.h
include/libs/transport/trpc.h
+1
-2
source/libs/transport/inc/transComm.h
source/libs/transport/inc/transComm.h
+3
-2
source/libs/transport/src/trans.c
source/libs/transport/src/trans.c
+1
-4
source/libs/transport/src/transSrv.c
source/libs/transport/src/transSrv.c
+64
-17
未找到文件。
include/libs/transport/trpc.h
浏览文件 @
916dbe79
...
...
@@ -38,13 +38,12 @@ typedef struct SRpcConnInfo {
typedef
struct
SRpcMsg
{
tmsg_t
msgType
;
tmsg_t
expectMsgType
;
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
indicate
resp);
int
noResp
;
// has response or not(default 0
, 0: resp, 1: no
resp);
int
persistHandle
;
// persist handle or not
}
SRpcMsg
;
...
...
source/libs/transport/inc/transComm.h
浏览文件 @
916dbe79
...
...
@@ -181,7 +181,7 @@ typedef struct {
#pragma pack(pop)
typedef
enum
{
Normal
,
Quit
,
Release
}
STransMsgType
;
typedef
enum
{
Normal
,
Quit
,
Release
,
Register
}
STransMsgType
;
typedef
enum
{
ConnNormal
,
ConnAcquire
,
ConnRelease
,
ConnBroken
}
ConnStatus
;
#define container_of(ptr, type, member) ((type*)((char*)(ptr)-offsetof(type, member)))
...
...
@@ -262,7 +262,8 @@ void transReleaseSrvHandle(void* handle);
void
transSendRequest
(
void
*
shandle
,
const
char
*
ip
,
uint32_t
port
,
STransMsg
*
pMsg
,
STransCtx
*
pCtx
);
void
transSendRecv
(
void
*
shandle
,
const
char
*
ip
,
uint32_t
port
,
STransMsg
*
pMsg
,
STransMsg
*
pRsp
);
void
transSendResponse
(
const
STransMsg
*
pMsg
);
void
transSendResponse
(
const
STransMsg
*
msg
);
void
transRegisterMsg
(
const
STransMsg
*
msg
);
int
transGetConnInfo
(
void
*
thandle
,
STransHandleInfo
*
pInfo
);
void
*
transInitServer
(
uint32_t
ip
,
uint32_t
port
,
char
*
label
,
int
numOfThreads
,
void
*
fp
,
void
*
shandle
);
...
...
source/libs/transport/src/trans.c
浏览文件 @
916dbe79
...
...
@@ -144,10 +144,7 @@ void rpcUnrefHandle(void* handle, int8_t type) {
(
*
taosUnRefHandle
[
type
])(
handle
);
}
void
rpcRegisterBrokenLinkArg
(
SRpcMsg
*
msg
)
{
//
rpcSendResponse
(
msg
);
}
void
rpcRegisterBrokenLinkArg
(
SRpcMsg
*
msg
)
{
rpcSendResponse
(
msg
);
}
void
rpcReleaseHandle
(
void
*
handle
,
int8_t
type
)
{
assert
(
type
==
TAOS_CONN_SERVER
||
type
==
TAOS_CONN_CLIENT
);
(
*
transReleaseHandle
[
type
])(
handle
);
...
...
source/libs/transport/src/transSrv.c
浏览文件 @
916dbe79
...
...
@@ -17,6 +17,12 @@
#include "transComm.h"
typedef
struct
{
int
notifyCount
;
//
int
init
;
// init or not
STransMsg
msg
;
}
SSrvRegArg
;
typedef
struct
SSrvConn
{
T_REF_DECLARE
()
uv_tcp_t
*
pTcp
;
...
...
@@ -33,7 +39,8 @@ typedef struct SSrvConn {
void
*
hostThrd
;
SArray
*
srvMsgs
;
bool
broken
;
// conn broken;
SSrvRegArg
regArg
;
bool
broken
;
// conn broken;
ConnStatus
status
;
struct
sockaddr_in
addr
;
...
...
@@ -117,7 +124,9 @@ static void destroyConn(SSrvConn* conn, bool clear /*clear handle or not*/)
static
void
uvHandleQuit
(
SSrvMsg
*
msg
,
SWorkThrdObj
*
thrd
);
static
void
uvHandleRelease
(
SSrvMsg
*
msg
,
SWorkThrdObj
*
thrd
);
static
void
uvHandleSendResp
(
SSrvMsg
*
msg
,
SWorkThrdObj
*
thrd
);
static
void
(
*
transAsyncHandle
[])(
SSrvMsg
*
msg
,
SWorkThrdObj
*
thrd
)
=
{
uvHandleSendResp
,
uvHandleQuit
,
uvHandleRelease
};
static
void
uvHandleRegister
(
SSrvMsg
*
msg
,
SWorkThrdObj
*
thrd
);
static
void
(
*
transAsyncHandle
[])(
SSrvMsg
*
msg
,
SWorkThrdObj
*
thrd
)
=
{
uvHandleSendResp
,
uvHandleQuit
,
uvHandleRelease
,
uvHandleRegister
};
static
void
uvDestroyConn
(
uv_handle_t
*
handle
);
...
...
@@ -285,11 +294,13 @@ 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
;
// uvNotifyLinkBrokenToApp(conn);
// STrans* pTransInst = conn->pTransInst;
// if (pTransInst->efp != NULL && (pTransInst->efp)(NULL, conn->inType)) {
//}
if
(
conn
->
status
==
ConnAcquire
)
{
if
(
conn
->
regArg
.
init
)
{
STrans
*
pTransInst
=
conn
->
pTransInst
;
(
*
pTransInst
->
cfp
)(
pTransInst
->
parent
,
&
(
conn
->
regArg
.
msg
),
NULL
);
memset
(
&
conn
->
regArg
,
0
,
sizeof
(
conn
->
regArg
));
}
}
transUnrefSrvHandle
(
conn
);
}
}
...
...
@@ -317,6 +328,17 @@ void uvOnSendCb(uv_write_t* req, int status) {
if
(
msg
->
type
==
Release
&&
conn
->
status
!=
ConnNormal
)
{
conn
->
status
=
ConnNormal
;
transUnrefSrvHandle
(
conn
);
}
else
if
(
msg
->
type
==
Register
&&
conn
->
status
==
ConnAcquire
)
{
conn
->
regArg
.
notifyCount
=
0
;
conn
->
regArg
.
init
=
1
;
conn
->
regArg
.
msg
=
msg
->
msg
;
if
(
conn
->
broken
)
{
STrans
*
pTransInst
=
conn
->
pTransInst
;
(
pTransInst
->
cfp
)(
pTransInst
->
parent
,
&
(
conn
->
regArg
.
msg
),
NULL
);
memset
(
&
conn
->
regArg
,
0
,
sizeof
(
conn
->
regArg
));
}
free
(
msg
);
return
;
}
destroySmsg
(
msg
);
// send second data, just use for push
...
...
@@ -403,16 +425,6 @@ static void uvStartSendResp(SSrvMsg* 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
;
...
...
@@ -641,6 +653,7 @@ static SSrvConn* createConn(void* hThrd) {
pConn
->
srvMsgs
=
taosArrayInit
(
2
,
sizeof
(
void
*
));
//
tTrace
(
"conn %p created"
,
pConn
);
memset
(
&
pConn
->
regArg
,
0
,
sizeof
(
pConn
->
regArg
));
pConn
->
broken
=
false
;
pConn
->
status
=
ConnNormal
;
...
...
@@ -774,6 +787,7 @@ void uvHandleRelease(SSrvMsg* msg, SWorkThrdObj* thrd) {
if
(
conn
->
status
==
ConnAcquire
)
{
if
(
taosArrayGetSize
(
conn
->
srvMsgs
)
>
0
)
{
taosArrayPush
(
conn
->
srvMsgs
,
&
msg
);
return
;
}
taosArrayPush
(
conn
->
srvMsgs
,
&
msg
);
uvStartSendRespInternal
(
msg
);
...
...
@@ -790,6 +804,25 @@ void uvHandleSendResp(SSrvMsg* msg, SWorkThrdObj* thrd) {
// send msg to client
uvStartSendResp
(
msg
);
}
void
uvHandleRegister
(
SSrvMsg
*
msg
,
SWorkThrdObj
*
thrd
)
{
SSrvConn
*
conn
=
msg
->
pConn
;
if
(
conn
->
status
==
ConnAcquire
)
{
if
(
taosArrayGetSize
(
conn
->
srvMsgs
)
>
0
)
{
taosArrayPush
(
conn
->
srvMsgs
,
&
msg
);
return
;
}
conn
->
regArg
.
notifyCount
=
0
;
conn
->
regArg
.
init
=
1
;
conn
->
regArg
.
msg
=
msg
->
msg
;
if
(
conn
->
broken
)
{
STrans
*
pTransInst
=
conn
->
pTransInst
;
(
*
pTransInst
->
cfp
)(
pTransInst
->
parent
,
&
(
conn
->
regArg
.
msg
),
NULL
);
memset
(
&
conn
->
regArg
,
0
,
sizeof
(
conn
->
regArg
));
}
free
(
msg
);
}
}
void
destroyWorkThrd
(
SWorkThrdObj
*
pThrd
)
{
if
(
pThrd
==
NULL
)
{
return
;
...
...
@@ -884,6 +917,20 @@ void transSendResponse(const STransMsg* pMsg) {
tTrace
(
"server conn %p start to send resp"
,
pConn
);
transSendAsync
(
pThrd
->
asyncPool
,
&
srvMsg
->
q
);
}
void
transRegisterMsg
(
const
STransMsg
*
msg
)
{
if
(
msg
->
handle
==
NULL
)
{
return
;
}
SSrvConn
*
pConn
=
msg
->
handle
;
SWorkThrdObj
*
pThrd
=
pConn
->
hostThrd
;
SSrvMsg
*
srvMsg
=
calloc
(
1
,
sizeof
(
SSrvMsg
));
srvMsg
->
pConn
=
pConn
;
srvMsg
->
msg
=
*
msg
;
srvMsg
->
type
=
Register
;
tTrace
(
"server conn %p start to send resp"
,
pConn
);
transSendAsync
(
pThrd
->
asyncPool
,
&
srvMsg
->
q
);
}
int
transGetConnInfo
(
void
*
thandle
,
STransHandleInfo
*
pInfo
)
{
SSrvConn
*
pConn
=
thandle
;
struct
sockaddr_in
addr
=
pConn
->
addr
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录