Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
590f7c4c
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看板
未验证
提交
590f7c4c
编写于
7月 15, 2022
作者:
dengyihao
提交者:
GitHub
7月 15, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14915 from taosdata/enh/preallocHandle
enh: prealloc handle
上级
84740bc7
d7a463da
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
58 addition
and
15 deletion
+58
-15
include/libs/transport/trpc.h
include/libs/transport/trpc.h
+1
-0
source/libs/transport/inc/transComm.h
source/libs/transport/inc/transComm.h
+2
-0
source/libs/transport/src/trans.c
source/libs/transport/src/trans.c
+2
-2
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+53
-13
未找到文件。
include/libs/transport/trpc.h
浏览文件 @
590f7c4c
...
...
@@ -135,6 +135,7 @@ void rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg
int32_t
rpcGetConnInfo
(
void
*
thandle
,
SRpcConnInfo
*
pInfo
);
void
rpcSendRecv
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pReq
,
SRpcMsg
*
pRsp
);
void
rpcSetDefaultAddr
(
void
*
thandle
,
const
char
*
ip
,
const
char
*
fqdn
);
int64_t
rpcAllocHandle
();
#ifdef __cplusplus
}
...
...
source/libs/transport/inc/transComm.h
浏览文件 @
590f7c4c
...
...
@@ -298,6 +298,8 @@ void transSendResponse(const STransMsg* msg);
void
transRegisterMsg
(
const
STransMsg
*
msg
);
void
transSetDefaultAddr
(
void
*
shandle
,
const
char
*
ip
,
const
char
*
fqdn
);
int64_t
transAllocHandle
();
void
*
transInitServer
(
uint32_t
ip
,
uint32_t
port
,
char
*
label
,
int
numOfThreads
,
void
*
fp
,
void
*
shandle
);
void
*
transInitClient
(
uint32_t
ip
,
uint32_t
port
,
char
*
label
,
int
numOfThreads
,
void
*
fp
,
void
*
shandle
);
...
...
source/libs/transport/src/trans.c
浏览文件 @
590f7c4c
...
...
@@ -149,8 +149,6 @@ void rpcSendRecv(void* shandle, SEpSet* pEpSet, SRpcMsg* pMsg, SRpcMsg* pRsp) {
void
rpcSendResponse
(
const
SRpcMsg
*
pMsg
)
{
transSendResponse
(
pMsg
);
}
int32_t
rpcGetConnInfo
(
void
*
thandle
,
SRpcConnInfo
*
pInfo
)
{
return
0
;
}
void
rpcRefHandle
(
void
*
handle
,
int8_t
type
)
{
assert
(
type
==
TAOS_CONN_SERVER
||
type
==
TAOS_CONN_CLIENT
);
(
*
taosRefHandle
[
type
])(
handle
);
...
...
@@ -172,6 +170,8 @@ void rpcSetDefaultAddr(void* thandle, const char* ip, const char* fqdn) {
transSetDefaultAddr
(
thandle
,
ip
,
fqdn
);
}
int64_t
rpcAllocHandle
()
{
return
transAllocHandle
();
}
int32_t
rpcInit
()
{
transInit
();
return
0
;
...
...
source/libs/transport/src/transCli.c
浏览文件 @
590f7c4c
...
...
@@ -504,7 +504,7 @@ static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port) {
assert
(
h
==
&
conn
->
conn
);
return
conn
;
}
static
void
allocConnRef
(
SCliConn
*
conn
,
bool
update
)
{
static
int32_t
allocConnRef
(
SCliConn
*
conn
,
bool
update
)
{
if
(
update
)
{
transRemoveExHandle
(
transGetRefMgt
(),
conn
->
refId
);
conn
->
refId
=
-
1
;
...
...
@@ -514,6 +514,24 @@ static void allocConnRef(SCliConn* conn, bool update) {
exh
->
pThrd
=
conn
->
hostThrd
;
exh
->
refId
=
transAddExHandle
(
transGetRefMgt
(),
exh
);
conn
->
refId
=
exh
->
refId
;
return
0
;
}
static
int32_t
specifyConnRef
(
SCliConn
*
conn
,
bool
update
,
int64_t
handle
)
{
if
(
update
)
{
transRemoveExHandle
(
transGetRefMgt
(),
conn
->
refId
);
conn
->
refId
=
-
1
;
}
SExHandle
*
exh
=
transAcquireExHandle
(
transGetRefMgt
(),
handle
);
if
(
exh
==
NULL
)
{
return
-
1
;
}
exh
->
handle
=
conn
;
exh
->
pThrd
=
conn
->
hostThrd
;
conn
->
refId
=
exh
->
refId
;
transReleaseExHandle
(
transGetRefMgt
(),
handle
);
return
0
;
}
static
void
addConnToPool
(
void
*
pool
,
SCliConn
*
conn
)
{
if
(
conn
->
status
==
ConnInPool
)
{
...
...
@@ -753,9 +771,12 @@ static void cliHandleRelease(SCliMsg* pMsg, SCliThrd* pThrd) {
SExHandle
*
exh
=
transAcquireExHandle
(
transGetRefMgt
(),
refId
);
if
(
exh
==
NULL
)
{
tDebug
(
"%"
PRId64
" already release"
,
refId
);
return
;
}
SCliConn
*
conn
=
exh
->
handle
;
transReleaseExHandle
(
transGetRefMgt
(),
refId
);
tDebug
(
"%s conn %p start to release to inst"
,
CONN_GET_INST_LABEL
(
conn
),
conn
);
if
(
T_REF_VAL_GET
(
conn
)
==
2
)
{
...
...
@@ -773,8 +794,10 @@ static void cliHandleUpdate(SCliMsg* pMsg, SCliThrd* pThrd) {
}
SCliConn
*
cliGetConn
(
SCliMsg
*
pMsg
,
SCliThrd
*
pThrd
,
bool
*
ignore
)
{
SCliConn
*
conn
=
NULL
;
int64_t
refId
=
(
int64_t
)(
pMsg
->
msg
.
info
.
handle
);
STransConnCtx
*
pCtx
=
pMsg
->
ctx
;
SCliConn
*
conn
=
NULL
;
int64_t
refId
=
(
int64_t
)(
pMsg
->
msg
.
info
.
handle
);
if
(
refId
!=
0
)
{
SExHandle
*
exh
=
transAcquireExHandle
(
transGetRefMgt
(),
refId
);
if
(
exh
==
NULL
)
{
...
...
@@ -783,12 +806,15 @@ SCliConn* cliGetConn(SCliMsg* pMsg, SCliThrd* pThrd, bool* ignore) {
return
NULL
;
}
else
{
conn
=
exh
->
handle
;
if
(
conn
==
NULL
)
{
conn
=
getConnFromPool
(
pThrd
->
pool
,
EPSET_GET_INUSE_IP
(
&
pCtx
->
epSet
),
EPSET_GET_INUSE_PORT
(
&
pCtx
->
epSet
));
*
ignore
=
(
conn
&&
0
==
specifyConnRef
(
conn
,
true
,
refId
))
?
false
:
true
;
}
transReleaseExHandle
(
transGetRefMgt
(),
refId
);
}
return
conn
;
};
STransConnCtx
*
pCtx
=
pMsg
->
ctx
;
conn
=
getConnFromPool
(
pThrd
->
pool
,
EPSET_GET_INUSE_IP
(
&
pCtx
->
epSet
),
EPSET_GET_INUSE_PORT
(
&
pCtx
->
epSet
));
if
(
conn
!=
NULL
)
{
tTrace
(
"%s conn %p get from conn pool:%p"
,
CONN_GET_INST_LABEL
(
conn
),
conn
,
pThrd
->
pool
);
...
...
@@ -1161,27 +1187,31 @@ void transUnrefCliHandle(void* handle) {
cliDestroyConn
((
SCliConn
*
)
handle
,
true
);
}
}
SCliThrd
*
transGetWorkThrdFromHandle
(
int64_t
handle
)
{
SCliThrd
*
transGetWorkThrdFromHandle
(
int64_t
handle
,
bool
*
validHandle
)
{
SCliThrd
*
pThrd
=
NULL
;
SExHandle
*
exh
=
transAcquireExHandle
(
transGetRefMgt
(),
handle
);
if
(
exh
==
NULL
)
{
return
NULL
;
}
*
validHandle
=
true
;
pThrd
=
exh
->
pThrd
;
transReleaseExHandle
(
transGetRefMgt
(),
handle
);
return
pThrd
;
}
SCliThrd
*
transGetWorkThrd
(
STrans
*
trans
,
int64_t
handle
)
{
SCliThrd
*
transGetWorkThrd
(
STrans
*
trans
,
int64_t
handle
,
bool
*
validHandle
)
{
if
(
handle
==
0
)
{
int
idx
=
cliRBChoseIdx
(
trans
);
if
(
idx
<
0
)
return
NULL
;
return
((
SCliObj
*
)
trans
->
tcphandle
)
->
pThreadObj
[
idx
];
}
return
transGetWorkThrdFromHandle
(
handle
);
return
transGetWorkThrdFromHandle
(
handle
,
validHandle
);
}
void
transReleaseCliHandle
(
void
*
handle
)
{
int
idx
=
-
1
;
SCliThrd
*
pThrd
=
transGetWorkThrdFromHandle
((
int64_t
)
handle
);
int
idx
=
-
1
;
bool
valid
=
false
;
SCliThrd
*
pThrd
=
transGetWorkThrdFromHandle
((
int64_t
)
handle
,
&
valid
);
if
(
pThrd
==
NULL
)
{
return
;
}
...
...
@@ -1198,8 +1228,9 @@ void transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STra
STrans
*
pTransInst
=
(
STrans
*
)
transAcquireExHandle
(
transGetInstMgt
(),
(
int64_t
)
shandle
);
if
(
pTransInst
==
NULL
)
return
;
SCliThrd
*
pThrd
=
transGetWorkThrd
(
pTransInst
,
(
int64_t
)
pReq
->
info
.
handle
);
if
(
pThrd
==
NULL
)
{
bool
valid
=
false
;
SCliThrd
*
pThrd
=
transGetWorkThrd
(
pTransInst
,
(
int64_t
)
pReq
->
info
.
handle
,
&
valid
);
if
(
pThrd
==
NULL
&&
valid
==
false
)
{
transFreeMsg
(
pReq
->
pCont
);
transReleaseExHandle
(
transGetInstMgt
(),
(
int64_t
)
shandle
);
return
;
...
...
@@ -1236,12 +1267,14 @@ void transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransM
STrans
*
pTransInst
=
(
STrans
*
)
transAcquireExHandle
(
transGetInstMgt
(),
(
int64_t
)
shandle
);
if
(
pTransInst
==
NULL
)
return
;
SCliThrd
*
pThrd
=
transGetWorkThrd
(
pTransInst
,
(
int64_t
)
pReq
->
info
.
handle
);
if
(
pThrd
==
NULL
)
{
bool
valid
=
false
;
SCliThrd
*
pThrd
=
transGetWorkThrd
(
pTransInst
,
(
int64_t
)
pReq
->
info
.
handle
,
&
valid
);
if
(
pThrd
==
NULL
&&
valid
==
false
)
{
transFreeMsg
(
pReq
->
pCont
);
transReleaseExHandle
(
transGetInstMgt
(),
(
int64_t
)
shandle
);
return
;
}
tsem_t
*
sem
=
taosMemoryCalloc
(
1
,
sizeof
(
tsem_t
));
tsem_init
(
sem
,
0
,
0
);
...
...
@@ -1303,4 +1336,11 @@ void transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn) {
}
transReleaseExHandle
(
transGetInstMgt
(),
(
int64_t
)
shandle
);
}
int64_t
transAllocHandle
()
{
SExHandle
*
exh
=
taosMemoryCalloc
(
1
,
sizeof
(
SExHandle
));
exh
->
refId
=
transAddExHandle
(
transGetRefMgt
(),
exh
);
tDebug
(
"pre alloc refId %"
PRId64
""
,
exh
->
refId
);
return
exh
->
refId
;
}
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录