From d907e448632e25ac82ee996a604a79f640de6b9f Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 11 Mar 2022 02:48:03 +0000 Subject: [PATCH] refact TDB --- source/libs/tdb/src/db/tdbEnv.c | 4 ++-- source/libs/tdb/src/db/tdbPCache.c | 6 ++---- source/libs/tdb/src/inc/tdbPCache.h | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/source/libs/tdb/src/db/tdbEnv.c b/source/libs/tdb/src/db/tdbEnv.c index 0b27796790..9a4dcdbcd5 100644 --- a/source/libs/tdb/src/db/tdbEnv.c +++ b/source/libs/tdb/src/db/tdbEnv.c @@ -19,7 +19,7 @@ int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, STEnv **ppEnv) STEnv *pEnv; int dsize; int zsize; - u8 * pPtr; + u8 *pPtr; int ret; *ppEnv = NULL; @@ -48,7 +48,7 @@ int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, STEnv **ppEnv) pEnv->jfd = -1; - ret = tdbPCacheOpen(pageSize, cacheSize, 0, &(pEnv->pCache)); + ret = tdbPCacheOpen(pageSize, cacheSize, &(pEnv->pCache)); if (ret < 0) { return -1; } diff --git a/source/libs/tdb/src/db/tdbPCache.c b/source/libs/tdb/src/db/tdbPCache.c index 3c8c8d84cd..54a0c038a0 100644 --- a/source/libs/tdb/src/db/tdbPCache.c +++ b/source/libs/tdb/src/db/tdbPCache.c @@ -17,7 +17,6 @@ struct SPCache { int pageSize; int cacheSize; - int extraSize; pthread_mutex_t mutex; int nFree; SPage *pFree; @@ -47,7 +46,7 @@ static void tdbPCacheRemovePageFromHash(SPage *pPage); static void tdbPCacheAddPageToHash(SPage *pPage); static void tdbPCacheUnpinPage(SPage *pPage); -int tdbPCacheOpen(int pageSize, int cacheSize, int extraSize, SPCache **ppCache) { +int tdbPCacheOpen(int pageSize, int cacheSize, SPCache **ppCache) { SPCache *pCache; void *pPtr; SPage *pPgHdr; @@ -59,7 +58,6 @@ int tdbPCacheOpen(int pageSize, int cacheSize, int extraSize, SPCache **ppCache) pCache->pageSize = pageSize; pCache->cacheSize = cacheSize; - pCache->extraSize = extraSize; if (tdbPCacheOpenImpl(pCache) < 0) { free(pCache); @@ -244,7 +242,7 @@ static int tdbPCacheOpenImpl(SPCache *pCache) { pCache->nFree = 0; pCache->pFree = NULL; for (int i = 0; i < pCache->cacheSize; i++) { - tsize = pCache->pageSize + sizeof(SPage) + pCache->extraSize; + tsize = pCache->pageSize + sizeof(SPage); pPtr = (u8 *)calloc(1, tsize); if (pPtr == NULL) { // TODO diff --git a/source/libs/tdb/src/inc/tdbPCache.h b/source/libs/tdb/src/inc/tdbPCache.h index 85b795a30e..fe5131e58b 100644 --- a/source/libs/tdb/src/inc/tdbPCache.h +++ b/source/libs/tdb/src/inc/tdbPCache.h @@ -33,7 +33,7 @@ extern "C" { SPage *pDirtyNext; \ SPager *pPager; -int tdbPCacheOpen(int pageSize, int cacheSize, int extraSize, SPCache **ppCache); +int tdbPCacheOpen(int pageSize, int cacheSize, SPCache **ppCache); int tdbPCacheClose(SPCache *pCache); SPage *tdbPCacheFetch(SPCache *pCache, const SPgid *pPgid, bool alcNewPage); void tdbPCacheRelease(SPage *pPage); -- GitLab