Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c7c0fd1d
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
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看板
提交
c7c0fd1d
编写于
1月 27, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug
上级
2327cbb9
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
58 addition
and
25 deletion
+58
-25
src/cq/src/cqMain.c
src/cq/src/cqMain.c
+58
-25
未找到文件。
src/cq/src/cqMain.c
浏览文件 @
c7c0fd1d
...
...
@@ -50,6 +50,8 @@ typedef struct {
void
*
dbConn
;
void
*
tmrCtrl
;
pthread_mutex_t
mutex
;
int32_t
delete
;
int32_t
cqObjNum
;
}
SCqContext
;
typedef
struct
SCqObj
{
...
...
@@ -72,17 +74,10 @@ static void cqCreateStream(SCqContext *pContext, SCqObj *pObj);
int32_t
cqObjRef
=
-
1
;
void
cqRmFromList
(
SCqObj
*
pObj
)
{
//LOCK in caller
void
cqFree
(
void
*
handle
)
{
if
(
tsEnableStream
==
0
)
{
return
;
}
SCqObj
*
pObj
=
handle
;
SCqContext
*
pContext
=
pObj
->
pContext
;
int32_t
last
=
0
;
pthread_mutex_lock
(
&
pContext
->
mutex
);
if
(
pObj
->
prev
)
{
pObj
->
prev
->
next
=
pObj
->
next
;
...
...
@@ -94,9 +89,17 @@ void cqFree(void *handle) {
pObj
->
next
->
prev
=
pObj
->
prev
;
}
if
(
pContext
->
pHead
==
NULL
)
{
last
=
1
;
}
void
cqFree
(
void
*
handle
)
{
if
(
tsEnableStream
==
0
)
{
return
;
}
SCqObj
*
pObj
=
handle
;
SCqContext
*
pContext
=
pObj
->
pContext
;
int32_t
delete
=
0
;
pthread_mutex_lock
(
&
pContext
->
mutex
);
// free the resources associated
if
(
pObj
->
pStream
)
{
...
...
@@ -113,9 +116,15 @@ void cqFree(void *handle) {
free
(
pObj
->
sqlStr
);
free
(
pObj
);
pContext
->
cqObjNum
--
;
if
(
pContext
->
cqObjNum
<=
0
&&
pContext
->
delete
)
{
delete
=
1
;
}
pthread_mutex_unlock
(
&
pContext
->
mutex
);
if
(
last
)
{
if
(
delete
)
{
pthread_mutex_unlock
(
&
pContext
->
mutex
);
pthread_mutex_destroy
(
&
pContext
->
mutex
);
...
...
@@ -184,18 +193,29 @@ void cqClose(void *handle) {
SCqContext
*
pContext
=
handle
;
if
(
handle
==
NULL
)
return
;
pContext
->
delete
=
1
;
// stop all CQs
cqStop
(
pContext
);
// free all resources
int64_t
rid
=
0
;
while
(
1
)
{
pthread_mutex_lock
(
&
pContext
->
mutex
);
SCqObj
*
pObj
=
pContext
->
pHead
;
while
(
pObj
)
{
SCqObj
*
pTemp
=
pObj
;
pObj
=
pObj
->
next
;
if
(
pObj
)
{
cqRmFromList
(
pObj
);
rid
=
pObj
->
rid
;
}
else
{
pthread_mutex_unlock
(
&
pContext
->
mutex
);
break
;
}
pthread_mutex_unlock
(
&
pContext
->
mutex
);
taosReleaseRef
(
cqObjRef
,
pTemp
->
rid
);
taosReleaseRef
(
cqObjRef
,
rid
);
}
}
...
...
@@ -255,6 +275,7 @@ void *cqCreate(void *handle, uint64_t uid, int32_t sid, const char* dstTable, ch
return
NULL
;
}
SCqContext
*
pContext
=
handle
;
int64_t
rid
=
0
;
SCqObj
*
pObj
=
calloc
(
sizeof
(
SCqObj
),
1
);
if
(
pObj
==
NULL
)
return
NULL
;
...
...
@@ -277,25 +298,36 @@ void *cqCreate(void *handle, uint64_t uid, int32_t sid, const char* dstTable, ch
if
(
pContext
->
pHead
)
pContext
->
pHead
->
prev
=
pObj
;
pContext
->
pHead
=
pObj
;
pContext
->
cqObjNum
++
;
pObj
->
rid
=
taosAddRef
(
cqObjRef
,
pObj
);
cqCreateStream
(
pContext
,
pObj
);
rid
=
pObj
->
rid
;
pthread_mutex_unlock
(
&
pContext
->
mutex
);
return
pObj
;
return
(
void
*
)
rid
;
}
void
cqDrop
(
void
*
handle
)
{
if
(
tsEnableStream
==
0
)
{
return
;
}
SCqObj
*
pObj
=
handle
;
SCqObj
*
pObj
=
(
SCqObj
*
)
taosAcquireRef
(
cqObjRef
,
(
int64_t
)
handle
);
if
(
pObj
==
NULL
)
{
return
;
}
SCqContext
*
pContext
=
pObj
->
pContext
;
pthread_mutex_lock
(
&
pContext
->
mutex
);
cqRmFromList
(
pObj
);
// free the resources associated
if
(
pObj
->
pStream
)
{
taos_close_stream
(
pObj
->
pStream
);
...
...
@@ -307,7 +339,8 @@ void cqDrop(void *handle) {
pthread_mutex_unlock
(
&
pContext
->
mutex
);
taosReleaseRef
(
cqObjRef
,
pObj
->
rid
);
taosRemoveRef
(
cqObjRef
,
(
int64_t
)
handle
);
taosReleaseRef
(
cqObjRef
,
(
int64_t
)
handle
);
}
static
void
doCreateStream
(
void
*
param
,
TAOS_RES
*
result
,
int32_t
code
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录