Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
928af5f0
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
未验证
提交
928af5f0
编写于
5月 14, 2022
作者:
S
shenglian-zhou
提交者:
GitHub
5月 14, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12472 from taosdata/feature/udf
fix: taosd core by thread switching to new thread and free uvtask
上级
64395dbd
2a42fc66
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
21 addition
and
13 deletion
+21
-13
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+21
-13
未找到文件。
source/libs/function/src/tudf.c
浏览文件 @
928af5f0
...
...
@@ -964,7 +964,7 @@ void udfcUvHandleError(SClientUvConn *conn) {
uv_close
((
uv_handle_t
*
)
conn
->
pipe
,
onUdfcPipeClose
);
}
void
onUdfcRead
(
uv_stream_t
*
client
,
ssize_t
nread
,
const
uv_buf_t
*
buf
)
{
void
onUdfc
Pipe
Read
(
uv_stream_t
*
client
,
ssize_t
nread
,
const
uv_buf_t
*
buf
)
{
fnTrace
(
"udfc client %p, client read from pipe. nread: %zd"
,
client
,
nread
);
if
(
nread
==
0
)
return
;
...
...
@@ -987,30 +987,32 @@ void onUdfcRead(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf) {
}
void
onUdf
Clien
tWrite
(
uv_write_t
*
write
,
int
status
)
{
void
onUdf
cPipe
tWrite
(
uv_write_t
*
write
,
int
status
)
{
SClientUvTaskNode
*
uvTask
=
write
->
data
;
uv_pipe_t
*
pipe
=
uvTask
->
pipe
;
fnTrace
(
"udfc client %p write length:%zu"
,
pipe
,
uvTask
->
reqBuf
.
len
);
SClientUvConn
*
conn
=
pipe
->
data
;
if
(
status
==
0
)
{
SClientUvConn
*
conn
=
pipe
->
data
;
QUEUE_INSERT_TAIL
(
&
conn
->
taskQueue
,
&
uvTask
->
connTaskQueue
);
}
else
{
fnError
(
"udfc client %p write error."
,
pipe
);
udfcUvHandleError
(
conn
);
}
fnTrace
(
"udfc client %p write length:%zu"
,
pipe
,
uvTask
->
reqBuf
.
len
);
taosMemoryFree
(
write
);
taosMemoryFree
(
uvTask
->
reqBuf
.
base
);
}
void
onUdf
Client
Connect
(
uv_connect_t
*
connect
,
int
status
)
{
void
onUdf
cPipe
Connect
(
uv_connect_t
*
connect
,
int
status
)
{
SClientUvTaskNode
*
uvTask
=
connect
->
data
;
uvTask
->
errCode
=
status
;
if
(
status
!=
0
)
{
//TODO: LOG error
fnError
(
"client connect error, task seq: %"
PRId64
", code: %s"
,
uvTask
->
seqNum
,
uv_strerror
(
status
));
}
uv_read_start
((
uv_stream_t
*
)
uvTask
->
pipe
,
udfcAllocateBuffer
,
onUdfcRead
);
uvTask
->
errCode
=
status
;
uv_read_start
((
uv_stream_t
*
)
uvTask
->
pipe
,
udfcAllocateBuffer
,
onUdfcPipeRead
);
taosMemoryFree
(
connect
);
uv_sem_post
(
&
uvTask
->
taskSem
);
QUEUE_REMOVE
(
&
uvTask
->
procTaskQueue
);
uv_sem_post
(
&
uvTask
->
taskSem
);
}
int32_t
udfcCreateUvTask
(
SClientUdfTask
*
task
,
int8_t
uvTaskType
,
SClientUvTaskNode
**
pUvTask
)
{
...
...
@@ -1088,14 +1090,17 @@ int32_t udfcStartUvTask(SClientUvTaskNode *uvTask) {
uv_connect_t
*
connReq
=
taosMemoryMalloc
(
sizeof
(
uv_connect_t
));
connReq
->
data
=
uvTask
;
uv_pipe_connect
(
connReq
,
pipe
,
uvTask
->
udfc
->
udfdPipeName
,
onUdf
Client
Connect
);
uv_pipe_connect
(
connReq
,
pipe
,
uvTask
->
udfc
->
udfdPipeName
,
onUdf
cPipe
Connect
);
break
;
}
case
UV_TASK_REQ_RSP
:
{
uv_pipe_t
*
pipe
=
uvTask
->
pipe
;
uv_write_t
*
write
=
taosMemoryMalloc
(
sizeof
(
uv_write_t
));
write
->
data
=
uvTask
;
uv_write
(
write
,
(
uv_stream_t
*
)
pipe
,
&
uvTask
->
reqBuf
,
1
,
onUdfClientWrite
);
int
err
=
uv_write
(
write
,
(
uv_stream_t
*
)
pipe
,
&
uvTask
->
reqBuf
,
1
,
onUdfcPipetWrite
);
if
(
err
!=
0
)
{
fnError
(
"udfc event loop start req/rsp task uv_write failed. code: %s"
,
uv_strerror
(
err
));
}
break
;
}
case
UV_TASK_DISCONNECT
:
{
...
...
@@ -1105,6 +1110,7 @@ int32_t udfcStartUvTask(SClientUvTaskNode *uvTask) {
break
;
}
default:
{
fnError
(
"udfc event loop unknown task type."
)
break
;
}
}
...
...
@@ -1124,8 +1130,10 @@ void udfClientAsyncCb(uv_async_t *async) {
QUEUE
*
h
=
QUEUE_HEAD
(
&
wq
);
QUEUE_REMOVE
(
h
);
SClientUvTaskNode
*
task
=
QUEUE_DATA
(
h
,
SClientUvTaskNode
,
recvTaskQueue
);
udfcStartUvTask
(
task
);
QUEUE_INSERT_TAIL
(
&
udfc
->
uvProcTaskQueue
,
&
task
->
procTaskQueue
);
int32_t
code
=
udfcStartUvTask
(
task
);
if
(
code
==
0
)
{
QUEUE_INSERT_TAIL
(
&
udfc
->
uvProcTaskQueue
,
&
task
->
procTaskQueue
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录