tstrncpy
This commit is contained in:
parent
95a26d7ee9
commit
eaf8bf0ca6
|
@ -214,7 +214,7 @@ extern int64_t tsMinDiskFreeSize;
|
||||||
// udf
|
// udf
|
||||||
extern bool tsStartUdfd;
|
extern bool tsStartUdfd;
|
||||||
extern char tsUdfdResFuncs[];
|
extern char tsUdfdResFuncs[];
|
||||||
extern char tsUdfdLdLibPath[];
|
extern char tsUdfdLdLibPath[512];
|
||||||
|
|
||||||
// schemaless
|
// schemaless
|
||||||
extern char tsSmlChildTableName[];
|
extern char tsSmlChildTableName[];
|
||||||
|
|
|
@ -143,10 +143,10 @@ static int32_t udfSpawnUdfd(SUdfdData *pData) {
|
||||||
|
|
||||||
char udfdPathLdLib[1024] = {0};
|
char udfdPathLdLib[1024] = {0};
|
||||||
size_t udfdLdLibPathLen = strlen(tsUdfdLdLibPath);
|
size_t udfdLdLibPathLen = strlen(tsUdfdLdLibPath);
|
||||||
strncpy(udfdPathLdLib, tsUdfdLdLibPath, tListLen(udfdPathLdLib));
|
tstrncpy(udfdPathLdLib, tsUdfdLdLibPath, sizeof(udfdPathLdLib) < sizeof(tsUdfdLdLibPath) ? sizeof(udfdPathLdLib) : sizeof(tsUdfdLdLibPath));
|
||||||
|
|
||||||
udfdPathLdLib[udfdLdLibPathLen] = ':';
|
udfdPathLdLib[udfdLdLibPathLen] = ':';
|
||||||
strncpy(udfdPathLdLib + udfdLdLibPathLen + 1, pathTaosdLdLib, sizeof(udfdPathLdLib) - udfdLdLibPathLen - 1);
|
tstrncpy(udfdPathLdLib + udfdLdLibPathLen + 1, pathTaosdLdLib, sizeof(udfdPathLdLib) - udfdLdLibPathLen - 1);
|
||||||
if (udfdLdLibPathLen + taosdLdLibPathLen < 1024) {
|
if (udfdLdLibPathLen + taosdLdLibPathLen < 1024) {
|
||||||
fnInfo("[UDFD]udfd LD_LIBRARY_PATH: %s", udfdPathLdLib);
|
fnInfo("[UDFD]udfd LD_LIBRARY_PATH: %s", udfdPathLdLib);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1073,7 +1073,7 @@ int32_t acquireUdfFuncHandle(char *udfName, UdfcFuncHandle *pHandle) {
|
||||||
int32_t code = 0, line = 0;
|
int32_t code = 0, line = 0;
|
||||||
uv_mutex_lock(&gUdfcProxy.udfStubsMutex);
|
uv_mutex_lock(&gUdfcProxy.udfStubsMutex);
|
||||||
SUdfcFuncStub key = {0};
|
SUdfcFuncStub key = {0};
|
||||||
strncpy(key.udfName, udfName, TSDB_FUNC_NAME_LEN);
|
tstrncpy(key.udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||||
int32_t stubIndex = taosArraySearchIdx(gUdfcProxy.udfStubs, &key, compareUdfcFuncSub, TD_EQ);
|
int32_t stubIndex = taosArraySearchIdx(gUdfcProxy.udfStubs, &key, compareUdfcFuncSub, TD_EQ);
|
||||||
if (stubIndex != -1) {
|
if (stubIndex != -1) {
|
||||||
SUdfcFuncStub *foundStub = taosArrayGet(gUdfcProxy.udfStubs, stubIndex);
|
SUdfcFuncStub *foundStub = taosArrayGet(gUdfcProxy.udfStubs, stubIndex);
|
||||||
|
@ -1106,7 +1106,7 @@ int32_t acquireUdfFuncHandle(char *udfName, UdfcFuncHandle *pHandle) {
|
||||||
code = doSetupUdf(udfName, pHandle);
|
code = doSetupUdf(udfName, pHandle);
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
SUdfcFuncStub stub = {0};
|
SUdfcFuncStub stub = {0};
|
||||||
strncpy(stub.udfName, udfName, TSDB_FUNC_NAME_LEN);
|
tstrncpy(stub.udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||||
stub.handle = *pHandle;
|
stub.handle = *pHandle;
|
||||||
++stub.refCount;
|
++stub.refCount;
|
||||||
stub.createTime = taosGetTimestampUs();
|
stub.createTime = taosGetTimestampUs();
|
||||||
|
@ -1130,7 +1130,7 @@ _exit:
|
||||||
void releaseUdfFuncHandle(char *udfName, UdfcFuncHandle handle) {
|
void releaseUdfFuncHandle(char *udfName, UdfcFuncHandle handle) {
|
||||||
uv_mutex_lock(&gUdfcProxy.udfStubsMutex);
|
uv_mutex_lock(&gUdfcProxy.udfStubsMutex);
|
||||||
SUdfcFuncStub key = {0};
|
SUdfcFuncStub key = {0};
|
||||||
strncpy(key.udfName, udfName, TSDB_FUNC_NAME_LEN);
|
tstrncpy(key.udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||||
SUdfcFuncStub *foundStub = taosArraySearch(gUdfcProxy.udfStubs, &key, compareUdfcFuncSub, TD_EQ);
|
SUdfcFuncStub *foundStub = taosArraySearch(gUdfcProxy.udfStubs, &key, compareUdfcFuncSub, TD_EQ);
|
||||||
SUdfcFuncStub *expiredStub = taosArraySearch(gUdfcProxy.expiredUdfStubs, &key, compareUdfcFuncSub, TD_EQ);
|
SUdfcFuncStub *expiredStub = taosArraySearch(gUdfcProxy.expiredUdfStubs, &key, compareUdfcFuncSub, TD_EQ);
|
||||||
if (!foundStub && !expiredStub) {
|
if (!foundStub && !expiredStub) {
|
||||||
|
@ -2021,7 +2021,7 @@ int32_t doSetupUdf(char udfName[], UdfcFuncHandle *funcHandle) {
|
||||||
task->type = UDF_TASK_SETUP;
|
task->type = UDF_TASK_SETUP;
|
||||||
|
|
||||||
SUdfSetupRequest *req = &task->_setup.req;
|
SUdfSetupRequest *req = &task->_setup.req;
|
||||||
strncpy(req->udfName, udfName, TSDB_FUNC_NAME_LEN);
|
tstrncpy(req->udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||||
|
|
||||||
code = udfcRunUdfUvTask(task, UV_TASK_CONNECT);
|
code = udfcRunUdfUvTask(task, UV_TASK_CONNECT);
|
||||||
TAOS_CHECK_GOTO(code, &lino, _exit);
|
TAOS_CHECK_GOTO(code, &lino, _exit);
|
||||||
|
@ -2034,7 +2034,7 @@ int32_t doSetupUdf(char udfName[], UdfcFuncHandle *funcHandle) {
|
||||||
task->session->outputType = rsp->outputType;
|
task->session->outputType = rsp->outputType;
|
||||||
task->session->bytes = rsp->bytes;
|
task->session->bytes = rsp->bytes;
|
||||||
task->session->bufSize = rsp->bufSize;
|
task->session->bufSize = rsp->bufSize;
|
||||||
strncpy(task->session->udfName, udfName, TSDB_FUNC_NAME_LEN);
|
tstrncpy(task->session->udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||||
fnInfo("successfully setup udf func handle. udfName: %s, handle: %p", udfName, task->session);
|
fnInfo("successfully setup udf func handle. udfName: %s, handle: %p", udfName, task->session);
|
||||||
*funcHandle = task->session;
|
*funcHandle = task->session;
|
||||||
taosMemoryFree(task);
|
taosMemoryFree(task);
|
||||||
|
|
|
@ -617,7 +617,7 @@ int32_t udfdNewUdf(SUdf **pUdf, const char *udfName) {
|
||||||
}
|
}
|
||||||
udfNew->refCount = 1;
|
udfNew->refCount = 1;
|
||||||
udfNew->lastFetchTime = taosGetTimestampMs();
|
udfNew->lastFetchTime = taosGetTimestampMs();
|
||||||
strncpy(udfNew->name, udfName, TSDB_FUNC_NAME_LEN);
|
tstrncpy(udfNew->name, udfName, TSDB_FUNC_NAME_LEN);
|
||||||
|
|
||||||
udfNew->state = UDF_STATE_INIT;
|
udfNew->state = UDF_STATE_INIT;
|
||||||
if (uv_mutex_init(&udfNew->lock) != 0) return TSDB_CODE_UDF_UV_EXEC_FAILURE;
|
if (uv_mutex_init(&udfNew->lock) != 0) return TSDB_CODE_UDF_UV_EXEC_FAILURE;
|
||||||
|
@ -997,7 +997,7 @@ int32_t udfdSaveFuncBodyToFile(SFuncInfo *pFuncInfo, SUdf *udf) {
|
||||||
udfdGetFuncBodyPath(udf, path);
|
udfdGetFuncBodyPath(udf, path);
|
||||||
bool fileExist = !(taosStatFile(path, NULL, NULL, NULL) < 0);
|
bool fileExist = !(taosStatFile(path, NULL, NULL, NULL) < 0);
|
||||||
if (fileExist) {
|
if (fileExist) {
|
||||||
strncpy(udf->path, path, PATH_MAX);
|
tstrncpy(udf->path, path, PATH_MAX);
|
||||||
fnInfo("udfd func body file. reuse existing file %s", path);
|
fnInfo("udfd func body file. reuse existing file %s", path);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1017,7 +1017,7 @@ int32_t udfdSaveFuncBodyToFile(SFuncInfo *pFuncInfo, SUdf *udf) {
|
||||||
return TSDB_CODE_FILE_CORRUPTED;
|
return TSDB_CODE_FILE_CORRUPTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(udf->path, path, PATH_MAX);
|
tstrncpy(udf->path, path, PATH_MAX);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1612,7 +1612,7 @@ int32_t udfdInitResidentFuncs() {
|
||||||
char *token;
|
char *token;
|
||||||
while ((token = strtok_r(pSave, ",", &pSave)) != NULL) {
|
while ((token = strtok_r(pSave, ",", &pSave)) != NULL) {
|
||||||
char func[TSDB_FUNC_NAME_LEN + 1] = {0};
|
char func[TSDB_FUNC_NAME_LEN + 1] = {0};
|
||||||
strncpy(func, token, TSDB_FUNC_NAME_LEN);
|
tstrncpy(func, token, TSDB_FUNC_NAME_LEN);
|
||||||
fnInfo("udfd add resident function %s", func);
|
fnInfo("udfd add resident function %s", func);
|
||||||
if(taosArrayPush(global.residentFuncs, func) == NULL)
|
if(taosArrayPush(global.residentFuncs, func) == NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -207,7 +207,7 @@ int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
SDbCfgReq dbCfgReq = {0};
|
SDbCfgReq dbCfgReq = {0};
|
||||||
strncpy(dbCfgReq.db, input, sizeof(dbCfgReq.db) - 1);
|
tstrncpy(dbCfgReq.db, input, TSDB_DB_FNAME_LEN);
|
||||||
|
|
||||||
int32_t bufLen = tSerializeSDbCfgReq(NULL, 0, &dbCfgReq);
|
int32_t bufLen = tSerializeSDbCfgReq(NULL, 0, &dbCfgReq);
|
||||||
void *pBuf = (*mallcFp)(bufLen);
|
void *pBuf = (*mallcFp)(bufLen);
|
||||||
|
@ -231,7 +231,7 @@ int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
SUserIndexReq indexReq = {0};
|
SUserIndexReq indexReq = {0};
|
||||||
strncpy(indexReq.indexFName, input, sizeof(indexReq.indexFName) - 1);
|
tstrncpy(indexReq.indexFName, input, TSDB_INDEX_FNAME_LEN);
|
||||||
|
|
||||||
int32_t bufLen = tSerializeSUserIndexReq(NULL, 0, &indexReq);
|
int32_t bufLen = tSerializeSUserIndexReq(NULL, 0, &indexReq);
|
||||||
void *pBuf = (*mallcFp)(bufLen);
|
void *pBuf = (*mallcFp)(bufLen);
|
||||||
|
@ -293,7 +293,7 @@ int32_t queryBuildGetUserAuthMsg(void *input, char **msg, int32_t msgSize, int32
|
||||||
}
|
}
|
||||||
|
|
||||||
SGetUserAuthReq req = {0};
|
SGetUserAuthReq req = {0};
|
||||||
strncpy(req.user, input, sizeof(req.user) - 1);
|
tstrncpy(req.user, input, TSDB_USER_LEN);
|
||||||
|
|
||||||
int32_t bufLen = tSerializeSGetUserAuthReq(NULL, 0, &req);
|
int32_t bufLen = tSerializeSGetUserAuthReq(NULL, 0, &req);
|
||||||
void *pBuf = (*mallcFp)(bufLen);
|
void *pBuf = (*mallcFp)(bufLen);
|
||||||
|
@ -316,7 +316,7 @@ int32_t queryBuildGetTbIndexMsg(void *input, char **msg, int32_t msgSize, int32_
|
||||||
}
|
}
|
||||||
|
|
||||||
STableIndexReq indexReq = {0};
|
STableIndexReq indexReq = {0};
|
||||||
strncpy(indexReq.tbFName, input, sizeof(indexReq.tbFName) - 1);
|
tstrncpy(indexReq.tbFName, input, TSDB_TABLE_FNAME_LEN);
|
||||||
|
|
||||||
int32_t bufLen = tSerializeSTableIndexReq(NULL, 0, &indexReq);
|
int32_t bufLen = tSerializeSTableIndexReq(NULL, 0, &indexReq);
|
||||||
void *pBuf = (*mallcFp)(bufLen);
|
void *pBuf = (*mallcFp)(bufLen);
|
||||||
|
@ -342,8 +342,8 @@ int32_t queryBuildGetTbCfgMsg(void *input, char **msg, int32_t msgSize, int32_t
|
||||||
SBuildTableInput *pInput = input;
|
SBuildTableInput *pInput = input;
|
||||||
STableCfgReq cfgReq = {0};
|
STableCfgReq cfgReq = {0};
|
||||||
cfgReq.header.vgId = pInput->vgId;
|
cfgReq.header.vgId = pInput->vgId;
|
||||||
strncpy(cfgReq.dbFName, pInput->dbFName, sizeof(cfgReq.dbFName) - 1);
|
tstrncpy(cfgReq.dbFName, pInput->dbFName, TSDB_DB_FNAME_LEN);
|
||||||
strncpy(cfgReq.tbName, pInput->tbName, sizeof(cfgReq.tbName) - 1);
|
tstrncpy(cfgReq.tbName, pInput->tbName, TSDB_TABLE_NAME_LEN);
|
||||||
|
|
||||||
int32_t bufLen = tSerializeSTableCfgReq(NULL, 0, &cfgReq);
|
int32_t bufLen = tSerializeSTableCfgReq(NULL, 0, &cfgReq);
|
||||||
void *pBuf = (*mallcFp)(bufLen);
|
void *pBuf = (*mallcFp)(bufLen);
|
||||||
|
@ -367,7 +367,7 @@ int32_t queryBuildGetViewMetaMsg(void *input, char **msg, int32_t msgSize, int32
|
||||||
}
|
}
|
||||||
|
|
||||||
SViewMetaReq req = {0};
|
SViewMetaReq req = {0};
|
||||||
strncpy(req.fullname, input, sizeof(req.fullname) - 1);
|
tstrncpy(req.fullname, input, TSDB_VIEW_FNAME_LEN);
|
||||||
|
|
||||||
int32_t bufLen = tSerializeSViewMetaReq(NULL, 0, &req);
|
int32_t bufLen = tSerializeSViewMetaReq(NULL, 0, &req);
|
||||||
void *pBuf = (*mallcFp)(bufLen);
|
void *pBuf = (*mallcFp)(bufLen);
|
||||||
|
@ -392,7 +392,7 @@ int32_t queryBuildGetTableTSMAMsg(void *input, char **msg, int32_t msgSize, int3
|
||||||
}
|
}
|
||||||
|
|
||||||
STableTSMAInfoReq req = {0};
|
STableTSMAInfoReq req = {0};
|
||||||
strncpy(req.name, input, sizeof(req.name) - 1);
|
tstrncpy(req.name, input, TSDB_TABLE_FNAME_LEN);
|
||||||
|
|
||||||
int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req);
|
int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req);
|
||||||
void * pBuf = (*mallcFp)(bufLen);
|
void * pBuf = (*mallcFp)(bufLen);
|
||||||
|
@ -417,7 +417,7 @@ int32_t queryBuildGetTSMAMsg(void *input, char **msg, int32_t msgSize, int32_t *
|
||||||
|
|
||||||
STableTSMAInfoReq req = {0};
|
STableTSMAInfoReq req = {0};
|
||||||
req.fetchingWithTsmaName = true;
|
req.fetchingWithTsmaName = true;
|
||||||
strncpy(req.name, input, sizeof(req.name) - 1);
|
tstrncpy(req.name, input, TSDB_TABLE_FNAME_LEN);
|
||||||
|
|
||||||
int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req);
|
int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req);
|
||||||
void * pBuf = (*mallcFp)(bufLen);
|
void * pBuf = (*mallcFp)(bufLen);
|
||||||
|
|
Loading…
Reference in New Issue