diff --git a/source/libs/catalog/test/catalogTests.cpp b/source/libs/catalog/test/catalogTests.cpp index 5e543384ac2747005ddb40602ca778253ea1eacd..f3f7d62acf5c97c8f4d565aa69cdd8bcee0eea93 100644 --- a/source/libs/catalog/test/catalogTests.cpp +++ b/source/libs/catalog/test/catalogTests.cpp @@ -672,12 +672,15 @@ void ctgTestRspUdfInfo(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pR SRetrieveFuncRsp funcRsp = {0}; funcRsp.numOfFuncs = 1; funcRsp.pFuncInfos = taosArrayInit(1, sizeof(SFuncInfo)); + funcRsp.pFuncVersions = taosArrayInit(1, sizeof(int32_t)); SFuncInfo funcInfo = {0}; strcpy(funcInfo.name, "func1"); funcInfo.funcType = ctgTestFuncType; (void)taosArrayPush(funcRsp.pFuncInfos, &funcInfo); - + int32_t version = 0; + (void)taosArrayPush(funcRsp.pFuncVersions, &version); + int32_t rspLen = tSerializeSRetrieveFuncRsp(NULL, 0, &funcRsp); void *pReq = rpcMallocCont(rspLen); tSerializeSRetrieveFuncRsp(pReq, rspLen, &funcRsp); diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index 3e03e1acb61d0959b7c567d8cd67d2a1474e2daf..fbf523ac4fd4a657540dbe4fe8e66b9b5d16b54d 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -581,6 +581,7 @@ int32_t udfdInitUdf(char *udfName, SUdf *udf) { SUdf *udfdNewUdf(const char *udfName) { SUdf *udfNew = taosMemoryCalloc(1, sizeof(SUdf)); udfNew->refCount = 1; + udfNew->lastFetchTime = taosGetTimestampUs(); strncpy(udfNew->name, udfName, TSDB_FUNC_NAME_LEN); udfNew->state = UDF_STATE_INIT; @@ -618,6 +619,7 @@ SUdf *udfdGetOrCreateUdf(const char *udfName) { } SUdf *udf = udfdNewUdf(udfName); + SUdf **pUdf = &udf; taosHashPut(global.udfsHash, udfName, strlen(udfName), pUdf, POINTER_BYTES); uv_mutex_unlock(&global.udfsMutex); @@ -902,8 +904,8 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { udf->version = *(int32_t *)taosArrayGet(retrieveRsp.pFuncVersions, 0); msgInfo->code = udfdSaveFuncBodyToFile(pFuncInfo, udf); - if (msgInfo->code == 0) { - udf->lastFetchTime = taosGetTimestampUs(); + if (msgInfo->code != 0) { + udf->lastFetchTime = 0; } tFreeSFuncInfo(pFuncInfo); taosArrayDestroy(retrieveRsp.pFuncInfos);