Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
02bdbce3
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看板
提交
02bdbce3
编写于
8月 01, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] merge develop
上级
4b3ead4b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
31 addition
and
40 deletion
+31
-40
src/mnode/src/mnodeProfile.c
src/mnode/src/mnodeProfile.c
+1
-1
src/util/inc/hash.h
src/util/inc/hash.h
+0
-9
src/util/inc/tcache.h
src/util/inc/tcache.h
+1
-1
src/util/src/hash.c
src/util/src/hash.c
+2
-2
src/util/src/tcache.c
src/util/src/tcache.c
+27
-27
未找到文件。
src/mnode/src/mnodeProfile.c
浏览文件 @
02bdbce3
...
...
@@ -112,7 +112,7 @@ void mnodeReleaseConn(SConnObj *pConn) {
SConnObj
*
mnodeAccquireConn
(
int32_t
connId
,
char
*
user
,
uint32_t
ip
,
uint16_t
port
)
{
uint64_t
expireTime
=
CONN_KEEP_TIME
*
1000
+
(
uint64_t
)
taosGetTimestampMs
();
SConnObj
*
pConn
=
taosCache
UpdateExpireTimeByName
(
tsMnodeConnCache
,
&
connId
,
sizeof
(
int32_t
),
expireTime
);
SConnObj
*
pConn
=
taosCache
AcquireByKey
(
tsMnodeConnCache
,
&
connId
,
sizeof
(
int32_t
)
);
if
(
pConn
==
NULL
)
{
mDebug
(
"connId:%d, is already destroyed, user:%s ip:%s:%u"
,
connId
,
user
,
taosIpStr
(
ip
),
port
);
return
NULL
;
...
...
src/util/inc/hash.h
浏览文件 @
02bdbce3
...
...
@@ -41,18 +41,9 @@ typedef struct SHashNode {
typedef
enum
SHashLockTypeE
{
HASH_NO_LOCK
=
0
,
// HASH_GLOBAL_LOCK = 1,
HASH_ENTRY_LOCK
=
1
,
}
SHashLockTypeE
;
//typedef struct SHashLock {
//#if defined(LINUX)
// pthread_rwlock_t *lock;
//#else
// pthread_mutex_t *lock;
//#endif
//} SHashLock;
typedef
struct
SHashEntry
{
int32_t
num
;
// number of elements in current entry
SRWLatch
latch
;
// entry latch
...
...
src/util/inc/tcache.h
浏览文件 @
02bdbce3
...
...
@@ -121,7 +121,7 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen
* @param expireTime new expire time of data
* @return
*/
void
*
taosCacheUpdateExpireTimeByName
(
SCacheObj
*
pCacheObj
,
void
*
key
,
size_t
keyLen
,
uint64_t
expireTime
);
//
void* taosCacheUpdateExpireTimeByName(SCacheObj *pCacheObj, void *key, size_t keyLen, uint64_t expireTime);
/**
* Add one reference count for the exist data, and assign this data for a new owner.
...
...
src/util/src/hash.c
浏览文件 @
02bdbce3
...
...
@@ -447,8 +447,7 @@ void taosHashCleanup(SHashObj *pHashObj) {
pHashObj
->
freeFp
(
pNode
->
data
);
}
free
(
pNode
->
data
);
free
(
pNode
);
FREE_HASH_NODE
(
pNode
);
pNode
=
pNext
;
}
}
...
...
@@ -651,6 +650,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
SHashNode
*
doCreateHashNode
(
const
void
*
key
,
size_t
keyLen
,
const
void
*
pData
,
size_t
dsize
,
uint32_t
hashVal
)
{
SHashNode
*
pNewNode
=
calloc
(
1
,
sizeof
(
SHashNode
));
if
(
pNewNode
==
NULL
)
{
uError
(
"failed to allocate memory, reason:%s"
,
strerror
(
errno
));
return
NULL
;
...
...
src/util/src/tcache.c
浏览文件 @
02bdbce3
...
...
@@ -340,33 +340,33 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen
return
pData
;
}
void
*
taosCacheUpdateExpireTimeByName
(
SCacheObj
*
pCacheObj
,
void
*
key
,
size_t
keyLen
,
uint64_t
expireTime
)
{
if
(
pCacheObj
==
NULL
||
taosHashGetSize
(
pCacheObj
->
pHashTable
)
==
0
)
{
return
NULL
;
}
__cache_rd_lock
(
pCacheObj
);
SCacheDataNode
**
ptNode
=
(
SCacheDataNode
**
)
taosHashGet
(
pCacheObj
->
pHashTable
,
key
,
keyLen
);
if
(
ptNode
!=
NULL
)
{
T_REF_INC
(
*
ptNode
);
(
*
ptNode
)
->
expireTime
=
expireTime
;
// taosGetTimestampMs() + (*ptNode)->lifespan;
}
__cache_unlock
(
pCacheObj
);
if
(
ptNode
!=
NULL
)
{
atomic_add_fetch_32
(
&
pCacheObj
->
statistics
.
hitCount
,
1
);
uDebug
(
"cache:%s, key:%p, %p expireTime is updated in cache, refcnt:%d"
,
pCacheObj
->
name
,
key
,
(
*
ptNode
)
->
data
,
T_REF_VAL_GET
(
*
ptNode
));
}
else
{
atomic_add_fetch_32
(
&
pCacheObj
->
statistics
.
missCount
,
1
);
uDebug
(
"cache:%s, key:%p, not in cache, retrieved failed"
,
pCacheObj
->
name
,
key
);
}
atomic_add_fetch_32
(
&
pCacheObj
->
statistics
.
totalAccess
,
1
);
return
(
ptNode
!=
NULL
)
?
(
*
ptNode
)
->
data
:
NULL
;
}
//
void* taosCacheUpdateExpireTimeByName(SCacheObj *pCacheObj, void *key, size_t keyLen, uint64_t expireTime) {
//
if (pCacheObj == NULL || taosHashGetSize(pCacheObj->pHashTable) == 0) {
//
return NULL;
//
}
//
//
__cache_rd_lock(pCacheObj);
//
//
SCacheDataNode **ptNode = (SCacheDataNode **)taosHashGet(pCacheObj->pHashTable, key, keyLen);
//
if (ptNode != NULL) {
//
T_REF_INC(*ptNode);
//
(*ptNode)->expireTime = expireTime; // taosGetTimestampMs() + (*ptNode)->lifespan;
//
}
//
//
__cache_unlock(pCacheObj);
//
//
if (ptNode != NULL) {
//
atomic_add_fetch_32(&pCacheObj->statistics.hitCount, 1);
//
uDebug("cache:%s, key:%p, %p expireTime is updated in cache, refcnt:%d", pCacheObj->name, key,
//
(*ptNode)->data, T_REF_VAL_GET(*ptNode));
//
} else {
//
atomic_add_fetch_32(&pCacheObj->statistics.missCount, 1);
//
uDebug("cache:%s, key:%p, not in cache, retrieved failed", pCacheObj->name, key);
//
}
//
//
atomic_add_fetch_32(&pCacheObj->statistics.totalAccess, 1);
//
return (ptNode != NULL) ? (*ptNode)->data : NULL;
//
}
void
*
taosCacheAcquireByData
(
SCacheObj
*
pCacheObj
,
void
*
data
)
{
if
(
pCacheObj
==
NULL
||
data
==
NULL
)
return
NULL
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录