Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
abd8b930
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
abd8b930
编写于
7月 31, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225]
上级
6f3f7f7f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
28 deletion
+28
-28
src/util/src/hash.c
src/util/src/hash.c
+25
-25
src/util/src/tcache.c
src/util/src/tcache.c
+1
-1
src/vnode/src/vnodeRead.c
src/vnode/src/vnodeRead.c
+2
-2
未找到文件。
src/util/src/hash.c
浏览文件 @
abd8b930
...
...
@@ -21,6 +21,12 @@
#define HASH_NEED_RESIZE(_h) ((_h)->size >= (_h)->capacity * HASH_DEFAULT_LOAD_FACTOR)
#define FREE_HASH_NODE(_n) \
do { \
tfree((_n)->data); \
tfree(_n); \
} while (0)
static
FORCE_INLINE
void
__wr_lock
(
void
*
lock
,
int32_t
type
)
{
if
(
type
==
HASH_NO_LOCK
)
{
return
;
...
...
@@ -258,9 +264,7 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *da
// enable resize
__rd_unlock
(
&
pHashObj
->
lock
,
pHashObj
->
type
);
tfree
(
pNewNode
->
data
)
tfree
(
pNewNode
);
FREE_HASH_NODE
(
pNewNode
);
return
pHashObj
->
enableUpdate
?
0
:-
1
;
}
}
...
...
@@ -273,7 +277,7 @@ void *taosHashGet(SHashObj *pHashObj, const void *key, size_t keyLen) {
uint32_t
hashVal
=
(
*
pHashObj
->
hashFp
)(
key
,
keyLen
);
// only add the read lock to disable the resize process
__rd_lock
(
&
pHashObj
->
lock
,
pHashObj
->
type
);
__rd_lock
(
&
pHashObj
->
lock
,
pHashObj
->
type
);
SHashNode
*
pNode
=
doGetNodeFromHashTable
(
pHashObj
,
key
,
keyLen
,
hashVal
);
...
...
@@ -291,6 +295,18 @@ int32_t taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) {
return
taosHashRemoveNode
(
pHashObj
,
key
,
keyLen
,
NULL
,
0
);
}
static
FORCE_INLINE
void
popNodeFromEntryList
(
SHashEntry
*
pe
,
SHashNode
*
pNode
)
{
SHashNode
*
pNext
=
pNode
->
next
;
assert
(
pNode
->
prev
!=
NULL
);
pNode
->
prev
->
next
=
pNext
;
if
(
pNext
!=
NULL
)
{
pNext
->
prev
=
pNode
->
prev
;
}
pe
->
num
-=
1
;
}
int32_t
taosHashRemoveNode
(
SHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
void
*
data
,
size_t
dsize
)
{
if
(
pHashObj
->
size
<=
0
)
{
return
-
1
;
...
...
@@ -316,16 +332,7 @@ int32_t taosHashRemoveNode(SHashObj *pHashObj, const void *key, size_t keyLen, v
SHashNode
*
pNode
=
doSearchEntryList
(
pe
,
key
,
keyLen
,
hashVal
);
if
(
pNode
!=
NULL
)
{
assert
(
pNode
->
prev
!=
NULL
);
SHashNode
*
pNext
=
pNode
->
next
;
pNode
->
prev
->
next
=
pNext
;
if
(
pNext
!=
NULL
)
{
pNext
->
prev
=
pNode
->
prev
;
}
pe
->
num
-=
1
;
popNodeFromEntryList
(
pe
,
pNode
);
}
if
(
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
...
...
@@ -344,8 +351,7 @@ int32_t taosHashRemoveNode(SHashObj *pHashObj, const void *key, size_t keyLen, v
pNode
->
next
=
NULL
;
pNode
->
prev
=
NULL
;
tfree
(
pNode
->
data
);
tfree
(
pNode
);
FREE_HASH_NODE
(
pNode
);
return
0
;
}
else
{
...
...
@@ -540,22 +546,16 @@ void taosHashTableResize(SHashObj *pHashObj) {
int32_t
j
=
HASH_INDEX
(
pNode
->
hashVal
,
pHashObj
->
capacity
);
if
(
j
==
i
)
{
// this key locates in the same slot, no need to relocate it
pNode
=
pNode
->
next
;
assert
(
pNode
==
NULL
||
pNode
->
next
!=
pNode
);
}
else
{
pNext
=
pNode
->
next
;
assert
(
pNode
!=
pNext
&&
(
pNext
==
NULL
||
pNext
->
prev
==
pNode
)
&&
pNode
->
prev
->
next
==
pNode
);
assert
(
pNode
->
prev
!=
NULL
);
pNode
->
prev
->
next
=
pNext
;
if
(
pNext
!=
NULL
)
{
pNext
->
prev
=
pNode
->
prev
;
}
popNodeFromEntryList
(
pe
,
pNode
);
// clear pointer
pNode
->
next
=
NULL
;
pNode
->
prev
=
NULL
;
pe
->
num
-=
1
;
// added into new slot
SHashEntry
*
pNewEntry
=
pHashObj
->
hashList
[
j
];
pushfrontNode
(
pNewEntry
,
pNode
);
...
...
src/util/src/tcache.c
浏览文件 @
abd8b930
...
...
@@ -653,7 +653,7 @@ static void doCacheRefresh(SCacheObj* pCacheObj, int64_t time, __cache_free_fn_t
SCacheDataNode
*
pNode
=
*
(
SCacheDataNode
**
)
taosHashIterGet
(
pIter
);
if
(
pNode
->
expireTime
<
time
&&
T_REF_VAL_GET
(
pNode
)
<=
0
)
{
//
taosCacheReleaseNode(pCacheObj, pNode);
taosCacheReleaseNode
(
pCacheObj
,
pNode
);
continue
;
}
...
...
src/vnode/src/vnodeRead.c
浏览文件 @
abd8b930
...
...
@@ -213,7 +213,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
}
}
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
f
reehandl
e
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
f
als
e
);
}
}
...
...
@@ -268,7 +268,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
code
=
vnodeDumpQueryResult
(
pRet
,
pVnode
,
*
handle
,
&
freeHandle
);
}
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
f
reeHandl
e
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
f
als
e
);
return
code
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录