Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c45c1a06
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看板
提交
c45c1a06
编写于
2月 10, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix push crashed
上级
e5d767cf
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
53 addition
and
17 deletion
+53
-17
include/libs/transport/trpc.h
include/libs/transport/trpc.h
+12
-0
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+41
-17
未找到文件。
include/libs/transport/trpc.h
浏览文件 @
c45c1a06
...
@@ -29,6 +29,8 @@ extern "C" {
...
@@ -29,6 +29,8 @@ extern "C" {
extern
int
tsRpcHeadSize
;
extern
int
tsRpcHeadSize
;
typedef
struct
SRpcPush
SRpcPush
;
typedef
struct
SRpcConnInfo
{
typedef
struct
SRpcConnInfo
{
uint32_t
clientIp
;
uint32_t
clientIp
;
uint16_t
clientPort
;
uint16_t
clientPort
;
...
@@ -43,8 +45,17 @@ typedef struct SRpcMsg {
...
@@ -43,8 +45,17 @@ typedef struct SRpcMsg {
int32_t
code
;
int32_t
code
;
void
*
handle
;
// rpc handle returned to app
void
*
handle
;
// rpc handle returned to app
void
*
ahandle
;
// app handle set by client
void
*
ahandle
;
// app handle set by client
int
persist
;
// keep handle or not, default 0
SRpcPush
*
push
;
}
SRpcMsg
;
}
SRpcMsg
;
typedef
struct
SRpcPush
{
void
*
arg
;
int
(
*
callback
)(
void
*
arg
,
SRpcMsg
*
rpcMsg
);
}
SRpcPush
;
typedef
struct
SRpcInit
{
typedef
struct
SRpcInit
{
uint16_t
localPort
;
// local port
uint16_t
localPort
;
// local port
char
*
label
;
// for debug purpose
char
*
label
;
// for debug purpose
...
@@ -83,6 +94,7 @@ int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo);
...
@@ -83,6 +94,7 @@ int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo);
void
rpcSendRecv
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pReq
,
SRpcMsg
*
pRsp
);
void
rpcSendRecv
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pReq
,
SRpcMsg
*
pRsp
);
int
rpcReportProgress
(
void
*
pConn
,
char
*
pCont
,
int
contLen
);
int
rpcReportProgress
(
void
*
pConn
,
char
*
pCont
,
int
contLen
);
void
rpcCancelRequest
(
int64_t
rid
);
void
rpcCancelRequest
(
int64_t
rid
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/libs/transport/src/transCli.c
浏览文件 @
c45c1a06
...
@@ -27,12 +27,16 @@ typedef struct SCliConn {
...
@@ -27,12 +27,16 @@ typedef struct SCliConn {
SConnBuffer
readBuf
;
SConnBuffer
readBuf
;
void
*
data
;
void
*
data
;
queue
conn
;
queue
conn
;
char
spi
;
char
secured
;
uint64_t
expireTime
;
uint64_t
expireTime
;
int8_t
notifyCount
;
// timers already notify to client
int8_t
notifyCount
;
// timers already notify to client
int32_t
ref
;
SRpcPush
*
push
;
int
persist
;
//
// spi configure
char
spi
;
char
secured
;
int32_t
ref
;
// debug and log info
struct
sockaddr_in
addr
;
struct
sockaddr_in
addr
;
}
SCliConn
;
}
SCliConn
;
...
@@ -128,13 +132,18 @@ static void clientHandleResp(SCliConn* conn) {
...
@@ -128,13 +132,18 @@ static void clientHandleResp(SCliConn* conn) {
tDebug
(
"client conn %p %s received from %s:%d"
,
conn
,
TMSG_INFO
(
pHead
->
msgType
),
inet_ntoa
(
conn
->
addr
.
sin_addr
),
tDebug
(
"client conn %p %s received from %s:%d"
,
conn
,
TMSG_INFO
(
pHead
->
msgType
),
inet_ntoa
(
conn
->
addr
.
sin_addr
),
ntohs
(
conn
->
addr
.
sin_port
));
ntohs
(
conn
->
addr
.
sin_port
));
if
(
pCtx
->
pSem
==
NULL
)
{
tTrace
(
"client conn(sync) %p handle resp"
,
conn
);
if
(
conn
->
push
!=
NULL
)
{
(
pRpc
->
cfp
)(
pRpc
->
parent
,
&
rpcMsg
,
NULL
);
(
*
conn
->
push
->
callback
)(
conn
->
push
->
arg
,
&
rpcMsg
);
}
else
{
}
else
{
tTrace
(
"client conn(sync) %p handle resp"
,
conn
);
if
(
pCtx
->
pSem
==
NULL
)
{
memcpy
((
char
*
)
pCtx
->
pRsp
,
(
char
*
)
&
rpcMsg
,
sizeof
(
rpcMsg
));
tTrace
(
"client conn(sync) %p handle resp"
,
conn
);
tsem_post
(
pCtx
->
pSem
);
(
pRpc
->
cfp
)(
pRpc
->
parent
,
&
rpcMsg
,
NULL
);
}
else
{
tTrace
(
"client conn(sync) %p handle resp"
,
conn
);
memcpy
((
char
*
)
pCtx
->
pRsp
,
(
char
*
)
&
rpcMsg
,
sizeof
(
rpcMsg
));
tsem_post
(
pCtx
->
pSem
);
}
}
}
conn
->
notifyCount
+=
1
;
conn
->
notifyCount
+=
1
;
...
@@ -144,7 +153,10 @@ static void clientHandleResp(SCliConn* conn) {
...
@@ -144,7 +153,10 @@ static void clientHandleResp(SCliConn* conn) {
uv_read_start
((
uv_stream_t
*
)
conn
->
stream
,
clientAllocBufferCb
,
clientReadCb
);
uv_read_start
((
uv_stream_t
*
)
conn
->
stream
,
clientAllocBufferCb
,
clientReadCb
);
SCliThrdObj
*
pThrd
=
conn
->
hostThrd
;
SCliThrdObj
*
pThrd
=
conn
->
hostThrd
;
addConnToPool
(
pThrd
->
pool
,
pCtx
->
ip
,
pCtx
->
port
,
conn
);
// user owns conn->persist = 1
if
(
conn
->
push
!=
NULL
)
{
addConnToPool
(
pThrd
->
pool
,
pCtx
->
ip
,
pCtx
->
port
,
conn
);
}
destroyCmsg
(
pMsg
);
destroyCmsg
(
pMsg
);
conn
->
data
=
NULL
;
conn
->
data
=
NULL
;
...
@@ -154,7 +166,7 @@ static void clientHandleResp(SCliConn* conn) {
...
@@ -154,7 +166,7 @@ static void clientHandleResp(SCliConn* conn) {
}
}
}
}
static
void
clientHandleExcept
(
SCliConn
*
pConn
)
{
static
void
clientHandleExcept
(
SCliConn
*
pConn
)
{
if
(
pConn
->
data
==
NULL
)
{
if
(
pConn
->
data
==
NULL
&&
pConn
->
push
==
NULL
)
{
// handle conn except in conn pool
// handle conn except in conn pool
clientConnDestroy
(
pConn
,
true
);
clientConnDestroy
(
pConn
,
true
);
return
;
return
;
...
@@ -169,13 +181,17 @@ static void clientHandleExcept(SCliConn* pConn) {
...
@@ -169,13 +181,17 @@ static void clientHandleExcept(SCliConn* pConn) {
SRpcMsg
rpcMsg
=
{
0
};
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
ahandle
=
pCtx
->
ahandle
;
rpcMsg
.
ahandle
=
pCtx
->
ahandle
;
rpcMsg
.
code
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
rpcMsg
.
code
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
if
(
pCtx
->
pSem
==
NULL
)
{
// SRpcInfo* pRpc = pMsg->ctx->pRpc;
if
(
pConn
->
push
!=
NULL
)
{
(
pCtx
->
pTransInst
->
cfp
)(
pCtx
->
pTransInst
->
parent
,
&
rpcMsg
,
NULL
);
(
*
pConn
->
push
->
callback
)(
pConn
->
push
->
arg
,
&
rpcMsg
);
}
else
{
}
else
{
memcpy
((
char
*
)(
pCtx
->
pRsp
),
(
char
*
)(
&
rpcMsg
),
sizeof
(
rpcMsg
));
if
(
pCtx
->
pSem
==
NULL
)
{
// SRpcMsg rpcMsg
(
pCtx
->
pTransInst
->
cfp
)(
pCtx
->
pTransInst
->
parent
,
&
rpcMsg
,
NULL
);
tsem_post
(
pCtx
->
pSem
);
}
else
{
memcpy
((
char
*
)(
pCtx
->
pRsp
),
(
char
*
)(
&
rpcMsg
),
sizeof
(
rpcMsg
));
// SRpcMsg rpcMsg
tsem_post
(
pCtx
->
pSem
);
}
}
}
destroyCmsg
(
pMsg
);
destroyCmsg
(
pMsg
);
...
@@ -411,6 +427,10 @@ static void clientHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
...
@@ -411,6 +427,10 @@ static void clientHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
tTrace
(
"client msg tran time cost: %"
PRIu64
""
,
el
);
tTrace
(
"client msg tran time cost: %"
PRIu64
""
,
el
);
et
=
taosGetTimestampUs
();
et
=
taosGetTimestampUs
();
// if (pMsg->msg.handle != NULL) {
// // handle
//}
STransConnCtx
*
pCtx
=
pMsg
->
ctx
;
STransConnCtx
*
pCtx
=
pMsg
->
ctx
;
SCliConn
*
conn
=
getConnFromPool
(
pThrd
->
pool
,
pCtx
->
ip
,
pCtx
->
port
);
SCliConn
*
conn
=
getConnFromPool
(
pThrd
->
pool
,
pCtx
->
ip
,
pCtx
->
port
);
if
(
conn
!=
NULL
)
{
if
(
conn
!=
NULL
)
{
...
@@ -426,6 +446,8 @@ static void clientHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
...
@@ -426,6 +446,8 @@ static void clientHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
}
}
clientWrite
(
conn
);
clientWrite
(
conn
);
conn
->
push
=
pMsg
->
msg
.
push
;
}
else
{
}
else
{
SCliConn
*
conn
=
calloc
(
1
,
sizeof
(
SCliConn
));
SCliConn
*
conn
=
calloc
(
1
,
sizeof
(
SCliConn
));
conn
->
ref
++
;
conn
->
ref
++
;
...
@@ -444,6 +466,8 @@ static void clientHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
...
@@ -444,6 +466,8 @@ static void clientHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
conn
->
data
=
pMsg
;
conn
->
data
=
pMsg
;
conn
->
hostThrd
=
pThrd
;
conn
->
hostThrd
=
pThrd
;
conn
->
push
=
pMsg
->
msg
.
push
;
struct
sockaddr_in
addr
;
struct
sockaddr_in
addr
;
uv_ip4_addr
(
pMsg
->
ctx
->
ip
,
pMsg
->
ctx
->
port
,
&
addr
);
uv_ip4_addr
(
pMsg
->
ctx
->
ip
,
pMsg
->
ctx
->
port
,
&
addr
);
// handle error in callback if fail to connect
// handle error in callback if fail to connect
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录