Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
b157f711
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b157f711
编写于
12月 17, 2020
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move signal handle to thread
上级
fce7a9d2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
41 addition
and
10 deletion
+41
-10
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+13
-4
src/kit/shell/src/shellMain.c
src/kit/shell/src/shellMain.c
+28
-6
未找到文件。
src/kit/shell/src/shellEngine.c
浏览文件 @
b157f711
...
...
@@ -260,6 +260,14 @@ int32_t shellRunCommand(TAOS* con, char* command) {
}
void
freeResultWithRid
(
int64_t
rid
)
{
SSqlObj
*
pSql
=
taosAcquireRef
(
tscObjRef
,
rid
);
if
(
pSql
){
taos_free_result
(
pSql
);
taosReleaseRef
(
tscObjRef
,
rid
);
}
}
void
shellRunCommandOnServer
(
TAOS
*
con
,
char
command
[])
{
int64_t
st
,
et
;
wordexp_t
full_path
;
...
...
@@ -301,14 +309,15 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
return
;
}
result
=
((
SSqlObj
*
)
tmpSql
)
->
self
;
atomic_store_64
(
&
result
,
((
SSqlObj
*
)
tmpSql
)
->
self
);
int64_t
oresult
=
atomic_load_64
(
&
result
);
if
(
regex_match
(
command
,
"^
\\
s*use
\\
s+[a-zA-Z0-9_]+
\\
s*;
\\
s*$"
,
REG_EXTENDED
|
REG_ICASE
))
{
fprintf
(
stdout
,
"Database changed.
\n\n
"
);
fflush
(
stdout
);
atomic_store_64
(
&
result
,
0
);
taos_free_result
(
pSql
);
freeResultWithRid
(
oresult
);
return
;
}
...
...
@@ -317,7 +326,7 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
int
numOfRows
=
shellDumpResult
(
pSql
,
fname
,
&
error_no
,
printMode
);
if
(
numOfRows
<
0
)
{
atomic_store_64
(
&
result
,
0
);
taos_free_result
(
pSql
);
freeResultWithRid
(
oresult
);
return
;
}
...
...
@@ -340,7 +349,7 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
}
atomic_store_64
(
&
result
,
0
);
taos_free_result
(
pSql
);
freeResultWithRid
(
oresult
);
}
/* Function to do regular expression check */
...
...
src/kit/shell/src/shellMain.c
浏览文件 @
b157f711
...
...
@@ -19,17 +19,31 @@
#include "tnettest.h"
pthread_t
pid
;
static
tsem_t
cancelSem
;
void
shellQueryInterruptHandler
(
int
signum
)
{
tsem_post
(
&
cancelSem
);
}
void
*
cancelHandler
(
void
*
arg
)
{
while
(
1
)
{
if
(
tsem_wait
(
&
cancelSem
)
!=
0
)
{
taosMsleep
(
10
);
continue
;
}
#ifdef LINUX
int64_t
rid
=
atomic_val_compare_exchange_64
(
&
result
,
result
,
0
);
SSqlObj
*
pSql
=
taosAcquireRef
(
tscObjRef
,
rid
);
taos_stop_query
(
pSql
);
taosReleaseRef
(
tscObjRef
,
rid
);
int64_t
rid
=
atomic_val_compare_exchange_64
(
&
result
,
result
,
0
);
SSqlObj
*
pSql
=
taosAcquireRef
(
tscObjRef
,
rid
);
taos_stop_query
(
pSql
);
taosReleaseRef
(
tscObjRef
,
rid
);
#else
printf
(
"
\n
Receive ctrl+c or other signal, quit shell.
\n
"
);
exit
(
0
);
printf
(
"
\n
Receive ctrl+c or other signal, quit shell.
\n
"
);
exit
(
0
);
#endif
}
return
NULL
;
}
int
checkVersion
()
{
...
...
@@ -107,6 +121,14 @@ int main(int argc, char* argv[]) {
exit
(
EXIT_FAILURE
);
}
if
(
tsem_init
(
&
cancelSem
,
0
,
0
)
!=
0
)
{
printf
(
"failed to create cancel semphore
\n
"
);
exit
(
EXIT_FAILURE
);
}
pthread_t
spid
;
pthread_create
(
&
spid
,
NULL
,
cancelHandler
,
NULL
);
/* Interrupt handler. */
struct
sigaction
act
;
memset
(
&
act
,
0
,
sizeof
(
struct
sigaction
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录