Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5136d644
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5136d644
编写于
1月 25, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor rpc
上级
3b5f9215
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
17 addition
and
10 deletion
+17
-10
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+17
-10
未找到文件。
source/libs/transport/src/transCli.c
浏览文件 @
5136d644
...
...
@@ -31,6 +31,7 @@ typedef struct SCliConn {
char
secured
;
uint64_t
expireTime
;
int8_t
notifyCount
;
// timers already notify to client
int32_t
ref
;
}
SCliConn
;
typedef
struct
SCliMsg
{
...
...
@@ -126,6 +127,7 @@ static void clientHandleResp(SCliConn* conn) {
// buf alread translated to rpcMsg.pCont
transClearBuffer
(
&
conn
->
readBuf
);
uv_read_start
((
uv_stream_t
*
)
conn
->
stream
,
clientAllocBufferCb
,
clientReadCb
);
addConnToPool
(
pThrd
->
pool
,
pCtx
->
ip
,
pCtx
->
port
,
conn
);
// start thread's timer of conn pool if not active
...
...
@@ -137,6 +139,7 @@ static void clientHandleResp(SCliConn* conn) {
static
void
clientHandleExcept
(
SCliConn
*
pConn
)
{
if
(
pConn
->
data
==
NULL
)
{
clientConnDestroy
(
pConn
,
true
);
return
;
}
tDebug
(
"conn %p destroy"
,
pConn
);
...
...
@@ -258,7 +261,7 @@ static bool clientReadComplete(SConnBuffer* data) {
return
false
;
}
}
static
void
clientAlloc
Read
BufferCb
(
uv_handle_t
*
handle
,
size_t
suggested_size
,
uv_buf_t
*
buf
)
{
static
void
clientAllocBufferCb
(
uv_handle_t
*
handle
,
size_t
suggested_size
,
uv_buf_t
*
buf
)
{
SCliConn
*
conn
=
handle
->
data
;
SConnBuffer
*
pBuf
=
&
conn
->
readBuf
;
transAllocBuffer
(
pBuf
,
buf
);
...
...
@@ -270,6 +273,7 @@ static void clientReadCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf
if
(
nread
>
0
)
{
pBuf
->
len
+=
nread
;
if
(
clientReadComplete
(
pBuf
))
{
uv_read_stop
((
uv_stream_t
*
)
conn
->
stream
);
tDebug
(
"conn %p read complete"
,
conn
);
clientHandleResp
(
conn
);
}
else
{
...
...
@@ -291,16 +295,19 @@ static void clientReadCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf
static
void
clientConnDestroy
(
SCliConn
*
conn
,
bool
clear
)
{
//
tDebug
(
"conn %p remove from conn pool"
,
conn
);
QUEUE_REMOVE
(
&
conn
->
conn
);
tDebug
(
"conn %p remove from conn pool successfully"
,
conn
);
if
(
clear
)
{
uv_close
((
uv_handle_t
*
)
conn
->
stream
,
clientDestroy
);
conn
->
ref
--
;
if
(
conn
->
ref
==
0
)
{
tDebug
(
"conn %p remove from conn pool"
,
conn
);
QUEUE_REMOVE
(
&
conn
->
conn
);
tDebug
(
"conn %p remove from conn pool successfully"
,
conn
);
if
(
clear
)
{
uv_close
((
uv_handle_t
*
)
conn
->
stream
,
clientDestroy
);
}
}
}
static
void
clientDestroy
(
uv_handle_t
*
handle
)
{
SCliConn
*
conn
=
handle
->
data
;
transDestroyBuffer
(
&
conn
->
readBuf
);
//
transDestroyBuffer(&conn->readBuf);
free
(
conn
->
stream
);
free
(
conn
->
writeReq
);
...
...
@@ -325,7 +332,7 @@ static void clientWriteCb(uv_write_t* req, int status) {
// uv_tcp_init(pThrd->loop, (uv_tcp_t*)pConn->stream);
// pConn->stream->data = pConn;
//}
uv_read_start
((
uv_stream_t
*
)
pConn
->
stream
,
clientAlloc
Read
BufferCb
,
clientReadCb
);
uv_read_start
((
uv_stream_t
*
)
pConn
->
stream
,
clientAllocBufferCb
,
clientReadCb
);
// impl later
}
...
...
@@ -371,11 +378,11 @@ static void clientHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
tDebug
(
"conn %p get from conn pool"
,
conn
);
conn
->
data
=
pMsg
;
conn
->
writeReq
->
data
=
conn
;
transDestroyBuffer
(
&
conn
->
readBuf
);
//
transDestroyBuffer(&conn->readBuf);
clientWrite
(
conn
);
}
else
{
SCliConn
*
conn
=
calloc
(
1
,
sizeof
(
SCliConn
));
conn
->
ref
++
;
// read/write stream handle
conn
->
stream
=
(
uv_stream_t
*
)
malloc
(
sizeof
(
uv_tcp_t
));
uv_tcp_init
(
pThrd
->
loop
,
(
uv_tcp_t
*
)(
conn
->
stream
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录