Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e26c474f
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
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看板
未验证
提交
e26c474f
编写于
11月 12, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
11月 12, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18076 from taosdata/fix/avoidAhandleleak
fix: avoid ahandle leak
上级
7af24443
5a0da6d2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
102 addition
and
28 deletion
+102
-28
source/client/src/clientHb.c
source/client/src/clientHb.c
+4
-1
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
+95
-24
source/libs/transport/src/transComm.c
source/libs/transport/src/transComm.c
+1
-1
source/util/src/tlog.c
source/util/src/tlog.c
+1
-1
未找到文件。
source/client/src/clientHb.c
浏览文件 @
e26c474f
...
@@ -61,7 +61,8 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
...
@@ -61,7 +61,8 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
int32_t
numOfBatchs
=
taosArrayGetSize
(
batchUseRsp
.
pArray
);
int32_t
numOfBatchs
=
taosArrayGetSize
(
batchUseRsp
.
pArray
);
for
(
int32_t
i
=
0
;
i
<
numOfBatchs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfBatchs
;
++
i
)
{
SUseDbRsp
*
rsp
=
taosArrayGet
(
batchUseRsp
.
pArray
,
i
);
SUseDbRsp
*
rsp
=
taosArrayGet
(
batchUseRsp
.
pArray
,
i
);
tscDebug
(
"hb db rsp, db:%s, vgVersion:%d, stateTs:%"
PRId64
", uid:%"
PRIx64
,
rsp
->
db
,
rsp
->
vgVersion
,
rsp
->
stateTs
,
rsp
->
uid
);
tscDebug
(
"hb db rsp, db:%s, vgVersion:%d, stateTs:%"
PRId64
", uid:%"
PRIx64
,
rsp
->
db
,
rsp
->
vgVersion
,
rsp
->
stateTs
,
rsp
->
uid
);
if
(
rsp
->
vgVersion
<
0
)
{
if
(
rsp
->
vgVersion
<
0
)
{
code
=
catalogRemoveDB
(
pCatalog
,
rsp
->
db
,
rsp
->
uid
);
code
=
catalogRemoveDB
(
pCatalog
,
rsp
->
db
,
rsp
->
uid
);
...
@@ -293,6 +294,7 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
...
@@ -293,6 +294,7 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
taosThreadMutexUnlock
(
&
appInfo
.
mutex
);
taosThreadMutexUnlock
(
&
appInfo
.
mutex
);
tscError
(
"cluster not exist, key:%s"
,
key
);
tscError
(
"cluster not exist, key:%s"
,
key
);
taosMemoryFree
(
pMsg
->
pData
);
taosMemoryFree
(
pMsg
->
pData
);
taosMemoryFree
(
pMsg
->
pEpSet
);
tFreeClientHbBatchRsp
(
&
pRsp
);
tFreeClientHbBatchRsp
(
&
pRsp
);
return
-
1
;
return
-
1
;
}
}
...
@@ -322,6 +324,7 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
...
@@ -322,6 +324,7 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
tFreeClientHbBatchRsp
(
&
pRsp
);
tFreeClientHbBatchRsp
(
&
pRsp
);
taosMemoryFree
(
pMsg
->
pData
);
taosMemoryFree
(
pMsg
->
pData
);
taosMemoryFree
(
pMsg
->
pEpSet
);
return
code
;
return
code
;
}
}
...
...
source/libs/transport/inc/transComm.h
浏览文件 @
e26c474f
...
@@ -96,7 +96,7 @@ typedef void* queue[2];
...
@@ -96,7 +96,7 @@ typedef void* queue[2];
//#define TRANS_RETRY_COUNT_LIMIT 100 // retry count limit
//#define TRANS_RETRY_COUNT_LIMIT 100 // retry count limit
//#define TRANS_RETRY_INTERVAL 15 // retry interval (ms)
//#define TRANS_RETRY_INTERVAL 15 // retry interval (ms)
#define TRANS_CONN_TIMEOUT 3
// connect timeout (
s)
#define TRANS_CONN_TIMEOUT 3
000 // connect timeout (m
s)
#define TRANS_READ_TIMEOUT 3000 // read timeout (ms)
#define TRANS_READ_TIMEOUT 3000 // read timeout (ms)
#define TRANS_PACKET_LIMIT 1024 * 1024 * 512
#define TRANS_PACKET_LIMIT 1024 * 1024 * 512
...
...
source/libs/transport/src/transCli.c
浏览文件 @
e26c474f
...
@@ -25,7 +25,8 @@ typedef struct SCliConn {
...
@@ -25,7 +25,8 @@ typedef struct SCliConn {
uv_connect_t
connReq
;
uv_connect_t
connReq
;
uv_stream_t
*
stream
;
uv_stream_t
*
stream
;
queue
wreqQueue
;
queue
wreqQueue
;
uv_timer_t
*
timer
;
uv_timer_t
*
timer
;
// read timer, forbidden
void
*
hostThrd
;
void
*
hostThrd
;
...
@@ -79,6 +80,7 @@ typedef struct SCliThrd {
...
@@ -79,6 +80,7 @@ typedef struct SCliThrd {
uint64_t
nextTimeout
;
// next timeout
uint64_t
nextTimeout
;
// next timeout
void
*
pTransInst
;
//
void
*
pTransInst
;
//
void
(
*
destroyAhandleFp
)(
void
*
ahandle
);
SHashObj
*
fqdn2ipCache
;
SHashObj
*
fqdn2ipCache
;
SCvtAddr
cvtAddr
;
SCvtAddr
cvtAddr
;
...
@@ -102,6 +104,8 @@ static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port);
...
@@ -102,6 +104,8 @@ static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port);
static
void
addConnToPool
(
void
*
pool
,
SCliConn
*
conn
);
static
void
addConnToPool
(
void
*
pool
,
SCliConn
*
conn
);
static
void
doCloseIdleConn
(
void
*
param
);
static
void
doCloseIdleConn
(
void
*
param
);
// register conn timer
static
void
cliConnTimeout
(
uv_timer_t
*
handle
);
// register timer for read
// register timer for read
static
void
cliReadTimeoutCb
(
uv_timer_t
*
handle
);
static
void
cliReadTimeoutCb
(
uv_timer_t
*
handle
);
// register timer in each thread to clear expire conn
// register timer in each thread to clear expire conn
...
@@ -155,6 +159,7 @@ static void (*cliAsyncHandle[])(SCliMsg* pMsg, SCliThrd* pThrd) = {cliHandleReq,
...
@@ -155,6 +159,7 @@ static void (*cliAsyncHandle[])(SCliMsg* pMsg, SCliThrd* pThrd) = {cliHandleReq,
static
FORCE_INLINE
void
destroyUserdata
(
STransMsg
*
userdata
);
static
FORCE_INLINE
void
destroyUserdata
(
STransMsg
*
userdata
);
static
FORCE_INLINE
void
destroyCmsg
(
void
*
cmsg
);
static
FORCE_INLINE
void
destroyCmsg
(
void
*
cmsg
);
static
FORCE_INLINE
void
destroyCmsgAndAhandle
(
void
*
cmsg
);
static
FORCE_INLINE
int
cliRBChoseIdx
(
STrans
*
pTransInst
);
static
FORCE_INLINE
int
cliRBChoseIdx
(
STrans
*
pTransInst
);
static
FORCE_INLINE
void
transDestroyConnCtx
(
STransConnCtx
*
ctx
);
static
FORCE_INLINE
void
transDestroyConnCtx
(
STransConnCtx
*
ctx
);
...
@@ -258,16 +263,15 @@ static void* cliWorkThread(void* arg);
...
@@ -258,16 +263,15 @@ static void* cliWorkThread(void* arg);
static
void
cliReleaseUnfinishedMsg
(
SCliConn
*
conn
)
{
static
void
cliReleaseUnfinishedMsg
(
SCliConn
*
conn
)
{
SCliThrd
*
pThrd
=
conn
->
hostThrd
;
SCliThrd
*
pThrd
=
conn
->
hostThrd
;
STrans
*
pTransInst
=
pThrd
->
pTransInst
;
for
(
int
i
=
0
;
i
<
transQueueSize
(
&
conn
->
cliMsgs
);
i
++
)
{
for
(
int
i
=
0
;
i
<
transQueueSize
(
&
conn
->
cliMsgs
);
i
++
)
{
SCliMsg
*
msg
=
transQueueGet
(
&
conn
->
cliMsgs
,
i
);
SCliMsg
*
msg
=
transQueueGet
(
&
conn
->
cliMsgs
,
i
);
if
(
msg
!=
NULL
&&
msg
->
ctx
!=
NULL
&&
msg
->
ctx
->
ahandle
!=
(
void
*
)
0x9527
)
{
if
(
msg
!=
NULL
&&
msg
->
ctx
!=
NULL
&&
msg
->
ctx
->
ahandle
!=
(
void
*
)
0x9527
)
{
if
(
conn
->
ctx
.
freeFunc
!=
NULL
&&
msg
->
ctx
->
ahandle
!=
NULL
)
{
if
(
conn
->
ctx
.
freeFunc
!=
NULL
&&
msg
->
ctx
->
ahandle
!=
NULL
)
{
conn
->
ctx
.
freeFunc
(
msg
->
ctx
->
ahandle
);
conn
->
ctx
.
freeFunc
(
msg
->
ctx
->
ahandle
);
}
else
if
(
msg
->
ctx
->
ahandle
!=
NULL
&&
pT
ransInst
->
destroy
Fp
!=
NULL
)
{
}
else
if
(
msg
->
ctx
->
ahandle
!=
NULL
&&
pT
hrd
->
destroyAhandle
Fp
!=
NULL
)
{
tDebug
(
"%s conn %p destroy unfinished ahandle %p"
,
CONN_GET_INST_LABEL
(
conn
),
conn
,
msg
->
ctx
->
ahandle
);
tDebug
(
"%s conn %p destroy unfinished ahandle %p"
,
CONN_GET_INST_LABEL
(
conn
),
conn
,
msg
->
ctx
->
ahandle
);
pT
ransInst
->
destroy
Fp
(
msg
->
ctx
->
ahandle
);
pT
hrd
->
destroyAhandle
Fp
(
msg
->
ctx
->
ahandle
);
}
}
}
}
destroyCmsg
(
msg
);
destroyCmsg
(
msg
);
...
@@ -407,9 +411,16 @@ void cliHandleExceptImpl(SCliConn* pConn, int32_t code) {
...
@@ -407,9 +411,16 @@ void cliHandleExceptImpl(SCliConn* pConn, int32_t code) {
bool
once
=
false
;
bool
once
=
false
;
do
{
do
{
SCliMsg
*
pMsg
=
transQueuePop
(
&
pConn
->
cliMsgs
);
SCliMsg
*
pMsg
=
transQueuePop
(
&
pConn
->
cliMsgs
);
if
(
pMsg
==
NULL
&&
once
)
{
if
(
pMsg
==
NULL
&&
once
)
{
break
;
break
;
}
}
if
(
pMsg
!=
NULL
&&
REQUEST_NO_RESP
(
&
pMsg
->
msg
))
{
destroyCmsg
(
pMsg
);
break
;
}
STransConnCtx
*
pCtx
=
pMsg
?
pMsg
->
ctx
:
NULL
;
STransConnCtx
*
pCtx
=
pMsg
?
pMsg
->
ctx
:
NULL
;
STransMsg
transMsg
=
{
0
};
STransMsg
transMsg
=
{
0
};
...
@@ -439,6 +450,7 @@ void cliHandleExceptImpl(SCliConn* pConn, int32_t code) {
...
@@ -439,6 +450,7 @@ void cliHandleExceptImpl(SCliConn* pConn, int32_t code) {
continue
;
continue
;
}
}
}
}
if
(
pMsg
==
NULL
||
(
pMsg
&&
pMsg
->
type
!=
Release
))
{
if
(
pMsg
==
NULL
||
(
pMsg
&&
pMsg
->
type
!=
Release
))
{
if
(
cliAppCb
(
pConn
,
&
transMsg
,
pMsg
)
!=
0
)
{
if
(
cliAppCb
(
pConn
,
&
transMsg
,
pMsg
)
!=
0
)
{
return
;
return
;
...
@@ -454,6 +466,19 @@ void cliHandleExcept(SCliConn* conn) {
...
@@ -454,6 +466,19 @@ void cliHandleExcept(SCliConn* conn) {
cliHandleExceptImpl
(
conn
,
-
1
);
cliHandleExceptImpl
(
conn
,
-
1
);
}
}
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
,
-
1
);
}
void
cliReadTimeoutCb
(
uv_timer_t
*
handle
)
{
void
cliReadTimeoutCb
(
uv_timer_t
*
handle
)
{
// set up timeout cb
// set up timeout cb
SCliConn
*
conn
=
handle
->
data
;
SCliConn
*
conn
=
handle
->
data
;
...
@@ -545,7 +570,7 @@ static void addConnToPool(void* pool, SCliConn* conn) {
...
@@ -545,7 +570,7 @@ static void addConnToPool(void* pool, SCliConn* conn) {
if
(
conn
->
list
->
size
>=
50
)
{
if
(
conn
->
list
->
size
>=
50
)
{
STaskArg
*
arg
=
taosMemoryCalloc
(
1
,
sizeof
(
STaskArg
));
STaskArg
*
arg
=
taosMemoryCalloc
(
1
,
sizeof
(
STaskArg
));
arg
->
param1
=
conn
;
arg
->
param1
=
conn
;
arg
->
param2
=
NULL
;
arg
->
param2
=
thrd
;
STrans
*
pTransInst
=
thrd
->
pTransInst
;
STrans
*
pTransInst
=
thrd
->
pTransInst
;
conn
->
task
=
transDQSched
(
thrd
->
timeoutQueue
,
doCloseIdleConn
,
arg
,
CONN_PERSIST_TIME
(
pTransInst
->
idleTime
));
conn
->
task
=
transDQSched
(
thrd
->
timeoutQueue
,
doCloseIdleConn
,
arg
,
CONN_PERSIST_TIME
(
pTransInst
->
idleTime
));
...
@@ -630,8 +655,16 @@ static SCliConn* cliCreateConn(SCliThrd* pThrd) {
...
@@ -630,8 +655,16 @@ static SCliConn* cliCreateConn(SCliThrd* pThrd) {
uv_tcp_init
(
pThrd
->
loop
,
(
uv_tcp_t
*
)(
conn
->
stream
));
uv_tcp_init
(
pThrd
->
loop
,
(
uv_tcp_t
*
)(
conn
->
stream
));
conn
->
stream
->
data
=
conn
;
conn
->
stream
->
data
=
conn
;
conn
->
connReq
.
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
);
transReqQueueInit
(
&
conn
->
wreqQueue
);
transQueueInit
(
&
conn
->
cliMsgs
,
NULL
);
transQueueInit
(
&
conn
->
cliMsgs
,
NULL
);
...
@@ -661,8 +694,8 @@ static void cliDestroyConn(SCliConn* conn, bool clear) {
...
@@ -661,8 +694,8 @@ static void cliDestroyConn(SCliConn* conn, bool clear) {
}
}
if
(
conn
->
timer
!=
NULL
)
{
if
(
conn
->
timer
!=
NULL
)
{
uv_timer_stop
(
conn
->
timer
);
uv_timer_stop
(
conn
->
timer
);
taosArrayPush
(
pThrd
->
timerList
,
&
conn
->
timer
);
conn
->
timer
->
data
=
NULL
;
conn
->
timer
->
data
=
NULL
;
taosArrayPush
(
pThrd
->
timerList
,
&
conn
->
timer
);
conn
->
timer
=
NULL
;
conn
->
timer
=
NULL
;
}
}
...
@@ -811,6 +844,15 @@ _RETURN:
...
@@ -811,6 +844,15 @@ _RETURN:
void
cliConnCb
(
uv_connect_t
*
req
,
int
status
)
{
void
cliConnCb
(
uv_connect_t
*
req
,
int
status
)
{
// impl later
// impl later
SCliConn
*
pConn
=
req
->
data
;
SCliConn
*
pConn
=
req
->
data
;
SCliThrd
*
pThrd
=
pConn
->
hostThrd
;
if
(
pConn
->
timer
!=
NULL
)
{
uv_timer_stop
(
pConn
->
timer
);
pConn
->
timer
->
data
=
NULL
;
taosArrayPush
(
pThrd
->
timerList
,
&
pConn
->
timer
);
pConn
->
timer
=
NULL
;
}
if
(
status
!=
0
)
{
if
(
status
!=
0
)
{
tError
(
"%s conn %p failed to connect server:%s"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
,
uv_strerror
(
status
));
tError
(
"%s conn %p failed to connect server:%s"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
,
uv_strerror
(
status
));
cliHandleExcept
(
pConn
);
cliHandleExcept
(
pConn
);
...
@@ -989,31 +1031,26 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
...
@@ -989,31 +1031,26 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
conn
->
ip
=
strdup
(
EPSET_GET_INUSE_IP
(
&
pCtx
->
epSet
));
conn
->
ip
=
strdup
(
EPSET_GET_INUSE_IP
(
&
pCtx
->
epSet
));
conn
->
port
=
EPSET_GET_INUSE_PORT
(
&
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
;
struct
sockaddr_in
addr
;
addr
.
sin_family
=
AF_INET
;
addr
.
sin_family
=
AF_INET
;
addr
.
sin_addr
.
s_addr
=
cliGetIpFromFqdnCache
(
pThrd
->
fqdn2ipCache
,
conn
->
ip
);
addr
.
sin_addr
.
s_addr
=
cliGetIpFromFqdnCache
(
pThrd
->
fqdn2ipCache
,
conn
->
ip
);
addr
.
sin_port
=
(
uint16_t
)
htons
((
uint16_t
)
conn
->
port
);
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
);
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
)
{
if
(
ret
!=
0
)
{
tTrace
(
"%s conn %p failed to connect to %s:%d, reason:%s"
,
pTransInst
->
label
,
conn
,
conn
->
ip
,
conn
->
port
,
tTrace
(
"%s conn %p failed to connect to %s:%d, reason:%s"
,
pTransInst
->
label
,
conn
,
conn
->
ip
,
conn
->
port
,
uv_err_name
(
ret
));
uv_err_name
(
ret
));
uv_timer_stop
(
conn
->
timer
);
conn
->
timer
->
data
=
NULL
;
taosArrayPush
(
pThrd
->
timerList
,
&
conn
->
timer
);
conn
->
timer
=
NULL
;
cliHandleExcept
(
conn
);
cliHandleExcept
(
conn
);
return
;
return
;
}
}
uv_timer_start
(
conn
->
timer
,
cliConnTimeout
,
TRANS_CONN_TIMEOUT
,
0
);
}
}
STraceId
*
trace
=
&
pMsg
->
msg
.
info
.
traceId
;
STraceId
*
trace
=
&
pMsg
->
msg
.
info
.
traceId
;
tGTrace
(
"%s conn %p ready"
,
pTransInst
->
label
,
conn
);
tGTrace
(
"%s conn %p ready"
,
pTransInst
->
label
,
conn
);
...
@@ -1136,6 +1173,8 @@ static void* cliWorkThread(void* arg) {
...
@@ -1136,6 +1173,8 @@ static void* cliWorkThread(void* arg) {
pThrd
->
pid
=
taosGetSelfPthreadId
();
pThrd
->
pid
=
taosGetSelfPthreadId
();
setThreadName
(
"trans-cli-work"
);
setThreadName
(
"trans-cli-work"
);
uv_run
(
pThrd
->
loop
,
UV_RUN_DEFAULT
);
uv_run
(
pThrd
->
loop
,
UV_RUN_DEFAULT
);
tDebug
(
"thread quit-thread:%08"
PRId64
,
pThrd
->
pid
);
return
NULL
;
return
NULL
;
}
}
...
@@ -1177,6 +1216,25 @@ static FORCE_INLINE void destroyCmsg(void* arg) {
...
@@ -1177,6 +1216,25 @@ static FORCE_INLINE void destroyCmsg(void* arg) {
taosMemoryFree
(
pMsg
);
taosMemoryFree
(
pMsg
);
}
}
static
FORCE_INLINE
void
destroyCmsgAndAhandle
(
void
*
param
)
{
if
(
param
==
NULL
)
return
;
STaskArg
*
arg
=
param
;
SCliMsg
*
pMsg
=
arg
->
param1
;
SCliThrd
*
pThrd
=
arg
->
param2
;
tDebug
(
"destroy Ahandle A"
);
if
(
pThrd
!=
NULL
&&
pThrd
->
destroyAhandleFp
!=
NULL
)
{
tDebug
(
"destroy Ahandle B"
);
pThrd
->
destroyAhandleFp
(
pMsg
->
ctx
->
ahandle
);
}
tDebug
(
"destroy Ahandle C"
);
transDestroyConnCtx
(
pMsg
->
ctx
);
destroyUserdata
(
&
pMsg
->
msg
);
taosMemoryFree
(
pMsg
);
}
static
SCliThrd
*
createThrdObj
(
void
*
trans
)
{
static
SCliThrd
*
createThrdObj
(
void
*
trans
)
{
STrans
*
pTransInst
=
trans
;
STrans
*
pTransInst
=
trans
;
...
@@ -1195,7 +1253,7 @@ static SCliThrd* createThrdObj(void* trans) {
...
@@ -1195,7 +1253,7 @@ static SCliThrd* createThrdObj(void* trans) {
pThrd
->
prepare
->
data
=
pThrd
;
pThrd
->
prepare
->
data
=
pThrd
;
// uv_prepare_start(pThrd->prepare, cliPrepareCb);
// uv_prepare_start(pThrd->prepare, cliPrepareCb);
int32_t
timerSize
=
512
;
int32_t
timerSize
=
64
;
pThrd
->
timerList
=
taosArrayInit
(
timerSize
,
sizeof
(
void
*
));
pThrd
->
timerList
=
taosArrayInit
(
timerSize
,
sizeof
(
void
*
));
for
(
int
i
=
0
;
i
<
timerSize
;
i
++
)
{
for
(
int
i
=
0
;
i
<
timerSize
;
i
++
)
{
uv_timer_t
*
timer
=
taosMemoryCalloc
(
1
,
sizeof
(
uv_timer_t
));
uv_timer_t
*
timer
=
taosMemoryCalloc
(
1
,
sizeof
(
uv_timer_t
));
...
@@ -1211,6 +1269,7 @@ static SCliThrd* createThrdObj(void* trans) {
...
@@ -1211,6 +1269,7 @@ static SCliThrd* createThrdObj(void* trans) {
pThrd
->
nextTimeout
=
taosGetTimestampMs
()
+
CONN_PERSIST_TIME
(
pTransInst
->
idleTime
);
pThrd
->
nextTimeout
=
taosGetTimestampMs
()
+
CONN_PERSIST_TIME
(
pTransInst
->
idleTime
);
pThrd
->
pTransInst
=
trans
;
pThrd
->
pTransInst
=
trans
;
pThrd
->
destroyAhandleFp
=
pTransInst
->
destroyFp
;
pThrd
->
fqdn2ipCache
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
pThrd
->
fqdn2ipCache
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
pThrd
->
quit
=
false
;
pThrd
->
quit
=
false
;
return
pThrd
;
return
pThrd
;
...
@@ -1226,9 +1285,10 @@ static void destroyThrdObj(SCliThrd* pThrd) {
...
@@ -1226,9 +1285,10 @@ static void destroyThrdObj(SCliThrd* pThrd) {
TRANS_DESTROY_ASYNC_POOL_MSG
(
pThrd
->
asyncPool
,
SCliMsg
,
destroyCmsg
);
TRANS_DESTROY_ASYNC_POOL_MSG
(
pThrd
->
asyncPool
,
SCliMsg
,
destroyCmsg
);
transAsyncPoolDestroy
(
pThrd
->
asyncPool
);
transAsyncPoolDestroy
(
pThrd
->
asyncPool
);
transDQDestroy
(
pThrd
->
delayQueue
,
destroyCmsg
);
transDQDestroy
(
pThrd
->
delayQueue
,
destroyCmsg
AndAhandle
);
transDQDestroy
(
pThrd
->
timeoutQueue
,
NULL
);
transDQDestroy
(
pThrd
->
timeoutQueue
,
NULL
);
tDebug
(
"thread destroy %"
PRId64
,
pThrd
->
pid
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pThrd
->
timerList
);
i
++
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pThrd
->
timerList
);
i
++
)
{
uv_timer_t
*
timer
=
taosArrayGetP
(
pThrd
->
timerList
,
i
);
uv_timer_t
*
timer
=
taosArrayGetP
(
pThrd
->
timerList
,
i
);
taosMemoryFree
(
timer
);
taosMemoryFree
(
timer
);
...
@@ -1254,7 +1314,18 @@ void cliSendQuit(SCliThrd* thrd) {
...
@@ -1254,7 +1314,18 @@ void cliSendQuit(SCliThrd* thrd) {
}
}
void
cliWalkCb
(
uv_handle_t
*
handle
,
void
*
arg
)
{
void
cliWalkCb
(
uv_handle_t
*
handle
,
void
*
arg
)
{
if
(
!
uv_is_closing
(
handle
))
{
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
);
uv_close
(
handle
,
cliDestroy
);
}
}
}
}
...
...
source/libs/transport/src/transComm.c
浏览文件 @
e26c474f
...
@@ -497,7 +497,7 @@ void transDQDestroy(SDelayQueue* queue, void (*freeFunc)(void* arg)) {
...
@@ -497,7 +497,7 @@ void transDQDestroy(SDelayQueue* queue, void (*freeFunc)(void* arg)) {
SDelayTask
*
task
=
container_of
(
minNode
,
SDelayTask
,
node
);
SDelayTask
*
task
=
container_of
(
minNode
,
SDelayTask
,
node
);
STaskArg
*
arg
=
task
->
arg
;
STaskArg
*
arg
=
task
->
arg
;
if
(
freeFunc
)
freeFunc
(
arg
->
param1
);
if
(
freeFunc
)
freeFunc
(
arg
);
taosMemoryFree
(
arg
);
taosMemoryFree
(
arg
);
taosMemoryFree
(
task
);
taosMemoryFree
(
task
);
...
...
source/util/src/tlog.c
浏览文件 @
e26c474f
...
@@ -435,7 +435,7 @@ static inline int32_t taosBuildLogHead(char *buffer, const char *flags) {
...
@@ -435,7 +435,7 @@ static inline int32_t taosBuildLogHead(char *buffer, const char *flags) {
taosGetTimeOfDay
(
&
timeSecs
);
taosGetTimeOfDay
(
&
timeSecs
);
time_t
curTime
=
timeSecs
.
tv_sec
;
time_t
curTime
=
timeSecs
.
tv_sec
;
ptm
=
taosLocalTime
Nolock
(
&
Tm
,
&
curTime
,
taosGetDaylight
()
);
ptm
=
taosLocalTime
(
&
curTime
,
&
Tm
);
return
sprintf
(
buffer
,
"%02d/%02d %02d:%02d:%02d.%06d %08"
PRId64
" %s"
,
ptm
->
tm_mon
+
1
,
ptm
->
tm_mday
,
ptm
->
tm_hour
,
return
sprintf
(
buffer
,
"%02d/%02d %02d:%02d:%02d.%06d %08"
PRId64
" %s"
,
ptm
->
tm_mon
+
1
,
ptm
->
tm_mday
,
ptm
->
tm_hour
,
ptm
->
tm_min
,
ptm
->
tm_sec
,
(
int32_t
)
timeSecs
.
tv_usec
,
taosGetSelfPthreadId
(),
flags
);
ptm
->
tm_min
,
ptm
->
tm_sec
,
(
int32_t
)
timeSecs
.
tv_usec
,
taosGetSelfPthreadId
(),
flags
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录