提交 8ab1aa4a 编写于 作者: S slzhou

fix: change bugs related to expired udf

上级 adec92b0
...@@ -513,9 +513,9 @@ void convertUdf2UdfInfo(SUdf *udf, SScriptUdfInfo *udfInfo) { ...@@ -513,9 +513,9 @@ void convertUdf2UdfInfo(SUdf *udf, SScriptUdfInfo *udfInfo) {
int32_t udfdRenameUdfFile(SUdf *udf) { int32_t udfdRenameUdfFile(SUdf *udf) {
char newPath[PATH_MAX]; char newPath[PATH_MAX];
if (udf->scriptType == TSDB_FUNC_SCRIPT_BIN_LIB) { if (udf->scriptType == TSDB_FUNC_SCRIPT_BIN_LIB) {
snprintf(newPath, PATH_MAX, "%s/lib%s_%d_%"PRId64".so", tsTempDir, udf->name, udf->version, udf->lastFetchTime); snprintf(newPath, PATH_MAX, "%s/lib%s_%d_%" PRId64 ".so", tsTempDir, udf->name, udf->version, udf->lastFetchTime);
} else if (udf->scriptType == TSDB_FUNC_SCRIPT_PYTHON) { } else if (udf->scriptType == TSDB_FUNC_SCRIPT_PYTHON) {
snprintf(newPath, PATH_MAX, "%s/%s_%d_%"PRId64".py", tsTempDir, udf->name, udf->version, udf->lastFetchTime); snprintf(newPath, PATH_MAX, "%s/%s_%d_%" PRId64 ".py", tsTempDir, udf->name, udf->version, udf->lastFetchTime);
} else { } else {
return TSDB_CODE_UDF_SCRIPT_NOT_SUPPORTED; return TSDB_CODE_UDF_SCRIPT_NOT_SUPPORTED;
} }
...@@ -589,17 +589,18 @@ SUdf *udfdGetOrCreateUdf(const char *udfName) { ...@@ -589,17 +589,18 @@ SUdf *udfdGetOrCreateUdf(const char *udfName) {
uv_mutex_lock(&global.udfsMutex); uv_mutex_lock(&global.udfsMutex);
SUdf **pUdfHash = taosHashGet(global.udfsHash, udfName, strlen(udfName)); SUdf **pUdfHash = taosHashGet(global.udfsHash, udfName, strlen(udfName));
int64_t currTime = taosGetTimestampSec(); int64_t currTime = taosGetTimestampSec();
bool expired = currTime - (*pUdfHash)->lastFetchTime > 10 * 1000; bool expired = false;
if (pUdfHash && !expired) { if (pUdfHash) {
++(*pUdfHash)->refCount; expired = currTime - (*pUdfHash)->lastFetchTime > 10 * 1000;
SUdf *udf = *pUdfHash; if (!expired) {
uv_mutex_unlock(&global.udfsMutex); ++(*pUdfHash)->refCount;
return udf; SUdf *udf = *pUdfHash;
} uv_mutex_unlock(&global.udfsMutex);
return udf;
if (pUdfHash && expired) { } else {
(*pUdfHash)->expired = true; (*pUdfHash)->expired = true;
taosHashRemove(global.udfsHash, udfName, strlen(udfName)); taosHashRemove(global.udfsHash, udfName, strlen(udfName));
}
} }
SUdf *udf = udfdNewUdf(udfName); SUdf *udf = udfdNewUdf(udfName);
...@@ -809,7 +810,7 @@ void udfdProcessTeardownRequest(SUvUdfWork *uvUdf, SUdfRequest *request) { ...@@ -809,7 +810,7 @@ void udfdProcessTeardownRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
return; return;
} }
int32_t udfdSaveFuncBodyToFile(SFuncInfo* pFuncInfo, SUdf* udf) { int32_t udfdSaveFuncBodyToFile(SFuncInfo *pFuncInfo, SUdf *udf) {
if (!osTempSpaceAvailable()) { if (!osTempSpaceAvailable()) {
terrno = TSDB_CODE_NO_AVAIL_DISK; terrno = TSDB_CODE_NO_AVAIL_DISK;
fnError("udfd create shared library failed since %s", terrstr(terrno)); fnError("udfd create shared library failed since %s", terrstr(terrno));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册