Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
50f148ab
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
50f148ab
编写于
11月 11, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
conn timeout refactor
上级
1c519bca
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
44 addition
and
8 deletion
+44
-8
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+44
-8
未找到文件。
source/libs/transport/src/transCli.c
浏览文件 @
50f148ab
...
...
@@ -27,7 +27,6 @@ typedef struct SCliConn {
queue
wreqQueue
;
uv_timer_t
*
timer
;
// read timer, forbidden
uv_timer_t
connTimer
;
void
*
hostThrd
;
...
...
@@ -468,8 +467,15 @@ void cliHandleExcept(SCliConn* conn) {
void
cliConnTimeout
(
uv_timer_t
*
handle
)
{
SCliConn
*
conn
=
handle
->
data
;
SCliThrd
*
pThrd
=
conn
->
hostThrd
;
tTrace
(
"%s conn %p conn timeout, ref:%d"
,
CONN_GET_INST_LABEL
(
conn
),
conn
,
T_REF_VAL_GET
(
conn
));
uv_timer_stop
(
handle
);
handle
->
data
=
NULL
;
taosArrayPush
(
pThrd
->
timerList
,
&
conn
->
timer
);
conn
->
timer
=
NULL
;
cliHandleExceptImpl
(
conn
,
TSDB_CODE_RPC_TIMEOUT
);
}
void
cliReadTimeoutCb
(
uv_timer_t
*
handle
)
{
...
...
@@ -648,8 +654,14 @@ static SCliConn* cliCreateConn(SCliThrd* pThrd) {
uv_tcp_init
(
pThrd
->
loop
,
(
uv_tcp_t
*
)(
conn
->
stream
));
conn
->
stream
->
data
=
conn
;
uv_timer_init
(
pThrd
->
loop
,
&
conn
->
connTimer
);
conn
->
connTimer
.
data
=
conn
;
uv_timer_t
*
timer
=
taosArrayGetSize
(
pThrd
->
timerList
)
>
0
?
*
(
uv_timer_t
**
)
taosArrayPop
(
pThrd
->
timerList
)
:
NULL
;
if
(
timer
==
NULL
)
{
timer
=
taosMemoryCalloc
(
1
,
sizeof
(
uv_timer_t
));
tDebug
(
"no available timer, create a timer %p"
,
timer
);
uv_timer_init
(
pThrd
->
loop
,
timer
);
}
timer
->
data
=
conn
;
conn
->
timer
=
timer
;
conn
->
connReq
.
data
=
conn
;
transReqQueueInit
(
&
conn
->
wreqQueue
);
...
...
@@ -831,7 +843,12 @@ _RETURN:
void
cliConnCb
(
uv_connect_t
*
req
,
int
status
)
{
// impl later
SCliConn
*
pConn
=
req
->
data
;
uv_timer_stop
(
&
pConn
->
connTimer
);
SCliThrd
*
pThrd
=
pConn
->
hostThrd
;
uv_timer_stop
(
pConn
->
timer
);
pConn
->
timer
->
data
=
NULL
;
taosArrayPush
(
pThrd
->
timerList
,
&
pConn
->
timer
);
pConn
->
timer
=
NULL
;
if
(
status
!=
0
)
{
tError
(
"%s conn %p failed to connect server:%s"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
,
uv_strerror
(
status
));
...
...
@@ -1021,11 +1038,16 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
if
(
ret
!=
0
)
{
tTrace
(
"%s conn %p failed to connect to %s:%d, reason:%s"
,
pTransInst
->
label
,
conn
,
conn
->
ip
,
conn
->
port
,
uv_err_name
(
ret
));
uv_timer_stop
(
&
conn
->
connTimer
);
uv_timer_stop
(
conn
->
timer
);
conn
->
timer
->
data
=
NULL
;
taosArrayPush
(
pThrd
->
timerList
,
&
conn
->
timer
);
conn
->
timer
=
NULL
;
cliHandleExcept
(
conn
);
return
;
}
uv_timer_start
(
&
conn
->
connT
imer
,
cliConnTimeout
,
TRANS_CONN_TIMEOUT
,
0
);
uv_timer_start
(
conn
->
t
imer
,
cliConnTimeout
,
TRANS_CONN_TIMEOUT
,
0
);
}
STraceId
*
trace
=
&
pMsg
->
msg
.
info
.
traceId
;
tGTrace
(
"%s conn %p ready"
,
pTransInst
->
label
,
conn
);
...
...
@@ -1148,6 +1170,8 @@ static void* cliWorkThread(void* arg) {
pThrd
->
pid
=
taosGetSelfPthreadId
();
setThreadName
(
"trans-cli-work"
);
uv_run
(
pThrd
->
loop
,
UV_RUN_DEFAULT
);
tDebug
(
"thread quit-thread:%08"
PRId64
,
pThrd
->
pid
);
return
NULL
;
}
...
...
@@ -1207,7 +1231,7 @@ static SCliThrd* createThrdObj(void* trans) {
pThrd
->
prepare
->
data
=
pThrd
;
// uv_prepare_start(pThrd->prepare, cliPrepareCb);
int32_t
timerSize
=
512
;
int32_t
timerSize
=
64
;
pThrd
->
timerList
=
taosArrayInit
(
timerSize
,
sizeof
(
void
*
));
for
(
int
i
=
0
;
i
<
timerSize
;
i
++
)
{
uv_timer_t
*
timer
=
taosMemoryCalloc
(
1
,
sizeof
(
uv_timer_t
));
...
...
@@ -1241,6 +1265,7 @@ static void destroyThrdObj(SCliThrd* pThrd) {
transDQDestroy
(
pThrd
->
delayQueue
,
destroyCmsg
);
transDQDestroy
(
pThrd
->
timeoutQueue
,
NULL
);
tDebug
(
"thread destroy %"
PRId64
,
pThrd
->
pid
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pThrd
->
timerList
);
i
++
)
{
uv_timer_t
*
timer
=
taosArrayGetP
(
pThrd
->
timerList
,
i
);
taosMemoryFree
(
timer
);
...
...
@@ -1266,7 +1291,18 @@ void cliSendQuit(SCliThrd* thrd) {
}
void
cliWalkCb
(
uv_handle_t
*
handle
,
void
*
arg
)
{
if
(
!
uv_is_closing
(
handle
))
{
uv_read_stop
((
uv_stream_t
*
)
handle
);
if
(
uv_handle_get_type
(
handle
)
==
UV_TIMER
)
{
// SCliConn* pConn = handle->data;
// if (pConn != NULL && pConn->timer != NULL) {
// SCliThrd* pThrd = pConn->hostThrd;
// uv_timer_stop((uv_timer_t*)handle);
// handle->data = NULL;
// taosArrayPush(pThrd->timerList, &pConn->timer);
// pConn->timer = NULL;
// }
}
else
{
uv_read_stop
((
uv_stream_t
*
)
handle
);
}
uv_close
(
handle
,
cliDestroy
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录