Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
650ea06b
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
650ea06b
编写于
1月 03, 2023
作者:
S
Shengliang Guan
提交者:
GitHub
1月 03, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19321 from taosdata/feature/3_liaohj
fix(utility): fix the bug in creating auto delete files.
上级
49cc5012
b8aa4fae
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
53 deletion
+20
-53
source/libs/function/src/udfd.c
source/libs/function/src/udfd.c
+3
-2
source/os/src/osFile.c
source/os/src/osFile.c
+17
-51
未找到文件。
source/libs/function/src/udfd.c
浏览文件 @
650ea06b
...
...
@@ -460,13 +460,14 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
#else
snprintf
(
path
,
sizeof
(
path
),
"%s/lib%s.so"
,
tsTempDir
,
pFuncInfo
->
name
);
#endif
TdFilePtr
file
=
taosOpenFile
(
path
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_READ
|
TD_FILE_TRUNC
|
TD_FILE_AUTO_DEL
);
TdFilePtr
file
=
taosOpenFile
(
path
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_READ
|
TD_FILE_TRUNC
);
if
(
file
==
NULL
)
{
fnError
(
"udfd write udf shared library: %s failed, error: %d %s"
,
path
,
errno
,
strerror
(
errno
));
msgInfo
->
code
=
TSDB_CODE_FILE_CORRUPTED
;
goto
_return
;
}
int64_t
count
=
taosWriteFile
(
file
,
pFuncInfo
->
pCode
,
pFuncInfo
->
codeSize
);
if
(
count
!=
pFuncInfo
->
codeSize
)
{
fnError
(
"udfd write udf shared library failed"
);
...
...
source/os/src/osFile.c
浏览文件 @
650ea06b
...
...
@@ -39,14 +39,6 @@
#define _SEND_FILE_STEP_ 1000
#endif
#if defined(WINDOWS)
typedef
int32_t
FileFd
;
typedef
int32_t
SocketFd
;
#else
typedef
int32_t
FileFd
;
typedef
int32_t
SocketFd
;
#endif
typedef
int32_t
FileFd
;
typedef
struct
TdFile
{
...
...
@@ -54,19 +46,10 @@ typedef struct TdFile {
int
refId
;
FileFd
fd
;
FILE
*
fp
;
}
*
TdFilePtr
,
TdFile
;
}
TdFile
;
#define FILE_WITH_LOCK 1
typedef
struct
AutoDelFile
*
AutoDelFilePtr
;
typedef
struct
AutoDelFile
{
char
*
name
;
AutoDelFilePtr
lastAutoDelFilePtr
;
}
AutoDelFile
;
static
TdThreadMutex
autoDelFileLock
;
static
AutoDelFilePtr
nowAutoDelFilePtr
=
NULL
;
static
TdThreadOnce
autoDelFileInit
=
PTHREAD_ONCE_INIT
;
void
taosGetTmpfilePath
(
const
char
*
inputTmpDir
,
const
char
*
fileNamePrefix
,
char
*
dstPath
)
{
#ifdef WINDOWS
const
char
*
tdengineTmpFileNamePrefix
=
"tdengine-"
;
...
...
@@ -268,34 +251,6 @@ int32_t taosDevInoFile(TdFilePtr pFile, int64_t *stDev, int64_t *stIno) {
return
0
;
}
void
autoDelFileList
()
{
taosThreadMutexLock
(
&
autoDelFileLock
);
while
(
nowAutoDelFilePtr
!=
NULL
)
{
taosRemoveFile
(
nowAutoDelFilePtr
->
name
);
AutoDelFilePtr
tmp
=
nowAutoDelFilePtr
->
lastAutoDelFilePtr
;
taosMemoryFree
(
nowAutoDelFilePtr
->
name
);
taosMemoryFree
(
nowAutoDelFilePtr
);
nowAutoDelFilePtr
=
tmp
;
}
taosThreadMutexUnlock
(
&
autoDelFileLock
);
taosThreadMutexDestroy
(
&
autoDelFileLock
);
}
void
autoDelFileListInit
()
{
taosThreadMutexInit
(
&
autoDelFileLock
,
NULL
);
atexit
(
autoDelFileList
);
}
void
autoDelFileListAdd
(
const
char
*
path
)
{
taosThreadOnce
(
&
autoDelFileInit
,
autoDelFileListInit
);
taosThreadMutexLock
(
&
autoDelFileLock
);
AutoDelFilePtr
tmp
=
taosMemoryMalloc
(
sizeof
(
AutoDelFile
));
tmp
->
lastAutoDelFilePtr
=
nowAutoDelFilePtr
;
tmp
->
name
=
taosMemoryStrDup
(
path
);
nowAutoDelFilePtr
=
tmp
;
taosThreadMutexUnlock
(
&
autoDelFileLock
);
}
TdFilePtr
taosOpenFile
(
const
char
*
path
,
int32_t
tdFileOptions
)
{
int
fd
=
-
1
;
FILE
*
fp
=
NULL
;
...
...
@@ -313,7 +268,6 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
assert
(
!
(
tdFileOptions
&
TD_FILE_EXCL
));
fp
=
fopen
(
path
,
mode
);
if
(
fp
==
NULL
)
{
// terrno = TAOS_SYSTEM_ERROR(errno);
return
NULL
;
}
}
else
{
...
...
@@ -331,32 +285,44 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
access
|=
(
tdFileOptions
&
TD_FILE_TEXT
)
?
O_TEXT
:
0
;
access
|=
(
tdFileOptions
&
TD_FILE_EXCL
)
?
O_EXCL
:
0
;
#ifdef WINDOWS
fd
=
_open
(
path
,
access
,
_S_IREAD
|
_S_IWRITE
);
int32_t
pmode
=
_S_IREAD
|
_S_IWRITE
;
if
(
tdFileOptions
&
TD_FILE_AUTO_DEL
)
{
pmode
|=
_O_TEMPORARY
;
}
fd
=
_open
(
path
,
access
,
pmode
);
#else
fd
=
open
(
path
,
access
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
#endif
if
(
fd
==
-
1
)
{
// terrno = TAOS_SYSTEM_ERROR(errno);
return
NULL
;
}
}
TdFilePtr
pFile
=
(
TdFilePtr
)
taosMemoryMalloc
(
sizeof
(
TdFile
));
if
(
pFile
==
NULL
)
{
// terrno = TSDB_CODE_OUT_OF_MEMORY;
if
(
fd
>=
0
)
close
(
fd
);
if
(
fp
!=
NULL
)
fclose
(
fp
);
return
NULL
;
}
#if FILE_WITH_LOCK
taosThreadRwlockInit
(
&
(
pFile
->
rwlock
),
NULL
);
#endif
pFile
->
fd
=
fd
;
pFile
->
fp
=
fp
;
pFile
->
refId
=
0
;
if
(
tdFileOptions
&
TD_FILE_AUTO_DEL
)
{
autoDelFileListAdd
(
path
);
#ifdef WINDOWS
// do nothing, since the property of pmode is set with _O_TEMPORARY; the OS will recycle
// the file handle, as well as the space on disk.
#else
// Remove it instantly, so when the program exits normally/abnormally, the file
// will be automatically remove by OS.
unlink
(
path
);
#endif
}
return
pFile
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录