fix: call closeFunc when it is not nullptr
This commit is contained in:
parent
7ec5a5df3a
commit
a7888257d7
|
@ -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) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -379,7 +378,9 @@ void udfdDeinitCPlugin(SUdfScriptPlugin *plugin) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void udfdDeinitPythonPlugin(SUdfScriptPlugin *plugin) {
|
void udfdDeinitPythonPlugin(SUdfScriptPlugin *plugin) {
|
||||||
|
if (plugin->closeFunc) {
|
||||||
plugin->closeFunc();
|
plugin->closeFunc();
|
||||||
|
}
|
||||||
uv_dlclose(&plugin->lib);
|
uv_dlclose(&plugin->lib);
|
||||||
if (plugin->libLoaded) {
|
if (plugin->libLoaded) {
|
||||||
plugin->libLoaded = false;
|
plugin->libLoaded = false;
|
||||||
|
@ -422,7 +423,6 @@ void udfdDeinitScriptPlugins() {
|
||||||
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) {
|
||||||
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) {
|
||||||
|
@ -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));
|
||||||
|
|
Loading…
Reference in New Issue