Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
232404fa
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
232404fa
编写于
3月 29, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
shm queue
上级
ac6b1213
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
26 deletion
+23
-26
source/util/src/tprocess.c
source/util/src/tprocess.c
+23
-26
未找到文件。
source/util/src/tprocess.c
浏览文件 @
232404fa
...
...
@@ -208,16 +208,11 @@ static void taosProcCleanupQueue(SProcQueue *pQueue) {
}
static
int32_t
taosProcQueuePush
(
SProcQueue
*
pQueue
,
const
char
*
pHead
,
int16_t
rawHeadLen
,
const
char
*
pBody
,
int32_t
rawBodyLen
,
ProcFuncType
f
uncT
ype
)
{
int32_t
rawBodyLen
,
ProcFuncType
f
t
ype
)
{
const
int32_t
headLen
=
CEIL8
(
rawHeadLen
);
const
int32_t
bodyLen
=
CEIL8
(
rawBodyLen
);
const
int32_t
fullLen
=
headLen
+
bodyLen
+
8
;
if
(
headLen
<=
0
||
bodyLen
<=
0
)
{
terrno
=
TSDB_CODE_INVALID_PARA
;
return
-
1
;
}
taosThreadMutexLock
(
pQueue
->
mutex
);
if
(
fullLen
>
pQueue
->
avail
)
{
taosThreadMutexUnlock
(
pQueue
->
mutex
);
...
...
@@ -225,13 +220,14 @@ static int32_t taosProcQueuePush(SProcQueue *pQueue, const char *pHead, int16_t
return
-
1
;
}
const
int32_t
pos
=
pQueue
->
tail
;
if
(
pQueue
->
tail
<
pQueue
->
total
)
{
*
(
int16_t
*
)(
pQueue
->
pBuffer
+
pQueue
->
head
)
=
headLen
;
*
(
int8_t
*
)(
pQueue
->
pBuffer
+
pQueue
->
head
+
2
)
=
(
int8_t
)
funcT
ype
;
*
(
int32_t
*
)(
pQueue
->
pBuffer
+
pQueue
->
head
+
4
)
=
bodyLen
;
*
(
int16_t
*
)(
pQueue
->
pBuffer
+
pQueue
->
tail
)
=
headLen
;
*
(
int8_t
*
)(
pQueue
->
pBuffer
+
pQueue
->
tail
+
2
)
=
(
int8_t
)
ft
ype
;
*
(
int32_t
*
)(
pQueue
->
pBuffer
+
pQueue
->
tail
+
4
)
=
bodyLen
;
}
else
{
*
(
int16_t
*
)(
pQueue
->
pBuffer
)
=
headLen
;
*
(
int8_t
*
)(
pQueue
->
pBuffer
+
pQueue
->
head
+
2
)
=
(
int8_t
)
funcT
ype
;
*
(
int8_t
*
)(
pQueue
->
pBuffer
+
2
)
=
(
int8_t
)
ft
ype
;
*
(
int32_t
*
)(
pQueue
->
pBuffer
+
4
)
=
bodyLen
;
}
...
...
@@ -250,19 +246,19 @@ static int32_t taosProcQueuePush(SProcQueue *pQueue, const char *pHead, int16_t
memcpy
(
pQueue
->
pBuffer
+
headLen
,
pBody
,
rawBodyLen
);
pQueue
->
tail
=
headLen
+
bodyLen
;
}
else
if
(
remain
<
8
+
headLen
)
{
memcpy
(
pQueue
->
pBuffer
+
pQueue
->
head
+
8
,
pHead
,
remain
-
8
);
memcpy
(
pQueue
->
pBuffer
+
pQueue
->
tail
+
8
,
pHead
,
remain
-
8
);
memcpy
(
pQueue
->
pBuffer
,
pHead
+
remain
-
8
,
rawHeadLen
-
(
remain
-
8
));
memcpy
(
pQueue
->
pBuffer
+
headLen
-
(
remain
-
8
),
pBody
,
rawBodyLen
);
pQueue
->
tail
=
headLen
-
(
remain
-
8
)
+
bodyLen
;
}
else
if
(
remain
<
8
+
bodyLen
)
{
memcpy
(
pQueue
->
pBuffer
+
pQueue
->
head
+
8
,
pHead
,
rawHeadLen
);
memcpy
(
pQueue
->
pBuffer
+
pQueue
->
head
+
8
+
headLen
,
pBody
,
remain
-
8
-
headLen
);
}
else
if
(
remain
<
8
+
headLen
+
bodyLen
)
{
memcpy
(
pQueue
->
pBuffer
+
pQueue
->
tail
+
8
,
pHead
,
rawHeadLen
);
memcpy
(
pQueue
->
pBuffer
+
pQueue
->
tail
+
8
+
headLen
,
pBody
,
remain
-
8
-
headLen
);
memcpy
(
pQueue
->
pBuffer
,
pBody
+
remain
-
8
-
headLen
,
rawBodyLen
-
(
remain
-
8
-
headLen
));
pQueue
->
tail
=
bodyLen
-
(
remain
-
8
-
headLen
);
}
else
{
memcpy
(
pQueue
->
pBuffer
+
pQueue
->
head
+
8
,
pHead
,
rawHeadLen
);
memcpy
(
pQueue
->
pBuffer
+
pQueue
->
head
+
headLen
+
8
,
pBody
,
rawBodyLen
);
pQueue
->
tail
=
pQueue
->
head
+
headLen
+
bodyLen
+
8
;
memcpy
(
pQueue
->
pBuffer
+
pQueue
->
tail
+
8
,
pHead
,
rawHeadLen
);
memcpy
(
pQueue
->
pBuffer
+
pQueue
->
tail
+
headLen
+
8
,
pBody
,
rawBodyLen
);
pQueue
->
tail
=
pQueue
->
tail
+
headLen
+
bodyLen
+
8
;
}
}
...
...
@@ -271,8 +267,8 @@ static int32_t taosProcQueuePush(SProcQueue *pQueue, const char *pHead, int16_t
taosThreadMutexUnlock
(
pQueue
->
mutex
);
tsem_post
(
&
pQueue
->
sem
);
uTrace
(
"proc:%s, push msg
to queue:%p remains:%d, head:%d:%p body:%d:%p ftype:%d"
,
pQueue
->
name
,
pQueue
,
pQueue
->
items
,
headLen
,
pHead
,
bodyLen
,
pBody
,
funcType
);
uTrace
(
"proc:%s, push msg
at pos:%d ftype:%d remain:%d, head:%d %p body:%d %p"
,
pQueue
->
name
,
pos
,
ftype
,
pQueue
->
items
,
headLen
,
pHead
,
bodyLen
,
pBody
);
return
0
;
}
...
...
@@ -312,6 +308,7 @@ static int32_t taosProcQueuePop(SProcQueue *pQueue, void **ppHead, int16_t *pHea
return
-
1
;
}
const
int32_t
pos
=
pQueue
->
head
;
if
(
pQueue
->
head
<
pQueue
->
tail
)
{
memcpy
(
pHead
,
pQueue
->
pBuffer
+
pQueue
->
head
+
8
,
headLen
);
memcpy
(
pBody
,
pQueue
->
pBuffer
+
pQueue
->
head
+
8
+
headLen
,
bodyLen
);
...
...
@@ -331,7 +328,7 @@ static int32_t taosProcQueuePop(SProcQueue *pQueue, void **ppHead, int16_t *pHea
memcpy
(
pHead
+
remain
-
8
,
pQueue
->
pBuffer
,
headLen
-
(
remain
-
8
));
memcpy
(
pBody
,
pQueue
->
pBuffer
+
headLen
-
(
remain
-
8
),
bodyLen
);
pQueue
->
head
=
headLen
-
(
remain
-
8
)
+
bodyLen
;
}
else
if
(
remain
<
8
+
bodyLen
)
{
}
else
if
(
remain
<
8
+
headLen
+
bodyLen
)
{
memcpy
(
pHead
,
pQueue
->
pBuffer
+
pQueue
->
head
+
8
,
headLen
);
memcpy
(
pBody
,
pQueue
->
pBuffer
+
pQueue
->
head
+
8
+
headLen
,
remain
-
8
-
headLen
);
memcpy
(
pBody
+
remain
-
8
-
headLen
,
pQueue
->
pBuffer
,
bodyLen
-
(
remain
-
8
-
headLen
));
...
...
@@ -353,8 +350,8 @@ static int32_t taosProcQueuePop(SProcQueue *pQueue, void **ppHead, int16_t *pHea
*
pBodyLen
=
bodyLen
;
*
pFuncType
=
(
ProcFuncType
)
ftype
;
uTrace
(
"proc:%s, pop msg
from queue:%p remains:%d, head:%d:%p body:%d:%p ftype:%d"
,
pQueue
->
name
,
pQueue
,
pQueue
->
items
,
headLen
,
pHead
,
bodyLen
,
pBody
,
ftype
);
uTrace
(
"proc:%s, pop msg
at pos:%d ftype:%d remain:%d, head:%d %p body:%d %p"
,
pQueue
->
name
,
pos
,
ftype
,
pQueue
->
items
,
headLen
,
pHead
,
bodyLen
,
pBody
);
return
1
;
}
...
...
@@ -472,11 +469,11 @@ void taosProcCleanup(SProcObj *pProc) {
}
int32_t
taosProcPutToChildQ
(
SProcObj
*
pProc
,
const
void
*
pHead
,
int16_t
headLen
,
const
void
*
pBody
,
int32_t
bodyLen
,
ProcFuncType
f
uncT
ype
)
{
return
taosProcQueuePush
(
pProc
->
pChildQueue
,
pHead
,
headLen
,
pBody
,
bodyLen
,
f
uncT
ype
);
ProcFuncType
f
t
ype
)
{
return
taosProcQueuePush
(
pProc
->
pChildQueue
,
pHead
,
headLen
,
pBody
,
bodyLen
,
f
t
ype
);
}
int32_t
taosProcPutToParentQ
(
SProcObj
*
pProc
,
const
void
*
pHead
,
int16_t
headLen
,
const
void
*
pBody
,
int32_t
bodyLen
,
ProcFuncType
f
uncT
ype
)
{
return
taosProcQueuePush
(
pProc
->
pParentQueue
,
pHead
,
headLen
,
pBody
,
bodyLen
,
f
uncT
ype
);
ProcFuncType
f
t
ype
)
{
return
taosProcQueuePush
(
pProc
->
pParentQueue
,
pHead
,
headLen
,
pBody
,
bodyLen
,
f
t
ype
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录