Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0d904d5a
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看板
提交
0d904d5a
编写于
6月 23, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: handle except
上级
d5f5c33c
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
173 addition
and
178 deletion
+173
-178
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+16
-15
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+121
-127
source/libs/transport/src/transSvr.c
source/libs/transport/src/transSvr.c
+36
-36
未找到文件。
source/client/src/clientEnv.c
浏览文件 @
0d904d5a
...
...
@@ -13,11 +13,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "os.h"
#include "catalog.h"
#include "functionMgt.h"
#include "clientInt.h"
#include "clientLog.h"
#include "functionMgt.h"
#include "os.h"
#include "query.h"
#include "scheduler.h"
#include "tcache.h"
...
...
@@ -38,7 +38,7 @@ static TdThreadOnce tscinit = PTHREAD_ONCE_INIT;
volatile
int32_t
tscInitRes
=
0
;
static
void
registerRequest
(
SRequestObj
*
pRequest
)
{
STscObj
*
pTscObj
=
acquireTscObj
(
*
(
int64_t
*
)
pRequest
->
pTscObj
->
id
);
STscObj
*
pTscObj
=
acquireTscObj
(
*
(
int64_t
*
)
pRequest
->
pTscObj
->
id
);
assert
(
pTscObj
!=
NULL
);
...
...
@@ -54,14 +54,14 @@ static void registerRequest(SRequestObj *pRequest) {
int32_t
currentInst
=
atomic_add_fetch_64
((
int64_t
*
)
&
pSummary
->
currentRequests
,
1
);
tscDebug
(
"0x%"
PRIx64
" new Request from connObj:0x%"
PRIx64
", current:%d, app current:%d, total:%d, reqId:0x%"
PRIx64
,
pRequest
->
self
,
*
(
int64_t
*
)
pRequest
->
pTscObj
->
id
,
num
,
currentInst
,
total
,
pRequest
->
requestId
);
pRequest
->
self
,
*
(
int64_t
*
)
pRequest
->
pTscObj
->
id
,
num
,
currentInst
,
total
,
pRequest
->
requestId
);
}
}
static
void
deregisterRequest
(
SRequestObj
*
pRequest
)
{
assert
(
pRequest
!=
NULL
);
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
SAppClusterSummary
*
pActivity
=
&
pTscObj
->
pAppInfo
->
summary
;
int32_t
currentInst
=
atomic_sub_fetch_64
((
int64_t
*
)
&
pActivity
->
currentRequests
,
1
);
...
...
@@ -70,8 +70,8 @@ static void deregisterRequest(SRequestObj *pRequest) {
int64_t
duration
=
taosGetTimestampUs
()
-
pRequest
->
metric
.
start
;
tscDebug
(
"0x%"
PRIx64
" free Request from connObj: 0x%"
PRIx64
", reqId:0x%"
PRIx64
" elapsed:%"
PRIu64
" ms, current:%d, app current:%d"
,
pRequest
->
self
,
*
(
int64_t
*
)
pTscObj
->
id
,
pRequest
->
requestId
,
duration
/
1000
,
num
,
currentInst
);
releaseTscObj
(
*
(
int64_t
*
)
pTscObj
->
id
);
pRequest
->
self
,
*
(
int64_t
*
)
pTscObj
->
id
,
pRequest
->
requestId
,
duration
/
1000
,
num
,
currentInst
);
releaseTscObj
(
*
(
int64_t
*
)
pTscObj
->
id
);
}
// todo close the transporter properly
...
...
@@ -80,7 +80,7 @@ void closeTransporter(STscObj *pTscObj) {
return
;
}
tscDebug
(
"free transporter:%p in connObj: 0x%"
PRIx64
,
pTscObj
->
pAppInfo
->
pTransporter
,
*
(
int64_t
*
)
pTscObj
->
id
);
tscDebug
(
"free transporter:%p in connObj: 0x%"
PRIx64
,
pTscObj
->
pAppInfo
->
pTransporter
,
*
(
int64_t
*
)
pTscObj
->
id
);
rpcClose
(
pTscObj
->
pAppInfo
->
pTransporter
);
}
...
...
@@ -128,16 +128,17 @@ void closeAllRequests(SHashObj *pRequests) {
void
destroyTscObj
(
void
*
pObj
)
{
STscObj
*
pTscObj
=
pObj
;
SClientHbKey
connKey
=
{.
tscRid
=
*
(
int64_t
*
)
pTscObj
->
id
,
.
connType
=
pTscObj
->
connType
};
SClientHbKey
connKey
=
{.
tscRid
=
*
(
int64_t
*
)
pTscObj
->
id
,
.
connType
=
pTscObj
->
connType
};
hbDeregisterConn
(
pTscObj
->
pAppInfo
->
pAppHbMgr
,
connKey
);
int64_t
connNum
=
atomic_sub_fetch_64
(
&
pTscObj
->
pAppInfo
->
numOfConns
,
1
);
closeAllRequests
(
pTscObj
->
pRequests
);
schedulerStopQueryHb
(
pTscObj
->
pAppInfo
->
pTransporter
);
if
(
0
==
connNum
)
{
// TODO
//
closeTransporter(pTscObj);
// TODO
closeTransporter
(
pTscObj
);
}
tscDebug
(
"connObj 0x%"
PRIx64
" destroyed, totalConn:%"
PRId64
,
*
(
int64_t
*
)
pTscObj
->
id
,
pTscObj
->
pAppInfo
->
numOfConns
);
tscDebug
(
"connObj 0x%"
PRIx64
" destroyed, totalConn:%"
PRId64
,
*
(
int64_t
*
)
pTscObj
->
id
,
pTscObj
->
pAppInfo
->
numOfConns
);
taosThreadMutexDestroy
(
&
pTscObj
->
mutex
);
taosMemoryFreeClear
(
pTscObj
);
}
...
...
@@ -167,10 +168,10 @@ void *createTscObj(const char *user, const char *auth, const char *db, int32_t c
taosThreadMutexInit
(
&
pObj
->
mutex
,
NULL
);
pObj
->
id
=
taosMemoryMalloc
(
sizeof
(
int64_t
));
*
(
int64_t
*
)
pObj
->
id
=
taosAddRef
(
clientConnRefPool
,
pObj
);
*
(
int64_t
*
)
pObj
->
id
=
taosAddRef
(
clientConnRefPool
,
pObj
);
pObj
->
schemalessType
=
1
;
tscDebug
(
"connObj created, 0x%"
PRIx64
,
*
(
int64_t
*
)
pObj
->
id
);
tscDebug
(
"connObj created, 0x%"
PRIx64
,
*
(
int64_t
*
)
pObj
->
id
);
return
pObj
;
}
...
...
@@ -325,7 +326,7 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
return
0
;
}
SConfig
*
pCfg
=
taosGetCfg
();
SConfig
*
pCfg
=
taosGetCfg
();
SConfigItem
*
pItem
=
NULL
;
switch
(
option
)
{
...
...
source/libs/transport/src/transCli.c
浏览文件 @
0d904d5a
此差异已折叠。
点击以展开。
source/libs/transport/src/transSvr.c
浏览文件 @
0d904d5a
...
...
@@ -65,7 +65,7 @@ typedef struct SSvrMsg {
STransMsgType
type
;
}
SSvrMsg
;
typedef
struct
SWorkThrd
Obj
{
typedef
struct
SWorkThrd
{
TdThread
thread
;
uv_connect_t
connect_req
;
uv_pipe_t
*
pipe
;
...
...
@@ -78,7 +78,7 @@ typedef struct SWorkThrdObj {
queue
conn
;
void
*
pTransInst
;
bool
quit
;
}
SWorkThrd
Obj
;
}
SWorkThrd
;
typedef
struct
SServerObj
{
TdThread
thread
;
...
...
@@ -86,10 +86,10 @@ typedef struct SServerObj {
uv_loop_t
*
loop
;
// work thread info
int
workerIdx
;
int
numOfThreads
;
int
numOfWorkerReady
;
SWorkThrd
Obj
**
pThreadObj
;
int
workerIdx
;
int
numOfThreads
;
int
numOfWorkerReady
;
SWorkThrd
**
pThreadObj
;
uv_pipe_t
pipeListen
;
uv_pipe_t
**
pipe
;
...
...
@@ -135,12 +135,12 @@ static void destroyConnRegArg(SSvrConn* conn);
static
int
reallocConnRef
(
SSvrConn
*
conn
);
static
void
uvHandleQuit
(
SSvrMsg
*
msg
,
SWorkThrd
Obj
*
thrd
);
static
void
uvHandleRelease
(
SSvrMsg
*
msg
,
SWorkThrd
Obj
*
thrd
);
static
void
uvHandleResp
(
SSvrMsg
*
msg
,
SWorkThrd
Obj
*
thrd
);
static
void
uvHandleRegister
(
SSvrMsg
*
msg
,
SWorkThrd
Obj
*
thrd
);
static
void
(
*
transAsyncHandle
[])(
SSvrMsg
*
msg
,
SWorkThrd
Obj
*
thrd
)
=
{
uvHandleResp
,
uvHandleQuit
,
uvHandleRelease
,
uvHandleRegister
,
NULL
};
static
void
uvHandleQuit
(
SSvrMsg
*
msg
,
SWorkThrd
*
thrd
);
static
void
uvHandleRelease
(
SSvrMsg
*
msg
,
SWorkThrd
*
thrd
);
static
void
uvHandleResp
(
SSvrMsg
*
msg
,
SWorkThrd
*
thrd
);
static
void
uvHandleRegister
(
SSvrMsg
*
msg
,
SWorkThrd
*
thrd
);
static
void
(
*
transAsyncHandle
[])(
SSvrMsg
*
msg
,
SWorkThrd
*
thrd
)
=
{
uvHandleResp
,
uvHandleQuit
,
uvHandleRelease
,
uvHandleRegister
,
NULL
};
static
int32_t
exHandlesMgt
;
...
...
@@ -160,7 +160,7 @@ static void* transWorkerThread(void* arg);
static
void
*
transAcceptThread
(
void
*
arg
);
// add handle loop
static
bool
addHandleToWorkloop
(
SWorkThrd
Obj
*
pThrd
,
char
*
pipeName
);
static
bool
addHandleToWorkloop
(
SWorkThrd
*
pThrd
,
char
*
pipeName
);
static
bool
addHandleToAcceptloop
(
void
*
arg
);
#define CONN_SHOULD_RELEASE(conn, head) \
...
...
@@ -233,7 +233,7 @@ static void uvHandleReq(SSvrConn* pConn) {
// wreq->data = pConn;
// uv_read_stop((uv_stream_t*)pConn->pTcp);
// transRefSrvHandle(pConn);
// uv_queue_work(((SWorkThrd
Obj
*)pConn->hostThrd)->loop, wreq, uvWorkDoTask, uvWorkAfterTask);
// uv_queue_work(((SWorkThrd*)pConn->hostThrd)->loop, wreq, uvWorkDoTask, uvWorkAfterTask);
CONN_SHOULD_RELEASE
(
pConn
,
pHead
);
...
...
@@ -478,7 +478,7 @@ static void destroySmsg(SSvrMsg* smsg) {
transFreeMsg
(
smsg
->
msg
.
pCont
);
taosMemoryFree
(
smsg
);
}
static
void
destroyAllConn
(
SWorkThrd
Obj
*
pThrd
)
{
static
void
destroyAllConn
(
SWorkThrd
*
pThrd
)
{
tTrace
(
"thread %p destroy all conn "
,
pThrd
);
while
(
!
QUEUE_IS_EMPTY
(
&
pThrd
->
conn
))
{
queue
*
h
=
QUEUE_HEAD
(
&
pThrd
->
conn
);
...
...
@@ -493,10 +493,10 @@ static void destroyAllConn(SWorkThrdObj* pThrd) {
}
}
void
uvWorkerAsyncCb
(
uv_async_t
*
handle
)
{
SAsyncItem
*
item
=
handle
->
data
;
SWorkThrd
Obj
*
pThrd
=
item
->
pThrd
;
SSvrConn
*
conn
=
NULL
;
queue
wq
;
SAsyncItem
*
item
=
handle
->
data
;
SWorkThrd
*
pThrd
=
item
->
pThrd
;
SSvrConn
*
conn
=
NULL
;
queue
wq
;
// batch process to avoid to lock/unlock frequently
taosThreadMutexLock
(
&
item
->
mtx
);
...
...
@@ -624,7 +624,7 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) {
assert
(
buf
->
base
[
0
]
==
notify
[
0
]);
taosMemoryFree
(
buf
->
base
);
SWorkThrd
Obj
*
pThrd
=
q
->
data
;
SWorkThrd
*
pThrd
=
q
->
data
;
uv_pipe_t
*
pipe
=
(
uv_pipe_t
*
)
q
;
if
(
!
uv_pipe_pending_count
(
pipe
))
{
...
...
@@ -692,10 +692,10 @@ void uvOnPipeConnectionCb(uv_connect_t* connect, int status) {
if
(
status
!=
0
)
{
return
;
}
SWorkThrd
Obj
*
pThrd
=
container_of
(
connect
,
SWorkThrdObj
,
connect_req
);
SWorkThrd
*
pThrd
=
container_of
(
connect
,
SWorkThrd
,
connect_req
);
uv_read_start
((
uv_stream_t
*
)
pThrd
->
pipe
,
uvAllocConnBufferCb
,
uvOnConnectionCb
);
}
static
bool
addHandleToWorkloop
(
SWorkThrd
Obj
*
pThrd
,
char
*
pipeName
)
{
static
bool
addHandleToWorkloop
(
SWorkThrd
*
pThrd
,
char
*
pipeName
)
{
pThrd
->
loop
=
(
uv_loop_t
*
)
taosMemoryMalloc
(
sizeof
(
uv_loop_t
));
if
(
0
!=
uv_loop_init
(
pThrd
->
loop
))
{
return
false
;
...
...
@@ -748,14 +748,14 @@ static bool addHandleToAcceptloop(void* arg) {
}
void
*
transWorkerThread
(
void
*
arg
)
{
setThreadName
(
"trans-worker"
);
SWorkThrd
Obj
*
pThrd
=
(
SWorkThrdObj
*
)
arg
;
SWorkThrd
*
pThrd
=
(
SWorkThrd
*
)
arg
;
uv_run
(
pThrd
->
loop
,
UV_RUN_DEFAULT
);
return
NULL
;
}
static
SSvrConn
*
createConn
(
void
*
hThrd
)
{
SWorkThrd
Obj
*
pThrd
=
hThrd
;
SWorkThrd
*
pThrd
=
hThrd
;
SSvrConn
*
pConn
=
(
SSvrConn
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SSvrConn
));
QUEUE_INIT
(
&
pConn
->
queue
);
...
...
@@ -818,7 +818,7 @@ static void uvDestroyConn(uv_handle_t* handle) {
if
(
conn
==
NULL
)
{
return
;
}
SWorkThrd
Obj
*
thrd
=
conn
->
hostThrd
;
SWorkThrd
*
thrd
=
conn
->
hostThrd
;
transReleaseExHandle
(
refMgt
,
conn
->
refId
);
transRemoveExHandle
(
refMgt
,
conn
->
refId
);
...
...
@@ -863,7 +863,7 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
srv
->
numOfThreads
=
numOfThreads
;
srv
->
workerIdx
=
0
;
srv
->
numOfWorkerReady
=
0
;
srv
->
pThreadObj
=
(
SWorkThrd
Obj
**
)
taosMemoryCalloc
(
srv
->
numOfThreads
,
sizeof
(
SWorkThrdObj
*
));
srv
->
pThreadObj
=
(
SWorkThrd
**
)
taosMemoryCalloc
(
srv
->
numOfThreads
,
sizeof
(
SWorkThrd
*
));
srv
->
pipe
=
(
uv_pipe_t
**
)
taosMemoryCalloc
(
srv
->
numOfThreads
,
sizeof
(
uv_pipe_t
*
));
srv
->
ip
=
ip
;
srv
->
port
=
port
;
...
...
@@ -888,7 +888,7 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
assert
(
0
==
uv_listen
((
uv_stream_t
*
)
&
srv
->
pipeListen
,
SOMAXCONN
,
uvPipeListenCb
));
for
(
int
i
=
0
;
i
<
srv
->
numOfThreads
;
i
++
)
{
SWorkThrd
Obj
*
thrd
=
(
SWorkThrdObj
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SWorkThrdObj
));
SWorkThrd
*
thrd
=
(
SWorkThrd
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SWorkThrd
));
thrd
->
pTransInst
=
shandle
;
thrd
->
quit
=
false
;
srv
->
pThreadObj
[
i
]
=
thrd
;
...
...
@@ -933,7 +933,7 @@ End:
return
NULL
;
}
void
uvHandleQuit
(
SSvrMsg
*
msg
,
SWorkThrd
Obj
*
thrd
)
{
void
uvHandleQuit
(
SSvrMsg
*
msg
,
SWorkThrd
*
thrd
)
{
thrd
->
quit
=
true
;
if
(
QUEUE_IS_EMPTY
(
&
thrd
->
conn
))
{
uv_walk
(
thrd
->
loop
,
uvWalkCb
,
NULL
);
...
...
@@ -942,7 +942,7 @@ void uvHandleQuit(SSvrMsg* msg, SWorkThrdObj* thrd) {
}
taosMemoryFree
(
msg
);
}
void
uvHandleRelease
(
SSvrMsg
*
msg
,
SWorkThrd
Obj
*
thrd
)
{
void
uvHandleRelease
(
SSvrMsg
*
msg
,
SWorkThrd
*
thrd
)
{
SSvrConn
*
conn
=
msg
->
pConn
;
if
(
conn
->
status
==
ConnAcquire
)
{
reallocConnRef
(
conn
);
...
...
@@ -956,12 +956,12 @@ void uvHandleRelease(SSvrMsg* msg, SWorkThrdObj* thrd) {
}
destroySmsg
(
msg
);
}
void
uvHandleResp
(
SSvrMsg
*
msg
,
SWorkThrd
Obj
*
thrd
)
{
void
uvHandleResp
(
SSvrMsg
*
msg
,
SWorkThrd
*
thrd
)
{
// send msg to client
tDebug
(
"%s conn %p start to send resp (2/2)"
,
transLabel
(
thrd
->
pTransInst
),
msg
->
pConn
);
uvStartSendResp
(
msg
);
}
void
uvHandleRegister
(
SSvrMsg
*
msg
,
SWorkThrd
Obj
*
thrd
)
{
void
uvHandleRegister
(
SSvrMsg
*
msg
,
SWorkThrd
*
thrd
)
{
SSvrConn
*
conn
=
msg
->
pConn
;
tDebug
(
"%s conn %p register brokenlink callback"
,
transLabel
(
thrd
->
pTransInst
),
conn
);
if
(
conn
->
status
==
ConnAcquire
)
{
...
...
@@ -982,7 +982,7 @@ void uvHandleRegister(SSvrMsg* msg, SWorkThrdObj* thrd) {
taosMemoryFree
(
msg
);
}
}
void
destroyWorkThrd
(
SWorkThrd
Obj
*
pThrd
)
{
void
destroyWorkThrd
(
SWorkThrd
*
pThrd
)
{
if
(
pThrd
==
NULL
)
{
return
;
}
...
...
@@ -993,7 +993,7 @@ void destroyWorkThrd(SWorkThrdObj* pThrd) {
taosMemoryFree
(
pThrd
->
loop
);
taosMemoryFree
(
pThrd
);
}
void
sendQuitToWorkThrd
(
SWorkThrd
Obj
*
pThrd
)
{
void
sendQuitToWorkThrd
(
SWorkThrd
*
pThrd
)
{
SSvrMsg
*
msg
=
taosMemoryCalloc
(
1
,
sizeof
(
SSvrMsg
));
msg
->
type
=
Quit
;
tDebug
(
"server send quit msg to work thread"
);
...
...
@@ -1060,7 +1060,7 @@ void transReleaseSrvHandle(void* handle) {
ASYNC_CHECK_HANDLE
(
exh
,
refId
);
SWorkThrd
Obj
*
pThrd
=
exh
->
pThrd
;
SWorkThrd
*
pThrd
=
exh
->
pThrd
;
ASYNC_ERR_JRET
(
pThrd
);
STransMsg
tmsg
=
{.
code
=
0
,
.
info
.
handle
=
exh
,
.
info
.
ahandle
=
NULL
,
.
info
.
refId
=
refId
};
...
...
@@ -1090,7 +1090,7 @@ void transSendResponse(const STransMsg* msg) {
STransMsg
tmsg
=
*
msg
;
tmsg
.
info
.
refId
=
refId
;
SWorkThrd
Obj
*
pThrd
=
exh
->
pThrd
;
SWorkThrd
*
pThrd
=
exh
->
pThrd
;
ASYNC_ERR_JRET
(
pThrd
);
SSvrMsg
*
m
=
taosMemoryCalloc
(
1
,
sizeof
(
SSvrMsg
));
...
...
@@ -1120,7 +1120,7 @@ void transRegisterMsg(const STransMsg* msg) {
STransMsg
tmsg
=
*
msg
;
tmsg
.
info
.
refId
=
refId
;
SWorkThrd
Obj
*
pThrd
=
exh
->
pThrd
;
SWorkThrd
*
pThrd
=
exh
->
pThrd
;
ASYNC_ERR_JRET
(
pThrd
);
SSvrMsg
*
m
=
taosMemoryCalloc
(
1
,
sizeof
(
SSvrMsg
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录