From 8748df275d446451fc59cf0e81f1a5d7e851b9ae Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 25 Dec 2020 17:34:05 +0800 Subject: [PATCH] [TD-225]refactor. --- src/client/src/tscSystem.c | 3 ++- src/client/src/tscUtil.c | 2 +- src/util/inc/hash.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index 35ee916d7d..ff605dad72 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -132,7 +132,8 @@ void taos_init_imp(void) { int64_t refreshTime = 10; // 10 seconds by default if (tscMetaCache == NULL) { tscMetaCache = taosCacheInit(TSDB_DATA_TYPE_BINARY, refreshTime, false, tscFreeTableMetaHelper, "tableMeta"); - tscObjRef = taosOpenRef(40960, tscFreeRegisteredSqlObj); + tscObjRef = taosOpenRef(40960, tscFreeRegisteredSqlObj); + tscHashMap = taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK); } tscRefId = taosOpenRef(200, tscCloseTscObj); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index bbad7bf257..172887c110 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1913,7 +1913,7 @@ void registerSqlObj(SSqlObj* pSql) { int32_t num = atomic_add_fetch_32(&pSql->pTscObj->numOfObj, 1); int32_t total = atomic_add_fetch_32(&tscNumOfObj, 1); - tscDebug("%p new SqlObj, total in tscObj:%d, total:%d", pSql, num, total); + tscDebug("%p new SqlObj from %p, total in tscObj:%d, total:%d", pSql, pSql->pTscObj, num, total); } SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cmd) { diff --git a/src/util/inc/hash.h b/src/util/inc/hash.h index 6a97a74c04..7ec4e5445a 100644 --- a/src/util/inc/hash.h +++ b/src/util/inc/hash.h @@ -43,6 +43,7 @@ typedef struct SHashNode { #define GET_HASH_NODE_KEY(_n) ((char*)(_n) + sizeof(SHashNode) + (_n)->dataLen) #define GET_HASH_NODE_DATA(_n) ((char*)(_n) + sizeof(SHashNode)) #define GET_HASH_PNODE(_n) ((char*)(_n) - sizeof(SHashNode)); + typedef enum SHashLockTypeE { HASH_NO_LOCK = 0, HASH_ENTRY_LOCK = 1, -- GitLab