提交 02bdbce3 编写于 作者: H Haojun Liao

[td-225] merge develop

上级 4b3ead4b
......@@ -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 = taosCacheUpdateExpireTimeByName(tsMnodeConnCache, &connId, sizeof(int32_t), expireTime);
SConnObj *pConn = taosCacheAcquireByKey(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;
......
......@@ -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
......
......@@ -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.
......
......@@ -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;
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册