提交 5fabd7d3 编写于 作者: wafwerar's avatar wafwerar

os: add file auto del func

上级 6c853fc5
...@@ -54,6 +54,8 @@ typedef struct TdFile { ...@@ -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) { ...@@ -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) { ...@@ -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) { ...@@ -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) { ...@@ -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 ...@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册