Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
3e6471eb
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看板
提交
3e6471eb
编写于
5月 09, 2020
作者:
weixin_48148422
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enhance exception handling
上级
b42a8214
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
54 addition
and
8 deletion
+54
-8
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+4
-0
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+23
-0
src/util/inc/exception.h
src/util/inc/exception.h
+6
-3
src/util/src/exception.c
src/util/src/exception.c
+21
-5
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
3e6471eb
...
...
@@ -265,6 +265,10 @@ void tscTryQueryNextVnode(SSqlObj *pSql, __async_cb_func_t fp);
void
tscAsyncQuerySingleRowForNextVnode
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
);
void
tscTryQueryNextClause
(
SSqlObj
*
pSql
,
void
(
*
queryFp
)());
void
*
malloc_throw
(
size_t
size
);
void
*
calloc_throw
(
size_t
nmemb
,
size_t
size
);
char
*
strdup_throw
(
const
char
*
str
);
#ifdef __cplusplus
}
#endif
...
...
src/client/src/tscUtil.c
浏览文件 @
3e6471eb
...
...
@@ -2156,3 +2156,26 @@ void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pFieldInfo, int32_t column
}
}
void
*
malloc_throw
(
size_t
size
)
{
void
*
p
=
malloc
(
size
);
if
(
p
==
NULL
)
{
THROW
(
TSDB_CODE_CLI_OUT_OF_MEMORY
);
}
return
p
;
}
void
*
calloc_throw
(
size_t
nmemb
,
size_t
size
)
{
void
*
p
=
malloc
(
size
);
if
(
p
==
NULL
)
{
THROW
(
TSDB_CODE_CLI_OUT_OF_MEMORY
);
}
return
p
;
}
char
*
strdup_throw
(
const
char
*
str
)
{
char
*
p
=
strdup
(
str
);
if
(
p
==
NULL
)
{
THROW
(
TSDB_CODE_CLI_OUT_OF_MEMORY
);
}
return
p
;
}
src/util/inc/exception.h
浏览文件 @
3e6471eb
...
...
@@ -73,6 +73,7 @@ void cleanupPush_void_ptr_bool ( bool failOnly, void* func, void* arg1, bool ar
void
cleanupPush_void_ptr
(
bool
failOnly
,
void
*
func
,
void
*
arg
);
void
cleanupPush_int_int
(
bool
failOnly
,
void
*
func
,
int
arg
);
void
cleanupPush_void
(
bool
failOnly
,
void
*
func
);
void
cleanupPush_int_ptr
(
bool
failOnly
,
void
*
func
,
void
*
arg
);
int32_t
cleanupGetActionCount
();
void
cleanupExecuteTo
(
int32_t
anchor
,
bool
failed
);
...
...
@@ -83,8 +84,10 @@ void cleanupExecute( SExceptionNode* node, bool failed );
#define CLEANUP_PUSH_VOID_PTR( failOnly, func, arg ) cleanupPush_void_ptr( (failOnly), (void*)(func), (void*)(arg) )
#define CLEANUP_PUSH_INT_INT( failOnly, func, arg ) cleanupPush_void_ptr( (failOnly), (void*)(func), (int)(arg) )
#define CLEANUP_PUSH_VOID( failOnly, func ) cleanupPush_void( (failOnly), (void*)(func) )
#define CLEANUP_PUSH_INT_PTR( failOnly, func, arg ) cleanupPush_int_ptr( (failOnly), (void*)(func), (void*)(arg) )
#define CLEANUP_PUSH_FREE( failOnly, arg ) cleanupPush_void_ptr( (failOnly), free, (void*)(arg) )
#define CLEANUP_PUSH_CLOSE( failOnly, arg ) cleanupPush_int_int( (failOnly), close, (int)(arg) )
#define CLEANUP_PUSH_FCLOSE( failOnly, arg ) cleanupPush_int_ptr( (failOnly), fclose, (void*)(arg) )
#define CLEANUP_GET_ANCHOR() cleanupGetActionCount()
#define CLEANUP_EXECUTE_TO( anchor, failed ) cleanupExecuteTo( (anchor), (failed) )
...
...
@@ -95,7 +98,7 @@ void cleanupExecute( SExceptionNode* node, bool failed );
void
exceptionPushNode
(
SExceptionNode
*
node
);
int32_t
exceptionPopNode
();
void
exceptionThrow
(
int
code
);
void
exceptionThrow
(
int
32_t
code
);
#define TRY(maxCleanupActions) do { \
SExceptionNode exceptionNode = { 0 }; \
...
...
@@ -106,10 +109,10 @@ void exceptionThrow( int code );
int caughtException = setjmp( exceptionNode.jb ); \
if( caughtException == 0 )
#define CATCH( code ) int code = exceptionPopNode(); \
#define CATCH( code ) int
32_t
code = exceptionPopNode(); \
if( caughtException == 1 )
#define FINALLY( code ) int code = exceptionPopNode();
#define FINALLY( code ) int
32_t
code = exceptionPopNode();
#define END_TRY } while( 0 );
...
...
src/util/src/exception.c
浏览文件 @
3e6471eb
...
...
@@ -14,7 +14,7 @@ int32_t exceptionPopNode() {
return
node
->
code
;
}
void
exceptionThrow
(
int
code
)
{
void
exceptionThrow
(
int
32_t
code
)
{
expList
->
code
=
code
;
longjmp
(
expList
->
jb
,
1
);
}
...
...
@@ -38,21 +38,27 @@ static void cleanupWrapper_void_ptr( SCleanupAction* ca ) {
static
void
cleanupWrapper_int_int
(
SCleanupAction
*
ca
)
{
int
(
*
func
)(
int
)
=
ca
->
func
;
func
(
(
int
)(
intptr_t
)(
ca
->
arg1
.
Int
)
);
func
(
ca
->
arg1
.
Int
);
}
static
void
cleanupWrapper_void
_void
(
SCleanupAction
*
ca
)
{
static
void
cleanupWrapper_void
(
SCleanupAction
*
ca
)
{
void
(
*
func
)()
=
ca
->
func
;
func
();
}
static
void
cleanupWrapper_int_ptr
(
SCleanupAction
*
ca
)
{
int
(
*
func
)(
void
*
)
=
ca
->
func
;
func
(
ca
->
arg1
.
Ptr
);
}
typedef
void
(
*
wrapper
)(
SCleanupAction
*
);
static
wrapper
wrappers
[]
=
{
cleanupWrapper_void_ptr_ptr
,
cleanupWrapper_void_ptr_bool
,
cleanupWrapper_void_ptr
,
cleanupWrapper_int_int
,
cleanupWrapper_void_void
,
cleanupWrapper_void
,
cleanupWrapper_int_ptr
,
};
...
...
@@ -107,6 +113,15 @@ void cleanupPush_void( bool failOnly, void* func ) {
ca
->
func
=
func
;
}
void
cleanupPush_int_ptr
(
bool
failOnly
,
void
*
func
,
void
*
arg
)
{
assert
(
expList
->
numCleanupAction
<
expList
->
maxCleanupAction
);
SCleanupAction
*
ca
=
expList
->
cleanupActions
+
expList
->
numCleanupAction
++
;
ca
->
wrapper
=
5
;
ca
->
failOnly
=
failOnly
;
ca
->
func
=
func
;
ca
->
arg1
.
Ptr
=
arg
;
}
int32_t
cleanupGetActionCount
()
{
...
...
@@ -118,8 +133,9 @@ static void doExecuteCleanup( SExceptionNode* node, int32_t anchor, bool failed
while
(
node
->
numCleanupAction
>
anchor
)
{
--
node
->
numCleanupAction
;
SCleanupAction
*
ca
=
node
->
cleanupActions
+
node
->
numCleanupAction
;
if
(
failed
||
!
(
ca
->
failOnly
)
)
if
(
failed
||
!
(
ca
->
failOnly
)
)
{
wrappers
[
ca
->
wrapper
](
ca
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录