Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1d2e13c9
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
1d2e13c9
编写于
5月 28, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: refactor rpc code
上级
ddab6752
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
89 addition
and
91 deletion
+89
-91
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+13
-15
source/libs/transport/src/transSvr.c
source/libs/transport/src/transSvr.c
+76
-76
未找到文件。
source/libs/executor/src/executorimpl.c
浏览文件 @
1d2e13c9
...
...
@@ -4511,7 +4511,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
}
SArray
*
tableIdList
=
extractTableIdList
(
pTableListInfo
);
SOperatorInfo
*
pOperator
=
createStreamScanOperatorInfo
(
pDataReader
,
pHandle
,
tableIdList
,
pTableScanNode
,
pTaskInfo
);
SOperatorInfo
*
pOperator
=
createStreamScanOperatorInfo
(
pDataReader
,
pHandle
,
tableIdList
,
pTableScanNode
,
pTaskInfo
);
taosArrayDestroy
(
tableIdList
);
return
pOperator
;
...
...
@@ -4699,9 +4700,9 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
}
int32_t
compareTimeWindow
(
const
void
*
p1
,
const
void
*
p2
,
const
void
*
param
)
{
const
SQueryTableDataCond
*
pCond
=
param
;
const
STimeWindow
*
pWin1
=
p1
;
const
STimeWindow
*
pWin2
=
p2
;
const
SQueryTableDataCond
*
pCond
=
param
;
const
STimeWindow
*
pWin1
=
p1
;
const
STimeWindow
*
pWin2
=
p2
;
if
(
pCond
->
order
==
TSDB_ORDER_ASC
)
{
return
pWin1
->
skey
-
pWin2
->
skey
;
}
else
if
(
pCond
->
order
==
TSDB_ORDER_DESC
)
{
...
...
@@ -4721,8 +4722,8 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi
return
terrno
;
}
//pCond->twindow = pTableScanNode->scanRange;
//TODO: get it from stable scan node
//
pCond->twindow = pTableScanNode->scanRange;
//
TODO: get it from stable scan node
pCond
->
numOfTWindows
=
1
;
pCond
->
twindows
=
taosMemoryCalloc
(
pCond
->
numOfTWindows
,
sizeof
(
STimeWindow
));
pCond
->
twindows
[
0
]
=
pTableScanNode
->
scanRange
;
...
...
@@ -4743,11 +4744,7 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi
TSWAP
(
pCond
->
twindows
[
i
].
skey
,
pCond
->
twindows
[
i
].
ekey
);
}
}
taosqsort
(
pCond
->
twindows
,
pCond
->
numOfTWindows
,
sizeof
(
STimeWindow
),
pCond
,
compareTimeWindow
);
taosqsort
(
pCond
->
twindows
,
pCond
->
numOfTWindows
,
sizeof
(
STimeWindow
),
pCond
,
compareTimeWindow
);
pCond
->
type
=
BLOCK_LOAD_OFFSET_SEQ_ORDER
;
// pCond->type = pTableScanNode->scanFlag;
...
...
@@ -4907,7 +4904,8 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod
return
pList
;
}
int32_t
getTableList
(
void
*
metaHandle
,
int32_t
tableType
,
uint64_t
tableUid
,
STableListInfo
*
pListInfo
,
SNode
*
pTagCond
)
{
int32_t
getTableList
(
void
*
metaHandle
,
int32_t
tableType
,
uint64_t
tableUid
,
STableListInfo
*
pListInfo
,
SNode
*
pTagCond
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
pListInfo
->
pTableList
=
taosArrayInit
(
8
,
sizeof
(
STableKeyInfo
));
...
...
@@ -4918,12 +4916,12 @@ int32_t getTableList(void* metaHandle, int32_t tableType, uint64_t tableUid, STa
SArray
*
res
=
taosArrayInit
(
8
,
sizeof
(
uint64_t
));
code
=
doFilterTag
(
pTagCond
,
&
metaArg
,
res
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"
doFilterTag error:%d"
,
code
);
qError
(
"
failed to get tableIds, reason: %s, suid: %"
PRIu64
""
,
tstrerror
(
code
),
tableUid
);
taosArrayDestroy
(
res
);
terrno
=
code
;
return
code
;
}
else
{
qDebug
(
"
doFilterTag error:%d, suid: %"
PRIu64
""
,
code
,
tableUid
);
qDebug
(
"
sucess to get tableIds, size: %d, suid: %"
PRIu64
""
,
(
int
)
taosArrayGetSize
(
res
)
,
tableUid
);
}
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
res
);
i
++
)
{
STableKeyInfo
info
=
{.
lastKey
=
TSKEY_INITIAL_VAL
,
.
uid
=
*
(
uint64_t
*
)
taosArrayGet
(
res
,
i
)};
...
...
source/libs/transport/src/transS
rv
.c
→
source/libs/transport/src/transS
vr
.c
浏览文件 @
1d2e13c9
...
...
@@ -20,15 +20,15 @@
static
TdThreadOnce
transModuleInit
=
PTHREAD_ONCE_INIT
;
static
char
*
notify
=
"a"
;
static
int
tran
sSrv
Inst
=
0
;
static
int
tran
SSvr
Inst
=
0
;
typedef
struct
{
int
notifyCount
;
//
int
init
;
// init or not
STransMsg
msg
;
}
SS
rv
RegArg
;
}
SS
vr
RegArg
;
typedef
struct
SS
rv
Conn
{
typedef
struct
SS
vr
Conn
{
T_REF_DECLARE
()
uv_tcp_t
*
pTcp
;
uv_write_t
pWriter
;
...
...
@@ -42,7 +42,7 @@ typedef struct SSrvConn {
void
*
hostThrd
;
STransQueue
srvMsgs
;
SS
rv
RegArg
regArg
;
SS
vr
RegArg
regArg
;
bool
broken
;
// conn broken;
ConnStatus
status
;
...
...
@@ -55,14 +55,14 @@ typedef struct SSrvConn {
char
user
[
TSDB_UNI_LEN
];
// user ID for the link
char
secret
[
TSDB_PASSWORD_LEN
];
char
ckey
[
TSDB_PASSWORD_LEN
];
// ciphering key
}
SS
rv
Conn
;
}
SS
vr
Conn
;
typedef
struct
SS
rv
Msg
{
SS
rv
Conn
*
pConn
;
typedef
struct
SS
vr
Msg
{
SS
vr
Conn
*
pConn
;
STransMsg
msg
;
queue
q
;
STransMsgType
type
;
}
SS
rv
Msg
;
}
SS
vr
Msg
;
typedef
struct
SWorkThrdObj
{
TdThread
thread
;
...
...
@@ -127,25 +127,25 @@ static void uvWorkAfterTask(uv_work_t* req, int status);
static
void
uvWalkCb
(
uv_handle_t
*
handle
,
void
*
arg
);
static
void
uvFreeCb
(
uv_handle_t
*
handle
);
static
void
uvStartSendRespInternal
(
SS
rv
Msg
*
smsg
);
static
void
uvPrepareSendData
(
SS
rv
Msg
*
msg
,
uv_buf_t
*
wb
);
static
void
uvStartSendResp
(
SS
rv
Msg
*
msg
);
static
void
uvStartSendRespInternal
(
SS
vr
Msg
*
smsg
);
static
void
uvPrepareSendData
(
SS
vr
Msg
*
msg
,
uv_buf_t
*
wb
);
static
void
uvStartSendResp
(
SS
vr
Msg
*
msg
);
static
void
uvNotifyLinkBrokenToApp
(
SS
rv
Conn
*
conn
);
static
void
uvNotifyLinkBrokenToApp
(
SS
vr
Conn
*
conn
);
static
void
destroySmsg
(
SS
rv
Msg
*
smsg
);
static
void
destroySmsg
(
SS
vr
Msg
*
smsg
);
// check whether already read complete packet
static
SS
rv
Conn
*
createConn
(
void
*
hThrd
);
static
void
destroyConn
(
SS
rv
Conn
*
conn
,
bool
clear
/*clear handle or not*/
);
static
void
destroyConnRegArg
(
SS
rv
Conn
*
conn
);
static
SS
vr
Conn
*
createConn
(
void
*
hThrd
);
static
void
destroyConn
(
SS
vr
Conn
*
conn
,
bool
clear
/*clear handle or not*/
);
static
void
destroyConnRegArg
(
SS
vr
Conn
*
conn
);
static
int
reallocConnRefHandle
(
SS
rv
Conn
*
conn
);
static
int
reallocConnRefHandle
(
SS
vr
Conn
*
conn
);
static
void
uvHandleQuit
(
SS
rv
Msg
*
msg
,
SWorkThrdObj
*
thrd
);
static
void
uvHandleRelease
(
SS
rv
Msg
*
msg
,
SWorkThrdObj
*
thrd
);
static
void
uvHandleResp
(
SS
rv
Msg
*
msg
,
SWorkThrdObj
*
thrd
);
static
void
uvHandleRegister
(
SS
rv
Msg
*
msg
,
SWorkThrdObj
*
thrd
);
static
void
(
*
transAsyncHandle
[])(
SS
rv
Msg
*
msg
,
SWorkThrdObj
*
thrd
)
=
{
uvHandleResp
,
uvHandleQuit
,
uvHandleRelease
,
static
void
uvHandleQuit
(
SS
vr
Msg
*
msg
,
SWorkThrdObj
*
thrd
);
static
void
uvHandleRelease
(
SS
vr
Msg
*
msg
,
SWorkThrdObj
*
thrd
);
static
void
uvHandleResp
(
SS
vr
Msg
*
msg
,
SWorkThrdObj
*
thrd
);
static
void
uvHandleRegister
(
SS
vr
Msg
*
msg
,
SWorkThrdObj
*
thrd
);
static
void
(
*
transAsyncHandle
[])(
SS
vr
Msg
*
msg
,
SWorkThrdObj
*
thrd
)
=
{
uvHandleResp
,
uvHandleQuit
,
uvHandleRelease
,
uvHandleRegister
,
NULL
};
static
int32_t
exHandlesMgt
;
...
...
@@ -178,7 +178,7 @@ static bool addHandleToAcceptloop(void* arg);
tTrace("server conn %p received release request", conn); \
\
STransMsg tmsg = {.code = 0, .info.handle = (void*)conn, .info.ahandle = NULL}; \
SS
rvMsg* srvMsg = taosMemoryCalloc(1, sizeof(SSrv
Msg)); \
SS
vrMsg* srvMsg = taosMemoryCalloc(1, sizeof(SSvr
Msg)); \
srvMsg->msg = tmsg; \
srvMsg->type = Release; \
srvMsg->pConn = conn; \
...
...
@@ -233,18 +233,18 @@ static bool addHandleToAcceptloop(void* arg);
} while (0)
void
uvAllocRecvBufferCb
(
uv_handle_t
*
handle
,
size_t
suggested_size
,
uv_buf_t
*
buf
)
{
SS
rv
Conn
*
conn
=
handle
->
data
;
SS
vr
Conn
*
conn
=
handle
->
data
;
SConnBuffer
*
pBuf
=
&
conn
->
readBuf
;
transAllocBuffer
(
pBuf
,
buf
);
}
// refers specifically to query or insert timeout
static
void
uvHandleActivityTimeout
(
uv_timer_t
*
handle
)
{
SS
rv
Conn
*
conn
=
handle
->
data
;
SS
vr
Conn
*
conn
=
handle
->
data
;
tDebug
(
"%p timeout since no activity"
,
conn
);
}
static
void
uvHandleReq
(
SS
rv
Conn
*
pConn
)
{
static
void
uvHandleReq
(
SS
vr
Conn
*
pConn
)
{
SConnBuffer
*
pBuf
=
&
pConn
->
readBuf
;
char
*
msg
=
pBuf
->
buf
;
uint32_t
msgLen
=
pBuf
->
len
;
...
...
@@ -316,7 +316,7 @@ static void uvHandleReq(SSrvConn* pConn) {
void
uvOnRecvCb
(
uv_stream_t
*
cli
,
ssize_t
nread
,
const
uv_buf_t
*
buf
)
{
// opt
SS
rv
Conn
*
conn
=
cli
->
data
;
SS
vr
Conn
*
conn
=
cli
->
data
;
SConnBuffer
*
pBuf
=
&
conn
->
readBuf
;
if
(
nread
>
0
)
{
pBuf
->
len
+=
nread
;
...
...
@@ -354,17 +354,17 @@ void uvAllocConnBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* b
void
uvOnTimeoutCb
(
uv_timer_t
*
handle
)
{
// opt
SS
rv
Conn
*
pConn
=
handle
->
data
;
SS
vr
Conn
*
pConn
=
handle
->
data
;
tError
(
"server conn %p time out"
,
pConn
);
}
void
uvOnSendCb
(
uv_write_t
*
req
,
int
status
)
{
SS
rv
Conn
*
conn
=
req
->
data
;
SS
vr
Conn
*
conn
=
req
->
data
;
// transClearBuffer(&conn->readBuf);
if
(
status
==
0
)
{
tTrace
(
"server conn %p data already was written on stream"
,
conn
);
if
(
!
transQueueEmpty
(
&
conn
->
srvMsgs
))
{
SS
rv
Msg
*
msg
=
transQueuePop
(
&
conn
->
srvMsgs
);
SS
vr
Msg
*
msg
=
transQueuePop
(
&
conn
->
srvMsgs
);
// if (msg->type == Release && conn->status != ConnNormal) {
// conn->status = ConnNormal;
// transUnrefSrvHandle(conn);
...
...
@@ -376,7 +376,7 @@ void uvOnSendCb(uv_write_t* req, int status) {
destroySmsg
(
msg
);
// send second data, just use for push
if
(
!
transQueueEmpty
(
&
conn
->
srvMsgs
))
{
msg
=
(
SS
rv
Msg
*
)
transQueueGet
(
&
conn
->
srvMsgs
,
0
);
msg
=
(
SS
vr
Msg
*
)
transQueueGet
(
&
conn
->
srvMsgs
,
0
);
if
(
msg
->
type
==
Register
&&
conn
->
status
==
ConnAcquire
)
{
conn
->
regArg
.
notifyCount
=
0
;
conn
->
regArg
.
init
=
1
;
...
...
@@ -389,7 +389,7 @@ void uvOnSendCb(uv_write_t* req, int status) {
transQueuePop
(
&
conn
->
srvMsgs
);
taosMemoryFree
(
msg
);
msg
=
(
SS
rv
Msg
*
)
transQueueGet
(
&
conn
->
srvMsgs
,
0
);
msg
=
(
SS
vr
Msg
*
)
transQueueGet
(
&
conn
->
srvMsgs
,
0
);
if
(
msg
!=
NULL
)
{
uvStartSendRespInternal
(
msg
);
}
...
...
@@ -415,10 +415,10 @@ static void uvOnPipeWriteCb(uv_write_t* req, int status) {
taosMemoryFree
(
req
);
}
static
void
uvPrepareSendData
(
SS
rv
Msg
*
smsg
,
uv_buf_t
*
wb
)
{
static
void
uvPrepareSendData
(
SS
vr
Msg
*
smsg
,
uv_buf_t
*
wb
)
{
tTrace
(
"server conn %p prepare to send resp"
,
smsg
->
pConn
);
SS
rv
Conn
*
pConn
=
smsg
->
pConn
;
SS
vr
Conn
*
pConn
=
smsg
->
pConn
;
STransMsg
*
pMsg
=
&
smsg
->
msg
;
if
(
pMsg
->
pCont
==
0
)
{
pMsg
->
pCont
=
(
void
*
)
rpcMallocCont
(
0
);
...
...
@@ -455,17 +455,17 @@ static void uvPrepareSendData(SSrvMsg* smsg, uv_buf_t* wb) {
wb
->
len
=
len
;
}
static
void
uvStartSendRespInternal
(
SS
rv
Msg
*
smsg
)
{
static
void
uvStartSendRespInternal
(
SS
vr
Msg
*
smsg
)
{
uv_buf_t
wb
;
uvPrepareSendData
(
smsg
,
&
wb
);
SS
rv
Conn
*
pConn
=
smsg
->
pConn
;
SS
vr
Conn
*
pConn
=
smsg
->
pConn
;
// uv_timer_stop(&pConn->pTimer);
uv_write
(
&
pConn
->
pWriter
,
(
uv_stream_t
*
)
pConn
->
pTcp
,
&
wb
,
1
,
uvOnSendCb
);
}
static
void
uvStartSendResp
(
SS
rv
Msg
*
smsg
)
{
static
void
uvStartSendResp
(
SS
vr
Msg
*
smsg
)
{
// impl
SS
rv
Conn
*
pConn
=
smsg
->
pConn
;
SS
vr
Conn
*
pConn
=
smsg
->
pConn
;
if
(
pConn
->
broken
==
true
)
{
// persist by
...
...
@@ -485,7 +485,7 @@ static void uvStartSendResp(SSrvMsg* smsg) {
return
;
}
static
void
destroySmsg
(
SS
rv
Msg
*
smsg
)
{
static
void
destroySmsg
(
SS
vr
Msg
*
smsg
)
{
if
(
smsg
==
NULL
)
{
return
;
}
...
...
@@ -499,7 +499,7 @@ static void destroyAllConn(SWorkThrdObj* pThrd) {
QUEUE_REMOVE
(
h
);
QUEUE_INIT
(
h
);
SS
rvConn
*
c
=
QUEUE_DATA
(
h
,
SSrv
Conn
,
queue
);
SS
vrConn
*
c
=
QUEUE_DATA
(
h
,
SSvr
Conn
,
queue
);
while
(
T_REF_VAL_GET
(
c
)
>=
2
)
{
transUnrefSrvHandle
(
c
);
}
...
...
@@ -509,7 +509,7 @@ static void destroyAllConn(SWorkThrdObj* pThrd) {
void
uvWorkerAsyncCb
(
uv_async_t
*
handle
)
{
SAsyncItem
*
item
=
handle
->
data
;
SWorkThrdObj
*
pThrd
=
item
->
pThrd
;
SS
rv
Conn
*
conn
=
NULL
;
SS
vr
Conn
*
conn
=
NULL
;
queue
wq
;
// batch process to avoid to lock/unlock frequently
...
...
@@ -521,7 +521,7 @@ void uvWorkerAsyncCb(uv_async_t* handle) {
queue
*
head
=
QUEUE_HEAD
(
&
wq
);
QUEUE_REMOVE
(
head
);
SS
rvMsg
*
msg
=
QUEUE_DATA
(
head
,
SSrv
Msg
,
q
);
SS
vrMsg
*
msg
=
QUEUE_DATA
(
head
,
SSvr
Msg
,
q
);
if
(
msg
==
NULL
)
{
tError
(
"unexcept occurred, continue"
);
continue
;
...
...
@@ -649,7 +649,7 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) {
uv_handle_type
pending
=
uv_pipe_pending_type
(
pipe
);
assert
(
pending
==
UV_TCP
);
SS
rv
Conn
*
pConn
=
createConn
(
pThrd
);
SS
vr
Conn
*
pConn
=
createConn
(
pThrd
);
pConn
->
pTransInst
=
pThrd
->
pTransInst
;
/* init conn timer*/
...
...
@@ -768,10 +768,10 @@ void* transWorkerThread(void* arg) {
return
NULL
;
}
static
SS
rv
Conn
*
createConn
(
void
*
hThrd
)
{
static
SS
vr
Conn
*
createConn
(
void
*
hThrd
)
{
SWorkThrdObj
*
pThrd
=
hThrd
;
SS
rvConn
*
pConn
=
(
SSrvConn
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SSrv
Conn
));
SS
vrConn
*
pConn
=
(
SSvrConn
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SSvr
Conn
));
QUEUE_INIT
(
&
pConn
->
queue
);
QUEUE_PUSH
(
&
pThrd
->
conn
,
&
pConn
->
queue
);
...
...
@@ -794,7 +794,7 @@ static SSrvConn* createConn(void* hThrd) {
return
pConn
;
}
static
void
destroyConn
(
SS
rv
Conn
*
conn
,
bool
clear
)
{
static
void
destroyConn
(
SS
vr
Conn
*
conn
,
bool
clear
)
{
if
(
conn
==
NULL
)
{
return
;
}
...
...
@@ -808,13 +808,13 @@ static void destroyConn(SSrvConn* conn, bool clear) {
// uv_shutdown(req, (uv_stream_t*)conn->pTcp, uvShutDownCb);
}
}
static
void
destroyConnRegArg
(
SS
rv
Conn
*
conn
)
{
static
void
destroyConnRegArg
(
SS
vr
Conn
*
conn
)
{
if
(
conn
->
regArg
.
init
==
1
)
{
transFreeMsg
(
conn
->
regArg
.
msg
.
pCont
);
conn
->
regArg
.
init
=
0
;
}
}
static
int
reallocConnRefHandle
(
SS
rv
Conn
*
conn
)
{
static
int
reallocConnRefHandle
(
SS
vr
Conn
*
conn
)
{
uvReleaseExHandle
(
conn
->
refId
);
uvRemoveExHandle
(
conn
->
refId
);
// avoid app continue to send msg on invalid handle
...
...
@@ -828,7 +828,7 @@ static int reallocConnRefHandle(SSrvConn* conn) {
return
0
;
}
static
void
uvDestroyConn
(
uv_handle_t
*
handle
)
{
SS
rv
Conn
*
conn
=
handle
->
data
;
SS
vr
Conn
*
conn
=
handle
->
data
;
if
(
conn
==
NULL
)
{
return
;
}
...
...
@@ -884,7 +884,7 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
uv_loop_init
(
srv
->
loop
);
taosThreadOnce
(
&
transModuleInit
,
uvInitEnv
);
tran
sSrv
Inst
++
;
tran
SSvr
Inst
++
;
assert
(
0
==
uv_pipe_init
(
srv
->
loop
,
&
srv
->
pipeListen
,
0
));
#ifdef WINDOWS
...
...
@@ -981,7 +981,7 @@ void uvDestoryExHandle(void* handle) {
taosMemoryFree
(
handle
);
}
void
uvHandleQuit
(
SS
rv
Msg
*
msg
,
SWorkThrdObj
*
thrd
)
{
void
uvHandleQuit
(
SS
vr
Msg
*
msg
,
SWorkThrdObj
*
thrd
)
{
thrd
->
quit
=
true
;
if
(
QUEUE_IS_EMPTY
(
&
thrd
->
conn
))
{
uv_walk
(
thrd
->
loop
,
uvWalkCb
,
NULL
);
...
...
@@ -990,8 +990,8 @@ void uvHandleQuit(SSrvMsg* msg, SWorkThrdObj* thrd) {
}
taosMemoryFree
(
msg
);
}
void
uvHandleRelease
(
SS
rv
Msg
*
msg
,
SWorkThrdObj
*
thrd
)
{
SS
rv
Conn
*
conn
=
msg
->
pConn
;
void
uvHandleRelease
(
SS
vr
Msg
*
msg
,
SWorkThrdObj
*
thrd
)
{
SS
vr
Conn
*
conn
=
msg
->
pConn
;
if
(
conn
->
status
==
ConnAcquire
)
{
reallocConnRefHandle
(
conn
);
if
(
!
transQueuePush
(
&
conn
->
srvMsgs
,
msg
))
{
...
...
@@ -1004,13 +1004,13 @@ void uvHandleRelease(SSrvMsg* msg, SWorkThrdObj* thrd) {
}
destroySmsg
(
msg
);
}
void
uvHandleResp
(
SS
rv
Msg
*
msg
,
SWorkThrdObj
*
thrd
)
{
void
uvHandleResp
(
SS
vr
Msg
*
msg
,
SWorkThrdObj
*
thrd
)
{
// send msg to client
tDebug
(
"server conn %p start to send resp (2/2)"
,
msg
->
pConn
);
uvStartSendResp
(
msg
);
}
void
uvHandleRegister
(
SS
rv
Msg
*
msg
,
SWorkThrdObj
*
thrd
)
{
SS
rv
Conn
*
conn
=
msg
->
pConn
;
void
uvHandleRegister
(
SS
vr
Msg
*
msg
,
SWorkThrdObj
*
thrd
)
{
SS
vr
Conn
*
conn
=
msg
->
pConn
;
tDebug
(
"server conn %p register brokenlink callback"
,
conn
);
if
(
conn
->
status
==
ConnAcquire
)
{
if
(
!
transQueuePush
(
&
conn
->
srvMsgs
,
msg
))
{
...
...
@@ -1036,13 +1036,13 @@ void destroyWorkThrd(SWorkThrdObj* pThrd) {
}
taosThreadJoin
(
pThrd
->
thread
,
NULL
);
SRV_RELEASE_UV
(
pThrd
->
loop
);
TRANS_DESTROY_ASYNC_POOL_MSG
(
pThrd
->
asyncPool
,
SS
rv
Msg
,
destroySmsg
);
TRANS_DESTROY_ASYNC_POOL_MSG
(
pThrd
->
asyncPool
,
SS
vr
Msg
,
destroySmsg
);
transDestroyAsyncPool
(
pThrd
->
asyncPool
);
taosMemoryFree
(
pThrd
->
loop
);
taosMemoryFree
(
pThrd
);
}
void
sendQuitToWorkThrd
(
SWorkThrdObj
*
pThrd
)
{
SS
rvMsg
*
msg
=
taosMemoryCalloc
(
1
,
sizeof
(
SSrv
Msg
));
SS
vrMsg
*
msg
=
taosMemoryCalloc
(
1
,
sizeof
(
SSvr
Msg
));
msg
->
type
=
Quit
;
tDebug
(
"server send quit msg to work thread"
);
transSendAsync
(
pThrd
->
asyncPool
,
&
msg
->
q
);
...
...
@@ -1075,8 +1075,8 @@ void transCloseServer(void* arg) {
taosMemoryFree
(
srv
);
tran
sSrv
Inst
--
;
if
(
tran
sSrv
Inst
==
0
)
{
tran
SSvr
Inst
--
;
if
(
tran
SSvr
Inst
==
0
)
{
TdThreadOnce
tmpInit
=
PTHREAD_ONCE_INIT
;
memcpy
(
&
transModuleInit
,
&
tmpInit
,
sizeof
(
TdThreadOnce
));
uvCloseExHandleMgt
();
...
...
@@ -1087,7 +1087,7 @@ void transRefSrvHandle(void* handle) {
if
(
handle
==
NULL
)
{
return
;
}
int
ref
=
T_REF_INC
((
SS
rv
Conn
*
)
handle
);
int
ref
=
T_REF_INC
((
SS
vr
Conn
*
)
handle
);
tDebug
(
"server conn %p ref count: %d"
,
handle
,
ref
);
}
...
...
@@ -1095,10 +1095,10 @@ void transUnrefSrvHandle(void* handle) {
if
(
handle
==
NULL
)
{
return
;
}
int
ref
=
T_REF_DEC
((
SS
rv
Conn
*
)
handle
);
int
ref
=
T_REF_DEC
((
SS
vr
Conn
*
)
handle
);
tDebug
(
"server conn %p ref count: %d"
,
handle
,
ref
);
if
(
ref
==
0
)
{
destroyConn
((
SS
rv
Conn
*
)
handle
,
true
);
destroyConn
((
SS
vr
Conn
*
)
handle
,
true
);
}
}
...
...
@@ -1113,12 +1113,12 @@ void transReleaseSrvHandle(void* handle) {
STransMsg
tmsg
=
{.
code
=
0
,
.
info
.
handle
=
exh
,
.
info
.
ahandle
=
NULL
,
.
info
.
refId
=
refId
};
SS
rvMsg
*
srvMsg
=
taosMemoryCalloc
(
1
,
sizeof
(
SSrv
Msg
));
srvMsg
->
msg
=
tmsg
;
srvMsg
->
type
=
Release
;
SS
vrMsg
*
m
=
taosMemoryCalloc
(
1
,
sizeof
(
SSvr
Msg
));
m
->
msg
=
tmsg
;
m
->
type
=
Release
;
tTrace
(
"server conn %p start to release"
,
exh
->
handle
);
transSendAsync
(
pThrd
->
asyncPool
,
&
srvMsg
->
q
);
transSendAsync
(
pThrd
->
asyncPool
,
&
m
->
q
);
uvReleaseExHandle
(
refId
);
return
;
_return1:
...
...
@@ -1141,11 +1141,11 @@ void transSendResponse(const STransMsg* msg) {
SWorkThrdObj
*
pThrd
=
exh
->
pThrd
;
ASYNC_ERR_JRET
(
pThrd
);
SS
rvMsg
*
srvMsg
=
taosMemoryCalloc
(
1
,
sizeof
(
SSrv
Msg
));
srvMsg
->
msg
=
tmsg
;
srvMsg
->
type
=
Normal
;
SS
vrMsg
*
m
=
taosMemoryCalloc
(
1
,
sizeof
(
SSvr
Msg
));
m
->
msg
=
tmsg
;
m
->
type
=
Normal
;
tDebug
(
"server conn %p start to send resp (1/2)"
,
exh
->
handle
);
transSendAsync
(
pThrd
->
asyncPool
,
&
srvMsg
->
q
);
transSendAsync
(
pThrd
->
asyncPool
,
&
m
->
q
);
uvReleaseExHandle
(
refId
);
return
;
_return1:
...
...
@@ -1169,11 +1169,11 @@ void transRegisterMsg(const STransMsg* msg) {
SWorkThrdObj
*
pThrd
=
exh
->
pThrd
;
ASYNC_ERR_JRET
(
pThrd
);
SS
rvMsg
*
srvMsg
=
taosMemoryCalloc
(
1
,
sizeof
(
SSrv
Msg
));
srvMsg
->
msg
=
tmsg
;
srvMsg
->
type
=
Register
;
SS
vrMsg
*
m
=
taosMemoryCalloc
(
1
,
sizeof
(
SSvr
Msg
));
m
->
msg
=
tmsg
;
m
->
type
=
Register
;
tTrace
(
"server conn %p start to register brokenlink callback"
,
exh
->
handle
);
transSendAsync
(
pThrd
->
asyncPool
,
&
srvMsg
->
q
);
transSendAsync
(
pThrd
->
asyncPool
,
&
m
->
q
);
uvReleaseExHandle
(
refId
);
return
;
...
...
@@ -1193,7 +1193,7 @@ int transGetConnInfo(void* thandle, STransHandleInfo* pInfo) {
return
-
1
;
}
SExHandle
*
ex
=
thandle
;
SS
rv
Conn
*
pConn
=
ex
->
handle
;
SS
vr
Conn
*
pConn
=
ex
->
handle
;
struct
sockaddr_in
addr
=
pConn
->
addr
;
pInfo
->
clientIp
=
(
uint32_t
)(
addr
.
sin_addr
.
s_addr
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录