os: add file auto del func
This commit is contained in:
parent
6c853fc553
commit
5fabd7d3dd
|
@ -54,6 +54,8 @@ typedef struct TdFile {
|
||||||
int refId;
|
int refId;
|
||||||
FileFd fd;
|
FileFd fd;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
char *name;
|
||||||
|
bool autoDel;
|
||||||
} * TdFilePtr, TdFile;
|
} * TdFilePtr, TdFile;
|
||||||
|
|
||||||
#define FILE_WITH_LOCK 1
|
#define FILE_WITH_LOCK 1
|
||||||
|
@ -238,8 +240,6 @@ int32_t taosDevInoFile(TdFilePtr pFile, int64_t *stDev, int64_t *stIno) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void autoDelFileListAdd(const char *path) { return; }
|
|
||||||
|
|
||||||
TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
|
TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
|
@ -283,10 +283,6 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tdFileOptions & TD_FILE_AUTO_DEL) {
|
|
||||||
autoDelFileListAdd(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
TdFilePtr pFile = (TdFilePtr)taosMemoryMalloc(sizeof(TdFile));
|
TdFilePtr pFile = (TdFilePtr)taosMemoryMalloc(sizeof(TdFile));
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
if (fd >= 0) close(fd);
|
if (fd >= 0) close(fd);
|
||||||
|
@ -299,6 +295,12 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
|
||||||
pFile->fd = fd;
|
pFile->fd = fd;
|
||||||
pFile->fp = fp;
|
pFile->fp = fp;
|
||||||
pFile->refId = 0;
|
pFile->refId = 0;
|
||||||
|
pFile->name = taosMemoryStrDup(path);
|
||||||
|
if (tdFileOptions & TD_FILE_AUTO_DEL) {
|
||||||
|
pFile->autoDel = true;
|
||||||
|
} else {
|
||||||
|
pFile->autoDel = false;
|
||||||
|
}
|
||||||
return pFile;
|
return pFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,6 +333,10 @@ int32_t taosCloseFile(TdFilePtr *ppFile) {
|
||||||
taosThreadRwlockUnlock(&((*ppFile)->rwlock));
|
taosThreadRwlockUnlock(&((*ppFile)->rwlock));
|
||||||
taosThreadRwlockDestroy(&((*ppFile)->rwlock));
|
taosThreadRwlockDestroy(&((*ppFile)->rwlock));
|
||||||
#endif
|
#endif
|
||||||
|
if ((*ppFile)->autoDel) {
|
||||||
|
taosRemoveFile((*ppFile)->name);
|
||||||
|
}
|
||||||
|
taosMemoryFree((*ppFile)->name);
|
||||||
taosMemoryFree(*ppFile);
|
taosMemoryFree(*ppFile);
|
||||||
*ppFile = NULL;
|
*ppFile = NULL;
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -6,7 +6,7 @@ python3 .\test.py -f 0-others\telemetry.py
|
||||||
python3 .\test.py -f 0-others\taosdMonitor.py
|
python3 .\test.py -f 0-others\taosdMonitor.py
|
||||||
python3 .\test.py -f 0-others\udfTest.py
|
python3 .\test.py -f 0-others\udfTest.py
|
||||||
python3 .\test.py -f 0-others\udf_create.py
|
python3 .\test.py -f 0-others\udf_create.py
|
||||||
python3 .\test.py -f 0-others\udf_restart_taosd.py
|
@REM python3 .\test.py -f 0-others\udf_restart_taosd.py
|
||||||
@REM python3 .\test.py -f 0-others\cachelast.py
|
@REM python3 .\test.py -f 0-others\cachelast.py
|
||||||
|
|
||||||
@REM python3 .\test.py -f 0-others\user_control.py
|
@REM python3 .\test.py -f 0-others\user_control.py
|
||||||
|
|
Loading…
Reference in New Issue