Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a7888257
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看板
提交
a7888257
编写于
2月 23, 2023
作者:
S
slzhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: call closeFunc when it is not nullptr
上级
7ec5a5df
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
20 deletion
+20
-20
source/libs/function/src/udfd.c
source/libs/function/src/udfd.c
+20
-20
未找到文件。
source/libs/function/src/udfd.c
浏览文件 @
a7888257
...
@@ -33,7 +33,6 @@
...
@@ -33,7 +33,6 @@
#define MAX_NUM_SCRIPT_PLUGINS 64
#define MAX_NUM_SCRIPT_PLUGINS 64
#define MAX_NUM_PLUGIN_FUNCS 9
#define MAX_NUM_PLUGIN_FUNCS 9
typedef
struct
SUdfCPluginCtx
{
typedef
struct
SUdfCPluginCtx
{
uv_lib_t
lib
;
uv_lib_t
lib
;
...
@@ -347,14 +346,14 @@ void udfdInitializePythonPlugin(SUdfScriptPlugin *plugin) {
...
@@ -347,14 +346,14 @@ void udfdInitializePythonPlugin(SUdfScriptPlugin *plugin) {
return
;
return
;
}
}
if
(
plugin
->
openFunc
)
{
if
(
plugin
->
openFunc
)
{
int16_t
lenPythonPath
=
strlen
(
tsUdfdLdLibPath
)
+
strlen
(
tsTempDir
)
+
1
+
1
;
//
tsTempDir:tsUdfdLdLibPath
int16_t
lenPythonPath
=
strlen
(
tsUdfdLdLibPath
)
+
strlen
(
tsTempDir
)
+
1
+
1
;
//
tsTempDir:tsUdfdLdLibPath
char
*
pythonPath
=
taosMemoryMalloc
(
lenPythonPath
);
char
*
pythonPath
=
taosMemoryMalloc
(
lenPythonPath
);
#ifdef WINDOWS
#ifdef WINDOWS
snprintf
(
pythonPath
,
lenPythonPath
,
"%s;%s"
,
tsTempDir
,
tsUdfdLdLibPath
);
snprintf
(
pythonPath
,
lenPythonPath
,
"%s;%s"
,
tsTempDir
,
tsUdfdLdLibPath
);
#else
#else
snprintf
(
pythonPath
,
lenPythonPath
,
"%s:%s"
,
tsTempDir
,
tsUdfdLdLibPath
);
snprintf
(
pythonPath
,
lenPythonPath
,
"%s:%s"
,
tsTempDir
,
tsUdfdLdLibPath
);
#endif
#endif
SScriptUdfEnvItem
items
[]
=
{{
"PYTHONPATH"
,
pythonPath
}};
SScriptUdfEnvItem
items
[]
=
{{
"PYTHONPATH"
,
pythonPath
}};
plugin
->
openFunc
(
items
,
1
);
plugin
->
openFunc
(
items
,
1
);
taosMemoryFree
(
pythonPath
);
taosMemoryFree
(
pythonPath
);
}
}
...
@@ -374,12 +373,14 @@ void udfdDeinitCPlugin(SUdfScriptPlugin *plugin) {
...
@@ -374,12 +373,14 @@ void udfdDeinitCPlugin(SUdfScriptPlugin *plugin) {
plugin
->
udfAggStartFunc
=
NULL
;
plugin
->
udfAggStartFunc
=
NULL
;
plugin
->
udfAggProcFunc
=
NULL
;
plugin
->
udfAggProcFunc
=
NULL
;
plugin
->
udfAggMergeFunc
=
NULL
;
plugin
->
udfAggMergeFunc
=
NULL
;
plugin
->
udfAggFinishFunc
=
NULL
;
plugin
->
udfAggFinishFunc
=
NULL
;
return
;
return
;
}
}
void
udfdDeinitPythonPlugin
(
SUdfScriptPlugin
*
plugin
)
{
void
udfdDeinitPythonPlugin
(
SUdfScriptPlugin
*
plugin
)
{
plugin
->
closeFunc
();
if
(
plugin
->
closeFunc
)
{
plugin
->
closeFunc
();
}
uv_dlclose
(
&
plugin
->
lib
);
uv_dlclose
(
&
plugin
->
lib
);
if
(
plugin
->
libLoaded
)
{
if
(
plugin
->
libLoaded
)
{
plugin
->
libLoaded
=
false
;
plugin
->
libLoaded
=
false
;
...
@@ -418,11 +419,10 @@ void udfdDeinitScriptPlugins() {
...
@@ -418,11 +419,10 @@ void udfdDeinitScriptPlugins() {
plugin
=
global
.
scriptPlugins
[
TSDB_FUNC_SCRIPT_BIN_LIB
];
plugin
=
global
.
scriptPlugins
[
TSDB_FUNC_SCRIPT_BIN_LIB
];
udfdDeinitCPlugin
(
plugin
);
udfdDeinitCPlugin
(
plugin
);
taosMemoryFree
(
plugin
);
taosMemoryFree
(
plugin
);
return
;
return
;
}
}
void
udfdProcessRequest
(
uv_work_t
*
req
)
{
void
udfdProcessRequest
(
uv_work_t
*
req
)
{
SUvUdfWork
*
uvUdf
=
(
SUvUdfWork
*
)(
req
->
data
);
SUvUdfWork
*
uvUdf
=
(
SUvUdfWork
*
)(
req
->
data
);
SUdfRequest
request
=
{
0
};
SUdfRequest
request
=
{
0
};
...
@@ -469,7 +469,7 @@ int32_t udfdInitUdf(char *udfName, SUdf *udf) {
...
@@ -469,7 +469,7 @@ int32_t udfdInitUdf(char *udfName, SUdf *udf) {
fnError
(
"can not retrieve udf from mnode. udf name %s"
,
udfName
);
fnError
(
"can not retrieve udf from mnode. udf name %s"
,
udfName
);
return
TSDB_CODE_UDF_LOAD_UDF_FAILURE
;
return
TSDB_CODE_UDF_LOAD_UDF_FAILURE
;
}
}
//TODO: remove script plugins mutex
//
TODO: remove script plugins mutex
uv_mutex_lock
(
&
global
.
scriptPluginsMutex
);
uv_mutex_lock
(
&
global
.
scriptPluginsMutex
);
SUdfScriptPlugin
*
scriptPlugin
=
global
.
scriptPlugins
[
udf
->
scriptType
];
SUdfScriptPlugin
*
scriptPlugin
=
global
.
scriptPlugins
[
udf
->
scriptType
];
if
(
scriptPlugin
==
NULL
)
{
if
(
scriptPlugin
==
NULL
)
{
...
@@ -516,7 +516,7 @@ void udfdProcessSetupRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
...
@@ -516,7 +516,7 @@ void udfdProcessSetupRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
SUdfSetupRequest
*
setup
=
&
request
->
setup
;
SUdfSetupRequest
*
setup
=
&
request
->
setup
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SUdf
*
udf
=
NULL
;
SUdf
*
udf
=
NULL
;
udf
=
udfdGetOrCreateUdf
(
setup
->
udfName
);
udf
=
udfdGetOrCreateUdf
(
setup
->
udfName
);
...
@@ -766,11 +766,11 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
...
@@ -766,11 +766,11 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
}
}
char
path
[
PATH_MAX
]
=
{
0
};
char
path
[
PATH_MAX
]
=
{
0
};
#ifdef WINDOWS
#ifdef WINDOWS
snprintf
(
path
,
sizeof
(
path
),
"%s%s"
,
tsTempDir
,
pFuncInfo
->
name
);
snprintf
(
path
,
sizeof
(
path
),
"%s%s"
,
tsTempDir
,
pFuncInfo
->
name
);
#else
#else
snprintf
(
path
,
sizeof
(
path
),
"%s/%s"
,
tsTempDir
,
pFuncInfo
->
name
);
snprintf
(
path
,
sizeof
(
path
),
"%s/%s"
,
tsTempDir
,
pFuncInfo
->
name
);
#endif
#endif
TdFilePtr
file
=
taosOpenFile
(
path
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_READ
|
TD_FILE_TRUNC
);
TdFilePtr
file
=
taosOpenFile
(
path
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_READ
|
TD_FILE_TRUNC
);
if
(
file
==
NULL
)
{
if
(
file
==
NULL
)
{
fnError
(
"udfd write udf shared library: %s failed, error: %d %s"
,
path
,
errno
,
strerror
(
errno
));
fnError
(
"udfd write udf shared library: %s failed, error: %d %s"
,
path
,
errno
,
strerror
(
errno
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录