Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bf97ce3d
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看板
提交
bf97ce3d
编写于
12月 10, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-10564] refactor and add test cases.
上级
33e384a7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
40 deletion
+36
-40
source/client/src/tscEnv.c
source/client/src/tscEnv.c
+36
-40
未找到文件。
source/client/src/tscEnv.c
浏览文件 @
bf97ce3d
...
...
@@ -13,8 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "clientInt.h"
#include "trpc.h"
#include "os.h"
#include "taosmsg.h"
#include "tcache.h"
...
...
@@ -25,23 +23,52 @@
#include "tscLog.h"
#include "tsched.h"
#include "ttime.h"
#include "trpc.h"
#include "ttimezone.h"
#include "clientInt.h"
#define TSC_VAR_NOT_RELEASE 1
#define TSC_VAR_RELEASED 0
SAppInfo
appInfo
;
int32_t
tscReqRef
=
-
1
;
void
*
tscQhandle
;
int32_t
tscReqRef
=
-
1
;
int32_t
tscConnRef
=
-
1
;
void
*
tscRpcCache
;
// TODO removed from here.
void
*
tscQhandle
=
NULL
;
void
*
tscRpcCache
=
NULL
;
// TODO removed from here.
pthread_mutex_t
rpcObjMutex
;
// mutex to protect open the rpc obj concurrently
static
pthread_once_t
tscinit
=
PTHREAD_ONCE_INIT
;
static
pthread_mutex_t
setConfMutex
=
PTHREAD_MUTEX_INITIALIZER
;
volatile
int32_t
tscInitRes
=
0
;
// pthread_once can not return result code, so result code is set to a global variable.
static
volatile
int
tscInitRes
=
0
;
static
void
registerRequest
(
SRequestObj
*
pRequest
)
{
STscObj
*
pTscObj
=
(
STscObj
*
)
taosAcquireRef
(
tscConnRef
,
pRequest
->
pTscObj
->
id
);
assert
(
pTscObj
!=
NULL
);
// connection has been released already, abort creating request.
pRequest
->
self
=
taosAddRef
(
tscReqRef
,
pRequest
);
int32_t
num
=
atomic_add_fetch_32
(
&
pTscObj
->
numOfReqs
,
1
);
SInstanceActivity
*
pActivity
=
&
pTscObj
->
pAppInfo
->
summary
;
int32_t
total
=
atomic_add_fetch_32
(
&
pActivity
->
totalRequests
,
1
);
int32_t
currentInst
=
atomic_add_fetch_32
(
&
pActivity
->
currentRequests
,
1
);
tscDebug
(
"0x%"
PRIx64
" new Request from 0x%"
PRIx64
", current:%d, app current:%d, total:%d"
,
pRequest
->
self
,
pRequest
->
pTscObj
->
id
,
num
,
currentInst
,
total
);
}
static
void
deregisterRequest
(
SRequestObj
*
pRequest
)
{
assert
(
pRequest
!=
NULL
);
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
);
taosReleaseRef
(
tscConnRef
,
pTscObj
->
id
);
}
void
tscFreeRpcObj
(
void
*
param
)
{
#if 0
...
...
@@ -139,22 +166,6 @@ void* createTscObj(const char* user, const char* auth, const char *ip, uint32_t
pObj
->
id
=
taosAddRef
(
tscConnRef
,
pObj
);
}
static
void
registerRequest
(
SRequestObj
*
pRequest
)
{
STscObj
*
pTscObj
=
(
STscObj
*
)
taosAcquireRef
(
tscConnRef
,
pRequest
->
pTscObj
->
id
);
assert
(
pTscObj
!=
NULL
);
// connection has been released already, abort creating request.
pRequest
->
self
=
taosAddRef
(
tscReqRef
,
pRequest
);
int32_t
num
=
atomic_add_fetch_32
(
&
pTscObj
->
numOfReqs
,
1
);
SInstanceActivity
*
pActivity
=
&
pTscObj
->
pAppInfo
->
summary
;
int32_t
total
=
atomic_add_fetch_32
(
&
pActivity
->
totalRequests
,
1
);
int32_t
currentInst
=
atomic_add_fetch_32
(
&
pActivity
->
currentRequests
,
1
);
tscDebug
(
"0x%"
PRIx64
" new Request from 0x%"
PRIx64
", current:%d, app current:%d, total:%d"
,
pRequest
->
self
,
pRequest
->
pTscObj
->
id
,
num
,
currentInst
,
total
);
}
void
*
createRequest
(
STscObj
*
pObj
,
__taos_async_fn_t
fp
,
void
*
param
,
int32_t
type
)
{
assert
(
pObj
!=
NULL
);
...
...
@@ -176,21 +187,6 @@ void* createRequest(STscObj* pObj, __taos_async_fn_t fp, void* param, int32_t ty
registerRequest
(
pRequest
);
}
static
void
deregisterRequest
(
SRequestObj
*
pRequest
)
{
assert
(
pRequest
!=
NULL
);
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
);
taosReleaseRef
(
tscConnRef
,
pTscObj
->
id
);
}
void
destroyRequest
(
void
*
p
)
{
assert
(
p
!=
NULL
);
SRequestObj
*
pRequest
=
*
(
SRequestObj
**
)
p
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录