Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b82c54f8
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
未验证
提交
b82c54f8
编写于
12月 02, 2020
作者:
H
haojun Liao
提交者:
GitHub
12月 02, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4412 from taosdata/bugfix/td-2290
fix td-2290
上级
68c96c78
e690846c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
83 addition
and
8 deletion
+83
-8
src/client/src/tscSub.c
src/client/src/tscSub.c
+83
-8
未找到文件。
src/client/src/tscSub.c
浏览文件 @
b82c54f8
...
...
@@ -157,7 +157,7 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char*
registerSqlObj
(
pSql
);
code
=
tsParseSql
(
pSql
,
fals
e
);
code
=
tsParseSql
(
pSql
,
tru
e
);
if
(
code
==
TSDB_CODE_TSC_ACTION_IN_PROGRESS
)
{
tsem_wait
(
&
pSub
->
sem
);
code
=
pSql
->
res
.
code
;
...
...
@@ -168,7 +168,7 @@ static SSub* tscCreateSubscription(STscObj* pObj, const char* topic, const char*
goto
fail
;
}
if
(
pSql
->
cmd
.
command
!=
TSDB_SQL_SELECT
)
{
if
(
pSql
->
cmd
.
command
!=
TSDB_SQL_SELECT
&&
pSql
->
cmd
.
command
!=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
)
{
line
=
__LINE__
;
code
=
TSDB_CODE_TSC_INVALID_SQL
;
goto
fail
;
...
...
@@ -182,7 +182,7 @@ fail:
if
(
pSql
->
self
!=
0
)
{
taosReleaseRef
(
tscObjRef
,
pSql
->
self
);
}
else
{
tscFreeSqlObj
(
pSql
);
tscFreeSqlObj
(
pSql
);
}
pSql
=
NULL
;
...
...
@@ -401,9 +401,11 @@ TAOS_SUB *taos_subscribe(TAOS *taos, int restart, const char* topic, const char
tscLoadSubscriptionProgress
(
pSub
);
}
if
(
!
tscUpdateSubscription
(
pObj
,
pSub
))
{
taos_unsubscribe
(
pSub
,
1
);
return
NULL
;
if
(
pSub
->
pSql
->
cmd
.
command
==
TSDB_SQL_SELECT
)
{
if
(
!
tscUpdateSubscription
(
pObj
,
pSub
))
{
taos_unsubscribe
(
pSub
,
1
);
return
NULL
;
}
}
pSub
->
interval
=
interval
;
...
...
@@ -417,10 +419,80 @@ TAOS_SUB *taos_subscribe(TAOS *taos, int restart, const char* topic, const char
return
pSub
;
}
SSqlObj
*
recreateSqlObj
(
SSub
*
pSub
)
{
SSqlObj
*
pSql
=
calloc
(
1
,
sizeof
(
SSqlObj
));
if
(
pSql
==
NULL
)
{
return
NULL
;
}
pSql
->
signature
=
pSql
;
pSql
->
pTscObj
=
pSub
->
taos
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
if
(
tsem_init
(
&
pSql
->
rspSem
,
0
,
0
)
==
-
1
)
{
tscFreeSqlObj
(
pSql
);
return
NULL
;
}
pSql
->
param
=
pSub
;
pSql
->
maxRetry
=
TSDB_MAX_REPLICA
;
pSql
->
fp
=
asyncCallback
;
pSql
->
fetchFp
=
asyncCallback
;
pSql
->
sqlstr
=
strdup
(
pSub
->
pSql
->
sqlstr
);
if
(
pSql
->
sqlstr
==
NULL
)
{
tscFreeSqlObj
(
pSql
);
return
NULL
;
}
pRes
->
qhandle
=
0
;
pRes
->
numOfRows
=
1
;
int
code
=
tscAllocPayload
(
pCmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscFreeSqlObj
(
pSql
);
return
NULL
;
}
registerSqlObj
(
pSql
);
code
=
tsParseSql
(
pSql
,
true
);
if
(
code
==
TSDB_CODE_TSC_ACTION_IN_PROGRESS
)
{
tsem_wait
(
&
pSub
->
sem
);
code
=
pSql
->
res
.
code
;
}
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
taosReleaseRef
(
tscObjRef
,
pSql
->
self
);
return
NULL
;
}
if
(
pSql
->
cmd
.
command
!=
TSDB_SQL_SELECT
)
{
taosReleaseRef
(
tscObjRef
,
pSql
->
self
);
return
NULL
;
}
return
pSql
;
}
TAOS_RES
*
taos_consume
(
TAOS_SUB
*
tsub
)
{
SSub
*
pSub
=
(
SSub
*
)
tsub
;
if
(
pSub
==
NULL
)
return
NULL
;
if
(
pSub
->
pSql
->
cmd
.
command
==
TSDB_SQL_RETRIEVE_EMPTY_RESULT
)
{
SSqlObj
*
pSql
=
recreateSqlObj
(
pSub
);
if
(
pSql
==
NULL
)
{
return
NULL
;
}
if
(
pSub
->
pSql
->
self
!=
0
)
{
taosReleaseRef
(
tscObjRef
,
pSub
->
pSql
->
self
);
}
else
{
tscFreeSqlObj
(
pSub
->
pSql
);
}
pSub
->
pSql
=
pSql
;
pSql
->
pSubscription
=
pSub
;
}
tscSaveSubscriptionProgress
(
pSub
);
SSqlObj
*
pSql
=
pSub
->
pSql
;
...
...
@@ -512,10 +584,13 @@ void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress) {
}
if
(
pSub
->
pSql
!=
NULL
)
{
taos_free_result
(
pSub
->
pSql
);
if
(
pSub
->
pSql
->
self
!=
0
)
{
taosReleaseRef
(
tscObjRef
,
pSub
->
pSql
->
self
);
}
else
{
tscFreeSqlObj
(
pSub
->
pSql
);
}
}
tscFreeSqlObj
(
pSub
->
pSql
);
taosArrayDestroy
(
pSub
->
progress
);
tsem_destroy
(
&
pSub
->
sem
);
memset
(
pSub
,
0
,
sizeof
(
*
pSub
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录