Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
538a0217
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看板
提交
538a0217
编写于
3月 19, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
merge 3.0
上级
96db2f50
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
20 deletion
+30
-20
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+12
-15
source/libs/transport/src/transSrv.c
source/libs/transport/src/transSrv.c
+18
-5
未找到文件。
source/libs/transport/src/transCli.c
浏览文件 @
538a0217
...
@@ -173,6 +173,7 @@ static void destroyThrdObj(SCliThrdObj* pThrd);
...
@@ -173,6 +173,7 @@ static void destroyThrdObj(SCliThrdObj* pThrd);
#define REQUEST_NO_RESP(msg) ((msg)->noResp == 1)
#define REQUEST_NO_RESP(msg) ((msg)->noResp == 1)
#define REQUEST_PERSIS_HANDLE(msg) ((msg)->persistHandle == 1)
#define REQUEST_PERSIS_HANDLE(msg) ((msg)->persistHandle == 1)
#define REQUEST_RELEASE_HANDLE(cmsg) ((cmsg)->type == Release)
static
void
*
cliWorkThread
(
void
*
arg
);
static
void
*
cliWorkThread
(
void
*
arg
);
...
@@ -509,7 +510,10 @@ void cliSend(SCliConn* pConn) {
...
@@ -509,7 +510,10 @@ void cliSend(SCliConn* pConn) {
STrans
*
pTransInst
=
pThrd
->
pTransInst
;
STrans
*
pTransInst
=
pThrd
->
pTransInst
;
STransMsg
*
pMsg
=
(
STransMsg
*
)(
&
pCliMsg
->
msg
);
STransMsg
*
pMsg
=
(
STransMsg
*
)(
&
pCliMsg
->
msg
);
if
(
pMsg
->
pCont
==
0
)
{
pMsg
->
pCont
=
(
void
*
)
rpcMallocCont
(
0
);
pMsg
->
contLen
=
0
;
}
STransMsgHead
*
pHead
=
transHeadFromCont
(
pMsg
->
pCont
);
STransMsgHead
*
pHead
=
transHeadFromCont
(
pMsg
->
pCont
);
int
msgLen
=
transMsgLenFromCont
(
pMsg
->
contLen
);
int
msgLen
=
transMsgLenFromCont
(
pMsg
->
contLen
);
...
@@ -537,6 +541,7 @@ void cliSend(SCliConn* pConn) {
...
@@ -537,6 +541,7 @@ void cliSend(SCliConn* pConn) {
pHead
->
persist
=
REQUEST_PERSIS_HANDLE
(
pMsg
)
?
1
:
0
;
pHead
->
persist
=
REQUEST_PERSIS_HANDLE
(
pMsg
)
?
1
:
0
;
pHead
->
msgType
=
pMsg
->
msgType
;
pHead
->
msgType
=
pMsg
->
msgType
;
pHead
->
msgLen
=
(
int32_t
)
htonl
((
uint32_t
)
msgLen
);
pHead
->
msgLen
=
(
int32_t
)
htonl
((
uint32_t
)
msgLen
);
pHead
->
release
=
REQUEST_RELEASE_HANDLE
(
pCliMsg
)
?
1
:
0
;
uv_buf_t
wb
=
uv_buf_init
((
char
*
)
pHead
,
msgLen
);
uv_buf_t
wb
=
uv_buf_init
((
char
*
)
pHead
,
msgLen
);
tDebug
(
"%s cli conn %p %s is send to %s:%d, local info %s:%d"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
,
tDebug
(
"%s cli conn %p %s is send to %s:%d, local info %s:%d"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
,
...
@@ -546,6 +551,7 @@ void cliSend(SCliConn* pConn) {
...
@@ -546,6 +551,7 @@ void cliSend(SCliConn* pConn) {
if
(
pHead
->
persist
==
1
)
{
if
(
pHead
->
persist
==
1
)
{
CONN_SET_PERSIST_BY_APP
(
pConn
);
CONN_SET_PERSIST_BY_APP
(
pConn
);
}
}
pConn
->
writeReq
.
data
=
pConn
;
pConn
->
writeReq
.
data
=
pConn
;
uv_write
(
&
pConn
->
writeReq
,
(
uv_stream_t
*
)
pConn
->
stream
,
&
wb
,
1
,
cliSendCb
);
uv_write
(
&
pConn
->
writeReq
,
(
uv_stream_t
*
)
pConn
->
stream
,
&
wb
,
1
,
cliSendCb
);
...
@@ -586,22 +592,13 @@ static void cliHandleQuit(SCliMsg* pMsg, SCliThrdObj* pThrd) {
...
@@ -586,22 +592,13 @@ static void cliHandleQuit(SCliMsg* pMsg, SCliThrdObj* pThrd) {
}
}
static
void
cliHandleRelease
(
SCliMsg
*
pMsg
,
SCliThrdObj
*
pThrd
)
{
static
void
cliHandleRelease
(
SCliMsg
*
pMsg
,
SCliThrdObj
*
pThrd
)
{
SCliConn
*
conn
=
pMsg
->
msg
.
handle
;
SCliConn
*
conn
=
pMsg
->
msg
.
handle
;
tDebug
(
"%s cli conn %p release to inst"
,
CONN_GET_INST_LABEL
(
conn
),
conn
);
tDebug
(
"%s cli conn %p start to release to inst"
,
CONN_GET_INST_LABEL
(
conn
),
conn
);
while
(
taosArrayGetSize
(
conn
->
cliMsgs
)
>
0
)
{
SCliMsg
*
pMsg
=
taosArrayGetP
(
conn
->
cliMsgs
,
0
);
destroyCmsg
(
pMsg
);
taosArrayRemove
(
conn
->
cliMsgs
,
0
);
}
transDestroyBuffer
(
&
conn
->
readBuf
);
taosArrayPush
(
conn
->
cliMsgs
,
&
pMsg
);
conn
->
status
=
ConnRelease
;
if
(
taosArrayGetSize
(
conn
->
cliMsgs
)
>=
2
)
{
int
ref
=
T_REF_VAL_GET
(
conn
);
return
;
// send one by one
if
(
ref
==
2
)
{
transUnrefCliHandle
(
conn
);
}
else
if
(
ref
==
1
)
{
addConnToPool
(
pThrd
->
pool
,
conn
);
}
}
cliSend
(
conn
);
}
}
SCliConn
*
cliGetConn
(
SCliMsg
*
pMsg
,
SCliThrdObj
*
pThrd
)
{
SCliConn
*
cliGetConn
(
SCliMsg
*
pMsg
,
SCliThrdObj
*
pThrd
)
{
...
...
source/libs/transport/src/transSrv.c
浏览文件 @
538a0217
...
@@ -93,6 +93,15 @@ typedef struct SServerObj {
...
@@ -93,6 +93,15 @@ typedef struct SServerObj {
static
const
char
*
notify
=
"a"
;
static
const
char
*
notify
=
"a"
;
#define CONN_SHOULD_RELEASE(conn, head) \
do { \
if ((head)->release == 1 && (head->msgLen) == sizeof(*head)) { \
conn->status = ConnRelease; \
transClearBuffer(&conn->readBuf); \
transFreeMsg(transContFromHead((char*)head)); \
goto _RETURE; \
} \
} while (0)
// refactor later
// refactor later
static
int
transAddAuthPart
(
SSrvConn
*
pConn
,
char
*
msg
,
int
msgLen
);
static
int
transAddAuthPart
(
SSrvConn
*
pConn
,
char
*
msg
,
int
msgLen
);
...
@@ -233,6 +242,7 @@ static void uvHandleReq(SSrvConn* pConn) {
...
@@ -233,6 +242,7 @@ static void uvHandleReq(SSrvConn* pConn) {
pHead
->
msgLen
-=
sizeof
(
STransUserMsg
);
pHead
->
msgLen
-=
sizeof
(
STransUserMsg
);
}
}
}
}
CONN_SHOULD_RELEASE
(
pConn
,
pHead
);
STransMsg
transMsg
;
STransMsg
transMsg
;
transMsg
.
contLen
=
transContLenFromMsg
(
pHead
->
msgLen
);
transMsg
.
contLen
=
transContLenFromMsg
(
pHead
->
msgLen
);
...
@@ -257,8 +267,8 @@ static void uvHandleReq(SSrvConn* pConn) {
...
@@ -257,8 +267,8 @@ static void uvHandleReq(SSrvConn* pConn) {
ntohs
(
pConn
->
locaddr
.
sin_port
),
transMsg
.
contLen
);
ntohs
(
pConn
->
locaddr
.
sin_port
),
transMsg
.
contLen
);
}
else
{
}
else
{
tDebug
(
"server conn %p %s received from %s:%d, local info: %s:%d, msg size: %d, resp:%d "
,
pConn
,
tDebug
(
"server conn %p %s received from %s:%d, local info: %s:%d, msg size: %d, resp:%d "
,
pConn
,
TMSG_INFO
(
transMsg
.
msgType
),
inet_n
toa
(
pConn
->
addr
.
sin_addr
),
ntohs
(
pConn
->
addr
.
sin_port
),
TMSG_INFO
(
transMsg
.
msgType
),
taosInetN
toa
(
pConn
->
addr
.
sin_addr
),
ntohs
(
pConn
->
addr
.
sin_port
),
inet_n
toa
(
pConn
->
locaddr
.
sin_addr
),
ntohs
(
pConn
->
locaddr
.
sin_port
),
transMsg
.
contLen
,
pHead
->
noResp
);
taosInetN
toa
(
pConn
->
locaddr
.
sin_addr
),
ntohs
(
pConn
->
locaddr
.
sin_port
),
transMsg
.
contLen
,
pHead
->
noResp
);
// no ref here
// no ref here
}
}
...
@@ -270,6 +280,8 @@ static void uvHandleReq(SSrvConn* pConn) {
...
@@ -270,6 +280,8 @@ static void uvHandleReq(SSrvConn* pConn) {
(
*
pTransInst
->
cfp
)(
pTransInst
->
parent
,
&
transMsg
,
NULL
);
(
*
pTransInst
->
cfp
)(
pTransInst
->
parent
,
&
transMsg
,
NULL
);
// uv_timer_start(&pConn->pTimer, uvHandleActivityTimeout, pRpc->idleTime * 10000, 0);
// uv_timer_start(&pConn->pTimer, uvHandleActivityTimeout, pRpc->idleTime * 10000, 0);
// auth
// auth
_RETURE:
return
;
}
}
void
uvOnRecvCb
(
uv_stream_t
*
cli
,
ssize_t
nread
,
const
uv_buf_t
*
buf
)
{
void
uvOnRecvCb
(
uv_stream_t
*
cli
,
ssize_t
nread
,
const
uv_buf_t
*
buf
)
{
...
@@ -350,7 +362,7 @@ void uvOnSendCb(uv_write_t* req, int status) {
...
@@ -350,7 +362,7 @@ void uvOnSendCb(uv_write_t* req, int status) {
}
}
}
else
{
}
else
{
tError
(
"server conn %p failed to write data, %s"
,
conn
,
uv_err_name
(
status
));
tError
(
"server conn %p failed to write data, %s"
,
conn
,
uv_err_name
(
status
));
conn
->
broken
=
fals
e
;
conn
->
broken
=
tru
e
;
transUnrefSrvHandle
(
conn
);
transUnrefSrvHandle
(
conn
);
}
}
}
}
...
@@ -407,6 +419,7 @@ static void uvStartSendResp(SSrvMsg* smsg) {
...
@@ -407,6 +419,7 @@ static void uvStartSendResp(SSrvMsg* smsg) {
SSrvConn
*
pConn
=
smsg
->
pConn
;
SSrvConn
*
pConn
=
smsg
->
pConn
;
if
(
pConn
->
broken
==
true
)
{
if
(
pConn
->
broken
==
true
)
{
// persist by
transUnrefSrvHandle
(
pConn
);
transUnrefSrvHandle
(
pConn
);
return
;
return
;
}
}
...
@@ -415,8 +428,8 @@ static void uvStartSendResp(SSrvMsg* smsg) {
...
@@ -415,8 +428,8 @@ static void uvStartSendResp(SSrvMsg* smsg) {
}
}
if
(
taosArrayGetSize
(
pConn
->
srvMsgs
)
>
0
)
{
if
(
taosArrayGetSize
(
pConn
->
srvMsgs
)
>
0
)
{
tDebug
(
"server conn %p send data to client %s:%d, local info: %s:%d"
,
pConn
,
inet_n
toa
(
pConn
->
addr
.
sin_addr
),
tDebug
(
"server conn %p send data to client %s:%d, local info: %s:%d"
,
pConn
,
taosInetN
toa
(
pConn
->
addr
.
sin_addr
),
ntohs
(
pConn
->
addr
.
sin_port
),
inet_n
toa
(
pConn
->
locaddr
.
sin_addr
),
ntohs
(
pConn
->
locaddr
.
sin_port
));
ntohs
(
pConn
->
addr
.
sin_port
),
taosInetN
toa
(
pConn
->
locaddr
.
sin_addr
),
ntohs
(
pConn
->
locaddr
.
sin_port
));
taosArrayPush
(
pConn
->
srvMsgs
,
&
smsg
);
taosArrayPush
(
pConn
->
srvMsgs
,
&
smsg
);
return
;
return
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录