Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b65bbcfd
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,发现更多精彩内容 >>
提交
b65bbcfd
编写于
1月 25, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor rpc
上级
5136d644
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
14 addition
and
13 deletion
+14
-13
source/libs/transport/src/trans.c
source/libs/transport/src/trans.c
+2
-1
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+11
-12
source/libs/transport/src/transSrv.c
source/libs/transport/src/transSrv.c
+1
-0
未找到文件。
source/libs/transport/src/trans.c
浏览文件 @
b65bbcfd
...
@@ -30,7 +30,8 @@ void* rpcOpen(const SRpcInit* pInit) {
...
@@ -30,7 +30,8 @@ void* rpcOpen(const SRpcInit* pInit) {
tstrncpy
(
pRpc
->
label
,
pInit
->
label
,
strlen
(
pInit
->
label
));
tstrncpy
(
pRpc
->
label
,
pInit
->
label
,
strlen
(
pInit
->
label
));
}
}
pRpc
->
cfp
=
pInit
->
cfp
;
pRpc
->
cfp
=
pInit
->
cfp
;
pRpc
->
numOfThreads
=
pInit
->
numOfThreads
>
TSDB_MAX_RPC_THREADS
?
TSDB_MAX_RPC_THREADS
:
pInit
->
numOfThreads
;
// pRpc->numOfThreads = pInit->numOfThreads > TSDB_MAX_RPC_THREADS ? TSDB_MAX_RPC_THREADS : pInit->numOfThreads;
pRpc
->
numOfThreads
=
pInit
->
numOfThreads
;
pRpc
->
connType
=
pInit
->
connType
;
pRpc
->
connType
=
pInit
->
connType
;
pRpc
->
idleTime
=
pInit
->
idleTime
;
pRpc
->
idleTime
=
pInit
->
idleTime
;
pRpc
->
tcphandle
=
(
*
taosInitHandle
[
pRpc
->
connType
])(
0
,
pInit
->
localPort
,
pRpc
->
label
,
pRpc
->
numOfThreads
,
NULL
,
pRpc
);
pRpc
->
tcphandle
=
(
*
taosInitHandle
[
pRpc
->
connType
])(
0
,
pInit
->
localPort
,
pRpc
->
label
,
pRpc
->
numOfThreads
,
NULL
,
pRpc
);
...
...
source/libs/transport/src/transCli.c
浏览文件 @
b65bbcfd
...
@@ -139,18 +139,16 @@ static void clientHandleResp(SCliConn* conn) {
...
@@ -139,18 +139,16 @@ static void clientHandleResp(SCliConn* conn) {
static
void
clientHandleExcept
(
SCliConn
*
pConn
)
{
static
void
clientHandleExcept
(
SCliConn
*
pConn
)
{
if
(
pConn
->
data
==
NULL
)
{
if
(
pConn
->
data
==
NULL
)
{
clientConnDestroy
(
pConn
,
true
);
clientConnDestroy
(
pConn
,
true
);
return
;
return
;
}
}
tDebug
(
"conn %p destroy"
,
pConn
);
tDebug
(
"conn %p destroy"
,
pConn
);
SCliMsg
*
pMsg
=
pConn
->
data
;
SCliMsg
*
pMsg
=
pConn
->
data
;
transFreeMsg
((
pMsg
->
msg
.
pCont
));
pMsg
->
msg
.
pCont
=
NULL
;
STransConnCtx
*
pCtx
=
pMsg
->
ctx
;
STransConnCtx
*
pCtx
=
pMsg
->
ctx
;
SRpcInfo
*
pRpc
=
pCtx
->
pTransInst
;
SRpcInfo
*
pRpc
=
pCtx
->
pTransInst
;
transFreeMsg
((
pMsg
->
msg
.
pCont
));
pMsg
->
msg
.
pCont
=
NULL
;
SRpcMsg
rpcMsg
=
{
0
};
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
ahandle
=
pCtx
->
ahandle
;
rpcMsg
.
ahandle
=
pCtx
->
ahandle
;
rpcMsg
.
code
=
-
1
;
rpcMsg
.
code
=
-
1
;
...
@@ -254,7 +252,8 @@ static bool clientReadComplete(SConnBuffer* data) {
...
@@ -254,7 +252,8 @@ static bool clientReadComplete(SConnBuffer* data) {
if
(
msgLen
>
data
->
len
)
{
if
(
msgLen
>
data
->
len
)
{
data
->
left
=
msgLen
-
data
->
len
;
data
->
left
=
msgLen
-
data
->
len
;
return
false
;
return
false
;
}
else
{
}
else
if
(
msgLen
==
data
->
len
)
{
data
->
left
=
0
;
return
true
;
return
true
;
}
}
}
else
{
}
else
{
...
@@ -321,19 +320,19 @@ static void clientWriteCb(uv_write_t* req, int status) {
...
@@ -321,19 +320,19 @@ static void clientWriteCb(uv_write_t* req, int status) {
SCliConn
*
pConn
=
req
->
data
;
SCliConn
*
pConn
=
req
->
data
;
if
(
status
==
0
)
{
if
(
status
==
0
)
{
tDebug
(
"conn %p data already was written out"
,
pConn
);
tDebug
(
"conn %p data already was written out"
,
pConn
);
SCliMsg
*
pMsg
=
pConn
->
data
;
if
(
pMsg
!=
NULL
)
{
transFreeMsg
((
pMsg
->
msg
.
pCont
));
pMsg
->
msg
.
pCont
=
NULL
;
}
}
else
{
}
else
{
tError
(
"conn %p failed to write: %s"
,
pConn
,
uv_err_name
(
status
));
tError
(
"conn %p failed to write: %s"
,
pConn
,
uv_err_name
(
status
));
clientHandleExcept
(
pConn
);
clientHandleExcept
(
pConn
);
return
;
return
;
}
}
SCliThrdObj
*
pThrd
=
pConn
->
hostThrd
;
SCliThrdObj
*
pThrd
=
pConn
->
hostThrd
;
// if (pConn->stream == NULL) {
// pConn->stream = (uv_stream_t*)malloc(sizeof(uv_tcp_t));
// uv_tcp_init(pThrd->loop, (uv_tcp_t*)pConn->stream);
// pConn->stream->data = pConn;
//}
uv_read_start
((
uv_stream_t
*
)
pConn
->
stream
,
clientAllocBufferCb
,
clientReadCb
);
uv_read_start
((
uv_stream_t
*
)
pConn
->
stream
,
clientAllocBufferCb
,
clientReadCb
);
// impl later
}
}
static
void
clientWrite
(
SCliConn
*
pConn
)
{
static
void
clientWrite
(
SCliConn
*
pConn
)
{
...
@@ -378,7 +377,7 @@ static void clientHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
...
@@ -378,7 +377,7 @@ static void clientHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
tDebug
(
"conn %p get from conn pool"
,
conn
);
tDebug
(
"conn %p get from conn pool"
,
conn
);
conn
->
data
=
pMsg
;
conn
->
data
=
pMsg
;
conn
->
writeReq
->
data
=
conn
;
conn
->
writeReq
->
data
=
conn
;
//
transDestroyBuffer(&conn->readBuf);
transDestroyBuffer
(
&
conn
->
readBuf
);
clientWrite
(
conn
);
clientWrite
(
conn
);
}
else
{
}
else
{
SCliConn
*
conn
=
calloc
(
1
,
sizeof
(
SCliConn
));
SCliConn
*
conn
=
calloc
(
1
,
sizeof
(
SCliConn
));
...
...
source/libs/transport/src/transSrv.c
浏览文件 @
b65bbcfd
...
@@ -306,6 +306,7 @@ void uvOnTimeoutCb(uv_timer_t* handle) {
...
@@ -306,6 +306,7 @@ void uvOnTimeoutCb(uv_timer_t* handle) {
void
uvOnWriteCb
(
uv_write_t
*
req
,
int
status
)
{
void
uvOnWriteCb
(
uv_write_t
*
req
,
int
status
)
{
SSrvConn
*
conn
=
req
->
data
;
SSrvConn
*
conn
=
req
->
data
;
SSrvMsg
*
smsg
=
conn
->
pSrvMsg
;
SSrvMsg
*
smsg
=
conn
->
pSrvMsg
;
destroySrvMsg
(
conn
);
transClearBuffer
(
&
conn
->
readBuf
);
transClearBuffer
(
&
conn
->
readBuf
);
if
(
status
==
0
)
{
if
(
status
==
0
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录