Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a0804f19
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看板
提交
a0804f19
编写于
2月 09, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix crash
上级
e2d4c81c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
26 addition
and
21 deletion
+26
-21
source/libs/transport/src/trans.c
source/libs/transport/src/trans.c
+1
-0
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+20
-20
source/libs/transport/src/transSrv.c
source/libs/transport/src/transSrv.c
+5
-1
未找到文件。
source/libs/transport/src/trans.c
浏览文件 @
a0804f19
...
@@ -35,6 +35,7 @@ void* rpcOpen(const SRpcInit* pInit) {
...
@@ -35,6 +35,7 @@ void* rpcOpen(const SRpcInit* pInit) {
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
);
pRpc
->
parent
=
pInit
->
parent
;
return
pRpc
;
return
pRpc
;
}
}
...
...
source/libs/transport/src/transCli.c
浏览文件 @
a0804f19
...
@@ -124,10 +124,10 @@ static void clientHandleResp(SCliConn* conn) {
...
@@ -124,10 +124,10 @@ static void clientHandleResp(SCliConn* conn) {
rpcMsg
.
msgType
=
pHead
->
msgType
;
rpcMsg
.
msgType
=
pHead
->
msgType
;
rpcMsg
.
ahandle
=
pCtx
->
ahandle
;
rpcMsg
.
ahandle
=
pCtx
->
ahandle
;
if
(
pCtx
->
pSem
==
NULL
)
{
if
(
pCtx
->
pSem
==
NULL
)
{
tDebug
(
"c
onn %p handle resp
"
,
conn
);
tDebug
(
"c
lient conn %p handle resp,
"
,
conn
);
(
pRpc
->
cfp
)(
NULL
,
&
rpcMsg
,
NULL
);
(
pRpc
->
cfp
)(
pRpc
->
parent
,
&
rpcMsg
,
NULL
);
}
else
{
}
else
{
tDebug
(
"c
onn
%p handle resp"
,
conn
);
tDebug
(
"c
lient conn(sync)
%p handle resp"
,
conn
);
memcpy
((
char
*
)
pCtx
->
pRsp
,
(
char
*
)
&
rpcMsg
,
sizeof
(
rpcMsg
));
memcpy
((
char
*
)
pCtx
->
pRsp
,
(
char
*
)
&
rpcMsg
,
sizeof
(
rpcMsg
));
tsem_post
(
pCtx
->
pSem
);
tsem_post
(
pCtx
->
pSem
);
}
}
...
@@ -154,7 +154,7 @@ static void clientHandleExcept(SCliConn* pConn) {
...
@@ -154,7 +154,7 @@ static void clientHandleExcept(SCliConn* pConn) {
clientConnDestroy
(
pConn
,
true
);
clientConnDestroy
(
pConn
,
true
);
return
;
return
;
}
}
tDebug
(
"conn %p start to destroy"
,
pConn
);
tDebug
(
"c
lient c
onn %p start to destroy"
,
pConn
);
SCliMsg
*
pMsg
=
pConn
->
data
;
SCliMsg
*
pMsg
=
pConn
->
data
;
destroyUserdata
(
&
pMsg
->
msg
);
destroyUserdata
(
&
pMsg
->
msg
);
...
@@ -166,7 +166,7 @@ static void clientHandleExcept(SCliConn* pConn) {
...
@@ -166,7 +166,7 @@ static void clientHandleExcept(SCliConn* pConn) {
rpcMsg
.
code
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
rpcMsg
.
code
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
if
(
pCtx
->
pSem
==
NULL
)
{
if
(
pCtx
->
pSem
==
NULL
)
{
// SRpcInfo* pRpc = pMsg->ctx->pRpc;
// SRpcInfo* pRpc = pMsg->ctx->pRpc;
(
pCtx
->
pTransInst
->
cfp
)(
NULL
,
&
rpcMsg
,
NULL
);
(
pCtx
->
pTransInst
->
cfp
)(
pCtx
->
pTransInst
->
parent
,
&
rpcMsg
,
NULL
);
}
else
{
}
else
{
memcpy
((
char
*
)(
pCtx
->
pRsp
),
(
char
*
)(
&
rpcMsg
),
sizeof
(
rpcMsg
));
memcpy
((
char
*
)(
pCtx
->
pRsp
),
(
char
*
)(
&
rpcMsg
),
sizeof
(
rpcMsg
));
// SRpcMsg rpcMsg
// SRpcMsg rpcMsg
...
@@ -184,7 +184,7 @@ static void clientTimeoutCb(uv_timer_t* handle) {
...
@@ -184,7 +184,7 @@ static void clientTimeoutCb(uv_timer_t* handle) {
SCliThrdObj
*
pThrd
=
handle
->
data
;
SCliThrdObj
*
pThrd
=
handle
->
data
;
SRpcInfo
*
pRpc
=
pThrd
->
pTransInst
;
SRpcInfo
*
pRpc
=
pThrd
->
pTransInst
;
int64_t
currentTime
=
pThrd
->
nextTimeout
;
int64_t
currentTime
=
pThrd
->
nextTimeout
;
tDebug
(
"timeout, try to remove expire conn from conn pool"
);
tDebug
(
"
client conn
timeout, try to remove expire conn from conn pool"
);
SConnList
*
p
=
taosHashIterate
((
SHashObj
*
)
pThrd
->
pool
,
NULL
);
SConnList
*
p
=
taosHashIterate
((
SHashObj
*
)
pThrd
->
pool
,
NULL
);
while
(
p
!=
NULL
)
{
while
(
p
!=
NULL
)
{
...
@@ -253,7 +253,7 @@ static void addConnToPool(void* pool, char* ip, uint32_t port, SCliConn* conn) {
...
@@ -253,7 +253,7 @@ static void addConnToPool(void* pool, char* ip, uint32_t port, SCliConn* conn) {
tstrncpy
(
key
,
ip
,
strlen
(
ip
));
tstrncpy
(
key
,
ip
,
strlen
(
ip
));
tstrncpy
(
key
+
strlen
(
key
),
(
char
*
)(
&
port
),
sizeof
(
port
));
tstrncpy
(
key
+
strlen
(
key
),
(
char
*
)(
&
port
),
sizeof
(
port
));
tDebug
(
"conn %p added to conn pool, read buf cap: %d"
,
conn
,
conn
->
readBuf
.
cap
);
tDebug
(
"c
lient c
onn %p added to conn pool, read buf cap: %d"
,
conn
,
conn
->
readBuf
.
cap
);
SRpcInfo
*
pRpc
=
((
SCliThrdObj
*
)
conn
->
hostThrd
)
->
pTransInst
;
SRpcInfo
*
pRpc
=
((
SCliThrdObj
*
)
conn
->
hostThrd
)
->
pTransInst
;
...
@@ -294,10 +294,10 @@ static void clientReadCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf
...
@@ -294,10 +294,10 @@ static void clientReadCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf
pBuf
->
len
+=
nread
;
pBuf
->
len
+=
nread
;
if
(
clientReadComplete
(
pBuf
))
{
if
(
clientReadComplete
(
pBuf
))
{
uv_read_stop
((
uv_stream_t
*
)
conn
->
stream
);
uv_read_stop
((
uv_stream_t
*
)
conn
->
stream
);
tDebug
(
"conn %p read complete"
,
conn
);
tDebug
(
"c
lient c
onn %p read complete"
,
conn
);
clientHandleResp
(
conn
);
clientHandleResp
(
conn
);
}
else
{
}
else
{
tDebug
(
"conn %p read partial packet, continue to read"
,
conn
);
tDebug
(
"c
lient c
onn %p read partial packet, continue to read"
,
conn
);
}
}
return
;
return
;
}
}
...
@@ -309,7 +309,7 @@ static void clientReadCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf
...
@@ -309,7 +309,7 @@ static void clientReadCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf
return
;
return
;
}
}
if
(
nread
<
0
||
nread
==
UV_EOF
)
{
if
(
nread
<
0
||
nread
==
UV_EOF
)
{
tError
(
"conn %p read error: %s"
,
conn
,
uv_err_name
(
nread
));
tError
(
"c
lient c
onn %p read error: %s"
,
conn
,
uv_err_name
(
nread
));
clientHandleExcept
(
conn
);
clientHandleExcept
(
conn
);
}
}
// tDebug("Read error %s\n", uv_err_name(nread));
// tDebug("Read error %s\n", uv_err_name(nread));
...
@@ -320,9 +320,9 @@ static void clientConnDestroy(SCliConn* conn, bool clear) {
...
@@ -320,9 +320,9 @@ static void clientConnDestroy(SCliConn* conn, bool clear) {
//
//
conn
->
ref
--
;
conn
->
ref
--
;
if
(
conn
->
ref
==
0
)
{
if
(
conn
->
ref
==
0
)
{
tDebug
(
"conn %p remove from conn pool"
,
conn
);
tDebug
(
"c
lient c
onn %p remove from conn pool"
,
conn
);
QUEUE_REMOVE
(
&
conn
->
conn
);
QUEUE_REMOVE
(
&
conn
->
conn
);
tDebug
(
"conn %p remove from conn pool successfully"
,
conn
);
tDebug
(
"c
lient c
onn %p remove from conn pool successfully"
,
conn
);
if
(
clear
)
{
if
(
clear
)
{
uv_close
((
uv_handle_t
*
)
conn
->
stream
,
clientDestroy
);
uv_close
((
uv_handle_t
*
)
conn
->
stream
,
clientDestroy
);
}
}
...
@@ -334,7 +334,7 @@ static void clientDestroy(uv_handle_t* handle) {
...
@@ -334,7 +334,7 @@ static void clientDestroy(uv_handle_t* handle) {
free
(
conn
->
stream
);
free
(
conn
->
stream
);
free
(
conn
->
writeReq
);
free
(
conn
->
writeReq
);
tDebug
(
"conn %p destroy successfully"
,
conn
);
tDebug
(
"c
lient c
onn %p destroy successfully"
,
conn
);
free
(
conn
);
free
(
conn
);
// clientConnDestroy(conn, false);
// clientConnDestroy(conn, false);
...
@@ -343,7 +343,7 @@ static void clientDestroy(uv_handle_t* handle) {
...
@@ -343,7 +343,7 @@ static void clientDestroy(uv_handle_t* handle) {
static
void
clientWriteCb
(
uv_write_t
*
req
,
int
status
)
{
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
(
"c
lient c
onn %p data already was written out"
,
pConn
);
SCliMsg
*
pMsg
=
pConn
->
data
;
SCliMsg
*
pMsg
=
pConn
->
data
;
if
(
pMsg
==
NULL
)
{
if
(
pMsg
==
NULL
)
{
// handle
// handle
...
@@ -351,7 +351,7 @@ static void clientWriteCb(uv_write_t* req, int status) {
...
@@ -351,7 +351,7 @@ static void clientWriteCb(uv_write_t* req, int status) {
}
}
destroyUserdata
(
&
pMsg
->
msg
);
destroyUserdata
(
&
pMsg
->
msg
);
}
else
{
}
else
{
tError
(
"conn %p failed to write: %s"
,
pConn
,
uv_err_name
(
status
));
tError
(
"c
lient c
onn %p failed to write: %s"
,
pConn
,
uv_err_name
(
status
));
clientHandleExcept
(
pConn
);
clientHandleExcept
(
pConn
);
return
;
return
;
}
}
...
@@ -370,7 +370,7 @@ static void clientWrite(SCliConn* pConn) {
...
@@ -370,7 +370,7 @@ static void clientWrite(SCliConn* pConn) {
pHead
->
msgLen
=
(
int32_t
)
htonl
((
uint32_t
)
msgLen
);
pHead
->
msgLen
=
(
int32_t
)
htonl
((
uint32_t
)
msgLen
);
uv_buf_t
wb
=
uv_buf_init
((
char
*
)
pHead
,
msgLen
);
uv_buf_t
wb
=
uv_buf_init
((
char
*
)
pHead
,
msgLen
);
tDebug
(
"c
onn %p data write out, msgType : %d, len: %d"
,
pConn
,
pHead
->
msgType
,
msgLen
);
tDebug
(
"c
lient conn %p data write out, msgType : %s, len: %d"
,
pConn
,
TMSG_INFO
(
pHead
->
msgType
)
,
msgLen
);
uv_write
(
pConn
->
writeReq
,
(
uv_stream_t
*
)
pConn
->
stream
,
&
wb
,
1
,
clientWriteCb
);
uv_write
(
pConn
->
writeReq
,
(
uv_stream_t
*
)
pConn
->
stream
,
&
wb
,
1
,
clientWriteCb
);
}
}
static
void
clientConnCb
(
uv_connect_t
*
req
,
int
status
)
{
static
void
clientConnCb
(
uv_connect_t
*
req
,
int
status
)
{
...
@@ -378,11 +378,11 @@ static void clientConnCb(uv_connect_t* req, int status) {
...
@@ -378,11 +378,11 @@ static void clientConnCb(uv_connect_t* req, int status) {
SCliConn
*
pConn
=
req
->
data
;
SCliConn
*
pConn
=
req
->
data
;
if
(
status
!=
0
)
{
if
(
status
!=
0
)
{
// tError("failed to connect server(%s, %d), errmsg: %s", pCtx->ip, pCtx->port, uv_strerror(status));
// tError("failed to connect server(%s, %d), errmsg: %s", pCtx->ip, pCtx->port, uv_strerror(status));
tError
(
"conn %p failed to connect server: %s"
,
pConn
,
uv_strerror
(
status
));
tError
(
"c
lient c
onn %p failed to connect server: %s"
,
pConn
,
uv_strerror
(
status
));
clientHandleExcept
(
pConn
);
clientHandleExcept
(
pConn
);
return
;
return
;
}
}
tDebug
(
"conn %p create"
,
pConn
);
tDebug
(
"c
lient c
onn %p create"
,
pConn
);
assert
(
pConn
->
stream
==
req
->
handle
);
assert
(
pConn
->
stream
==
req
->
handle
);
clientWrite
(
pConn
);
clientWrite
(
pConn
);
...
@@ -400,14 +400,14 @@ static void clientHandleQuit(SCliMsg* pMsg, SCliThrdObj* pThrd) {
...
@@ -400,14 +400,14 @@ static void clientHandleQuit(SCliMsg* pMsg, SCliThrdObj* pThrd) {
static
void
clientHandleReq
(
SCliMsg
*
pMsg
,
SCliThrdObj
*
pThrd
)
{
static
void
clientHandleReq
(
SCliMsg
*
pMsg
,
SCliThrdObj
*
pThrd
)
{
uint64_t
et
=
taosGetTimestampUs
();
uint64_t
et
=
taosGetTimestampUs
();
uint64_t
el
=
et
-
pMsg
->
st
;
uint64_t
el
=
et
-
pMsg
->
st
;
tDebug
(
"msg tran time cost: %"
PRIu64
""
,
el
);
tDebug
(
"
client
msg tran time cost: %"
PRIu64
""
,
el
);
et
=
taosGetTimestampUs
();
et
=
taosGetTimestampUs
();
STransConnCtx
*
pCtx
=
pMsg
->
ctx
;
STransConnCtx
*
pCtx
=
pMsg
->
ctx
;
SCliConn
*
conn
=
getConnFromPool
(
pThrd
->
pool
,
pCtx
->
ip
,
pCtx
->
port
);
SCliConn
*
conn
=
getConnFromPool
(
pThrd
->
pool
,
pCtx
->
ip
,
pCtx
->
port
);
if
(
conn
!=
NULL
)
{
if
(
conn
!=
NULL
)
{
// impl later
// impl later
tDebug
(
"c
onn %p get from conn
pool"
,
conn
);
tDebug
(
"c
lient get conn %p from
pool"
,
conn
);
conn
->
data
=
pMsg
;
conn
->
data
=
pMsg
;
conn
->
writeReq
->
data
=
conn
;
conn
->
writeReq
->
data
=
conn
;
transDestroyBuffer
(
&
conn
->
readBuf
);
transDestroyBuffer
(
&
conn
->
readBuf
);
...
...
source/libs/transport/src/transSrv.c
浏览文件 @
a0804f19
...
@@ -266,6 +266,7 @@ static void uvHandleReq(SSrvConn* pConn) {
...
@@ -266,6 +266,7 @@ static void uvHandleReq(SSrvConn* pConn) {
transClearBuffer
(
&
pConn
->
readBuf
);
transClearBuffer
(
&
pConn
->
readBuf
);
pConn
->
ref
++
;
pConn
->
ref
++
;
tDebug
(
"%s received on %p"
,
TMSG_INFO
(
rpcMsg
.
msgType
),
pConn
);
(
*
(
pRpc
->
cfp
))(
pRpc
->
parent
,
&
rpcMsg
,
NULL
);
(
*
(
pRpc
->
cfp
))(
pRpc
->
parent
,
&
rpcMsg
,
NULL
);
// uv_timer_start(pConn->pTimer, uvHandleActivityTimeout, pRpc->idleTime * 10000, 0);
// uv_timer_start(pConn->pTimer, uvHandleActivityTimeout, pRpc->idleTime * 10000, 0);
// auth
// auth
...
@@ -278,7 +279,7 @@ void uvOnReadCb(uv_stream_t* cli, ssize_t nread, const uv_buf_t* buf) {
...
@@ -278,7 +279,7 @@ void uvOnReadCb(uv_stream_t* cli, ssize_t nread, const uv_buf_t* buf) {
SConnBuffer
*
pBuf
=
&
conn
->
readBuf
;
SConnBuffer
*
pBuf
=
&
conn
->
readBuf
;
if
(
nread
>
0
)
{
if
(
nread
>
0
)
{
pBuf
->
len
+=
nread
;
pBuf
->
len
+=
nread
;
tDebug
(
"conn %p read summ
ro
y, total read: %d, current read: %d"
,
conn
,
pBuf
->
len
,
(
int
)
nread
);
tDebug
(
"conn %p read summ
ar
y, total read: %d, current read: %d"
,
conn
,
pBuf
->
len
,
(
int
)
nread
);
if
(
readComplete
(
pBuf
))
{
if
(
readComplete
(
pBuf
))
{
tDebug
(
"conn %p alread read complete packet"
,
conn
);
tDebug
(
"conn %p alread read complete packet"
,
conn
);
uvHandleReq
(
conn
);
uvHandleReq
(
conn
);
...
@@ -717,6 +718,9 @@ void taosCloseServer(void* arg) {
...
@@ -717,6 +718,9 @@ void taosCloseServer(void* arg) {
}
}
void
rpcSendResponse
(
const
SRpcMsg
*
pMsg
)
{
void
rpcSendResponse
(
const
SRpcMsg
*
pMsg
)
{
if
(
pMsg
->
handle
==
NULL
)
{
return
;
}
SSrvConn
*
pConn
=
pMsg
->
handle
;
SSrvConn
*
pConn
=
pMsg
->
handle
;
SWorkThrdObj
*
pThrd
=
pConn
->
hostThrd
;
SWorkThrdObj
*
pThrd
=
pConn
->
hostThrd
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录