Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1c519bca
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
1c519bca
编写于
11月 10, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
redefine timer
上级
5c5d70e0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
17 deletion
+21
-17
source/libs/transport/inc/transComm.h
source/libs/transport/inc/transComm.h
+1
-1
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+20
-16
未找到文件。
source/libs/transport/inc/transComm.h
浏览文件 @
1c519bca
...
...
@@ -96,7 +96,7 @@ typedef void* queue[2];
#define TRANS_RETRY_COUNT_LIMIT 100 // retry count limit
#define TRANS_RETRY_INTERVAL 15 // retry interval (ms)
#define TRANS_CONN_TIMEOUT 3
// connect timeout (s)
#define TRANS_CONN_TIMEOUT 3
000
// connect timeout (s)
#define TRANS_READ_TIMEOUT 3000 // read timeout (ms)
#define TRANS_PACKET_LIMIT 1024 * 1024 * 512
...
...
source/libs/transport/src/transCli.c
浏览文件 @
1c519bca
...
...
@@ -25,7 +25,9 @@ typedef struct SCliConn {
uv_connect_t
connReq
;
uv_stream_t
*
stream
;
queue
wreqQueue
;
uv_timer_t
*
timer
;
uv_timer_t
*
timer
;
// read timer, forbidden
uv_timer_t
connTimer
;
void
*
hostThrd
;
...
...
@@ -102,6 +104,8 @@ static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port);
static
void
addConnToPool
(
void
*
pool
,
SCliConn
*
conn
);
static
void
doCloseIdleConn
(
void
*
param
);
// register conn timer
static
void
cliConnTimeout
(
uv_timer_t
*
handle
);
// register timer for read
static
void
cliReadTimeoutCb
(
uv_timer_t
*
handle
);
// register timer in each thread to clear expire conn
...
...
@@ -462,6 +466,12 @@ void cliHandleExcept(SCliConn* conn) {
cliHandleExceptImpl
(
conn
,
-
1
);
}
void
cliConnTimeout
(
uv_timer_t
*
handle
)
{
SCliConn
*
conn
=
handle
->
data
;
tTrace
(
"%s conn %p conn timeout, ref:%d"
,
CONN_GET_INST_LABEL
(
conn
),
conn
,
T_REF_VAL_GET
(
conn
));
uv_timer_stop
(
handle
);
cliHandleExceptImpl
(
conn
,
TSDB_CODE_RPC_TIMEOUT
);
}
void
cliReadTimeoutCb
(
uv_timer_t
*
handle
)
{
// set up timeout cb
SCliConn
*
conn
=
handle
->
data
;
...
...
@@ -638,8 +648,10 @@ static SCliConn* cliCreateConn(SCliThrd* pThrd) {
uv_tcp_init
(
pThrd
->
loop
,
(
uv_tcp_t
*
)(
conn
->
stream
));
conn
->
stream
->
data
=
conn
;
conn
->
connReq
.
data
=
conn
;
uv_timer_init
(
pThrd
->
loop
,
&
conn
->
connTimer
);
conn
->
connTimer
.
data
=
conn
;
conn
->
connReq
.
data
=
conn
;
transReqQueueInit
(
&
conn
->
wreqQueue
);
transQueueInit
(
&
conn
->
cliMsgs
,
NULL
);
...
...
@@ -819,6 +831,8 @@ _RETURN:
void
cliConnCb
(
uv_connect_t
*
req
,
int
status
)
{
// impl later
SCliConn
*
pConn
=
req
->
data
;
uv_timer_stop
(
&
pConn
->
connTimer
);
if
(
status
!=
0
)
{
tError
(
"%s conn %p failed to connect server:%s"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
,
uv_strerror
(
status
));
cliHandleExcept
(
pConn
);
...
...
@@ -997,31 +1011,21 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
conn
->
ip
=
strdup
(
EPSET_GET_INUSE_IP
(
&
pCtx
->
epSet
));
conn
->
port
=
EPSET_GET_INUSE_PORT
(
&
pCtx
->
epSet
);
int
ret
=
transSetConnOption
((
uv_tcp_t
*
)
conn
->
stream
);
if
(
ret
)
{
tError
(
"%s conn %p failed to set conn option, errmsg %s"
,
transLabel
(
pTransInst
),
conn
,
uv_err_name
(
ret
));
}
int32_t
fd
=
taosCreateSocketWithTimeout
(
TRANS_CONN_TIMEOUT
);
if
(
fd
==
-
1
)
{
tTrace
(
"%s conn %p failed to create socket"
,
transLabel
(
pTransInst
),
conn
);
cliHandleExcept
(
conn
);
return
;
}
uv_tcp_open
((
uv_tcp_t
*
)
conn
->
stream
,
fd
);
struct
sockaddr_in
addr
;
addr
.
sin_family
=
AF_INET
;
addr
.
sin_addr
.
s_addr
=
cliGetIpFromFqdnCache
(
pThrd
->
fqdn2ipCache
,
conn
->
ip
);
addr
.
sin_port
=
(
uint16_t
)
htons
((
uint16_t
)
conn
->
port
);
tTrace
(
"%s conn %p try to connect to %s:%d"
,
pTransInst
->
label
,
conn
,
conn
->
ip
,
conn
->
port
);
ret
=
uv_tcp_connect
(
&
conn
->
connReq
,
(
uv_tcp_t
*
)(
conn
->
stream
),
(
const
struct
sockaddr
*
)
&
addr
,
cliConnCb
);
int
ret
=
uv_tcp_connect
(
&
conn
->
connReq
,
(
uv_tcp_t
*
)(
conn
->
stream
),
(
const
struct
sockaddr
*
)
&
addr
,
cliConnCb
);
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
);
cliHandleExcept
(
conn
);
return
;
}
uv_timer_start
(
&
conn
->
connTimer
,
cliConnTimeout
,
TRANS_CONN_TIMEOUT
,
0
);
}
STraceId
*
trace
=
&
pMsg
->
msg
.
info
.
traceId
;
tGTrace
(
"%s conn %p ready"
,
pTransInst
->
label
,
conn
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录