Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
14952d7f
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
14952d7f
编写于
12月 14, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-10564] fix bug in taos_close
上级
8ff4a07d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
29 addition
and
24 deletion
+29
-24
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+2
-2
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+4
-2
source/client/src/clientmain.c
source/client/src/clientmain.c
+3
-0
source/client/src/tscEnv.c
source/client/src/tscEnv.c
+16
-19
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+4
-1
未找到文件。
source/client/inc/clientInt.h
浏览文件 @
14952d7f
...
...
@@ -58,7 +58,7 @@ typedef struct SAppInstInfo {
SCorEpSet
mgmtEp
;
SInstanceActivity
summary
;
SList
*
pConnList
;
// STscObj linked list
char
clusterId
[
TSDB_CLUSTER_ID_LEN
]
;
uint32_t
clusterId
;
void
*
pTransporter
;
}
SAppInstInfo
;
...
...
@@ -127,7 +127,7 @@ void* createTscObj(const char* user, const char* auth, const char *ip, uint32_t
void
destroyTscObj
(
void
*
pObj
);
void
*
createRequest
(
STscObj
*
pObj
,
__taos_async_fn_t
fp
,
void
*
param
,
int32_t
type
);
void
destroyRequest
(
void
*
p
);
void
destroyRequest
(
SRequestObj
*
pRequest
);
TAOS
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
);
...
...
source/client/src/clientImpl.c
浏览文件 @
14952d7f
...
...
@@ -172,7 +172,7 @@ STscObj* taosConnectImpl(const char *ip, const char *user, const char *auth, con
taos_close
(
pTscObj
);
pTscObj
=
NULL
;
}
else
{
tscDebug
(
"
%p connection is opening, dnodeConn:%p"
,
pTscObj
,
pTscObj
->
pTransporter
);
tscDebug
(
"
0x%"
PRIx64
" connection is opening, connId:%d, dnodeConn:%p"
,
pTscObj
->
id
,
pTscObj
->
connId
,
pTscObj
->
pTransporter
);
destroyRequest
(
pRequest
);
}
...
...
@@ -267,6 +267,8 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
tstrerror
(
pMsg
->
code
),
pMsg
->
contLen
);
}
taosReleaseRef
(
requestRefId
,
requestRefId
);
taosReleaseRef
(
tscReqRef
,
requestRefId
);
rpcFreeCont
(
pMsg
->
pCont
);
sem_post
(
&
pRequest
->
body
.
rspSem
);
}
source/client/src/clientmain.c
浏览文件 @
14952d7f
...
...
@@ -70,7 +70,10 @@ void taos_close(TAOS* taos) {
return
;
}
STscObj
*
pTscObj
=
(
STscObj
*
)
taos
;
tscDebug
(
"0x%"
PRIx64
" try to close connection, numOfReq:%d"
,
pTscObj
->
id
,
pTscObj
->
numOfReqs
);
taosRemoveRef
(
tscConnRef
,
pTscObj
->
id
);
}
const
char
*
taos_errstr
(
TAOS_RES
*
res
)
{
...
...
source/client/src/tscEnv.c
浏览文件 @
14952d7f
...
...
@@ -36,8 +36,6 @@ int32_t tscConnRef = -1;
void
*
tscQhandle
=
NULL
;
int32_t
tsNumOfThreads
=
1
;
pthread_mutex_t
rpcObjMutex
;
// mutex to protect open the rpc obj concurrently
volatile
int32_t
tscInitRes
=
0
;
static
void
registerRequest
(
SRequestObj
*
pRequest
)
{
...
...
@@ -65,12 +63,10 @@ static void deregisterRequest(SRequestObj* pRequest) {
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
SInstanceActivity
*
pActivity
=
&
pTscObj
->
pAppInfo
->
summary
;
taosReleaseRef
(
tscReqRef
,
pRequest
->
self
);
int32_t
currentInst
=
atomic_sub_fetch_32
(
&
pActivity
->
currentRequests
,
1
);
int32_t
num
=
atomic_sub_fetch_32
(
&
pTscObj
->
numOfReqs
,
1
);
tscDebug
(
"0x%"
PRIx64
" free Request from 0x%"
PRIx64
", current:%d, app current:%d"
,
pRequest
->
self
,
pTscObj
->
id
,
num
,
currentInst
);
tscDebug
(
"0x%"
PRIx64
" free Request from
connObj:
0x%"
PRIx64
", current:%d, app current:%d"
,
pRequest
->
self
,
pTscObj
->
id
,
num
,
currentInst
);
taosReleaseRef
(
tscConnRef
,
pTscObj
->
id
);
}
...
...
@@ -90,15 +86,6 @@ static void tscInitLogFile() {
}
}
void
tscFreeRpcObj
(
void
*
param
)
{
#if 0
assert(param);
SRpcObj *pRpcObj = (SRpcObj *)(param);
tscDebug("free rpcObj:%p and free pDnodeConn: %p", pRpcObj, pRpcObj->pDnodeConn);
rpcClose(pRpcObj->pDnodeConn);
#endif
}
void
closeTransporter
(
STscObj
*
pTscObj
)
{
if
(
pTscObj
==
NULL
||
pTscObj
->
pTransporter
==
NULL
)
{
return
;
...
...
@@ -136,7 +123,9 @@ void* openTransporter(const char *user, const char *auth) {
void
destroyTscObj
(
void
*
pObj
)
{
STscObj
*
pTscObj
=
pObj
;
tscDebug
(
"connect obj destroyed, 0x%"
PRIx64
,
pTscObj
->
id
);
atomic_sub_fetch_64
(
&
pTscObj
->
pAppInfo
->
numOfConns
,
1
);
tscDebug
(
"connObj 0x%"
PRIx64
" destroyed, totalConn:%"
PRId64
,
pTscObj
->
id
,
pTscObj
->
pAppInfo
->
numOfConns
);
closeTransporter
(
pTscObj
);
pthread_mutex_destroy
(
&
pTscObj
->
mutex
);
...
...
@@ -161,7 +150,7 @@ void* createTscObj(const char* user, const char* auth, const char *ip, uint32_t
pthread_mutex_init
(
&
pObj
->
mutex
,
NULL
);
pObj
->
id
=
taosAddRef
(
tscConnRef
,
pObj
);
tscDebug
(
"conn
ect o
bj created, 0x%"
PRIx64
,
pObj
->
id
);
tscDebug
(
"conn
O
bj created, 0x%"
PRIx64
,
pObj
->
id
);
return
pObj
;
}
...
...
@@ -189,9 +178,9 @@ void* createRequest(STscObj* pObj, __taos_async_fn_t fp, void* param, int32_t ty
return
pRequest
;
}
void
d
estroyRequest
(
void
*
p
)
{
static
void
doD
estroyRequest
(
void
*
p
)
{
assert
(
p
!=
NULL
);
SRequestObj
*
pRequest
=
*
(
SRequestObj
*
*
)
p
;
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
p
;
assert
(
RID_VALID
(
pRequest
->
self
));
...
...
@@ -202,6 +191,14 @@ void destroyRequest(void* p) {
deregisterRequest
(
pRequest
);
}
void
destroyRequest
(
SRequestObj
*
pRequest
)
{
if
(
pRequest
==
NULL
)
{
return
;
}
taosReleaseRef
(
tscReqRef
,
pRequest
->
self
);
}
void
taos_init_imp
(
void
)
{
// In the APIs of other program language, taos_cleanup is not available yet.
// So, to make sure taos_cleanup will be invoked to clean up the allocated resource to suppress the valgrind warning.
...
...
@@ -242,7 +239,7 @@ void taos_init_imp(void) {
tscDebug
(
"client task queue is initialized, numOfThreads: %d"
,
numOfThreads
);
tscConnRef
=
taosOpenRef
(
200
,
destroyTscObj
);
tscReqRef
=
taosOpenRef
(
40960
,
destroyRequest
);
tscReqRef
=
taosOpenRef
(
40960
,
d
oD
estroyRequest
);
taosGetAppName
(
appInfo
.
appName
,
NULL
);
appInfo
.
pid
=
taosGetPId
();
...
...
source/client/test/clientTests.cpp
浏览文件 @
14952d7f
...
...
@@ -33,5 +33,8 @@ int main(int argc, char** argv) {
}
TEST
(
testCase
,
driverInit_Test
)
{
TAOS
*
pTaos
=
taos_connect
(
"ubuntu"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS
*
pConn
=
taos_connect
(
"ubuntu"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
taos_close
(
pConn
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录