Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b9165a95
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1191
Star
22018
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看板
提交
b9165a95
编写于
7月 12, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: reset queueSize after the queueItem is consumed and executed by the worker
上级
52b63db9
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
24 addition
and
6 deletion
+24
-6
include/util/tqueue.h
include/util/tqueue.h
+1
-0
source/libs/sync/src/syncIO.c
source/libs/sync/src/syncIO.c
+2
-0
source/libs/transport/test/pushServer.c
source/libs/transport/test/pushServer.c
+4
-1
source/util/src/tqueue.c
source/util/src/tqueue.c
+13
-4
source/util/src/tworker.c
source/util/src/tworker.c
+4
-1
未找到文件。
include/util/tqueue.h
浏览文件 @
b9165a95
...
...
@@ -67,6 +67,7 @@ void taosFreeQitem(void *pItem);
void
taosWriteQitem
(
STaosQueue
*
queue
,
void
*
pItem
);
int32_t
taosReadQitem
(
STaosQueue
*
queue
,
void
**
ppItem
);
bool
taosQueueEmpty
(
STaosQueue
*
queue
);
void
taosUpdateItemSize
(
STaosQueue
*
queue
,
int32_t
items
);
int32_t
taosQueueItemSize
(
STaosQueue
*
queue
);
int64_t
taosQueueMemorySize
(
STaosQueue
*
queue
);
...
...
source/libs/sync/src/syncIO.c
浏览文件 @
b9165a95
...
...
@@ -369,6 +369,8 @@ static void *syncIOConsumerFunc(void *param) {
taosFreeQitem
(
pRpcMsg
);
}
taosUpdateItemSize
(
qinfo
.
queue
,
numOfMsgs
);
}
taosFreeQall
(
qall
);
...
...
source/libs/transport/test/pushServer.c
浏览文件 @
b9165a95
...
...
@@ -32,11 +32,12 @@ void processShellMsg() {
SRpcMsg
*
pRpcMsg
,
rpcMsg
;
int
type
;
void
*
pvnode
;
SQueueInfo
qinfo
=
{
0
};
qall
=
taosAllocateQall
();
while
(
1
)
{
int
numOfMsgs
=
taosReadAllQitemsFromQset
(
qset
,
qall
,
&
pvnode
,
NULL
);
int
numOfMsgs
=
taosReadAllQitemsFromQset
(
qset
,
qall
,
&
pvnode
,
&
qinfo
);
tDebug
(
"%d shell msgs are received"
,
numOfMsgs
);
if
(
numOfMsgs
<=
0
)
break
;
...
...
@@ -86,6 +87,8 @@ void processShellMsg() {
rpcSendResponse
(
&
nRpcMsg
);
}
}
taosUpdateItemSize
(
qinfo
.
queue
,
numOfMsgs
);
}
taosFreeQall
(
qall
);
...
...
source/util/src/tqueue.c
浏览文件 @
b9165a95
...
...
@@ -123,6 +123,14 @@ bool taosQueueEmpty(STaosQueue *queue) {
return
empty
;
}
void
taosUpdateItemSize
(
STaosQueue
*
queue
,
int32_t
items
)
{
if
(
queue
==
NULL
)
return
;
taosThreadMutexLock
(
&
queue
->
mutex
);
queue
->
numOfItems
-=
items
;
taosThreadMutexUnlock
(
&
queue
->
mutex
);
}
int32_t
taosQueueItemSize
(
STaosQueue
*
queue
)
{
if
(
queue
==
NULL
)
return
0
;
...
...
@@ -257,6 +265,7 @@ int32_t taosReadAllQitems(STaosQueue *queue, STaosQall *qall) {
queue
->
tail
=
NULL
;
queue
->
numOfItems
=
0
;
queue
->
memOfItems
=
0
;
uTrace
(
"read %d items from queue:%p, items:%d mem:%"
PRId64
,
code
,
queue
,
queue
->
numOfItems
,
queue
->
memOfItems
);
if
(
queue
->
qset
)
atomic_sub_fetch_32
(
&
queue
->
qset
->
numOfItems
,
qall
->
numOfItems
);
}
...
...
@@ -424,11 +433,11 @@ int32_t taosReadQitemFromQset(STaosQset *qset, void **ppItem, SQueueInfo *qinfo)
queue
->
head
=
pNode
->
next
;
if
(
queue
->
head
==
NULL
)
queue
->
tail
=
NULL
;
queue
->
numOfItems
--
;
//
queue->numOfItems--;
queue
->
memOfItems
-=
pNode
->
size
;
atomic_sub_fetch_32
(
&
qset
->
numOfItems
,
1
);
code
=
1
;
uTrace
(
"item:%p is read out from queue:%p, items:%d mem:%"
PRId64
,
*
ppItem
,
queue
,
queue
->
numOfItems
,
uTrace
(
"item:%p is read out from queue:%p, items:%d mem:%"
PRId64
,
*
ppItem
,
queue
,
queue
->
numOfItems
-
1
,
queue
->
memOfItems
);
}
...
...
@@ -468,9 +477,9 @@ int32_t taosReadAllQitemsFromQset(STaosQset *qset, STaosQall *qall, SQueueInfo *
queue
->
head
=
NULL
;
queue
->
tail
=
NULL
;
queue
->
numOfItems
=
0
;
//
queue->numOfItems = 0;
queue
->
memOfItems
=
0
;
uTrace
(
"read %d items from queue:%p, items:
%d mem:%"
PRId64
,
code
,
queue
,
queue
->
numOfItems
,
queue
->
memOfItems
);
uTrace
(
"read %d items from queue:%p, items:
0 mem:%"
PRId64
,
code
,
queue
,
queue
->
memOfItems
);
atomic_sub_fetch_32
(
&
qset
->
numOfItems
,
qall
->
numOfItems
);
for
(
int32_t
j
=
1
;
j
<
qall
->
numOfItems
;
++
j
)
{
...
...
source/util/src/tworker.c
浏览文件 @
b9165a95
...
...
@@ -79,7 +79,7 @@ static void *tQWorkerThreadFp(SQWorker *worker) {
uDebug
(
"worker:%s:%d is running"
,
pool
->
name
,
worker
->
id
);
while
(
1
)
{
if
(
taosReadQitemFromQset
(
pool
->
qset
,
(
void
**
)
&
msg
,
&
qinfo
)
==
0
)
{
if
(
taosReadQitemFromQset
(
pool
->
qset
,
(
void
**
)
&
msg
,
&
qinfo
)
==
0
)
{
uDebug
(
"worker:%s:%d qset:%p, got no message and exiting"
,
pool
->
name
,
worker
->
id
,
pool
->
qset
);
break
;
}
...
...
@@ -89,6 +89,8 @@ static void *tQWorkerThreadFp(SQWorker *worker) {
qinfo
.
threadNum
=
pool
->
num
;
(
*
((
FItem
)
qinfo
.
fp
))(
&
qinfo
,
msg
);
}
taosUpdateItemSize
(
qinfo
.
queue
,
1
);
}
return
NULL
;
...
...
@@ -214,6 +216,7 @@ static void *tWWorkerThreadFp(SWWorker *worker) {
qinfo
.
threadNum
=
pool
->
num
;
(
*
((
FItems
)
qinfo
.
fp
))(
&
qinfo
,
worker
->
qall
,
numOfMsgs
);
}
taosUpdateItemSize
(
qinfo
.
queue
,
numOfMsgs
);
}
return
NULL
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录