Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7c54b699
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7c54b699
编写于
4月 22, 2022
作者:
S
slzhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sigkill to kill taosd causes udfd to exit
上级
ad398bb6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
56 addition
and
18 deletion
+56
-18
source/dnode/mgmt/implement/src/dmHandle.c
source/dnode/mgmt/implement/src/dmHandle.c
+7
-5
source/dnode/mgmt/interface/inc/dmDef.h
source/dnode/mgmt/interface/inc/dmDef.h
+1
-0
source/libs/function/src/udfd.c
source/libs/function/src/udfd.c
+48
-13
未找到文件。
source/dnode/mgmt/implement/src/dmHandle.c
浏览文件 @
7c54b699
...
...
@@ -226,6 +226,7 @@ void dmUdfdExit(uv_process_t *process, int64_t exitStatus, int termSignal) {
if
(
atomic_load_8
(
&
pData
->
stopping
)
!=
0
)
{
dDebug
(
"udfd process exit due to stopping"
);
}
else
{
uv_close
((
uv_handle_t
*
)
&
pData
->
ctrlPipe
,
NULL
);
dmSpawnUdfd
(
pDnode
);
}
}
...
...
@@ -243,20 +244,21 @@ static int32_t dmSpawnUdfd(SDnode *pDnode) {
options
.
file
=
path
;
options
.
exit_cb
=
dmUdfdExit
;
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
uv_pipe_init
(
&
pData
->
loop
,
&
pData
->
ctrlPipe
,
1
);
options
.
stdio_count
=
3
;
uv_stdio_container_t
child_stdio
[
3
];
child_stdio
[
0
].
flags
=
UV_
IGNOR
E
;
child_stdio
[
1
].
flags
=
UV_INHERIT_FD
;
child_stdio
[
1
].
data
.
fd
=
1
;
child_stdio
[
0
].
flags
=
UV_
CREATE_PIPE
|
UV_READABLE_PIP
E
;
child_stdio
[
0
].
data
.
stream
=
(
uv_stream_t
*
)
&
pData
->
ctrlPipe
;
child_stdio
[
1
].
flags
=
UV_IGNORE
;
child_stdio
[
2
].
flags
=
UV_INHERIT_FD
;
child_stdio
[
2
].
data
.
fd
=
2
;
options
.
stdio_count
=
3
;
options
.
stdio
=
child_stdio
;
char
dnodeIdEnvItem
[
32
]
=
{
0
};
char
thrdPoolSizeEnvItem
[
32
]
=
{
0
};
snprintf
(
dnodeIdEnvItem
,
32
,
"%s=%d"
,
"DNODE_ID"
,
pDnode
->
data
.
dnodeId
);
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
float
numCpuCores
=
4
;
taosGetCpuCores
(
&
numCpuCores
);
snprintf
(
thrdPoolSizeEnvItem
,
32
,
"%s=%d"
,
"UV_THREADPOOL_SIZE"
,
(
int
)
numCpuCores
*
2
);
...
...
source/dnode/mgmt/interface/inc/dmDef.h
浏览文件 @
7c54b699
...
...
@@ -152,6 +152,7 @@ typedef struct SUdfdData {
uv_process_t
process
;
int
spawnErr
;
int8_t
stopping
;
uv_pipe_t
ctrlPipe
;
}
SUdfdData
;
typedef
struct
SDnode
{
...
...
source/libs/function/src/udfd.c
浏览文件 @
7c54b699
...
...
@@ -27,7 +27,10 @@
typedef
struct
SUdfdContext
{
uv_loop_t
*
loop
;
uv_pipe_t
ctrlPipe
;
uv_signal_t
intrSignal
;
char
listenPipeName
[
UDF_LISTEN_PIPE_NAME_LEN
];
uv_pipe_t
listeningPipe
;
void
*
clientRpc
;
uv_mutex_t
udfsMutex
;
...
...
@@ -380,10 +383,12 @@ void udfdOnNewConnection(uv_stream_t *server, int status) {
}
}
void
removeListeningPipe
(
int
sig
)
{
void
udfdIntrSignalHandler
(
uv_signal_t
*
handle
,
int
signum
)
{
fnInfo
(
"udfd signal received: %d
\n
"
,
signum
);
uv_fs_t
req
;
uv_fs_unlink
(
global
.
loop
,
&
req
,
"udf.sock"
,
NULL
);
exit
(
0
);
uv_fs_unlink
(
global
.
loop
,
&
req
,
global
.
listenPipeName
,
NULL
);
uv_signal_stop
(
handle
);
uv_stop
(
global
.
loop
);
}
void
udfdProcessRpcRsp
(
void
*
parent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
return
;
}
...
...
@@ -492,37 +497,67 @@ static int32_t udfdInitLog() {
return
taosCreateLog
(
logName
,
1
,
configDir
,
NULL
,
NULL
,
NULL
,
0
);
}
void
udfdCtrlAllocBufCb
(
uv_handle_t
*
handle
,
size_t
suggested_size
,
uv_buf_t
*
buf
)
{
buf
->
base
=
taosMemoryMalloc
(
suggested_size
);
buf
->
len
=
suggested_size
;
}
void
udfdCtrlReadCb
(
uv_stream_t
*
q
,
ssize_t
nread
,
const
uv_buf_t
*
buf
)
{
if
(
nread
<
0
)
{
fnError
(
"udfd ctrl pipe read error. %s"
,
uv_err_name
(
nread
));
uv_close
((
uv_handle_t
*
)
q
,
NULL
);
uv_stop
(
global
.
loop
);
return
;
}
fnError
(
"udfd ctrl pipe read %zu bytes"
,
nread
);
taosMemoryFree
(
buf
->
base
);
}
static
int32_t
removeListeningPipe
()
{
uv_fs_t
req
;
int
err
=
uv_fs_unlink
(
global
.
loop
,
&
req
,
global
.
listenPipeName
,
NULL
);
uv_fs_req_cleanup
(
&
req
);
return
err
;
}
static
int32_t
udfdUvInit
()
{
uv_loop_t
*
loop
=
taosMemoryMalloc
(
sizeof
(
uv_loop_t
));
if
(
loop
)
{
uv_loop_init
(
loop
);
}
global
.
loop
=
loop
;
uv_pipe_init
(
global
.
loop
,
&
global
.
ctrlPipe
,
1
);
uv_pipe_open
(
&
global
.
ctrlPipe
,
0
);
uv_read_start
((
uv_stream_t
*
)
&
global
.
ctrlPipe
,
udfdCtrlAllocBufCb
,
udfdCtrlReadCb
);
char
dnodeId
[
8
]
=
{
0
};
size_t
dnodeIdSize
;
uv_os_getenv
(
"DNODE_ID"
,
dnodeId
,
&
dnodeIdSize
);
int32_t
err
=
uv_os_getenv
(
"DNODE_ID"
,
dnodeId
,
&
dnodeIdSize
);
if
(
err
!=
0
)
{
dnodeId
[
0
]
=
'1'
;
}
char
listenPipeName
[
32
]
=
{
0
};
snprintf
(
listenPipeName
,
sizeof
(
listenPipeName
),
"%s%s"
,
UDF_LISTEN_PIPE_NAME_PREFIX
,
dnodeId
);
strcpy
(
global
.
listenPipeName
,
listenPipeName
);
uv_fs_t
req
;
uv_fs_unlink
(
global
.
loop
,
&
req
,
global
.
listenPipeName
,
NULL
);
removeListeningPipe
();
uv_pipe_t
server
;
uv_pipe_init
(
global
.
loop
,
&
server
,
0
);
uv_pipe_init
(
global
.
loop
,
&
global
.
listeningPipe
,
0
);
signal
(
SIGINT
,
removeListeningPipe
);
uv_signal_init
(
global
.
loop
,
&
global
.
intrSignal
);
uv_signal_start
(
&
global
.
intrSignal
,
udfdIntrSignalHandler
,
SIGINT
);
int
r
;
fnInfo
(
"bind to pipe %s"
,
global
.
listenPipeName
);
if
((
r
=
uv_pipe_bind
(
&
server
,
listenPipeName
)))
{
if
((
r
=
uv_pipe_bind
(
&
global
.
listeningPipe
,
listenPipeName
)))
{
fnError
(
"Bind error %s"
,
uv_err_name
(
r
));
removeListeningPipe
(
0
);
removeListeningPipe
();
return
-
1
;
}
if
((
r
=
uv_listen
((
uv_stream_t
*
)
&
server
,
128
,
udfdOnNewConnection
)))
{
if
((
r
=
uv_listen
((
uv_stream_t
*
)
&
global
.
listeningPipe
,
128
,
udfdOnNewConnection
)))
{
fnError
(
"Listen error %s"
,
uv_err_name
(
r
));
removeListeningPipe
(
0
);
removeListeningPipe
();
return
-
2
;
}
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录